Replace -U,--upcase with mapping flag OLTU

This commit is contained in:
Martin Lund 2022-07-11 10:15:12 +02:00
parent 555e526ce7
commit 11762b2300
6 changed files with 17 additions and 30 deletions

View file

@ -36,9 +36,9 @@ when used in combination with [tmux](https://tmux.github.io).
* Local echo support
* Remap special characters (nl, cr-nl, bs, etc.)
* Line timestamps
* Support for delayed output per transmitted character
* Support for delayed output per character
* Support for delayed output per line
* Support for translation of lower case to upper case
* Support for translation of lowercase to uppercase
* Hexadecimal mode
* Log to file
* Autogeneration of log filename
@ -88,7 +88,6 @@ The command-line interface is straightforward as reflected in the output from
-c, --color 0..255|none|list Colorize tio text (default: 15)
-S, --socket <socket> Redirect I/O to file or network socket
-x, --hexadecimal Enable hexadecimal mode
-U, --upper Enable translation of lower case to upper
-v, --version Display version
-h, --help Display help
@ -147,7 +146,7 @@ ctrl-t ? to list the available key commands.
[20:19:12.041] ctrl-t s Show statistics
[20:19:12.041] ctrl-t t Send ctrl-t key code
[20:19:12.041] ctrl-t T Toggle line timestamp mode
[20:19:12.041] ctrl-t U Toggle lower case alpha to upper case
[20:19:12.041] ctrl-t U Toggle conversion to uppercase
[20:19:12.041] ctrl-t v Show version
```

View file

@ -47,10 +47,6 @@ Set output delay [ms] inserted between each sent character (default: 0).
Set EOL delay [ms] inserted between each sent line (default: 0).
.TP
.BR \-U ", " \-\-upcase"
Convert any entered lower case alpha to upper case (default: disabled)
.TP
.BR " \-\-dtr\-pulse\-duration " \fI<ms>
@ -120,7 +116,7 @@ Strip control characters and escape sequences from log.
.TP
.BR \-m ", " "\-\-map " \fI<flags>
Map (replace, translate) special characters on input or output. The following mapping flags are supported:
Map (replace, translate) characters on input or output. The following mapping flags are supported:
.RS
.TP 12n
.IP "\fBICRNL"
@ -137,6 +133,8 @@ Map CR to NL on output.
Map DEL to BS on output.
.IP "\fBONLCRNL"
Map NL to CR-NL on output.
.IP "\fBOLTU"
Map lowercase characters to uppercase on output.
.P
If defining more than one flag, the flags must be comma separated.
.RE
@ -219,7 +217,7 @@ Pulse DTR
.IP "\fBctrl-t r"
Toggle RTS
.IP "\fBctrl-t U"
Toggle upcase
Toggle conversion to uppercase
.IP "\fBctrl-t v"
Show version
@ -275,8 +273,6 @@ Set parity
Set output delay
.IP "\fBeol-delay"
Set EOL delay
.IP "\fBupcase"
Set translation of alpha from lower to upper case
.IP "\fBdtr-pulse-duration"
Set DTR pulse duration
.IP "\fBno-autoconnect"

View file

@ -128,10 +128,6 @@ static int data_handler(void *user, const char *section, const char *name,
{
option.eol_delay = atoi(value);
}
else if ( !strcmp(name, "upcase"))
{
option.upcase = true;
}
else if (!strcmp(name, "dtr-pulse-duration"))
{
option.dtr_pulse_duration = atoi(value);

View file

@ -57,7 +57,6 @@ struct option_t option =
.output_delay = 0,
.dtr_pulse_duration = 100,
.eol_delay = 0,
.upcase = false,
.no_autoconnect = false,
.log = false,
.log_filename = NULL,
@ -93,11 +92,10 @@ void print_help(char *argv[])
printf(" -l, --log Enable log to file\n");
printf(" --log-file <filename> Set log filename\n");
printf(" --log-strip Strip control characters and escape sequences\n");
printf(" -m, --map <flags> Map special characters\n");
printf(" -m, --map <flags> Map characters\n");
printf(" -c, --color 0..255|none|list Colorize tio text (default: 15)\n");
printf(" -S, --socket <socket> Redirect I/O to file or network socket\n");
printf(" -x, --hexadecimal Enable hexadecimal mode\n");
printf(" -U, --upcase Translate lower case alpha to upper case\n");
printf(" -v, --version Display version\n");
printf(" -h, --help Display help\n");
printf("\n");
@ -177,7 +175,6 @@ void options_print()
tio_printf(" Timestamp: %s", timestamp_state_to_string(option.timestamp));
tio_printf(" Output delay: %d", option.output_delay);
tio_printf(" EOL delay: %d", option.eol_delay);
tio_printf(" Upcase: %s", option.upcase ? "enabled" : "disabled");
tio_printf(" DTR pulse duration: %d", option.dtr_pulse_duration);
tio_printf(" Auto connect: %s", option.no_autoconnect ? "disabled" : "enabled");
if (option.map[0] != 0)
@ -209,7 +206,6 @@ void options_parse(int argc, char *argv[])
{"parity", required_argument, 0, 'p' },
{"output-delay", required_argument, 0, 'o' },
{"eol-delay", required_argument, 0, 'O' },
{"upcase", no_argument, 0, 'U' },
{"dtr-pulse-duration", required_argument, 0, OPT_DTR_PULSE_DURATION },
{"no-autoconnect", no_argument, 0, 'n' },
{"local-echo", no_argument, 0, 'e' },
@ -232,7 +228,7 @@ void options_parse(int argc, char *argv[])
int option_index = 0;
/* Parse argument using getopt_long */
c = getopt_long(argc, argv, "b:d:f:s:p:o:O:UnetLlS:m:c:xvh", long_options, &option_index);
c = getopt_long(argc, argv, "b:d:f:s:p:o:O:netLlS:m:c:xvh", long_options, &option_index);
/* Detect the end of the options */
if (c == -1)
@ -353,10 +349,6 @@ void options_parse(int argc, char *argv[])
option.hex_mode = true;
break;
case 'U':
option.upcase = true;
break;
case 'v':
printf("tio v%s\n", VERSION);
printf("Copyright (c) 2014-2022 Martin Lund\n");

View file

@ -50,7 +50,6 @@ struct option_t
int output_delay;
int dtr_pulse_duration;
int eol_delay;
bool upcase;
bool no_autoconnect;
bool log;
bool log_strip;

View file

@ -77,6 +77,7 @@ static bool map_i_nl_crnl = false;
static bool map_o_cr_nl = false;
static bool map_o_nl_crnl = false;
static bool map_o_del_bs = false;
static bool map_o_ltu = false;
static char hex_chars[2];
static unsigned char hex_char_index = 0;
static char tty_buffer[BUFSIZ*2];
@ -148,7 +149,7 @@ ssize_t tty_write(int fd, const void *buffer, size_t count)
ssize_t retval = 0, bytes_written = 0;
size_t i;
if (option.upcase)
if (map_o_ltu)
{
// Convert lower case to upper case
for (i = 0; i<count; i++)
@ -287,7 +288,7 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
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 upper case");
tio_printf(" ctrl-t U Toggle conversion to uppercase");
tio_printf(" ctrl-t v Show version");
break;
@ -398,7 +399,7 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
break;
case KEY_U:
option.upcase = !option.upcase;
map_o_ltu = !map_o_ltu;
break;
case KEY_V:
@ -686,6 +687,10 @@ void tty_configure(void)
{
map_o_nl_crnl = true;
}
else if (strcmp(token, "OLTU") == 0)
{
map_o_ltu = true;
}
else
{
printf("Error: Unknown mapping flag %s\n", token);