mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Stop ctrl-c quitting with /ctrlc off
This commit is contained in:
parent
2a69f8d23f
commit
721df8ca48
@ -116,6 +116,7 @@ static gboolean _cmd_set_chlog(gchar **args, struct cmd_help_t help);
|
|||||||
static gboolean _cmd_set_history(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_set_history(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_set_states(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_set_states(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_set_outtype(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_set_outtype(gchar **args, struct cmd_help_t help);
|
||||||
|
static gboolean _cmd_set_ctrlc(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_vercheck(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_vercheck(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_away(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_away(gchar **args, struct cmd_help_t help);
|
||||||
static gboolean _cmd_online(gchar **args, struct cmd_help_t help);
|
static gboolean _cmd_online(gchar **args, struct cmd_help_t help);
|
||||||
@ -485,6 +486,15 @@ static struct cmd_t setting_commands[] =
|
|||||||
"Config file value : maxsize=bytes",
|
"Config file value : maxsize=bytes",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
|
{ "/ctrlc",
|
||||||
|
_cmd_set_ctrlc, parse_args, 1, 1,
|
||||||
|
{ "/ctrlc on|off", "Set ctrl-c to quit profanity.",
|
||||||
|
{ "/ctrlc on|off",
|
||||||
|
"---------------",
|
||||||
|
"Setting this option will allow you to quit using ctrl-c.",
|
||||||
|
NULL } } },
|
||||||
|
|
||||||
|
|
||||||
{ "/priority",
|
{ "/priority",
|
||||||
_cmd_set_priority, parse_args, 1, 1,
|
_cmd_set_priority, parse_args, 1, 1,
|
||||||
{ "/priority <value>", "Set priority for connection.",
|
{ "/priority <value>", "Set priority for connection.",
|
||||||
@ -855,6 +865,8 @@ _cmd_complete_parameters(char *input, int *size)
|
|||||||
prefs_autocomplete_boolean_choice);
|
prefs_autocomplete_boolean_choice);
|
||||||
_parameter_autocomplete(input, size, "/states",
|
_parameter_autocomplete(input, size, "/states",
|
||||||
prefs_autocomplete_boolean_choice);
|
prefs_autocomplete_boolean_choice);
|
||||||
|
_parameter_autocomplete(input, size, "/ctrlc",
|
||||||
|
prefs_autocomplete_boolean_choice);
|
||||||
_parameter_autocomplete(input, size, "/outtype",
|
_parameter_autocomplete(input, size, "/outtype",
|
||||||
prefs_autocomplete_boolean_choice);
|
prefs_autocomplete_boolean_choice);
|
||||||
_parameter_autocomplete(input, size, "/flash",
|
_parameter_autocomplete(input, size, "/flash",
|
||||||
@ -1389,6 +1401,13 @@ _cmd_set_states(gchar **args, struct cmd_help_t help)
|
|||||||
"Sending chat states", prefs_set_states);
|
"Sending chat states", prefs_set_states);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cmd_set_ctrlc(gchar **args, struct cmd_help_t help)
|
||||||
|
{
|
||||||
|
return _cmd_set_boolean_preference(args, help, "/ctrlc",
|
||||||
|
"Ctrl-C quit", prefs_set_ctrlc);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_set_outtype(gchar **args, struct cmd_help_t help)
|
_cmd_set_outtype(gchar **args, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
|
@ -241,17 +241,33 @@ _handle_edit(const int ch, char *input, int *size)
|
|||||||
char *next = NULL;
|
char *next = NULL;
|
||||||
int inp_y = 0;
|
int inp_y = 0;
|
||||||
int inp_x = 0;
|
int inp_x = 0;
|
||||||
|
int next_ch;
|
||||||
|
|
||||||
getmaxyx(stdscr, rows, cols);
|
getmaxyx(stdscr, rows, cols);
|
||||||
getyx(inp_win, inp_y, inp_x);
|
getyx(inp_win, inp_y, inp_x);
|
||||||
|
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
|
||||||
case 27: // ESC
|
case 3: // CTRL-C
|
||||||
*size = 0;
|
if (prefs_get_ctrlc()) {
|
||||||
inp_clear();
|
exit(0);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
case 27:
|
||||||
|
next_ch = wgetch(inp_win);
|
||||||
|
|
||||||
|
// ESC
|
||||||
|
if (next_ch == ERR) {
|
||||||
|
*size = 0;
|
||||||
|
inp_clear();
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// ALT-<next_ch>
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
case 127:
|
case 127:
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
contact_list_reset_search_attempts();
|
contact_list_reset_search_attempts();
|
||||||
|
@ -132,6 +132,19 @@ prefs_set_beep(gboolean value)
|
|||||||
_save_prefs();
|
_save_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
prefs_get_ctrlc(void)
|
||||||
|
{
|
||||||
|
return g_key_file_get_boolean(prefs, "ui", "ctrlc", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prefs_set_ctrlc(gboolean value)
|
||||||
|
{
|
||||||
|
g_key_file_set_boolean(prefs, "ui", "ctrlc", value);
|
||||||
|
_save_prefs();
|
||||||
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
prefs_get_theme(void)
|
prefs_get_theme(void)
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,8 @@ gboolean prefs_get_outtype(void);
|
|||||||
void prefs_set_outtype(gboolean value);
|
void prefs_set_outtype(gboolean value);
|
||||||
gchar * prefs_get_theme(void);
|
gchar * prefs_get_theme(void);
|
||||||
void prefs_set_theme(gchar *value);
|
void prefs_set_theme(gchar *value);
|
||||||
|
gboolean prefs_get_ctrlc(void);
|
||||||
|
void prefs_set_ctrlc(gboolean value);
|
||||||
|
|
||||||
void prefs_set_notify_message(gboolean value);
|
void prefs_set_notify_message(gboolean value);
|
||||||
gboolean prefs_get_notify_message(void);
|
gboolean prefs_get_notify_message(void);
|
||||||
|
@ -106,7 +106,7 @@ gui_init(void)
|
|||||||
{
|
{
|
||||||
log_info("Initialising UI");
|
log_info("Initialising UI");
|
||||||
initscr();
|
initscr();
|
||||||
cbreak();
|
raw();
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
|
|
||||||
win_load_colours();
|
win_load_colours();
|
||||||
@ -1050,6 +1050,11 @@ cons_prefs(void)
|
|||||||
else
|
else
|
||||||
cons_show("Version checking : OFF");
|
cons_show("Version checking : OFF");
|
||||||
|
|
||||||
|
if (prefs_get_ctrlc())
|
||||||
|
cons_show("Ctrl-c quits : ON");
|
||||||
|
else
|
||||||
|
cons_show("Ctrl-c quits : OFF");
|
||||||
|
|
||||||
if (prefs_get_notify_message())
|
if (prefs_get_notify_message())
|
||||||
cons_show("Message notifications : ON");
|
cons_show("Message notifications : ON");
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user