jcs
/subtext
/amendments
/244
chat: Previous change to drawing reverse bar isn't widely compatible
Go back to padding it with spaces.
jcs made amendment 244 over 2 years ago
--- chat.c Wed Jul 20 09:32:36 2022
+++ chat.c Sat Aug 13 14:49:46 2022
@@ -147,6 +147,8 @@ chat_printf_line(struct session *s, short around_bar,
void
chat_start(struct session *s, char *with_node)
{
+ static char chat_bar[255];
+ size_t len;
char *input;
bool lagged = false;
@@ -169,10 +171,20 @@ chat_start(struct session *s, char *with_node)
ansi(s, ANSI_BOLD, ANSI_END), ansi(s, ANSI_RESET, ANSI_END));
session_flush(s);
- session_printf(s, "\r%s [ %s ] [ Chatting with %s ]%s\r\n",
- ansi(s, ANSI_REVERSE, ANSI_ERASE_LINE, ANSI_END),
+ len = snprintf(chat_bar, sizeof(chat_bar),
+ " [ %s ] [ Chatting with %s ] ",
s->user ? s->user->username : "guest",
- s->chatting_with_node[0] ? "..." : "everyone",
+ s->chatting_with_node[0] ? "..." : "everyone");
+
+ while (len < sizeof(chat_bar) && len < s->terminal_columns) {
+ chat_bar[len - 1] = ' ';
+ chat_bar[len] = '\0';
+ len++;
+ }
+
+ session_printf(s, "\r%s%s%s\r\n",
+ ansi(s, ANSI_REVERSE, ANSI_ERASE_LINE, ANSI_END),
+ chat_bar,
ansi(s, ANSI_RESET, ANSI_END));
session_flush(s);