]> git.sur5r.net Git - tio/blobdiff - src/tty.c
New upstream version 1.30
[tio] / src / tty.c
index 9ad4980b31026e1395af262f2d4ccb01f0827272..c823e1b7c25dd98936b4a13347cf47436da83ea8 100644 (file)
--- a/src/tty.c
+++ b/src/tty.c
@@ -55,6 +55,7 @@ static bool standard_baudrate = true;
 static void (*print)(char c);
 static int fd;
 static bool map_inlcrnl = false;
+static bool map_onlcrnl = false;
 static bool map_odelbs = false;
 
 #define tio_printf(format, args...) \
@@ -413,14 +414,14 @@ void tty_configure(void)
                 tio.c_iflag |= IGNCR;
             else if (strcmp(token,"ICRNL") == 0)
                 tio.c_iflag |= ICRNL;
-            else if (strcmp(token,"ONLCRNL") == 0)
-                tio.c_oflag |= ONLCR;
             else if (strcmp(token,"OCRNL") == 0)
                 tio.c_oflag |= OCRNL;
             else if (strcmp(token,"ODELBS") == 0)
                 map_odelbs = true;
             else if (strcmp(token,"INLCRNL") == 0)
                 map_inlcrnl = true;
+            else if (strcmp(token, "ONLCRNL") == 0)
+                map_onlcrnl = true;
             else
             {
                 printf("Error: Unknown mapping flag %s\n", token);
@@ -652,6 +653,18 @@ int tty_connect(void)
                     if ((output_char == 127) && (map_odelbs))
                         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 */
                     status = write(fd, &output_char, 1);
                     if (status < 0)