From 2acf15de0de6cb42e1dcf08b15a686e05c62b08e Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 1 Mar 2012 00:40:51 +0000 Subject: Close win now has return value --- windows.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'windows.c') diff --git a/windows.c b/windows.c index 4d1f2900..5e523711 100644 --- a/windows.c +++ b/windows.c @@ -28,8 +28,13 @@ #define CONS_WIN_TITLE "_cons" +// holds console at index 0 and chat wins 1 through to 9 static struct prof_win _wins[10]; + +// the window currently being displayed static int _curr_prof_win = 0; + +// shortcut pointer to console window static WINDOW * _cons_win = NULL; static void _create_windows(void); @@ -83,18 +88,26 @@ void gui_close(void) endwin(); } -void win_close_win(void) +int win_close_win(void) { - // reset the chat win to unused - strcpy(_wins[_curr_prof_win].from, ""); - wclear(_wins[_curr_prof_win].win); + if (win_in_chat()) { + // reset the chat win to unused + strcpy(_wins[_curr_prof_win].from, ""); + wclear(_wins[_curr_prof_win].win); - // set it as inactive in the status bar - status_bar_inactive(_curr_prof_win); + // set it as inactive in the status bar + status_bar_inactive(_curr_prof_win); + + // go back to console window + _curr_prof_win = 0; + title_bar_title(); - // go back to console window - _curr_prof_win = 0; - title_bar_title(); + // success + return 1; + } else { + // didn't close anything + return 0; + } } int win_in_chat(void) -- cgit 1.4.1-2-gfad0