commit b8c5c0ce30494fc72ab3f545456470f2668e0c1a
parent 3d1df3f96c44b1addff2bfeb4cc9a2b1b213a05d
Author: hhvn <dev@hhvn.uk>
Date: Sun, 31 Oct 2021 00:33:40 +0100
ui.c: index buffers starting at 1
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/ui.c b/ui.c
@@ -306,7 +306,7 @@ ui_buflist_count(int *ret_servers, int *ret_channels) {
if (ret_channels)
*ret_channels = cc;
- return sc + cc;
+ return sc + cc + 1;
}
void
@@ -315,12 +315,17 @@ ui_buflist_select(int num) {
struct Channel *chp;
int i;
- if (num == 0) {
+ if (num <= 0) {
+ ui_error("buffer index greater than 0 expected", NULL);
+ return;
+ }
+
+ if (num == 1) {
ui_select(NULL, NULL);
return;
}
- for (i = 1, sp = servers; sp; sp = sp->next, i++) {
+ for (i = 2, sp = servers; sp; sp = sp->next, i++) {
if (i == num) {
ui_select(sp, NULL);
return;
@@ -339,7 +344,7 @@ void
ui_draw_buflist(void) {
struct Server *sp;
struct Channel *chp;
- int i = 0, len, tmp;
+ int i = 1, len, tmp;
int sc, cc;
wclear(windows[Win_buflist].window);