mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Add special character map feature
Add a --map option which allows to map special characters, in particular CR and NL characters which are used in various combinations on varios platforms.
This commit is contained in:
parent
078bb6213d
commit
b2aafd696b
6 changed files with 77 additions and 2 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <termios.h>
|
||||
|
|
@ -44,7 +45,8 @@ struct option_t option =
|
|||
0, // No output delay
|
||||
false, // No autoconnect
|
||||
false, // No log
|
||||
"" // Log filename
|
||||
"", // Log filename
|
||||
"" // Map string
|
||||
};
|
||||
|
||||
void print_help(char *argv[])
|
||||
|
|
@ -60,6 +62,7 @@ void print_help(char *argv[])
|
|||
printf(" -o, --output-delay <ms> Output delay (default: 0)\n");
|
||||
printf(" -n, --no-autoconnect Disable automatic connect\n");
|
||||
printf(" -l, --log <filename> Log to file\n");
|
||||
printf(" -m, --map <flags> Map special characters\n");
|
||||
printf(" -v, --version Display version\n");
|
||||
printf(" -h, --help Display help\n");
|
||||
printf("\n");
|
||||
|
|
@ -105,6 +108,7 @@ void parse_options(int argc, char *argv[])
|
|||
{"output-delay", required_argument, 0, 'o'},
|
||||
{"no-autoconnect", no_argument, 0, 'n'},
|
||||
{"log", required_argument, 0, 'l'},
|
||||
{"map", required_argument, 0, 'm'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0 }
|
||||
|
|
@ -114,7 +118,7 @@ void parse_options(int argc, char *argv[])
|
|||
int option_index = 0;
|
||||
|
||||
/* Parse argument using getopt_long */
|
||||
c = getopt_long(argc, argv, "b:d:f:s:p:o:nl:vh", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "b:d:f:s:p:o:nl:m:vh", long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options */
|
||||
if (c == -1)
|
||||
|
|
@ -165,6 +169,10 @@ void parse_options(int argc, char *argv[])
|
|||
option.log_filename = optarg;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
option.map = optarg;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
printf("tio v%s\n", VERSION);
|
||||
printf("Copyright (c) 2014-2017 Martin Lund\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue