1
1

* edit.c (edit_translate_key): Remove x_state argument, it's now

a part of x_keycode.
* editwidget.c (get_key_state): Remove.
Этот коммит содержится в:
Pavel Roskin 2002-12-21 08:46:50 +00:00
родитель 0d0009e263
Коммит d6947e39cf
5 изменённых файлов: 57 добавлений и 64 удалений

Просмотреть файл

@ -1,3 +1,9 @@
2002-12-21 Pavel Roskin <proski@gnu.org>
* edit.c (edit_translate_key): Remove x_state argument, it's now
a part of x_keycode.
* editwidget.c (get_key_state): Remove.
2002-12-18 Andrew V. Samoilov <sav@bcs.zp.ua>
* editcmd.c (edit_block_process_cmd): Quote filename.

Просмотреть файл

@ -28,7 +28,7 @@
#include "src/user.h" /* user_menu_cmd() */
#include "src/tty.h" /* keys */
#include "src/main.h" /* edit_one_file */
#include "src/key.h" /* SHIFT_PRESSED */
#include "src/key.h" /* KEY_M_SHIFT */
#include "src/wtools.h" /* query_dialog() */
#include "src/charsets.h"
@ -2034,7 +2034,9 @@ static void check_and_wrap_line (WEdit * edit)
static void edit_execute_macro (WEdit *edit, struct macro macro[], int n);
int edit_translate_key (WEdit * edit, unsigned int x_keycode, long x_key, int x_state, int *cmd, int *ch)
int
edit_translate_key (WEdit *edit, unsigned int x_keycode, long x_key,
int *cmd, int *ch)
{
int command = -1;
int char_for_insertion = -1;
@ -2044,8 +2046,11 @@ int edit_translate_key (WEdit * edit, unsigned int x_keycode, long x_key, int x_
*cmd = command;
*ch = char_for_insertion;
if((command == -1 || command == 0) && char_for_insertion == -1) /* unchanged, key has no function here */
if ((command == -1 || command == 0) && char_for_insertion == -1) {
/* unchanged, key has no function here */
return 0;
}
return 1;
}

Просмотреть файл

@ -123,7 +123,8 @@ void menu_save_mode_cmd (void);
int edit_raw_key_query (char *heading, char *query, int cancel);
char *strcasechr (const unsigned char *s, int c);
int edit (const char *_file, int line);
int edit_translate_key (WEdit * edit, unsigned int x_keycode, long x_key, int x_state, int *cmd, int *ch);
int edit_translate_key (WEdit *edit, unsigned int x_keycode, long x_key,
int *cmd, int *ch);
#ifndef NO_INLINE_GETBYTE
int edit_get_byte (WEdit * edit, long byte_index);

Просмотреть файл

@ -24,9 +24,7 @@
This is #include'd into the function edit_translate_key in edit.c.
This sequence of code takes 'x_state' and 'x_key' and translates them
into either 'command' or 'char_for_insertion'. 'x_key' holds one of
KEY_NPAGE, KEY_HOME etc., and 'x_state' holds a bitwise inclusive OR of
CONTROL_PRESSED, ALT_PRESSED or SHIFT_PRESSED, although none may
be supported.
KEY_NPAGE, KEY_HOME etc., possibly with modifiers.
'command' is one of the editor commands editcmddef.h.
Almost any C code can go into this file. The code below is an example
@ -180,13 +178,8 @@
command = edit->macro_i < 0 ? CK_Begin_Record_Macro : CK_End_Record_Macro;
goto fin;
}
/* if (x_key == KEY_NUMLOCK) {
num_lock = 1 - num_lock;
return 1;
}
*/
/* first translate the key-pad */
/* first translate the key-pad */
if (num_lock) {
if (x_key >= '0' && x_key <= '9') {
x_key = key_pad_map[x_key - '0'];
@ -195,105 +188,101 @@
x_key = KEY_DC;
}
}
if ((x_state & SHIFT_PRESSED) && (x_state & CONTROL_PRESSED)) {
switch (x_key) {
case KEY_PPAGE:
/* keys with modifiers */
switch (x_key) {
/* shift + ctrl */
case KEY_M_SHIFT | KEY_M_CTRL | KEY_PPAGE:
command = CK_Beginning_Of_Text_Highlight;
goto fin;
case KEY_NPAGE:
case KEY_M_SHIFT | KEY_M_CTRL | KEY_NPAGE:
command = CK_End_Of_Text_Highlight;
goto fin;
case KEY_LEFT:
case KEY_M_SHIFT | KEY_M_CTRL | KEY_LEFT:
command = CK_Word_Left_Highlight;
goto fin;
case KEY_RIGHT:
case KEY_M_SHIFT | KEY_M_CTRL | KEY_RIGHT:
command = CK_Word_Right_Highlight;
goto fin;
case KEY_UP:
case KEY_M_SHIFT | KEY_M_CTRL | KEY_UP:
command = CK_Scroll_Up_Highlight;
goto fin;
case KEY_DOWN:
case KEY_M_SHIFT | KEY_M_CTRL | KEY_DOWN:
command = CK_Scroll_Down_Highlight;
goto fin;
}
}
if ((x_state & SHIFT_PRESSED) && !(x_state & CONTROL_PRESSED)) {
switch (x_key) {
case KEY_PPAGE:
/* shift */
case KEY_M_SHIFT | KEY_PPAGE:
command = CK_Page_Up_Highlight;
goto fin;
case KEY_NPAGE:
case KEY_M_SHIFT | KEY_NPAGE:
command = CK_Page_Down_Highlight;
goto fin;
case KEY_LEFT:
case KEY_M_SHIFT | KEY_LEFT:
command = CK_Left_Highlight;
goto fin;
case KEY_RIGHT:
case KEY_M_SHIFT | KEY_RIGHT:
command = CK_Right_Highlight;
goto fin;
case KEY_UP:
case KEY_M_SHIFT | KEY_UP:
command = CK_Up_Highlight;
goto fin;
case KEY_DOWN:
case KEY_M_SHIFT | KEY_DOWN:
command = CK_Down_Highlight;
goto fin;
case KEY_HOME:
case KEY_M_SHIFT | KEY_HOME:
command = CK_Home_Highlight;
goto fin;
case KEY_END:
case KEY_M_SHIFT | KEY_END:
command = CK_End_Highlight;
goto fin;
case KEY_IC:
case KEY_M_SHIFT | KEY_IC:
command = CK_XPaste;
goto fin;
case KEY_DC:
case KEY_M_SHIFT | KEY_DC:
command = CK_XCut;
goto fin;
}
}
/* things that need a control key */
if (x_state & CONTROL_PRESSED) {
switch (x_key) {
case KEY_F (2):
/* ctrl */
case KEY_M_CTRL | (KEY_F (2)):
command = CK_Save_As;
goto fin;
case KEY_F (4):
case KEY_M_CTRL | (KEY_F (4)):
command = CK_Replace_Again;
goto fin;
case KEY_F (7):
case KEY_M_CTRL | (KEY_F (7)):
command = CK_Find_Again;
goto fin;
case KEY_BACKSPACE:
case KEY_M_CTRL | KEY_BACKSPACE:
command = CK_Undo;
goto fin;
case KEY_PPAGE:
case KEY_M_CTRL | KEY_PPAGE:
command = CK_Beginning_Of_Text;
goto fin;
case KEY_NPAGE:
case KEY_M_CTRL | KEY_NPAGE:
command = CK_End_Of_Text;
goto fin;
case KEY_UP:
case KEY_M_CTRL | KEY_UP:
command = CK_Scroll_Up;
goto fin;
case KEY_DOWN:
case KEY_M_CTRL | KEY_DOWN:
command = CK_Scroll_Down;
goto fin;
case KEY_LEFT:
case KEY_M_CTRL | KEY_LEFT:
command = CK_Word_Left;
goto fin;
case KEY_RIGHT:
case KEY_M_CTRL | KEY_RIGHT:
command = CK_Word_Right;
goto fin;
case KEY_IC:
case KEY_M_CTRL | KEY_IC:
command = CK_XStore;
goto fin;
case KEY_DC:
case KEY_M_CTRL | KEY_DC:
command = CK_Remove;
goto fin;
}
}
/* an ordinary insertable character */
/* an ordinary insertable character */
if (x_key < 256) {
int c = convert_from_input_c (x_key);
@ -303,7 +292,7 @@
}
}
/* other commands */
/* other commands */
i = 0;
while (key_map[i] != x_key && (key_map[i] || key_map[i + 1]))
i += 2;

Просмотреть файл

@ -25,7 +25,6 @@
#include "edit-widget.h"
#include "src/tty.h" /* LINES */
#include "src/key.h" /* get_modifier() */
#include "src/widget.h" /* redraw_labels() */
#include "src/menu.h" /* menubar_new() */
@ -294,13 +293,6 @@ edit_labels (WEdit *edit)
redraw_labels (h);
}
static long
get_key_state (void)
{
return (long) get_modifier ();
}
void edit_update_screen (WEdit * e)
{
edit_scroll_screen_over_cursor (e);
@ -337,7 +329,7 @@ static int edit_callback (WEdit *e, int msg, int par)
int cmd, ch;
if (edit_drop_hotkey_menu (e, par)) /* first check alt-f, alt-e, alt-s, etc for drop menus */
return 1;
if (!edit_translate_key (e, 0, par, get_key_state (), &cmd, &ch))
if (!edit_translate_key (e, 0, par, &cmd, &ch))
return 0;
edit_execute_key_command (e, cmd, ch);
edit_update_screen (e);