comparison mcabber/src/hbuf.c @ 733:c502bfe67c31

Fix highlighting of outgoing multi-line messages
author Mikael Berthe <mikael@lilotux.net>
date Thu, 09 Mar 2006 19:25:31 +0100
parents 39f67cade02c
children 5d4ad1d77da4
comparison
equal deleted inserted replaced
732:ab623c2df964 733:c502bfe67c31
248 hbb_line **hbuf_get_lines(GList *hbuf, unsigned int n) 248 hbb_line **hbuf_get_lines(GList *hbuf, unsigned int n)
249 { 249 {
250 unsigned int i; 250 unsigned int i;
251 hbuf_block *blk; 251 hbuf_block *blk;
252 guchar last_persist_prefixflags = 0; 252 guchar last_persist_prefixflags = 0;
253 GList *last_persist; 253 GList *last_persist; // last persistent flags
254 254
255 // To be able to correctly highlight multi-line messages,
256 // we need to look at the last non-null prefix, which should be the first
257 // line of the message.
255 last_persist = hbuf_previous_persistent(hbuf); 258 last_persist = hbuf_previous_persistent(hbuf);
256 if (last_persist && last_persist != hbuf) { 259 while (last_persist) {
257 blk = (hbuf_block*)(last_persist->data); 260 blk = (hbuf_block*)last_persist->data;
258 last_persist_prefixflags = blk->prefix.flags; 261 if ((blk->flags & HBB_FLAG_PERSISTENT) && blk->prefix.flags) {
262 last_persist_prefixflags = blk->prefix.flags;
263 break;
264 }
265 last_persist = g_list_previous(last_persist);
259 } 266 }
260 267
261 hbb_line **array = g_new0(hbb_line*, n); 268 hbb_line **array = g_new0(hbb_line*, n);
262 hbb_line **array_elt = array; 269 hbb_line **array_elt = array;
263 270
269 *array_elt = (hbb_line*)g_new(hbb_line, 1); 276 *array_elt = (hbb_line*)g_new(hbb_line, 1);
270 (*array_elt)->timestamp = blk->prefix.timestamp; 277 (*array_elt)->timestamp = blk->prefix.timestamp;
271 (*array_elt)->flags = blk->prefix.flags; 278 (*array_elt)->flags = blk->prefix.flags;
272 (*array_elt)->text = g_strndup(blk->ptr, maxlen); 279 (*array_elt)->text = g_strndup(blk->ptr, maxlen);
273 280
274 if (blk->flags & HBB_FLAG_PERSISTENT) { 281 if ((blk->flags & HBB_FLAG_PERSISTENT) && blk->prefix.flags) {
275 last_persist_prefixflags = blk->prefix.flags; 282 last_persist_prefixflags = blk->prefix.flags;
276 } else { 283 } else {
277 // Propagate hilighting flag 284 // Propagate hilighting flag
278 (*array_elt)->flags |= last_persist_prefixflags & HBB_PREFIX_HLIGHT; 285 (*array_elt)->flags |= last_persist_prefixflags & HBB_PREFIX_HLIGHT;
279 } 286 }