Add support for remapping prefix key

Make it possible to remap the prefix key (default: ctrl-t) by setting
the prefix-ctrl-key variable in the configuration file.

Allowed values are in the range a..z.

Example, to set the prefix key to ctrl-a simply do:

prefix-ctrl-key = a
This commit is contained in:
Martin Lund 2022-07-15 11:58:53 +02:00
parent 1c53af0681
commit 02729c10b1
9 changed files with 36 additions and 34 deletions

View file

@ -262,7 +262,7 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
forward = &unused_bool;
/* Handle escape key commands */
if (previous_char == KEY_CTRL_T)
if (previous_char == option.prefix_code)
{
/* Do not forward input char to output by default */
*forward = false;
@ -271,22 +271,21 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
{
case KEY_QUESTION:
tio_printf("Key commands:");
tio_printf(" ctrl-t ? List available key commands");
tio_printf(" ctrl-t b Send break");
tio_printf(" ctrl-t c Show configuration");
tio_printf(" ctrl-t d Toggle DTR line");
tio_printf(" ctrl-t D Pulse DTR line");
tio_printf(" ctrl-t e Toggle local echo mode");
tio_printf(" ctrl-t h Toggle hexadecimal mode");
tio_printf(" ctrl-t l Clear screen");
tio_printf(" ctrl-t L Show line states");
tio_printf(" ctrl-t q Quit");
tio_printf(" ctrl-t r Toggle RTS line");
tio_printf(" ctrl-t s Show statistics");
tio_printf(" ctrl-t t Send ctrl-t key code");
tio_printf(" ctrl-t T Toggle line timestamp mode");
tio_printf(" ctrl-t U Toggle conversion to uppercase");
tio_printf(" ctrl-t v Show version");
tio_printf(" ctrl-%c ? List available key commands", option.prefix_key);
tio_printf(" ctrl-%c b Send break", option.prefix_key);
tio_printf(" ctrl-%c c Show configuration", option.prefix_key);
tio_printf(" ctrl-%c d Toggle DTR line", option.prefix_key);
tio_printf(" ctrl-%c D Pulse DTR line", option.prefix_key);
tio_printf(" ctrl-%c e Toggle local echo mode", option.prefix_key);
tio_printf(" ctrl-%c h Toggle hexadecimal mode", option.prefix_key);
tio_printf(" ctrl-%c l Clear screen", option.prefix_key);
tio_printf(" ctrl-%c L Show line states", option.prefix_key);
tio_printf(" ctrl-%c q Quit", option.prefix_key);
tio_printf(" ctrl-%c r Toggle RTS line", option.prefix_key);
tio_printf(" ctrl-%c s Show statistics", option.prefix_key);
tio_printf(" ctrl-%c T Toggle line timestamp mode", option.prefix_key);
tio_printf(" ctrl-%c U Toggle conversion to uppercase", option.prefix_key);
tio_printf(" ctrl-%c v Show version", option.prefix_key);
break;
case KEY_SHIFT_L:
@ -364,12 +363,6 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
tio_printf(" Received %lu bytes", rx_total);
break;
case KEY_T:
/* Send ctrl-t key code upon ctrl-t t sequence */
*output_char = KEY_CTRL_T;
*forward = true;
break;
case KEY_SHIFT_T:
option.timestamp += 1;
switch (option.timestamp)
@ -1057,8 +1050,8 @@ int tty_connect(void)
if (interactive_mode)
{
/* Do not forward ctrl-t key */
if (input_char == KEY_CTRL_T)
/* Do not forward prefix key */
if (input_char == option.prefix_code)
{
forward = false;
}