1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

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

@ -34,7 +34,6 @@
static void _profanity_init(int disable_tls);
static void _profanity_event_loop(int *ch, char *cmd, int *size);
static void _process_special_keys(int *ch);
void profanity_main(int disable_tls)
{
@ -69,41 +68,6 @@ static void _profanity_event_loop(int *ch, char *cmd, int *size)
usleep(1);
gui_refresh();
jabber_process_events();
_process_special_keys(ch);
win_handle_switch(ch);
inp_poll_char(ch, cmd, size);
}
static void _process_special_keys(int *ch)
{
if (*ch == KEY_F(1)) {
if (win_is_active(0))
win_switch_to(0);
} else if (*ch == KEY_F(2)) {
if (win_is_active(1))
win_switch_to(1);
} else if (*ch == KEY_F(3)) {
if (win_is_active(2))
win_switch_to(2);
} else if (*ch == KEY_F(4)) {
if (win_is_active(3))
win_switch_to(3);
} else if (*ch == KEY_F(5)) {
if (win_is_active(4))
win_switch_to(4);
} else if (*ch == KEY_F(6)) {
if (win_is_active(5))
win_switch_to(5);
} else if (*ch == KEY_F(7)) {
if (win_is_active(6))
win_switch_to(6);
} else if (*ch == KEY_F(8)) {
if (win_is_active(7))
win_switch_to(7);
} else if (*ch == KEY_F(9)) {
if (win_is_active(8))
win_switch_to(8);
} else if (*ch == KEY_F(10)) {
if (win_is_active(9))
win_switch_to(9);
}
}

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];

View File

@ -48,13 +48,12 @@ void title_bar_connected(void);
void title_bar_disconnected(void);
// main window actions
int win_is_active(int i);
void win_switch_to(int i);
void win_close_win(void);
int win_in_chat(void);
char *win_get_recipient(void);
void win_show_incomming_msg(char *from, char *message);
void win_show_outgoing_msg(char *from, char *to, char *message);
void win_handle_switch(int *ch);
// console window actions
void cons_help(void);