browser: add the option showcursor, to place the cursor on the highlight

This lets users of braille displays find the selected item immediately.

This fulfills a request by Enrico Mioso.
See https://lists.gnu.org/archive/html/nano-devel/2016-09/msg00025.html.
master
Benno Schulenberg 2016-09-11 09:41:09 +02:00
parent 9eeb1c8fb8
commit b92d35d1f2
7 changed files with 31 additions and 5 deletions

View File

@ -200,6 +200,10 @@ won't work properly with this option enabled.
.B set regexp
Do extended regular expression searches by default.
.TP
.B set showcursor
Put the cursor on the highlighted item in the file browser, to aid
braille users.
.TP
.B set smarthome
Make the Home key smarter. When Home is pressed anywhere but at the
very beginning of non-whitespace characters on a line, the cursor will

View File

@ -138,6 +138,10 @@
## Do extended regular expression searches by default.
# set regexp
## Put the cursor on the highlighted item in the file browser;
## useful for people who use a braille display.
# set showcursor
## Make the Home key smarter. When Home is pressed anywhere but at the
## very beginning of non-whitespace characters on a line, the cursor
## will jump to that beginning (either forwards or backwards). If the

View File

@ -7,7 +7,7 @@ comment "#"
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|comment|magic|linter|i?color|extendsyntax).*$"
# Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>"
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|justifytrim|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>"
icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor|statuscolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace)[[:space:]]+"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"

View File

@ -782,6 +782,10 @@ won't work properly with this option enabled.
@item set regexp
Do extended regular expression searches by default.
@item set showcursor
Put the cursor on the highlighted item in the file browser, to aid
braille users.
@item set smarthome
Make the Home key smarter. When Home is pressed anywhere but at the
very beginning of non-whitespace characters on a line, the cursor will

View File

@ -502,6 +502,8 @@ void browser_refresh(void)
size_t i;
int line = 0, col = 0;
/* The current line and column while the list is getting displayed. */
int the_line = 0, the_column = 0;
/* The line and column of the selected item. */
char *info;
/* The additional information that we'll display about a file. */
@ -536,9 +538,13 @@ void browser_refresh(void)
* "(dir)", or the file size, plus three columns for the
* ellipsis. */
/* Start highlighting the currently selected file or directory. */
if (i == selected)
/* If this is the selected item, start its highlighting, and
* remember its location to be able to place the cursor on it. */
if (i == selected) {
wattron(edit, hilite_attribute);
the_line = line;
the_column = col;
}
blank_line(edit, line, col, longest);
@ -610,7 +616,7 @@ void browser_refresh(void)
mvwaddstr(edit, line, col - infolen, info);
/* Finish highlighting the currently selected file or directory. */
/* If this is the selected item, finish its highlighting. */
if (i == selected)
wattroff(edit, hilite_attribute);
@ -629,6 +635,12 @@ void browser_refresh(void)
wmove(edit, line, col);
}
/* If requested, put the cursor on the selected item and switch it on. */
if (ISSET(SHOW_CURSOR)) {
wmove(edit, the_line, the_column);
curs_set(1);
}
wnoutrefresh(edit);
}

View File

@ -535,7 +535,8 @@ enum
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
JUSTIFY_TRIM
JUSTIFY_TRIM,
SHOW_CURSOR
};
/* Flags for the menus in which a given function should be present. */

View File

@ -96,6 +96,7 @@ static const rcoption rcopts[] = {
{"noconvert", NO_CONVERT},
{"quickblank", QUICK_BLANK},
{"quiet", QUIET},
{"showcursor", SHOW_CURSOR},
{"smarthome", SMART_HOME},
{"smooth", SMOOTH_SCROLL},
{"softwrap", SOFTWRAP},