nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit c28048d20f18a22e6feff34ae6df4461de2de8a9
parent a24e72f972abfbfe650f0821310d24299cfef341
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri,  4 Feb 2022 12:12:18 +0100

tweaks: rename another variable, to better fit in with its sisters

Diffstat:
Msrc/global.c | 6+++---
Msrc/nano.c | 18+++++++++---------
Msrc/prompt.c | 60++++++++++++++++++++++++++++++------------------------------
Msrc/prototypes.h | 2+-
Msrc/text.c | 2+-
Msrc/winio.c | 104++++++++++++++++++++++++++++++++++++++++----------------------------------------
6 files changed, 96 insertions(+), 96 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -121,9 +121,9 @@ WINDOW *topwin = NULL; WINDOW *midwin = NULL; /* The middle portion of the screen: the edit window, showing the * contents of the current buffer, the file we are editing. */ -WINDOW *bottomwin = NULL; - /* The bottom portion of the screen, where we display statusbar - * messages, the status-bar prompt, and a list of shortcuts. */ +WINDOW *footwin = NULL; + /* The bottom portion of the screen, where status-bar messages, + * the status-bar prompt, and a list of shortcuts are shown. */ int editwinrows = 0; /* How many rows does the edit window take up? */ int editwincols = -1; diff --git a/src/nano.c b/src/nano.c @@ -243,14 +243,14 @@ void finish(void) /* Blank the status bar and (if applicable) the shortcut list. */ blank_statusbar(); blank_bottombars(); - wrefresh(bottomwin); + wrefresh(footwin); #ifndef NANO_TINY /* Deallocate the two or three subwindows. */ if (topwin != NULL) delwin(topwin); delwin(midwin); - delwin(bottomwin); + delwin(footwin); #endif /* Switch the cursor on, exit from curses, and restore terminal settings. */ restore_terminal(); @@ -407,7 +407,7 @@ void window_init(void) if (topwin != NULL) delwin(topwin); delwin(midwin); - delwin(bottomwin); + delwin(footwin); } topwin = NULL; @@ -418,7 +418,7 @@ void window_init(void) /* Set up two subwindows. If the terminal is just one line, * edit window and status-bar window will cover each other. */ midwin = newwin(editwinrows, COLS, 0, 0); - bottomwin = newwin(1, COLS, LINES - 1, 0); + footwin = newwin(1, COLS, LINES - 1, 0); } else { int toprows = ((ISSET(EMPTY_LINE) && LINES > 6) ? 2 : 1); int bottomrows = ((ISSET(NO_HELP) || LINES < 6) ? 1 : 3); @@ -433,16 +433,16 @@ void window_init(void) if (toprows > 0) topwin = newwin(toprows, COLS, 0, 0); midwin = newwin(editwinrows, COLS, toprows, 0); - bottomwin = newwin(bottomrows, COLS, LINES - bottomrows, 0); + footwin = newwin(bottomrows, COLS, LINES - bottomrows, 0); } /* In case the terminal shrunk, make sure the status line is clear. */ - wnoutrefresh(bottomwin); + wnoutrefresh(footwin); /* When not disabled, turn escape-sequence translation on. */ if (!ISSET(RAW_SEQUENCES)) { keypad(midwin, TRUE); - keypad(bottomwin, TRUE); + keypad(footwin, TRUE); } #ifdef ENABLED_WRAPORJUSTIFY @@ -2558,8 +2558,8 @@ int main(int argc, char **argv) edit_scroll(FORWARD); wnoutrefresh(midwin); } - wredrawln(bottomwin, 0 ,1); - wnoutrefresh(bottomwin); + wredrawln(footwin, 0 ,1); + wnoutrefresh(footwin); place_the_cursor(); } else if (ISSET(ZERO) && lastmessage > VACUUM) wredrawln(midwin, editwinrows - 1, 1); diff --git a/src/prompt.c b/src/prompt.c @@ -204,7 +204,7 @@ int do_statusbar_mouse(void) int retval = get_mouseinput(&click_row, &click_col, TRUE); /* We can click on the status-bar window text to move the cursor. */ - if (retval == 0 && wmouse_trafo(bottomwin, &click_row, &click_col, FALSE)) { + if (retval == 0 && wmouse_trafo(footwin, &click_row, &click_col, FALSE)) { size_t start_col = breadth(prompt) + 2; /* Move to where the click occurred. */ @@ -240,7 +240,7 @@ void do_statusbar_verbatim_input(void) size_t count = 1; char *bytes; - bytes = get_verbatim_kbinput(bottomwin, &count); + bytes = get_verbatim_kbinput(footwin, &count); if (0 < count && count < 999) inject_into_answer(bytes, count); @@ -266,7 +266,7 @@ int do_statusbar_input(bool *finished) *finished = FALSE; /* Read in a character. */ - input = get_kbinput(bottomwin, VISIBLE); + input = get_kbinput(footwin, VISIBLE); #ifndef NANO_TINY if (input == KEY_WINCH) @@ -278,7 +278,7 @@ int do_statusbar_input(bool *finished) * shortcut character. */ if (input == KEY_MOUSE) { if (do_statusbar_mouse() == 1) - input = get_kbinput(bottomwin, BLIND); + input = get_kbinput(footwin, BLIND); else return ERR; } @@ -410,33 +410,33 @@ void draw_the_promptbar(void) end_page = get_statusbar_page_start(base, base + breadth(answer) - 1); /* Color the prompt bar over its full width. */ - wattron(bottomwin, interface_color_pair[PROMPT_BAR]); - mvwprintw(bottomwin, 0, 0, "%*s", COLS, " "); + wattron(footwin, interface_color_pair[PROMPT_BAR]); + mvwprintw(footwin, 0, 0, "%*s", COLS, " "); - mvwaddstr(bottomwin, 0, 0, prompt); - waddch(bottomwin, ':'); - waddch(bottomwin, (the_page == 0) ? ' ' : '<'); + mvwaddstr(footwin, 0, 0, prompt); + waddch(footwin, ':'); + waddch(footwin, (the_page == 0) ? ' ' : '<'); expanded = display_string(answer, the_page, COLS - base, FALSE, TRUE); - waddstr(bottomwin, expanded); + waddstr(footwin, expanded); free(expanded); if (the_page < end_page && base + breadth(answer) - the_page > COLS) - mvwaddch(bottomwin, 0, COLS - 1, '>'); + mvwaddch(footwin, 0, COLS - 1, '>'); - wattroff(bottomwin, interface_color_pair[PROMPT_BAR]); + wattroff(footwin, interface_color_pair[PROMPT_BAR]); #if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH < 20210220) /* Work around a cursor-misplacement bug -- https://sv.gnu.org/bugs/?59808. */ if (ISSET(NO_HELP)) { - wmove(bottomwin, 0, 0); - wrefresh(bottomwin); + wmove(footwin, 0, 0); + wrefresh(footwin); } #endif /* Place the cursor at the right spot. */ - wmove(bottomwin, 0, column - the_page); - wnoutrefresh(bottomwin); + wmove(footwin, 0, column - the_page); + wnoutrefresh(footwin); } #ifndef NANO_TINY @@ -689,34 +689,34 @@ int ask_user(bool withall, const char *question) /* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */ sprintf(shortstr, " %c", yesstr[0]); - wmove(bottomwin, 1, 0); + wmove(footwin, 1, 0); post_one_key(shortstr, _("Yes"), width); shortstr[1] = nostr[0]; - wmove(bottomwin, 2, 0); + wmove(footwin, 2, 0); post_one_key(shortstr, _("No"), width); if (withall) { shortstr[1] = allstr[0]; - wmove(bottomwin, 1, width); + wmove(footwin, 1, width); post_one_key(shortstr, _("All"), width); } - wmove(bottomwin, 2, width); + wmove(footwin, 2, width); post_one_key(cancelshortcut->keystr, _("Cancel"), width); } /* Color the prompt bar over its full width and display the question. */ - wattron(bottomwin, interface_color_pair[PROMPT_BAR]); - mvwprintw(bottomwin, 0, 0, "%*s", COLS, " "); - mvwaddnstr(bottomwin, 0, 0, question, actual_x(question, COLS - 1)); - wattroff(bottomwin, interface_color_pair[PROMPT_BAR]); - wnoutrefresh(bottomwin); + wattron(footwin, interface_color_pair[PROMPT_BAR]); + mvwprintw(footwin, 0, 0, "%*s", COLS, " "); + mvwaddnstr(footwin, 0, 0, question, actual_x(question, COLS - 1)); + wattroff(footwin, interface_color_pair[PROMPT_BAR]); + wnoutrefresh(footwin); currmenu = MYESNO; /* When not replacing, show the cursor while waiting for a key. */ - kbinput = get_kbinput(bottomwin, !withall); + kbinput = get_kbinput(footwin, !withall); #ifndef NANO_TINY if (kbinput == KEY_WINCH) @@ -724,7 +724,7 @@ int ask_user(bool withall, const char *question) /* Accept the first character of an external paste. */ if (bracketed_paste && kbinput == BRACKETED_PASTE_MARKER) - kbinput = get_kbinput(bottomwin, BLIND); + kbinput = get_kbinput(footwin, BLIND); #endif #ifdef ENABLE_NLS @@ -736,7 +736,7 @@ int ask_user(bool withall, const char *question) int extras = (kbinput / 16) % 4 + (kbinput <= 0xCF ? 1 : 0); while (extras <= waiting_keycodes() && extras-- > 0) - letter[index++] = (unsigned char)get_kbinput(bottomwin, !withall); + letter[index++] = (unsigned char)get_kbinput(footwin, !withall); } #endif letter[index] = '\0'; @@ -769,7 +769,7 @@ int ask_user(bool withall, const char *question) int mouse_x, mouse_y; /* We can click on the Yes/No/All shortcuts to select an answer. */ if (get_mouseinput(&mouse_y, &mouse_x, FALSE) == 0 && - wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE) && + wmouse_trafo(footwin, &mouse_y, &mouse_x, FALSE) && mouse_x < (width * 2) && mouse_y > 0) { int x = mouse_x / width; int y = mouse_y - 1; @@ -800,7 +800,7 @@ int ask_user(bool withall, const char *question) #ifndef NANO_TINY /* Ignore the rest of an external paste. */ while (bracketed_paste) - kbinput = get_kbinput(bottomwin, BLIND); + kbinput = get_kbinput(footwin, BLIND); #endif } diff --git a/src/prototypes.h b/src/prototypes.h @@ -88,7 +88,7 @@ extern size_t wrap_at; extern WINDOW *topwin; extern WINDOW *midwin; -extern WINDOW *bottomwin; +extern WINDOW *footwin; extern int editwinrows; extern int editwincols; extern int margin; diff --git a/src/text.c b/src/text.c @@ -2820,7 +2820,7 @@ void do_linter(void) place_the_cursor(); wnoutrefresh(midwin); - kbinput = get_kbinput(bottomwin, VISIBLE); + kbinput = get_kbinput(footwin, VISIBLE); #ifndef NANO_TINY if (kbinput == KEY_WINCH) diff --git a/src/winio.c b/src/winio.c @@ -1507,7 +1507,7 @@ char *get_verbatim_kbinput(WINDOW *frame, size_t *count) * the data that the frame parameter points to. */ if (!ISSET(RAW_SEQUENCES)) { keypad(midwin, TRUE); - keypad(bottomwin, TRUE); + keypad(footwin, TRUE); } if (*count < 999) { @@ -1543,7 +1543,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) return -1; in_editwin = wenclose(midwin, event.y, event.x); - in_bottomwin = wenclose(bottomwin, event.y, event.x); + in_bottomwin = wenclose(footwin, event.y, event.x); /* Save the screen coordinates where the mouse event took place. */ *mouse_x = event.x - (in_editwin ? margin : 0); @@ -1564,8 +1564,8 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) size_t number; /* The number of shortcut items that get displayed. */ - /* Translate the coordinates to become relative to bottomwin. */ - wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE); + /* Shift the coordinates to be relative to the bottom window. */ + wmouse_trafo(footwin, mouse_y, mouse_x, FALSE); /* Clicks on the status bar are handled elsewhere, so * restore the untranslated mouse-event coordinates. */ @@ -1615,7 +1615,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) return 1; } else - /* Clicks outside of bottomwin are handled elsewhere. */ + /* Clicks outside of the bottom window are handled elsewhere. */ return 0; } #if NCURSES_MOUSE_VERSION >= 2 @@ -1626,8 +1626,8 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) bool in_edit = wenclose(midwin, *mouse_y, *mouse_x); if (in_bottomwin) - /* Translate the coordinates to become relative to bottomwin. */ - wmouse_trafo(bottomwin, mouse_y, mouse_x, FALSE); + /* Shift the coordinates to be relative to the bottom window. */ + wmouse_trafo(footwin, mouse_y, mouse_x, FALSE); if (in_edit || (in_bottomwin && *mouse_y == 0)) { int keycode = (event.bstate & BUTTON4_PRESSED) ? KEY_UP : KEY_DOWN; @@ -1671,7 +1671,7 @@ void blank_edit(void) /* Blank the first line of the bottom portion of the screen. */ void blank_statusbar(void) { - blank_row(bottomwin, 0); + blank_row(footwin, 0); } /* Wipe the status bar clean and include this in the next screen update. */ @@ -1682,16 +1682,16 @@ void wipe_statusbar(void) if (ISSET(ZERO) || ISSET(MINIBAR) || LINES == 1) return; - blank_row(bottomwin, 0); - wnoutrefresh(bottomwin); + blank_row(footwin, 0); + wnoutrefresh(footwin); } /* Blank out the two help lines (when they are present). */ void blank_bottombars(void) { if (!ISSET(NO_HELP) && LINES > 5) { - blank_row(bottomwin, 1); - blank_row(bottomwin, 2); + blank_row(footwin, 1); + blank_row(footwin, 2); } } @@ -2117,8 +2117,8 @@ void minibar(void) #endif /* Draw a colored bar over the full width of the screen. */ - wattron(bottomwin, interface_color_pair[MINI_INFOBAR]); - mvwprintw(bottomwin, 0, 0, "%*s", COLS, " "); + wattron(footwin, interface_color_pair[MINI_INFOBAR]); + mvwprintw(footwin, 0, 0, "%*s", COLS, " "); if (openfile->filename[0] != '\0') { as_an_at = FALSE; @@ -2140,13 +2140,13 @@ void minibar(void) if (namewidth > COLS - 2) { char *shortname = display_string(thename, namewidth - COLS + 5, COLS - 5, FALSE, FALSE); - mvwaddstr(bottomwin, 0, 0, "..."); - waddstr(bottomwin, shortname); + mvwaddstr(footwin, 0, 0, "..."); + waddstr(footwin, shortname); free(shortname); } else - mvwaddstr(bottomwin, 0, padding, thename); + mvwaddstr(footwin, 0, padding, thename); - waddstr(bottomwin, openfile->modified ? " *" : " "); + waddstr(footwin, openfile->modified ? " *" : " "); } /* Right after reading or writing a file, display its number of lines; @@ -2158,7 +2158,7 @@ void minibar(void) sprintf(number_of_lines, P_(" (%zu line)", " (%zu lines)", count), count); tallywidth = breadth(number_of_lines); if (namewidth + tallywidth + 11 < COLS) - waddstr(bottomwin, number_of_lines); + waddstr(footwin, number_of_lines); else tallywidth = 0; report_size = FALSE; @@ -2168,13 +2168,13 @@ void minibar(void) ranking = nmalloc(24); sprintf(ranking, " [%i/%i]", buffer_number(openfile), buffer_number(startfile->prev)); if (namewidth + placewidth + breadth(ranking) + 32 < COLS) - waddstr(bottomwin, ranking); + waddstr(footwin, ranking); } #endif /* Display the line/column position of the cursor. */ if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + placewidth + 32 < COLS) - mvwaddstr(bottomwin, 0, COLS - 27 - placewidth, location); + mvwaddstr(footwin, 0, COLS - 27 - placewidth, location); /* Display the hexadecimal code of the character under the cursor, * plus the codes of up to two succeeding zero-width characters. */ @@ -2198,7 +2198,7 @@ void minibar(void) else sprintf(hexadecimal, " 0x%02X", (unsigned char)*this_position); - mvwaddstr(bottomwin, 0, COLS - 23, hexadecimal); + mvwaddstr(footwin, 0, COLS - 23, hexadecimal); #ifdef ENABLE_UTF8 successor = this_position + char_length(this_position); @@ -2206,13 +2206,13 @@ void minibar(void) if (*this_position && *successor && is_zerowidth(successor) && mbtowide(&widecode, successor) > 0) { sprintf(hexadecimal, "|%04X", (int)widecode); - waddstr(bottomwin, hexadecimal); + waddstr(footwin, hexadecimal); successor += char_length(successor); if (is_zerowidth(successor) && mbtowide(&widecode, successor) > 0) { sprintf(hexadecimal, "|%04X", (int)widecode); - waddstr(bottomwin, hexadecimal); + waddstr(footwin, hexadecimal); } } else successor = NULL; @@ -2221,18 +2221,18 @@ void minibar(void) /* Display the state of three flags, and the state of macro and mark. */ if (ISSET(STATEFLAGS) && !successor && namewidth + tallywidth + 14 + 2 * padding < COLS) { - wmove(bottomwin, 0, COLS - 11 - padding); - show_states_at(bottomwin); + wmove(footwin, 0, COLS - 11 - padding); + show_states_at(footwin); } /* Display how many percent the current line is into the file. */ if (namewidth + 6 < COLS) { sprintf(location, "%3zi%%", 100 * openfile->current->lineno / openfile->filebot->lineno); - mvwaddstr(bottomwin, 0, COLS - 4 - padding, location); + mvwaddstr(footwin, 0, COLS - 4 - padding, location); } - wattroff(bottomwin, interface_color_pair[MINI_INFOBAR]); - wrefresh(bottomwin); + wattroff(footwin, interface_color_pair[MINI_INFOBAR]); + wrefresh(footwin); free(number_of_lines); free(hexadecimal); @@ -2284,11 +2284,11 @@ void statusline(message_type importance, const char *msg, ...) /* If there are multiple alert messages, add trailing dots to the first. */ if (lastmessage == ALERT) { if (start_col > 4) { - wmove(bottomwin, 0, COLS + 2 - start_col); - wattron(bottomwin, interface_color_pair[ERROR_MESSAGE]); - waddstr(bottomwin, "..."); - wattroff(bottomwin, interface_color_pair[ERROR_MESSAGE]); - wnoutrefresh(bottomwin); + wmove(footwin, 0, COLS + 2 - start_col); + wattron(footwin, interface_color_pair[ERROR_MESSAGE]); + waddstr(footwin, "..."); + wattroff(footwin, interface_color_pair[ERROR_MESSAGE]); + wnoutrefresh(footwin); start_col = 0; napms(100); beep(); @@ -2320,23 +2320,23 @@ void statusline(message_type importance, const char *msg, ...) start_col = (COLS - breadth(message)) / 2; bracketed = (start_col > 1); - wmove(bottomwin, 0, (bracketed ? start_col - 2 : start_col)); - wattron(bottomwin, colorpair); + wmove(footwin, 0, (bracketed ? start_col - 2 : start_col)); + wattron(footwin, colorpair); if (bracketed) - waddstr(bottomwin, "[ "); - waddstr(bottomwin, message); + waddstr(footwin, "[ "); + waddstr(footwin, message); if (bracketed) - waddstr(bottomwin, " ]"); - wattroff(bottomwin, colorpair); + waddstr(footwin, " ]"); + wattroff(footwin, colorpair); #ifdef USING_OLDER_LIBVTE /* Defeat a VTE/Konsole bug, where the cursor can go off-limits. */ if (ISSET(CONSTANT_SHOW) && ISSET(NO_HELP)) - wmove(bottomwin, 0, 0); + wmove(footwin, 0, 0); #endif /* Push the message to the screen straightaway. */ - wrefresh(bottomwin); + wrefresh(footwin); free(compound); free(message); @@ -2366,19 +2366,19 @@ void warn_and_briefly_pause(const char *msg) * Key plus tag may occupy at most width columns. */ void post_one_key(const char *keystroke, const char *tag, int width) { - wattron(bottomwin, interface_color_pair[KEY_COMBO]); - waddnstr(bottomwin, keystroke, actual_x(keystroke, width)); - wattroff(bottomwin, interface_color_pair[KEY_COMBO]); + wattron(footwin, interface_color_pair[KEY_COMBO]); + waddnstr(footwin, keystroke, actual_x(keystroke, width)); + wattroff(footwin, interface_color_pair[KEY_COMBO]); /* If the remaining space is too small, skip the description. */ width -= breadth(keystroke); if (width < 2) return; - waddch(bottomwin, ' '); - wattron(bottomwin, interface_color_pair[FUNCTION_TAG]); - waddnstr(bottomwin, tag, actual_x(tag, width - 1)); - wattroff(bottomwin, interface_color_pair[FUNCTION_TAG]); + waddch(footwin, ' '); + wattron(footwin, interface_color_pair[FUNCTION_TAG]); + waddnstr(footwin, tag, actual_x(tag, width - 1)); + wattroff(footwin, interface_color_pair[FUNCTION_TAG]); } /* Display the shortcut list corresponding to menu on the last two rows @@ -2420,7 +2420,7 @@ void bottombars(int menu) if (s == NULL) continue; - wmove(bottomwin, 1 + index % 2, (index / 2) * itemwidth); + wmove(footwin, 1 + index % 2, (index / 2) * itemwidth); /* When the number is uneven, the penultimate item can be double wide. */ if ((number % 2) == 1 && (index + 2 == number)) @@ -2435,7 +2435,7 @@ void bottombars(int menu) index++; } - wrefresh(bottomwin); + wrefresh(footwin); } /* Redetermine current_y from the position of current relative to edittop, @@ -3704,7 +3704,7 @@ void do_credits(void) wrefresh(topwin); wrefresh(midwin); - wrefresh(bottomwin); + wrefresh(footwin); napms(700); for (crpos = 0; crpos < CREDIT_LEN + editwinrows / 2; crpos++) {