# HG changeset patch # User Mikael Berthe # Date 1131803315 -3600 # Node ID 5a2132ba22204b0c1dbf8d3527176e489ef8a871 # Parent 16dd9b91702f34f80a13b06b8822c2aecc1a4e86 Add "/buffer up" and "/buffer down" diff -r 16dd9b91702f -r 5a2132ba2220 mcabber/src/commands.c --- a/mcabber/src/commands.c Sat Nov 12 11:33:14 2005 +0100 +++ b/mcabber/src/commands.c Sat Nov 12 14:48:35 2005 +0100 @@ -134,9 +134,11 @@ compl_add_category_word(COMPL_ROSTER, "unread_next"); // Roster category + compl_add_category_word(COMPL_BUFFER, "clear"); compl_add_category_word(COMPL_BUFFER, "bottom"); - compl_add_category_word(COMPL_BUFFER, "clear"); compl_add_category_word(COMPL_BUFFER, "top"); + compl_add_category_word(COMPL_BUFFER, "up"); + compl_add_category_word(COMPL_BUFFER, "down"); compl_add_category_word(COMPL_BUFFER, "search_backward"); compl_add_category_word(COMPL_BUFFER, "search_forward"); compl_add_category_word(COMPL_BUFFER, "date"); @@ -728,6 +730,26 @@ scr_BufferTopBottom(1); } else if (!strcasecmp(arg, "clear")) { scr_BufferClear(); + } else if (!strncasecmp(arg, "up", 2)) { + int nblines; + arg += 2; + if (*arg && *arg++ != ' ') { + scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); + return; + } + nblines = atoi(arg); + if (nblines >= 0) + scr_BufferScrollUpDown(-1, nblines); + } else if (!strncasecmp(arg, "down", 4)) { + int nblines; + arg += 4; + if (*arg && *arg++ != ' ') { + scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); + return; + } + nblines = atoi(arg); + if (nblines >= 0) + scr_BufferScrollUpDown(1, nblines); } else if (!strncasecmp(arg, "search_backward", 15)) { arg += 15; if (*arg++ == ' ') diff -r 16dd9b91702f -r 5a2132ba2220 mcabber/src/screen.c --- a/mcabber/src/screen.c Sat Nov 12 11:33:14 2005 +0100 +++ b/mcabber/src/screen.c Sat Nov 12 14:48:35 2005 +0100 @@ -985,12 +985,13 @@ } // scr_BufferScrollUpDown() -// Scroll up/down the current buddy window, half a screen. -// (up if updown == -1, down if updown == 1) -void scr_BufferScrollUpDown(int updown) +// Scroll up/down the current buddy window, +// - half a screen if nblines is 0, +// - up if updown == -1, down if updown == 1 +void scr_BufferScrollUpDown(int updown, unsigned int nblines) { window_entry_t *win_entry; - int n, nblines; + int n, nbl; GList *hbuf_top; // Get win_entry @@ -998,23 +999,27 @@ win_entry = scr_SearchWindow(CURRENT_JID); if (!win_entry) return; - // Scroll half a screen (or less) - nblines = CHAT_WIN_HEIGHT/2-1; + if (!nblines) { + // Scroll half a screen (or less) + nbl = CHAT_WIN_HEIGHT/2-1; + } else { + nbl = nblines; + } hbuf_top = win_entry->top; if (updown == -1) { // UP if (!hbuf_top) { hbuf_top = g_list_last(win_entry->hbuf); - if (!win_entry->cleared) - nblines *= 3; + if (!nblines && !win_entry->cleared) + nbl *= 3; else win_entry->cleared = FALSE; } - for (n=0 ; hbuf_top && n < nblines && g_list_previous(hbuf_top) ; n++) + for (n=0 ; hbuf_top && n < nbl && g_list_previous(hbuf_top) ; n++) hbuf_top = g_list_previous(hbuf_top); win_entry->top = hbuf_top; } else { // DOWN - for (n=0 ; hbuf_top && n < nblines ; n++) + for (n=0 ; hbuf_top && n < nbl ; n++) hbuf_top = g_list_next(hbuf_top); win_entry->top = hbuf_top; // Check if we are at the bottom @@ -1668,10 +1673,10 @@ *ptr_inputline = 0; break; case 16: // Ctrl-p - scr_BufferScrollUpDown(-1); + scr_BufferScrollUpDown(-1, 0); break; case 14: // Ctrl-n - scr_BufferScrollUpDown(1); + scr_BufferScrollUpDown(1, 0); break; case 17: // Ctrl-q scr_CheckAutoAway(TRUE); diff -r 16dd9b91702f -r 5a2132ba2220 mcabber/src/screen.h --- a/mcabber/src/screen.h Sat Nov 12 11:33:14 2005 +0100 +++ b/mcabber/src/screen.h Sat Nov 12 14:48:35 2005 +0100 @@ -59,5 +59,6 @@ void scr_BufferDate(time_t t); void scr_RosterUnreadMessage(int); void scr_RosterJumpAlternate(void); +void scr_BufferScrollUpDown(int updown, unsigned int nblines); #endif