mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Merge pull request #68 from zhaozhongchen/master
ONLCRNL: change the method to map NL to CR-NL
This commit is contained in:
commit
038eebdeb3
1 changed files with 15 additions and 2 deletions
17
src/tty.c
17
src/tty.c
|
|
@ -55,6 +55,7 @@ static bool standard_baudrate = true;
|
||||||
static void (*print)(char c);
|
static void (*print)(char c);
|
||||||
static int fd;
|
static int fd;
|
||||||
static bool map_inlcrnl = false;
|
static bool map_inlcrnl = false;
|
||||||
|
static bool map_onlcrnl = false;
|
||||||
static bool map_odelbs = false;
|
static bool map_odelbs = false;
|
||||||
|
|
||||||
#define tio_printf(format, args...) \
|
#define tio_printf(format, args...) \
|
||||||
|
|
@ -413,14 +414,14 @@ void tty_configure(void)
|
||||||
tio.c_iflag |= IGNCR;
|
tio.c_iflag |= IGNCR;
|
||||||
else if (strcmp(token,"ICRNL") == 0)
|
else if (strcmp(token,"ICRNL") == 0)
|
||||||
tio.c_iflag |= ICRNL;
|
tio.c_iflag |= ICRNL;
|
||||||
else if (strcmp(token,"ONLCRNL") == 0)
|
|
||||||
tio.c_oflag |= ONLCR;
|
|
||||||
else if (strcmp(token,"OCRNL") == 0)
|
else if (strcmp(token,"OCRNL") == 0)
|
||||||
tio.c_oflag |= OCRNL;
|
tio.c_oflag |= OCRNL;
|
||||||
else if (strcmp(token,"ODELBS") == 0)
|
else if (strcmp(token,"ODELBS") == 0)
|
||||||
map_odelbs = true;
|
map_odelbs = true;
|
||||||
else if (strcmp(token,"INLCRNL") == 0)
|
else if (strcmp(token,"INLCRNL") == 0)
|
||||||
map_inlcrnl = true;
|
map_inlcrnl = true;
|
||||||
|
else if (strcmp(token, "ONLCRNL") == 0)
|
||||||
|
map_onlcrnl = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Error: Unknown mapping flag %s\n", token);
|
printf("Error: Unknown mapping flag %s\n", token);
|
||||||
|
|
@ -652,6 +653,18 @@ int tty_connect(void)
|
||||||
if ((output_char == 127) && (map_odelbs))
|
if ((output_char == 127) && (map_odelbs))
|
||||||
output_char = '\b';
|
output_char = '\b';
|
||||||
|
|
||||||
|
/* Map newline character */
|
||||||
|
if ((output_char == '\n') && (map_onlcrnl)) {
|
||||||
|
char r = '\r';
|
||||||
|
|
||||||
|
status = write(fd, &r, 1);
|
||||||
|
if (status < 0)
|
||||||
|
warning_printf("Could not write to tty device");
|
||||||
|
|
||||||
|
tx_total++;
|
||||||
|
delay(option.output_delay);
|
||||||
|
}
|
||||||
|
|
||||||
/* Send output to tty device */
|
/* Send output to tty device */
|
||||||
status = write(fd, &output_char, 1);
|
status = write(fd, &output_char, 1);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue