curses 1.2.6 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +19 -0
- data/.github/workflows/ubuntu.yml +26 -0
- data/.github/workflows/windows.yml +28 -0
- data/.gitmodules +1 -1
- data/.travis.yml +6 -3
- data/History.md +40 -0
- data/README.md +4 -1
- data/Rakefile +0 -83
- data/curses.gemspec +2 -3
- data/ext/curses/curses.c +1271 -151
- data/ext/curses/extconf.rb +140 -17
- data/lib/curses.rb +5 -12
- data/sample/form.rb +52 -0
- data/sample/menu.rb +1 -1
- 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/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.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/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.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.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.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.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 +255 -21
@@ -0,0 +1,188 @@
|
|
1
|
+
/* Public Domain Curses */
|
2
|
+
|
3
|
+
#include "pdcos2.h"
|
4
|
+
|
5
|
+
/*man-start**************************************************************
|
6
|
+
|
7
|
+
clipboard
|
8
|
+
---------
|
9
|
+
|
10
|
+
### Synopsis
|
11
|
+
|
12
|
+
int PDC_getclipboard(char **contents, long *length);
|
13
|
+
int PDC_setclipboard(const char *contents, long length);
|
14
|
+
int PDC_freeclipboard(char *contents);
|
15
|
+
int PDC_clearclipboard(void);
|
16
|
+
|
17
|
+
### Description
|
18
|
+
|
19
|
+
PDC_getclipboard() gets the textual contents of the system's
|
20
|
+
clipboard. This function returns the contents of the clipboard
|
21
|
+
in the contents argument. It is the responsibilitiy of the
|
22
|
+
caller to free the memory returned, via PDC_freeclipboard().
|
23
|
+
The length of the clipboard contents is returned in the length
|
24
|
+
argument.
|
25
|
+
|
26
|
+
PDC_setclipboard copies the supplied text into the system's
|
27
|
+
clipboard, emptying the clipboard prior to the copy.
|
28
|
+
|
29
|
+
PDC_clearclipboard() clears the internal clipboard.
|
30
|
+
|
31
|
+
### Return Values
|
32
|
+
|
33
|
+
indicator of success/failure of call.
|
34
|
+
PDC_CLIP_SUCCESS the call was successful
|
35
|
+
PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
|
36
|
+
the clipboard contents
|
37
|
+
PDC_CLIP_EMPTY the clipboard contains no text
|
38
|
+
PDC_CLIP_ACCESS_ERROR no clipboard support
|
39
|
+
|
40
|
+
### Portability
|
41
|
+
X/Open BSD SYS V
|
42
|
+
PDC_getclipboard - - -
|
43
|
+
PDC_setclipboard - - -
|
44
|
+
PDC_freeclipboard - - -
|
45
|
+
PDC_clearclipboard - - -
|
46
|
+
|
47
|
+
**man-end****************************************************************/
|
48
|
+
|
49
|
+
int PDC_getclipboard(char **contents, long *length)
|
50
|
+
{
|
51
|
+
#ifndef EMXVIDEO
|
52
|
+
HMQ hmq;
|
53
|
+
HAB hab;
|
54
|
+
PTIB ptib;
|
55
|
+
PPIB ppib;
|
56
|
+
ULONG ulRet;
|
57
|
+
long len;
|
58
|
+
int rc;
|
59
|
+
#endif
|
60
|
+
PDC_LOG(("PDC_getclipboard() - called\n"));
|
61
|
+
|
62
|
+
#ifndef EMXVIDEO
|
63
|
+
DosGetInfoBlocks(&ptib, &ppib);
|
64
|
+
ppib->pib_ultype = 3;
|
65
|
+
hab = WinInitialize(0);
|
66
|
+
hmq = WinCreateMsgQueue(hab, 0);
|
67
|
+
|
68
|
+
if (!WinOpenClipbrd(hab))
|
69
|
+
{
|
70
|
+
WinDestroyMsgQueue(hmq);
|
71
|
+
WinTerminate(hab);
|
72
|
+
return PDC_CLIP_ACCESS_ERROR;
|
73
|
+
}
|
74
|
+
|
75
|
+
rc = PDC_CLIP_EMPTY;
|
76
|
+
|
77
|
+
ulRet = WinQueryClipbrdData(hab, CF_TEXT);
|
78
|
+
|
79
|
+
if (ulRet)
|
80
|
+
{
|
81
|
+
len = strlen((char *)ulRet);
|
82
|
+
*contents = malloc(len + 1);
|
83
|
+
|
84
|
+
if (!*contents)
|
85
|
+
rc = PDC_CLIP_MEMORY_ERROR;
|
86
|
+
else
|
87
|
+
{
|
88
|
+
strcpy((char *)*contents, (char *)ulRet);
|
89
|
+
*length = len;
|
90
|
+
rc = PDC_CLIP_SUCCESS;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
WinCloseClipbrd(hab);
|
95
|
+
WinDestroyMsgQueue(hmq);
|
96
|
+
WinTerminate(hab);
|
97
|
+
|
98
|
+
return rc;
|
99
|
+
#else
|
100
|
+
return PDC_CLIP_ACCESS_ERROR;
|
101
|
+
#endif
|
102
|
+
}
|
103
|
+
|
104
|
+
int PDC_setclipboard(const char *contents, long length)
|
105
|
+
{
|
106
|
+
#ifndef EMXVIDEO
|
107
|
+
HAB hab;
|
108
|
+
PTIB ptib;
|
109
|
+
PPIB ppib;
|
110
|
+
ULONG ulRC;
|
111
|
+
PSZ szTextOut = NULL;
|
112
|
+
int rc;
|
113
|
+
#endif
|
114
|
+
PDC_LOG(("PDC_setclipboard() - called\n"));
|
115
|
+
|
116
|
+
#ifndef EMXVIDEO
|
117
|
+
DosGetInfoBlocks(&ptib, &ppib);
|
118
|
+
ppib->pib_ultype = 3;
|
119
|
+
hab = WinInitialize(0);
|
120
|
+
|
121
|
+
if (!WinOpenClipbrd(hab))
|
122
|
+
{
|
123
|
+
WinTerminate(hab);
|
124
|
+
return PDC_CLIP_ACCESS_ERROR;
|
125
|
+
}
|
126
|
+
|
127
|
+
rc = PDC_CLIP_MEMORY_ERROR;
|
128
|
+
|
129
|
+
ulRC = DosAllocSharedMem((PVOID)&szTextOut, NULL, length + 1,
|
130
|
+
PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE);
|
131
|
+
|
132
|
+
if (ulRC == 0)
|
133
|
+
{
|
134
|
+
strcpy(szTextOut, contents);
|
135
|
+
WinEmptyClipbrd(hab);
|
136
|
+
|
137
|
+
if (WinSetClipbrdData(hab, (ULONG)szTextOut, CF_TEXT, CFI_POINTER))
|
138
|
+
rc = PDC_CLIP_SUCCESS;
|
139
|
+
else
|
140
|
+
{
|
141
|
+
DosFreeMem(szTextOut);
|
142
|
+
rc = PDC_CLIP_ACCESS_ERROR;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
WinCloseClipbrd(hab);
|
147
|
+
WinTerminate(hab);
|
148
|
+
|
149
|
+
return rc;
|
150
|
+
#else
|
151
|
+
return PDC_CLIP_ACCESS_ERROR;
|
152
|
+
#endif
|
153
|
+
}
|
154
|
+
|
155
|
+
int PDC_freeclipboard(char *contents)
|
156
|
+
{
|
157
|
+
PDC_LOG(("PDC_freeclipboard() - called\n"));
|
158
|
+
|
159
|
+
if (contents)
|
160
|
+
free(contents);
|
161
|
+
|
162
|
+
return PDC_CLIP_SUCCESS;
|
163
|
+
}
|
164
|
+
|
165
|
+
int PDC_clearclipboard(void)
|
166
|
+
{
|
167
|
+
#ifndef EMXVIDEO
|
168
|
+
HAB hab;
|
169
|
+
PTIB ptib;
|
170
|
+
PPIB ppib;
|
171
|
+
#endif
|
172
|
+
PDC_LOG(("PDC_clearclipboard() - called\n"));
|
173
|
+
|
174
|
+
#ifndef EMXVIDEO
|
175
|
+
DosGetInfoBlocks(&ptib, &ppib);
|
176
|
+
ppib->pib_ultype = 3;
|
177
|
+
hab = WinInitialize(0);
|
178
|
+
|
179
|
+
WinEmptyClipbrd(hab);
|
180
|
+
|
181
|
+
WinCloseClipbrd(hab);
|
182
|
+
WinTerminate(hab);
|
183
|
+
|
184
|
+
return PDC_CLIP_SUCCESS;
|
185
|
+
#else
|
186
|
+
return PDC_CLIP_ACCESS_ERROR;
|
187
|
+
#endif
|
188
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/* Public Domain Curses */
|
2
|
+
|
3
|
+
#include "pdcos2.h"
|
4
|
+
|
5
|
+
/* ACS definitions originally by jshumate@wrdis01.robins.af.mil -- these
|
6
|
+
match code page 437 and compatible pages (CP850, CP852, etc.) */
|
7
|
+
|
8
|
+
#ifdef CHTYPE_LONG
|
9
|
+
|
10
|
+
# define A(x) ((chtype)x | A_ALTCHARSET)
|
11
|
+
|
12
|
+
chtype acs_map[128] =
|
13
|
+
{
|
14
|
+
A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9),
|
15
|
+
A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
|
16
|
+
A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27),
|
17
|
+
A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
|
18
|
+
'\'', '(', ')', '*',
|
19
|
+
|
20
|
+
A(0x1a), A(0x1b), A(0x18), A(0x19),
|
21
|
+
|
22
|
+
'/',
|
23
|
+
|
24
|
+
0xdb,
|
25
|
+
|
26
|
+
'1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
|
27
|
+
'>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
|
28
|
+
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
29
|
+
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
30
|
+
|
31
|
+
A(0x04), 0xb1,
|
32
|
+
|
33
|
+
'b', 'c', 'd', 'e',
|
34
|
+
|
35
|
+
0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
|
36
|
+
0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3,
|
37
|
+
0xf2, 0xe3, 0xd8, 0x9c, 0xf9,
|
38
|
+
|
39
|
+
A(127)
|
40
|
+
};
|
41
|
+
|
42
|
+
# undef A
|
43
|
+
|
44
|
+
#endif
|
45
|
+
|
46
|
+
/* position hardware cursor at (y, x) */
|
47
|
+
|
48
|
+
void PDC_gotoyx(int row, int col)
|
49
|
+
{
|
50
|
+
PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
|
51
|
+
|
52
|
+
#ifdef EMXVIDEO
|
53
|
+
v_gotoxy(col, row);
|
54
|
+
#else
|
55
|
+
VioSetCurPos(row, col, 0);
|
56
|
+
#endif
|
57
|
+
}
|
58
|
+
|
59
|
+
/* update the given physical line to look like the corresponding line in
|
60
|
+
curscr */
|
61
|
+
|
62
|
+
void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
63
|
+
{
|
64
|
+
/* this should be enough for the maximum width of a screen. */
|
65
|
+
|
66
|
+
struct {unsigned char text, attr;} temp_line[256];
|
67
|
+
int j;
|
68
|
+
|
69
|
+
PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
|
70
|
+
|
71
|
+
/* replace the attribute part of the chtype with the
|
72
|
+
actual color value for each chtype in the line */
|
73
|
+
|
74
|
+
for (j = 0; j < len; j++)
|
75
|
+
{
|
76
|
+
chtype ch = srcp[j];
|
77
|
+
|
78
|
+
temp_line[j].attr = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
|
79
|
+
|
80
|
+
#ifdef CHTYPE_LONG
|
81
|
+
if (ch & A_ALTCHARSET && !(ch & 0xff80))
|
82
|
+
ch = acs_map[ch & 0x7f];
|
83
|
+
#endif
|
84
|
+
temp_line[j].text = ch & 0xff;
|
85
|
+
}
|
86
|
+
|
87
|
+
#ifdef EMXVIDEO
|
88
|
+
v_putline((char *)temp_line, x, lineno, len);
|
89
|
+
#else
|
90
|
+
VioWrtCellStr((PCH)temp_line, (USHORT)(len * sizeof(unsigned short)),
|
91
|
+
(USHORT)lineno, (USHORT)x, 0);
|
92
|
+
#endif
|
93
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/* Public Domain Curses */
|
2
|
+
|
3
|
+
#include "pdcos2.h"
|
4
|
+
|
5
|
+
/* return width of screen/viewport */
|
6
|
+
|
7
|
+
int PDC_get_columns(void)
|
8
|
+
{
|
9
|
+
#ifdef EMXVIDEO
|
10
|
+
int rows = 0;
|
11
|
+
#else
|
12
|
+
VIOMODEINFO modeInfo = {0};
|
13
|
+
#endif
|
14
|
+
int cols = 0;
|
15
|
+
const char *env_cols;
|
16
|
+
|
17
|
+
PDC_LOG(("PDC_get_columns() - called\n"));
|
18
|
+
|
19
|
+
#ifdef EMXVIDEO
|
20
|
+
v_dimen(&cols, &rows);
|
21
|
+
#else
|
22
|
+
modeInfo.cb = sizeof(modeInfo);
|
23
|
+
VioGetMode(&modeInfo, 0);
|
24
|
+
cols = modeInfo.col;
|
25
|
+
#endif
|
26
|
+
env_cols = getenv("COLS");
|
27
|
+
|
28
|
+
if (env_cols)
|
29
|
+
cols = min(atoi(env_cols), cols);
|
30
|
+
|
31
|
+
PDC_LOG(("PDC_get_columns() - returned: cols %d\n", cols));
|
32
|
+
|
33
|
+
return cols;
|
34
|
+
}
|
35
|
+
|
36
|
+
/* get the cursor size/shape */
|
37
|
+
|
38
|
+
int PDC_get_cursor_mode(void)
|
39
|
+
{
|
40
|
+
#ifdef EMXVIDEO
|
41
|
+
int curstart = 0, curend = 0;
|
42
|
+
#else
|
43
|
+
VIOCURSORINFO cursorInfo;
|
44
|
+
#endif
|
45
|
+
PDC_LOG(("PDC_get_cursor_mode() - called\n"));
|
46
|
+
|
47
|
+
#ifdef EMXVIDEO
|
48
|
+
v_getctype(&curstart, &curend);
|
49
|
+
return (curstart << 8) | curend;
|
50
|
+
#else
|
51
|
+
VioGetCurType (&cursorInfo, 0);
|
52
|
+
|
53
|
+
return (cursorInfo.yStart << 8) | cursorInfo.cEnd;
|
54
|
+
#endif
|
55
|
+
}
|
56
|
+
|
57
|
+
/* return number of screen rows */
|
58
|
+
|
59
|
+
int PDC_get_rows(void)
|
60
|
+
{
|
61
|
+
#ifdef EMXVIDEO
|
62
|
+
int cols = 0;
|
63
|
+
#else
|
64
|
+
VIOMODEINFO modeInfo = {0};
|
65
|
+
#endif
|
66
|
+
int rows = 0;
|
67
|
+
const char *env_rows;
|
68
|
+
|
69
|
+
PDC_LOG(("PDC_get_rows() - called\n"));
|
70
|
+
|
71
|
+
/* use the value from LINES environment variable, if set. MH 10-Jun-92 */
|
72
|
+
/* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */
|
73
|
+
|
74
|
+
#ifdef EMXVIDEO
|
75
|
+
v_dimen(&cols, &rows);
|
76
|
+
#else
|
77
|
+
modeInfo.cb = sizeof(modeInfo);
|
78
|
+
VioGetMode(&modeInfo, 0);
|
79
|
+
rows = modeInfo.row;
|
80
|
+
#endif
|
81
|
+
env_rows = getenv("LINES");
|
82
|
+
|
83
|
+
if (env_rows)
|
84
|
+
rows = min(atoi(env_rows), rows);
|
85
|
+
|
86
|
+
PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));
|
87
|
+
|
88
|
+
return rows;
|
89
|
+
}
|
@@ -0,0 +1,521 @@
|
|
1
|
+
/* Public Domain Curses */
|
2
|
+
|
3
|
+
#if defined(__EMX__) || defined(__WATCOMC__) || defined(__IBMC__) || \
|
4
|
+
defined(__TURBOC__)
|
5
|
+
# define HAVE_SIGNAL
|
6
|
+
# include <signal.h>
|
7
|
+
#endif
|
8
|
+
|
9
|
+
#include "pdcos2.h"
|
10
|
+
|
11
|
+
/*man-start**************************************************************
|
12
|
+
|
13
|
+
pdckbd
|
14
|
+
------
|
15
|
+
|
16
|
+
### Synopsis
|
17
|
+
|
18
|
+
unsigned long PDC_get_input_fd(void);
|
19
|
+
|
20
|
+
### Description
|
21
|
+
|
22
|
+
PDC_get_input_fd() returns the file descriptor that PDCurses
|
23
|
+
reads its input from. It can be used for select().
|
24
|
+
|
25
|
+
### Portability
|
26
|
+
X/Open BSD SYS V
|
27
|
+
PDC_get_input_fd - - -
|
28
|
+
|
29
|
+
**man-end****************************************************************/
|
30
|
+
|
31
|
+
#ifdef EMXVIDEO
|
32
|
+
# include <termios.h>
|
33
|
+
static int tahead = -1;
|
34
|
+
#else
|
35
|
+
static KBDINFO kbdinfo; /* default keyboard mode */
|
36
|
+
static HMOU mouse_handle = 0;
|
37
|
+
static MOUSE_STATUS old_mouse_status;
|
38
|
+
static USHORT old_shift = 0;
|
39
|
+
static bool key_pressed = FALSE;
|
40
|
+
static int mouse_events = 0;
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/************************************************************************
|
44
|
+
* Table for key code translation of function keys in keypad mode *
|
45
|
+
* These values are for strict IBM keyboard compatibles only *
|
46
|
+
************************************************************************/
|
47
|
+
|
48
|
+
static short key_table[] =
|
49
|
+
{
|
50
|
+
-1, ALT_ESC, -1, 0,
|
51
|
+
-1, -1, -1, -1,
|
52
|
+
-1, -1, -1, -1,
|
53
|
+
-1, -1, ALT_BKSP, KEY_BTAB,
|
54
|
+
ALT_Q, ALT_W, ALT_E, ALT_R,
|
55
|
+
ALT_T, ALT_Y, ALT_U, ALT_I,
|
56
|
+
ALT_O, ALT_P, ALT_LBRACKET, ALT_RBRACKET,
|
57
|
+
ALT_ENTER, -1, ALT_A, ALT_S,
|
58
|
+
ALT_D, ALT_F, ALT_G, ALT_H,
|
59
|
+
ALT_J, ALT_K, ALT_L, ALT_SEMICOLON,
|
60
|
+
ALT_FQUOTE, ALT_BQUOTE, -1, ALT_BSLASH,
|
61
|
+
ALT_Z, ALT_X, ALT_C, ALT_V,
|
62
|
+
ALT_B, ALT_N, ALT_M, ALT_COMMA,
|
63
|
+
ALT_STOP, ALT_FSLASH, -1, ALT_PADSTAR,
|
64
|
+
-1, -1, -1, KEY_F(1),
|
65
|
+
KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
|
66
|
+
KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9),
|
67
|
+
KEY_F(10), -1, -1, KEY_HOME,
|
68
|
+
KEY_UP, KEY_PPAGE, ALT_PADMINUS, KEY_LEFT,
|
69
|
+
KEY_B2, KEY_RIGHT, ALT_PADPLUS, KEY_END,
|
70
|
+
KEY_DOWN, KEY_NPAGE, KEY_IC, KEY_DC,
|
71
|
+
KEY_F(13), KEY_F(14), KEY_F(15), KEY_F(16),
|
72
|
+
KEY_F(17), KEY_F(18), KEY_F(19), KEY_F(20),
|
73
|
+
KEY_F(21), KEY_F(22), KEY_F(25), KEY_F(26),
|
74
|
+
KEY_F(27), KEY_F(28), KEY_F(29), KEY_F(30),
|
75
|
+
KEY_F(31), KEY_F(32), KEY_F(33), KEY_F(34),
|
76
|
+
KEY_F(37), KEY_F(38), KEY_F(39), KEY_F(40),
|
77
|
+
KEY_F(41), KEY_F(42), KEY_F(43), KEY_F(44),
|
78
|
+
KEY_F(45), KEY_F(46), -1, CTL_LEFT,
|
79
|
+
CTL_RIGHT, CTL_END, CTL_PGDN, CTL_HOME,
|
80
|
+
ALT_1, ALT_2, ALT_3, ALT_4,
|
81
|
+
ALT_5, ALT_6, ALT_7, ALT_8,
|
82
|
+
ALT_9, ALT_0, ALT_MINUS, ALT_EQUAL,
|
83
|
+
CTL_PGUP, KEY_F(11), KEY_F(12), KEY_F(23),
|
84
|
+
KEY_F(24), KEY_F(35), KEY_F(36), KEY_F(47),
|
85
|
+
KEY_F(48), CTL_UP, CTL_PADMINUS, CTL_PADCENTER,
|
86
|
+
CTL_PADPLUS, CTL_DOWN, CTL_INS, CTL_DEL,
|
87
|
+
CTL_TAB, CTL_PADSLASH, CTL_PADSTAR, ALT_HOME,
|
88
|
+
ALT_UP, ALT_PGUP, -1, ALT_LEFT,
|
89
|
+
-1, ALT_RIGHT, -1, ALT_END,
|
90
|
+
ALT_DOWN, ALT_PGDN, ALT_INS, ALT_DEL,
|
91
|
+
ALT_PADSLASH, ALT_TAB, ALT_PADENTER, -1
|
92
|
+
};
|
93
|
+
|
94
|
+
unsigned long pdc_key_modifiers = 0L;
|
95
|
+
|
96
|
+
unsigned long PDC_get_input_fd(void)
|
97
|
+
{
|
98
|
+
PDC_LOG(("PDC_get_input_fd() - called\n"));
|
99
|
+
|
100
|
+
return (unsigned long)fileno(stdin);
|
101
|
+
}
|
102
|
+
|
103
|
+
#ifndef EMXVIDEO
|
104
|
+
|
105
|
+
void PDC_get_keyboard_info(void)
|
106
|
+
{
|
107
|
+
kbdinfo.cb = sizeof(kbdinfo);
|
108
|
+
KbdGetStatus(&kbdinfo, 0);
|
109
|
+
}
|
110
|
+
|
111
|
+
void PDC_set_keyboard_default(void)
|
112
|
+
{
|
113
|
+
KbdSetStatus(&kbdinfo, 0);
|
114
|
+
}
|
115
|
+
|
116
|
+
#endif /* ifndef EMXVIDEO */
|
117
|
+
|
118
|
+
void PDC_set_keyboard_binary(bool on)
|
119
|
+
{
|
120
|
+
PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
|
121
|
+
|
122
|
+
#ifndef EMXVIDEO
|
123
|
+
if (on)
|
124
|
+
{
|
125
|
+
kbdinfo.fsMask &= ~(KEYBOARD_ASCII_MODE);
|
126
|
+
kbdinfo.fsMask |= KEYBOARD_BINARY_MODE;
|
127
|
+
}
|
128
|
+
else
|
129
|
+
{
|
130
|
+
kbdinfo.fsMask &= ~(KEYBOARD_BINARY_MODE);
|
131
|
+
kbdinfo.fsMask |= KEYBOARD_ASCII_MODE;
|
132
|
+
}
|
133
|
+
|
134
|
+
KbdSetStatus(&kbdinfo, 0);
|
135
|
+
#endif
|
136
|
+
|
137
|
+
#ifdef HAVE_SIGNAL
|
138
|
+
signal(SIGBREAK, on ? SIG_IGN : SIG_DFL);
|
139
|
+
#endif
|
140
|
+
}
|
141
|
+
|
142
|
+
/* check if a key or mouse event is waiting */
|
143
|
+
|
144
|
+
bool PDC_check_key(void)
|
145
|
+
{
|
146
|
+
#if !defined(_MSC_VER) && !defined(EMXVIDEO)
|
147
|
+
KBDKEYINFO keyInfo = {0};
|
148
|
+
#endif
|
149
|
+
|
150
|
+
#ifdef EMXVIDEO
|
151
|
+
if (tahead == -1) /* Nothing typed yet */
|
152
|
+
{
|
153
|
+
tahead = _read_kbd(0, 0, 0);
|
154
|
+
|
155
|
+
/* Read additional */
|
156
|
+
|
157
|
+
if (tahead == 0)
|
158
|
+
tahead = _read_kbd(0, 1, 0) << 8;
|
159
|
+
}
|
160
|
+
|
161
|
+
return (tahead != -1);
|
162
|
+
#else
|
163
|
+
# ifndef _MSC_VER
|
164
|
+
|
165
|
+
KbdGetStatus(&kbdinfo, 0);
|
166
|
+
|
167
|
+
if (mouse_handle)
|
168
|
+
{
|
169
|
+
MOUQUEINFO queue;
|
170
|
+
|
171
|
+
MouGetNumQueEl(&queue, mouse_handle);
|
172
|
+
mouse_events = queue.cEvents;
|
173
|
+
|
174
|
+
if (mouse_events)
|
175
|
+
return TRUE;
|
176
|
+
}
|
177
|
+
|
178
|
+
if (old_shift && !kbdinfo.fsState) /* modifier released */
|
179
|
+
{
|
180
|
+
if (!key_pressed && SP->return_key_modifiers)
|
181
|
+
return TRUE;
|
182
|
+
}
|
183
|
+
else if (!old_shift && kbdinfo.fsState) /* modifier pressed */
|
184
|
+
key_pressed = FALSE;
|
185
|
+
|
186
|
+
old_shift = kbdinfo.fsState;
|
187
|
+
|
188
|
+
KbdPeek(&keyInfo, 0); /* peek at keyboard */
|
189
|
+
return (keyInfo.fbStatus != 0);
|
190
|
+
# else
|
191
|
+
return kbhit();
|
192
|
+
# endif
|
193
|
+
#endif
|
194
|
+
}
|
195
|
+
|
196
|
+
#ifndef EMXVIDEO
|
197
|
+
|
198
|
+
static int _process_mouse_events(void)
|
199
|
+
{
|
200
|
+
MOUEVENTINFO event;
|
201
|
+
static const USHORT button_mask[] = {6, 96, 24},
|
202
|
+
move_mask[] = {2, 32, 8},
|
203
|
+
press_mask[] = {4, 64, 16};
|
204
|
+
USHORT count = 1;
|
205
|
+
short shift_flags = 0;
|
206
|
+
int i;
|
207
|
+
|
208
|
+
MouReadEventQue(&event, &count, mouse_handle);
|
209
|
+
mouse_events--;
|
210
|
+
|
211
|
+
for (i = 0; i < 3; i++)
|
212
|
+
{
|
213
|
+
pdc_mouse_status.button[i] =
|
214
|
+
((event.fs & move_mask[i]) ? BUTTON_MOVED : 0) |
|
215
|
+
((event.fs & press_mask[i]) ? BUTTON_PRESSED : 0);
|
216
|
+
|
217
|
+
/* PRESS events are sometimes mistakenly reported as MOVE
|
218
|
+
events. A MOVE should always follow a PRESS, so treat a MOVE
|
219
|
+
immediately after a RELEASE as a PRESS. */
|
220
|
+
|
221
|
+
if ((pdc_mouse_status.button[i] == BUTTON_MOVED) &&
|
222
|
+
(old_mouse_status.button[i] == BUTTON_RELEASED))
|
223
|
+
{
|
224
|
+
pdc_mouse_status.button[i] = BUTTON_PRESSED;
|
225
|
+
}
|
226
|
+
|
227
|
+
if (pdc_mouse_status.button[i] == BUTTON_PRESSED && SP->mouse_wait)
|
228
|
+
{
|
229
|
+
/* Check for a click -- a PRESS followed immediately by a
|
230
|
+
release */
|
231
|
+
|
232
|
+
if (!mouse_events)
|
233
|
+
{
|
234
|
+
MOUQUEINFO queue;
|
235
|
+
|
236
|
+
napms(SP->mouse_wait);
|
237
|
+
|
238
|
+
MouGetNumQueEl(&queue, mouse_handle);
|
239
|
+
mouse_events = queue.cEvents;
|
240
|
+
}
|
241
|
+
|
242
|
+
if (mouse_events)
|
243
|
+
{
|
244
|
+
MouReadEventQue(&event, &count, mouse_handle);
|
245
|
+
|
246
|
+
if (!(event.fs & button_mask[i]))
|
247
|
+
pdc_mouse_status.button[i] = BUTTON_CLICKED;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
pdc_mouse_status.x = event.col;
|
253
|
+
pdc_mouse_status.y = event.row;
|
254
|
+
|
255
|
+
pdc_mouse_status.changes = 0;
|
256
|
+
|
257
|
+
for (i = 0; i < 3; i++)
|
258
|
+
{
|
259
|
+
if (old_mouse_status.button[i] != pdc_mouse_status.button[i])
|
260
|
+
pdc_mouse_status.changes |= (1 << i);
|
261
|
+
|
262
|
+
if (pdc_mouse_status.button[i] == BUTTON_MOVED)
|
263
|
+
{
|
264
|
+
/* Discard non-moved "moves" */
|
265
|
+
|
266
|
+
if (pdc_mouse_status.x == old_mouse_status.x &&
|
267
|
+
pdc_mouse_status.y == old_mouse_status.y)
|
268
|
+
return -1;
|
269
|
+
|
270
|
+
/* Motion events always flag the button as changed */
|
271
|
+
|
272
|
+
pdc_mouse_status.changes |= (1 << i);
|
273
|
+
pdc_mouse_status.changes |= PDC_MOUSE_MOVED;
|
274
|
+
break;
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
old_mouse_status = pdc_mouse_status;
|
279
|
+
|
280
|
+
/* Treat click events as release events for comparison purposes */
|
281
|
+
|
282
|
+
for (i = 0; i < 3; i++)
|
283
|
+
{
|
284
|
+
if (old_mouse_status.button[i] == BUTTON_CLICKED)
|
285
|
+
old_mouse_status.button[i] = BUTTON_RELEASED;
|
286
|
+
}
|
287
|
+
|
288
|
+
/* Check for SHIFT/CONTROL/ALT */
|
289
|
+
|
290
|
+
if (kbdinfo.fsState & KBDSTF_ALT)
|
291
|
+
shift_flags |= BUTTON_ALT;
|
292
|
+
|
293
|
+
if (kbdinfo.fsState & KBDSTF_CONTROL)
|
294
|
+
shift_flags |= BUTTON_CONTROL;
|
295
|
+
|
296
|
+
if (kbdinfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
|
297
|
+
shift_flags |= BUTTON_SHIFT;
|
298
|
+
|
299
|
+
if (shift_flags)
|
300
|
+
{
|
301
|
+
for (i = 0; i < 3; i++)
|
302
|
+
{
|
303
|
+
if (pdc_mouse_status.changes & (1 << i))
|
304
|
+
pdc_mouse_status.button[i] |= shift_flags;
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
old_shift = kbdinfo.fsState;
|
309
|
+
key_pressed = TRUE;
|
310
|
+
|
311
|
+
SP->key_code = TRUE;
|
312
|
+
return KEY_MOUSE;
|
313
|
+
}
|
314
|
+
|
315
|
+
#endif
|
316
|
+
|
317
|
+
/* return the next available key or mouse event */
|
318
|
+
|
319
|
+
int PDC_get_key(void)
|
320
|
+
{
|
321
|
+
int key, scan;
|
322
|
+
#ifndef EMXVIDEO
|
323
|
+
KBDKEYINFO keyInfo = {0};
|
324
|
+
#endif
|
325
|
+
|
326
|
+
#ifdef EMXVIDEO
|
327
|
+
if (tahead == -1)
|
328
|
+
{
|
329
|
+
tahead = _read_kbd(0, 1, 0);
|
330
|
+
|
331
|
+
/* Read additional */
|
332
|
+
|
333
|
+
if (tahead == 0)
|
334
|
+
tahead = _read_kbd(0, 1, 0) << 8;
|
335
|
+
}
|
336
|
+
|
337
|
+
key = tahead & 0xff;
|
338
|
+
scan = tahead >> 8;
|
339
|
+
pdc_key_modifiers = 0L;
|
340
|
+
|
341
|
+
tahead = -1;
|
342
|
+
#else
|
343
|
+
pdc_key_modifiers = 0L;
|
344
|
+
|
345
|
+
if (mouse_handle && mouse_events)
|
346
|
+
return _process_mouse_events();
|
347
|
+
|
348
|
+
if (old_shift && !kbdinfo.fsState)
|
349
|
+
{
|
350
|
+
key = -1;
|
351
|
+
|
352
|
+
if (old_shift & KBDSTF_LEFTALT)
|
353
|
+
{
|
354
|
+
key = KEY_ALT_L;
|
355
|
+
}
|
356
|
+
else if (old_shift & KBDSTF_RIGHTALT)
|
357
|
+
{
|
358
|
+
key = KEY_ALT_R;
|
359
|
+
}
|
360
|
+
else if (old_shift & KBDSTF_LEFTCONTROL)
|
361
|
+
{
|
362
|
+
key = KEY_CONTROL_L;
|
363
|
+
}
|
364
|
+
else if (old_shift & KBDSTF_RIGHTCONTROL)
|
365
|
+
{
|
366
|
+
key = KEY_CONTROL_R;
|
367
|
+
}
|
368
|
+
else if (old_shift & KBDSTF_LEFTSHIFT)
|
369
|
+
{
|
370
|
+
key = KEY_SHIFT_L;
|
371
|
+
}
|
372
|
+
else if (old_shift & KBDSTF_RIGHTSHIFT)
|
373
|
+
{
|
374
|
+
key = KEY_SHIFT_R;
|
375
|
+
}
|
376
|
+
|
377
|
+
key_pressed = FALSE;
|
378
|
+
old_shift = kbdinfo.fsState;
|
379
|
+
|
380
|
+
SP->key_code = TRUE;
|
381
|
+
return key;
|
382
|
+
}
|
383
|
+
|
384
|
+
KbdCharIn(&keyInfo, IO_WAIT, 0); /* get a character */
|
385
|
+
|
386
|
+
key = keyInfo.chChar;
|
387
|
+
scan = keyInfo.chScan;
|
388
|
+
|
389
|
+
if (SP->save_key_modifiers)
|
390
|
+
{
|
391
|
+
if (keyInfo.fsState & KBDSTF_ALT)
|
392
|
+
pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
|
393
|
+
|
394
|
+
if (keyInfo.fsState & KBDSTF_CONTROL)
|
395
|
+
pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
|
396
|
+
|
397
|
+
if (keyInfo.fsState & KBDSTF_NUMLOCK_ON)
|
398
|
+
pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
|
399
|
+
|
400
|
+
if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
|
401
|
+
pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
|
402
|
+
}
|
403
|
+
#endif
|
404
|
+
if (scan == 0x1c && key == 0x0a) /* ^Enter */
|
405
|
+
key = CTL_ENTER;
|
406
|
+
else if (scan == 0xe0 && key == 0x0d) /* PadEnter */
|
407
|
+
key = PADENTER;
|
408
|
+
else if (scan == 0xe0 && key == 0x0a) /* ^PadEnter */
|
409
|
+
key = CTL_PADENTER;
|
410
|
+
else if (scan == 0x37 && key == 0x2a) /* Star */
|
411
|
+
key = PADSTAR;
|
412
|
+
else if (scan == 0x4a && key == 0x2d) /* Minus */
|
413
|
+
key = PADMINUS;
|
414
|
+
else if (scan == 0x4e && key == 0x2b) /* Plus */
|
415
|
+
key = PADPLUS;
|
416
|
+
else if (scan == 0xe0 && key == 0x2f) /* Slash */
|
417
|
+
key = PADSLASH;
|
418
|
+
else if (key == 0x00 || (key == 0xe0 && scan > 53 && scan != 86))
|
419
|
+
key = (scan > 0xa7) ? -1 : key_table[scan];
|
420
|
+
|
421
|
+
if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
|
422
|
+
{
|
423
|
+
switch (key)
|
424
|
+
{
|
425
|
+
case KEY_HOME: /* Shift Home */
|
426
|
+
key = KEY_SHOME;
|
427
|
+
break;
|
428
|
+
case KEY_UP: /* Shift Up */
|
429
|
+
key = KEY_SUP;
|
430
|
+
break;
|
431
|
+
case KEY_PPAGE: /* Shift PgUp */
|
432
|
+
key = KEY_SPREVIOUS;
|
433
|
+
break;
|
434
|
+
case KEY_LEFT: /* Shift Left */
|
435
|
+
key = KEY_SLEFT;
|
436
|
+
break;
|
437
|
+
case KEY_RIGHT: /* Shift Right */
|
438
|
+
key = KEY_SRIGHT;
|
439
|
+
break;
|
440
|
+
case KEY_END: /* Shift End */
|
441
|
+
key = KEY_SEND;
|
442
|
+
break;
|
443
|
+
case KEY_DOWN: /* Shift Down */
|
444
|
+
key = KEY_SDOWN;
|
445
|
+
break;
|
446
|
+
case KEY_NPAGE: /* Shift PgDn */
|
447
|
+
key = KEY_SNEXT;
|
448
|
+
break;
|
449
|
+
case KEY_IC: /* Shift Ins */
|
450
|
+
key = KEY_SIC;
|
451
|
+
break;
|
452
|
+
case KEY_DC: /* Shift Del */
|
453
|
+
key = KEY_SDC;
|
454
|
+
}
|
455
|
+
}
|
456
|
+
|
457
|
+
key_pressed = TRUE;
|
458
|
+
SP->key_code = ((unsigned)key >= 256);
|
459
|
+
|
460
|
+
return key;
|
461
|
+
}
|
462
|
+
|
463
|
+
/* discard any pending keyboard or mouse input -- this is the core
|
464
|
+
routine for flushinp() */
|
465
|
+
|
466
|
+
void PDC_flushinp(void)
|
467
|
+
{
|
468
|
+
PDC_LOG(("PDC_flushinp() - called\n"));
|
469
|
+
|
470
|
+
#ifdef EMXVIDEO
|
471
|
+
tcflush(0, TCIFLUSH);
|
472
|
+
#else
|
473
|
+
if (mouse_handle)
|
474
|
+
MouFlushQue(mouse_handle);
|
475
|
+
|
476
|
+
KbdFlushBuffer(0);
|
477
|
+
#endif
|
478
|
+
}
|
479
|
+
|
480
|
+
int PDC_mouse_set(void)
|
481
|
+
{
|
482
|
+
#ifndef EMXVIDEO
|
483
|
+
|
484
|
+
unsigned long mbe = SP->_trap_mbe;
|
485
|
+
|
486
|
+
if (mbe && !mouse_handle)
|
487
|
+
{
|
488
|
+
memset(&old_mouse_status, 0, sizeof(MOUSE_STATUS));
|
489
|
+
MouOpen(NULL, &mouse_handle);
|
490
|
+
if (mouse_handle)
|
491
|
+
MouDrawPtr(mouse_handle);
|
492
|
+
}
|
493
|
+
else if (!mbe && mouse_handle)
|
494
|
+
{
|
495
|
+
MouClose(mouse_handle);
|
496
|
+
mouse_handle = 0;
|
497
|
+
}
|
498
|
+
|
499
|
+
if (mbe && mouse_handle)
|
500
|
+
{
|
501
|
+
USHORT mask = ((mbe & (BUTTON1_PRESSED | BUTTON1_CLICKED |
|
502
|
+
BUTTON1_MOVED)) ? 6 : 0) |
|
503
|
+
|
504
|
+
((mbe & (BUTTON3_PRESSED | BUTTON3_CLICKED |
|
505
|
+
BUTTON3_MOVED)) ? 24 : 0) |
|
506
|
+
|
507
|
+
((mbe & (BUTTON2_PRESSED | BUTTON2_CLICKED |
|
508
|
+
BUTTON2_MOVED)) ? 96 : 0);
|
509
|
+
|
510
|
+
MouSetEventMask(&mask, mouse_handle);
|
511
|
+
}
|
512
|
+
#endif
|
513
|
+
return OK;
|
514
|
+
}
|
515
|
+
|
516
|
+
int PDC_modifiers_set(void)
|
517
|
+
{
|
518
|
+
key_pressed = FALSE;
|
519
|
+
|
520
|
+
return OK;
|
521
|
+
}
|