summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés <andmarti@gmail.com>2021-04-22 10:31:33 -0300
committerAndrés <andmarti@gmail.com>2021-04-22 10:31:33 -0300
commitc3fda0e70c7e8e5ab8d7a63f43a2b509c9cb11c1 (patch)
treea437386ec1e99fcbc68f97a60b1bd6f4eaaa9735
parent31aca3049255d015e0703e05a43929dca29e8f5d (diff)
tui: fix after refresh of input pad
-rw-r--r--src/cmds_command.c4
-rw-r--r--src/cmds_edit.c4
-rw-r--r--src/cmds_insert.c6
-rw-r--r--src/cmds_normal.c2
-rw-r--r--src/tui.c35
5 files changed, 27 insertions, 24 deletions
diff --git a/src/cmds_command.c b/src/cmds_command.c
index c6bf0b7..8dba28c 100644
--- a/src/cmds_command.c
+++ b/src/cmds_command.c
@@ -210,8 +210,8 @@ void do_commandmode(struct block * sb) {
real_inputline_pos--;
int l = wcwidth(inputline[real_inputline_pos]);
inputline_pos -= l;
- ui_show_header();
}
+ ui_show_header();
return;
} else if (sb->value == OKEY_RIGHT) { // RIGHT
@@ -219,8 +219,8 @@ void do_commandmode(struct block * sb) {
if (inputline_pos < max) {
int l = wcwidth(inputline[real_inputline_pos++]);
inputline_pos += l;
- ui_show_header();
}
+ ui_show_header();
return;
} else if (sb->value == OKEY_DEL) { // DEL
diff --git a/src/cmds_edit.c b/src/cmds_edit.c
index 9b857cd..b9a25ca 100644
--- a/src/cmds_edit.c
+++ b/src/cmds_edit.c
@@ -81,16 +81,16 @@ void do_editmode(struct block * sb) {
if (real_inputline_pos) {
real_inputline_pos--;
inputline_pos = wcswidth(inputline, real_inputline_pos);
- ui_show_header();
}
+ ui_show_header();
return;
} else if (sb->value == L'l' || sb->value == OKEY_RIGHT) { // RIGHT
if (real_inputline_pos < wcslen(inputline)-1) {
real_inputline_pos++;
inputline_pos = wcswidth(inputline, real_inputline_pos);
- ui_show_header();
}
+ ui_show_header();
return;
} else if (sb->value == L' ' && ( wcslen(inputline) < (COLS - 14) ) ) { // SPACE
diff --git a/src/cmds_insert.c b/src/cmds_insert.c
index 86f227c..0a0151e 100644
--- a/src/cmds_insert.c
+++ b/src/cmds_insert.c
@@ -83,16 +83,18 @@ void do_insertmode(struct block * sb) {
real_inputline_pos--;
int l = wcwidth(inputline[real_inputline_pos]);
inputline_pos -= l;
- ui_show_header();
}
+ ui_show_header();
+ return;
} else if (sb->value == OKEY_RIGHT) { // RIGHT
int max = wcswidth(inputline, wcslen(inputline));
if (inputline_pos < max) {
int l = wcwidth(inputline[real_inputline_pos++]);
inputline_pos += l;
- ui_show_header();
}
+ ui_show_header();
+ return;
#ifdef INS_HISTORY_FILE
} else if (sb->value == OKEY_UP || sb->value == ctl('p') || // UP
diff --git a/src/cmds_normal.c b/src/cmds_normal.c
index 1548dcb..d16789d 100644
--- a/src/cmds_normal.c
+++ b/src/cmds_normal.c
@@ -509,7 +509,6 @@ void do_normalmode(struct block * buf) {
// edit cell (v)
case L'e':
if (locked_cell(currow, curcol)) return;
- //ui_clr_header(0);
inputline_pos = 0;
real_inputline_pos = 0;
if (start_edit_mode(buf, 'v')) ui_show_header();
@@ -518,7 +517,6 @@ void do_normalmode(struct block * buf) {
// edit cell (s)
case L'E':
if (locked_cell(currow, curcol)) return;
- //ui_clr_header(0);
inputline_pos = 0;
real_inputline_pos = 0;
if (start_edit_mode(buf, 's')) ui_show_header();
diff --git a/src/tui.c b/src/tui.c
index e47b3d5..58d8452 100644
--- a/src/tui.c
+++ b/src/tui.c
@@ -574,7 +574,7 @@ void ui_show_header() {
wmove(input_pad, 0, inputline_pos + 1);
break;
case EDIT_MODE:
- mvwprintw(input_pad, 0, 0, " %ls", inputline);
+ mvwprintw(input_pad, 0, 1, "%ls", inputline);
wmove(input_pad, 0, inputline_pos + 1);
}
int scroll = 0;
@@ -593,20 +593,21 @@ void ui_show_header() {
*/
void ui_clr_header(int i) {
int row_orig, col_orig;
- getyx(input_pad, row_orig, col_orig);
+ getyx(i == 0 ? input_win : input_pad, row_orig, col_orig);
if (col_orig > COLS) col_orig = COLS - 1;
if (i == 0) {
wmove(input_win, 0, 0);
wclrtoeol(input_win);
} else {
+ getyx(input_pad, row_orig, col_orig);
wmove(input_pad, 0, 0);
wclrtoeol(input_pad);
status_line_empty = 1;
}
// Return cursor to previous position
- if (get_conf_int("show_cursor")) wmove(input_pad, row_orig, col_orig);
- ui_refresh_pad(0);
+ wmove(i == 0 ? input_win : input_pad, row_orig, col_orig);
+ if (! i) ui_refresh_pad(0);
}
@@ -649,6 +650,8 @@ void ui_print_mode() {
} else if (curmode == EDIT_MODE) {
strcat(strm, " -- EDIT --");
ui_write_j(input_win, strm, row, RIGHT);
+ // Show ^ in 0,0 position of pad
+ mvwprintw(input_pad, 0, 0, "^");
} else if (curmode == VISUAL_MODE) {
strcat(strm, " -- VISUAL --");
@@ -1097,7 +1100,7 @@ void ui_add_cell_detail(char * d, struct ent * p1) {
*/
void ui_show_celldetails() {
char head[FBUFLEN];
- int inputline_pos = 0;
+ int il_pos = 0;
// show cell in header
#ifdef USECOLORS
@@ -1105,7 +1108,7 @@ void ui_show_celldetails() {
#endif
sprintf(head, "%s%d ", coltoa(curcol), currow);
mvwprintw(input_win, 0, 0, "%s", head);
- inputline_pos += strlen(head);
+ il_pos += strlen(head);
// show the current cell's format
#ifdef USECOLORS
@@ -1125,8 +1128,8 @@ void ui_show_celldetails() {
sprintf(head + strlen(head), "(%s) ", p1->format);
else
sprintf(head + strlen(head), "(%d %d %d) ", fwidth[curcol], precision[curcol], realfmt[curcol]);
- mvwprintw(input_win, 0, inputline_pos, "%s", head);
- inputline_pos += strlen(head);
+ mvwprintw(input_win, 0, il_pos, "%s", head);
+ il_pos += strlen(head);
// show expr
#ifdef USECOLORS
@@ -1137,22 +1140,22 @@ void ui_show_celldetails() {
editexp(currow, curcol); /* set line to expr */
linelim = -1;
sprintf(head, "[%.*s] ", FBUFLEN-4, line);
- mvwprintw(input_win, 0, inputline_pos, "%s", head);
- inputline_pos += strlen(head);
+ mvwprintw(input_win, 0, il_pos, "%s", head);
+ il_pos += strlen(head);
}
// add cell content to head string
head[0] = '\0';
ui_add_cell_detail(head, p1);
// cut string if its too large!
- if (strlen(head) > COLS - inputline_pos - 1) {
- head[COLS - inputline_pos - 1 - 15]='>';
- head[COLS - inputline_pos - 1 - 14]='>';
- head[COLS - inputline_pos - 1 - 13]='>';
- head[COLS - inputline_pos - 1 - 12]='\0';
+ if (strlen(head) > COLS - il_pos - 1) {
+ head[COLS - il_pos - 1 - 15]='>';
+ head[COLS - il_pos - 1 - 14]='>';
+ head[COLS - il_pos - 1 - 13]='>';
+ head[COLS - il_pos - 1 - 12]='\0';
}
- mvwprintw(input_win, 0, inputline_pos, "%s", head);
+ mvwprintw(input_win, 0, il_pos, "%s", head);
wclrtoeol(input_win);
wrefresh(input_win);
}