mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Remove newline option in hex mode
This commit is contained in:
parent
0b55981e52
commit
6d007d39d7
6 changed files with 5 additions and 21 deletions
|
|
@ -46,6 +46,7 @@ The command-line interface is straightforward as reflected in the output from
|
||||||
-m, --map <flags> Map special characters
|
-m, --map <flags> Map special characters
|
||||||
-c, --color <code> Colorize tio text
|
-c, --color <code> Colorize tio text
|
||||||
-S, --socket <socket> Listen on socket
|
-S, --socket <socket> Listen on socket
|
||||||
|
-x, --hex Enable hexadecimal mode
|
||||||
-v, --version Display version
|
-v, --version Display version
|
||||||
-h, --help Display help
|
-h, --help Display help
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,12 +120,7 @@ If defining more than one flag, the flags must be comma separated.
|
||||||
.TP
|
.TP
|
||||||
.BR \-x ", " \-\-hex
|
.BR \-x ", " \-\-hex
|
||||||
|
|
||||||
Start in hexadecimal mode.
|
Enable hexadecimal mode.
|
||||||
|
|
||||||
.TP
|
|
||||||
.BR \-\-newline-in-hex
|
|
||||||
|
|
||||||
Interpret new line characters ('\\r', '\\n') in hexadecimal mode.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-c ", " "\-\-color " \fI<code>
|
.BR \-c ", " "\-\-color " \fI<code>
|
||||||
|
|
@ -194,8 +189,6 @@ Show version
|
||||||
.TP
|
.TP
|
||||||
In hexadecimal mode each incoming byte is printed out as a hexadecimal value.
|
In hexadecimal mode each incoming byte is printed out as a hexadecimal value.
|
||||||
.TP
|
.TP
|
||||||
By default there is \fBno new line\fR in this mode, but it can be turned on using the \fB--newline-in-hex\fR option.
|
|
||||||
.TP
|
|
||||||
Bytes can be sent in this mode by typing the \fBtwo-character hexadecimal\fR representation of the value, e.g.: to send \fI0xA\fR you must type \fI0a\fR or \fI0A\fR.
|
Bytes can be sent in this mode by typing the \fBtwo-character hexadecimal\fR representation of the value, e.g.: to send \fI0xA\fR you must type \fI0a\fR or \fI0A\fR.
|
||||||
|
|
||||||
.SH "CONFIGURATION"
|
.SH "CONFIGURATION"
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,6 @@ struct option_t option =
|
||||||
.map = "",
|
.map = "",
|
||||||
.color = -1,
|
.color = -1,
|
||||||
.hex_mode = false,
|
.hex_mode = false,
|
||||||
.newline_in_hex = false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void print_help(char *argv[])
|
void print_help(char *argv[])
|
||||||
|
|
@ -86,8 +85,7 @@ void print_help(char *argv[])
|
||||||
printf(" -m, --map <flags> Map special characters\n");
|
printf(" -m, --map <flags> Map special characters\n");
|
||||||
printf(" -c, --color <code> Colorize tio text\n");
|
printf(" -c, --color <code> Colorize tio text\n");
|
||||||
printf(" -S, --socket <socket> Listen on socket\n");
|
printf(" -S, --socket <socket> Listen on socket\n");
|
||||||
printf(" -x, --hex Start in hexadecimal mode\n");
|
printf(" -x, --hex Enable hexadecimal mode\n");
|
||||||
printf(" --newline-in-hex Interpret new line characters in hex mode\n");
|
|
||||||
printf(" -v, --version Display version\n");
|
printf(" -v, --version Display version\n");
|
||||||
printf(" -h, --help Display help\n");
|
printf(" -h, --help Display help\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
@ -200,7 +198,6 @@ void options_parse(int argc, char *argv[])
|
||||||
{"map", required_argument, 0, 'm' },
|
{"map", required_argument, 0, 'm' },
|
||||||
{"color", required_argument, 0, 'c' },
|
{"color", required_argument, 0, 'c' },
|
||||||
{"hex", no_argument, 0, 'x' },
|
{"hex", no_argument, 0, 'x' },
|
||||||
{"newline-in-hex", no_argument, 0, OPT_NEWLINE_IN_HEX },
|
|
||||||
{"version", no_argument, 0, 'v' },
|
{"version", no_argument, 0, 'v' },
|
||||||
{"help", no_argument, 0, 'h' },
|
{"help", no_argument, 0, 'h' },
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
|
|
@ -311,10 +308,6 @@ void options_parse(int argc, char *argv[])
|
||||||
option.hex_mode = true;
|
option.hex_mode = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPT_NEWLINE_IN_HEX:
|
|
||||||
option.newline_in_hex = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
printf("tio v%s\n", VERSION);
|
printf("tio v%s\n", VERSION);
|
||||||
printf("Copyright (c) 2014-2022 Martin Lund\n");
|
printf("Copyright (c) 2014-2022 Martin Lund\n");
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@ enum timestamp_t
|
||||||
const char* timestamp_token(enum timestamp_t timestamp);
|
const char* timestamp_token(enum timestamp_t timestamp);
|
||||||
enum timestamp_t timestamp_option_parse(const char *arg);
|
enum timestamp_t timestamp_option_parse(const char *arg);
|
||||||
|
|
||||||
#define OPT_NEWLINE_IN_HEX 1000 // "short" option for --newline-in-hex
|
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
struct option_t
|
struct option_t
|
||||||
{
|
{
|
||||||
|
|
@ -59,7 +57,6 @@ struct option_t
|
||||||
const char *socket;
|
const char *socket;
|
||||||
int color;
|
int color;
|
||||||
bool hex_mode;
|
bool hex_mode;
|
||||||
bool newline_in_hex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct option_t option;
|
extern struct option_t option;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ char ansi_format[30];
|
||||||
|
|
||||||
void print_hex(char c)
|
void print_hex(char c)
|
||||||
{
|
{
|
||||||
if (((c == '\n') || (c == '\r')) && option.newline_in_hex)
|
if ((c == '\n') || (c == '\r'))
|
||||||
{
|
{
|
||||||
printf("%c", c);
|
printf("%c", c);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -687,6 +687,7 @@ int tty_connect(void)
|
||||||
if (option.timestamp)
|
if (option.timestamp)
|
||||||
next_timestamp = true;
|
next_timestamp = true;
|
||||||
|
|
||||||
|
/* Manage print output mode */
|
||||||
if (option.hex_mode)
|
if (option.hex_mode)
|
||||||
{
|
{
|
||||||
print = print_hex;
|
print = print_hex;
|
||||||
|
|
@ -697,7 +698,6 @@ int tty_connect(void)
|
||||||
{
|
{
|
||||||
print = print_normal;
|
print = print_normal;
|
||||||
print_mode = NORMAL;
|
print_mode = NORMAL;
|
||||||
tio_printf("Switched to normal mode");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save current port settings */
|
/* Save current port settings */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue