Moved window switching

This commit is contained in:
James Booth
2012-02-27 02:01:19 +00:00
parent aa680b98a2
commit 5c9061671e
3 changed files with 40 additions and 57 deletions

View File

@@ -32,6 +32,7 @@ static int _curr_win = 0;
static void _create_windows(void);
static int _find_win(char *contact);
static void _current_window_refresh();
static void _win_switch_if_active(int i);
static void _win_show_time(int win);
static void _win_show_user(int win, char *user, int colour);
@@ -73,24 +74,6 @@ void gui_close(void)
endwin();
}
int win_is_active(int i)
{
if (strcmp(_wins[i].from, "") == 0)
return FALSE;
else
return TRUE;
}
void win_switch_to(int i)
{
_curr_win = i;
if (i == 0)
title_bar_title();
else
title_bar_show(_wins[i].from);
}
void win_close_win(void)
{
// reset the chat win to unused
@@ -220,6 +203,31 @@ void cons_bad_message(void)
cons_show("Usage: /msg user@host message");
}
void win_handle_switch(int *ch)
{
if (*ch == KEY_F(1)) {
_win_switch_if_active(0);
} else if (*ch == KEY_F(2)) {
_win_switch_if_active(1);
} else if (*ch == KEY_F(3)) {
_win_switch_if_active(2);
} else if (*ch == KEY_F(4)) {
_win_switch_if_active(3);
} else if (*ch == KEY_F(5)) {
_win_switch_if_active(4);
} else if (*ch == KEY_F(6)) {
_win_switch_if_active(5);
} else if (*ch == KEY_F(7)) {
_win_switch_if_active(6);
} else if (*ch == KEY_F(8)) {
_win_switch_if_active(7);
} else if (*ch == KEY_F(9)) {
_win_switch_if_active(8);
} else if (*ch == KEY_F(10)) {
_win_switch_if_active(9);
}
}
static void _create_windows(void)
{
int rows, cols;
@@ -273,6 +281,18 @@ static int _find_win(char *contact)
return i;
}
static void _win_switch_if_active(int i)
{
if (strcmp(_wins[i].from, "") != 0) {
_curr_win = i;
if (i == 0)
title_bar_title();
else
title_bar_show(_wins[i].from);
}
}
static void _win_show_time(int win)
{
char tstmp[80];