mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
Extended hexadecimal mode.
While in hex mode (ctrl-t h) you can output hexadecimal values. E.g.: to send 0x0A you have to type 0A (always 2 characters). Added option -x, --hex to start in hexadecimal mode. Added option --newline-in-hex to interpret newline characters in hex mode. This is disabled by default, because, in my opinion, hex stream is fundamentally different from text, so a "new line" is meaningless in this context.
This commit is contained in:
parent
7d3b687eb4
commit
0b55981e52
5 changed files with 128 additions and 20 deletions
|
|
@ -61,6 +61,8 @@ struct option_t option =
|
|||
.socket = NULL,
|
||||
.map = "",
|
||||
.color = -1,
|
||||
.hex_mode = false,
|
||||
.newline_in_hex = false,
|
||||
};
|
||||
|
||||
void print_help(char *argv[])
|
||||
|
|
@ -84,6 +86,8 @@ void print_help(char *argv[])
|
|||
printf(" -m, --map <flags> Map special characters\n");
|
||||
printf(" -c, --color <code> Colorize tio text\n");
|
||||
printf(" -S, --socket <socket> Listen on socket\n");
|
||||
printf(" -x, --hex Start in hexadecimal mode\n");
|
||||
printf(" --newline-in-hex Interpret new line characters in hex mode\n");
|
||||
printf(" -v, --version Display version\n");
|
||||
printf(" -h, --help Display help\n");
|
||||
printf("\n");
|
||||
|
|
@ -195,6 +199,8 @@ void options_parse(int argc, char *argv[])
|
|||
{"socket", required_argument, 0, 'S' },
|
||||
{"map", required_argument, 0, 'm' },
|
||||
{"color", required_argument, 0, 'c' },
|
||||
{"hex", no_argument, 0, 'x' },
|
||||
{"newline-in-hex", no_argument, 0, OPT_NEWLINE_IN_HEX },
|
||||
{"version", no_argument, 0, 'v' },
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{0, 0, 0, 0 }
|
||||
|
|
@ -204,7 +210,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:netLlS:m:c:vh", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "b:d:f:s:p:o:netLlS:m:c:xvh", long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options */
|
||||
if (c == -1)
|
||||
|
|
@ -301,6 +307,14 @@ void options_parse(int argc, char *argv[])
|
|||
}
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
option.hex_mode = true;
|
||||
break;
|
||||
|
||||
case OPT_NEWLINE_IN_HEX:
|
||||
option.newline_in_hex = true;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
printf("tio v%s\n", VERSION);
|
||||
printf("Copyright (c) 2014-2022 Martin Lund\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue