summaryrefslogtreecommitdiffstats
path: root/src/tui.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@fluxnic.net>2020-12-22 23:31:24 -0500
committerNicolas Pitre <nico@fluxnic.net>2021-03-18 16:43:26 -0400
commit62f3b6d1d9dc2a0cd9ad3b0e01521fa3c65fb232 (patch)
tree6d16b1e07bdf56d09386864dc6d8c6e6cd5e0d9a /src/tui.c
parent9ed39afd19a152d6a5f630e6619a50d3746469fc (diff)
move (invisible) cursor to the active grid cell
This is especially useful for blind people using braille displays. A braille display is a device with mechanical dots representing the content of the screen in braille with the aid of a software package such as BRLTTY. Those displays are made of a single line with a variable number of rows depending on the model, usually 40 or 80. This is effectively a 1x40 window view of the screen. By default, the braille window moves with the position of the screen cursor. It doesn't track attributes such as reverse color as this is too unreliable. Finding the actual active cell manually is a daunting task. This patch makes sc-im locate the cursor in the active cell when navigating around so the braille window can automatically be located on the active cell, or on the input field when active, or on the last status message, hugely improving the user experience.
Diffstat (limited to 'src/tui.c')
-rw-r--r--src/tui.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tui.c b/src/tui.c
index 25eafbb..6ae8d7c 100644
--- a/src/tui.c
+++ b/src/tui.c
@@ -104,6 +104,9 @@ WINDOW * input_win;
SCREEN * sstderr;
SCREEN * sstdout;
+int status_line_empty;
+int curwinrow, curwincol;
+
/**
* \brief Called to start UI
*
@@ -118,6 +121,7 @@ void ui_start_screen() {
main_win = newwin(LINES - RESROW, COLS, atoi(get_conf_value("input_bar_bottom")) ? 0 : RESROW, 0);
input_win = newwin(RESROW, COLS, atoi(get_conf_value("input_bar_bottom")) ? LINES-RESROW : 0, 0);
+ status_line_empty = 1;
#ifdef USECOLORS
if (has_colors()) {
@@ -247,6 +251,8 @@ void ui_sc_msg(char * s, int type, ...) {
#endif
mvwprintw(input_win, 1, 0, "%s", t);
wclrtoeol(input_win);
+ wmove(input_win, 1, 0);
+ status_line_empty = 0;
if (type == DEBUG_MSG || (loading && type == ERROR_MSG)) {
wtimeout(input_win, -1);
@@ -343,6 +349,12 @@ void ui_do_welcome() {
}
}
wrefresh(main_win);
+
+ /* land cursor next to the help line */
+ curwinrow = LINES/2;
+ curwincol = COLS/2-strlen(msg_help)/2-1;
+ status_line_empty = 1;
+
return;
}
@@ -376,6 +388,7 @@ void ui_update(int header) {
// comment this to prevent info message to be erased
//wmove(input_win, 0, 0);
//wclrtobot(input_win);
+ //status_line_empty = 1;
ui_show_celldetails(); // always before ui_print_mode
ui_print_mode();
}
@@ -419,6 +432,10 @@ void ui_update(int header) {
// Show sc_row headings: 0, 1, 2, 3..
ui_show_sc_row_headings(main_win, mxrow);
+ // Leave cursor on selected cell when no status message
+ if (status_line_empty)
+ wmove(main_win, curwinrow, curwincol);
+
// Refresh curses windows
wrefresh(main_win);
@@ -506,6 +523,12 @@ void ui_print_mult_pend() {
// Return cursor to previous position
wmove(input_win, row_orig, col_orig);
wrefresh(input_win);
+
+ if (status_line_empty && curmode != EDIT_MODE) {
+ // Leave cursor on selected cell when no status message
+ wmove(main_win, curwinrow, curwincol);
+ wrefresh(main_win);
+ }
}
/**
@@ -560,6 +583,8 @@ void ui_clr_header(int i) {
// Return cursor to previous position
wmove(input_win, row_orig, col_orig);
+ if (i == 1) status_line_empty = 1;
+
return;
}
@@ -1013,6 +1038,11 @@ void ui_show_content(WINDOW * win, int mxrow, int mxcol) {
wclrtoeol(win);
}
+ if (currow == row && curcol == col) {
+ curwinrow = row + 1 - offscr_sc_rows - q_row_hidden;
+ curwincol = c + ((align == 1) ? (fieldlen - 1) : 0);
+ }
+
// clean format
#ifndef USECOLORS
wattroff(win, A_REVERSE);
@@ -1262,6 +1292,7 @@ void ui_bail(lua_State *L, char * msg) {
set_term(sstderr);
move(0, 0);
clrtobot();
+ status_line_empty = 1;
clearok(stdscr, TRUE);
mvprintw(0, 0, "%s", stderr_buffer);
stderr_buffer[0]='\0';
@@ -1370,6 +1401,7 @@ char * ui_query(char * initial_msg) {
wclrtoeol(input_win);
wmove(input_win, 1,0);
wclrtoeol(input_win);
+ status_line_empty = 1;
wrefresh(input_win);
return hline;
}