aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-21 19:56:13 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-22 04:10:39 +0200
commit17e7768e3393eaac91ebfa7467be3d1cabd7659a (patch)
tree61287c03ac216f91f8e8460ebb771ac3ad918519 /src
parent1d626c2785117f9c9bf6683d98f57e825a9e7938 (diff)
downloadsciteco-17e7768e3393eaac91ebfa7467be3d1cabd7659a.tar.gz
added XCurses support
* enabled via --with-interface=xcurses, so we can configure it automatically via xcurses-config. This also adds XCURSES_CFLAGS and XCURSES_LIBS. * The X11 window class name is set to "SciTECO". X11 resource overrides can currently not be set via sciteco's command line. The user may use .Xdefaults though. * interruptions via CTRL+C are currently not supported. Apparently, XCurses also does send SIGINT in cbreak() mode. An XCurses-specific hack would be cumbersome. * ~InterfaceCurses() should probably be rewritten. Curses cleanup should be completely in restore_batch() as the destructor may be called after Curses-cleanup handlers. E.g. isendwin() SEGFAULTs on XCurses when called from the destructor.
Diffstat (limited to 'src')
-rw-r--r--src/interface-curses.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/interface-curses.cpp b/src/interface-curses.cpp
index b6a2a6f..55bab8e 100644
--- a/src/interface-curses.cpp
+++ b/src/interface-curses.cpp
@@ -203,6 +203,27 @@ InterfaceCurses::init_screen(void)
}
}
+#elif defined(XCURSES)
+
+void
+InterfaceCurses::init_screen(void)
+{
+ const char *argv[] = {PACKAGE_NAME, NULL};
+
+ /*
+ * This sets the program name to "SciTECO"
+ * which may then also be used as the X11 class name
+ * for overwriting X11 resources in .Xdefaults
+ * FIXME: We could support passing in resource
+ * overrides via the SciTECO command line.
+ * But unfortunately, Xinitscr() is called too
+ * late to modify argc/argv for command-line parsing.
+ * Therefore this could only be supported by
+ * adding a special option like --resource.
+ */
+ Xinitscr(1, (char **)argv);
+}
+
#else
void
@@ -255,6 +276,7 @@ InterfaceCurses::init_interactive(void)
msg_window = newwin(1, 0, LINES - 2, 0);
cmdline_window = newwin(0, 0, LINES - 1, 0);
+ keypad(cmdline_window, TRUE);
#ifdef EMSCRIPTEN
nodelay(cmdline_window, TRUE);
@@ -343,7 +365,7 @@ 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(PDCURSES_WIN32A) || defined(NCURSES_UNIX)
+#if defined(XCURSES) || defined(PDCURSES_WIN32A) || defined(NCURSES_UNIX)
stdio_vmsg(type, fmt, ap);
if (!msg_window) /* batch mode */
return;
@@ -792,8 +814,12 @@ event_loop_iter()
* on Unix Curses, as ESCAPE is handled as the beginning
* of a escape sequence when terminal emulators are
* involved.
+ * On some Curses variants (XCurses) however, keypad
+ * must always be TRUE so we receive KEY_RESIZE.
*/
+#ifdef NCURSES_UNIX
keypad(interface.cmdline_window, Flags::ed & Flags::ED_FNKEYS);
+#endif
/* no special <CTRL/C> handling */
raw();
@@ -813,7 +839,7 @@ event_loop_iter()
switch (key) {
#ifdef KEY_RESIZE
case KEY_RESIZE:
-#ifdef __PDCURSES__
+#if PDCURSES
resize_term(0, 0);
#endif
interface.resize_all_windows();
@@ -953,9 +979,16 @@ InterfaceCurses::~InterfaceCurses()
if (msg_window)
delwin(msg_window);
- /* PDCurses (win32) crashes if initscr() wasn't called */
+ /*
+ * PDCurses (win32) crashes if initscr() wasn't called.
+ * Others (XCurses) crash if we try to use isendwin() here.
+ * Perhaps Curses cleanup should be in restore_batch()
+ * instead.
+ */
+#ifndef XCURSES
if (info_window && !isendwin())
endwin();
+#endif
if (screen)
delscreen(screen);