diff options
author | James Booth <boothj5@gmail.com> | 2012-02-13 00:59:04 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-02-13 00:59:04 +0000 |
commit | 181c423636e4131597104e088563df276393a3db (patch) | |
tree | c8c7bb986c1f0e02c91840f817df6d75f767200f | |
parent | 0e473e34aa76328f0709df830d8688773a7369fc (diff) | |
download | profani-tty-181c423636e4131597104e088563df276393a3db.tar.gz |
Tidy up refreshing current chat
-rw-r--r-- | windows.c | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/windows.c b/windows.c index 94620dcf..a30fa80d 100644 --- a/windows.c +++ b/windows.c @@ -8,6 +8,7 @@ static int _curr_win = 0; static void _create_windows(void); static void _send_message_to_win(char *contact, char *line); +static void _refresh_if_current(int i); void gui_init(void) { @@ -140,11 +141,7 @@ void cons_help(void) wprintw(_wins[0].win, " [%s] F2-10 : Chat windows.\n", tstmp); - // if its the current window, draw it - if (_curr_win == 0) { - touchwin(_wins[0].win); - wrefresh(_wins[0].win); - } + _refresh_if_current(0); } void cons_show(char *msg) @@ -153,12 +150,7 @@ void cons_show(char *msg) get_time(tstmp); wprintw(_wins[0].win, " [%s] %s\n", tstmp, msg); - - // if its the current window, draw it - if (_curr_win == 0) { - touchwin(_wins[0].win); - wrefresh(_wins[0].win); - } + _refresh_if_current(0); } void cons_bad_command(char *cmd) @@ -167,12 +159,7 @@ void cons_bad_command(char *cmd) get_time(tstmp); wprintw(_wins[0].win, " [%s] Unknown command: %s\n", tstmp, cmd); - - // if its the current window, draw it - if (_curr_win == 0) { - touchwin(_wins[0].win); - wrefresh(_wins[0].win); - } + _refresh_if_current(0); } static void _create_windows(void) @@ -220,33 +207,25 @@ static void _send_message_to_win(char *contact, char *line) if (strcmp(_wins[i].from, "") == 0) break; - // set it up and print the message to it + // set it up and use it strcpy(_wins[i].from, contact); wclear(_wins[i].win); wprintw(_wins[i].win, line); - - // signify active window in status bar status_bar_active(i); - - // if its the current window, draw it - if (_curr_win == i) { - touchwin(_wins[i].win); - wrefresh(_wins[i].win); - } + _refresh_if_current(i); } - // otherwise + // otherwise, just use it else { - // add the line to the senders window wprintw(_wins[i].win, line); - - // signify active window in status bar status_bar_active(i); - - // if its the current window, draw it - if (_curr_win == i) { - touchwin(_wins[i].win); - wrefresh(_wins[i].win); - } + _refresh_if_current(i); } } +static void _refresh_if_current(int i) +{ + if (_curr_win == i) { + touchwin(_wins[i].win); + wrefresh(_wins[i].win); + } +} |