diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-16 19:41:03 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-16 19:44:29 +0100 |
commit | 64ee41446def1605a71d49fce6461b8ff3f5c0d2 (patch) | |
tree | 78acef7be5dcd510354d61b81d2f6ca84963cbe0 /src | |
parent | 746d7d1caf0fd0fb767a359f0eb5534ae2d8e653 (diff) | |
download | sciteco-64ee41446def1605a71d49fce6461b8ff3f5c0d2.tar.gz |
implemented function key masking (context-sensitive function key macros)
* fnkeys.tes has been updated to enable the command line
editing macros (cursor keys, etc.) only in the "start" state.
This avoids the annoying effect of inserting the macros
into string arguments where they have no effect and must be
rubbed out again.
Diffstat (limited to 'src')
-rw-r--r-- | src/cmdline.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp index e7ce066..90fed6e 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -499,21 +499,43 @@ Cmdline::process_edit_cmd(gchar key) void Cmdline::fnmacro(const gchar *name) { + enum { + FNMACRO_MASK_START = (1 << 0), + FNMACRO_MASK_STRING = (1 << 1) + }; + if (!(Flags::ed & Flags::ED_FNKEYS)) + /* function key macros disabled */ return; gchar macro_name[1 + strlen(name) + 1]; QRegister *reg; + tecoInt mask; + gchar *macro; macro_name[0] = CTL_KEY('F'); g_strlcpy(macro_name + 1, name, sizeof(macro_name) - 1); reg = QRegisters::globals[macro_name]; - if (reg) { - gchar *macro = reg->get_string(); - keypress(macro); - g_free(macro); + if (!reg) + /* macro undefined */ + return; + + mask = reg->get_integer(); + if (States::current == &States::start) { + if (mask & FNMACRO_MASK_START) + return; + } else if (States::is_string()) { + if (mask & FNMACRO_MASK_STRING) + return; + } else if (mask & ~(tecoInt)(FNMACRO_MASK_START | FNMACRO_MASK_STRING)) { + /* all other bits refer to any other state */ + return; } + + macro = reg->get_string(); + keypress(macro); + g_free(macro); } static gchar * |