mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Closing chat windows
This commit is contained in:
parent
8c24a7c475
commit
c92b268809
17
app.c
17
app.c
@ -19,7 +19,6 @@ void start_profanity(void)
|
||||
break;
|
||||
} else if (strncmp(cmd, "/help", 5) == 0) {
|
||||
cons_help();
|
||||
cons_show();
|
||||
inp_clear();
|
||||
} else if (strncmp(cmd, "/connect ", 9) == 0) {
|
||||
char *user;
|
||||
@ -35,7 +34,6 @@ void start_profanity(void)
|
||||
break;
|
||||
} else {
|
||||
cons_bad_command(cmd);
|
||||
cons_show();
|
||||
inp_clear();
|
||||
}
|
||||
}
|
||||
@ -98,15 +96,26 @@ static void main_event_loop(void)
|
||||
cons_help();
|
||||
inp_clear();
|
||||
|
||||
// send message to recipient if chat window
|
||||
// /close -> close the current chat window, if in chat
|
||||
} else if (strncmp(command, "/close", 6) == 0) {
|
||||
if (in_chat()) {
|
||||
close_win();
|
||||
} else {
|
||||
cons_bad_command(command);
|
||||
}
|
||||
inp_clear();
|
||||
|
||||
// send message to recipient, if in chat
|
||||
} else {
|
||||
if (in_chat()) {
|
||||
char recipient[100] = "";
|
||||
get_recipient(recipient);
|
||||
jabber_send(command, recipient);
|
||||
show_outgoing_msg("me", command);
|
||||
inp_clear();
|
||||
} else {
|
||||
cons_bad_command(command);
|
||||
}
|
||||
inp_clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
35
windows.c
35
windows.c
@ -60,6 +60,23 @@ void switch_to(int i)
|
||||
curr_win = i;
|
||||
}
|
||||
|
||||
void close_win(void)
|
||||
{
|
||||
// reset the chat win to unused
|
||||
strcpy(wins[curr_win].from, "");
|
||||
wclear(wins[curr_win].win);
|
||||
|
||||
// set it as inactive in the status bar
|
||||
mvwaddch(inp_bar, 0, 30 + curr_win, ' ');
|
||||
if (curr_win == 9)
|
||||
mvwaddch(inp_bar, 0, 30 + curr_win + 1, ' ');
|
||||
wrefresh(inp_bar);
|
||||
|
||||
// go back to console window
|
||||
touchwin(wins[0].win);
|
||||
wrefresh(wins[0].win);
|
||||
}
|
||||
|
||||
int in_chat(void)
|
||||
{
|
||||
return (curr_win != 0);
|
||||
@ -213,17 +230,23 @@ void cons_help(void)
|
||||
waddstr(wins[0].win, "----\n");
|
||||
waddstr(wins[0].win, "/quit - Quits Profanity.\n");
|
||||
waddstr(wins[0].win, "/connect <username@host> - Login to jabber.\n");
|
||||
|
||||
// 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)
|
||||
{
|
||||
wprintw(wins[0].win, "Unknown command: %s\n", cmd);
|
||||
}
|
||||
|
||||
void cons_show(void)
|
||||
{
|
||||
touchwin(wins[0].win);
|
||||
wrefresh(wins[0].win);
|
||||
|
||||
// if its the current window, draw it
|
||||
if (curr_win == 0) {
|
||||
touchwin(wins[0].win);
|
||||
wrefresh(wins[0].win);
|
||||
}
|
||||
}
|
||||
|
||||
static void create_title_bar(void)
|
||||
|
@ -12,6 +12,7 @@ struct prof_win {
|
||||
void gui_init(void);
|
||||
void gui_close(void);
|
||||
void switch_to(int i);
|
||||
void close_win(void);
|
||||
int in_chat(void);
|
||||
void get_recipient(char *recipient);
|
||||
void show_incomming_msg(char *from, char *message);
|
||||
@ -23,7 +24,5 @@ void inp_non_block(void);
|
||||
void inp_get_password(char *passwd);
|
||||
void bar_print_message(char *msg);
|
||||
void cons_help(void);
|
||||
void cons_show(void);
|
||||
void chat_show(void);
|
||||
void cons_bad_command(char *cmd);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user