[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patches to enhance ncurses mouse functionality.
From: |
Clive Nicolson |
Subject: |
Re: Patches to enhance ncurses mouse functionality. |
Date: |
Thu, 7 Jun 2007 19:26:34 +1200 (NZST) |
On Thu, 31 May 2007, Thomas Dickey wrote:
On Wed, 30 May 2007, Clive Nicolson wrote:
I have some patches that enhance mouse functionality:
int slk_enclose(int y, int x);
that's a useful idea for an extension (though the other enclose functions don't
seem to be used much).
For form_driver:
...
Anyone interested in these?
I don't know - that sounds rather complicated. Positioning to a field
is obvious (it's been on my long to-do list for a few years), but the
double-clicking and overloading of commands isn't...
Thanks for the form mouse functionallity, saved me posting my diffs.
Here are the diffs for slk_enclose:
diff -r -u ncurses-5.6/include/curses.h ncurses-5.6_move_mouse/include/curses.h
--- ncurses-5.6/include/curses.h 2007-06-05 12:58:07.000000000 +1200
+++ ncurses-5.6_move_mouse/include/curses.h 2007-06-06 11:56:39.000000000
+1200
@@ -1404,6 +1404,9 @@
extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /*
generated */
+#define NCURSES_SLK_ENCLOSE
+extern NCURSES_EXPORT(int) slk_enclose (int, int);
+
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
/* other non-XSI functions */
diff -r -u ncurses-5.6/include/curses.tail
ncurses-5.6_move_mouse/include/curses.tail
--- ncurses-5.6/include/curses.tail 2007-06-04 22:32:24.000000000 +1200
+++ ncurses-5.6_move_mouse/include/curses.tail 2007-06-06 11:52:36.000000000
+1200
@@ -102,6 +102,9 @@
extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /*
generated */
+#define NCURSES_SLK_ENCLOSE
+extern NCURSES_EXPORT(int) slk_enclose (int, int);
+
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
/* other non-XSI functions */
diff -r -u ncurses-5.6/man/curs_mouse.3x
ncurses-5.6_move_mouse/man/curs_mouse.3x
--- ncurses-5.6/man/curs_mouse.3x 2007-06-04 22:12:04.000000000 +1200
+++ ncurses-5.6_move_mouse/man/curs_mouse.3x 2007-06-06 10:30:25.000000000
+1200
@@ -35,7 +35,7 @@
\fBgetmouse\fR, \fBungetmouse\fR,
\fBmousemask\fR, \fBwenclose\fR,
\fBmouse_trafo\fR, \fBwmouse_trafo\fR,
-\fBmouseinterval\fR - mouse interface through curses
+\fBmouseinterval\fR, \fBslk_enclose\fR - mouse interface through curses
.ad
.hy
.SH SYNOPSIS
@@ -61,6 +61,8 @@
.br
\fBbool wenclose(const WINDOW *win, int y, int x);\fR
.br
+\fBint slk_enclose(int y, int x);\fR
+.br
\fBbool mouse_trafo(int* pY, int* pX, bool to_screen);\fR
.br
\fBbool wmouse_trafo(const WINDOW* win, int* pY, int* pX,\fR
@@ -158,6 +160,13 @@
It is useful for determining what subset of
the screen windows enclose the location of a mouse event.
.PP
+The \fBslk_enclose\fR function tests whether a given pair of screen-relative
+character-cell coordinates is enclosed by the slk window, returning non-zero
+if it is and 0 otherwise. If slk label n encloses the coordinates, n is
+returned otherwise -1 is returned.
+It is useful for determining which slk label of
+the slk window enclose the location of a mouse event.
+.PP
The \fBwmouse_trafo\fR function transforms a given pair of coordinates
from stdscr-relative coordinates
to coordinates relative to the given window or vice versa.
@@ -227,6 +236,8 @@
\fBwenclose\fR and \fBwmouse_trafo\fR
are boolean functions returning \fBTRUE\fR or \fBFALSE\fR depending
on their test result.
+.PP
+\fBslk_enclose\fR is a int function.
.SH PORTABILITY
These calls were designed for \fBncurses\fR(3X), and are not found in SVr4
curses, 4.4BSD curses, or any other previous version of curses.
@@ -252,6 +263,8 @@
The order of the \fBMEVENT\fR structure members is not guaranteed.
Additional fields may be added to the structure in the future.
.PP
+The feature macro \fBNCURSES_SLK_ENCLOSE\fR is defined if slk_enclose is
availi\able.
+.PP
Under \fBncurses\fR(3X), these calls are implemented using either
xterm's built-in mouse-tracking API or
platform-specific drivers including
diff -r -u ncurses-5.6/ncurses/base/lib_mouse.c
ncurses-5.6_move_mouse/ncurses/base/lib_mouse.c
--- ncurses-5.6/ncurses/base/lib_mouse.c 2007-06-04 22:12:05.000000000
+1200
+++ ncurses-5.6_move_mouse/ncurses/base/lib_mouse.c 2007-06-06
11:47:10.000000000 +1200
@@ -1361,3 +1361,34 @@
}
returnBool(result);
}
+
+NCURSES_EXPORT(int)
+ slk_enclose(int y, int x)
+{
+/*
+ * Fetch the label index that is at given coords.
+ * Returns -1, 0=>not on line or Fn number.
+ */
+ int res;
+
+ T((T_CALLED("slk_enclose(%d,%d)"), y, x));
+
+ res = 0;
+
+ if (SP && SP->_slk && wenclose(SP->_slk->win, y, x))
+ {
+ int i;
+
+ res = -1;
+
+ for (i = 0; (i < SP->_slk->maxlab &&
+ x >= SP->_slk->ent[i].ent_x); i++)
+ if (x < (SP->_slk->ent[i].ent_x+SP->_slk->maxlen))
+ {
+ res = i+1;
+ break;
+ }
+ }
+
+ return res;
+}
diff -r -u ncurses-5.6/ncurses/llib-lncurses
ncurses-5.6_move_mouse/ncurses/llib-lncurses
--- ncurses-5.6/ncurses/llib-lncurses 2006-10-29 11:20:51.000000000 +1300
+++ ncurses-5.6_move_mouse/ncurses/llib-lncurses 2007-06-06
11:43:00.000000000 +1200
@@ -1220,6 +1220,12 @@
NCURSES_BOOL to_screen)
{ return(*(NCURSES_BOOL *)0); }
+#undef slk_enclose
+int slk_enclose(
+ int y,
+ int x)
+ { return(*(int *)0); }
+
/* ./base/lib_move.c */
#undef wmove
diff -r -u ncurses-5.6/ncurses/llib-lncursesw
ncurses-5.6_move_mouse/ncurses/llib-lncursesw
--- ncurses-5.6/ncurses/llib-lncursesw 2006-12-18 06:37:36.000000000 +1300
+++ ncurses-5.6_move_mouse/ncurses/llib-lncursesw 2007-06-06
11:45:17.000000000 +1200
@@ -1728,6 +1728,12 @@
NCURSES_BOOL to_screen)
{ return(*(NCURSES_BOOL *)0); }
+#undef slk_enclose
+int slk_enclose(
+ int y,
+ int x)
+ { return(*(int *)0); }
+
/* ./base/lib_move.c */
#undef wmove
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Patches to enhance ncurses mouse functionality.,
Clive Nicolson <=