curses 1.4.6 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/push_gem.yml +6 -4
- data/README.md +8 -1
- data/curses.gemspec +2 -2
- data/ext/curses/curses.c +188 -12
- data/ext/curses/extconf.rb +3 -2
- data/lib/curses.rb +7 -0
- data/sample/attr_demo.rb +4 -2
- data/sample/screen.rb +9 -0
- data/vendor/PDCurses/.gitignore +47 -0
- data/vendor/PDCurses/.travis.yml +49 -0
- data/vendor/PDCurses/CMakeLists.txt +68 -0
- data/vendor/PDCurses/HISTORY.md +2036 -0
- data/vendor/PDCurses/IMPLEMNT.md +327 -0
- data/vendor/PDCurses/Makefile +27 -0
- data/vendor/PDCurses/README.md +77 -0
- data/vendor/PDCurses/acs_defs.h +265 -0
- data/vendor/PDCurses/appveyor.yml +218 -0
- data/vendor/PDCurses/cmake/README.md +71 -0
- data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
- data/vendor/PDCurses/cmake/build_options.cmake +25 -0
- data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
- data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
- data/vendor/PDCurses/cmake/get_version.cmake +17 -0
- data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
- data/vendor/PDCurses/cmake/project_common.cmake +121 -0
- data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
- data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
- data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
- data/vendor/PDCurses/cmake/version.in.cmake +73 -0
- data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
- data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
- data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
- data/vendor/PDCurses/curses.h +1846 -0
- data/vendor/PDCurses/curspriv.h +134 -0
- data/vendor/PDCurses/demos/README.md +25 -0
- data/vendor/PDCurses/demos/firework.c +144 -0
- data/vendor/PDCurses/demos/newtest.c +581 -0
- data/vendor/PDCurses/demos/ozdemo.c +447 -0
- data/vendor/PDCurses/demos/ptest.c +283 -0
- data/vendor/PDCurses/demos/rain.c +157 -0
- data/vendor/PDCurses/demos/testcurs.c +1607 -0
- data/vendor/PDCurses/demos/tui.c +1048 -0
- data/vendor/PDCurses/demos/tui.h +65 -0
- data/vendor/PDCurses/demos/tuidemo.c +233 -0
- data/vendor/PDCurses/demos/version.c +61 -0
- data/vendor/PDCurses/demos/worm.c +432 -0
- data/vendor/PDCurses/demos/xmas.c +955 -0
- data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
- data/vendor/PDCurses/dos/Makefile +105 -0
- data/vendor/PDCurses/dos/Makefile.bcc +83 -0
- data/vendor/PDCurses/dos/Makefile.dmc +257 -0
- data/vendor/PDCurses/dos/Makefile.msc +113 -0
- data/vendor/PDCurses/dos/Makefile.wcc +107 -0
- data/vendor/PDCurses/dos/README.md +51 -0
- data/vendor/PDCurses/dos/bccdos.lrf +9 -0
- data/vendor/PDCurses/dos/mscdos.lrf +50 -0
- data/vendor/PDCurses/dos/pdcclip.c +132 -0
- data/vendor/PDCurses/dos/pdcdisp.c +135 -0
- data/vendor/PDCurses/dos/pdcdos.h +194 -0
- data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
- data/vendor/PDCurses/dos/pdckbd.c +513 -0
- data/vendor/PDCurses/dos/pdcscrn.c +785 -0
- data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
- data/vendor/PDCurses/dos/pdcutil.c +212 -0
- data/vendor/PDCurses/libobjs.mif +26 -0
- data/vendor/PDCurses/makedist.mif +20 -0
- data/vendor/PDCurses/man/Makefile +37 -0
- data/vendor/PDCurses/man/README.md +21 -0
- data/vendor/PDCurses/man/intro.md +361 -0
- data/vendor/PDCurses/man/manext.c +119 -0
- data/vendor/PDCurses/man/sdl.md +152 -0
- data/vendor/PDCurses/man/sdl2.md +58 -0
- data/vendor/PDCurses/man/x11.md +407 -0
- data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
- data/vendor/PDCurses/ncurses/README.md +26 -0
- data/vendor/PDCurses/ncurses/makefile +29 -0
- data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
- data/vendor/PDCurses/os2/Makefile +132 -0
- data/vendor/PDCurses/os2/Makefile.bcc +90 -0
- data/vendor/PDCurses/os2/Makefile.wcc +43 -0
- data/vendor/PDCurses/os2/README.md +43 -0
- data/vendor/PDCurses/os2/iccos2.lrf +50 -0
- data/vendor/PDCurses/os2/iccos2.mak +256 -0
- data/vendor/PDCurses/os2/pdcclip.c +188 -0
- data/vendor/PDCurses/os2/pdcdisp.c +93 -0
- data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
- data/vendor/PDCurses/os2/pdckbd.c +521 -0
- data/vendor/PDCurses/os2/pdcos2.h +55 -0
- data/vendor/PDCurses/os2/pdcscrn.c +449 -0
- data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
- data/vendor/PDCurses/os2/pdcutil.c +52 -0
- data/vendor/PDCurses/panel.h +56 -0
- data/vendor/PDCurses/pdcurses/README.md +25 -0
- data/vendor/PDCurses/pdcurses/addch.c +693 -0
- data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
- data/vendor/PDCurses/pdcurses/addstr.c +240 -0
- data/vendor/PDCurses/pdcurses/attr.c +359 -0
- data/vendor/PDCurses/pdcurses/beep.c +68 -0
- data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
- data/vendor/PDCurses/pdcurses/border.c +411 -0
- data/vendor/PDCurses/pdcurses/clear.c +159 -0
- data/vendor/PDCurses/pdcurses/color.c +298 -0
- data/vendor/PDCurses/pdcurses/debug.c +109 -0
- data/vendor/PDCurses/pdcurses/delch.c +96 -0
- data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
- data/vendor/PDCurses/pdcurses/deprec.c +27 -0
- data/vendor/PDCurses/pdcurses/getch.c +417 -0
- data/vendor/PDCurses/pdcurses/getstr.c +474 -0
- data/vendor/PDCurses/pdcurses/getyx.c +139 -0
- data/vendor/PDCurses/pdcurses/inch.c +127 -0
- data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
- data/vendor/PDCurses/pdcurses/initscr.c +367 -0
- data/vendor/PDCurses/pdcurses/inopts.c +324 -0
- data/vendor/PDCurses/pdcurses/insch.c +271 -0
- data/vendor/PDCurses/pdcurses/insstr.c +264 -0
- data/vendor/PDCurses/pdcurses/instr.c +246 -0
- data/vendor/PDCurses/pdcurses/kernel.c +259 -0
- data/vendor/PDCurses/pdcurses/keyname.c +157 -0
- data/vendor/PDCurses/pdcurses/mouse.c +438 -0
- data/vendor/PDCurses/pdcurses/move.c +57 -0
- data/vendor/PDCurses/pdcurses/outopts.c +159 -0
- data/vendor/PDCurses/pdcurses/overlay.c +214 -0
- data/vendor/PDCurses/pdcurses/pad.c +260 -0
- data/vendor/PDCurses/pdcurses/panel.c +633 -0
- data/vendor/PDCurses/pdcurses/printw.c +126 -0
- data/vendor/PDCurses/pdcurses/refresh.c +279 -0
- data/vendor/PDCurses/pdcurses/scanw.c +578 -0
- data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
- data/vendor/PDCurses/pdcurses/scroll.c +101 -0
- data/vendor/PDCurses/pdcurses/slk.c +591 -0
- data/vendor/PDCurses/pdcurses/termattr.c +182 -0
- data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
- data/vendor/PDCurses/pdcurses/touch.c +163 -0
- data/vendor/PDCurses/pdcurses/util.c +312 -0
- data/vendor/PDCurses/pdcurses/window.c +569 -0
- data/vendor/PDCurses/sdl1/Makefile +129 -0
- data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
- data/vendor/PDCurses/sdl1/README.md +31 -0
- data/vendor/PDCurses/sdl1/deffont.h +385 -0
- data/vendor/PDCurses/sdl1/deficon.h +23 -0
- data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
- data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
- data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
- data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
- data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
- data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
- data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
- data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
- data/vendor/PDCurses/sdl1/sdltest.c +79 -0
- data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
- data/vendor/PDCurses/sdl2/Makefile +135 -0
- data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
- data/vendor/PDCurses/sdl2/README.md +34 -0
- data/vendor/PDCurses/sdl2/deffont.h +385 -0
- data/vendor/PDCurses/sdl2/deficon.h +23 -0
- data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
- data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
- data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
- data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
- data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
- data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
- data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
- data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
- data/vendor/PDCurses/sdl2/sdltest.c +81 -0
- data/vendor/PDCurses/term.h +48 -0
- data/vendor/PDCurses/version.mif +7 -0
- data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
- data/vendor/PDCurses/vt/Makefile +135 -0
- data/vendor/PDCurses/vt/Makefile.bcc +111 -0
- data/vendor/PDCurses/vt/Makefile.dmc +258 -0
- data/vendor/PDCurses/vt/Makefile.vc +144 -0
- data/vendor/PDCurses/vt/Makefile.wcc +107 -0
- data/vendor/PDCurses/vt/README.md +64 -0
- data/vendor/PDCurses/vt/pdcclip.c +20 -0
- data/vendor/PDCurses/vt/pdcdisp.c +284 -0
- data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
- data/vendor/PDCurses/vt/pdckbd.c +394 -0
- data/vendor/PDCurses/vt/pdcscrn.c +434 -0
- data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
- data/vendor/PDCurses/vt/pdcutil.c +43 -0
- data/vendor/PDCurses/vt/pdcvt.h +16 -0
- data/vendor/PDCurses/watcom.mif +68 -0
- data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
- data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
- data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
- data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
- data/vendor/PDCurses/wincon/Makefile.mng +176 -0
- data/vendor/PDCurses/wincon/Makefile.vc +144 -0
- data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
- data/vendor/PDCurses/wincon/README.md +85 -0
- data/vendor/PDCurses/wincon/pdcclip.c +174 -0
- data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
- data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
- data/vendor/PDCurses/wincon/pdckbd.c +786 -0
- data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
- data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
- data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
- data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
- data/vendor/PDCurses/wincon/pdcutil.c +41 -0
- data/vendor/PDCurses/wincon/pdcwin.h +31 -0
- data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
- data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
- data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
- data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
- data/vendor/PDCurses/wingui/Makefile.mng +171 -0
- data/vendor/PDCurses/wingui/Makefile.vc +144 -0
- data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
- data/vendor/PDCurses/wingui/README.md +93 -0
- data/vendor/PDCurses/wingui/pdcclip.c +174 -0
- data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
- data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
- data/vendor/PDCurses/wingui/pdckbd.c +143 -0
- data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
- data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
- data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
- data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
- data/vendor/PDCurses/wingui/pdcutil.c +61 -0
- data/vendor/PDCurses/wingui/pdcwin.h +122 -0
- data/vendor/PDCurses/x11/Makefile.in +754 -0
- data/vendor/PDCurses/x11/PDCurses.spec +82 -0
- data/vendor/PDCurses/x11/README.md +62 -0
- data/vendor/PDCurses/x11/ScrollBox.c +319 -0
- data/vendor/PDCurses/x11/ScrollBox.h +51 -0
- data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
- data/vendor/PDCurses/x11/aclocal.m4 +994 -0
- data/vendor/PDCurses/x11/big_icon.xbm +46 -0
- data/vendor/PDCurses/x11/compose.h +201 -0
- data/vendor/PDCurses/x11/config.guess +1500 -0
- data/vendor/PDCurses/x11/config.h.in +100 -0
- data/vendor/PDCurses/x11/config.sub +1616 -0
- data/vendor/PDCurses/x11/configure +6700 -0
- data/vendor/PDCurses/x11/configure.ac +295 -0
- data/vendor/PDCurses/x11/debian/changelog +6 -0
- data/vendor/PDCurses/x11/debian/compat +1 -0
- data/vendor/PDCurses/x11/debian/control +11 -0
- data/vendor/PDCurses/x11/debian/copyright +27 -0
- data/vendor/PDCurses/x11/debian/rules +98 -0
- data/vendor/PDCurses/x11/install-sh +253 -0
- data/vendor/PDCurses/x11/little_icon.xbm +14 -0
- data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
- data/vendor/PDCurses/x11/pdcclip.c +173 -0
- data/vendor/PDCurses/x11/pdcdisp.c +85 -0
- data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
- data/vendor/PDCurses/x11/pdckbd.c +104 -0
- data/vendor/PDCurses/x11/pdcscrn.c +258 -0
- data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
- data/vendor/PDCurses/x11/pdcutil.c +52 -0
- data/vendor/PDCurses/x11/pdcx11.c +316 -0
- data/vendor/PDCurses/x11/pdcx11.h +191 -0
- data/vendor/PDCurses/x11/sb.c +155 -0
- data/vendor/PDCurses/x11/x11.c +3686 -0
- data/vendor/PDCurses/x11/xcurses-config.in +81 -0
- metadata +249 -8
@@ -0,0 +1,438 @@
|
|
1
|
+
/* Public Domain Curses */
|
2
|
+
|
3
|
+
#include <curspriv.h>
|
4
|
+
|
5
|
+
/*man-start**************************************************************
|
6
|
+
|
7
|
+
mouse
|
8
|
+
-----
|
9
|
+
|
10
|
+
### Synopsis
|
11
|
+
|
12
|
+
int mouse_set(unsigned long mbe);
|
13
|
+
int mouse_on(unsigned long mbe);
|
14
|
+
int mouse_off(unsigned long mbe);
|
15
|
+
int request_mouse_pos(void);
|
16
|
+
int map_button(unsigned long button);
|
17
|
+
void wmouse_position(WINDOW *win, int *y, int *x);
|
18
|
+
unsigned long getmouse(void);
|
19
|
+
unsigned long getbmap(void);
|
20
|
+
|
21
|
+
int mouseinterval(int wait);
|
22
|
+
bool wenclose(const WINDOW *win, int y, int x);
|
23
|
+
bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen);
|
24
|
+
bool mouse_trafo(int *y, int *x, bool to_screen);
|
25
|
+
mmask_t mousemask(mmask_t mask, mmask_t *oldmask);
|
26
|
+
int nc_getmouse(MEVENT *event);
|
27
|
+
int ungetmouse(MEVENT *event);
|
28
|
+
|
29
|
+
### Description
|
30
|
+
|
31
|
+
As of PDCurses 3.0, there are two separate mouse interfaces: the
|
32
|
+
classic interface, which is based on the undocumented Sys V
|
33
|
+
mouse functions; and an ncurses-compatible interface. Both are
|
34
|
+
active at all times, and you can mix and match functions from
|
35
|
+
each, though it's not recommended. The ncurses interface is
|
36
|
+
essentially an emulation layer built on top of the classic
|
37
|
+
interface; it's here to allow easier porting of ncurses apps.
|
38
|
+
|
39
|
+
The classic interface: mouse_set(), mouse_on(), mouse_off(),
|
40
|
+
request_mouse_pos(), map_button(), wmouse_position(),
|
41
|
+
getmouse(), and getbmap(). An application using this interface
|
42
|
+
would start by calling mouse_set() or mouse_on() with a non-zero
|
43
|
+
value, often ALL_MOUSE_EVENTS. Then it would check for a
|
44
|
+
KEY_MOUSE return from getch(). If found, it would call
|
45
|
+
request_mouse_pos() to get the current mouse status.
|
46
|
+
|
47
|
+
mouse_set(), mouse_on() and mouse_off() are analagous to
|
48
|
+
attrset(), attron() and attroff(). These functions set the
|
49
|
+
mouse button events to trap. The button masks used in these
|
50
|
+
functions are defined in curses.h and can be or'ed together.
|
51
|
+
They are the group of masks starting with BUTTON1_RELEASED.
|
52
|
+
|
53
|
+
request_mouse_pos() requests curses to fill in the Mouse_status
|
54
|
+
structure with the current state of the mouse.
|
55
|
+
|
56
|
+
map_button() enables the specified mouse action to activate the
|
57
|
+
Soft Label Keys if the action occurs over the area of the screen
|
58
|
+
where the Soft Label Keys are displayed. The mouse actions are
|
59
|
+
defined in curses.h in the group that starts with BUTTON_RELEASED.
|
60
|
+
|
61
|
+
wmouse_position() determines if the current mouse position is
|
62
|
+
within the window passed as an argument. If the mouse is
|
63
|
+
outside the current window, -1 is returned in the y and x
|
64
|
+
arguments; otherwise the y and x coordinates of the mouse
|
65
|
+
(relative to the top left corner of the window) are returned in
|
66
|
+
y and x.
|
67
|
+
|
68
|
+
getmouse() returns the current status of the trapped mouse
|
69
|
+
buttons as set by mouse_set() or mouse_on().
|
70
|
+
|
71
|
+
getbmap() returns the current status of the button action used
|
72
|
+
to map a mouse action to the Soft Label Keys as set by the
|
73
|
+
map_button() function.
|
74
|
+
|
75
|
+
The ncurses interface: mouseinterval(), wenclose(),
|
76
|
+
wmouse_trafo(), mouse_trafo(), mousemask(), nc_getmouse(), and
|
77
|
+
ungetmouse(). A typical application using this interface would
|
78
|
+
start by calling mousemask() with a non-zero value, often
|
79
|
+
ALL_MOUSE_EVENTS. Then it would check for a KEY_MOUSE return
|
80
|
+
from getch(). If found, it would call nc_getmouse() to get the
|
81
|
+
current mouse status.
|
82
|
+
|
83
|
+
mouseinterval() sets the timeout for a mouse click. On all
|
84
|
+
current platforms, PDCurses receives mouse button press and
|
85
|
+
release events, but must synthesize click events. It does this
|
86
|
+
by checking whether a release event is queued up after a press
|
87
|
+
event. If it gets a press event, and there are no more events
|
88
|
+
waiting, it will wait for the timeout interval, then check again
|
89
|
+
for a release. A press followed by a release is reported as
|
90
|
+
BUTTON_CLICKED; otherwise it's passed through as BUTTON_PRESSED.
|
91
|
+
The default timeout is 150ms; valid values are 0 (no clicks
|
92
|
+
reported) through 1000ms. In x11, the timeout can also be set
|
93
|
+
via the clickPeriod resource. The return value from
|
94
|
+
mouseinterval() is the old timeout. To check the old value
|
95
|
+
without setting a new one, call it with a parameter of -1. Note
|
96
|
+
that although there's no classic equivalent for this function
|
97
|
+
(apart from the clickPeriod resource), the value set applies in
|
98
|
+
both interfaces.
|
99
|
+
|
100
|
+
wenclose() reports whether the given screen-relative y, x
|
101
|
+
coordinates fall within the given window.
|
102
|
+
|
103
|
+
wmouse_trafo() converts between screen-relative and window-
|
104
|
+
relative coordinates. A to_screen parameter of TRUE means to
|
105
|
+
convert from window to screen; otherwise the reverse. The
|
106
|
+
function returns FALSE if the coordinates aren't within the
|
107
|
+
window, or if any of the parameters are NULL. The coordinates
|
108
|
+
have been converted when the function returns TRUE.
|
109
|
+
|
110
|
+
mouse_trafo() is the stdscr version of wmouse_trafo().
|
111
|
+
|
112
|
+
mousemask() is nearly equivalent to mouse_set(), but instead of
|
113
|
+
OK/ERR, it returns the value of the mask after setting it. (This
|
114
|
+
isn't necessarily the same value passed in, since the mask could
|
115
|
+
be altered on some platforms.) And if the second parameter is a
|
116
|
+
non-null pointer, mousemask() stores the previous mask value
|
117
|
+
there. Also, since the ncurses interface doesn't work with
|
118
|
+
PDCurses' BUTTON_MOVED events, mousemask() filters them out.
|
119
|
+
|
120
|
+
nc_getmouse() returns the current mouse status in an MEVENT
|
121
|
+
struct. This is equivalent to ncurses' getmouse(), renamed to
|
122
|
+
avoid conflict with PDCurses' getmouse(). But if you define
|
123
|
+
PDC_NCMOUSE before including curses.h, it defines getmouse() to
|
124
|
+
nc_getmouse(), along with a few other redefintions needed for
|
125
|
+
compatibility with ncurses code. nc_getmouse() calls
|
126
|
+
request_mouse_pos(), which (not getmouse()) is the classic
|
127
|
+
equivalent.
|
128
|
+
|
129
|
+
ungetmouse() is the mouse equivalent of ungetch(). However,
|
130
|
+
PDCurses doesn't maintain a queue of mouse events; only one can
|
131
|
+
be pushed back, and it can overwrite or be overwritten by real
|
132
|
+
mouse events.
|
133
|
+
|
134
|
+
### Portability
|
135
|
+
X/Open BSD SYS V
|
136
|
+
mouse_set - - 4.0
|
137
|
+
mouse_on - - 4.0
|
138
|
+
mouse_off - - 4.0
|
139
|
+
request_mouse_pos - - 4.0
|
140
|
+
map_button - - 4.0
|
141
|
+
wmouse_position - - 4.0
|
142
|
+
getmouse - - 4.0
|
143
|
+
getbmap - - 4.0
|
144
|
+
mouseinterval - - -
|
145
|
+
wenclose - - -
|
146
|
+
wmouse_trafo - - -
|
147
|
+
mouse_trafo - - -
|
148
|
+
mousemask - - -
|
149
|
+
nc_getmouse - - -
|
150
|
+
ungetmouse - - -
|
151
|
+
|
152
|
+
**man-end****************************************************************/
|
153
|
+
|
154
|
+
#include <string.h>
|
155
|
+
|
156
|
+
static bool ungot = FALSE;
|
157
|
+
|
158
|
+
int mouse_set(unsigned long mbe)
|
159
|
+
{
|
160
|
+
PDC_LOG(("mouse_set() - called: event %x\n", mbe));
|
161
|
+
|
162
|
+
SP->_trap_mbe = mbe;
|
163
|
+
return PDC_mouse_set();
|
164
|
+
}
|
165
|
+
|
166
|
+
int mouse_on(unsigned long mbe)
|
167
|
+
{
|
168
|
+
PDC_LOG(("mouse_on() - called: event %x\n", mbe));
|
169
|
+
|
170
|
+
SP->_trap_mbe |= mbe;
|
171
|
+
return PDC_mouse_set();
|
172
|
+
}
|
173
|
+
|
174
|
+
int mouse_off(unsigned long mbe)
|
175
|
+
{
|
176
|
+
PDC_LOG(("mouse_off() - called: event %x\n", mbe));
|
177
|
+
|
178
|
+
SP->_trap_mbe &= ~mbe;
|
179
|
+
return PDC_mouse_set();
|
180
|
+
}
|
181
|
+
|
182
|
+
int map_button(unsigned long button)
|
183
|
+
{
|
184
|
+
PDC_LOG(("map_button() - called: button %x\n", button));
|
185
|
+
|
186
|
+
/****************** this does nothing at the moment ***************/
|
187
|
+
SP->_map_mbe_to_key = button;
|
188
|
+
|
189
|
+
return OK;
|
190
|
+
}
|
191
|
+
|
192
|
+
int request_mouse_pos(void)
|
193
|
+
{
|
194
|
+
PDC_LOG(("request_mouse_pos() - called\n"));
|
195
|
+
|
196
|
+
Mouse_status = pdc_mouse_status;
|
197
|
+
|
198
|
+
return OK;
|
199
|
+
}
|
200
|
+
|
201
|
+
void wmouse_position(WINDOW *win, int *y, int *x)
|
202
|
+
{
|
203
|
+
PDC_LOG(("wmouse_position() - called\n"));
|
204
|
+
|
205
|
+
if (win && wenclose(win, MOUSE_Y_POS, MOUSE_X_POS))
|
206
|
+
{
|
207
|
+
if (y)
|
208
|
+
*y = MOUSE_Y_POS - win->_begy;
|
209
|
+
if (x)
|
210
|
+
*x = MOUSE_X_POS - win->_begx;
|
211
|
+
}
|
212
|
+
else
|
213
|
+
{
|
214
|
+
if (y)
|
215
|
+
*y = -1;
|
216
|
+
if (x)
|
217
|
+
*x = -1;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
unsigned long getmouse(void)
|
222
|
+
{
|
223
|
+
PDC_LOG(("getmouse() - called\n"));
|
224
|
+
|
225
|
+
return SP->_trap_mbe;
|
226
|
+
}
|
227
|
+
|
228
|
+
unsigned long getbmap(void)
|
229
|
+
{
|
230
|
+
PDC_LOG(("getbmap() - called\n"));
|
231
|
+
|
232
|
+
return SP->_map_mbe_to_key;
|
233
|
+
}
|
234
|
+
|
235
|
+
/* ncurses mouse interface */
|
236
|
+
|
237
|
+
int mouseinterval(int wait)
|
238
|
+
{
|
239
|
+
int old_wait;
|
240
|
+
|
241
|
+
PDC_LOG(("mouseinterval() - called: %d\n", wait));
|
242
|
+
|
243
|
+
old_wait = SP->mouse_wait;
|
244
|
+
|
245
|
+
if (wait >= 0 && wait <= 1000)
|
246
|
+
SP->mouse_wait = wait;
|
247
|
+
|
248
|
+
return old_wait;
|
249
|
+
}
|
250
|
+
|
251
|
+
bool wenclose(const WINDOW *win, int y, int x)
|
252
|
+
{
|
253
|
+
PDC_LOG(("wenclose() - called: %p %d %d\n", win, y, x));
|
254
|
+
|
255
|
+
return (win && y >= win->_begy && y < win->_begy + win->_maxy
|
256
|
+
&& x >= win->_begx && x < win->_begx + win->_maxx);
|
257
|
+
}
|
258
|
+
|
259
|
+
bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen)
|
260
|
+
{
|
261
|
+
int newy, newx;
|
262
|
+
|
263
|
+
PDC_LOG(("wmouse_trafo() - called\n"));
|
264
|
+
|
265
|
+
if (!win || !y || !x)
|
266
|
+
return FALSE;
|
267
|
+
|
268
|
+
newy = *y;
|
269
|
+
newx = *x;
|
270
|
+
|
271
|
+
if (to_screen)
|
272
|
+
{
|
273
|
+
newy += win->_begy;
|
274
|
+
newx += win->_begx;
|
275
|
+
|
276
|
+
if (!wenclose(win, newy, newx))
|
277
|
+
return FALSE;
|
278
|
+
}
|
279
|
+
else
|
280
|
+
{
|
281
|
+
if (wenclose(win, newy, newx))
|
282
|
+
{
|
283
|
+
newy -= win->_begy;
|
284
|
+
newx -= win->_begx;
|
285
|
+
}
|
286
|
+
else
|
287
|
+
return FALSE;
|
288
|
+
}
|
289
|
+
|
290
|
+
*y = newy;
|
291
|
+
*x = newx;
|
292
|
+
|
293
|
+
return TRUE;
|
294
|
+
}
|
295
|
+
|
296
|
+
bool mouse_trafo(int *y, int *x, bool to_screen)
|
297
|
+
{
|
298
|
+
PDC_LOG(("mouse_trafo() - called\n"));
|
299
|
+
|
300
|
+
return wmouse_trafo(stdscr, y, x, to_screen);
|
301
|
+
}
|
302
|
+
|
303
|
+
mmask_t mousemask(mmask_t mask, mmask_t *oldmask)
|
304
|
+
{
|
305
|
+
PDC_LOG(("mousemask() - called\n"));
|
306
|
+
|
307
|
+
if (oldmask)
|
308
|
+
*oldmask = SP->_trap_mbe;
|
309
|
+
|
310
|
+
/* The ncurses interface doesn't work with our move events, so
|
311
|
+
filter them here */
|
312
|
+
|
313
|
+
mask &= ~(BUTTON1_MOVED | BUTTON2_MOVED | BUTTON3_MOVED);
|
314
|
+
|
315
|
+
mouse_set(mask);
|
316
|
+
|
317
|
+
return SP->_trap_mbe;
|
318
|
+
}
|
319
|
+
|
320
|
+
int nc_getmouse(MEVENT *event)
|
321
|
+
{
|
322
|
+
int i;
|
323
|
+
mmask_t bstate = 0;
|
324
|
+
|
325
|
+
PDC_LOG(("nc_getmouse() - called\n"));
|
326
|
+
|
327
|
+
if (!event)
|
328
|
+
return ERR;
|
329
|
+
|
330
|
+
ungot = FALSE;
|
331
|
+
|
332
|
+
request_mouse_pos();
|
333
|
+
|
334
|
+
event->id = 0;
|
335
|
+
|
336
|
+
event->x = Mouse_status.x;
|
337
|
+
event->y = Mouse_status.y;
|
338
|
+
event->z = 0;
|
339
|
+
|
340
|
+
for (i = 0; i < 3; i++)
|
341
|
+
{
|
342
|
+
if (Mouse_status.changes & (1 << i))
|
343
|
+
{
|
344
|
+
int shf = i * 5;
|
345
|
+
short button = Mouse_status.button[i] & BUTTON_ACTION_MASK;
|
346
|
+
|
347
|
+
if (button == BUTTON_RELEASED)
|
348
|
+
bstate |= (BUTTON1_RELEASED << shf);
|
349
|
+
else if (button == BUTTON_PRESSED)
|
350
|
+
bstate |= (BUTTON1_PRESSED << shf);
|
351
|
+
else if (button == BUTTON_CLICKED)
|
352
|
+
bstate |= (BUTTON1_CLICKED << shf);
|
353
|
+
else if (button == BUTTON_DOUBLE_CLICKED)
|
354
|
+
bstate |= (BUTTON1_DOUBLE_CLICKED << shf);
|
355
|
+
else if (button == BUTTON_TRIPLE_CLICKED)
|
356
|
+
bstate |= (BUTTON1_TRIPLE_CLICKED << shf);
|
357
|
+
|
358
|
+
button = Mouse_status.button[i] & BUTTON_MODIFIER_MASK;
|
359
|
+
|
360
|
+
if (button & PDC_BUTTON_SHIFT)
|
361
|
+
bstate |= BUTTON_MODIFIER_SHIFT;
|
362
|
+
if (button & PDC_BUTTON_CONTROL)
|
363
|
+
bstate |= BUTTON_MODIFIER_CONTROL;
|
364
|
+
if (button & PDC_BUTTON_ALT)
|
365
|
+
bstate |= BUTTON_MODIFIER_ALT;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
|
369
|
+
if (MOUSE_WHEEL_UP)
|
370
|
+
bstate |= BUTTON4_PRESSED;
|
371
|
+
else if (MOUSE_WHEEL_DOWN)
|
372
|
+
bstate |= BUTTON5_PRESSED;
|
373
|
+
if( MOUSE_MOVED)
|
374
|
+
bstate |= REPORT_MOUSE_POSITION;
|
375
|
+
|
376
|
+
/* extra filter pass -- mainly for button modifiers */
|
377
|
+
|
378
|
+
event->bstate = bstate & SP->_trap_mbe;
|
379
|
+
|
380
|
+
return OK;
|
381
|
+
}
|
382
|
+
|
383
|
+
int ungetmouse(MEVENT *event)
|
384
|
+
{
|
385
|
+
int i;
|
386
|
+
unsigned long bstate;
|
387
|
+
|
388
|
+
PDC_LOG(("ungetmouse() - called\n"));
|
389
|
+
|
390
|
+
if (!event || ungot)
|
391
|
+
return ERR;
|
392
|
+
|
393
|
+
ungot = TRUE;
|
394
|
+
|
395
|
+
pdc_mouse_status.x = event->x;
|
396
|
+
pdc_mouse_status.y = event->y;
|
397
|
+
|
398
|
+
pdc_mouse_status.changes = 0;
|
399
|
+
bstate = event->bstate;
|
400
|
+
|
401
|
+
for (i = 0; i < 3; i++)
|
402
|
+
{
|
403
|
+
int shf = i * 5;
|
404
|
+
short button = 0;
|
405
|
+
|
406
|
+
if (bstate & ((BUTTON1_RELEASED | BUTTON1_PRESSED |
|
407
|
+
BUTTON1_TRIPLE_CLICKED |
|
408
|
+
BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED) << shf))
|
409
|
+
{
|
410
|
+
pdc_mouse_status.changes |= 1 << i;
|
411
|
+
|
412
|
+
if (bstate & (BUTTON1_PRESSED << shf))
|
413
|
+
button = BUTTON_PRESSED;
|
414
|
+
if (bstate & (BUTTON1_CLICKED << shf))
|
415
|
+
button = BUTTON_CLICKED;
|
416
|
+
if (bstate & (BUTTON1_DOUBLE_CLICKED << shf))
|
417
|
+
button = BUTTON_DOUBLE_CLICKED;
|
418
|
+
if (bstate & (BUTTON1_TRIPLE_CLICKED << shf))
|
419
|
+
button = BUTTON_TRIPLE_CLICKED;
|
420
|
+
|
421
|
+
if (bstate & BUTTON_MODIFIER_SHIFT)
|
422
|
+
button |= PDC_BUTTON_SHIFT;
|
423
|
+
if (bstate & BUTTON_MODIFIER_CONTROL)
|
424
|
+
button |= PDC_BUTTON_CONTROL;
|
425
|
+
if (bstate & BUTTON_MODIFIER_ALT)
|
426
|
+
button |= PDC_BUTTON_ALT;
|
427
|
+
}
|
428
|
+
|
429
|
+
pdc_mouse_status.button[i] = button;
|
430
|
+
}
|
431
|
+
|
432
|
+
if (bstate & BUTTON4_PRESSED)
|
433
|
+
pdc_mouse_status.changes |= PDC_MOUSE_WHEEL_UP;
|
434
|
+
else if (bstate & BUTTON5_PRESSED)
|
435
|
+
pdc_mouse_status.changes |= PDC_MOUSE_WHEEL_DOWN;
|
436
|
+
|
437
|
+
return ungetch(KEY_MOUSE);
|
438
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
/* Public Domain Curses */
|
2
|
+
|
3
|
+
#include <curspriv.h>
|
4
|
+
|
5
|
+
/*man-start**************************************************************
|
6
|
+
|
7
|
+
move
|
8
|
+
----
|
9
|
+
|
10
|
+
### Synopsis
|
11
|
+
|
12
|
+
int move(int y, int x);
|
13
|
+
int wmove(WINDOW *win, int y, int x);
|
14
|
+
|
15
|
+
### Description
|
16
|
+
|
17
|
+
The cursor associated with the window is moved to the given
|
18
|
+
location. This does not move the physical cursor of the
|
19
|
+
terminal until refresh() is called. The position specified is
|
20
|
+
relative to the upper left corner of the window, which is (0,0).
|
21
|
+
|
22
|
+
### Return Value
|
23
|
+
|
24
|
+
All functions return OK on success and ERR on error.
|
25
|
+
|
26
|
+
### Portability
|
27
|
+
X/Open BSD SYS V
|
28
|
+
move Y Y Y
|
29
|
+
wmove Y Y Y
|
30
|
+
|
31
|
+
**man-end****************************************************************/
|
32
|
+
|
33
|
+
int move(int y, int x)
|
34
|
+
{
|
35
|
+
PDC_LOG(("move() - called: y=%d x=%d\n", y, x));
|
36
|
+
|
37
|
+
if (!stdscr || x < 0 || y < 0 || x >= stdscr->_maxx || y >= stdscr->_maxy)
|
38
|
+
return ERR;
|
39
|
+
|
40
|
+
stdscr->_curx = x;
|
41
|
+
stdscr->_cury = y;
|
42
|
+
|
43
|
+
return OK;
|
44
|
+
}
|
45
|
+
|
46
|
+
int wmove(WINDOW *win, int y, int x)
|
47
|
+
{
|
48
|
+
PDC_LOG(("wmove() - called: y=%d x=%d\n", y, x));
|
49
|
+
|
50
|
+
if (!win || x < 0 || y < 0 || x >= win->_maxx || y >= win->_maxy)
|
51
|
+
return ERR;
|
52
|
+
|
53
|
+
win->_curx = x;
|
54
|
+
win->_cury = y;
|
55
|
+
|
56
|
+
return OK;
|
57
|
+
}
|
@@ -0,0 +1,159 @@
|
|
1
|
+
/* Public Domain Curses */
|
2
|
+
|
3
|
+
#include <curspriv.h>
|
4
|
+
|
5
|
+
/*man-start**************************************************************
|
6
|
+
|
7
|
+
outopts
|
8
|
+
-------
|
9
|
+
|
10
|
+
### Synopsis
|
11
|
+
|
12
|
+
int clearok(WINDOW *win, bool bf);
|
13
|
+
int idlok(WINDOW *win, bool bf);
|
14
|
+
void idcok(WINDOW *win, bool bf);
|
15
|
+
void immedok(WINDOW *win, bool bf);
|
16
|
+
int leaveok(WINDOW *win, bool bf);
|
17
|
+
int setscrreg(int top, int bot);
|
18
|
+
int wsetscrreg(WINDOW *win, int top, int bot);
|
19
|
+
int scrollok(WINDOW *win, bool bf);
|
20
|
+
|
21
|
+
int raw_output(bool bf);
|
22
|
+
|
23
|
+
### Description
|
24
|
+
|
25
|
+
With clearok(), if bf is TRUE, the next call to wrefresh() with
|
26
|
+
this window will clear the screen completely and redraw the
|
27
|
+
entire screen.
|
28
|
+
|
29
|
+
immedok(), called with a second argument of TRUE, causes an
|
30
|
+
automatic wrefresh() every time a change is made to the
|
31
|
+
specified window.
|
32
|
+
|
33
|
+
Normally, the hardware cursor is left at the location of the
|
34
|
+
window being refreshed. leaveok() allows the cursor to be
|
35
|
+
left wherever the update happens to leave it. It's useful
|
36
|
+
for applications where the cursor is not used, since it reduces
|
37
|
+
the need for cursor motions. If possible, the cursor is made
|
38
|
+
invisible when this option is enabled.
|
39
|
+
|
40
|
+
wsetscrreg() sets a scrolling region in a window; "top" and
|
41
|
+
"bot" are the line numbers for the top and bottom margins. If
|
42
|
+
this option and scrollok() are enabled, any attempt to move off
|
43
|
+
the bottom margin will cause all lines in the scrolling region
|
44
|
+
to scroll up one line. setscrreg() is the stdscr version.
|
45
|
+
|
46
|
+
idlok() and idcok() do nothing in PDCurses, but are provided for
|
47
|
+
compatibility with other curses implementations.
|
48
|
+
|
49
|
+
raw_output() enables the output of raw characters using the
|
50
|
+
standard *add* and *ins* curses functions (that is, it disables
|
51
|
+
translation of control characters).
|
52
|
+
|
53
|
+
### Return Value
|
54
|
+
|
55
|
+
All functions return OK on success and ERR on error.
|
56
|
+
|
57
|
+
### Portability
|
58
|
+
X/Open BSD SYS V
|
59
|
+
clearok Y Y Y
|
60
|
+
idlok Y Y Y
|
61
|
+
idcok Y - 4.0
|
62
|
+
immedok Y - 4.0
|
63
|
+
leaveok Y Y Y
|
64
|
+
setscrreg Y Y Y
|
65
|
+
wsetscrreg Y Y Y
|
66
|
+
scrollok Y Y Y
|
67
|
+
raw_output - - -
|
68
|
+
|
69
|
+
**man-end****************************************************************/
|
70
|
+
|
71
|
+
int clearok(WINDOW *win, bool bf)
|
72
|
+
{
|
73
|
+
PDC_LOG(("clearok() - called\n"));
|
74
|
+
|
75
|
+
if (!win)
|
76
|
+
return ERR;
|
77
|
+
|
78
|
+
win->_clear = bf;
|
79
|
+
|
80
|
+
return OK;
|
81
|
+
}
|
82
|
+
|
83
|
+
int idlok(WINDOW *win, bool bf)
|
84
|
+
{
|
85
|
+
PDC_LOG(("idlok() - called\n"));
|
86
|
+
|
87
|
+
return OK;
|
88
|
+
}
|
89
|
+
|
90
|
+
void idcok(WINDOW *win, bool bf)
|
91
|
+
{
|
92
|
+
PDC_LOG(("idcok() - called\n"));
|
93
|
+
}
|
94
|
+
|
95
|
+
void immedok(WINDOW *win, bool bf)
|
96
|
+
{
|
97
|
+
PDC_LOG(("immedok() - called\n"));
|
98
|
+
|
99
|
+
if (win)
|
100
|
+
win->_immed = bf;
|
101
|
+
}
|
102
|
+
|
103
|
+
int leaveok(WINDOW *win, bool bf)
|
104
|
+
{
|
105
|
+
PDC_LOG(("leaveok() - called\n"));
|
106
|
+
|
107
|
+
if (!win)
|
108
|
+
return ERR;
|
109
|
+
|
110
|
+
win->_leaveit = bf;
|
111
|
+
|
112
|
+
curs_set(!bf);
|
113
|
+
|
114
|
+
return OK;
|
115
|
+
}
|
116
|
+
|
117
|
+
int setscrreg(int top, int bottom)
|
118
|
+
{
|
119
|
+
PDC_LOG(("setscrreg() - called: top %d bottom %d\n", top, bottom));
|
120
|
+
|
121
|
+
return wsetscrreg(stdscr, top, bottom);
|
122
|
+
}
|
123
|
+
|
124
|
+
int wsetscrreg(WINDOW *win, int top, int bottom)
|
125
|
+
{
|
126
|
+
PDC_LOG(("wsetscrreg() - called: top %d bottom %d\n", top, bottom));
|
127
|
+
|
128
|
+
if (win && 0 <= top && top <= win->_cury &&
|
129
|
+
win->_cury <= bottom && bottom < win->_maxy)
|
130
|
+
{
|
131
|
+
win->_tmarg = top;
|
132
|
+
win->_bmarg = bottom;
|
133
|
+
|
134
|
+
return OK;
|
135
|
+
}
|
136
|
+
else
|
137
|
+
return ERR;
|
138
|
+
}
|
139
|
+
|
140
|
+
int scrollok(WINDOW *win, bool bf)
|
141
|
+
{
|
142
|
+
PDC_LOG(("scrollok() - called\n"));
|
143
|
+
|
144
|
+
if (!win)
|
145
|
+
return ERR;
|
146
|
+
|
147
|
+
win->_scroll = bf;
|
148
|
+
|
149
|
+
return OK;
|
150
|
+
}
|
151
|
+
|
152
|
+
int raw_output(bool bf)
|
153
|
+
{
|
154
|
+
PDC_LOG(("raw_output() - called\n"));
|
155
|
+
|
156
|
+
SP->raw_out = bf;
|
157
|
+
|
158
|
+
return OK;
|
159
|
+
}
|