new feature: option --zero for an interface without bars

With --zero or 'set zero', nano will hide the title bar or the minibar
(whichever is active) and will use all rows of the terminal for showing
the text of the buffer.  Only when there is an important message will
it be shown on the bottom row -- until the next keystroke.

This feature can be toggled with M-Z.

The feedback at startup ("Read nnn lines") is suppressed with --zero,
because it disrupts the fullscreen experience (and is hardly useful).
The "Reading..." message then needs to be suppressed too, otherwise
it creates an annoying little flash.

There are still some issues that need to be addressed:

* In the browser, when the highlighted item is on the bottom row, it
  will get obscured by the prompt bar or the "Search Wrapped" message.

* In the edit window, when the search occurrence is on the bottom row,
  it can get obscured by the "This is the only occurrence" message.

* When tabbing at a prompt shows possible completions, they are shown
  a row too low.
master
Benno Schulenberg 2021-10-28 12:51:29 +02:00
parent dfbe3ce6dc
commit 0363703073
6 changed files with 56 additions and 26 deletions

View File

@ -357,7 +357,8 @@ enum {
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC,
MINIBAR
MINIBAR,
ZERO
};
/* Structure types. */

View File

@ -819,7 +819,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
"Read %zu lines (Converted from DOS format)",
num_lines), num_lines);
#endif
else
else if (!ISSET(ZERO))
statusline(HUSH, P_("Read %zu line", "Read %zu lines",
num_lines), num_lines);
@ -898,7 +898,7 @@ int open_file(const char *filename, bool new_one, FILE **f)
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
close(fd);
fd = -1;
} else
} else if (!ISSET(ZERO))
statusbar(_("Reading..."));
}
@ -2025,7 +2025,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
}
#ifndef NANO_TINY
if (ISSET(MINIBAR) && LINES > 1 && annotate)
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && annotate)
report_size = TRUE;
else
#endif

View File

@ -1355,6 +1355,7 @@ void shortcut_init(void)
#ifndef NANO_TINY
/* Group of "Appearance" toggles. */
add_to_sclist(MMAIN, "M-Z", 0, do_toggle, ZERO);
add_to_sclist((MMOST|MBROWSER|MYESNO) & ~MFINDINHELP, "M-X", 0, do_toggle, NO_HELP);
add_to_sclist(MMAIN, "M-C", 0, do_toggle, CONSTANT_SHOW);
add_to_sclist(MMAIN, "M-S", 0, do_toggle, SOFTWRAP);
@ -1524,6 +1525,8 @@ const char *flagtostr(int flag)
return N_("Mouse support");
case LINE_NUMBERS:
return N_("Line numbering");
case ZERO:
return N_("Hidden interface");
default:
die("Bad toggle -- please report a bug\n");
return "";

View File

@ -414,26 +414,26 @@ void window_init(void)
/* If the terminal is very flat, don't set up a title bar. */
if (LINES < 3) {
editwinrows = 1;
editwinrows = (ISSET(ZERO) ? LINES : 1);
/* Set up two subwindows. If the terminal is just one line,
* edit window and status-bar window will cover each other. */
edit = newwin(1, COLS, 0, 0);
edit = newwin(editwinrows, COLS, 0, 0);
bottomwin = newwin(1, COLS, LINES - 1, 0);
} else {
int toprows = ((ISSET(EMPTY_LINE) && LINES > 5) ? 2 : 1);
int bottomrows = ((ISSET(NO_HELP) || LINES < 5) ? 1 : 3);
#ifndef NANO_TINY
if (ISSET(MINIBAR))
if (ISSET(MINIBAR) || ISSET(ZERO))
toprows = 0;
#endif
editwinrows = LINES - toprows - bottomrows;
editwinrows = LINES - toprows - bottomrows + (ISSET(ZERO) ? 1 : 0);
/* Set up the normal three subwindows. */
if (toprows > 0)
topwin = newwin(toprows, COLS, 0, 0);
edit = newwin(editwinrows, COLS, toprows, 0);
bottomwin = newwin(bottomrows, COLS, toprows + editwinrows, 0);
bottomwin = newwin(bottomrows, COLS, LINES - bottomrows, 0);
}
/* In case the terminal shrunk, make sure the status line is clear. */
@ -653,6 +653,7 @@ void usage(void)
print_opt("-y", "--afterends", N_("Make Ctrl+Right stop at word ends"));
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
print_opt("-0", "--zero", N_("Hide all bars, use whole terminal"));
#endif
#ifdef HAVE_LIBMAGIC
print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
@ -1071,6 +1072,7 @@ void toggle_this(int flag)
switch (flag) {
case NO_HELP:
case ZERO:
window_init();
draw_all_subwindows();
break;
@ -1096,7 +1098,10 @@ void toggle_this(int flag)
#endif
}
if (ISSET(STATEFLAGS) && (flag == AUTOINDENT ||
if (flag == ZERO)
return;
if (ISSET(STATEFLAGS) && !ISSET(ZERO) && (flag == AUTOINDENT ||
flag == BREAK_LONG_LINES || flag == SOFTWRAP)) {
if (ISSET(MINIBAR))
return;
@ -1104,12 +1109,16 @@ void toggle_this(int flag)
titlebar(NULL);
}
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS))
if ((ISSET(MINIBAR) || ISSET(ZERO)) && (flag == NO_HELP || flag == LINE_NUMBERS))
return;
if (flag == CONSTANT_SHOW)
wipe_statusbar();
else {
if (flag == CONSTANT_SHOW) {
if (ISSET(ZERO)) {
statusline(AHEM, _("Not possible in barless mode"));
TOGGLE(flag);
} else if (!ISSET(MINIBAR))
wipe_statusbar();
} else {
bool enabled = ISSET(flag);
if (flag == NO_HELP || flag == NO_SYNTAX)
@ -1760,6 +1769,7 @@ int main(int argc, char **argv)
{"afterends", 0, NULL, 'y'},
{"stateflags", 0, NULL, '%'},
{"minibar", 0, NULL, '_'},
{"zero", 0, NULL, '0'},
#endif
#ifdef HAVE_LIBMAGIC
{"magic", 0, NULL, '!'},
@ -1803,7 +1813,7 @@ int main(int argc, char **argv)
if (*(tail(argv[0])) == 'r')
SET(RESTRICTED);
while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
while ((optchr = getopt_long(argc, argv, "0ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
"abcdef:ghijklmno:pqr:s:tuvwxyz$%_!", long_options, NULL)) != -1) {
switch (optchr) {
#ifndef NANO_TINY
@ -2046,6 +2056,9 @@ int main(int argc, char **argv)
case '_':
SET(MINIBAR);
break;
case '0':
SET(ZERO);
break;
#endif
#ifdef HAVE_LIBMAGIC
case '!':
@ -2514,25 +2527,30 @@ int main(int argc, char **argv)
bottombars(MMAIN);
#ifndef NANO_TINY
if (ISSET(MINIBAR) && LINES > 1 && lastmessage < REMARK)
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && lastmessage < REMARK)
minibar();
else
#endif
/* Update the displayed current cursor position only when there
* is no message and no keys are waiting in the input buffer. */
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && LINES > 1 &&
get_key_buffer_len() == 0)
!ISSET(ZERO) && get_key_buffer_len() == 0)
report_cursor_position();
as_an_at = TRUE;
/* Refresh just the cursor position or the entire edit window. */
if (!refresh_needed) {
place_the_cursor();
wnoutrefresh(edit);
} else if (LINES > 1 || lastmessage == VACUUM)
if (refresh_needed && (LINES > 1 || lastmessage == VACUUM))
edit_refresh();
/* When there are no bars, redraw a relevant status message. */
if (ISSET(ZERO) && lastmessage > HUSH) {
redrawwin(bottomwin);
wnoutrefresh(bottomwin);
}
place_the_cursor();
wnoutrefresh(edit);
errno = 0;
focusing = TRUE;

View File

@ -122,6 +122,7 @@ static const rcoption rcopts[] = {
{"wordbounds", WORD_BOUNDS},
{"wordchars", 0},
{"zap", LET_THEM_ZAP},
{"zero", ZERO},
#endif
#ifdef ENABLE_COLOR
{"titlecolor", 0},
@ -451,6 +452,8 @@ keystruct *strtosc(const char *input)
s->func = do_toggle;
if (!strcmp(input, "nohelp"))
s->toggle = NO_HELP;
else if (!strcmp(input, "zero"))
s->toggle = ZERO;
else if (!strcmp(input, "constantshow"))
s->toggle = CONSTANT_SHOW;
else if (!strcmp(input, "softwrap"))

View File

@ -192,6 +192,9 @@ void read_keys_from(WINDOW *win)
if (reveal_cursor && !hide_cursor && (LINES > 1 || lastmessage <= HUSH))
curs_set(1);
if (ISSET(ZERO) && openfile->current_y == editwinrows - 1 && lastmessage > HUSH)
curs_set(0);
#ifndef NANO_TINY
if (currmenu == MMAIN && (spotlighted || ((ISSET(MINIBAR) || LINES == 1) &&
lastmessage > HUSH &&
@ -224,7 +227,7 @@ void read_keys_from(WINDOW *win)
wnoutrefresh(edit);
curs_set(1);
}
if (ISSET(MINIBAR) && LINES > 1)
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1)
minibar();
as_an_at = TRUE;
place_the_cursor();
@ -1706,7 +1709,7 @@ void check_statusblank(void)
wipe_statusbar();
/* If the subwindows overlap, make sure to show the edit window now. */
if (LINES == 1)
if (currmenu == MMAIN && (ISSET(ZERO) || LINES == 1))
edit_refresh();
}
@ -3328,6 +3331,8 @@ bool current_is_above_screen(void)
return (openfile->current->lineno < openfile->edittop->lineno);
}
#define SHIM (ISSET(ZERO) && (currmenu == MREPLACEWITH || currmenu == MYESNO) ? 1 : 0)
/* Return TRUE if current[current_x] is beyond the viewport. */
bool current_is_below_screen(void)
{
@ -3338,14 +3343,14 @@ bool current_is_below_screen(void)
/* If current[current_x] is more than a screen's worth of lines after
* edittop at column firstcolumn, it's below the screen. */
return (go_forward_chunks(editwinrows - 1, &line, &leftedge) == 0 &&
return (go_forward_chunks(editwinrows - 1 - SHIM, &line, &leftedge) == 0 &&
(line->lineno < openfile->current->lineno ||
(line->lineno == openfile->current->lineno &&
leftedge < leftedge_for(xplustabs(), openfile->current))));
} else
#endif
return (openfile->current->lineno >=
openfile->edittop->lineno + editwinrows);
openfile->edittop->lineno + editwinrows - SHIM);
}
/* Return TRUE if current[current_x] is outside the viewport. */