mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-07 01:52:19 +03:00
tweaks: elide an unneeded global variable
The constant cursor display must be suppressed whenever a message was printed to the status bar. That is: whenever 'lastmessage' is something other than 'VACUUM'.
This commit is contained in:
parent
80ff5e76d6
commit
2e6886406c
@ -70,9 +70,6 @@ bool as_an_at = TRUE;
|
||||
bool control_C_was_pressed = FALSE;
|
||||
/* Whether Ctrl+C was pressed (when a keyboard interrupt is enabled). */
|
||||
|
||||
bool suppress_cursorpos = FALSE;
|
||||
/* Should we skip constant position display for current keystroke? */
|
||||
|
||||
message_type lastmessage = HUSH;
|
||||
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
|
||||
|
||||
|
@ -178,7 +178,7 @@ void show_help(void)
|
||||
edit_refresh();
|
||||
|
||||
while (TRUE) {
|
||||
lastmessage = HUSH;
|
||||
lastmessage = VACUUM;
|
||||
focusing = TRUE;
|
||||
|
||||
/* Show the cursor when we searched and found something. */
|
||||
|
10
src/nano.c
10
src/nano.c
@ -944,7 +944,7 @@ RETSIGTYPE do_suspend(int signal)
|
||||
fflush(stdout);
|
||||
|
||||
/* The suspend keystroke must not elicit cursor-position display. */
|
||||
suppress_cursorpos=TRUE;
|
||||
lastmessage = HUSH;
|
||||
|
||||
#ifdef SIGSTOP
|
||||
/* Do what mutt does: send ourselves a SIGSTOP. */
|
||||
@ -2481,13 +2481,13 @@ int main(int argc, char **argv)
|
||||
if (currmenu != MMAIN)
|
||||
bottombars(MMAIN);
|
||||
|
||||
lastmessage = VACUUM;
|
||||
as_an_at = TRUE;
|
||||
|
||||
/* 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)
|
||||
do_cursorpos(FALSE);
|
||||
report_cursor_position();
|
||||
|
||||
lastmessage = VACUUM;
|
||||
as_an_at = TRUE;
|
||||
|
||||
/* Refresh just the cursor position or the entire edit window. */
|
||||
if (!refresh_needed) {
|
||||
|
@ -48,8 +48,6 @@ extern bool as_an_at;
|
||||
|
||||
extern bool control_C_was_pressed;
|
||||
|
||||
extern bool suppress_cursorpos;
|
||||
|
||||
extern message_type lastmessage;
|
||||
|
||||
extern linestruct *pletion_line;
|
||||
@ -636,7 +634,7 @@ void edit_refresh(void);
|
||||
void adjust_viewport(update_type manner);
|
||||
void full_refresh(void);
|
||||
void draw_all_subwindows(void);
|
||||
void do_cursorpos(bool force);
|
||||
void report_cursor_position(void);
|
||||
void do_cursorpos_void(void);
|
||||
void spotlight(size_t from_col, size_t to_col);
|
||||
#ifndef NANO_TINY
|
||||
|
@ -307,10 +307,10 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
if (match_len != NULL)
|
||||
*match_len = found_len;
|
||||
|
||||
/* Wipe the "Searching..." message and unset the suppression flag. */
|
||||
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
|
||||
if (feedback > 0) {
|
||||
wipe_statusbar();
|
||||
suppress_cursorpos = FALSE;
|
||||
lastmessage = VACUUM;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -3018,7 +3018,7 @@ void do_verbatim_input(void)
|
||||
|
||||
/* Unsuppress cursor-position display or blank the status bar. */
|
||||
if (ISSET(CONSTANT_SHOW))
|
||||
suppress_cursorpos = FALSE;
|
||||
lastmessage = VACUUM;
|
||||
else
|
||||
wipe_statusbar();
|
||||
|
||||
|
25
src/winio.c
25
src/winio.c
@ -2117,9 +2117,8 @@ void titlebar(const char *path)
|
||||
wrefresh(topwin);
|
||||
}
|
||||
|
||||
/* Display a message on the status bar, and set suppress_cursorpos to
|
||||
* TRUE, so that the message won't be immediately overwritten if
|
||||
* constant cursor position display is on. */
|
||||
/* Display the given message on the status bar, but only if its importance
|
||||
* is higher than that of a message that is already there. */
|
||||
void statusline(message_type importance, const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@ -2203,8 +2202,6 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
/* Push the message to the screen straightaway. */
|
||||
wrefresh(bottomwin);
|
||||
|
||||
suppress_cursorpos = TRUE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (old_whitespace)
|
||||
SET(WHITESPACE_DISPLAY);
|
||||
@ -3362,21 +3359,17 @@ void draw_all_subwindows(void)
|
||||
bottombars(currmenu);
|
||||
}
|
||||
|
||||
/* Show info about the current cursor position on the status bar.
|
||||
* Do this unconditionally when force is TRUE; otherwise, only if
|
||||
* suppress_cursorpos is FALSE. In any case, reset the latter. */
|
||||
void do_cursorpos(bool force)
|
||||
/* Display details about the current cursor position on the status bar. */
|
||||
void report_cursor_position(void)
|
||||
{
|
||||
char saved_byte;
|
||||
size_t sum, cur_xpt = xplustabs() + 1;
|
||||
size_t cur_lenpt = breadth(openfile->current->data) + 1;
|
||||
int linepct, colpct, charpct;
|
||||
|
||||
/* If the showing needs to be suppressed, don't suppress it next time. */
|
||||
if (suppress_cursorpos && !force) {
|
||||
suppress_cursorpos = FALSE;
|
||||
/* 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];
|
||||
@ -3395,15 +3388,13 @@ void do_cursorpos(bool force)
|
||||
_("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char %zu/%zu (%d%%)"),
|
||||
openfile->current->lineno, openfile->filebot->lineno, linepct,
|
||||
cur_xpt, cur_lenpt, colpct, sum, openfile->totsize, charpct);
|
||||
|
||||
/* Displaying the cursor position should not suppress it next time. */
|
||||
suppress_cursorpos = FALSE;
|
||||
}
|
||||
|
||||
/* Unconditionally display the current cursor position. */
|
||||
void do_cursorpos_void(void)
|
||||
{
|
||||
do_cursorpos(TRUE);
|
||||
lastmessage = VACUUM;
|
||||
report_cursor_position();
|
||||
}
|
||||
|
||||
void disable_waiting(void)
|
||||
|
Loading…
Reference in New Issue
Block a user