Fix display bug with special chars (ascii value below 32) (bug #30602)
This commit is contained in:
parent
2fb864b8f8
commit
f11549f654
@ -1,7 +1,7 @@
|
||||
WeeChat ChangeLog
|
||||
=================
|
||||
Sébastien Helleu <flashcode@flashtux.org>
|
||||
v0.3.3-dev, 2010-08-04
|
||||
v0.3.3-dev, 2010-08-06
|
||||
|
||||
|
||||
Version 0.3.3 (under dev!)
|
||||
@ -18,6 +18,7 @@ Version 0.3.3 (under dev!)
|
||||
(bug #29991)
|
||||
* core: fix crash with hook_process (when timer is called on a deleted hook
|
||||
process)
|
||||
* core: fix display bug with special chars (ascii value below 32) (bug #30602)
|
||||
* core: fix display bug with attributes like underlined in bars (bug #29889)
|
||||
* core: add hashtables with new functions in plugin API
|
||||
* api: fix bug with replacement char in function string_remove_color
|
||||
|
@ -356,8 +356,8 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
|
||||
else
|
||||
{
|
||||
low_char = 0;
|
||||
if (!gui_window_utf_char_valid (utf_char))
|
||||
snprintf (utf_char, sizeof (utf_char), ".");
|
||||
if (!gui_chat_utf_char_valid (utf_char))
|
||||
snprintf (utf_char, sizeof (utf_char), " ");
|
||||
}
|
||||
|
||||
size_on_screen = utf8_char_size_screen (utf_char);
|
||||
|
@ -377,8 +377,9 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
|
||||
{
|
||||
memcpy (utf_char, string, next_char - string);
|
||||
utf_char[next_char - string] = '\0';
|
||||
if (gui_window_utf_char_valid (utf_char))
|
||||
{
|
||||
if (!gui_chat_utf_char_valid (utf_char))
|
||||
snprintf (utf_char, sizeof (utf_char), " ");
|
||||
|
||||
size_on_screen = utf8_strlen_screen (utf_char);
|
||||
if (max_chars_on_screen > 0)
|
||||
{
|
||||
@ -395,17 +396,6 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
|
||||
free (output);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (max_chars_on_screen > 0)
|
||||
{
|
||||
if (chars_displayed + 1 > max_chars_on_screen)
|
||||
return chars_displayed;
|
||||
chars_displayed++;
|
||||
}
|
||||
wprintw (GUI_WINDOW_OBJECTS(window)->win_chat, ".");
|
||||
}
|
||||
}
|
||||
|
||||
string = next_char;
|
||||
}
|
||||
|
@ -144,24 +144,6 @@ gui_window_objects_free (struct t_gui_window *window, int free_separator)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_utf_char_valid: return 1 if utf char is valid for screen
|
||||
* otherwise return 0
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_utf_char_valid (const char *utf_char)
|
||||
{
|
||||
/* 146 or 0x7F are not valid */
|
||||
if ((((unsigned char)(utf_char[0]) == 146)
|
||||
|| ((unsigned char)(utf_char[0]) == 0x7F))
|
||||
&& (!utf_char[1]))
|
||||
return 0;
|
||||
|
||||
/* any other char is valid */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_get_hline_char: get char used to draw horizontal lines
|
||||
* Note: ACS_HLINE from ncurses is better for
|
||||
|
@ -78,7 +78,6 @@ extern int gui_keyboard_read_cb (void *data, int fd);
|
||||
/* window functions */
|
||||
extern void gui_window_read_terminal_size ();
|
||||
extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer);
|
||||
extern int gui_window_utf_char_valid (const char *utf_char);
|
||||
extern int gui_window_get_hline_char ();
|
||||
extern void gui_window_clear (WINDOW *window, int bg);
|
||||
extern void gui_window_reset_style (WINDOW *window, int num_color);
|
||||
|
@ -118,6 +118,28 @@ gui_chat_prefix_build ()
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_QUIT] = strdup (prefix);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_utf_char_valid: return 1 if utf char is valid for screen
|
||||
* otherwise return 0
|
||||
*/
|
||||
|
||||
int
|
||||
gui_chat_utf_char_valid (const char *utf_char)
|
||||
{
|
||||
/* chars below 32 are not valid */
|
||||
if ((unsigned char)utf_char[0] < 32)
|
||||
return 0;
|
||||
|
||||
/* 146 or 0x7F are not valid */
|
||||
if ((((unsigned char)(utf_char[0]) == 146)
|
||||
|| ((unsigned char)(utf_char[0]) == 0x7F))
|
||||
&& (!utf_char[1]))
|
||||
return 0;
|
||||
|
||||
/* any other char is valid */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_strlen_screen: returns number of char needed on sreen to display a
|
||||
* word special chars like color, bold, .. are ignored
|
||||
@ -134,7 +156,7 @@ gui_chat_strlen_screen (const char *string)
|
||||
string = gui_chat_string_next_char (NULL, (unsigned char *)string, 0);
|
||||
if (string)
|
||||
{
|
||||
size_on_screen = (((unsigned char)string[0]) < 32) ? 1 : utf8_char_size_screen (string);
|
||||
size_on_screen = (gui_chat_utf_char_valid (string)) ? utf8_char_size_screen (string) : 1;
|
||||
if (size_on_screen > 0)
|
||||
length += size_on_screen;
|
||||
string = utf8_next_char (string);
|
||||
|
@ -59,6 +59,7 @@ extern struct t_gui_buffer *gui_chat_mute_buffer;
|
||||
|
||||
extern void gui_chat_init ();
|
||||
extern void gui_chat_prefix_build ();
|
||||
extern int gui_chat_utf_char_valid (const char *utf_char);
|
||||
extern int gui_chat_strlen_screen (const char *string);
|
||||
extern char *gui_chat_string_add_offset (const char *string, int offset);
|
||||
extern int gui_chat_string_real_pos (const char *string, int pos);
|
||||
|
Loading…
x
Reference in New Issue
Block a user