Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 1948:e8cebf5fd36c
Add readmark support
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 14 Mar 2011 12:48:15 +0100 |
parents | 518740bcd78b |
children | 13d18777a629 |
comparison
equal
deleted
inserted
replaced
1947:5ba4d4bb5465 | 1948:e8cebf5fd36c |
---|---|
1125 | 1125 |
1126 // scr_update_window() | 1126 // scr_update_window() |
1127 // (Re-)Display the given chat window. | 1127 // (Re-)Display the given chat window. |
1128 static void scr_update_window(winbuf *win_entry) | 1128 static void scr_update_window(winbuf *win_entry) |
1129 { | 1129 { |
1130 int n; | 1130 int n, mark_offset = 0; |
1131 guint prefixwidth; | 1131 guint prefixwidth; |
1132 char pref[96]; | 1132 char pref[96]; |
1133 hbb_line **lines, *line; | 1133 hbb_line **lines, *line; |
1134 GList *hbuf_head; | 1134 GList *hbuf_head; |
1135 int color; | 1135 int color; |
1136 bool readmark = FALSE; | |
1137 bool skipline = FALSE; | |
1136 | 1138 |
1137 prefixwidth = scr_getprefixwidth(); | 1139 prefixwidth = scr_getprefixwidth(); |
1138 prefixwidth = MIN(prefixwidth, sizeof pref); | 1140 prefixwidth = MIN(prefixwidth, sizeof pref); |
1139 | 1141 |
1140 // Should the window be empty? | 1142 // Should the window be empty? |
1166 hbuf_head = win_entry->bd->top; | 1168 hbuf_head = win_entry->bd->top; |
1167 | 1169 |
1168 // Get the last CHAT_WIN_HEIGHT lines. | 1170 // Get the last CHAT_WIN_HEIGHT lines. |
1169 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); | 1171 lines = hbuf_get_lines(hbuf_head, CHAT_WIN_HEIGHT); |
1170 | 1172 |
1171 // Display these lines | 1173 if (CHAT_WIN_HEIGHT > 1) { |
1172 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { | 1174 // Do we have a read mark? |
1173 wmove(win_entry->win, n, 0); | 1175 for (n = 0; n < CHAT_WIN_HEIGHT; n++) { |
1176 line = *(lines+n); | |
1177 if (line && line->flags & HBB_PREFIX_READMARK) { | |
1178 // If this is not the last line, we'll display a mark | |
1179 if (n+1 < CHAT_WIN_HEIGHT && *(lines+n+1)) | |
1180 readmark = TRUE; | |
1181 } | |
1182 } | |
1183 } | |
1184 | |
1185 // Skip first line if there's a mark | |
1186 if (readmark) { | |
1187 skipline = TRUE; | |
1188 mark_offset = -1; | |
1189 } | |
1190 | |
1191 // Display the lines | |
1192 for (n = 0 ; n < CHAT_WIN_HEIGHT; n++) { | |
1193 int winy = n + mark_offset; | |
1194 wmove(win_entry->win, winy, 0); | |
1174 line = *(lines+n); | 1195 line = *(lines+n); |
1175 if (line) { | 1196 if (line) { |
1197 if (skipline) | |
1198 goto scr_update_window_skipline; | |
1199 | |
1176 if (line->flags & HBB_PREFIX_HLIGHT_OUT) | 1200 if (line->flags & HBB_PREFIX_HLIGHT_OUT) |
1177 color = COLOR_MSGOUT; | 1201 color = COLOR_MSGOUT; |
1178 else if (line->flags & HBB_PREFIX_HLIGHT) | 1202 else if (line->flags & HBB_PREFIX_HLIGHT) |
1179 color = COLOR_MSGHL; | 1203 color = COLOR_MSGHL; |
1180 else if (line->flags & HBB_PREFIX_INFO) | 1204 else if (line->flags & HBB_PREFIX_INFO) |
1190 // Generate the prefix area and display it | 1214 // Generate the prefix area and display it |
1191 scr_line_prefix(line, pref, prefixwidth); | 1215 scr_line_prefix(line, pref, prefixwidth); |
1192 wprintw(win_entry->win, pref); | 1216 wprintw(win_entry->win, pref); |
1193 | 1217 |
1194 // Make sure we are at the right position | 1218 // Make sure we are at the right position |
1195 wmove(win_entry->win, n, prefixwidth-1); | 1219 wmove(win_entry->win, winy, prefixwidth-1); |
1196 | 1220 |
1197 // The MUC nick - overwrite with proper color | 1221 // The MUC nick - overwrite with proper color |
1198 if (line->mucnicklen) { | 1222 if (line->mucnicklen) { |
1199 char *mucjid; | 1223 char *mucjid; |
1200 char tmp; | 1224 char tmp; |
1255 | 1279 |
1256 // Return the color back | 1280 // Return the color back |
1257 if (color != COLOR_GENERAL) | 1281 if (color != COLOR_GENERAL) |
1258 wattrset(win_entry->win, get_color(COLOR_GENERAL)); | 1282 wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
1259 | 1283 |
1284 scr_update_window_skipline: | |
1285 skipline = FALSE; | |
1286 if (readmark && line->flags & HBB_PREFIX_READMARK) { | |
1287 int i, w; | |
1288 mark_offset++; | |
1289 | |
1290 // Display the mark | |
1291 winy = n + mark_offset; | |
1292 wmove(win_entry->win, winy, 0); | |
1293 g_snprintf(pref, prefixwidth, " == "); | |
1294 wprintw(win_entry->win, pref); | |
1295 w = scr_gettextwidth() / 3; | |
1296 for (i=0; i<w; i++) | |
1297 wprintw(win_entry->win, "== "); | |
1298 wclrtoeol(win_entry->win); | |
1299 } | |
1300 | |
1260 g_free(line->text); | 1301 g_free(line->text); |
1261 g_free(line); | 1302 g_free(line); |
1262 } else { | 1303 } else { |
1263 wclrtobot(win_entry->win); | 1304 wclrtobot(win_entry->win); |
1264 break; | 1305 break; |