changeset 1573:ece4f26bf9ff

Add count parameter to roster up/down command (Based on a patch from knyar in the issue tracker)
author Mikael Berthe <mikael@lilotux.net>
date Mon, 13 Apr 2009 00:26:56 +0200
parents 8c0237c8c186
children 5bb4b580f229
files mcabber/src/commands.c mcabber/src/screen.c mcabber/src/screen.h
diffstat 3 files changed, 34 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/commands.c	Sat Apr 11 12:30:51 2009 +0200
+++ b/mcabber/src/commands.c	Mon Apr 13 00:26:56 2009 +0200
@@ -633,6 +633,21 @@
   }
 }
 
+//  roster_updown(updown, nitems)
+// updown: -1=up, +1=down
+inline static void roster_updown(int updown, char *nitems)
+{
+  int nbitems;
+
+  if (!nitems || !*nitems)
+    nbitems = 1;
+  else
+    nbitems = strtol(nitems, NULL, 10);
+
+  if (nbitems > 0)
+    scr_RosterUpDown(updown, nbitems);
+}
+
 /* Commands callback functions */
 /* All these do_*() functions will be called with a "arg" parameter */
 /* (with arg not null)                                              */
@@ -701,9 +716,9 @@
     scr_RosterSearch(arg);
     update_roster = TRUE;
   } else if (!strcasecmp(subcmd, "up")) {
-    scr_RosterUp();
+    roster_updown(-1, arg);
   } else if (!strcasecmp(subcmd, "down")) {
-    scr_RosterDown();
+    roster_updown(1, arg);
   } else if (!strcasecmp(subcmd, "group_prev")) {
     scr_RosterPrevGroup();
   } else if (!strcasecmp(subcmd, "group_next")) {
@@ -1534,7 +1549,7 @@
   if (!nlines || !*nlines)
     nblines = 0;
   else
-    nblines = atoi(nlines);
+    nblines = strtol(nlines, NULL, 10);
 
   if (nblines >= 0)
     scr_BufferScrollUpDown(updown, nblines);
@@ -1934,7 +1949,7 @@
     foreach_group_member(bud, &move_group_member, name_utf8);
     // Let's jump to the previous buddy, because this group name should
     // disappear when we receive the server answer.
-    scr_RosterUp();
+    scr_RosterUpDown(-1, 1);
   } else {
     // Rename a single buddy
     guint del_name = 0;
@@ -1988,7 +2003,7 @@
     guint msgflag;
 
     jb_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL);
-    scr_RosterUp();
+    scr_RosterUpDown(-1, 1);
 
     // If the buddy has a pending message flag,
     // we remove it temporarily in order to reset the global group
--- a/mcabber/src/screen.c	Sat Apr 11 12:30:51 2009 +0200
+++ b/mcabber/src/screen.c	Mon Apr 13 00:26:56 2009 +0200
@@ -2253,20 +2253,20 @@
     scr_ShowBuddyWindow();
 }
 
-//  scr_RosterUp()
-// Go to the previous buddy in the buddylist
-void scr_RosterUp(void)
+//  scr_RosterUpDown(updown, n)
+// Go to the nth next buddy in the buddylist
+// (up if updown == -1, down if updown == 1)
+void scr_RosterUpDown(int updown, unsigned int n)
 {
-  set_current_buddy(g_list_previous(current_buddy));
-  if (chatmode)
-    scr_ShowBuddyWindow();
-}
-
-//  scr_RosterDown()
-// Go to the next buddy in the buddylist
-void scr_RosterDown(void)
-{
-  set_current_buddy(g_list_next(current_buddy));
+  unsigned int i;
+
+  if (updown < 0) {
+    for (i = 0; i < n; i++)
+      set_current_buddy(g_list_previous(current_buddy));
+  } else {
+    for (i = 0; i < n; i++)
+      set_current_buddy(g_list_next(current_buddy));
+  }
   if (chatmode)
     scr_ShowBuddyWindow();
 }
--- a/mcabber/src/screen.h	Sat Apr 11 12:30:51 2009 +0200
+++ b/mcabber/src/screen.h	Mon Apr 13 00:26:56 2009 +0200
@@ -130,8 +130,7 @@
 // For commands...
 void scr_RosterTop(void);
 void scr_RosterBottom(void);
-void scr_RosterUp(void);
-void scr_RosterDown(void);
+void scr_RosterUpDown(int updown, unsigned int n);
 void scr_RosterPrevGroup(void);
 void scr_RosterNextGroup(void);
 void scr_RosterSearch(char *);