diff --git a/edit/ChangeLog b/edit/ChangeLog index bc17a0936..86973fc36 100644 --- a/edit/ChangeLog +++ b/edit/ChangeLog @@ -1,5 +1,11 @@ 2004-02-04 Pavel Roskin + * editcmddef.h: Split CK_No_Command into CK_Insert_Char and + CK_Ignore_Key. + * editkeys.c (emacs_key_map): Ignore Ctrl-g. Requested by + Paul Seelig + (edit_translate_key): Implement CK_Ignore_Key. + * edit.c (edit_execute_key_command): Return void, the result is never used. (edit_execute_cmd): Likewise. diff --git a/edit/editcmddef.h b/edit/editcmddef.h index c8f1923f1..19c3e0c81 100644 --- a/edit/editcmddef.h +++ b/edit/editcmddef.h @@ -4,8 +4,11 @@ /* in the distant future, keyboards will be invented with a separate key for each one of these commands *sigh* */ +/* special commands */ +#define CK_Insert_Char -1 +#define CK_Ignore_Key 0 + /* cursor movements */ -#define CK_No_Command -1 #define CK_BackSpace 1 #define CK_Delete 2 #define CK_Enter 3 diff --git a/edit/editkeys.c b/edit/editkeys.c index 83b11c0d9..c74a04488 100644 --- a/edit/editkeys.c +++ b/edit/editkeys.c @@ -56,6 +56,7 @@ static long const emacs_key_map[] = { XCTRL ('b'), CK_Left, XCTRL ('e'), CK_End, XCTRL ('f'), CK_Right, + XCTRL ('g'), CK_Ignore_Key, XCTRL ('n'), CK_Down, XCTRL ('p'), CK_Up, XCTRL ('s'), CK_Find, @@ -163,7 +164,7 @@ static long const common_key_map[] = { int edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch) { - int command = -1; + int command = CK_Insert_Char; int char_for_insertion = -1; int i = 0; static const long *key_map; @@ -194,7 +195,7 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch) (_(" Execute Macro "), _(" Press macro hotkey: "), 1)); if (command == CK_Macro (0)) - command = -1; + command = CK_Insert_Char; goto fin; } goto fin; @@ -225,7 +226,7 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch) (_(" Execute Macro "), _(" Press macro hotkey: "), 1)); if (command == CK_Macro (0)) - command = -1; + command = CK_Insert_Char; goto fin; } /* edit is a pointer to the widget */ @@ -250,20 +251,22 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch) /* Commands specific to the key emulation */ i = 0; - while (key_map[i] != x_key && (key_map[i] || key_map[i + 1])) + while (key_map[i] && (key_map[i] != x_key)) i += 2; - command = key_map[i + 1]; - if (command) + if (key_map[i]) { + command = key_map[i + 1]; goto fin; + } /* Commands common for the key emulations */ key_map = common_key_map; i = 0; - while (key_map[i] != x_key && (key_map[i] || key_map[i + 1])) + while (key_map[i] && (key_map[i] != x_key)) i += 2; - command = key_map[i + 1]; - if (command) + if (key_map[i]) { + command = key_map[i + 1]; goto fin; + } /* Function still not found for this key, so try macros */ /* This allows the same macro to be @@ -282,7 +285,7 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch) *cmd = command; *ch = char_for_insertion; - if ((command == -1 || command == 0) && char_for_insertion == -1) { + if (command == CK_Insert_Char && char_for_insertion == -1) { /* unchanged, key has no function here */ return 0; }