summaryrefslogtreecommitdiff
path: root/src/gui/curses/gui-curses-chat.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-05-31 08:46:08 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-05-31 08:46:08 +0200
commit60bba82150debdeea71f92376c0ba25133150b2f (patch)
treebebc0c3544ae5c1e2578c8343ebdb7d21940f370 /src/gui/curses/gui-curses-chat.c
parent92b88e659970cc9a350e4c71e0524def1342f98f (diff)
downloadweechat-60bba82150debdeea71f92376c0ba25133150b2f.zip
core: fix bug with horizontal scroll in windows and long lines
Diffstat (limited to 'src/gui/curses/gui-curses-chat.c')
-rw-r--r--src/gui/curses/gui-curses-chat.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index 34740ed13..c9173fdb1 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -255,7 +255,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
int max_chars_on_screen, int display)
{
char *next_char, *output, utf_char[16];
- int chars_displayed, display_char, size_on_screen;
+ int x, chars_displayed, display_char, size_on_screen;
if (display)
wmove (GUI_WINDOW_OBJECTS(window)->win_chat,
@@ -263,6 +263,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
window->win_chat_cursor_x);
chars_displayed = 0;
+ x = window->win_chat_cursor_x;
while (string && string[0])
{
@@ -280,14 +281,13 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
snprintf (utf_char, sizeof (utf_char), " ");
display_char = (window->buffer->type != GUI_BUFFER_TYPE_FREE)
- || (chars_displayed >= window->scroll->start_col);
+ || (x >= window->scroll->start_col);
size_on_screen = utf8_strlen_screen (utf_char);
- if (max_chars_on_screen > 0)
+ if ((max_chars_on_screen > 0)
+ && (chars_displayed + size_on_screen > max_chars_on_screen))
{
- if (chars_displayed + size_on_screen > max_chars_on_screen)
- return chars_displayed;
- chars_displayed += size_on_screen;
+ return chars_displayed;
}
if (display_char && (size_on_screen > 0))
{
@@ -296,7 +296,9 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
"%s", (output) ? output : utf_char);
if (output)
free (output);
+ chars_displayed += size_on_screen;
}
+ x += size_on_screen;
}
string = next_char;