Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses curses: Add stubs for mouse functions



details:   https://anonhg.NetBSD.org/src/rev/4ea0d307efd5
branches:  trunk
changeset: 970428:4ea0d307efd5
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Mar 23 13:37:36 2020 +0000

description:
curses: Add stubs for mouse functions

No mouse support actually included.
But that doesn't matter because most terms don't actually support a mouse.

We should look into hooking these into wsmouse(4) and xterm mouse
in the future.

Compatable with nCurses mouse API version 2.

diffstat:

 distrib/sets/lists/comp/mi |   26 +++++++++-
 lib/libcurses/Makefile     |   13 +++-
 lib/libcurses/curses.h     |   70 ++++++++++++++++++++++++-
 lib/libcurses/mouse.c      |  125 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 228 insertions(+), 6 deletions(-)

diffs (truncated from 434 to 300 lines):

diff -r a3c486bc56a0 -r 4ea0d307efd5 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Mon Mar 23 11:45:00 2020 +0000
+++ b/distrib/sets/lists/comp/mi        Mon Mar 23 13:37:36 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.2313 2020/03/22 14:27:33 ad Exp $
+#      $NetBSD: mi,v 1.2314 2020/03/23 13:37:37 roy Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp                           comp-sys-root
@@ -6402,6 +6402,7 @@
 ./usr/share/man/cat3/curses_insertln.0         comp-c-catman           .cat
 ./usr/share/man/cat3/curses_keyname.0          comp-c-catman           .cat
 ./usr/share/man/cat3/curses_line.0             comp-c-catman           .cat
+./usr/share/man/cat3/curses_mouse.0            comp-c-catman           .cat
 ./usr/share/man/cat3/curses_pad.0              comp-c-catman           .cat
 ./usr/share/man/cat3/curses_print.0            comp-c-catman           .cat
 ./usr/share/man/cat3/curses_refresh.0          comp-c-catman           .cat
@@ -7308,6 +7309,7 @@
 ./usr/share/man/cat3/getmntopts.0              comp-c-catman           .cat
 ./usr/share/man/cat3/getmntoptstr.0            comp-c-catman           .cat
 ./usr/share/man/cat3/getmode.0                 comp-c-catman           .cat
+./usr/share/man/cat3/getmouse.0                        comp-c-catman           .cat
 ./usr/share/man/cat3/getnameinfo.0             comp-c-catman           .cat
 ./usr/share/man/cat3/getnetbyaddr.0            comp-c-catman           .cat
 ./usr/share/man/cat3/getnetbyname.0            comp-c-catman           .cat
@@ -7428,6 +7430,7 @@
 ./usr/share/man/cat3/has_ic.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/has_il.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/has_key.0                 comp-c-catman           .cat
+./usr/share/man/cat3/has_mouse.0               comp-c-catman           .cat
 ./usr/share/man/cat3/hash.0                    comp-c-catman           .cat
 ./usr/share/man/cat3/hcreate.0                 comp-c-catman           .cat
 ./usr/share/man/cat3/hcreate_r.0               comp-c-catman           .cat
@@ -8542,6 +8545,8 @@
 ./usr/share/man/cat3/modfl.0                   comp-c-catman           .cat
 ./usr/share/man/cat3/moncontrol.0              comp-c-catman           .cat
 ./usr/share/man/cat3/monstartup.0              comp-c-catman           .cat
+./usr/share/man/cat3/mouse_trafo.0             comp-c-catman           .cat
+./usr/share/man/cat3/mouseinterval.0           comp-c-catman           .cat
 ./usr/share/man/cat3/move.0                    comp-c-catman           .cat
 ./usr/share/man/cat3/move_field.0              comp-c-catman           .cat
 ./usr/share/man/cat3/move_panel.0              comp-c-catman           .cat
@@ -10277,6 +10282,7 @@
 ./usr/share/man/cat3/underscore.0              comp-c-catman           .cat
 ./usr/share/man/cat3/ungetc.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/ungetch.0                 comp-c-catman           .cat
+./usr/share/man/cat3/ungetmouse.0              comp-c-catman           .cat
 ./usr/share/man/cat3/ungetwc.0                 comp-c-catman           .cat
 ./usr/share/man/cat3/unistd.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/unlockpt.0                        comp-c-catman           .cat
@@ -10424,6 +10430,7 @@
 ./usr/share/man/cat3/wdelch.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/wdeleteln.0               comp-c-catman           .cat
 ./usr/share/man/cat3/wechochar.0               comp-c-catman           .cat
+./usr/share/man/cat3/wenclose.0                        comp-c-catman           .cat
 ./usr/share/man/cat3/werase.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/wgetch.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/wgetnstr.0                        comp-c-catman           .cat
@@ -10442,6 +10449,7 @@
 ./usr/share/man/cat3/wmemcpy.0                 comp-c-catman           .cat
 ./usr/share/man/cat3/wmemmove.0                        comp-c-catman           .cat
 ./usr/share/man/cat3/wmemset.0                 comp-c-catman           .cat
+./usr/share/man/cat3/wmouse_trafo.0            comp-c-catman           .cat
 ./usr/share/man/cat3/wmove.0                   comp-c-catman           .cat
 ./usr/share/man/cat3/wnoutrefresh.0            comp-c-catman           .cat
 ./usr/share/man/cat3/wordexp.0                 comp-c-catman           .cat
@@ -14426,6 +14434,7 @@
 ./usr/share/man/html3/curses_insertln.html     comp-c-htmlman          html
 ./usr/share/man/html3/curses_keyname.html      comp-c-htmlman          html
 ./usr/share/man/html3/curses_line.html         comp-c-htmlman          html
+./usr/share/man/html3/curses_mouse.html                comp-c-htmlman          html
 ./usr/share/man/html3/curses_pad.html          comp-c-htmlman          html
 ./usr/share/man/html3/curses_print.html                comp-c-htmlman          html
 ./usr/share/man/html3/curses_refresh.html      comp-c-htmlman          html
@@ -15339,6 +15348,7 @@
 ./usr/share/man/html3/getmntopts.html          comp-c-htmlman          html
 ./usr/share/man/html3/getmntoptstr.html                comp-c-htmlman          html
 ./usr/share/man/html3/getmode.html             comp-c-htmlman          html
+./usr/share/man/html3/getmouse.html            comp-c-htmlman          html
 ./usr/share/man/html3/getnameinfo.html         comp-c-htmlman          html
 ./usr/share/man/html3/getnetbyaddr.html                comp-c-htmlman          html
 ./usr/share/man/html3/getnetbyname.html                comp-c-htmlman          html
@@ -15458,6 +15468,7 @@
 ./usr/share/man/html3/has_ic.html              comp-c-htmlman          html
 ./usr/share/man/html3/has_il.html              comp-c-htmlman          html
 ./usr/share/man/html3/has_key.html             comp-c-htmlman          html
+./usr/share/man/html3/has_mouse.html           comp-c-htmlman          html
 ./usr/share/man/html3/hash.html                        comp-c-htmlman          html
 ./usr/share/man/html3/hcreate.html             comp-c-htmlman          html
 ./usr/share/man/html3/hcreate_r.html           comp-c-htmlman          html
@@ -16540,6 +16551,8 @@
 ./usr/share/man/html3/modfl.html               comp-c-htmlman          html
 ./usr/share/man/html3/moncontrol.html          comp-c-htmlman          html
 ./usr/share/man/html3/monstartup.html          comp-c-htmlman          html
+./usr/share/man/html3/mouse_trafo.html         comp-c-htmlman          html
+./usr/share/man/html3/mouseinterval.html       comp-c-htmlman          html
 ./usr/share/man/html3/move.html                        comp-c-htmlman          html
 ./usr/share/man/html3/move_field.html          comp-c-htmlman          html
 ./usr/share/man/html3/move_panel.html          comp-c-htmlman          html
@@ -18257,6 +18270,7 @@
 ./usr/share/man/html3/underscore.html          comp-c-htmlman          html
 ./usr/share/man/html3/ungetc.html              comp-c-htmlman          html
 ./usr/share/man/html3/ungetch.html             comp-c-htmlman          html
+./usr/share/man/html3/ungetmouse.html          comp-c-htmlman          html
 ./usr/share/man/html3/ungetwc.html             comp-c-htmlman          html
 ./usr/share/man/html3/unistd.html              comp-c-htmlman          html
 ./usr/share/man/html3/unlockpt.html            comp-c-htmlman          html
@@ -18400,6 +18414,7 @@
 ./usr/share/man/html3/wdelch.html              comp-c-htmlman          html
 ./usr/share/man/html3/wdeleteln.html           comp-c-htmlman          html
 ./usr/share/man/html3/wechochar.html           comp-c-htmlman          html
+./usr/share/man/html3/wenclose.html            comp-c-htmlman          html
 ./usr/share/man/html3/werase.html              comp-c-htmlman          html
 ./usr/share/man/html3/wgetch.html              comp-c-htmlman          html
 ./usr/share/man/html3/wgetnstr.html            comp-c-htmlman          html
@@ -18418,6 +18433,7 @@
 ./usr/share/man/html3/wmemcpy.html             comp-c-htmlman          html
 ./usr/share/man/html3/wmemmove.html            comp-c-htmlman          html
 ./usr/share/man/html3/wmemset.html             comp-c-htmlman          html
+./usr/share/man/html3/wmouse_trafo.html                comp-c-htmlman          html
 ./usr/share/man/html3/wmove.html               comp-c-htmlman          html
 ./usr/share/man/html3/wnoutrefresh.html                comp-c-htmlman          html
 ./usr/share/man/html3/wordexp.html             comp-c-htmlman          html
@@ -22393,6 +22409,7 @@
 ./usr/share/man/man3/curses_insertln.3         comp-c-man              .man
 ./usr/share/man/man3/curses_keyname.3          comp-c-man              .man
 ./usr/share/man/man3/curses_line.3             comp-c-man              .man
+./usr/share/man/man3/curses_mouse.3            comp-c-man              .man
 ./usr/share/man/man3/curses_pad.3              comp-c-man              .man
 ./usr/share/man/man3/curses_print.3            comp-c-man              .man
 ./usr/share/man/man3/curses_refresh.3          comp-c-man              .man
@@ -23310,6 +23327,7 @@
 ./usr/share/man/man3/getmntopts.3              comp-c-man              .man
 ./usr/share/man/man3/getmntoptstr.3            comp-c-man              .man
 ./usr/share/man/man3/getmode.3                 comp-c-man              .man
+./usr/share/man/man3/getmouse.3                        comp-c-man              .man
 ./usr/share/man/man3/getnameinfo.3             comp-c-man              .man
 ./usr/share/man/man3/getnetbyaddr.3            comp-c-man              .man
 ./usr/share/man/man3/getnetbyname.3            comp-c-man              .man
@@ -23430,6 +23448,7 @@
 ./usr/share/man/man3/has_ic.3                  comp-c-man              .man
 ./usr/share/man/man3/has_il.3                  comp-c-man              .man
 ./usr/share/man/man3/has_key.3                 comp-c-man              .man
+./usr/share/man/man3/has_mouse.3               comp-c-man              .man
 ./usr/share/man/man3/hash.3                    comp-c-man              .man
 ./usr/share/man/man3/hcreate.3                 comp-c-man              .man
 ./usr/share/man/man3/hcreate_r.3               comp-c-man              .man
@@ -24545,6 +24564,8 @@
 ./usr/share/man/man3/modfl.3                   comp-c-man              .man
 ./usr/share/man/man3/moncontrol.3              comp-c-man              .man
 ./usr/share/man/man3/monstartup.3              comp-c-man              .man
+./usr/share/man/man3/mouse_trafo.3             comp-c-man              .man
+./usr/share/man/man3/mouseinterval.3           comp-c-man              .man
 ./usr/share/man/man3/move.3                    comp-c-man              .man
 ./usr/share/man/man3/move_field.3              comp-c-man              .man
 ./usr/share/man/man3/move_panel.3              comp-c-man              .man
@@ -26299,6 +26320,7 @@
 ./usr/share/man/man3/underscore.3              comp-c-man              .man
 ./usr/share/man/man3/ungetc.3                  comp-c-man              .man
 ./usr/share/man/man3/ungetch.3                 comp-c-man              .man
+./usr/share/man/man3/ungetmouse.3              comp-c-man              .man
 ./usr/share/man/man3/ungetwc.3                 comp-c-man              .man
 ./usr/share/man/man3/unistd.3                  comp-c-man              .man
 ./usr/share/man/man3/unlockpt.3                        comp-c-man              .man
@@ -26447,6 +26469,7 @@
 ./usr/share/man/man3/wdeleteln.3               comp-c-man              .man
 ./usr/share/man/man3/wechochar.3               comp-c-man              .man
 ./usr/share/man/man3/werase.3                  comp-c-man              .man
+./usr/share/man/man3/wenclose.3                        comp-c-man              .man
 ./usr/share/man/man3/wgetch.3                  comp-c-man              .man
 ./usr/share/man/man3/wgetnstr.3                        comp-c-man              .man
 ./usr/share/man/man3/wgetstr.3                 comp-c-man              .man
@@ -26464,6 +26487,7 @@
 ./usr/share/man/man3/wmemcpy.3                 comp-c-man              .man
 ./usr/share/man/man3/wmemmove.3                        comp-c-man              .man
 ./usr/share/man/man3/wmemset.3                 comp-c-man              .man
+./usr/share/man/man3/wmouse_trafo.3            comp-c-man              .man
 ./usr/share/man/man3/wmove.3                   comp-c-man              .man
 ./usr/share/man/man3/wnoutrefresh.3            comp-c-man              .man
 ./usr/share/man/man3/wordexp.3                 comp-c-man              .man
diff -r a3c486bc56a0 -r 4ea0d307efd5 lib/libcurses/Makefile
--- a/lib/libcurses/Makefile    Mon Mar 23 11:45:00 2020 +0000
+++ b/lib/libcurses/Makefile    Mon Mar 23 13:37:36 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.93 2019/09/03 13:43:34 roy Exp $
+#      $NetBSD: Makefile,v 1.94 2020/03/23 13:37:36 roy Exp $
 #      @(#)Makefile    8.2 (Berkeley) 1/2/94
 
 .include <bsd.own.mk>
@@ -21,7 +21,7 @@
        flushok.c fullname.c getch.c getstr.c getyx.c id_subwins.c idlok.c \
        idcok.c immedok.c inch.c inchstr.c initscr.c insch.c insdelln.c \
        insertln.c insstr.c instr.c keypad.c keyname.c leaveok.c line.c \
-       meta.c move.c \
+       meta.c mouse.c move.c \
        mvwin.c newwin.c nodelay.c notimeout.c overlay.c overwrite.c pause.c \
        printw.c putchar.c refresh.c resize.c ripoffline.c scanw.c screen.c \
        scroll.c scrollok.c setterm.c slk.c standout.c syncok.c timeout.c \
@@ -34,7 +34,8 @@
        curses_cursor.3 curses_default_colors.3 \
        curses_delch.3 curses_deleteln.3 curses_echochar.3 curses_fileio.3 \
        curses_inch.3 curses_input.3 curses_insch.3 curses_insertln.3 \
-       curses_insdelln.3 curses_keyname.3 curses_line.3 curses_pad.3 \
+       curses_insdelln.3 curses_keyname.3 curses_line.3 \
+       curses_mouse.3 curses_pad.3 \
        curses_print.3 curses_refresh.3 curses_scanw.3 curses_screen.3 \
        curses_scroll.3 curses_slk.3 curses_standout.3 curses_termcap.3 \
        curses_touch.3 curses_tty.3 curses_underscore.3 curses_version.3 \
@@ -203,7 +204,11 @@
         curses_standout.3 wstandout.3 curses_touch.3 wsyncup.3 \
         curses_input.3 wtimeout.3 \
         curses_touch.3 wtouchln.3 curses_underscore.3 wunderend.3 \
-        curses_underscore.3 wunderscore.3 curses_line.3 wvline.3
+        curses_underscore.3 wunderscore.3 curses_line.3 wvline.3 \
+        curses_mouse.3 has_mouse.3 \
+        curses_mouse.3 getmouse.3 curses_mouse.3 ungetmouse.3 \
+        curses_mouse.3 mouse_trafo.3 curses_mouse.3 wmouse_trafo.3 \
+        curses_mouse.3 wenclose.3 curses_mouse.3 mouseinterval.3
 
 SUBDIR.roff+= PSD.doc
 
diff -r a3c486bc56a0 -r 4ea0d307efd5 lib/libcurses/curses.h
--- a/lib/libcurses/curses.h    Mon Mar 23 11:45:00 2020 +0000
+++ b/lib/libcurses/curses.h    Mon Mar 23 13:37:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses.h,v 1.128 2020/03/13 02:57:26 roy Exp $ */
+/*     $NetBSD: curses.h,v 1.129 2020/03/23 13:37:36 roy Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -980,6 +980,74 @@
 bool is_leaveok(const WINDOW *);
 bool is_pad(const WINDOW *);
 
+/* ncurses mouse support */
+#define        NB_MOUSE_MASK(b, m)     ((m) << (((b) - 1) * 5))
+#define        NB_BUTTON_RELEASED      001L
+#define        NB_BUTTON_PRESSED       002L
+#define        NB_BUTTON_CLICKED       004L
+#define        NB_DOUBLE_CLICKED       010L
+#define        NB_TRIPLE_CLICKED       020L
+#define        NB_RESERVED_EVENT       040L
+
+#define        BUTTON1_RELEASED        NB_MOUSE_MASK(1, NB_BUTTON_RELEASED)
+#define        BUTTON1_PRESSED         NB_MOUSE_MASK(1, NB_BUTTON_PRESSED)
+#define        BUTTON1_CLICKED         NB_MOUSE_MASK(1, NB_BUTTON_CLICKED)
+#define        BUTTON1_DOUBLE_CLICKED  NB_MOUSE_MASK(1, NB_DOUBLE_CLICKED)
+#define        BUTTON1_TRIPLE_CLICKED  NB_MOUSE_MASK(1, NB_TRIPLE_CLICKED)
+
+#define        BUTTON2_RELEASED        NB_MOUSE_MASK(2, NB_BUTTON_RELEASED)
+#define        BUTTON2_PRESSED         NB_MOUSE_MASK(2, NB_BUTTON_PRESSED)
+#define        BUTTON2_CLICKED         NB_MOUSE_MASK(2, NB_BUTTON_CLICKED)
+#define        BUTTON2_DOUBLE_CLICKED  NB_MOUSE_MASK(2, NB_DOUBLE_CLICKED)
+#define        BUTTON2_TRIPLE_CLICKED  NB_MOUSE_MASK(2, NB_TRIPLE_CLICKED)
+
+#define        BUTTON3_RELEASED        NB_MOUSE_MASK(3, NB_BUTTON_RELEASED)
+#define        BUTTON3_PRESSED         NB_MOUSE_MASK(3, NB_BUTTON_PRESSED)
+#define        BUTTON3_CLICKED         NB_MOUSE_MASK(3, NB_BUTTON_CLICKED)
+#define        BUTTON3_DOUBLE_CLICKED  NB_MOUSE_MASK(3, NB_DOUBLE_CLICKED)
+#define        BUTTON3_TRIPLE_CLICKED  NB_MOUSE_MASK(3, NB_TRIPLE_CLICKED)
+
+#define        BUTTON4_RELEASED        NB_MOUSE_MASK(4, NB_BUTTON_RELEASED)
+#define        BUTTON4_PRESSED         NB_MOUSE_MASK(4, NB_BUTTON_PRESSED)
+#define        BUTTON4_CLICKED         NB_MOUSE_MASK(4, NB_BUTTON_CLICKED)
+#define        BUTTON4_DOUBLE_CLICKED  NB_MOUSE_MASK(4, NB_DOUBLE_CLICKED)
+#define        BUTTON4_TRIPLE_CLICKED  NB_MOUSE_MASK(4, NB_TRIPLE_CLICKED)
+
+#define        BUTTON5_RELEASED        NB_MOUSE_MASK(5, NB_BUTTON_RELEASED)
+#define        BUTTON5_PRESSED         NB_MOUSE_MASK(5, NB_BUTTON_PRESSED)
+#define        BUTTON5_CLICKED         NB_MOUSE_MASK(5, NB_BUTTON_CLICKED)
+#define        BUTTON5_DOUBLE_CLICKED  NB_MOUSE_MASK(5, NB_DOUBLE_CLICKED)
+#define        BUTTON5_TRIPLE_CLICKED  NB_MOUSE_MASK(5, NB_TRIPLE_CLICKED)
+
+#define        BUTTON_CTRL             NB_MOUSE_MASK(6, 0001L)
+#define        BUTTON_SHIFT            NB_MOUSE_MASK(6, 0002L)
+#define        BUTTON_ALT              NB_MOUSE_MASK(6, 0004L)
+#define        REPORT_MOUSE_POSITION   NB_MOUSE_MASK(6, 0010L)
+#define        ALL_MOUSE_EVENTS        (REPORT_MOUSE_POSITION - 1)
+
+#define        BUTTON_RELEASE(e, x)            ((e) & NB_MOUSE_MASK(x, 001))
+#define        BUTTON_PRESS(e, x)              ((e) & NB_MOUSE_MASK(x, 002))
+#define        BUTTON_CLICK(e, x)              ((e) & NB_MOUSE_MASK(x, 004))
+#define        BUTTON_DOUBLE_CLICK(e, x)       ((e) & NB_MOUSE_MASK(x, 010))
+#define        BUTTON_TRIPLE_CLICK(e, x)       ((e) & NB_MOUSE_MASK(x, 020))
+#define        BUTTON_RESERVED_EVENT(e, x)     ((e) & NB_MOUSE_MASK(x, 040))
+
+typedef unsigned long mmask_t;
+typedef struct {
+       short id;       /* ID to distinguish multiple devices */
+       int x, y, z;    /* event coordinates */
+       mmask_t bstate;   /* button state bits */
+} MEVENT;
+
+bool has_mouse(void);
+int getmouse(MEVENT *);
+int ungetmouse(MEVENT *);
+mmask_t mousemask(mmask_t, mmask_t *);
+bool wenclose(const WINDOW *, int, int);
+bool mouse_trafo(int *, int *, bool);
+bool wmouse_trafo(const WINDOW *, int *, int *, bool);



Home | Main Index | Thread Index | Old Index