diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-04-03 18:11:32 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-04-03 18:11:32 +0200 |
commit | 48bbd32f123f1212441e909e7892eeec8e97f16e (patch) | |
tree | 10984e928719269d0bd38a895bf03beeec20eb11 /src/gui/curses/gui-curses-bar.c | |
parent | bab03d044bfceed7e5c9eaaaf3f3ffd61329784c (diff) | |
download | weechat-48bbd32f123f1212441e909e7892eeec8e97f16e.zip |
Bugs fixed with bars
Diffstat (limited to 'src/gui/curses/gui-curses-bar.c')
-rw-r--r-- | src/gui/curses/gui-curses-bar.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/gui/curses/gui-curses-bar.c b/src/gui/curses/gui-curses-bar.c index 7feb60bd9..1ea49bc5e 100644 --- a/src/gui/curses/gui-curses-bar.c +++ b/src/gui/curses/gui-curses-bar.c @@ -510,9 +510,9 @@ gui_bar_window_add_missing_bars (struct t_gui_window *window) int gui_bar_window_print_string (struct t_gui_bar_window *bar_window, - char *string, int max_chars) + char *string, int max_chars_on_screen) { - int weechat_color, num_displayed, size_on_screen; + int weechat_color, chars_displayed, size_on_screen; char str_color[3], utf_char[16], *next_char, *output; if (!string || !string[0]) @@ -524,7 +524,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, else gui_window_set_weechat_color (bar_window->win_bar, GUI_COLOR_STATUS); - num_displayed = 0; + chars_displayed = 0; while (string && string[0]) { @@ -552,31 +552,29 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, if (gui_window_utf_char_valid (utf_char)) { + size_on_screen = utf8_char_size_screen (utf_char); + if (chars_displayed + size_on_screen > max_chars_on_screen) + return chars_displayed; + chars_displayed += size_on_screen; output = string_iconv_from_internal (NULL, utf_char); wprintw (bar_window->win_bar, "%s", (output) ? output : utf_char); - size_on_screen = utf8_char_size_screen ((output) ? - output : utf_char); - num_displayed += size_on_screen; - max_chars -= size_on_screen; if (output) free (output); } else { + if (chars_displayed + 1 > max_chars_on_screen) + return chars_displayed; + chars_displayed++; wprintw (bar_window->win_bar, "."); - num_displayed++; - max_chars--; } string = next_char; - - if (max_chars <= 0) - break; } } - return num_displayed; + return chars_displayed; } /* |