commit 3b8370e70fc41acf5764bad589ea56fdf2022ff4
parent cc5e34a83e8cb8c2867cdd76610ccd26277c9f16
Author: hhvn <dev@hhvn.uk>
Date: Wed, 15 Dec 2021 19:27:13 +0000
s/ui.c s/config.c: nicklist scrolling
Diffstat:
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/config.c b/src/config.c
@@ -319,6 +319,11 @@ struct Config config[] = {
.strhandle = config_redraws,
.description = {
"Indicator for buffer with activity of level `hilight`", NULL}},
+ {"format.ui.nicklist.more", 1, Val_string,
+ .str = "%{c:92}...",
+ .strhandle = config_redraws,
+ .description = {
+ "Shown if there are more nicks that must be scrolled to see.", NULL}},
{"format.ui.separator.vertical", 1, Val_string,
.str = "│",
.strhandle = config_redraws,
diff --git a/src/ui.c b/src/ui.c
@@ -635,7 +635,7 @@ ui_draw_input(void) {
void
ui_draw_nicklist(void) {
struct Nick *p;
- int y;
+ int y = 0, i;
ui_wclear(&windows[Win_nicklist]);
@@ -645,11 +645,23 @@ ui_draw_nicklist(void) {
wmove(windows[Win_nicklist].window, 0, 0);
nick_sort(&selected.channel->nicks, selected.server);
- /* TODO: more nicks than screen height? */
- for (p = selected.channel->nicks; p; p = p->next) {
- ui_wprintc(&windows[Win_nicklist], 0, "%c%02d%c%s\n",
+
+ for (i=0, p = selected.channel->nicks; p && p->next && p->next->next && i < windows[Win_nicklist].scroll; i++)
+ p = p->next;
+ if (i != 0) {
+ ui_wprintc(&windows[Win_nicklist], 1, "%s\n", ui_format(config_gets("format.ui.nicklist.more"), NULL));
+ y++;
+ p = p->next;
+ windows[Win_nicklist].scroll = i;
+ }
+
+ for (; p && y < windows[Win_nicklist].h - (p->next ? 1 : 0); p = p->next, y++) {
+ ui_wprintc(&windows[Win_nicklist], 1, "%c%02d%c%s\n",
3 /* ^C */, nick_getcolour(p), p->priv, p->nick);
}
+
+ if (p)
+ ui_wprintc(&windows[Win_nicklist], 1, "%s\n", ui_format(config_gets("format.ui.nicklist.more"), NULL));
}
int