mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
Merge pull request #80 from marmidr/crlf
Newline: handle booth NL and CR
This commit is contained in:
commit
febefa638f
1 changed files with 19 additions and 17 deletions
16
src/tty.c
16
src/tty.c
|
|
@ -788,18 +788,19 @@ int tty_connect(void)
|
||||||
output_char = '\n';
|
output_char = '\n';
|
||||||
|
|
||||||
/* Map newline character */
|
/* Map newline character */
|
||||||
if ((output_char == '\n') && (map_o_nl_crnl)) {
|
if ((output_char == '\n' || output_char == '\r') && (map_o_nl_crnl)) {
|
||||||
char r = '\r';
|
const char *crlf = "\r\n";
|
||||||
|
|
||||||
optional_local_echo(r);
|
optional_local_echo(crlf[0]);
|
||||||
status = write(fd, &r, 1);
|
optional_local_echo(crlf[1]);
|
||||||
|
status = write(fd, crlf, 2);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
warning_printf("Could not write to tty device");
|
warning_printf("Could not write to tty device");
|
||||||
|
|
||||||
tx_total++;
|
tx_total += 2;
|
||||||
delay(option.output_delay);
|
delay(option.output_delay);
|
||||||
}
|
} else
|
||||||
|
{
|
||||||
/* Send output to tty device */
|
/* Send output to tty device */
|
||||||
optional_local_echo(output_char);
|
optional_local_echo(output_char);
|
||||||
status = write(fd, &output_char, 1);
|
status = write(fd, &output_char, 1);
|
||||||
|
|
@ -813,6 +814,7 @@ int tty_connect(void)
|
||||||
/* Insert output delay */
|
/* Insert output delay */
|
||||||
delay(option.output_delay);
|
delay(option.output_delay);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Save previous key */
|
/* Save previous key */
|
||||||
previous_char = input_char;
|
previous_char = input_char;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue