Tidy up refreshing current chat

This commit is contained in:
James Booth
2012-02-13 00:59:04 +00:00
parent 0e473e34aa
commit 181c423636

View File

@@ -8,6 +8,7 @@ static int _curr_win = 0;
static void _create_windows(void); static void _create_windows(void);
static void _send_message_to_win(char *contact, char *line); static void _send_message_to_win(char *contact, char *line);
static void _refresh_if_current(int i);
void gui_init(void) void gui_init(void)
{ {
@@ -140,11 +141,7 @@ void cons_help(void)
wprintw(_wins[0].win, wprintw(_wins[0].win,
" [%s] F2-10 : Chat windows.\n", tstmp); " [%s] F2-10 : Chat windows.\n", tstmp);
// if its the current window, draw it _refresh_if_current(0);
if (_curr_win == 0) {
touchwin(_wins[0].win);
wrefresh(_wins[0].win);
}
} }
void cons_show(char *msg) void cons_show(char *msg)
@@ -153,12 +150,7 @@ void cons_show(char *msg)
get_time(tstmp); get_time(tstmp);
wprintw(_wins[0].win, " [%s] %s\n", tstmp, msg); wprintw(_wins[0].win, " [%s] %s\n", tstmp, msg);
_refresh_if_current(0);
// if its the current window, draw it
if (_curr_win == 0) {
touchwin(_wins[0].win);
wrefresh(_wins[0].win);
}
} }
void cons_bad_command(char *cmd) void cons_bad_command(char *cmd)
@@ -167,12 +159,7 @@ void cons_bad_command(char *cmd)
get_time(tstmp); get_time(tstmp);
wprintw(_wins[0].win, " [%s] Unknown command: %s\n", tstmp, cmd); wprintw(_wins[0].win, " [%s] Unknown command: %s\n", tstmp, cmd);
_refresh_if_current(0);
// if its the current window, draw it
if (_curr_win == 0) {
touchwin(_wins[0].win);
wrefresh(_wins[0].win);
}
} }
static void _create_windows(void) 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) if (strcmp(_wins[i].from, "") == 0)
break; break;
// set it up and print the message to it // set it up and use it
strcpy(_wins[i].from, contact); strcpy(_wins[i].from, contact);
wclear(_wins[i].win); wclear(_wins[i].win);
wprintw(_wins[i].win, line); wprintw(_wins[i].win, line);
// signify active window in status bar
status_bar_active(i); status_bar_active(i);
_refresh_if_current(i);
// if its the current window, draw it
if (_curr_win == i) {
touchwin(_wins[i].win);
wrefresh(_wins[i].win);
}
} }
// otherwise // otherwise, just use it
else { else {
// add the line to the senders window
wprintw(_wins[i].win, line); wprintw(_wins[i].win, line);
// signify active window in status bar
status_bar_active(i); status_bar_active(i);
_refresh_if_current(i);
// if its the current window, draw it
if (_curr_win == i) {
touchwin(_wins[i].win);
wrefresh(_wins[i].win);
}
} }
} }
static void _refresh_if_current(int i)
{
if (_curr_win == i) {
touchwin(_wins[i].win);
wrefresh(_wins[i].win);
}
}