summaryrefslogtreecommitdiff
path: root/src/gui/curses
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/curses')
-rw-r--r--src/gui/curses/gui-curses-bar-window.c3
-rw-r--r--src/gui/curses/gui-curses-chat.c12
-rw-r--r--src/gui/curses/gui-curses-key.c9
-rw-r--r--src/gui/curses/gui-curses-main.c56
-rw-r--r--src/gui/curses/gui-curses-mouse.c6
-rw-r--r--src/gui/curses/gui-curses-term.c6
-rw-r--r--src/gui/curses/gui-curses-window.c2
-rw-r--r--src/gui/curses/gui-curses.h4
8 files changed, 52 insertions, 46 deletions
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c
index 6f143cd33..8c6749cd8 100644
--- a/src/gui/curses/gui-curses-bar-window.c
+++ b/src/gui/curses/gui-curses-bar-window.c
@@ -332,7 +332,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
1);
break;
default:
- next_char = utf8_next_char (string);
+ next_char = (char *)utf8_next_char (string);
if (!next_char)
break;
@@ -473,6 +473,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
content = gui_bar_window_content_get_with_filling (bar_window, window);
if (content)
{
+ utf8_normalize (content, '?');
if ((filling == GUI_BAR_FILLING_HORIZONTAL)
&& (bar_window->scroll_x > 0))
{
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index 51d30c7a0..c1cf10a82 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -223,7 +223,7 @@ gui_chat_display_horizontal_line (struct t_gui_window *window, int simulate)
* colors/attributes are skipped and optionally applied.
*/
-char *
+const char *
gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
const unsigned char *string, int apply_style,
int apply_style_inactive,
@@ -394,7 +394,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
if (!string)
return chars_displayed;
- next_char = utf8_next_char (string);
+ next_char = (char *)utf8_next_char (string);
if (next_char)
{
ptr_char = utf_char;
@@ -1231,8 +1231,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
int read_marker_x, read_marker_y;
int word_start_offset, word_end_offset;
int word_length_with_spaces, word_length;
- char *ptr_data, *ptr_end_offset, *next_char;
- char *ptr_style, *message_with_tags, *message_with_search;
+ char *message_with_tags, *message_with_search;
+ const char *ptr_data, *ptr_end_offset, *ptr_style, *next_char;
struct t_gui_line *ptr_prev_line, *ptr_next_line;
struct tm local_time, local_time2;
struct timeval tv_time;
@@ -1879,6 +1879,8 @@ gui_chat_draw_free_buffer (struct t_gui_window *window, int clear_chat)
/*
* Gets line content in bare display.
+ *
+ * Note: result must be freed after use.
*/
char *
@@ -1905,8 +1907,6 @@ gui_chat_get_bare_line (struct t_gui_line *line)
str_time[0] = '\0';
if (line->data->buffer->time_for_each_line
&& (line->data->date > 0)
- && CONFIG_STRING(config_look_buffer_time_format)
- && CONFIG_STRING(config_look_buffer_time_format)[0]
&& CONFIG_STRING(config_look_bare_display_time_format)
&& CONFIG_STRING(config_look_bare_display_time_format)[0])
{
diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c
index 51fdd22c9..b1205b400 100644
--- a/src/gui/curses/gui-curses-key.c
+++ b/src/gui/curses/gui-curses-key.c
@@ -222,7 +222,7 @@ gui_key_default_bindings (int context)
for (i = 1; i < 100; i++)
{
snprintf (key_str, sizeof (key_str), "meta-j%02d", i);
- snprintf (command, sizeof (command), "/buffer %d", i);
+ snprintf (command, sizeof (command), "/buffer *%d", i);
BIND(key_str, command);
}
}
@@ -381,7 +381,7 @@ gui_key_flush (int paste)
(void) utf8_is_valid (ptr_char, &ptr_error);
if (!ptr_error)
break;
- next_char = utf8_next_char (ptr_error);
+ next_char = (char *)utf8_next_char (ptr_error);
if (next_char && next_char[0])
{
ptr_char = ptr_error;
@@ -466,7 +466,10 @@ gui_key_flush (int paste)
* found
*/
if (CONFIG_BOOLEAN(config_look_search_text_not_found_alert))
- printf ("\a");
+ {
+ fprintf (stderr, "\a");
+ fflush (stderr);
+ }
}
else
{
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index 3f3016aa9..090c1ef04 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -73,22 +73,26 @@ int gui_term_lines = 0; /* number of lines in terminal */
*/
void
-gui_main_get_password (const char *prompt1, const char *prompt2,
- const char *prompt3,
- char *password, int size)
+gui_main_get_password (const char **prompt, char *password, int size)
{
- int i, ch;
+ int line, i, ch;
initscr ();
cbreak ();
noecho ();
+ raw ();
clear();
- mvaddstr (0, 0, prompt1);
- mvaddstr (1, 0, prompt2);
- mvaddstr (2, 0, prompt3);
- mvaddstr (3, 0, "=> ");
+ line = 0;
+
+ while (prompt[line])
+ {
+ mvaddstr (line, 0, prompt[line]);
+ line++;
+ }
+
+ mvaddstr (line, 0, "=> ");
refresh ();
memset (password, '\0', size);
@@ -96,22 +100,30 @@ gui_main_get_password (const char *prompt1, const char *prompt2,
while (i < size - 1)
{
ch = getch ();
+ /* enter */
if (ch == '\n')
break;
+ /* ctrl-C */
+ if (ch == 3)
+ {
+ password[0] = 3;
+ i = 1;
+ break;
+ }
if (ch == 127)
{
if (i > 0)
{
i--;
password[i] = '\0';
- mvaddstr (3, 3 + i, " ");
- move (3, 3 + i);
+ mvaddstr (line, 3 + i, " ");
+ move (line, 3 + i);
}
}
else
{
password[i] = ch;
- mvaddstr (3, 3 + i, "*");
+ mvaddstr (line, 3 + i, "*");
i++;
}
refresh ();
@@ -252,7 +264,7 @@ gui_main_debug_libs ()
NCURSES_VERSION, NCURSES_VERSION_PATCH);
#else
gui_chat_printf (NULL, " ncurses: (?)");
-#endif
+#endif /* defined(NCURSES_VERSION) && defined(NCURSES_VERSION_PATCH) */
}
/*
@@ -370,10 +382,6 @@ void
gui_main_loop ()
{
struct t_hook *hook_fd_keyboard;
- struct timeval tv_timeout;
- fd_set read_fds, write_fds, except_fds;
- int max_fd;
- int ready;
/* catch SIGWINCH signal: redraw screen */
util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch);
@@ -386,7 +394,7 @@ gui_main_loop ()
while (!weechat_quit)
{
- /* execute hook timers */
+ /* execute timer hooks */
hook_timer_exec ();
/* auto reset of color pairs */
@@ -411,18 +419,8 @@ gui_main_loop ()
gui_color_pairs_auto_reset_pending = 0;
- /* wait for keyboard or network activity */
- FD_ZERO (&read_fds);
- FD_ZERO (&write_fds);
- FD_ZERO (&except_fds);
- max_fd = hook_fd_set (&read_fds, &write_fds, &except_fds);
- hook_timer_time_to_next (&tv_timeout);
- ready = select (max_fd + 1, &read_fds, &write_fds, &except_fds,
- &tv_timeout);
- if (ready > 0)
- {
- hook_fd_exec (&read_fds, &write_fds, &except_fds);
- }
+ /* execute fd hooks */
+ hook_fd_exec ();
}
/* remove keyboard hook */
diff --git a/src/gui/curses/gui-curses-mouse.c b/src/gui/curses/gui-curses-mouse.c
index d20ba4ce2..16330a76e 100644
--- a/src/gui/curses/gui-curses-mouse.c
+++ b/src/gui/curses/gui-curses-mouse.c
@@ -89,6 +89,7 @@ gui_mouse_enable ()
{
gui_mouse_enabled = 1;
fprintf (stderr, "\033[?1005h\033[?1000h\033[?1002h");
+ fflush (stderr);
(void) hook_signal_send ("mouse_enabled",
WEECHAT_HOOK_SIGNAL_STRING, NULL);
@@ -103,6 +104,7 @@ gui_mouse_disable ()
{
gui_mouse_enabled = 0;
fprintf (stderr, "\033[?1002l\033[?1000l\033[?1005l");
+ fflush (stderr);
(void) hook_signal_send ("mouse_disabled",
WEECHAT_HOOK_SIGNAL_STRING, NULL);
@@ -139,7 +141,7 @@ gui_mouse_grab_init (int area)
* @*
*/
-char *
+const char *
gui_mouse_grab_event2input ()
{
struct t_gui_focus_info *focus_info;
@@ -255,7 +257,7 @@ gui_mouse_event_code2key (const char *code)
int i, x, y, code_utf8, length;
double diff_x, diff_y, distance, angle, pi4;
static char key[128];
- char *ptr_code;
+ const char *ptr_code;
key[0] = '\0';
diff --git a/src/gui/curses/gui-curses-term.c b/src/gui/curses/gui-curses-term.c
index fa6340b2f..c5408bbcd 100644
--- a/src/gui/curses/gui-curses-term.c
+++ b/src/gui/curses/gui-curses-term.c
@@ -28,10 +28,10 @@
#include <ncurses/term.h>
#else
#include <ncursesw/term.h>
-#endif
+#endif /* __sun */
#else
#include <term.h>
-#endif
+#endif /* HAVE_NCURSESW_CURSES_H */
/*
@@ -50,5 +50,5 @@ gui_term_set_eat_newline_glitch (int value)
#else
/* make C compiler happy */
(void) value;
-#endif
+#endif /* HAVE_EAT_NEWLINE_GLITCH */
}
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index a758383c9..af0a69c91 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -2521,6 +2521,7 @@ gui_window_send_clipboard (const char *storage_unit, const char *text)
fprintf (stderr, "\033]52;%s;%s\a",
(storage_unit) ? storage_unit : "",
text_base64);
+ fflush (stderr);
free (text_base64);
}
}
@@ -2545,6 +2546,7 @@ gui_window_set_bracketed_paste_mode (int enable)
(screen) ? "\033P" : "",
(enable) ? "h" : "l",
(screen) ? "\033\\" : "");
+ fflush (stderr);
}
/*
diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h
index ae05bdc21..682c98596 100644
--- a/src/gui/curses/gui-curses.h
+++ b/src/gui/curses/gui-curses.h
@@ -28,7 +28,7 @@
#include <ncurses.h>
#else
#include <curses.h>
-#endif
+#endif /* HAVE_NCURSESW_CURSES_H */
struct t_gui_buffer;
struct t_gui_line;
@@ -39,7 +39,7 @@ struct t_gui_bar_window;
#ifndef A_ITALIC /* A_ITALIC is defined in ncurses >= 5.9 patch 20130831 */
#define A_ITALIC 0
-#endif
+#endif /* A_ITALIC */
#define A_ALL_ATTR A_BOLD | A_UNDERLINE | A_REVERSE | A_ITALIC