--- a/mcabber/src/commands.c Wed Sep 28 21:56:35 2005 +0200
+++ b/mcabber/src/commands.c Thu Sep 29 21:28:39 2005 +0200
@@ -136,6 +136,7 @@
compl_add_category_word(COMPL_BUFFER, "top");
compl_add_category_word(COMPL_BUFFER, "search_backward");
compl_add_category_word(COMPL_BUFFER, "search_forward");
+ compl_add_category_word(COMPL_BUFFER, "%");
// Group category
compl_add_category_word(COMPL_GROUP, "fold");
@@ -659,6 +660,13 @@
search_dir = 1;
else
scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter");
+ } else if (*arg == '%') {
+ arg++;
+ while (*arg == ' ') arg++;
+ if (*arg)
+ scr_BufferPercent(atoi(arg));
+ else
+ scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter");
} else
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!");
--- a/mcabber/src/hbuf.c Wed Sep 28 21:56:35 2005 +0200
+++ b/mcabber/src/hbuf.c Thu Sep 29 21:28:39 2005 +0200
@@ -295,3 +295,15 @@
return hbuf;
}
+
+// hbuf_jump_percent(hbuf, pc)
+// Return a pointer to the line at % pc of the history buffer
+GList *hbuf_jump_percent(GList *hbuf, int pc)
+{
+ guint hlen;
+
+ hbuf = g_list_first(hbuf);
+ hlen = g_list_length(hbuf);
+
+ return g_list_nth(hbuf, pc*hlen/100);
+}
--- a/mcabber/src/hbuf.h Wed Sep 28 21:56:35 2005 +0200
+++ b/mcabber/src/hbuf.h Thu Sep 29 21:28:39 2005 +0200
@@ -35,5 +35,6 @@
hbb_line **hbuf_get_lines(GList *hbuf, unsigned int n);
GList *hbuf_search(GList *hbuf, int direction, const char *string);
+GList *hbuf_jump_percent(GList *hbuf, int pc);
#endif /* __HBUF_H__ */
--- a/mcabber/src/screen.c Wed Sep 28 21:56:35 2005 +0200
+++ b/mcabber/src/screen.c Thu Sep 29 21:28:39 2005 +0200
@@ -1093,6 +1093,36 @@
scr_LogPrint(LPRINT_NORMAL, "Search string not found");
}
+// scr_BufferPercent(n)
+// Jump to the specified position in the buffer, in %
+void scr_BufferPercent(int pc)
+{
+ window_entry_t *win_entry;
+ GList *search_res;
+
+ // Get win_entry
+ if (!current_buddy) return;
+ win_entry = scr_SearchWindow(CURRENT_JID);
+ if (!win_entry) return;
+
+ if (pc < 0 || pc > 100) {
+ scr_LogPrint(LPRINT_NORMAL, "Bad % value");
+ return;
+ }
+
+ search_res = hbuf_jump_percent(win_entry->hbuf, pc);
+
+ win_entry->cleared = FALSE;
+ win_entry->top = search_res;
+
+ // Refresh the window
+ scr_UpdateWindow(win_entry);
+
+ // Finished :)
+ update_panels();
+ doupdate();
+}
+
// scr_set_chatmode()
// Public function to (un)set chatmode...
inline void scr_set_chatmode(int enable)
--- a/mcabber/src/screen.h Wed Sep 28 21:56:35 2005 +0200
+++ b/mcabber/src/screen.h Thu Sep 29 21:28:39 2005 +0200
@@ -54,6 +54,7 @@
void scr_BufferTopBottom(int topbottom);
void scr_BufferClear(void);
void scr_BufferSearch(int direction, const char *text);
+void scr_BufferPercent(int pc);
void scr_RosterUnreadMessage(int);
void scr_RosterJumpAlternate(void);