aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-ncurses.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-16 02:22:51 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-16 02:22:51 +0100
commit7b16df057ce5b8cd5ad1870d5188ee11140e73b5 (patch)
treef593584458b8737738f0d7767a1e9d41dc71efc0 /src/interface-ncurses.cpp
parentb08d5e7dad907493bc6946ab708640b567e2dffe (diff)
downloadsciteco-7b16df057ce5b8cd5ad1870d5188ee11140e73b5.tar.gz
function key support (keys without printable representation) using keyboard macros
* if enabled, when a function key is pressed it is looked up in Q-Registers ^F... e.g. HOME key corresponds to register ^FHOME * the string if available is inserted as if it was entered by key-presses (later it may be entered as a single input token which may be removed in a single rubout) * only NCurses currently, key names directly correspond to Curses key names * on Curses if function keys are enabled ESCAPE will be inserted after a delay (because function keys are transmitted via escape sequences). A function key macro may be used to define an alternative escape character
Diffstat (limited to 'src/interface-ncurses.cpp')
-rw-r--r--src/interface-ncurses.cpp39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/interface-ncurses.cpp b/src/interface-ncurses.cpp
index b850ad4..a0e1e9a 100644
--- a/src/interface-ncurses.cpp
+++ b/src/interface-ncurses.cpp
@@ -49,9 +49,6 @@ static void scintilla_notify(Scintilla *sci, int idFrom,
#define UNNAMED_FILE "(Unnamed)"
-/* FIXME: should be configurable in TECO (Function key substitutes) */
-#define ESCAPE_SURROGATE KEY_DC
-
#define SCI_COLOR_ATTR(f, b) \
COLOR_PAIR(SCI_COLOR_PAIR(f, b))
@@ -76,7 +73,6 @@ InterfaceNCurses::InterfaceNCurses()
msg_window = newwin(1, 0, LINES - 2, 0);
cmdline_window = newwin(0, 0, LINES - 1, 0);
- keypad(cmdline_window, TRUE);
cmdline_current = NULL;
ssm(SCI_SETFOCUS, TRUE);
@@ -362,6 +358,8 @@ InterfaceNCurses::event_loop(void)
if (popup.window)
wrefresh(popup.window);
+ keypad(cmdline_window, Flags::ed & Flags::ED_FNKEYS);
+
/* no special <CTRL/C> handling */
raw();
key = wgetch(cmdline_window);
@@ -378,9 +376,7 @@ InterfaceNCurses::event_loop(void)
resize_all_windows();
break;
#endif
- case ESCAPE_SURROGATE:
- cmdline_keypress('\x1B');
- break;
+ case 0x7F: /* DEL */
case KEY_BACKSPACE:
cmdline_keypress('\b');
break;
@@ -398,6 +394,35 @@ InterfaceNCurses::event_loop(void)
cmdline_keypress('\n');
}
break;
+
+ /*
+ * Function key macros
+ */
+#define FN(KEY) case KEY_##KEY: cmdline_fnmacro(#KEY); break
+ FN(DOWN); FN(UP); FN(LEFT); FN(RIGHT);
+ FN(SLEFT); FN(SRIGHT);
+ FN(HOME); FN(SHOME);
+ case KEY_F(0)...KEY_F(63): {
+ gchar macro_name[3+1];
+
+ g_snprintf(macro_name, sizeof(macro_name),
+ "F%d", key - KEY_F0);
+ cmdline_fnmacro(macro_name);
+ break;
+ }
+ FN(DC); FN(SDC);
+ FN(IC); FN(SIC);
+ FN(NPAGE); FN(PPAGE);
+ FN(PRINT); FN(SPRINT);
+ FN(A1); FN(A3); FN(B2); FN(C1); FN(C3);
+ FN(COMMAND); FN(SCOMMAND);
+ FN(END); FN(SEND);
+ FN(HELP); FN(SHELP);
+#undef FN
+
+ /*
+ * Control keys and keys with printable representation
+ */
default:
if (key <= 0xFF)
cmdline_keypress((gchar)key);