From 9ea01579698fe222e514c5ae96dcd6efa375aab5 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sat, 14 Jul 2018 18:25:12 -0700 Subject: [PATCH] Partial harmonize key commands. Fix bug cut instead of copy. --- joy/gui/main.py | 25 ++++++++++++++++++------- joy/gui/mousebindings.py | 4 ++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/joy/gui/main.py b/joy/gui/main.py index d0fdd30..fea0104 100755 --- a/joy/gui/main.py +++ b/joy/gui/main.py @@ -98,12 +98,10 @@ def init_text(t, title, filename): def key_bindings(*args): print dedent(''' Ctrl-Enter - Run the selection as Joy code. + F1 - Reset and show (if hidden) the log. Esc - Like F1 but also clears the stack. - F5 - Copy the selection to text on the stack. - Shift-F5 - As F5 but cuts the selection. - F6 - Paste as text from top of stack. - Shift-F6 - As F6 but pops the item. + ... F12 - print a list of all command words, or right-click "words". ''') return args @@ -164,9 +162,9 @@ def load_stack(): tb = TEXT_BINDINGS.copy() tb.update({ - '': lambda tv: tv.cut, - '': lambda tv: tv.copy_selection_to_stack, - '': lambda tv: tv.pastecut, + '': lambda tv: tv.cut, + '': lambda tv: tv.copy_selection_to_stack, +# '': lambda tv: tv.pastecut, '': lambda tv: tv.copyto, }) @@ -210,9 +208,22 @@ init_text(t, 'Joy - ' + JOY_HOME, JOY_FN) GLOBAL_COMMANDS = { + '': 'swap', + '': 'dup', + + '': 'roll<', + '': 'roll>', + + '': 'over', + '': 'tuck', + + '': 'parse', + '': 'words', '': 'reset_log show_log', '': 'clear reset_log show_log', + '': 'pop', + '': 'popd', } for event, command in GLOBAL_COMMANDS.items(): t.bind_all(event, lambda _, _command=command: w.interpret(_command)) diff --git a/joy/gui/mousebindings.py b/joy/gui/mousebindings.py index baff8dd..87bc687 100644 --- a/joy/gui/mousebindings.py +++ b/joy/gui/mousebindings.py @@ -104,8 +104,8 @@ class MouseBindingsMixin: self.dothis = self.cancel else: - #left-middle-interclick - cut selection to stack - self.dothis = self.cut + #left-middle-interclick - copy selection to stack + self.dothis = self.copy_selection_to_stack elif self.B3_DOWN : self.unhighlight_command()