From 68824e778a9474ecd53903bfe952aa12d8147cba Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Wed, 16 Oct 2019 22:54:51 -0400 Subject: [PATCH] Adds ICRCRNL flag to map to on input I'm working with a device that terminates command with a bare . This results in everything on the same line, which is confusing. Remapping that bare to makes it much easier to work with, and this seems like a natural counterpart to INLCRNL. --- man/tio.1 | 2 ++ src/tty.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/man/tio.1 b/man/tio.1 index 566e22c..94ad94b 100644 --- a/man/tio.1 +++ b/man/tio.1 @@ -76,6 +76,8 @@ Ignore CR on input. Map NL to CR on input. .IP "\fBINLCRNL" Map NL to CR-NL on input. +.IP "\fBICRCRNL" +Map CR to CR-NL on input. .IP "\fBOCRNL" Map CR to NL on output. .IP "\fBODELBS" diff --git a/src/tty.c b/src/tty.c index bee6f9f..6d0fbcf 100644 --- a/src/tty.c +++ b/src/tty.c @@ -56,6 +56,7 @@ static bool standard_baudrate = true; static void (*print)(char c); static int fd; static bool map_i_nl_crnl = false; +static bool map_i_cr_crnl = false; static bool map_o_cr_nl = false; static bool map_o_nl_crnl = false; static bool map_o_del_bs = false; @@ -439,6 +440,8 @@ void tty_configure(void) map_o_del_bs = true; else if (strcmp(token,"INLCRNL") == 0) map_i_nl_crnl = true; + else if (strcmp(token,"ICRCRNL") == 0) + map_i_cr_crnl = true; else if (strcmp(token, "ONLCRNL") == 0) map_o_nl_crnl = true; else @@ -647,6 +650,12 @@ int tty_connect(void) /* Map input character */ if ((input_char == '\n') && (map_i_nl_crnl)) + { + print('\r'); + print('\n'); + if (option.timestamp) + next_timestamp = time(NULL); + } else if ((input_char == '\r') && (map_i_cr_crnl)) { print('\r'); print('\n');