comparison mcabber/src/screen.c @ 707:b26a0bde4cdb

Add /roster hide|show|toggle
author Mikael Berthe <mikael@lilotux.net>
date Tue, 21 Feb 2006 22:57:49 +0100
parents 6c100adfbfb6
children ed326697e4ed
comparison
equal deleted inserted replaced
706:934fddc99592 707:b26a0bde4cdb
71 static PANEL *rosterPanel, *chatPanel, *inputPanel; 71 static PANEL *rosterPanel, *chatPanel, *inputPanel;
72 static PANEL *logPanel, *logPanel_border; 72 static PANEL *logPanel, *logPanel_border;
73 static int maxY, maxX; 73 static int maxY, maxX;
74 static window_entry_t *currentWindow; 74 static window_entry_t *currentWindow;
75 75
76 static int roster_hidden;
76 static int chatmode; 77 static int chatmode;
77 static int multimode; 78 static int multimode;
78 static char *multiline; 79 static char *multiline;
79 int update_roster; 80 int update_roster;
80 int utf8_mode = 0; 81 int utf8_mode = 0;
574 } else { 575 } else {
575 Log_Win_Height = maxY - 2; 576 Log_Win_Height = maxY - 2;
576 } 577 }
577 } 578 }
578 579
579 requested_size = settings_opt_get_int("roster_width"); 580 if (roster_hidden) {
580 if (requested_size > 1) 581 Roster_Width = 0;
581 Roster_Width = requested_size; 582 } else {
582 else if (requested_size == 1) 583 requested_size = settings_opt_get_int("roster_width");
583 Roster_Width = 2; 584 if (requested_size > 1)
584 else 585 Roster_Width = requested_size;
585 Roster_Width = DEFAULT_ROSTER_WIDTH; 586 else if (requested_size == 1)
587 Roster_Width = 2;
588 else
589 Roster_Width = DEFAULT_ROSTER_WIDTH;
590 }
586 591
587 if (fullinit) { 592 if (fullinit) {
588 /* Create windows */ 593 /* Create windows */
589 rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, 0, 0); 594 rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, 0, 0);
590 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, 0, Roster_Width); 595 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, 0, Roster_Width);
729 getmaxyx(rosterWnd, maxy, maxx); 734 getmaxyx(rosterWnd, maxy, maxx);
730 maxx--; // Last char is for vertical border 735 maxx--; // Last char is for vertical border
731 736
732 // Cleanup of roster window 737 // Cleanup of roster window
733 werase(rosterWnd); 738 werase(rosterWnd);
734 // Redraw the vertical line (not very good...) 739
735 wattrset(rosterWnd, COLOR_PAIR(COLOR_GENERAL)); 740 if (Roster_Width) {
736 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) 741 // Redraw the vertical line (not very good...)
737 mvwaddch(rosterWnd, i, Roster_Width-1, ACS_VLINE); 742 wattrset(rosterWnd, COLOR_PAIR(COLOR_GENERAL));
738 743 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++)
739 // Leave now if buddylist is empty 744 mvwaddch(rosterWnd, i, Roster_Width-1, ACS_VLINE);
740 if (!buddylist) { 745 }
746
747 if (!buddylist)
741 offset = 0; 748 offset = 0;
749
750 // Leave now if buddylist is empty or the roster is hidden
751 if (!buddylist || !Roster_Width) {
742 update_panels(); 752 update_panels();
743 doupdate(); 753 doupdate();
744 return; 754 return;
745 } 755 }
746 756
836 g_free(rline); 846 g_free(rline);
837 g_free(name); 847 g_free(name);
838 top_panel(inputPanel); 848 top_panel(inputPanel);
839 update_panels(); 849 update_panels();
840 doupdate(); 850 doupdate();
851 }
852
853 // scr_RosterVisibility(status)
854 // Set the roster visibility:
855 // status=1 Show roster
856 // status=0 Hide roster
857 // status=-1 Toggle roster status
858 void scr_RosterVisibility(int status)
859 {
860 if (status > 0)
861 roster_hidden = FALSE;
862 else if (status == 0)
863 roster_hidden = TRUE;
864 else
865 roster_hidden = !roster_hidden;
866
867 // Recalculate windows size and redraw
868 scr_Resize();
869 redrawwin(stdscr);
841 } 870 }
842 871
843 inline void scr_WriteMessage(const char *jid, const char *text, 872 inline void scr_WriteMessage(const char *jid, const char *text,
844 time_t timestamp, guint prefix_flags) 873 time_t timestamp, guint prefix_flags)
845 { 874 {