diff --git a/input_win.c b/input_win.c index 51e5552d..db13e7ab 100644 --- a/input_win.c +++ b/input_win.c @@ -131,6 +131,15 @@ void inp_put_back(void) wrefresh(inp_win); } +void inp_win_write(const char * const new_input, const int size) +{ + int i; + inp_clear(); + for (i = 0; i < size; i++) + waddch(inp_win, new_input[i]); +} + + /* * Deal with command editing, return 1 if ch was an edit * key press: up, down, left, right or backspace diff --git a/profanity.c b/profanity.c index ab50d4fd..11dd0e0c 100644 --- a/profanity.c +++ b/profanity.c @@ -49,6 +49,9 @@ void profanity_run(void) jabber_process_events(); inp_get_char(&ch, inp, &size); win_handle_special_keys(&ch); + if (ch == KEY_RESIZE) { + gui_resize(ch, inp, size); + } } inp[size++] = '\0'; diff --git a/windows.c b/windows.c index 37f94053..3acda7b7 100644 --- a/windows.c +++ b/windows.c @@ -57,7 +57,6 @@ static void _cons_show_incoming_message(const char * const short_from, const int win_index); static void _win_handle_switch(const int * const ch); static void _win_handle_page(const int * const ch); -static void _win_handle_resize(const int * const ch); void gui_init(void) { @@ -107,6 +106,16 @@ void gui_close(void) endwin(); } +void gui_resize(const int ch, const char * const input, const int size) +{ + create_title_bar(); + create_status_bar(); + create_input_window(); + inp_win_write(input, size); + _current_window_refresh(); + dirty = TRUE; +} + int win_close_win(void) { if (win_in_chat()) { @@ -317,7 +326,6 @@ void win_handle_special_keys(const int * const ch) { _win_handle_switch(ch); _win_handle_page(ch); - _win_handle_resize(ch); } void win_page_off(void) @@ -514,17 +522,6 @@ static void _win_handle_switch(const int * const ch) } } -static void _win_handle_resize(const int * const ch) -{ - if (*ch == KEY_RESIZE) { - create_title_bar(); - create_status_bar(); - create_input_window(); - _current_window_refresh(); - dirty = TRUE; - } -} - static void _win_handle_page(const int * const ch) { int rows, cols, y, x; diff --git a/windows.h b/windows.h index de72a23e..8d21e906 100644 --- a/windows.h +++ b/windows.h @@ -33,10 +33,12 @@ struct prof_win { int paged; }; -// gui startup and shutdown +// gui startup and shutdown, resize void gui_init(void); void gui_refresh(void); void gui_close(void); +void gui_resize(const int ch, const char * const input, + const int size); // create windows void create_title_bar(void); @@ -92,5 +94,6 @@ void inp_put_back(void); void inp_non_block(void); void inp_block(void); void inp_get_password(char *passwd); +void inp_win_write(const char * const new_input, const int size); #endif