From: Jonas Fonseca Date: Wed, 15 Oct 2008 10:07:38 +0000 (+0200) Subject: Fix waiting for input after executing a run request in pager mode X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cb7138b216275f5197ee621b674b03edd95cf1b6;p=tig.git Fix waiting for input after executing a run request in pager mode When in pager mode, stdin should not be touched. After executing a run request a getc(stdin) was done to wait for the user's command to continue, which didn't result in the expected behavior. To fix this store the proper TTY handle in the new opt_tty variable which is set up by init_display(). --- diff --git a/NEWS b/NEWS index d192439..a0f75c6 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ Bug fixes: - Separate blame revision and file argument by "--" to avoid problems. - Main view: fix redrawing of the last commit wrt. the revision graph. + - Fix waiting for input after executing a run request in pager mode. tig-0.12.1 ---------- diff --git a/tig.c b/tig.c index b5078c0..3394d40 100644 --- a/tig.c +++ b/tig.c @@ -483,6 +483,7 @@ static char opt_cdup[SIZEOF_STR] = ""; static char opt_git_dir[SIZEOF_STR] = ""; static signed char opt_is_inside_work_tree = -1; /* set to TRUE or FALSE */ static char opt_editor[SIZEOF_STR] = ""; +static FILE *opt_tty = NULL; static enum request parse_options(int argc, const char *argv[]) @@ -2562,7 +2563,7 @@ open_external_viewer(const char *cmd) endwin(); /* restore original tty modes */ system(cmd); fprintf(stderr, "Press Enter to continue"); - getc(stdin); + getc(opt_tty); reset_prog_mode(); redraw_display(); } @@ -5527,13 +5528,13 @@ init_display(void) /* Initialize the curses library */ if (isatty(STDIN_FILENO)) { cursed = !!initscr(); + opt_tty = stdin; } else { /* Leave stdin and stdout alone when acting as a pager. */ - FILE *io = fopen("/dev/tty", "r+"); - - if (!io) + opt_tty = fopen("/dev/tty", "r+"); + if (!opt_tty) die("Failed to open /dev/tty"); - cursed = !!newterm(NULL, io, io); + cursed = !!newterm(NULL, opt_tty, opt_tty); } if (!cursed)