Add support for disabling prefix key handling

To disable prefix key input handing simply set prefix-ctrl-key to
'none'.

Based on original patch from Sebastian Krahmer.
This commit is contained in:
Martin Lund 2024-02-19 16:46:20 +01:00
parent 6c520090c6
commit 593f9495f4
5 changed files with 11 additions and 5 deletions

View file

@ -417,7 +417,7 @@ Enable hexadecimal mode
.IP "\fBsocket"
Set socket to redirect I/O to
.IP "\fBprefix-ctrl-key"
Set prefix ctrl key (a..z, default: t)
Set prefix ctrl key (a..z or 'none', default: t)
.IP "\fBresponse-wait"
Enable wait for line response
.IP "\fBresponse-timeout"

View file

@ -259,7 +259,11 @@ static int data_handler(void *user, const char *section, const char *name,
}
else if (!strcmp(name, "prefix-ctrl-key"))
{
if (ctrl_key_code(value[0]) > 0)
if (!strcmp(value, "none"))
{
option.prefix_enabled = false;
}
else if (ctrl_key_code(value[0]) > 0)
{
option.prefix_code = ctrl_key_code(value[0]);
option.prefix_key = value[0];

View file

@ -86,6 +86,7 @@ struct option_t option =
.hex_mode = false,
.prefix_code = 20, // ctrl-t
.prefix_key = 't',
.prefix_enabled = true,
.response_wait = false,
.response_timeout = 100,
.mute = false,

View file

@ -59,6 +59,7 @@ struct option_t
bool hex_mode;
unsigned char prefix_code;
unsigned char prefix_key;
bool prefix_enabled;
bool response_wait;
int response_timeout;
bool mute;

View file

@ -339,7 +339,7 @@ void *tty_stdin_input_thread(void *arg)
input_char = input_buffer[i];
if (previous_char == option.prefix_code)
if (option.prefix_enabled && previous_char == option.prefix_code)
{
if (input_char == option.prefix_code)
{
@ -569,7 +569,7 @@ void handle_command_sequence(char input_char, char *output_char, bool *forward)
}
/* Handle escape key commands */
if (previous_char == option.prefix_code)
if (option.prefix_enabled && previous_char == option.prefix_code)
{
/* Do not forward input char to output by default */
*forward = false;
@ -1545,7 +1545,7 @@ int tty_connect(void)
if (interactive_mode)
{
/* Do not forward prefix key */
if (input_char == option.prefix_code)
if (option.prefix_enabled && input_char == option.prefix_code)
{
forward = false;
}