diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-07 03:16:49 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-07 03:16:49 +0100 |
commit | d107f8d1de766ca339f61a189bd01810af89986f (patch) | |
tree | 3297152f484603e40aed82e80fbee75db82f4991 /src | |
parent | 2789e5da50987b908a4aa5758a17c86570d94d63 (diff) | |
download | sciteco-d107f8d1de766ca339f61a189bd01810af89986f.tar.gz |
Curses UI: fixed translation of the backspace key
* for historic reasons, the backspace key can be transmitted as
^H by the terminal. Some terminal emulators might do that - these
are fixed by this commit.
* Use CTL_KEY('H') instead of standard C '\b' as the former is less
ambiguous given the confusion around the backspace character.
Diffstat (limited to 'src')
-rw-r--r-- | src/cmdline.cpp | 2 | ||||
-rw-r--r-- | src/interface-curses.cpp | 13 | ||||
-rw-r--r-- | src/interface-gtk.cpp | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 888a70c..4a04277 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -268,7 +268,7 @@ Cmdline::process_edit_cmd(gchar key) modifier_enabled ? "enabled" : "disabled"); break; - case '\b': /* rubout/reinsert character */ + case CTL_KEY('H'): /* rubout/reinsert character */ interface.popup_clear(); if (modifier_enabled) diff --git a/src/interface-curses.cpp b/src/interface-curses.cpp index e05643b..da0f158 100644 --- a/src/interface-curses.cpp +++ b/src/interface-curses.cpp @@ -509,9 +509,18 @@ event_loop_iter() interface.resize_all_windows(); break; #endif - case 0x7F: /* DEL */ + case CTL_KEY('H'): + case 0x7F: /* ^? */ case KEY_BACKSPACE: - cmdline.keypress('\b'); + /* + * For historic reasons terminals can send + * ASCII 8 (^H) or 127 (^?) for backspace. + * Curses also defines KEY_BACKSPACE, probably + * for terminals that send an escape sequence for + * backspace. + * In SciTECO backspace is normalized to ^H. + */ + cmdline.keypress(CTL_KEY('H')); break; case KEY_ENTER: case '\r': diff --git a/src/interface-gtk.cpp b/src/interface-gtk.cpp index 8375dd8..14dfafd 100644 --- a/src/interface-gtk.cpp +++ b/src/interface-gtk.cpp @@ -311,7 +311,7 @@ handle_key_press(bool is_shift, bool is_ctl, guint keyval) cmdline.keypress(CTL_KEY_ESC); break; case GDK_BackSpace: - cmdline.keypress('\b'); + cmdline.keypress(CTL_KEY('H')); break; case GDK_Tab: cmdline.keypress('\t'); |