McKael / mcabber (http://mcabber.com)
Mirror of the mcabber upstream repository. MCabber is a small Jabber console client.
| commit 1573: | ece4f26bf9ff |
| parent 1572: | 8c0237c8c186 |
| branch: | default |
Add count parameter to roster up/down command
(Based on a patch from knyar in the issue tracker)
Changed (Δ400 bytes):
raw changeset »
mcabber/src/commands.c (20 lines added, 5 lines removed)
mcabber/src/screen.c (14 lines added, 14 lines removed)
mcabber/src/screen.h (1 lines added, 2 lines removed)
Up to file-list mcabber/src/commands.c:
| … | … | @@ -633,6 +633,21 @@ static void roster_note(char *arg) |
633 |
633 |
} |
634 |
634 |
} |
635 |
635 |
|
636 |
// roster_updown(updown, nitems) |
|
637 |
// updown: -1=up, +1=down |
|
638 |
inline static void roster_updown(int updown, char *nitems) |
|
639 |
{ |
|
640 |
int nbitems; |
|
641 |
||
642 |
if (!nitems || !*nitems) |
|
643 |
nbitems = 1; |
|
644 |
else |
|
645 |
nbitems = strtol(nitems, NULL, 10); |
|
646 |
||
647 |
if (nbitems > 0) |
|
648 |
scr_RosterUpDown(updown, nbitems); |
|
649 |
} |
|
650 |
||
636 |
651 |
/* Commands callback functions */ |
637 |
652 |
/* All these do_*() functions will be called with a "arg" parameter */ |
638 |
653 |
/* (with arg not null) */ |
| … | … | @@ -701,9 +716,9 @@ static void do_roster(char *arg) |
701 |
716 |
scr_RosterSearch(arg); |
702 |
717 |
update_roster = TRUE; |
703 |
718 |
} else if (!strcasecmp(subcmd, "up")) { |
704 |
|
|
719 |
roster_updown(-1, arg); |
|
705 |
720 |
} else if (!strcasecmp(subcmd, "down")) { |
706 |
|
|
721 |
roster_updown(1, arg); |
|
707 |
722 |
} else if (!strcasecmp(subcmd, "group_prev")) { |
708 |
723 |
scr_RosterPrevGroup(); |
709 |
724 |
} else if (!strcasecmp(subcmd, "group_next")) { |
| … | … | @@ -1534,7 +1549,7 @@ inline static void buffer_updown(int upd |
1534 |
1549 |
if (!nlines || !*nlines) |
1535 |
1550 |
nblines = 0; |
1536 |
1551 |
else |
1537 |
nblines = |
|
1552 |
nblines = strtol(nlines, NULL, 10); |
|
1538 |
1553 |
|
1539 |
1554 |
if (nblines >= 0) |
1540 |
1555 |
scr_BufferScrollUpDown(updown, nblines); |
| … | … | @@ -1934,7 +1949,7 @@ static void do_rename(char *arg) |
1934 |
1949 |
foreach_group_member(bud, &move_group_member, name_utf8); |
1935 |
1950 |
// Let's jump to the previous buddy, because this group name should |
1936 |
1951 |
// disappear when we receive the server answer. |
1937 |
scr_RosterUp |
|
1952 |
scr_RosterUpDown(-1, 1); |
|
1938 |
1953 |
} else { |
1939 |
1954 |
// Rename a single buddy |
1940 |
1955 |
guint del_name = 0; |
| … | … | @@ -1988,7 +2003,7 @@ static void do_move(char *arg) |
1988 |
2003 |
guint msgflag; |
1989 |
2004 |
|
1990 |
2005 |
jb_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL); |
1991 |
scr_RosterUp |
|
2006 |
scr_RosterUpDown(-1, 1); |
|
1992 |
2007 |
|
1993 |
2008 |
// If the buddy has a pending message flag, |
1994 |
2009 |
// we remove it temporarily in order to reset the global group |
Up to file-list mcabber/src/screen.c:
| … | … | @@ -2253,20 +2253,20 @@ void scr_RosterBottom(void) |
2253 |
2253 |
scr_ShowBuddyWindow(); |
2254 |
2254 |
} |
2255 |
2255 |
|
2256 |
// scr_RosterUp() |
|
2257 |
// Go to the previous buddy in the buddylist |
|
2258 |
void scr_RosterUp(void) |
|
2259 |
{ |
|
2260 |
set_current_buddy(g_list_previous(current_buddy)); |
|
2261 |
if (chatmode) |
|
2262 |
scr_ShowBuddyWindow(); |
|
2263 |
} |
|
2264 |
||
2265 |
// scr_RosterDown() |
|
2266 |
// Go to the next buddy in the buddylist |
|
2267 |
void scr_RosterDown(void) |
|
2268 |
{ |
|
2269 |
set_current_buddy(g_list_next(current_buddy)); |
|
2256 |
// scr_RosterUpDown(updown, n) |
|
2257 |
// Go to the nth next buddy in the buddylist |
|
2258 |
// (up if updown == -1, down if updown == 1) |
|
2259 |
void scr_RosterUpDown(int updown, unsigned int n) |
|
2260 |
{ |
|
2261 |
unsigned int i; |
|
2262 |
||
2263 |
if (updown < 0) { |
|
2264 |
for (i = 0; i < n; i++) |
|
2265 |
set_current_buddy(g_list_previous(current_buddy)); |
|
2266 |
} else { |
|
2267 |
for (i = 0; i < n; i++) |
|
2268 |
set_current_buddy(g_list_next(current_buddy)); |
|
2269 |
} |
|
2270 |
2270 |
if (chatmode) |
2271 |
2271 |
scr_ShowBuddyWindow(); |
2272 |
2272 |
} |
Up to file-list mcabber/src/screen.h:
| … | … | @@ -130,8 +130,7 @@ int chatstates_disabled; |
130 |
130 |
// For commands... |
131 |
131 |
void scr_RosterTop(void); |
132 |
132 |
void scr_RosterBottom(void); |
133 |
void scr_RosterUp(void); |
|
134 |
void scr_RosterDown(void); |
|
133 |
void scr_RosterUpDown(int updown, unsigned int n); |
|
135 |
134 |
void scr_RosterPrevGroup(void); |
136 |
135 |
void scr_RosterNextGroup(void); |
137 |
136 |
void scr_RosterSearch(char *); |
