comparison mcabber/src/screen.c @ 973:e693cbe33802

Add option 'roster_win_on_right'
author Mikael Berthe <mikael@lilotux.net>
date Sat, 30 Sep 2006 19:13:20 +0200
parents 11b632d824f6
children 023891f99732
comparison
equal deleted inserted replaced
972:11b632d824f6 973:e693cbe33802
82 int update_roster; 82 int update_roster;
83 int utf8_mode = 0; 83 int utf8_mode = 0;
84 static bool Autoaway; 84 static bool Autoaway;
85 static bool Curses; 85 static bool Curses;
86 static bool log_win_on_top; 86 static bool log_win_on_top;
87 static bool roster_win_on_right;
87 static time_t LastActivity; 88 static time_t LastActivity;
88 89
89 static char inputLine[INPUTLINE_LENGTH+1]; 90 static char inputLine[INPUTLINE_LENGTH+1];
90 static char *ptr_inputline; 91 static char *ptr_inputline;
91 static short int inputline_offset; 92 static short int inputline_offset;
421 winbuf *tmp; 422 winbuf *tmp;
422 423
423 tmp = g_new0(winbuf, 1); 424 tmp = g_new0(winbuf, 1);
424 425
425 // Dimensions 426 // Dimensions
426 x = Roster_Width; 427 if (roster_win_on_right)
428 x = 0;
429 else
430 x = Roster_Width;
427 if (log_win_on_top) 431 if (log_win_on_top)
428 y = Log_Win_Height-1; 432 y = Log_Win_Height-1;
429 else 433 else
430 y = 0; 434 y = 0;
431 lines = CHAT_WIN_HEIGHT; 435 lines = CHAT_WIN_HEIGHT;
773 void scr_DrawMainWindow(unsigned int fullinit) 777 void scr_DrawMainWindow(unsigned int fullinit)
774 { 778 {
775 int requested_size; 779 int requested_size;
776 gchar *ver, *message; 780 gchar *ver, *message;
777 int chat_y_pos, chatstatus_y_pos, log_y_pos; 781 int chat_y_pos, chatstatus_y_pos, log_y_pos;
782 int roster_x_pos, chat_x_pos;
778 783
779 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; 784 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
780 requested_size = settings_opt_get_int("log_win_height"); 785 requested_size = settings_opt_get_int("log_win_height");
781 if (requested_size > 0) { 786 if (requested_size > 0) {
782 if (maxY > requested_size + 3) 787 if (maxY > requested_size + 3)
807 else 812 else
808 Roster_Width = DEFAULT_ROSTER_WIDTH; 813 Roster_Width = DEFAULT_ROSTER_WIDTH;
809 } 814 }
810 815
811 log_win_on_top = (settings_opt_get_int("log_win_on_top") == 1); 816 log_win_on_top = (settings_opt_get_int("log_win_on_top") == 1);
817 roster_win_on_right = (settings_opt_get_int("roster_win_on_right") == 1);
812 818
813 if (log_win_on_top) { 819 if (log_win_on_top) {
814 chat_y_pos = Log_Win_Height-1; 820 chat_y_pos = Log_Win_Height-1;
815 log_y_pos = 0; 821 log_y_pos = 0;
816 chatstatus_y_pos = Log_Win_Height-2; 822 chatstatus_y_pos = Log_Win_Height-2;
818 chat_y_pos = 0; 824 chat_y_pos = 0;
819 log_y_pos = CHAT_WIN_HEIGHT+1; 825 log_y_pos = CHAT_WIN_HEIGHT+1;
820 chatstatus_y_pos = CHAT_WIN_HEIGHT; 826 chatstatus_y_pos = CHAT_WIN_HEIGHT;
821 } 827 }
822 828
829 if (roster_win_on_right) {
830 roster_x_pos = maxX - Roster_Width;
831 chat_x_pos = 0;
832 } else {
833 roster_x_pos = 0;
834 chat_x_pos = Roster_Width;
835 }
836
823 if (fullinit) { 837 if (fullinit) {
824 /* Create windows */ 838 /* Create windows */
825 rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, chat_y_pos, 0); 839 rosterWnd = newwin(CHAT_WIN_HEIGHT, Roster_Width, chat_y_pos, roster_x_pos);
826 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, chat_y_pos, 840 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - Roster_Width, chat_y_pos,
827 Roster_Width); 841 chat_x_pos);
828 logWnd = newwin(Log_Win_Height-2, maxX, log_y_pos, 0); 842 logWnd = newwin(Log_Win_Height-2, maxX, log_y_pos, 0);
829 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0); 843 chatstatusWnd = newwin(1, maxX, chatstatus_y_pos, 0);
830 mainstatusWnd = newwin(1, maxX, maxY-2, 0); 844 mainstatusWnd = newwin(1, maxX, maxY-2, 0);
831 inputWnd = newwin(1, maxX, maxY-1, 0); 845 inputWnd = newwin(1, maxX, maxY-1, 0);
832 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { 846 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) {
843 /* Resize/move windows */ 857 /* Resize/move windows */
844 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width); 858 wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width);
845 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width); 859 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - Roster_Width);
846 wresize(logWnd, Log_Win_Height-2, maxX); 860 wresize(logWnd, Log_Win_Height-2, maxX);
847 861
848 mvwin(chatWnd, chat_y_pos, Roster_Width); 862 mvwin(chatWnd, chat_y_pos, chat_x_pos);
849 mvwin(rosterWnd, chat_y_pos, 0); 863 mvwin(rosterWnd, chat_y_pos, roster_x_pos);
850 mvwin(logWnd, log_y_pos, 0); 864 mvwin(logWnd, log_y_pos, 0);
851 865
852 // Resize & move chat status window 866 // Resize & move chat status window
853 wresize(chatstatusWnd, 1, maxX); 867 wresize(chatstatusWnd, 1, maxX);
854 mvwin(chatstatusWnd, chatstatus_y_pos, 0); 868 mvwin(chatstatusWnd, chatstatus_y_pos, 0);
915 } 929 }
916 930
917 static inline void resize_win_buffer(winbuf *wbp, int x, int y, 931 static inline void resize_win_buffer(winbuf *wbp, int x, int y,
918 int lines, int cols) 932 int lines, int cols)
919 { 933 {
920 int chat_y_pos; 934 int chat_x_pos, chat_y_pos;
921 935
922 if (log_win_on_top) 936 if (log_win_on_top)
923 chat_y_pos = Log_Win_Height-1; 937 chat_y_pos = Log_Win_Height-1;
924 else 938 else
925 chat_y_pos = 0; 939 chat_y_pos = 0;
926 940
941 if (roster_win_on_right)
942 chat_x_pos = 0;
943 else
944 chat_x_pos = Roster_Width;
945
927 // Resize/move buddy window 946 // Resize/move buddy window
928 wresize(wbp->win, lines, cols); 947 wresize(wbp->win, lines, cols);
929 mvwin(wbp->win, chat_y_pos, Roster_Width); 948 mvwin(wbp->win, chat_y_pos, chat_x_pos);
930 werase(wbp->win); 949 werase(wbp->win);
931 // If a panel exists, replace the old window with the new 950 // If a panel exists, replace the old window with the new
932 if (wbp->panel) 951 if (wbp->panel)
933 replace_panel(wbp->panel, wbp->win); 952 replace_panel(wbp->panel, wbp->win);
934 // Redo line wrapping 953 // Redo line wrapping
1081 int i, n; 1100 int i, n;
1082 int rOffset; 1101 int rOffset;
1083 int cursor_backup; 1102 int cursor_backup;
1084 char status, pending; 1103 char status, pending;
1085 enum imstatus currentstatus = jb_getstatus(); 1104 enum imstatus currentstatus = jb_getstatus();
1105 int x_pos;
1086 1106
1087 // We can reset update_roster 1107 // We can reset update_roster
1088 update_roster = FALSE; 1108 update_roster = FALSE;
1089 1109
1090 getmaxyx(rosterWnd, maxy, maxx); 1110 getmaxyx(rosterWnd, maxy, maxx);
1099 1119
1100 // Cleanup of roster window 1120 // Cleanup of roster window
1101 werase(rosterWnd); 1121 werase(rosterWnd);
1102 1122
1103 if (Roster_Width) { 1123 if (Roster_Width) {
1124 int line_x_pos = roster_win_on_right ? 0 : Roster_Width-1;
1104 // Redraw the vertical line (not very good...) 1125 // Redraw the vertical line (not very good...)
1105 wattrset(rosterWnd, get_color(COLOR_GENERAL)); 1126 wattrset(rosterWnd, get_color(COLOR_GENERAL));
1106 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++) 1127 for (i=0 ; i < CHAT_WIN_HEIGHT ; i++)
1107 mvwaddch(rosterWnd, i, Roster_Width-1, ACS_VLINE); 1128 mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE);
1108 } 1129 }
1109 1130
1110 // Leave now if buddylist is empty or the roster is hidden 1131 // Leave now if buddylist is empty or the roster is hidden
1111 if (!buddylist || !Roster_Width) { 1132 if (!buddylist || !Roster_Width) {
1112 update_panels(); 1133 update_panels();
1134 offset = i; 1155 offset = i;
1135 } else if (i+1 > offset + maxy) { 1156 } else if (i+1 > offset + maxy) {
1136 offset = i + 1 - maxy; 1157 offset = i + 1 - maxy;
1137 } 1158 }
1138 1159
1160 if (roster_win_on_right)
1161 x_pos = 1; // 1 char offset (vertical line)
1162 else
1163 x_pos = 0;
1164
1139 rline = g_new0(char, Roster_Width+1); 1165 rline = g_new0(char, Roster_Width+1);
1140 1166
1141 buddy = buddylist; 1167 buddy = buddylist;
1142 rOffset = offset; 1168 rOffset = offset;
1143 1169
1183 if (pending == '#') 1209 if (pending == '#')
1184 wattrset(rosterWnd, get_color(COLOR_ROSTERSELNMSG)); 1210 wattrset(rosterWnd, get_color(COLOR_ROSTERSELNMSG));
1185 else 1211 else
1186 wattrset(rosterWnd, get_color(COLOR_ROSTERSEL)); 1212 wattrset(rosterWnd, get_color(COLOR_ROSTERSEL));
1187 // The 3 following lines aim at coloring the whole line 1213 // The 3 following lines aim at coloring the whole line
1188 wmove(rosterWnd, i, 0); 1214 wmove(rosterWnd, i, x_pos);
1189 for (n = 0; n < maxx; n++) 1215 for (n = 0; n < maxx; n++)
1190 waddch(rosterWnd, ' '); 1216 waddch(rosterWnd, ' ');
1191 } else { 1217 } else {
1192 if (pending == '#') 1218 if (pending == '#')
1193 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); 1219 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG));
1225 snprintf(rline, Roster_Width, 1251 snprintf(rline, Roster_Width,
1226 " %c%c%c%c %s", pending, sepleft, status, sepright, name); 1252 " %c%c%c%c %s", pending, sepleft, status, sepright, name);
1227 } 1253 }
1228 1254
1229 rline_locale = from_utf8(rline); 1255 rline_locale = from_utf8(rline);
1230 mvwprintw(rosterWnd, i, 0, "%s", rline_locale); 1256 mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale);
1231 g_free(rline_locale); 1257 g_free(rline_locale);
1232 i++; 1258 i++;
1233 } 1259 }
1234 1260
1235 g_free(rline); 1261 g_free(rline);