console_flag & xterm_flag and their relation to Cygwin



Hello,


I'm currently preparing a set of patches to MC to enable some existing and
add some new functionality on the Cygwin platform. Today I've been playing
with the mouse support and it works quite well. Now before I submit a final
patch I'd like someone to clarify a part of the MC code that I cannot fully
understand. Mainly I do not fully understand the meaning of the flags xterm_flag
and console_flag. While it turns that the xterm_flag enables the Ctrl+O
functionality I cannot get the point of the console_flag. I am asking this question
since currently there is a pice of code in init_xterm_support () that
hardcodes the value of xterm_flag to 1 if Cygwin is detected. But from what I know
about Cygwin it tries to follow/emulate the linux console terminfo entry.
Now, isn't it better to use console_flag then ? On the other hand the mouse
support in the Cygwin console works by generating \E[M sequnce followed by the
mouse button state and the coordinates i.e. exactly like the xterm mouse
support. Now, I cannot decide what is the right way to enable the mouse support for
Cygwin then - should I just change the following snippet from
init_xterm_support:

    if (strcmp (termvalue, "cygwin") == 0) {
        force_xterm = 1;
        use_mouse_p = MOUSE_DISABLED;
    }

to

    if (strcmp (termvalue, "cygwin") == 0) {
        force_xterm = 1;
        use_mouse_p = MOUSE_XTERM;
    }

?

The current patch (attached) just removes the snippet above which doesnt
seem a good idea. Maybe I should set here use_mouse_p to MOUSE_NONE and the
patch will work just fine then ? I find the usage of those two flags quite
confusing ;)

Thanks!

-- 
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post
Index: mouse.c
===================================================================
RCS file: /cvsroot/mc/mc/src/mouse.c,v
retrieving revision 1.12
diff -u -p -r1.12 mouse.c
--- mouse.c	26 Sep 2002 23:13:47 -0000	1.12
+++ mouse.c	30 Jul 2003 23:32:28 -0000
@@ -31,7 +31,7 @@
 #include "key.h"		/* define sequence */
 
 int mouse_enabled = 0;
-char *xmouse_seq;
+char *mouse_seq;
 
 #ifdef HAVE_LIBGPM
 void show_mouse_pointer (int x, int y)
@@ -44,14 +44,23 @@ void show_mouse_pointer (int x, int y)
 
 void init_mouse (void)
 {
-    switch (use_mouse_p) {
-#ifdef HAVE_LIBGPM
-    case MOUSE_NONE:
+    if (use_mouse_p == MOUSE_NONE) {
+#if defined(HAVE_LIBGPM)
 	use_mouse_p = MOUSE_GPM;
-	break;
-#endif /* HAVE_LIBGPM */
+#elif defined(__CYGWIN__)
+	use_mouse_p = MOUSE_CYGWIN;
+#endif
+    }
+
+    switch (use_mouse_p) {
     case MOUSE_XTERM:
-	define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
+    case MOUSE_CYGWIN:
+	/* Default to the standard xterm sequence */
+	if (!mouse_seq) {
+	    mouse_seq = ESC_STR "[M";
+	}
+
+	define_sequence (MCKEY_MOUSE, mouse_seq, MCKEY_NOACTION);
 	break;
     default:
 	break;
@@ -96,6 +105,13 @@ void enable_mouse (void)
 	fflush (stdout);
 	mouse_enabled = 1; 
 	break;
+#ifdef __CYGWIN__
+    case MOUSE_CYGWIN:
+	printf (ESC_STR "[?1000h");
+	fflush (stdout);
+	mouse_enabled = 1;
+	break;
+#endif /* __CYGWIN__ */
     default:
 	break;
     }
@@ -124,6 +140,12 @@ void disable_mouse (void)
 
 	fflush (stdout);
 	break;
+#ifdef __CYGWIN__
+    case MOUSE_CYGWIN:
+	printf (ESC_STR "[?1000l");
+	fflush (stdout);
+	break;
+#endif /* __CYGWIN__ */
     default:
 	break;
     }
Index: mouse.h
===================================================================
RCS file: /cvsroot/mc/mc/src/mouse.h,v
retrieving revision 1.6
diff -u -p -r1.6 mouse.h
--- mouse.h	30 Oct 2002 20:52:59 -0000	1.6
+++ mouse.h	30 Jul 2003 23:31:53 -0000
@@ -55,7 +55,8 @@ typedef enum {
     MOUSE_NONE,		/* Not detected yet */
     MOUSE_DISABLED,	/* Explicitly disabled by -d */
     MOUSE_GPM,		/* Support using GPM on Linux */
-    MOUSE_XTERM		/* Support using xterm-style mouse reporting */
+    MOUSE_XTERM,	/* Support using xterm-style mouse reporting */
+    MOUSE_CYGWIN	/* Mouse support in Cygwin console */
 } Mouse_Type;
 
 /* Type of the currently used mouse */
@@ -65,7 +66,7 @@ extern Mouse_Type use_mouse_p;
 extern int mouse_enabled;
 
 /* String indicating that a mouse event has occured, usually "\E[M" */
-extern char *xmouse_seq;
+extern char *mouse_seq;
 
 void init_mouse (void);
 void enable_mouse (void);
Index: key.c
===================================================================
RCS file: /cvsroot/mc/mc/src/key.c,v
retrieving revision 1.61
diff -u -p -r1.61 key.c
--- key.c	23 Jul 2003 05:44:25 -0000	1.61
+++ key.c	30 Jul 2003 23:34:43 -0000
@@ -385,7 +385,7 @@ void init_key_input_fd (void)
 
 
 static void
-xmouse_get_event (Gpm_Event *ev)
+mouse_get_event (Gpm_Event *ev)
 {
     int btn;
     static struct timeval tv1 = { 0, 0 }; /* Force first click as single */
@@ -976,7 +976,7 @@ get_event (Gpm_Event * event, int redo_e
 #endif				/* KEY_MOUSE */
 	) {
 	/* Mouse event */
-	xmouse_get_event (event);
+	mouse_get_event (event);
 	if (event->type)
 	    return EV_MOUSE;
 	else
Index: main.c
===================================================================
RCS file: /cvsroot/mc/mc/src/main.c,v
retrieving revision 1.291
diff -u -p -r1.291 main.c
--- main.c	28 Jul 2003 16:11:45 -0000	1.291
+++ main.c	30 Jul 2003 23:33:05 -0000
@@ -189,7 +193,7 @@ WButtonBar *the_bar;
 /* For slow terminals */
 int slow_terminal = 0;
 
-/* Mouse type: GPM, xterm or none */
+/* Mouse type: GPM, xterm, Cygwin or none */
 Mouse_Type use_mouse_p = MOUSE_NONE;
 
 /* If true, assume we are running on an xterm terminal */
@ -1365,30 +1375,27 @@ init_xterm_support (void)
     /* Check mouse capabilities */
 #ifdef HAVE_SLANG
     term_entry = SLtt_tigetent (termvalue);
-    xmouse_seq = SLtt_tigetstr ("Km", &term_entry);
+    mouse_seq = SLtt_tigetstr ("Km", &term_entry);
 #else
-    xmouse_seq = tigetstr ("kmous");
+    mouse_seq = tigetstr ("kmous");
 #endif
 
     /* -1 means invalid capability, shouldn't happen, but let's make it 0 */
-    if ((long) xmouse_seq == -1) {
-	xmouse_seq = NULL;
+    if ((long) mouse_seq == -1) {
+	mouse_seq = NULL;
     }
 
+    /*
     if (strcmp (termvalue, "cygwin") == 0) {
 	force_xterm = 1;
 	use_mouse_p = MOUSE_DISABLED;
     }
+    */
 
     if (force_xterm || strncmp (termvalue, "xterm", 5) == 0
 	|| strncmp (termvalue, "rxvt", 4) == 0
 	|| strcmp (termvalue, "dtterm") == 0) {
 	xterm_flag = 1;
-
-	/* Default to the standard xterm sequence */
-	if (!xmouse_seq) {
-	    xmouse_seq = ESC_STR "[M";
-	}
 
 	/* Enable mouse unless explicitly disabled by --nomouse */
 	if (use_mouse_p != MOUSE_DISABLED) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]