+2015-06-28 Benno Schulenberg <bensberg@justemail.net>
+ * src/global.c (add_to_sclist), src/help.c (help_init), src/nano.h,
+ src/rcfile.c (parse_binding): When defining the toggles, give each
+ of them a sequence number, so that, when they are rebound, they can
+ still be listed in the original order in the help text.
+
GNU nano 2.4.2 - 2015.07.05
2015-06-28 Benno Schulenberg <bensberg@justemail.net>
* src/browser.c (browser_refresh): Limit the selected file to the
void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggle)
{
static sc *tailsc;
+ static int counter = 0;
sc *s = (sc *)nmalloc(sizeof(sc));
/* Start the list, or tack on the next item. */
s->menu = menu;
s->scfunc = func;
s->toggle = toggle;
+ if (toggle)
+ s->ordinal = ++counter;
s->keystr = (char *) scstring;
s->type = strtokeytype(scstring);
assign_keyinfo(s);
#ifndef NANO_TINY
/* And the toggles... */
- if (currmenu == MMAIN)
+ if (currmenu == MMAIN) {
+ int maximum = 0, counter = 0;
+
+ /* First see how many toggles there are. */
for (s = sclist; s != NULL; s = s->next) {
- if (s->scfunc == do_toggle_void)
+ maximum = (s->toggle && s->ordinal > maximum) ? s->ordinal : maximum;
+ }
+
+ /* Now show them in the original order. */
+ while (counter < maximum) {
+ counter++;
+ for (s = sclist; s != NULL; s = s->next) {
+ if (s->toggle && s->ordinal == counter) {
ptr += sprintf(ptr, "%s\t\t%s %s\n", (s->menu == MMAIN ? s->keystr : ""),
_(flagtostr(s->toggle)), _("enable/disable"));
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
ptr += sprintf(ptr, "\n");
+ break;
}
+ }
+ }
+ }
#ifndef DISABLE_NANORC
if (old_whitespace)
/* The function we're going to run. */
int toggle;
/* If a toggle, what we're toggling. */
+ int ordinal;
+ /* The how-manieth toggle this is, in order to be able to
+ * keep them in sequence. */
struct sc *next;
/* Next in the list. */
} sc;
}
if (dobind) {
+ /* If this is a toggle, copy its sequence number. */
+ if (newsc->scfunc == do_toggle_void) {
+ for (s = sclist; s != NULL; s = s->next)
+ if (newsc->toggle == s->toggle)
+ newsc->ordinal = s->ordinal;
+ } else
+ newsc->ordinal = 0;
/* Add the new shortcut at the start of the list. */
newsc->next = sclist;
sclist = newsc;