aboutsummaryrefslogtreecommitdiffhomepage
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
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.
-rw-r--r--INSTALL12
-rw-r--r--configure.ac34
-rw-r--r--scintilla.am2
-rw-r--r--src/interface-curses.cpp39
4 files changed, 77 insertions, 10 deletions
diff --git a/INSTALL b/INSTALL
index 0a50328..735b7f3 100644
--- a/INSTALL
+++ b/INSTALL
@@ -17,11 +17,13 @@ SciTECO Build and Runtime Dependencies
* Glib 2 as a cross-platform runtime library
(v2.28 or later on Unix, v2.34 or later for MinGW):
https://developer.gnome.org/glib/
- * When choosing the Curses interface:
- * NCurses (http://www.gnu.org/software/ncurses/),
- PDCurses/XCurses (http://pdcurses.sourceforge.net/),
- PDCurses/Win32a (http://www.projectpluto.com/win32a.htm) or
- PDCurses/EMCurses (https://github.com/rhaberkorn/emcurses)
+ * When choosing the Curses interface, you need one of:
+ * NCurses (http://www.gnu.org/software/ncurses/).
+ * PDCurses/XCurses (http://pdcurses.sourceforge.net/).
+ Note that XCurses v3.4 appears to be broken, you should
+ build from PDCurses Git instead.
+ * PDCurses/Win32a (http://www.projectpluto.com/win32a.htm).
+ * PDCurses/EMCurses (https://github.com/rhaberkorn/emcurses).
* other curses implementations might work as well but are untested
* When choosing the GTK interface:
* GTK+ 2: http://www.gtk.org/
diff --git a/configure.ac b/configure.ac
index 9e0cc29..f952d44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,7 +142,7 @@ SCINTERM_PATH=`canonicalize $SCINTERM_PATH`
AC_SUBST(SCINTERM_PATH)
AC_ARG_WITH(interface,
- AS_HELP_STRING([--with-interface=ncurses|pdcurses|gtk],
+ AS_HELP_STRING([--with-interface=ncurses|xcurses|pdcurses|gtk],
[Specify user interface [default=ncurses]]),
[INTERFACE=$withval], [INTERFACE=ncurses])
@@ -162,6 +162,38 @@ case $INTERFACE in
AC_CHECK_FUNCS([tigetstr])
;;
+ xcurses)
+ AC_CHECK_PROG(XCURSES_CONFIG, xcurses-config, xcurses-config)
+
+ AC_ARG_VAR(XCURSES_CFLAGS, [
+ C compiler flags for XCurses,
+ overriding the autoconf check
+ ])
+ if [[ "x$XCURSES_CFLAGS" = "x" -a "x$XCURSES_CONFIG" != "x" ]]; then
+ XCURSES_CFLAGS=`$XCURSES_CONFIG --cflags`
+ fi
+ CFLAGS="$CFLAGS $XCURSES_CFLAGS"
+ CXXFLAGS="$CXXFLAGS $XCURSES_CFLAGS"
+
+ AC_ARG_VAR(XCURSES_LIBS, [
+ linker flags for XCurses,
+ overriding the autoconf check
+ ])
+ AC_MSG_CHECKING([checking for XCurses])
+ if [[ "x$XCURSES_LIBS" = "x" -a "x$XCURSES_CONFIG" != "x" ]]; then
+ XCURSES_LIBS=`$XCURSES_CONFIG --libs`
+ fi
+ if [[ "x$XCURSES_LIBS" = "x" ]]; then
+ AC_MSG_ERROR([libXCurses not configured correctly!
+ xcurses-config must be present or XCURSES_LIBS must be specified.])
+ fi
+ AC_MSG_RESULT([$XCURSES_LIBS])
+ LIBS="$LIBS $XCURSES_LIBS"
+
+ # This is also used by the curses.h itself:
+ AC_DEFINE(XCURSES, , [Enable PDCurses/XCurses extensions])
+ ;;
+
pdcurses)
AC_ARG_VAR(PDCURSES_CFLAGS, [
C compiler flags for PDCurses,
diff --git a/scintilla.am b/scintilla.am
index 53f22d6..481bcc6 100644
--- a/scintilla.am
+++ b/scintilla.am
@@ -7,7 +7,7 @@ MAKE_SCINTILLA = $(MAKE) -C @SCINTILLA_PATH@/gtk \
CONFIGFLAGS='@LIBGTK_CFLAGS@'
else
MAKE_SCINTILLA = $(MAKE) -C @SCINTERM_PATH@ \
- CURSES_CFLAGS='@PDCURSES_CFLAGS@ @NCURSES_CFLAGS@'
+ CURSES_CFLAGS='@PDCURSES_CFLAGS@ @XCURSES_CFLAGS@ @NCURSES_CFLAGS@'
endif
# Pass toolchain configuration to Scintilla.
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);