mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 04:16:38 +02:00
Merge branch 'protocols' of ssh://git.sv.gnu.org/srv/git/weechat into protocols
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
@@ -334,7 +335,8 @@ gui_keyboard_flush ()
|
||||
int
|
||||
gui_keyboard_read_cb (void *data)
|
||||
{
|
||||
int key, accept_paste, cancel_paste, text_added_to_buffer, paste_lines;
|
||||
int ret, i, accept_paste, cancel_paste, text_added_to_buffer, paste_lines;
|
||||
unsigned char buffer[4096];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -342,35 +344,44 @@ gui_keyboard_read_cb (void *data)
|
||||
accept_paste = 0;
|
||||
cancel_paste = 0;
|
||||
text_added_to_buffer = 0;
|
||||
|
||||
while (1)
|
||||
|
||||
if (gui_keyboard_paste_pending)
|
||||
{
|
||||
key = getch ();
|
||||
|
||||
if (key == ERR)
|
||||
break;
|
||||
|
||||
#ifdef KEY_RESIZE
|
||||
if (key == KEY_RESIZE)
|
||||
continue;
|
||||
#endif
|
||||
if (gui_keyboard_paste_pending)
|
||||
ret = read (STDIN_FILENO, buffer, 1);
|
||||
if (ret == 0)
|
||||
{
|
||||
/* ctrl-Y: accept paste */
|
||||
if (key == 25)
|
||||
{
|
||||
accept_paste = 1;
|
||||
break;
|
||||
}
|
||||
/* ctrl-N: cancel paste */
|
||||
else if (key == 14)
|
||||
{
|
||||
cancel_paste = 1;
|
||||
break;
|
||||
}
|
||||
/* no data on stdin, terminal lost */
|
||||
quit_weechat = 1;
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if (ret <= 0)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
/* ctrl-Y: accept paste */
|
||||
if (buffer[0] == 25)
|
||||
accept_paste = 1;
|
||||
|
||||
/* ctrl-N: cancel paste */
|
||||
if (buffer[0] == 14)
|
||||
cancel_paste = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = read (STDIN_FILENO, buffer, sizeof (buffer));
|
||||
if (ret == 0)
|
||||
{
|
||||
/* no data on stdin, terminal lost */
|
||||
quit_weechat = 1;
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if (ret < 0)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
for (i = 0; i < ret; i++)
|
||||
{
|
||||
gui_keyboard_buffer_add (buffer[i]);
|
||||
}
|
||||
|
||||
gui_keyboard_buffer_add (key);
|
||||
text_added_to_buffer = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "../../core/wee-command.h"
|
||||
#include "../../core/wee-config.h"
|
||||
#include "../../core/wee-hook.h"
|
||||
#include "../../core/wee-log.h"
|
||||
#include "../../core/wee-string.h"
|
||||
#include "../../core/wee-utf8.h"
|
||||
#include "../../core/wee-util.h"
|
||||
@@ -52,6 +53,9 @@
|
||||
#include "gui-curses.h"
|
||||
|
||||
|
||||
int gui_reload_config = 0;
|
||||
|
||||
|
||||
/*
|
||||
* gui_main_pre_init: pre-initialize GUI (called before gui_init)
|
||||
*/
|
||||
@@ -150,23 +154,48 @@ gui_main_init ()
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_quit: quit WeeChat
|
||||
* gui_main_signal_sigquit: quit WeeChat
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_quit ()
|
||||
gui_main_signal_sigquit ()
|
||||
{
|
||||
log_printf (_("Signal %s received, quitting WeeChat..."),
|
||||
"SIGQUIT");
|
||||
quit_weechat = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_reload: reload WeeChat configuration
|
||||
* gui_main_signal_sigterm: quit WeeChat
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_reload ()
|
||||
gui_main_signal_sigterm ()
|
||||
{
|
||||
command_reload (NULL, NULL, 0, NULL, NULL);
|
||||
log_printf (_("Signal %s received, quitting WeeChat..."),
|
||||
"SIGTERM");
|
||||
quit_weechat = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_signal_sighup: reload WeeChat configuration
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_signal_sighup ()
|
||||
{
|
||||
log_printf (_("Signal SIGHUP received, reloading configuration files"));
|
||||
gui_reload_config = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_signal_sigwinch: called when signal SIGWINCH is received
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_signal_sigwinch ()
|
||||
{
|
||||
gui_window_refresh_needed = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -187,13 +216,14 @@ gui_main_loop ()
|
||||
quit_weechat = 0;
|
||||
|
||||
/* catch SIGTERM signal: quit program */
|
||||
util_catch_signal (SIGTERM, &gui_main_quit);
|
||||
util_catch_signal (SIGTERM, &gui_main_signal_sigterm);
|
||||
util_catch_signal (SIGQUIT, &gui_main_signal_sigquit);
|
||||
|
||||
/* catch SIGHUP signal: reload configuration */
|
||||
util_catch_signal (SIGHUP, &gui_main_reload);
|
||||
util_catch_signal (SIGHUP, &gui_main_signal_sighup);
|
||||
|
||||
/* catch SIGWINCH signal: redraw screen */
|
||||
util_catch_signal (SIGWINCH, &gui_window_refresh_screen_sigwinch);
|
||||
util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch);
|
||||
|
||||
/* hook stdin (read keyboard) */
|
||||
hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0,
|
||||
@@ -201,6 +231,13 @@ gui_main_loop ()
|
||||
|
||||
while (!quit_weechat)
|
||||
{
|
||||
/* reload config, if SIGHUP reveived */
|
||||
if (gui_reload_config)
|
||||
{
|
||||
gui_reload_config = 0;
|
||||
command_reload (NULL, NULL, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
/* execute hook timers */
|
||||
hook_timer_exec ();
|
||||
|
||||
|
||||
@@ -1752,16 +1752,6 @@ gui_window_refresh_screen ()
|
||||
gui_window_refresh_needed = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_refresh_screen_sigwinch: called when signal SIGWINCH is received
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_refresh_screen_sigwinch ()
|
||||
{
|
||||
gui_window_refresh_needed = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_title_set: set terminal title
|
||||
*/
|
||||
|
||||
@@ -103,7 +103,6 @@ extern void gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg);
|
||||
extern void gui_window_set_custom_color_fg (WINDOW *window, int fg);
|
||||
extern void gui_window_set_custom_color_bg (WINDOW *window, int bg);
|
||||
extern void gui_window_clrtoeol_with_current_bg (WINDOW *window);
|
||||
extern void gui_window_refresh_screen_sigwinch ();
|
||||
extern void gui_window_title_set ();
|
||||
extern void gui_window_title_reset ();
|
||||
|
||||
|
||||
@@ -762,7 +762,7 @@ gui_keyboard_buffer_reset ()
|
||||
*/
|
||||
|
||||
void
|
||||
gui_keyboard_buffer_add (int key)
|
||||
gui_keyboard_buffer_add (unsigned char key)
|
||||
{
|
||||
if (!gui_keyboard_buffer)
|
||||
gui_keyboard_buffer_reset ();
|
||||
@@ -774,9 +774,9 @@ gui_keyboard_buffer_add (int key)
|
||||
if (gui_keyboard_buffer)
|
||||
{
|
||||
gui_keyboard_buffer[gui_keyboard_buffer_size - 1] = key;
|
||||
if ((key == 10)
|
||||
if ((key == 13)
|
||||
&& (gui_keyboard_buffer_size > 1)
|
||||
&& (gui_keyboard_buffer[gui_keyboard_buffer_size - 2] != 10))
|
||||
&& (gui_keyboard_buffer[gui_keyboard_buffer_size - 2] != 13))
|
||||
gui_keyboard_paste_lines++;
|
||||
}
|
||||
else
|
||||
@@ -797,7 +797,7 @@ int
|
||||
gui_keyboard_get_paste_lines ()
|
||||
{
|
||||
if ((gui_keyboard_buffer_size > 0)
|
||||
&& (gui_keyboard_buffer[gui_keyboard_buffer_size - 1] != 10))
|
||||
&& (gui_keyboard_buffer[gui_keyboard_buffer_size - 1] != 13))
|
||||
return gui_keyboard_paste_lines + 1;
|
||||
|
||||
return gui_keyboard_paste_lines;
|
||||
|
||||
@@ -77,7 +77,7 @@ extern void gui_keyboard_free (struct t_gui_key **keys,
|
||||
extern void gui_keyboard_free_all (struct t_gui_key **keys,
|
||||
struct t_gui_key **last_key);
|
||||
extern void gui_keyboard_buffer_reset ();
|
||||
extern void gui_keyboard_buffer_add (int key);
|
||||
extern void gui_keyboard_buffer_add (unsigned char key);
|
||||
extern int gui_keyboard_get_paste_lines ();
|
||||
extern void gui_keyboard_paste_accept ();
|
||||
extern void gui_keyboard_paste_cancel ();
|
||||
|
||||
Reference in New Issue
Block a user