mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
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:
parent
1c53af0681
commit
02729c10b1
9 changed files with 36 additions and 34 deletions
|
|
@ -89,8 +89,6 @@ The command-line interface is straightforward as reflected in the output from
|
||||||
|
|
||||||
Options and sub-configurations may be set via configuration file.
|
Options and sub-configurations may be set via configuration file.
|
||||||
|
|
||||||
In session, press ctrl-t q to quit.
|
|
||||||
|
|
||||||
See the man page for more details.
|
See the man page for more details.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ Display help.
|
||||||
.SH "KEYS"
|
.SH "KEYS"
|
||||||
.PP
|
.PP
|
||||||
.TP 16n
|
.TP 16n
|
||||||
In session, the following key sequences are intercepted as tio commands:
|
In session, the following key sequences, a prefix key (default: ctrl-t) followed by a command key, are intercepted as tio commands:
|
||||||
.IP "\fBctrl-t ?"
|
.IP "\fBctrl-t ?"
|
||||||
List available key commands
|
List available key commands
|
||||||
.IP "\fBctrl-t b"
|
.IP "\fBctrl-t b"
|
||||||
|
|
@ -218,8 +218,6 @@ Clear screen
|
||||||
Quit
|
Quit
|
||||||
.IP "\fBctrl-t s"
|
.IP "\fBctrl-t s"
|
||||||
Show TX/RX statistics
|
Show TX/RX statistics
|
||||||
.IP "\fBctrl-t t"
|
|
||||||
Send ctrl-t key code
|
|
||||||
.IP "\fBctrl-t L"
|
.IP "\fBctrl-t L"
|
||||||
Show line states (DTR, RTS, CTS, DSR, DCD, RI)
|
Show line states (DTR, RTS, CTS, DSR, DCD, RI)
|
||||||
.IP "\fBctrl-t d"
|
.IP "\fBctrl-t d"
|
||||||
|
|
@ -315,6 +313,8 @@ Colorize tio text using ANSI color code ranging from 0 to 255
|
||||||
Enable hexadecimal mode
|
Enable hexadecimal mode
|
||||||
.IP "\fBsocket"
|
.IP "\fBsocket"
|
||||||
Set socket to redirect I/O to
|
Set socket to redirect I/O to
|
||||||
|
.IP "\fBprefix-ctrl-key"
|
||||||
|
Set prefix ctrl key (a..z, default: t)
|
||||||
|
|
||||||
.SH "CONFIGURATION FILE EXAMPLES"
|
.SH "CONFIGURATION FILE EXAMPLES"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,15 @@ static int data_handler(void *user, const char *section, const char *name,
|
||||||
asprintf(&c->socket, "%s", value);
|
asprintf(&c->socket, "%s", value);
|
||||||
option.socket = c->socket;
|
option.socket = c->socket;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(name, "prefix-ctrl-key"))
|
||||||
|
{
|
||||||
|
if (ctrl_key_code(value[0]) > 0)
|
||||||
|
{
|
||||||
|
option.prefix_code = ctrl_key_code(value[0]);
|
||||||
|
option.prefix_key = value[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ int main(int argc, char *argv[])
|
||||||
tio_printf("tio v%s", VERSION);
|
tio_printf("tio v%s", VERSION);
|
||||||
if (interactive_mode)
|
if (interactive_mode)
|
||||||
{
|
{
|
||||||
tio_printf("Press ctrl-t q to quit");
|
tio_printf("Press ctrl-%c q to quit", option.prefix_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open socket */
|
/* Open socket */
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,4 @@
|
||||||
char * current_time(void);
|
char * current_time(void);
|
||||||
void delay(long ms);
|
void delay(long ms);
|
||||||
long string_to_long(char *string);
|
long string_to_long(char *string);
|
||||||
|
int ctrl_key_code(unsigned char key);
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ struct option_t option =
|
||||||
.map = "",
|
.map = "",
|
||||||
.color = 15,
|
.color = 15,
|
||||||
.hex_mode = false,
|
.hex_mode = false,
|
||||||
|
.prefix_code = 20, // ctrl-t
|
||||||
|
.prefix_key = 't',
|
||||||
};
|
};
|
||||||
|
|
||||||
void print_help(char *argv[])
|
void print_help(char *argv[])
|
||||||
|
|
@ -101,8 +103,6 @@ void print_help(char *argv[])
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Options and sub-configurations may be set via configuration file.\n");
|
printf("Options and sub-configurations may be set via configuration file.\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("In session, press ctrl-t q to quit.\n");
|
|
||||||
printf("\n");
|
|
||||||
printf("See the man page for more details.\n");
|
printf("See the man page for more details.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ struct option_t
|
||||||
const char *socket;
|
const char *socket;
|
||||||
int color;
|
int color;
|
||||||
bool hex_mode;
|
bool hex_mode;
|
||||||
|
unsigned char prefix_code;
|
||||||
|
unsigned char prefix_key;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct option_t option;
|
extern struct option_t option;
|
||||||
|
|
|
||||||
43
src/tty.c
43
src/tty.c
|
|
@ -262,7 +262,7 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
|
||||||
forward = &unused_bool;
|
forward = &unused_bool;
|
||||||
|
|
||||||
/* Handle escape key commands */
|
/* 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 */
|
/* Do not forward input char to output by default */
|
||||||
*forward = false;
|
*forward = false;
|
||||||
|
|
@ -271,22 +271,21 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
|
||||||
{
|
{
|
||||||
case KEY_QUESTION:
|
case KEY_QUESTION:
|
||||||
tio_printf("Key commands:");
|
tio_printf("Key commands:");
|
||||||
tio_printf(" ctrl-t ? List available key commands");
|
tio_printf(" ctrl-%c ? List available key commands", option.prefix_key);
|
||||||
tio_printf(" ctrl-t b Send break");
|
tio_printf(" ctrl-%c b Send break", option.prefix_key);
|
||||||
tio_printf(" ctrl-t c Show configuration");
|
tio_printf(" ctrl-%c c Show configuration", option.prefix_key);
|
||||||
tio_printf(" ctrl-t d Toggle DTR line");
|
tio_printf(" ctrl-%c d Toggle DTR line", option.prefix_key);
|
||||||
tio_printf(" ctrl-t D Pulse DTR line");
|
tio_printf(" ctrl-%c D Pulse DTR line", option.prefix_key);
|
||||||
tio_printf(" ctrl-t e Toggle local echo mode");
|
tio_printf(" ctrl-%c e Toggle local echo mode", option.prefix_key);
|
||||||
tio_printf(" ctrl-t h Toggle hexadecimal mode");
|
tio_printf(" ctrl-%c h Toggle hexadecimal mode", option.prefix_key);
|
||||||
tio_printf(" ctrl-t l Clear screen");
|
tio_printf(" ctrl-%c l Clear screen", option.prefix_key);
|
||||||
tio_printf(" ctrl-t L Show line states");
|
tio_printf(" ctrl-%c L Show line states", option.prefix_key);
|
||||||
tio_printf(" ctrl-t q Quit");
|
tio_printf(" ctrl-%c q Quit", option.prefix_key);
|
||||||
tio_printf(" ctrl-t r Toggle RTS line");
|
tio_printf(" ctrl-%c r Toggle RTS line", option.prefix_key);
|
||||||
tio_printf(" ctrl-t s Show statistics");
|
tio_printf(" ctrl-%c s Show statistics", option.prefix_key);
|
||||||
tio_printf(" ctrl-t t Send ctrl-t key code");
|
tio_printf(" ctrl-%c T Toggle line timestamp mode", option.prefix_key);
|
||||||
tio_printf(" ctrl-t T Toggle line timestamp mode");
|
tio_printf(" ctrl-%c U Toggle conversion to uppercase", option.prefix_key);
|
||||||
tio_printf(" ctrl-t U Toggle conversion to uppercase");
|
tio_printf(" ctrl-%c v Show version", option.prefix_key);
|
||||||
tio_printf(" ctrl-t v Show version");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_SHIFT_L:
|
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);
|
tio_printf(" Received %lu bytes", rx_total);
|
||||||
break;
|
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:
|
case KEY_SHIFT_T:
|
||||||
option.timestamp += 1;
|
option.timestamp += 1;
|
||||||
switch (option.timestamp)
|
switch (option.timestamp)
|
||||||
|
|
@ -1057,8 +1050,8 @@ int tty_connect(void)
|
||||||
|
|
||||||
if (interactive_mode)
|
if (interactive_mode)
|
||||||
{
|
{
|
||||||
/* Do not forward ctrl-t key */
|
/* Do not forward prefix key */
|
||||||
if (input_char == KEY_CTRL_T)
|
if (input_char == option.prefix_code)
|
||||||
{
|
{
|
||||||
forward = false;
|
forward = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@
|
||||||
#define KEY_S 0x73
|
#define KEY_S 0x73
|
||||||
#define KEY_T 0x74
|
#define KEY_T 0x74
|
||||||
#define KEY_SHIFT_T 0x54
|
#define KEY_SHIFT_T 0x54
|
||||||
#define KEY_CTRL_T 0x14
|
|
||||||
#define KEY_U 0x55
|
#define KEY_U 0x55
|
||||||
#define KEY_V 0x76
|
#define KEY_V 0x76
|
||||||
#define KEY_D 0x64
|
#define KEY_D 0x64
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue