From 11762b2300f506a5361527e0a27e84671e27c851 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Mon, 11 Jul 2022 10:15:12 +0200 Subject: [PATCH] Replace -U,--upcase with mapping flag OLTU --- README.md | 7 +++---- man/tio.1.in | 12 ++++-------- src/configfile.c | 4 ---- src/options.c | 12 ++---------- src/options.h | 1 - src/tty.c | 11 ++++++++--- 6 files changed, 17 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index c67b48f..3a39b91 100644 --- a/README.md +++ b/README.md @@ -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 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 ``` diff --git a/man/tio.1.in b/man/tio.1.in index 46001d5..538b586 100644 --- a/man/tio.1.in +++ b/man/tio.1.in @@ -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 @@ -120,7 +116,7 @@ Strip control characters and escape sequences from log. .TP .BR \-m ", " "\-\-map " \fI -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" diff --git a/src/configfile.c b/src/configfile.c index 56d158a..e858aab 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -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); diff --git a/src/options.c b/src/options.c index 62e657a..25fa579 100644 --- a/src/options.c +++ b/src/options.c @@ -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 Set log filename\n"); printf(" --log-strip Strip control characters and escape sequences\n"); - printf(" -m, --map Map special characters\n"); + printf(" -m, --map Map characters\n"); printf(" -c, --color 0..255|none|list Colorize tio text (default: 15)\n"); printf(" -S, --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"); diff --git a/src/options.h b/src/options.h index 1dbe724..66573d0 100644 --- a/src/options.h +++ b/src/options.h @@ -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; diff --git a/src/tty.c b/src/tty.c index d380337..e9d345e 100644 --- a/src/tty.c +++ b/src/tty.c @@ -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