nano

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

commit 1388af2bdcfadc2e4285f0d0c9a95a300bc39629
parent 2e6886406ca2c3d4d31056d9f20eb925ff6abeec
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri,  3 Jul 2020 12:39:04 +0200

tweaks: elide a wrapper function, by checking a precondition earlier

Diffstat:
Msrc/global.c | 6+++---
Msrc/nano.c | 4++--
Msrc/prototypes.h | 1-
Msrc/rcfile.c | 2+-
Msrc/winio.c | 11-----------
5 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -789,7 +789,7 @@ void shortcut_init(void) #endif } - add_to_funcs(do_cursorpos_void, MMAIN, + add_to_funcs(report_cursor_position, MMAIN, N_("Location"), WITHORSANS(cursorpos_gist), TOGETHER, VIEW); #if defined(NANO_TINY) || defined(ENABLE_JUSTIFY) @@ -1179,7 +1179,7 @@ void shortcut_init(void) add_to_sclist(MMAIN, "M-F", 0, do_formatter, 0); add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0); #endif - add_to_sclist(MMAIN, "^C", 0, do_cursorpos_void, 0); + add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0); add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0); add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0); add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^Y", 0, do_page_up, 0); @@ -1458,7 +1458,7 @@ void shortcut_init(void) add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "F8", KEY_F(8), do_page_down, 0); add_to_sclist(MMOST, "F9", KEY_F(9), cut_text, 0); add_to_sclist(MMOST, "F10", KEY_F(10), paste_text, 0); - add_to_sclist(MMAIN, "F11", KEY_F(11), do_cursorpos_void, 0); + add_to_sclist(MMAIN, "F11", KEY_F(11), report_cursor_position, 0); #ifdef ENABLE_SPELLER add_to_sclist(MMAIN, "F12", KEY_F(12), do_spell, 0); #endif diff --git a/src/nano.c b/src/nano.c @@ -2482,8 +2482,8 @@ int main(int argc, char **argv) bottombars(MMAIN); /* Update the displayed current cursor position only when there - * are no keys waiting in the input buffer. */ - if (ISSET(CONSTANT_SHOW) && get_key_buffer_len() == 0) + * is no message and no keys are waiting in the input buffer. */ + if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && get_key_buffer_len() == 0) report_cursor_position(); lastmessage = VACUUM; diff --git a/src/prototypes.h b/src/prototypes.h @@ -635,7 +635,6 @@ void adjust_viewport(update_type manner); void full_refresh(void); void draw_all_subwindows(void); void report_cursor_position(void); -void do_cursorpos_void(void); void spotlight(size_t from_col, size_t to_col); #ifndef NANO_TINY void spotlight_softwrapped(size_t from_col, size_t to_col); diff --git a/src/rcfile.c b/src/rcfile.c @@ -280,7 +280,7 @@ keystruct *strtosc(const char *input) s->func = do_formatter; #endif else if (!strcmp(input, "curpos")) - s->func = do_cursorpos_void; + s->func = report_cursor_position; else if (!strcmp(input, "gotoline")) s->func = do_gotolinecolumn_void; #ifdef ENABLE_JUSTIFY diff --git a/src/winio.c b/src/winio.c @@ -3367,10 +3367,6 @@ void report_cursor_position(void) size_t cur_lenpt = breadth(openfile->current->data) + 1; int linepct, colpct, charpct; - /* If there is a message on the status bar, do not overwrite it. */ - if (lastmessage != VACUUM) - return; - /* Determine the size of the file up to the cursor. */ saved_byte = openfile->current->data[openfile->current_x]; openfile->current->data[openfile->current_x] = '\0'; @@ -3390,13 +3386,6 @@ void report_cursor_position(void) cur_xpt, cur_lenpt, colpct, sum, openfile->totsize, charpct); } -/* Unconditionally display the current cursor position. */ -void do_cursorpos_void(void) -{ - lastmessage = VACUUM; - report_cursor_position(); -} - void disable_waiting(void) { waiting_mode = FALSE;