diff --git a/input.c b/input.c index b5dba7347..5b9051f44 100644 --- a/input.c +++ b/input.c @@ -134,7 +134,6 @@ static const wchar_t *name_arr[] = L"kill-word", L"backward-kill-word", L"dump-functions", - L"winch", L"history-token-search-backward", L"history-token-search-forward", L"self-insert", @@ -216,7 +215,6 @@ static const wchar_t code_arr[] = R_KILL_WORD, R_BACKWARD_KILL_WORD, R_DUMP_FUNCTIONS, - R_WINCH, R_HISTORY_TOKEN_SEARCH_BACKWARD, R_HISTORY_TOKEN_SEARCH_FORWARD, R_SELF_INSERT, @@ -346,7 +344,7 @@ static int interrupt_handler() return 3; } - return R_WINCH; + return R_NULL; } int input_init() diff --git a/input.h b/input.h index 3c3bae159..2814d809f 100644 --- a/input.h +++ b/input.h @@ -38,7 +38,6 @@ enum R_KILL_WORD, R_BACKWARD_KILL_WORD, R_DUMP_FUNCTIONS, - R_WINCH, R_HISTORY_TOKEN_SEARCH_BACKWARD, R_HISTORY_TOKEN_SEARCH_FORWARD, R_SELF_INSERT, diff --git a/reader.c b/reader.c index 47fd18690..04a5606f8 100644 --- a/reader.c +++ b/reader.c @@ -679,12 +679,11 @@ void repaint() parser_test( data->buff, data->indent, 0, 0 ); s_write( &data->screen, - (wchar_t *)data->prompt_buff.buff, - data->buff, - data->color, - data->indent, - data->buff_pos ); - + (wchar_t *)data->prompt_buff.buff, + data->buff, + data->color, + data->indent, + data->buff_pos ); } @@ -2339,7 +2338,7 @@ wchar_t *reader_readline() exec_prompt(); reader_super_highlight_me_plenty( data->buff_pos, 0 ); - s_reset( &data->screen, 0 ); + s_reset( &data->screen, 1 ); repaint(); /* @@ -2465,7 +2464,6 @@ wchar_t *reader_readline() case R_NULL: { - repaint(); break; } @@ -2473,13 +2471,7 @@ wchar_t *reader_readline() { exec_prompt(); write( 1, "\r", 1 ); - s_reset( &data->screen, 1 ); - repaint(); - break; - } - - case R_WINCH: - { + s_reset( &data->screen, 0 ); repaint(); break; } diff --git a/screen.c b/screen.c index 98061c6a7..33d9811ce 100644 --- a/screen.c +++ b/screen.c @@ -658,7 +658,7 @@ static void s_update( screen_t *scr, wchar_t *prompt ) need_clear = 1; s_move( scr, &output, 0, 0 ); scr->actual_width = screen_width; - s_reset( scr, 1 ); + s_reset( scr, 0 ); } if( wcscmp( prompt, (wchar_t *)scr->actual_prompt.buff ) ) @@ -918,6 +918,8 @@ void s_write( screen_t *s, void s_reset( screen_t *s, int reset_cursor ) { CHECK( s, ); + + int prev_line = s->actual_cursor[1]; s_reset_arr( &s->actual ); s->actual_cursor[0] = s->actual_cursor[1] = 0; sb_clear( &s->actual_prompt ); @@ -931,6 +933,8 @@ void s_reset( screen_t *s, int reset_cursor ) */ fstat( 1, &s->prev_buff_1 ); fstat( 2, &s->prev_buff_2 ); + write( 1, "\r", 1 ); + s->actual_cursor[1] = prev_line; } } diff --git a/screen.h b/screen.h index 581fce396..19b12f7f2 100644 --- a/screen.h +++ b/screen.h @@ -102,9 +102,19 @@ void s_write( screen_t *s, int cursor_pos ); /** - This function resets the screen buffers internal knowledge about - the contents of the screen. Use this function when some other - function than s_write has written to the screen. + This function resets the screen buffers internal knowledge about + the contents of the screen. Use this function when some other + function than s_write has written to the screen. + + \param s the screen to reset + \param reset_cursor whether the line on which the curor has changed should be assumed to have changed. If \c reset_cursor is set to 0, the library will attempt to make sure that the screen area does not seem to move up or down on repaint. + + If reset_cursor is incorreclt set to 0, this may result in screen + contents being erased. If it is incorrectly set to one, it may + result in one or more lines of garbage on screen on the next + repaint. If this happens during a loop, such as an interactive + resizing, there will be one line of garbage for every repaint, + which will quicly fill the screen. */ void s_reset( screen_t *s, int reset_cursor ); diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index e30efb6a4..cb3ee93e3 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -195,6 +195,9 @@ function __fish_config_interactive -d "Initializations that should be performed eval $fish_key_bindings end ^/dev/null + function __fish_winch_handler --on-signal winch + commandline -f repaint + end + end -