diff options
author | Jonas Fonseca <jonas.fonseca@gmail.com> | 2017-07-09 22:23:03 -0400 |
---|---|---|
committer | Jonas Fonseca <jonas.fonseca@gmail.com> | 2017-07-14 17:44:11 -0400 |
commit | 9b6fa85f975025c41c62d2c72c6f8a2f0e05a908 (patch) | |
tree | 73425f171e3cb229d7f4596e6bcdd8d21519c524 | |
parent | 12ed3a709dc576ecc2da0b980f785e9d3b363131 (diff) |
Fix suspension capability when calling out to external commandsfix-restoring-from-suspend
Clear the terminal before calling out to an external command so the
altscreen won't mess up any downstream subshell management. Restore
terminal settings as per init_display when restoring. Reproducible with
example from[0]:
- Run `tig status`
- Press 'e' to open Vim
- Press Ctrl-Z to suspend Vim
- Run `fg`
- Quit Vim
[0] https://github.com/jonas/tig/issues/232#issuecomment-313790438
Refs: #232
-rw-r--r-- | src/display.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/display.c b/src/display.c index ec6b01e4..0ba460d0 100644 --- a/src/display.c +++ b/src/display.c @@ -57,6 +57,8 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf ok = io_run_bg(argv, dir); } else { + clear(); + refresh(); endwin(); /* restore original tty modes */ ok = io_run_fg(argv, dir); if (confirm || !ok) { @@ -65,6 +67,11 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf fprintf(stderr, "Press Enter to continue"); getc(opt_tty); } + nonl(); /* Disable conversion and detect newlines from input. */ + raw(); /* Take input chars one at a time, no wait for \n */ + noecho(); /* Don't echo input */ + curs_set(0); + leaveok(stdscr, false); } if (watch_update(WATCH_EVENT_AFTER_COMMAND) && refresh) { @@ -546,10 +553,7 @@ init_display(void) die("Failed to register done_display"); /* Initialize the curses library */ - if (!no_display && isatty(STDIN_FILENO)) { - cursed = !!initscr(); - opt_tty = stdin; - } else { + { /* Leave stdin and stdout alone when acting as a pager. */ FILE *out_tty; |