AmendHub

Download:

jcs

/

wallops

/

amendments

/

68

chatter: Open query window when double-clicking a nick in a chan list

Remove index, not used

jcs made amendment 68 2 months ago
--- chatter.c Sun Sep 8 16:07:36 2024 +++ chatter.c Sun Sep 8 17:08:17 2024 @@ -239,7 +239,7 @@ chatter_add_tab(struct chatter *chatter, Rect *win_bou if (tab == NULL) panic("xmalloc failed: out of memory"); SLIST_APPEND(&chatter->tabs_list, tab, chatter_tab, list); - tab->index = chatter->ntabs++; + chatter->ntabs++; tab->conn = conn; tab->channel = channel; if (query_nick) @@ -732,6 +732,8 @@ chatter_mouse_down(struct focusable *focusable, EventR ControlHandle control; Rect r; short val, adj, ret, part, n; + bool dclick; + char nick[member_size(struct irc_user, nick) + 1]; p = event->where; GlobalToLocal(&p); @@ -741,14 +743,25 @@ chatter_mouse_down(struct focusable *focusable, EventR r.right += SCROLLBAR_WIDTH; if (PtInRect(p, &r)) { /* store what is selected now */ - ret = LGetSelect(true, &selected, tab->nick_list); + LGetSelect(true, &selected, tab->nick_list); /* possibly highlight a new cell */ - LClick(p, event->modifiers, tab->nick_list); + dclick = LClick(p, event->modifiers, tab->nick_list); - if (selected.v != now.v) { + LGetSelect(true, &now, tab->nick_list); + + if (selected.v != now.v) LSetSelect(false, selected, tab->nick_list); - /* TODO: detect double-click, open query window? */ + + if (dclick) { + /* double-click, query this user (or focus existing) */ + n = sizeof(nick) - 2; + LGetCell(&nick, &n, now, tab->nick_list); + nick[n] = '\0'; + n = 0; + if (nick[0] == '@' || nick[0] == '+') + n = 1; + chatter_add_tab(chatter, NULL, tab->conn, NULL, nick + n); } return; @@ -1207,6 +1220,7 @@ chatter_close_tab(struct chatter *chatter, struct chat DisposeControl(tab->messages_scroller); TEDispose(tab->messages_te); SLIST_REMOVE(&chatter->tabs_list, tab, chatter_tab, list); + chatter->ntabs--; if (chatter->current_tab == tab) chatter->current_tab = NULL; --- chatter.h Thu Sep 5 21:25:04 2024 +++ chatter.h Sun Sep 8 17:08:04 2024 @@ -57,7 +57,6 @@ struct chatter_tab { struct irc_connection *conn; struct irc_channel *channel; char query_nick[member_size(struct irc_user, nick)]; - short index; TEHandle messages_te; ControlHandle messages_scroller; ListHandle nick_list;