File shelltool-mouse.patch of Package xview-64bit
diff -rNu xview-3.2p1.4-old/lib/libxview/ttysw/charscreen.h xview-3.2p1.4/lib/libxview/ttysw/charscreen.h
--- xview-3.2p1.4-old/lib/libxview/ttysw/charscreen.h 2013-08-25 14:09:20.604490258 +0200
+++ xview-3.2p1.4/lib/libxview/ttysw/charscreen.h 2013-08-25 14:17:42.560497620 +0200
@@ -19,6 +19,9 @@
#define x_to_col(x) ((((x) >= chrleftmargin) ? \
((x) - chrleftmargin) : 0)/chrwidth)
+#define row_to_mouse_y(row) (unsigned char)(1 + 32 + row)
+#define col_to_mouse_x(col) (unsigned char)(1 + 32 + col)
+
/*
* Character dimensions (fixed width fonts only!)
* and of screen in pixels.
diff -rNu xview-3.2p1.4-old/lib/libxview/ttysw/tty_impl.h xview-3.2p1.4/lib/libxview/ttysw/tty_impl.h
--- xview-3.2p1.4-old/lib/libxview/ttysw/tty_impl.h 2013-08-25 14:09:20.604490258 +0200
+++ xview-3.2p1.4/lib/libxview/ttysw/tty_impl.h 2013-08-25 14:20:00.456499642 +0200
@@ -54,6 +54,12 @@
#define TTY_FROM_TTY_VIEW(_tty_view_public) \
((Tty) TTY_PUBLIC(TTY_FOLIO_FROM_TTY_VIEW(_tty_view_public)))
+#define TTY_ESC (unsigned char)27
+#define TTY_LEFT_MOUSE_BTN (unsigned char)(32 + 0)
+#define TTY_RIGHT_MOUSE_BTN (unsigned char)(32 + 1)
+#define TTY_MIDDLE_MOUSE_BTN (unsigned char)(32 + 2)
+#define TTY_MOUSE_BTN_RELEASED (unsigned char)(32 + 3)
+
/*
* These are the data structures internal to the tty subwindow
* implementation. They are considered private to the implementation.
@@ -186,6 +192,8 @@
#endif
int pass_thru_modifiers; /* Modifiers we don't interpret */
int eight_bit_output; /* Print eight bit characters? */
+ int enable_mouse_legacy; /* enable mouse button reporting (X10) */
+ int enable_mouse; /* enable mouse button reporting */
} Ttysw;
typedef Ttysw *Ttysw_folio;
diff -rNu xview-3.2p1.4-old/lib/libxview/ttysw/tty_main.c xview-3.2p1.4/lib/libxview/ttysw/tty_main.c
--- xview-3.2p1.4-old/lib/libxview/ttysw/tty_main.c 2013-08-25 14:09:20.608490259 +0200
+++ xview-3.2p1.4/lib/libxview/ttysw/tty_main.c 2013-08-25 14:46:05.820522600 +0200
@@ -53,6 +53,7 @@
#include <xview_private/term_impl.h>
#include <xview_private/tty_impl.h>
#include <xview_private/draw_impl.h>
+#include <xview_private/charscreen.h>
#include <xview/sel_svc.h>
#ifdef OW_I18N
@@ -1387,6 +1388,31 @@
register Ttysw_folio ttysw;
register struct inputevent *ie;
{
+ if(ttysw->enable_mouse || ttysw->enable_mouse_legacy) {
+ /* if application wants to use mouse, then selection won't work */
+ unsigned char x, y;
+ char buf[7];
+
+ x = col_to_mouse_x(x_to_col(ie->ie_locx));
+ y = row_to_mouse_y(y_to_row(ie->ie_locy));
+
+ /* if we are using modern mouse button reporting, we will report when
+ * button is released or pressed. In legacy (X10) mode, we will report
+ * only when mouse button is pressed. */
+
+ if(win_inputposevent(ie) && ttysw->enable_mouse_legacy) {
+ sprintf(buf, "%c[M%c%c%c", TTY_ESC, TTY_LEFT_MOUSE_BTN, x, y);
+ ttysw_input_it(ttysw, buf, 6);
+ } else if(win_inputposevent(ie) && ttysw->enable_mouse) {
+ sprintf(buf, "%c[M%c%c%c", TTY_ESC, TTY_LEFT_MOUSE_BTN, x, y);
+ ttysw_input_it(ttysw, buf, 6);
+ } else if(win_inputnegevent(ie) && ttysw->enable_mouse) {
+ sprintf(buf, "%c[M%c%c%c", TTY_ESC, TTY_MOUSE_BTN_RELEASED, x, y);
+ ttysw_input_it(ttysw, buf, 6);
+ }
+
+ return TTY_DONE;
+ }
if (win_inputposevent(ie)) {
#ifdef OW_I18N
diff -rNu xview-3.2p1.4-old/lib/libxview/ttysw/ttyansi.c xview-3.2p1.4/lib/libxview/ttysw/ttyansi.c
--- xview-3.2p1.4-old/lib/libxview/ttysw/ttyansi.c 2013-08-25 14:09:20.604490258 +0200
+++ xview-3.2p1.4/lib/libxview/ttysw/ttyansi.c 2013-08-25 14:36:08.260513836 +0200
@@ -1274,6 +1274,53 @@
return (olen - len);
}
+Pkg_private void
+ttysw_set_dec_private(ttysw, code, ac, av)
+Ttysw_folio ttysw;
+int code, ac, *av;
+{
+ int i;
+
+ for(i = 0; i < ac; i++) {
+ switch(av[i] & 0x00ffffff) {
+ case 9: /* enable mouse button reporting (X10 compatibility mode) */
+ ttysw->enable_mouse_legacy = TRUE;
+ /* we have to disable modern mouse button reporting, because
+ * these modes are mutually exclusive */
+ ttysw->enable_mouse = FALSE;
+ break;
+
+ case 1000: /* enable mouse button reporting */
+ ttysw->enable_mouse = TRUE;
+ /* we have to disable legacy mouse button reporting, because
+ * these modes are mutually exclusive */
+ ttysw->enable_mouse_legacy = FALSE;
+ break;
+ }
+ }
+}
+
+Pkg_private void
+ttysw_reset_dec_private(ttysw, code, ac, av)
+Ttysw_folio ttysw;
+int code, ac, *av;
+{
+ int i;
+
+ for(i = 0; i < ac; i++) {
+ switch(av[i] & 0x00ffffff) {
+ case 9: /* disable mouse button reporting (X10 compatibility mode) */
+ ttysw->enable_mouse_legacy = FALSE;
+ break;
+
+ case 1000: /* disable mouse button reporting */
+ ttysw->enable_mouse = FALSE;
+ break;
+ }
+ }
+}
+
+
Pkg_private int
ttysw_ansi_escape(ttysw_view_public, c, ac, av)
Tty_view ttysw_view_public;
@@ -1435,6 +1482,12 @@
case 'h':{ /* set mode */
int turn_on;
+ if(prefix == '?') {
+ /* DECSET */
+ ttysw_set_dec_private(ttysw, c, ac, av);
+ break;
+ }
+
for (i = 0; i < ac; i++) {
if (av[i] > 0 &&
(av[i] & 0xff000000) == ('>' << 24)) {
@@ -1468,6 +1521,13 @@
break;
case 'l': /* reset mode */
+
+ if(prefix == '?') {
+ /* DECRST */
+ ttysw_reset_dec_private(ttysw, c, ac, av);
+ break;
+ }
+
for (i = 0; i < ac; i++)
if (av[i] > 0 &&
(av[i] & 0xff000000) == ('>' << 24)) {