From 2cf211b99fa4cf91d5f98eb4cae206e796778873 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Wed, 8 Oct 2014 19:25:35 +0200 Subject: [PATCH] Changed quit key sequence to ctrl-g + q Changed the quit key sequence from ctrl-g + ctrl-q to ctrl-g + q as the latter is simpler and considered more conventional. --- src/include/gotty/tty.h | 4 ++-- src/options.c | 2 +- src/tty.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) 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 */