summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-01-22 18:37:58 +0100
committerJohn Ankarström <john@ankarstrom.se>2022-01-22 18:37:58 +0100
commit960418c239da83786f09846639b0cdd2e064aae5 (patch)
tree04cfa0796496fe22ffe9e48c97fb59ed2e537fac
parent718402f4b0a5fbfe8041c3111ac55d97891da913 (diff)
downloadsave-960418c239da83786f09846639b0cdd2e064aae5.tar.gz
M save.exe
M save.pl M save.pl~
-rw-r--r--save.exebin276159 -> 278385 bytes
-rw-r--r--save.pl30
-rw-r--r--save.pl~36
3 files changed, 43 insertions, 23 deletions
diff --git a/save.exe b/save.exe
index 377a6ba..b51a897 100644
--- a/save.exe
+++ b/save.exe
Binary files differ
diff --git a/save.pl b/save.pl
index 00cc42a..a793e06 100644
--- a/save.pl
+++ b/save.pl
@@ -2,12 +2,22 @@
:- consult(library(pce)).
:- consult(library(process)).
-:- pce_global(@dialog, new(dialog('Save'))).
+:- pce_begin_class(save_dialog, dialog).
+
+unlink(D) :->
+ shell("git reset"),
+ send_super(D, unlink).
+
+:- pce_end_class(save_dialog).
+
+:- pce_global(@dialog, new(save_dialog('Save'))).
:- pce_global(@files, new(chain)).
:- pce_global(@editor, new(editor)).
+:- pce_global(@browser, new(browser)).
:- pce_global(@save_button,
new(button(save,
- message(@prolog, save)))).
+ message(@prolog, save),
+ 'RET'))).
main :-
pce_main_loop(main).
@@ -28,9 +38,8 @@ added(0) :-
%send(@pce, load_defaults, 'Defaults'),
% File browser.
- status(@files),
- send(new(B, browser), right, @dialog),
- send(B, members(@files)),
+ send(@browser, right, @dialog),
+ refresh,
% Input fields.
send(@dialog, append, text('Commit message (optional):',
@@ -38,13 +47,14 @@ added(0) :-
bold)),
send(@dialog, append, @editor),
send(@dialog, append, @save_button),
- send(@dialog, append, button(cancel,
- and(message(@prolog, reset),
- message(@dialog, destroy)))),
+ send(@dialog, append, button(refresh,
+ and(message(@prolog, refresh)))),
send(@dialog, open).
-reset :-
- shell("git reset").
+refresh :-
+ send(@files, clear),
+ status(@files),
+ send(@browser, members(@files)).
status(C) :-
setup_call_cleanup(
diff --git a/save.pl~ b/save.pl~
index 7fe2a02..ad99f3c 100644
--- a/save.pl~
+++ b/save.pl~
@@ -2,12 +2,22 @@
:- consult(library(pce)).
:- consult(library(process)).
-:- pce_global(@dialog, new(dialog('Save'))).
+:- pce_begin_class(save_dialog, dialog).
+
+unlink(D) :->
+ shell("git reset"),
+ send_super(D, unlink).
+
+:- pce_end_class(save_dialog).
+
+:- pce_global(@dialog, new(save_dialog('Save'))).
:- pce_global(@files, new(chain)).
:- pce_global(@editor, new(editor)).
+:- pce_global(@browser, new(browser)).
:- pce_global(@save_button,
new(button(save,
- message(@prolog, save)))).
+ message(@prolog, save),
+ RET))).
main :-
pce_main_loop(main).
@@ -28,9 +38,8 @@ added(0) :-
%send(@pce, load_defaults, 'Defaults'),
% File browser.
- status(@files),
- send(new(B, browser), right, @dialog),
- send(B, members(@files)),
+ send(@browser, right, @dialog),
+ refresh,
% Input fields.
send(@dialog, append, text('Commit message (optional):',
@@ -38,13 +47,14 @@ added(0) :-
bold)),
send(@dialog, append, @editor),
send(@dialog, append, @save_button),
- send(@dialog, append, button(cancel,
- and(message(@prolog, reset),
- message(@dialog, destroy)))),
+ send(@dialog, append, button(refresh,
+ and(message(@prolog, refresh)))),
send(@dialog, open).
-reset :-
- shell("git reset").
+refresh :-
+ send(@files, clear),
+ status(@files),
+ send(@browser, members(@files)).
status(C) :-
setup_call_cleanup(
@@ -62,12 +72,12 @@ read_to_chain(S, C) :-
read_to_chain(S, C)
).
-save(Editor, Chain) :-
- get(Editor?text_buffer, contents, S),
+save :-
+ get(@editor?text_buffer, contents, S),
send(S, strip),
get(S, value, Msg),
( Msg == ''
- -> chain_atom(Chain, A),
+ -> chain_atom(@files, A),
commit(A)
; commit(Msg)
).