Mercurial > hg
comparison mcabber/mcabber/hbuf.c @ 1956:f309f343070c
Add command /buffer readmark
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 14 Mar 2011 23:16:11 +0100 |
parents | e8cebf5fd36c |
children | 39021fd6b0e1 |
comparison
equal
deleted
inserted
replaced
1955:fad27c72a229 | 1956:f309f343070c |
---|---|
426 hlen = g_list_length(hbuf); | 426 hlen = g_list_length(hbuf); |
427 | 427 |
428 return g_list_nth(hbuf, pc*hlen/100); | 428 return g_list_nth(hbuf, pc*hlen/100); |
429 } | 429 } |
430 | 430 |
431 // hbuf_jump_readmark(hbuf) | |
432 // Return a pointer to the line following the readmark | |
433 // or NULL if no mark was found. | |
434 GList *hbuf_jump_readmark(GList *hbuf) | |
435 { | |
436 hbuf_block *blk; | |
437 | |
438 hbuf = g_list_last(hbuf); | |
439 for ( ; hbuf; hbuf = g_list_previous(hbuf)) { | |
440 blk = (hbuf_block*)(hbuf->data); | |
441 if (blk->prefix.flags & HBB_PREFIX_READMARK) | |
442 return g_list_next(hbuf); | |
443 } | |
444 | |
445 return NULL; | |
446 } | |
447 | |
431 // hbuf_dump_to_file(hbuf, filename) | 448 // hbuf_dump_to_file(hbuf, filename) |
432 // Save the buffer to a file. | 449 // Save the buffer to a file. |
433 void hbuf_dump_to_file(GList *hbuf, const char *filename) | 450 void hbuf_dump_to_file(GList *hbuf, const char *filename) |
434 { | 451 { |
435 hbuf_block *blk; | 452 hbuf_block *blk; |
520 if (action) { | 537 if (action) { |
521 // Add a readmark flag | 538 // Add a readmark flag |
522 blk = (hbuf_block*)(hbuf->data); | 539 blk = (hbuf_block*)(hbuf->data); |
523 blk->prefix.flags ^= HBB_PREFIX_READMARK; | 540 blk->prefix.flags ^= HBB_PREFIX_READMARK; |
524 // Shift hbuf in order to remove previous flags | 541 // Shift hbuf in order to remove previous flags |
525 // (XXX maybe can be optimized out if there's no risk | 542 // (maybe it can be optimized out, if there's no risk |
526 // we have several marks) | 543 // we have several marks) |
527 hbuf = g_list_previous(hbuf); | 544 hbuf = g_list_previous(hbuf); |
528 } | 545 } |
529 | 546 |
530 // Remove old marks | 547 // Remove old mark |
531 for ( ; hbuf; hbuf = g_list_previous(hbuf)) { | 548 for ( ; hbuf; hbuf = g_list_previous(hbuf)) { |
532 blk = (hbuf_block*)(hbuf->data); | 549 blk = (hbuf_block*)(hbuf->data); |
533 if (blk->prefix.flags & HBB_PREFIX_READMARK) { | 550 if (blk->prefix.flags & HBB_PREFIX_READMARK) { |
534 blk->prefix.flags &= ~HBB_PREFIX_READMARK; | 551 blk->prefix.flags &= ~HBB_PREFIX_READMARK; |
535 break; | 552 break; |