# HG changeset patch # User Mikael Berthe # Date 1140559069 -3600 # Node ID b26a0bde4cdb2336b8d67d1c5f5ec6ada8543c9d # Parent 934fddc99592431f096d7199cbbe77d105185d17 Add /roster hide|show|toggle diff -r 934fddc99592 -r b26a0bde4cdb mcabber/src/commands.c --- a/mcabber/src/commands.c Sat Feb 18 15:07:51 2006 +0100 +++ b/mcabber/src/commands.c Tue Feb 21 22:57:49 2006 +0100 @@ -131,6 +131,9 @@ compl_add_category_word(COMPL_ROSTER, "top"); compl_add_category_word(COMPL_ROSTER, "up"); compl_add_category_word(COMPL_ROSTER, "down"); + compl_add_category_word(COMPL_ROSTER, "hide"); + compl_add_category_word(COMPL_ROSTER, "show"); + compl_add_category_word(COMPL_ROSTER, "toggle"); compl_add_category_word(COMPL_ROSTER, "hide_offline"); compl_add_category_word(COMPL_ROSTER, "show_offline"); compl_add_category_word(COMPL_ROSTER, "toggle_offline"); @@ -391,6 +394,12 @@ } else if (!strcasecmp(arg, "bottom")) { scr_RosterBottom(); update_roster = TRUE; + } else if (!strcasecmp(arg, "hide")) { + scr_RosterVisibility(0); + } else if (!strcasecmp(arg, "show")) { + scr_RosterVisibility(1); + } else if (!strcasecmp(arg, "toggle")) { + scr_RosterVisibility(-1); } else if (!strcasecmp(arg, "hide_offline")) { buddylist_set_hide_offline_buddies(TRUE); if (current_buddy) diff -r 934fddc99592 -r b26a0bde4cdb mcabber/src/screen.c --- a/mcabber/src/screen.c Sat Feb 18 15:07:51 2006 +0100 +++ b/mcabber/src/screen.c Tue Feb 21 22:57:49 2006 +0100 @@ -73,6 +73,7 @@ static int maxY, maxX; static window_entry_t *currentWindow; +static int roster_hidden; static int chatmode; static int multimode; static char *multiline; @@ -576,13 +577,17 @@ } } - requested_size = settings_opt_get_int("roster_width"); - if (requested_size > 1) - Roster_Width = requested_size; - else if (requested_size == 1) - Roster_Width = 2; - else - Roster_Width = DEFAULT_ROSTER_WIDTH; + if (roster_hidden) { + Roster_Width = 0; + } else { + requested_size = settings_opt_get_int("roster_width"); + if (requested_size > 1) + Roster_Width = requested_size; + else if (requested_size == 1) + Roster_Width = 2; + else + Roster_Width = DEFAULT_ROSTER_WIDTH; + } if (fullinit) { /* Create windows */ @@ -731,14 +736,19 @@ // Cleanup of roster window werase(rosterWnd); - // Redraw the vertical line (not very good...) - wattrset(rosterWnd, COLOR_PAIR(COLOR_GENERAL)); - for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) - mvwaddch(rosterWnd, i, Roster_Width-1, ACS_VLINE); - // Leave now if buddylist is empty - if (!buddylist) { + if (Roster_Width) { + // Redraw the vertical line (not very good...) + wattrset(rosterWnd, COLOR_PAIR(COLOR_GENERAL)); + for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) + mvwaddch(rosterWnd, i, Roster_Width-1, ACS_VLINE); + } + + if (!buddylist) offset = 0; + + // Leave now if buddylist is empty or the roster is hidden + if (!buddylist || !Roster_Width) { update_panels(); doupdate(); return; @@ -840,6 +850,25 @@ doupdate(); } +// scr_RosterVisibility(status) +// Set the roster visibility: +// status=1 Show roster +// status=0 Hide roster +// status=-1 Toggle roster status +void scr_RosterVisibility(int status) +{ + if (status > 0) + roster_hidden = FALSE; + else if (status == 0) + roster_hidden = TRUE; + else + roster_hidden = !roster_hidden; + + // Recalculate windows size and redraw + scr_Resize(); + redrawwin(stdscr); +} + inline void scr_WriteMessage(const char *jid, const char *text, time_t timestamp, guint prefix_flags) { diff -r 934fddc99592 -r b26a0bde4cdb mcabber/src/screen.h --- a/mcabber/src/screen.h Sat Feb 18 15:07:51 2006 +0100 +++ b/mcabber/src/screen.h Tue Feb 21 22:57:49 2006 +0100 @@ -27,6 +27,7 @@ void scr_TerminateCurses(void); void scr_DrawMainWindow(unsigned int fullinit); void scr_DrawRoster(void); +void scr_RosterVisibility(int status); void scr_WriteIncomingMessage(const char *jidfrom, const char *text, time_t timestamp, guint prefix); void scr_WriteOutgoingMessage(const char *jidto, const char *text);