Mercurial > hg
changeset 1956:f309f343070c
Add command /buffer readmark
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 14 Mar 2011 23:16:11 +0100 |
parents | fad27c72a229 |
children | e3e8fb918d56 |
files | mcabber/mcabber/commands.c mcabber/mcabber/hbuf.c mcabber/mcabber/hbuf.h mcabber/mcabber/screen.c mcabber/mcabber/screen.h |
diffstat | 5 files changed, 50 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/mcabber/commands.c Mon Mar 14 15:04:00 2011 +0100 +++ b/mcabber/mcabber/commands.c Mon Mar 14 23:16:11 2011 +0100 @@ -1730,6 +1730,8 @@ scr_buffer_dump(arg); } else if (!strcasecmp(subcmd, "list")) { scr_buffer_list(); + } else if (!strcasecmp(subcmd, "readmark")) { + scr_buffer_jump_readmark(); } else { scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); }
--- a/mcabber/mcabber/hbuf.c Mon Mar 14 15:04:00 2011 +0100 +++ b/mcabber/mcabber/hbuf.c Mon Mar 14 23:16:11 2011 +0100 @@ -428,6 +428,23 @@ return g_list_nth(hbuf, pc*hlen/100); } +// hbuf_jump_readmark(hbuf) +// Return a pointer to the line following the readmark +// or NULL if no mark was found. +GList *hbuf_jump_readmark(GList *hbuf) +{ + hbuf_block *blk; + + hbuf = g_list_last(hbuf); + for ( ; hbuf; hbuf = g_list_previous(hbuf)) { + blk = (hbuf_block*)(hbuf->data); + if (blk->prefix.flags & HBB_PREFIX_READMARK) + return g_list_next(hbuf); + } + + return NULL; +} + // hbuf_dump_to_file(hbuf, filename) // Save the buffer to a file. void hbuf_dump_to_file(GList *hbuf, const char *filename) @@ -522,12 +539,12 @@ blk = (hbuf_block*)(hbuf->data); blk->prefix.flags ^= HBB_PREFIX_READMARK; // Shift hbuf in order to remove previous flags - // (XXX maybe can be optimized out if there's no risk + // (maybe it can be optimized out, if there's no risk // we have several marks) hbuf = g_list_previous(hbuf); } - // Remove old marks + // Remove old mark for ( ; hbuf; hbuf = g_list_previous(hbuf)) { blk = (hbuf_block*)(hbuf->data); if (blk->prefix.flags & HBB_PREFIX_READMARK) {
--- a/mcabber/mcabber/hbuf.h Mon Mar 14 15:04:00 2011 +0100 +++ b/mcabber/mcabber/hbuf.h Mon Mar 14 23:16:11 2011 +0100 @@ -49,6 +49,7 @@ GList *hbuf_search(GList *hbuf, int direction, const char *string); GList *hbuf_jump_date(GList *hbuf, time_t t); GList *hbuf_jump_percent(GList *hbuf, int pc); +GList *hbuf_jump_readmark(GList *hbuf); gboolean hbuf_remove_receipt(GList *hbuf, gpointer xep184); void hbuf_set_readmark(GList *hbuf, gboolean action);
--- a/mcabber/mcabber/screen.c Mon Mar 14 15:04:00 2011 +0100 +++ b/mcabber/mcabber/screen.c Mon Mar 14 23:16:11 2011 +0100 @@ -2946,6 +2946,33 @@ update_panels(); } +// scr_buffer_jump_readmark() +// Jump to the buffer readmark, if there's one +void scr_buffer_jump_readmark(void) +{ + winbuf *win_entry; + GList *search_res; + guint isspe; + + // Get win_entry + if (!current_buddy) return; + isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; + if (isspe) return; + win_entry = scr_search_window(CURRENT_JID, isspe); + if (!win_entry) return; + + search_res = hbuf_jump_readmark(win_entry->bd->hbuf); + + win_entry->bd->cleared = FALSE; + win_entry->bd->top = search_res; + + // Refresh the window + scr_update_window(win_entry); + + // Finished :) + update_panels(); +} + // scr_buffer_dump(filename) // Dump the current buffer content to the specified file. void scr_buffer_dump(const char *file)
--- a/mcabber/mcabber/screen.h Mon Mar 14 15:04:00 2011 +0100 +++ b/mcabber/mcabber/screen.h Mon Mar 14 23:16:11 2011 +0100 @@ -156,6 +156,7 @@ void scr_buffer_list(void); void scr_buffer_scroll_up_down(int updown, unsigned int nblines); void scr_buffer_readmark(gboolean action); +void scr_buffer_jump_readmark(void); bool scr_roster_color(const char *status, const char *wildcard, const char *color);