1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Close win now has return value

This commit is contained in:
James Booth 2012-03-01 00:40:51 +00:00
parent 1cc22c23f9
commit 2acf15de0d
3 changed files with 24 additions and 14 deletions

View File

@ -177,11 +177,8 @@ static int _cmd_msg(char *inp)
static int _cmd_close(char *inp) static int _cmd_close(char *inp)
{ {
if (win_in_chat()) { if (!win_close_win())
win_close_win();
} else {
cons_bad_command(inp); cons_bad_command(inp);
}
return TRUE; return TRUE;
} }

View File

@ -28,8 +28,13 @@
#define CONS_WIN_TITLE "_cons" #define CONS_WIN_TITLE "_cons"
// holds console at index 0 and chat wins 1 through to 9
static struct prof_win _wins[10]; static struct prof_win _wins[10];
// the window currently being displayed
static int _curr_prof_win = 0; static int _curr_prof_win = 0;
// shortcut pointer to console window
static WINDOW * _cons_win = NULL; static WINDOW * _cons_win = NULL;
static void _create_windows(void); static void _create_windows(void);
@ -83,18 +88,26 @@ void gui_close(void)
endwin(); endwin();
} }
void win_close_win(void) int win_close_win(void)
{ {
// reset the chat win to unused if (win_in_chat()) {
strcpy(_wins[_curr_prof_win].from, ""); // reset the chat win to unused
wclear(_wins[_curr_prof_win].win); strcpy(_wins[_curr_prof_win].from, "");
wclear(_wins[_curr_prof_win].win);
// set it as inactive in the status bar // set it as inactive in the status bar
status_bar_inactive(_curr_prof_win); status_bar_inactive(_curr_prof_win);
// go back to console window // go back to console window
_curr_prof_win = 0; _curr_prof_win = 0;
title_bar_title(); title_bar_title();
// success
return 1;
} else {
// didn't close anything
return 0;
}
} }
int win_in_chat(void) int win_in_chat(void)

View File

@ -48,7 +48,7 @@ void title_bar_connected(void);
void title_bar_disconnected(void); void title_bar_disconnected(void);
// main window actions // main window actions
void win_close_win(void); int win_close_win(void);
int win_in_chat(void); int win_in_chat(void);
char *win_get_recipient(void); char *win_get_recipient(void);
void win_show_incomming_msg(char *from, char *message); void win_show_incomming_msg(char *from, char *message);