1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 03:03:12 +02:00

core: add key ctrl+z to suspend WeeChat process (closes #985)

This commit is contained in:
Sébastien Helleu
2023-08-28 17:39:33 +02:00
parent 5ecb1adc34
commit cc2b44a8ec
12 changed files with 100 additions and 7 deletions
+17 -6
View File
@@ -59,12 +59,13 @@
#include "wee-secure.h"
#include "wee-secure-buffer.h"
#include "wee-secure-config.h"
#include "wee-signal.h"
#include "wee-string.h"
#include "wee-sys.h"
#include "wee-upgrade.h"
#include "wee-utf8.h"
#include "wee-util.h"
#include "wee-version.h"
#include "wee-sys.h"
#include "../gui/gui-bar.h"
#include "../gui/gui-bar-item.h"
#include "../gui/gui-bar-item-custom.h"
@@ -7801,6 +7802,12 @@ COMMAND_CALLBACK(sys)
return WEECHAT_RC_OK;
}
if (string_strcmp (argv[1], "suspend") == 0)
{
signal_suspend ();
return WEECHAT_RC_OK;
}
COMMAND_ERROR;
}
@@ -9489,12 +9496,16 @@ command_init ()
hook_command (
NULL, "sys",
N_("system actions"),
N_("get rlimit|rusage"),
N_(" get: display system info\n"
"rlimit: display resource limits "
N_("get rlimit|rusage"
" || suspend"),
N_(" get: display system info\n"
" rlimit: display resource limits "
"(see /help weechat.startup.sys_rlimit and man getrlimit)\n"
"rusage: display resource usage (see man getrusage)"),
"get rlimit|rusage",
" rusage: display resource usage (see man getrusage)\n"
"suspend: suspend WeeChat and go back to the shell, by sending "
"signal SIGTSTP to the WeeChat process"),
"get rlimit|rusage"
" || suspend",
&command_sys, NULL, NULL);
}
+12
View File
@@ -37,6 +37,7 @@
#include "wee-log.h"
#include "wee-string.h"
#include "../gui/gui-buffer.h"
#include "../gui/gui-window.h"
#include "../plugins/plugin.h"
@@ -293,6 +294,17 @@ signal_handle ()
signal_sigterm_count = 0;
}
/*
* Suspends WeeChat process.
*/
void
signal_suspend ()
{
kill (getpid (), SIGTSTP);
gui_window_ask_refresh (2);
}
/*
* Initializes signal.
*/
+1
View File
@@ -32,6 +32,7 @@ extern int signal_search_number (int signal_number);
extern int signal_search_name (const char *name);
extern void signal_catch (int signum, void (*handler)(int));
extern void signal_handle ();
extern void signal_suspend ();
extern void signal_init ();
#endif /* WEECHAT_SIGNAL_H */
+1
View File
@@ -102,6 +102,7 @@ gui_key_default_bindings (int context, int create_option)
BIND("ctrl-u", "/input delete_beginning_of_line");
BIND("meta-ctrl-u", "/input delete_beginning_of_input");
BIND("ctrl-y", "/input clipboard_paste");
BIND("ctrl-z", "/sys suspend");
BIND("home", "/input move_beginning_of_line");
BIND("ctrl-a", "/input move_beginning_of_line");
BIND("shift-home", "/input move_beginning_of_input");