/* Check whether the user has unmapped every shortcut for a sequence we consider 'vital', like the exit function */ static void check_vitals_mapped(void) { subnfunc *f; int v; #define VITALS 5 short vitals[VITALS] = { DO_EXIT, DO_EXIT, CANCEL_MSG, CANCEL_MSG, CANCEL_MSG }; int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE }; 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 (!s) { rcfile_error(N_("Fatal error: no keys mapped for function \"%s\""), f->desc); fprintf(stderr, N_("Exiting. Please use nano with the -I option if needed to adjust your nanorc settings\n")); exit(1); } break; } } } }
/* Check whether the user has unmapped every shortcut for a * sequence we consider 'vital', like the exit function. */ static void check_vitals_mapped(void) { subnfunc *f; int v; #define VITALS 5 void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel, do_cancel, do_cancel }; int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE }; 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 (!s) { fprintf(stderr, _("Fatal error: no keys mapped for function " "\"%s\". Exiting.\n"), f->desc); fprintf(stderr, _("If needed, use nano with the -I option " "to adjust your nanorc settings.\n")); exit(1); } break; } } } }
/* Display the shortcut list in s on the last two rows of the bottom * portion of the window. */ void bottombars(int menu) { size_t i = 0, colwidth, slen; const sc *s; /* Set the global variable to the given menu. */ currmenu = menu; if (ISSET(NO_HELP)) { return; } if (menu == MMAIN) { slen = MAIN_VISIBLE; assert(slen <= length_of_list(menu)); } else { slen = length_of_list(menu); /* Don't show any more shortcuts than the main list does. */ if (slen > MAIN_VISIBLE) { slen = MAIN_VISIBLE; } } /* There will be this many characters per column, except for the * last two, which will be longer by (COLS % colwidth) columns so as * to not waste space. We need at least three columns to display * anything properly. */ colwidth = COLS / ((slen / 2) + (slen % 2)); blank_bottombars(); DEBUG_LOG("In bottombars, and slen == " << slen); DEBUG_LOG("Checking menu items...."); for (auto f : allfuncs) { if ((f->menus & menu) == 0) { continue; } if (f->desc == "") { continue; } DEBUG_LOG("found one! f->menus = " << f->menus << ", desc = \"" << f->desc << '"'); s = first_sc_for(menu, f->scfunc); if (s == NULL) { DEBUG_LOG("Whoops, guess not, no shortcut key found for func!"); continue; } wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth); DEBUG_LOG("Calling onekey with keystr \"" << s->keystr << "\" and desc \"" << f->desc << '"'); onekey(s->keystr, _(f->desc.c_str()), colwidth + (COLS % colwidth)); if (++i >= slen) { break; } } wnoutrefresh(bottomwin); reset_cursor(); wnoutrefresh(edit); }