Commit 1c9ab8bf authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: rename a struct element, to be more fitting

The keycode is not a sequence; it is a single integer value.
parent e2950701
Showing with 29 additions and 29 deletions
+29 -29
...@@ -342,7 +342,7 @@ void add_to_sclist(int menus, const char *scstring, void (*func)(void), int togg ...@@ -342,7 +342,7 @@ void add_to_sclist(int menus, const char *scstring, void (*func)(void), int togg
assign_keyinfo(s, scstring); assign_keyinfo(s, scstring);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Setting sequence to %d for shortcut \"%s\" in menus %x\n", s->seq, scstring, s->menus); fprintf(stderr, "Setting keycode to %d for shortcut \"%s\" in menus %x\n", s->keycode, scstring, s->menus);
#endif #endif
} }
...@@ -381,7 +381,7 @@ int sc_seq_or(void (*func)(void), int defaultval) ...@@ -381,7 +381,7 @@ int sc_seq_or(void (*func)(void), int defaultval)
if (s) { if (s) {
meta_key = s->meta; meta_key = s->meta;
return s->seq; return s->keycode;
} }
/* else */ /* else */
return defaultval; return defaultval;
...@@ -406,51 +406,51 @@ void assign_keyinfo(sc *s, const char *keystring) ...@@ -406,51 +406,51 @@ void assign_keyinfo(sc *s, const char *keystring)
if (s->keystr[0] == '^') { if (s->keystr[0] == '^') {
assert(strlen(s->keystr) > 1); assert(strlen(s->keystr) > 1);
s->seq = s->keystr[1] - 64; s->keycode = s->keystr[1] - 64;
} else if (s->meta) { } else if (s->meta) {
assert(strlen(s->keystr) > 2); assert(strlen(s->keystr) > 2);
s->seq = tolower((int) s->keystr[2]); s->keycode = tolower((int) s->keystr[2]);
} else if (s->keystr[0] == 'F') { } else if (s->keystr[0] == 'F') {
assert(strlen(s->keystr) > 1); assert(strlen(s->keystr) > 1);
s->seq = KEY_F0 + atoi(&s->keystr[1]); s->keycode = KEY_F0 + atoi(&s->keystr[1]);
} else /* RAWINPUT */ } else /* RAWINPUT */
s->seq = (int) s->keystr[0]; s->keycode = (int) s->keystr[0];
/* Override some keys which don't bind as easily as we'd like. */ /* Override some keys which don't bind as easily as we'd like. */
if (strcasecmp(s->keystr, "^Space") == 0) if (strcasecmp(s->keystr, "^Space") == 0)
s->seq = 0; s->keycode = 0;
else if (strcasecmp(s->keystr, "M-Space") == 0) else if (strcasecmp(s->keystr, "M-Space") == 0)
s->seq = (int) ' '; s->keycode = (int) ' ';
else { else {
if (!strcasecmp(s->keystr, "Up")) if (!strcasecmp(s->keystr, "Up"))
s->seq = KEY_UP; s->keycode = KEY_UP;
else if (!strcasecmp(s->keystr, "Down")) else if (!strcasecmp(s->keystr, "Down"))
s->seq = KEY_DOWN; s->keycode = KEY_DOWN;
else if (!strcasecmp(s->keystr, "Left")) else if (!strcasecmp(s->keystr, "Left"))
s->seq = KEY_LEFT; s->keycode = KEY_LEFT;
else if (!strcasecmp(s->keystr, "Right")) else if (!strcasecmp(s->keystr, "Right"))
s->seq = KEY_RIGHT; s->keycode = KEY_RIGHT;
else if (!strcasecmp(s->keystr, "Ins")) else if (!strcasecmp(s->keystr, "Ins"))
s->seq = KEY_IC; s->keycode = KEY_IC;
else if (!strcasecmp(s->keystr, "Del")) else if (!strcasecmp(s->keystr, "Del"))
s->seq = KEY_DC; s->keycode = KEY_DC;
else if (!strcasecmp(s->keystr, "Bsp")) else if (!strcasecmp(s->keystr, "Bsp"))
s->seq = KEY_BACKSPACE; s->keycode = KEY_BACKSPACE;
/* The Tab and Enter keys don't actually produce special codes /* The Tab and Enter keys don't actually produce special codes
* but the exact integer values of ^I and ^M. Rebinding the * but the exact integer values of ^I and ^M. Rebinding the
* latter therefore also rebinds Tab and Enter. */ * latter therefore also rebinds Tab and Enter. */
else if (!strcasecmp(s->keystr, "Tab")) else if (!strcasecmp(s->keystr, "Tab"))
s->seq = NANO_CONTROL_I; s->keycode = NANO_CONTROL_I;
else if (!strcasecmp(s->keystr, "Enter")) else if (!strcasecmp(s->keystr, "Enter"))
s->seq = KEY_ENTER; s->keycode = KEY_ENTER;
else if (!strcasecmp(s->keystr, "PgUp")) else if (!strcasecmp(s->keystr, "PgUp"))
s->seq = KEY_PPAGE; s->keycode = KEY_PPAGE;
else if (!strcasecmp(s->keystr, "PgDn")) else if (!strcasecmp(s->keystr, "PgDn"))
s->seq = KEY_NPAGE; s->keycode = KEY_NPAGE;
else if (!strcasecmp(s->keystr, "Home")) else if (!strcasecmp(s->keystr, "Home"))
s->seq = KEY_HOME; s->keycode = KEY_HOME;
else if (!strcasecmp(s->keystr, "End")) else if (!strcasecmp(s->keystr, "End"))
s->seq = KEY_END; s->keycode = KEY_END;
} }
} }
......
...@@ -436,11 +436,11 @@ typedef struct rcoption { ...@@ -436,11 +436,11 @@ typedef struct rcoption {
typedef struct sc { typedef struct sc {
char *keystr; char *keystr;
/* The shortcut key for a function, ASCII version. */ /* The string that describes a keystroke, like "^C" or "M-R". */
bool meta; bool meta;
/* Whether this is a Meta keystroke. */ /* Whether this is a Meta keystroke. */
int seq; int keycode;
/* The actual sequence to check once the type is determined. */ /* The integer that, together with meta, identifies the keystroke. */
int menus; int menus;
/* Which menus this applies to. */ /* Which menus this applies to. */
void (*scfunc)(void); void (*scfunc)(void);
......
...@@ -474,14 +474,14 @@ void parse_binding(char *ptr, bool dobind) ...@@ -474,14 +474,14 @@ void parse_binding(char *ptr, bool dobind)
assign_keyinfo(newsc, keycopy); assign_keyinfo(newsc, keycopy);
/* Do not allow rebinding a frequent escape-sequence starter: Esc [. */ /* Do not allow rebinding a frequent escape-sequence starter: Esc [. */
if (newsc->meta && newsc->seq == 91) { if (newsc->meta && newsc->keycode == 91) {
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr); rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
free(newsc); free(newsc);
goto free_copy; goto free_copy;
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "s->keystr = \"%s\"\n", newsc->keystr); fprintf(stderr, "s->keystr = \"%s\"\n", newsc->keystr);
fprintf(stderr, "s->seq = \"%d\"\n", newsc->seq); fprintf(stderr, "s->keycode = \"%d\"\n", newsc->keycode);
#endif #endif
} }
......
...@@ -591,7 +591,7 @@ int parse_kbinput(WINDOW *win) ...@@ -591,7 +591,7 @@ int parse_kbinput(WINDOW *win)
#endif #endif
/* Slang doesn't support KEY_CANCEL. */ /* Slang doesn't support KEY_CANCEL. */
case KEY_CANCEL: case KEY_CANCEL:
retval = first_sc_for(currmenu, do_cancel)->seq; retval = first_sc_for(currmenu, do_cancel)->keycode;
break; break;
#endif #endif
#ifdef KEY_SUSPEND #ifdef KEY_SUSPEND
...@@ -1558,7 +1558,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts) ...@@ -1558,7 +1558,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
/* And put the corresponding key into the keyboard buffer. */ /* And put the corresponding key into the keyboard buffer. */
if (f != NULL) { if (f != NULL) {
const sc *s = first_sc_for(currmenu, f->scfunc); const sc *s = first_sc_for(currmenu, f->scfunc);
unget_kbinput(s->seq, s->meta); unget_kbinput(s->keycode, s->meta);
} }
return 1; return 1;
} else } else
...@@ -1616,7 +1616,7 @@ const sc *get_shortcut(int *kbinput) ...@@ -1616,7 +1616,7 @@ const sc *get_shortcut(int *kbinput)
#endif #endif
for (s = sclist; s != NULL; s = s->next) { for (s = sclist; s != NULL; s = s->next) {
if ((s->menus & currmenu) && *kbinput == s->seq && if ((s->menus & currmenu) && *kbinput == s->keycode &&
meta_key == s->meta) { meta_key == s->meta) {
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "matched seq '%s' (menu is %x from %x)\n", fprintf (stderr, "matched seq '%s' (menu is %x from %x)\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment