diff --git a/src/include/gotty/tty.h b/src/include/gotty/tty.h index 9d9ea67..136bdc5 100644 --- a/src/include/gotty/tty.h +++ b/src/include/gotty/tty.h @@ -22,8 +22,8 @@ #ifndef TTY_H #define TTY_H -#define CTRLG 0x07 -#define CTRLQ 0x11 +#define KEY_CTRL_G 0x07 +#define KEY_Q 0x71 void configure_stdout(void); void restore_stdout(void); diff --git a/src/options.c b/src/options.c index d1d7289..bedef80 100644 --- a/src/options.c +++ b/src/options.c @@ -51,7 +51,7 @@ void print_options_help(char *argv[]) printf(" -v, --version Display version\n"); printf(" -h, --help Display help\n"); printf("\n"); - printf("In session, press ctrl-g + ctrl-q to quit.\n"); + printf("In session, press ctrl-g + q to quit.\n"); printf("\n"); } diff --git a/src/tty.c b/src/tty.c index 9e5be18..d9a5907 100644 --- a/src/tty.c +++ b/src/tty.c @@ -68,10 +68,10 @@ void wait_for_tty_device(void) /* Read one character */ n = read(STDIN_FILENO, &c_stdin[0], 1); - /* Exit upon ctrl-g ctrl-q sequence */ + /* Exit upon ctrl-g + q sequence */ c_stdin[2] = c_stdin[1]; c_stdin[1] = c_stdin[0]; - if ((c_stdin[1] == CTRLQ) && (c_stdin[2] == CTRLG)) + if ((c_stdin[1] == KEY_Q) && (c_stdin[2] == KEY_CTRL_G)) exit(EXIT_SUCCESS); } else { @@ -222,13 +222,13 @@ int connect_tty(void) { /* Input from stdin ready */ status = read(STDIN_FILENO, &c_stdin[0], 1); - if ((c_stdin[0] != CTRLQ) && (c_stdin[0] != CTRLG)) + if ((c_stdin[0] != KEY_Q) && (c_stdin[0] != KEY_CTRL_G)) tainted = true; - /* Exit upon ctrl-g ctrl-q sequence */ + /* Exit upon ctrl-g + q sequence */ c_stdin[2] = c_stdin[1]; c_stdin[1] = c_stdin[0]; - if ((c_stdin[1] == CTRLQ) && (c_stdin[2] == CTRLG)) + if ((c_stdin[1] == KEY_Q) && (c_stdin[2] == KEY_CTRL_G)) exit(EXIT_SUCCESS); /* Forward input to tty device */