summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-05-28 14:56:56 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-29 17:10:25 +0200
commit6f3a67fdc111fa661198df917971aeb36a605186 (patch)
treeae2634b7720a20bb10ad248c4c362bc59b6a45a0 /src/gui
parent96f41ce4bfdbd57aee7103479faff54d7093e087 (diff)
downloadweechat-6f3a67fdc111fa661198df917971aeb36a605186.zip
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.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-chat.c6
-rw-r--r--src/gui/gui-chat.c10
2 files changed, 8 insertions, 8 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index b4fa4cc92..6ab731b83 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -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;
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 59c1e339f..44f847d25 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -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;
}
}