diff --git a/input.c b/input.c index 2d57b84f1..833e78083 100644 --- a/input.c +++ b/input.c @@ -123,7 +123,7 @@ static const wchar_t *name_arr[] = L"kill-word", L"backward-kill-word", L"dump-functions", - L"clear-screen", + L"winch", L"exit", L"history-token-search-backward", L"history-token-search-forward", @@ -200,7 +200,7 @@ static const wchar_t code_arr[] = R_KILL_WORD, R_BACKWARD_KILL_WORD, R_DUMP_FUNCTIONS, - R_CLEAR_SCREEN, + R_WINCH, R_EXIT, R_HISTORY_TOKEN_SEARCH_BACKWARD, R_HISTORY_TOKEN_SEARCH_FORWARD, @@ -1398,7 +1398,7 @@ static int interrupt_handler() return 3; } - return 0; + return R_WINCH; } int input_init() diff --git a/input.h b/input.h index b7b5a61c6..619c8d816 100644 --- a/input.h +++ b/input.h @@ -39,7 +39,7 @@ enum R_KILL_WORD, R_BACKWARD_KILL_WORD, R_DUMP_FUNCTIONS, - R_CLEAR_SCREEN, + R_WINCH, R_EXIT, R_HISTORY_TOKEN_SEARCH_BACKWARD, R_HISTORY_TOKEN_SEARCH_FORWARD, diff --git a/reader.c b/reader.c index 07084eaf1..b9155f6c2 100644 --- a/reader.c +++ b/reader.c @@ -2171,6 +2171,12 @@ wchar_t *reader_readline() break; } + case R_WINCH: + { + repaint(); + break; + } + case R_EOF: { exit_forced = 1; @@ -2521,15 +2527,6 @@ wchar_t *reader_readline() break; } - case R_CLEAR_SCREEN: - { - if( clear_screen ) - writembs( clear_screen ); - s_reset( &data->screen ); - repaint(); - break; - } - case R_BEGINNING_OF_HISTORY: { history_first(); diff --git a/screen.c b/screen.c index a1e207b7a..222872614 100644 --- a/screen.c +++ b/screen.c @@ -490,10 +490,18 @@ static void s_update( screen_t *scr, wchar_t *prompt ) int i, j, k; int prompt_width = calc_prompt_width( prompt ); int current_width=0; + int screen_width = common_get_width(); buffer_t output; b_init( &output ); + if( scr->actual_width != screen_width ) + { + s_move( scr, &output, 0, 0 ); + scr->actual_width = screen_width; + s_reset( scr ); + } + if( wcscmp( prompt, (wchar_t *)scr->actual_prompt.buff ) ) { s_move( scr, &output, 0, 0 ); diff --git a/screen.h b/screen.h index 10cce22fa..d732fd405 100644 --- a/screen.h +++ b/screen.h @@ -34,6 +34,12 @@ typedef struct the screen. */ string_buffer_t actual_prompt; + + /* + The actual width of the screen at the time of the last screen + write. + */ + int actual_width; } screen_t;