Moved resize code to windows.c, reorder main loop

This commit is contained in:
James Booth
2012-04-17 22:43:35 +01:00
parent 84c864663b
commit 32e025f5cd
4 changed files with 34 additions and 35 deletions

View File

@@ -87,9 +87,6 @@ void inp_get_char(int *ch, char *input, int *size)
noecho(); noecho();
*ch = wgetch(inp_win); *ch = wgetch(inp_win);
if (*ch == KEY_RESIZE) {
win_resize();
} else {
// if it wasn't an arrow key etc // if it wasn't an arrow key etc
if (!_handle_edit(*ch, input, size)) { if (!_handle_edit(*ch, input, size)) {
if (_printable(*ch)) { if (_printable(*ch)) {
@@ -115,7 +112,6 @@ void inp_get_char(int *ch, char *input, int *size)
reset_search_attempts(); reset_search_attempts();
} }
} }
}
echo(); echo();
} }
@@ -254,7 +250,7 @@ static int _printable(const int ch)
ch != KEY_F(4) && ch != KEY_F(5) && ch != KEY_F(6) && ch != KEY_F(4) && ch != KEY_F(5) && ch != KEY_F(6) &&
ch != KEY_F(7) && ch != KEY_F(8) && ch != KEY_F(9) && ch != KEY_F(7) && ch != KEY_F(8) && ch != KEY_F(9) &&
ch != KEY_F(10) && ch!= KEY_F(11) && ch != KEY_F(12) && ch != KEY_F(10) && ch!= KEY_F(11) && ch != KEY_F(12) &&
ch != KEY_IC && ch != KEY_EIC); ch != KEY_IC && ch != KEY_EIC && ch != KEY_RESIZE);
} }
static void _replace_input(char *input, const char * const new_input, int *size) static void _replace_input(char *input, const char * const new_input, int *size)

View File

@@ -47,8 +47,8 @@ void profanity_run(void)
while(ch != '\n') { while(ch != '\n') {
gui_refresh(); gui_refresh();
jabber_process_events(); jabber_process_events();
win_handle_special_keys(&ch);
inp_get_char(&ch, inp, &size); inp_get_char(&ch, inp, &size);
win_handle_special_keys(&ch);
} }
inp[size++] = '\0'; inp[size++] = '\0';

View File

@@ -57,6 +57,7 @@ static void _cons_show_incoming_message(const char * const short_from,
const int win_index); const int win_index);
static void _win_handle_switch(const int * const ch); static void _win_handle_switch(const int * const ch);
static void _win_handle_page(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) void gui_init(void)
{ {
@@ -88,15 +89,6 @@ void gui_init(void)
dirty = TRUE; dirty = TRUE;
} }
void win_resize(void)
{
create_title_bar();
create_status_bar();
create_input_window();
_current_window_refresh();
dirty = TRUE;
}
void gui_refresh(void) void gui_refresh(void)
{ {
title_bar_refresh(); title_bar_refresh();
@@ -325,6 +317,7 @@ void win_handle_special_keys(const int * const ch)
{ {
_win_handle_switch(ch); _win_handle_switch(ch);
_win_handle_page(ch); _win_handle_page(ch);
_win_handle_resize(ch);
} }
void win_page_off(void) void win_page_off(void)
@@ -521,6 +514,17 @@ 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) static void _win_handle_page(const int * const ch)
{ {
int rows, cols, y, x; int rows, cols, y, x;

View File

@@ -37,7 +37,6 @@ struct prof_win {
void gui_init(void); void gui_init(void);
void gui_refresh(void); void gui_refresh(void);
void gui_close(void); void gui_close(void);
void win_resize(void);
// create windows // create windows
void create_title_bar(void); void create_title_bar(void);