tweaks: shorten the name of two record elements

Exclude the confusing, pleonastic 'sc' abbreviation from their names.
master
Benno Schulenberg 2018-02-24 19:31:11 +01:00
parent e55227f65f
commit ffebd31cbb
7 changed files with 135 additions and 135 deletions

View File

@ -254,7 +254,7 @@ size_t length_of_list(int menu)
size_t i = 0;
for (f = allfuncs; f != NULL; f = f->next)
if ((f->menus & menu) && first_sc_for(menu, f->scfunc) != NULL)
if ((f->menus & menu) && first_sc_for(menu, f->func) != NULL)
i++;
return i;
@ -337,7 +337,7 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
tailfunc = f;
f->next = NULL;
f->scfunc = func;
f->func = func;
f->menus = menus;
f->desc = desc;
f->viewok = viewok;
@ -371,7 +371,7 @@ void add_to_sclist(int menus, const char *scstring, const int keycode,
/* Fill in the data. */
s->menus = menus;
s->scfunc = func;
s->func = func;
#ifndef NANO_TINY
s->toggle = toggle;
if (toggle)
@ -391,7 +391,7 @@ const sc *first_sc_for(int menu, void (*func)(void))
const sc *s;
for (s = sclist; s != NULL; s = s->next)
if ((s->menus & menu) && s->scfunc == func)
if ((s->menus & menu) && s->func == func)
return s;
#ifdef DEBUG
@ -420,7 +420,7 @@ functionptrtype func_from_key(int *kbinput)
const sc *s = get_shortcut(kbinput);
if (s)
return s->scfunc;
return s->func;
else
return NULL;
}
@ -1364,8 +1364,8 @@ void shortcut_init(void)
void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
{
for (sc *s = sclist; s != NULL; s = s->next)
if (s->scfunc == oldfunc)
s->scfunc = newfunc;
if (s->func == oldfunc)
s->func = newfunc;
}
void set_lint_or_format_shortcuts(void)
@ -1390,20 +1390,20 @@ void set_spell_shortcuts(void)
void execute(const sc *shortcut)
{
#ifdef ENABLE_NANORC
if (shortcut->scfunc == implant)
if (shortcut->func == implant)
/* Insert the corresponding string into the keyboard buffer. */
for (int i = strlen(shortcut->expansion); i > 0; i--)
put_back(shortcut->expansion[i - 1]);
else
#endif
shortcut->scfunc();
shortcut->func();
}
const subnfunc *sctofunc(const sc *s)
{
subnfunc *f = allfuncs;
while (f != NULL && f->scfunc != s->scfunc)
while (f != NULL && f->func != s->func)
f = f->next;
return f;
@ -1472,207 +1472,207 @@ sc *strtosc(const char *input)
#ifdef ENABLE_HELP
if (!strcasecmp(input, "help"))
s->scfunc = do_help_void;
s->func = do_help_void;
else
#endif
if (!strcasecmp(input, "cancel"))
s->scfunc = do_cancel;
s->func = do_cancel;
else if (!strcasecmp(input, "exit"))
s->scfunc = do_exit;
s->func = do_exit;
else if (!strcasecmp(input, "discardbuffer"))
s->scfunc = discard_buffer;
s->func = discard_buffer;
else if (!strcasecmp(input, "writeout"))
s->scfunc = do_writeout_void;
s->func = do_writeout_void;
else if (!strcasecmp(input, "savefile"))
s->scfunc = do_savefile;
s->func = do_savefile;
else if (!strcasecmp(input, "insert"))
s->scfunc = do_insertfile_void;
s->func = do_insertfile_void;
else if (!strcasecmp(input, "whereis"))
s->scfunc = do_search_forward;
s->func = do_search_forward;
else if (!strcasecmp(input, "wherewas"))
s->scfunc = do_search_backward;
s->func = do_search_backward;
else if (!strcasecmp(input, "searchagain"))
s->scfunc = do_research;
s->func = do_research;
#ifndef NANO_TINY
else if (!strcasecmp(input, "findprevious"))
s->scfunc = do_findprevious;
s->func = do_findprevious;
else if (!strcasecmp(input, "findnext"))
s->scfunc = do_findnext;
s->func = do_findnext;
#endif
else if (!strcasecmp(input, "replace"))
s->scfunc = do_replace;
s->func = do_replace;
else if (!strcasecmp(input, "cut"))
s->scfunc = do_cut_text_void;
s->func = do_cut_text_void;
else if (!strcasecmp(input, "uncut"))
s->scfunc = do_uncut_text;
s->func = do_uncut_text;
#ifndef NANO_TINY
else if (!strcasecmp(input, "cutrestoffile"))
s->scfunc = do_cut_till_eof;
s->func = do_cut_till_eof;
else if (!strcasecmp(input, "copytext"))
s->scfunc = do_copy_text;
s->func = do_copy_text;
else if (!strcasecmp(input, "mark"))
s->scfunc = do_mark;
s->func = do_mark;
#endif
#ifdef ENABLE_SPELLER
else if (!strcasecmp(input, "tospell") ||
!strcasecmp(input, "speller"))
s->scfunc = do_spell;
s->func = do_spell;
#endif
#ifdef ENABLE_COLOR
else if (!strcasecmp(input, "linter"))
s->scfunc = do_linter;
s->func = do_linter;
#endif
else if (!strcasecmp(input, "curpos"))
s->scfunc = do_cursorpos_void;
s->func = do_cursorpos_void;
else if (!strcasecmp(input, "gotoline"))
s->scfunc = do_gotolinecolumn_void;
s->func = do_gotolinecolumn_void;
#ifdef ENABLE_JUSTIFY
else if (!strcasecmp(input, "justify"))
s->scfunc = do_justify_void;
s->func = do_justify_void;
else if (!strcasecmp(input, "fulljustify"))
s->scfunc = do_full_justify;
s->func = do_full_justify;
else if (!strcasecmp(input, "beginpara"))
s->scfunc = do_para_begin_void;
s->func = do_para_begin_void;
else if (!strcasecmp(input, "endpara"))
s->scfunc = do_para_end_void;
s->func = do_para_end_void;
#endif
#ifdef ENABLE_COMMENT
else if (!strcasecmp(input, "comment"))
s->scfunc = do_comment;
s->func = do_comment;
#endif
#ifdef ENABLE_WORDCOMPLETION
else if (!strcasecmp(input, "complete"))
s->scfunc = complete_a_word;
s->func = complete_a_word;
#endif
#ifndef NANO_TINY
else if (!strcasecmp(input, "indent"))
s->scfunc = do_indent;
s->func = do_indent;
else if (!strcasecmp(input, "unindent"))
s->scfunc = do_unindent;
s->func = do_unindent;
else if (!strcasecmp(input, "scrollup"))
s->scfunc = do_scroll_up;
s->func = do_scroll_up;
else if (!strcasecmp(input, "scrolldown"))
s->scfunc = do_scroll_down;
s->func = do_scroll_down;
else if (!strcasecmp(input, "cutwordleft"))
s->scfunc = do_cut_prev_word;
s->func = do_cut_prev_word;
else if (!strcasecmp(input, "cutwordright"))
s->scfunc = do_cut_next_word;
s->func = do_cut_next_word;
else if (!strcasecmp(input, "findbracket"))
s->scfunc = do_find_bracket;
s->func = do_find_bracket;
else if (!strcasecmp(input, "wordcount"))
s->scfunc = do_wordlinechar_count;
s->func = do_wordlinechar_count;
else if (!strcasecmp(input, "recordmacro"))
s->scfunc = record_macro;
s->func = record_macro;
else if (!strcasecmp(input, "runmacro"))
s->scfunc = run_macro;
s->func = run_macro;
else if (!strcasecmp(input, "undo"))
s->scfunc = do_undo;
s->func = do_undo;
else if (!strcasecmp(input, "redo"))
s->scfunc = do_redo;
s->func = do_redo;
#endif
else if (!strcasecmp(input, "left") ||
!strcasecmp(input, "back"))
s->scfunc = do_left;
s->func = do_left;
else if (!strcasecmp(input, "right") ||
!strcasecmp(input, "forward"))
s->scfunc = do_right;
s->func = do_right;
else if (!strcasecmp(input, "up") ||
!strcasecmp(input, "prevline"))
s->scfunc = do_up_void;
s->func = do_up_void;
else if (!strcasecmp(input, "down") ||
!strcasecmp(input, "nextline"))
s->scfunc = do_down_void;
s->func = do_down_void;
else if (!strcasecmp(input, "prevword"))
s->scfunc = do_prev_word_void;
s->func = do_prev_word_void;
else if (!strcasecmp(input, "nextword"))
s->scfunc = do_next_word_void;
s->func = do_next_word_void;
else if (!strcasecmp(input, "home"))
s->scfunc = do_home;
s->func = do_home;
else if (!strcasecmp(input, "end"))
s->scfunc = do_end;
s->func = do_end;
else if (!strcasecmp(input, "prevblock"))
s->scfunc = do_prev_block;
s->func = do_prev_block;
else if (!strcasecmp(input, "nextblock"))
s->scfunc = do_next_block;
s->func = do_next_block;
else if (!strcasecmp(input, "pageup") ||
!strcasecmp(input, "prevpage"))
s->scfunc = do_page_up;
s->func = do_page_up;
else if (!strcasecmp(input, "pagedown") ||
!strcasecmp(input, "nextpage"))
s->scfunc = do_page_down;
s->func = do_page_down;
else if (!strcasecmp(input, "firstline"))
s->scfunc = to_first_line;
s->func = to_first_line;
else if (!strcasecmp(input, "lastline"))
s->scfunc = to_last_line;
s->func = to_last_line;
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "prevbuf"))
s->scfunc = switch_to_prev_buffer;
s->func = switch_to_prev_buffer;
else if (!strcasecmp(input, "nextbuf"))
s->scfunc = switch_to_next_buffer;
s->func = switch_to_next_buffer;
#endif
else if (!strcasecmp(input, "verbatim"))
s->scfunc = do_verbatim_input;
s->func = do_verbatim_input;
else if (!strcasecmp(input, "tab"))
s->scfunc = do_tab;
s->func = do_tab;
else if (!strcasecmp(input, "enter"))
s->scfunc = do_enter;
s->func = do_enter;
else if (!strcasecmp(input, "delete"))
s->scfunc = do_delete;
s->func = do_delete;
else if (!strcasecmp(input, "backspace"))
s->scfunc = do_backspace;
s->func = do_backspace;
else if (!strcasecmp(input, "refresh"))
s->scfunc = total_refresh;
s->func = total_refresh;
else if (!strcasecmp(input, "suspend"))
s->scfunc = do_suspend_void;
s->func = do_suspend_void;
else if (!strcasecmp(input, "casesens"))
s->scfunc = case_sens_void;
s->func = case_sens_void;
else if (!strcasecmp(input, "regexp"))
s->scfunc = regexp_void;
s->func = regexp_void;
else if (!strcasecmp(input, "backwards"))
s->scfunc = backwards_void;
s->func = backwards_void;
else if (!strcasecmp(input, "flipreplace"))
s->scfunc = flip_replace;
s->func = flip_replace;
else if (!strcasecmp(input, "flipgoto") ||
!strcasecmp(input, "gototext")) /* Deprecated. Remove end of 2018. */
s->scfunc = flip_goto;
s->func = flip_goto;
#ifdef ENABLE_HISTORIES
else if (!strcasecmp(input, "prevhistory"))
s->scfunc = get_history_older_void;
s->func = get_history_older_void;
else if (!strcasecmp(input, "nexthistory"))
s->scfunc = get_history_newer_void;
s->func = get_history_newer_void;
#endif
#ifndef NANO_TINY
else if (!strcasecmp(input, "dosformat"))
s->scfunc = dos_format_void;
s->func = dos_format_void;
else if (!strcasecmp(input, "macformat"))
s->scfunc = mac_format_void;
s->func = mac_format_void;
else if (!strcasecmp(input, "append"))
s->scfunc = append_void;
s->func = append_void;
else if (!strcasecmp(input, "prepend"))
s->scfunc = prepend_void;
s->func = prepend_void;
else if (!strcasecmp(input, "backup"))
s->scfunc = backup_file_void;
s->func = backup_file_void;
else if (!strcasecmp(input, "flipexecute"))
s->scfunc = flip_execute;
s->func = flip_execute;
#endif
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "flipnewbuffer"))
s->scfunc = flip_newbuffer;
s->func = flip_newbuffer;
#endif
#ifdef ENABLE_BROWSER
else if (!strcasecmp(input, "tofiles") ||
!strcasecmp(input, "browser"))
s->scfunc = to_files_void;
s->func = to_files_void;
else if (!strcasecmp(input, "gotodir"))
s->scfunc = goto_dir_void;
s->func = goto_dir_void;
else if (!strcasecmp(input, "firstfile"))
s->scfunc = to_first_file;
s->func = to_first_file;
else if (!strcasecmp(input, "lastfile"))
s->scfunc = to_last_file;
s->func = to_last_file;
#endif
else {
#ifndef NANO_TINY
s->scfunc = do_toggle_void;
s->func = do_toggle_void;
if (!strcasecmp(input, "nohelp"))
s->toggle = NO_HELP;
else if (!strcasecmp(input, "constupdate"))

View File

@ -471,7 +471,7 @@ void help_init(void)
size_t endis_len = strlen(_("enable/disable"));
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == do_toggle_void)
if (s->func == do_toggle_void)
allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 8;
}
#endif
@ -504,7 +504,7 @@ void help_init(void)
if ((s->menus & currmenu) == 0)
continue;
if (s->scfunc == f->scfunc) {
if (s->func == f->func) {
scsfound++;
/* Make the first column narrower (6) than the second (10),
* but allow it to spill into the second, for "M-Space". */

View File

@ -1717,20 +1717,20 @@ int do_input(bool allow_funcs)
/* If the function associated with this shortcut is
* cutting or copying text, remember this. */
if (shortcut->scfunc == do_cut_text_void
if (shortcut->func == do_cut_text_void
#ifndef NANO_TINY
|| shortcut->scfunc == do_copy_text
|| shortcut->scfunc == do_cut_till_eof
|| shortcut->func == do_copy_text
|| shortcut->func == do_cut_till_eof
#endif
)
retain_cuts = TRUE;
#ifdef ENABLE_WORDCOMPLETION
if (shortcut->scfunc != complete_a_word)
if (shortcut->func != complete_a_word)
pletion_line = NULL;
#endif
#ifndef NANO_TINY
if (shortcut->scfunc == do_toggle_void) {
if (shortcut->func == do_toggle_void) {
do_toggle(shortcut->toggle);
if (shortcut->toggle != CUT_FROM_CURSOR)
retain_cuts = TRUE;
@ -1771,16 +1771,16 @@ int do_input(bool allow_funcs)
/* If the cursor moved to another line and this was not caused
* by adding characters to the buffer, clear the prepend flag. */
if (openfile->current->next != was_next &&
shortcut->scfunc != do_tab &&
shortcut->scfunc != do_verbatim_input)
shortcut->func != do_tab &&
shortcut->func != do_verbatim_input)
wrap_reset();
#endif
#ifdef ENABLE_COLOR
if (f && !f->viewok && !refresh_needed)
check_the_multis(openfile->current);
#endif
if (!refresh_needed && (shortcut->scfunc == do_delete ||
shortcut->scfunc == do_backspace))
if (!refresh_needed && (shortcut->func == do_delete ||
shortcut->func == do_backspace))
update_line(openfile->current, openfile->current_x);
}
}

View File

@ -431,7 +431,7 @@ typedef struct sc {
/* The integer that, together with meta, identifies the keystroke. */
int menus;
/* Which menus this applies to. */
void (*scfunc)(void);
void (*func)(void);
/* The function we're going to run. */
#ifndef NANO_TINY
int toggle;
@ -449,7 +449,7 @@ typedef struct sc {
} sc;
typedef struct subnfunc {
void (*scfunc)(void);
void (*func)(void);
/* The actual function to call. */
int menus;
/* In what menus this function applies. */

View File

@ -129,41 +129,41 @@ int do_statusbar_input(bool *ran_func, bool *finished)
}
if (shortcut) {
if (shortcut->scfunc == do_tab || shortcut->scfunc == do_enter)
if (shortcut->func == do_tab || shortcut->func == do_enter)
;
else if (shortcut->scfunc == do_left)
else if (shortcut->func == do_left)
do_statusbar_left();
else if (shortcut->scfunc == do_right)
else if (shortcut->func == do_right)
do_statusbar_right();
#ifndef NANO_TINY
else if (shortcut->scfunc == do_prev_word_void)
else if (shortcut->func == do_prev_word_void)
do_statusbar_prev_word();
else if (shortcut->scfunc == do_next_word_void)
else if (shortcut->func == do_next_word_void)
do_statusbar_next_word();
#endif
else if (shortcut->scfunc == do_home)
else if (shortcut->func == do_home)
do_statusbar_home();
else if (shortcut->scfunc == do_end)
else if (shortcut->func == do_end)
do_statusbar_end();
/* When in restricted mode at the "Write File" prompt and the
* filename isn't blank, disallow any input and deletion. */
else if (ISSET(RESTRICTED) && currmenu == MWRITEFILE &&
openfile->filename[0] != '\0' &&
(shortcut->scfunc == do_verbatim_input ||
shortcut->scfunc == do_cut_text_void ||
shortcut->scfunc == do_uncut_text ||
shortcut->scfunc == do_delete ||
shortcut->scfunc == do_backspace))
(shortcut->func == do_verbatim_input ||
shortcut->func == do_cut_text_void ||
shortcut->func == do_uncut_text ||
shortcut->func == do_delete ||
shortcut->func == do_backspace))
;
else if (shortcut->scfunc == do_verbatim_input)
else if (shortcut->func == do_verbatim_input)
do_statusbar_verbatim_input();
else if (shortcut->scfunc == do_cut_text_void)
else if (shortcut->func == do_cut_text_void)
do_statusbar_cut_text();
else if (shortcut->scfunc == do_delete)
else if (shortcut->func == do_delete)
do_statusbar_delete();
else if (shortcut->scfunc == do_backspace)
else if (shortcut->func == do_backspace)
do_statusbar_backspace();
else if (shortcut->scfunc == do_uncut_text) {
else if (shortcut->func == do_uncut_text) {
if (cutbuffer != NULL)
do_statusbar_uncut_text();
} else {
@ -172,10 +172,10 @@ int do_statusbar_input(bool *ran_func, bool *finished)
* and setting finished to TRUE to indicatethat we're done after
* running or trying to run their associated functions. */
f = sctofunc(shortcut);
if (shortcut->scfunc != NULL) {
if (shortcut->func != NULL) {
*ran_func = TRUE;
if (f && (!ISSET(VIEW_MODE) || f->viewok) &&
f->scfunc != do_gotolinecolumn_void)
f->func != do_gotolinecolumn_void)
execute(shortcut);
}
*finished = TRUE;

View File

@ -421,7 +421,7 @@ void parse_binding(char *ptr, bool dobind)
* otherwise it is the name of a function. */
if (*funcptr == '"') {
newsc = nmalloc(sizeof(sc));
newsc->scfunc = implant;
newsc->func = implant;
newsc->expansion = mallocstrcpy(NULL, funcptr + 1);
#ifndef NANO_TINY
newsc->toggle = 0;
@ -447,17 +447,17 @@ void parse_binding(char *ptr, bool dobind)
/* Tally up the menus where the function exists. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->scfunc == newsc->scfunc)
if (f->func == newsc->func)
mask = mask | f->menus;
#ifndef NANO_TINY
/* Handle the special case of the toggles. */
if (newsc->scfunc == do_toggle_void)
if (newsc->func == do_toggle_void)
mask = MMAIN;
#endif
/* Now limit the given menu to those where the function exists. */
if (is_universal(newsc->scfunc))
if (is_universal(newsc->func))
menu = menu & MMOST;
else
menu = menu & mask;
@ -486,9 +486,9 @@ void parse_binding(char *ptr, bool dobind)
if (dobind) {
#ifndef NANO_TINY
/* If this is a toggle, copy its sequence number. */
if (newsc->scfunc == do_toggle_void) {
if (newsc->func == do_toggle_void) {
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == do_toggle_void && s->toggle == newsc->toggle)
if (s->func == do_toggle_void && s->toggle == newsc->toggle)
newsc->ordinal = s->ordinal;
} else
newsc->ordinal = 0;
@ -891,8 +891,8 @@ static void check_vitals_mapped(void)
for (v = 0; v < VITALS; v++) {
for (f = allfuncs; f != NULL; f = f->next) {
if (f->scfunc == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->scfunc);
if (f->func == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->func);
if (!s) {
fprintf(stderr, _("Fatal error: no keys mapped for function "
"\"%s\". Exiting.\n"), f->desc);

View File

@ -1660,7 +1660,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
for (f = allfuncs; f != NULL; f = f->next) {
if ((f->menus & currmenu) == 0)
continue;
if (first_sc_for(currmenu, f->scfunc) == NULL)
if (first_sc_for(currmenu, f->func) == NULL)
continue;
/* Tick off an actually shown shortcut. */
j -= 1;
@ -1670,7 +1670,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->scfunc);
const sc *s = first_sc_for(currmenu, f->func);
unget_kbinput(s->keycode, s->meta);
}
return 1;
@ -2255,7 +2255,7 @@ void bottombars(int menu)
if ((f->menus & menu) == 0)
continue;
s = first_sc_for(menu, f->scfunc);
s = first_sc_for(menu, f->func);
if (s == NULL)
continue;