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
parent
dfbe3ce6dc
commit
0363703073
|
@ -357,7 +357,8 @@ enum {
|
||||||
BOOKSTYLE,
|
BOOKSTYLE,
|
||||||
STATEFLAGS,
|
STATEFLAGS,
|
||||||
USE_MAGIC,
|
USE_MAGIC,
|
||||||
MINIBAR
|
MINIBAR,
|
||||||
|
ZERO
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Structure types. */
|
/* Structure types. */
|
||||||
|
|
|
@ -819,7 +819,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||||
"Read %zu lines (Converted from DOS format)",
|
"Read %zu lines (Converted from DOS format)",
|
||||||
num_lines), num_lines);
|
num_lines), num_lines);
|
||||||
#endif
|
#endif
|
||||||
else
|
else if (!ISSET(ZERO))
|
||||||
statusline(HUSH, P_("Read %zu line", "Read %zu lines",
|
statusline(HUSH, P_("Read %zu line", "Read %zu lines",
|
||||||
num_lines), num_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));
|
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
} else
|
} else if (!ISSET(ZERO))
|
||||||
statusbar(_("Reading..."));
|
statusbar(_("Reading..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2025,7 +2025,7 @@ bool write_file(const char *name, FILE *thefile, bool normal,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(MINIBAR) && LINES > 1 && annotate)
|
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && annotate)
|
||||||
report_size = TRUE;
|
report_size = TRUE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1355,6 +1355,7 @@ void shortcut_init(void)
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* Group of "Appearance" toggles. */
|
/* 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((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-C", 0, do_toggle, CONSTANT_SHOW);
|
||||||
add_to_sclist(MMAIN, "M-S", 0, do_toggle, SOFTWRAP);
|
add_to_sclist(MMAIN, "M-S", 0, do_toggle, SOFTWRAP);
|
||||||
|
@ -1524,6 +1525,8 @@ const char *flagtostr(int flag)
|
||||||
return N_("Mouse support");
|
return N_("Mouse support");
|
||||||
case LINE_NUMBERS:
|
case LINE_NUMBERS:
|
||||||
return N_("Line numbering");
|
return N_("Line numbering");
|
||||||
|
case ZERO:
|
||||||
|
return N_("Hidden interface");
|
||||||
default:
|
default:
|
||||||
die("Bad toggle -- please report a bug\n");
|
die("Bad toggle -- please report a bug\n");
|
||||||
return "";
|
return "";
|
||||||
|
|
54
src/nano.c
54
src/nano.c
|
@ -414,26 +414,26 @@ void window_init(void)
|
||||||
|
|
||||||
/* If the terminal is very flat, don't set up a title bar. */
|
/* If the terminal is very flat, don't set up a title bar. */
|
||||||
if (LINES < 3) {
|
if (LINES < 3) {
|
||||||
editwinrows = 1;
|
editwinrows = (ISSET(ZERO) ? LINES : 1);
|
||||||
/* Set up two subwindows. If the terminal is just one line,
|
/* Set up two subwindows. If the terminal is just one line,
|
||||||
* edit window and status-bar window will cover each other. */
|
* 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);
|
bottomwin = newwin(1, COLS, LINES - 1, 0);
|
||||||
} else {
|
} else {
|
||||||
int toprows = ((ISSET(EMPTY_LINE) && LINES > 5) ? 2 : 1);
|
int toprows = ((ISSET(EMPTY_LINE) && LINES > 5) ? 2 : 1);
|
||||||
int bottomrows = ((ISSET(NO_HELP) || LINES < 5) ? 1 : 3);
|
int bottomrows = ((ISSET(NO_HELP) || LINES < 5) ? 1 : 3);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(MINIBAR))
|
if (ISSET(MINIBAR) || ISSET(ZERO))
|
||||||
toprows = 0;
|
toprows = 0;
|
||||||
#endif
|
#endif
|
||||||
editwinrows = LINES - toprows - bottomrows;
|
editwinrows = LINES - toprows - bottomrows + (ISSET(ZERO) ? 1 : 0);
|
||||||
|
|
||||||
/* Set up the normal three subwindows. */
|
/* Set up the normal three subwindows. */
|
||||||
if (toprows > 0)
|
if (toprows > 0)
|
||||||
topwin = newwin(toprows, COLS, 0, 0);
|
topwin = newwin(toprows, COLS, 0, 0);
|
||||||
edit = newwin(editwinrows, COLS, toprows, 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. */
|
/* 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("-y", "--afterends", N_("Make Ctrl+Right stop at word ends"));
|
||||||
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
|
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
|
||||||
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
|
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
|
||||||
|
print_opt("-0", "--zero", N_("Hide all bars, use whole terminal"));
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LIBMAGIC
|
#ifdef HAVE_LIBMAGIC
|
||||||
print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
|
print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
|
||||||
|
@ -1071,6 +1072,7 @@ void toggle_this(int flag)
|
||||||
|
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case NO_HELP:
|
case NO_HELP:
|
||||||
|
case ZERO:
|
||||||
window_init();
|
window_init();
|
||||||
draw_all_subwindows();
|
draw_all_subwindows();
|
||||||
break;
|
break;
|
||||||
|
@ -1096,7 +1098,10 @@ void toggle_this(int flag)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ISSET(STATEFLAGS) && (flag == AUTOINDENT ||
|
if (flag == ZERO)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ISSET(STATEFLAGS) && !ISSET(ZERO) && (flag == AUTOINDENT ||
|
||||||
flag == BREAK_LONG_LINES || flag == SOFTWRAP)) {
|
flag == BREAK_LONG_LINES || flag == SOFTWRAP)) {
|
||||||
if (ISSET(MINIBAR))
|
if (ISSET(MINIBAR))
|
||||||
return;
|
return;
|
||||||
|
@ -1104,12 +1109,16 @@ void toggle_this(int flag)
|
||||||
titlebar(NULL);
|
titlebar(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS))
|
if ((ISSET(MINIBAR) || ISSET(ZERO)) && (flag == NO_HELP || flag == LINE_NUMBERS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (flag == CONSTANT_SHOW)
|
if (flag == CONSTANT_SHOW) {
|
||||||
wipe_statusbar();
|
if (ISSET(ZERO)) {
|
||||||
else {
|
statusline(AHEM, _("Not possible in barless mode"));
|
||||||
|
TOGGLE(flag);
|
||||||
|
} else if (!ISSET(MINIBAR))
|
||||||
|
wipe_statusbar();
|
||||||
|
} else {
|
||||||
bool enabled = ISSET(flag);
|
bool enabled = ISSET(flag);
|
||||||
|
|
||||||
if (flag == NO_HELP || flag == NO_SYNTAX)
|
if (flag == NO_HELP || flag == NO_SYNTAX)
|
||||||
|
@ -1760,6 +1769,7 @@ int main(int argc, char **argv)
|
||||||
{"afterends", 0, NULL, 'y'},
|
{"afterends", 0, NULL, 'y'},
|
||||||
{"stateflags", 0, NULL, '%'},
|
{"stateflags", 0, NULL, '%'},
|
||||||
{"minibar", 0, NULL, '_'},
|
{"minibar", 0, NULL, '_'},
|
||||||
|
{"zero", 0, NULL, '0'},
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LIBMAGIC
|
#ifdef HAVE_LIBMAGIC
|
||||||
{"magic", 0, NULL, '!'},
|
{"magic", 0, NULL, '!'},
|
||||||
|
@ -1803,7 +1813,7 @@ int main(int argc, char **argv)
|
||||||
if (*(tail(argv[0])) == 'r')
|
if (*(tail(argv[0])) == 'r')
|
||||||
SET(RESTRICTED);
|
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) {
|
"abcdef:ghijklmno:pqr:s:tuvwxyz$%_!", long_options, NULL)) != -1) {
|
||||||
switch (optchr) {
|
switch (optchr) {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
@ -2046,6 +2056,9 @@ int main(int argc, char **argv)
|
||||||
case '_':
|
case '_':
|
||||||
SET(MINIBAR);
|
SET(MINIBAR);
|
||||||
break;
|
break;
|
||||||
|
case '0':
|
||||||
|
SET(ZERO);
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LIBMAGIC
|
#ifdef HAVE_LIBMAGIC
|
||||||
case '!':
|
case '!':
|
||||||
|
@ -2514,25 +2527,30 @@ int main(int argc, char **argv)
|
||||||
bottombars(MMAIN);
|
bottombars(MMAIN);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(MINIBAR) && LINES > 1 && lastmessage < REMARK)
|
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && lastmessage < REMARK)
|
||||||
minibar();
|
minibar();
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
/* Update the displayed current cursor position only when there
|
/* Update the displayed current cursor position only when there
|
||||||
* is no message and no keys are waiting in the input buffer. */
|
* is no message and no keys are waiting in the input buffer. */
|
||||||
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && LINES > 1 &&
|
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && LINES > 1 &&
|
||||||
get_key_buffer_len() == 0)
|
!ISSET(ZERO) && get_key_buffer_len() == 0)
|
||||||
report_cursor_position();
|
report_cursor_position();
|
||||||
|
|
||||||
as_an_at = TRUE;
|
as_an_at = TRUE;
|
||||||
|
|
||||||
/* Refresh just the cursor position or the entire edit window. */
|
if (refresh_needed && (LINES > 1 || lastmessage == VACUUM))
|
||||||
if (!refresh_needed) {
|
|
||||||
place_the_cursor();
|
|
||||||
wnoutrefresh(edit);
|
|
||||||
} else if (LINES > 1 || lastmessage == VACUUM)
|
|
||||||
edit_refresh();
|
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;
|
errno = 0;
|
||||||
focusing = TRUE;
|
focusing = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ static const rcoption rcopts[] = {
|
||||||
{"wordbounds", WORD_BOUNDS},
|
{"wordbounds", WORD_BOUNDS},
|
||||||
{"wordchars", 0},
|
{"wordchars", 0},
|
||||||
{"zap", LET_THEM_ZAP},
|
{"zap", LET_THEM_ZAP},
|
||||||
|
{"zero", ZERO},
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
{"titlecolor", 0},
|
{"titlecolor", 0},
|
||||||
|
@ -451,6 +452,8 @@ keystruct *strtosc(const char *input)
|
||||||
s->func = do_toggle;
|
s->func = do_toggle;
|
||||||
if (!strcmp(input, "nohelp"))
|
if (!strcmp(input, "nohelp"))
|
||||||
s->toggle = NO_HELP;
|
s->toggle = NO_HELP;
|
||||||
|
else if (!strcmp(input, "zero"))
|
||||||
|
s->toggle = ZERO;
|
||||||
else if (!strcmp(input, "constantshow"))
|
else if (!strcmp(input, "constantshow"))
|
||||||
s->toggle = CONSTANT_SHOW;
|
s->toggle = CONSTANT_SHOW;
|
||||||
else if (!strcmp(input, "softwrap"))
|
else if (!strcmp(input, "softwrap"))
|
||||||
|
|
13
src/winio.c
13
src/winio.c
|
@ -192,6 +192,9 @@ void read_keys_from(WINDOW *win)
|
||||||
if (reveal_cursor && !hide_cursor && (LINES > 1 || lastmessage <= HUSH))
|
if (reveal_cursor && !hide_cursor && (LINES > 1 || lastmessage <= HUSH))
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
|
||||||
|
if (ISSET(ZERO) && openfile->current_y == editwinrows - 1 && lastmessage > HUSH)
|
||||||
|
curs_set(0);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (currmenu == MMAIN && (spotlighted || ((ISSET(MINIBAR) || LINES == 1) &&
|
if (currmenu == MMAIN && (spotlighted || ((ISSET(MINIBAR) || LINES == 1) &&
|
||||||
lastmessage > HUSH &&
|
lastmessage > HUSH &&
|
||||||
|
@ -224,7 +227,7 @@ void read_keys_from(WINDOW *win)
|
||||||
wnoutrefresh(edit);
|
wnoutrefresh(edit);
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
}
|
}
|
||||||
if (ISSET(MINIBAR) && LINES > 1)
|
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1)
|
||||||
minibar();
|
minibar();
|
||||||
as_an_at = TRUE;
|
as_an_at = TRUE;
|
||||||
place_the_cursor();
|
place_the_cursor();
|
||||||
|
@ -1706,7 +1709,7 @@ void check_statusblank(void)
|
||||||
wipe_statusbar();
|
wipe_statusbar();
|
||||||
|
|
||||||
/* If the subwindows overlap, make sure to show the edit window now. */
|
/* If the subwindows overlap, make sure to show the edit window now. */
|
||||||
if (LINES == 1)
|
if (currmenu == MMAIN && (ISSET(ZERO) || LINES == 1))
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3328,6 +3331,8 @@ bool current_is_above_screen(void)
|
||||||
return (openfile->current->lineno < openfile->edittop->lineno);
|
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. */
|
/* Return TRUE if current[current_x] is beyond the viewport. */
|
||||||
bool current_is_below_screen(void)
|
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
|
/* If current[current_x] is more than a screen's worth of lines after
|
||||||
* edittop at column firstcolumn, it's below the screen. */
|
* 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 ||
|
||||||
(line->lineno == openfile->current->lineno &&
|
(line->lineno == openfile->current->lineno &&
|
||||||
leftedge < leftedge_for(xplustabs(), openfile->current))));
|
leftedge < leftedge_for(xplustabs(), openfile->current))));
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
return (openfile->current->lineno >=
|
return (openfile->current->lineno >=
|
||||||
openfile->edittop->lineno + editwinrows);
|
openfile->edittop->lineno + editwinrows - SHIM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return TRUE if current[current_x] is outside the viewport. */
|
/* Return TRUE if current[current_x] is outside the viewport. */
|
||||||
|
|
Loading…
Reference in New Issue