Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/hbuf.c @ 1970:10eead2ba1b7
Fix another readmark issue with line wrapping
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 19 Mar 2011 10:38:17 +0100 |
parents | f016c9c9d992 |
children | f740c4128f76 |
comparison
equal
deleted
inserted
replaced
1969:d9255c408027 | 1970:10eead2ba1b7 |
---|---|
320 hbb_line **array, **array_elt; | 320 hbb_line **array, **array_elt; |
321 hbb_line *prev_array_elt = NULL; | 321 hbb_line *prev_array_elt = NULL; |
322 | 322 |
323 // To be able to correctly highlight multi-line messages, | 323 // To be able to correctly highlight multi-line messages, |
324 // we need to look at the last non-null prefix, which should be the first | 324 // we need to look at the last non-null prefix, which should be the first |
325 // line of the message. | 325 // line of the message. We also need to check if there's a readmark flag |
326 // somewhere in the message. | |
326 last_persist = hbuf_previous_persistent(hbuf); | 327 last_persist = hbuf_previous_persistent(hbuf); |
327 while (last_persist) { | 328 while (last_persist) { |
328 blk = (hbuf_block*)last_persist->data; | 329 blk = (hbuf_block*)last_persist->data; |
329 if ((blk->flags & HBB_FLAG_PERSISTENT) && | 330 if ((blk->flags & HBB_FLAG_PERSISTENT) && blk->prefix.flags) { |
330 (blk->prefix.flags & ~HBB_PREFIX_READMARK)) { | 331 // This can be either the beginning of the message, |
331 last_persist_prefixflags = blk->prefix.flags; | 332 // or a persistent line with a readmark flag (or both). |
332 break; | 333 if (blk->prefix.flags & ~HBB_PREFIX_READMARK) { // First message line |
334 last_persist_prefixflags |= blk->prefix.flags; | |
335 break; | |
336 } else { // Not the first line, but we need to keep the readmark flag | |
337 last_persist_prefixflags = blk->prefix.flags; | |
338 } | |
333 } | 339 } |
334 last_persist = g_list_previous(last_persist); | 340 last_persist = g_list_previous(last_persist); |
335 } | 341 } |
336 | 342 |
337 array = g_new0(hbb_line*, n); | 343 array = g_new0(hbb_line*, n); |
361 HBB_PREFIX_INFO | HBB_PREFIX_IN | | 367 HBB_PREFIX_INFO | HBB_PREFIX_IN | |
362 HBB_PREFIX_READMARK); | 368 HBB_PREFIX_READMARK); |
363 // Continuation of a message - omit the prefix | 369 // Continuation of a message - omit the prefix |
364 (*array_elt)->flags |= HBB_PREFIX_CONT; | 370 (*array_elt)->flags |= HBB_PREFIX_CONT; |
365 (*array_elt)->mucnicklen = 0; // The nick is in the first one | 371 (*array_elt)->mucnicklen = 0; // The nick is in the first one |
372 | |
373 // If there is a readmark on this line, update last_persist_prefixflags | |
374 if (blk->flags & HBB_FLAG_PERSISTENT) | |
375 last_persist_prefixflags |= blk->prefix.flags & HBB_PREFIX_READMARK; | |
366 // Remove readmark flag from the previous line | 376 // Remove readmark flag from the previous line |
367 if (prev_array_elt && last_persist_prefixflags & HBB_PREFIX_READMARK) | 377 if (prev_array_elt && last_persist_prefixflags & HBB_PREFIX_READMARK) |
368 prev_array_elt->flags &= ~HBB_PREFIX_READMARK; | 378 prev_array_elt->flags &= ~HBB_PREFIX_READMARK; |
369 } | 379 } |
370 | 380 |