From 1964d19c464d25fb1898a8ea38579f97b36fafd5 Mon Sep 17 00:00:00 2001 From: that Date: Thu, 7 Jan 2016 00:41:03 +0100 Subject: gui: add terminal emulator Emulates enough of a VT-100 to run busybox vi. Change-Id: I99c829c6c9de2246194ecb8b8b3cdf4ac34a0606 --- gui/gui.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gui/gui.cpp') diff --git a/gui/gui.cpp b/gui/gui.cpp index 63baeee92..08178fc17 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -80,6 +80,9 @@ static float scale_theme_h = 1; // Needed by pages.cpp too int gGuiRunning = 0; +int g_pty_fd = -1; // set by terminal on init +void terminal_pty_read(); + static int gRecorder = -1; extern "C" void gr_write_frame_to_file(int fd); @@ -640,6 +643,17 @@ static int runPages(const char *page_name, const int stop_on_page_done) for (;;) { loopTimer(input_timeout_ms); + if (g_pty_fd > 0) { + // TODO: this is not nice, we should have one central select for input, pty, and ors + FD_ZERO(&fdset); + FD_SET(g_pty_fd, &fdset); + timeout.tv_sec = 0; + timeout.tv_usec = 1; + has_data = select(g_pty_fd+1, &fdset, NULL, NULL, &timeout); + if (has_data > 0) { + terminal_pty_read(); + } + } #ifndef TW_OEM_BUILD if (ors_read_fd > 0 && !orsout) { // orsout is non-NULL if a command is still running FD_ZERO(&fdset); -- cgit v1.2.3