AmendHub

Download:

jcs

/

wallops

/

amendments

/

116

chatter: If the user tries typing more than allowed, beep

Also prevent sending blank messages :/

jcs made amendment 116 about 1 month ago
--- chatter.c Tue Sep 17 15:40:13 2024 +++ chatter.c Tue Sep 17 22:10:43 2024 @@ -1036,15 +1036,19 @@ chatter_key_down(struct focusable *focusable, EventRec chatter->tab_comp_input[0] = '\0'; chatter->tab_comp_match[0] = '\0'; } - + + HLock(chatter->input_te); + te = *(chatter->input_te); + if (k == '\r') { - HLock(chatter->input_te); - te = *(chatter->input_te); + if (te->teLength == 0) { + HUnlock(chatter->input_te); + return; + } HLock(te->hText); memcpy(chatter->input, *(te->hText), MIN(te->teLength, sizeof(chatter->input) - 1)); HUnlock(te->hText); - HUnlock(chatter->input_te); chatter->input[MIN(te->teLength, sizeof(chatter->input) - 1)] = '\0'; EraseRect(&te->viewRect); chatter_set_input(chatter, "", 0); @@ -1053,7 +1057,10 @@ chatter_key_down(struct focusable *focusable, EventRec } else if (te->teLength < IRC_MAX_MSG_SIZE - 1) { TEKey(k, chatter->input_te); TESelView(chatter->input_te); - } + } else + SysBeep(10); + + HUnlock(chatter->input_te); } struct chatter_tab * @@ -1258,7 +1265,7 @@ no_overflow: SetClip(savergn); DisposeRgn(savergn); - if (!had_activity) { + if (!had_activity && !tab->ignore_activity) { tab->have_activity = true; chatter_draw_tab_bar(chatter); } --- chatter.h Mon Sep 16 16:37:58 2024 +++ chatter.h Tue Sep 17 16:06:44 2024 @@ -80,6 +80,7 @@ struct chatter_tab { ListHandle nick_list; Rect label_rect; bool have_activity; + bool ignore_activity; }; SLIST_HEAD(chatter_tabs_head, chatter_tab);