From 718402f4b0a5fbfe8041c3111ac55d97891da913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 22 Jan 2022 18:30:00 +0100 Subject: M save.pl M save.pl~ --- save.pl | 32 +++++++++++++++++--------------- save.pl~ | 27 ++++++++++++++------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/save.pl b/save.pl index 2e6a8d8..00cc42a 100644 --- a/save.pl +++ b/save.pl @@ -3,6 +3,11 @@ :- consult(library(process)). :- pce_global(@dialog, new(dialog('Save'))). +:- pce_global(@files, new(chain)). +:- pce_global(@editor, new(editor)). +:- pce_global(@save_button, + new(button(save, + message(@prolog, save)))). main :- pce_main_loop(main). @@ -21,25 +26,22 @@ Ensure Git is in PATH.'). added(0) :- %send(@pce, load_defaults, 'Defaults'), - new(D, @dialog), % File browser. - new(C, chain), - status(C), - send(new(B, browser), right, D), - send(B, members(C)), + status(@files), + send(new(B, browser), right, @dialog), + send(B, members(@files)), % Input fields. - send(D, append, text('Commit message (optional):', + send(@dialog, append, text('Commit message (optional):', left, bold)), - send(D, append, new(E, editor)), - send(D, append, button(save, - message(@prolog, save, E, C))), - send(D, append, button(cancel, + send(@dialog, append, @editor), + send(@dialog, append, @save_button), + send(@dialog, append, button(cancel, and(message(@prolog, reset), - message(D, destroy)))), - send(D, open). + message(@dialog, destroy)))), + send(@dialog, open). reset :- shell("git reset"). @@ -60,12 +62,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) ). diff --git a/save.pl~ b/save.pl~ index ab73aea..7fe2a02 100644 --- a/save.pl~ +++ b/save.pl~ @@ -3,6 +3,11 @@ :- consult(library(process)). :- pce_global(@dialog, new(dialog('Save'))). +:- pce_global(@files, new(chain)). +:- pce_global(@editor, new(editor)). +:- pce_global(@save_button, + new(button(save, + message(@prolog, save)))). main :- pce_main_loop(main). @@ -21,25 +26,22 @@ Ensure Git is in PATH.'). added(0) :- %send(@pce, load_defaults, 'Defaults'), - new(D, @dialog), % File browser. - new(C, chain), - status(C), - send(new(B, browser), right, D), - send(B, members(C)), + status(@files), + send(new(B, browser), right, @dialog), + send(B, members(@files)), % Input fields. - send(D, append, text('Commit message (optional):', + send(@dialog, append, text('Commit message (optional):', left, bold)), - send(D, append, new(E, editor)), - send(D, append, button(save, - message(@prolog, save, E, C))), - send(D, append, button(cancel, + send(@dialog, append, @editor), + send(@dialog, append, @save_button), + send(@dialog, append, button(cancel, and(message(@prolog, reset), - message(D, destroy)))), - send(D, open). + message(@dialog, destroy)))), + send(@dialog, open). reset :- shell("git reset"). @@ -83,7 +85,6 @@ chain_atom_x(C, A0, A) :- ). commit(Msg) :- - write('creating process'), nl, process_create(path(git), ['commit', '-m', Msg], [process(PID)]), process_wait(PID, S), -- cgit v1.2.3