From 3fd90ce83b834d4f8df0903cccb23af072d4da86 Mon Sep 17 00:00:00 2001 From: Norbert Warmuth Date: Wed, 21 Apr 1999 19:18:31 +0000 Subject: [PATCH] This patch set adds a new feature to the text edtion (off by default). `--with-tm-x-support' This option enables minimal X Window support in the text edition. It enables MC to query the status of the modifiers CONTROL and SHIFT when invoked in a terminal emulation under X11. That's necessary to recognice key combinations like C-HOME or S-Cursor key. Wed Apr 21 20:37:32 1999 Norbert Warmuth * configure.in: New option --with-tm-x-support, use MCCFLAGS and MCLIBS for build flags which are specific to the text edition. * INSTALL: Added documentation for --with-tm-x-support * src/Makefile.in: use MCCFLAGS and MCLIBS Wed Apr 21 20:19:45 1999 Norbert Warmuth * src/key.c (get_modifier): Query the state of the modifier keys when running inside a terminal emulation under X11. * src/key.c (init_textmode_x11_support, done_textmode_x11_support): new functions, only used in the text edition. Connect to and disconnect from the X Server when DISPLAY is set. * src/key.h: added prototypes for the new functions * src/main.c (main): call (init|done)_textmode_x11_support --- ChangeLog | 7 ++++++ INSTALL | 6 +++++ acconfig.h | 3 +++ configure.in | 35 +++++++++++++++++++++------ src/ChangeLog | 17 ++++++++++++++ src/Makefile.in | 4 ++-- src/features.inc | 3 +++ src/key.c | 61 +++++++++++++++++++++++++++++++++++++++++++----- src/key.h | 3 +++ src/main.c | 9 +++++++ 10 files changed, 133 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8605965c6..ef2c53888 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Apr 21 20:44:41 1999 Norbert Warmuth + + * configure.in: New option --with-tm-x-support, use MCCFLAGS and + MCLIBS which are specific to the text edition. + + * INSTALL: Added documentation for --with-tm-x-support + Sun Apr 18 17:51:54 EDT 1999 Gregory McLean * mc.spec.in : Folded in some changes from the 'offical' rpm diff --git a/INSTALL b/INSTALL index ee53905dd..8520edfaf 100644 --- a/INSTALL +++ b/INSTALL @@ -162,6 +162,12 @@ installed the gpm package. Default is somewhere in your XView binaries directory, $OPENWINHOME/bin. +`--with-tm-x-support' + This option enables minimal X Window support in the text edition. It + enables MC to query the status of the modifiers CONTROL and SHIFT + when invoked in a terminal emulation under X11. That's necessary + to recognice key combinations like C-HOME or S-Cursor key. + `--without-vfs' This option disables the Virtual File System switch code in the Midnight Commander and uses the standard file system calls for diff --git a/acconfig.h b/acconfig.h index edc3a0924..9b81ca31c 100644 --- a/acconfig.h +++ b/acconfig.h @@ -62,6 +62,9 @@ /* Is the program using the GPM library? */ #undef HAVE_LIBGPM +/* Is the text edition compiled with X11 support? */ +#undef HAVE_TEXTMODE_X11_SUPPORT + /* Is the program using the distributed slang library? */ #undef HAVE_SLANG diff --git a/configure.in b/configure.in index 685779ece..6453d478f 100644 --- a/configure.in +++ b/configure.in @@ -295,6 +295,27 @@ dnl ]) AC_PATH_XTRA +dnl +dnl X11 support in the textmode edition. +dnl + +dnl These variables are only used when building the text edition MC binary +MCCFLAGS="" +MCLIBS="" +AC_SUBST(MCCFLAGS) +AC_SUBST(MCLIBS) + +textmode_x11_support="no" +AC_ARG_WITH(tm-x-support, + [--with-tm-x-support Add X Window System support to the text edition], + if test x$withval = xyes; then + MCCFLAGS="$X_CFLAGS" + MCLIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS" + AC_DEFINE(HAVE_TEXTMODE_X11_SUPPORT) + textmode_x11_support="yes" + fi +) + dnl dnl Network related functions dnl @@ -696,11 +717,10 @@ AC_ARG_WITH(debug, mem_debug="Janne's MAD library" AC_DEFINE(HAVE_MAD) AC_DEFINE(MCDEBUG) - if [ echo `uname -s -r` | grep 'SunOS 4.1' ] + if [ echo `uname -s -r` | grep -q 'SunOS 4.1' ] then CFLAGS="$CFLAGS -Wno-implicit" - fi >& /dev/null - + fi if echo "$CFLAGS" | grep -e -g >/dev/null 2>&1; then : else @@ -721,10 +741,10 @@ AC_ARG_WITH(efence, CFLAGS="$CFLAGS -Wall" AC_DEFINE(MCDEBUG) LIBS="$LIBS -lefence" - if [ echo `uname -s -r` | grep 'SunOS 4.1' ] + if [ echo `uname -s -r` | grep -q 'SunOS 4.1' ] then CFLAGS="$CFLAGS -Wno-implicit" - fi >& /dev/null + fi if echo "$CFLAGS" | grep -e -g >/dev/null 2>&1; then : else @@ -1247,9 +1267,9 @@ if test x$srcdir != x; then fi fi -if echo "$screen_manager" | grep "SLang" ; then +if echo "$screen_manager" | grep -q "SLang" ; then screen_manager="${screen_manager}${slang_term}" -fi >& /dev/null +fi echo " Configuration: @@ -1262,6 +1282,7 @@ Configuration: Text mode screen manager: ${screen_manager} Install console saver: ${install_saver} Text mode mouse library: ${mouse_lib} + Text mode X11 support: ${textmode_x11_support} Debugger code: ${mem_debug} With subshell support: ${subshell} X11 versions: ${xvers} diff --git a/src/ChangeLog b/src/ChangeLog index ea2b4861a..2e7e8f245 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +Wed Apr 21 20:40:38 1999 Norbert Warmuth + + * Makefile.in: use MCCFLAGS and MCLIBS + +Wed Apr 21 20:19:45 1999 Norbert Warmuth + + * key.c (get_modifier): Query the state of the modifier keys when + running inside a terminal emulation under X11. + + * key.c (init_textmode_x11_support, done_textmode_x11_support): new + functions, only used in the text edition. Connect to and disconnect + from the X Server when DISPLAY is set. + + * key.h: added prototypes for the new functions + + * main.c (main): call (init|done)_textmode_x11_support + Sat Apr 17 13:04:19 1999 Norbert Warmuth * view.c (do_view_init): Enable viewing of files with negative diff --git a/src/Makefile.in b/src/Makefile.in index c09f35c2e..1bedf4217 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -5,11 +5,11 @@ SHELL = @SHELL@ rootdir = $(srcdir)/.. @MCFG@@MCF@ -CFLAGS = $(XCFLAGS) +CFLAGS = $(XCFLAGS) @MCCFLAGS@ CPPFLAGS = $(XCPPFLAGS) -DREGEX_MALLOC LDFLAGS = $(XLDFLAGS) DEFS = $(XDEFS) -LIBS = $(XLIBS) @TERMNET@ $(XLIB) @TERMNET@ +LIBS = $(XLIBS) @TERMNET@ $(XLIB) @TERMNET@ @MCLIBS@ OURLIBS = @LVFS@ @LSLANG@ @LEDIT@ @LGPM@ @LINTL@ INSTALL = @INSTALL@ diff --git a/src/features.inc b/src/features.inc index 035bc007a..158853eb8 100644 --- a/src/features.inc +++ b/src/features.inc @@ -14,6 +14,9 @@ char *features = # endif #else "text mode" +#ifdef HAVE_TEXTMODE_X11_SUPPORT + " with X11 support to read modifiers" +#endif #endif ".\n" diff --git a/src/key.c b/src/key.c index 78d185fc9..eb60b8afb 100644 --- a/src/key.c +++ b/src/key.c @@ -44,6 +44,10 @@ #include "cons.saver.h" #include "../vfs/vfs.h" +#if defined (HAVE_TEXTMODE_X11_SUPPORT) && !defined (HAVE_X) +#include +#endif + #ifdef __linux__ # if defined(__GLIBC__) && (__GLIBC__ < 2) # include /* This is needed for TIOCLINUX */ @@ -226,6 +230,19 @@ define_sequences (key_define_t *kd) #endif } +#if defined (HAVE_TEXTMODE_X11_SUPPORT) && !defined (HAVE_X) +Display *display; +Window w; + +void +init_textmode_x11_support (void) +{ + display = XOpenDisplay (0); + if (display) + w = DefaultRootWindow (display); +} +#endif + /* This has to be called before slang_init or whatever routine calls any define_sequence */ void init_key (void) @@ -963,15 +980,38 @@ int is_idle (void) int get_modifier (void) { +#if defined (HAVE_TEXTMODE_X11_SUPPORT) && !defined (HAVE_X) + if (display) { + Window root, child; + int root_x, root_y; + int win_x, win_y; + unsigned int mask; + Bool b; + int result = 0; + + b = XQueryPointer(display, w, &root, &child, + &root_x, &root_y, + &win_x, &win_y, + &mask); + + if (mask & ShiftMask) + result |= SHIFT_PRESSED; + if (mask & ControlMask) + result |= CONTROL_PRESSED; + return result; + } else +#endif #ifdef __linux__ - unsigned char modifiers; + { + unsigned char modifiers; - modifiers = 6; + modifiers = 6; - if (ioctl (0, TIOCLINUX, &modifiers) < 0) - return 0; + if (ioctl (0, TIOCLINUX, &modifiers) < 0) + return 0; - return (int) modifiers; + return (int) modifiers; + } #else return 0; #endif @@ -989,6 +1029,7 @@ ctrl_pressed () #ifdef HAVE_MAD #ifndef HAVE_X + void k_dispose (key_def *k) { if (!k) @@ -1014,10 +1055,18 @@ void done_key () } #else - void done_key () { } #endif /* HAVE_X */ #endif /* HAVE_MAD */ + +#if defined (HAVE_TEXTMODE_X11_SUPPORT) && !defined (HAVE_X) +void +done_textmode_x11_support (void) +{ + if (display) + XCloseDisplay (display); +} +#endif diff --git a/src/key.h b/src/key.h index 9efe2ab3f..1f517cf6f 100644 --- a/src/key.h +++ b/src/key.h @@ -4,6 +4,9 @@ void init_key (void); void init_key_input_fd (void); void done_key (void); +void init_textmode_x11_support (void); +void done_textmode_x11_support (void); + int get_event (Gpm_Event *event, int redo_event, int block); int is_idle (void); int ctrl_pressed (void); diff --git a/src/main.c b/src/main.c index af4d7718a..75bd609eb 100644 --- a/src/main.c +++ b/src/main.c @@ -2990,6 +2990,10 @@ main (int argc, char *argv []) calls any define_sequence */ init_key (); +#if defined (HAVE_TEXTMODE_X11_SUPPORT) && !defined (HAVE_X) + init_textmode_x11_support (); +#endif + #ifndef HAVE_GNOME handle_args (argc, argv); #endif @@ -3170,6 +3174,11 @@ main (int argc, char *argv []) #ifdef HAVE_MAD done_key (); #endif + +#if defined (HAVE_TEXTMODE_X11_SUPPORT) && !defined (HAVE_X) + done_textmode_x11_support (); +#endif + mad_finalize (__FILE__, __LINE__); #ifdef HAVE_X xtoolkit_end ();