Sort channels and private chats in the tree
This commit is contained in:
parent
410990c63d
commit
38dca11cf8
2 changed files with 26 additions and 5 deletions
|
|
@ -123,7 +123,8 @@ Build yours by copying `irc9rc-example` to `irc9rc` next to the binary (or to
|
|||
```
|
||||
|
||||
The left column is a tree: each server and its windows (channels and private
|
||||
message windows). An unread window shows `(n)` next to its name. `*` marks a
|
||||
message windows). Channels appear before private message windows, with
|
||||
uppercase names sorting before lowercase names in each group. An unread window shows `(n)` next to its name. `*` marks a
|
||||
connected server. The selected server or window is shown bold and underlined. Highlights use the
|
||||
terminal's default background so transparency is preserved where supported.
|
||||
Channel topics wrap to the chat pane width and stay at the top while you scroll.
|
||||
|
|
|
|||
28
irc9.c
28
irc9.c
|
|
@ -290,17 +290,25 @@ static Window *reply_window(Server *s)
|
|||
/* ------------------------------------------------------------------ */
|
||||
/* windows and scrollback */
|
||||
|
||||
static void window_insert(Server *s, Window *w)
|
||||
{
|
||||
Window **link = &s->windows;
|
||||
while (*link && ((*link)->type < w->type ||
|
||||
((*link)->type == w->type && strcmp((*link)->name, w->name) <= 0)))
|
||||
link = &(*link)->next;
|
||||
w->next = *link;
|
||||
*link = w;
|
||||
}
|
||||
|
||||
static Window *window_new(Server *s, const char *name, Wintype type)
|
||||
{
|
||||
Window *w = xmalloc(sizeof *w);
|
||||
Window **tail = &s->windows;
|
||||
memset(w, 0, sizeof *w);
|
||||
snprintf(w->name, sizeof w->name, "%s", name);
|
||||
w->type = type;
|
||||
w->srv = s;
|
||||
w->lines = xalloc_array(MAXSCROLL, sizeof *w->lines);
|
||||
while (*tail) tail = &(*tail)->next;
|
||||
*tail = w;
|
||||
window_insert(s, w);
|
||||
return w;
|
||||
}
|
||||
|
||||
|
|
@ -1316,14 +1324,26 @@ static void handle_line(Server *s, char *line)
|
|||
if (strcasecmp(cmd, "NICK") == 0) {
|
||||
if (narg < 1) return;
|
||||
int in_channel = 0;
|
||||
for (Window *w = s->windows; w; w = w->next) {
|
||||
Window *renamed = NULL;
|
||||
for (Window **link = &s->windows; *link; ) {
|
||||
Window *w = *link;
|
||||
if (w->type == W_CHANNEL && member_find(w, nick)) {
|
||||
member_rename(w, nick, arg[0]);
|
||||
if (!silent) append_nickf(w, "* ", nick, " ", "is now known as %s", arg[0]);
|
||||
in_channel = 1;
|
||||
} else if (w->type == W_QUERY && strcasecmp(w->name, nick) == 0) {
|
||||
snprintf(w->name, sizeof w->name, "%s", arg[0]);
|
||||
*link = w->next;
|
||||
w->next = renamed;
|
||||
renamed = w;
|
||||
continue;
|
||||
}
|
||||
link = &w->next;
|
||||
}
|
||||
while (renamed) {
|
||||
Window *w = renamed;
|
||||
renamed = w->next;
|
||||
window_insert(s, w);
|
||||
}
|
||||
if (strcasecmp(nick, s->nick) == 0)
|
||||
snprintf(s->nick, sizeof s->nick, "%s", arg[0]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue