Merge branch 'master' into selfunload-fix

This commit is contained in:
aquanight 2020-07-10 18:32:48 -06:00 committed by GitHub
commit 12685f8074
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 38 deletions

View file

@ -246,7 +246,7 @@ FE common
"gui print text", WINDOW_REC, int fg, int bg, int flags, char *text, TEXT_DEST_REC "gui print text", WINDOW_REC, int fg, int bg, int flags, char *text, TEXT_DEST_REC
(Can be used to determine when all "gui print text"s are sent (not required)) (Can be used to determine when all "gui print text"s are sent (not required))
"gui print text finished", WINDOW_REC "gui print text finished", WINDOW_REC, TEXT_DEST_REC
* Provides signals: * Provides signals:
@ -353,7 +353,7 @@ gui-readline.c:
gui-printtext.c: gui-printtext.c:
"beep" "beep"
"gui print text after finished", WINDOW_REC, LINE_REC *line, LINE_REC *prev_line "gui print text after finished", WINDOW_REC, LINE_REC *line, LINE_REC *prev_line, TEXT_DEST_REC
textbuffer-view.c textbuffer-view.c
"gui textbuffer line removed", TEXTBUFFER_VIEW_REC *view, LINE_REC *line, LINE_REC *prev_line "gui textbuffer line removed", TEXTBUFFER_VIEW_REC *view, LINE_REC *line, LINE_REC *prev_line

View file

@ -117,7 +117,8 @@ static void cmd_version(char *data)
/* SYNTAX: CAT [-window] <file> [<seek position>] */ /* SYNTAX: CAT [-window] <file> [<seek position>] */
static void cmd_cat(const char *data, SERVER_REC *server, WI_ITEM_REC *item) static void cmd_cat(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{ {
char *fname, *fposstr, *target; char *fname, *fposstr;
gboolean target;
GHashTable *optlist; GHashTable *optlist;
void *free_arg; void *free_arg;
int fpos; int fpos;
@ -155,15 +156,18 @@ static void cmd_cat(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
return; return;
} }
target = g_hash_table_lookup(optlist, "window") != NULL ? item->name : NULL; target = g_hash_table_lookup(optlist, "window") != NULL;
g_io_channel_set_encoding(handle, NULL, NULL); g_io_channel_set_encoding(handle, NULL, NULL);
g_io_channel_seek_position(handle, fpos, G_SEEK_SET, NULL); g_io_channel_seek_position(handle, fpos, G_SEEK_SET, NULL);
buf = g_string_sized_new(512); buf = g_string_sized_new(512);
while (g_io_channel_read_line_string(handle, buf, &tpos, NULL) == G_IO_STATUS_NORMAL) { while (g_io_channel_read_line_string(handle, buf, &tpos, NULL) == G_IO_STATUS_NORMAL) {
buf->str[tpos] = '\0'; buf->str[tpos] = '\0';
printtext(target != NULL ? server : NULL, target, MSGLEVEL_CLIENTCRAP | if (target)
MSGLEVEL_NEVER, "%s", buf->str); printtext_window(active_win, MSGLEVEL_CLIENTCRAP | MSGLEVEL_NEVER, "%s",
buf->str);
else
printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP | MSGLEVEL_NEVER, "%s", buf->str);
} }
g_string_free(buf, TRUE); g_string_free(buf, TRUE);
cmd_params_free(free_arg); cmd_params_free(free_arg);

View file

@ -442,7 +442,7 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text)
format_send_to_gui(dest, str); format_send_to_gui(dest, str);
g_free(str); g_free(str);
signal_emit_id(signal_gui_print_text_finished, 1, dest->window); signal_emit_id(signal_gui_print_text_finished, 2, dest->window, dest);
} }
static void sig_print_format(THEME_REC *theme, const char *module, TEXT_DEST_REC *dest, static void sig_print_format(THEME_REC *theme, const char *module, TEXT_DEST_REC *dest,

View file

@ -158,7 +158,8 @@ void gui_printtext_after_time(TEXT_DEST_REC *dest, LINE_REC *prev, const char *s
gui->insert_after_time = time; gui->insert_after_time = time;
format_send_to_gui(dest, str); format_send_to_gui(dest, str);
gui->use_insert_after = FALSE; gui->use_insert_after = FALSE;
signal_emit("gui print text after finished", 3, dest->window, gui->insert_after, prev); signal_emit("gui print text after finished", 4, dest->window, gui->insert_after, prev,
dest);
} }
void gui_printtext_after(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str) void gui_printtext_after(TEXT_DEST_REC *dest, LINE_REC *prev, const char *str)
@ -376,7 +377,7 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
gui->insert_after = insert_after; gui->insert_after = insert_after;
} }
static void sig_gui_printtext_finished(WINDOW_REC *window) static void sig_gui_printtext_finished(WINDOW_REC *window, TEXT_DEST_REC *dest)
{ {
TEXT_BUFFER_VIEW_REC *view; TEXT_BUFFER_VIEW_REC *view;
LINE_REC *insert_after; LINE_REC *insert_after;

View file

@ -672,7 +672,11 @@ void term_stop(void)
static int input_utf8(const unsigned char *buffer, int size, unichar *result) static int input_utf8(const unsigned char *buffer, int size, unichar *result)
{ {
unichar c = g_utf8_get_char_validated((char *)buffer, size); unichar c = g_utf8_get_char_validated((char *) buffer, size);
/* GLib >= 2.63 do not accept Unicode NUL anymore */
if (c == (unichar) -2 && *buffer == 0 && size > 0)
c = 0;
switch (c) { switch (c) {
case (unichar)-1: case (unichar)-1:

View file

@ -42,6 +42,7 @@ void textbuffer_format_rec_free(TEXT_BUFFER_FORMAT_REC *rec)
i_refstr_release(rec->server_tag); i_refstr_release(rec->server_tag);
i_refstr_release(rec->target); i_refstr_release(rec->target);
i_refstr_release(rec->nick); i_refstr_release(rec->nick);
i_refstr_release(rec->address);
if (rec->nargs >= 1) { if (rec->nargs >= 1) {
i_refstr_release(rec->args[0]); i_refstr_release(rec->args[0]);
} }
@ -54,17 +55,13 @@ void textbuffer_format_rec_free(TEXT_BUFFER_FORMAT_REC *rec)
g_slice_free(TEXT_BUFFER_FORMAT_REC, rec); g_slice_free(TEXT_BUFFER_FORMAT_REC, rec);
} }
static TEXT_BUFFER_FORMAT_REC *format_rec_new(const char *module, const char *format_tag, static TEXT_BUFFER_FORMAT_REC *format_rec_new(const char *module, const char *format_tag, int nargs,
const char *server_tag, const char *target, const char **args)
const char *nick, int nargs, const char **args)
{ {
int n; int n;
TEXT_BUFFER_FORMAT_REC *ret = g_slice_new0(TEXT_BUFFER_FORMAT_REC); TEXT_BUFFER_FORMAT_REC *ret = g_slice_new0(TEXT_BUFFER_FORMAT_REC);
ret->module = i_refstr_intern(module); ret->module = i_refstr_intern(module);
ret->format = i_refstr_intern(format_tag); ret->format = i_refstr_intern(format_tag);
ret->server_tag = i_refstr_intern(server_tag);
ret->target = i_refstr_intern(target);
ret->nick = i_refstr_intern(nick);
ret->nargs = nargs; ret->nargs = nargs;
ret->args = g_new0(char *, nargs); ret->args = g_new0(char *, nargs);
if (nargs >= 1) { if (nargs >= 1) {
@ -76,6 +73,19 @@ static TEXT_BUFFER_FORMAT_REC *format_rec_new(const char *module, const char *fo
return ret; return ret;
} }
static void format_rec_set_dest(TEXT_BUFFER_FORMAT_REC *rec, const TEXT_DEST_REC *dest)
{
i_refstr_release(rec->server_tag);
i_refstr_release(rec->target);
i_refstr_release(rec->nick);
i_refstr_release(rec->address);
rec->server_tag = i_refstr_intern(dest->server_tag);
rec->target = i_refstr_intern(dest->target);
rec->nick = i_refstr_intern(dest->nick);
rec->address = i_refstr_intern(dest->address);
rec->flags = dest->flags & ~PRINT_FLAG_FORMAT;
}
static LINE_INFO_REC *store_lineinfo_tmp(TEXT_DEST_REC *dest) static LINE_INFO_REC *store_lineinfo_tmp(TEXT_DEST_REC *dest)
{ {
GUI_WINDOW_REC *gui; GUI_WINDOW_REC *gui;
@ -132,11 +142,10 @@ static void sig_print_format(THEME_REC *theme, const char *module, TEXT_DEST_REC
formatnum = GPOINTER_TO_INT(formatnump); formatnum = GPOINTER_TO_INT(formatnump);
formats = g_hash_table_lookup(default_formats, module); formats = g_hash_table_lookup(default_formats, module);
info->format = format_rec_new(module, formats[formatnum].tag, dest->server_tag, info->format =
dest->target, dest->nick, formats[formatnum].params, args); format_rec_new(module, formats[formatnum].tag, formats[formatnum].params, args);
special_push_collector(&info->format->expando_cache); special_push_collector(&info->format->expando_cache);
info->format->flags = dest->flags;
dest->flags |= PRINT_FLAG_FORMAT; dest->flags |= PRINT_FLAG_FORMAT;
signal_continue(5, theme, module, dest, formatnump, args); signal_continue(5, theme, module, dest, formatnump, args);
@ -155,11 +164,9 @@ static void sig_print_noformat(TEXT_DEST_REC *dest, const char *text)
special_push_collector(NULL); special_push_collector(NULL);
info = store_lineinfo_tmp(dest); info = store_lineinfo_tmp(dest);
info->format = format_rec_new(NULL, NULL, dest->server_tag, dest->target, dest->nick, 2, info->format = format_rec_new(NULL, NULL, 2, (const char *[]){ NULL, text });
(const char *[]){ NULL, text });
special_push_collector(&info->format->expando_cache); special_push_collector(&info->format->expando_cache);
info->format->flags = dest->flags;
dest->flags |= PRINT_FLAG_FORMAT; dest->flags |= PRINT_FLAG_FORMAT;
signal_continue(2, dest, text); signal_continue(2, dest, text);
@ -182,7 +189,7 @@ static GSList *reverse_collector(GSList *a1)
return c1; return c1;
} }
static void sig_gui_print_text_finished(WINDOW_REC *window) static void sig_gui_print_text_finished(WINDOW_REC *window, TEXT_DEST_REC *dest)
{ {
GUI_WINDOW_REC *gui; GUI_WINDOW_REC *gui;
LINE_REC *insert_after; LINE_REC *insert_after;
@ -202,6 +209,7 @@ static void sig_gui_print_text_finished(WINDOW_REC *window)
return; return;
info->format->expando_cache = reverse_collector(info->format->expando_cache); info->format->expando_cache = reverse_collector(info->format->expando_cache);
format_rec_set_dest(info->format, dest);
info->level |= MSGLEVEL_FORMAT; info->level |= MSGLEVEL_FORMAT;
@ -290,12 +298,16 @@ char *textbuffer_line_get_text(TEXT_BUFFER_REC *buffer, LINE_REC *line)
curr = line; curr = line;
line = NULL; line = NULL;
format_rec = curr->info.format;
format_create_dest( format_rec = curr->info.format;
format_create_dest_tag(
&dest, &dest,
format_rec->server_tag != NULL ? server_find_tag(format_rec->server_tag) : NULL, format_rec->server_tag != NULL ? server_find_tag(format_rec->server_tag) : NULL,
format_rec->target, curr->info.level & ~MSGLEVEL_FORMAT, buffer->window); format_rec->server_tag, format_rec->target, curr->info.level & ~MSGLEVEL_FORMAT,
buffer->window);
dest.nick = format_rec->nick;
dest.address = format_rec->address;
dest.flags = format_rec->flags;
theme = window_get_theme(dest.window); theme = window_get_theme(dest.window);

View file

@ -9,6 +9,7 @@ typedef struct _TEXT_BUFFER_FORMAT_REC {
char *server_tag; char *server_tag;
char *target; char *target;
char *nick; char *nick;
char *address;
char **args; char **args;
int nargs; int nargs;
GSList *expando_cache; GSList *expando_cache;

View file

@ -189,30 +189,32 @@ static inline void unformat(const unsigned char **ptr, int *color, unsigned int
break; break;
case FORMAT_STYLE_CLRTOEOL: case FORMAT_STYLE_CLRTOEOL:
break; break;
#define SET_COLOR_EXT_FG_BITS(base, pc) \
*color &= ~ATTR_FGCOLOR24; \
*color = (*color & BGATTR) | (base + *pc - FORMAT_COLOR_NOCHANGE)
#define SET_COLOR_EXT_BG_BITS(base, pc) \
*color &= ~ATTR_BGCOLOR24; \
*color = (*color & FGATTR) | ((base + *pc - FORMAT_COLOR_NOCHANGE) << BG_SHIFT)
case FORMAT_COLOR_EXT1: case FORMAT_COLOR_EXT1:
*color &= ~ATTR_FGCOLOR24; SET_COLOR_EXT_FG_BITS(0x10, ++*ptr);
*color = (*color & BGATTR) | (0x10 + *++*ptr - FORMAT_COLOR_NOCHANGE);
break; break;
case FORMAT_COLOR_EXT1_BG: case FORMAT_COLOR_EXT1_BG:
*color &= ~ATTR_BGCOLOR24; SET_COLOR_EXT_BG_BITS(0x10, ++*ptr);
*color = (*color & FGATTR) | (0x10 + *++*ptr - FORMAT_COLOR_NOCHANGE);
break; break;
case FORMAT_COLOR_EXT2: case FORMAT_COLOR_EXT2:
*color &= ~ATTR_FGCOLOR24; SET_COLOR_EXT_FG_BITS(0x60, ++*ptr);
*color = (*color & BGATTR) | (0x60 + *++*ptr - FORMAT_COLOR_NOCHANGE);
break; break;
case FORMAT_COLOR_EXT2_BG: case FORMAT_COLOR_EXT2_BG:
*color &= ~ATTR_BGCOLOR24; SET_COLOR_EXT_BG_BITS(0x60, ++*ptr);
*color = (*color & FGATTR) | (0x60 + *++*ptr - FORMAT_COLOR_NOCHANGE);
break; break;
case FORMAT_COLOR_EXT3: case FORMAT_COLOR_EXT3:
*color &= ~ATTR_FGCOLOR24; SET_COLOR_EXT_FG_BITS(0xb0, ++*ptr);
*color = (*color & BGATTR) | (0xb0 + *++*ptr - FORMAT_COLOR_NOCHANGE);
break; break;
case FORMAT_COLOR_EXT3_BG: case FORMAT_COLOR_EXT3_BG:
*color &= ~ATTR_BGCOLOR24; SET_COLOR_EXT_BG_BITS(0xb0, ++*ptr);
*color = (*color & FGATTR) | (0xb0 + *++*ptr - FORMAT_COLOR_NOCHANGE);
break; break;
#undef SET_COLOR_EXT_BG_BITS
#undef SET_COLOR_EXT_FG_BITS
#ifdef TERM_TRUECOLOR #ifdef TERM_TRUECOLOR
case FORMAT_COLOR_24: case FORMAT_COLOR_24:
unformat_24bit_line_color(ptr, 1, color, fg24, bg24); unformat_24bit_line_color(ptr, 1, color, fg24, bg24);