diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-10 22:22:52 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-10 22:22:52 +0200 |
| commit | e2e0162b5bfd2a5ef31f1d09fca4da8962d5d098 (patch) | |
| tree | 984329f1824e81b0eb2a6f162f5c33ec7c8eb69c /ui-curses.c | |
| parent | 0ac9c6210b3b08b2e8a9e7e4de387abcef9afcff (diff) | |
| download | vis-e2e0162b5bfd2a5ef31f1d09fca4da8962d5d098.tar.gz vis-e2e0162b5bfd2a5ef31f1d09fca4da8962d5d098.tar.xz | |
Revert "vis: clean up interaction between vis and ui"
This caused issues on OpenBSD where it crashed the terminal.
Also on Mac OS X suspend via ^Z (Ctrl-Z) was missing a \r i.e.
the shell prompt was not properly redrawn.
While in principle user interfaces should not have to depend on
libtermkey, in practice this won't be an issue unless we are
adding a non-terminal based UI (which won't happen anytime soon).
This reverts commit 8f92b98848f9366e78c7aa824615bade83971513.
Close #311
Diffstat (limited to 'ui-curses.c')
| -rw-r--r-- | ui-curses.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/ui-curses.c b/ui-curses.c index 1b3af1e..d6f042b 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -15,7 +15,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <termios.h> -#include <termkey.h> #include "ui-curses.h" #include "vis.h" @@ -1079,14 +1078,23 @@ static TermKey *ui_termkey_new(int fd) { return termkey; } +static TermKey *ui_termkey_get(Ui *ui) { + UiCurses *uic = (UiCurses*)ui; + return uic->termkey; +} + static void ui_suspend(Ui *ui) { endwin(); raise(SIGSTOP); } -static void ui_needkey(Ui *ui) { - UiCurses *uic = (UiCurses*)ui; - termkey_advisereadable(uic->termkey); +static bool ui_haskey(Ui *ui) { + nodelay(stdscr, TRUE); + int c = getch(); + if (c != ERR) + ungetch(c); + nodelay(stdscr, FALSE); + return c != ERR; } static const char *ui_getkey(Ui *ui) { @@ -1175,7 +1183,9 @@ Ui *ui_curses_new(void) { .init = ui_init, .start = ui_start, .free = ui_curses_free, + .termkey_get = ui_termkey_get, .suspend = ui_suspend, + .resize = ui_resize, .update = ui_update, .window_new = ui_window_new, .window_free = ui_window_free, @@ -1187,7 +1197,7 @@ Ui *ui_curses_new(void) { .die = ui_die, .info = ui_info, .info_hide = ui_info_hide, - .needkey = ui_needkey, + .haskey = ui_haskey, .getkey = ui_getkey, .terminal_save = ui_terminal_save, .terminal_restore = ui_terminal_restore, |
