1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 16:23:14 +02:00

core: set word_end_offset to character after word

It seemed strange to me to have word_end_offset point to the last
character in the word, rather than the character after the word,
especially now with the word stopping before a newline character which
meant word_end_offset would be -1 if there was no characters before the
newline character.
This commit is contained in:
Trygve Aaberge
2023-05-28 14:56:56 +02:00
committed by Sébastien Helleu
parent 96f41ce4bf
commit 6f3a67fdc1
3 changed files with 24 additions and 24 deletions
+3 -3
View File
@@ -1544,7 +1544,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
/* if message ends with spaces, display them */
if ((word_length <= 0) && (word_length_with_spaces > 0)
&& !ptr_data[word_end_offset + 1])
&& !ptr_data[word_end_offset])
{
word_length = word_length_with_spaces;
}
@@ -1582,7 +1582,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
/* display word */
gui_chat_display_word (window, line, ptr_data,
ptr_end_offset + 1,
ptr_end_offset,
0, num_lines, count,
pre_lines_displayed, &lines_displayed,
simulate,
@@ -1594,7 +1594,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
else
{
/* move pointer after end of word */
ptr_data = ptr_end_offset + 1;
ptr_data = ptr_end_offset;
if (*(ptr_data - 1) == '\0')
ptr_data = NULL;
+5 -5
View File
@@ -338,7 +338,7 @@ gui_chat_get_word_info (struct t_gui_window *window,
{
if (next_char[0] == '\n')
{
*word_end_offset = next_char - start_data - 1;
*word_end_offset = next_char - start_data;
if (*word_length < 0)
*word_length = 0;
return;
@@ -348,7 +348,7 @@ gui_chat_get_word_info (struct t_gui_window *window,
if (leading_spaces)
*word_start_offset = next_char - start_data;
leading_spaces = 0;
*word_end_offset = next_char2 - start_data - 1;
*word_end_offset = next_char2 - start_data;
char_size_screen = utf8_char_size_screen (next_char);
if (char_size_screen > 0)
(*word_length_with_spaces) += char_size_screen;
@@ -362,11 +362,11 @@ gui_chat_get_word_info (struct t_gui_window *window,
if (leading_spaces)
{
(*word_length_with_spaces)++;
*word_end_offset = next_char2 - start_data - 1;
*word_end_offset = next_char2 - start_data;
}
else
{
*word_end_offset = next_char - start_data - 1;
*word_end_offset = next_char - start_data;
return;
}
}
@@ -375,7 +375,7 @@ gui_chat_get_word_info (struct t_gui_window *window,
}
else
{
*word_end_offset = data + strlen (data) - start_data - 1;
*word_end_offset = data + strlen (data) - start_data;
return;
}
}