Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 1093:6ca9a65df21f
Do not rewrap buffer lines when the chat window width doesn't change
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 08 Dec 2006 23:20:17 +0100 |
parents | a61c3311a5bb |
children | 922a9ae1a17e |
comparison
equal
deleted
inserted
replaced
1092:1ef7572c3096 | 1093:6ca9a65df21f |
---|---|
72 static WINDOW *mainstatusWnd, *chatstatusWnd; | 72 static WINDOW *mainstatusWnd, *chatstatusWnd; |
73 static PANEL *rosterPanel, *chatPanel, *inputPanel; | 73 static PANEL *rosterPanel, *chatPanel, *inputPanel; |
74 static PANEL *mainstatusPanel, *chatstatusPanel; | 74 static PANEL *mainstatusPanel, *chatstatusPanel; |
75 static PANEL *logPanel; | 75 static PANEL *logPanel; |
76 static int maxY, maxX; | 76 static int maxY, maxX; |
77 static int prev_chatwidth; | |
77 static winbuf *statusWindow; | 78 static winbuf *statusWindow; |
78 static winbuf *currentWindow; | 79 static winbuf *currentWindow; |
79 static GList *statushbuf; | 80 static GList *statushbuf; |
80 | 81 |
81 static int roster_hidden; | 82 static int roster_hidden; |
429 x = Roster_Width; | 430 x = Roster_Width; |
430 if (log_win_on_top) | 431 if (log_win_on_top) |
431 y = Log_Win_Height-1; | 432 y = Log_Win_Height-1; |
432 else | 433 else |
433 y = 0; | 434 y = 0; |
435 | |
434 lines = CHAT_WIN_HEIGHT; | 436 lines = CHAT_WIN_HEIGHT; |
435 cols = maxX - Roster_Width; | 437 cols = maxX - Roster_Width; |
436 if (cols < 1) cols = 1; | 438 if (cols < 1) |
439 cols = 1; | |
437 | 440 |
438 tmp->win = newwin(lines, cols, y, x); | 441 tmp->win = newwin(lines, cols, y, x); |
439 while (!tmp->win) { | 442 while (!tmp->win) { |
440 safe_usleep(250); | 443 safe_usleep(250); |
441 tmp->win = newwin(lines, cols, y, x); | 444 tmp->win = newwin(lines, cols, y, x); |
903 inputPanel = new_panel(inputWnd); | 906 inputPanel = new_panel(inputWnd); |
904 | 907 |
905 // Build the buddylist at least once, to make sure the special buffer | 908 // Build the buddylist at least once, to make sure the special buffer |
906 // is added | 909 // is added |
907 buddylist_build(); | 910 buddylist_build(); |
911 | |
912 // Init prev_chatwidth; this variable will be used to prevent us | |
913 // from rewrapping buffers when the width doesn't change. | |
914 prev_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; | |
908 // Wrap existing status buffer lines | 915 // Wrap existing status buffer lines |
909 hbuf_rebuild(&statushbuf, maxX - Roster_Width - PREFIX_WIDTH); | 916 hbuf_rebuild(&statushbuf, prev_chatwidth); |
910 | 917 |
911 #ifndef UNICODE | 918 #ifndef UNICODE |
912 if (utf8_mode) | 919 if (utf8_mode) |
913 scr_LogPrint(LPRINT_NORMAL, | 920 scr_LogPrint(LPRINT_NORMAL, |
914 "WARNING: Compiled without full UTF-8 support!"); | 921 "WARNING: Compiled without full UTF-8 support!"); |
931 static void resize_win_buffer(gpointer key, gpointer value, gpointer data) | 938 static void resize_win_buffer(gpointer key, gpointer value, gpointer data) |
932 { | 939 { |
933 winbuf *wbp = value; | 940 winbuf *wbp = value; |
934 struct dimensions *dim = data; | 941 struct dimensions *dim = data; |
935 int chat_x_pos, chat_y_pos; | 942 int chat_x_pos, chat_y_pos; |
943 int new_chatwidth; | |
936 | 944 |
937 if (!(wbp && wbp->win)) | 945 if (!(wbp && wbp->win)) |
938 return; | 946 return; |
939 | 947 |
940 if (log_win_on_top) | 948 if (log_win_on_top) |
954 // If a panel exists, replace the old window with the new | 962 // If a panel exists, replace the old window with the new |
955 if (wbp->panel) | 963 if (wbp->panel) |
956 replace_panel(wbp->panel, wbp->win); | 964 replace_panel(wbp->panel, wbp->win); |
957 // Redo line wrapping | 965 // Redo line wrapping |
958 wbp->top = hbuf_previous_persistent(wbp->top); | 966 wbp->top = hbuf_previous_persistent(wbp->top); |
959 hbuf_rebuild(&wbp->hbuf, maxX - Roster_Width - PREFIX_WIDTH); | 967 |
968 new_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; | |
969 if (new_chatwidth != prev_chatwidth) | |
970 hbuf_rebuild(&wbp->hbuf, new_chatwidth); | |
960 } | 971 } |
961 | 972 |
962 // scr_Resize() | 973 // scr_Resize() |
963 // Function called when the window is resized. | 974 // Function called when the window is resized. |
964 // - Resize windows | 975 // - Resize windows |
987 g_hash_table_foreach(winbufhash, resize_win_buffer, &dim); | 998 g_hash_table_foreach(winbufhash, resize_win_buffer, &dim); |
988 | 999 |
989 // Resize/move special status buffer | 1000 // Resize/move special status buffer |
990 if (statusWindow) | 1001 if (statusWindow) |
991 resize_win_buffer(NULL, statusWindow, &dim); | 1002 resize_win_buffer(NULL, statusWindow, &dim); |
1003 | |
1004 // Update prev_chatwidth, now that all buffers have been resized | |
1005 prev_chatwidth = maxX - Roster_Width - PREFIX_WIDTH; | |
992 | 1006 |
993 // Refresh current buddy window | 1007 // Refresh current buddy window |
994 if (chatmode) | 1008 if (chatmode) |
995 scr_ShowBuddyWindow(); | 1009 scr_ShowBuddyWindow(); |
996 } | 1010 } |