prompt: properly save and restore the x position in the statusbar
This fixes https://savannah.gnu.org/bugs/?47720.master
parent
6f185d3022
commit
34a20f8839
|
@ -2641,6 +2641,9 @@ int main(int argc, char **argv)
|
||||||
if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
|
if (ISSET(CONST_UPDATE) && get_key_buffer_len() == 0)
|
||||||
do_cursorpos(TRUE);
|
do_cursorpos(TRUE);
|
||||||
|
|
||||||
|
/* Forget any earlier statusbar x position. */
|
||||||
|
reinit_statusbar_x();
|
||||||
|
|
||||||
/* Place the cursor in the edit window and make it visible. */
|
/* Place the cursor in the edit window and make it visible. */
|
||||||
reset_cursor();
|
reset_cursor();
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
|
31
src/prompt.c
31
src/prompt.c
|
@ -32,10 +32,6 @@ static size_t statusbar_x = (size_t)-1;
|
||||||
/* The cursor position in answer. */
|
/* The cursor position in answer. */
|
||||||
static size_t statusbar_pww = (size_t)-1;
|
static size_t statusbar_pww = (size_t)-1;
|
||||||
/* The place we want in answer. */
|
/* The place we want in answer. */
|
||||||
static size_t old_statusbar_x = (size_t)-1;
|
|
||||||
/* The old cursor position in answer, if any. */
|
|
||||||
static size_t old_pww = (size_t)-1;
|
|
||||||
/* The old place we want in answer, if any. */
|
|
||||||
|
|
||||||
/* Read in a character, interpret it as a shortcut or toggle if
|
/* Read in a character, interpret it as a shortcut or toggle if
|
||||||
* necessary, and return it.
|
* necessary, and return it.
|
||||||
|
@ -466,6 +462,13 @@ size_t get_statusbar_page_start(size_t start_col, size_t column)
|
||||||
start_col - 1);
|
start_col - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reinitialize the cursor position in the status bar prompt. */
|
||||||
|
void reinit_statusbar_x(void)
|
||||||
|
{
|
||||||
|
statusbar_x = (size_t)-1;
|
||||||
|
statusbar_pww = (size_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Put the cursor in the statusbar prompt at statusbar_x. */
|
/* Put the cursor in the statusbar prompt at statusbar_x. */
|
||||||
void reset_statusbar_cursor(void)
|
void reset_statusbar_cursor(void)
|
||||||
{
|
{
|
||||||
|
@ -703,13 +706,6 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If we're done with this prompt, restore the cursor position
|
|
||||||
* to what it was at the /previous/ prompt, in case there was. */
|
|
||||||
if (func == do_cancel || func == do_enter) {
|
|
||||||
statusbar_x = old_statusbar_x;
|
|
||||||
statusbar_pww = old_pww;
|
|
||||||
}
|
|
||||||
|
|
||||||
*actual = kbinput;
|
*actual = kbinput;
|
||||||
|
|
||||||
return func;
|
return func;
|
||||||
|
@ -742,6 +738,9 @@ int do_prompt(bool allow_tabs,
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
bool listed = FALSE;
|
bool listed = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
/* Save a possible current statusbar x position. */
|
||||||
|
size_t was_statusbar_x = statusbar_x;
|
||||||
|
size_t was_pww = statusbar_pww;
|
||||||
|
|
||||||
prompt = charalloc(((COLS - 4) * mb_cur_max()) + 1);
|
prompt = charalloc(((COLS - 4) * mb_cur_max()) + 1);
|
||||||
|
|
||||||
|
@ -765,10 +764,12 @@ int do_prompt(bool allow_tabs,
|
||||||
free(prompt);
|
free(prompt);
|
||||||
prompt = NULL;
|
prompt = NULL;
|
||||||
|
|
||||||
/* We're done with the prompt, so save the statusbar cursor
|
/* If we're done with this prompt, restore the x position to what
|
||||||
* position. */
|
* it was at a possible previous prompt. */
|
||||||
old_statusbar_x = statusbar_x;
|
if (func == do_cancel || func == do_enter) {
|
||||||
old_pww = statusbar_pww;
|
statusbar_x = was_statusbar_x;
|
||||||
|
statusbar_pww = was_pww;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we left the prompt via Cancel or Enter, set the return value
|
/* If we left the prompt via Cancel or Enter, set the return value
|
||||||
* properly. */
|
* properly. */
|
||||||
|
|
|
@ -526,6 +526,7 @@ void do_statusbar_next_word(void);
|
||||||
void do_statusbar_verbatim_input(bool *got_enter);
|
void do_statusbar_verbatim_input(bool *got_enter);
|
||||||
size_t statusbar_xplustabs(void);
|
size_t statusbar_xplustabs(void);
|
||||||
size_t get_statusbar_page_start(size_t start_col, size_t column);
|
size_t get_statusbar_page_start(size_t start_col, size_t column);
|
||||||
|
void reinit_statusbar_x(void);
|
||||||
void reset_statusbar_cursor(void);
|
void reset_statusbar_cursor(void);
|
||||||
void update_the_statusbar(void);
|
void update_the_statusbar(void);
|
||||||
void update_bar_if_needed(void);
|
void update_bar_if_needed(void);
|
||||||
|
|
Loading…
Reference in New Issue