mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Merge pull request #914 from ailin-nemui/textbuffer_lineinfo
properly record line info on empty lines
This commit is contained in:
commit
e5759a7fb7
@ -1233,6 +1233,13 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text)
|
|||||||
dup = str = g_strdup(text);
|
dup = str = g_strdup(text);
|
||||||
|
|
||||||
flags = 0; fgcolor = theme->default_color; bgcolor = -1;
|
flags = 0; fgcolor = theme->default_color; bgcolor = -1;
|
||||||
|
|
||||||
|
if (*str == '\0') {
|
||||||
|
/* empty line, write line info only */
|
||||||
|
signal_emit_id(signal_gui_print_text, 6, dest->window, GINT_TO_POINTER(fgcolor),
|
||||||
|
GINT_TO_POINTER(bgcolor), GINT_TO_POINTER(flags), str, dest);
|
||||||
|
}
|
||||||
|
|
||||||
while (*str != '\0') {
|
while (*str != '\0') {
|
||||||
type = '\0';
|
type = '\0';
|
||||||
for (ptr = str; *ptr != '\0'; ptr++) {
|
for (ptr = str; *ptr != '\0'; ptr++) {
|
||||||
|
@ -307,9 +307,15 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
|
|||||||
}
|
}
|
||||||
textbuffer_line_add_colors(view->buffer, &insert_after, fg, bg, flags);
|
textbuffer_line_add_colors(view->buffer, &insert_after, fg, bg, flags);
|
||||||
|
|
||||||
insert_after = textbuffer_insert(view->buffer, insert_after,
|
/* for historical reasons, the \n will set
|
||||||
(unsigned char *) str,
|
GUI_PRINT_FLAG_NEWLINE and print an empty string. in this
|
||||||
|
special case, ignore the empty string which would otherwise
|
||||||
|
start another new line */
|
||||||
|
if (~flags & GUI_PRINT_FLAG_NEWLINE || *str != '\0') {
|
||||||
|
insert_after = textbuffer_insert(view->buffer, insert_after, (unsigned char *) str,
|
||||||
strlen(str), &lineinfo);
|
strlen(str), &lineinfo);
|
||||||
|
}
|
||||||
|
|
||||||
if (gui->use_insert_after)
|
if (gui->use_insert_after)
|
||||||
gui->insert_after = insert_after;
|
gui->insert_after = insert_after;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ static LINE_REC *textbuffer_line_create(TEXT_BUFFER_REC *buffer)
|
|||||||
if (buffer->cur_text == NULL)
|
if (buffer->cur_text == NULL)
|
||||||
text_chunk_create(buffer);
|
text_chunk_create(buffer);
|
||||||
|
|
||||||
rec = g_slice_new(LINE_REC);
|
rec = g_slice_new0(LINE_REC);
|
||||||
rec->text = buffer->cur_text->buffer + buffer->cur_text->pos;
|
rec->text = buffer->cur_text->buffer + buffer->cur_text->pos;
|
||||||
|
|
||||||
buffer->cur_text->refcount++;
|
buffer->cur_text->refcount++;
|
||||||
@ -333,8 +333,9 @@ void textbuffer_line_add_colors(TEXT_BUFFER_REC *buffer, LINE_REC **line,
|
|||||||
data[pos++] = LINE_CMD_INDENT;
|
data[pos++] = LINE_CMD_INDENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos > 0)
|
if (pos > 0) {
|
||||||
*line = textbuffer_insert(buffer, *line, data, pos, NULL);
|
*line = textbuffer_insert(buffer, *line, data, pos, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
buffer->last_flags = flags;
|
buffer->last_flags = flags;
|
||||||
}
|
}
|
||||||
@ -355,9 +356,6 @@ LINE_REC *textbuffer_insert(TEXT_BUFFER_REC *buffer, LINE_REC *insert_after,
|
|||||||
g_return_val_if_fail(buffer != NULL, NULL);
|
g_return_val_if_fail(buffer != NULL, NULL);
|
||||||
g_return_val_if_fail(data != NULL, NULL);
|
g_return_val_if_fail(data != NULL, NULL);
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
return insert_after;
|
|
||||||
|
|
||||||
line = !buffer->last_eol ? insert_after :
|
line = !buffer->last_eol ? insert_after :
|
||||||
textbuffer_line_insert(buffer, insert_after);
|
textbuffer_line_insert(buffer, insert_after);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user