Additional commands: EOL delay, lower to upper translation, added mark parity

Added command line options:
-O, --eol-delay to have a separate delay for end of line
-U, --upper to enable translation of lower case alpha to upper case

Added ability to set mark parity.
Added ctrl-t U key sequence to allow enable/disable lower case alpha to
upper case during a session.
Updated Man page with command line options, ctrl-t sequences and
configuration file options.
Updated README.md, with above information.
This commit is contained in:
Robert Snell 2022-07-09 21:22:43 -04:00
parent dbdb84743f
commit 944ee9173b
7 changed files with 98 additions and 6 deletions

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/types.h>
@ -146,11 +147,16 @@ ssize_t tty_write(int fd, const void *buffer, size_t count)
{
ssize_t bytes_written = 0;
if (option.output_delay)
if (option.output_delay || option.eol_delay )
{
// Write byte by byte with output delay
for (size_t i=0; i<count; i++)
{
// convert alpha to upper case
if ( option.upcase )
{
*(unsigned char*)buffer = toupper(*(unsigned char*)buffer);
}
ssize_t retval = write(fd, buffer, 1);
if (retval < 0)
{
@ -159,8 +165,15 @@ ssize_t tty_write(int fd, const void *buffer, size_t count)
break;
}
bytes_written += retval;
if ( option.eol_delay && *(unsigned char*)buffer == '\r' )
{
delay( option.eol_delay );
}
fsync(fd);
delay(option.output_delay);
if ( option.output_delay )
{
delay(option.output_delay);
}
}
}
else
@ -171,6 +184,14 @@ ssize_t tty_write(int fd, const void *buffer, size_t count)
tty_flush(fd);
}
// convert lower case to upper case, in situ
if ( option.upcase )
{
for ( size_t i = 0; i<count; i++ )
{
*((unsigned char*)buffer+i) = toupper(*((unsigned char*)buffer+i));
}
}
// Copy bytes to tty write buffer
memcpy(tty_buffer_write_ptr, buffer, count);
tty_buffer_write_ptr += count;
@ -266,6 +287,7 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
tio_printf(" ctrl-t s Show statistics");
tio_printf(" ctrl-t t Send ctrl-t key code");
tio_printf(" ctrl-t T Toggle line timestamp mode");
tio_printf(" ctrl-t U Toggle upcase");
tio_printf(" ctrl-t v Show version");
break;
@ -375,6 +397,17 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
}
break;
case KEY_U:
if ( option.upcase == true )
{
option.upcase = false;
}
else
{
option.upcase = true;
}
break;
case KEY_V:
tio_printf("tio v%s", VERSION);
break;
@ -596,6 +629,12 @@ void tty_configure(void)
{
tio.c_cflag &= ~PARENB;
}
else if ( strcmp("mark", option.parity) == 0)
{
tio.c_cflag &= ~PARENB;
tio.c_cflag |= PARODD;
tio.c_cflag |= CMSPAR;
}
else
{
error_printf("Invalid parity");