TTY: code reorganization.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-07-04 14:48:39 +04:00
parent 6b07af2fc4
commit aadc438c20
3 changed files with 1189 additions and 1173 deletions

View File

@ -102,29 +102,26 @@ _("Please press the %s\n"
/* Esc hides the dialog and do not allow definitions of
* regular characters
*/
int seq_ok;
gboolean seq_ok = FALSE;
if (*seq && strcmp (seq, "\\e") && strcmp (seq, "\\e\\e")
&& strcmp (seq, "^m" ) && strcmp (seq, "^i" )
&& (seq [1] || (*seq < ' ' || *seq > '~'))){
learnchanged = 1;
learnkeys [action - B_USER].sequence = seq;
seq = convert_controls (seq);
seq_ok = define_sequence (key_name_conv_tab [action - B_USER].code,
seq, MCKEY_NOACTION);
} else {
seq_ok = 0;
}
if (!seq_ok) {
if (!seq_ok)
message (D_NORMAL, _(" Cannot accept this key "),
_(" You have entered \"%s\""), seq);
}
g_free (seq);
g_free (seq);
}
dlg_run_done (d);
destroy_dlg (d);
dlg_select_widget (learnkeys [action - B_USER].button);

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,10 @@
#include "../../src/global.h" /* <glib.h> */
#include "../../src/dialog.h" /* cb_ret_t */
#include "../../src/tty/tty.h" /* KEY_F macro */
gboolean define_sequence (int code, const char *seq, int action);
void init_key (void);
void init_key_input_fd (void);
void done_key (void);
@ -32,14 +36,13 @@ extern key_code_name_t key_name_conv_tab [];
/* mouse support */
struct Gpm_Event;
int tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block);
int is_idle (void);
gboolean is_idle (void);
int tty_getch (void);
/* Possible return values from tty_get_event: */
#define EV_MOUSE -2
#define EV_NONE -1
/*
* Internal representation of the key modifiers. It is used in the
* sequence tables and the keycodes in the mc sources.
@ -55,7 +58,7 @@ extern int use_8th_bit_as_meta;
extern int mou_auto_repeat;
/* While waiting for input, the program can select on more than one file */
typedef int (*select_fn)(int fd, void *info);
typedef int (*select_fn) (int fd, void *info);
/* Channel manipulation */
void add_select_channel (int fd, select_fn callback, void *info);
@ -66,11 +69,16 @@ void remove_select_channel (int fd);
void channels_up (void);
void channels_down (void);
gboolean is_abort_char (int c);
#define XCTRL(x) (KEY_M_CTRL | ((x) & 31))
#define ALT(x) (KEY_M_ALT | (unsigned int)(x))
static inline gboolean
is_abort_char (int c)
{
return ((c == XCTRL ('c')) || (c == XCTRL ('g'))
|| (c == ESC_CHAR) || (c == KEY_F (10)));
}
/* To define sequences and return codes */
#define MCKEY_NOACTION 0
#define MCKEY_ESCAPE 1
@ -78,7 +86,6 @@ gboolean is_abort_char (int c);
/* Return code for the mouse sequence */
#define MCKEY_MOUSE -2
int define_sequence (int code, const char *seq, int action);
/* internally used in key.c, defined in keyxtra.c */
void load_xtra_key_defines (void);