diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-22 01:03:12 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-22 04:10:40 +0200 |
commit | 91bbf67eeba0627c684fb4f9e522ac114c456e47 (patch) | |
tree | a30973c2435d8d3cb5d3aa8d05521fe551bcbf6c | |
parent | 17e7768e3393eaac91ebfa7467be3d1cabd7659a (diff) | |
download | sciteco-91bbf67eeba0627c684fb4f9e522ac114c456e47.tar.gz |
improved ncurses/win32 support
* CTRL+C interruptions are now possible.
ncurses/win32 needs a noraw() (bug!?) and
the console_ctrl_handler for this to work.
* setting the window title is not possible on this port
* stdio output can be redirected, even in interactive mode.
Also, we can write to stdout/stderr even in interactive mode
without disrupting the terminal.
After endwin(), the user will see these messages (if they
haven't been redirected).
* there's one bug left:
the Scintilla cursor is not drawn correctly at the end of
lines.
* part of the solution to #4
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | src/interface-curses.cpp | 26 |
2 files changed, 12 insertions, 16 deletions
@@ -19,6 +19,8 @@ SciTECO Build and Runtime Dependencies https://developer.gnome.org/glib/ * When choosing the Curses interface, you need one of: * NCurses (http://www.gnu.org/software/ncurses/). + If you plan to use the ncurses MinGW port, + I recommend ncurses 6.0 or later. * PDCurses/XCurses (http://pdcurses.sourceforge.net/). Note that XCurses v3.4 appears to be broken, you should build from PDCurses Git instead. diff --git a/src/interface-curses.cpp b/src/interface-curses.cpp index 55bab8e..aafab29 100644 --- a/src/interface-curses.cpp +++ b/src/interface-curses.cpp @@ -97,9 +97,9 @@ namespace SciTECO { extern "C" { static void scintilla_notify(Scintilla *sci, int idFrom, - void *notify, void *user_data); + void *notify, void *user_data); -#ifdef PDCURSES_WIN32 +#if defined(PDCURSES_WIN32) || defined(NCURSES_WIN32) /** * This handler is the Windows-analogue of a signal @@ -154,7 +154,7 @@ InterfaceCurses::main_impl(int &argc, char **&argv) * reliably. The signal handler we already * have won't do. */ -#ifdef PDCURSES_WIN32 +#if defined(PDCURSES_WIN32) || defined(NCURSES_WIN32) SetConsoleCtrlHandler(console_ctrl_handler, TRUE); #endif @@ -246,13 +246,12 @@ InterfaceCurses::init_interactive(void) */ QRegisters::globals.update_environ(); -#ifdef NCURSES_WIN32 /* - * $TERM must be unset for the win32 driver to load. + * $TERM must be unset or "#win32con" for the win32 + * driver to load. * So we always ignore any $TERM changes by the user. */ - //g_unsetenv("TERM"); - // May be necessary to set window title on ncurses/win32 +#ifdef NCURSES_WIN32 g_setenv("TERM", "#win32con", TRUE); #endif @@ -365,7 +364,8 @@ InterfaceCurses::vmsg_impl(MessageType type, const gchar *fmt, va_list ap) * On most platforms we can write to stdout/stderr * even in interactive mode. */ -#if defined(XCURSES) || defined(PDCURSES_WIN32A) || defined(NCURSES_UNIX) +#if defined(XCURSES) || defined(PDCURSES_WIN32A) || \ + defined(NCURSES_UNIX) || defined(NCURSES_WIN32) stdio_vmsg(type, fmt, ap); if (!msg_window) /* batch mode */ return; @@ -456,7 +456,7 @@ InterfaceCurses::set_window_title(const gchar *title) last_title = g_strdup(title); } -#elif defined(HAVE_TIGETSTR) +#elif defined(NCURSES_UNIX) && defined(HAVE_TIGETSTR) void InterfaceCurses::set_window_title(const gchar *title) @@ -489,17 +489,10 @@ InterfaceCurses::set_window_title(const gchar *title) * we do not let curses write to stdout. * NOTE: This leaves the title set after we quit. */ -#ifdef G_OS_UNIX fputs(to_status_line, screen_tty); fputs(title, screen_tty); fputs(from_status_line, screen_tty); fflush(screen_tty); -#else /* presumably ncurses/win32 */ - putp(to_status_line); - putp(title); - putp(from_status_line); - //fflush(stdout); -#endif } #else @@ -829,6 +822,7 @@ event_loop_iter() key = wgetch(interface.cmdline_window); /* allow asynchronous interruptions on <CTRL/C> */ sigint_occurred = FALSE; + noraw(); /* FIXME: necessary because of NCURSES_WIN32 bug */ cbreak(); #ifdef PDCURSES_WIN32 SetConsoleMode(console_hnd, console_mode | ENABLE_PROCESSED_INPUT); |