tweaks: rename an overshort type to something that makes some sense

master
Benno Schulenberg 2019-04-03 17:34:05 +02:00
parent acfee2538e
commit 671db5e1e3
8 changed files with 38 additions and 38 deletions

View File

@ -194,7 +194,7 @@ bool refresh_needed = FALSE;
int currmenu = MMOST;
/* The currently active menu, initialized to a dummy value. */
sc *sclist = NULL;
keystruct *sclist = NULL;
/* The start of the shortcuts list. */
funcstruct *allfuncs = NULL;
/* The start of the functions list. */
@ -386,11 +386,11 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
void add_to_sclist(int menus, const char *scstring, const int keycode,
void (*func)(void), int toggle)
{
static sc *tailsc;
static keystruct *tailsc;
#ifndef NANO_TINY
static int counter = 0;
#endif
sc *s = nmalloc(sizeof(sc));
keystruct *s = nmalloc(sizeof(keystruct));
/* Start the list, or tack on the next item. */
if (sclist == NULL)
@ -417,9 +417,9 @@ void add_to_sclist(int menus, const char *scstring, const int keycode,
/* Return the first shortcut in the list of shortcuts that
* matches the given func in the given menu. */
const sc *first_sc_for(int menu, void (*func)(void))
const keystruct *first_sc_for(int menu, void (*func)(void))
{
const sc *s;
const keystruct *s;
for (s = sclist; s != NULL; s = s->next)
if ((s->menus & menu) && s->func == func)
@ -435,7 +435,7 @@ const sc *first_sc_for(int menu, void (*func)(void))
* current menu, if any; otherwise, return the given default value. */
int the_code_for(void (*func)(void), int defaultval)
{
const sc *s = first_sc_for(currmenu, func);
const keystruct *s = first_sc_for(currmenu, func);
if (s == NULL)
return defaultval;
@ -447,7 +447,7 @@ int the_code_for(void (*func)(void), int defaultval)
/* Return a pointer to the function that is bound to the given key. */
functionptrtype func_from_key(int *kbinput)
{
const sc *s = get_shortcut(kbinput);
const keystruct *s = get_shortcut(kbinput);
if (s)
return s->func;
@ -456,7 +456,7 @@ functionptrtype func_from_key(int *kbinput)
}
/* Set the string and its corresponding keycode for the given shortcut s. */
void assign_keyinfo(sc *s, const char *keystring, const int keycode)
void assign_keyinfo(keystruct *s, const char *keystring, const int keycode)
{
s->keystr = keystring;
s->meta = (keystring[0] == 'M' && keycode == 0);
@ -505,7 +505,7 @@ int keycode_from_string(const char *keystring)
#ifdef DEBUG
void print_sclist(void)
{
sc *s;
keystruct *s;
const funcstruct *f;
for (s = sclist; s != NULL; s = s->next) {
@ -1390,7 +1390,7 @@ void shortcut_init(void)
#endif
}
const funcstruct *sctofunc(const sc *s)
const funcstruct *sctofunc(const keystruct *s)
{
funcstruct *f = allfuncs;
@ -1444,9 +1444,9 @@ const char *flagtostr(int flag)
#ifdef ENABLE_NANORC
/* Interpret a function string given in the rc file, and return a
* shortcut record with the corresponding function filled in. */
sc *strtosc(const char *input)
keystruct *strtosc(const char *input)
{
sc *s = nmalloc(sizeof(sc));
keystruct *s = nmalloc(sizeof(keystruct));
#ifndef NANO_TINY
s->toggle = 0;

View File

@ -292,7 +292,7 @@ void help_init(void)
* in case the full string is too long for the compiler to handle. */
char *ptr;
const funcstruct *f;
const sc *s;
const keystruct *s;
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {

View File

@ -1656,7 +1656,7 @@ bool wanted_to_move(void (*func)(void))
}
/* Return TRUE when the given shortcut is admissible in view mode. */
bool okay_for_view(const sc *shortcut)
bool okay_for_view(const keystruct *shortcut)
{
const funcstruct *func = sctofunc(shortcut);
@ -1675,7 +1675,7 @@ void do_input(void)
/* The length of the input buffer. */
bool retain_cuts = FALSE;
/* Whether to conserve the current contents of the cutbuffer. */
const sc *shortcut;
const keystruct *shortcut;
/* Read in a keystroke, and show the cursor while waiting. */
input = get_kbinput(edit, VISIBLE);

View File

@ -426,17 +426,17 @@ typedef struct rcoption {
} rcoption;
#endif
typedef struct sc {
typedef struct keystruct {
const char *keystr;
/* The string that describes a keystroke, like "^C" or "M-R". */
/* The string that describes the keystroke, like "^C" or "M-R". */
bool meta;
/* Whether this is a Meta keystroke. */
int keycode;
/* The integer that, together with meta, identifies the keystroke. */
int menus;
/* Which menus this applies to. */
/* The menus in which this keystroke is bound. */
void (*func)(void);
/* The function we're going to run. */
/* The function to which this keystroke is bound. */
#ifndef NANO_TINY
int toggle;
/* If a toggle, what we're toggling. */
@ -448,9 +448,9 @@ typedef struct sc {
char *expansion;
/* The string of keycodes to which this shortcut is expanded. */
#endif
struct sc *next;
struct keystruct *next;
/* Next in the list. */
} sc;
} keystruct;
typedef struct funcstruct {
void (*func)(void);

View File

@ -61,7 +61,7 @@ int do_statusbar_input(bool *finished)
/* The input buffer. */
static size_t kbinput_len = 0;
/* The length of the input buffer. */
const sc *shortcut;
const keystruct *shortcut;
*finished = FALSE;
@ -667,7 +667,7 @@ int do_yesno_prompt(bool all, const char *msg)
if (!ISSET(NO_HELP)) {
char shortstr[MAXCHARLEN + 2];
/* Temporary string for (translated) " Y", " N" and " A". */
const sc *cancelshortcut = first_sc_for(MYESNO, do_cancel);
const keystruct *cancelshortcut = first_sc_for(MYESNO, do_cancel);
/* The keystroke that is bound to the Cancel function. */
if (COLS < 32)

View File

@ -143,7 +143,7 @@ extern bool have_palette;
extern bool refresh_needed;
extern int currmenu;
extern sc *sclist;
extern keystruct *sclist;
extern funcstruct *allfuncs;
extern funcstruct *exitfunc;
@ -315,17 +315,17 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
/* Some functions in global.c. */
size_t length_of_list(int menu);
const sc *first_sc_for(int menu, void (*func)(void));
const keystruct *first_sc_for(int menu, void (*func)(void));
int the_code_for(void (*func)(void), int defaultval);
functionptrtype func_from_key(int *kbinput);
int keycode_from_string(const char *keystring);
void assign_keyinfo(sc *s, const char *keystring, const int keycode);
void assign_keyinfo(keystruct *s, const char *keystring, const int keycode);
void print_sclist(void);
void shortcut_init(void);
const funcstruct *sctofunc(const sc *s);
const funcstruct *sctofunc(const keystruct *s);
const char *flagtostr(int flag);
#ifdef ENABLE_NANORC
sc *strtosc(const char *input);
keystruct *strtosc(const char *input);
int name_to_menu(const char *name);
char *menu_to_name(int menu);
#endif
@ -440,7 +440,7 @@ void terminal_init(void);
void confirm_margin(void);
#endif
void unbound_key(int code);
bool okay_for_view(const sc *shortcut);
bool okay_for_view(const keystruct *shortcut);
void do_output(char *output, size_t output_len, bool allow_cntrls);
/* Most functions in prompt.c. */
@ -616,7 +616,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_row, int *mouse_col, bool allow_shortcuts);
#endif
const sc *get_shortcut(int *kbinput);
const keystruct *get_shortcut(int *kbinput);
void blank_row(WINDOW *win, int y, int x, int n);
void blank_edit(void);
void blank_statusbar(void);

View File

@ -347,7 +347,7 @@ bool is_universal(void (*func)(void))
void parse_binding(char *ptr, bool dobind)
{
char *keyptr = NULL, *keycopy = NULL, *funcptr = NULL, *menuptr = NULL;
sc *s, *newsc = NULL;
keystruct *s, *newsc = NULL;
int menu, mask = 0;
funcstruct *f;
@ -413,7 +413,7 @@ void parse_binding(char *ptr, bool dobind)
/* If the thing to bind starts with a double quote, it is a string,
* otherwise it is the name of a function. */
if (*funcptr == '"') {
newsc = nmalloc(sizeof(sc));
newsc = nmalloc(sizeof(keystruct));
newsc->func = (functionptrtype)implant;
newsc->expansion = mallocstrcpy(NULL, funcptr + 1);
#ifndef NANO_TINY
@ -893,7 +893,7 @@ static void check_vitals_mapped(void)
for (v = 0; v < VITALS; v++) {
for (f = allfuncs; f != NULL; f = f->next) {
if (f->func == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->func);
const keystruct *s = first_sc_for(inmenus[v], f->func);
if (!s) {
fprintf(stderr, _("No key is bound to function '%s' in "
"menu '%s'. Exiting.\n"), f->desc,

View File

@ -656,7 +656,7 @@ int parse_kbinput(WINDOW *win)
#ifndef NANO_TINY
/* When <Tab> is pressed while the mark is on, do an indent. */
if (retval == TAB_CODE && openfile->mark && currmenu == MMAIN) {
const sc *command = first_sc_for(MMAIN, do_indent);
const keystruct *command = first_sc_for(MMAIN, do_indent);
meta_key = command->meta;
return command->keycode;
@ -1729,7 +1729,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
/* And put the corresponding key into the keyboard buffer. */
if (f != NULL) {
const sc *s = first_sc_for(currmenu, f->func);
const keystruct *s = first_sc_for(currmenu, f->func);
unget_kbinput(s->keycode, s->meta);
}
return 1;
@ -1769,9 +1769,9 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
* key itself) and meta_key (whether the key is a meta sequence). The
* returned shortcut will be the first in the list that corresponds to
* the given sequence. */
const sc *get_shortcut(int *kbinput)
const keystruct *get_shortcut(int *kbinput)
{
sc *s;
keystruct *s;
/* Plain characters cannot be shortcuts, so just skip those. */
if (!meta_key && ((*kbinput >= 0x20 && *kbinput < 0x7F) ||
@ -2287,7 +2287,7 @@ void bottombars(int menu)
{
size_t number, itemwidth, i;
funcstruct *f;
const sc *s;
const keystruct *s;
/* Set the global variable to the given menu. */
currmenu = menu;