xC: mIRC didn't invent all IRC formatting

So let's not confuse ourselves.
This commit is contained in:
Přemysl Eric Janouch 2021-08-29 12:07:31 +02:00
parent de7df1f60d
commit 9323089d66
Signed by: p
GPG Key ID: A0420B94F92B9493

24
xC.c
View File

@ -1448,7 +1448,7 @@ enum formatter_item_type
FORMATTER_ITEM_ATTR, ///< Formatting attributes FORMATTER_ITEM_ATTR, ///< Formatting attributes
FORMATTER_ITEM_FG_COLOR, ///< Foreground colour FORMATTER_ITEM_FG_COLOR, ///< Foreground colour
FORMATTER_ITEM_BG_COLOR, ///< Background colour FORMATTER_ITEM_BG_COLOR, ///< Background colour
FORMATTER_ITEM_SIMPLE, ///< Toggle mIRC formatting FORMATTER_ITEM_SIMPLE, ///< Toggle IRC formatting
FORMATTER_ITEM_IGNORE_ATTR ///< Un/set attribute ignoration FORMATTER_ITEM_IGNORE_ATTR ///< Un/set attribute ignoration
}; };
@ -2089,7 +2089,7 @@ struct app_context
int *nick_palette; ///< A 256-colour palette for nicknames int *nick_palette; ///< A 256-colour palette for nicknames
size_t nick_palette_len; ///< Number of entries in nick_palette size_t nick_palette_len; ///< Number of entries in nick_palette
bool awaiting_mirc_escape; ///< Awaiting a mIRC attribute escape bool awaiting_formatting_escape; ///< Awaiting an IRC formatting escape
bool in_bracketed_paste; ///< User is pasting some content bool in_bracketed_paste; ///< User is pasting some content
struct str input_buffer; ///< Buffered pasted content struct str input_buffer; ///< Buffered pasted content
@ -3123,7 +3123,7 @@ irc_to_utf8 (const char *text)
// #l inserts a locale-encoded string // #l inserts a locale-encoded string
// //
// #S inserts a string from the server with unknown encoding // #S inserts a string from the server with unknown encoding
// #m inserts a mIRC-formatted string (auto-resets at boundaries) // #m inserts an IRC-formatted string (auto-resets at boundaries)
// #n cuts the nickname from a string and automatically colours it // #n cuts the nickname from a string and automatically colours it
// #N is like #n but also appends userhost, if present // #N is like #n but also appends userhost, if present
// //
@ -3322,7 +3322,7 @@ formatter_parse_mirc_color (struct formatter *self, const char *s)
} }
static void static void
formatter_parse_mirc (struct formatter *self, const char *s) formatter_parse_message (struct formatter *self, const char *s)
{ {
FORMATTER_ADD_RESET (self); FORMATTER_ADD_RESET (self);
@ -3454,7 +3454,7 @@ restart:
break; break;
case 'm': case 'm':
tmp = irc_to_utf8 ((s = va_arg (*ap, char *))); tmp = irc_to_utf8 ((s = va_arg (*ap, char *)));
formatter_parse_mirc (self, tmp); formatter_parse_message (self, tmp);
free (tmp); free (tmp);
break; break;
case 'n': case 'n':
@ -6286,7 +6286,7 @@ irc_is_highlight (struct server *s, const char *message)
// Strip formatting from the message so that it doesn't interfere // Strip formatting from the message so that it doesn't interfere
// with nickname detection (colour sequences in particular) // with nickname detection (colour sequences in particular)
struct formatter f = formatter_make (s->ctx, NULL); struct formatter f = formatter_make (s->ctx, NULL);
formatter_parse_mirc (&f, message); formatter_parse_message (&f, message);
struct str stripped = str_make (); struct str stripped = str_make ();
for (size_t i = 0; i < f.items_len; i++) for (size_t i = 0; i < f.items_len; i++)
@ -13500,7 +13500,7 @@ on_insert_attribute (int count, int key, void *user_data)
(void) key; (void) key;
struct app_context *ctx = user_data; struct app_context *ctx = user_data;
ctx->awaiting_mirc_escape = true; ctx->awaiting_formatting_escape = true;
return true; return true;
} }
@ -13534,7 +13534,7 @@ input_add_functions (void *user_data)
XX ("toggle-unimportant", "Toggle junk msgs", on_toggle_unimportant) XX ("toggle-unimportant", "Toggle junk msgs", on_toggle_unimportant)
XX ("edit-input", "Edit input", on_edit_input) XX ("edit-input", "Edit input", on_edit_input)
XX ("redraw-screen", "Redraw screen", on_redraw_screen) XX ("redraw-screen", "Redraw screen", on_redraw_screen)
XX ("insert-attribute", "mIRC formatting", on_insert_attribute) XX ("insert-attribute", "IRC formatting", on_insert_attribute)
XX ("start-paste-mode", "Bracketed paste", on_start_paste_mode) XX ("start-paste-mode", "Bracketed paste", on_start_paste_mode)
#undef XX #undef XX
} }
@ -14064,7 +14064,7 @@ on_signal_pipe_readable (const struct pollfd *fd, struct app_context *ctx)
} }
static void static void
process_mirc_escape (const struct pollfd *fd, struct app_context *ctx) process_formatting_escape (const struct pollfd *fd, struct app_context *ctx)
{ {
// There's no other way with libedit, as both el_getc() in a function // There's no other way with libedit, as both el_getc() in a function
// handler and CC_ARGHACK would block execution // handler and CC_ARGHACK would block execution
@ -14116,7 +14116,7 @@ error:
CALL (ctx->input, ding); CALL (ctx->input, ding);
done: done:
str_reset (buf); str_reset (buf);
ctx->awaiting_mirc_escape = false; ctx->awaiting_formatting_escape = false;
} }
#define BRACKETED_PASTE_LIMIT 102400 ///< How much text can be pasted #define BRACKETED_PASTE_LIMIT 102400 ///< How much text can be pasted
@ -14212,8 +14212,8 @@ on_tty_readable (const struct pollfd *fd, struct app_context *ctx)
if (fd->revents & ~(POLLIN | POLLHUP | POLLERR)) if (fd->revents & ~(POLLIN | POLLHUP | POLLERR))
print_debug ("fd %d: unexpected revents: %d", fd->fd, fd->revents); print_debug ("fd %d: unexpected revents: %d", fd->fd, fd->revents);
if (ctx->awaiting_mirc_escape) if (ctx->awaiting_formatting_escape)
process_mirc_escape (fd, ctx); process_formatting_escape (fd, ctx);
else if (ctx->in_bracketed_paste) else if (ctx->in_bracketed_paste)
process_bracketed_paste (fd, ctx); process_bracketed_paste (fd, ctx);
else if (!ctx->quitting) else if (!ctx->quitting)