From e2e0162b5bfd2a5ef31f1d09fca4da8962d5d098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 10 May 2016 22:22:52 +0200 Subject: 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 --- ui-curses.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'ui-curses.c') 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 #include #include -#include #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, -- cgit v1.2.3