1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-30 21:55:24 +00:00

Stop ctrl-c quitting with /ctrlc off

This commit is contained in:
James Booth 2012-11-23 02:00:51 +00:00
parent 2a69f8d23f
commit 721df8ca48
5 changed files with 59 additions and 4 deletions

View File

@ -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_states(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_away(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",
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",
_cmd_set_priority, parse_args, 1, 1,
{ "/priority <value>", "Set priority for connection.",
@ -855,6 +865,8 @@ _cmd_complete_parameters(char *input, int *size)
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/states",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/ctrlc",
prefs_autocomplete_boolean_choice);
_parameter_autocomplete(input, size, "/outtype",
prefs_autocomplete_boolean_choice);
_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);
}
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
_cmd_set_outtype(gchar **args, struct cmd_help_t help)
{

View File

@ -241,17 +241,33 @@ _handle_edit(const int ch, char *input, int *size)
char *next = NULL;
int inp_y = 0;
int inp_x = 0;
int next_ch;
getmaxyx(stdscr, rows, cols);
getyx(inp_win, inp_y, inp_x);
switch(ch) {
case 27: // ESC
*size = 0;
inp_clear();
case 3: // CTRL-C
if (prefs_get_ctrlc()) {
exit(0);
}
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 KEY_BACKSPACE:
contact_list_reset_search_attempts();

View File

@ -132,6 +132,19 @@ prefs_set_beep(gboolean value)
_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 *
prefs_get_theme(void)
{

View File

@ -65,6 +65,8 @@ gboolean prefs_get_outtype(void);
void prefs_set_outtype(gboolean value);
gchar * prefs_get_theme(void);
void prefs_set_theme(gchar *value);
gboolean prefs_get_ctrlc(void);
void prefs_set_ctrlc(gboolean value);
void prefs_set_notify_message(gboolean value);
gboolean prefs_get_notify_message(void);

View File

@ -106,7 +106,7 @@ gui_init(void)
{
log_info("Initialising UI");
initscr();
cbreak();
raw();
keypad(stdscr, TRUE);
win_load_colours();
@ -1050,6 +1050,11 @@ cons_prefs(void)
else
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())
cons_show("Message notifications : ON");
else