startup: show the correct number of lines when opening multiple files
When switching to a different buffer, don't just show its name but also the number of lines it contains. This is useful extra info. Then use this same message when at startup multiple files are opened and (after reading them all) we switch back to the first buffer. (This loses, when multiple files are opened, the information about format conversion that nano still shows when a single file is opened, but... this bug has shown that people don't really look at this line anyway, so... let it be. The info can still be seen when writing out the file with ^O.) This addresses https://savannah.gnu.org/bugs/?54047.master
parent
ecc9211afc
commit
063a8b0870
17
src/files.c
17
src/files.c
|
@ -585,6 +585,17 @@ void prepare_for_display(void)
|
|||
}
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Show name of current buffer and its number of lines on the status bar. */
|
||||
void mention_name_and_linecount(void)
|
||||
{
|
||||
size_t count = openfile->filebot->lineno -
|
||||
(openfile->filebot->data[0] == '\0' ? 1 : 0);
|
||||
|
||||
statusline(HUSH, P_("%s -- %zu line", "%s -- %zu lines", count),
|
||||
openfile->filename[0] == '\0' ?
|
||||
_("New Buffer") : tail(openfile->filename), count);
|
||||
}
|
||||
|
||||
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
|
||||
* otherwise, to the previous one. */
|
||||
void switch_to_adjacent_buffer(bool to_next)
|
||||
|
@ -615,10 +626,8 @@ void switch_to_adjacent_buffer(bool to_next)
|
|||
/* Ensure that the main loop will redraw the help lines. */
|
||||
currmenu = MMOST;
|
||||
|
||||
/* Indicate the switch on the statusbar. */
|
||||
statusline(HUSH, _("Switched to %s"),
|
||||
((openfile->filename[0] == '\0') ?
|
||||
_("New Buffer") : openfile->filename));
|
||||
/* Indicate on the status bar where we switched to. */
|
||||
mention_name_and_linecount();
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(openfile->current);
|
||||
|
|
|
@ -2652,8 +2652,11 @@ int main(int argc, char **argv)
|
|||
UNSET(VIEW_MODE);
|
||||
}
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
else
|
||||
else {
|
||||
openfile = openfile->next;
|
||||
if (more_than_one)
|
||||
mention_name_and_linecount();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -273,6 +273,7 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
|
|||
#endif
|
||||
void prepare_for_display(void);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
void mention_name_and_linecount(void);
|
||||
void switch_to_prev_buffer(void);
|
||||
void switch_to_next_buffer(void);
|
||||
bool close_buffer(void);
|
||||
|
|
Loading…
Reference in New Issue