From b57e0f1e669b81fd2fffcf1dc01e2e3af9510c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 22 Jan 2022 22:26:16 +0100 Subject: Update ieditor. --- ieditor.pl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ieditor.pl b/ieditor.pl index a1cd173..8c6d3ab 100644 --- a/ieditor.pl +++ b/ieditor.pl @@ -1,10 +1,23 @@ :- use_module(library(pce)). :- consult(ieditor_gesture). + +:- pce_begin_class(iview, view, "Improved view"). + +initialise(V, L:label=[name], S:size=[size], D:display=[display], + E:editor=[editor]) :-> + send_super(V, initialise, L, S, D, when(E == @default, + new(ieditor), + E)), + send(V, wrap, word). + +:- pce_end_class(iview). + :- pce_begin_class(ieditor, editor, "Improved editor"). initialise(E, T:text=[text_buffer], W:width=[int], H:height=[int], M:margin=[int]) :-> send_super(E, initialise, T, W, H, M), + send(E, wrap, word), send(E, key_binding, '\\ed', message(E, kill_word)), send(E, key_binding, '\\e\\C-h', message(E, backward_kill_word)). @@ -69,13 +82,13 @@ selection_save_mark(E, M) :<- cursor_up(E, Arg:[int]) :-> "Handle cursor up-arrow":: - cursor_updown(E, cursor_up, Arg). + send(E, cursor_updown, cursor_up, Arg). cursor_down(E, Arg:[int]) :-> "Handle cursor down-arrow":: - cursor_updown(E, cursor_down, Arg). + send(E, cursor_updown, cursor_down, Arg). -cursor_updown(E, Msg, Arg:[int]) :- - get(E, char_x, E?caret, X0), +cursor_updown(E, Msg, Arg:[int]) :-> + char_x(E, E?caret, X0), get(E, selection_save_mark, M), ( Msg == cursor_up -> send_super(E, cursor_up, Arg) ; Msg == cursor_down -> send_super(E, cursor_down, Arg) -- cgit v1.2.3