xaizek / vifm-pdcurses (License: mostly public domain) (since 2019-03-20)
PDCurses 3.4 with vifm-specific patches applied (a couple were upstreamed)
Commit 2fbb30894fab0a27bf7473481334783f7faaf59c

Original source of PDCurses 3.4
Author: xaizek
Author date (UTC): 2019-03-20 12:18
Committer name: xaizek
Committer date (UTC): 2019-03-20 12:18
Parent(s):
Signing key: 99DC5E4DB05F6BE2
Tree: c6f89658168dd66e20d3a06961dc3d679be22480
File Lines added Lines deleted
HISTORY 1925 0
IMPLEMNT 325 0
Makefile.in 108 0
PDCurses.spec 52 0
README 48 0
aclocal.m4 613 0
config.guess 1500 0
config.h.in 133 0
config.sub 1616 0
configure 6738 0
configure.ac 285 0
curses.h 1377 0
curspriv.h 142 0
demos/README 25 0
demos/firework.c 148 0
demos/newdemo.c 425 0
demos/ptest.c 285 0
demos/rain.c 159 0
demos/testcurs.c 1144 0
demos/tui.c 821 0
demos/tui.h 67 0
demos/tuidemo.c 233 0
demos/worm.c 434 0
demos/xmas.c 957 0
doc/Makefile 37 0
doc/intro.txt 834 0
doc/manext.c 119 0
doc/sdl.txt 152 0
doc/x11.txt 416 0
dos/README 49 0
dos/bccdos.lrf 9 0
dos/bccdos.mak 82 0
dos/gccdos.mak 87 0
dos/mscdos.lrf 50 0
dos/mscdos.mak 114 0
dos/pdcclip.c 129 0
dos/pdcdisp.c 158 0
dos/pdcdos.h 186 0
dos/pdcgetsc.c 100 0
dos/pdckbd.c 511 0
dos/pdcscrn.c 757 0
dos/pdcsetsc.c 99 0
dos/pdcutil.c 105 0
dos/wccdos16.mak 48 0
dos/wccdos4g.mak 45 0
exp-base.def 374 0
exp-wide.def 90 0
install-sh 253 0
libobjs.mif 26 0
makedist.mif 20 0
os2/README 43 0
os2/bccos2.mak 90 0
os2/gccos2.mak 148 0
os2/iccos2.lrf 50 0
os2/iccos2.mak 256 0
os2/pdcclip.c 185 0
os2/pdcdisp.c 95 0
os2/pdcgetsc.c 91 0
os2/pdckbd.c 519 0
os2/pdcos2.h 51 0
os2/pdcscrn.c 422 0
os2/pdcsetsc.c 110 0
os2/pdcutil.c 36 0
os2/wccos2.mak 43 0
panel.h 58 0
pdcurses/README 25 0
pdcurses/addch.c 408 0
pdcurses/addchstr.c 242 0
pdcurses/addstr.c 237 0
pdcurses/attr.c 349 0
pdcurses/beep.c 65 0
pdcurses/bkgd.c 220 0
pdcurses/border.c 408 0
pdcurses/clear.c 154 0
pdcurses/color.c 295 0
pdcurses/debug.c 81 0
pdcurses/delch.c 93 0
pdcurses/deleteln.c 208 0
pdcurses/deprec.c 29 0
pdcurses/getch.c 410 0
pdcurses/getstr.c 471 0
pdcurses/getyx.c 143 0
pdcurses/inch.c 125 0
pdcurses/inchstr.c 211 0
pdcurses/initscr.c 339 0
pdcurses/inopts.c 321 0
pdcurses/insch.c 268 0
pdcurses/insstr.c 261 0
pdcurses/instr.c 243 0
pdcurses/kernel.c 256 0
pdcurses/keyname.c 125 0
pdcurses/mouse.c 429 0
pdcurses/move.c 54 0
pdcurses/outopts.c 156 0
pdcurses/overlay.c 256 0
pdcurses/pad.c 259 0
pdcurses/panel.c 630 0
pdcurses/printw.c 123 0
pdcurses/refresh.c 276 0
pdcurses/scanw.c 575 0
pdcurses/scr_dump.c 210 0
pdcurses/scroll.c 98 0
pdcurses/slk.c 643 0
pdcurses/termattr.c 176 0
pdcurses/terminfo.c 215 0
pdcurses/touch.c 160 0
pdcurses/util.c 309 0
pdcurses/window.c 562 0
sdl1/Makefile 101 0
sdl1/Makefile.mng 105 0
sdl1/README 33 0
sdl1/deffont.h 385 0
sdl1/deficon.h 23 0
sdl1/pdcclip.c 128 0
sdl1/pdcdisp.c 301 0
sdl1/pdcgetsc.c 32 0
sdl1/pdckbd.c 389 0
sdl1/pdcscrn.c 295 0
sdl1/pdcsdl.h 26 0
sdl1/pdcsetsc.c 62 0
sdl1/pdcutil.c 23 0
sdl1/sdltest.c 81 0
term.h 57 0
version.mif 4 0
watcom.mif 59 0
win32/README 76 0
win32/bccwin32.mak 85 0
win32/dmcwin32.mak 253 0
win32/gccwin32.mak 128 0
win32/lccwin32.mak 273 0
win32/mingwin32.mak 121 0
win32/pdcclip.c 145 0
win32/pdcdisp.c 117 0
win32/pdcgetsc.c 57 0
win32/pdckbd.c 656 0
win32/pdcscrn.c 620 0
win32/pdcsetsc.c 89 0
win32/pdcurses.ico 0 0
win32/pdcurses.rc 28 0
win32/pdcutil.c 25 0
win32/pdcwin.h 17 0
win32/vcwin32.mak 136 0
win32/wccwin32.mak 51 0
x11/Makefile.aix.in 234 0
x11/Makefile.in 572 0
x11/README 64 0
x11/ScrollBox.c 321 0
x11/ScrollBox.h 53 0
x11/ScrollBoxP.h 72 0
x11/big_icon.xbm 46 0
x11/compose.h 203 0
x11/little_icon.xbm 14 0
x11/ncurses_cfg.h 47 0
x11/pdcclip.c 170 0
x11/pdcdisp.c 132 0
x11/pdcgetsc.c 30 0
x11/pdckbd.c 102 0
x11/pdcscrn.c 150 0
x11/pdcsetsc.c 74 0
x11/pdcutil.c 39 0
x11/pdcx11.c 317 0
x11/pdcx11.h 188 0
x11/sb.c 153 0
x11/x11.c 3229 0
x11/xcurses-config.in 76 0
File HISTORY added (mode: 100644) (index 00000000..7cf5b71a)
1 PDCurses 3.4 - 2008/09/08
2 =========================
3
4 Nothing much new this time, but I've been sitting on some bug fixes for
5 almost a year, so it's overdue. Apart from bugs, the main changes are in
6 the documentation.
7
8 New features:
9
10 - setsyx() is now a function rather than a macro.
11
12 Bug fixes and such:
13
14 - In x11, the xc_atrtab table size was under-calculated by half,
15 resulting in crashes at (oddly) certain line counts. (It should've
16 crashed a lot more.) Reported by Mark Hessling.
17
18 - Test for moved cursor was omitting the window origin offset. Reported
19 by Carey Evans.
20
21 - Is DOS and OS/2, the value for max items in key_table was still wrong.
22 Reported by C.E.
23
24 - Changed isendwin() so it won't crash after delscreen().
25
26 - Ensure zero-termination in PDC_mbstowcs() and PDC_wcstombs().
27
28 - Disable QuickEdit Mode when enabling mouse input for the Win32
29 console; reported by "Zalapkrakna".
30
31 - Fix for building under Innotek C (I hope). Report by Elbert Pol, fix
32 courtesy of Paul Smedley.
33
34 - Unified exports list with no duplicates -- pdcurses.def is now built
35 from components at compile time.
36
37 - Don't install curspriv.h, and don't include it with binary
38 distributions.
39
40 - Building DLLs with LCC is no longer supported, due to the primitive
41 nature of its make.exe.
42
43 - Export the terminfo stub functions from the DLLs, too.
44
45 - Added support for Apple's ".dylib" in configure. Suggested by Marc
46 Vaillant (who says it's needed with OS 10.5.)
47
48 - In sdl1/Makefile.mng, ensure that CC is set.
49
50 - In the gcc makefiles, "$?" didn't really have the desired effect --
51 _all_ the dependencies showed up on the command line, including
52 curses.h, and pdcurses.a twice. And apparently, this can mess up some
53 old version (?) of MinGW. So, revert to spelling out "tuidemo.o
54 tui.o". Reported by "Howard L."
55
56 - Extensive documentation revision and reorganizing. More to do here.
57 For example, I moved the build instructions from INSTALL (which never
58 really described installation) to the platform-specific READMEs.
59
60 - New indentation standard: four spaces, no tabs.
61
62 ------------------------------------------------------------------------
63
64 PDCurses 3.3 - 2007/07/11
65 =========================
66
67 This release adds an SDL backend, refines the demos, and is faster in
68 some cases.
69
70 New features:
71
72 - SDL port. See INSTALL, doc/sdl.txt and sdl1/* for details.
73
74 - Double-buffering -- minimize screen writes by checking, in doupdate()
75 and wnoutrefresh(), whether the changes to curscr are really changes.
76 In most cases, this makes no difference (writes were already limited
77 to areas marked as changed), but it can greatly reduce the overhead
78 from touchwin(). It also helps if you have small, separated updates on
79 the same line.
80
81 - The PDC_RGB colors can now be used, or not, with any platform (as long
82 as the same options are used when compiling both the library and
83 apps). This may help if you have apps that are hardwired to assume
84 certain definitions.
85
86 - Restored the use_default_colors() stuff from the ncurses versions of
87 the rain and worm demos, to make them "transparent" (this is useful
88 now, with the SDL port); added transparency to newdemo.
89
90 - Added setlocale() to tuidemo, to make it easier to browse files with
91 non-ASCII characters.
92
93 - Sped up firework demo by replacing unneeded clear() and init_pair()
94 calls.
95
96 - Allow exit from ptest demo by typing 'q'.
97
98 - New functions for implementors: PDC_pair_content() and PDC_init_pair()
99 (the old pdc_atrtab stuff was arguably the last remnant of code in the
100 pdcurses directory that was based on platform details).
101
102 Bug fixes and such:
103
104 - Implicit wrefresh() needs to be called from wgetch() when the window's
105 cursor position is changed, even if there are no other changes.
106
107 - Set SP->audible on a per-platform basis, as was documented in
108 IMPLEMNT, but not actually being done.
109
110 - Minor tweaks for efficiency and readability, notably with wscrl().
111
112 - tuidemo didn't work correctly on monochrome screens when A_COLOR was
113 defined -- the color pair numbers appeared as the corresponding
114 character; also, the input box was (I now realize) broken with ncurses
115 since our 2.7, and broke more subtly with PDCurses' new implicit
116 refresh handling; also, the path to the default file for the Browse
117 function was a bit off.
118
119 - Assume in the demos that curs_set() is always available -- there's no
120 good test for this, and the existing tests were bogus.
121
122 - Made the command-line parameter for ptest work. (If given an argument,
123 it delays that number of milliseconds between changes, instead of
124 waiting for a key, and automatically loops five times.)
125
126 - Building the Win32 DLL with MinGW or Cygwin wouldn't work from outside
127 the platform directory.
128
129 - Building the X11 port with Cygwin required manually editing the
130 Makefile after configuring; no longer. Reported by Warren W. Gay.
131
132 - Minor tightening of configure and makefiles.
133
134 - Bogus references to "ACS_BLCORNER" in the border man page. Reported by
135 "Walrii".
136
137 - slk_wlabel() was not documented.
138
139 - Spelling cleanup.
140
141 - Changed RCSIDs to not end with a semicolon -- avoids warnings when
142 compiling with the -pedantic option.
143
144 - Merged latin-1.txt into x11.txt.
145
146 - Updated config.guess and config.sub to more recent versions.
147
148 ------------------------------------------------------------------------
149
150 PDCurses 3.2 - 2007/06/06
151 =========================
152
153 This release mainly covers changes to the build process, along with a
154 few structural changes.
155
156 New features:
157
158 - The panel library has been folded into the main library. What this
159 means is that you no longer need to specify "-lpanel" or equivalent
160 when linking programs that use panel functionality with PDCurses;
161 however, panel.lib/.a is still provided (as a copy of pdcurses.lib/.a)
162 so that you can, optionally, build your projects with no changes. It
163 also means that panel functionality is available with the DLL or
164 shared library. Note that panel.h remains separate from curses.h.
165
166 - Setting the PDCURSES_SRCDIR environment variable is no longer required
167 before building, unless you want to build in a location other than the
168 platform directory. (See INSTALL.)
169
170 - MinGW and Cygwin makefiles support building DLLs, via the "DLL=Y"
171 option. Partly due to Timofei Shatrov.
172
173 - Support for the Digital Mars compiler.
174
175 - Watcom makefiles now use the "loaddll" feature.
176
177 Bug fixes and such:
178
179 - Eliminated the platform defines (DOS, WIN32, OS2, XCURSES) from
180 curses.h, except for X11-specific SCREEN elements and functions.
181 Dynamically-linked X11 apps built against an old version will have
182 their red and blue swapped until rebuilt. (You can define PDC_RGB to
183 build the library with the old color scheme, but it would also have to
184 be defined when building any new app.) Any app that depends on
185 PDCurses to determine the platform it's building on will have to make
186 other arrangements.
187
188 - Documentation cleanup -- added more details; removed some content that
189 didn't apply to PDCurses; moved the doc-building tool to the doc
190 directory; changed *.man to *.txt.
191
192 - The EMX makefile now accepts "DLL=Y", builds pdcurses.dll instead of
193 curses.dll, builds either the static library or the DLL (not both at
194 once), and links all the demos with the DLL when building it.
195
196 - In Win32, read the registry only when needed: when init_color() or
197 color_content() is called, instead of at startup.
198
199 - A few additional consts in declarations.
200
201 - The Win32 compilers that build DLLs now use common .def files.
202
203 - panel.h functions sorted by name, as with other .h files; curses.h is
204 no longer included by repeated inclusions of panel.h or term.h.
205
206 - Simplified Borland makefiles.
207
208 - Makefile.aix.in depended on a file, xcurses.exp, that was never there.
209 This problem was fixed as part of the change to common .def files;
210 however, I still haven't been able to test building on AIX.
211
212 ------------------------------------------------------------------------
213
214 PDCurses 3.1 - 2007/05/03
215 =========================
216
217 Primarily clipboard-related fixes, and special UTF-8 support.
218
219 New features:
220
221 - "Force UTF-8" mode, a compile-time option to force the use of UTF-8
222 for multibyte strings, instead of the system locale. (Mainly for
223 Windows, where UTF-8 doesn't work well in the console.) See INSTALL.
224
225 - Multibyte string support in PDC_*clipboard() functions, and in Win32's
226 PDC_set_title().
227
228 - Added the global string "ttytype", per other curses implementations,
229 for compatibility with old BSD curses.
230
231 - Real functions for the "quasi-standard aliases" -- crmode(),
232 nocrmode(), draino(), resetterm(), fixterm() and saveterm().
233 (Corresponding macros removed.)
234
235 Bug fixes and such:
236
237 - In Win32, under NT-family OSes, the scrollback buffer would be
238 restored by endwin(), but would not be turned off again when resuming
239 curses after an endwin(). The result was an odd, partly-scrolled-up
240 display. Now, the buffer is toggled by PDC_reset_prog_mode() and
241 PDC_reset_shell_mode(), so it's properly turned off when returning
242 from an endwin().
243
244 - In 3.0, selection in X11 didn't work. (Well, the selecting worked, but
245 the pasting elsewhere didn't.) This was due to the attempted fix
246 "don't return selection start as a press event," so that's been
247 reverted for now.
248
249 - PDC_setclipboard() was locking up in X11. Reported by Mark Hessling.
250
251 - Missing underscore in the declaration of XC_say() prevented
252 compilation with PDCDEBUG defined. Reported by M.H.
253
254 - Off-by-one error in copywin() -- the maximum coordinates for the
255 destination window should be inclusive. Reported by Tiago Dionizio.
256
257 - Start in echo mode, per X/Open. Reported by T.D.
258
259 - Strip leading and trailing spaces from slk labels, per a literal
260 reading of X/Open. Suggested by Alexey Miheev (about ncurses, but it
261 also applies here).
262
263 - The #endif for __PDCURSES__ needs to come _after_ the closing of the
264 extern "C". This has been broken since June 2005. Fortunately (?), it
265 only shows up if the file is included multiple times, and then only in
266 C++. Reported on the DOSBox forums.
267
268 - Use CF_OEMTEXT instead of CF_TEXT in the narrow versions of the
269 clipboard functions in Win32, to match the console.
270
271 - Changed the format of the string returned from longname().
272
273 - In the clipboard test in the testcurs demo, use a single mvprintw() to
274 display the return from PDC_getclipboard(), instead of a loop of
275 addch(), which was incompatible with multibyte strings.
276
277 - Moved has_key() into the keyname module, and documented it.
278
279 - Moved RIPPEDOFFLINE to curspriv.h.
280
281 - Typos in IMPLEMNT.
282
283 ------------------------------------------------------------------------
284
285 PDCurses 3.0 - 2007/04/01
286 =========================
287
288 The focuses for this release are X/Open conformance, i18n, better color
289 support, cleaner code, and more consistency across platforms.
290
291 This is only a brief summary of the changes. For more details, consult
292 the CVS log.
293
294 New features:
295
296 - An almost complete implementation of X/Open curses, including the
297 wide-character and attr_t functions (but excluding terminfo). The
298 wide-character functions work only in Win32 and X11, for now, and
299 require building the library with the appropriate options (see
300 INSTALL). Note that this is a simplistic implementation, with exactly
301 one wchar_t per cchar_t; the only characters it handles properly are
302 those that are one column wide.
303
304 - Support for X Input Methods in the X11 port (see INSTALL). When built
305 this way, the internal compose key support is disabled in favor of
306 XIM's, which is a lot more complete, although you lose the box cursor.
307
308 - Multibyte character support in the non-wide string handling functions,
309 per X/Open. This only works when the library is built with wide-
310 character support enabled.
311
312 - Mouse support for DOS and OS/2. The DOS version includes untested
313 support for scroll wheels, via the "CuteMouse" driver.
314
315 - An ncurses-compatible mouse interface, which can work in parallel with
316 the traditional PDCurses mouse interface. See the man page (or
317 mouse.c) for details.
318
319 - DOS and OS/2 can now return modifiers as keys, as in Win32 and X11.
320
321 - COLORS, which had been fixed at 8, is now either 8 or 16, depending on
322 the terminal -- usually 16. When it's 8, blinking mode is enabled
323 (controlled as before by the A_BLINK attribute); when it's 16, bright
324 background colors are used instead. On platforms where it can be
325 changed, the mode is toggled by the new function PDC_set_blink().
326 PDCurses tries to set PDC_set_blink(FALSE) at startup. (In Win32, it's
327 always set to FALSE; in DOS, with other than an EGA or VGA card, it
328 can't be.) Also, COLORS is now set to 0 until start_color() is called.
329
330 - Corresponding to the change in COLORS, COLOR_PAIRS is now 256.
331
332 - Working init_color() and color_content(). The OS/2 version of
333 init_color() works only in a full-screen session; the Win32 version
334 works only in windowed mode, and only in NT-family OSes; the DOS
335 version works only with VGA adapters (real or simulated). The Win32
336 version is based mostly on James Brown's setconsoleinfo.c
337 (www.catch22.net).
338
339 - use_default_colors(), assume_default_colors(), and curses_version(),
340 after ncurses.
341
342 - Added global int TABSIZE, after ncurses and Solaris curses; removed
343 window-specific _tabsize.
344
345 - Logical extension to the wide-character slk_ funcs: slk_wlabel(), for
346 retrieving the label as a wide-character string.
347
348 - A non-macro implementation of ncurses' wresize().
349
350 - Working putwin(), getwin(), scr_dump() and scr_restore().
351
352 - A working acs_map[]. Characters from the ACS are now stored in window
353 structures as a regular character plus the A_ALTCHARSET attribute, and
354 rendered to the ACS only when displayed. (This allows, for example,
355 the correct display on one platform of windows saved from another.)
356
357 - In X11, allow selection and paste of UTF8_STRING.
358
359 - The testcurs demo now includes a color chart and init_color() test, a
360 wide character input test, a display of wide ACS characters with
361 sample Unicode text, a specific test of flash(), more info in the
362 resize test, and attempts to change the width as well as the height.
363
364 - Command-line option for MSVC to build DLLs (see INSTALL). Also, the
365 naming distinction for DLLs ("curses" vs. "pdcurses") is abandoned,
366 and either the static lib or DLL is built, not both at once (except
367 for X11).
368
369 - For backwards compatibility, a special module just for deprecated
370 functions -- currently PDC_check_bios_key(), PDC_get_bios_key(),
371 PDC_get_ctrl_break() and PDC_set_ctrl_break(). These shouldn't be used
372 in applications, but currently are... in fact, all the "private"
373 functions (in curspriv.h) are subject to change and should be avoided.
374
375 - A new document, IMPLEMNT, describing PDCurses' internal functions for
376 those wishing to port it to new platforms.
377
378 - Mark Hessling has released the X11 port to the public domain.
379 (However, x11/ScrollBox* retain their separate copyright and MIT-like
380 license.)
381
382 Bug fixes and such:
383
384 - Most of the macros have been removed (along with the NOMACROS ifdef).
385 The only remaining ones are those which have to be macros to work, and
386 those that are required by X/Open to be macros. There were numerous
387 problems with the macros, and no apparent reason to keep them, except
388 tradition -- although it was PCcurses 1.x that first omitted them.
389
390 - Clean separation of platform-specific code from the rest. Outside of
391 the platform directories, there remain only a few ifdefs in curses.h
392 and curspriv.h.
393
394 - General reorganization and simplification.
395
396 - Documentation revisions.
397
398 - When expanding control characters in addch() or insch(), retain the
399 attributes from the chtype.
400
401 - Preserve the A_ALTCHARSET attribute in addch() and insch().
402
403 - Per X/Open, beep() should always return OK.
404
405 - On platforms with a controlling terminal (i.e., not X11), curs_set(1)
406 now sets the cursor to the shape it had at the time of initscr(),
407 rather than always making it small. (Exception for DOS: If the video
408 mode has been changed by PDC_resize_screen(), curs_set(1) reverts to
409 line 6/7.) The shape is taken from SP->orig_cursor (the meaning of
410 which is platform-specific).
411
412 - Stop updating the cursor position when the cursor is invisible (this
413 gives a huge performance boost in Win 9x); update the cursor position
414 from curs_set() if changing from invisible to visible.
415
416 - Some tweaking of the behavior of def_prog_mode(), def_shell_mode(),
417 savetty(), reset_prog_mode(), reset_shell_mode() and resetty()...
418 still not quite right.
419
420 - flash() was not implemented for Win32 or X. A portable implementation
421 is now used for all platforms. Note that it's much slower than the
422 old (DOS and OS/2) version, but this is only apparent on an extremely
423 slow machine, such as an XT.
424
425 - In getstr(), backspacing on high-bit characters caused a double
426 backspace.
427
428 - hline() and vline() used an incorrect (off by one) interpretation of
429 _maxx and _maxy. If values of n greater than the max were specified,
430 these functions could access unallocated memory.
431
432 - innstr() is supposed to return the number of characters read, not just
433 OK or ERR. Reported by Mike Aubury.
434
435 - A proper implementation of insch() -- the PDC_chadd()-based version
436 wasn't handling the control characters correctly.
437
438 - Return ASCII and control key names from keyname() (problem revealed by
439 ncurses' movewindow test); also, per X/Open, return "UNKNOWN KEY" when
440 appropriate, rather than "NO KEY NAME".
441
442 - Turn off the cursor from leaveok(TRUE), even in X11; leaveok(FALSE)
443 now calls curs_set(1), regardless of the previous state of the cursor.
444
445 - In the slk area, BUTTON_CLICKED events now translate to function keys,
446 along with the previously recognized BUTTON_PRESSED events. Of course,
447 it should really be checking the events specified by map_button(),
448 which still doesn't work.
449
450 - napms(0) now returns immediately.
451
452 - A unified napms() implementation for DOS -- no longer throttles the
453 CPU when built with any compiler.
454
455 - Allow backspace editing of the nocbreak() buffer.
456
457 - pair_content(0, ...) is valid.
458
459 - There was no check to ensure that the pnoutrefresh() window fit within
460 the screen. It now returns an ERR if it doesn't.
461
462 - In X11, resize_term() must be called with parameters (0, 0), and only
463 when SP->resized is set, else it returns ERR.
464
465 - Copy _bkgd in resize_window(). Patch found on Frederic L. W. Meunier's
466 web site.
467
468 - slk_clear() now removes the buttons completely, as in ncurses.
469
470 - Use the current foreground color for the line attributes (underline,
471 left, right), unless PDC_set_line_color() is explicitly called. After
472 setting the line color, you can reset it to this mode via
473 "PDC_set_line_color(-1)".
474
475 - Removed non-macro implementations of COLOR_PAIR() and PAIR_NUMBER().
476
477 - Dispensed with PDC_chadd() and PDC_chins() -- waddch() and winsch()
478 are now (again) the core functions.
479
480 - Dropped or made static many obsolete, unused, and/or broken functions,
481 including PDC_chg_attrs(), PDC_cursor_on() and _off(),
482 PDC_fix_cursor(), PDC_get_attribute(), PDC_get_cur_col() and _row(),
483 PDC_set_80x25(), PDC_set_cursor_mode(), PDC_set_rows(),
484 PDC_wunderline(), PDC_wleftline(), PDC_wrightline(),
485 XCursesModifierPress() and XCurses_refresh_scrollbar().
486
487 - Obsolete/unused defines: _BCHAR, _GOCHAR, _STOPCHAR, _PRINTCHAR
488 _ENDLINE, _FULLWIN and _SCROLLWIN.
489
490 - Obsolete/unused elements of the WINDOW struct: _pmax*, _lastp*,
491 _lasts*.
492
493 - Obsolete/unused elements of the SCREEN struct: orgcbr, visible_cursor,
494 sizeable, shell, blank, cursor, orig_emulation, font, orig_font,
495 tahead, adapter, scrnmode, kbdinfo, direct_video, video_page,
496 video_seg, video_ofs, bogus_adapter. (Some of these persist outside
497 the SCREEN struct, in the platform directories.) Added mouse_wait and
498 key_code.
499
500 - Removed all the EMALLOC stuff. Straight malloc calls were used
501 elsewhere; it was undocumented outside of comments in curspriv.h; and
502 there are better ways to use a substitute malloc().
503
504 - Single mouse clicks are now reportable on all platforms (not just
505 double-clicks). And in general, mouse event reporting is more
506 consistent across platforms.
507
508 - The mouse cursor no longer appears in full-screen mode in Win32 unless
509 a nonzero mouse event mask is used.
510
511 - ALT-keypad input now works in Win32.
512
513 - In Win32, SetConsoleMode(ENABLE_WINDOW_INPUT) is not useful, and
514 appears to be the source of a four-year-old bug report (hanging in
515 THE) by Phil Smith.
516
517 - Removed the PDC_THREAD_BUILD stuff, which has never worked. For the
518 record: PDCurses is not thread-safe. Neither is ncurses; and the
519 X/Open curses spec explicitly makes it a non-requirement.
520
521 - With the internal compose key system in the X11 port, modifier keys
522 were breaking out of the compose state, making it impossible to type
523 accented capitals, etc. Also, Multi_key is now the default compose
524 key, instead of leaving it undefined by default; and a few more combos
525 are supported.
526
527 - In X11, the first reported mouse event after startup always read as a
528 double-click at position 0, 0. (This bug was introduced in 2.8.)
529
530 - In X11, don't return selection start as a press event. (Shift-click on
531 button 1 is still returned.)
532
533 - In X11, properly handle pasting of high-bit chars. (It was doing an
534 unwanted sign extension.)
535
536 - In X11, BUTTON_MOVED was never returned, although PDC_MOUSE_MOVED was
537 set.
538
539 - The fix in 2.8 for the scroll wheel in X11 wasn't very good -- it did
540 report the events as scroll wheel events, but it doubled them. Here's
541 a proper fix.
542
543 - Changed mouse handling in X11: Simpler translation table, with
544 XCursesPasteSelection() called from XCursesButton() instead of the
545 translation table; require shift with button 1 or 2 for select or
546 paste when mouse events are being reported (as with ncurses), allowing
547 passthrough of simple button 2 events. This fixes the previously
548 unreliable button 2 behavior.
549
550 - Modifier keys are now returned on key up in X11, as in Win32. And in
551 general, modifier key reporting is more consistent across platforms.
552
553 - Modifiers are not returned as keys when a mouse click has occurred
554 since the key press.
555
556 - In BIOS mode (in DOS), count successive identical output bytes, and
557 make only one BIOS call for all of them. This dramatically improves
558 performance.
559
560 - The cursor position was not always updated correctly in BIOS mode.
561
562 - In testcurs, the way the ACS test was written, it would really only
563 work with a) PDCurses (with any compiler), or b) gcc (with any
564 curses). Here's a more portable implementation.
565
566 - Better reporting of mouse events in testcurs.
567
568 - Blank out buffer and num before the scanw() test in testcurs, in case
569 the user just hits enter or etc.; clear the screen after resizing.
570
571 - Allow tuidemo to use the last line.
572
573 - Separate left/right modifier keys are now reported properly in Win32.
574 (Everything was being reported as _R.)
575
576 - Attempts to redirect input in Win32 now cause program exit and an
577 error message, instead of hanging.
578
579 - Dropped support for the Microway NDP compiler.
580
581 - Some modules renamed, rearranged.
582
583 - Fixes for errors and warnings when building with Visual C++ 2005.
584
585 - In MSVC, the panel library didn't work with the DLL.
586
587 - Complete export lists for DLLs.
588
589 - Simplified makefiles; moved common elements to .mif files; better
590 optimization; strip demos when possible.
591
592 - Changed makefile targets of "pdcurses.a/lib" and "panel.a/lib" to
593 $(LIBCURSES) and $(LIBPANEL). Suggestion of Doug Kaufman.
594
595 - Changed "install" target in the makefile to a double-colon rule, to
596 get around a conflict with INSTALL on non-case-sensitive filesystems,
597 such as Mac OS X's HFS+. Reported by Douglas Godfrey et al.
598
599 - Make PDCurses.man dependent on manext. Suggestion of Tiziano Mueller.
600
601 - Set up configure.ac so autoheader works; removed some obsolescent
602 macros. Partly the suggestion of T.M.
603
604 - The X11 port now builds in the x11 directory (including the demos), as
605 with other ports.
606
607 - The X11 port should now build on more 64-bit systems. Partly due to
608 M.H.
609
610 - The default window title and icons for the X11 port are now "PDCurses"
611 instead of "XCurses".
612
613 - Internal functions and variables made static where possible.
614
615 - Adopted a somewhat more consistent naming style: Internal functions
616 with external linkage, and only those, have the prefix "PDC_";
617 external variables that aren't part of the API use "pdc_"; static
618 functions use "_"; and "XC_" and "xc_" prefixes are used for functions
619 and variables, respectively, that are shared between both processes in
620 the X11 port. Also eliminated camel casing, where possible.
621
622 - Changed the encoding for non-ASCII characters in comments and
623 documentation from Latin-1 to UTF-8.
624
625 ------------------------------------------------------------------------
626
627 PDCurses 2.8 - 2006/04/01
628 =========================
629
630 As with the previous version, you should assume that apps linked against
631 older dynamic versions of the library won't work with this one until
632 recompiled.
633
634 New features:
635
636 - Simpler, faster.
637
638 - Declarations for all supported, standard functions, per the X/Open
639 Curses 4.2 spec, with the notable exception of getch() and ungetch().
640 You can disable the use of the macro versions by defining NOMACROS
641 before including curses.h (see xmas.c for an example). NOMACROS yields
642 smaller but theoretically slower executables.
643
644 - New functions: vwprintw(), vwscanw(), vw_printw() and vw_scanw(). This
645 completes the list of X/Open 4.2 functions, except for those concerned
646 with attr_t and wide characters. Some (especially the terminfo/termcap
647 functions) aren't yet fully fleshed out, though.
648
649 - Non-macro implementations for COLOR_PAIR(), PAIR_NUMBER(), getbkgd(),
650 mvgetnstr(), mvwgetnstr(), mvhline(), mvvline(), mvwhline(), and
651 mvwvline(). (The macros are still available, too.)
652
653 - newterm() works now, in a limited way -- the parameters are ignored,
654 and only the first invocation will work (i.e., only one SCREEN can be
655 used).
656
657 - start_color() works now -- which is to say, if you _don't_ call it,
658 you'll only get monochrome output. Also, without calling it, the
659 terminal's default colors will be used, where supported (currently
660 only in Win32). This is equivalent to the PDC_ORIGINAL_COLORS behavior
661 introduced in 2.7, except that _only_ the default colors will be used.
662 (PDC_ORIGINAL_COLORS is still available, if you want to combine the
663 use of specific colors and the default colors.)
664
665 - New logic for termname() and longname(): termname() always returns
666 "pdcurses"; longname() returns "PDCurses for [platform] [adapter]
667 [COLOR/MONO]-YxX" (adapter is only defined for DOS and OS/2). This is
668 the first time these functions return _anything_ in Win32.
669
670 - New installation method for XCurses: the header files are placed in a
671 subdirectory "xcurses" within the include directory, rather than being
672 renamed. (But the renamed xcurses.h and xpanel.h are also installed,
673 for backwards compatibility.) curspriv.h and term.h are now available,
674 and existing curses-based code need no longer be edited to use
675 XCurses' curses.h. And with no more need for explicit XCursesExit()
676 calls (see below), your code need not be changed at all to move from
677 another curses implementation to XCurses. It can be as simple as "gcc
678 -I/usr/local/include/xcurses -lXCurses -oprogname progname.c".
679
680 - Combined readme.* into this HISTORY file, and incorporated the old 1.x
681 (PCcurses) history.
682
683 - New functionality for the testcurs demo: ACS character display; menu
684 support for PgUp, PgDn, Home and End; centered menu; and it can now
685 be resized in X.
686
687 - Added modified versions of the rain and worm demos from ncurses.
688
689 Bug fixes and such:
690
691 - Big cleanup of dead and redundant code, including unneeded defines,
692 ifdefs, and structure elements.
693
694 - flushinp() was not implemented for Win32.
695
696 - resetty() was not restoring LINES and COLS.
697
698 - nonl() made '\n' print a line feed without carriage return. This was
699 incorrect.
700
701 - Removed bogus implementation of intrflush().
702
703 - The line-breakout optimization system, disabled by default in 2.7, is
704 removed in 2.8. It simply didn't work, and never has. (The typeahead()
705 function remains, for compatibility, but does nothing.)
706
707 - The declarations for the printw() and scanw() function families were
708 erroneously ifdef'd.
709
710 - Safer printw() calls on platforms that support vsnprintf().
711
712 - Use the native vsscanf() in DJGPP, MinGW and Cygwin.
713
714 - ACS_BLOCK now works in X.
715
716 - Explicit calls to XCursesExit() are no longer needed.
717
718 - XCURSES is now defined automatically if not DOS, OS2 or WIN32.
719
720 - The default icon for XCurses wasn't working (had to remove the focus
721 hint code to fix this). Also, the default title is now "XCurses"
722 instead of "main".
723
724 - Incorrect dimensions (undercounting by two in each direction) were
725 shown while resizing in X.
726
727 - Scroll wheel events were not always correctly reported in X.
728
729 - 32 bits are enough for the "long" chtype, but 64 bits were used on a
730 64-bit system, wasting memory. Now conditioned on _LP64. This could be
731 faster, too.
732
733 - The short, 16-bit chtype now works with XCurses.
734
735 - Corrected return value for is_linetouched(), is_wintouched(),
736 can_change_color() and isendwin() (bool instead of int).
737
738 - timeout(), wtimeout(), idcok() and immedok() return void.
739
740 - pair_content() takes a short.
741
742 - Replaced incorrect usages of attr_t with chtype. attr_t is still
743 typedef'd, for backwards compatibility. (It's supposed to be used for
744 the WA_*-style functions, which PDCurses doesn't yet support.)
745
746 - Added const where required by the spec, and in other appropriate
747 places.
748
749 - Removed PDC_usleep(). napms() is now the core delay routine.
750
751 - Fixed poll() support in napms().
752
753 - Various changes to the internal PDC_* functions -- don't depend on
754 these, and don't use them unless you absolutely have to.
755
756 - Some routines accessed window structures in their variable
757 declarations, _before_ checking for a NULL window pointer.
758
759 - Dropped support for the undocumented PDC_FULL_DISPLAY, wtitle(), and
760 PDC_print().
761
762 - Cleaned up remaining warnings.
763
764 - Reduced unnecessary #include directives -- speeds up compilation.
765
766 - Fix for demos build in Borland/DOS -- the makefile in 2.7 didn't
767 specify the memory model. Reported by Erwin Waterlander.
768
769 - Simplified the makefiles; e.g., some now build each demo in a single
770 step, and Watcom no longer uses demos.lnk. Also, the demo exes are now
771 stripped when possible; maximum compression used for archives built
772 by the makefiles; xcurses-config removed as part of "make distclean";
773 and I tweaked optimization for some platforms.
774
775 - Reverted to /usr/local/ as default installation directory for XCurses.
776
777 - Upgraded to autoconf 2.59... instantly doubling the size of the
778 configure script. Ah well. Otherwise, simplified the build system.
779
780 - Dropped support for pre-ANSI compilers. (It hasn't worked since at
781 least version 2.4, anyway.)
782
783 - Revised and, I hope, clarified the boilerplate and other comments.
784
785 - Simplified logging and RCS ids; added RCS ids where missing.
786
787 - Consistent formatting for all code, approximately equivalent to
788 "indent -kr -i8 -bl -bli0", with adjustments for 80 columns.
789
790 ------------------------------------------------------------------------
791
792 PDCurses 2.7 - 2005/12/30
793 =========================
794
795 INTRODUCTION:
796
797 Hello all. As of a few weeks ago, I'm the new maintainer for PDCurses.
798 Here's a brief summary of changes in this release. (More details are
799 available in the CVS log and trackers on SourceForge.)
800
801 NEW FEATURES:
802
803 - Functions: delscreen(), getattrs(), has_key(), slk_color(),
804 wcolor_set(), wtimeout().
805
806 - Macros: color_set(), mvhline(), mvvline(), mvwgetnstr(), mvwhline(),
807 mvwvline(), timeout(), wresize().
808
809 - Stub implementations of terminfo functions (including a term.h).
810
811 - More stubs for compatibility: filter(), getwin(), putwin(),
812 noqiflush(), qiflush(), scr_dump(), scr_init(), scr_restore(),
813 scr_set(), use_env(), vidattr(), vidputs().
814
815 - The terminal's default colors are used as curses' default colors when
816 the environment variable "PDC_ORIGINAL_COLORS" is set to any value
817 (Win32 only at the moment).
818
819 - Simplified build system.
820
821 - Replaced PDC_STATIC_BUILD with its opposite, PDC_DLL_BUILD (see .mak
822 files for more info).
823
824 - Minimal implementation of color_content() -- no longer a stub.
825
826 - Added the remaining ACS defines (ACS_S3, ACS_BBSS, etc.) for
827 DOS/OS2/Win; "enhanced" versions of existing ACS characters used.
828
829 - Support for scroll wheels.
830
831 - Support for Pacific C.
832
833 BUGS FIXED:
834
835 - Builds correctly (including demos) on all tested platforms (see
836 below); nearly all compiler warnings have been cleaned up; the ptest
837 demo is built on all platforms; "clean" targets are improved.
838
839 - The ability to build ncurses_tests has been restored (see demos dir).
840
841 - Line-breakout optimization now defaults to off (equivalent to
842 "typeahead(-1)"), so output is not interrupted by keystrokes (it's
843 supposed to resume on the next refresh(), which wasn't working).
844
845 - Implicit wrefresh() in wgetch() was not being invoked in nodelay mode.
846
847 - subpad() was erroneously offsetting from the origin coordinates of the
848 parent pad (which are always -1,-1).
849
850 - In wborder(), whline(), and wvline(), the current (wattrset) attribute
851 was being used, but not the current background (wbkgd).
852
853 - Allow Russian 'r' character ASCII 0xe0 to be returned.
854
855 - termattrs() now also returns A_UNDERLINE, A_REVERSE.
856
857 - In Win32, with large scrollback buffers set, there was an unwanted
858 "scrollup" effect on startup.
859
860 - Revamped keyboard handling for Win32.
861
862 - New screen resize method for Win32.
863
864 - napms(), delay_output(), etc. now work with Cygwin.
865
866 - curs_set(0) wasn't working in Win32 in full-screen (ALT-ENTER) mode --
867 the cursor stayed on.
868
869 - The A_REVERSE attribute was broken in XCurses.
870
871 - On 64-bit systems, XCurses was ignoring every other keystroke.
872
873 - Added focus hints for XCurses.
874
875 - Demos (except for tuidemo) once again have their proper titles in
876 XCurses (using Xinitscr() instead of the obsolete XCursesProgramName).
877
878 - The 16-bit chtype is a working option again (by removing #define
879 CHTYPE_LONG from curses.h), except in XCurses. It's not recommended;
880 but if your needs are limited, it still works.
881
882 - Reset screen size in resetty() under DOS, as in Win32 and OS/2.
883
884 - Changes for cursor size under DOS.
885
886 - Automatic setting of BIOS mode for CGA under DOS now works.
887
888 - The cursor is now always updated in PDC_gotoxy(); this fixes the
889 problem of missing characters in BIOS mode.
890
891 - Macros nocbreak(), cbreak(), nocrmode(), crmode(), nodelay(),
892 nl() and nonl() now return OK.
893
894 - ERR and OK are now defined as -1 and 0, respectively, for
895 compatibility with other curses implementations -- note that this
896 change is not binary compatible; you'll have to rebuild programs that
897 use shared/dynamic libraries.
898
899 - Added "const" to prototypes where appropriate.
900
901 - Miscellaneous code cleanup.
902
903 ACKNOWLEDGEMENTS:
904
905 Walter Briscoe
906 Jean-Pierre Demailly
907 Ruslan Fedyarov
908 Warren Gay
909 Florian Grosse-Coosmann
910 Vladimir Kokovic
911 Matt Maloy
912 K.H. Man
913 Michael Ryazanov
914 Ron Thibodeau
915 Alexandr Zamaraev
916
917 and of course, MARK HESSLING, for his over 13 years of service as the
918 maintainer of PDCurses. Plus, thanks to all who've reported bugs or
919 requested features. Apologies to anyone I've forgotten.
920
921 I've tested this version on Turbo C++ 3.0 and Borland C++ 3.1 for DOS;
922 DJGPP 2.X; Open Watcom 1.3 for DOS (16 and 32-bit), Windows and OS/2;
923 EMX 0.9d and the "newgcc" version of EMX; Borland C++ 5.5 for Windows;
924 recent versions of MinGW, Cygwin, LCC-Win32 and Microsoft Visual C++;
925 and gcc under several flavors of Linux, Mac OS X, *BSD and Solaris.
926
927 -- William McBrine
928
929 ------------------------------------------------------------------------
930
931 PDCurses 2.6 - 2003/01/08
932 =========================
933
934 INTRODUCTION:
935
936 This release of PDCurses includes the following changes:
937
938 BUGS FIXED:
939
940 - Allow accented characters on Win32 platform when run on non-English
941 keyboards.
942
943 - Allow "special" characters like Ctrl-S, Ctrl-Q under OS/2 to be returned.
944
945 - Some bugs with halfdelay() fixed by William McBrine.
946
947 - pechochar() should now work correctly.
948
949 - redrawwin() macro in curses.h was incorrect - fixed by Alberto Ornaghi
950
951 - Don't include "special" characters like KEY_SHIFT_L to be returned in
952 getnstr() family. Bug 542913
953
954 - Entering TAB in wgetnstr() no longer exceeds requested buffer size.
955 Bug 489233
956
957 - Fixed bug 550066, scrollok() and pads.
958 Also beep() called when buffer exceeded. Bug 562041.
959
960 - Reverse video of X11 selection reinstated. Pablo Garcia Abio??
961
962 - Right Alt modifier now works like left Alt modifier under Win32
963
964 - Add support for all libXaw replacement libraries with Scrollbar bug.
965 Note that for this to work, you still have to change the libXaw
966 replacement libraries to fix the bug :-(
967
968 - Don't trap signals in XCurses if calling application has ignored them.
969 Change by Frank Heckenbach.
970
971 - Bug reports from Warren W. Gay:
972 - Fix termattrs() to return A_REVERSE and A_BLINK on all platforms.
973 - Fix definition of getsyx() and setsyx() to be consistent with
974 ncurses. Bug 624424.
975 - Fix definition of echo() and noecho(). Bug 625001.
976 - Fix definition of keypad() and leaveok(). Bug 632653.
977 - Missing panel_hidden() prototype. Bug 649320.
978
979 - Fixed bug with calling def_prog_mode(), resize_term(),
980 reset_prog_mode(); the resize details were being lost.
981
982 NEW FEATURES:
983
984 - Clipboard support now available on DOS platform, but handled
985 internally to the currently running process.
986
987 - New X11 resource: textCursor, allows the text cursor to be specified
988 as a vertical bar, or the standard horizontal bar. Thanks to Frank
989 Heckenbach for the suggestion.
990
991 NEW COMPILER SUPPORT:
992
993 - lcc-win32 now works correctly
994
995 ------------------------------------------------------------------------
996
997 PDCurses 2.5 - 2001/11/26
998 =========================
999
1000 INTRODUCTION:
1001
1002 This release of PDCurses includes the following changes:
1003
1004 - Set BASE address for Win32 DLL
1005
1006 - Add KEY_SUP and KEY_SDOWN.
1007
1008 - Add PDC_set_line_color()
1009
1010 - Add blink support as bold background
1011
1012 - Add bold colors
1013
1014 - Add getbkgd() macro
1015
1016 - Add new PDC functions for adding underline, overline, leftline and
1017 rightline
1018
1019 - Add support for shifted keypad keys.
1020
1021 - Allow more keypad keys to work under Win32
1022
1023 - Change Win32 and OS/2 DLL name to curses.dll
1024
1025 - Change example resources to allow overriding from the command line
1026
1027 - Changes for building cleanly on OS/2
1028
1029 - Changes to handle building XCurses under AIX
1030
1031 - Check if prefresh() and pnoutrefresh() parameters are valid.
1032
1033 - Ensure build/install works from any directory
1034
1035 - Handle platforms where X11 headers do not typedef XPointer.
1036
1037 - Mention that Flexos is likely out-of-date.
1038
1039 - Pass delaytenths to XCurses_rawgetch()
1040
1041 - Remove boldFont
1042
1043 - Updates for cursor blinking and italic.
1044
1045 BUGS FIXED:
1046
1047 - Fix bug with getting Win32 clipboard contents. Added new
1048 PDC_freeclipboard() function.
1049
1050 - Fix bug with halfdelay()
1051
1052 - Fix bug with mouse interrupting programs that are not trapping mouse
1053 events under Win32.
1054
1055 - Fix return value from curs_set()
1056
1057 - Reverse the left and right pointing bars in ALT_CHARSET
1058
1059 NEW COMPILER SUPPORT:
1060
1061 - Add QNX-RTP port
1062
1063 ------------------------------------------------------------------------
1064
1065 PDCurses 2.4 - 2000/01/17
1066 =========================
1067
1068 INTRODUCTION:
1069
1070 This release of PDCurses includes the following changes:
1071
1072 - full support of X11 selection handling
1073
1074 - removed the need for the cursos2.h file
1075
1076 - enabled the "shifted" key on the numeric keypad
1077
1078 - added native clipboard support for X11, Win32 and OS/2
1079
1080 - added extra functions for obtaining internal PDCurses status
1081
1082 - added clipboard and key modifier tests in testcurs.c
1083
1084 - fixes for panel library
1085
1086 - key modifiers pressed by themselves are now returned as keys:
1087 KEY_SHIFT_L KEY_SHIFT_R KEY_CONTROL_L KEY_CONTROL_R KEY_ALT_L KEY_ALT_R
1088 This works on Win32 and X11 ports only
1089
1090 - Added X11 shared library support
1091
1092 - Added extra slk formats supported by ncurses
1093
1094 - Fixed bug with resizing the terminal when slk were on.
1095
1096 - Changed behavior of slk_attrset(), slk_attron() slk_attroff()
1097 functions to work more like ncurses.
1098
1099 BUGS FIXED:
1100
1101 - some minor bug and portability fixes were included in this release
1102
1103 NEW FUNCTIONS:
1104
1105 - PDC_getclipboard() and PDC_setclipboard() for accessing the native
1106 clipboard (X11, Win32 and OS/2)
1107
1108 - PDC_set_title() for setting the title of the window (X11 and Win32
1109 only)
1110
1111 - PDC_get_input_fd() for getting the file handle of the PDCurses input
1112
1113 - PDC_get_key_modifiers() for getting the keyboard modifier settings at
1114 the time of the last (w)getch()
1115
1116 - Xinitscr() (only for X11 port) which allows standard X11 switches to
1117 be passed to the application
1118
1119 NEW COMPILER SUPPORT:
1120
1121 - MingW32 GNU compiler under Win95/NT
1122
1123 - Cygnus Win32 GNU compiler under Win95/NT
1124
1125 - Borland C++ for OS/2 1.0+
1126
1127 - lcc-win32 compiler under Win95/NT
1128
1129 ACKNOWLEDGEMENTS: (for this release)
1130
1131 Georg Fuchs for various changes.
1132 Juan David Palomar for pointing out getnstr() was not implemented.
1133 William McBrine for fix to allow black/black as valid color pair.
1134 Peter Preus for pointing out the missing bccos2.mak file.
1135 Laura Michaels for a couple of bug fixes and changes required to
1136 support Mingw32 compiler.
1137 Frank Heckenbach for PDC_get_input_fd() and some portability fixes and
1138 the fixes for panel library.
1139 Matthias Burian for the lcc-win32 compiler support.
1140
1141 ------------------------------------------------------------------------
1142
1143 PDCurses 2.3 - 1998/07/09
1144 =========================
1145
1146 INTRODUCTION:
1147
1148 This release of PDCurses includes the following changes:
1149
1150 - added more System V R4 functions
1151
1152 - added Win32 port
1153
1154 - the X11 port is now fully functional
1155
1156 - the MS Visual C++ Win32 port now includes a DLL
1157
1158 - both the X11 and Win32 ports support the mouse
1159
1160 - the slk..() functions are now functional
1161
1162 - support for scrollbars under X11 are experimental at this stage
1163
1164 - long chtype extended to non-Unix ports
1165
1166 The name of the statically built library is pdcurses.lib (or
1167 pdcurses.a). The name of the DLL import library (where applicable) is
1168 curses.lib.
1169
1170 BUGS FIXED:
1171
1172 - some minor bugs were corrected in this release
1173
1174 NEW FUNCTIONS:
1175
1176 - slk..() functions
1177
1178 NEW COMPILER SUPPORT:
1179
1180 - MS Visual C++ under Win95/NT
1181
1182 - Watcom C++ under OS/2, Win32 and DOS
1183
1184 - two EMX ports have been provided:
1185 - OS/2 only using OS/2 APIs
1186 - OS/2 and DOS using EMX video support routines
1187
1188 EXTRA OPTIONS:
1189
1190 PDCurses recognizes two environment variables which determines the
1191 initialization and finalization behavior. These environment variables
1192 do not apply to the X11 port.
1193
1194 PDC_PRESERVE_SCREEN
1195 If this environment variable is set, PDCurses will not clear the screen
1196 to the default white on black on startup. This allows you to overlay
1197 a window over the top of the existing screen background.
1198
1199 PDC_RESTORE_SCREEN
1200 If this environment variable is set, PDCurses will take a copy of the
1201 contents of the screen at the time that PDCurses is started; initscr(),
1202 and when endwin() is called, the screen will be restored.
1203
1204
1205 ACKNOWLEDGEMENTS: (for this release)
1206
1207 Chris Szurgot for original Win32 port.
1208 Gurusamy Sarathy for some updates to the Win32 port.
1209 Kim Huron for the slk..() functions.
1210 Florian Grosse Coosmann for some bug fixes.
1211 Esa Peuha for reducing compiler warnings.
1212 Augustin Martin Domingo for patches to X11 port to enable accented
1213 characters.
1214
1215 ------------------------------------------------------------------------
1216
1217 PDCurses 2.2 - 1995/02/12
1218 =========================
1219
1220 INTRODUCTION:
1221
1222 This release of PDCurses has includes a number of major changes:
1223
1224 - The portable library functions are now grouped together into single
1225 files with the same arrangement as System V R4 curses.
1226
1227 - A panels library has been included. This panels library was written by
1228 Warren Tucker.
1229
1230 - Quite a few more functions have been supplied by Wade Schauer and
1231 incorporated into release 2.2. Wade also supplied the support for the
1232 Microway NDP C/C++ 32 bit DOS compiler.
1233
1234 - The curses datatype has been changed from an unsigned int to a long.
1235 This allows more attributes to be stored as well as increasing the
1236 number of color-pairs from 32 to 64.
1237
1238 - Xwindows port (experimental at the moment).
1239
1240 BUGS FIXED:
1241
1242 - mvwin() checked the wrong coordinates
1243
1244 - removed DESQview shadow memory buffer checking bug in curses.h in
1245 #define for wstandout()
1246
1247 - lots of others I can't remember
1248
1249 NEW FUNCTIONS:
1250
1251 - Too many to mention. See intro.man for a complete list of the
1252 functions PDCurses now supports.
1253
1254 COMPILER SUPPORT:
1255
1256 - DJGPP 1.12 is now supported. The run-time error that caused programs
1257 to crash has been removed.
1258
1259 - emx 0.9a is supported. A program compiled for OS/2 should also work
1260 under DOS if you use the VID=EMX switch when compiling. See the
1261 makefile for details.
1262
1263 - The Microway NDP C/C++ DOS compiler is now supported. Thanks to Wade
1264 Schauer for this port.
1265
1266 - The Watcom C++ 10.0 DOS compiler is now supported. Thanks to Pieter
1267 Kunst for this port.
1268
1269 - The library now has many functions grouped together to reduce the size
1270 of the library and to improve the speed of compilation.
1271
1272 - The "names" of a couple of the compilers in the makefile has changed;
1273 CSET2 is now ICC and GO32 is now GCC.
1274
1275 EXTRA OPTIONS:
1276
1277 One difference between the behavior of PDCurses and Unix curses is the
1278 attributes that are displayed when a character is cleared. Under Unix
1279 curses, no attributes are displayed, so the result is always black.
1280 Under PDCurses, these functions clear with the current attributes in
1281 effect at the time. With the introduction of the bkgd functions, by
1282 default, PDCurses clears using the value set by (w)bkgd(). To have
1283 PDCurses behave the same way as it did before release 2.2, compile with
1284 -DPDCURSES_WCLR
1285
1286 ACKNOWLEDGEMENTS: (for this release)
1287
1288 Pieter Kunst, David Nugent, Warren Tucker, Darin Haugen, Stefan Strack,
1289 Wade Schauer and others who either alerted me to bugs or supplied
1290 fixes.
1291
1292 ------------------------------------------------------------------------
1293
1294 PDCurses 2.1 - 1993/06/20
1295 =========================
1296
1297 INTRODUCTION:
1298
1299 The current code contains bug fixes for the DOS and OS/2 releases and
1300 also includes an alpha release for Unix. The Unix release uses another
1301 public domain package (mytinfo) to handle the low-level screen writes.
1302 mytinfo was posted to comp.sources.unix (or misc) in December 1992 or
1303 January 1993. Unless you are a glutton for punishment I would recommend
1304 you avoid the Unix port at this stage.
1305
1306 The other major addition to PDCurses is the support for DJGPP (the DOS
1307 port of GNU C++). Thanks to David Nugent <davidn@csource.oz.au>.
1308
1309 Other additions are copywin() function, function debugging support and
1310 getting the small and medium memory models to work. The testcurs.c demo
1311 program has also been changed significantly and a new demo program,
1312 tuidemo, has been added.
1313
1314 Some people have suggested including information on where to get dmake
1315 from. oak.oakland.edu in /pub/msdos/c
1316
1317 OTHER NOTES:
1318
1319 Under DOS, by default, screen writes to a CGA monitor are done via the
1320 video BIOS rather than by direct video memory writes. This is due to
1321 the CGA "snow" problem. If you have a CGA monitor and do not suffer
1322 from snow, you can compile private\_queryad.c with CGA_DIRECT defined.
1323 This will then use cause PDCurses to write directly to the CGA video
1324 memory.
1325
1326 Function debugging: Firstly to get function debugging, you have to
1327 compile the library with OPT=N in the makefile. This also turns on
1328 compiler debugging. You can control when you want PDCurses to write to
1329 the debug file (called trace in the current directory) by using the
1330 functions traceon() and traceoff() in your program.
1331
1332 Microsoft C 6.00 Users note:
1333 ----------------------------
1334
1335 With the addition of several new functions, using dmake to compile
1336 PDCurses now causes the compiler to run "out of heap space in pass 2".
1337 Using the 6.00AX version (DOS-Extended) to compile PDCurses fixes this
1338 problem; hence the -EM switch.
1339
1340 Functional changes
1341 ------------------
1342
1343 Added OS/2 DLL support.
1344
1345 A few curses functions have been fixed to exhibit their correct
1346 behavior and make them more functionally portable with System V
1347 curses. The functions that have changed are overlay(), overwrite() and
1348 typeahead.
1349
1350 overlay() and overwrite()
1351
1352 Both of theses functions in PDCurses 2.0 allowed for one window to be
1353 effectively placed on top of another, and the characters in the first
1354 window were overlaid or overwritten starting at 0,0 in both windows.
1355 This behavior of these functions was not correct. These functions only
1356 operate on windows that physically overlap with respect to the
1357 displayed screen. To achieve the same functionality as before, use the
1358 new function copywin(). See the manual page for further details.
1359
1360 typeahead()
1361
1362 This function in PDCurses 2.0 effectively checked to see if there were
1363 any characters remaining in the keyboard buffer. This is not the
1364 behavior exhibited by System V curses. This function is intended
1365 purely to set a flag so that curses can check while updating the
1366 physical screen if any keyboard input is pending. To achieve the same
1367 effect with typeahead() under PDCurses 2.1 the following code should be
1368 used.
1369
1370 In place of...
1371
1372 while(!typeahead(stdin))
1373 {
1374 /* do something until any key is pressed... */
1375 }
1376
1377 use...
1378
1379 /* getch() to return ERR if no key pending */
1380 nodelay(stdscr,TRUE);
1381 while(getch() == (ERR))
1382 {
1383 /* do something until any key is pressed... */
1384 }
1385
1386
1387 ACKNOWLEDGEMENTS: (in no particular order)
1388
1389 Jason Shumate, Pieter Kunst, David Nugent, Andreas Otte, Pasi
1390 Hamalainen, James McLennan, Duane Paulson, Ib Hojme
1391
1392 Apologies to anyone I may have left out.
1393
1394 ------------------------------------------------------------------------
1395
1396 PDCurses 2.0 - 1992/11/23
1397 =========================
1398
1399 INTRODUCTION:
1400
1401 Well, here it finally is; PDCurses v2.0.
1402
1403 PDCurses v2.0 is an almost total rewrite of PCcurses 1.4 done by John
1404 'Frotz' Fa'atuai, the previous maintainer. It adds support for OS/2 as
1405 well as DOS.
1406
1407 This version has been tested with Microsoft C v6.0, QuickC v2.0 and
1408 Borland C++ 2.0 under DOS and Microsoft C v6.0 and TopSpeed c v3.02
1409 under OS/2 2.0. Also the library has been compiled successfully with
1410 emx 0.8e, C Set/2 and Watcom 9. Most testing was done with the large
1411 memory model, where applicable. The large memory model is probably the
1412 best model to use.
1413
1414 The amount of testing has not been as extensive as I would have liked,
1415 but demands on releasing a product have outweighed the product's
1416 quality. Nothing new with that !! Hopefully with wider circulation,
1417 more bugs will be fixed more quickly.
1418
1419 I have included just 1 makefile which is suitable for dmake 3.8 for
1420 both DOS and OS/2. The makefile does not rely on customization of the
1421 dmake.ini file.
1422
1423 If you discover bugs, and especially if you have fixes, please let me
1424 know ASAP.
1425
1426 The source to the library is distributed as a zip file made with zip
1427 1.9. You will need Info-ZIP unzip 5.0 to unzip. Follow the directions
1428 below to compile the library.
1429
1430 DIRECTIONS:
1431
1432 1. Create a new directory in which to unzip pdcurs20.zip. This will
1433 create a curses directory and a number of subdirectories containing
1434 source code for the library and utilities and the documentation.
1435
1436 2. Make changes to the makefile where necessary:
1437 Change the MODEL or model macro to the appropriate value (if it
1438 applies to your compiler). Use model for Borland compilers.
1439
1440 Change any paths in the defined macros to be suitable for your
1441 compiler.
1442
1443 3. Invoke DMAKE [-e environment_options] [target]
1444
1445 where environment_options are:
1446
1447 OS (host operating system)
1448 COMP (compiler)
1449 OPT (optimized version or debug version) - optional. default Y
1450 TOS (target operating system) - optional. default OS
1451
1452 see the makefile for valid combinations
1453
1454 targets: all, demos, lcursesd.lib, manual...
1455
1456 NB. dmake is case sensitive with targets, so those environments that
1457 use an upper case model value (eg MSC) MUST specify the library
1458 target as for eg. Lcursesd.lib
1459
1460 The makefile is by default set up for Borland C++. The use of -e
1461 environment_options override these defaults. If you prefer, you can
1462 just change the defaults in the makefile and invoke it without the
1463 -e switch.
1464
1465 OTHER NOTES:
1466
1467 The documentation for the library is built into each source file, a
1468 couple of specific doc files and the header files. A program is
1469 supplied (manext) to build the manual. This program gets compiled when
1470 you build the documentation.
1471
1472 To generate the library response file correctly, I had to write a quick
1473 and dirty program (buildlrf) to achieve this. Originally the makefiles
1474 just had statements like: "echo -+$(OBJ)\$* & >> $(LRF)" which appended
1475 a suitable line to the response file. Unfortunately under some
1476 combinations of makefiles and command processors (eg. nmake and 4DOS)
1477 the & would get treated as stderr and the echo command would fail.
1478
1479 The original source for PDCurses that I received from the previous
1480 maintainer contained support for the FLEXOS operating system. Not
1481 having access to it, I could not test the changes I made so its support
1482 has fallen by the wayside. If you really need to have PDCurses running
1483 under FLEXOS, contact me and I will see what can be arranged.
1484
1485 Under DOS, by default, screen writes to a CGA monitor are done via the
1486 video BIOS rather than by direct video memory writes. This is due to
1487 the CGA "snow" problem. If you have a CGA monitor and do not suffer
1488 from snow, you can compile private\_queryad.c with CGA_DIRECT defined.
1489 This will then use cause PDCurses to write directly to the CGA video
1490 memory.
1491
1492 Added System V color support.
1493
1494 COMPILER-SPECIFIC NOTES:
1495
1496 Microsoft C
1497 -----------
1498
1499 It is possible with MSC 6.0 to build the OS/2 libraries and demo
1500 programs from within DOS. This is the only case where it is possible to
1501 specify the value of TOS on the command line to be OS2 and the value of
1502 OS be DOS.
1503
1504 C Set/2
1505 -------
1506
1507 I have only tested the library using the migration libraries. I doubt
1508 that the demo programs will work without them.
1509
1510 emx
1511 ---
1512
1513 Testing has been done with 0.8e of emx together with the 16_to_32
1514 libraries. The emx\lib directory should include the vio32.lib and
1515 kbd32.lib libraries from the 16_to_32 package.
1516
1517 BUGS and UNFINISHED BUSINESS:
1518
1519 - PDC_set_ctrl_break() function does not work under OS/2.
1520
1521 - win_print() and PDC_print() do not work under OS/2.
1522
1523 - The file todo.man in the doc directory also lists those functions of
1524 System V 3.2 curses not yet implemented. Any volunteers?
1525
1526 ACKNOWLEDGEMENTS:
1527
1528 John 'Frotz' Fa'atuai, the previous maintainer for providing an
1529 excellent base for further development.
1530 John Burnell <johnb@kea.am.dsir.govt.nz>, for the OS/2 port.
1531 John Steele, Jason (finally NOT a John) Shumate....
1532 for various fixes and suggestions.
1533 Eberhardt Mattes (author of emx) for allowing code based on his
1534 C library to be included with PDCurses.
1535 Several others for their support, moral and actual.
1536
1537 -- Mark Hessling
1538
1539 ------------------------------------------------------------------------
1540
1541 PDCurses 2.0Beta - 1991/12/21
1542 =============================
1543
1544 Changed back from short to int. (int is the correct size for the default
1545 platform. Short might be too short on some platforms. This is more
1546 portable. I, also, made this mistake.)
1547
1548 Many functions are now macros. If you want the real thing, #undef the
1549 macro. (X/Open requirement.)
1550
1551 Merged many sources into current release.
1552
1553 Added many X/Open routines (not quite all yet).
1554
1555 Added internal documentation to all routines.
1556
1557 Added a HISTORY file to the environment.
1558
1559 Added a CONTRIB file to the environment.
1560
1561 ------------------------------------------------------------------------
1562
1563 PDCurses 1.5Beta - 1990/07/14
1564 =============================
1565
1566 Added many levels of compiler support. Added mixed prototypes for all
1567 "internal" routines. Removed all assembly language. Added EGA/VGA
1568 support. Converted all #ifdef to #if in all modules except CURSES.H and
1569 CURSPRIV.H. Always include ASSERT.H. Added support for an external
1570 malloc(), calloc() and free(). Added support for FAST_VIDEO
1571 (direct-memory writes). Added various memory model support (for
1572 FAST_VIDEO). Added much of the December 1988 X/Open Curses
1573 specification.
1574
1575 -- John 'Frotz' Fa'atuai
1576
1577 ------------------------------------------------------------------------
1578
1579 PCcurses 1.4 - 1990/01/14
1580 =========================
1581
1582 In PCcurses v.1.4, both portability improvements and bugfixes have
1583 been made. The files have been changed to allow lint-free compilation
1584 with Microsoft C v.5.1, and with Turbo C v.2.0. The source should still
1585 compile without problems on older compilers, although this has not been
1586 verified.
1587
1588 The makefiles have been changed to suit both the public release and
1589 the author, who maintains a special kind of libraries for himself. In
1590 the case of Microsoft C, changes were done in the makefile to lower the
1591 warning level to 2 (was 3). This was to avoid ANSI warnings which are
1592 abundant because PCcurses does not attempt to follow strict ANSI C
1593 standard.
1594
1595 BUG FIXES FROM V.1.3 TO V.1.4:
1596
1597 !!!IMPORTANT CHANGE!!!
1598
1599 The definitions for OK and ERR in curses.h were exchanged. This was
1600 done to be more consistent with UNIX versions. Also, it permits
1601 functions like newwin() and subwin() to return 0 (=NULL) when they fail
1602 due to memory shortage. This incompatibility with UNIX curses was
1603 pointed out by Fred C. Smith. If you have tested success/failure by
1604 comparisons to anything other than ERR and OK, your applications will
1605 need to be be changed on that point. Sorry... but presumably most of you
1606 used the symbolic constants?
1607
1608 (END OF IMPORTANT CHANGE)
1609
1610 Fred also pointed out a bug in the file update.c. The bug caused the
1611 first character printed after 'unauthorized' screen changes (like during
1612 a shell escape, for example) to be placed at the wrong screen position.
1613 This happened even if the normal precautions (clear / touch / refresh)
1614 were taken. The problem has now been fixed.
1615
1616 PCcurses is currently also being used on a 68000 system with
1617 hard-coded ESCape sequences for ANSI terminals. However, ints used by
1618 the 68000 C compiler are 32 bits. Therefore ints have been turned into
1619 shorts wherever possible in the code (otherwise all window structures
1620 occupy twice as much space as required on the 68000). This does not
1621 affect PC versions since normally both ints and shorts are 16 bits for
1622 PC C compilers.
1623
1624 At some places in the source code there are references made to the
1625 68000 version. There are also a makefile, a curses68.c file, and a
1626 curses68.cmd file. These are for making, low-level I/O, and linking
1627 commands when building the 68000 version. These files are probably
1628 useful to no-one but the author, since it is very specific for its
1629 special hardware environment. Still in an effort to keep all
1630 curses-related sources in one place they are included. Note however that
1631 PCcurses will not officially support a non-PC environment.
1632
1633 The file cursesio.c, which was included in the package at revision
1634 level 1.2, and which was to be an alternative to the cursesio.asm file,
1635 has been verified to behave incorrectly in the function _curseskeytst().
1636 The problem was that the value of 'cflag' does not contain the proper
1637 data for the test that is attempted. Furthermore, neither Turbo C or
1638 Microsoft C allows any way to return the data that is needed, and
1639 consequently you should not use cursesio.c. The best solution is to
1640 simply use the ASM version. In v.1.2 and v.1.3, the user could edit the
1641 makefile to select which version he wanted to use. The makefiles in
1642 v.1.4 have removed this possibility forcing the use of the ASM file, and
1643 cursesio.c has been dropped from the distribution.
1644
1645 A bug in the wgetstr() function caused PCcurses to echo characters
1646 when reading a keyboard string, even if the echo had been turned off.
1647 Thanks to Per Foreby at Lund University, Sweden, for this. Per also
1648 reported bugs concerning the handling of characters with bit 8 set.
1649 Their ASCII code were considered as lower than 32, so they were erased
1650 etc. like control characters, i.e. erasing two character positions. The
1651 control character test was changed to cope with this.
1652
1653 The overlay() and overwrite() functions were changed so that the
1654 overlaying window is positioned at its 'own' coordinates inside the
1655 underlying window (it used to be at the underlying window's [0,0]
1656 position). There is some controversy about this - the documentation for
1657 different curses versions say different things. I think the choice made
1658 is the most reasonable.
1659
1660 The border() and wborder() functions were changed to actually draw a
1661 border, since this seems to be the correct behavior of these functions.
1662 They used to just set the border characters to be used by box(). These
1663 functions are not present in standard BSD UNIX curses.
1664
1665 The subwin() function previously did not allow the subwindow to be as
1666 big as the original window in which it was created. This has now been
1667 fixed. There was also the problem that the default size (set by
1668 specifying numlines or numcols (or both) as 0 made the resulting actual
1669 size 1 line/column too small.
1670
1671 There were a few spelling errors in function names, both in the
1672 function declarations and in curses.h. This was reported by Carlos
1673 Amaral at INESC in Portugal. Thanks! There was also an unnecessary (but
1674 harmless) parameter in a function call at one place.
1675
1676 ------------------------------------------------------------------------
1677
1678 PCcurses 1.3 - 1988/10/05
1679 =========================
1680
1681 The file 'border.c' is now included. It allows you to explicitly
1682 specify what characters should be used as box borders when the box()
1683 functions are called. If the new border characters are non-0, they
1684 override the border characters specified in the box() call. In my
1685 understanding, this functionality is required for AT&T UNIX sV.3
1686 compatibility. Thanks for this goes to Tony L. Hansen
1687 (hansen@pegasus.UUCP) for posting an article about it on Usenet
1688 (newsgroup comp.unix.questions; his posting was not related at all to
1689 PCcurses).
1690
1691 The only other difference between v.1.2 and v.1.3 is that the latter
1692 has been changed to avoid warning diagnostics if the source files are
1693 compiled with warning switches on (for Microsoft this means '-W3', for
1694 Turbo C it means '-w -w-pro'). Of these, the Turbo C warning check is
1695 clearly to be used rather than Microsoft, even if neither of them comes
1696 even close to a real UNIX 'lint'. Some of the warnings in fact indicated
1697 real bugs, mostly functions that did not return correct return values or
1698 types.
1699
1700 The makefiles for both MSC and TRC have been modified to produce
1701 warning messages as part of normal compilation.
1702
1703 ------------------------------------------------------------------------
1704
1705 PCcurses 1.2 - 1988/10/02
1706 =========================
1707
1708 The changes from v.1.1 to v.1.2 are minor. The biggest change is that
1709 there was a bug related to limiting the cursor movement if the
1710 application tried to move it outside the screen (something that should
1711 not be done anyway). Such erroneous application behavior is now handled
1712 appropriately.
1713
1714 All modules have been changed to have a revision string in them, which
1715 makes it easier to determine what version is linked into a program (or
1716 what library version you have).
1717
1718 There is now a 'cursesio.c' file. That file does the same as
1719 'cursesio.asm' (i.e. it provides the interface to the lower-level system
1720 I/O routines). It is written in C and thus it is (possibly) more
1721 portable than the assembler version (but still not so portable since it
1722 uses 8086 INT XX calls directly). When one creates new curses libraries,
1723 one chooses whether to use the assembler or the C version of cursesio.
1724 The choice is made by commenting out the appropriate dependencies for
1725 cursesio.obj, near the end of the makefiles.
1726
1727 There is now a 'setmode.c' file. That file contains functions that
1728 save and restore terminal modes. They do it into other variables than do
1729 savetty() and resetty(), so one should probably use either
1730 savetty()/resetty() or the new functions only - and not mix the both
1731 ways unless one really knows what one does.
1732
1733 Diff lists vs v.1.0 are no longer included in the distribution. The
1734 make utility still is. PCcurses v.1.2 still compiles with Microsoft C
1735 v.4.0, and with Borland Turbo C v.1.0. There is as far as I know no
1736 reason to believe that it does not compile under Microsoft C v.3.0 and
1737 5.x, or Turbo C v.1.5, but this has not been tested.
1738
1739 There are two makefiles included, one for Microsoft C, one for Turbo
1740 C. They are both copies of my personal makefiles, and as such they
1741 reflect the directory structure on my own computer. This will have to be
1742 changed before you run make. Check $(INCDIR) and $(LIBDIR) in
1743 particular, and make the choice of ASM or C cursesio version as
1744 mentioned above (the distribution version uses the C version of
1745 cursesio).
1746
1747 The manual file (curses.man) has been changed at appropriate places.
1748
1749 I would like to thank the following persons for their help:
1750
1751 Brandon S. Allbery (alberry@ncoast.UUCP)
1752 for running comp.binaries.ibm.pc (at that time)
1753 and comp.source.misc.
1754
1755 Steve Balogh (Steve@cit5.cit.oz.AU)
1756 for writing a set of manual pages and posting
1757 them to the net.
1758
1759 Torbjorn Lindh
1760 for finding bugs and suggesting raw
1761 character output routines.
1762
1763 Nathan Glasser (nathan@eddie.mit.edu)
1764 for finding and reporting bugs.
1765
1766 Ingvar Olafsson (...enea!hafro!ingvar)
1767 for finding and reporting bugs.
1768
1769 Eric Rosco (...enea!ipmoea!ericr)
1770 for finding and reporting bugs.
1771
1772 Steve Creps (creps@silver.bacs.indiana.edu)
1773 for doing a lot of work - among others
1774 posting bug fixes to the net, and writing
1775 the new cursesio.c module.
1776
1777 N. Dean Pentcheff (dean@violet.berkeley.edu)
1778 for finding bugs and rewriting cursesio.asm
1779 for Turbo 'C' 1.5.
1780
1781 Finally, Jeff Dean (parcvax,hplabs}!cdp!jeff)
1782 (jeff@ads.arpa)
1783 has had a shareware version of curses deliverable since
1784 about half a year before I released PCcurses 1.0 on Use-
1785 Net. He is very concerned about confusion between the two
1786 packages, and therefore any references on the network
1787 should make clear whether they reference Dean's PCcurses
1788 or Larsson's PCcurses.
1789
1790 ------------------------------------------------------------------------
1791
1792 PCcurses 1.1 - 1988/03/06
1793 =========================
1794
1795 The changes from v.1.0 to v.1.1 are minor. There are a few bug fixes,
1796 and new (non-portable) functions for verbatim IBM character font display
1797 have been added (in charadd.c and charins.c). The manual file
1798 (curses.man) has been changed at appropriate places.
1799
1800 In the file v10tov11.dif there are listings of the differences between
1801 version 1.0 and 1.1. The diff listings are in UNIX diff(1) format.
1802
1803 Version 1.1 compiles with Turbo C v.1.0, as well as Microsoft C v.3.0
1804 and v.4.0. On the release disk there is a make.exe utility which is very
1805 similar to UNIX make (If the package was mailed to you, the make utility
1806 will be in uuencoded format - in make.uu - and must be uudecoded first).
1807 It is much more powerful than Microsoft's different MAKEs; the latter
1808 ones will NOT generate libraries properly if used with the PCcurses
1809 makefiles.
1810
1811 There are three makefiles:
1812
1813 makefile generic MSC 3.0 makefile
1814 makefile.ms MSC 4.0 makefile
1815 makefile.tc Turbo C 1.0 makefile
1816
1817 To make a library with for example Turbo C, make directories to hold
1818 .H and .LIB files (these directories are the 'standard places'), edit
1819 makefile.tc for this, and type
1820
1821 make -f makefile.tc all
1822
1823 and libraries for all memory models will be created in the .LIB
1824 directory, while the include files will end up in the .H directory. Also
1825 read what is said about installation below!
1826
1827 ------------------------------------------------------------------------
1828
1829 PCcurses 1.0 - 1987/08/24
1830 =========================
1831
1832 This is the release notes for the PCcurses v.1.0 cursor/window control
1833 package. PCcurses offers the functionality of UNIX curses, plus some
1834 extras. Normally it should be possible to port curses-based programs
1835 from UNIX curses to PCcurses on the IBM PC without changes. PCcurses is
1836 a port/ rewrite of Pavel Curtis' public domain 'ncurses' package. All
1837 the code has been re-written - it is not just an edit of ncurses (or
1838 UNIX curses). I mention this to clarify any copyright violation claims.
1839 The data structures and ideas are very similar to ncurses. As for UNIX
1840 curses, I have not even seen any sources for it.
1841
1842 For an introduction to the use of 'curses' and its derivatives, you
1843 should read 'Screen Updating and Cursor Movement Optimization: A Library
1844 Package' by Kenneth C. R. C. Arnold, which describes the original
1845 Berkeley UNIX version of curses. It is available as part of the UNIX
1846 manuals. The other source of information is 'The Ncurses Reference
1847 Manual' by Pavel Curtis. The latter is part of Curtis' ncurses package.
1848
1849 The only other documentation provided is a 'man' page which describes
1850 all the included functions in a very terse way. In the sources, each
1851 function is preceded by a rather thorough description of what the
1852 function does. I didn't have time to write a nice manual/tutorial -
1853 sorry.
1854
1855 PCcurses is released as a number of source files, a man page, and a
1856 make file. A uuencoded copy of a 'make' utility, and a manpage for the
1857 'make' is also provided to make it easier to put together PCcurses
1858 libraries. Even if you are not interested in PCcurses, it may be
1859 worthwhile to grab the make.
1860
1861 The makefile assumes the presence of the Microsoft C compiler (3.0 or
1862 4.0), Microsoft MASM and LIB, plus some MS-DOS utilities. The reason for
1863 supplying MAKE.EXE is that the Microsoft 'MAKE:s' are much inferior to a
1864 real UNIX make. The supplied make is a port of a public domain make,
1865 published on Usenet. It is almost completely compatible with UNIX make.
1866 When generating the curses libraries, the makefile will direct make to
1867 do some directory creating and file copying, and then re-invoke itself
1868 with new targets. The workings of the makefile are not absolutely
1869 crystal clear at first sight... just start it and see what it does.
1870
1871 For portability, the curses libraries depend on one assembler file for
1872 access to the BIOS routines. There is no support for the EGA, but both
1873 CGA, MGA, and the HGA can be used. The libraries are originally for
1874 Microsoft C, but all C modules should be portable right away. In the
1875 assembler file, segment names probably need to be changed, and possibly
1876 the parameter passing scheme. I think Turbo C will work right away - as
1877 far as I understand, all its conventions are compatible with Microsoft
1878 C.
1879
1880 There are some parts left out between ncurses and PCcurses. One is the
1881 support for multiple terminals - not very interesting on a PC anyway.
1882 Because we KNOW what terminal we have, there is no need for a termcap or
1883 terminfo library. PCcurses also has some things that neither curses nor
1884 ncurses have. Compared to the original UNIX curses, PCcurses has lots of
1885 extras.
1886
1887 The BIOS routines are used directly, which gives fast screen updates.
1888 PCcurses does not do direct writes to screen RAM - in my opinion it is
1889 a bit ugly to rely that much on hardware compatibility. Anyone could fix
1890 that, of course...
1891
1892 One of the more serious problems with PCcurses is the way in which
1893 normal, cbreak, and raw input modes are done. All those details are in
1894 the 'charget' module - I do raw I/O via the BIOS, and perform any
1895 buffering myself. If an application program uses PCcurses, it should do
1896 ALL its I/O via PCcurses calls, otherwise the mix of normal and
1897 PCcurses I/O may mess up the display. I think my code is reasonable...
1898 comments are welcome, provided you express them nicely...
1899
1900 To install, copy all files to a work directory, edit 'makefile' to
1901 define the standard include and library file directory names of your
1902 choice (these directories must exist already, and their path names must
1903 be relative to the root directory, not to the current one). You must
1904 also run uudecode on make.uu, to generate MAKE.EXE. You can do that on
1905 your PC, if you have uudecode there, otherwise you can do it under UNIX
1906 and do a binary transfer to the PC. When you have MAKE.EXE in your work
1907 directory (or in your /bin directory), type make.
1908
1909 Make will now create 4 sub-directories (one for each memory model),
1910 copy some assembler include files into them, copy two include files to
1911 your include directory, CHDIR to each sub-directory and re-invoke itself
1912 with other make targets to compile and assemble all the source files
1913 into the appropriate directories. Then the library manager is run to
1914 create the library files in your desired library directory. Presto!
1915
1916 If you only want to generate a library for one memory model, type
1917 'make small', 'make large', etc. The name of the memory model must be in
1918 lower case, like in the makefile.
1919
1920 I think the package is fairly well debugged - but then again, that's
1921 what I always think. It was completed in May-87, and no problems found
1922 yet. Now it's your turn... Comments, suggestions and bug reports and
1923 fixes (no flames please) to
1924
1925 -- Bjorn Larsson
File IMPLEMNT added (mode: 100644) (index 00000000..0445f8bb)
1 PDCurses Implementor's Guide
2 ============================
3
4 Version 1.3 - 200?/??/?? - notes about official ports
5 Version 1.2 - 2007/07/11 - added PDC_init_pair(), PDC_pair_content(),
6 version history; removed pdc_atrtab
7 Version 1.1 - 2007/06/06 - minor cosmetic change
8 Version 1.0 - 2007/04/01 - initial revision
9
10 This document is for those wishing to port PDCurses to a new platform,
11 or just wanting to better understand how it works. Nothing here should
12 be needed for application programming; for that, refer to PDCurses.txt,
13 as built in doc/, or distributed as a file separate from this source
14 package. This document assumes that you've read the user-level
15 documentation and are very familiar with application-level curses
16 programming.
17
18 If you want to submit your port for possible inclusion into the main
19 PDCurses distribution, please follow these guidelines:
20
21 - Don't modify anything in the pdcurses directory or in other port
22 directories. Don't modify curses.h or curspriv.h unless absolutely
23 necessary. (And prefer modifying curspriv.h over curses.h.)
24
25 - Use the same indentation style, naming and scope conventions as the
26 existing code.
27
28 - Release all your code to the public domain -- no copyright. Code
29 under GPL, BSD, etc. will not be accepted.
30
31
32 DATA STRUCTURES
33 ---------------
34
35 A port of PDCurses must provide acs_map[], a 128-element array of
36 chtypes, with values laid out based on the Alternate Character Set of
37 the VT100 (see curses.h). PDC_transform_line() must use this table; when
38 it encounters a chtype with the A_ALTCHARSET flag set, and an A_CHARTEXT
39 value in the range 0-127, it must render it using the A_CHARTEXT portion
40 of the corresponding value from this table, instead of the original
41 value. Also, values may be read from this table by apps, and passed
42 through functions such as waddch(), which does no special processing on
43 control characters (0-31 and 127) when the A_ALTCHARSET flag is set.
44 Thus, any control characters used in acs_map[] should also have the
45 A_ALTCHARSET flag set. Implementations should provide suitable values
46 for all the ACS_ macros defined in curses.h; other values in the table
47 should be filled with their own indices (e.g., acs_map['E'] == 'E'). The
48 table can be either hardwired, or filled by PDC_scr_open(). Existing
49 ports define it in pdcdisp.c, but this is not required.
50
51
52 FUNCTIONS
53 ---------
54
55 A port of PDCurses must implement the following functions, with extern
56 scope. These functions are traditionally divided into several modules,
57 as indicated below; this division is not required (only the functions
58 are), but may make it easier to follow for someone familiar with the
59 existing ports.
60
61 Any other functions you create as part of your implementation should
62 have static scope, if possible. If they can't be static, they should be
63 named with the "PDC_" prefix. This minimizes the risk of collision with
64 an application's choices.
65
66 Current PDCurses style also uses a single leading underscore with the
67 name of any static function; and modified BSD/Allman-style indentation,
68 approximately equivalent to "indent -kr -i8 -bl -bli0", with adjustments
69 to keep every line under 80 columns. This isn't essential, but a
70 consistent style helps readability.
71
72
73 pdcdisp.c:
74 ----------
75
76 void PDC_gotoyx(int y, int x);
77
78 Move the physical cursor (as opposed to the logical cursor affected by
79 wmove()) to the given location. This is called mainly from doupdate().
80 In general, this function need not compare the old location with the new
81 one, and should just move the cursor unconditionally.
82
83 void PDC_transform_line(int lineno, int x, int len, const chtype *srcp);
84
85 The core output routine. It takes len chtype entities from srcp (a
86 pointer into curscr) and renders them to the physical screen at line
87 lineno, column x. It must also translate characters 0-127 via acs_map[],
88 if they're flagged with A_ALTCHARSET in the attribute portion of the
89 chtype.
90
91
92 pdcgetsc.c:
93 -----------
94
95 int PDC_get_columns(void);
96
97 Returns the size of the screen in columns. It's used in resize_term() to
98 set the new value of COLS. (Some existing implementations also call it
99 internally from PDC_scr_open(), but this is not required.)
100
101 int PDC_get_cursor_mode(void);
102
103 Returns the size/shape of the cursor. The format of the result is
104 unspecified, except that it must be returned as an int. This function is
105 called from initscr(), and the result is stored in SP->orig_cursor,
106 which is used by PDC_curs_set() to determine the size/shape of the
107 cursor in normal visibility mode (curs_set(1)).
108
109 int PDC_get_rows(void);
110
111 Returns the size of the screen in rows. It's used in resize_term() to
112 set the new value of LINES. (Some existing implementations also call it
113 internally from PDC_scr_open(), but this is not required.)
114
115
116 pdckbd.c:
117 ---------
118
119 bool PDC_check_key(void);
120
121 Keyboard/mouse event check, called from wgetch(). Returns TRUE if
122 there's an event ready to process. This function must be non-blocking.
123
124 void PDC_flushinp(void);
125
126 This is the core of flushinp(). It discards any pending key or mouse
127 events, removing them from any internal queue and from the OS queue, if
128 applicable.
129
130 int PDC_get_key(void);
131
132 Get the next available key, or mouse event (indicated by a return of
133 KEY_MOUSE), and remove it from the OS' input queue, if applicable. This
134 function is called from wgetch(). This function may be blocking, and
135 traditionally is; but it need not be. If a valid key or mouse event
136 cannot be returned, for any reason, this function returns -1. Valid keys
137 are those that fall within the appropriate character set, or are in the
138 list of special keys found in curses.h (KEY_MIN through KEY_MAX). When
139 returning a special key code, this routine must also set SP->key_code to
140 TRUE; otherwise it must set it to FALSE. If SP->return_key_modifiers is
141 TRUE, this function may return modifier keys (shift, control, alt),
142 pressed alone, as special key codes; if SP->return_key_modifiers is
143 FALSE, it must not. If modifier keys are returned, it should only happen
144 if no other keys were pressed in the meantime; i.e., the return should
145 happen on key up. But if this is not possible, it may return the
146 modifier keys on key down (if and only if SP->return_key_modifiers is
147 TRUE).
148
149 int PDC_modifiers_set(void);
150
151 Called from PDC_return_key_modifiers(). If your platform needs to do
152 anything in response to a change in SP->return_key_modifiers, do it
153 here. Returns OK or ERR, which is passed on by the caller.
154
155 int PDC_mouse_set(void);
156
157 Called by mouse_set(), mouse_on(), and mouse_off() -- all the functions
158 that modify SP->_trap_mbe. If your platform needs to do anything in
159 response to a change in SP->_trap_mbe (for example, turning the mouse
160 cursor on or off), do it here. Returns OK or ERR, which is passed on by
161 the caller.
162
163 void PDC_set_keyboard_binary(bool on);
164
165 Set keyboard input to "binary" mode. If you need to do something to keep
166 the OS from processing ^C, etc. on your platform, do it here. TRUE turns
167 the mode on; FALSE reverts it. This function is called from raw() and
168 noraw().
169
170
171 pdcscrn.c:
172 ----------
173
174 bool PDC_can_change_color(void);
175
176 Returns TRUE if init_color() and color_content() give meaningful
177 results, FALSE otherwise. Called from can_change_color().
178
179 int PDC_color_content(short color, short *red, short *green, short *blue);
180
181 The core of color_content(). This does all the work of that function,
182 except checking for values out of range and null pointers.
183
184 int PDC_init_color(short color, short red, short green, short blue);
185
186 The core of init_color(). This does all the work of that function,
187 except checking for values out of range.
188
189 void PDC_init_pair(short pair, short fg, short bg);
190
191 The core of init_pair(). This does all the work of that function, except
192 checking for values out of range. The values passed to this function
193 should be returned by a call to PDC_pair_content() with the same pair
194 number. PDC_transform_line() should use the specified colors when
195 rendering a chtype with the given pair number.
196
197 int PDC_pair_content(short pair, short *fg, short *bg);
198
199 The core of pair_content(). This does all the work of that function,
200 except checking for values out of range and null pointers.
201
202 void PDC_reset_prog_mode(void);
203
204 The non-portable functionality of reset_prog_mode() is handled here --
205 whatever's not done in _restore_mode(). In current ports: In OS/2, this
206 sets the keyboard to binary mode; in Win32, it enables or disables the
207 mouse pointer to match the saved mode; in others it does nothing.
208
209 void PDC_reset_shell_mode(void);
210
211 The same thing, for reset_shell_mode(). In OS/2 and Win32, it restores
212 the default console mode; in others it does nothing.
213
214 int PDC_resize_screen(int nlines, int ncols);
215
216 This does the main work of resize_term(). It may respond to non-zero
217 parameters, by setting the screen to the specified size; to zero
218 parameters, by setting the screen to a size chosen by the user at
219 runtime, in an unspecified way (e.g., by dragging the edges of the
220 window); or both. It may also do nothing, if there's no appropriate
221 action for the platform.
222
223 void PDC_restore_screen_mode(int i);
224
225 Called from _restore_mode() in kernel.c, this function does the actual
226 mode changing, if applicable. Currently used only in DOS and OS/2.
227
228 void PDC_save_screen_mode(int i);
229
230 Called from _save_mode() in kernel.c, this function saves the actual
231 screen mode, if applicable. Currently used only in DOS and OS/2.
232
233 void PDC_scr_close(void);
234
235 The platform-specific part of endwin(). It may restore the image of the
236 original screen saved by PDC_scr_open(), if the PDC_RESTORE_SCREEN
237 environment variable is set; either way, if using an existing terminal,
238 this function should restore it to the mode it had at startup, and move
239 the cursor to the lower left corner. (The X11 port does nothing.)
240
241 void PDC_scr_free(void);
242
243 Frees the memory for SP allocated by PDC_scr_open(). Called by
244 delscreen().
245
246 int PDC_scr_open(int argc, char **argv);
247
248 The platform-specific part of initscr(). It's actually called from
249 Xinitscr(); the arguments, if present, correspond to those used with
250 main(), and may be used to set the title of the terminal window, or for
251 other, platform-specific purposes. (The arguments are currently used
252 only in X11.) PDC_scr_open() must allocate memory for SP, and must
253 initialize acs_map[] (unless it's preset) and several members of SP,
254 including lines, cols, mouse_wait, orig_attr (and if orig_attr is TRUE,
255 orig_fore and orig_back), mono, _restore and _preserve. (Although SP is
256 used the same way in all ports, it's allocated here in order to allow
257 the X11 port to map it to a block of shared memory.) If using an
258 existing terminal, and the environment variable PDC_RESTORE_SCREEN is
259 set, this function may also store the existing screen image for later
260 restoration by PDC_scr_close().
261
262
263 pdcsetsc.c:
264 -----------
265
266 int PDC_curs_set(int visibility);
267
268 Called from curs_set(). Changes the appearance of the cursor -- 0 turns
269 it off, 1 is normal (the terminal's default, if applicable, as
270 determined by SP->orig_cursor), and 2 is high visibility. The exact
271 appearance of these modes is not specified.
272
273
274 pdcutil.c:
275 ----------
276
277 void PDC_beep(void);
278
279 Emits a short audible beep. If this is not possible on your platform,
280 you must set SP->audible to FALSE during initialization (i.e., from
281 PDC_scr_open() -- not here); otherwise, set it to TRUE. This function is
282 called from beep().
283
284 void PDC_napms(int ms);
285
286 This is the core delay routine, called by napms(). It pauses for about
287 (the X/Open spec says "at least") ms milliseconds, then returns. High
288 degrees of accuracy and precision are not expected (though desirable, if
289 you can achieve them). More important is that this function gives back
290 the process' time slice to the OS, so that PDCurses idles at low CPU
291 usage.
292
293 const char *PDC_sysname(void);
294
295 Returns a short string describing the platform, such as "DOS" or "X11".
296 This is used by longname(). It must be no more than 100 characters; it
297 should be much, much shorter (existing platforms use no more than 5).
298
299 --------------------------------------------------------------------------
300
301 The following functions are implemented in the platform directories, but
302 are accessed directly by apps. Refer to the user documentation for their
303 descriptions:
304
305
306 pdcclip.c:
307 ----------
308
309 int PDC_clearclipboard(void);
310 int PDC_freeclipboard(char *contents);
311 int PDC_getclipboard(char **contents, long *length);
312 int PDC_setclipboard(const char *contents, long length);
313
314
315 pdckbd.c:
316 ---------
317
318 unsigned long PDC_get_input_fd(void);
319
320
321 pdcsetsc.c:
322 -----------
323
324 int PDC_set_blink(bool blinkon);
325 void PDC_set_title(const char *title);
File Makefile.in added (mode: 100644) (index 00000000..dc40abfb)
1 # Makefile for PDCurses library for X11
2
3 SHELL = @SHELL@
4
5 @SET_MAKE@
6
7 srcdir =@srcdir@
8 prefix =@prefix@
9 exec_prefix =$(DESTDIR)@exec_prefix@
10 libdir =$(exec_prefix)/lib
11 bindir =$(exec_prefix)/bin
12 includedir =$(exec_prefix)/include
13 pdcursesdir =./x11
14
15 INSTALL =$(srcdir)/install-sh
16 RANLIB =@RANLIB@
17 SHLPRE = @SHLPRE@
18 SHLPST = @SHLPST@
19 SHLFILE = XCurses
20
21 include $(srcdir)/version.mif
22
23 PDC_DIR=PDCurses-$(VERDOT)
24
25 ZIPFILE = pdcurs$(VER).zip
26 TARBALL = $(PDC_DIR).tar.gz
27
28 all \
29 clean \
30 distclean \
31 mostlyclean \
32 realclean ::
33 cd x11; $(MAKE) $(MFLAGS) $@
34 cd doc; $(MAKE) $(MFLAGS) $@
35
36 install ::
37 $(INSTALL) -d -m 755 $(libdir)
38 $(INSTALL) -d -m 755 $(bindir)
39 $(INSTALL) -d -m 755 $(includedir)
40 $(INSTALL) -d -m 755 $(includedir)/xcurses
41 $(INSTALL) -c -m 644 $(srcdir)/curses.h $(includedir)/xcurses.h
42 $(INSTALL) -c -m 644 $(srcdir)/curses.h $(includedir)/xcurses/curses.h
43 sed -e 's/#include <curses.h>/#include <xcurses.h>/' \
44 < $(srcdir)/panel.h > ./xpanel.h
45 $(INSTALL) -m 644 ./xpanel.h $(includedir)/xpanel.h
46 $(INSTALL) -c -m 644 $(srcdir)/panel.h $(includedir)/xcurses/panel.h
47 $(INSTALL) -c -m 644 $(srcdir)/term.h $(includedir)/xcurses/term.h
48 $(INSTALL) -c -m 644 $(pdcursesdir)/libXCurses.a $(libdir)/libXCurses.a
49 -$(RANLIB) $(libdir)/libXCurses.a
50 -$(INSTALL) -c -m 755 $(pdcursesdir)/$(SHLPRE)$(SHLFILE)$(SHLPST) \
51 $(libdir)/$(SHLPRE)$(SHLFILE)$(SHLPST)
52 ln -f -s $(libdir)/$(SHLPRE)$(SHLFILE)$(SHLPST) \
53 $(libdir)/$(SHLPRE)Xpanel$(SHLPST)
54 ln -f -s $(libdir)/libXCurses.a $(libdir)/libXpanel.a
55 -$(RANLIB) $(libdir)/libXpanel.a
56 $(INSTALL) -c -m 755 x11/xcurses-config $(bindir)/xcurses-config
57
58 clean ::
59 rm -f config.log config.cache config.status
60
61 distclean ::
62 rm -f config.log config.cache config.status
63 rm -f config.h Makefile x11/xcurses-config
64
65 manual:
66 cd doc; $(MAKE) $(MFLAGS) $@
67
68 $(ZIPFILE):
69 zip -9y $(ZIPFILE) README HISTORY IMPLEMNT *.spec *.mif *.def \
70 Makefile.in config.h.in configure configure.ac config.guess \
71 config.sub x11/xcurses-config.in install-sh aclocal.m4 curses.h \
72 curspriv.h panel.h term.h pdcurses/README \
73 pdcurses/*.c demos/README demos/*.c demos/*.h dos/README dos/*.c \
74 dos/*.h dos/*.mak dos/*.lrf os2/README os2/*.c os2/*.h os2/*.mak \
75 os2/*.lrf sdl1/README sdl1/*.c sdl1/*.h sdl1/Make* \
76 win32/README win32/*.c win32/*.h win32/*.mak \
77 win32/*.ico win32/*.rc x11/README x11/*.c x11/*.h x11/Makefile.* \
78 x11/*.xbm doc/*.txt doc/manext.c doc/Makefile
79
80 zip: $(ZIPFILE)
81
82 ../$(TARBALL):
83 (cd ..; tar cvf - $(PDC_DIR)/README $(PDC_DIR)/HISTORY \
84 $(PDC_DIR)/IMPLEMNT $(PDC_DIR)/*.spec $(PDC_DIR)/*.mif \
85 $(PDC_DIR)/*.def $(PDC_DIR)/Makefile.in $(PDC_DIR)/aclocal.m4 \
86 $(PDC_DIR)/config.h.in $(PDC_DIR)/configure \
87 $(PDC_DIR)/config.guess $(PDC_DIR)/x11/xcurses-config.in \
88 $(PDC_DIR)/config.sub $(PDC_DIR)/configure.ac \
89 $(PDC_DIR)/install-sh $(PDC_DIR)/curses.h $(PDC_DIR)/curspriv.h \
90 $(PDC_DIR)/panel.h $(PDC_DIR)/term.h \
91 $(PDC_DIR)/pdcurses/README $(PDC_DIR)/pdcurses/*.c \
92 $(PDC_DIR)/demos/README $(PDC_DIR)/demos/*.c $(PDC_DIR)/demos/*.h \
93 $(PDC_DIR)/doc/*.txt $(PDC_DIR)/dos/README $(PDC_DIR)/dos/*.c \
94 $(PDC_DIR)/dos/*.h $(PDC_DIR)/dos/*.mak $(PDC_DIR)/dos/*.lrf \
95 $(PDC_DIR)/os2/README $(PDC_DIR)/os2/*.c $(PDC_DIR)/os2/*.h \
96 $(PDC_DIR)/os2/*.mak $(PDC_DIR)/os2/*.lrf \
97 $(PDC_DIR)/sdl1/README $(PDC_DIR)/sdl1/*.c $(PDC_DIR)/sdl1/*.h \
98 $(PDC_DIR)/sdl1/Make* $(PDC_DIR)/win32/README $(PDC_DIR)/win32/*.c \
99 $(PDC_DIR)/win32/*.h $(PDC_DIR)/win32/*.mak \
100 $(PDC_DIR)/win32/*.ico $(PDC_DIR)/win32/*.rc $(PDC_DIR)/x11/README \
101 $(PDC_DIR)/x11/*.c $(PDC_DIR)/x11/*.xbm $(PDC_DIR)/x11/*.h \
102 $(PDC_DIR)/x11/Makefile.* $(PDC_DIR)/doc/manext.c \
103 $(PDC_DIR)/doc/Makefile | gzip -9 > $(TARBALL))
104
105 dist: ../$(TARBALL)
106
107 rpm: ../$(TARBALL)
108 rpmbuild -ba $(srcdir)/PDCurses.spec
File PDCurses.spec added (mode: 100644) (index 00000000..814e313f)
1 # $Id: PDCurses.spec,v 1.18 2008/07/21 12:25:20 wmcbrine Exp $
2
3 %define ver 34
4 %define verdot 3.4
5 %define base /usr
6
7 Summary: Public Domain Curses for X11
8 Name: PDCurses
9 Version: %verdot
10 Release: 1
11 Copyright: Public Domain
12 Group: Development/Libraries
13 Source: %{name}-%{version}.tar.gz
14 URL: http://pdcurses.sourceforge.net
15 BuildRoot: %{_tmppath}/%{name}-%{version}-root
16 Prefix: %base
17
18 %description
19 PDCurses for X11 is an implementation of the curses library that lets
20 you build text-mode curses programs as native X11 applications. For more
21 information, visit http://pdcurses.sourceforge.net/
22
23 %prep
24 %setup -q
25
26 %build
27 ./configure --prefix=%{base}
28 make
29
30 %install
31 make DESTDIR=$RPM_BUILD_ROOT install
32
33 %clean
34 rm -rf $RPM_BUILD_ROOT
35 rm -rf $RPM_BUILD_DIR/%{name}-%{version}
36
37 %post -p /sbin/ldconfig
38
39 %postun -p /sbin/ldconfig
40
41 %files
42 %defattr(-,root,root)
43 %doc README HISTORY
44 %{base}/bin/xcurses-config
45 %{base}/lib/libXCurses.a
46 %{base}/lib/libXpanel.a
47 %{base}/lib/libXCurses.so
48 %{base}/include/xcurses.h
49 %{base}/include/xpanel.h
50 %{base}/include/xcurses/curses.h
51 %{base}/include/xcurses/panel.h
52 %{base}/include/xcurses/term.h
File README added (mode: 100644) (index 00000000..dc476a9f)
1 Welcome to PDCurses!
2 ====================
3
4 Public Domain Curses, aka PDCurses, is an implementation of X/Open
5 curses for multiple platforms. The latest version can be found at:
6
7 http://pdcurses.sourceforge.net/
8
9 For changes, see the HISTORY file.
10
11
12 Legal Stuff
13 -----------
14
15 The core package is in the public domain, but small portions of PDCurses
16 are subject to copyright under various licenses. Each directory
17 contains a README file, with a section titled "Distribution Status"
18 which describes the status of the files in that directory.
19
20 If you use PDCurses in an application, an acknowledgement would be
21 appreciated, but is not mandatory. If you make corrections or
22 enhancements to PDCurses, please forward them to the current maintainer
23 for the benefit of other users.
24
25 This software is provided AS IS with NO WARRANTY whatsoever.
26
27
28 Ports
29 -----
30
31 PDCurses has been ported to DOS, OS/2, Win32, X11 and SDL. A directory
32 containing the port-specific source files exists for each of these
33 platforms. Build instructions are in the README file for each platform.
34
35
36 Distribution Status
37 -------------------
38
39 All files in this directory except configure, config.guess and
40 config.sub are released to the Public Domain. config.guess and
41 config.sub are under the GPL; configure is under a free license
42 described within it.
43
44
45 Maintainer
46 ----------
47
48 William McBrine <wmcbrine@users.sf.net>
File aclocal.m4 added (mode: 100644) (index 00000000..ad7c3f3a)
1 dnl ---------------------------------------------------------------------------
2 dnl This file offers the following macros...
3 dnl ---------------------------------------------------------------------------
4 dnl MH_IPC
5 dnl MH_CHECK_X_INC
6 dnl MH_CHECK_X_LIB
7 dnl MH_CHECK_X_HEADERS
8 dnl MH_CHECK_X_KEYDEFS
9 dnl MH_CHECK_X_TYPEDEF
10 dnl MH_CHECK_LIB
11 dnl MH_SHARED_LIBRARY
12 dnl MH_HOWTO_DYN_LINK
13 dnl MH_CHECK_CC_O
14 dnl MH_SHLPST
15 dnl MH_CHECK_MAX_SIGNALS
16
17 dnl ---------------------------------------------------------------------------
18 dnl Determine if the system has System V IPC. ie sys/ipc.h and sys/shm.h
19 dnl headers.
20 dnl ---------------------------------------------------------------------------
21 AC_DEFUN([MH_IPC],
22 [
23 AC_CHECK_HEADER(sys/ipc.h)
24 if test $ac_cv_header_sys_ipc_h = no; then
25 AC_MSG_ERROR(Cannot find required header file sys/ipc.h; PDCurses cannot be configured)
26 fi
27 ])dnl
28
29 dnl ---------------------------------------------------------------------------
30 dnl Set up the correct X header file location
31 dnl ---------------------------------------------------------------------------
32 AC_DEFUN([MH_CHECK_X_INC],
33 [
34 mh_x11_dir=""
35 mh_x11_xaw_dir=""
36
37 mh_inc_dirs="$ac_x_header_dirs"
38
39 dnl Provide for user supplying directory
40
41 if test "x$x_includes" != xNONE ; then
42 mh_inc_dirs="$x_includes $mh_inc_dirs"
43 fi
44
45 dnl Try to determine the directory containing X headers
46 dnl We will append X11 to all the paths above as an extra check
47
48 for ac_dir in $mh_inc_dirs ; do
49 if test -r $ac_dir/Intrinsic.h; then
50 mh_x11_dir=$ac_dir
51 break
52 fi
53 if test -r $ac_dir/X11/Intrinsic.h; then
54 mh_x11_dir="$ac_dir/X11"
55 break
56 fi
57 done
58
59 dnl Try to determine the directory containing Xaw headers
60 dnl We will append X11 to all the paths above as an extra check
61
62 if test "$with_xaw3d" = yes; then
63 mh_xaw_dir="Xaw3d"
64 else
65 if test "$with_nextaw" = yes; then
66 mh_xaw_dir="neXtaw"
67 else
68 mh_xaw_dir="Xaw"
69 fi
70 fi
71 for ac_dir in $mh_inc_dirs ; do
72 if test -r $ac_dir/$mh_xaw_dir/Box.h; then
73 mh_x11_xaw_dir=$ac_dir
74 break
75 fi
76 if test -r $ac_dir/X11/$mh_xaw_dir/Box.h; then
77 mh_x11_xaw_dir="$ac_dir/X11"
78 break
79 fi
80 done
81
82 if test "x$mh_x11_dir" != "x" ; then
83 mh_x11_dir_no_x11=`echo $mh_x11_dir | sed 's/\/X11$//'`
84
85 if test "$mh_x11_dir_no_x11" != "$mh_x11_dir" ; then
86 MH_XINC_DIR="-I$mh_x11_dir -I$mh_x11_dir_no_x11"
87 else
88 MH_XINC_DIR="-I$mh_x11_dir"
89 fi
90 else
91 AC_MSG_ERROR(Cannot find required header file Intrinsic.h; PDCurses cannot be configured)
92 fi
93
94 if test "x$mh_x11_xaw_dir" != "x"; then
95 if test "$mh_x11_xaw_dir" != "$mh_x11_dir" ; then
96 MH_XINC_DIR="-I$mh_x11_xaw_dir $MH_XINC_DIR"
97 fi
98 else
99 AC_MSG_ERROR(Cannot find required Xaw header file Box.h; PDCurses cannot be configured)
100 fi
101
102 AC_SUBST(MH_XINC_DIR)
103
104 ])dnl
105
106 dnl ---------------------------------------------------------------------------
107 dnl Set up the correct X library file location
108 dnl ---------------------------------------------------------------------------
109 AC_DEFUN([MH_CHECK_X_LIB],
110 [
111 dnl Some systems require extra libraries...
112
113 mh_solaris_flag=no
114 mh_hpux9_flag=no
115 AC_REQUIRE([AC_CANONICAL_SYSTEM])
116 case "$target" in
117 *solaris*)
118 mh_solaris_flag=yes
119 ;;
120 *pc-sco*)
121 extra_x_libs="Xext"
122 ;;
123 sparc*sunos*)
124 extra_x_libs="Xext"
125 if test "$ac_cv_prog_CC" = "gcc" ; then
126 extra_ld_flags="-Wl,-Bstatic"
127 extra_ld_flags2="-Wl,-Bdynamic"
128 else
129 extra_ld_flags="-Bstatic"
130 extra_ld_flags2="-Bdynamic"
131 fi
132 ;;
133 *hpux9*)
134 mh_hpux9_flag=yes
135 ;;
136 esac
137
138 if test "$with_xaw3d" = yes; then
139 MH_X11_LIBS="Xaw3d Xmu Xt X11"
140 else
141 if test "$with_nextaw" = yes; then
142 MH_X11_LIBS="neXtaw Xmu Xt X11"
143 else
144 MH_X11_LIBS="Xaw Xmu Xt X11"
145 fi
146 fi
147 MH_X11R6_LIBS="SM ICE Xext"
148 mh_x11r6=no
149
150 mh_lib_dirs="$x_libraries `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`"
151
152 dnl try to find libSM.[a,sl,so,dylib]. If we find it we are using X11R6
153 for ac_dir in $mh_lib_dirs ; do
154 for mh_xsm in libSM.a libSM.so libSM.sl libSM.dylib; do
155 if test -r $ac_dir/$mh_xsm; then
156 mh_x11r6=yes
157 break 2
158 fi
159 done
160 done
161
162 if test "$mh_x11r6" = yes ; then
163 mh_libs="$MH_X11_LIBS $MH_X11R6_LIBS"
164 else
165 mh_libs="$MH_X11_LIBS $extra_x_libs"
166 fi
167
168
169 dnl Ensure that all required X libraries are found
170
171 mh_prev_dir=""
172 mh_where_found=""
173 mh_where_found_dirs=""
174 mh_solaris_path=""
175 for mh_lib in $mh_libs; do
176 mh_lib_found=no
177 for ac_dir in $mh_lib_dirs ; do
178 for mh_ext in a so sl dll.a dylib; do
179 if test -r $ac_dir/lib$mh_lib.$mh_ext; then
180 if test "x$mh_prev_dir" != "x$ac_dir" ; then
181 if test "x$mh_prev_dir" = "x" ; then
182 mh_where_found="$mh_where_found found in $ac_dir"
183 else
184 mh_where_found="$mh_where_found and in $ac_dir"
185 fi
186 mh_prev_dir=$ac_dir
187 mh_where_found_dirs="$mh_where_found_dirs $ac_dir"
188 MH_XLIBS="$MH_XLIBS -L$ac_dir"
189 mh_solaris_path="${mh_solaris_path}:$ac_dir"
190 fi
191 MH_XLIBS="$MH_XLIBS -l$mh_lib"
192 mh_lib_found=yes
193 break 2
194 fi
195 done
196 done
197 if test "$mh_lib_found" = no; then
198 AC_MSG_ERROR(Cannot find required X library; lib$mh_lib. PDCurses cannot be configured)
199 fi
200 done
201
202 mh_solaris_path=`echo $mh_solaris_path | sed 's/^://'`
203 if test "$mh_solaris_flag" = yes ; then
204 MH_XLIBS="-R$mh_solaris_path $extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2"
205 else
206 MH_XLIBS="$extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2"
207 fi
208 if test "$mh_hpux9_flag" = yes ; then
209 grep -q XtSetLanguageProc $mh_x11_dir/Intrinsic.h
210 if test $? -eq 0 ; then
211 mh_found_xtshellstrings=no
212 for mh_acdir in $mh_where_found_dirs ; do
213 for mh_xaw in `ls $mh_acdir/libXaw.*` ; do
214 nm $mh_xaw | grep XtShellStrings | grep -qv extern
215 if test $? -eq 0 ; then
216 mh_found_xtshellstrings=yes
217 fi
218 done
219 done
220 if test "$mh_found_xtshellstrings" = no ; then
221 AC_MSG_WARN(The X11 development environment has not been installed correctly.)
222 AC_MSG_WARN(The header file; Intrinsic.h, is for X11R5 while the Athena Widget)
223 AC_MSG_WARN(Set library; libXaw is for X11R4. This is a common problem with)
224 AC_MSG_WARN(HP-UX 9.x.)
225 AC_MSG_ERROR(X11 installation incomplete; cannot continue)
226 fi
227 fi
228 fi
229
230 AC_SUBST(MH_XLIBS)
231
232 ])dnl
233
234 dnl ---------------------------------------------------------------------------
235 dnl Determine if the supplied X headers exist.
236 dnl ---------------------------------------------------------------------------
237 AC_DEFUN([MH_CHECK_X_HEADERS],
238 [
239 save_CPPFLAGS="$CPPFLAGS"
240 CPPFLAGS="$CPPFLAGS $MH_XINC_DIR"
241 for mh_header in $1; do
242 AC_CHECK_HEADERS($mh_header)
243 done
244 CPPFLAGS="$save_CPPFLAGS"
245 ])dnl
246
247 dnl ---------------------------------------------------------------------------
248 dnl Determine if various key definitions exist in keysym.h
249 dnl ---------------------------------------------------------------------------
250 AC_DEFUN([MH_CHECK_X_KEYDEFS],
251 [
252 save_CPPFLAGS="$CPPFLAGS"
253 CPPFLAGS="$CPPFLAGS $MH_XINC_DIR"
254 for mh_keydef in $1; do
255 AC_MSG_CHECKING(for $mh_keydef in keysym.h)
256 mh_upper_name="HAVE_`echo $mh_keydef | tr '[a-z]' '[A-Z]'`"
257 AC_TRY_COMPILE([#include <keysym.h>],
258 [int i = $mh_keydef;],
259 mh_have_key=yes; AC_DEFINE_UNQUOTED($mh_upper_name,1), mh_have_key=no )
260 AC_MSG_RESULT($mh_have_key)
261 done
262 CPPFLAGS="$save_CPPFLAGS"
263 ])dnl
264
265 dnl ---------------------------------------------------------------------------
266 dnl Determine if supplied types have been typedefed
267 dnl ---------------------------------------------------------------------------
268 AC_DEFUN([MH_CHECK_X_TYPEDEF],
269 [
270 save_CPPFLAGS="$CPPFLAGS"
271 CPPFLAGS="$CPPFLAGS $SYS_DEFS $MH_XINC_DIR"
272 for td in $1 ; do
273 AC_MSG_CHECKING(if $td is typedefed:)
274 AC_TRY_COMPILE(
275 [#include "X11/Xlib.h"],
276 [$td fred],
277 [mh_td=yes],
278 [mh_td=no]
279 )
280 if test "$mh_td" = yes ; then
281 TD_upper=`echo $td | tr a-z A-Z`
282 AC_DEFINE_UNQUOTED(${TD_upper}_TYPEDEFED, 1)
283 fi
284 AC_MSG_RESULT($mh_td)
285 done
286 CPPFLAGS="$save_CPPFLAGS"
287 ])dnl
288
289 dnl ---------------------------------------------------------------------------
290 dnl Check for presence of various libraries
291 dnl ---------------------------------------------------------------------------
292 AC_DEFUN([MH_CHECK_LIB],
293 [
294 MH_EXTRA_LIBS=''
295 for mh_lib in $1; do
296 if test "$on_qnx" = yes; then
297 AC_MSG_CHECKING(for library -l${mh_lib})
298 if test -r /usr/lib/${mh_lib}3r.lib; then
299 AC_MSG_RESULT(found)
300 MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
301 else
302 AC_MSG_RESULT(not found)
303 fi
304 else
305 AC_CHECK_LIB($mh_lib,main,mh_lib_found=yes,mh_lib_found=no)
306 if test "$mh_lib_found" = yes; then
307 MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
308 fi
309 fi
310 done
311 ])dnl
312
313 dnl ---------------------------------------------------------------------------
314 dnl Work out how to create a dynamically loaded module
315 dnl ---------------------------------------------------------------------------
316 AC_DEFUN([MH_HOWTO_DYN_LINK],
317 [
318 mh_compile='${CC-cc} -c $DYN_COMP conftest.$ac_ext 1>&AC_FD_CC'
319 cat > conftest.$ac_ext <<EOF
320 dnl [#]line __oline__ "[$]0"
321 [#]line __oline__ "configure"
322 int foo()
323 {
324 return(0);
325 }
326 EOF
327 if AC_TRY_EVAL(mh_compile) && test -s conftest.o; then
328 mh_dyn_link='ld -shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
329 # mh_dyn_link='${CC} -Wl,-shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
330 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then
331 LD_RXLIB1="ld -shared"
332 # LD_RXLIB1="${CC} -Wl,-shared"
333 SHLPRE="lib"
334 SHLPST=".so"
335 else
336 mh_dyn_link='ld -G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
337 # mh_dyn_link='${CC} -Wl,-G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
338 if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then
339 LD_RXLIB1="ld -G"
340 # LD_RXLIB1="${CC} -Wl,-G"
341 SHLPRE="lib"
342 SHLPST=".so"
343 else
344 LD_RXLIB1=""
345 SHLPRE=""
346 SHLPST=""
347 fi
348 fi
349 fi
350 rm -f conftest*
351 ])dnl
352
353 dnl ---------------------------------------------------------------------------
354 dnl Determine how to build shared libraries etc..
355 dnl ---------------------------------------------------------------------------
356 AC_DEFUN([MH_SHARED_LIBRARY],
357 [
358 AC_REQUIRE([MH_SHLPST])
359 dnl
360 dnl If compiler is gcc, then flags should be the same for all platforms
361 dnl (just guessing on this)
362 dnl
363 AIX_DYN="no"
364 BEOS_DYN="no"
365 SHLFILE="$1"
366 SHLFILES="$*"
367 RXPACKEXPORTS=""
368 SHLPRE="lib"
369 LD_RXLIB1=""
370
371 AC_REQUIRE([AC_CANONICAL_SYSTEM])
372 case "$target" in
373 *hp-hpux*)
374 SYS_DEFS="-D_HPUX_SOURCE"
375 LD_RXLIB1="ld -b -q -n"
376 ;;
377 *ibm-aix*)
378 SYS_DEFS="-D_ALL_SOURCE -DAIX"
379 AIX_DYN="yes"
380 DYN_COMP="-DDYNAMIC"
381 LD_RXLIB1="ld -bnoentry -bM:SRE"
382 RXPACKEXPORTS="-bE:$SHLFILE.exp"
383 RXPACKEXP="$SHLFILE.exp"
384 ;;
385 *dec-osf*)
386 if test "$ac_cv_prog_CC" = "gcc"; then
387 SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE"
388 else
389 SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE -Olimit 800"
390 fi
391 LD_RXLIB1="ld -shared"
392 ;;
393 *sequent-dynix*|*esix*|*dgux*)
394 LD_RXLIB1="ld -G"
395 ;;
396 *solaris*)
397 if test "$ac_cv_prog_CC" = "gcc"; then
398 LD_RXLIB1="gcc -shared"
399 else
400 LD_RXLIB1="ld -G"
401 fi
402 ;;
403 sparc*sunos*)
404 SYS_DEFS="-DSUNOS -DSUNOS_STRTOD_BUG"
405 LD_RXLIB1="ld"
406 ;;
407 *linux*|*atheos*|*nto-qnx*)
408 LD_RXLIB1="${CC} -shared"
409 ;;
410 *freebsd*)
411 LD_RXLIB1="ld -Bdynamic -Bshareable"
412 ;;
413 *pc-sco*)
414 LD_RXLIB1="ld -dy -G"
415 ;;
416 *beos*)
417 LD_RXLIB1="${CC} -Wl,-shared -nostart -Xlinker -soname=\$(@)"
418 BEOS_DYN="yes"
419 ;;
420 *qnx*)
421 SHLPRE=""
422 DYN_COMP="-Q" # force no check for dynamic loading
423 SHLFILE=""
424 ;;
425 *cygwin)
426 SHLPRE=""
427 DYN_COMP="-DDYNAMIC"
428 LD_RXLIB1="dllwrap --def \$(srcdir)/../win32/pdcurses.def --target i386-cygwin32 --dllname \$(@)"
429 # cygwininstall target MUST install the shared library itself because
430 # it puts it into $(bindir) not $(libdir) as all other platforms
431 ;;
432 *darwin*)
433 DYN_COMP="-fno-common"
434 LD_RXLIB1="${CC} -flat_namespace -undefined suppress -dynamiclib -install_name=\$(@)"
435 ;;
436 *)
437 ;;
438 esac
439
440 dnl determine what switches our compiler uses for building objects
441 dnl suitable for inclusion in shared libraries
442 dnl Only call this if DYN_COMP is not set. If we have set DYN_COMP
443 dnl above, then we know how to compile AND link for dynamic libraries
444
445 if test "$DYN_COMP" = ""; then
446 AC_MSG_CHECKING(compiler flags for a dynamic object)
447
448 cat > conftest.$ac_ext <<EOF
449 dnl [#]line __oline__ "[$]0"
450 [#]line __oline__ "configure"
451 int a=0
452 EOF
453
454 DYN_COMP=""
455 mh_cv_stop=no
456 save_cflags="$CFLAGS"
457 mh_cv_flags="-fPIC -KPIC +Z"
458 for a in $mh_cv_flags; do
459 CFLAGS="-c $a"
460
461 mh_compile='${CC-cc} -c $CFLAGS conftest.$ac_ext > conftest.tmp 2>&1'
462 if AC_TRY_EVAL(mh_compile); then
463 DYN_COMP=""
464 else
465 slash="\\"
466 mh_dyncomp="`egrep -c $slash$a conftest.tmp`"
467 if test "$mh_dyncomp" = "0"; then
468 DYN_COMP="$a -DDYNAMIC"
469 AC_MSG_RESULT($a)
470 break
471 else
472 DYN_COMP=""
473 fi
474 fi
475 done
476 if test "$DYN_COMP" = ""; then
477 AC_MSG_RESULT(none of $mh_cv_flags supported)
478 fi
479 if test "$LD_RXLIB1" = ""; then
480 MH_HOWTO_DYN_LINK()
481 fi
482 CFLAGS=$save_cflags
483 rm -f conftest.*
484 fi
485
486
487 SHL_TARGETS=""
488
489 if test "$AIX_DYN" = "yes"; then
490 aix_exports="config.exports.aix"
491 echo "" > $aix_exports
492 fi
493
494 if test "$ac_cv_header_dl_h" = "yes" -o "$ac_cv_header_dlfcn_h" = "yes" -o "$AIX_DYN" = "yes" -o "$BEOS_DYN" = "yes" -o "$DLFCNINCDIR" != "" -o "$DLFCNLIBDIR" != ""; then
495 EXPS="1,2,3,4,5,6,7,8,9"
496 for a in $SHLFILES
497 do
498 SHL_TARGETS="${SHL_TARGETS} ${SHLPRE}${a}${SHLPST}"
499 this=`echo $EXPS | cut -d, -f1`
500 EXPS=`echo $EXPS | cut -d, -f2-`
501 if test "$AIX_DYN" = "yes"; then
502 echo "RXPACKEXP$this=$a.exp" >> $aix_exports
503 echo "RXPACKEXPORTS$this=-bE:$a.exp" >> $aix_exports
504 fi
505 done
506 fi
507
508 AC_SUBST(DYN_COMP)
509 AC_SUBST(LIBS)
510 AC_SUBST(LD_RXLIB1)
511 AC_SUBST(SHLPRE)
512 AC_SUBST(SHLPST)
513 AC_SUBST(SHL_TARGETS)
514 AC_SUBST(O2SAVE)
515 AC_SUBST(CC2O)
516 AC_SUBST(SAVE2O)
517 AC_SUBST(RXPACKEXPORTS)
518 ])dnl
519
520 dnl ---------------------------------------------------------------------------
521 dnl Check if C compiler supports -c -o file.ooo
522 dnl ---------------------------------------------------------------------------
523 AC_DEFUN([MH_CHECK_CC_O],
524 [
525 AC_MSG_CHECKING(whether $CC understand -c and -o together)
526 set dummy $CC; ac_cc="`echo [$]2 |
527 changequote(, )dnl
528 sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
529 changequote([, ])dnl
530 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
531 [echo 'foo(){}' > conftest.c
532 # We do the test twice because some compilers refuse to overwrite an
533 # existing .o file with -o, though they will create one.
534 eval ac_cv_prog_cc_${ac_cc}_c_o=no
535 ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC'
536 if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try);
537 then
538 ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC'
539 if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try);
540 then
541 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
542 fi
543 fi
544 rm -f conftest*
545 ])dnl
546 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
547 O2SAVE=""
548 SAVE2O=""
549 CC2O="-o $"'@'
550 AC_MSG_RESULT(yes)
551 else
552 O2SAVE="-mv \`basename "$'@'" .sho\`.o \`basename "$'@'" .sho\`.o.save;"
553 SAVE2O="-mv \`basename "$'@'" .sho\`.o "$'@'"; mv \`basename "$'@'" .sho\`.o.save \`basename "$'@'" .sho\`.o"
554 CC2O=""
555 AC_MSG_RESULT(no)
556 fi
557 ])
558
559 dnl ---------------------------------------------------------------------------
560 dnl Determines the file extension for shared libraries
561 dnl ---------------------------------------------------------------------------
562 AC_DEFUN([MH_SHLPST],
563 [
564 AC_MSG_CHECKING(shared library extension)
565 SHLPST=".so"
566 AC_REQUIRE([AC_CANONICAL_SYSTEM])
567 case "$target" in
568 *hp-hpux*)
569 SHLPST=".sl"
570 ;;
571 *ibm-aix*)
572 SHLPST=".a"
573 ;;
574 *qnx*)
575 SHLPST=""
576 ;;
577 *cygwin*)
578 SHLPST=".dll"
579 ;;
580 *darwin*)
581 SHLPST=".dylib"
582 ;;
583 esac
584 AC_SUBST(SHLPST)
585 AC_MSG_RESULT($SHLPST)
586 ])
587
588 dnl ---------------------------------------------------------------------------
589 dnl Determine the system limit for number of signals
590 dnl ---------------------------------------------------------------------------
591 AC_DEFUN([MH_CHECK_MAX_SIGNALS],
592 [
593 save_CPPFLAGS="$CPPFLAGS"
594 CPPFLAGS="$CPPFLAGS $SYS_DEFS"
595 AC_MSG_CHECKING(for maximum signal specifier:)
596 AC_CACHE_VAL(mh_cv_max_signals,
597 mh_found="no"
598 for mh_sigs in $1; do
599 AC_TRY_COMPILE([#include <signal.h>],
600 [return $mh_sigs;],
601 mh_found="yes"; mh_cv_max_signals="$mh_sigs" )
602 if test "$mh_found" = "yes"; then
603 break;
604 fi
605 done)
606 CPPFLAGS="$save_CPPFLAGS"
607 if test "$mh_found" = "no"; then
608 AC_MSG_ERROR(Cannot find a system limit for number of signals. PDCurses cannot be configured on this machine.)
609 else
610 AC_DEFINE_UNQUOTED(PDC_MAX_SIGNALS,$mh_cv_max_signals)
611 AC_MSG_RESULT($mh_cv_max_signals)
612 fi
613 ])dnl
File config.guess added (mode: 100755) (index 00000000..396482d6)
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
5 # Inc.
6
7 timestamp='2006-07-02'
8
9 # This file is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
22 # 02110-1301, USA.
23 #
24 # As a special exception to the GNU General Public License, if you
25 # distribute this file as part of a program that contains a
26 # configuration script generated by Autoconf, you may include it under
27 # the same distribution terms that you use for the rest of that program.
28
29
30 # Originally written by Per Bothner <per@bothner.com>.
31 # Please send patches to <config-patches@gnu.org>. Submit a context
32 # diff and a properly formatted ChangeLog entry.
33 #
34 # This script attempts to guess a canonical system name similar to
35 # config.sub. If it succeeds, it prints the system name on stdout, and
36 # exits with 0. Otherwise, it exits with 1.
37 #
38 # The plan is that this can be called by configure scripts if you
39 # don't specify an explicit build system type.
40
41 me=`echo "$0" | sed -e 's,.*/,,'`
42
43 usage="\
44 Usage: $0 [OPTION]
45
46 Output the configuration name of the system \`$me' is run on.
47
48 Operation modes:
49 -h, --help print this help, then exit
50 -t, --time-stamp print date of last modification, then exit
51 -v, --version print version number, then exit
52
53 Report bugs and patches to <config-patches@gnu.org>."
54
55 version="\
56 GNU config.guess ($timestamp)
57
58 Originally written by Per Bothner.
59 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
60 Free Software Foundation, Inc.
61
62 This is free software; see the source for copying conditions. There is NO
63 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
64
65 help="
66 Try \`$me --help' for more information."
67
68 # Parse command line
69 while test $# -gt 0 ; do
70 case $1 in
71 --time-stamp | --time* | -t )
72 echo "$timestamp" ; exit ;;
73 --version | -v )
74 echo "$version" ; exit ;;
75 --help | --h* | -h )
76 echo "$usage"; exit ;;
77 -- ) # Stop option processing
78 shift; break ;;
79 - ) # Use stdin as input.
80 break ;;
81 -* )
82 echo "$me: invalid option $1$help" >&2
83 exit 1 ;;
84 * )
85 break ;;
86 esac
87 done
88
89 if test $# != 0; then
90 echo "$me: too many arguments$help" >&2
91 exit 1
92 fi
93
94 trap 'exit 1' 1 2 15
95
96 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
97 # compiler to aid in system detection is discouraged as it requires
98 # temporary files to be created and, as you can see below, it is a
99 # headache to deal with in a portable fashion.
100
101 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
102 # use `HOST_CC' if defined, but it is deprecated.
103
104 # Portable tmp directory creation inspired by the Autoconf team.
105
106 set_cc_for_build='
107 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
108 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
109 : ${TMPDIR=/tmp} ;
110 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
111 { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
112 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
113 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
114 dummy=$tmp/dummy ;
115 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
116 case $CC_FOR_BUILD,$HOST_CC,$CC in
117 ,,) echo "int x;" > $dummy.c ;
118 for c in cc gcc c89 c99 ; do
119 if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
120 CC_FOR_BUILD="$c"; break ;
121 fi ;
122 done ;
123 if test x"$CC_FOR_BUILD" = x ; then
124 CC_FOR_BUILD=no_compiler_found ;
125 fi
126 ;;
127 ,,*) CC_FOR_BUILD=$CC ;;
128 ,*,*) CC_FOR_BUILD=$HOST_CC ;;
129 esac ; set_cc_for_build= ;'
130
131 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
132 # (ghazi@noc.rutgers.edu 1994-08-24)
133 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
134 PATH=$PATH:/.attbin ; export PATH
135 fi
136
137 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
138 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
139 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
140 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
141
142 # Note: order is significant - the case branches are not exclusive.
143
144 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
145 *:NetBSD:*:*)
146 # NetBSD (nbsd) targets should (where applicable) match one or
147 # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
148 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
149 # switched to ELF, *-*-netbsd* would select the old
150 # object file format. This provides both forward
151 # compatibility and a consistent mechanism for selecting the
152 # object file format.
153 #
154 # Note: NetBSD doesn't particularly care about the vendor
155 # portion of the name. We always set it to "unknown".
156 sysctl="sysctl -n hw.machine_arch"
157 UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
158 /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
159 case "${UNAME_MACHINE_ARCH}" in
160 armeb) machine=armeb-unknown ;;
161 arm*) machine=arm-unknown ;;
162 sh3el) machine=shl-unknown ;;
163 sh3eb) machine=sh-unknown ;;
164 *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
165 esac
166 # The Operating System including object format, if it has switched
167 # to ELF recently, or will in the future.
168 case "${UNAME_MACHINE_ARCH}" in
169 arm*|i386|m68k|ns32k|sh3*|sparc|vax)
170 eval $set_cc_for_build
171 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
172 | grep __ELF__ >/dev/null
173 then
174 # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
175 # Return netbsd for either. FIX?
176 os=netbsd
177 else
178 os=netbsdelf
179 fi
180 ;;
181 *)
182 os=netbsd
183 ;;
184 esac
185 # The OS release
186 # Debian GNU/NetBSD machines have a different userland, and
187 # thus, need a distinct triplet. However, they do not need
188 # kernel version information, so it can be replaced with a
189 # suitable tag, in the style of linux-gnu.
190 case "${UNAME_VERSION}" in
191 Debian*)
192 release='-gnu'
193 ;;
194 *)
195 release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
196 ;;
197 esac
198 # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
199 # contains redundant information, the shorter form:
200 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
201 echo "${machine}-${os}${release}"
202 exit ;;
203 *:OpenBSD:*:*)
204 UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
205 echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
206 exit ;;
207 *:ekkoBSD:*:*)
208 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
209 exit ;;
210 *:SolidBSD:*:*)
211 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
212 exit ;;
213 macppc:MirBSD:*:*)
214 echo powerpc-unknown-mirbsd${UNAME_RELEASE}
215 exit ;;
216 *:MirBSD:*:*)
217 echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
218 exit ;;
219 alpha:OSF1:*:*)
220 case $UNAME_RELEASE in
221 *4.0)
222 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
223 ;;
224 *5.*)
225 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
226 ;;
227 esac
228 # According to Compaq, /usr/sbin/psrinfo has been available on
229 # OSF/1 and Tru64 systems produced since 1995. I hope that
230 # covers most systems running today. This code pipes the CPU
231 # types through head -n 1, so we only detect the type of CPU 0.
232 ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
233 case "$ALPHA_CPU_TYPE" in
234 "EV4 (21064)")
235 UNAME_MACHINE="alpha" ;;
236 "EV4.5 (21064)")
237 UNAME_MACHINE="alpha" ;;
238 "LCA4 (21066/21068)")
239 UNAME_MACHINE="alpha" ;;
240 "EV5 (21164)")
241 UNAME_MACHINE="alphaev5" ;;
242 "EV5.6 (21164A)")
243 UNAME_MACHINE="alphaev56" ;;
244 "EV5.6 (21164PC)")
245 UNAME_MACHINE="alphapca56" ;;
246 "EV5.7 (21164PC)")
247 UNAME_MACHINE="alphapca57" ;;
248 "EV6 (21264)")
249 UNAME_MACHINE="alphaev6" ;;
250 "EV6.7 (21264A)")
251 UNAME_MACHINE="alphaev67" ;;
252 "EV6.8CB (21264C)")
253 UNAME_MACHINE="alphaev68" ;;
254 "EV6.8AL (21264B)")
255 UNAME_MACHINE="alphaev68" ;;
256 "EV6.8CX (21264D)")
257 UNAME_MACHINE="alphaev68" ;;
258 "EV6.9A (21264/EV69A)")
259 UNAME_MACHINE="alphaev69" ;;
260 "EV7 (21364)")
261 UNAME_MACHINE="alphaev7" ;;
262 "EV7.9 (21364A)")
263 UNAME_MACHINE="alphaev79" ;;
264 esac
265 # A Pn.n version is a patched version.
266 # A Vn.n version is a released version.
267 # A Tn.n version is a released field test version.
268 # A Xn.n version is an unreleased experimental baselevel.
269 # 1.2 uses "1.2" for uname -r.
270 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
271 exit ;;
272 Alpha\ *:Windows_NT*:*)
273 # How do we know it's Interix rather than the generic POSIX subsystem?
274 # Should we change UNAME_MACHINE based on the output of uname instead
275 # of the specific Alpha model?
276 echo alpha-pc-interix
277 exit ;;
278 21064:Windows_NT:50:3)
279 echo alpha-dec-winnt3.5
280 exit ;;
281 Amiga*:UNIX_System_V:4.0:*)
282 echo m68k-unknown-sysv4
283 exit ;;
284 *:[Aa]miga[Oo][Ss]:*:*)
285 echo ${UNAME_MACHINE}-unknown-amigaos
286 exit ;;
287 *:[Mm]orph[Oo][Ss]:*:*)
288 echo ${UNAME_MACHINE}-unknown-morphos
289 exit ;;
290 *:OS/390:*:*)
291 echo i370-ibm-openedition
292 exit ;;
293 *:z/VM:*:*)
294 echo s390-ibm-zvmoe
295 exit ;;
296 *:OS400:*:*)
297 echo powerpc-ibm-os400
298 exit ;;
299 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
300 echo arm-acorn-riscix${UNAME_RELEASE}
301 exit ;;
302 arm:riscos:*:*|arm:RISCOS:*:*)
303 echo arm-unknown-riscos
304 exit ;;
305 SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
306 echo hppa1.1-hitachi-hiuxmpp
307 exit ;;
308 Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
309 # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
310 if test "`(/bin/universe) 2>/dev/null`" = att ; then
311 echo pyramid-pyramid-sysv3
312 else
313 echo pyramid-pyramid-bsd
314 fi
315 exit ;;
316 NILE*:*:*:dcosx)
317 echo pyramid-pyramid-svr4
318 exit ;;
319 DRS?6000:unix:4.0:6*)
320 echo sparc-icl-nx6
321 exit ;;
322 DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
323 case `/usr/bin/uname -p` in
324 sparc) echo sparc-icl-nx7; exit ;;
325 esac ;;
326 sun4H:SunOS:5.*:*)
327 echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
328 exit ;;
329 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
330 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
331 exit ;;
332 i86pc:SunOS:5.*:*)
333 echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
334 exit ;;
335 sun4*:SunOS:6*:*)
336 # According to config.sub, this is the proper way to canonicalize
337 # SunOS6. Hard to guess exactly what SunOS6 will be like, but
338 # it's likely to be more like Solaris than SunOS4.
339 echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
340 exit ;;
341 sun4*:SunOS:*:*)
342 case "`/usr/bin/arch -k`" in
343 Series*|S4*)
344 UNAME_RELEASE=`uname -v`
345 ;;
346 esac
347 # Japanese Language versions have a version number like `4.1.3-JL'.
348 echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
349 exit ;;
350 sun3*:SunOS:*:*)
351 echo m68k-sun-sunos${UNAME_RELEASE}
352 exit ;;
353 sun*:*:4.2BSD:*)
354 UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
355 test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
356 case "`/bin/arch`" in
357 sun3)
358 echo m68k-sun-sunos${UNAME_RELEASE}
359 ;;
360 sun4)
361 echo sparc-sun-sunos${UNAME_RELEASE}
362 ;;
363 esac
364 exit ;;
365 aushp:SunOS:*:*)
366 echo sparc-auspex-sunos${UNAME_RELEASE}
367 exit ;;
368 # The situation for MiNT is a little confusing. The machine name
369 # can be virtually everything (everything which is not
370 # "atarist" or "atariste" at least should have a processor
371 # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
372 # to the lowercase version "mint" (or "freemint"). Finally
373 # the system name "TOS" denotes a system which is actually not
374 # MiNT. But MiNT is downward compatible to TOS, so this should
375 # be no problem.
376 atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
377 echo m68k-atari-mint${UNAME_RELEASE}
378 exit ;;
379 atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
380 echo m68k-atari-mint${UNAME_RELEASE}
381 exit ;;
382 *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
383 echo m68k-atari-mint${UNAME_RELEASE}
384 exit ;;
385 milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
386 echo m68k-milan-mint${UNAME_RELEASE}
387 exit ;;
388 hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
389 echo m68k-hades-mint${UNAME_RELEASE}
390 exit ;;
391 *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
392 echo m68k-unknown-mint${UNAME_RELEASE}
393 exit ;;
394 m68k:machten:*:*)
395 echo m68k-apple-machten${UNAME_RELEASE}
396 exit ;;
397 powerpc:machten:*:*)
398 echo powerpc-apple-machten${UNAME_RELEASE}
399 exit ;;
400 RISC*:Mach:*:*)
401 echo mips-dec-mach_bsd4.3
402 exit ;;
403 RISC*:ULTRIX:*:*)
404 echo mips-dec-ultrix${UNAME_RELEASE}
405 exit ;;
406 VAX*:ULTRIX*:*:*)
407 echo vax-dec-ultrix${UNAME_RELEASE}
408 exit ;;
409 2020:CLIX:*:* | 2430:CLIX:*:*)
410 echo clipper-intergraph-clix${UNAME_RELEASE}
411 exit ;;
412 mips:*:*:UMIPS | mips:*:*:RISCos)
413 eval $set_cc_for_build
414 sed 's/^ //' << EOF >$dummy.c
415 #ifdef __cplusplus
416 #include <stdio.h> /* for printf() prototype */
417 int main (int argc, char *argv[]) {
418 #else
419 int main (argc, argv) int argc; char *argv[]; {
420 #endif
421 #if defined (host_mips) && defined (MIPSEB)
422 #if defined (SYSTYPE_SYSV)
423 printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
424 #endif
425 #if defined (SYSTYPE_SVR4)
426 printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
427 #endif
428 #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
429 printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
430 #endif
431 #endif
432 exit (-1);
433 }
434 EOF
435 $CC_FOR_BUILD -o $dummy $dummy.c &&
436 dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
437 SYSTEM_NAME=`$dummy $dummyarg` &&
438 { echo "$SYSTEM_NAME"; exit; }
439 echo mips-mips-riscos${UNAME_RELEASE}
440 exit ;;
441 Motorola:PowerMAX_OS:*:*)
442 echo powerpc-motorola-powermax
443 exit ;;
444 Motorola:*:4.3:PL8-*)
445 echo powerpc-harris-powermax
446 exit ;;
447 Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
448 echo powerpc-harris-powermax
449 exit ;;
450 Night_Hawk:Power_UNIX:*:*)
451 echo powerpc-harris-powerunix
452 exit ;;
453 m88k:CX/UX:7*:*)
454 echo m88k-harris-cxux7
455 exit ;;
456 m88k:*:4*:R4*)
457 echo m88k-motorola-sysv4
458 exit ;;
459 m88k:*:3*:R3*)
460 echo m88k-motorola-sysv3
461 exit ;;
462 AViiON:dgux:*:*)
463 # DG/UX returns AViiON for all architectures
464 UNAME_PROCESSOR=`/usr/bin/uname -p`
465 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
466 then
467 if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
468 [ ${TARGET_BINARY_INTERFACE}x = x ]
469 then
470 echo m88k-dg-dgux${UNAME_RELEASE}
471 else
472 echo m88k-dg-dguxbcs${UNAME_RELEASE}
473 fi
474 else
475 echo i586-dg-dgux${UNAME_RELEASE}
476 fi
477 exit ;;
478 M88*:DolphinOS:*:*) # DolphinOS (SVR3)
479 echo m88k-dolphin-sysv3
480 exit ;;
481 M88*:*:R3*:*)
482 # Delta 88k system running SVR3
483 echo m88k-motorola-sysv3
484 exit ;;
485 XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
486 echo m88k-tektronix-sysv3
487 exit ;;
488 Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
489 echo m68k-tektronix-bsd
490 exit ;;
491 *:IRIX*:*:*)
492 echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
493 exit ;;
494 ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
495 echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
496 exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
497 i*86:AIX:*:*)
498 echo i386-ibm-aix
499 exit ;;
500 ia64:AIX:*:*)
501 if [ -x /usr/bin/oslevel ] ; then
502 IBM_REV=`/usr/bin/oslevel`
503 else
504 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
505 fi
506 echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
507 exit ;;
508 *:AIX:2:3)
509 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
510 eval $set_cc_for_build
511 sed 's/^ //' << EOF >$dummy.c
512 #include <sys/systemcfg.h>
513
514 main()
515 {
516 if (!__power_pc())
517 exit(1);
518 puts("powerpc-ibm-aix3.2.5");
519 exit(0);
520 }
521 EOF
522 if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
523 then
524 echo "$SYSTEM_NAME"
525 else
526 echo rs6000-ibm-aix3.2.5
527 fi
528 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
529 echo rs6000-ibm-aix3.2.4
530 else
531 echo rs6000-ibm-aix3.2
532 fi
533 exit ;;
534 *:AIX:*:[45])
535 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
536 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
537 IBM_ARCH=rs6000
538 else
539 IBM_ARCH=powerpc
540 fi
541 if [ -x /usr/bin/oslevel ] ; then
542 IBM_REV=`/usr/bin/oslevel`
543 else
544 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
545 fi
546 echo ${IBM_ARCH}-ibm-aix${IBM_REV}
547 exit ;;
548 *:AIX:*:*)
549 echo rs6000-ibm-aix
550 exit ;;
551 ibmrt:4.4BSD:*|romp-ibm:BSD:*)
552 echo romp-ibm-bsd4.4
553 exit ;;
554 ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
555 echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
556 exit ;; # report: romp-ibm BSD 4.3
557 *:BOSX:*:*)
558 echo rs6000-bull-bosx
559 exit ;;
560 DPX/2?00:B.O.S.:*:*)
561 echo m68k-bull-sysv3
562 exit ;;
563 9000/[34]??:4.3bsd:1.*:*)
564 echo m68k-hp-bsd
565 exit ;;
566 hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
567 echo m68k-hp-bsd4.4
568 exit ;;
569 9000/[34678]??:HP-UX:*:*)
570 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
571 case "${UNAME_MACHINE}" in
572 9000/31? ) HP_ARCH=m68000 ;;
573 9000/[34]?? ) HP_ARCH=m68k ;;
574 9000/[678][0-9][0-9])
575 if [ -x /usr/bin/getconf ]; then
576 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
577 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
578 case "${sc_cpu_version}" in
579 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
580 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
581 532) # CPU_PA_RISC2_0
582 case "${sc_kernel_bits}" in
583 32) HP_ARCH="hppa2.0n" ;;
584 64) HP_ARCH="hppa2.0w" ;;
585 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
586 esac ;;
587 esac
588 fi
589 if [ "${HP_ARCH}" = "" ]; then
590 eval $set_cc_for_build
591 sed 's/^ //' << EOF >$dummy.c
592
593 #define _HPUX_SOURCE
594 #include <stdlib.h>
595 #include <unistd.h>
596
597 int main ()
598 {
599 #if defined(_SC_KERNEL_BITS)
600 long bits = sysconf(_SC_KERNEL_BITS);
601 #endif
602 long cpu = sysconf (_SC_CPU_VERSION);
603
604 switch (cpu)
605 {
606 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
607 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
608 case CPU_PA_RISC2_0:
609 #if defined(_SC_KERNEL_BITS)
610 switch (bits)
611 {
612 case 64: puts ("hppa2.0w"); break;
613 case 32: puts ("hppa2.0n"); break;
614 default: puts ("hppa2.0"); break;
615 } break;
616 #else /* !defined(_SC_KERNEL_BITS) */
617 puts ("hppa2.0"); break;
618 #endif
619 default: puts ("hppa1.0"); break;
620 }
621 exit (0);
622 }
623 EOF
624 (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
625 test -z "$HP_ARCH" && HP_ARCH=hppa
626 fi ;;
627 esac
628 if [ ${HP_ARCH} = "hppa2.0w" ]
629 then
630 eval $set_cc_for_build
631
632 # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
633 # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
634 # generating 64-bit code. GNU and HP use different nomenclature:
635 #
636 # $ CC_FOR_BUILD=cc ./config.guess
637 # => hppa2.0w-hp-hpux11.23
638 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
639 # => hppa64-hp-hpux11.23
640
641 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
642 grep __LP64__ >/dev/null
643 then
644 HP_ARCH="hppa2.0w"
645 else
646 HP_ARCH="hppa64"
647 fi
648 fi
649 echo ${HP_ARCH}-hp-hpux${HPUX_REV}
650 exit ;;
651 ia64:HP-UX:*:*)
652 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
653 echo ia64-hp-hpux${HPUX_REV}
654 exit ;;
655 3050*:HI-UX:*:*)
656 eval $set_cc_for_build
657 sed 's/^ //' << EOF >$dummy.c
658 #include <unistd.h>
659 int
660 main ()
661 {
662 long cpu = sysconf (_SC_CPU_VERSION);
663 /* The order matters, because CPU_IS_HP_MC68K erroneously returns
664 true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
665 results, however. */
666 if (CPU_IS_PA_RISC (cpu))
667 {
668 switch (cpu)
669 {
670 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
671 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
672 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
673 default: puts ("hppa-hitachi-hiuxwe2"); break;
674 }
675 }
676 else if (CPU_IS_HP_MC68K (cpu))
677 puts ("m68k-hitachi-hiuxwe2");
678 else puts ("unknown-hitachi-hiuxwe2");
679 exit (0);
680 }
681 EOF
682 $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
683 { echo "$SYSTEM_NAME"; exit; }
684 echo unknown-hitachi-hiuxwe2
685 exit ;;
686 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
687 echo hppa1.1-hp-bsd
688 exit ;;
689 9000/8??:4.3bsd:*:*)
690 echo hppa1.0-hp-bsd
691 exit ;;
692 *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
693 echo hppa1.0-hp-mpeix
694 exit ;;
695 hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
696 echo hppa1.1-hp-osf
697 exit ;;
698 hp8??:OSF1:*:*)
699 echo hppa1.0-hp-osf
700 exit ;;
701 i*86:OSF1:*:*)
702 if [ -x /usr/sbin/sysversion ] ; then
703 echo ${UNAME_MACHINE}-unknown-osf1mk
704 else
705 echo ${UNAME_MACHINE}-unknown-osf1
706 fi
707 exit ;;
708 parisc*:Lites*:*:*)
709 echo hppa1.1-hp-lites
710 exit ;;
711 C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
712 echo c1-convex-bsd
713 exit ;;
714 C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
715 if getsysinfo -f scalar_acc
716 then echo c32-convex-bsd
717 else echo c2-convex-bsd
718 fi
719 exit ;;
720 C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
721 echo c34-convex-bsd
722 exit ;;
723 C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
724 echo c38-convex-bsd
725 exit ;;
726 C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
727 echo c4-convex-bsd
728 exit ;;
729 CRAY*Y-MP:*:*:*)
730 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
731 exit ;;
732 CRAY*[A-Z]90:*:*:*)
733 echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
734 | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
735 -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
736 -e 's/\.[^.]*$/.X/'
737 exit ;;
738 CRAY*TS:*:*:*)
739 echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
740 exit ;;
741 CRAY*T3E:*:*:*)
742 echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
743 exit ;;
744 CRAY*SV1:*:*:*)
745 echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
746 exit ;;
747 *:UNICOS/mp:*:*)
748 echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
749 exit ;;
750 F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
751 FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
752 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
753 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
754 echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
755 exit ;;
756 5000:UNIX_System_V:4.*:*)
757 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
758 FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
759 echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
760 exit ;;
761 i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
762 echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
763 exit ;;
764 sparc*:BSD/OS:*:*)
765 echo sparc-unknown-bsdi${UNAME_RELEASE}
766 exit ;;
767 *:BSD/OS:*:*)
768 echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
769 exit ;;
770 *:FreeBSD:*:*)
771 case ${UNAME_MACHINE} in
772 pc98)
773 echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
774 amd64)
775 echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
776 *)
777 echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
778 esac
779 exit ;;
780 i*:CYGWIN*:*)
781 echo ${UNAME_MACHINE}-pc-cygwin
782 exit ;;
783 i*:MINGW*:*)
784 echo ${UNAME_MACHINE}-pc-mingw32
785 exit ;;
786 i*:windows32*:*)
787 # uname -m includes "-pc" on this system.
788 echo ${UNAME_MACHINE}-mingw32
789 exit ;;
790 i*:PW*:*)
791 echo ${UNAME_MACHINE}-pc-pw32
792 exit ;;
793 x86:Interix*:[3456]*)
794 echo i586-pc-interix${UNAME_RELEASE}
795 exit ;;
796 EM64T:Interix*:[3456]*)
797 echo x86_64-unknown-interix${UNAME_RELEASE}
798 exit ;;
799 [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
800 echo i${UNAME_MACHINE}-pc-mks
801 exit ;;
802 i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
803 # How do we know it's Interix rather than the generic POSIX subsystem?
804 # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
805 # UNAME_MACHINE based on the output of uname instead of i386?
806 echo i586-pc-interix
807 exit ;;
808 i*:UWIN*:*)
809 echo ${UNAME_MACHINE}-pc-uwin
810 exit ;;
811 amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
812 echo x86_64-unknown-cygwin
813 exit ;;
814 p*:CYGWIN*:*)
815 echo powerpcle-unknown-cygwin
816 exit ;;
817 prep*:SunOS:5.*:*)
818 echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
819 exit ;;
820 *:GNU:*:*)
821 # the GNU system
822 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
823 exit ;;
824 *:GNU/*:*:*)
825 # other systems with GNU libc and userland
826 echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
827 exit ;;
828 i*86:Minix:*:*)
829 echo ${UNAME_MACHINE}-pc-minix
830 exit ;;
831 arm*:Linux:*:*)
832 echo ${UNAME_MACHINE}-unknown-linux-gnu
833 exit ;;
834 avr32*:Linux:*:*)
835 echo ${UNAME_MACHINE}-unknown-linux-gnu
836 exit ;;
837 cris:Linux:*:*)
838 echo cris-axis-linux-gnu
839 exit ;;
840 crisv32:Linux:*:*)
841 echo crisv32-axis-linux-gnu
842 exit ;;
843 frv:Linux:*:*)
844 echo frv-unknown-linux-gnu
845 exit ;;
846 ia64:Linux:*:*)
847 echo ${UNAME_MACHINE}-unknown-linux-gnu
848 exit ;;
849 m32r*:Linux:*:*)
850 echo ${UNAME_MACHINE}-unknown-linux-gnu
851 exit ;;
852 m68*:Linux:*:*)
853 echo ${UNAME_MACHINE}-unknown-linux-gnu
854 exit ;;
855 mips:Linux:*:*)
856 eval $set_cc_for_build
857 sed 's/^ //' << EOF >$dummy.c
858 #undef CPU
859 #undef mips
860 #undef mipsel
861 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
862 CPU=mipsel
863 #else
864 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
865 CPU=mips
866 #else
867 CPU=
868 #endif
869 #endif
870 EOF
871 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
872 /^CPU/{
873 s: ::g
874 p
875 }'`"
876 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
877 ;;
878 mips64:Linux:*:*)
879 eval $set_cc_for_build
880 sed 's/^ //' << EOF >$dummy.c
881 #undef CPU
882 #undef mips64
883 #undef mips64el
884 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
885 CPU=mips64el
886 #else
887 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
888 CPU=mips64
889 #else
890 CPU=
891 #endif
892 #endif
893 EOF
894 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
895 /^CPU/{
896 s: ::g
897 p
898 }'`"
899 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
900 ;;
901 or32:Linux:*:*)
902 echo or32-unknown-linux-gnu
903 exit ;;
904 ppc:Linux:*:*)
905 echo powerpc-unknown-linux-gnu
906 exit ;;
907 ppc64:Linux:*:*)
908 echo powerpc64-unknown-linux-gnu
909 exit ;;
910 alpha:Linux:*:*)
911 case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
912 EV5) UNAME_MACHINE=alphaev5 ;;
913 EV56) UNAME_MACHINE=alphaev56 ;;
914 PCA56) UNAME_MACHINE=alphapca56 ;;
915 PCA57) UNAME_MACHINE=alphapca56 ;;
916 EV6) UNAME_MACHINE=alphaev6 ;;
917 EV67) UNAME_MACHINE=alphaev67 ;;
918 EV68*) UNAME_MACHINE=alphaev68 ;;
919 esac
920 objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
921 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
922 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
923 exit ;;
924 parisc:Linux:*:* | hppa:Linux:*:*)
925 # Look for CPU level
926 case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
927 PA7*) echo hppa1.1-unknown-linux-gnu ;;
928 PA8*) echo hppa2.0-unknown-linux-gnu ;;
929 *) echo hppa-unknown-linux-gnu ;;
930 esac
931 exit ;;
932 parisc64:Linux:*:* | hppa64:Linux:*:*)
933 echo hppa64-unknown-linux-gnu
934 exit ;;
935 s390:Linux:*:* | s390x:Linux:*:*)
936 echo ${UNAME_MACHINE}-ibm-linux
937 exit ;;
938 sh64*:Linux:*:*)
939 echo ${UNAME_MACHINE}-unknown-linux-gnu
940 exit ;;
941 sh*:Linux:*:*)
942 echo ${UNAME_MACHINE}-unknown-linux-gnu
943 exit ;;
944 sparc:Linux:*:* | sparc64:Linux:*:*)
945 echo ${UNAME_MACHINE}-unknown-linux-gnu
946 exit ;;
947 vax:Linux:*:*)
948 echo ${UNAME_MACHINE}-dec-linux-gnu
949 exit ;;
950 x86_64:Linux:*:*)
951 echo x86_64-unknown-linux-gnu
952 exit ;;
953 i*86:Linux:*:*)
954 # The BFD linker knows what the default object file format is, so
955 # first see if it will tell us. cd to the root directory to prevent
956 # problems with other programs or directories called `ld' in the path.
957 # Set LC_ALL=C to ensure ld outputs messages in English.
958 ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
959 | sed -ne '/supported targets:/!d
960 s/[ ][ ]*/ /g
961 s/.*supported targets: *//
962 s/ .*//
963 p'`
964 case "$ld_supported_targets" in
965 elf32-i386)
966 TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
967 ;;
968 a.out-i386-linux)
969 echo "${UNAME_MACHINE}-pc-linux-gnuaout"
970 exit ;;
971 coff-i386)
972 echo "${UNAME_MACHINE}-pc-linux-gnucoff"
973 exit ;;
974 "")
975 # Either a pre-BFD a.out linker (linux-gnuoldld) or
976 # one that does not give us useful --help.
977 echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
978 exit ;;
979 esac
980 # Determine whether the default compiler is a.out or elf
981 eval $set_cc_for_build
982 sed 's/^ //' << EOF >$dummy.c
983 #include <features.h>
984 #ifdef __ELF__
985 # ifdef __GLIBC__
986 # if __GLIBC__ >= 2
987 LIBC=gnu
988 # else
989 LIBC=gnulibc1
990 # endif
991 # else
992 LIBC=gnulibc1
993 # endif
994 #else
995 #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
996 LIBC=gnu
997 #else
998 LIBC=gnuaout
999 #endif
1000 #endif
1001 #ifdef __dietlibc__
1002 LIBC=dietlibc
1003 #endif
1004 EOF
1005 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
1006 /^LIBC/{
1007 s: ::g
1008 p
1009 }'`"
1010 test x"${LIBC}" != x && {
1011 echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
1012 exit
1013 }
1014 test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
1015 ;;
1016 i*86:DYNIX/ptx:4*:*)
1017 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1018 # earlier versions are messed up and put the nodename in both
1019 # sysname and nodename.
1020 echo i386-sequent-sysv4
1021 exit ;;
1022 i*86:UNIX_SV:4.2MP:2.*)
1023 # Unixware is an offshoot of SVR4, but it has its own version
1024 # number series starting with 2...
1025 # I am not positive that other SVR4 systems won't match this,
1026 # I just have to hope. -- rms.
1027 # Use sysv4.2uw... so that sysv4* matches it.
1028 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
1029 exit ;;
1030 i*86:OS/2:*:*)
1031 # If we were able to find `uname', then EMX Unix compatibility
1032 # is probably installed.
1033 echo ${UNAME_MACHINE}-pc-os2-emx
1034 exit ;;
1035 i*86:XTS-300:*:STOP)
1036 echo ${UNAME_MACHINE}-unknown-stop
1037 exit ;;
1038 i*86:atheos:*:*)
1039 echo ${UNAME_MACHINE}-unknown-atheos
1040 exit ;;
1041 i*86:syllable:*:*)
1042 echo ${UNAME_MACHINE}-pc-syllable
1043 exit ;;
1044 i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
1045 echo i386-unknown-lynxos${UNAME_RELEASE}
1046 exit ;;
1047 i*86:*DOS:*:*)
1048 echo ${UNAME_MACHINE}-pc-msdosdjgpp
1049 exit ;;
1050 i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
1051 UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
1052 if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1053 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
1054 else
1055 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
1056 fi
1057 exit ;;
1058 i*86:*:5:[678]*)
1059 # UnixWare 7.x, OpenUNIX and OpenServer 6.
1060 case `/bin/uname -X | grep "^Machine"` in
1061 *486*) UNAME_MACHINE=i486 ;;
1062 *Pentium) UNAME_MACHINE=i586 ;;
1063 *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1064 esac
1065 echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1066 exit ;;
1067 i*86:*:3.2:*)
1068 if test -f /usr/options/cb.name; then
1069 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1070 echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
1071 elif /bin/uname -X 2>/dev/null >/dev/null ; then
1072 UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1073 (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1074 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1075 && UNAME_MACHINE=i586
1076 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1077 && UNAME_MACHINE=i686
1078 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1079 && UNAME_MACHINE=i686
1080 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
1081 else
1082 echo ${UNAME_MACHINE}-pc-sysv32
1083 fi
1084 exit ;;
1085 pc:*:*:*)
1086 # Left here for compatibility:
1087 # uname -m prints for DJGPP always 'pc', but it prints nothing about
1088 # the processor, so we play safe by assuming i386.
1089 echo i386-pc-msdosdjgpp
1090 exit ;;
1091 Intel:Mach:3*:*)
1092 echo i386-pc-mach3
1093 exit ;;
1094 paragon:*:*:*)
1095 echo i860-intel-osf1
1096 exit ;;
1097 i860:*:4.*:*) # i860-SVR4
1098 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1099 echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
1100 else # Add other i860-SVR4 vendors below as they are discovered.
1101 echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
1102 fi
1103 exit ;;
1104 mini*:CTIX:SYS*5:*)
1105 # "miniframe"
1106 echo m68010-convergent-sysv
1107 exit ;;
1108 mc68k:UNIX:SYSTEM5:3.51m)
1109 echo m68k-convergent-sysv
1110 exit ;;
1111 M680?0:D-NIX:5.3:*)
1112 echo m68k-diab-dnix
1113 exit ;;
1114 M68*:*:R3V[5678]*:*)
1115 test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1116 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
1117 OS_REL=''
1118 test -r /etc/.relid \
1119 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1120 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1121 && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
1122 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1123 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
1124 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1125 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1126 && { echo i486-ncr-sysv4; exit; } ;;
1127 m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1128 echo m68k-unknown-lynxos${UNAME_RELEASE}
1129 exit ;;
1130 mc68030:UNIX_System_V:4.*:*)
1131 echo m68k-atari-sysv4
1132 exit ;;
1133 TSUNAMI:LynxOS:2.*:*)
1134 echo sparc-unknown-lynxos${UNAME_RELEASE}
1135 exit ;;
1136 rs6000:LynxOS:2.*:*)
1137 echo rs6000-unknown-lynxos${UNAME_RELEASE}
1138 exit ;;
1139 PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
1140 echo powerpc-unknown-lynxos${UNAME_RELEASE}
1141 exit ;;
1142 SM[BE]S:UNIX_SV:*:*)
1143 echo mips-dde-sysv${UNAME_RELEASE}
1144 exit ;;
1145 RM*:ReliantUNIX-*:*:*)
1146 echo mips-sni-sysv4
1147 exit ;;
1148 RM*:SINIX-*:*:*)
1149 echo mips-sni-sysv4
1150 exit ;;
1151 *:SINIX-*:*:*)
1152 if uname -p 2>/dev/null >/dev/null ; then
1153 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1154 echo ${UNAME_MACHINE}-sni-sysv4
1155 else
1156 echo ns32k-sni-sysv
1157 fi
1158 exit ;;
1159 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1160 # says <Richard.M.Bartel@ccMail.Census.GOV>
1161 echo i586-unisys-sysv4
1162 exit ;;
1163 *:UNIX_System_V:4*:FTX*)
1164 # From Gerald Hewes <hewes@openmarket.com>.
1165 # How about differentiating between stratus architectures? -djm
1166 echo hppa1.1-stratus-sysv4
1167 exit ;;
1168 *:*:*:FTX*)
1169 # From seanf@swdc.stratus.com.
1170 echo i860-stratus-sysv4
1171 exit ;;
1172 i*86:VOS:*:*)
1173 # From Paul.Green@stratus.com.
1174 echo ${UNAME_MACHINE}-stratus-vos
1175 exit ;;
1176 *:VOS:*:*)
1177 # From Paul.Green@stratus.com.
1178 echo hppa1.1-stratus-vos
1179 exit ;;
1180 mc68*:A/UX:*:*)
1181 echo m68k-apple-aux${UNAME_RELEASE}
1182 exit ;;
1183 news*:NEWS-OS:6*:*)
1184 echo mips-sony-newsos6
1185 exit ;;
1186 R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1187 if [ -d /usr/nec ]; then
1188 echo mips-nec-sysv${UNAME_RELEASE}
1189 else
1190 echo mips-unknown-sysv${UNAME_RELEASE}
1191 fi
1192 exit ;;
1193 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
1194 echo powerpc-be-beos
1195 exit ;;
1196 BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
1197 echo powerpc-apple-beos
1198 exit ;;
1199 BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
1200 echo i586-pc-beos
1201 exit ;;
1202 SX-4:SUPER-UX:*:*)
1203 echo sx4-nec-superux${UNAME_RELEASE}
1204 exit ;;
1205 SX-5:SUPER-UX:*:*)
1206 echo sx5-nec-superux${UNAME_RELEASE}
1207 exit ;;
1208 SX-6:SUPER-UX:*:*)
1209 echo sx6-nec-superux${UNAME_RELEASE}
1210 exit ;;
1211 Power*:Rhapsody:*:*)
1212 echo powerpc-apple-rhapsody${UNAME_RELEASE}
1213 exit ;;
1214 *:Rhapsody:*:*)
1215 echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
1216 exit ;;
1217 *:Darwin:*:*)
1218 UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
1219 case $UNAME_PROCESSOR in
1220 unknown) UNAME_PROCESSOR=powerpc ;;
1221 esac
1222 echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
1223 exit ;;
1224 *:procnto*:*:* | *:QNX:[0123456789]*:*)
1225 UNAME_PROCESSOR=`uname -p`
1226 if test "$UNAME_PROCESSOR" = "x86"; then
1227 UNAME_PROCESSOR=i386
1228 UNAME_MACHINE=pc
1229 fi
1230 echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
1231 exit ;;
1232 *:QNX:*:4*)
1233 echo i386-pc-qnx
1234 exit ;;
1235 NSE-?:NONSTOP_KERNEL:*:*)
1236 echo nse-tandem-nsk${UNAME_RELEASE}
1237 exit ;;
1238 NSR-?:NONSTOP_KERNEL:*:*)
1239 echo nsr-tandem-nsk${UNAME_RELEASE}
1240 exit ;;
1241 *:NonStop-UX:*:*)
1242 echo mips-compaq-nonstopux
1243 exit ;;
1244 BS2000:POSIX*:*:*)
1245 echo bs2000-siemens-sysv
1246 exit ;;
1247 DS/*:UNIX_System_V:*:*)
1248 echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
1249 exit ;;
1250 *:Plan9:*:*)
1251 # "uname -m" is not consistent, so use $cputype instead. 386
1252 # is converted to i386 for consistency with other x86
1253 # operating systems.
1254 if test "$cputype" = "386"; then
1255 UNAME_MACHINE=i386
1256 else
1257 UNAME_MACHINE="$cputype"
1258 fi
1259 echo ${UNAME_MACHINE}-unknown-plan9
1260 exit ;;
1261 *:TOPS-10:*:*)
1262 echo pdp10-unknown-tops10
1263 exit ;;
1264 *:TENEX:*:*)
1265 echo pdp10-unknown-tenex
1266 exit ;;
1267 KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1268 echo pdp10-dec-tops20
1269 exit ;;
1270 XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1271 echo pdp10-xkl-tops20
1272 exit ;;
1273 *:TOPS-20:*:*)
1274 echo pdp10-unknown-tops20
1275 exit ;;
1276 *:ITS:*:*)
1277 echo pdp10-unknown-its
1278 exit ;;
1279 SEI:*:*:SEIUX)
1280 echo mips-sei-seiux${UNAME_RELEASE}
1281 exit ;;
1282 *:DragonFly:*:*)
1283 echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
1284 exit ;;
1285 *:*VMS:*:*)
1286 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1287 case "${UNAME_MACHINE}" in
1288 A*) echo alpha-dec-vms ; exit ;;
1289 I*) echo ia64-dec-vms ; exit ;;
1290 V*) echo vax-dec-vms ; exit ;;
1291 esac ;;
1292 *:XENIX:*:SysV)
1293 echo i386-pc-xenix
1294 exit ;;
1295 i*86:skyos:*:*)
1296 echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
1297 exit ;;
1298 i*86:rdos:*:*)
1299 echo ${UNAME_MACHINE}-pc-rdos
1300 exit ;;
1301 esac
1302
1303 #echo '(No uname command or uname output not recognized.)' 1>&2
1304 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
1305
1306 eval $set_cc_for_build
1307 cat >$dummy.c <<EOF
1308 #ifdef _SEQUENT_
1309 # include <sys/types.h>
1310 # include <sys/utsname.h>
1311 #endif
1312 main ()
1313 {
1314 #if defined (sony)
1315 #if defined (MIPSEB)
1316 /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
1317 I don't know.... */
1318 printf ("mips-sony-bsd\n"); exit (0);
1319 #else
1320 #include <sys/param.h>
1321 printf ("m68k-sony-newsos%s\n",
1322 #ifdef NEWSOS4
1323 "4"
1324 #else
1325 ""
1326 #endif
1327 ); exit (0);
1328 #endif
1329 #endif
1330
1331 #if defined (__arm) && defined (__acorn) && defined (__unix)
1332 printf ("arm-acorn-riscix\n"); exit (0);
1333 #endif
1334
1335 #if defined (hp300) && !defined (hpux)
1336 printf ("m68k-hp-bsd\n"); exit (0);
1337 #endif
1338
1339 #if defined (NeXT)
1340 #if !defined (__ARCHITECTURE__)
1341 #define __ARCHITECTURE__ "m68k"
1342 #endif
1343 int version;
1344 version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1345 if (version < 4)
1346 printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1347 else
1348 printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1349 exit (0);
1350 #endif
1351
1352 #if defined (MULTIMAX) || defined (n16)
1353 #if defined (UMAXV)
1354 printf ("ns32k-encore-sysv\n"); exit (0);
1355 #else
1356 #if defined (CMU)
1357 printf ("ns32k-encore-mach\n"); exit (0);
1358 #else
1359 printf ("ns32k-encore-bsd\n"); exit (0);
1360 #endif
1361 #endif
1362 #endif
1363
1364 #if defined (__386BSD__)
1365 printf ("i386-pc-bsd\n"); exit (0);
1366 #endif
1367
1368 #if defined (sequent)
1369 #if defined (i386)
1370 printf ("i386-sequent-dynix\n"); exit (0);
1371 #endif
1372 #if defined (ns32000)
1373 printf ("ns32k-sequent-dynix\n"); exit (0);
1374 #endif
1375 #endif
1376
1377 #if defined (_SEQUENT_)
1378 struct utsname un;
1379
1380 uname(&un);
1381
1382 if (strncmp(un.version, "V2", 2) == 0) {
1383 printf ("i386-sequent-ptx2\n"); exit (0);
1384 }
1385 if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1386 printf ("i386-sequent-ptx1\n"); exit (0);
1387 }
1388 printf ("i386-sequent-ptx\n"); exit (0);
1389
1390 #endif
1391
1392 #if defined (vax)
1393 # if !defined (ultrix)
1394 # include <sys/param.h>
1395 # if defined (BSD)
1396 # if BSD == 43
1397 printf ("vax-dec-bsd4.3\n"); exit (0);
1398 # else
1399 # if BSD == 199006
1400 printf ("vax-dec-bsd4.3reno\n"); exit (0);
1401 # else
1402 printf ("vax-dec-bsd\n"); exit (0);
1403 # endif
1404 # endif
1405 # else
1406 printf ("vax-dec-bsd\n"); exit (0);
1407 # endif
1408 # else
1409 printf ("vax-dec-ultrix\n"); exit (0);
1410 # endif
1411 #endif
1412
1413 #if defined (alliant) && defined (i860)
1414 printf ("i860-alliant-bsd\n"); exit (0);
1415 #endif
1416
1417 exit (1);
1418 }
1419 EOF
1420
1421 $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
1422 { echo "$SYSTEM_NAME"; exit; }
1423
1424 # Apollos put the system type in the environment.
1425
1426 test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
1427
1428 # Convex versions that predate uname can use getsysinfo(1)
1429
1430 if [ -x /usr/convex/getsysinfo ]
1431 then
1432 case `getsysinfo -f cpu_type` in
1433 c1*)
1434 echo c1-convex-bsd
1435 exit ;;
1436 c2*)
1437 if getsysinfo -f scalar_acc
1438 then echo c32-convex-bsd
1439 else echo c2-convex-bsd
1440 fi
1441 exit ;;
1442 c34*)
1443 echo c34-convex-bsd
1444 exit ;;
1445 c38*)
1446 echo c38-convex-bsd
1447 exit ;;
1448 c4*)
1449 echo c4-convex-bsd
1450 exit ;;
1451 esac
1452 fi
1453
1454 cat >&2 <<EOF
1455 $0: unable to guess system type
1456
1457 This script, last modified $timestamp, has failed to recognize
1458 the operating system you are using. It is advised that you
1459 download the most up to date version of the config scripts from
1460
1461 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
1462 and
1463 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
1464
1465 If the version you run ($0) is already up to date, please
1466 send the following data and any information you think might be
1467 pertinent to <config-patches@gnu.org> in order to provide the needed
1468 information to handle your system.
1469
1470 config.guess timestamp = $timestamp
1471
1472 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1473 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1474 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1475 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1476
1477 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1478 /bin/uname -X = `(/bin/uname -X) 2>/dev/null`
1479
1480 hostinfo = `(hostinfo) 2>/dev/null`
1481 /bin/universe = `(/bin/universe) 2>/dev/null`
1482 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
1483 /bin/arch = `(/bin/arch) 2>/dev/null`
1484 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
1485 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1486
1487 UNAME_MACHINE = ${UNAME_MACHINE}
1488 UNAME_RELEASE = ${UNAME_RELEASE}
1489 UNAME_SYSTEM = ${UNAME_SYSTEM}
1490 UNAME_VERSION = ${UNAME_VERSION}
1491 EOF
1492
1493 exit 1
1494
1495 # Local variables:
1496 # eval: (add-hook 'write-file-hooks 'time-stamp)
1497 # time-stamp-start: "timestamp='"
1498 # time-stamp-format: "%:y-%02m-%02d"
1499 # time-stamp-end: "'"
1500 # End:
File config.h.in added (mode: 100644) (index 00000000..28e9e48e)
1 /* config.h.in. Generated from configure.ac by autoheader. */
2
3 /* Define if you have the <DECkeySym.h> header file */
4 #undef HAVE_DECKEYSYM_H
5
6 /* Define to 1 if you have the <dlfcn.h> header file. */
7 #undef HAVE_DLFCN_H
8
9 /* Define to 1 if you have the <dl.h> header file. */
10 #undef HAVE_DL_H
11
12 /* Define to 1 if you have the <fcntl.h> header file. */
13 #undef HAVE_FCNTL_H
14
15 /* Define to 1 if you have the <inttypes.h> header file. */
16 #undef HAVE_INTTYPES_H
17
18 /* Define to 1 if you have the <memory.h> header file. */
19 #undef HAVE_MEMORY_H
20
21 /* Define to 1 if you have the `poll' function. */
22 #undef HAVE_POLL
23
24 /* Define to 1 if you have the <stdint.h> header file. */
25 #undef HAVE_STDINT_H
26
27 /* Define to 1 if you have the <stdlib.h> header file. */
28 #undef HAVE_STDLIB_H
29
30 /* Define to 1 if you have the <strings.h> header file. */
31 #undef HAVE_STRINGS_H
32
33 /* Define to 1 if you have the <string.h> header file. */
34 #undef HAVE_STRING_H
35
36 /* Define if you have the <Sunkeysym.h> header file */
37 #undef HAVE_SUNKEYSYM_H
38
39 /* Define to 1 if you have the <sys/select.h> header file. */
40 #undef HAVE_SYS_SELECT_H
41
42 /* Define to 1 if you have the <sys/stat.h> header file. */
43 #undef HAVE_SYS_STAT_H
44
45 /* Define to 1 if you have the <sys/time.h> header file. */
46 #undef HAVE_SYS_TIME_H
47
48 /* Define to 1 if you have the <sys/types.h> header file. */
49 #undef HAVE_SYS_TYPES_H
50
51 /* Define to 1 if you have the <unistd.h> header file. */
52 #undef HAVE_UNISTD_H
53
54 /* Define to 1 if you have the `usleep' function. */
55 #undef HAVE_USLEEP
56
57 /* Define to 1 if you have the `vsnprintf' function. */
58 #undef HAVE_VSNPRINTF
59
60 /* Define to 1 if you have the `vsscanf' function. */
61 #undef HAVE_VSSCANF
62
63 /* Define if you have this defined in <keysym.h> */
64 #undef HAVE_XK_KP_BEGIN
65
66 /* Define if you have this defined in <keysym.h> */
67 #undef HAVE_XK_KP_DELETE
68
69 /* Define if you have this defined in <keysym.h> */
70 #undef HAVE_XK_KP_DOWN
71
72 /* Define if you have this defined in <keysym.h> */
73 #undef HAVE_XK_KP_END
74
75 /* Define if you have this defined in <keysym.h> */
76 #undef HAVE_XK_KP_HOME
77
78 /* Define if you have this defined in <keysym.h> */
79 #undef HAVE_XK_KP_INSERT
80
81 /* Define if you have this defined in <keysym.h> */
82 #undef HAVE_XK_KP_LEFT
83
84 /* Define if you have this defined in <keysym.h> */
85 #undef HAVE_XK_KP_NEXT
86
87 /* Define if you have this defined in <keysym.h> */
88 #undef HAVE_XK_KP_PRIOR
89
90 /* Define if you have this defined in <keysym.h> */
91 #undef HAVE_XK_KP_RIGHT
92
93 /* Define if you have this defined in <keysym.h> */
94 #undef HAVE_XK_KP_UP
95
96 /* Define if you have the <xpm.h> header file */
97 #undef HAVE_XPM_H
98
99 /* Define to the address where bug reports for this package should be sent. */
100 #undef PACKAGE_BUGREPORT
101
102 /* Define to the full name of this package. */
103 #undef PACKAGE_NAME
104
105 /* Define to the full name and version of this package. */
106 #undef PACKAGE_STRING
107
108 /* Define to the one symbol short name of this package. */
109 #undef PACKAGE_TARNAME
110
111 /* Define to the version of this package. */
112 #undef PACKAGE_VERSION
113
114 /* Define as the system defined limit for number of signals */
115 #undef PDC_MAX_SIGNALS
116
117 /* Define as the return type of signal handlers (`int' or `void'). */
118 #undef RETSIGTYPE
119
120 /* Define to 1 if you have the ANSI C header files. */
121 #undef STDC_HEADERS
122
123 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
124 #undef TIME_WITH_SYS_TIME
125
126 /* Define if you want to use neXtaw library */
127 #undef USE_NEXTAW
128
129 /* Define if you want to use Xaw3d library */
130 #undef USE_XAW3D
131
132 /* Define XPointer is typedefed in X11/Xlib.h */
133 #undef XPOINTER_TYPEDEFED
File config.sub added (mode: 100755) (index 00000000..fab0aa35)
1 #! /bin/sh
2 # Configuration validation subroutine script.
3 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
5 # Inc.
6
7 timestamp='2006-09-20'
8
9 # This file is (in principle) common to ALL GNU software.
10 # The presence of a machine in this file suggests that SOME GNU software
11 # can handle that machine. It does not imply ALL GNU software can.
12 #
13 # This file is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
26 # 02110-1301, USA.
27 #
28 # As a special exception to the GNU General Public License, if you
29 # distribute this file as part of a program that contains a
30 # configuration script generated by Autoconf, you may include it under
31 # the same distribution terms that you use for the rest of that program.
32
33
34 # Please send patches to <config-patches@gnu.org>. Submit a context
35 # diff and a properly formatted ChangeLog entry.
36 #
37 # Configuration subroutine to validate and canonicalize a configuration type.
38 # Supply the specified configuration type as an argument.
39 # If it is invalid, we print an error message on stderr and exit with code 1.
40 # Otherwise, we print the canonical config type on stdout and succeed.
41
42 # This file is supposed to be the same for all GNU packages
43 # and recognize all the CPU types, system types and aliases
44 # that are meaningful with *any* GNU software.
45 # Each package is responsible for reporting which valid configurations
46 # it does not support. The user should be able to distinguish
47 # a failure to support a valid configuration from a meaningless
48 # configuration.
49
50 # The goal of this file is to map all the various variations of a given
51 # machine specification into a single specification in the form:
52 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
53 # or in some cases, the newer four-part form:
54 # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
55 # It is wrong to echo any other type of specification.
56
57 me=`echo "$0" | sed -e 's,.*/,,'`
58
59 usage="\
60 Usage: $0 [OPTION] CPU-MFR-OPSYS
61 $0 [OPTION] ALIAS
62
63 Canonicalize a configuration name.
64
65 Operation modes:
66 -h, --help print this help, then exit
67 -t, --time-stamp print date of last modification, then exit
68 -v, --version print version number, then exit
69
70 Report bugs and patches to <config-patches@gnu.org>."
71
72 version="\
73 GNU config.sub ($timestamp)
74
75 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
76 Free Software Foundation, Inc.
77
78 This is free software; see the source for copying conditions. There is NO
79 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
80
81 help="
82 Try \`$me --help' for more information."
83
84 # Parse command line
85 while test $# -gt 0 ; do
86 case $1 in
87 --time-stamp | --time* | -t )
88 echo "$timestamp" ; exit ;;
89 --version | -v )
90 echo "$version" ; exit ;;
91 --help | --h* | -h )
92 echo "$usage"; exit ;;
93 -- ) # Stop option processing
94 shift; break ;;
95 - ) # Use stdin as input.
96 break ;;
97 -* )
98 echo "$me: invalid option $1$help"
99 exit 1 ;;
100
101 *local*)
102 # First pass through any local machine types.
103 echo $1
104 exit ;;
105
106 * )
107 break ;;
108 esac
109 done
110
111 case $# in
112 0) echo "$me: missing argument$help" >&2
113 exit 1;;
114 1) ;;
115 *) echo "$me: too many arguments$help" >&2
116 exit 1;;
117 esac
118
119 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
120 # Here we must recognize all the valid KERNEL-OS combinations.
121 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
122 case $maybe_os in
123 nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
124 uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
125 storm-chaos* | os2-emx* | rtmk-nova*)
126 os=-$maybe_os
127 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
128 ;;
129 *)
130 basic_machine=`echo $1 | sed 's/-[^-]*$//'`
131 if [ $basic_machine != $1 ]
132 then os=`echo $1 | sed 's/.*-/-/'`
133 else os=; fi
134 ;;
135 esac
136
137 ### Let's recognize common machines as not being operating systems so
138 ### that things like config.sub decstation-3100 work. We also
139 ### recognize some manufacturers as not being operating systems, so we
140 ### can provide default operating systems below.
141 case $os in
142 -sun*os*)
143 # Prevent following clause from handling this invalid input.
144 ;;
145 -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
146 -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
147 -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
148 -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
149 -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
150 -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
151 -apple | -axis | -knuth | -cray)
152 os=
153 basic_machine=$1
154 ;;
155 -sim | -cisco | -oki | -wec | -winbond)
156 os=
157 basic_machine=$1
158 ;;
159 -scout)
160 ;;
161 -wrs)
162 os=-vxworks
163 basic_machine=$1
164 ;;
165 -chorusos*)
166 os=-chorusos
167 basic_machine=$1
168 ;;
169 -chorusrdb)
170 os=-chorusrdb
171 basic_machine=$1
172 ;;
173 -hiux*)
174 os=-hiuxwe2
175 ;;
176 -sco6)
177 os=-sco5v6
178 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
179 ;;
180 -sco5)
181 os=-sco3.2v5
182 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
183 ;;
184 -sco4)
185 os=-sco3.2v4
186 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
187 ;;
188 -sco3.2.[4-9]*)
189 os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
190 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
191 ;;
192 -sco3.2v[4-9]*)
193 # Don't forget version if it is 3.2v4 or newer.
194 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
195 ;;
196 -sco5v6*)
197 # Don't forget version if it is 3.2v4 or newer.
198 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
199 ;;
200 -sco*)
201 os=-sco3.2v2
202 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
203 ;;
204 -udk*)
205 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
206 ;;
207 -isc)
208 os=-isc2.2
209 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
210 ;;
211 -clix*)
212 basic_machine=clipper-intergraph
213 ;;
214 -isc*)
215 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
216 ;;
217 -lynx*)
218 os=-lynxos
219 ;;
220 -ptx*)
221 basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
222 ;;
223 -windowsnt*)
224 os=`echo $os | sed -e 's/windowsnt/winnt/'`
225 ;;
226 -psos*)
227 os=-psos
228 ;;
229 -mint | -mint[0-9]*)
230 basic_machine=m68k-atari
231 os=-mint
232 ;;
233 esac
234
235 # Decode aliases for certain CPU-COMPANY combinations.
236 case $basic_machine in
237 # Recognize the basic CPU types without company name.
238 # Some are omitted here because they have special meanings below.
239 1750a | 580 \
240 | a29k \
241 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
242 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
243 | am33_2.0 \
244 | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
245 | bfin \
246 | c4x | clipper \
247 | d10v | d30v | dlx | dsp16xx \
248 | fr30 | frv \
249 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
250 | i370 | i860 | i960 | ia64 \
251 | ip2k | iq2000 \
252 | m32c | m32r | m32rle | m68000 | m68k | m88k \
253 | maxq | mb | microblaze | mcore \
254 | mips | mipsbe | mipseb | mipsel | mipsle \
255 | mips16 \
256 | mips64 | mips64el \
257 | mips64vr | mips64vrel \
258 | mips64orion | mips64orionel \
259 | mips64vr4100 | mips64vr4100el \
260 | mips64vr4300 | mips64vr4300el \
261 | mips64vr5000 | mips64vr5000el \
262 | mips64vr5900 | mips64vr5900el \
263 | mipsisa32 | mipsisa32el \
264 | mipsisa32r2 | mipsisa32r2el \
265 | mipsisa64 | mipsisa64el \
266 | mipsisa64r2 | mipsisa64r2el \
267 | mipsisa64sb1 | mipsisa64sb1el \
268 | mipsisa64sr71k | mipsisa64sr71kel \
269 | mipstx39 | mipstx39el \
270 | mn10200 | mn10300 \
271 | mt \
272 | msp430 \
273 | nios | nios2 \
274 | ns16k | ns32k \
275 | or32 \
276 | pdp10 | pdp11 | pj | pjl \
277 | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
278 | pyramid \
279 | score \
280 | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
281 | sh64 | sh64le \
282 | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
283 | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
284 | spu | strongarm \
285 | tahoe | thumb | tic4x | tic80 | tron \
286 | v850 | v850e \
287 | we32k \
288 | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
289 | z8k)
290 basic_machine=$basic_machine-unknown
291 ;;
292 m6811 | m68hc11 | m6812 | m68hc12)
293 # Motorola 68HC11/12.
294 basic_machine=$basic_machine-unknown
295 os=-none
296 ;;
297 m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
298 ;;
299 ms1)
300 basic_machine=mt-unknown
301 ;;
302
303 # We use `pc' rather than `unknown'
304 # because (1) that's what they normally are, and
305 # (2) the word "unknown" tends to confuse beginning users.
306 i*86 | x86_64)
307 basic_machine=$basic_machine-pc
308 ;;
309 # Object if more than one company name word.
310 *-*-*)
311 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
312 exit 1
313 ;;
314 # Recognize the basic CPU types with company name.
315 580-* \
316 | a29k-* \
317 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
318 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
319 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
320 | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
321 | avr-* | avr32-* \
322 | bfin-* | bs2000-* \
323 | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
324 | clipper-* | craynv-* | cydra-* \
325 | d10v-* | d30v-* | dlx-* \
326 | elxsi-* \
327 | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
328 | h8300-* | h8500-* \
329 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
330 | i*86-* | i860-* | i960-* | ia64-* \
331 | ip2k-* | iq2000-* \
332 | m32c-* | m32r-* | m32rle-* \
333 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
334 | m88110-* | m88k-* | maxq-* | mcore-* \
335 | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
336 | mips16-* \
337 | mips64-* | mips64el-* \
338 | mips64vr-* | mips64vrel-* \
339 | mips64orion-* | mips64orionel-* \
340 | mips64vr4100-* | mips64vr4100el-* \
341 | mips64vr4300-* | mips64vr4300el-* \
342 | mips64vr5000-* | mips64vr5000el-* \
343 | mips64vr5900-* | mips64vr5900el-* \
344 | mipsisa32-* | mipsisa32el-* \
345 | mipsisa32r2-* | mipsisa32r2el-* \
346 | mipsisa64-* | mipsisa64el-* \
347 | mipsisa64r2-* | mipsisa64r2el-* \
348 | mipsisa64sb1-* | mipsisa64sb1el-* \
349 | mipsisa64sr71k-* | mipsisa64sr71kel-* \
350 | mipstx39-* | mipstx39el-* \
351 | mmix-* \
352 | mt-* \
353 | msp430-* \
354 | nios-* | nios2-* \
355 | none-* | np1-* | ns16k-* | ns32k-* \
356 | orion-* \
357 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
358 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
359 | pyramid-* \
360 | romp-* | rs6000-* \
361 | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
362 | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
363 | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
364 | sparclite-* \
365 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
366 | tahoe-* | thumb-* \
367 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
368 | tron-* \
369 | v850-* | v850e-* | vax-* \
370 | we32k-* \
371 | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
372 | xstormy16-* | xtensa-* \
373 | ymp-* \
374 | z8k-*)
375 ;;
376 # Recognize the various machine names and aliases which stand
377 # for a CPU type and a company and sometimes even an OS.
378 386bsd)
379 basic_machine=i386-unknown
380 os=-bsd
381 ;;
382 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
383 basic_machine=m68000-att
384 ;;
385 3b*)
386 basic_machine=we32k-att
387 ;;
388 a29khif)
389 basic_machine=a29k-amd
390 os=-udi
391 ;;
392 abacus)
393 basic_machine=abacus-unknown
394 ;;
395 adobe68k)
396 basic_machine=m68010-adobe
397 os=-scout
398 ;;
399 alliant | fx80)
400 basic_machine=fx80-alliant
401 ;;
402 altos | altos3068)
403 basic_machine=m68k-altos
404 ;;
405 am29k)
406 basic_machine=a29k-none
407 os=-bsd
408 ;;
409 amd64)
410 basic_machine=x86_64-pc
411 ;;
412 amd64-*)
413 basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
414 ;;
415 amdahl)
416 basic_machine=580-amdahl
417 os=-sysv
418 ;;
419 amiga | amiga-*)
420 basic_machine=m68k-unknown
421 ;;
422 amigaos | amigados)
423 basic_machine=m68k-unknown
424 os=-amigaos
425 ;;
426 amigaunix | amix)
427 basic_machine=m68k-unknown
428 os=-sysv4
429 ;;
430 apollo68)
431 basic_machine=m68k-apollo
432 os=-sysv
433 ;;
434 apollo68bsd)
435 basic_machine=m68k-apollo
436 os=-bsd
437 ;;
438 aux)
439 basic_machine=m68k-apple
440 os=-aux
441 ;;
442 balance)
443 basic_machine=ns32k-sequent
444 os=-dynix
445 ;;
446 c90)
447 basic_machine=c90-cray
448 os=-unicos
449 ;;
450 convex-c1)
451 basic_machine=c1-convex
452 os=-bsd
453 ;;
454 convex-c2)
455 basic_machine=c2-convex
456 os=-bsd
457 ;;
458 convex-c32)
459 basic_machine=c32-convex
460 os=-bsd
461 ;;
462 convex-c34)
463 basic_machine=c34-convex
464 os=-bsd
465 ;;
466 convex-c38)
467 basic_machine=c38-convex
468 os=-bsd
469 ;;
470 cray | j90)
471 basic_machine=j90-cray
472 os=-unicos
473 ;;
474 craynv)
475 basic_machine=craynv-cray
476 os=-unicosmp
477 ;;
478 cr16c)
479 basic_machine=cr16c-unknown
480 os=-elf
481 ;;
482 crds | unos)
483 basic_machine=m68k-crds
484 ;;
485 crisv32 | crisv32-* | etraxfs*)
486 basic_machine=crisv32-axis
487 ;;
488 cris | cris-* | etrax*)
489 basic_machine=cris-axis
490 ;;
491 crx)
492 basic_machine=crx-unknown
493 os=-elf
494 ;;
495 da30 | da30-*)
496 basic_machine=m68k-da30
497 ;;
498 decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
499 basic_machine=mips-dec
500 ;;
501 decsystem10* | dec10*)
502 basic_machine=pdp10-dec
503 os=-tops10
504 ;;
505 decsystem20* | dec20*)
506 basic_machine=pdp10-dec
507 os=-tops20
508 ;;
509 delta | 3300 | motorola-3300 | motorola-delta \
510 | 3300-motorola | delta-motorola)
511 basic_machine=m68k-motorola
512 ;;
513 delta88)
514 basic_machine=m88k-motorola
515 os=-sysv3
516 ;;
517 djgpp)
518 basic_machine=i586-pc
519 os=-msdosdjgpp
520 ;;
521 dpx20 | dpx20-*)
522 basic_machine=rs6000-bull
523 os=-bosx
524 ;;
525 dpx2* | dpx2*-bull)
526 basic_machine=m68k-bull
527 os=-sysv3
528 ;;
529 ebmon29k)
530 basic_machine=a29k-amd
531 os=-ebmon
532 ;;
533 elxsi)
534 basic_machine=elxsi-elxsi
535 os=-bsd
536 ;;
537 encore | umax | mmax)
538 basic_machine=ns32k-encore
539 ;;
540 es1800 | OSE68k | ose68k | ose | OSE)
541 basic_machine=m68k-ericsson
542 os=-ose
543 ;;
544 fx2800)
545 basic_machine=i860-alliant
546 ;;
547 genix)
548 basic_machine=ns32k-ns
549 ;;
550 gmicro)
551 basic_machine=tron-gmicro
552 os=-sysv
553 ;;
554 go32)
555 basic_machine=i386-pc
556 os=-go32
557 ;;
558 h3050r* | hiux*)
559 basic_machine=hppa1.1-hitachi
560 os=-hiuxwe2
561 ;;
562 h8300hms)
563 basic_machine=h8300-hitachi
564 os=-hms
565 ;;
566 h8300xray)
567 basic_machine=h8300-hitachi
568 os=-xray
569 ;;
570 h8500hms)
571 basic_machine=h8500-hitachi
572 os=-hms
573 ;;
574 harris)
575 basic_machine=m88k-harris
576 os=-sysv3
577 ;;
578 hp300-*)
579 basic_machine=m68k-hp
580 ;;
581 hp300bsd)
582 basic_machine=m68k-hp
583 os=-bsd
584 ;;
585 hp300hpux)
586 basic_machine=m68k-hp
587 os=-hpux
588 ;;
589 hp3k9[0-9][0-9] | hp9[0-9][0-9])
590 basic_machine=hppa1.0-hp
591 ;;
592 hp9k2[0-9][0-9] | hp9k31[0-9])
593 basic_machine=m68000-hp
594 ;;
595 hp9k3[2-9][0-9])
596 basic_machine=m68k-hp
597 ;;
598 hp9k6[0-9][0-9] | hp6[0-9][0-9])
599 basic_machine=hppa1.0-hp
600 ;;
601 hp9k7[0-79][0-9] | hp7[0-79][0-9])
602 basic_machine=hppa1.1-hp
603 ;;
604 hp9k78[0-9] | hp78[0-9])
605 # FIXME: really hppa2.0-hp
606 basic_machine=hppa1.1-hp
607 ;;
608 hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
609 # FIXME: really hppa2.0-hp
610 basic_machine=hppa1.1-hp
611 ;;
612 hp9k8[0-9][13679] | hp8[0-9][13679])
613 basic_machine=hppa1.1-hp
614 ;;
615 hp9k8[0-9][0-9] | hp8[0-9][0-9])
616 basic_machine=hppa1.0-hp
617 ;;
618 hppa-next)
619 os=-nextstep3
620 ;;
621 hppaosf)
622 basic_machine=hppa1.1-hp
623 os=-osf
624 ;;
625 hppro)
626 basic_machine=hppa1.1-hp
627 os=-proelf
628 ;;
629 i370-ibm* | ibm*)
630 basic_machine=i370-ibm
631 ;;
632 # I'm not sure what "Sysv32" means. Should this be sysv3.2?
633 i*86v32)
634 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
635 os=-sysv32
636 ;;
637 i*86v4*)
638 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
639 os=-sysv4
640 ;;
641 i*86v)
642 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
643 os=-sysv
644 ;;
645 i*86sol2)
646 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
647 os=-solaris2
648 ;;
649 i386mach)
650 basic_machine=i386-mach
651 os=-mach
652 ;;
653 i386-vsta | vsta)
654 basic_machine=i386-unknown
655 os=-vsta
656 ;;
657 iris | iris4d)
658 basic_machine=mips-sgi
659 case $os in
660 -irix*)
661 ;;
662 *)
663 os=-irix4
664 ;;
665 esac
666 ;;
667 isi68 | isi)
668 basic_machine=m68k-isi
669 os=-sysv
670 ;;
671 m88k-omron*)
672 basic_machine=m88k-omron
673 ;;
674 magnum | m3230)
675 basic_machine=mips-mips
676 os=-sysv
677 ;;
678 merlin)
679 basic_machine=ns32k-utek
680 os=-sysv
681 ;;
682 mingw32)
683 basic_machine=i386-pc
684 os=-mingw32
685 ;;
686 miniframe)
687 basic_machine=m68000-convergent
688 ;;
689 *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
690 basic_machine=m68k-atari
691 os=-mint
692 ;;
693 mips3*-*)
694 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
695 ;;
696 mips3*)
697 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
698 ;;
699 monitor)
700 basic_machine=m68k-rom68k
701 os=-coff
702 ;;
703 morphos)
704 basic_machine=powerpc-unknown
705 os=-morphos
706 ;;
707 msdos)
708 basic_machine=i386-pc
709 os=-msdos
710 ;;
711 ms1-*)
712 basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
713 ;;
714 mvs)
715 basic_machine=i370-ibm
716 os=-mvs
717 ;;
718 ncr3000)
719 basic_machine=i486-ncr
720 os=-sysv4
721 ;;
722 netbsd386)
723 basic_machine=i386-unknown
724 os=-netbsd
725 ;;
726 netwinder)
727 basic_machine=armv4l-rebel
728 os=-linux
729 ;;
730 news | news700 | news800 | news900)
731 basic_machine=m68k-sony
732 os=-newsos
733 ;;
734 news1000)
735 basic_machine=m68030-sony
736 os=-newsos
737 ;;
738 news-3600 | risc-news)
739 basic_machine=mips-sony
740 os=-newsos
741 ;;
742 necv70)
743 basic_machine=v70-nec
744 os=-sysv
745 ;;
746 next | m*-next )
747 basic_machine=m68k-next
748 case $os in
749 -nextstep* )
750 ;;
751 -ns2*)
752 os=-nextstep2
753 ;;
754 *)
755 os=-nextstep3
756 ;;
757 esac
758 ;;
759 nh3000)
760 basic_machine=m68k-harris
761 os=-cxux
762 ;;
763 nh[45]000)
764 basic_machine=m88k-harris
765 os=-cxux
766 ;;
767 nindy960)
768 basic_machine=i960-intel
769 os=-nindy
770 ;;
771 mon960)
772 basic_machine=i960-intel
773 os=-mon960
774 ;;
775 nonstopux)
776 basic_machine=mips-compaq
777 os=-nonstopux
778 ;;
779 np1)
780 basic_machine=np1-gould
781 ;;
782 nsr-tandem)
783 basic_machine=nsr-tandem
784 ;;
785 op50n-* | op60c-*)
786 basic_machine=hppa1.1-oki
787 os=-proelf
788 ;;
789 openrisc | openrisc-*)
790 basic_machine=or32-unknown
791 ;;
792 os400)
793 basic_machine=powerpc-ibm
794 os=-os400
795 ;;
796 OSE68000 | ose68000)
797 basic_machine=m68000-ericsson
798 os=-ose
799 ;;
800 os68k)
801 basic_machine=m68k-none
802 os=-os68k
803 ;;
804 pa-hitachi)
805 basic_machine=hppa1.1-hitachi
806 os=-hiuxwe2
807 ;;
808 paragon)
809 basic_machine=i860-intel
810 os=-osf
811 ;;
812 pbd)
813 basic_machine=sparc-tti
814 ;;
815 pbb)
816 basic_machine=m68k-tti
817 ;;
818 pc532 | pc532-*)
819 basic_machine=ns32k-pc532
820 ;;
821 pc98)
822 basic_machine=i386-pc
823 ;;
824 pc98-*)
825 basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
826 ;;
827 pentium | p5 | k5 | k6 | nexgen | viac3)
828 basic_machine=i586-pc
829 ;;
830 pentiumpro | p6 | 6x86 | athlon | athlon_*)
831 basic_machine=i686-pc
832 ;;
833 pentiumii | pentium2 | pentiumiii | pentium3)
834 basic_machine=i686-pc
835 ;;
836 pentium4)
837 basic_machine=i786-pc
838 ;;
839 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
840 basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
841 ;;
842 pentiumpro-* | p6-* | 6x86-* | athlon-*)
843 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
844 ;;
845 pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
846 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
847 ;;
848 pentium4-*)
849 basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
850 ;;
851 pn)
852 basic_machine=pn-gould
853 ;;
854 power) basic_machine=power-ibm
855 ;;
856 ppc) basic_machine=powerpc-unknown
857 ;;
858 ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
859 ;;
860 ppcle | powerpclittle | ppc-le | powerpc-little)
861 basic_machine=powerpcle-unknown
862 ;;
863 ppcle-* | powerpclittle-*)
864 basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
865 ;;
866 ppc64) basic_machine=powerpc64-unknown
867 ;;
868 ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
869 ;;
870 ppc64le | powerpc64little | ppc64-le | powerpc64-little)
871 basic_machine=powerpc64le-unknown
872 ;;
873 ppc64le-* | powerpc64little-*)
874 basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
875 ;;
876 ps2)
877 basic_machine=i386-ibm
878 ;;
879 pw32)
880 basic_machine=i586-unknown
881 os=-pw32
882 ;;
883 rdos)
884 basic_machine=i386-pc
885 os=-rdos
886 ;;
887 rom68k)
888 basic_machine=m68k-rom68k
889 os=-coff
890 ;;
891 rm[46]00)
892 basic_machine=mips-siemens
893 ;;
894 rtpc | rtpc-*)
895 basic_machine=romp-ibm
896 ;;
897 s390 | s390-*)
898 basic_machine=s390-ibm
899 ;;
900 s390x | s390x-*)
901 basic_machine=s390x-ibm
902 ;;
903 sa29200)
904 basic_machine=a29k-amd
905 os=-udi
906 ;;
907 sb1)
908 basic_machine=mipsisa64sb1-unknown
909 ;;
910 sb1el)
911 basic_machine=mipsisa64sb1el-unknown
912 ;;
913 sde)
914 basic_machine=mipsisa32-sde
915 os=-elf
916 ;;
917 sei)
918 basic_machine=mips-sei
919 os=-seiux
920 ;;
921 sequent)
922 basic_machine=i386-sequent
923 ;;
924 sh)
925 basic_machine=sh-hitachi
926 os=-hms
927 ;;
928 sh64)
929 basic_machine=sh64-unknown
930 ;;
931 sparclite-wrs | simso-wrs)
932 basic_machine=sparclite-wrs
933 os=-vxworks
934 ;;
935 sps7)
936 basic_machine=m68k-bull
937 os=-sysv2
938 ;;
939 spur)
940 basic_machine=spur-unknown
941 ;;
942 st2000)
943 basic_machine=m68k-tandem
944 ;;
945 stratus)
946 basic_machine=i860-stratus
947 os=-sysv4
948 ;;
949 sun2)
950 basic_machine=m68000-sun
951 ;;
952 sun2os3)
953 basic_machine=m68000-sun
954 os=-sunos3
955 ;;
956 sun2os4)
957 basic_machine=m68000-sun
958 os=-sunos4
959 ;;
960 sun3os3)
961 basic_machine=m68k-sun
962 os=-sunos3
963 ;;
964 sun3os4)
965 basic_machine=m68k-sun
966 os=-sunos4
967 ;;
968 sun4os3)
969 basic_machine=sparc-sun
970 os=-sunos3
971 ;;
972 sun4os4)
973 basic_machine=sparc-sun
974 os=-sunos4
975 ;;
976 sun4sol2)
977 basic_machine=sparc-sun
978 os=-solaris2
979 ;;
980 sun3 | sun3-*)
981 basic_machine=m68k-sun
982 ;;
983 sun4)
984 basic_machine=sparc-sun
985 ;;
986 sun386 | sun386i | roadrunner)
987 basic_machine=i386-sun
988 ;;
989 sv1)
990 basic_machine=sv1-cray
991 os=-unicos
992 ;;
993 symmetry)
994 basic_machine=i386-sequent
995 os=-dynix
996 ;;
997 t3e)
998 basic_machine=alphaev5-cray
999 os=-unicos
1000 ;;
1001 t90)
1002 basic_machine=t90-cray
1003 os=-unicos
1004 ;;
1005 tic54x | c54x*)
1006 basic_machine=tic54x-unknown
1007 os=-coff
1008 ;;
1009 tic55x | c55x*)
1010 basic_machine=tic55x-unknown
1011 os=-coff
1012 ;;
1013 tic6x | c6x*)
1014 basic_machine=tic6x-unknown
1015 os=-coff
1016 ;;
1017 tx39)
1018 basic_machine=mipstx39-unknown
1019 ;;
1020 tx39el)
1021 basic_machine=mipstx39el-unknown
1022 ;;
1023 toad1)
1024 basic_machine=pdp10-xkl
1025 os=-tops20
1026 ;;
1027 tower | tower-32)
1028 basic_machine=m68k-ncr
1029 ;;
1030 tpf)
1031 basic_machine=s390x-ibm
1032 os=-tpf
1033 ;;
1034 udi29k)
1035 basic_machine=a29k-amd
1036 os=-udi
1037 ;;
1038 ultra3)
1039 basic_machine=a29k-nyu
1040 os=-sym1
1041 ;;
1042 v810 | necv810)
1043 basic_machine=v810-nec
1044 os=-none
1045 ;;
1046 vaxv)
1047 basic_machine=vax-dec
1048 os=-sysv
1049 ;;
1050 vms)
1051 basic_machine=vax-dec
1052 os=-vms
1053 ;;
1054 vpp*|vx|vx-*)
1055 basic_machine=f301-fujitsu
1056 ;;
1057 vxworks960)
1058 basic_machine=i960-wrs
1059 os=-vxworks
1060 ;;
1061 vxworks68)
1062 basic_machine=m68k-wrs
1063 os=-vxworks
1064 ;;
1065 vxworks29k)
1066 basic_machine=a29k-wrs
1067 os=-vxworks
1068 ;;
1069 w65*)
1070 basic_machine=w65-wdc
1071 os=-none
1072 ;;
1073 w89k-*)
1074 basic_machine=hppa1.1-winbond
1075 os=-proelf
1076 ;;
1077 xbox)
1078 basic_machine=i686-pc
1079 os=-mingw32
1080 ;;
1081 xps | xps100)
1082 basic_machine=xps100-honeywell
1083 ;;
1084 ymp)
1085 basic_machine=ymp-cray
1086 os=-unicos
1087 ;;
1088 z8k-*-coff)
1089 basic_machine=z8k-unknown
1090 os=-sim
1091 ;;
1092 none)
1093 basic_machine=none-none
1094 os=-none
1095 ;;
1096
1097 # Here we handle the default manufacturer of certain CPU types. It is in
1098 # some cases the only manufacturer, in others, it is the most popular.
1099 w89k)
1100 basic_machine=hppa1.1-winbond
1101 ;;
1102 op50n)
1103 basic_machine=hppa1.1-oki
1104 ;;
1105 op60c)
1106 basic_machine=hppa1.1-oki
1107 ;;
1108 romp)
1109 basic_machine=romp-ibm
1110 ;;
1111 mmix)
1112 basic_machine=mmix-knuth
1113 ;;
1114 rs6000)
1115 basic_machine=rs6000-ibm
1116 ;;
1117 vax)
1118 basic_machine=vax-dec
1119 ;;
1120 pdp10)
1121 # there are many clones, so DEC is not a safe bet
1122 basic_machine=pdp10-unknown
1123 ;;
1124 pdp11)
1125 basic_machine=pdp11-dec
1126 ;;
1127 we32k)
1128 basic_machine=we32k-att
1129 ;;
1130 sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
1131 basic_machine=sh-unknown
1132 ;;
1133 sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
1134 basic_machine=sparc-sun
1135 ;;
1136 cydra)
1137 basic_machine=cydra-cydrome
1138 ;;
1139 orion)
1140 basic_machine=orion-highlevel
1141 ;;
1142 orion105)
1143 basic_machine=clipper-highlevel
1144 ;;
1145 mac | mpw | mac-mpw)
1146 basic_machine=m68k-apple
1147 ;;
1148 pmac | pmac-mpw)
1149 basic_machine=powerpc-apple
1150 ;;
1151 *-unknown)
1152 # Make sure to match an already-canonicalized machine name.
1153 ;;
1154 *)
1155 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
1156 exit 1
1157 ;;
1158 esac
1159
1160 # Here we canonicalize certain aliases for manufacturers.
1161 case $basic_machine in
1162 *-digital*)
1163 basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
1164 ;;
1165 *-commodore*)
1166 basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
1167 ;;
1168 *)
1169 ;;
1170 esac
1171
1172 # Decode manufacturer-specific aliases for certain operating systems.
1173
1174 if [ x"$os" != x"" ]
1175 then
1176 case $os in
1177 # First match some system type aliases
1178 # that might get confused with valid system types.
1179 # -solaris* is a basic system type, with this one exception.
1180 -solaris1 | -solaris1.*)
1181 os=`echo $os | sed -e 's|solaris1|sunos4|'`
1182 ;;
1183 -solaris)
1184 os=-solaris2
1185 ;;
1186 -svr4*)
1187 os=-sysv4
1188 ;;
1189 -unixware*)
1190 os=-sysv4.2uw
1191 ;;
1192 -gnu/linux*)
1193 os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
1194 ;;
1195 # First accept the basic system types.
1196 # The portable systems comes first.
1197 # Each alternative MUST END IN A *, to match a version number.
1198 # -sysv* is not here because it comes later, after sysvr4.
1199 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
1200 | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
1201 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
1202 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
1203 | -aos* \
1204 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
1205 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
1206 | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
1207 | -openbsd* | -solidbsd* \
1208 | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
1209 | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
1210 | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
1211 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
1212 | -chorusos* | -chorusrdb* \
1213 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
1214 | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
1215 | -uxpv* | -beos* | -mpeix* | -udk* \
1216 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
1217 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
1218 | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
1219 | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
1220 | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
1221 | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
1222 | -skyos* | -haiku* | -rdos* | -toppers*)
1223 # Remember, each alternative MUST END IN *, to match a version number.
1224 ;;
1225 -qnx*)
1226 case $basic_machine in
1227 x86-* | i*86-*)
1228 ;;
1229 *)
1230 os=-nto$os
1231 ;;
1232 esac
1233 ;;
1234 -nto-qnx*)
1235 ;;
1236 -nto*)
1237 os=`echo $os | sed -e 's|nto|nto-qnx|'`
1238 ;;
1239 -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
1240 | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
1241 | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
1242 ;;
1243 -mac*)
1244 os=`echo $os | sed -e 's|mac|macos|'`
1245 ;;
1246 -linux-dietlibc)
1247 os=-linux-dietlibc
1248 ;;
1249 -linux*)
1250 os=`echo $os | sed -e 's|linux|linux-gnu|'`
1251 ;;
1252 -sunos5*)
1253 os=`echo $os | sed -e 's|sunos5|solaris2|'`
1254 ;;
1255 -sunos6*)
1256 os=`echo $os | sed -e 's|sunos6|solaris3|'`
1257 ;;
1258 -opened*)
1259 os=-openedition
1260 ;;
1261 -os400*)
1262 os=-os400
1263 ;;
1264 -wince*)
1265 os=-wince
1266 ;;
1267 -osfrose*)
1268 os=-osfrose
1269 ;;
1270 -osf*)
1271 os=-osf
1272 ;;
1273 -utek*)
1274 os=-bsd
1275 ;;
1276 -dynix*)
1277 os=-bsd
1278 ;;
1279 -acis*)
1280 os=-aos
1281 ;;
1282 -atheos*)
1283 os=-atheos
1284 ;;
1285 -syllable*)
1286 os=-syllable
1287 ;;
1288 -386bsd)
1289 os=-bsd
1290 ;;
1291 -ctix* | -uts*)
1292 os=-sysv
1293 ;;
1294 -nova*)
1295 os=-rtmk-nova
1296 ;;
1297 -ns2 )
1298 os=-nextstep2
1299 ;;
1300 -nsk*)
1301 os=-nsk
1302 ;;
1303 # Preserve the version number of sinix5.
1304 -sinix5.*)
1305 os=`echo $os | sed -e 's|sinix|sysv|'`
1306 ;;
1307 -sinix*)
1308 os=-sysv4
1309 ;;
1310 -tpf*)
1311 os=-tpf
1312 ;;
1313 -triton*)
1314 os=-sysv3
1315 ;;
1316 -oss*)
1317 os=-sysv3
1318 ;;
1319 -svr4)
1320 os=-sysv4
1321 ;;
1322 -svr3)
1323 os=-sysv3
1324 ;;
1325 -sysvr4)
1326 os=-sysv4
1327 ;;
1328 # This must come after -sysvr4.
1329 -sysv*)
1330 ;;
1331 -ose*)
1332 os=-ose
1333 ;;
1334 -es1800*)
1335 os=-ose
1336 ;;
1337 -xenix)
1338 os=-xenix
1339 ;;
1340 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1341 os=-mint
1342 ;;
1343 -aros*)
1344 os=-aros
1345 ;;
1346 -kaos*)
1347 os=-kaos
1348 ;;
1349 -zvmoe)
1350 os=-zvmoe
1351 ;;
1352 -none)
1353 ;;
1354 *)
1355 # Get rid of the `-' at the beginning of $os.
1356 os=`echo $os | sed 's/[^-]*-//'`
1357 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
1358 exit 1
1359 ;;
1360 esac
1361 else
1362
1363 # Here we handle the default operating systems that come with various machines.
1364 # The value should be what the vendor currently ships out the door with their
1365 # machine or put another way, the most popular os provided with the machine.
1366
1367 # Note that if you're going to try to match "-MANUFACTURER" here (say,
1368 # "-sun"), then you have to tell the case statement up towards the top
1369 # that MANUFACTURER isn't an operating system. Otherwise, code above
1370 # will signal an error saying that MANUFACTURER isn't an operating
1371 # system, and we'll never get to this point.
1372
1373 case $basic_machine in
1374 score-*)
1375 os=-elf
1376 ;;
1377 spu-*)
1378 os=-elf
1379 ;;
1380 *-acorn)
1381 os=-riscix1.2
1382 ;;
1383 arm*-rebel)
1384 os=-linux
1385 ;;
1386 arm*-semi)
1387 os=-aout
1388 ;;
1389 c4x-* | tic4x-*)
1390 os=-coff
1391 ;;
1392 # This must come before the *-dec entry.
1393 pdp10-*)
1394 os=-tops20
1395 ;;
1396 pdp11-*)
1397 os=-none
1398 ;;
1399 *-dec | vax-*)
1400 os=-ultrix4.2
1401 ;;
1402 m68*-apollo)
1403 os=-domain
1404 ;;
1405 i386-sun)
1406 os=-sunos4.0.2
1407 ;;
1408 m68000-sun)
1409 os=-sunos3
1410 # This also exists in the configure program, but was not the
1411 # default.
1412 # os=-sunos4
1413 ;;
1414 m68*-cisco)
1415 os=-aout
1416 ;;
1417 mips*-cisco)
1418 os=-elf
1419 ;;
1420 mips*-*)
1421 os=-elf
1422 ;;
1423 or32-*)
1424 os=-coff
1425 ;;
1426 *-tti) # must be before sparc entry or we get the wrong os.
1427 os=-sysv3
1428 ;;
1429 sparc-* | *-sun)
1430 os=-sunos4.1.1
1431 ;;
1432 *-be)
1433 os=-beos
1434 ;;
1435 *-haiku)
1436 os=-haiku
1437 ;;
1438 *-ibm)
1439 os=-aix
1440 ;;
1441 *-knuth)
1442 os=-mmixware
1443 ;;
1444 *-wec)
1445 os=-proelf
1446 ;;
1447 *-winbond)
1448 os=-proelf
1449 ;;
1450 *-oki)
1451 os=-proelf
1452 ;;
1453 *-hp)
1454 os=-hpux
1455 ;;
1456 *-hitachi)
1457 os=-hiux
1458 ;;
1459 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1460 os=-sysv
1461 ;;
1462 *-cbm)
1463 os=-amigaos
1464 ;;
1465 *-dg)
1466 os=-dgux
1467 ;;
1468 *-dolphin)
1469 os=-sysv3
1470 ;;
1471 m68k-ccur)
1472 os=-rtu
1473 ;;
1474 m88k-omron*)
1475 os=-luna
1476 ;;
1477 *-next )
1478 os=-nextstep
1479 ;;
1480 *-sequent)
1481 os=-ptx
1482 ;;
1483 *-crds)
1484 os=-unos
1485 ;;
1486 *-ns)
1487 os=-genix
1488 ;;
1489 i370-*)
1490 os=-mvs
1491 ;;
1492 *-next)
1493 os=-nextstep3
1494 ;;
1495 *-gould)
1496 os=-sysv
1497 ;;
1498 *-highlevel)
1499 os=-bsd
1500 ;;
1501 *-encore)
1502 os=-bsd
1503 ;;
1504 *-sgi)
1505 os=-irix
1506 ;;
1507 *-siemens)
1508 os=-sysv4
1509 ;;
1510 *-masscomp)
1511 os=-rtu
1512 ;;
1513 f30[01]-fujitsu | f700-fujitsu)
1514 os=-uxpv
1515 ;;
1516 *-rom68k)
1517 os=-coff
1518 ;;
1519 *-*bug)
1520 os=-coff
1521 ;;
1522 *-apple)
1523 os=-macos
1524 ;;
1525 *-atari*)
1526 os=-mint
1527 ;;
1528 *)
1529 os=-none
1530 ;;
1531 esac
1532 fi
1533
1534 # Here we handle the case where we know the os, and the CPU type, but not the
1535 # manufacturer. We pick the logical manufacturer.
1536 vendor=unknown
1537 case $basic_machine in
1538 *-unknown)
1539 case $os in
1540 -riscix*)
1541 vendor=acorn
1542 ;;
1543 -sunos*)
1544 vendor=sun
1545 ;;
1546 -aix*)
1547 vendor=ibm
1548 ;;
1549 -beos*)
1550 vendor=be
1551 ;;
1552 -hpux*)
1553 vendor=hp
1554 ;;
1555 -mpeix*)
1556 vendor=hp
1557 ;;
1558 -hiux*)
1559 vendor=hitachi
1560 ;;
1561 -unos*)
1562 vendor=crds
1563 ;;
1564 -dgux*)
1565 vendor=dg
1566 ;;
1567 -luna*)
1568 vendor=omron
1569 ;;
1570 -genix*)
1571 vendor=ns
1572 ;;
1573 -mvs* | -opened*)
1574 vendor=ibm
1575 ;;
1576 -os400*)
1577 vendor=ibm
1578 ;;
1579 -ptx*)
1580 vendor=sequent
1581 ;;
1582 -tpf*)
1583 vendor=ibm
1584 ;;
1585 -vxsim* | -vxworks* | -windiss*)
1586 vendor=wrs
1587 ;;
1588 -aux*)
1589 vendor=apple
1590 ;;
1591 -hms*)
1592 vendor=hitachi
1593 ;;
1594 -mpw* | -macos*)
1595 vendor=apple
1596 ;;
1597 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1598 vendor=atari
1599 ;;
1600 -vos*)
1601 vendor=stratus
1602 ;;
1603 esac
1604 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
1605 ;;
1606 esac
1607
1608 echo $basic_machine$os
1609 exit
1610
1611 # Local variables:
1612 # eval: (add-hook 'write-file-hooks 'time-stamp)
1613 # time-stamp-start: "timestamp='"
1614 # time-stamp-format: "%:y-%02m-%02d"
1615 # time-stamp-end: "'"
1616 # End:
The diff for file configure is too big (6738 changes) and cannot be shown.
File configure.ac added (mode: 100644) (index 00000000..cf87496d)
1 dnl $Id: configure.ac,v 1.35 2008/07/21 12:19:21 wmcbrine Exp $
2 dnl Process this file with autoconf to produce a configure script.
3
4 AC_INIT([PDCurses], [3.4], [wmcbrine@users.sf.net], [PDCurses])
5 AC_CONFIG_SRCDIR([curspriv.h])
6
7 AC_SUBST(prefix)
8
9 AC_PROG_CC
10
11 AC_CONFIG_HEADER(config.h)
12 dnl Checks for system first
13 AC_CANONICAL_SYSTEM([])
14
15 mymakefile="Makefile"
16 on_qnx=no
17 case "$target" in
18 *hp-hpux*)
19 SYS_DEFS="-D_HPUX_SOURCE"
20 ;;
21 *ibm-aix*)
22 SYS_DEFS="-D_ALL_SOURCE"
23 mymakefile="Makefile.aix"
24 ;;
25 *dec-osf*)
26 SYS_DEFS="-D_XOPEN_SOURCE_EXTENDED"
27 ;;
28 *pc-sco*)
29 SYS_DEFS="-UM_XENIX -b elf"
30 ;;
31 *qnx*)
32 on_qnx=yes
33 SYS_DEFS="-Q"
34 ;;
35 *)
36 ;;
37 esac
38 AC_SUBST(SYS_DEFS)
39
40 MH_CHECK_MAX_SIGNALS(NSIG __sys_nsig)
41
42 dnl Check for other programs.
43 AC_PROG_RANLIB
44 AC_PROG_INSTALL
45 AC_PROG_MAKE_SET
46
47 dnl ensure that the system has System V IPC support
48 MH_IPC
49
50 if test $ac_cv_header_stdc != yes; then
51 AC_MSG_ERROR([Need ANSI C headers])
52 fi
53
54 dnl Checks for libraries.
55
56 AC_CHECK_HEADERS(fcntl.h \
57 sys/time.h \
58 sys/select.h \
59 dlfcn.h \
60 dl.h
61 )
62
63 dnl Checks for typedefs, structures, and compiler characteristics.
64 AC_HEADER_TIME
65 MH_CHECK_LIB(socket nls)
66 AC_SUBST(MH_EXTRA_LIBS)
67 MH_CHECK_CC_O
68
69 dnl Checks for library functions.
70 AC_TYPE_SIGNAL
71 AC_CHECK_FUNCS(vsscanf usleep poll vsnprintf)
72
73 dnl Check for X includes and X libraries
74 AC_PATH_X
75 MH_CHECK_X_INC
76 MH_CHECK_X_LIB
77 MH_CHECK_X_HEADERS(DECkeysym.h Sunkeysym.h xpm.h)
78 MH_CHECK_X_KEYDEFS(XK_KP_Delete XK_KP_Insert XK_KP_End XK_KP_Down XK_KP_Next \
79 XK_KP_Left XK_KP_Right XK_KP_Home XK_KP_Up XK_KP_Prior XK_KP_Begin)
80 MH_CHECK_X_TYPEDEF(XPointer)
81 dnl
82 dnl extra for xpm library
83 if test $ac_cv_header_xpm_h = yes; then
84 MH_XLIBS="$MH_XLIBS -lXpm"
85 fi
86 dnl ---------- allow --enable-debug to compile in debug mode ---------
87 AC_ARG_ENABLE(debug,
88 [ --enable-debug turn on debugging],
89 [with_debug=$enableval],
90 [with_debug=no],
91 )
92 cflags_g="`echo $CFLAGS | grep -c '\-g'`"
93 cflags_O="`echo $CFLAGS | grep -c '\-O'`"
94
95 if test "$with_debug" = yes; then
96 if test "$cflags_g" = "0"; then
97 CFLAGS="${CFLAGS} -g"
98 fi
99 if test "$cflags_O" != "0"; then
100 CFLAGS="`echo ${CFLAGS} | sed -e s/-O.//`"
101 fi
102 CFLAGS="${CFLAGS} -DPDCDEBUG"
103 else
104 if test "$cflags_O" = "0"; then
105 CFLAGS="${CFLAGS} -O"
106 fi
107 if test "$cflags_g" != "0"; then
108 CFLAGS="`echo ${CFLAGS} | sed -e s/-g//`"
109 fi
110 fi
111 if test "$ac_cv_prog_CC" = "gcc"; then
112 if test "$with_debug" = yes; then
113 CFLAGS="${CFLAGS} -Wall"
114 else
115 CFLAGS="-O2 -Wall -fomit-frame-pointer"
116 fi
117 fi
118 if test "$on_qnx" = yes; then
119 if test "$with_debug" = yes; then
120 CFLAGS="-g"
121 else
122 CFLAGS="-Otax"
123 fi
124 fi
125
126 dnl --------------- check for wide character support -----------------
127 dnl allow --enable-widec to include wide character support
128 AC_ARG_ENABLE(widec,
129 [ --enable-widec include support for wide characters],
130 [with_widec=$enableval],
131 [with_widec=no],
132 )
133 if test "$with_widec" = yes; then
134 SYS_DEFS="$SYS_DEFS -DPDC_WIDE"
135 fi
136
137 dnl -------------------- check for XIM support -----------------------
138 dnl allow --enable-xim to include XIM support
139 AC_ARG_ENABLE(xim,
140 [ --enable-xim include support for XIM],
141 [with_xim=$enableval],
142 [with_xim=no],
143 )
144 if test "$with_xim" = yes; then
145 SYS_DEFS="$SYS_DEFS -DPDC_XIM"
146 fi
147
148 dnl ------------------------ force UTF-8? ----------------------------
149 dnl allow --enable-force-utf8 to override locale settings
150 AC_ARG_ENABLE(force-utf8,
151 [ --enable-force-utf8 override locale settings; use UTF-8],
152 [force_utf8=$enableval],
153 [force_utf8=no],
154 )
155 if test "$force_utf8" = yes; then
156 SYS_DEFS="$SYS_DEFS -DPDC_FORCE_UTF8"
157 fi
158
159 dnl ----------------- check for Purify support -----------------------
160 dnl allow --enable-purify to enable linking with Purify
161 AC_ARG_ENABLE(purify,
162 [ --enable-purify link with Purify (TM)],
163 [with_purify=$enableval],
164 [with_purify=no],
165 )
166 if test "$with_purify" = yes; then
167 PURIFY="purify"
168 else
169 PURIFY=""
170 fi
171 AC_SUBST(PURIFY)
172
173 dnl --------------------- check for Xaw3d library --------------------
174 dnl allow --with-xaw3d to link with PDCurses
175 AC_ARG_WITH(xaw3d,
176 [ --with-xaw3d link with Xaw3d],
177 [with_xaw3d=$withval],
178 [with_xaw3d=no],
179 )
180 if test "$with_xaw3d" = yes; then
181 AC_DEFINE([USE_XAW3D], [1],
182 [Define if you want to use Xaw3d library]
183 )
184 fi
185
186 dnl --------------------- check for neXtaw library -------------------
187 dnl allow --with-nextaw to link with PDCurses
188 AC_ARG_WITH(nextaw,
189 [ --with-nextaw link with neXtaw],
190 [with_nextaw=$withval],
191 [with_nextaw=no],
192 )
193 if test "$with_nextaw" = yes; then
194 AC_DEFINE([USE_NEXTAW], [1],
195 [Define if you want to use neXtaw library]
196 )
197 fi
198
199 dnl -------------- check how to make shared libraries ----------------
200 dnl Force the ability of shared library usage
201 MH_SHARED_LIBRARY(XCurses)
202
203 AC_CONFIG_FILES([Makefile x11/$mymakefile x11/xcurses-config])
204 AC_OUTPUT
205
206 case "$target" in
207 *ibm-aix*)
208 mv x11/Makefile.aix x11/Makefile
209 AC_MSG_RESULT(renaming x11/Makefile.aix to x11/Makefile)
210 ;;
211 *)
212 ;;
213 esac
214
215 AC_DEFINE([PDC_MAX_SIGNALS], [],
216 [Define as the system defined limit for number of signals]
217 )
218
219 AC_DEFINE([HAVE_DECKEYSYM_H], [],
220 [Define if you have the <DECkeySym.h> header file]
221 )
222
223 AC_DEFINE([HAVE_SUNKEYSYM_H], [],
224 [Define if you have the <Sunkeysym.h> header file]
225 )
226
227 AC_DEFINE([HAVE_XPM_H], [],
228 [Define if you have the <xpm.h> header file]
229 )
230
231 AC_DEFINE([HAVE_XK_KP_DELETE], [],
232 [Define if you have this defined in <keysym.h>]
233 )
234
235 AC_DEFINE([HAVE_XK_KP_INSERT], [],
236 [Define if you have this defined in <keysym.h>]
237 )
238
239 AC_DEFINE([HAVE_XK_KP_END], [],
240 [Define if you have this defined in <keysym.h>]
241 )
242
243 AC_DEFINE([HAVE_XK_KP_DOWN], [],
244 [Define if you have this defined in <keysym.h>]
245 )
246
247 AC_DEFINE([HAVE_XK_KP_NEXT], [],
248 [Define if you have this defined in <keysym.h>]
249 )
250
251 AC_DEFINE([HAVE_XK_KP_LEFT], [],
252 [Define if you have this defined in <keysym.h>]
253 )
254
255 AC_DEFINE([HAVE_XK_KP_RIGHT], [],
256 [Define if you have this defined in <keysym.h>]
257 )
258
259 AC_DEFINE([HAVE_XK_KP_HOME], [],
260 [Define if you have this defined in <keysym.h>]
261 )
262
263 AC_DEFINE([HAVE_XK_KP_UP], [],
264 [Define if you have this defined in <keysym.h>]
265 )
266
267 AC_DEFINE([HAVE_XK_KP_PRIOR], [],
268 [Define if you have this defined in <keysym.h>]
269 )
270
271 AC_DEFINE([HAVE_XK_KP_BEGIN], [],
272 [Define if you have this defined in <keysym.h>]
273 )
274
275 AC_DEFINE([USE_XAW3D], [],
276 [Define if you want to use Xaw3d library]
277 )
278
279 AC_DEFINE([USE_NEXTAW], [],
280 [Define if you want to use neXtaw library]
281 )
282
283 AC_DEFINE([XPOINTER_TYPEDEFED], [],
284 [Define XPointer is typedefed in X11/Xlib.h]
285 )
File curses.h added (mode: 100644) (index 00000000..6f3ce19d)
1 /* Public Domain Curses */
2
3 /* $Id: curses.h,v 1.295 2008/07/15 17:13:25 wmcbrine Exp $ */
4
5 /*----------------------------------------------------------------------*
6 * PDCurses *
7 *----------------------------------------------------------------------*/
8
9 #ifndef __PDCURSES__
10 #define __PDCURSES__ 1
11
12 /*man-start**************************************************************
13
14 PDCurses definitions list: (Only define those needed)
15
16 XCURSES True if compiling for X11.
17 PDC_RGB True if you want to use RGB color definitions
18 (Red = 1, Green = 2, Blue = 4) instead of BGR.
19 PDC_WIDE True if building wide-character support.
20 PDC_DLL_BUILD True if building a Win32 DLL.
21 NCURSES_MOUSE_VERSION Use the ncurses mouse API instead
22 of PDCurses' traditional mouse API.
23
24 PDCurses portable platform definitions list:
25
26 PDC_BUILD Defines API build version.
27 PDCURSES Enables access to PDCurses-only routines.
28 XOPEN Always true.
29 SYSVcurses True if you are compiling for SYSV portability.
30 BSDcurses True if you are compiling for BSD portability.
31
32 **man-end****************************************************************/
33
34 #define PDC_BUILD 3401
35 #define PDCURSES 1 /* PDCurses-only routines */
36 #define XOPEN 1 /* X/Open Curses routines */
37 #define SYSVcurses 1 /* System V Curses routines */
38 #define BSDcurses 1 /* BSD Curses routines */
39 #define CHTYPE_LONG 1 /* size of chtype; long */
40
41 /*----------------------------------------------------------------------*/
42
43 #include <stdarg.h>
44 #include <stddef.h>
45 #include <stdio.h> /* Required by X/Open usage below */
46
47 #ifdef PDC_WIDE
48 # include <wchar.h>
49 #endif
50
51 #if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
52 extern "C"
53 {
54 # define bool _bool
55 #endif
56
57 /*----------------------------------------------------------------------
58 *
59 * PDCurses Manifest Constants
60 *
61 */
62
63 #ifndef FALSE
64 # define FALSE 0
65 #endif
66 #ifndef TRUE
67 # define TRUE 1
68 #endif
69 #ifndef NULL
70 # define NULL (void *)0
71 #endif
72 #ifndef ERR
73 # define ERR (-1)
74 #endif
75 #ifndef OK
76 # define OK 0
77 #endif
78
79 /*----------------------------------------------------------------------
80 *
81 * PDCurses Type Declarations
82 *
83 */
84
85 typedef unsigned char bool; /* PDCurses Boolean type */
86
87 #ifdef CHTYPE_LONG
88 # if _LP64
89 typedef unsigned int chtype;
90 # else
91 typedef unsigned long chtype; /* 16-bit attr + 16-bit char */
92 # endif
93 #else
94 typedef unsigned short chtype; /* 8-bit attr + 8-bit char */
95 #endif
96
97 #ifdef PDC_WIDE
98 typedef chtype cchar_t;
99 #endif
100
101 typedef chtype attr_t;
102
103 /*----------------------------------------------------------------------
104 *
105 * PDCurses Mouse Interface -- SYSVR4, with extensions
106 *
107 */
108
109 typedef struct
110 {
111 int x; /* absolute column, 0 based, measured in characters */
112 int y; /* absolute row, 0 based, measured in characters */
113 short button[3]; /* state of each button */
114 int changes; /* flags indicating what has changed with the mouse */
115 } MOUSE_STATUS;
116
117 #define BUTTON_RELEASED 0x0000
118 #define BUTTON_PRESSED 0x0001
119 #define BUTTON_CLICKED 0x0002
120 #define BUTTON_DOUBLE_CLICKED 0x0003
121 #define BUTTON_TRIPLE_CLICKED 0x0004
122 #define BUTTON_MOVED 0x0005 /* PDCurses */
123 #define WHEEL_SCROLLED 0x0006 /* PDCurses */
124 #define BUTTON_ACTION_MASK 0x0007 /* PDCurses */
125
126 #define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */
127 #define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */
128 #define PDC_BUTTON_ALT 0x0020 /* PDCurses */
129 #define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */
130
131 #define MOUSE_X_POS (Mouse_status.x)
132 #define MOUSE_Y_POS (Mouse_status.y)
133
134 /*
135 * Bits associated with the .changes field:
136 * 3 2 1 0
137 * 210987654321098765432109876543210
138 * 1 <- button 1 has changed
139 * 10 <- button 2 has changed
140 * 100 <- button 3 has changed
141 * 1000 <- mouse has moved
142 * 10000 <- mouse position report
143 * 100000 <- mouse wheel up
144 * 1000000 <- mouse wheel down
145 */
146
147 #define PDC_MOUSE_MOVED 0x0008
148 #define PDC_MOUSE_POSITION 0x0010
149 #define PDC_MOUSE_WHEEL_UP 0x0020
150 #define PDC_MOUSE_WHEEL_DOWN 0x0040
151
152 #define A_BUTTON_CHANGED (Mouse_status.changes & 7)
153 #define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED)
154 #define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION)
155 #define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - 1)))
156 #define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1])
157 #define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP)
158 #define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN)
159
160 /* mouse bit-masks */
161
162 #define BUTTON1_RELEASED 0x00000001L
163 #define BUTTON1_PRESSED 0x00000002L
164 #define BUTTON1_CLICKED 0x00000004L
165 #define BUTTON1_DOUBLE_CLICKED 0x00000008L
166 #define BUTTON1_TRIPLE_CLICKED 0x00000010L
167 #define BUTTON1_MOVED 0x00000010L /* PDCurses */
168
169 #define BUTTON2_RELEASED 0x00000020L
170 #define BUTTON2_PRESSED 0x00000040L
171 #define BUTTON2_CLICKED 0x00000080L
172 #define BUTTON2_DOUBLE_CLICKED 0x00000100L
173 #define BUTTON2_TRIPLE_CLICKED 0x00000200L
174 #define BUTTON2_MOVED 0x00000200L /* PDCurses */
175
176 #define BUTTON3_RELEASED 0x00000400L
177 #define BUTTON3_PRESSED 0x00000800L
178 #define BUTTON3_CLICKED 0x00001000L
179 #define BUTTON3_DOUBLE_CLICKED 0x00002000L
180 #define BUTTON3_TRIPLE_CLICKED 0x00004000L
181 #define BUTTON3_MOVED 0x00004000L /* PDCurses */
182
183 /* For the ncurses-compatible functions only, BUTTON4_PRESSED and
184 BUTTON5_PRESSED are returned for mouse scroll wheel up and down;
185 otherwise PDCurses doesn't support buttons 4 and 5 */
186
187 #define BUTTON4_RELEASED 0x00008000L
188 #define BUTTON4_PRESSED 0x00010000L
189 #define BUTTON4_CLICKED 0x00020000L
190 #define BUTTON4_DOUBLE_CLICKED 0x00040000L
191 #define BUTTON4_TRIPLE_CLICKED 0x00080000L
192
193 #define BUTTON5_RELEASED 0x00100000L
194 #define BUTTON5_PRESSED 0x00200000L
195 #define BUTTON5_CLICKED 0x00400000L
196 #define BUTTON5_DOUBLE_CLICKED 0x00800000L
197 #define BUTTON5_TRIPLE_CLICKED 0x01000000L
198
199 #define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */
200 #define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */
201 #define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */
202 #define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */
203
204 #define ALL_MOUSE_EVENTS 0x1fffffffL
205 #define REPORT_MOUSE_POSITION 0x20000000L
206
207 /* ncurses mouse interface */
208
209 typedef unsigned long mmask_t;
210
211 typedef struct
212 {
213 short id; /* unused, always 0 */
214 int x, y, z; /* x, y same as MOUSE_STATUS; z unused */
215 mmask_t bstate; /* equivalent to changes + button[], but
216 in the same format as used for mousemask() */
217 } MEVENT;
218
219 #ifdef NCURSES_MOUSE_VERSION
220 # define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT
221 # define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL
222 # define BUTTON_CTRL BUTTON_MODIFIER_CONTROL
223 # define BUTTON_ALT BUTTON_MODIFIER_ALT
224 #else
225 # define BUTTON_SHIFT PDC_BUTTON_SHIFT
226 # define BUTTON_CONTROL PDC_BUTTON_CONTROL
227 # define BUTTON_ALT PDC_BUTTON_ALT
228 #endif
229
230 /*----------------------------------------------------------------------
231 *
232 * PDCurses Structure Definitions
233 *
234 */
235
236 typedef struct _win /* definition of a window */
237 {
238 int _cury; /* current pseudo-cursor */
239 int _curx;
240 int _maxy; /* max window coordinates */
241 int _maxx;
242 int _begy; /* origin on screen */
243 int _begx;
244 int _flags; /* window properties */
245 chtype _attrs; /* standard attributes and colors */
246 chtype _bkgd; /* background, normally blank */
247 bool _clear; /* causes clear at next refresh */
248 bool _leaveit; /* leaves cursor where it is */
249 bool _scroll; /* allows window scrolling */
250 bool _nodelay; /* input character wait flag */
251 bool _immed; /* immediate update flag */
252 bool _sync; /* synchronise window ancestors */
253 bool _use_keypad; /* flags keypad key mode active */
254 chtype **_y; /* pointer to line pointer array */
255 int *_firstch; /* first changed character in line */
256 int *_lastch; /* last changed character in line */
257 int _tmarg; /* top of scrolling region */
258 int _bmarg; /* bottom of scrolling region */
259 int _delayms; /* milliseconds of delay for getch() */
260 int _parx, _pary; /* coords relative to parent (0,0) */
261 struct _win *_parent; /* subwin's pointer to parent win */
262 } WINDOW;
263
264 /* Avoid using the SCREEN struct directly -- use the corresponding
265 functions if possible. This struct may eventually be made private. */
266
267 typedef struct
268 {
269 bool alive; /* if initscr() called, and not endwin() */
270 bool autocr; /* if cr -> lf */
271 bool cbreak; /* if terminal unbuffered */
272 bool echo; /* if terminal echo */
273 bool raw_inp; /* raw input mode (v. cooked input) */
274 bool raw_out; /* raw output mode (7 v. 8 bits) */
275 bool audible; /* FALSE if the bell is visual */
276 bool mono; /* TRUE if current screen is mono */
277 bool resized; /* TRUE if TERM has been resized */
278 bool orig_attr; /* TRUE if we have the original colors */
279 short orig_fore; /* original screen foreground color */
280 short orig_back; /* original screen foreground color */
281 int cursrow; /* position of physical cursor */
282 int curscol; /* position of physical cursor */
283 int visibility; /* visibility of cursor */
284 int orig_cursor; /* original cursor size */
285 int lines; /* new value for LINES */
286 int cols; /* new value for COLS */
287 unsigned long _trap_mbe; /* trap these mouse button events */
288 unsigned long _map_mbe_to_key; /* map mouse buttons to slk */
289 int mouse_wait; /* time to wait (in ms) for a
290 button release after a press, in
291 order to count it as a click */
292 int slklines; /* lines in use by slk_init() */
293 WINDOW *slk_winptr; /* window for slk */
294 int linesrippedoff; /* lines ripped off via ripoffline() */
295 int linesrippedoffontop; /* lines ripped off on
296 top via ripoffline() */
297 int delaytenths; /* 1/10ths second to wait block
298 getch() for */
299 bool _preserve; /* TRUE if screen background
300 to be preserved */
301 int _restore; /* specifies if screen background
302 to be restored, and how */
303 bool save_key_modifiers; /* TRUE if each key modifiers saved
304 with each key press */
305 bool return_key_modifiers; /* TRUE if modifier keys are
306 returned as "real" keys */
307 bool key_code; /* TRUE if last key is a special key;
308 used internally by get_wch() */
309 #ifdef XCURSES
310 int XcurscrSize; /* size of Xcurscr shared memory block */
311 bool sb_on;
312 int sb_viewport_y;
313 int sb_viewport_x;
314 int sb_total_y;
315 int sb_total_x;
316 int sb_cur_y;
317 int sb_cur_x;
318 #endif
319 short line_color; /* color of line attributes - default -1 */
320 } SCREEN;
321
322 /*----------------------------------------------------------------------
323 *
324 * PDCurses External Variables
325 *
326 */
327
328 #ifdef PDC_DLL_BUILD
329 # ifdef CURSES_LIBRARY
330 # define PDCEX __declspec(dllexport) extern
331 # else
332 # define PDCEX __declspec(dllimport)
333 # endif
334 #else
335 # define PDCEX extern
336 #endif
337
338 PDCEX int LINES; /* terminal height */
339 PDCEX int COLS; /* terminal width */
340 PDCEX WINDOW *stdscr; /* the default screen window */
341 PDCEX WINDOW *curscr; /* the current screen image */
342 PDCEX SCREEN *SP; /* curses variables */
343 PDCEX MOUSE_STATUS Mouse_status;
344 PDCEX int COLORS;
345 PDCEX int COLOR_PAIRS;
346 PDCEX int TABSIZE;
347 PDCEX chtype acs_map[]; /* alternate character set map */
348 PDCEX char ttytype[]; /* terminal name/description */
349
350 /*man-start**************************************************************
351
352 PDCurses Text Attributes
353 ========================
354
355 Originally, PDCurses used a short (16 bits) for its chtype. To include
356 color, a number of things had to be sacrificed from the strict Unix and
357 System V support. The main problem was fitting all character attributes
358 and color into an unsigned char (all 8 bits!).
359
360 Today, PDCurses by default uses a long (32 bits) for its chtype, as in
361 System V. The short chtype is still available, by undefining CHTYPE_LONG
362 and rebuilding the library.
363
364 The following is the structure of a win->_attrs chtype:
365
366 short form:
367
368 -------------------------------------------------
369 |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
370 -------------------------------------------------
371 color number | attrs | character eg 'a'
372
373 The available non-color attributes are bold, reverse and blink. Others
374 have no effect. The high order char is an index into an array of
375 physical colors (defined in color.c) -- 32 foreground/background color
376 pairs (5 bits) plus 3 bits for other attributes.
377
378 long form:
379
380 ----------------------------------------------------------------------------
381 |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|..| 3| 2| 1| 0|
382 ----------------------------------------------------------------------------
383 color number | modifiers | character eg 'a'
384
385 The available non-color attributes are bold, underline, invisible,
386 right-line, left-line, protect, reverse and blink. 256 color pairs (8
387 bits), 8 bits for other attributes, and 16 bits for character data.
388
389 **man-end****************************************************************/
390
391 /*** Video attribute macros ***/
392
393 #define A_NORMAL (chtype)0
394
395 #ifdef CHTYPE_LONG
396 # define A_ALTCHARSET (chtype)0x00010000
397 # define A_RIGHTLINE (chtype)0x00020000
398 # define A_LEFTLINE (chtype)0x00040000
399 # define A_INVIS (chtype)0x00080000
400 # define A_UNDERLINE (chtype)0x00100000
401 # define A_REVERSE (chtype)0x00200000
402 # define A_BLINK (chtype)0x00400000
403 # define A_BOLD (chtype)0x00800000
404
405 # define A_ATTRIBUTES (chtype)0xffff0000
406 # define A_CHARTEXT (chtype)0x0000ffff
407 # define A_COLOR (chtype)0xff000000
408
409 # define A_ITALIC A_INVIS
410 # define A_PROTECT (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE)
411
412 # define PDC_ATTR_SHIFT 19
413 # define PDC_COLOR_SHIFT 24
414 #else
415 # define A_BOLD (chtype)0x0100 /* X/Open */
416 # define A_REVERSE (chtype)0x0200 /* X/Open */
417 # define A_BLINK (chtype)0x0400 /* X/Open */
418
419 # define A_ATTRIBUTES (chtype)0xff00 /* X/Open */
420 # define A_CHARTEXT (chtype)0x00ff /* X/Open */
421 # define A_COLOR (chtype)0xf800 /* System V */
422
423 # define A_ALTCHARSET A_NORMAL /* X/Open */
424 # define A_PROTECT A_NORMAL /* X/Open */
425 # define A_UNDERLINE A_NORMAL /* X/Open */
426
427 # define A_LEFTLINE A_NORMAL
428 # define A_RIGHTLINE A_NORMAL
429 # define A_ITALIC A_NORMAL
430 # define A_INVIS A_NORMAL
431
432 # define PDC_ATTR_SHIFT 8
433 # define PDC_COLOR_SHIFT 11
434 #endif
435
436 #define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */
437 #define A_DIM A_NORMAL
438
439 #define CHR_MSK A_CHARTEXT /* Obsolete */
440 #define ATR_MSK A_ATTRIBUTES /* Obsolete */
441 #define ATR_NRM A_NORMAL /* Obsolete */
442
443 /* For use with attr_t -- X/Open says, "these shall be distinct", so
444 this is a non-conforming implementation. */
445
446 #define WA_ALTCHARSET A_ALTCHARSET
447 #define WA_BLINK A_BLINK
448 #define WA_BOLD A_BOLD
449 #define WA_DIM A_DIM
450 #define WA_INVIS A_INVIS
451 #define WA_LEFT A_LEFTLINE
452 #define WA_PROTECT A_PROTECT
453 #define WA_REVERSE A_REVERSE
454 #define WA_RIGHT A_RIGHTLINE
455 #define WA_STANDOUT A_STANDOUT
456 #define WA_UNDERLINE A_UNDERLINE
457
458 #define WA_HORIZONTAL A_NORMAL
459 #define WA_LOW A_NORMAL
460 #define WA_TOP A_NORMAL
461 #define WA_VERTICAL A_NORMAL
462
463 /*** Alternate character set macros ***/
464
465 /* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET
466 'n' = 16-bit chtype; it gets the fallback set because no bit is
467 available for A_ALTCHARSET */
468
469 #ifdef CHTYPE_LONG
470 # define ACS_PICK(w, n) ((chtype)w | A_ALTCHARSET)
471 #else
472 # define ACS_PICK(w, n) ((chtype)n)
473 #endif
474
475 /* VT100-compatible symbols -- box chars */
476
477 #define ACS_ULCORNER ACS_PICK('l', '+')
478 #define ACS_LLCORNER ACS_PICK('m', '+')
479 #define ACS_URCORNER ACS_PICK('k', '+')
480 #define ACS_LRCORNER ACS_PICK('j', '+')
481 #define ACS_RTEE ACS_PICK('u', '+')
482 #define ACS_LTEE ACS_PICK('t', '+')
483 #define ACS_BTEE ACS_PICK('v', '+')
484 #define ACS_TTEE ACS_PICK('w', '+')
485 #define ACS_HLINE ACS_PICK('q', '-')
486 #define ACS_VLINE ACS_PICK('x', '|')
487 #define ACS_PLUS ACS_PICK('n', '+')
488
489 /* VT100-compatible symbols -- other */
490
491 #define ACS_S1 ACS_PICK('o', '-')
492 #define ACS_S9 ACS_PICK('s', '_')
493 #define ACS_DIAMOND ACS_PICK('`', '+')
494 #define ACS_CKBOARD ACS_PICK('a', ':')
495 #define ACS_DEGREE ACS_PICK('f', '\'')
496 #define ACS_PLMINUS ACS_PICK('g', '#')
497 #define ACS_BULLET ACS_PICK('~', 'o')
498
499 /* Teletype 5410v1 symbols -- these are defined in SysV curses, but
500 are not well-supported by most terminals. Stick to VT100 characters
501 for optimum portability. */
502
503 #define ACS_LARROW ACS_PICK(',', '<')
504 #define ACS_RARROW ACS_PICK('+', '>')
505 #define ACS_DARROW ACS_PICK('.', 'v')
506 #define ACS_UARROW ACS_PICK('-', '^')
507 #define ACS_BOARD ACS_PICK('h', '#')
508 #define ACS_LANTERN ACS_PICK('i', '*')
509 #define ACS_BLOCK ACS_PICK('0', '#')
510
511 /* That goes double for these -- undocumented SysV symbols. Don't use
512 them. */
513
514 #define ACS_S3 ACS_PICK('p', '-')
515 #define ACS_S7 ACS_PICK('r', '-')
516 #define ACS_LEQUAL ACS_PICK('y', '<')
517 #define ACS_GEQUAL ACS_PICK('z', '>')
518 #define ACS_PI ACS_PICK('{', 'n')
519 #define ACS_NEQUAL ACS_PICK('|', '+')
520 #define ACS_STERLING ACS_PICK('}', 'L')
521
522 /* Box char aliases */
523
524 #define ACS_BSSB ACS_ULCORNER
525 #define ACS_SSBB ACS_LLCORNER
526 #define ACS_BBSS ACS_URCORNER
527 #define ACS_SBBS ACS_LRCORNER
528 #define ACS_SBSS ACS_RTEE
529 #define ACS_SSSB ACS_LTEE
530 #define ACS_SSBS ACS_BTEE
531 #define ACS_BSSS ACS_TTEE
532 #define ACS_BSBS ACS_HLINE
533 #define ACS_SBSB ACS_VLINE
534 #define ACS_SSSS ACS_PLUS
535
536 /* cchar_t aliases */
537
538 #ifdef PDC_WIDE
539 # define WACS_ULCORNER (&(acs_map['l']))
540 # define WACS_LLCORNER (&(acs_map['m']))
541 # define WACS_URCORNER (&(acs_map['k']))
542 # define WACS_LRCORNER (&(acs_map['j']))
543 # define WACS_RTEE (&(acs_map['u']))
544 # define WACS_LTEE (&(acs_map['t']))
545 # define WACS_BTEE (&(acs_map['v']))
546 # define WACS_TTEE (&(acs_map['w']))
547 # define WACS_HLINE (&(acs_map['q']))
548 # define WACS_VLINE (&(acs_map['x']))
549 # define WACS_PLUS (&(acs_map['n']))
550
551 # define WACS_S1 (&(acs_map['o']))
552 # define WACS_S9 (&(acs_map['s']))
553 # define WACS_DIAMOND (&(acs_map['`']))
554 # define WACS_CKBOARD (&(acs_map['a']))
555 # define WACS_DEGREE (&(acs_map['f']))
556 # define WACS_PLMINUS (&(acs_map['g']))
557 # define WACS_BULLET (&(acs_map['~']))
558
559 # define WACS_LARROW (&(acs_map[',']))
560 # define WACS_RARROW (&(acs_map['+']))
561 # define WACS_DARROW (&(acs_map['.']))
562 # define WACS_UARROW (&(acs_map['-']))
563 # define WACS_BOARD (&(acs_map['h']))
564 # define WACS_LANTERN (&(acs_map['i']))
565 # define WACS_BLOCK (&(acs_map['0']))
566
567 # define WACS_S3 (&(acs_map['p']))
568 # define WACS_S7 (&(acs_map['r']))
569 # define WACS_LEQUAL (&(acs_map['y']))
570 # define WACS_GEQUAL (&(acs_map['z']))
571 # define WACS_PI (&(acs_map['{']))
572 # define WACS_NEQUAL (&(acs_map['|']))
573 # define WACS_STERLING (&(acs_map['}']))
574
575 # define WACS_BSSB WACS_ULCORNER
576 # define WACS_SSBB WACS_LLCORNER
577 # define WACS_BBSS WACS_URCORNER
578 # define WACS_SBBS WACS_LRCORNER
579 # define WACS_SBSS WACS_RTEE
580 # define WACS_SSSB WACS_LTEE
581 # define WACS_SSBS WACS_BTEE
582 # define WACS_BSSS WACS_TTEE
583 # define WACS_BSBS WACS_HLINE
584 # define WACS_SBSB WACS_VLINE
585 # define WACS_SSSS WACS_PLUS
586 #endif
587
588 /*** Color macros ***/
589
590 #define COLOR_BLACK 0
591
592 #ifdef PDC_RGB /* RGB */
593 # define COLOR_RED 1
594 # define COLOR_GREEN 2
595 # define COLOR_BLUE 4
596 #else /* BGR */
597 # define COLOR_BLUE 1
598 # define COLOR_GREEN 2
599 # define COLOR_RED 4
600 #endif
601
602 #define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN)
603 #define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE)
604 #define COLOR_YELLOW (COLOR_RED | COLOR_GREEN)
605
606 #define COLOR_WHITE 7
607
608 /*----------------------------------------------------------------------
609 *
610 * Function and Keypad Key Definitions.
611 * Many are just for compatibility.
612 *
613 */
614
615 #define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */
616
617 #define KEY_BREAK 0x101 /* Not on PC KBD */
618 #define KEY_DOWN 0x102 /* Down arrow key */
619 #define KEY_UP 0x103 /* Up arrow key */
620 #define KEY_LEFT 0x104 /* Left arrow key */
621 #define KEY_RIGHT 0x105 /* Right arrow key */
622 #define KEY_HOME 0x106 /* home key */
623 #define KEY_BACKSPACE 0x107 /* not on pc */
624 #define KEY_F0 0x108 /* function keys; 64 reserved */
625
626 #define KEY_DL 0x148 /* delete line */
627 #define KEY_IL 0x149 /* insert line */
628 #define KEY_DC 0x14a /* delete character */
629 #define KEY_IC 0x14b /* insert char or enter ins mode */
630 #define KEY_EIC 0x14c /* exit insert char mode */
631 #define KEY_CLEAR 0x14d /* clear screen */
632 #define KEY_EOS 0x14e /* clear to end of screen */
633 #define KEY_EOL 0x14f /* clear to end of line */
634 #define KEY_SF 0x150 /* scroll 1 line forward */
635 #define KEY_SR 0x151 /* scroll 1 line back (reverse) */
636 #define KEY_NPAGE 0x152 /* next page */
637 #define KEY_PPAGE 0x153 /* previous page */
638 #define KEY_STAB 0x154 /* set tab */
639 #define KEY_CTAB 0x155 /* clear tab */
640 #define KEY_CATAB 0x156 /* clear all tabs */
641 #define KEY_ENTER 0x157 /* enter or send (unreliable) */
642 #define KEY_SRESET 0x158 /* soft/reset (partial/unreliable) */
643 #define KEY_RESET 0x159 /* reset/hard reset (unreliable) */
644 #define KEY_PRINT 0x15a /* print/copy */
645 #define KEY_LL 0x15b /* home down/bottom (lower left) */
646 #define KEY_ABORT 0x15c /* abort/terminate key (any) */
647 #define KEY_SHELP 0x15d /* short help */
648 #define KEY_LHELP 0x15e /* long help */
649 #define KEY_BTAB 0x15f /* Back tab key */
650 #define KEY_BEG 0x160 /* beg(inning) key */
651 #define KEY_CANCEL 0x161 /* cancel key */
652 #define KEY_CLOSE 0x162 /* close key */
653 #define KEY_COMMAND 0x163 /* cmd (command) key */
654 #define KEY_COPY 0x164 /* copy key */
655 #define KEY_CREATE 0x165 /* create key */
656 #define KEY_END 0x166 /* end key */
657 #define KEY_EXIT 0x167 /* exit key */
658 #define KEY_FIND 0x168 /* find key */
659 #define KEY_HELP 0x169 /* help key */
660 #define KEY_MARK 0x16a /* mark key */
661 #define KEY_MESSAGE 0x16b /* message key */
662 #define KEY_MOVE 0x16c /* move key */
663 #define KEY_NEXT 0x16d /* next object key */
664 #define KEY_OPEN 0x16e /* open key */
665 #define KEY_OPTIONS 0x16f /* options key */
666 #define KEY_PREVIOUS 0x170 /* previous object key */
667 #define KEY_REDO 0x171 /* redo key */
668 #define KEY_REFERENCE 0x172 /* ref(erence) key */
669 #define KEY_REFRESH 0x173 /* refresh key */
670 #define KEY_REPLACE 0x174 /* replace key */
671 #define KEY_RESTART 0x175 /* restart key */
672 #define KEY_RESUME 0x176 /* resume key */
673 #define KEY_SAVE 0x177 /* save key */
674 #define KEY_SBEG 0x178 /* shifted beginning key */
675 #define KEY_SCANCEL 0x179 /* shifted cancel key */
676 #define KEY_SCOMMAND 0x17a /* shifted command key */
677 #define KEY_SCOPY 0x17b /* shifted copy key */
678 #define KEY_SCREATE 0x17c /* shifted create key */
679 #define KEY_SDC 0x17d /* shifted delete char key */
680 #define KEY_SDL 0x17e /* shifted delete line key */
681 #define KEY_SELECT 0x17f /* select key */
682 #define KEY_SEND 0x180 /* shifted end key */
683 #define KEY_SEOL 0x181 /* shifted clear line key */
684 #define KEY_SEXIT 0x182 /* shifted exit key */
685 #define KEY_SFIND 0x183 /* shifted find key */
686 #define KEY_SHOME 0x184 /* shifted home key */
687 #define KEY_SIC 0x185 /* shifted input key */
688
689 #define KEY_SLEFT 0x187 /* shifted left arrow key */
690 #define KEY_SMESSAGE 0x188 /* shifted message key */
691 #define KEY_SMOVE 0x189 /* shifted move key */
692 #define KEY_SNEXT 0x18a /* shifted next key */
693 #define KEY_SOPTIONS 0x18b /* shifted options key */
694 #define KEY_SPREVIOUS 0x18c /* shifted prev key */
695 #define KEY_SPRINT 0x18d /* shifted print key */
696 #define KEY_SREDO 0x18e /* shifted redo key */
697 #define KEY_SREPLACE 0x18f /* shifted replace key */
698 #define KEY_SRIGHT 0x190 /* shifted right arrow */
699 #define KEY_SRSUME 0x191 /* shifted resume key */
700 #define KEY_SSAVE 0x192 /* shifted save key */
701 #define KEY_SSUSPEND 0x193 /* shifted suspend key */
702 #define KEY_SUNDO 0x194 /* shifted undo key */
703 #define KEY_SUSPEND 0x195 /* suspend key */
704 #define KEY_UNDO 0x196 /* undo key */
705
706 /* PDCurses-specific key definitions -- PC only */
707
708 #define ALT_0 0x197
709 #define ALT_1 0x198
710 #define ALT_2 0x199
711 #define ALT_3 0x19a
712 #define ALT_4 0x19b
713 #define ALT_5 0x19c
714 #define ALT_6 0x19d
715 #define ALT_7 0x19e
716 #define ALT_8 0x19f
717 #define ALT_9 0x1a0
718 #define ALT_A 0x1a1
719 #define ALT_B 0x1a2
720 #define ALT_C 0x1a3
721 #define ALT_D 0x1a4
722 #define ALT_E 0x1a5
723 #define ALT_F 0x1a6
724 #define ALT_G 0x1a7
725 #define ALT_H 0x1a8
726 #define ALT_I 0x1a9
727 #define ALT_J 0x1aa
728 #define ALT_K 0x1ab
729 #define ALT_L 0x1ac
730 #define ALT_M 0x1ad
731 #define ALT_N 0x1ae
732 #define ALT_O 0x1af
733 #define ALT_P 0x1b0
734 #define ALT_Q 0x1b1
735 #define ALT_R 0x1b2
736 #define ALT_S 0x1b3
737 #define ALT_T 0x1b4
738 #define ALT_U 0x1b5
739 #define ALT_V 0x1b6
740 #define ALT_W 0x1b7
741 #define ALT_X 0x1b8
742 #define ALT_Y 0x1b9
743 #define ALT_Z 0x1ba
744
745 #define CTL_LEFT 0x1bb /* Control-Left-Arrow */
746 #define CTL_RIGHT 0x1bc
747 #define CTL_PGUP 0x1bd
748 #define CTL_PGDN 0x1be
749 #define CTL_HOME 0x1bf
750 #define CTL_END 0x1c0
751
752 #define KEY_A1 0x1c1 /* upper left on Virtual keypad */
753 #define KEY_A2 0x1c2 /* upper middle on Virt. keypad */
754 #define KEY_A3 0x1c3 /* upper right on Vir. keypad */
755 #define KEY_B1 0x1c4 /* middle left on Virt. keypad */
756 #define KEY_B2 0x1c5 /* center on Virt. keypad */
757 #define KEY_B3 0x1c6 /* middle right on Vir. keypad */
758 #define KEY_C1 0x1c7 /* lower left on Virt. keypad */
759 #define KEY_C2 0x1c8 /* lower middle on Virt. keypad */
760 #define KEY_C3 0x1c9 /* lower right on Vir. keypad */
761
762 #define PADSLASH 0x1ca /* slash on keypad */
763 #define PADENTER 0x1cb /* enter on keypad */
764 #define CTL_PADENTER 0x1cc /* ctl-enter on keypad */
765 #define ALT_PADENTER 0x1cd /* alt-enter on keypad */
766 #define PADSTOP 0x1ce /* stop on keypad */
767 #define PADSTAR 0x1cf /* star on keypad */
768 #define PADMINUS 0x1d0 /* minus on keypad */
769 #define PADPLUS 0x1d1 /* plus on keypad */
770 #define CTL_PADSTOP 0x1d2 /* ctl-stop on keypad */
771 #define CTL_PADCENTER 0x1d3 /* ctl-enter on keypad */
772 #define CTL_PADPLUS 0x1d4 /* ctl-plus on keypad */
773 #define CTL_PADMINUS 0x1d5 /* ctl-minus on keypad */
774 #define CTL_PADSLASH 0x1d6 /* ctl-slash on keypad */
775 #define CTL_PADSTAR 0x1d7 /* ctl-star on keypad */
776 #define ALT_PADPLUS 0x1d8 /* alt-plus on keypad */
777 #define ALT_PADMINUS 0x1d9 /* alt-minus on keypad */
778 #define ALT_PADSLASH 0x1da /* alt-slash on keypad */
779 #define ALT_PADSTAR 0x1db /* alt-star on keypad */
780 #define ALT_PADSTOP 0x1dc /* alt-stop on keypad */
781 #define CTL_INS 0x1dd /* ctl-insert */
782 #define ALT_DEL 0x1de /* alt-delete */
783 #define ALT_INS 0x1df /* alt-insert */
784 #define CTL_UP 0x1e0 /* ctl-up arrow */
785 #define CTL_DOWN 0x1e1 /* ctl-down arrow */
786 #define CTL_TAB 0x1e2 /* ctl-tab */
787 #define ALT_TAB 0x1e3
788 #define ALT_MINUS 0x1e4
789 #define ALT_EQUAL 0x1e5
790 #define ALT_HOME 0x1e6
791 #define ALT_PGUP 0x1e7
792 #define ALT_PGDN 0x1e8
793 #define ALT_END 0x1e9
794 #define ALT_UP 0x1ea /* alt-up arrow */
795 #define ALT_DOWN 0x1eb /* alt-down arrow */
796 #define ALT_RIGHT 0x1ec /* alt-right arrow */
797 #define ALT_LEFT 0x1ed /* alt-left arrow */
798 #define ALT_ENTER 0x1ee /* alt-enter */
799 #define ALT_ESC 0x1ef /* alt-escape */
800 #define ALT_BQUOTE 0x1f0 /* alt-back quote */
801 #define ALT_LBRACKET 0x1f1 /* alt-left bracket */
802 #define ALT_RBRACKET 0x1f2 /* alt-right bracket */
803 #define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */
804 #define ALT_FQUOTE 0x1f4 /* alt-forward quote */
805 #define ALT_COMMA 0x1f5 /* alt-comma */
806 #define ALT_STOP 0x1f6 /* alt-stop */
807 #define ALT_FSLASH 0x1f7 /* alt-forward slash */
808 #define ALT_BKSP 0x1f8 /* alt-backspace */
809 #define CTL_BKSP 0x1f9 /* ctl-backspace */
810 #define PAD0 0x1fa /* keypad 0 */
811
812 #define CTL_PAD0 0x1fb /* ctl-keypad 0 */
813 #define CTL_PAD1 0x1fc
814 #define CTL_PAD2 0x1fd
815 #define CTL_PAD3 0x1fe
816 #define CTL_PAD4 0x1ff
817 #define CTL_PAD5 0x200
818 #define CTL_PAD6 0x201
819 #define CTL_PAD7 0x202
820 #define CTL_PAD8 0x203
821 #define CTL_PAD9 0x204
822
823 #define ALT_PAD0 0x205 /* alt-keypad 0 */
824 #define ALT_PAD1 0x206
825 #define ALT_PAD2 0x207
826 #define ALT_PAD3 0x208
827 #define ALT_PAD4 0x209
828 #define ALT_PAD5 0x20a
829 #define ALT_PAD6 0x20b
830 #define ALT_PAD7 0x20c
831 #define ALT_PAD8 0x20d
832 #define ALT_PAD9 0x20e
833
834 #define CTL_DEL 0x20f /* clt-delete */
835 #define ALT_BSLASH 0x210 /* alt-back slash */
836 #define CTL_ENTER 0x211 /* ctl-enter */
837
838 #define SHF_PADENTER 0x212 /* shift-enter on keypad */
839 #define SHF_PADSLASH 0x213 /* shift-slash on keypad */
840 #define SHF_PADSTAR 0x214 /* shift-star on keypad */
841 #define SHF_PADPLUS 0x215 /* shift-plus on keypad */
842 #define SHF_PADMINUS 0x216 /* shift-minus on keypad */
843 #define SHF_UP 0x217 /* shift-up on keypad */
844 #define SHF_DOWN 0x218 /* shift-down on keypad */
845 #define SHF_IC 0x219 /* shift-insert on keypad */
846 #define SHF_DC 0x21a /* shift-delete on keypad */
847
848 #define KEY_MOUSE 0x21b /* "mouse" key */
849 #define KEY_SHIFT_L 0x21c /* Left-shift */
850 #define KEY_SHIFT_R 0x21d /* Right-shift */
851 #define KEY_CONTROL_L 0x21e /* Left-control */
852 #define KEY_CONTROL_R 0x21f /* Right-control */
853 #define KEY_ALT_L 0x220 /* Left-alt */
854 #define KEY_ALT_R 0x221 /* Right-alt */
855 #define KEY_RESIZE 0x222 /* Window resize */
856 #define KEY_SUP 0x223 /* Shifted up arrow */
857 #define KEY_SDOWN 0x224 /* Shifted down arrow */
858
859 #define KEY_MIN KEY_BREAK /* Minimum curses key value */
860 #define KEY_MAX KEY_SDOWN /* Maximum curses key */
861
862 #define KEY_F(n) (KEY_F0 + (n))
863
864 /*----------------------------------------------------------------------
865 *
866 * PDCurses Function Declarations
867 *
868 */
869
870 /* Standard */
871
872 int addch(const chtype);
873 int addchnstr(const chtype *, int);
874 int addchstr(const chtype *);
875 int addnstr(const char *, int);
876 int addstr(const char *);
877 int attroff(chtype);
878 int attron(chtype);
879 int attrset(chtype);
880 int attr_get(attr_t *, short *, void *);
881 int attr_off(attr_t, void *);
882 int attr_on(attr_t, void *);
883 int attr_set(attr_t, short, void *);
884 int baudrate(void);
885 int beep(void);
886 int bkgd(chtype);
887 void bkgdset(chtype);
888 int border(chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype);
889 int box(WINDOW *, chtype, chtype);
890 bool can_change_color(void);
891 int cbreak(void);
892 int chgat(int, attr_t, short, const void *);
893 int clearok(WINDOW *, bool);
894 int clear(void);
895 int clrtobot(void);
896 int clrtoeol(void);
897 int color_content(short, short *, short *, short *);
898 int color_set(short, void *);
899 int copywin(const WINDOW *, WINDOW *, int, int, int, int, int, int, int);
900 int curs_set(int);
901 int def_prog_mode(void);
902 int def_shell_mode(void);
903 int delay_output(int);
904 int delch(void);
905 int deleteln(void);
906 void delscreen(SCREEN *);
907 int delwin(WINDOW *);
908 WINDOW *derwin(WINDOW *, int, int, int, int);
909 int doupdate(void);
910 WINDOW *dupwin(WINDOW *);
911 int echochar(const chtype);
912 int echo(void);
913 int endwin(void);
914 char erasechar(void);
915 int erase(void);
916 void filter(void);
917 int flash(void);
918 int flushinp(void);
919 chtype getbkgd(WINDOW *);
920 int getnstr(char *, int);
921 int getstr(char *);
922 WINDOW *getwin(FILE *);
923 int halfdelay(int);
924 bool has_colors(void);
925 bool has_ic(void);
926 bool has_il(void);
927 int hline(chtype, int);
928 void idcok(WINDOW *, bool);
929 int idlok(WINDOW *, bool);
930 void immedok(WINDOW *, bool);
931 int inchnstr(chtype *, int);
932 int inchstr(chtype *);
933 chtype inch(void);
934 int init_color(short, short, short, short);
935 int init_pair(short, short, short);
936 WINDOW *initscr(void);
937 int innstr(char *, int);
938 int insch(chtype);
939 int insdelln(int);
940 int insertln(void);
941 int insnstr(const char *, int);
942 int insstr(const char *);
943 int instr(char *);
944 int intrflush(WINDOW *, bool);
945 bool isendwin(void);
946 bool is_linetouched(WINDOW *, int);
947 bool is_wintouched(WINDOW *);
948 char *keyname(int);
949 int keypad(WINDOW *, bool);
950 char killchar(void);
951 int leaveok(WINDOW *, bool);
952 char *longname(void);
953 int meta(WINDOW *, bool);
954 int move(int, int);
955 int mvaddch(int, int, const chtype);
956 int mvaddchnstr(int, int, const chtype *, int);
957 int mvaddchstr(int, int, const chtype *);
958 int mvaddnstr(int, int, const char *, int);
959 int mvaddstr(int, int, const char *);
960 int mvchgat(int, int, int, attr_t, short, const void *);
961 int mvcur(int, int, int, int);
962 int mvdelch(int, int);
963 int mvderwin(WINDOW *, int, int);
964 int mvgetch(int, int);
965 int mvgetnstr(int, int, char *, int);
966 int mvgetstr(int, int, char *);
967 int mvhline(int, int, chtype, int);
968 chtype mvinch(int, int);
969 int mvinchnstr(int, int, chtype *, int);
970 int mvinchstr(int, int, chtype *);
971 int mvinnstr(int, int, char *, int);
972 int mvinsch(int, int, chtype);
973 int mvinsnstr(int, int, const char *, int);
974 int mvinsstr(int, int, const char *);
975 int mvinstr(int, int, char *);
976 int mvprintw(int, int, const char *, ...);
977 int mvscanw(int, int, const char *, ...);
978 int mvvline(int, int, chtype, int);
979 int mvwaddchnstr(WINDOW *, int, int, const chtype *, int);
980 int mvwaddchstr(WINDOW *, int, int, const chtype *);
981 int mvwaddch(WINDOW *, int, int, const chtype);
982 int mvwaddnstr(WINDOW *, int, int, const char *, int);
983 int mvwaddstr(WINDOW *, int, int, const char *);
984 int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *);
985 int mvwdelch(WINDOW *, int, int);
986 int mvwgetch(WINDOW *, int, int);
987 int mvwgetnstr(WINDOW *, int, int, char *, int);
988 int mvwgetstr(WINDOW *, int, int, char *);
989 int mvwhline(WINDOW *, int, int, chtype, int);
990 int mvwinchnstr(WINDOW *, int, int, chtype *, int);
991 int mvwinchstr(WINDOW *, int, int, chtype *);
992 chtype mvwinch(WINDOW *, int, int);
993 int mvwinnstr(WINDOW *, int, int, char *, int);
994 int mvwinsch(WINDOW *, int, int, chtype);
995 int mvwinsnstr(WINDOW *, int, int, const char *, int);
996 int mvwinsstr(WINDOW *, int, int, const char *);
997 int mvwinstr(WINDOW *, int, int, char *);
998 int mvwin(WINDOW *, int, int);
999 int mvwprintw(WINDOW *, int, int, const char *, ...);
1000 int mvwscanw(WINDOW *, int, int, const char *, ...);
1001 int mvwvline(WINDOW *, int, int, chtype, int);
1002 int napms(int);
1003 WINDOW *newpad(int, int);
1004 SCREEN *newterm(const char *, FILE *, FILE *);
1005 WINDOW *newwin(int, int, int, int);
1006 int nl(void);
1007 int nocbreak(void);
1008 int nodelay(WINDOW *, bool);
1009 int noecho(void);
1010 int nonl(void);
1011 void noqiflush(void);
1012 int noraw(void);
1013 int notimeout(WINDOW *, bool);
1014 int overlay(const WINDOW *, WINDOW *);
1015 int overwrite(const WINDOW *, WINDOW *);
1016 int pair_content(short, short *, short *);
1017 int pechochar(WINDOW *, chtype);
1018 int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
1019 int prefresh(WINDOW *, int, int, int, int, int, int);
1020 int printw(const char *, ...);
1021 int putwin(WINDOW *, FILE *);
1022 void qiflush(void);
1023 int raw(void);
1024 int redrawwin(WINDOW *);
1025 int refresh(void);
1026 int reset_prog_mode(void);
1027 int reset_shell_mode(void);
1028 int resetty(void);
1029 int ripoffline(int, int (*)(WINDOW *, int));
1030 int savetty(void);
1031 int scanw(const char *, ...);
1032 int scr_dump(const char *);
1033 int scr_init(const char *);
1034 int scr_restore(const char *);
1035 int scr_set(const char *);
1036 int scrl(int);
1037 int scroll(WINDOW *);
1038 int scrollok(WINDOW *, bool);
1039 SCREEN *set_term(SCREEN *);
1040 int setscrreg(int, int);
1041 int slk_attroff(const chtype);
1042 int slk_attr_off(const attr_t, void *);
1043 int slk_attron(const chtype);
1044 int slk_attr_on(const attr_t, void *);
1045 int slk_attrset(const chtype);
1046 int slk_attr_set(const attr_t, short, void *);
1047 int slk_clear(void);
1048 int slk_color(short);
1049 int slk_init(int);
1050 char *slk_label(int);
1051 int slk_noutrefresh(void);
1052 int slk_refresh(void);
1053 int slk_restore(void);
1054 int slk_set(int, const char *, int);
1055 int slk_touch(void);
1056 int standend(void);
1057 int standout(void);
1058 int start_color(void);
1059 WINDOW *subpad(WINDOW *, int, int, int, int);
1060 WINDOW *subwin(WINDOW *, int, int, int, int);
1061 int syncok(WINDOW *, bool);
1062 chtype termattrs(void);
1063 attr_t term_attrs(void);
1064 char *termname(void);
1065 void timeout(int);
1066 int touchline(WINDOW *, int, int);
1067 int touchwin(WINDOW *);
1068 int typeahead(int);
1069 int untouchwin(WINDOW *);
1070 void use_env(bool);
1071 int vidattr(chtype);
1072 int vid_attr(attr_t, short, void *);
1073 int vidputs(chtype, int (*)(int));
1074 int vid_puts(attr_t, short, void *, int (*)(int));
1075 int vline(chtype, int);
1076 int vw_printw(WINDOW *, const char *, va_list);
1077 int vwprintw(WINDOW *, const char *, va_list);
1078 int vw_scanw(WINDOW *, const char *, va_list);
1079 int vwscanw(WINDOW *, const char *, va_list);
1080 int waddchnstr(WINDOW *, const chtype *, int);
1081 int waddchstr(WINDOW *, const chtype *);
1082 int waddch(WINDOW *, const chtype);
1083 int waddnstr(WINDOW *, const char *, int);
1084 int waddstr(WINDOW *, const char *);
1085 int wattroff(WINDOW *, chtype);
1086 int wattron(WINDOW *, chtype);
1087 int wattrset(WINDOW *, chtype);
1088 int wattr_get(WINDOW *, attr_t *, short *, void *);
1089 int wattr_off(WINDOW *, attr_t, void *);
1090 int wattr_on(WINDOW *, attr_t, void *);
1091 int wattr_set(WINDOW *, attr_t, short, void *);
1092 void wbkgdset(WINDOW *, chtype);
1093 int wbkgd(WINDOW *, chtype);
1094 int wborder(WINDOW *, chtype, chtype, chtype, chtype,
1095 chtype, chtype, chtype, chtype);
1096 int wchgat(WINDOW *, int, attr_t, short, const void *);
1097 int wclear(WINDOW *);
1098 int wclrtobot(WINDOW *);
1099 int wclrtoeol(WINDOW *);
1100 int wcolor_set(WINDOW *, short, void *);
1101 void wcursyncup(WINDOW *);
1102 int wdelch(WINDOW *);
1103 int wdeleteln(WINDOW *);
1104 int wechochar(WINDOW *, const chtype);
1105 int werase(WINDOW *);
1106 int wgetch(WINDOW *);
1107 int wgetnstr(WINDOW *, char *, int);
1108 int wgetstr(WINDOW *, char *);
1109 int whline(WINDOW *, chtype, int);
1110 int winchnstr(WINDOW *, chtype *, int);
1111 int winchstr(WINDOW *, chtype *);
1112 chtype winch(WINDOW *);
1113 int winnstr(WINDOW *, char *, int);
1114 int winsch(WINDOW *, chtype);
1115 int winsdelln(WINDOW *, int);
1116 int winsertln(WINDOW *);
1117 int winsnstr(WINDOW *, const char *, int);
1118 int winsstr(WINDOW *, const char *);
1119 int winstr(WINDOW *, char *);
1120 int wmove(WINDOW *, int, int);
1121 int wnoutrefresh(WINDOW *);
1122 int wprintw(WINDOW *, const char *, ...);
1123 int wredrawln(WINDOW *, int, int);
1124 int wrefresh(WINDOW *);
1125 int wscanw(WINDOW *, const char *, ...);
1126 int wscrl(WINDOW *, int);
1127 int wsetscrreg(WINDOW *, int, int);
1128 int wstandend(WINDOW *);
1129 int wstandout(WINDOW *);
1130 void wsyncdown(WINDOW *);
1131 void wsyncup(WINDOW *);
1132 void wtimeout(WINDOW *, int);
1133 int wtouchln(WINDOW *, int, int, int);
1134 int wvline(WINDOW *, chtype, int);
1135
1136 /* Wide-character functions */
1137
1138 #ifdef PDC_WIDE
1139 int addnwstr(const wchar_t *, int);
1140 int addwstr(const wchar_t *);
1141 int add_wch(const cchar_t *);
1142 int add_wchnstr(const cchar_t *, int);
1143 int add_wchstr(const cchar_t *);
1144 int border_set(const cchar_t *, const cchar_t *, const cchar_t *,
1145 const cchar_t *, const cchar_t *, const cchar_t *,
1146 const cchar_t *, const cchar_t *);
1147 int box_set(WINDOW *, const cchar_t *, const cchar_t *);
1148 int echo_wchar(const cchar_t *);
1149 int erasewchar(wchar_t *);
1150 int getbkgrnd(cchar_t *);
1151 int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *);
1152 int getn_wstr(wint_t *, int);
1153 int get_wch(wint_t *);
1154 int get_wstr(wint_t *);
1155 int hline_set(const cchar_t *, int);
1156 int innwstr(wchar_t *, int);
1157 int ins_nwstr(const wchar_t *, int);
1158 int ins_wch(const cchar_t *);
1159 int ins_wstr(const wchar_t *);
1160 int inwstr(wchar_t *);
1161 int in_wch(cchar_t *);
1162 int in_wchnstr(cchar_t *, int);
1163 int in_wchstr(cchar_t *);
1164 char *key_name(wchar_t);
1165 int killwchar(wchar_t *);
1166 int mvaddnwstr(int, int, const wchar_t *, int);
1167 int mvaddwstr(int, int, const wchar_t *);
1168 int mvadd_wch(int, int, const cchar_t *);
1169 int mvadd_wchnstr(int, int, const cchar_t *, int);
1170 int mvadd_wchstr(int, int, const cchar_t *);
1171 int mvgetn_wstr(int, int, wint_t *, int);
1172 int mvget_wch(int, int, wint_t *);
1173 int mvget_wstr(int, int, wint_t *);
1174 int mvhline_set(int, int, const cchar_t *, int);
1175 int mvinnwstr(int, int, wchar_t *, int);
1176 int mvins_nwstr(int, int, const wchar_t *, int);
1177 int mvins_wch(int, int, const cchar_t *);
1178 int mvins_wstr(int, int, const wchar_t *);
1179 int mvinwstr(int, int, wchar_t *);
1180 int mvin_wch(int, int, cchar_t *);
1181 int mvin_wchnstr(int, int, cchar_t *, int);
1182 int mvin_wchstr(int, int, cchar_t *);
1183 int mvvline_set(int, int, const cchar_t *, int);
1184 int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int);
1185 int mvwaddwstr(WINDOW *, int, int, const wchar_t *);
1186 int mvwadd_wch(WINDOW *, int, int, const cchar_t *);
1187 int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int);
1188 int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *);
1189 int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int);
1190 int mvwget_wch(WINDOW *, int, int, wint_t *);
1191 int mvwget_wstr(WINDOW *, int, int, wint_t *);
1192 int mvwhline_set(WINDOW *, int, int, const cchar_t *, int);
1193 int mvwinnwstr(WINDOW *, int, int, wchar_t *, int);
1194 int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int);
1195 int mvwins_wch(WINDOW *, int, int, const cchar_t *);
1196 int mvwins_wstr(WINDOW *, int, int, const wchar_t *);
1197 int mvwin_wch(WINDOW *, int, int, cchar_t *);
1198 int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int);
1199 int mvwin_wchstr(WINDOW *, int, int, cchar_t *);
1200 int mvwinwstr(WINDOW *, int, int, wchar_t *);
1201 int mvwvline_set(WINDOW *, int, int, const cchar_t *, int);
1202 int pecho_wchar(WINDOW *, const cchar_t*);
1203 int setcchar(cchar_t*, const wchar_t*, const attr_t, short, const void*);
1204 int slk_wset(int, const wchar_t *, int);
1205 int unget_wch(const wchar_t);
1206 int vline_set(const cchar_t *, int);
1207 int waddnwstr(WINDOW *, const wchar_t *, int);
1208 int waddwstr(WINDOW *, const wchar_t *);
1209 int wadd_wch(WINDOW *, const cchar_t *);
1210 int wadd_wchnstr(WINDOW *, const cchar_t *, int);
1211 int wadd_wchstr(WINDOW *, const cchar_t *);
1212 int wbkgrnd(WINDOW *, const cchar_t *);
1213 void wbkgrndset(WINDOW *, const cchar_t *);
1214 int wborder_set(WINDOW *, const cchar_t *, const cchar_t *,
1215 const cchar_t *, const cchar_t *, const cchar_t *,
1216 const cchar_t *, const cchar_t *, const cchar_t *);
1217 int wecho_wchar(WINDOW *, const cchar_t *);
1218 int wgetbkgrnd(WINDOW *, cchar_t *);
1219 int wgetn_wstr(WINDOW *, wint_t *, int);
1220 int wget_wch(WINDOW *, wint_t *);
1221 int wget_wstr(WINDOW *, wint_t *);
1222 int whline_set(WINDOW *, const cchar_t *, int);
1223 int winnwstr(WINDOW *, wchar_t *, int);
1224 int wins_nwstr(WINDOW *, const wchar_t *, int);
1225 int wins_wch(WINDOW *, const cchar_t *);
1226 int wins_wstr(WINDOW *, const wchar_t *);
1227 int winwstr(WINDOW *, wchar_t *);
1228 int win_wch(WINDOW *, cchar_t *);
1229 int win_wchnstr(WINDOW *, cchar_t *, int);
1230 int win_wchstr(WINDOW *, cchar_t *);
1231 wchar_t *wunctrl(cchar_t *);
1232 int wvline_set(WINDOW *, const cchar_t *, int);
1233 #endif
1234
1235 /* Quasi-standard */
1236
1237 chtype getattrs(WINDOW *);
1238 int getbegx(WINDOW *);
1239 int getbegy(WINDOW *);
1240 int getmaxx(WINDOW *);
1241 int getmaxy(WINDOW *);
1242 int getparx(WINDOW *);
1243 int getpary(WINDOW *);
1244 int getcurx(WINDOW *);
1245 int getcury(WINDOW *);
1246 void traceoff(void);
1247 void traceon(void);
1248 char *unctrl(chtype);
1249
1250 int crmode(void);
1251 int nocrmode(void);
1252 int draino(int);
1253 int resetterm(void);
1254 int fixterm(void);
1255 int saveterm(void);
1256 int setsyx(int, int);
1257
1258 int mouse_set(unsigned long);
1259 int mouse_on(unsigned long);
1260 int mouse_off(unsigned long);
1261 int request_mouse_pos(void);
1262 int map_button(unsigned long);
1263 void wmouse_position(WINDOW *, int *, int *);
1264 unsigned long getmouse(void);
1265 unsigned long getbmap(void);
1266
1267 /* ncurses */
1268
1269 int assume_default_colors(int, int);
1270 const char *curses_version(void);
1271 bool has_key(int);
1272 int use_default_colors(void);
1273 int wresize(WINDOW *, int, int);
1274
1275 int mouseinterval(int);
1276 mmask_t mousemask(mmask_t, mmask_t *);
1277 bool mouse_trafo(int *, int *, bool);
1278 int nc_getmouse(MEVENT *);
1279 int ungetmouse(MEVENT *);
1280 bool wenclose(const WINDOW *, int, int);
1281 bool wmouse_trafo(const WINDOW *, int *, int *, bool);
1282
1283 /* PDCurses */
1284
1285 int addrawch(chtype);
1286 int insrawch(chtype);
1287 bool is_termresized(void);
1288 int mvaddrawch(int, int, chtype);
1289 int mvdeleteln(int, int);
1290 int mvinsertln(int, int);
1291 int mvinsrawch(int, int, chtype);
1292 int mvwaddrawch(WINDOW *, int, int, chtype);
1293 int mvwdeleteln(WINDOW *, int, int);
1294 int mvwinsertln(WINDOW *, int, int);
1295 int mvwinsrawch(WINDOW *, int, int, chtype);
1296 int raw_output(bool);
1297 int resize_term(int, int);
1298 WINDOW *resize_window(WINDOW *, int, int);
1299 int waddrawch(WINDOW *, chtype);
1300 int winsrawch(WINDOW *, chtype);
1301 char wordchar(void);
1302
1303 #ifdef PDC_WIDE
1304 wchar_t *slk_wlabel(int);
1305 #endif
1306
1307 void PDC_debug(const char *, ...);
1308 int PDC_ungetch(int);
1309 int PDC_set_blink(bool);
1310 int PDC_set_line_color(short);
1311 void PDC_set_title(const char *);
1312
1313 int PDC_clearclipboard(void);
1314 int PDC_freeclipboard(char *);
1315 int PDC_getclipboard(char **, long *);
1316 int PDC_setclipboard(const char *, long);
1317
1318 unsigned long PDC_get_input_fd(void);
1319 unsigned long PDC_get_key_modifiers(void);
1320 int PDC_return_key_modifiers(bool);
1321 int PDC_save_key_modifiers(bool);
1322
1323 #ifdef XCURSES
1324 WINDOW *Xinitscr(int, char **);
1325 void XCursesExit(void);
1326 int sb_init(void);
1327 int sb_set_horz(int, int, int);
1328 int sb_set_vert(int, int, int);
1329 int sb_get_horz(int *, int *, int *);
1330 int sb_get_vert(int *, int *, int *);
1331 int sb_refresh(void);
1332 #endif
1333
1334 /*** Functions defined as macros ***/
1335
1336 /* getch() and ungetch() conflict with some DOS libraries */
1337
1338 #define getch() wgetch(stdscr)
1339 #define ungetch(ch) PDC_ungetch(ch)
1340
1341 #define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR)
1342 #define PAIR_NUMBER(n) (((n) & A_COLOR) >> PDC_COLOR_SHIFT)
1343
1344 /* These will _only_ work as macros */
1345
1346 #define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w))
1347 #define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w))
1348 #define getparyx(w, y, x) (y = getpary(w), x = getparx(w))
1349 #define getyx(w, y, x) (y = getcury(w), x = getcurx(w))
1350
1351 #define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \
1352 else getyx(curscr,(y),(x)); }
1353
1354 #ifdef NCURSES_MOUSE_VERSION
1355 # define getmouse(x) nc_getmouse(x)
1356 #endif
1357
1358 /* return codes from PDC_getclipboard() and PDC_setclipboard() calls */
1359
1360 #define PDC_CLIP_SUCCESS 0
1361 #define PDC_CLIP_ACCESS_ERROR 1
1362 #define PDC_CLIP_EMPTY 2
1363 #define PDC_CLIP_MEMORY_ERROR 3
1364
1365 /* PDCurses key modifier masks */
1366
1367 #define PDC_KEY_MODIFIER_SHIFT 1
1368 #define PDC_KEY_MODIFIER_CONTROL 2
1369 #define PDC_KEY_MODIFIER_ALT 4
1370 #define PDC_KEY_MODIFIER_NUMLOCK 8
1371
1372 #if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
1373 # undef bool
1374 }
1375 #endif
1376
1377 #endif /* __PDCURSES__ */
File curspriv.h added (mode: 100644) (index 00000000..8b34f010)
1 /* Public Domain Curses */
2
3 /* $Id: curspriv.h,v 1.158 2008/07/13 16:08:16 wmcbrine Exp $ */
4
5 /* Private definitions and declarations for use within PDCurses.
6 These should generally not be referenced by applications. */
7
8 #ifndef __CURSES_INTERNALS__
9 #define __CURSES_INTERNALS__ 1
10
11 #ifdef HAVE_CONFIG_H
12 # include <config.h>
13 #endif
14
15 #define CURSES_LIBRARY
16 #include <curses.h>
17
18 #if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \
19 defined(__CYGWIN32__) || defined(__MINGW32__) || \
20 defined(__WATCOMC__) || defined(__PACIFIC__)
21 # ifndef HAVE_VSSCANF
22 # define HAVE_VSSCANF /* have vsscanf() */
23 # endif
24 #endif
25
26 #if defined(__CYGWIN32__) || defined(__MINGW32__) || \
27 defined(__LCC__) || defined(__WATCOMC__)
28 # ifndef HAVE_VSNPRINTF
29 # define HAVE_VSNPRINTF /* have vsnprintf() */
30 # endif
31 #endif
32
33 #if defined(_MSC_VER) && defined(_WIN32) && !defined(_CRT_SECURE_NO_DEPRECATE)
34 # define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */
35 #endif
36
37 /*----------------------------------------------------------------------*/
38
39 typedef struct /* structure for ripped off lines */
40 {
41 int line;
42 int (*init)(WINDOW *, int);
43 } RIPPEDOFFLINE;
44
45 /* Window properties */
46
47 #define _SUBWIN 0x01 /* window is a subwindow */
48 #define _PAD 0x10 /* X/Open Pad. */
49 #define _SUBPAD 0x20 /* X/Open subpad. */
50
51 /* Miscellaneous */
52
53 #define _NO_CHANGE -1 /* flags line edge unchanged */
54
55 #define _ECHAR 0x08 /* Erase char (^H) */
56 #define _DWCHAR 0x17 /* Delete Word char (^W) */
57 #define _DLCHAR 0x15 /* Delete Line char (^U) */
58
59 extern WINDOW *pdc_lastscr;
60 extern bool pdc_trace_on; /* tracing flag */
61 extern bool pdc_color_started;
62 extern unsigned long pdc_key_modifiers;
63 extern MOUSE_STATUS pdc_mouse_status;
64
65 /*----------------------------------------------------------------------*/
66
67 /* Platform implementation functions */
68
69 void PDC_beep(void);
70 bool PDC_can_change_color(void);
71 int PDC_color_content(short, short *, short *, short *);
72 bool PDC_check_key(void);
73 int PDC_curs_set(int);
74 void PDC_flushinp(void);
75 int PDC_get_columns(void);
76 int PDC_get_cursor_mode(void);
77 int PDC_get_key(void);
78 int PDC_get_rows(void);
79 void PDC_gotoyx(int, int);
80 int PDC_init_color(short, short, short, short);
81 void PDC_init_pair(short, short, short);
82 int PDC_modifiers_set(void);
83 int PDC_mouse_set(void);
84 void PDC_napms(int);
85 int PDC_pair_content(short, short *, short *);
86 void PDC_reset_prog_mode(void);
87 void PDC_reset_shell_mode(void);
88 int PDC_resize_screen(int, int);
89 void PDC_restore_screen_mode(int);
90 void PDC_save_screen_mode(int);
91 void PDC_scr_close(void);
92 void PDC_scr_free(void);
93 int PDC_scr_open(int, char **);
94 void PDC_set_keyboard_binary(bool);
95 void PDC_transform_line(int, int, int, const chtype *);
96 const char *PDC_sysname(void);
97
98 /* Internal cross-module functions */
99
100 void PDC_init_atrtab(void);
101 WINDOW *PDC_makelines(WINDOW *);
102 WINDOW *PDC_makenew(int, int, int, int);
103 int PDC_mouse_in_slk(int, int);
104 void PDC_slk_free(void);
105 void PDC_slk_initialize(void);
106 void PDC_sync(WINDOW *);
107
108 #ifdef PDC_WIDE
109 int PDC_mbtowc(wchar_t *, const char *, size_t);
110 size_t PDC_mbstowcs(wchar_t *, const char *, size_t);
111 size_t PDC_wcstombs(char *, const wchar_t *, size_t);
112 #endif
113
114 #ifdef PDCDEBUG
115 # define PDC_LOG(x) if (pdc_trace_on) PDC_debug x
116 # define RCSID(x) static const char *rcsid = x;
117 #else
118 # define PDC_LOG(x)
119 # define RCSID(x)
120 #endif
121
122 /* Internal macros for attributes */
123
124 #ifdef CHTYPE_LONG
125 # define PDC_COLOR_PAIRS 256
126 #else
127 # define PDC_COLOR_PAIRS 32
128 #endif
129
130 #ifndef max
131 # define max(a,b) (((a) > (b)) ? (a) : (b))
132 #endif
133 #ifndef min
134 # define min(a,b) (((a) < (b)) ? (a) : (b))
135 #endif
136
137 #define DIVROUND(num, divisor) ((num) + ((divisor) >> 1)) / (divisor)
138
139 #define PDC_CLICK_PERIOD 150 /* time to wait for a click, if
140 not set by mouseinterval() */
141
142 #endif /* __CURSES_INTERNALS__*/
File demos/README added (mode: 100644) (index 00000000..8f4b5c6c)
1 PDCurses Demos
2 ==============
3
4 This directory contains demonstration programs to show and test the
5 capabilities of curses libraries. Some of them predate PDCurses,
6 PCcurses or even pcurses/ncurses. Although some PDCurses-specific code
7 has been added, all programs remain portable to other implementations
8 (at a minimum, to ncurses).
9
10
11 Building
12 --------
13
14 The demos are built by the platform-specific makefiles, in the platform
15 directories. Alternatively, you can build them manually, individually,
16 and link with any curses library; e.g., "cc -lcurses -orain rain.c".
17 There are no dependencies besides curses and the standard C library, and
18 no configuration is needed.
19
20
21 Distribution Status
22 -------------------
23
24 Public Domain, except for rain.c and worm.c, which are under the ncurses
25 license (MIT-like).
File demos/firework.c added (mode: 100644) (index 00000000..8d7921f3)
1 /* $Id: firework.c,v 1.25 2008/07/13 16:08:17 wmcbrine Exp $ */
2
3 #include <stdio.h>
4 #include <signal.h>
5 #include <curses.h>
6 #include <ctype.h>
7 #include <stdlib.h>
8 #include <sys/types.h>
9 #include <time.h>
10
11 #define DELAYSIZE 200
12
13 void myrefresh(void);
14 void get_color(void);
15 void explode(int, int);
16
17 short color_table[] =
18 {
19 COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
20 COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE
21 };
22
23 int main(int argc, char **argv)
24 {
25 int i, start, end, row, diff, flag, direction, seed;
26
27 #ifdef XCURSES
28 Xinitscr(argc, argv);
29 #else
30 initscr();
31 #endif
32 nodelay(stdscr, TRUE);
33 noecho();
34
35 if (has_colors())
36 start_color();
37
38 for (i = 0; i < 8; i++)
39 init_pair(i, color_table[i], COLOR_BLACK);
40
41 seed = time((time_t *)0);
42 srand(seed);
43 flag = 0;
44
45 while (getch() == ERR) /* loop until a key is hit */
46 {
47 do {
48 start = rand() % (COLS - 3);
49 end = rand() % (COLS - 3);
50 start = (start < 2) ? 2 : start;
51 end = (end < 2) ? 2 : end;
52 direction = (start > end) ? -1 : 1;
53 diff = abs(start - end);
54
55 } while (diff < 2 || diff >= LINES - 2);
56
57 attrset(A_NORMAL);
58
59 for (row = 0; row < diff; row++)
60 {
61 mvaddstr(LINES - row, row * direction + start,
62 (direction < 0) ? "\\" : "/");
63
64 if (flag++)
65 {
66 myrefresh();
67 erase();
68 flag = 0;
69 }
70 }
71
72 if (flag++)
73 {
74 myrefresh();
75 flag = 0;
76 }
77
78 explode(LINES - row, diff * direction + start);
79 erase();
80 myrefresh();
81 }
82
83 endwin();
84
85 return 0;
86 }
87
88 void explode(int row, int col)
89 {
90 erase();
91 mvaddstr(row, col, "-");
92 myrefresh();
93
94 --col;
95
96 get_color();
97 mvaddstr(row - 1, col, " - ");
98 mvaddstr(row, col, "-+-");
99 mvaddstr(row + 1, col, " - ");
100 myrefresh();
101
102 --col;
103
104 get_color();
105 mvaddstr(row - 2, col, " --- ");
106 mvaddstr(row - 1, col, "-+++-");
107 mvaddstr(row, col, "-+#+-");
108 mvaddstr(row + 1, col, "-+++-");
109 mvaddstr(row + 2, col, " --- ");
110 myrefresh();
111
112 get_color();
113 mvaddstr(row - 2, col, " +++ ");
114 mvaddstr(row - 1, col, "++#++");
115 mvaddstr(row, col, "+# #+");
116 mvaddstr(row + 1, col, "++#++");
117 mvaddstr(row + 2, col, " +++ ");
118 myrefresh();
119
120 get_color();
121 mvaddstr(row - 2, col, " # ");
122 mvaddstr(row - 1, col, "## ##");
123 mvaddstr(row, col, "# #");
124 mvaddstr(row + 1, col, "## ##");
125 mvaddstr(row + 2, col, " # ");
126 myrefresh();
127
128 get_color();
129 mvaddstr(row - 2, col, " # # ");
130 mvaddstr(row - 1, col, "# #");
131 mvaddstr(row, col, " ");
132 mvaddstr(row + 1, col, "# #");
133 mvaddstr(row + 2, col, " # # ");
134 myrefresh();
135 }
136
137 void myrefresh(void)
138 {
139 napms(DELAYSIZE);
140 move(LINES - 1, COLS - 1);
141 refresh();
142 }
143
144 void get_color(void)
145 {
146 chtype bold = (rand() % 2) ? A_BOLD : A_NORMAL;
147 attrset(COLOR_PAIR(rand() % 8) | bold);
148 }
File demos/newdemo.c added (mode: 100644) (index 00000000..3eae98d4)
1 /*
2 * newdemo.c - A demo program using PDCurses. The program
3 * illustrates the use of colors for text output.
4 *
5 * Hacks by jbuhler@cs.washington.edu on 12/29/96
6 *
7 * $Id: newdemo.c,v 1.39 2008/07/13 16:08:17 wmcbrine Exp $
8 */
9
10 #include <stdio.h>
11 #include <signal.h>
12 #include <string.h>
13 #include <curses.h>
14 #include <stdlib.h>
15 #include <time.h>
16
17 int WaitForUser(void);
18 int SubWinTest(WINDOW *);
19 int BouncingBalls(WINDOW *);
20 void trap(int);
21
22 /* An ASCII map of Australia */
23
24 char *AusMap[17] =
25 {
26 " A ",
27 " AA AA ",
28 " N.T. AAAAA AAAA ",
29 " AAAAAAAAAAA AAAAAAAA ",
30 " AAAAAAAAAAAAAAAAAAAAAAAAA Qld.",
31 " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
32 " AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
33 " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
34 " AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.",
35 "W.A. AAAAAAAAA AAAAAA Vic.",
36 " AAA S.A. AA",
37 " A Tas.",
38 ""
39 };
40
41 /* Funny messages for the scroller */
42
43 char *messages[] =
44 {
45 "Hello from the Land Down Under",
46 "The Land of crocs, and a big Red Rock",
47 "Where the sunflower runs along the highways",
48 "The dusty red roads lead one to loneliness",
49 "Blue sky in the morning and",
50 "Freezing nights and twinkling stars",
51 NULL
52 };
53
54 int WaitForUser(void)
55 {
56 chtype ch;
57
58 nodelay(stdscr, TRUE);
59 halfdelay(50);
60
61 ch = getch();
62
63 nodelay(stdscr, FALSE);
64 nocbreak(); /* Reset the halfdelay() value */
65 cbreak();
66
67 return (ch == '\033') ? ch : 0;
68 }
69
70 int SubWinTest(WINDOW *win)
71 {
72 WINDOW *swin1, *swin2, *swin3;
73 int w, h, sw, sh, bx, by;
74
75 wattrset(win, 0);
76 getmaxyx(win, h, w);
77 getbegyx(win, by, bx);
78
79 sw = w / 3;
80 sh = h / 3;
81
82 if ((swin1 = derwin(win, sh, sw, 3, 5)) == NULL)
83 return 1;
84 if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL)
85 return 1;
86 if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL)
87 return 1;
88
89 init_pair(8, COLOR_RED, COLOR_BLUE);
90 wbkgd(swin1, COLOR_PAIR(8));
91 werase(swin1);
92 mvwaddstr(swin1, 0, 3, "Sub-window 1");
93 wrefresh(swin1);
94
95 init_pair(9, COLOR_CYAN, COLOR_MAGENTA);
96 wbkgd(swin2, COLOR_PAIR(9));
97 werase(swin2);
98 mvwaddstr(swin2, 0, 3, "Sub-window 2");
99 wrefresh(swin2);
100
101 init_pair(10, COLOR_YELLOW, COLOR_GREEN);
102 wbkgd(swin3, COLOR_PAIR(10));
103 werase(swin3);
104 mvwaddstr(swin3, 0, 3, "Sub-window 3");
105 wrefresh(swin3);
106
107 delwin(swin1);
108 delwin(swin2);
109 delwin(swin3);
110 WaitForUser();
111
112 return 0;
113 }
114
115 int BouncingBalls(WINDOW *win)
116 {
117 chtype c1, c2, c3, ball1, ball2, ball3;
118 int w, h, x1, y1, xd1, yd1, x2, y2, xd2, yd2, x3, y3, xd3, yd3, c;
119
120 curs_set(0);
121
122 wbkgd(win, COLOR_PAIR(1));
123 wrefresh(win);
124 wattrset(win, 0);
125
126 init_pair(11, COLOR_RED, COLOR_GREEN);
127 init_pair(12, COLOR_BLUE, COLOR_RED);
128 init_pair(13, COLOR_YELLOW, COLOR_WHITE);
129
130 ball1 = 'O' | COLOR_PAIR(11);
131 ball2 = '*' | COLOR_PAIR(12);
132 ball3 = '@' | COLOR_PAIR(13);
133
134 getmaxyx(win, h, w);
135
136 x1 = 2 + rand() % (w - 4);
137 y1 = 2 + rand() % (h - 4);
138 x2 = 2 + rand() % (w - 4);
139 y2 = 2 + rand() % (h - 4);
140 x3 = 2 + rand() % (w - 4);
141 y3 = 2 + rand() % (h - 4);
142
143 xd1 = 1;
144 yd1 = 1;
145 xd2 = 1;
146 yd2 = -1;
147 xd3 = -1;
148 yd3 = 1;
149
150 nodelay(stdscr, TRUE);
151
152 while ((c = getch()) == ERR)
153 {
154 x1 += xd1;
155 if (x1 <= 1 || x1 >= w - 2)
156 xd1 *= -1;
157
158 y1 += yd1;
159 if (y1 <= 1 || y1 >= h - 2)
160 yd1 *= -1;
161
162 x2 += xd2;
163 if (x2 <= 1 || x2 >= w - 2)
164 xd2 *= -1;
165
166 y2 += yd2;
167 if (y2 <= 1 || y2 >= h - 2)
168 yd2 *= -1;
169
170 x3 += xd3;
171 if (x3 <= 1 || x3 >= w - 2)
172 xd3 *= -1;
173
174 y3 += yd3;
175 if (y3 <= 1 || y3 >= h - 2)
176 yd3 *= -1;
177
178 c1 = mvwinch(win, y1, x1);
179 c2 = mvwinch(win, y2, x2);
180 c3 = mvwinch(win, y3, x3);
181
182 mvwaddch(win, y1, x1, ball1);
183 mvwaddch(win, y2, x2, ball2);
184 mvwaddch(win, y3, x3, ball3);
185
186 wmove(win, 0, 0);
187 wrefresh(win);
188
189 mvwaddch(win, y1, x1, c1);
190 mvwaddch(win, y2, x2, c2);
191 mvwaddch(win, y3, x3, c3);
192
193 napms(150);
194 }
195
196 nodelay(stdscr, FALSE);
197 ungetch(c);
198 return 0;
199 }
200
201 /* Trap interrupt */
202
203 void trap(int sig)
204 {
205 if (sig == SIGINT)
206 {
207 endwin();
208
209 exit(0);
210 }
211 }
212
213 int main(int argc, char **argv)
214 {
215 WINDOW *win;
216 chtype save[80], ch;
217 int width, height, w, x, y, i, j, seed;
218
219 #ifdef XCURSES
220 Xinitscr(argc, argv);
221 #else
222 initscr();
223 #endif
224 seed = time((time_t *)0);
225 srand(seed);
226
227 start_color();
228 # if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
229 use_default_colors();
230 # endif
231 cbreak();
232 noecho();
233
234 curs_set(0);
235
236 #if !defined(__TURBOC__) && !defined(OS2)
237 signal(SIGINT, trap);
238 #endif
239 noecho();
240
241 /* refresh stdscr so that reading from it will not cause it to
242 overwrite the other windows that are being created */
243
244 refresh();
245
246 /* Create a drawing window */
247
248 width = 48;
249 height = 15;
250
251 win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
252
253 if (win == NULL)
254 {
255 endwin();
256
257 return 1;
258 }
259
260 for (;;)
261 {
262 init_pair(1, COLOR_WHITE, COLOR_BLUE);
263 wbkgd(win, COLOR_PAIR(1));
264 werase(win);
265
266 init_pair(2, COLOR_RED, COLOR_RED);
267 wattrset(win, COLOR_PAIR(2));
268 box(win, ' ', ' ');
269 wrefresh(win);
270
271 wattrset(win, 0);
272
273 /* Do random output of a character */
274
275 ch = 'a';
276
277 nodelay(stdscr, TRUE);
278
279 for (i = 0; i < 5000; ++i)
280 {
281 x = rand() % (width - 2) + 1;
282 y = rand() % (height - 2) + 1;
283
284 mvwaddch(win, y, x, ch);
285 wrefresh(win);
286
287 if (getch() != ERR)
288 break;
289
290 if (i == 2000)
291 {
292 ch = 'b';
293 init_pair(3, COLOR_CYAN, COLOR_YELLOW);
294 wattrset(win, COLOR_PAIR(3));
295 }
296 }
297
298 nodelay(stdscr, FALSE);
299
300 SubWinTest(win);
301
302 /* Erase and draw green window */
303
304 init_pair(4, COLOR_YELLOW, COLOR_GREEN);
305 wbkgd(win, COLOR_PAIR(4));
306 wattrset(win, A_BOLD);
307 werase(win);
308 wrefresh(win);
309
310 /* Draw RED bounding box */
311
312 wattrset(win, COLOR_PAIR(2));
313 box(win, ' ', ' ');
314 wrefresh(win);
315
316 /* Display Australia map */
317
318 wattrset(win, A_BOLD);
319 i = 0;
320
321 while (*AusMap[i])
322 {
323 mvwaddstr(win, i + 1, 8, AusMap[i]);
324 wrefresh(win);
325 napms(100);
326 ++i;
327 }
328
329 init_pair(5, COLOR_BLUE, COLOR_WHITE);
330 wattrset(win, COLOR_PAIR(5) | A_BLINK);
331 mvwaddstr(win, height - 2, 3,
332 " PDCurses 3.4 - DOS, OS/2, Win32, X11, SDL");
333 wrefresh(win);
334
335 /* Draw running messages */
336
337 init_pair(6, COLOR_BLACK, COLOR_WHITE);
338 wattrset(win, COLOR_PAIR(6));
339 w = width - 2;
340 nodelay(win, TRUE);
341
342 /* jbuhler's re-hacked scrolling messages */
343
344 for (j = 0; messages[j] != NULL; j++)
345 {
346 char *message = messages[j];
347 int msg_len = strlen(message);
348 int scroll_len = w + 2 * msg_len;
349 char *scrollbuf = malloc(scroll_len);
350 char *visbuf = scrollbuf + msg_len;
351 int stop = 0;
352 int i;
353
354 for (i = w + msg_len; i > 0; i--)
355 {
356 memset(visbuf, ' ', w);
357 strncpy(scrollbuf + i, message, msg_len);
358 mvwaddnstr(win, height / 2, 1, visbuf, w);
359 wrefresh(win);
360
361 if (wgetch(win) != ERR)
362 {
363 flushinp();
364 stop = 1;
365 break;
366 }
367
368 napms(100);
369 }
370
371 free(scrollbuf);
372
373 if (stop)
374 break;
375 }
376
377 j = 0;
378
379 /* Draw running 'A's across in RED */
380
381 init_pair(7, COLOR_RED, COLOR_GREEN);
382 wattron(win, COLOR_PAIR(7));
383
384 for (i = 2; i < width - 4; ++i)
385 {
386 ch = mvwinch(win, 5, i);
387 save[j++] = ch;
388 ch = ch & 0x7f;
389 mvwaddch(win, 5, i, ch);
390 }
391
392 wrefresh(win);
393
394 /* Put a message up; wait for a key */
395
396 i = height - 2;
397 wattrset(win, COLOR_PAIR(5));
398 mvwaddstr(win, i, 3,
399 " Type a key to continue or ESC to quit ");
400 wrefresh(win);
401
402 if (WaitForUser() == '\033')
403 break;
404
405 /* Restore the old line */
406
407 wattrset(win, 0);
408
409 for (i = 2, j = 0; i < width - 4; ++i)
410 mvwaddch(win, 5, i, save[j++]);
411
412 wrefresh(win);
413
414 BouncingBalls(win);
415
416 /* BouncingBalls() leaves a keystroke in the queue */
417
418 if (WaitForUser() == '\033')
419 break;
420 }
421
422 endwin();
423
424 return 0;
425 }
File demos/ptest.c added (mode: 100644) (index 00000000..1134f6ff)
1 /* $Id: ptest.c,v 1.24 2008/07/13 16:08:17 wmcbrine Exp $ */
2
3 #include <curses.h>
4 #include <panel.h>
5 #include <stdlib.h>
6
7 PANEL *p1, *p2, *p3, *p4, *p5;
8 WINDOW *w4, *w5;
9
10 long nap_msec = 1;
11
12 char *mod[] =
13 {
14 "test ", "TEST ", "(**) ", "*()* ", "<--> ", "LAST "
15 };
16
17 void pflush(void)
18 {
19 update_panels();
20 doupdate();
21 }
22
23 void backfill(void)
24 {
25 int y, x;
26
27 erase();
28
29 for (y = 0; y < LINES - 1; y++)
30 for (x = 0; x < COLS; x++)
31 printw("%d", (y + x) % 10);
32 }
33
34 void wait_a_while(long msec)
35 {
36 int c;
37
38 if (msec != 1)
39 timeout(msec);
40
41 c = getch();
42
43 if (c == 'q')
44 {
45 endwin();
46 exit(1);
47 }
48 }
49
50 void saywhat(const char *text)
51 {
52 mvprintw(LINES - 1, 0, "%-20.20s", text);
53 }
54
55 /* mkpanel - alloc a win and panel and associate them */
56
57 PANEL *mkpanel(int rows, int cols, int tly, int tlx)
58 {
59 WINDOW *win = newwin(rows, cols, tly, tlx);
60 PANEL *pan = (PANEL *)0;
61
62 if (win)
63 {
64 pan = new_panel(win);
65
66 if (!pan)
67 delwin(win);
68 }
69
70 return pan;
71 }
72
73 void rmpanel(PANEL *pan)
74 {
75 WINDOW *win = pan->win;
76
77 del_panel(pan);
78 delwin(win);
79 }
80
81 void fill_panel(PANEL *pan)
82 {
83 WINDOW *win = pan->win;
84 char num = *((char *)pan->user + 1);
85 int y, x, maxy, maxx;
86
87 box(win, 0, 0);
88 mvwprintw(win, 1, 1, "-pan%c-", num);
89 getmaxyx(win, maxy, maxx);
90
91 for (y = 2; y < maxy - 1; y++)
92 for (x = 1; x < maxx - 1; x++)
93 mvwaddch(win, y, x, num);
94 }
95
96 int main(int argc, char **argv)
97 {
98 int itmp, y;
99
100 if (argc > 1 && atol(argv[1]))
101 nap_msec = atol(argv[1]);
102
103 #ifdef XCURSES
104 Xinitscr(argc, argv);
105 #else
106 initscr();
107 #endif
108 backfill();
109
110 for (y = 0; y < 5; y++)
111 {
112 p1 = mkpanel(10, 10, 0, 0);
113 set_panel_userptr(p1, "p1");
114
115 p2 = mkpanel(14, 14, 5, 5);
116 set_panel_userptr(p2, "p2");
117
118 p3 = mkpanel(6, 8, 12, 12);
119 set_panel_userptr(p3, "p3");
120
121 p4 = mkpanel(10, 10, 10, 30);
122 w4 = panel_window(p4);
123 set_panel_userptr(p4, "p4");
124
125 p5 = mkpanel(10, 10, 13, 37);
126 w5 = panel_window(p5);
127 set_panel_userptr(p5, "p5");
128
129 fill_panel(p1);
130 fill_panel(p2);
131 fill_panel(p3);
132 fill_panel(p4);
133 fill_panel(p5);
134 hide_panel(p4);
135 hide_panel(p5);
136 pflush();
137 wait_a_while(nap_msec);
138
139 saywhat("h3 s1 s2 s4 s5;");
140 move_panel(p1, 0, 0);
141 hide_panel(p3);
142 show_panel(p1);
143 show_panel(p2);
144 show_panel(p4);
145 show_panel(p5);
146 pflush();
147 wait_a_while(nap_msec);
148
149 saywhat("s1;");
150 show_panel(p1);
151 pflush();
152 wait_a_while(nap_msec);
153
154 saywhat("s2;");
155 show_panel(p2);
156 pflush();
157 wait_a_while(nap_msec);
158
159 saywhat("m2;");
160 move_panel(p2, 10, 10);
161 pflush();
162 wait_a_while(nap_msec);
163
164 saywhat("s3;");
165 show_panel(p3);
166 pflush();
167 wait_a_while(nap_msec);
168
169 saywhat("m3;");
170 move_panel(p3, 5, 5);
171 pflush();
172 wait_a_while(nap_msec);
173
174 saywhat("b3;");
175 bottom_panel(p3);
176 pflush();
177 wait_a_while(nap_msec);
178
179 saywhat("s4;");
180 show_panel(p4);
181 pflush();
182 wait_a_while(nap_msec);
183
184 saywhat("s5;");
185 show_panel(p5);
186 pflush();
187 wait_a_while(nap_msec);
188
189 saywhat("t3;");
190 top_panel(p3);
191 pflush();
192 wait_a_while(nap_msec);
193
194 saywhat("t1;");
195 top_panel(p1);
196 pflush();
197 wait_a_while(nap_msec);
198
199 saywhat("t2;");
200 top_panel(p2);
201 pflush();
202 wait_a_while(nap_msec);
203
204 saywhat("t3;");
205 top_panel(p3);
206 pflush();
207 wait_a_while(nap_msec);
208
209 saywhat("t4;");
210 top_panel(p4);
211 pflush();
212 wait_a_while(nap_msec);
213
214 for (itmp = 0; itmp < 6; itmp++)
215 {
216 saywhat("m4;");
217 mvwaddstr(w4, 3, 1, mod[itmp]);
218 move_panel(p4, 4, itmp * 10);
219 mvwaddstr(w5, 4, 1, mod[itmp]);
220 pflush();
221 wait_a_while(nap_msec);
222
223 saywhat("m5;");
224 mvwaddstr(w4, 4, 1, mod[itmp]);
225 move_panel(p5, 7, itmp * 10 + 6);
226 mvwaddstr(w5, 3, 1, mod[itmp]);
227 pflush();
228 wait_a_while(nap_msec);
229 }
230
231 saywhat("m4;");
232 move_panel(p4, 4, itmp * 10);
233 pflush();
234 wait_a_while(nap_msec);
235
236 saywhat("t5;");
237 top_panel(p5);
238 pflush();
239 wait_a_while(nap_msec);
240
241 saywhat("t2;");
242 top_panel(p2);
243 pflush();
244 wait_a_while(nap_msec);
245
246 saywhat("t1;");
247 top_panel(p1);
248 pflush();
249 wait_a_while(nap_msec);
250
251 saywhat("d2;");
252 rmpanel(p2);
253 pflush();
254 wait_a_while(nap_msec);
255
256 saywhat("h3;");
257 hide_panel(p3);
258 pflush();
259 wait_a_while(nap_msec);
260
261 saywhat("d1;");
262 rmpanel(p1);
263 pflush();
264 wait_a_while(nap_msec);
265
266 saywhat("d4; ");
267 rmpanel(p4);
268 pflush();
269 wait_a_while(nap_msec);
270
271 saywhat("d5; ");
272 rmpanel(p5);
273 pflush();
274 wait_a_while(nap_msec);
275
276 if (nap_msec == 1)
277 break;
278
279 nap_msec = 100L;
280 }
281
282 endwin();
283
284 return 0;
285 } /* end of main */
File demos/rain.c added (mode: 100644) (index 00000000..51d05a90)
1 /****************************************************************************
2 * Copyright (c) 2002 Free Software Foundation, Inc. *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
28
29 /* $Id: rain.c,v 1.11 2008/07/13 16:08:17 wmcbrine Exp $ */
30
31 #include <curses.h>
32 #include <stdlib.h>
33 #include <time.h>
34
35 /* rain 11/3/1980 EPS/CITHEP */
36
37 static int next_j(int j)
38 {
39 if (j == 0)
40 j = 4;
41 else
42 --j;
43
44 if (has_colors())
45 {
46 int z = rand() % 3;
47 chtype color = COLOR_PAIR(z);
48
49 if (z)
50 color |= A_BOLD;
51
52 attrset(color);
53 }
54
55 return j;
56 }
57
58 int main(int argc, char *argv[])
59 {
60 int x, y, j, r, c, seed;
61 static int xpos[5], ypos[5];
62
63 #ifdef XCURSES
64 Xinitscr(argc, argv);
65 #else
66 initscr();
67 #endif
68 seed = time((time_t *)0);
69 srand(seed);
70
71 if (has_colors())
72 {
73 int bg = COLOR_BLACK;
74
75 start_color();
76
77 #if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
78 if (use_default_colors() == OK)
79 bg = -1;
80 #endif
81 init_pair(1, COLOR_BLUE, bg);
82 init_pair(2, COLOR_CYAN, bg);
83 }
84
85 nl();
86 noecho();
87 curs_set(0);
88 timeout(0);
89 keypad(stdscr, TRUE);
90
91 r = LINES - 4;
92 c = COLS - 4;
93
94 for (j = 5; --j >= 0;)
95 {
96 xpos[j] = rand() % c + 2;
97 ypos[j] = rand() % r + 2;
98 }
99
100 for (j = 0;;)
101 {
102 x = rand() % c + 2;
103 y = rand() % r + 2;
104
105 mvaddch(y, x, '.');
106
107 mvaddch(ypos[j], xpos[j], 'o');
108
109 j = next_j(j);
110 mvaddch(ypos[j], xpos[j], 'O');
111
112 j = next_j(j);
113 mvaddch(ypos[j] - 1, xpos[j], '-');
114 mvaddstr(ypos[j], xpos[j] - 1, "|.|");
115 mvaddch(ypos[j] + 1, xpos[j], '-');
116
117 j = next_j(j);
118 mvaddch(ypos[j] - 2, xpos[j], '-');
119 mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\");
120 mvaddstr(ypos[j], xpos[j] - 2, "| O |");
121 mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /");
122 mvaddch(ypos[j] + 2, xpos[j], '-');
123
124 j = next_j(j);
125 mvaddch(ypos[j] - 2, xpos[j], ' ');
126 mvaddstr(ypos[j] - 1, xpos[j] - 1, " ");
127 mvaddstr(ypos[j], xpos[j] - 2, " ");
128 mvaddstr(ypos[j] + 1, xpos[j] - 1, " ");
129 mvaddch(ypos[j] + 2, xpos[j], ' ');
130
131 xpos[j] = x;
132 ypos[j] = y;
133
134 switch (getch())
135 {
136 case 'q':
137 case 'Q':
138 curs_set(1);
139 endwin();
140 return EXIT_SUCCESS;
141 case 's':
142 nodelay(stdscr, FALSE);
143 break;
144 case ' ':
145 nodelay(stdscr, TRUE);
146 #ifdef KEY_RESIZE
147 break;
148 case KEY_RESIZE:
149 # ifdef PDCURSES
150 resize_term(0, 0);
151 erase();
152 # endif
153 r = LINES - 4;
154 c = COLS - 4;
155 #endif
156 }
157 napms(50);
158 }
159 }
File demos/testcurs.c added (mode: 100644) (index 00000000..5b330f55)
1 /*
2 * This is a test program for PDCurses. Originally by
3 * John Burnell <johnb@kea.am.dsir.govt.nz>
4 *
5 * wrs(5/28/93) -- modified to be consistent (perform identically)
6 * with either PDCurses or under Unix System V, R4
7 *
8 * $Id: testcurs.c,v 1.85 2008/07/14 12:35:23 wmcbrine Exp $
9 */
10
11 #ifndef _XOPEN_SOURCE_EXTENDED
12 # define _XOPEN_SOURCE_EXTENDED 1
13 #endif
14
15 #include <stdio.h>
16 #include <ctype.h>
17 #include <string.h>
18 #include <curses.h>
19
20 #ifdef WACS_S1
21 # define HAVE_WIDE 1
22 #else
23 # define HAVE_WIDE 0
24 #endif
25
26 #include <locale.h>
27
28 #if HAVE_WIDE
29 # include <wchar.h>
30 #endif
31
32 #if defined(PDCURSES) && !defined(XCURSES)
33 # define HAVE_RESIZE 1
34 #else
35 # define HAVE_RESIZE 0
36 #endif
37
38 #ifdef A_COLOR
39 # define HAVE_COLOR 1
40 #else
41 # define HAVE_COLOR 0
42 #endif
43
44 /* Set to non-zero if you want to test the PDCurses clipboard */
45
46 #define HAVE_CLIPBOARD 0
47
48 void inputTest(WINDOW *);
49 void scrollTest(WINDOW *);
50 void introTest(WINDOW *);
51 int initTest(WINDOW **, int, char **);
52 void outputTest(WINDOW *);
53 void padTest(WINDOW *);
54 void acsTest(WINDOW *);
55
56 #if HAVE_COLOR
57 void colorTest(WINDOW *);
58 #endif
59
60 #if HAVE_RESIZE
61 void resizeTest(WINDOW *);
62 #endif
63
64 #if HAVE_CLIPBOARD
65 void clipboardTest(WINDOW *);
66 #endif
67
68 #if HAVE_WIDE
69 void wideTest(WINDOW *);
70 #endif
71
72 void display_menu(int, int);
73
74 struct commands
75 {
76 const char *text;
77 void (*function)(WINDOW *);
78 };
79
80 typedef struct commands COMMAND;
81
82 #define MAX_OPTIONS (6 + HAVE_COLOR + HAVE_RESIZE + HAVE_CLIPBOARD + HAVE_WIDE)
83
84 COMMAND command[MAX_OPTIONS] =
85 {
86 {"Intro Test", introTest},
87 {"Pad Test", padTest},
88 #if HAVE_RESIZE
89 {"Resize Test", resizeTest},
90 #endif
91 {"Scroll Test", scrollTest},
92 {"Input Test", inputTest},
93 {"Output Test", outputTest},
94 {"ACS Test", acsTest},
95 #if HAVE_COLOR
96 {"Color Test", colorTest},
97 #endif
98 #if HAVE_CLIPBOARD
99 {"Clipboard Test", clipboardTest},
100 #endif
101 #if HAVE_WIDE
102 {"Wide Input", wideTest}
103 #endif
104 };
105
106 int width, height;
107
108 int main(int argc, char *argv[])
109 {
110 WINDOW *win;
111 int key, old_option = -1, new_option = 0;
112 bool quit = FALSE;
113
114 setlocale(LC_ALL, "");
115
116 if (initTest(&win, argc, argv))
117 return 1;
118
119 #ifdef A_COLOR
120 if (has_colors())
121 {
122 init_pair(1, COLOR_WHITE, COLOR_BLUE);
123 wbkgd(win, COLOR_PAIR(1));
124 }
125 else
126 #endif
127 wbkgd(win, A_REVERSE);
128
129 erase();
130 display_menu(old_option, new_option);
131
132 while (1)
133 {
134 noecho();
135 keypad(stdscr, TRUE);
136 raw();
137
138 key = getch();
139
140 switch(key)
141 {
142 case 10:
143 case 13:
144 case KEY_ENTER:
145 old_option = -1;
146 erase();
147 refresh();
148 (*command[new_option].function)(win);
149 erase();
150 display_menu(old_option, new_option);
151 break;
152
153 case KEY_PPAGE:
154 case KEY_HOME:
155 old_option = new_option;
156 new_option = 0;
157 display_menu(old_option, new_option);
158 break;
159
160 case KEY_NPAGE:
161 case KEY_END:
162 old_option = new_option;
163 new_option = MAX_OPTIONS - 1;
164 display_menu(old_option, new_option);
165 break;
166
167 case KEY_UP:
168 old_option = new_option;
169 new_option = (new_option == 0) ?
170 new_option : new_option - 1;
171 display_menu(old_option, new_option);
172 break;
173
174 case KEY_DOWN:
175 old_option = new_option;
176 new_option = (new_option == MAX_OPTIONS - 1) ?
177 new_option : new_option + 1;
178 display_menu(old_option, new_option);
179 break;
180 #ifdef KEY_RESIZE
181 case KEY_RESIZE:
182 # ifdef PDCURSES
183 resize_term(0, 0);
184 # endif
185 old_option = -1;
186 erase();
187 display_menu(old_option, new_option);
188 break;
189 #endif
190 case 'Q':
191 case 'q':
192 quit = TRUE;
193 }
194
195 if (quit == TRUE)
196 break;
197 }
198
199 delwin(win);
200 endwin();
201
202 return 0;
203 }
204
205 void Continue(WINDOW *win)
206 {
207 mvwaddstr(win, 10, 1, " Press any key to continue");
208 wrefresh(win);
209 raw();
210 wgetch(win);
211 }
212
213 void Continue2(void)
214 {
215 move(LINES - 1, 1);
216 clrtoeol();
217 mvaddstr(LINES - 2, 1, " Press any key to continue");
218 refresh();
219 raw();
220 getch();
221 }
222
223 int initTest(WINDOW **win, int argc, char *argv[])
224 {
225 #ifdef XCURSES
226 Xinitscr(argc, argv);
227 #else
228 initscr();
229 #endif
230 #ifdef A_COLOR
231 if (has_colors())
232 start_color();
233 #endif
234 /* Create a drawing window */
235
236 width = 60;
237 height = 13;
238
239 *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
240
241 if (*win == NULL)
242 {
243 endwin();
244 return 1;
245 }
246
247 return 0;
248 }
249
250 void introTest(WINDOW *win)
251 {
252 werase(win);
253 wmove(win, height / 2 - 5, width / 2);
254 wvline(win, ACS_VLINE, 10);
255 wmove(win, height / 2, width / 2 - 10);
256 whline(win, ACS_HLINE, 20);
257 Continue(win);
258
259 beep();
260 werase(win);
261
262 box(win, ACS_VLINE, ACS_HLINE);
263 wrefresh(win);
264
265 cbreak();
266 mvwaddstr(win, 1, 1,
267 "You should have a rectangle in the middle of the screen");
268 mvwaddstr(win, 2, 1, "You should have heard a beep");
269 Continue(win);
270
271 flash();
272 mvwaddstr(win, 3, 1, "You should have seen a flash");
273 Continue(win);
274 }
275
276 void scrollTest(WINDOW *win)
277 {
278 int i, OldY;
279 #ifndef PDCURSES
280 int OldX;
281 #endif
282 werase(win);
283 mvwaddstr(win, height - 2, 1, "The window will now scroll slowly");
284 box(win, ACS_VLINE, ACS_HLINE);
285 wrefresh(win);
286 scrollok(win, TRUE);
287 napms(500);
288
289 for (i = 1; i <= height; i++)
290 {
291 napms(150);
292 scroll(win);
293 wrefresh(win);
294 };
295
296 #ifdef PDCURSES
297 OldY = getmaxy(win);
298 #else
299 getmaxyx(win, OldY, OldX);
300 #endif
301 mvwaddstr(win, 6, 1, "The top of the window will scroll");
302 wmove(win, 1, 1);
303 wsetscrreg(win, 0, 4);
304 box(win, ACS_VLINE, ACS_HLINE);
305 wrefresh(win);
306
307 for (i = 1; i <= 5; i++)
308 {
309 napms(500);
310 scroll(win);
311 wrefresh(win);
312 }
313
314 mvwaddstr(win, 3, 1, "The bottom of the window will scroll");
315 wmove(win, 8, 1);
316 wsetscrreg(win, 5, --OldY);
317 box(win, ACS_VLINE, ACS_HLINE);
318 wrefresh(win);
319
320 for (i = 5; i <= OldY; i++)
321 {
322 napms(300);
323 wscrl(win, -1);
324 wrefresh(win);
325 }
326
327 wsetscrreg(win, 0, OldY);
328 }
329
330 void inputTest(WINDOW *win)
331 {
332 int w, h, bx, by, sw, sh, i, c, num = 0;
333 char buffer[80];
334 WINDOW *subWin;
335 static const char spinner[4] = "/-\\|";
336 int spinner_count = 0;
337
338 wclear(win);
339
340 getmaxyx(win, h, w);
341 getbegyx(win, by, bx);
342
343 sw = w / 3;
344 sh = h / 3;
345
346 if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2))
347 == NULL)
348 return;
349
350 #ifdef A_COLOR
351 if (has_colors())
352 {
353 init_pair(2, COLOR_WHITE, COLOR_RED);
354 wbkgd(subWin, COLOR_PAIR(2) | A_BOLD);
355 }
356 else
357 #endif
358 wbkgd(subWin, A_BOLD);
359
360 box(subWin, ACS_VLINE, ACS_HLINE);
361 wrefresh(win);
362
363 nocbreak();
364
365 wclear (win);
366 mvwaddstr(win, 1, 1,
367 "Press keys (or mouse buttons) to show their names");
368 mvwaddstr(win, 2, 1, "Press spacebar to finish");
369 wrefresh(win);
370
371 keypad(win, TRUE);
372 raw();
373 noecho();
374
375 wtimeout(win, 200);
376
377 #ifdef PDCURSES
378 mouse_set(ALL_MOUSE_EVENTS);
379 PDC_save_key_modifiers(TRUE);
380 PDC_return_key_modifiers(TRUE);
381 #endif
382 curs_set(0); /* turn cursor off */
383
384 while (1)
385 {
386 while (1)
387 {
388 c = wgetch(win);
389
390 if (c == ERR)
391 {
392 spinner_count++;
393 if (spinner_count == 4)
394 spinner_count = 0;
395 mvwaddch(win, 3, 3, spinner[spinner_count]);
396 wrefresh(win);
397 }
398 else
399 break;
400 }
401 #ifdef PDCURSES
402 wmove(win, 4, 18);
403 wclrtoeol(win);
404 #endif
405 mvwaddstr(win, 3, 5, "Key Pressed: ");
406 wclrtoeol(win);
407
408 if (c >= KEY_MIN)
409 wprintw(win, "%s", keyname(c));
410 else if (isprint(c))
411 wprintw(win, "%c", c);
412 else
413 wprintw(win, "%s", unctrl(c));
414 #ifdef PDCURSES
415 if (c == KEY_MOUSE)
416 {
417 int button = 0;
418 request_mouse_pos();
419
420 if (BUTTON_CHANGED(1))
421 button = 1;
422 else if (BUTTON_CHANGED(2))
423 button = 2;
424 else if (BUTTON_CHANGED(3))
425 button = 3;
426
427 if (button && (BUTTON_STATUS(button) &
428 BUTTON_MODIFIER_MASK))
429 {
430 waddstr(win, " Modifier(s):");
431
432 if (BUTTON_STATUS(button) & BUTTON_SHIFT)
433 waddstr(win, " SHIFT");
434
435 if (BUTTON_STATUS(button) & BUTTON_CONTROL)
436 waddstr(win, " CONTROL");
437
438 if (BUTTON_STATUS(button) & BUTTON_ALT)
439 waddstr(win, " ALT");
440 }
441
442 wmove(win, 4, 18);
443 wclrtoeol(win);
444 wprintw(win, "Button %d: ", button);
445
446 if (MOUSE_MOVED)
447 waddstr(win, "moved: ");
448 else if (MOUSE_WHEEL_UP)
449 waddstr(win, "wheel up: ");
450 else if (MOUSE_WHEEL_DOWN)
451 waddstr(win, "wheel dn: ");
452 else if ((BUTTON_STATUS(button) &
453 BUTTON_ACTION_MASK) == BUTTON_PRESSED)
454 waddstr(win, "pressed: ");
455 else if ((BUTTON_STATUS(button) &
456 BUTTON_ACTION_MASK) == BUTTON_CLICKED)
457 waddstr(win, "clicked: ");
458 else if ((BUTTON_STATUS(button) &
459 BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)
460 waddstr(win, "double: ");
461 else
462 waddstr(win, "released: ");
463
464 wprintw(win, "Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
465 }
466 else if (PDC_get_key_modifiers())
467 {
468 waddstr(win, " Modifier(s):");
469 if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_SHIFT)
470 waddstr(win, " SHIFT");
471
472 if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_CONTROL)
473 waddstr(win, " CONTROL");
474
475 if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_ALT)
476 waddstr(win, " ALT");
477
478 if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_NUMLOCK)
479 waddstr(win, " NUMLOCK");
480 }
481 #endif
482 wrefresh(win);
483
484 if (c == ' ')
485 break;
486 }
487
488 wtimeout(win, -1); /* turn off timeout() */
489 curs_set(1); /* turn cursor back on */
490
491 #ifdef PDCURSES
492 mouse_set(0L);
493 PDC_save_key_modifiers(FALSE);
494 PDC_return_key_modifiers(FALSE);
495 #endif
496 wclear(win);
497 mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
498 mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
499 wrefresh(win);
500
501 werase(subWin);
502 box(subWin, ACS_VLINE, ACS_HLINE);
503
504 for (i = 0; i < 5; i++)
505 {
506 mvwprintw(subWin, 1, 1, "Time = %d", i);
507 wrefresh(subWin);
508 napms(1000);
509 flushinp();
510 }
511
512 delwin(subWin);
513 werase(win);
514 flash();
515 wrefresh(win);
516 napms(500);
517 flushinp();
518
519 mvwaddstr(win, 2, 1, "Press a key, followed by ENTER");
520 wmove(win, 9, 10);
521 wrefresh(win);
522 echo();
523
524 keypad(win, TRUE);
525 raw();
526 wgetnstr(win, buffer, 3);
527 flushinp();
528
529 wmove(win, 9, 10);
530 wdelch(win);
531 mvwaddstr(win, 4, 1, "The character should now have been deleted");
532 Continue(win);
533
534 refresh();
535 wclear(win);
536 echo();
537 buffer[0] = '\0';
538 mvwaddstr(win, 3, 2, "The window should have moved");
539 mvwaddstr(win, 4, 2,
540 "This text should have appeared without you pressing a key");
541 mvwaddstr(win, 6, 2, "Enter a number then a string seperated by space");
542 mvwin(win, 2, 1);
543 wrefresh(win);
544 mvwscanw(win, 7, 6, "%d %s", &num, buffer);
545 mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
546 Continue(win);
547
548 refresh();
549 wclear(win);
550 echo();
551 mvwaddstr(win, 3, 2, "Enter a 5 character string: ");
552 wgetnstr(win, buffer, 5);
553 mvwprintw(win, 4, 2, "String: %s", buffer);
554 Continue(win);
555 }
556
557 void outputTest(WINDOW *win)
558 {
559 WINDOW *win1;
560 char Buffer[80];
561 chtype ch;
562 int by, bx;
563
564 nl();
565 wclear(win);
566 mvwaddstr(win, 1, 1, "You should now have a screen in the upper "
567 "left corner, and this text should have wrapped");
568 waddstr(win,"\nThis text should be down\n");
569 waddstr(win, "and broken into two here ^");
570 Continue(win);
571
572 wclear(win);
573 wattron(win, A_BOLD);
574 mvwaddstr(win, 1, 1, "A new window will appear with this text in it");
575 mvwaddstr(win, 8, 1, "Press any key to continue");
576 wrefresh(win);
577 wgetch(win);
578
579 getbegyx(win, by, bx);
580
581 if (LINES < 24 || COLS < 75)
582 {
583 mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a");
584 mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
585 Continue(win);
586 }
587 else
588 {
589 win1 = newwin(10, 50, 14, 25);
590
591 if (win1 == NULL)
592 {
593 endwin();
594 return;
595 }
596
597 #ifdef A_COLOR
598 if (has_colors())
599 {
600 init_pair(3, COLOR_BLUE, COLOR_WHITE);
601 wbkgd(win1, COLOR_PAIR(3));
602 }
603 else
604 #endif
605 wbkgd(win1, A_NORMAL);
606
607 wclear(win1);
608 mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
609 copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
610 box(win1, ACS_VLINE, ACS_HLINE);
611 wmove(win1, 8, 26);
612 wrefresh(win1);
613 wgetch(win1);
614
615 wclear(win1);
616
617 wattron(win1, A_BLINK);
618 mvwaddstr(win1, 4, 1,
619 "This blinking text should appear in only the second window");
620 wattroff(win1, A_BLINK);
621
622 mvwin(win1, by, bx);
623 overlay(win, win1);
624 mvwin(win1, 14, 25);
625 wmove(win1, 8, 26);
626 wrefresh(win1);
627 wgetch(win1);
628
629 delwin(win1);
630 }
631
632 clear();
633 wclear(win);
634 wrefresh(win);
635 mvwaddstr(win, 6, 2, "This line shouldn't appear");
636 mvwaddstr(win, 4, 2, "Only half of the next line is visible");
637 mvwaddstr(win, 5, 2, "Only half of the next line is visible");
638 wmove(win, 6, 1);
639 wclrtobot(win);
640 wmove(win, 5, 20);
641 wclrtoeol(win);
642 mvwaddstr(win, 8, 2, "This line also shouldn't appear");
643 wmove(win, 8, 1);
644 winsdelln(win, -1);
645 Continue(win);
646
647 wmove(win, 5, 9);
648 ch = winch(win);
649
650 wclear(win);
651 wmove(win, 6, 2);
652 waddstr(win, "The next char should be l: ");
653 winsch(win, ch);
654 Continue(win);
655
656 mvwinsstr(win, 6, 2, "A1B2C3D4E5");
657 Continue(win);
658
659 wmove(win, 5, 1);
660 winsdelln(win, 1);
661 mvwaddstr(win, 5, 2, "The lines below should have moved down");
662 Continue(win);
663
664 wclear(win);
665 wmove(win, 2, 2);
666 wprintw(win, "This is a formatted string in a window: %d %s\n",
667 42, "is it");
668 mvwaddstr(win, 10, 1, "Enter a string: ");
669 wrefresh(win);
670 echo();
671 wscanw(win, "%s", Buffer);
672
673 printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
674 mvaddstr(10, 1, "Enter a string: ");
675 scanw("%s", Buffer);
676
677 wclear(win);
678 curs_set(2);
679 mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode");
680 Continue(win);
681
682 wclear(win);
683 curs_set(0);
684 mvwaddstr(win, 1, 1, "The cursor should have disappeared");
685 Continue(win);
686
687 wclear(win);
688 curs_set(1);
689 mvwaddstr(win, 1, 1, "The cursor should be normal");
690 Continue(win);
691
692 #ifdef A_COLOR
693 if (has_colors())
694 {
695 wclear(win);
696 mvwaddstr(win, 1, 1, "Colors should change after you press a key");
697 Continue(win);
698
699 init_pair(1, COLOR_RED, COLOR_WHITE);
700 wrefresh(win);
701 }
702 #endif
703 werase(win);
704 mvwaddstr(win, 1, 1, "Information About Your Terminal");
705 mvwaddstr(win, 3, 1, termname());
706 mvwaddstr(win, 4, 1, longname());
707
708 if (termattrs() & A_BLINK)
709 mvwaddstr(win, 5, 1, "This terminal claims to support blinking.");
710 else
711 mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");
712
713 mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
714 wrefresh(win);
715
716 mvwinnstr(win, 7, 5, Buffer, 18);
717 mvaddstr(LINES - 2, 10, Buffer);
718 refresh();
719 Continue(win);
720 }
721
722 #if HAVE_RESIZE
723 void resizeTest(WINDOW *dummy)
724 {
725 WINDOW *win1;
726 int nwidth = 135, nheight = 52;
727 int owidth = COLS, oheight = LINES;
728
729 savetty();
730
731 resize_term(nheight, nwidth);
732
733 clear();
734 refresh();
735
736 win1 = newwin(10, 50, 14, 25);
737
738 if (win1 == NULL)
739 {
740 endwin();
741 return;
742 }
743
744 #ifdef A_COLOR
745 if (has_colors())
746 {
747 init_pair(3, COLOR_BLUE, COLOR_WHITE);
748 wattrset(win1, COLOR_PAIR(3));
749 }
750
751 wclear(win1);
752 #endif
753 mvwaddstr(win1, 0, 0, "The screen may now be resized");
754 mvwprintw(win1, 1, 4, "Given size: %d by %d", nwidth, nheight);
755 mvwprintw(win1, 2, 4, "Actual size: %d by %d", COLS, LINES);
756 Continue(win1);
757
758 wclear(win1);
759 resetty();
760
761 mvwaddstr(win1, 0, 0, "The screen should now be reset");
762 mvwprintw(win1, 1, 6, "Old size: %d by %d", owidth, oheight);
763 mvwprintw(win1, 2, 6, "Size now: %d by %d", COLS, LINES);
764 Continue(win1);
765
766 delwin(win1);
767
768 clear();
769 refresh();
770 }
771 #endif /* HAVE_RESIZE */
772
773 void padTest(WINDOW *dummy)
774 {
775 WINDOW *pad, *spad;
776
777 pad = newpad(50, 100);
778 wattron(pad, A_REVERSE);
779 mvwaddstr(pad, 5, 2, "This is a new pad");
780 wattrset(pad, 0);
781 mvwaddstr(pad, 8, 0,
782 "The end of this line should be truncated here:except now");
783 mvwaddstr(pad, 11, 1, "This line should not appear.It will now");
784 wmove(pad, 10, 1);
785 wclrtoeol(pad);
786 mvwaddstr(pad, 10, 1, " Press any key to continue");
787 prefresh(pad, 0, 0, 0, 0, 10, 45);
788 keypad(pad, TRUE);
789 raw();
790 wgetch(pad);
791
792 spad = subpad(pad, 12, 25, 7, 52);
793 mvwaddstr(spad, 2, 2, "This is a new subpad");
794 box(spad, 0, 0);
795 prefresh(pad, 0, 0, 0, 0, 15, 75);
796 keypad(pad, TRUE);
797 raw();
798 wgetch(pad);
799
800 mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");
801 mvwaddstr(pad, 40, 1, " Press any key to continue");
802 prefresh(pad, 30, 0, 0, 0, 10, 45);
803 keypad(pad, TRUE);
804 raw();
805 wgetch(pad);
806
807 delwin(pad);
808 }
809
810 #if HAVE_CLIPBOARD
811 void clipboardTest(WINDOW *win)
812 {
813 static const char *text =
814 "This string placed in clipboard by PDCurses test program, testcurs.";
815 char *ptr = NULL;
816 long i, length = 0;
817
818 mvaddstr(1, 1,
819 "This test will display the contents of the system clipboard");
820
821 Continue2();
822
823 scrollok(stdscr, TRUE);
824 i = PDC_getclipboard(&ptr, &length);
825
826 switch(i)
827 {
828 case PDC_CLIP_ACCESS_ERROR:
829 mvaddstr(3, 1, "There was an error accessing the clipboard");
830 refresh();
831 break;
832
833 case PDC_CLIP_MEMORY_ERROR:
834 mvaddstr(3, 1,
835 "Unable to allocate memory for clipboard contents");
836 break;
837
838 case PDC_CLIP_EMPTY:
839 mvaddstr(3, 1, "There was no text in the clipboard");
840 break;
841
842 default:
843 wsetscrreg(stdscr, 0, LINES - 1);
844 clear();
845 mvaddstr(1, 1, "Clipboard contents...");
846 mvprintw(2, 1, "%s\n", ptr);
847 }
848
849 Continue2();
850
851 clear();
852 mvaddstr(1, 1,
853 "This test will place the following string in the system clipboard:");
854 mvaddstr(2, 1, text);
855
856 i = PDC_setclipboard(text, strlen(text));
857
858 switch(i)
859 {
860 case PDC_CLIP_ACCESS_ERROR:
861 mvaddstr(3, 1, "There was an error accessing the clipboard");
862 break;
863
864 case PDC_CLIP_MEMORY_ERROR:
865 mvaddstr(3, 1, "Unable to allocate memory for clipboard contents");
866 break;
867
868 default:
869 mvaddstr(3, 1, "The string was placed in the clipboard successfully");
870 }
871
872 Continue2();
873 }
874 #endif /* HAVE_CLIPBOARD */
875
876 void acsTest(WINDOW *win)
877 {
878 #ifdef ACS_S3
879 # define ACSNUM 32
880 #else
881 # define ACSNUM 25
882 #endif
883 static const char *acs_names[] =
884 {
885 "ACS_ULCORNER", "ACS_URCORNER", "ACS_LLCORNER", "ACS_LRCORNER",
886 "ACS_LTEE", "ACS_RTEE", "ACS_TTEE", "ACS_BTEE", "ACS_HLINE",
887 "ACS_VLINE", "ACS_PLUS",
888
889 "ACS_S1", "ACS_S9", "ACS_DIAMOND", "ACS_CKBOARD", "ACS_DEGREE",
890 "ACS_PLMINUS", "ACS_BULLET",
891
892 "ACS_LARROW", "ACS_RARROW", "ACS_UARROW", "ACS_DARROW",
893 "ACS_BOARD", "ACS_LANTERN", "ACS_BLOCK"
894 #ifdef ACS_S3
895 , "ACS_S3", "ACS_S7", "ACS_LEQUAL", "ACS_GEQUAL",
896 "ACS_PI", "ACS_NEQUAL", "ACS_STERLING"
897 #endif
898 };
899
900 chtype acs_values[ACSNUM];
901
902 #if HAVE_WIDE
903 cchar_t *wacs_values[] =
904 {
905 WACS_ULCORNER, WACS_URCORNER, WACS_LLCORNER, WACS_LRCORNER,
906 WACS_LTEE, WACS_RTEE, WACS_TTEE, WACS_BTEE, WACS_HLINE,
907 WACS_VLINE, WACS_PLUS,
908
909 WACS_S1, WACS_S9, WACS_DIAMOND, WACS_CKBOARD, WACS_DEGREE,
910 WACS_PLMINUS, WACS_BULLET,
911
912 WACS_LARROW, WACS_RARROW, WACS_UARROW, WACS_DARROW, WACS_BOARD,
913 WACS_LANTERN, WACS_BLOCK
914 # ifdef WACS_S3
915 , WACS_S3, WACS_S7, WACS_LEQUAL, WACS_GEQUAL, WACS_PI,
916 WACS_NEQUAL, WACS_STERLING
917 # endif
918 };
919
920 static const wchar_t russian[] = {0x0420, 0x0443, 0x0441, 0x0441,
921 0x043a, 0x0438, 0x0439, L' ', 0x044f, 0x0437, 0x044b, 0x043a, 0};
922
923 static const wchar_t greek[] = {0x0395, 0x03bb, 0x03bb, 0x03b7,
924 0x03bd, 0x03b9, 0x03ba, 0x03ac, 0};
925
926 static const wchar_t georgian[] = {0x10e5, 0x10d0, 0x10e0, 0x10d7,
927 0x10e3, 0x10da, 0x10d8, L' ', 0x10d4, 0x10dc, 0x10d0, 0};
928 #endif
929
930 int i, tmarg = (LINES - 22) / 2;
931
932 attrset(A_BOLD);
933 mvaddstr(tmarg, (COLS - 23) / 2, "Alternate Character Set");
934 attrset(A_NORMAL);
935
936 tmarg += 3;
937
938 #define A(b,c) acs_values[b] = ACS_##c
939
940 A(0,ULCORNER); A(1,URCORNER); A(2,LLCORNER); A(3,LRCORNER);
941 A(4,LTEE); A(5,RTEE); A(6,TTEE); A(7,BTEE);
942 A(8,HLINE); A(9,VLINE); A(10,PLUS); A(11,S1);
943 A(12,S9); A(13,DIAMOND); A(14,CKBOARD); A(15,DEGREE);
944
945 A(16,PLMINUS); A(17,BULLET); A(18,LARROW); A(19,RARROW);
946 A(20,UARROW); A(21,DARROW); A(22,BOARD); A(23,LANTERN);
947 A(24,BLOCK);
948 #ifdef ACS_S3
949 A(25,S3); A(26,S7); A(27,LEQUAL); A(28,GEQUAL);
950 A(29,PI); A(30,NEQUAL); A(31,STERLING);
951 #endif
952
953 #undef A
954
955 for (i = 0; i < ACSNUM; i++)
956 {
957 move((i % 8) * 2 + tmarg, (i / 8) * (COLS / 4) + (COLS / 8 - 7));
958 addch(acs_values[i]);
959 printw(" %s", acs_names[i]);
960 }
961
962 mvaddstr(tmarg + 18, 3, "Press any key to continue");
963 getch();
964
965 #if HAVE_WIDE
966 clear();
967
968 attrset(A_BOLD);
969 mvaddstr(tmarg - 3, (COLS - 28) / 2, "Wide Alternate Character Set");
970 attrset(A_NORMAL);
971
972 for (i = 0; i < ACSNUM; i++)
973 {
974 move((i % 8) * 2 + tmarg, (i / 8) * (COLS / 4) + (COLS / 8 - 7));
975 add_wch(wacs_values[i]);
976 printw(" W%s", acs_names[i]);
977 }
978
979 /* Spanish, Russian, Greek, Georgian */
980
981 mvaddwstr(tmarg + 16, COLS / 8 - 5, L"Espa\xf1ol");
982 mvaddwstr(tmarg + 16, 3 * (COLS / 8) - 5, russian);
983 mvaddwstr(tmarg + 16, 5 * (COLS / 8) - 5, greek);
984 mvaddwstr(tmarg + 16, 7 * (COLS / 8) - 5, georgian);
985
986 mvaddstr(tmarg + 18, 3, "Press any key to continue");
987 getch();
988 #endif
989 }
990
991 #if HAVE_COLOR
992 void colorTest(WINDOW *win)
993 {
994 static const short colors[] =
995 {
996 COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE,
997 COLOR_CYAN, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE
998 };
999
1000 static const char *colornames[] =
1001 {
1002 "COLOR_BLACK", "COLOR_RED", "COLOR_GREEN", "COLOR_BLUE",
1003 "COLOR_CYAN", "COLOR_MAGENTA", "COLOR_YELLOW", "COLOR_WHITE"
1004 };
1005
1006 chtype fill = ACS_BLOCK;
1007
1008 int i, j, tmarg, col1, col2, col3;
1009
1010 if (!has_colors())
1011 return;
1012
1013 tmarg = (LINES - 19) / 2;
1014 col1 = (COLS - 60) / 2;
1015 col2 = col1 + 20;
1016 col3 = col2 + 20;
1017
1018 attrset(A_BOLD);
1019 mvaddstr(tmarg, (COLS - 22) / 2, "Color Attribute Macros");
1020 attrset(A_NORMAL);
1021
1022 mvaddstr(tmarg + 3, col2 + 4, "A_NORMAL");
1023 mvaddstr(tmarg + 3, col3 + 5, "A_BOLD");
1024
1025 for (i = 0; i < 8; i++)
1026 {
1027 init_pair(i + 4, colors[i], COLOR_BLACK);
1028
1029 mvaddstr(tmarg + i + 5, col1, colornames[i]);
1030
1031 for (j = 0; j < 16; j++)
1032 {
1033 mvaddch(tmarg + i + 5, col2 + j, fill | COLOR_PAIR(i + 4));
1034 mvaddch(tmarg + i + 5, col3 + j, fill | COLOR_PAIR(i + 4) | A_BOLD);
1035 }
1036 }
1037
1038 mvprintw(tmarg + 15, col1, "COLORS = %d", COLORS);
1039 mvprintw(tmarg + 16, col1, "COLOR_PAIRS = %d", COLOR_PAIRS);
1040
1041 mvaddstr(tmarg + 19, 3, "Press any key to continue");
1042 getch();
1043
1044 if (can_change_color())
1045 {
1046 struct
1047 {
1048 short red, green, blue;
1049 } orgcolors[16];
1050
1051 int MAXCOL = (COLORS >= 16) ? 16 : 8;
1052
1053 if (MAXCOL < 8)
1054 return;
1055
1056 for (i = 0; i < MAXCOL; i++)
1057 color_content(i, &(orgcolors[i].red),
1058 &(orgcolors[i].green),
1059 &(orgcolors[i].blue));
1060
1061 attrset(A_BOLD);
1062 mvaddstr(tmarg, (COLS - 22) / 2, " init_color() Example ");
1063 attrset(A_NORMAL);
1064
1065 refresh();
1066
1067 for (i = 0; i < 8; i++)
1068 {
1069 init_color(colors[i], i * 125, 0, i * 125);
1070
1071 if (MAXCOL == 16)
1072 init_color(colors[i] + 8, 0, i * 125, 0);
1073 }
1074
1075 mvaddstr(tmarg + 19, 3, "Press any key to continue");
1076 getch();
1077
1078 for (i = 0; i < MAXCOL; i++)
1079 init_color(i, orgcolors[i].red,
1080 orgcolors[i].green,
1081 orgcolors[i].blue);
1082 }
1083 }
1084 #endif
1085
1086 #if HAVE_WIDE
1087 void wideTest(WINDOW *win)
1088 {
1089 wchar_t tmp[513];
1090 size_t i;
1091
1092 attrset(A_BOLD);
1093 mvaddstr(1, (COLS - 25) / 2, "Wide Character Input Test");
1094 attrset(A_NORMAL);
1095
1096 mvaddstr(4, 1, "Enter a string: ");
1097
1098 echo();
1099
1100 get_wstr((wint_t *)tmp);
1101 addstr("\n\n String:\n\n ");
1102 addwstr(tmp);
1103 addstr("\n\n\n Hex:\n\n ");
1104
1105 for (i = 0; i < wcslen(tmp); i++)
1106 {
1107 printw("%04x ", tmp[i]);
1108 addnwstr(tmp + i, 1);
1109 addstr(" ");
1110 }
1111
1112 noecho();
1113
1114 Continue2();
1115 }
1116 #endif
1117
1118 void display_menu(int old_option, int new_option)
1119 {
1120 int lmarg = (COLS - 14) / 2,
1121 tmarg = (LINES - (MAX_OPTIONS + 2)) / 2;
1122
1123 if (old_option == -1)
1124 {
1125 int i;
1126
1127 attrset(A_BOLD);
1128 mvaddstr(tmarg - 3, lmarg - 5, "PDCurses Test Program");
1129 attrset(A_NORMAL);
1130
1131 for (i = 0; i < MAX_OPTIONS; i++)
1132 mvaddstr(tmarg + i, lmarg, command[i].text);
1133 }
1134 else
1135 mvaddstr(tmarg + old_option, lmarg, command[old_option].text);
1136
1137 attrset(A_REVERSE);
1138 mvaddstr(tmarg + new_option, lmarg, command[new_option].text);
1139 attrset(A_NORMAL);
1140
1141 mvaddstr(tmarg + MAX_OPTIONS + 2, lmarg - 23,
1142 "Use Up and Down Arrows to select - Enter to run - Q to quit");
1143 refresh();
1144 }
File demos/tui.c added (mode: 100644) (index 00000000..e57a1b09)
1 /********************************* tui.c ************************************/
2 /*
3 * 'textual user interface'
4 *
5 * $Id: tui.c,v 1.34 2008/07/14 12:35:23 wmcbrine Exp $
6 *
7 * Author : P.J. Kunst <kunst@prl.philips.nl>
8 * Date : 25-02-93
9 */
10
11 #include <ctype.h>
12 #include <curses.h>
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <time.h>
17 #include "tui.h"
18
19 void statusmsg(char *);
20 int waitforkey(void);
21 void rmerror(void);
22
23 #if defined(__unix) && !defined(__DJGPP__)
24 #include <unistd.h>
25 #endif
26
27 #ifdef A_COLOR
28 # define TITLECOLOR 1 /* color pair indices */
29 # define MAINMENUCOLOR (2 | A_BOLD)
30 # define MAINMENUREVCOLOR (3 | A_BOLD | A_REVERSE)
31 # define SUBMENUCOLOR (4 | A_BOLD)
32 # define SUBMENUREVCOLOR (5 | A_BOLD | A_REVERSE)
33 # define BODYCOLOR 6
34 # define STATUSCOLOR (7 | A_BOLD)
35 # define INPUTBOXCOLOR 8
36 # define EDITBOXCOLOR (9 | A_BOLD | A_REVERSE)
37 #else
38 # define TITLECOLOR 0 /* color pair indices */
39 # define MAINMENUCOLOR (A_BOLD)
40 # define MAINMENUREVCOLOR (A_BOLD | A_REVERSE)
41 # define SUBMENUCOLOR (A_BOLD)
42 # define SUBMENUREVCOLOR (A_BOLD | A_REVERSE)
43 # define BODYCOLOR 0
44 # define STATUSCOLOR (A_BOLD)
45 # define INPUTBOXCOLOR 0
46 # define EDITBOXCOLOR (A_BOLD | A_REVERSE)
47 #endif
48
49
50 #define th 1 /* title window height */
51 #define mh 1 /* main menu height */
52 #define sh 2 /* status window height */
53 #define bh (LINES - th - mh - sh) /* body window height */
54 #define bw COLS /* body window width */
55
56
57 /******************************* STATIC ************************************/
58
59 static WINDOW *wtitl, *wmain, *wbody, *wstat; /* title, menu, body, status win*/
60 static int nexty, nextx;
61 static int key = ERR, ch = ERR;
62 static bool quit = FALSE;
63 static bool incurses = FALSE;
64
65 #ifndef PDCURSES
66 static char wordchar(void)
67 {
68 return 0x17; /* ^W */
69 }
70 #endif
71
72 static char *padstr(char *s, int length)
73 {
74 static char buf[MAXSTRLEN];
75 char fmt[10];
76
77 sprintf(fmt, (int)strlen(s) > length ? "%%.%ds" : "%%-%ds", length);
78 sprintf(buf, fmt, s);
79
80 return buf;
81 }
82
83 static char *prepad(char *s, int length)
84 {
85 int i;
86 char *p = s;
87
88 if (length > 0)
89 {
90 memmove((void *)(s + length), (const void *)s, strlen(s) + 1);
91
92 for (i = 0; i < length; i++)
93 *p++ = ' ';
94 }
95
96 return s;
97 }
98
99 static void rmline(WINDOW *win, int nr) /* keeps box lines intact */
100 {
101 mvwaddstr(win, nr, 1, padstr(" ", bw - 2));
102 wrefresh(win);
103 }
104
105 static void initcolor(void)
106 {
107 #ifdef A_COLOR
108 if (has_colors())
109 start_color();
110
111 /* foreground, background */
112
113 init_pair(TITLECOLOR & ~A_ATTR, COLOR_BLACK, COLOR_CYAN);
114 init_pair(MAINMENUCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
115 init_pair(MAINMENUREVCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
116 init_pair(SUBMENUCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
117 init_pair(SUBMENUREVCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
118 init_pair(BODYCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLUE);
119 init_pair(STATUSCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
120 init_pair(INPUTBOXCOLOR & ~A_ATTR, COLOR_BLACK, COLOR_CYAN);
121 init_pair(EDITBOXCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
122 #endif
123 }
124
125 static void setcolor(WINDOW *win, chtype color)
126 {
127 chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */
128
129 #ifdef A_COLOR
130 attr &= ~A_REVERSE; /* ignore reverse, use colors instead! */
131 wattrset(win, COLOR_PAIR(color & A_CHARTEXT) | attr);
132 #else
133 attr &= ~A_BOLD; /* ignore bold, gives messy display on HP-UX */
134 wattrset(win, attr);
135 #endif
136 }
137
138 static void colorbox(WINDOW *win, chtype color, int hasbox)
139 {
140 int maxy;
141 #ifndef PDCURSES
142 int maxx;
143 #endif
144 chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */
145
146 setcolor(win, color);
147
148 #ifdef A_COLOR
149 if (has_colors())
150 wbkgd(win, COLOR_PAIR(color & A_CHARTEXT) | (attr & ~A_REVERSE));
151 else
152 #endif
153 wbkgd(win, attr);
154
155 werase(win);
156
157 #ifdef PDCURSES
158 maxy = getmaxy(win);
159 #else
160 getmaxyx(win, maxy, maxx);
161 #endif
162 if (hasbox && (maxy > 2))
163 box(win, 0, 0);
164
165 touchwin(win);
166 wrefresh(win);
167 }
168
169 static void idle(void)
170 {
171 char buf[MAXSTRLEN];
172 time_t t;
173 struct tm *tp;
174
175 if (time (&t) == -1)
176 return; /* time not available */
177
178 tp = localtime(&t);
179 sprintf(buf, " %.2d-%.2d-%.4d %.2d:%.2d:%.2d",
180 tp->tm_mday, tp->tm_mon + 1, tp->tm_year + 1900,
181 tp->tm_hour, tp->tm_min, tp->tm_sec);
182
183 mvwaddstr(wtitl, 0, bw - strlen(buf) - 2, buf);
184 wrefresh(wtitl);
185 }
186
187 static void menudim(menu *mp, int *lines, int *columns)
188 {
189 int n, l, mmax = 0;
190
191 for (n=0; mp->func; n++, mp++)
192 if ((l = strlen(mp->name)) > mmax) mmax = l;
193
194 *lines = n;
195 *columns = mmax + 2;
196 }
197
198 static void setmenupos(int y, int x)
199 {
200 nexty = y;
201 nextx = x;
202 }
203
204 static void getmenupos(int *y, int *x)
205 {
206 *y = nexty;
207 *x = nextx;
208 }
209
210 static int hotkey(const char *s)
211 {
212 int c0 = *s; /* if no upper case found, return first char */
213
214 for (; *s; s++)
215 if (isupper((unsigned char)*s))
216 break;
217
218 return *s ? *s : c0;
219 }
220
221 static void repaintmenu(WINDOW *wmenu, menu *mp)
222 {
223 int i;
224 menu *p = mp;
225
226 for (i = 0; p->func; i++, p++)
227 mvwaddstr(wmenu, i + 1, 2, p->name);
228
229 touchwin(wmenu);
230 wrefresh(wmenu);
231 }
232
233 static void repaintmainmenu(int width, menu *mp)
234 {
235 int i;
236 menu *p = mp;
237
238 for (i = 0; p->func; i++, p++)
239 mvwaddstr(wmain, 0, i * width, prepad(padstr(p->name, width - 1), 1));
240
241 touchwin(wmain);
242 wrefresh(wmain);
243 }
244
245 static void mainhelp(void)
246 {
247 #ifdef ALT_X
248 statusmsg("Use arrow keys and Enter to select (Alt-X to quit)");
249 #else
250 statusmsg("Use arrow keys and Enter to select");
251 #endif
252 }
253
254 static void mainmenu(menu *mp)
255 {
256 int nitems, barlen, old = -1, cur = 0, c, cur0;
257
258 menudim(mp, &nitems, &barlen);
259 repaintmainmenu(barlen, mp);
260
261 while (!quit)
262 {
263 if (cur != old)
264 {
265 if (old != -1)
266 {
267 mvwaddstr(wmain, 0, old * barlen,
268 prepad(padstr(mp[old].name, barlen - 1), 1));
269
270 statusmsg(mp[cur].desc);
271 }
272 else
273 mainhelp();
274
275 setcolor(wmain, MAINMENUREVCOLOR);
276
277 mvwaddstr(wmain, 0, cur * barlen,
278 prepad(padstr(mp[cur].name, barlen - 1), 1));
279
280 setcolor(wmain, MAINMENUCOLOR);
281 old = cur;
282 wrefresh(wmain);
283 }
284
285 switch (c = (key != ERR ? key : waitforkey()))
286 {
287 case KEY_DOWN:
288 case '\n': /* menu item selected */
289 touchwin(wbody);
290 wrefresh(wbody);
291 rmerror();
292 setmenupos(th + mh, cur * barlen);
293 curs_set(1);
294 (mp[cur].func)(); /* perform function */
295 curs_set(0);
296
297 switch (key)
298 {
299 case KEY_LEFT:
300 cur = (cur + nitems - 1) % nitems;
301 key = '\n';
302 break;
303
304 case KEY_RIGHT:
305 cur = (cur + 1) % nitems;
306 key = '\n';
307 break;
308
309 default:
310 key = ERR;
311 }
312
313 repaintmainmenu(barlen, mp);
314 old = -1;
315 break;
316
317 case KEY_LEFT:
318 cur = (cur + nitems - 1) % nitems;
319 break;
320
321 case KEY_RIGHT:
322 cur = (cur + 1) % nitems;
323 break;
324
325 case KEY_ESC:
326 mainhelp();
327 break;
328
329 default:
330 cur0 = cur;
331
332 do
333 {
334 cur = (cur + 1) % nitems;
335
336 } while ((cur != cur0) && (hotkey(mp[cur].name) != toupper(c)));
337
338 if (hotkey(mp[cur].name) == toupper(c))
339 key = '\n';
340 }
341
342 }
343
344 rmerror();
345 touchwin(wbody);
346 wrefresh(wbody);
347 }
348
349 static void cleanup(void) /* cleanup curses settings */
350 {
351 if (incurses)
352 {
353 delwin(wtitl);
354 delwin(wmain);
355 delwin(wbody);
356 delwin(wstat);
357 curs_set(1);
358 endwin();
359 incurses = FALSE;
360 }
361 }
362
363
364 /******************************* EXTERNAL **********************************/
365
366 void clsbody(void)
367 {
368 werase(wbody);
369 wmove(wbody, 0, 0);
370 }
371
372 int bodylen(void)
373 {
374 #ifdef PDCURSES
375 return getmaxy(wbody);
376 #else
377 int maxy, maxx;
378
379 getmaxyx(wbody, maxy, maxx);
380 return maxy;
381 #endif
382 }
383
384 WINDOW *bodywin(void)
385 {
386 return wbody;
387 }
388
389 void rmerror(void)
390 {
391 rmline(wstat, 0);
392 }
393
394 void rmstatus(void)
395 {
396 rmline(wstat, 1);
397 }
398
399 void titlemsg(char *msg)
400 {
401 mvwaddstr(wtitl, 0, 2, padstr(msg, bw - 3));
402 wrefresh(wtitl);
403 }
404
405 void bodymsg(char *msg)
406 {
407 waddstr(wbody, msg);
408 wrefresh(wbody);
409 }
410
411 void errormsg(char *msg)
412 {
413 beep();
414 mvwaddstr(wstat, 0, 2, padstr(msg, bw - 3));
415 wrefresh(wstat);
416 }
417
418 void statusmsg(char *msg)
419 {
420 mvwaddstr(wstat, 1, 2, padstr(msg, bw - 3));
421 wrefresh(wstat);
422 }
423
424 bool keypressed(void)
425 {
426 ch = wgetch(wbody);
427
428 return ch != ERR;
429 }
430
431 int getkey(void)
432 {
433 int c = ch;
434
435 ch = ERR;
436 #ifdef ALT_X
437 quit = (c == ALT_X); /* PC only ! */
438 #endif
439 return c;
440 }
441
442 int waitforkey(void)
443 {
444 do idle(); while (!keypressed());
445 return getkey();
446 }
447
448 void DoExit(void) /* terminate program */
449 {
450 quit = TRUE;
451 }
452
453 void domenu(menu *mp)
454 {
455 int y, x, nitems, barlen, mheight, mw, old = -1, cur = 0, cur0;
456 bool stop = FALSE;
457 WINDOW *wmenu;
458
459 curs_set(0);
460 getmenupos(&y, &x);
461 menudim(mp, &nitems, &barlen);
462 mheight = nitems + 2;
463 mw = barlen + 2;
464 wmenu = newwin(mheight, mw, y, x);
465 colorbox(wmenu, SUBMENUCOLOR, 1);
466 repaintmenu(wmenu, mp);
467
468 key = ERR;
469
470 while (!stop && !quit)
471 {
472 if (cur != old)
473 {
474 if (old != -1)
475 mvwaddstr(wmenu, old + 1, 1,
476 prepad(padstr(mp[old].name, barlen - 1), 1));
477
478 setcolor(wmenu, SUBMENUREVCOLOR);
479 mvwaddstr(wmenu, cur + 1, 1,
480 prepad(padstr(mp[cur].name, barlen - 1), 1));
481
482 setcolor(wmenu, SUBMENUCOLOR);
483 statusmsg(mp[cur].desc);
484
485 old = cur;
486 wrefresh(wmenu);
487 }
488
489 switch (key = ((key != ERR) ? key : waitforkey()))
490 {
491 case '\n': /* menu item selected */
492 touchwin(wbody);
493 wrefresh(wbody);
494 setmenupos(y + 1, x + 1);
495 rmerror();
496
497 key = ERR;
498 curs_set(1);
499 (mp[cur].func)(); /* perform function */
500 curs_set(0);
501
502 repaintmenu(wmenu, mp);
503
504 old = -1;
505 break;
506
507 case KEY_UP:
508 cur = (cur + nitems - 1) % nitems;
509 key = ERR;
510 break;
511
512 case KEY_DOWN:
513 cur = (cur + 1) % nitems;
514 key = ERR;
515 break;
516
517 case KEY_ESC:
518 case KEY_LEFT:
519 case KEY_RIGHT:
520 if (key == KEY_ESC)
521 key = ERR; /* return to prev submenu */
522
523 stop = TRUE;
524 break;
525
526 default:
527 cur0 = cur;
528
529 do
530 {
531 cur = (cur + 1) % nitems;
532
533 } while ((cur != cur0) &&
534 (hotkey(mp[cur].name) != toupper((int)key)));
535
536 key = (hotkey(mp[cur].name) == toupper((int)key)) ? '\n' : ERR;
537 }
538
539 }
540
541 rmerror();
542 delwin(wmenu);
543 touchwin(wbody);
544 wrefresh(wbody);
545 }
546
547 void startmenu(menu *mp, char *mtitle)
548 {
549 initscr();
550 incurses = TRUE;
551 initcolor();
552
553 wtitl = subwin(stdscr, th, bw, 0, 0);
554 wmain = subwin(stdscr, mh, bw, th, 0);
555 wbody = subwin(stdscr, bh, bw, th + mh, 0);
556 wstat = subwin(stdscr, sh, bw, th + mh + bh, 0);
557
558 colorbox(wtitl, TITLECOLOR, 0);
559 colorbox(wmain, MAINMENUCOLOR, 0);
560 colorbox(wbody, BODYCOLOR, 0);
561 colorbox(wstat, STATUSCOLOR, 0);
562
563 if (mtitle)
564 titlemsg(mtitle);
565
566 cbreak(); /* direct input (no newline required)... */
567 noecho(); /* ... without echoing */
568 curs_set(0); /* hide cursor (if possible) */
569 nodelay(wbody, TRUE); /* don't wait for input... */
570 halfdelay(10); /* ...well, no more than a second, anyway */
571 keypad(wbody, TRUE); /* enable cursor keys */
572 scrollok(wbody, TRUE); /* enable scrolling in main window */
573
574 leaveok(stdscr, TRUE);
575 leaveok(wtitl, TRUE);
576 leaveok(wmain, TRUE);
577 leaveok(wstat, TRUE);
578
579 mainmenu(mp);
580
581 cleanup();
582 }
583
584 static void repainteditbox(WINDOW *win, int x, char *buf)
585 {
586 #ifndef PDCURSES
587 int maxy;
588 #endif
589 int maxx;
590
591 #ifdef PDCURSES
592 maxx = getmaxx(win);
593 #else
594 getmaxyx(win, maxy, maxx);
595 #endif
596 werase(win);
597 mvwprintw(win, 0, 0, "%s", padstr(buf, maxx));
598 wmove(win, 0, x);
599 wrefresh(win);
600 }
601
602 /*
603
604 weditstr() - edit string
605
606 Description:
607 The initial value of 'str' with a maximum length of 'field' - 1,
608 which is supplied by the calling routine, is editted. The user's
609 erase (^H), kill (^U) and delete word (^W) chars are interpreted.
610 The PC insert or Tab keys toggle between insert and edit mode.
611 Escape aborts the edit session, leaving 'str' unchanged.
612 Enter, Up or Down Arrow are used to accept the changes to 'str'.
613 NOTE: editstr(), mveditstr(), and mvweditstr() are macros.
614
615 Return Value:
616 Returns the input terminating character on success (Escape,
617 Enter, Up or Down Arrow) and ERR on error.
618
619 Errors:
620 It is an error to call this function with a NULL window pointer.
621 The length of the initial 'str' must not exceed 'field' - 1.
622
623 */
624
625 int weditstr(WINDOW *win, char *buf, int field)
626 {
627 char org[MAXSTRLEN], *tp, *bp = buf;
628 bool defdisp = TRUE, stop = FALSE, insert = FALSE;
629 int cury, curx, begy, begx, oldattr;
630 WINDOW *wedit;
631 int c = 0;
632
633 if ((field >= MAXSTRLEN) || (buf == NULL) ||
634 ((int)strlen(buf) > field - 1))
635 return ERR;
636
637 strcpy(org, buf); /* save original */
638
639 wrefresh(win);
640 getyx(win, cury, curx);
641 getbegyx(win, begy, begx);
642
643 wedit = subwin(win, 1, field, begy + cury, begx + curx);
644 oldattr = wedit->_attrs;
645 colorbox(wedit, EDITBOXCOLOR, 0);
646
647 keypad(wedit, TRUE);
648 curs_set(1);
649
650 while (!stop)
651 {
652 idle();
653 repainteditbox(wedit, bp - buf, buf);
654
655 switch (c = wgetch(wedit))
656 {
657 case ERR:
658 break;
659
660 case KEY_ESC:
661 strcpy(buf, org); /* restore original */
662 stop = TRUE;
663 break;
664
665 case '\n':
666 case KEY_UP:
667 case KEY_DOWN:
668 stop = TRUE;
669 break;
670
671 case KEY_LEFT:
672 if (bp > buf)
673 bp--;
674 break;
675
676 case KEY_RIGHT:
677 defdisp = FALSE;
678 if (bp - buf < (int)strlen(buf))
679 bp++;
680 break;
681
682 case '\t': /* TAB -- because insert
683 is broken on HPUX */
684 case KEY_IC: /* enter insert mode */
685 case KEY_EIC: /* exit insert mode */
686 defdisp = FALSE;
687 insert = !insert;
688
689 curs_set(insert ? 2 : 1);
690 break;
691
692 default:
693 if (c == erasechar()) /* backspace, ^H */
694 {
695 if (bp > buf)
696 {
697 memmove((void *)(bp - 1), (const void *)bp, strlen(bp) + 1);
698 bp--;
699 }
700 }
701 else if (c == killchar()) /* ^U */
702 {
703 bp = buf;
704 *bp = '\0';
705 }
706 else if (c == wordchar()) /* ^W */
707 {
708 tp = bp;
709
710 while ((bp > buf) && (*(bp - 1) == ' '))
711 bp--;
712 while ((bp > buf) && (*(bp - 1) != ' '))
713 bp--;
714
715 memmove((void *)bp, (const void *)tp, strlen(tp) + 1);
716 }
717 else if (isprint(c))
718 {
719 if (defdisp)
720 {
721 bp = buf;
722 *bp = '\0';
723 defdisp = FALSE;
724 }
725
726 if (insert)
727 {
728 if ((int)strlen(buf) < field - 1)
729 {
730 memmove((void *)(bp + 1), (const void *)bp,
731 strlen(bp) + 1);
732
733 *bp++ = c;
734 }
735 }
736 else if (bp - buf < field - 1)
737 {
738 /* append new string terminator */
739
740 if (!*bp)
741 bp[1] = '\0';
742
743 *bp++ = c;
744 }
745 }
746 }
747 }
748
749 curs_set(0);
750
751 wattrset(wedit, oldattr);
752 repainteditbox(wedit, bp - buf, buf);
753 delwin(wedit);
754
755 return c;
756 }
757
758 WINDOW *winputbox(WINDOW *win, int nlines, int ncols)
759 {
760 WINDOW *winp;
761 int cury, curx, begy, begx;
762
763 getyx(win, cury, curx);
764 getbegyx(win, begy, begx);
765
766 winp = newwin(nlines, ncols, begy + cury, begx + curx);
767 colorbox(winp, INPUTBOXCOLOR, 1);
768
769 return winp;
770 }
771
772 int getstrings(char *desc[], char *buf[], int field)
773 {
774 WINDOW *winput;
775 int oldy, oldx, maxy, maxx, nlines, ncols, i, n, l, mmax = 0;
776 int c = 0;
777 bool stop = FALSE;
778
779 for (n = 0; desc[n]; n++)
780 if ((l = strlen(desc[n])) > mmax)
781 mmax = l;
782
783 nlines = n + 2; ncols = mmax + field + 4;
784 getyx(wbody, oldy, oldx);
785 getmaxyx(wbody, maxy, maxx);
786
787 winput = mvwinputbox(wbody, (maxy - nlines) / 2, (maxx - ncols) / 2,
788 nlines, ncols);
789
790 for (i = 0; i < n; i++)
791 mvwprintw(winput, i + 1, 2, "%s", desc[i]);
792
793 i = 0;
794
795 while (!stop)
796 {
797 switch (c = mvweditstr(winput, i+1, mmax+3, buf[i], field))
798 {
799 case KEY_ESC:
800 stop = TRUE;
801 break;
802
803 case KEY_UP:
804 i = (i + n - 1) % n;
805 break;
806
807 case '\n':
808 case '\t':
809 case KEY_DOWN:
810 if (++i == n)
811 stop = TRUE; /* all passed? */
812 }
813 }
814
815 delwin(winput);
816 touchwin(wbody);
817 wmove(wbody, oldy, oldx);
818 wrefresh(wbody);
819
820 return c;
821 }
File demos/tui.h added (mode: 100644) (index 00000000..b99ca6b2)
1 /*
2 * 'textual user interface'
3 *
4 * $Id: tui.h,v 1.11 2008/07/14 12:35:23 wmcbrine Exp $
5 *
6 * Author : P.J. Kunst <kunst@prl.philips.nl>
7 * Date : 25-02-93
8 */
9
10 #ifndef _TUI_H_
11 #define _TUI_H_
12
13 #include <curses.h>
14
15 #ifdef A_COLOR
16 #define A_ATTR (A_ATTRIBUTES ^ A_COLOR) /* A_BLINK, A_REVERSE, A_BOLD */
17 #else
18 #define A_ATTR (A_ATTRIBUTES) /* standard UNIX attributes */
19 #endif
20
21 #define MAXSTRLEN 256
22 #define KEY_ESC 0x1b /* Escape */
23
24 typedef void (*FUNC)(void);
25
26 typedef struct
27 {
28 char *name; /* item label */
29 FUNC func; /* (pointer to) function */
30 char *desc; /* function description */
31 } menu;
32
33 /* ANSI C function prototypes: */
34
35 void clsbody(void);
36 int bodylen(void);
37 WINDOW *bodywin(void);
38
39 void rmerror(void);
40 void rmstatus(void);
41
42 void titlemsg(char *msg);
43 void bodymsg(char *msg);
44 void errormsg(char *msg);
45 void statusmsg(char *msg);
46
47 bool keypressed(void);
48 int getkey(void);
49 int waitforkey(void);
50
51 void DoExit(void);
52 void startmenu(menu *mp, char *title);
53 void domenu(menu *mp);
54
55 int weditstr(WINDOW *win, char *buf, int field);
56 WINDOW *winputbox(WINDOW *win, int nlines, int ncols);
57 int getstrings(char *desc[], char *buf[], int field);
58
59 #define editstr(s,f) (weditstr(stdscr,s,f))
60 #define mveditstr(y,x,s,f) (move(y,x)==ERR?ERR:editstr(s,f))
61 #define mvweditstr(w,y,x,s,f) (wmove(w,y,x)==ERR?ERR:weditstr(w,s,f))
62
63 #define inputbox(l,c) (winputbox(stdscr,l,c))
64 #define mvinputbox(y,x,l,c) (move(y,x)==ERR?w:inputbox(l,c))
65 #define mvwinputbox(w,y,x,l,c) (wmove(w,y,x)==ERR?w:winputbox(w,l,c))
66
67 #endif
File demos/tuidemo.c added (mode: 100644) (index 00000000..a22d2a41)
1 /*
2 * $Id: tuidemo.c,v 1.22 2008/07/14 12:35:23 wmcbrine Exp $
3 *
4 * Author : P.J. Kunst <kunst@prl.philips.nl>
5 * Date : 25-02-93
6 *
7 * Purpose: This program demonstrates the use of the 'curses' library
8 * for the creation of (simple) menu-operated programs.
9 * In the PDCurses version, use is made of colors for the
10 * highlighting of subwindows (title bar, status bar etc).
11 *
12 * Acknowledgement: some ideas were borrowed from Mark Hessling's
13 * version of the 'testcurs' program.
14 */
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <locale.h>
20 #include "tui.h"
21
22 /* change this if source at other location */
23
24 #ifdef XCURSES
25 # define FNAME "../demos/tui.c"
26 #else
27 # define FNAME "..\\demos\\tui.c"
28 #endif
29
30 /**************************** strings entry box ***************************/
31
32 void address(void)
33 {
34 char *fieldname[6] =
35 {
36 "Name", "Street", "City", "State", "Country", (char *)0
37 };
38
39 char *fieldbuf[5];
40 WINDOW *wbody = bodywin();
41 int i, field = 50;
42
43 for (i = 0; i < 5; i++)
44 fieldbuf[i] = calloc(1, field + 1);
45
46 if (getstrings(fieldname, fieldbuf, field) != KEY_ESC)
47 {
48 for (i = 0; fieldname[i]; i++)
49 wprintw(wbody, "%10s : %s\n",
50 fieldname[i], fieldbuf[i]);
51
52 wrefresh(wbody);
53 }
54
55 for (i = 0; i < 5; i++)
56 free(fieldbuf[i]);
57 }
58
59 /**************************** string entry box ****************************/
60
61 char *getfname(char *desc, char *fname, int field)
62 {
63 char *fieldname[2];
64 char *fieldbuf[1];
65
66 fieldname[0] = desc;
67 fieldname[1] = 0;
68 fieldbuf[0] = fname;
69
70 return (getstrings(fieldname, fieldbuf, field) == KEY_ESC) ? NULL : fname;
71 }
72
73 /**************************** a very simple file browser ******************/
74
75 void showfile(char *fname)
76 {
77 int i, bh = bodylen();
78 FILE *fp;
79 char buf[MAXSTRLEN];
80 bool ateof = FALSE;
81
82 statusmsg("FileBrowser: Hit key to continue, Q to quit");
83
84 if ((fp = fopen(fname, "r")) != NULL) /* file available? */
85 {
86 while (!ateof)
87 {
88 clsbody();
89
90 for (i = 0; i < bh - 1 && !ateof; i++)
91 {
92 buf[0] = '\0';
93 fgets(buf, MAXSTRLEN, fp);
94
95 if (strlen(buf))
96 bodymsg(buf);
97 else
98 ateof = TRUE;
99 }
100
101 switch (waitforkey())
102 {
103 case 'Q':
104 case 'q':
105 case 0x1b:
106 ateof = TRUE;
107 }
108 }
109
110 fclose(fp);
111 }
112 else
113 {
114 sprintf(buf, "ERROR: file '%s' not found", fname);
115 errormsg(buf);
116 }
117 }
118
119 /***************************** forward declarations ***********************/
120
121 void sub0(void), sub1(void), sub2(void), sub3(void);
122 void func1(void), func2(void);
123 void subfunc1(void), subfunc2(void);
124 void subsub(void);
125
126 /***************************** menus initialization ***********************/
127
128 menu MainMenu[] =
129 {
130 { "Asub", sub0, "Go inside first submenu" },
131 { "Bsub", sub1, "Go inside second submenu" },
132 { "Csub", sub2, "Go inside third submenu" },
133 { "Dsub", sub3, "Go inside fourth submenu" },
134 { "", (FUNC)0, "" } /* always add this as the last item! */
135 };
136
137 menu SubMenu0[] =
138 {
139 { "Exit", DoExit, "Terminate program" },
140 { "", (FUNC)0, "" }
141 };
142
143 menu SubMenu1[] =
144 {
145 { "OneBeep", func1, "Sound one beep" },
146 { "TwoBeeps", func2, "Sound two beeps" },
147 { "", (FUNC)0, "" }
148 };
149
150 menu SubMenu2[] =
151 {
152 { "Browse", subfunc1, "Source file lister" },
153 { "Input", subfunc2, "Interactive file lister" },
154 { "Address", address, "Get address data" },
155 { "", (FUNC)0, "" }
156 };
157
158 menu SubMenu3[] =
159 {
160 { "SubSub", subsub, "Go inside sub-submenu" },
161 { "", (FUNC)0, "" }
162 };
163
164 /***************************** main menu functions ************************/
165
166 void sub0(void)
167 {
168 domenu(SubMenu0);
169 }
170
171 void sub1(void)
172 {
173 domenu(SubMenu1);
174 }
175
176 void sub2(void)
177 {
178 domenu(SubMenu2);
179 }
180
181 void sub3(void)
182 {
183 domenu(SubMenu3);
184 }
185
186 /***************************** submenu1 functions *************************/
187
188 void func1(void)
189 {
190 beep();
191 bodymsg("One beep! ");
192 }
193
194 void func2(void)
195 {
196 beep();
197 bodymsg("Two beeps! ");
198 beep();
199 }
200
201 /***************************** submenu2 functions *************************/
202
203 void subfunc1(void)
204 {
205 showfile(FNAME);
206 }
207
208 void subfunc2(void)
209 {
210 char fname[MAXSTRLEN];
211
212 strcpy(fname, FNAME);
213 if (getfname ("File to browse:", fname, 50))
214 showfile(fname);
215 }
216
217 /***************************** submenu3 functions *************************/
218
219 void subsub(void)
220 {
221 domenu(SubMenu2);
222 }
223
224 /***************************** start main menu ***************************/
225
226 int main(int argc, char **argv)
227 {
228 setlocale(LC_ALL, "");
229
230 startmenu(MainMenu, "TUI - 'textual user interface' demonstration program");
231
232 return 0;
233 }
File demos/worm.c added (mode: 100644) (index 00000000..5a823f90)
1 /****************************************************************************
2 * Copyright (c) 2005 Free Software Foundation, Inc. *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
28
29 /*
30
31 @@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
32 @@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@
33 @@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@
34 @@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
35 @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
36 @@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@
37 @@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@
38 @@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@
39 @@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@
40
41 Eric P. Scott
42 Caltech High Energy Physics
43 October, 1980
44
45 Color by Eric S. Raymond
46 July, 1995
47
48 Options:
49 -f fill screen with copies of 'WORM' at start.
50 -l <n> set worm length
51 -n <n> set number of worms
52 -t make worms leave droppings
53
54 $Id: worm.c,v 1.16 2008/07/13 16:08:17 wmcbrine Exp $
55 */
56
57 #include <curses.h>
58 #include <stdlib.h>
59 #include <time.h>
60
61 #define FLAVORS 7
62
63 static chtype flavor[FLAVORS] =
64 {
65 'O', '*', '#', '$', '%', '0', '@'
66 };
67
68 static const short xinc[] =
69 {
70 1, 1, 1, 0, -1, -1, -1, 0
71 },
72 yinc[] =
73 {
74 -1, 0, 1, 1, 1, 0, -1, -1
75 };
76
77 static struct worm
78 {
79 int orientation, head;
80 short *xpos, *ypos;
81 } worm[40];
82
83 static const char *field;
84 static int length = 16, number = 3;
85 static chtype trail = ' ';
86
87 static const struct options
88 {
89 int nopts;
90 int opts[3];
91 } normal[8] =
92 {
93 { 3, { 7, 0, 1 } }, { 3, { 0, 1, 2 } }, { 3, { 1, 2, 3 } },
94 { 3, { 2, 3, 4 } }, { 3, { 3, 4, 5 } }, { 3, { 4, 5, 6 } },
95 { 3, { 5, 6, 7 } }, { 3, { 6, 7, 0 } }
96 },
97 upper[8] =
98 {
99 { 1, { 1, 0, 0 } }, { 2, { 1, 2, 0 } }, { 0, { 0, 0, 0 } },
100 { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 2, { 4, 5, 0 } },
101 { 1, { 5, 0, 0 } }, { 2, { 1, 5, 0 } }
102 },
103 left[8] =
104 {
105 { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
106 { 2, { 2, 3, 0 } }, { 1, { 3, 0, 0 } }, { 2, { 3, 7, 0 } },
107 { 1, { 7, 0, 0 } }, { 2, { 7, 0, 0 } }
108 },
109 right[8] =
110 {
111 { 1, { 7, 0, 0 } }, { 2, { 3, 7, 0 } }, { 1, { 3, 0, 0 } },
112 { 2, { 3, 4, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
113 { 0, { 0, 0, 0 } }, { 2, { 6, 7, 0 } }
114 },
115 lower[8] =
116 {
117 { 0, { 0, 0, 0 } }, { 2, { 0, 1, 0 } }, { 1, { 1, 0, 0 } },
118 { 2, { 1, 5, 0 } }, { 1, { 5, 0, 0 } }, { 2, { 5, 6, 0 } },
119 { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }
120 },
121 upleft[8] =
122 {
123 { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
124 { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 1, { 3, 0, 0 } },
125 { 2, { 1, 3, 0 } }, { 1, { 1, 0, 0 } }
126 },
127 upright[8] =
128 {
129 { 2, { 3, 5, 0 } }, { 1, { 3, 0, 0 } }, { 0, { 0, 0, 0 } },
130 { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
131 { 0, { 0, 0, 0 } }, { 1, { 5, 0, 0 } }
132 },
133 lowleft[8] =
134 {
135 { 3, { 7, 0, 1 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
136 { 1, { 1, 0, 0 } }, { 2, { 1, 7, 0 } }, { 1, { 7, 0, 0 } },
137 { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }
138 },
139 lowright[8] =
140 {
141 { 0, { 0, 0, 0 } }, { 1, { 7, 0, 0 } }, { 2, { 5, 7, 0 } },
142 { 1, { 5, 0, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
143 { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }
144 };
145
146 static void cleanup(void)
147 {
148 standend();
149 refresh();
150 curs_set(1);
151 endwin();
152 }
153
154 int main(int argc, char *argv[])
155 {
156 const struct options *op;
157 struct worm *w;
158 short **ref, *ip;
159 int x, y, n, h, last, bottom, seed;
160
161 for (x = 1; x < argc; x++)
162 {
163 char *p = argv[x];
164
165 if (*p == '-')
166 p++;
167
168 switch (*p)
169 {
170 case 'f':
171 field = "WORM";
172 break;
173 case 'l':
174 if (++x == argc)
175 goto usage;
176
177 if ((length = atoi(argv[x])) < 2 || length > 1024)
178 {
179 fprintf(stderr, "%s: Invalid length\n", *argv);
180 return EXIT_FAILURE;
181 }
182
183 break;
184 case 'n':
185 if (++x == argc)
186 goto usage;
187
188 if ((number = atoi(argv[x])) < 1 || number > 40)
189 {
190 fprintf(stderr, "%s: Invalid number of worms\n", *argv);
191 return EXIT_FAILURE;
192 }
193
194 break;
195 case 't':
196 trail = '.';
197 break;
198 default:
199 usage:
200 fprintf(stderr, "usage: %s [-field] [-length #] "
201 "[-number #] [-trail]\n", *argv);
202 return EXIT_FAILURE;
203 }
204 }
205
206 #ifdef XCURSES
207 Xinitscr(argc, argv);
208 #else
209 initscr();
210 #endif
211 seed = time((time_t *)0);
212 srand(seed);
213
214 noecho();
215 cbreak();
216 nonl();
217 keypad(stdscr, TRUE);
218
219 curs_set(0);
220
221 bottom = LINES - 1;
222 last = COLS - 1;
223
224 #ifdef A_COLOR
225 if (has_colors())
226 {
227 int bg = COLOR_BLACK;
228 start_color();
229
230 # if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
231 if (use_default_colors() == OK)
232 bg = -1;
233 # endif
234
235 # define SET_COLOR(num, fg) \
236 init_pair(num + 1, fg, bg); \
237 flavor[num] |= COLOR_PAIR(num + 1) | A_BOLD
238
239 SET_COLOR(0, COLOR_GREEN);
240 SET_COLOR(1, COLOR_RED);
241 SET_COLOR(2, COLOR_CYAN);
242 SET_COLOR(3, COLOR_WHITE);
243 SET_COLOR(4, COLOR_MAGENTA);
244 SET_COLOR(5, COLOR_BLUE);
245 SET_COLOR(6, COLOR_YELLOW);
246 }
247 #endif
248
249 ref = malloc(sizeof(short *) * LINES);
250
251 for (y = 0; y < LINES; y++)
252 {
253 ref[y] = malloc(sizeof(short) * COLS);
254
255 for (x = 0; x < COLS; x++)
256 ref[y][x] = 0;
257 }
258
259 #ifdef BADCORNER
260 /* if addressing the lower right corner doesn't work in your curses */
261
262 ref[bottom][last] = 1;
263 #endif
264
265 for (n = number, w = &worm[0]; --n >= 0; w++)
266 {
267 w->orientation = w->head = 0;
268
269 if ((ip = malloc(sizeof(short) * (length + 1))) == NULL)
270 {
271 fprintf(stderr, "%s: out of memory\n", *argv);
272 return EXIT_FAILURE;
273 }
274
275 w->xpos = ip;
276
277 for (x = length; --x >= 0;)
278 *ip++ = -1;
279
280 if ((ip = malloc(sizeof(short) * (length + 1))) == NULL)
281 {
282 fprintf(stderr, "%s: out of memory\n", *argv);
283 return EXIT_FAILURE;
284 }
285
286 w->ypos = ip;
287
288 for (y = length; --y >= 0;)
289 *ip++ = -1;
290 }
291
292 if (field)
293 {
294 const char *p = field;
295
296 for (y = bottom; --y >= 0;)
297 for (x = COLS; --x >= 0;)
298 {
299 addch((chtype) (*p++));
300
301 if (!*p)
302 p = field;
303 }
304 }
305
306 napms(12);
307 refresh();
308 nodelay(stdscr, TRUE);
309
310 for (;;)
311 {
312 int ch;
313
314 if ((ch = getch()) > 0)
315 {
316 #ifdef KEY_RESIZE
317 if (ch == KEY_RESIZE)
318 {
319 # ifdef PDCURSES
320 resize_term(0, 0);
321 erase();
322 # endif
323 if (last != COLS - 1)
324 {
325 for (y = 0; y <= bottom; y++)
326 {
327 ref[y] = realloc(ref[y], sizeof(short) * COLS);
328
329 for (x = last + 1; x < COLS; x++)
330 ref[y][x] = 0;
331 }
332
333 last = COLS - 1;
334 }
335
336 if (bottom != LINES - 1)
337 {
338 for (y = LINES; y <= bottom; y++)
339 free(ref[y]);
340
341 ref = realloc(ref, sizeof(short *) * LINES);
342
343 for (y = bottom + 1; y < LINES; y++)
344 {
345 ref[y] = malloc(sizeof(short) * COLS);
346
347 for (x = 0; x < COLS; x++)
348 ref[y][x] = 0;
349 }
350
351 bottom = LINES - 1;
352 }
353 }
354
355 #endif /* KEY_RESIZE */
356
357 /* Make it simple to put this into single-step mode,
358 or resume normal operation - T. Dickey */
359
360 if (ch == 'q')
361 {
362 cleanup();
363 return EXIT_SUCCESS;
364 }
365 else if (ch == 's')
366 nodelay(stdscr, FALSE);
367 else if (ch == ' ')
368 nodelay(stdscr, TRUE);
369 }
370
371 for (n = 0, w = &worm[0]; n < number; n++, w++)
372 {
373 if ((x = w->xpos[h = w->head]) < 0)
374 {
375 move(y = w->ypos[h] = bottom, x = w->xpos[h] = 0);
376 addch(flavor[n % FLAVORS]);
377 ref[y][x]++;
378 }
379 else
380 y = w->ypos[h];
381
382 if (x > last)
383 x = last;
384
385 if (y > bottom)
386 y = bottom;
387
388 if (++h == length)
389 h = 0;
390
391 if (w->xpos[w->head = h] >= 0)
392 {
393 int x1 = w->xpos[h];
394 int y1 = w->ypos[h];
395
396 if (y1 < LINES && x1 < COLS && --ref[y1][x1] == 0)
397 {
398 move(y1, x1);
399 addch(trail);
400 }
401 }
402
403 op = &(x == 0 ? (y == 0 ? upleft :
404 (y == bottom ? lowleft : left)) :
405 (x == last ? (y == 0 ? upright :
406 (y == bottom ? lowright : right)) :
407 (y == 0 ? upper :
408 (y == bottom ? lower : normal))))
409 [w->orientation];
410
411 switch (op->nopts)
412 {
413 case 0:
414 cleanup();
415 return EXIT_SUCCESS;
416 case 1:
417 w->orientation = op->opts[0];
418 break;
419 default:
420 w->orientation = op->opts[rand() % op->nopts];
421 }
422
423 move(y += yinc[w->orientation], x += xinc[w->orientation]);
424
425 if (y < 0)
426 y = 0;
427
428 addch(flavor[n % FLAVORS]);
429 ref[w->ypos[h] = y][w->xpos[h] = x]++;
430 }
431 napms(12);
432 refresh();
433 }
434 }
File demos/xmas.c added (mode: 100644) (index 00000000..706858a5)
1 /******************************************************************************/
2 /* asciixmas */
3 /* December 1989 Larry Bartz Indianapolis, IN */
4 /* */
5 /* */
6 /* I'm dreaming of an ascii character-based monochrome Christmas, */
7 /* Just like the one's I used to know! */
8 /* Via a full duplex communications channel, */
9 /* At 9600 bits per second, */
10 /* Even though it's kinda slow. */
11 /* */
12 /* I'm dreaming of an ascii character-based monochrome Christmas, */
13 /* With ev'ry C program I write! */
14 /* May your screen be merry and bright! */
15 /* And may all your Christmases be amber or green, */
16 /* (for reduced eyestrain and improved visibility)! */
17 /* */
18 /* */
19 /* */
20 /* IMPLEMENTATION */
21 /* */
22 /* Feel free to modify the defined string FROMWHO to reflect you, your */
23 /* organization, your site, whatever. */
24 /* */
25 /* This looks a lot better if you can turn off your cursor before execution. */
26 /* The cursor is distracting but it doesn't really ruin the show. */
27 /* */
28 /* At our site, we invoke this for our users just after login and the */
29 /* determination of terminal type. */
30 /* */
31 /* */
32 /* PORTABILITY */
33 /* */
34 /* I wrote this using only the very simplest curses functions so that it */
35 /* might be the most portable. I was personally able to test on five */
36 /* different cpu/UNIX combinations. */
37 /* */
38 /* */
39 /* COMPILE */
40 /* */
41 /* usually this: */
42 /* */
43 /* cc -O xmas.c -lcurses -o xmas -s */
44 /* */
45 /******************************************************************************/
46
47 /* $Id: xmas.c,v 1.29 2008/07/13 16:08:17 wmcbrine Exp $ */
48
49 #include <curses.h>
50 #include <signal.h>
51
52 void lil(WINDOW *);
53 void midtop(WINDOW *);
54 void bigtop(WINDOW *);
55 void bigface(WINDOW *, chtype);
56 void legs1(WINDOW *);
57 void legs2(WINDOW *);
58 void legs3(WINDOW *);
59 void legs4(WINDOW *);
60 void initdeer(void);
61 void boxit(void);
62 void seas(void);
63 void greet(void);
64 void fromwho(void);
65 void del_msg(void);
66 void tree(void);
67 void balls(void);
68 void star(void);
69 void strng1(void);
70 void strng2(void);
71 void strng3(void);
72 void strng4(void);
73 void strng5(void);
74 void blinkit(void);
75 void reindeer(void);
76
77 #define FROMWHO "From Larry Bartz, Mark Hessling and William McBrine"
78
79 int y_pos, x_pos;
80
81 WINDOW *treescrn, *treescrn2, *treescrn3, *treescrn4, *treescrn5,
82 *treescrn6, *treescrn7, *treescrn8, *dotdeer0, *stardeer0,
83 *lildeer0, *lildeer1, *lildeer2, *lildeer3, *middeer0,
84 *middeer1, *middeer2, *middeer3, *bigdeer0, *bigdeer1,
85 *bigdeer2, *bigdeer3, *bigdeer4, *lookdeer0, *lookdeer1,
86 *lookdeer2, *lookdeer3, *lookdeer4, *w_holiday, *w_del_msg;
87
88 int main(int argc, char **argv)
89 {
90 int loopy;
91
92 #ifdef XCURSES
93 Xinitscr(argc, argv);
94 #else
95 initscr();
96 #endif
97 nodelay(stdscr, TRUE);
98 noecho();
99 nonl();
100 refresh();
101
102 #ifdef A_COLOR
103 if (has_colors())
104 start_color();
105 #endif
106 curs_set(0);
107
108 treescrn = newwin(16, 27, 3, 53);
109 treescrn2 = newwin(16, 27, 3, 53);
110 treescrn3 = newwin(16, 27, 3, 53);
111 treescrn4 = newwin(16, 27, 3, 53);
112 treescrn5 = newwin(16, 27, 3, 53);
113 treescrn6 = newwin(16, 27, 3, 53);
114 treescrn7 = newwin(16, 27, 3, 53);
115 treescrn8 = newwin(16, 27, 3, 53);
116
117 w_holiday = newwin(1, 26, 3, 27);
118
119 w_del_msg = newwin(1, 12, 23, 60);
120
121 mvwaddstr(w_holiday, 0, 0, "H A P P Y H O L I D A Y S");
122
123 initdeer();
124
125 clear();
126 werase(treescrn);
127 touchwin(treescrn);
128 werase(treescrn2);
129 touchwin(treescrn2);
130 werase(treescrn8);
131 touchwin(treescrn8);
132 refresh();
133 napms(1000);
134
135 boxit();
136 del_msg();
137 napms(1000);
138
139 seas();
140 del_msg();
141 napms(1000);
142
143 greet();
144 del_msg();
145 napms(1000);
146
147 fromwho();
148 del_msg();
149 napms(1000);
150
151 tree();
152 napms(1000);
153
154 balls();
155 napms(1000);
156
157 star();
158 napms(1000);
159
160 strng1();
161 strng2();
162 strng3();
163 strng4();
164 strng5();
165
166 /* set up the windows for our blinking trees */
167 /* **************************************** */
168 /* treescrn3 */
169
170 overlay(treescrn, treescrn3);
171
172 /* balls */
173 mvwaddch(treescrn3, 4, 18, ' ');
174 mvwaddch(treescrn3, 7, 6, ' ');
175 mvwaddch(treescrn3, 8, 19, ' ');
176 mvwaddch(treescrn3, 11, 22, ' ');
177
178 /* star */
179 mvwaddch(treescrn3, 0, 12, '*');
180
181 /* strng1 */
182 mvwaddch(treescrn3, 3, 11, ' ');
183
184 /* strng2 */
185 mvwaddch(treescrn3, 5, 13, ' ');
186 mvwaddch(treescrn3, 6, 10, ' ');
187
188 /* strng3 */
189 mvwaddch(treescrn3, 7, 16, ' ');
190 mvwaddch(treescrn3, 7, 14, ' ');
191
192 /* strng4 */
193 mvwaddch(treescrn3, 10, 13, ' ');
194 mvwaddch(treescrn3, 10, 10, ' ');
195 mvwaddch(treescrn3, 11, 8, ' ');
196
197 /* strng5 */
198 mvwaddch(treescrn3, 11, 18, ' ');
199 mvwaddch(treescrn3, 12, 13, ' ');
200
201 /* treescrn4 */
202
203 overlay(treescrn, treescrn4);
204
205 /* balls */
206 mvwaddch(treescrn4, 3, 9, ' ');
207 mvwaddch(treescrn4, 4, 16, ' ');
208 mvwaddch(treescrn4, 7, 6, ' ');
209 mvwaddch(treescrn4, 8, 19, ' ');
210 mvwaddch(treescrn4, 11, 2, ' ');
211 mvwaddch(treescrn4, 12, 23, ' ');
212
213 /* star */
214 mvwaddch(treescrn4, 0, 12, '*' | A_STANDOUT);
215
216 /* strng1 */
217 mvwaddch(treescrn4, 3, 13, ' ');
218
219 /* strng2 */
220
221 /* strng3 */
222 mvwaddch(treescrn4, 7, 15, ' ');
223 mvwaddch(treescrn4, 8, 11, ' ');
224
225 /* strng4 */
226 mvwaddch(treescrn4, 9, 16, ' ');
227 mvwaddch(treescrn4, 10, 12, ' ');
228 mvwaddch(treescrn4, 11, 8, ' ');
229
230 /* strng5 */
231 mvwaddch(treescrn4, 11, 18, ' ');
232 mvwaddch(treescrn4, 12, 14, ' ');
233
234 /* treescrn5 */
235
236 overlay(treescrn, treescrn5);
237
238 /* balls */
239 mvwaddch(treescrn5, 3, 15, ' ');
240 mvwaddch(treescrn5, 10, 20, ' ');
241 mvwaddch(treescrn5, 12, 1, ' ');
242
243 /* star */
244 mvwaddch(treescrn5, 0, 12, '*');
245
246 /* strng1 */
247 mvwaddch(treescrn5, 3, 11, ' ');
248
249 /* strng2 */
250 mvwaddch(treescrn5, 5, 12, ' ');
251
252 /* strng3 */
253 mvwaddch(treescrn5, 7, 14, ' ');
254 mvwaddch(treescrn5, 8, 10, ' ');
255
256 /* strng4 */
257 mvwaddch(treescrn5, 9, 15, ' ');
258 mvwaddch(treescrn5, 10, 11, ' ');
259 mvwaddch(treescrn5, 11, 7, ' ');
260
261 /* strng5 */
262 mvwaddch(treescrn5, 11, 17, ' ');
263 mvwaddch(treescrn5, 12, 13, ' ');
264
265 /* treescrn6 */
266
267 overlay(treescrn, treescrn6);
268
269 /* balls */
270 mvwaddch(treescrn6, 6, 7, ' ');
271 mvwaddch(treescrn6, 7, 18, ' ');
272 mvwaddch(treescrn6, 10, 4, ' ');
273 mvwaddch(treescrn6, 11, 23, ' ');
274
275 /* star */
276 mvwaddch(treescrn6, 0, 12, '*' | A_STANDOUT);
277
278 /* strng1 */
279
280 /* strng2 */
281 mvwaddch(treescrn6, 5, 11, ' ');
282
283 /* strng3 */
284 mvwaddch(treescrn6, 7, 13, ' ');
285 mvwaddch(treescrn6, 8, 9, ' ');
286
287 /* strng4 */
288 mvwaddch(treescrn6, 9, 14, ' ');
289 mvwaddch(treescrn6, 10, 10, ' ');
290 mvwaddch(treescrn6, 11, 6, ' ');
291
292 /* strng5 */
293 mvwaddch(treescrn6, 11, 16, ' ');
294 mvwaddch(treescrn6, 12, 12, ' ');
295
296 /* treescrn7 */
297
298 overlay(treescrn, treescrn7);
299
300 /* balls */
301 mvwaddch(treescrn7, 3, 15, ' ');
302 mvwaddch(treescrn7, 6, 7, ' ');
303 mvwaddch(treescrn7, 7, 18, ' ');
304 mvwaddch(treescrn7, 10, 4, ' ');
305 mvwaddch(treescrn7, 11, 22, ' ');
306
307 /* star */
308 mvwaddch(treescrn7, 0, 12, '*');
309
310 /* strng1 */
311 mvwaddch(treescrn7, 3, 12, ' ');
312
313 /* strng2 */
314 mvwaddch(treescrn7, 5, 13, ' ');
315 mvwaddch(treescrn7, 6, 9, ' ');
316
317 /* strng3 */
318 mvwaddch(treescrn7, 7, 15, ' ');
319 mvwaddch(treescrn7, 8, 11, ' ');
320
321 /* strng4 */
322 mvwaddch(treescrn7, 9, 16, ' ');
323 mvwaddch(treescrn7, 10, 12, ' ');
324 mvwaddch(treescrn7, 11, 8, ' ');
325
326 /* strng5 */
327 mvwaddch(treescrn7, 11, 18, ' ');
328 mvwaddch(treescrn7, 12, 14, ' ');
329
330 napms(1000);
331 reindeer();
332
333 touchwin(w_holiday);
334 wrefresh(w_holiday);
335 wrefresh(w_del_msg);
336
337 napms(1000);
338
339 for (loopy = 0; loopy < 50; loopy++)
340 blinkit();
341
342 clear();
343 refresh();
344 endwin();
345
346 return 0;
347 }
348
349 void lil(WINDOW *win)
350 {
351 mvwaddch(win, 0, 0, (chtype) 'V');
352 mvwaddch(win, 1, 0, (chtype) '@');
353 mvwaddch(win, 1, 3, (chtype) '~');
354 }
355
356 void midtop(WINDOW *win)
357 {
358 mvwaddstr(win, 0, 2, "yy");
359 mvwaddstr(win, 1, 2, "0(=)~");
360 }
361
362 void bigtop(WINDOW *win)
363 {
364 mvwaddstr(win, 0, 17, "\\/");
365 mvwaddstr(win, 0, 20, "\\/");
366 mvwaddch(win, 1, 18, (chtype) '\\');
367 mvwaddch(win, 1, 20, (chtype) '/');
368 mvwaddstr(win, 2, 19, "|_");
369 mvwaddstr(win, 3, 18, "/^0\\");
370 mvwaddstr(win, 4, 17, "//\\");
371 mvwaddch(win, 4, 22, (chtype) '\\');
372 mvwaddstr(win, 5, 7, "^~~~~~~~~// ~~U");
373 }
374
375 void bigface(WINDOW *win, chtype noseattr)
376 {
377 mvwaddstr(win, 0, 16, "\\/ \\/");
378 mvwaddstr(win, 1, 17, "\\Y/ \\Y/");
379 mvwaddstr(win, 2, 19, "\\=/");
380 mvwaddstr(win, 3, 17, "^\\o o/^");
381 mvwaddstr(win, 4, 17, "//( )");
382 mvwaddstr(win, 5, 7, "^~~~~~~~~// \\");
383 waddch(win, 'O' | noseattr);
384 waddstr(win, "/");
385 }
386
387 void legs1(WINDOW *win)
388 {
389 mvwaddstr(win, 6, 7, "( \\_____( /");
390 mvwaddstr(win, 7, 8, "( ) /");
391 mvwaddstr(win, 8, 9, "\\\\ /");
392 mvwaddstr(win, 9, 11, "\\>/>");
393 }
394
395 void legs2(WINDOW *win)
396 {
397 mvwaddstr(win, 6, 7, "(( )____( /");
398 mvwaddstr(win, 7, 7, "( / |");
399 mvwaddstr(win, 8, 8, "\\/ |");
400 mvwaddstr(win, 9, 9, "|> |>");
401 }
402
403 void legs3(WINDOW *win)
404 {
405 mvwaddstr(win, 6, 6, "( ()_____( /");
406 mvwaddstr(win, 7, 6, "/ / /");
407 mvwaddstr(win, 8, 5, "|/ \\");
408 mvwaddstr(win, 9, 5, "/> \\>");
409 }
410
411 void legs4(WINDOW *win)
412 {
413 mvwaddstr(win, 6, 6, "( )______( /");
414 mvwaddstr(win, 7, 5, "(/ \\");
415 mvwaddstr(win, 8, 0, "v___= ----^");
416 }
417
418 void initdeer(void)
419 {
420 chtype noseattr;
421
422 #ifdef A_COLOR
423 if (has_colors())
424 {
425 init_pair(31, COLOR_RED, COLOR_BLACK);
426 noseattr = COLOR_PAIR(31);
427 }
428 else
429 #endif
430 noseattr = A_NORMAL;
431
432 /* set up the windows for our various reindeer */
433
434 dotdeer0 = newwin(3, 71, 0, 8);
435 stardeer0 = newwin(4, 56, 0, 8);
436 lildeer0 = newwin(7, 54, 0, 8);
437 middeer0 = newwin(15, 42, 0, 8);
438 bigdeer0 = newwin(10, 23, 0, 0);
439 lookdeer0 = newwin(10, 25, 0, 0);
440
441 /* lildeer1 */
442 lildeer1 = newwin(2, 4, 0, 0);
443 lil(lildeer1);
444 mvwaddstr(lildeer1, 1, 1, "<>");
445
446 /* lildeer2 */
447 lildeer2 = newwin(2, 4, 0, 0);
448 lil(lildeer2);
449 mvwaddstr(lildeer2, 1, 1, "||");
450
451 /* lildeer3 */
452 lildeer3 = newwin(2, 4, 0, 0);
453 lil(lildeer3);
454 mvwaddstr(lildeer3, 1, 1, "><");
455
456 /* middeer1 */
457 middeer1 = newwin(3, 7, 0, 0);
458 midtop(middeer1);
459 mvwaddstr(middeer1, 2, 3, "\\/");
460
461 /* middeer2 */
462 middeer2 = newwin(3, 7, 0, 0);
463 midtop(middeer2);
464 mvwaddch(middeer2, 2, 3, (chtype) '|');
465 mvwaddch(middeer2, 2, 5, (chtype) '|');
466
467 /* middeer3 */
468 middeer3 = newwin(3, 7, 0, 0);
469 midtop(middeer3);
470 mvwaddch(middeer3, 2, 2, (chtype) '/');
471 mvwaddch(middeer3, 2, 6, (chtype) '\\');
472
473 /* bigdeer1 */
474 bigdeer1 = newwin(10, 23, 0, 0);
475 bigtop(bigdeer1);
476 legs1(bigdeer1);
477
478 /* bigdeer2 */
479 bigdeer2 = newwin(10, 23, 0, 0);
480 bigtop(bigdeer2);
481 legs2(bigdeer2);
482
483 /* bigdeer3 */
484 bigdeer3 = newwin(10, 23, 0, 0);
485 bigtop(bigdeer3);
486 legs3(bigdeer3);
487
488 /* bigdeer4 */
489 bigdeer4 = newwin(10, 23, 0, 0);
490 bigtop(bigdeer4);
491 legs4(bigdeer4);
492
493 /* lookdeer1 */
494 lookdeer1 = newwin(10, 25, 0, 0);
495 bigface(lookdeer1, noseattr);
496 legs1(lookdeer1);
497
498 /* lookdeer2 */
499 lookdeer2 = newwin(10, 25, 0, 0);
500 bigface(lookdeer2, noseattr);
501 legs2(lookdeer2);
502
503 /* lookdeer3 */
504 lookdeer3 = newwin(10, 25, 0, 0);
505 bigface(lookdeer3, noseattr);
506 legs3(lookdeer3);
507
508 /* lookdeer4 */
509 lookdeer4 = newwin(10, 25, 0, 0);
510 bigface(lookdeer4, noseattr);
511 legs4(lookdeer4);
512 }
513
514 void boxit(void)
515 {
516 int x;
517
518 for (x = 0; x < 20; ++x)
519 mvaddch(x, 7, '|');
520
521 for (x = 0; x < 80; ++x)
522 {
523 if (x > 7)
524 mvaddch(19, x, '_');
525
526 mvaddch(22, x, '_');
527 }
528 }
529
530 void seas(void)
531 {
532 mvaddch(4, 1, 'S');
533 mvaddch(6, 1, 'E');
534 mvaddch(8, 1, 'A');
535 mvaddch(10, 1, 'S');
536 mvaddch(12, 1, 'O');
537 mvaddch(14, 1, 'N');
538 mvaddch(16, 1, '`');
539 mvaddch(18, 1, 'S');
540 }
541
542 void greet(void)
543 {
544 mvaddch(3, 5, 'G');
545 mvaddch(5, 5, 'R');
546 mvaddch(7, 5, 'E');
547 mvaddch(9, 5, 'E');
548 mvaddch(11, 5, 'T');
549 mvaddch(13, 5, 'I');
550 mvaddch(15, 5, 'N');
551 mvaddch(17, 5, 'G');
552 mvaddch(19, 5, 'S');
553 }
554
555 void fromwho(void)
556 {
557 mvaddstr(21, 13, FROMWHO);
558 }
559
560 void del_msg(void)
561 {
562 refresh();
563 }
564
565 void tree(void)
566 {
567 #ifdef A_COLOR
568 if (has_colors())
569 {
570 init_pair(30, COLOR_GREEN, COLOR_BLACK);
571 wattrset(treescrn, COLOR_PAIR(30));
572 }
573 #endif
574 mvwaddch(treescrn, 1, 11, (chtype) '/');
575 mvwaddch(treescrn, 2, 11, (chtype) '/');
576 mvwaddch(treescrn, 3, 10, (chtype) '/');
577 mvwaddch(treescrn, 4, 9, (chtype) '/');
578 mvwaddch(treescrn, 5, 9, (chtype) '/');
579 mvwaddch(treescrn, 6, 8, (chtype) '/');
580 mvwaddch(treescrn, 7, 7, (chtype) '/');
581 mvwaddch(treescrn, 8, 6, (chtype) '/');
582 mvwaddch(treescrn, 9, 6, (chtype) '/');
583 mvwaddch(treescrn, 10, 5, (chtype) '/');
584 mvwaddch(treescrn, 11, 3, (chtype) '/');
585 mvwaddch(treescrn, 12, 2, (chtype) '/');
586
587 mvwaddch(treescrn, 1, 13, (chtype) '\\');
588 mvwaddch(treescrn, 2, 13, (chtype) '\\');
589 mvwaddch(treescrn, 3, 14, (chtype) '\\');
590 mvwaddch(treescrn, 4, 15, (chtype) '\\');
591 mvwaddch(treescrn, 5, 15, (chtype) '\\');
592 mvwaddch(treescrn, 6, 16, (chtype) '\\');
593 mvwaddch(treescrn, 7, 17, (chtype) '\\');
594 mvwaddch(treescrn, 8, 18, (chtype) '\\');
595 mvwaddch(treescrn, 9, 18, (chtype) '\\');
596 mvwaddch(treescrn, 10, 19, (chtype) '\\');
597 mvwaddch(treescrn, 11, 21, (chtype) '\\');
598 mvwaddch(treescrn, 12, 22, (chtype) '\\');
599
600 mvwaddch(treescrn, 4, 10, (chtype) '_');
601 mvwaddch(treescrn, 4, 14, (chtype) '_');
602 mvwaddch(treescrn, 8, 7, (chtype) '_');
603 mvwaddch(treescrn, 8, 17, (chtype) '_');
604
605 mvwaddstr(treescrn, 13, 0,
606 "//////////// \\\\\\\\\\\\\\\\\\\\\\\\");
607
608 #ifdef A_COLOR
609 if (has_colors())
610 {
611 init_pair(20, COLOR_YELLOW, COLOR_BLACK);
612 wattrset(treescrn, COLOR_PAIR(20));
613 }
614 #endif
615 mvwaddstr(treescrn, 14, 11, "| |");
616 mvwaddstr(treescrn, 15, 11, "|_|");
617
618 wrefresh(treescrn);
619 wrefresh(w_del_msg);
620 }
621
622 void balls(void)
623 {
624 chtype ball1, ball2, ball3, ball4, ball5, ball6;
625
626 overlay(treescrn, treescrn2);
627
628 #ifdef A_COLOR
629 if (has_colors())
630 {
631 init_pair(1, COLOR_BLUE, COLOR_BLACK);
632 init_pair(2, COLOR_RED, COLOR_BLACK);
633 init_pair(3, COLOR_MAGENTA, COLOR_BLACK);
634 init_pair(4, COLOR_CYAN, COLOR_BLACK);
635 init_pair(5, COLOR_YELLOW, COLOR_BLACK);
636 init_pair(6, COLOR_WHITE, COLOR_BLACK);
637 ball1 = COLOR_PAIR(1) | '@';
638 ball2 = COLOR_PAIR(2) | '@';
639 ball3 = COLOR_PAIR(3) | '@';
640 ball4 = COLOR_PAIR(4) | '@';
641 ball5 = COLOR_PAIR(5) | '@';
642 ball6 = COLOR_PAIR(6) | '@';
643 }
644 else
645 #endif
646 ball1 = ball2 = ball3 = ball4 = ball5 = ball6 = '@';
647
648 mvwaddch(treescrn2, 3, 9, ball1);
649 mvwaddch(treescrn2, 3, 15, ball2);
650 mvwaddch(treescrn2, 4, 8, ball3);
651 mvwaddch(treescrn2, 4, 16, ball4);
652 mvwaddch(treescrn2, 5, 7, ball5);
653 mvwaddch(treescrn2, 5, 17, ball6);
654 mvwaddch(treescrn2, 7, 6, ball1 | A_BOLD);
655 mvwaddch(treescrn2, 7, 18, ball2 | A_BOLD);
656 mvwaddch(treescrn2, 8, 5, ball3 | A_BOLD);
657 mvwaddch(treescrn2, 8, 19, ball4 | A_BOLD);
658 mvwaddch(treescrn2, 10, 4, ball5 | A_BOLD);
659 mvwaddch(treescrn2, 10, 20, ball6 | A_BOLD);
660 mvwaddch(treescrn2, 11, 2, ball1);
661 mvwaddch(treescrn2, 11, 22, ball2);
662 mvwaddch(treescrn2, 12, 1, ball3);
663 mvwaddch(treescrn2, 12, 23, ball4);
664
665 wrefresh(treescrn2);
666 wrefresh(w_del_msg);
667 }
668
669 void star(void)
670 {
671 mvwaddch(treescrn2, 0, 12, (chtype) '*' | A_STANDOUT);
672
673 wrefresh(treescrn2);
674 wrefresh(w_del_msg);
675 }
676
677 void strng1(void)
678 {
679 #ifdef A_COLOR
680 if (has_colors())
681 {
682 init_pair(10, COLOR_YELLOW, COLOR_BLACK);
683 wattrset(treescrn2, COLOR_PAIR(10) | A_BOLD);
684 }
685 #endif
686 mvwaddstr(treescrn2, 3, 11, ".:'");
687
688 wrefresh(treescrn2);
689 wrefresh(w_del_msg);
690 }
691
692 void strng2(void)
693 {
694 #ifdef A_COLOR
695 if (has_colors())
696 {
697 init_pair(11, COLOR_RED, COLOR_BLACK);
698 wattrset(treescrn2, COLOR_PAIR(11) | A_BOLD);
699 }
700 #endif
701 mvwaddstr(treescrn2, 5, 11, ",.:'");
702 mvwaddstr(treescrn2, 6, 9, ":'");
703
704 wrefresh(treescrn2);
705 wrefresh(w_del_msg);
706 }
707
708 void strng3(void)
709 {
710 #ifdef A_COLOR
711 if (has_colors())
712 {
713 init_pair(12, COLOR_GREEN, COLOR_BLACK);
714 wattrset(treescrn2, COLOR_PAIR(12) | A_BOLD);
715 }
716 #endif
717 mvwaddstr(treescrn2, 7, 13, ",.:'");
718 mvwaddstr(treescrn2, 8, 9, ",.:'");
719
720 wrefresh(treescrn2);
721 wrefresh(w_del_msg);
722 }
723
724 void strng4(void)
725 {
726 #ifdef A_COLOR
727 if (has_colors())
728 {
729 init_pair(13, COLOR_WHITE, COLOR_BLACK);
730 wattrset(treescrn2, COLOR_PAIR(13) | A_BOLD);
731 }
732 #endif
733 mvwaddstr(treescrn2, 9, 14, ",.:'");
734 mvwaddstr(treescrn2, 10, 10, ",.:'");
735 mvwaddstr(treescrn2, 11, 6, ",.:'");
736 mvwaddch(treescrn2, 12, 5, (chtype) '\'');
737
738 wrefresh(treescrn2);
739 wrefresh(w_del_msg);
740 }
741
742 void strng5(void)
743 {
744 #ifdef A_COLOR
745 if (has_colors())
746 {
747 init_pair(14, COLOR_CYAN, COLOR_BLACK);
748 wattrset(treescrn2, COLOR_PAIR(14) | A_BOLD);
749 }
750 #endif
751 mvwaddstr(treescrn2, 11, 16, ",.:'");
752 mvwaddstr(treescrn2, 12, 12, ",.:'");
753
754 /* save a fully lit tree */
755 overlay(treescrn2, treescrn);
756
757 wrefresh(treescrn2);
758 wrefresh(w_del_msg);
759 }
760
761 void blinkit(void)
762 {
763 static int cycle;
764
765 if (cycle > 4)
766 cycle = 0;
767
768 touchwin(treescrn8);
769
770 switch (cycle)
771 {
772 case 0:
773 overlay(treescrn3, treescrn8);
774 break;
775
776 case 1:
777 overlay(treescrn4, treescrn8);
778 break;
779
780 case 2:
781 overlay(treescrn5, treescrn8);
782 break;
783
784 case 3:
785 overlay(treescrn6, treescrn8);
786 break;
787
788 case 4:
789 overlay(treescrn7, treescrn8);
790 }
791
792 wrefresh(treescrn8);
793 wrefresh(w_del_msg);
794
795 napms(50);
796 touchwin(treescrn8);
797
798 /*ALL ON************************************************** */
799
800 overlay(treescrn, treescrn8);
801 wrefresh(treescrn8);
802 wrefresh(w_del_msg);
803
804 ++cycle;
805 }
806
807 #define TSHOW(win, pause) touchwin(win); wrefresh(win); \
808 wrefresh(w_del_msg); napms(pause)
809
810 #define SHOW(win, pause) mvwin(win, y_pos, x_pos); wrefresh(win); \
811 wrefresh(w_del_msg); napms(pause)
812
813 void reindeer(void)
814 {
815 int looper;
816
817 y_pos = 0;
818
819 for (x_pos = 70; x_pos > 62; x_pos--)
820 {
821 if (x_pos < 62)
822 y_pos = 1;
823
824 for (looper = 0; looper < 4; looper++)
825 {
826 mvwaddch(dotdeer0, y_pos, x_pos, (chtype) '.');
827 wrefresh(dotdeer0);
828 wrefresh(w_del_msg);
829 werase(dotdeer0);
830 wrefresh(dotdeer0);
831 wrefresh(w_del_msg);
832 }
833 }
834
835 y_pos = 2;
836
837 for (; x_pos > 50; x_pos--)
838 {
839 for (looper = 0; looper < 4; looper++)
840 {
841 if (x_pos < 56)
842 {
843 y_pos = 3;
844
845 mvwaddch(stardeer0, y_pos, x_pos, (chtype) '*');
846 wrefresh(stardeer0);
847 wrefresh(w_del_msg);
848 werase(stardeer0);
849 wrefresh(stardeer0);
850 }
851 else
852 {
853 mvwaddch(dotdeer0, y_pos, x_pos, (chtype) '*');
854 wrefresh(dotdeer0);
855 wrefresh(w_del_msg);
856 werase(dotdeer0);
857 wrefresh(dotdeer0);
858 }
859 wrefresh(w_del_msg);
860 }
861 }
862
863 x_pos = 58;
864
865 for (y_pos = 2; y_pos < 5; y_pos++)
866 {
867 TSHOW(lildeer0, 50);
868
869 for (looper = 0; looper < 4; looper++)
870 {
871 SHOW(lildeer3, 50);
872 SHOW(lildeer2, 50);
873 SHOW(lildeer1, 50);
874 SHOW(lildeer2, 50);
875 SHOW(lildeer3, 50);
876
877 TSHOW(lildeer0, 50);
878
879 x_pos -= 2;
880 }
881 }
882
883 x_pos = 35;
884
885 for (y_pos = 5; y_pos < 10; y_pos++)
886 {
887 touchwin(middeer0);
888 wrefresh(middeer0);
889 wrefresh(w_del_msg);
890
891 for (looper = 0; looper < 2; looper++)
892 {
893 SHOW(middeer3, 50);
894 SHOW(middeer2, 50);
895 SHOW(middeer1, 50);
896 SHOW(middeer2, 50);
897 SHOW(middeer3, 50);
898
899 TSHOW(middeer0, 50);
900
901 x_pos -= 3;
902 }
903 }
904
905 napms(2000);
906
907 y_pos = 1;
908
909 for (x_pos = 8; x_pos < 16; x_pos++)
910 {
911 SHOW(bigdeer4, 30);
912 SHOW(bigdeer3, 30);
913 SHOW(bigdeer2, 30);
914 SHOW(bigdeer1, 30);
915 SHOW(bigdeer2, 30);
916 SHOW(bigdeer3, 30);
917 SHOW(bigdeer4, 30);
918 SHOW(bigdeer0, 30);
919 }
920
921 --x_pos;
922
923 for (looper = 0; looper < 6; looper++)
924 {
925 SHOW(lookdeer4, 40);
926 SHOW(lookdeer3, 40);
927 SHOW(lookdeer2, 40);
928 SHOW(lookdeer1, 40);
929 SHOW(lookdeer2, 40);
930 SHOW(lookdeer3, 40);
931 SHOW(lookdeer4, 40);
932 }
933
934 SHOW(lookdeer0, 40);
935
936 for (; y_pos < 10; y_pos++)
937 {
938 for (looper = 0; looper < 2; looper++)
939 {
940 SHOW(bigdeer4, 30);
941 SHOW(bigdeer3, 30);
942 SHOW(bigdeer2, 30);
943 SHOW(bigdeer1, 30);
944 SHOW(bigdeer2, 30);
945 SHOW(bigdeer3, 30);
946 SHOW(bigdeer4, 30);
947 }
948
949 SHOW(bigdeer0, 30);
950 }
951
952 --y_pos;
953
954 mvwin(lookdeer3, y_pos, x_pos);
955 wrefresh(lookdeer3);
956 wrefresh(w_del_msg);
957 }
File doc/Makefile added (mode: 100644) (index 00000000..8b5f3377)
1 # Makefile for PDCurses manext program.
2
3 all: manual
4
5 manual: PDCurses.txt
6
7 PDCurses.txt: manext
8 cat intro.txt > PDCurses.txt
9 echo PDCurses Definitions and Variables >> PDCurses.txt
10 echo ================================== >> PDCurses.txt
11 ./manext ../curses.h >> PDCurses.txt
12 echo PDCurses Functions >> PDCurses.txt
13 echo ================== >> PDCurses.txt
14 ./manext ../pdcurses/*.c >> PDCurses.txt
15 ./manext ../x11/*.c >> PDCurses.txt
16 cat x11.txt >> PDCurses.txt
17 echo >> PDCurses.txt
18 echo >> PDCurses.txt
19 echo \
20 -------------------------------------------------------------------------- \
21 >> PDCurses.txt
22 echo >> PDCurses.txt
23 cat sdl.txt >> PDCurses.txt
24
25 manext: manext.c
26
27 install:
28 echo Does nothing at the moment
29
30 clean:
31 -rm -rf *.o manext PDCurses.txt
32
33 distclean: clean
34
35 mostlyclean: clean
36
37 realclean: distclean
File doc/intro.txt added (mode: 100644) (index 00000000..a13cb7af)
1 PDCurses User's Guide
2 =====================
3
4 Curses Overview
5 ---------------
6
7 The X/Open Curses Interface Definition describes a set of C-Language
8 functions that provide screen-handling and updating, which are
9 collectively known as the curses library.
10
11 The curses library permits manipulation of data structures called
12 windows which may be thought of as two-dimensional arrays of
13 characters representing all or part of a terminal's screen. The
14 windows are manipulated using a procedural interface described
15 elsewhere. The curses package maintains a record of what characters
16 are on the screen. At the most basic level, manipulation is done with
17 the routines move() and addch() which are used to "move" the curses
18 around and add characters to the default window, stdscr, which
19 represents the whole screen.
20
21 An application may use these routines to add data to the window in any
22 convenient order. Once all data have been added, the routine
23 refresh() is called. The package then determines what changes have
24 been made which affect the screen. The screen contents are then
25 changed to reflect those characters now in the window, using a
26 sequence of operations optimized for the type of terminal in use.
27
28 At a higher level routines combining the actions of move() and addch()
29 are defined, as are routines to add whole strings and to perform
30 format conversions in the manner of printf().
31
32 Interfaces are also defined to erase the entire window and to specify
33 the attributes of individual characters in the window. Attributes
34 such as inverse video, underline and blink can be used on a
35 per-character basis.
36
37 New windows can be created by allowing the application to build
38 several images of the screen and display the appropriate one very
39 quickly. New windows are created using the routine newwin(). For
40 each routine that manipulates the default window, stdscr, there is a
41 corresponding routine prefixed with w to manipulate the contents of a
42 specified window; for example, move() and wmove(). In fact, move(...)
43 is functionally equivalent to wmove( stdscr, ...). This is similar to
44 the interface offered by printf(...) and fprintf(stdout, ...).
45
46 Windows do not have to correspond to the entire screen. It is
47 possible to create smaller windows, and also to indicate that the
48 window is only partially visible on the screen. Furthermore, large
49 windows or pads, which are bigger than the actual screen size, may be
50 created.
51
52 Interfaces are also defined to allow input character manipulation and
53 to disable and enable many input attributes: character echo, single
54 character input with or without signal processing (cbreak or raw
55 modes), carriage returns mapping to newlines, screen scrolling, etc.
56
57
58 Data Types and the <curses.h> Header
59 ------------------------------------
60
61 The data types supported by curses are described in this section.
62
63 As the library supports a procedural interface to the data types, actual
64 structure contents are not described. All curses data are manipulated
65 using the routines provided.
66
67
68 THE <curses.h> HEADER
69
70 The <curses.h> header defines various constants and declares the data
71 types that are available to the application.
72
73
74 DATA TYPES
75
76 The following data types are declared:
77
78 WINDOW * pointer to screen representation
79 SCREEN * pointer to terminal descriptor
80 bool boolean data type
81 chtype representation of a character in a window
82 cchar_t the wide-character equivalent of chtype
83 attr_t for WA_-style attributes
84
85 The actual WINDOW and SCREEN objects used to store information are
86 created by the corresponding routines and a pointer to them is provided.
87 All manipulation is through that pointer.
88
89
90 VARIABLES
91
92 The following variables are defined:
93
94 LINES number of lines on terminal screen
95 COLS number of columns on terminal screen
96 stdscr pointer to the default screen window
97 curscr pointer to the current screen image
98 SP pointer to the current SCREEN struct
99 Mouse_status status of the mouse
100 COLORS number of colors available
101 COLOR_PAIRS number of color pairs available
102 TABSIZE size of one TAB block
103 acs_map[] alternate character set map
104 ttytype[] terminal name/description
105
106
107 CONSTANTS
108
109 The following constants are defined:
110
111 GENERAL
112
113 FALSE boolean false value
114 TRUE boolean true value
115 NULL zero pointer value
116 ERR value returned on error condition
117 OK value returned on successful completion
118
119 VIDEO ATTRIBUTES
120
121 Normally, attributes are a property of the character.
122
123 For chtype:
124
125 A_ALTCHARSET use the alternate character set
126 A_BLINK bright background or blinking
127 A_BOLD bright foreground or bold
128 A_DIM half bright -- no effect in PDCurses
129 A_INVIS invisible
130 A_ITALIC italic
131 A_LEFTLINE line along the left edge
132 A_PROTECT protected (?) -- PDCurses renders this as a
133 combination of the *LINE attributes
134 A_REVERSE reverse video
135 A_RIGHTLINE line along the right edge
136 A_STANDOUT terminal's best highlighting mode
137 A_UNDERLINE underline
138
139 A_ATTRIBUTES bit-mask to extract attributes
140 A_CHARTEXT bit-mask to extract a character
141 A_COLOR bit-mask to extract a color-pair
142
143 Not all attributes will work on all terminals. A_RIGHTLINE, A_LEFTLINE
144 and A_ITALIC are specific to PDCurses. A_INVIS and A_ITALIC are given
145 the same value in PDCurses.
146
147 For attr_t:
148
149 WA_ALTCHARSET same as A_ALTCHARSET
150 WA_BLINK same as A_BLINK
151 WA_BOLD same as A_BOLD
152 WA_DIM same as A_DIM
153 WA_INVIS same as A_INVIS
154 WA_LEFT same as A_LEFTLINE
155 WA_PROTECT same as A_PROTECT
156 WA_REVERSE same as A_REVERSE
157 WA_RIGHT same as A_RIGHTLINE
158 WA_STANDOUT same as A_STANDOUT
159 WA_UNDERLINE same as A_UNDERLINE
160
161 Note that while A_LEFTLINE and A_RIGHTLINE are PDCurses-specific,
162 WA_LEFT and WA_RIGHT are standard. The following are also defined, for
163 compatibility, but currently have no effect in PDCurses: WA_HORIZONTAL,
164 WA_LOW, WA_TOP, WA_VERTICAL.
165
166 THE ALTERNATE CHARACTER SET
167
168 For use in chtypes and with related functions. These are a portable way
169 to represent graphics characters on different terminals.
170
171 VT100-compatible symbols -- box characters:
172
173 ACS_ULCORNER upper left box corner
174 ACS_LLCORNER lower left box corner
175 ACS_URCORNER upper right box corner
176 ACS_LRCORNER lower right box corner
177 ACS_RTEE right "T"
178 ACS_LTEE left "T"
179 ACS_BTEE bottom "T"
180 ACS_TTEE top "T"
181 ACS_HLINE horizontal line
182 ACS_VLINE vertical line
183 ACS_PLUS plus sign, cross, or four-corner piece
184
185 VT100-compatible symbols -- other:
186
187 ACS_S1 scan line 1
188 ACS_S9 scan line 9
189 ACS_DIAMOND diamond
190 ACS_CKBOARD checkerboard -- 50% grey
191 ACS_DEGREE degree symbol
192 ACS_PLMINUS plus/minus sign
193 ACS_BULLET bullet
194
195 Teletype 5410v1 symbols -- these are defined in SysV curses, but
196 are not well-supported by most terminals. Stick to VT100 characters
197 for optimum portability:
198
199 ACS_LARROW left arrow
200 ACS_RARROW right arrow
201 ACS_DARROW down arrow
202 ACS_UARROW up arrow
203 ACS_BOARD checkerboard -- lighter (less dense) than
204 ACS_CKBOARD
205 ACS_LANTERN lantern symbol
206 ACS_BLOCK solid block
207
208 That goes double for these -- undocumented SysV symbols. Don't use
209 them:
210
211 ACS_S3 scan line 3
212 ACS_S7 scan line 7
213 ACS_LEQUAL less than or equal
214 ACS_GEQUAL greater than or equal
215 ACS_PI pi
216 ACS_NEQUAL not equal
217 ACS_STERLING pounds sterling symbol
218
219 Box character aliases:
220
221 ACS_BSSB same as ACS_ULCORNER
222 ACS_SSBB same as ACS_LLCORNER
223 ACS_BBSS same as ACS_URCORNER
224 ACS_SBBS same as ACS_LRCORNER
225 ACS_SBSS same as ACS_RTEE
226 ACS_SSSB same as ACS_LTEE
227 ACS_SSBS same as ACS_BTEE
228 ACS_BSSS same as ACS_TTEE
229 ACS_BSBS same as ACS_HLINE
230 ACS_SBSB same as ACS_VLINE
231 ACS_SSSS same as ACS_PLUS
232
233 For cchar_t and wide-character functions, WACS_ equivalents are also
234 defined.
235
236 COLORS
237
238 For use with init_pair(), color_set(), etc.:
239
240 COLOR_BLACK
241 COLOR_BLUE
242 COLOR_GREEN
243 COLOR_CYAN
244 COLOR_RED
245 COLOR_MAGENTA
246 COLOR_YELLOW
247 COLOR_WHITE
248
249 Use these instead of numeric values. The definition of the colors
250 depends on the implementation of curses.
251
252
253 INPUT VALUES
254
255 The following constants might be returned by getch() if keypad() has
256 been enabled. Note that not all of these may be supported on a
257 particular terminal:
258
259 KEY_BREAK break key
260 KEY_DOWN the four arrow keys
261 KEY_UP
262 KEY_LEFT
263 KEY_RIGHT
264 KEY_HOME home key (upward+left arrow)
265 KEY_BACKSPACE backspace
266 KEY_F0 function keys; space for 64 keys is reserved
267 KEY_F(n) (KEY_F0+(n))
268 KEY_DL delete line
269 KEY_IL insert line
270 KEY_DC delete character
271 KEY_IC insert character
272 KEY_EIC exit insert character mode
273 KEY_CLEAR clear screen
274 KEY_EOS clear to end of screen
275 KEY_EOL clear to end of line
276 KEY_SF scroll 1 line forwards
277 KEY_SR scroll 1 line backwards (reverse)
278 KEY_NPAGE next page
279 KEY_PPAGE previous page
280 KEY_STAB set tab
281 KEY_CTAB clear tab
282 KEY_CATAB clear all tabs
283 KEY_ENTER enter or send
284 KEY_SRESET soft (partial) reset
285 KEY_RESET reset or hard reset
286 KEY_PRINT print or copy
287 KEY_LL home down or bottom (lower left)
288 KEY_A1 upper left of virtual keypad
289 KEY_A3 upper right of virtual keypad
290 KEY_B2 center of virtual keypad
291 KEY_C1 lower left of virtual keypad
292 KEY_C3 lower right of virtual keypad
293
294 KEY_BTAB Back tab key
295 KEY_BEG Beginning key
296 KEY_CANCEL Cancel key
297 KEY_CLOSE Close key
298 KEY_COMMAND Cmd (command) key
299 KEY_COPY Copy key
300 KEY_CREATE Create key
301 KEY_END End key
302 KEY_EXIT Exit key
303 KEY_FIND Find key
304 KEY_HELP Help key
305 KEY_MARK Mark key
306 KEY_MESSAGE Message key
307 KEY_MOVE Move key
308 KEY_NEXT Next object key
309 KEY_OPEN Open key
310 KEY_OPTIONS Options key
311 KEY_PREVIOUS Previous object key
312 KEY_REDO Redo key
313 KEY_REFERENCE Reference key
314 KEY_REFRESH Refresh key
315 KEY_REPLACE Replace key
316 KEY_RESTART Restart key
317 KEY_RESUME Resume key
318 KEY_SAVE Save key
319 KEY_SBEG Shifted beginning key
320 KEY_SCANCEL Shifted cancel key
321 KEY_SCOMMAND Shifted command key
322 KEY_SCOPY Shifted copy key
323 KEY_SCREATE Shifted create key
324 KEY_SDC Shifted delete char key
325 KEY_SDL Shifted delete line key
326 KEY_SELECT Select key
327 KEY_SEND Shifted end key
328 KEY_SEOL Shifted clear line key
329 KEY_SEXIT Shifted exit key
330 KEY_SFIND Shifted find key
331 KEY_SHELP Shifted help key
332 KEY_SHOME Shifted home key
333 KEY_SIC Shifted input key
334 KEY_SLEFT Shifted left arrow key
335 KEY_SMESSAGE Shifted message key
336 KEY_SMOVE Shifted move key
337 KEY_SNEXT Shifted next key
338 KEY_SOPTIONS Shifted options key
339 KEY_SPREVIOUS Shifted prev key
340 KEY_SPRINT Shifted print key
341 KEY_SREDO Shifted redo key
342 KEY_SREPLACE Shifted replace key
343 KEY_SRIGHT Shifted right arrow
344 KEY_SRSUME Shifted resume key
345 KEY_SSAVE Shifted save key
346 KEY_SSUSPEND Shifted suspend key
347 KEY_SUNDO Shifted undo key
348 KEY_SUSPEND Suspend key
349 KEY_UNDO Undo key
350
351 The virtual keypad is arranged like this:
352
353 A1 up A3
354 left B2 right
355 C1 down C3
356
357 This list is incomplete -- see curses.h for the full list, and use the
358 testcurs demo to see what values are actually returned. The above are
359 just the keys required by X/Open. In particular, PDCurses defines many
360 CTL_ and ALT_ combinations; these are not portable.
361
362
363 FUNCTIONS
364
365 The following table lists each curses routine and the name of the manual
366 page on which it is described.
367
368 Functions from the X/Open curses standard -- complete, except for
369 getch() and ungetch(), which are implemented as macros for DOS
370 compatibility:
371
372 Curses Function Manual Page Name
373
374 addch addch
375 addchnstr addchstr
376 addchstr addchstr
377 addnstr addstr
378 addstr addstr
379 attroff attr
380 attron attr
381 attrset attr
382 attr_get attr
383 attr_off attr
384 attr_on attr
385 attr_set attr
386 baudrate termattr
387 beep beep
388 bkgd bkgd
389 bkgdset bkgd
390 border border
391 box border
392 can_change_color color
393 cbreak inopts
394 chgat attr
395 clearok outopts
396 clear clear
397 clrtobot clear
398 clrtoeol clear
399 color_content color
400 color_set attr
401 copywin overlay
402 curs_set kernel
403 def_prog_mode kernel
404 def_shell_mode kernel
405 del_curterm terminfo
406 delay_output util
407 delch delch
408 deleteln deleteln
409 delscreen initscr
410 delwin window
411 derwin window
412 doupdate refresh
413 dupwin window
414 echochar addch
415 echo inopts
416 endwin initscr
417 erasechar termattr
418 erase clear
419 filter util
420 flash beep
421 flushinp getch
422 getbkgd bkgd
423 getnstr getstr
424 getstr getstr
425 getwin scr_dump
426 halfdelay inopts
427 has_colors color
428 has_ic termattr
429 has_il termattr
430 hline border
431 idcok outopts
432 idlok outopts
433 immedok outopts
434 inchnstr inchstr
435 inchstr inchstr
436 inch inch
437 init_color color
438 init_pair color
439 initscr initscr
440 innstr instr
441 insch insch
442 insdelln deleteln
443 insertln deleteln
444 insnstr innstr
445 insstr innstr
446 instr instr
447 intrflush inopts
448 isendwin initscr
449 is_linetouched touch
450 is_wintouched touch
451 keyname keyname
452 keypad inopts
453 killchar termattr
454 leaveok outopts
455 longname termattr
456 meta inopts
457 move move
458 mvaddch addch
459 mvaddchnstr addchstr
460 mvaddchstr addchstr
461 mvaddnstr addstr
462 mvaddstr addstr
463 mvchgat attr
464 mvcur terminfo
465 mvdelch delch
466 mvderwin window
467 mvgetch getch
468 mvgetnstr getstr
469 mvgetstr getstr
470 mvhline border
471 mvinch inch
472 mvinchnstr inchstr
473 mvinchstr inchstr
474 mvinnstr instr
475 mvinsch insch
476 mvinsnstr insstr
477 mvinsstr insstr
478 mvinstr instr
479 mvprintw printw
480 mvscanw scanw
481 mvvline border
482 mvwaddchnstr addchstr
483 mvwaddchstr addchstr
484 mvwaddch addch
485 mvwaddnstr addstr
486 mvwaddstr addstr
487 mvwchgat attr
488 mvwdelch delch
489 mvwgetch getch
490 mvwgetnstr getstr
491 mvwgetstr getstr
492 mvwhline border
493 mvwinchnstr inchstr
494 mvwinchstr inchstr
495 mvwinch inch
496 mvwinnstr instr
497 mvwinsch insch
498 mvwinsnstr insstr
499 mvwinsstr insstr
500 mvwinstr instr
501 mvwin window
502 mvwprintw printw
503 mvwscanw scanw
504 mvwvline border
505 napms kernel
506 newpad pad
507 newterm initscr
508 newwin window
509 nl inopts
510 nocbreak inopts
511 nodelay inopts
512 noecho inopts
513 nonl inopts
514 noqiflush inopts
515 noraw inopts
516 notimeout inopts
517 overlay overlay
518 overwrite overlay
519 pair_content color
520 pechochar pad
521 pnoutrefresh pad
522 prefresh pad
523 printw printw
524 putp terminfo
525 putwin scr_dump
526 qiflush inopts
527 raw inopts
528 redrawwin refresh
529 refresh refresh
530 reset_prog_mode kernel
531 reset_shell_mode kernel
532 resetty kernel
533 restartterm terminfo
534 ripoffline kernel
535 savetty kernel
536 scanw scanw
537 scr_dump scr_dump
538 scr_init scr_dump
539 scr_restore scr_dump
540 scr_set scr_dump
541 scrl scroll
542 scroll scroll
543 scrollok outopts
544 set_term initscr
545 setscrreg outopts
546 setterm terminfo
547 setupterm terminfo
548 slk_attroff slk
549 slk_attr_off slk
550 slk_attron slk
551 slk_attr_on slk
552 slk_attrset slk
553 slk_attr_set slk
554 slk_clear slk
555 slk_color slk
556 slk_init slk
557 slk_label slk
558 slk_noutrefresh slk
559 slk_refresh slk
560 slk_restore slk
561 slk_set slk
562 slk_touch slk
563 standend attr
564 standout attr
565 start_color color
566 subpad pad
567 subwin window
568 syncok window
569 termattrs termattrs
570 term_attrs termattrs
571 termname termattrs
572 tgetent termcap
573 tgetflag termcap
574 tgetnum termcap
575 tgetstr termcap
576 tgoto termcap
577 tigetflag terminfo
578 tigetnum terminfo
579 tigetstr terminfo
580 timeout inopts
581 touchline touch
582 touchwin touch
583 tparm terminfo
584 tputs terminfo
585 typeahead inopts
586 untouchwin touch
587 use_env util
588 vidattr terminfo
589 vid_attr terminfo
590 vidputs terminfo
591 vid_puts terminfo
592 vline border
593 vw_printw printw
594 vwprintw printw
595 vw_scanw scanw
596 vwscanw scanw
597 waddchnstr addchstr
598 waddchstr addchstr
599 waddch addch
600 waddnstr addstr
601 waddstr addstr
602 wattroff attr
603 wattron attr
604 wattrset attr
605 wattr_get attr
606 wattr_off attr
607 wattr_on attr
608 wattr_set attr
609 wbkgdset bkgd
610 wbkgd bkgd
611 wborder border
612 wchgat attr
613 wclear clear
614 wclrtobot clear
615 wclrtoeol clear
616 wcolor_set attr
617 wcursyncup window
618 wdelch delch
619 wdeleteln deleteln
620 wechochar addch
621 werase clear
622 wgetch getch
623 wgetnstr getstr
624 wgetstr getstr
625 whline border
626 winchnstr inchstr
627 winchstr inchstr
628 winch inch
629 winnstr instr
630 winsch insch
631 winsdelln deleteln
632 winsertln deleteln
633 winsnstr insstr
634 winsstr insstr
635 winstr instr
636 wmove move
637 wnoutrefresh refresh
638 wprintw printw
639 wredrawln refresh
640 wrefresh refresh
641 wscanw scanw
642 wscrl scroll
643 wsetscrreg outopts
644 wstandend attr
645 wstandout attr
646 wsyncdown window
647 wsyncup window
648 wtimeout inopts
649 wtouchln touch
650 wvline border
651
652 Wide-character functions from the X/Open standard -- these are only
653 available when PDCurses is built with PDC_WIDE defined, and the
654 prototypes are only available from curses.h when PDC_WIDE is defined
655 before its inclusion in your app:
656
657 addnwstr addstr
658 addwstr addstr
659 add_wch addch
660 add_wchnstr addchstr
661 add_wchstr addchstr
662 border_set border
663 box_set border
664 echo_wchar addch
665 erasewchar termattr
666 getbkgrnd bkgd
667 getcchar util
668 getn_wstr getstr
669 get_wch getch
670 get_wstr getstr
671 hline_set border
672 innwstr instr
673 ins_nwstr insstr
674 ins_wch insch
675 ins_wstr insstr
676 inwstr instr
677 in_wch inch
678 in_wchnstr inchstr
679 in_wchstr inchstr
680 key_name keyname
681 killwchar termattr
682 mvaddnwstr addstr
683 mvaddwstr addstr
684 mvadd_wch addch
685 mvadd_wchnstr addchstr
686 mvadd_wchstr addchstr
687 mvgetn_wstr getstr
688 mvget_wch getch
689 mvget_wstr getstr
690 mvhline_set border
691 mvinnwstr instr
692 mvins_nwstr insstr
693 mvins_wch insch
694 mvins_wstr insstr
695 mvinwstr instr
696 mvwaddnwstr addstr
697 mvwaddwstr addstr
698 mvwadd_wch addch
699 mvwadd_wchnstr addchstr
700 mvwadd_wchstr addchstr
701 mvwgetn_wstr getstr
702 mvwget_wch getch
703 mvwget_wstr getstr
704 mvwhline_set border
705 mvwinnwstr instr
706 mvwins_nwstr insstr
707 mvwins_wch insch
708 mvwins_wstr insstr
709 mvwin_wch inch
710 mvwin_wchnstr inchstr
711 mvwin_wchstr inchstr
712 mvwinwstr instr
713 mvwvline_set border
714 pecho_wchar pad
715 setcchar util
716 slk_wset slk
717 unget_wch getch
718 vline_set border
719 waddnwstr addstr
720 waddwstr addstr
721 wadd_wch addch
722 wadd_wchnstr addchstr
723 wadd_wchstr addchstr
724 wbkgrnd bkgd
725 wbkgrndset bkgd
726 wborder_set border
727 wecho_wchar addch
728 wgetbkgrnd bkgd
729 wgetn_wstr getstr
730 wget_wch getch
731 wget_wstr getstr
732 whline_set border
733 winnwstr instr
734 wins_nwstr insstr
735 wins_wch insch
736 wins_wstr insstr
737 winwstr instr
738 win_wch inch
739 win_wchnstr inchstr
740 win_wchstr inchstr
741 wunctrl util
742 wvline_set border
743
744 Quasi-standard functions, from Sys V or BSD curses:
745
746 getattrs attr
747 getbegx getyx
748 getbegy getyx
749 getmaxx getyx
750 getmaxy getyx
751 getparx getyx
752 getparx getyx
753 traceoff debug
754 traceon debug
755 unctrl util
756
757 Classic PDCurses mouse functions, based on Sys V:
758
759 mouse_set mouse
760 mouse_on mouse
761 mouse_off mouse
762 request_mouse_pos mouse
763 map_button mouse
764 wmouse_position mouse
765 getmouse mouse
766 getbmap mouse
767
768 Functions from ncurses:
769
770 assume_default_colors color
771 curses_version initscr
772 has_key keyname
773 use_default_colors color
774 wresize window
775
776 mouseinterval mouse
777 mousemask mouse
778 mouse_trafo mouse
779 nc_getmouse mouse
780 ungetmouse mouse
781 wenclose mouse
782 wmouse_trafo mouse
783
784 PDCurses-specific functions -- avoid these in code that's intended to be
785 portable:
786
787 addrawch addch
788 insrawch insch
789 is_termresized initscr
790 mvaddrawch addch
791 mvdeleteln deleteln
792 mvinsertln deleteln
793 mvinsrawch insch
794 mvwaddrawch addch
795 mvwdeleteln deleteln
796 mvwinsertln deleteln
797 mvwinsrawch insch
798 raw_output outopts
799 resize_term initscr
800 resize_window window
801 slk_wlabel slk
802 waddrawch addch
803 winsrawch insch
804 wordchar termattr
805
806 PDC_debug debug
807 PDC_ungetch getch
808 PDC_set_blink pdcsetsc
809 PDC_set_line_color color
810 PDC_set_title pdcsetsc
811
812 PDC_clearclipboard pdcclip
813 PDC_freeclipboard pdcclip
814 PDC_getclipboard pdcclip
815 PDC_setclipboard pdcclip
816
817 PDC_get_input_fd pdckbd
818 PDC_get_key_modifiers getch
819 PDC_return_key_modifiers getch
820 PDC_save_key_modifiers getch
821
822 Functions specific to the X11 port of PDCurses:
823
824 Xinitscr initscr
825 XCursesExit -
826 sb_init sb
827 sb_set_horz sb
828 sb_set_vert sb
829 sb_get_horz sb
830 sb_get_vert sb
831 sb_refresh sb
832
833 --------------------------------------------------------------------------
834
File doc/manext.c added (mode: 100644) (index 00000000..4ce7cbf5)
1 /***********************************************************************/
2 /* MANEXT - Extract manual pages from C source code. */
3 /***********************************************************************/
4 /*
5 * MANEXT - A program to extract manual pages from C source code.
6 * Copyright (C) 1991-1996 Mark Hessling
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * If you make modifications to this software that you feel increases
19 * it usefulness for the rest of the community, please email the
20 * changes, enhancements, bug fixes as well as any and all ideas to me.
21 * This software is going to be maintained and enhanced as deemed
22 * necessary by the community.
23 *
24 * Mark Hessling <mark@rexx.org>
25 */
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30
31 #define MAX_LINE 255
32
33 void display_info()
34 {
35 fprintf(stderr, "\nMANEXT 1.03 Copyright (C) 1991-1996 Mark Hessling\n"
36 "All rights reserved.\n"
37 "MANEXT is distributed under the terms of the GNU\n"
38 "General Public License and comes with NO WARRANTY.\n"
39 "See the file COPYING for details.\n"
40 "\nUsage: manext sourcefile [...]\n\n");
41 }
42
43 int main(int argc, char **argv)
44 {
45 char s[MAX_LINE + 1]; /* input line */
46 int i;
47 FILE *fp;
48
49 #ifdef __EMX__
50 _wildcard(&argc, &argv);
51 #endif
52 if (strcmp(argv[1], "-h") == 0)
53 {
54 display_info();
55 exit(1);
56 }
57
58 for (i = 1; i < argc; i++)
59 {
60 if ((fp = fopen(argv[i], "r")) == NULL)
61 {
62 fprintf(stderr, "\nCould not open %s\n", argv[i]);
63 continue;
64 }
65
66 while (!feof(fp))
67 {
68 if (fgets(s, (int)sizeof(s), fp) == NULL)
69 {
70 if (ferror(fp) != 0)
71 {
72 fprintf(stderr, "*** Error reading %s. Exiting.\n",
73 argv[i]);
74 exit(1);
75 }
76
77 break;
78 }
79
80 /* check for manual entry marker at beginning of line */
81
82 if (strncmp(s, "/*man-start*", 12) != 0)
83 continue;
84
85 /* inner loop */
86
87 for (;;)
88 {
89 /* read next line of manual entry */
90
91 if (fgets(s, (int)sizeof(s), fp) == NULL)
92 {
93 if (ferror(fp) != 0)
94 {
95 fprintf(stderr, "*** Error reading %s. Exiting.\n",
96 argv[i]);
97 exit(1);
98 }
99
100 break;
101 }
102
103 /* check for end of entry marker */
104
105 if (strncmp(s, "**man-end", 9) == 0)
106 break;
107
108 printf("%s", s);
109 }
110
111 printf("\n\n-----------------------------------"
112 "---------------------------------------\n\n");
113 }
114
115 fclose(fp);
116 }
117
118 return 0;
119 }
File doc/sdl.txt added (mode: 100644) (index 00000000..6a54b9b4)
1 SDL Considerations
2 ==================
3
4 There are no special requirements to use PDCurses for SDL -- all
5 PDCurses-compatible code should work fine. (In fact, you can even build
6 against the Win32 console pdcurses.dll, and then swap in the SDL
7 pdcurses.dll.) Nothing extra is needed beyond the base SDL library.
8 However, there are some optional special features, described here.
9
10 The principal limitation of this port is that input is currently
11 restricted to ASCII (i.e., 0-127), plus the special keys like KEY_LEFT.
12 (You could have Unicode input, but then the input wouldn't match the
13 output, which is in Code Page 437.) Also, see the note about the
14 potential for incomplete output under "PDC_update_rects()", below.
15
16
17 Fonts
18 -----
19
20 The font is a simple BMP, 32 characters wide by 8 characters tall,
21 preferably with a palette. (BMPs without palettes still work, but in
22 that case, no attributes will be available, nor will the cursor work.)
23 The first entry in the palette (usually black) is treated as the
24 background color; the last entry (usually white) is treated as the
25 foreground. These are changed or made transparent as appropriate; any
26 other colors in the palette are passed through unchanged. So -- although
27 a one-bit depth is sufficient for a normal font -- you could redraw some
28 characters as multi-colored tiles.
29
30 The font must be monospaced. The size of each character is derived by
31 dividing the width of the BMP by 32 and the height by 8. There is no
32 constraint on the dimensions.
33
34 As provided in the default font and expected by acs_map[], the font is
35 in Code Page 437 form. But you can of course use any layout if you're
36 not relying on correct values for the ACS_* macros.
37
38 The font can be set via the environment variable PDC_FONT. If it's not
39 set, PDCurses looks for a file named "pdcfont.bmp" in the current
40 directory at the time of initscr(). If neither is found, it uses the
41 built-in default font encoded in deffont.h.
42
43
44 Backgrounds
45 -----------
46
47 PDCurses for SDL supports an optional background image BMP. This is used
48 whenever start_color() has not been called (see the ptest demo for an
49 example), or when use_default_colors() has been called after
50 start_color(), and the background color of a pair has been set to -1
51 (see newdemo, worm, and rain for examples). The usage parallels that of
52 ncurses in an appropriate terminal (e.g., Gnome Terminal). The image is
53 tiled to cover the PDCurses window, and can be any size or depth.
54
55 As with the font, you can point to a location for the background via the
56 environment variable PDC_BACKGROUND; "pdcback.bmp" is the fallback.
57 (There is no default background.)
58
59
60 Icons
61 -----
62
63 The icon (used with SDL_WM_SetIcon() -- not used for the executable
64 file) can be set via the environment variable PDC_ICON, and falls back
65 to "pdcicon.bmp", and then to the built-in icon from deficon.h. The
66 built-in icon is the PDCurses logo, as seen in ../x11/little_icon.xbm.
67 The SDL docs say that the icon must be 32x32, at least for use with MS
68 Windows.
69
70 If pdc_screen is preinitialized (see below), PDCurses does not attempt
71 to set the icon.
72
73
74 Screen size
75 -----------
76
77 The default screen size is 80x25 characters (whatever size they may be),
78 but you can override this via the environment variables PDC_COLS and/or
79 PDC_LINES. (Some other ports use COLS and LINES; this is not done here
80 because those values are, or should be, those of the controlling
81 terminal, and PDCurses for SDL is independent of the terminal.) If
82 pdc_screen is preinitialized (see below), these are ignored.
83
84
85 Integration with SDL
86 --------------------
87
88 If you want to go further, you can mix PDCurses and SDL functions. (Of
89 course this is extremely non-portable!) To aid you, there are several
90 external variables and functions specific to the SDL port; you could
91 include pdcsdl.h, or just add the declarations you need in your code:
92
93 PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back;
94 PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset;
95
96 void PDC_update_rects(void);
97 void PDC_retile(void);
98
99 pdc_screen is the main surface, created by SDL_SetVideoMode(), unless
100 it's preset before initscr(). You can perform normal SDL operations on
101 this surface, but PDCurses won't respect them when it updates. (For
102 that, see PDC_retile().) As an alternative, you can preinitialize this
103 surface before calling initscr(). In that case, you can use pdc_sheight,
104 pdc_swidth, pdc_yoffset and/or pdc_xoffset (q.v.) to confine PDCurses to
105 only a specific area of the surface, reserving the rest for other SDL
106 operations. If you preinitialize pdc_screen, you'll have to close it
107 yourself; PDCurses will ignore resize events, and won't try to set the
108 icon. Also note that if you preinitialize pdc_screen, it need not be the
109 display surface.
110
111 pdc_font, pdc_icon, and pdc_back are the SDL_surfaces for the font,
112 icon, and background, respectively. You can set any or all of them
113 before initscr(), and thus override any of the other ways to set them.
114 But note that pdc_icon will be ignored if pdc_screen is preset.
115
116 pdc_sheight and pdc_swidth are the dimensions of the area of pdc_screen
117 to be used by PDCurses. You can preset them before initscr(); if either
118 is not set, it defaults to the full screen size minus the x or y offset,
119 as appropriate.
120
121 pdc_xoffset and pdc_yoffset are the x and y offset for the area of
122 pdc_screen to be used by PDCurses. See the sdltest demo for an example.
123
124 PDC_retile() makes a copy of pdc_screen, then tiles it with the
125 background image, if any. The resulting surface is used as the
126 background for transparent character cells. PDC_retile() is called from
127 initscr() and resize_term(). However, you can also use it at other
128 times, to take advantage of the way it copies pdc_screen: Draw some SDL
129 stuff; call PDC_retile(); do some curses stuff -- it will use whatever
130 was on pdc_screen as the background. Then you can erase the curses
131 screen, do some more SDL stuff, and call PDC_retile() again to make a
132 new background. (If you don't erase the curses screen, it will be
133 incorporated into the background when you call PDC_retile().) But this
134 only works if no background image is set.
135
136 PDC_update_rects() is how the screen actually gets updated. For
137 performance reasons, when drawing, PDCurses for SDL maintains a table of
138 rectangles that need updating, and only updates (by calling this
139 function) during getch(), napms(), or when the table gets full.
140 Normally, this is sufficient; but if you're pausing in some way other
141 than by using napms(), and you're not doing keyboard checks, you may get
142 an incomplete update. If that happens, you can call PDC_update_rects()
143 manually.
144
145
146 Interaction with stdio
147 ----------------------
148
149 As with X11, it's a bad idea to mix curses and stdio calls. (In fact,
150 that's true for PDCurses on any platform; but especially these two,
151 which don't run under terminals.) Depending on how SDL is built, stdout
152 and stderr may be redirected to files.
File doc/x11.txt added (mode: 100644) (index 00000000..db05683d)
1 X11 Considerations
2 ==================
3
4 PDCurses for X11 uses the System V IPC shared memory facility, along
5 with sockets, to share data between the curses program and the child
6 process created to manage the X stuff.
7
8 When compiling your application, you need to include the <curses.h> or
9 <xcurses.h> that comes with PDCurses. You also need to link your code
10 with libXCurses. You may need to link with the following libraries under
11 X11R5:
12 Xaw Xmu Xt X11
13
14 or, under X11R6:
15 Xaw Xmu Xt X11 SM ICE Xext
16
17 You can run "xcurses-config --libs" to show the link parameters for your
18 system. If using dynamic linking, on some systems, "-lXCurses" suffices.
19
20 By calling Xinitscr() rather than initscr(), you can pass your program
21 name and resource overrides to PDCurses. The program name is used as the
22 title of the X window, and for defining X resources specific to your
23 program.
24
25
26 Interaction with stdio
27 ----------------------
28
29 Be aware that curses programs that expect to have a normal tty
30 underneath them will be very disappointed! Output directed to stdout
31 will go to the xterm that invoked the PDCurses application, or to the
32 console if not invoked directly from an xterm. Similarly, stdin will
33 expect its input from the same place as stdout.
34
35
36 X Resources
37 -----------
38
39 PDCurses for X11 recognizes the following resources:
40
41 lines
42 cols
43 normalFont
44 italicFont
45 pointer
46 pointerForeColor
47 pointerBackColor
48 cursorColor
49 textCursor
50 colorBlack
51 colorRed
52 colorGreen
53 colorYellow
54 colorBlue
55 colorMagenta
56 colorCyan
57 colorWhite
58 colorBoldBlack
59 colorBoldRed
60 colorBoldGreen
61 colorBoldYellow
62 colorBoldBlue
63 colorBoldMagenta
64 colorBoldCyan
65 colorBoldWhite
66 bitmap
67 pixmap
68 translations
69 shmmin
70 borderWidth
71 borderColor
72 clickPeriod
73 doubleClickPeriod
74 composeKey
75
76 lines: Specifies the number of lines the "screen" will have.
77 Directly equates to LINES.
78 There is no theoretical maximum.
79 The minimum value must be 2.
80 Default: 24
81
82 cols: Specifies the number of columns the "screen" will have.
83 Directly equates to COLS.
84 There is no theoretical maximum.
85 The minimum value must be 2.
86 Default: 80
87
88 normalFont: The name of a fixed width font.
89 Default: 7x13
90
91 italicFont: The name of a fixed width font to be used for
92 characters with A_ITALIC attributes. Must have the
93 same cell size as normalFont.
94 Default: 7x13 (obviously not an italic font)
95
96 pointer: The name of a valid pointer cursor.
97 Default: xterm
98
99 pointerForeColor: The foreground color of the pointer.
100 Default: black
101
102 pointerBackColor: The background color of the pointer.
103 Default: white
104
105 textCursor: The alignment of the text cursor; horizontal or vertical.
106 Default: horizontal
107
108 colorBlack: The color of the COLOR_BLACK attribute.
109 Default: Black
110
111 colorRed: The color of the COLOR_RED attribute.
112 Default: red3
113
114 colorGreen: The color of the COLOR_GREEN attribute.
115 Default: green3
116
117 colorYellow: The color of the COLOR_YELLOW attribute.
118 Default: yellow3
119
120 colorBlue: The color of the COLOR_BLUE attribute.
121 Default: blue3
122
123 colorMagenta: The color of the COLOR_MAGENTA attribute.
124 Default: magenta3
125
126 colorCyan: The color of the COLOR_CYAN attribute.
127 Default: cyan3
128
129 colorWhite: The color of the COLOR_WHITE attribute.
130 Default: Grey
131
132 colorBoldBlack: COLOR_BLACK combined with A_BOLD.
133 Default: grey40
134
135 colorBoldRed: COLOR_RED combined with A_BOLD.
136 Default: red1
137
138 colorBoldGreen: COLOR_GREEN combined with A_BOLD.
139 Default: green1
140
141 colorBoldYellow: COLOR_YELLOW combined with A_BOLD.
142 Default: yellow1
143
144 colorBoldBlue: COLOR_BLUE combined with A_BOLD.
145 Default: blue1
146
147 colorBoldMagenta: COLOR_MAGENTA combined with A_BOLD.
148 Default: magenta1
149
150 colorBoldCyan: COLOR_CYAN combined with A_BOLD.
151 Default: cyan1
152
153 colorBoldWhite: COLOR_WHITE combined with A_BOLD.
154 Default: White
155
156 bitmap: The name of a valid bitmap file of depth 1 (black and white)
157 used for the application's icon. The file is an X bitmap.
158 Default: a 32x32 or 64x64 pixmap depending on the
159 window manager
160
161 pixmap: The name of a valid pixmap file of any depth
162 supported by the window manager (color) for the
163 application's icon, The file is an X11 pixmap. This
164 resource is only available if the libXpm package has
165 been installed (most systems have this by default).
166 This resource overrides the "bitmap" resource.
167 Default: none, uses default bitmap above
168
169 translations: Translations enable the user to customize the action
170 that occurs when a key, combination of keys, or a
171 button is pressed. The translations are similar to
172 those used by xterm.
173 Defaults:
174 <Key>: XCursesKeyPress()
175 <KeyUp>: XCursesKeyPress()
176 <BtnDown>: XCursesButton()
177 <BtnUp>: XCursesButton()
178 <BtnMotion>: XCursesButton()
179
180 The most useful action for KeyPress translations is
181 string(). The argument to the string() action can be
182 either a string or a hex representation of a
183 character; e.g., string(0x1b) will send the ASCII
184 escape character to the application; string("[11~")
185 will send [ 1 1 ~ , as separate keystrokes.
186
187 shmmin: On most systems, there are two Unix kernel parameters
188 that determine the allowable size of a shared memory
189 segment. These parameters are usually something like
190 SHMMIN and SHMMAX. To use shared memory, a program
191 must allocate a segment of shared memory that is
192 between these two values. Usually these values are
193 like 1 for SHMMIN and some large number for SHMMAX.
194 Sometimes the Unix kernel is configured to have a
195 value of SHMMIN that is bigger than the size of one
196 of the shared memory segments that libXCurses uses.
197 On these systems an error message like:
198
199 Cannot allocate shared memory for SCREEN: Invalid argument
200
201 will result. To overcome this problem, this resource
202 should be set to the kernel value for SHMMIN. This
203 ensures that a shared memory segment will always be
204 bigger than the kernel value for SHMMIN (and
205 hopefully less than SHMMAX!)
206
207 Default: 0
208
209 borderColor: The color of the border around the screen.
210 Default: black
211
212 borderWidth: The width in pixels of the border around the screen.
213 Default: 0
214
215 clickPeriod: The period (in milliseconds) between a button
216 press and a button release that determines if a click
217 of a button has occurred.
218 Default: 100
219
220 doubleClickPeriod: The period (in milliseconds) between two button
221 press events that determines if a double click
222 of a button has occurred.
223 Default: 200
224
225 composeKey: The name of the X key that defines the "compose key",
226 which is used to enter characters in the Latin-1
227 character set above 0xA0. (See "Compose Keys for
228 Latin-1" below.) This is used only when PDCurses is
229 built without XIM support. While in compose mode, the
230 text cursor will appear as a hollow rectangle.
231 Default: Multi_key
232
233
234 Using Resources
235 ---------------
236
237 All applications have a top-level class name of "XCurses". If Xinitscr()
238 is used, it sets an application's top-level widget name. (Otherwise the
239 name defaults to "PDCurses".)
240
241 Examples for app-defaults or .Xdefaults:
242
243 !
244 ! resources for XCurses class of programs
245 !
246 XCurses*lines: 30
247 XCurses*cols: 80
248 XCurses*normalFont: 9x13
249 XCurses*bitmap: /tmp/xcurses.xbm
250 XCurses*pointer: top_left_arrow
251 !
252 ! resources for testcurs - XCurses
253 !
254 testcurs.colorRed: orange
255 testcurs.colorBlack: midnightblue
256 testcurs.lines: 25
257 *testcurs.Translations: #override \n \
258 <Key>F12: string(0x1b) string("[11~") \n
259 !
260 ! resources for THE - XCurses
261 !
262 ! resources with the * wildcard can be overridden by a parameter passed
263 ! to initscr()
264 !
265 the*normalFont: 9x15
266 the*lines: 40
267 the*cols: 86
268 the*pointer: xterm
269 the*pointerForeColor: white
270 the*pointerBackColor: black
271 !
272 ! resources with the . format can not be overridden by a parameter passed
273 ! to Xinitscr()
274 !
275 the.bitmap: /home/mark/the/the64.xbm
276 the.pixmap: /home/mark/the/the64.xpm
277
278 Resources may also be passed as parameters to the Xinitscr() function.
279 Parameters are strings in the form of switches; e.g., to set the color
280 "red" to "indianred", and the number of lines to 30, the string passed
281 to Xinitscr would be: "-colorRed indianred -lines 30"
282
283
284 Compose Keys for Latin-1
285 ------------------------
286
287 When built without XIM support, PDCurses for X11 provides its own,
288 limited compose key system for Latin-1 characters. The available
289 combinations are listed here. For a given character, any of the
290 combinations shown in the last column may be used. To generate a
291 character, press the "compose" key followed by one of the pairs of
292 keystrokes. Where no key is evident, the spacebar is used. Thus, to
293 generate the NO-BREAK SPACE, press the "compose" key followed by two
294 hits of the spacebar.
295
296 With a typical modern X server, you can get many more compose key
297 combinations by using XIM instead. Configure PDCurses with --enable-xim
298 to use XIM support.
299
300 This document is encoded in UTF-8.
301
302 +----+-----+---+---------------------------------+---------------------------+
303 |Hex | Dec |Chr| Description ISO 10646-1:1993(E) | Compose key combinations |
304 +----+-----+---+---------------------------------+---------------------------+
305 | A0 | 160 | | NO-BREAK SPACE | |
306 | A1 | 161 | ¡ | INVERTED EXCLAMATION MARK | ! !! |
307 | A2 | 162 | ¢ | CENT SIGN | c| |c c/ c$ C$ C| |
308 | A3 | 163 | £ | POUND SIGN | L- L$ L= l- l$ l= |-|
309 | A4 | 164 | ¤ | CURRENCY SIGN | xo ox XO g$ |
310 | A5 | 165 | ¥ | YEN SIGN | =y y= =Y Y= Y- y$ y-|
311 | A6 | 166 | ¦ | BROKEN BAR | | || vb VB |^ |
312 | A7 | 167 | § | SECTION SIGN | SO SS s! S! so |
313 | A8 | 168 | ¨ | DIAERESIS | " "" |
314 | A9 | 169 | © | COPYRIGHT SIGN | CO co OC |
315 | AA | 170 | ª | FEMININE ORDINAL INDICATOR | sa SA a_ A_ |
316 | AB | 171 | « | LEFT DOUBLE ANGLE QUOTES | << |
317 | AC | 172 | ¬ | NOT SIGN | -, no NO |
318 | AD | 173 | ­ | SOFT HYPHEN | - -- |
319 | AE | 174 | ® | REGISTERED SIGN | RO ro OR |
320 | AF | 175 | ¯ | MACRON | -^ _^ __ |
321 | B0 | 176 | ° | DEGREE SIGN | o 0^ 0* de DE ^0 |
322 | B1 | 177 | ± | PLUS-MINUS SIGN | -+ +- |
323 | B2 | 178 | ² | SUPERSCRIPT TWO | 2 2^ s2 ^2 |
324 | B3 | 179 | ³ | SUPERSCRIPT THREE | 3 3^ s3 ^3 |
325 | B4 | 180 | ´ | ACUTE ACCENT | ' '' |
326 | B5 | 181 | µ | MICRO SIGN | u /u /U *m *M |
327 | B6 | 182 | ¶ | PILCROW SIGN | p! P! pg PG |
328 | B7 | 183 | · | MIDDLE DOT | . .^ .. |
329 | B8 | 184 | ¸ | CEDILLA | , ,, |
330 | B9 | 185 | ¹ | SUPERSCRIPT ONE | 1 1^ s1 ^1 |
331 | BA | 186 | º | MASCULINE ORDINAL INDICATOR | o_ s0 S0 |
332 | BB | 187 | » | RIGHT DOUBLE ANGLE QUOTES | >> |
333 | BC | 188 | ¼ | VULGAR FRACTION ONE QUARTER | 14 |
334 | BD | 189 | ½ | VULGAR FRACTION ONE HALF | 12 |
335 | BE | 190 | ¾ | VULGAR FRACTION THREE QUARTERS | 34 |
336 | BF | 191 | ¿ | INVERTED QUESTION MARK | ? ?? |
337 | C0 | 192 | À | CAPITAL A WITH GRAVE ACCENT | `A A` |
338 | C1 | 193 | Á | CAPITAL A WITH ACUTE ACCENT | 'A A' |
339 | C2 | 194 | Â | CAPITAL A WITH CIRCUMFLEX ACCENT| ^A A^ A> |
340 | C3 | 195 | Ã | CAPITAL A WITH TILDE | ~A A~ A- |
341 | C4 | 196 | Ä | CAPITAL A WITH DIAERESIS | "A A" |
342 | C5 | 197 | Å | CAPITAL A WITH RING ABOVE | oA Ao A* OA *A |
343 | C6 | 198 | Æ | CAPITAL LIGATURE AE | AE |
344 | C7 | 199 | Ç | CAPITAL C WITH CEDILLA | ,C C, |
345 | C8 | 200 | È | CAPITAL E WITH GRAVE ACCENT | `E E` |
346 | C9 | 201 | É | CAPITAL E WITH ACUTE ACCENT | 'E E' |
347 | CA | 202 | Ê | CAPITAL E WITH CIRCUMFLEX ACCENT| ^E E^ E> |
348 | CB | 203 | Ë | CAPITAL E WITH DIAERESIS | "E E" |
349 | CC | 204 | Ì | CAPITAL I WITH GRAVE ACCENT | `I I` |
350 | CD | 205 | Í | CAPITAL I WITH ACUTE ACCENT | 'I I' |
351 | CE | 206 | Î | CAPITAL I WITH CIRCUMFLEX ACCENT| ^I I^ I> |
352 | CF | 207 | Ï | CAPITAL I WITH DIAERESIS | "I I" |
353 | D0 | 208 | Ð | CAPITAL ETH | D- |
354 | D1 | 209 | Ñ | CAPITAL N WITH TILDE | ~N N~ N- |
355 | D2 | 210 | Ò | CAPITAL O WITH GRAVE ACCENT | `O O` |
356 | D3 | 211 | Ó | CAPITAL O WITH ACUTE ACCENT | 'O O' |
357 | D4 | 212 | Ô | CAPITAL O WITH CIRCUMFLEX ACCENT| ^O O^ O> |
358 | D5 | 213 | Õ | CAPITAL O WITH TILDE | ~O O~ O- |
359 | D6 | 214 | Ö | CAPITAL O WITH DIAERESIS | "O O" |
360 | D7 | 215 | × | MULTIPLICATION SIGN | x xx XX mu MU |
361 | D8 | 216 | Ø | CAPITAL O WITH STROKE | /O O/ |
362 | D9 | 217 | Ù | CAPITAL U WITH GRAVE ACCENT | `U U` |
363 | DA | 218 | Ú | CAPITAL U WITH ACUTE ACCENT | 'U U' |
364 | DB | 219 | Û | CAPITAL U WITH CIRCUMFLEX ACCENT| ^U U^ U> |
365 | DC | 220 | Ü | CAPITAL U WITH DIAERESIS | "U U" |
366 | DD | 221 | Ý | CAPITAL Y WITH ACUTE ACCENT | 'Y Y' |
367 | DE | 222 | Þ | CAPITAL THORN | P TH |P |
368 | DF | 223 | ß | SMALL SHARP S | ss |
369 | E0 | 224 | à | SMALL A WITH GRAVE ACCENT | `a a` |
370 | E1 | 225 | á | SMALL A WITH ACUTE ACCENT | 'a a' |
371 | E2 | 226 | â | SMALL A WITH CIRCUMFLEX ACCENT | ^a a^ a> |
372 | E3 | 227 | ã | SMALL A WITH TILDE | ~a a~ a- |
373 | E4 | 228 | ä | SMALL A WITH DIAERESIS | "a a" |
374 | E5 | 229 | å | SMALL A WITH RING ABOVE | oa ao Oa a* *a |
375 | E6 | 230 | æ | SMALL LIGATURE AE | ae |
376 | E7 | 231 | ç | SMALL C WITH CEDILLA | ,c c, |
377 | E8 | 232 | è | SMALL E WITH GRAVE ACCENT | `e e` |
378 | E9 | 233 | é | SMALL E WITH ACUTE ACCENT | 'e e' |
379 | EA | 234 | ê | SMALL E WITH CIRCUMFLEX ACCENT | ^e e^ e> |
380 | EB | 235 | ë | SMALL E WITH DIAERESIS | "e e" |
381 | EC | 236 | ì | SMALL I WITH GRAVE ACCENT | `i i` |
382 | ED | 237 | í | SMALL I WITH ACUTE ACCENT | 'i i' |
383 | EE | 238 | î | SMALL I WITH CIRCUMFLEX ACCENT | ^i i^ i> |
384 | EF | 239 | ï | SMALL I WITH DIAERESIS | "i i" |
385 | F0 | 240 | ð | SMALL ETH | d- |
386 | F1 | 241 | ñ | SMALL N WITH TILDE | ~n n~ n- |
387 | F2 | 242 | ò | SMALL O WITH GRAVE ACCENT | `o o` |
388 | F3 | 243 | ó | SMALL O WITH ACUTE ACCENT | 'o o' |
389 | F4 | 244 | ô | SMALL O WITH CIRCUMFLEX ACCENT | ^o o^ o> |
390 | F5 | 245 | õ | SMALL O WITH TILDE | ~o o~ o- |
391 | F6 | 246 | ö | SMALL O WITH DIAERESIS | "o o" |
392 | F7 | 247 | ÷ | DIVISION SIGN | -: :- |
393 | F8 | 248 | ø | SMALL O WITH OBLIQUE BAR | /o o/ |
394 | F9 | 249 | ù | SMALL U WITH GRAVE ACCENT | `u u` |
395 | FA | 250 | ú | SMALL U WITH ACUTE ACCENT | 'u u' |
396 | FB | 251 | û | SMALL U WITH CIRCUMFLEX ACCENT | ^u u^ u> |
397 | FC | 252 | ü | SMALL U WITH DIAERESIS | "u u" |
398 | FD | 253 | ý | SMALL Y WITH ACUTE ACCENT | 'y y' |
399 | FE | 254 | þ | SMALL THORN | p th |p |
400 | FF | 255 | ÿ | SMALL Y WITH DIAERESIS | "y y" |
401 +----+-----+---+---------------------------------+---------------------------+
402
403
404 Deprecated
405 ----------
406
407 XCursesProgramName is no longer used. To set the program name, you must
408 use Xinitscr(), or PDC_set_title() to set just the window title.
409
410 The XCursesExit() function is now called automatically via atexit().
411 (Multiple calls to it are OK, so you don't need to remove it if you've
412 already added it for previous versions of PDCurses.)
413
414 XCURSES is no longer defined automatically, but need not be defined,
415 unless you want the X11-specific prototypes. (Normal curses programs
416 won't need it.)
File dos/README added (mode: 100644) (index 00000000..569034bb)
1 PDCurses for DOS
2 ================
3
4 This directory contains PDCurses source code files specific to DOS.
5
6
7 Building
8 --------
9
10 . Choose the appropriate makefile for your compiler:
11
12 bccdos.mak - Borland C++ 3.0+
13 gccdos.mak - DJGPP V2
14 mscdos.mak - Microsoft C
15 wccdos16.mak - Watcom 10.6+ (16-bit)
16 wccdos4g.mak - Watcom 10.6+ (32-bit)
17
18 . For 16-bit compilers, you can change the memory MODEL in the makefile.
19 (Large model is the default, and recommended.)
20
21 . Optionally, you can build in a different directory than the platform
22 directory by setting PDCURSES_SRCDIR to point to the directory where
23 you unpacked PDCurses, and changing to your target directory:
24
25 set PDCURSES_SRCDIR=c:\pdcurses
26
27 . Build it:
28
29 make -f makefile
30
31 (For Watcom, use "wmake" instead of "make"; for MSVC, "nmake".) You'll
32 get the libraries (pdcurses.lib or .a, depending on your compiler; and
33 panel.lib or .a), the demos (*.exe), and a lot of object files. Note
34 that the panel library is just a copy of the main library, provided
35 for convenience; both panel and curses functions are in the main
36 library.
37
38
39 Distribution Status
40 -------------------
41
42 The files in this directory are released to the Public Domain.
43
44
45 Acknowledgements
46 ----------------
47
48 Watcom C port was provided by Pieter Kunst <kunst@prl.philips.nl>
49 DJGPP 1.x port was provided by David Nugent <davidn@csource.oz.au>
File dos/bccdos.lrf added (mode: 100644) (index 00000000..9bd18c6b)
1 +addch.obj +addchstr.obj +addstr.obj +attr.obj +beep.obj +bkgd.obj &
2 +border.obj +clear.obj +color.obj +delch.obj +deleteln.obj +deprec.obj &
3 +getch.obj +getstr.obj +getyx.obj +inch.obj +inchstr.obj +initscr.obj &
4 +inopts.obj +insch.obj +insstr.obj +instr.obj +kernel.obj +keyname.obj &
5 +mouse.obj +move.obj +outopts.obj +overlay.obj +pad.obj +panel.obj &
6 +printw.obj +refresh.obj +scanw.obj +scr_dump.obj +scroll.obj +slk.obj &
7 +termattr.obj +terminfo.obj +touch.obj +util.obj +window.obj +debug.obj &
8 +pdcclip.obj +pdcdisp.obj +pdcgetsc.obj +pdckbd.obj +pdcscrn.obj &
9 +pdcsetsc.obj +pdcutil.obj ,lib.map
File dos/bccdos.mak added (mode: 100644) (index 00000000..6361a4d8)
1 # Borland MAKE Makefile for PDCurses library - DOS BC++ 3.0+
2 #
3 # Usage: make -f [path\]bccdos.mak [DEBUG=] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 # Change the memory MODEL here, if desired
9 MODEL = l
10
11 O = obj
12
13 !ifndef PDCURSES_SRCDIR
14 PDCURSES_SRCDIR = ..
15 !endif
16
17 !include $(PDCURSES_SRCDIR)\version.mif
18 !include $(PDCURSES_SRCDIR)\libobjs.mif
19
20 osdir = $(PDCURSES_SRCDIR)\dos
21
22 !ifdef DEBUG
23 CFLAGS = -N -v -y -DPDCDEBUG
24 !else
25 CFLAGS = -O
26 !endif
27
28 CPPFLAGS = -I$(PDCURSES_SRCDIR)
29
30 BUILD = $(CC) -1- -K -G -rd -d -w-eff -w-par -c \
31 -m$(MODEL) $(CFLAGS) $(CPPFLAGS)
32
33 LIBEXE = tlib /C /E
34
35 LIBCURSES = pdcurses.lib
36
37 all: $(LIBCURSES) $(DEMOS)
38
39 clean:
40 -del *.obj
41 -del *.lib
42 -del *.map
43 -del *.exe
44
45 demos: $(DEMOS)
46
47 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
48 -del $@
49 $(LIBEXE) $@ @$(osdir)\bccdos.lrf
50 -copy $(LIBCURSES) panel.lib
51
52 .autodepend
53
54 {$(srcdir)\}.c.obj:
55 $(BUILD) $<
56
57 {$(osdir)\}.c.obj:
58 $(BUILD) $<
59
60 {$(demodir)\}.c.obj:
61 $(BUILD) $<
62
63 .c.obj:
64 $(BUILD) $<
65
66 .obj.exe:
67 $(CC) -m$(MODEL) -e$@ $** $(LIBCURSES)
68
69 tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
70 $(CC) -m$(MODEL) -e$@ $**
71
72 tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
73 $(BUILD) -I$(demodir) $(demodir)\tui.c
74
75 tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
76 $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
77
78 PLATFORM1 = Borland C++ 3.1
79 PLATFORM2 = Borland C/C++ 3.1 for DOS
80 ARCNAME = pdc$(VER)bcc
81
82 !include $(PDCURSES_SRCDIR)\makedist.mif
File dos/gccdos.mak added (mode: 100644) (index 00000000..26a4ed3d)
1 # GNU MAKE (3.79.1) Makefile for PDCurses library - DOS DJGPP V2.0+
2 #
3 # Usage: make -f [path\]gccdos.mak [DEBUG=Y] [target]
4 #
5 # where target can be any of:
6 # [all|libs|demos|dist|pdcurses.a|testcurs.exe...]
7
8 O = o
9
10 ifndef PDCURSES_SRCDIR
11 PDCURSES_SRCDIR = ..
12 endif
13
14 include $(PDCURSES_SRCDIR)/version.mif
15 include $(PDCURSES_SRCDIR)/libobjs.mif
16
17 osdir = $(PDCURSES_SRCDIR)/dos
18
19 PDCURSES_DOS_H = $(osdir)/pdcdos.h
20
21 CC = gcc
22
23 ifeq ($(DEBUG),Y)
24 CFLAGS = -g -Wall -DPDCDEBUG
25 LDFLAGS = -g
26 else
27 CFLAGS = -O2 -Wall
28 LDFLAGS =
29 endif
30
31 CFLAGS += -I$(PDCURSES_SRCDIR)
32
33 LINK = gcc
34
35 LIBEXE = ar
36 LIBFLAGS = rcv
37
38 LIBCURSES = pdcurses.a
39
40 .PHONY: all libs clean demos dist
41
42 all: libs demos
43
44 libs: $(LIBCURSES)
45
46 clean:
47 -del *.o
48 -del *.a
49 -del *.exe
50
51 demos: $(DEMOS)
52 strip *.exe
53
54 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
55 $(LIBEXE) $(LIBFLAGS) $@ $?
56 -copy $(LIBCURSES) panel.a
57
58 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
59 $(PDCOBJS) : $(PDCURSES_DOS_H)
60 $(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
61 panel.o : $(PANEL_HEADER)
62 terminfo.o: $(TERM_HEADER)
63
64 $(LIBOBJS) : %.o: $(srcdir)/%.c
65 $(CC) -c $(CFLAGS) $<
66
67 $(PDCOBJS) : %.o: $(osdir)/%.c
68 $(CC) -c $(CFLAGS) $<
69
70 firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
71 ptest.exe: %.exe: $(demodir)/%.c
72 $(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)
73
74 tuidemo.exe: tuidemo.o tui.o
75 $(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)
76
77 tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
78 $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
79
80 tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
81 $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
82
83 PLATFORM1 = DJGPP 2.03
84 PLATFORM2 = DJGPP 2.03 for DOS
85 ARCNAME = pdc$(VER)djg
86
87 include $(PDCURSES_SRCDIR)/makedist.mif
File dos/mscdos.lrf added (mode: 100644) (index 00000000..b1fdf37e)
1 -+addch.obj &
2 -+addchstr.obj &
3 -+addstr.obj &
4 -+attr.obj &
5 -+beep.obj &
6 -+bkgd.obj &
7 -+border.obj &
8 -+clear.obj &
9 -+color.obj &
10 -+delch.obj &
11 -+deleteln.obj &
12 -+deprec.obj &
13 -+getch.obj &
14 -+getstr.obj &
15 -+getyx.obj &
16 -+inch.obj &
17 -+inchstr.obj &
18 -+initscr.obj &
19 -+inopts.obj &
20 -+insch.obj &
21 -+insstr.obj &
22 -+instr.obj &
23 -+kernel.obj &
24 -+keyname.obj &
25 -+mouse.obj &
26 -+move.obj &
27 -+outopts.obj &
28 -+overlay.obj &
29 -+pad.obj &
30 -+panel.obj &
31 -+printw.obj &
32 -+refresh.obj &
33 -+scanw.obj &
34 -+scr_dump.obj &
35 -+scroll.obj &
36 -+slk.obj &
37 -+termattr.obj &
38 -+terminfo.obj &
39 -+touch.obj &
40 -+util.obj &
41 -+window.obj &
42 -+debug.obj &
43 -+pdcclip.obj &
44 -+pdcdisp.obj &
45 -+pdcgetsc.obj &
46 -+pdckbd.obj &
47 -+pdcscrn.obj &
48 -+pdcsetsc.obj &
49 -+pdcutil.obj &
50 ,lib.map;
File dos/mscdos.mak added (mode: 100644) (index 00000000..7aa6c5f7)
1 # NMAKE Makefile for PDCurses library - Microsoft C for DOS
2 #
3 # Usage: nmake -f [path\]dosmsc.mak [DEBUG=] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 # Change the memory MODEL here, if desired
9 MODEL = L # one of L, S, M, T, H, C
10 SIZE = LARGE # one of LARGE, SMALL, MEDIUM, TINY, HUGE, COMPACT
11
12 O = obj
13
14 !ifndef PDCURSES_SRCDIR
15 PDCURSES_SRCDIR = ..
16 !endif
17
18 !include $(PDCURSES_SRCDIR)\version.mif
19 !include $(PDCURSES_SRCDIR)\libobjs.mif
20
21 osdir = $(PDCURSES_SRCDIR)\dos
22
23 PDCURSES_DOS_H = $(osdir)\pdcdos.h
24
25 CC = cl
26
27 !ifdef DEBUG
28 CFLAGS = /Od /Zi /DPDCDEBUG
29 LDFLAGS = /CO /NOE /SE:160
30 !else
31 CFLAGS = /Ox
32 LDFLAGS = /NOE /SE:160
33 !endif
34
35 CPPFLAGS = -I$(PDCURSES_SRCDIR)
36
37 BUILD = $(CC) /J /nologo /c /D$(SIZE) /A$(MODEL) $(CFLAGS) $(CPPFLAGS)
38
39 LINK = link
40
41 CCLIBS =
42
43 LIBEXE = lib
44
45 LIBCURSES = pdcurses.lib
46
47 all: $(LIBCURSES) $(DEMOS)
48
49 clean:
50 -del *.obj
51 -del *.lib
52 -del *.exe
53
54 demos: $(DEMOS)
55
56 DEMOOBJS = $(DEMOS:.exe=.obj) tui.obj
57
58 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
59 $(DEMOOBJS) : $(PDCURSES_CURSES_H)
60 $(DEMOS) : $(LIBCURSES)
61 panel.obj : $(PANEL_HEADER)
62 terminfo.obj: $(TERM_HEADER)
63
64 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
65 $(LIBEXE) $@ @$(osdir)\mscdos.lrf
66 -copy $(LIBCURSES) panel.lib
67
68 {$(srcdir)\}.c{}.obj:
69 $(BUILD) $<
70
71 {$(osdir)\}.c{}.obj:
72 $(BUILD) $<
73
74 {$(demodir)\}.c{}.obj:
75 $(BUILD) $<
76
77 firework.exe: firework.obj
78 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
79
80 newdemo.exe: newdemo.obj
81 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
82
83 ptest.exe: ptest.obj
84 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
85
86 rain.exe: rain.obj
87 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
88
89 testcurs.exe: testcurs.obj
90 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
91
92 tuidemo.exe: tuidemo.obj tui.obj
93 $(LINK) $(LDFLAGS) $*.obj+tui.obj,$*,,$(LIBCURSES);
94
95 worm.exe: worm.obj
96 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
97
98 xmas.exe: xmas.obj
99 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
100
101 ptest.obj: $(demodir)\ptest.c $(PANEL_HEADER)
102 $(BUILD) $(demodir)\ptest.c
103
104 tui.obj: $(demodir)\tui.c $(demodir)\tui.h
105 $(BUILD) -I$(demodir) $(demodir)\tui.c
106
107 tuidemo.obj: $(demodir)\tuidemo.c
108 $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
109
110 PLATFORM1 = Microsoft C
111 PLATFORM2 = Microsoft C for DOS
112 ARCNAME = pdc$(VER)msc
113
114 !include $(PDCURSES_SRCDIR)\makedist.mif
File dos/pdcclip.c added (mode: 100644) (index 00000000..74607aa0)
1 /* Public Domain Curses */
2
3 #include "pdcdos.h"
4
5 RCSID("$Id: pdcclip.c,v 1.33 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 #include <stdlib.h>
8
9 /*man-start**************************************************************
10
11 Name: clipboard
12
13 Synopsis:
14 int PDC_getclipboard(char **contents, long *length);
15 int PDC_setclipboard(const char *contents, long length);
16 int PDC_freeclipboard(char *contents);
17 int PDC_clearclipboard(void);
18
19 Description:
20 PDC_getclipboard() gets the textual contents of the system's
21 clipboard. This function returns the contents of the clipboard
22 in the contents argument. It is the responsibilitiy of the
23 caller to free the memory returned, via PDC_freeclipboard().
24 The length of the clipboard contents is returned in the length
25 argument.
26
27 PDC_setclipboard copies the supplied text into the system's
28 clipboard, emptying the clipboard prior to the copy.
29
30 PDC_clearclipboard() clears the internal clipboard.
31
32 Return Values:
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 X/Open BSD SYS V
41 PDC_getclipboard - - -
42 PDC_setclipboard - - -
43 PDC_freeclipboard - - -
44 PDC_clearclipboard - - -
45
46 **man-end****************************************************************/
47
48 /* global clipboard contents, should be NULL if none set */
49
50 static char *pdc_DOS_clipboard = NULL;
51
52 int PDC_getclipboard(char **contents, long *length)
53 {
54 int len;
55
56 PDC_LOG(("PDC_getclipboard() - called\n"));
57
58 if (!pdc_DOS_clipboard)
59 return PDC_CLIP_EMPTY;
60
61 len = strlen(pdc_DOS_clipboard);
62 if ((*contents = malloc(len + 1)) == NULL)
63 return PDC_CLIP_MEMORY_ERROR;
64
65 strcpy(*contents, pdc_DOS_clipboard);
66 *length = len;
67
68 return PDC_CLIP_SUCCESS;
69 }
70
71 int PDC_setclipboard(const char *contents, long length)
72 {
73 PDC_LOG(("PDC_setclipboard() - called\n"));
74
75 if (pdc_DOS_clipboard)
76 {
77 free(pdc_DOS_clipboard);
78 pdc_DOS_clipboard = NULL;
79 }
80
81 if (contents)
82 {
83 if ((pdc_DOS_clipboard = malloc(length + 1)) == NULL)
84 return PDC_CLIP_MEMORY_ERROR;
85
86 strcpy(pdc_DOS_clipboard, contents);
87 }
88
89 return PDC_CLIP_SUCCESS;
90 }
91
92 int PDC_freeclipboard(char *contents)
93 {
94 PDC_LOG(("PDC_freeclipboard() - called\n"));
95
96 /* should we also free empty the system clipboard? probably not */
97
98 if (contents)
99 {
100
101 /* NOTE: We free the memory, but we can not set caller's pointer
102 to NULL, so if caller calls again then will try to access
103 free'd memory. We 1st overwrite memory with a string so if
104 caller tries to use free memory they won't get what they
105 expect & hopefully notice. */
106
107 /* memset(contents, 0xFD, strlen(contents)); */
108
109 if (strlen(contents) >= strlen("PDCURSES"))
110 strcpy(contents, "PDCURSES");
111
112 free(contents);
113 }
114
115 return PDC_CLIP_SUCCESS;
116 }
117
118 int PDC_clearclipboard(void)
119 {
120 PDC_LOG(("PDC_clearclipboard() - called\n"));
121
122 if (pdc_DOS_clipboard)
123 {
124 free(pdc_DOS_clipboard);
125 pdc_DOS_clipboard = NULL;
126 }
127
128 return PDC_CLIP_SUCCESS;
129 }
File dos/pdcdisp.c added (mode: 100644) (index 00000000..aae9bfb5)
1 /* Public Domain Curses */
2
3 #include "pdcdos.h"
4
5 RCSID("$Id: pdcdisp.c,v 1.65 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 /* ACS definitions originally by jshumate@wrdis01.robins.af.mil -- these
8 match code page 437 and compatible pages (CP850, CP852, etc.) */
9
10 #ifdef CHTYPE_LONG
11
12 # define A(x) ((chtype)x | A_ALTCHARSET)
13
14 chtype acs_map[128] =
15 {
16 A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
17 A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
18 A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
19 A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
20 ')', '*',
21
22 A(0x1a), A(0x1b), A(0x18), A(0x19),
23
24 '/',
25
26 0xdb,
27
28 '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
29 '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
30 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
31 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
32
33 A(0x04), 0xb1,
34
35 'b', 'c', 'd', 'e',
36
37 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d, 0x2d,
38 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3, 0xf2, 0xe3,
39 0xd8, 0x9c, 0xf9,
40
41 A(127)
42 };
43
44 # undef A
45
46 #endif
47
48 #ifdef __PACIFIC__
49 void movedata(unsigned sseg, unsigned soff, unsigned dseg,
50 unsigned doff, unsigned n)
51 {
52 far char *src = MK_FP(sseg, soff);
53 far char *dst = MK_FP(dseg, doff);
54
55 while (n--)
56 *dst++ = *src++;
57 }
58 #endif
59
60 /* position hardware cursor at (y, x) */
61
62 void PDC_gotoyx(int row, int col)
63 {
64 PDCREGS regs;
65
66 PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
67
68 regs.h.ah = 0x02;
69 regs.h.bh = 0;
70 regs.h.dh = (unsigned char) row;
71 regs.h.dl = (unsigned char) col;
72 PDCINT(0x10, regs);
73 }
74
75 /* update the given physical line to look like the corresponding line in
76 curscr */
77
78 void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
79 {
80 int j;
81
82 PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
83
84 if (pdc_direct_video)
85 {
86 #if SMALL || MEDIUM
87 # ifndef __PACIFIC__
88 struct SREGS segregs;
89 # endif
90 int ds;
91 #endif
92 /* this should be enough for the maximum width of a screen */
93
94 struct {unsigned char text, attr;} temp_line[256];
95
96 /* replace the attribute part of the chtype with the actual
97 color value for each chtype in the line */
98
99 for (j = 0; j < len; j++)
100 {
101 chtype ch = srcp[j];
102
103 temp_line[j].attr = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
104 #ifdef CHTYPE_LONG
105 if (ch & A_ALTCHARSET && !(ch & 0xff80))
106 ch = acs_map[ch & 0x7f];
107 #endif
108 temp_line[j].text = ch & 0xff;
109 }
110
111 #ifdef __DJGPP__
112 dosmemput(temp_line, len * 2,
113 (unsigned long)_FAR_POINTER(pdc_video_seg,
114 pdc_video_ofs + (lineno * curscr->_maxx + x) * 2));
115 #else
116 # if SMALL || MEDIUM
117 # ifdef __PACIFIC__
118 ds = FP_SEG((void far *) temp_line);
119 # else
120 segread(&segregs);
121 ds = segregs.ds;
122 # endif
123 movedata(ds, (int)temp_line, pdc_video_seg,
124 pdc_video_ofs + (lineno * curscr->_maxx + x) * 2, len * 2);
125 # else
126 memcpy((void *)_FAR_POINTER(pdc_video_seg,
127 pdc_video_ofs + (lineno * curscr->_maxx + x) * 2),
128 temp_line, len * 2);
129 # endif
130 #endif
131
132 }
133 else
134 for (j = 0; j < len;)
135 {
136 PDCREGS regs;
137 unsigned short count = 1;
138 chtype ch = srcp[j];
139
140 while ((j + count < len) && (ch == srcp[j + count]))
141 count++;
142
143 PDC_gotoyx(lineno, j + x);
144
145 regs.h.ah = 0x09;
146 regs.W.bx = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
147 regs.W.cx = count;
148 #ifdef CHTYPE_LONG
149 if (ch & A_ALTCHARSET && !(ch & 0xff80))
150 ch = acs_map[ch & 0x7f];
151 #endif
152 regs.h.al = (unsigned char) (ch & 0xff);
153
154 PDCINT(0x10, regs);
155
156 j += count;
157 }
158 }
File dos/pdcdos.h added (mode: 100644) (index 00000000..436699de)
1 /* Public Domain Curses */
2
3 /* $Id: pdcdos.h,v 1.30 2008/07/13 16:08:17 wmcbrine Exp $ */
4
5 #include <curspriv.h>
6 #include <string.h>
7
8 #if defined(_MSC_VER) || defined(_QC)
9 # define MSC 1
10 #endif
11
12 #if defined(__PACIFIC__) && !defined(__SMALL__)
13 # define __SMALL__
14 #endif
15
16 #if defined(__HIGHC__) || MSC
17 # include <bios.h>
18 #endif
19
20 /*----------------------------------------------------------------------
21 * MEMORY MODEL SUPPORT:
22 *
23 * MODELS
24 * TINY cs,ds,ss all in 1 segment (not enough memory!)
25 * SMALL cs:1 segment, ds:1 segment
26 * MEDIUM cs:many segments, ds:1 segment
27 * COMPACT cs:1 segment, ds:many segments
28 * LARGE cs:many segments, ds:many segments
29 * HUGE cs:many segments, ds:segments > 64K
30 */
31
32 #ifdef __TINY__
33 # define SMALL 1
34 #endif
35 #ifdef __SMALL__
36 # define SMALL 1
37 #endif
38 #ifdef __MEDIUM__
39 # define MEDIUM 1
40 #endif
41 #ifdef __COMPACT__
42 # define COMPACT 1
43 #endif
44 #ifdef __LARGE__
45 # define LARGE 1
46 #endif
47 #ifdef __HUGE__
48 # define HUGE 1
49 #endif
50
51 #include <dos.h>
52
53 extern unsigned char *pdc_atrtab;
54 extern int pdc_adapter;
55 extern int pdc_scrnmode;
56 extern int pdc_font;
57 extern bool pdc_direct_video;
58 extern bool pdc_bogus_adapter;
59 extern unsigned pdc_video_seg;
60 extern unsigned pdc_video_ofs;
61
62 #ifdef __DJGPP__ /* Note: works only in plain DOS... */
63 # if DJGPP == 2
64 # define _FAR_POINTER(s,o) ((((int)(s)) << 4) + ((int)(o)))
65 # else
66 # define _FAR_POINTER(s,o) (0xe0000000 + (((int)(s)) << 4) + ((int)(o)))
67 # endif
68 # define _FP_SEGMENT(p) (unsigned short)((((long)p) >> 4) & 0xffff)
69 #else
70 # ifdef __TURBOC__
71 # define _FAR_POINTER(s,o) MK_FP(s,o)
72 # else
73 # if defined(__WATCOMC__) && defined(__FLAT__)
74 # define _FAR_POINTER(s,o) ((((int)(s)) << 4) + ((int)(o)))
75 # else
76 # define _FAR_POINTER(s,o) (((long)s << 16) | (long)o)
77 # endif
78 # endif
79 # define _FP_SEGMENT(p) (unsigned short)(((long)p) >> 4)
80 #endif
81 #define _FP_OFFSET(p) ((unsigned short)p & 0x000f)
82
83 #ifdef __DJGPP__
84 # include <sys/movedata.h>
85 unsigned char getdosmembyte(int offs);
86 unsigned short getdosmemword(int offs);
87 unsigned long getdosmemdword(int offs);
88 void setdosmembyte(int offs, unsigned char b);
89 void setdosmemword(int offs, unsigned short w);
90 #else
91 # if SMALL || MEDIUM || MSC
92 # define PDC_FAR far
93 # else
94 # define PDC_FAR
95 # endif
96 # define getdosmembyte(offs) \
97 (*((unsigned char PDC_FAR *) _FAR_POINTER(0,offs)))
98 # define getdosmemword(offs) \
99 (*((unsigned short PDC_FAR *) _FAR_POINTER(0,offs)))
100 # define getdosmemdword(offs) \
101 (*((unsigned long PDC_FAR *) _FAR_POINTER(0,offs)))
102 # define setdosmembyte(offs,x) \
103 (*((unsigned char PDC_FAR *) _FAR_POINTER(0,offs)) = (x))
104 # define setdosmemword(offs,x) \
105 (*((unsigned short PDC_FAR *) _FAR_POINTER(0,offs)) = (x))
106 #endif
107
108 #if defined(__WATCOMC__) && defined(__386__)
109
110 typedef union
111 {
112 struct
113 {
114 unsigned long edi, esi, ebp, res, ebx, edx, ecx, eax;
115 } d;
116
117 struct
118 {
119 unsigned short di, di_hi, si, si_hi, bp, bp_hi, res, res_hi,
120 bx, bx_hi, dx, dx_hi, cx, cx_hi, ax, ax_hi,
121 flags, es, ds, fs, gs, ip, cs, sp, ss;
122 } w;
123
124 struct
125 {
126 unsigned char edi[4], esi[4], ebp[4], res[4],
127 bl, bh, ebx_b2, ebx_b3, dl, dh, edx_b2, edx_b3,
128 cl, ch, ecx_b2, ecx_b3, al, ah, eax_b2, eax_b3;
129 } h;
130 } pdc_dpmi_regs;
131
132 void PDC_dpmi_int(int, pdc_dpmi_regs *);
133
134 #endif
135
136 #ifdef __DJGPP__
137 # include <dpmi.h>
138 # define PDCREGS __dpmi_regs
139 # define PDCINT(vector, regs) __dpmi_int(vector, &regs)
140 #else
141 # ifdef __WATCOMC__
142 # ifdef __386__
143 # define PDCREGS pdc_dpmi_regs
144 # define PDCINT(vector, regs) PDC_dpmi_int(vector, &regs)
145 # else
146 # define PDCREGS union REGPACK
147 # define PDCINT(vector, regs) intr(vector, &regs)
148 # endif
149 # else
150 # define PDCREGS union REGS
151 # define PDCINT(vector, regs) int86(vector, &regs, &regs)
152 # endif
153 #endif
154
155 /* Wide registers in REGS: w or x? */
156
157 #ifdef __WATCOMC__
158 # define W w
159 #else
160 # define W x
161 #endif
162
163 /* Monitor (terminal) type information */
164
165 enum
166 {
167 _NONE, _MDA, _CGA,
168 _EGACOLOR = 0x04, _EGAMONO,
169 _VGACOLOR = 0x07, _VGAMONO,
170 _MCGACOLOR = 0x0a, _MCGAMONO,
171 _MDS_GENIUS = 0x30
172 };
173
174 /* Text-mode font size information */
175
176 enum
177 {
178 _FONT8 = 8,
179 _FONT14 = 14,
180 _FONT15, /* GENIUS */
181 _FONT16
182 };
183
184 #ifdef __PACIFIC__
185 void movedata(unsigned, unsigned, unsigned, unsigned, unsigned);
186 #endif
File dos/pdcgetsc.c added (mode: 100644) (index 00000000..290db5a3)
1 /* Public Domain Curses */
2
3 #include "pdcdos.h"
4
5 RCSID("$Id: pdcgetsc.c,v 1.42 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 #include <stdlib.h>
8
9 /* return width of screen/viewport */
10
11 int PDC_get_columns(void)
12 {
13 PDCREGS regs;
14 int cols;
15 const char *env_cols;
16
17 PDC_LOG(("PDC_get_columns() - called\n"));
18
19 /* use the value from COLS environment variable, if set. MH 10-Jun-92 */
20 /* and use the minimum of COLS and return from int10h MH 18-Jun-92 */
21
22 regs.h.ah = 0x0f;
23 PDCINT(0x10, regs);
24 cols = (int)regs.h.ah;
25
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 PDC_LOG(("PDC_get_cursor_mode() - called\n"));
41
42 return getdosmemword(0x460);
43 }
44
45 /* return number of screen rows */
46
47 int PDC_get_rows(void)
48 {
49 const char *env_rows;
50 int rows;
51
52 PDC_LOG(("PDC_get_rows() - called\n"));
53
54 /* use the value from LINES environment variable, if set. MH 10-Jun-92 */
55 /* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */
56
57 rows = getdosmembyte(0x484) + 1;
58 env_rows = getenv("LINES");
59
60 if (env_rows)
61 rows = min(atoi(env_rows), rows);
62
63 if (rows == 1 && pdc_adapter == _MDS_GENIUS)
64 rows = 66;
65 if (rows == 1 && pdc_adapter == _MDA)
66 rows = 25;
67
68 if (rows == 1)
69 {
70 rows = 25;
71 pdc_direct_video = FALSE;
72 }
73
74 switch (pdc_adapter)
75 {
76 case _EGACOLOR:
77 case _EGAMONO:
78 switch (rows)
79 {
80 case 25:
81 case 43:
82 break;
83 default:
84 rows = 25;
85 }
86 break;
87
88 case _VGACOLOR:
89 case _VGAMONO:
90 break;
91
92 default:
93 rows = 25;
94 break;
95 }
96
97 PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));
98
99 return rows;
100 }
File dos/pdckbd.c added (mode: 100644) (index 00000000..652cb0cb)
1 /* Public Domain Curses */
2
3 /* MS C doesn't return flags from int86() */
4 #ifdef MSC
5 # define USE_KBHIT
6 #endif
7
8 #ifdef USE_KBHIT
9 # include <conio.h>
10 #endif
11
12 #include "pdcdos.h"
13
14 RCSID("$Id: pdckbd.c,v 1.87 2008/07/13 16:08:17 wmcbrine Exp $")
15
16 /*man-start**************************************************************
17
18 Name: pdckbd
19
20 Synopsis:
21 unsigned long PDC_get_input_fd(void);
22
23 Description:
24 PDC_get_input_fd() returns the file descriptor that PDCurses
25 reads its input from. It can be used for select().
26
27 Portability X/Open BSD SYS V
28 PDC_get_input_fd - - -
29
30 **man-end****************************************************************/
31
32 #ifdef __DJGPP__
33 # include <fcntl.h>
34 # include <io.h>
35 # include <signal.h>
36 #endif
37
38 /************************************************************************
39 * Table for key code translation of function keys in keypad mode *
40 * These values are for strict IBM keyboard compatibles only *
41 ************************************************************************/
42
43 static short key_table[] =
44 {
45 -1, ALT_ESC, -1, 0,
46 -1, -1, -1, -1,
47 -1, -1, -1, -1,
48 -1, -1, ALT_BKSP, KEY_BTAB,
49 ALT_Q, ALT_W, ALT_E, ALT_R,
50 ALT_T, ALT_Y, ALT_U, ALT_I,
51 ALT_O, ALT_P, ALT_LBRACKET, ALT_RBRACKET,
52 ALT_ENTER, -1, ALT_A, ALT_S,
53 ALT_D, ALT_F, ALT_G, ALT_H,
54 ALT_J, ALT_K, ALT_L, ALT_SEMICOLON,
55 ALT_FQUOTE, ALT_BQUOTE, -1, ALT_BSLASH,
56 ALT_Z, ALT_X, ALT_C, ALT_V,
57 ALT_B, ALT_N, ALT_M, ALT_COMMA,
58 ALT_STOP, ALT_FSLASH, -1, ALT_PADSTAR,
59 -1, -1, -1, KEY_F(1),
60 KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
61 KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9),
62 KEY_F(10), -1, -1, KEY_HOME,
63 KEY_UP, KEY_PPAGE, ALT_PADMINUS, KEY_LEFT,
64 KEY_B2, KEY_RIGHT, ALT_PADPLUS, KEY_END,
65 KEY_DOWN, KEY_NPAGE, KEY_IC, KEY_DC,
66 KEY_F(13), KEY_F(14), KEY_F(15), KEY_F(16),
67 KEY_F(17), KEY_F(18), KEY_F(19), KEY_F(20),
68 KEY_F(21), KEY_F(22), KEY_F(25), KEY_F(26),
69 KEY_F(27), KEY_F(28), KEY_F(29), KEY_F(30),
70 KEY_F(31), KEY_F(32), KEY_F(33), KEY_F(34),
71 KEY_F(37), KEY_F(38), KEY_F(39), KEY_F(40),
72 KEY_F(41), KEY_F(42), KEY_F(43), KEY_F(44),
73 KEY_F(45), KEY_F(46), -1, CTL_LEFT,
74 CTL_RIGHT, CTL_END, CTL_PGDN, CTL_HOME,
75 ALT_1, ALT_2, ALT_3, ALT_4,
76 ALT_5, ALT_6, ALT_7, ALT_8,
77 ALT_9, ALT_0, ALT_MINUS, ALT_EQUAL,
78 CTL_PGUP, KEY_F(11), KEY_F(12), KEY_F(23),
79 KEY_F(24), KEY_F(35), KEY_F(36), KEY_F(47),
80 KEY_F(48), CTL_UP, CTL_PADMINUS, CTL_PADCENTER,
81 CTL_PADPLUS, CTL_DOWN, CTL_INS, CTL_DEL,
82 CTL_TAB, CTL_PADSLASH, CTL_PADSTAR, ALT_HOME,
83 ALT_UP, ALT_PGUP, -1, ALT_LEFT,
84 -1, ALT_RIGHT, -1, ALT_END,
85 ALT_DOWN, ALT_PGDN, ALT_INS, ALT_DEL,
86 ALT_PADSLASH, ALT_TAB, ALT_PADENTER, -1
87 };
88
89 unsigned long pdc_key_modifiers = 0L;
90
91 static struct {unsigned short pressed, released;} button[3];
92
93 static bool mouse_avail = FALSE, mouse_vis = FALSE, mouse_moved = FALSE,
94 mouse_button = FALSE, key_pressed = FALSE;
95
96 static unsigned char mouse_scroll = 0;
97 static PDCREGS ms_regs, old_ms;
98 static unsigned short shift_status, old_shift = 0;
99 static unsigned char keyboard_function = 0xff, shift_function = 0xff,
100 check_function = 0xff;
101
102 static const unsigned short button_map[3] = {0, 2, 1};
103
104 unsigned long PDC_get_input_fd(void)
105 {
106 PDC_LOG(("PDC_get_input_fd() - called\n"));
107
108 return (unsigned long)fileno(stdin);
109 }
110
111 void PDC_set_keyboard_binary(bool on)
112 {
113 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
114
115 #ifdef __DJGPP__
116 setmode(fileno(stdin), on ? O_BINARY : O_TEXT);
117 signal(SIGINT, on ? SIG_IGN : SIG_DFL);
118 #endif
119 }
120
121 /* check if a key or mouse event is waiting */
122
123 bool PDC_check_key(void)
124 {
125 PDCREGS regs;
126
127 if (shift_function == 0xff)
128 {
129 int scan;
130
131 /* get shift status for all keyboards */
132
133 regs.h.ah = 0x02;
134 PDCINT(0x16, regs);
135 scan = regs.h.al;
136
137 /* get shift status for enhanced keyboards */
138
139 regs.h.ah = 0x12;
140 PDCINT(0x16, regs);
141
142 if (scan == regs.h.al && getdosmembyte(0x496) == 0x10)
143 {
144 keyboard_function = 0x10;
145 check_function = 0x11;
146 shift_function = 0x12;
147 }
148 else
149 {
150 keyboard_function = 0;
151 check_function = 1;
152 shift_function = 2;
153 }
154 }
155
156 regs.h.ah = shift_function;
157 PDCINT(0x16, regs);
158
159 shift_status = regs.W.ax;
160
161 if (mouse_vis)
162 {
163 unsigned short i;
164
165 ms_regs.W.ax = 3;
166 PDCINT(0x33, ms_regs);
167
168 mouse_button = FALSE;
169
170 for (i = 0; i < 3; i++)
171 {
172 regs.W.ax = 6;
173 regs.W.bx = button_map[i];
174 PDCINT(0x33, regs);
175 button[i].released = regs.W.bx;
176 if (regs.W.bx)
177 {
178 ms_regs.W.cx = regs.W.cx;
179 ms_regs.W.dx = regs.W.dx;
180 mouse_button = TRUE;
181 }
182
183 regs.W.ax = 5;
184 regs.W.bx = button_map[i];
185 PDCINT(0x33, regs);
186 button[i].pressed = regs.W.bx;
187 if (regs.W.bx)
188 {
189 ms_regs.W.cx = regs.W.cx;
190 ms_regs.W.dx = regs.W.dx;
191 mouse_button = TRUE;
192 }
193 }
194
195 mouse_scroll = ms_regs.h.bh;
196
197 mouse_moved = !mouse_button && ms_regs.h.bl &&
198 ms_regs.h.bl == old_ms.h.bl &&
199 (((ms_regs.W.cx ^ old_ms.W.cx) >> 3) ||
200 ((ms_regs.W.dx ^ old_ms.W.dx) >> 3));
201
202 if (mouse_scroll || mouse_button || mouse_moved)
203 return TRUE;
204 }
205
206 if (old_shift && !shift_status) /* modifier released */
207 {
208 if (!key_pressed && SP->return_key_modifiers)
209 return TRUE;
210 }
211 else if (!old_shift && shift_status) /* modifier pressed */
212 key_pressed = FALSE;
213
214 old_shift = shift_status;
215
216 #ifndef USE_KBHIT
217 regs.h.ah = check_function;
218 PDCINT(0x16, regs);
219
220 return !(regs.W.flags & 64);
221 #else
222 return kbhit();
223 #endif
224 }
225
226 static int _process_mouse_events(void)
227 {
228 int i;
229 short shift_flags = 0;
230
231 memset(&pdc_mouse_status, 0, sizeof(pdc_mouse_status));
232
233 key_pressed = TRUE;
234 old_shift = shift_status;
235 SP->key_code = TRUE;
236
237 /* Set shift modifiers */
238
239 if (shift_status & 3)
240 shift_flags |= BUTTON_SHIFT;
241
242 if (shift_status & 4)
243 shift_flags |= BUTTON_CONTROL;
244
245 if (shift_status & 8)
246 shift_flags |= BUTTON_ALT;
247
248 /* Scroll wheel support for CuteMouse */
249
250 if (mouse_scroll)
251 {
252 pdc_mouse_status.changes = mouse_scroll & 0x80 ?
253 PDC_MOUSE_WHEEL_UP : PDC_MOUSE_WHEEL_DOWN;
254
255 pdc_mouse_status.x = -1;
256 pdc_mouse_status.y = -1;
257
258 return KEY_MOUSE;
259 }
260
261 if (mouse_moved)
262 {
263 pdc_mouse_status.changes = PDC_MOUSE_MOVED;
264
265 for (i = 0; i < 3; i++)
266 {
267 if (ms_regs.h.bl & (1 << button_map[i]))
268 {
269 pdc_mouse_status.button[i] = BUTTON_MOVED | shift_flags;
270 pdc_mouse_status.changes |= (1 << i);
271 }
272 }
273 }
274 else /* button event */
275 {
276 for (i = 0; i < 3; i++)
277 {
278 if (button[i].pressed)
279 {
280 /* Check for a click -- a PRESS followed
281 immediately by a release */
282
283 if (!button[i].released)
284 {
285 if (SP->mouse_wait)
286 {
287 PDCREGS regs;
288
289 napms(SP->mouse_wait);
290
291 regs.W.ax = 6;
292 regs.W.bx = button_map[i];
293 PDCINT(0x33, regs);
294
295 pdc_mouse_status.button[i] = regs.W.bx ?
296 BUTTON_CLICKED : BUTTON_PRESSED;
297 }
298 else
299 pdc_mouse_status.button[i] = BUTTON_PRESSED;
300 }
301 else
302 pdc_mouse_status.button[i] = BUTTON_CLICKED;
303 }
304
305 if (button[i].pressed || button[i].released)
306 {
307 pdc_mouse_status.button[i] |= shift_flags;
308 pdc_mouse_status.changes |= (1 << i);
309 }
310 }
311 }
312
313 pdc_mouse_status.x = ms_regs.W.cx >> 3;
314 pdc_mouse_status.y = ms_regs.W.dx >> 3;
315
316 old_ms = ms_regs;
317
318 return KEY_MOUSE;
319 }
320
321 /* return the next available key or mouse event */
322
323 int PDC_get_key(void)
324 {
325 PDCREGS regs;
326 int key, scan;
327
328 pdc_key_modifiers = 0;
329
330 if (mouse_vis && (mouse_scroll || mouse_button || mouse_moved))
331 return _process_mouse_events();
332
333 /* Return modifiers as keys? */
334
335 if (old_shift && !shift_status)
336 {
337 key = -1;
338
339 if (old_shift & 1)
340 key = KEY_SHIFT_R;
341
342 if (old_shift & 2)
343 key = KEY_SHIFT_L;
344
345 if (shift_function == 0x12)
346 {
347 if (old_shift & 0x400)
348 key = KEY_CONTROL_R;
349
350 if (old_shift & 0x100)
351 key = KEY_CONTROL_L;
352
353 if (old_shift & 0x800)
354 key = KEY_ALT_R;
355
356 if (old_shift & 0x200)
357 key = KEY_ALT_L;
358 }
359 else
360 {
361 if (old_shift & 4)
362 key = KEY_CONTROL_R;
363
364 if (old_shift & 8)
365 key = KEY_ALT_R;
366 }
367
368 key_pressed = FALSE;
369 old_shift = shift_status;
370
371 SP->key_code = TRUE;
372 return key;
373 }
374
375 regs.h.ah = keyboard_function;
376 PDCINT(0x16, regs);
377 key = regs.h.al;
378 scan = regs.h.ah;
379
380 if (SP->save_key_modifiers)
381 {
382 if (shift_status & 3)
383 pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
384
385 if (shift_status & 4)
386 pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
387
388 if (shift_status & 8)
389 pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
390
391 if (shift_status & 0x20)
392 pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
393 }
394
395 if (scan == 0x1c && key == 0x0a) /* ^Enter */
396 key = CTL_ENTER;
397 else if (scan == 0xe0 && key == 0x0d) /* PadEnter */
398 key = PADENTER;
399 else if (scan == 0xe0 && key == 0x0a) /* ^PadEnter */
400 key = CTL_PADENTER;
401 else if (scan == 0x37 && key == 0x2a) /* Star */
402 key = PADSTAR;
403 else if (scan == 0x4a && key == 0x2d) /* Minus */
404 key = PADMINUS;
405 else if (scan == 0x4e && key == 0x2b) /* Plus */
406 key = PADPLUS;
407 else if (scan == 0xe0 && key == 0x2f) /* Slash */
408 key = PADSLASH;
409 else if (key == 0x00 || (key == 0xe0 && scan > 53 && scan != 86))
410 key = (scan > 0xa7) ? -1 : key_table[scan];
411
412 if (shift_status & 3)
413 {
414 switch (key)
415 {
416 case KEY_HOME: /* Shift Home */
417 key = KEY_SHOME;
418 break;
419 case KEY_UP: /* Shift Up */
420 key = KEY_SUP;
421 break;
422 case KEY_PPAGE: /* Shift PgUp */
423 key = KEY_SPREVIOUS;
424 break;
425 case KEY_LEFT: /* Shift Left */
426 key = KEY_SLEFT;
427 break;
428 case KEY_RIGHT: /* Shift Right */
429 key = KEY_SRIGHT;
430 break;
431 case KEY_END: /* Shift End */
432 key = KEY_SEND;
433 break;
434 case KEY_DOWN: /* Shift Down */
435 key = KEY_SDOWN;
436 break;
437 case KEY_NPAGE: /* Shift PgDn */
438 key = KEY_SNEXT;
439 break;
440 case KEY_IC: /* Shift Ins */
441 key = KEY_SIC;
442 break;
443 case KEY_DC: /* Shift Del */
444 key = KEY_SDC;
445 }
446 }
447
448 key_pressed = TRUE;
449 SP->key_code = ((unsigned)key >= 256);
450
451 return key;
452 }
453
454 /* discard any pending keyboard or mouse input -- this is the core
455 routine for flushinp() */
456
457 void PDC_flushinp(void)
458 {
459 PDC_LOG(("PDC_flushinp() - called\n"));
460
461 /* Force the BIOS keyboard buffer head and tail pointers to be
462 the same... Real nasty trick... */
463
464 setdosmemword(0x41a, getdosmemword(0x41c));
465 }
466
467 int PDC_mouse_set(void)
468 {
469 PDCREGS regs;
470 unsigned long mbe = SP->_trap_mbe;
471
472 if (mbe && !mouse_avail)
473 {
474 regs.W.ax = 0;
475 PDCINT(0x33, regs);
476
477 mouse_avail = !!(regs.W.ax);
478 }
479
480 if (mbe)
481 {
482 if (mouse_avail && !mouse_vis)
483 {
484 memset(&old_ms, 0, sizeof(old_ms));
485
486 regs.W.ax = 1;
487 PDCINT(0x33, regs);
488
489 mouse_vis = TRUE;
490 }
491 }
492 else
493 {
494 if (mouse_avail && mouse_vis)
495 {
496 regs.W.ax = 2;
497 PDCINT(0x33, regs);
498
499 mouse_vis = FALSE;
500 }
501 }
502
503 return (mouse_avail || !mbe) ? OK : ERR;
504 }
505
506 int PDC_modifiers_set(void)
507 {
508 key_pressed = FALSE;
509
510 return OK;
511 }
File dos/pdcscrn.c added (mode: 100644) (index 00000000..ddfb0956)
1 /* Public Domain Curses */
2
3 #include "pdcdos.h"
4
5 RCSID("$Id: pdcscrn.c,v 1.89 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 #include <stdlib.h>
8
9 #ifdef CHTYPE_LONG
10 # define PDC_OFFSET 32
11 #else
12 # define PDC_OFFSET 8
13 #endif
14
15 /* COLOR_PAIR to attribute encoding table. */
16
17 unsigned char *pdc_atrtab = (unsigned char *)NULL;
18
19 int pdc_adapter; /* screen type */
20 int pdc_scrnmode; /* default screen mode */
21 int pdc_font; /* default font size */
22 bool pdc_direct_video; /* allow direct screen memory writes */
23 bool pdc_bogus_adapter; /* TRUE if adapter has insane values */
24 unsigned pdc_video_seg; /* video base segment */
25 unsigned pdc_video_ofs; /* video base offset */
26
27 static short curstoreal[16], realtocurs[16] =
28 {
29 COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
30 COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
31 COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
32 COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
33 };
34
35 static bool sizeable = FALSE; /* TRUE if adapter is resizeable */
36
37 static unsigned short *saved_screen = NULL;
38 static int saved_lines = 0;
39 static int saved_cols = 0;
40
41 static int saved_scrnmode[3];
42 static int saved_font[3];
43
44 /* Thanks to Jeff Duntemann, K16RA for providing the impetus
45 (through the Dr. Dobbs Journal, March 1989 issue) for getting
46 the routines below merged into Bjorn Larsson's PDCurses 1.3...
47 -- frotz@dri.com 900730 */
48
49 /* _get_font() - Get the current font size */
50
51 static int _get_font(void)
52 {
53 int retval;
54
55 retval = getdosmemword(0x485);
56
57 /* Assume the MDS Genius is in 66 line mode. */
58
59 if ((retval == 0) && (pdc_adapter == _MDS_GENIUS))
60 retval = _FONT15;
61
62 switch (pdc_adapter)
63 {
64 case _MDA:
65 retval = 10; /* POINTS is not certain on MDA/Hercules */
66 break;
67
68 case _EGACOLOR:
69 case _EGAMONO:
70 switch (retval)
71 {
72 case _FONT8:
73 case _FONT14:
74 break;
75 default:
76 retval = _FONT14;
77 }
78 break;
79
80 case _CGA:
81 retval = _FONT8;
82 }
83
84 return retval;
85 }
86
87 /* _set_font() - Sets the current font size, if the adapter allows such a
88 change. It is an error to attempt to change the font size on a
89 "bogus" adapter. The reason for this is that we have a known video
90 adapter identity problem. e.g. Two adapters report the same identifying
91 characteristics. */
92
93 static void _set_font(int size)
94 {
95 PDCREGS regs;
96
97 if (pdc_bogus_adapter)
98 return;
99
100 switch (pdc_adapter)
101 {
102 case _CGA:
103 case _MDA:
104 case _MCGACOLOR:
105 case _MCGAMONO:
106 case _MDS_GENIUS:
107 break;
108
109 case _EGACOLOR:
110 case _EGAMONO:
111 if (sizeable && (pdc_font != size))
112 {
113 switch (size)
114 {
115 case _FONT8:
116 regs.W.ax = 0x1112;
117 regs.h.bl = 0x00;
118 PDCINT(0x10, regs);
119 break;
120 case _FONT14:
121 regs.W.ax = 0x1111;
122 regs.h.bl = 0x00;
123 PDCINT(0x10, regs);
124 }
125 }
126 break;
127
128 case _VGACOLOR:
129 case _VGAMONO:
130 if (sizeable && (pdc_font != size))
131 {
132 switch (size)
133 {
134 case _FONT8:
135 regs.W.ax = 0x1112;
136 regs.h.bl = 0x00;
137 PDCINT(0x10, regs);
138 break;
139 case _FONT14:
140 regs.W.ax = 0x1111;
141 regs.h.bl = 0x00;
142 PDCINT(0x10, regs);
143 break;
144 case _FONT16:
145 regs.W.ax = 0x1114;
146 regs.h.bl = 0x00;
147 PDCINT(0x10, regs);
148 }
149 }
150 }
151
152 curs_set(SP->visibility);
153
154 pdc_font = _get_font();
155 }
156
157 /* _set_80x25() - force a known screen state: 80x25 text mode. Forces the
158 appropriate 80x25 alpha mode given the display adapter. */
159
160 static void _set_80x25(void)
161 {
162 PDCREGS regs;
163
164 switch (pdc_adapter)
165 {
166 case _CGA:
167 case _EGACOLOR:
168 case _EGAMONO:
169 case _VGACOLOR:
170 case _VGAMONO:
171 case _MCGACOLOR:
172 case _MCGAMONO:
173 regs.h.ah = 0x00;
174 regs.h.al = 0x03;
175 PDCINT(0x10, regs);
176 break;
177 case _MDA:
178 regs.h.ah = 0x00;
179 regs.h.al = 0x07;
180 PDCINT(0x10, regs);
181 }
182 }
183
184 /* _get_scrn_mode() - Return the current BIOS video mode */
185
186 static int _get_scrn_mode(void)
187 {
188 PDCREGS regs;
189
190 regs.h.ah = 0x0f;
191 PDCINT(0x10, regs);
192
193 return (int)regs.h.al;
194 }
195
196 /* _set_scrn_mode() - Sets the BIOS Video Mode Number only if it is
197 different from the current video mode. */
198
199 static void _set_scrn_mode(int new_mode)
200 {
201 PDCREGS regs;
202
203 if (_get_scrn_mode() != new_mode)
204 {
205 regs.h.ah = 0;
206 regs.h.al = (unsigned char) new_mode;
207 PDCINT(0x10, regs);
208 }
209
210 pdc_font = _get_font();
211 pdc_scrnmode = new_mode;
212 LINES = PDC_get_rows();
213 COLS = PDC_get_columns();
214 }
215
216 /* _sanity_check() - A video adapter identification sanity check. This
217 routine will force sane values for various control flags. */
218
219 static int _sanity_check(int adapter)
220 {
221 int fontsize = _get_font();
222 int rows = PDC_get_rows();
223
224 PDC_LOG(("_sanity_check() - called: Adapter %d\n", adapter));
225
226 switch (adapter)
227 {
228 case _EGACOLOR:
229 case _EGAMONO:
230 switch (rows)
231 {
232 case 25:
233 case 43:
234 break;
235 default:
236 pdc_bogus_adapter = TRUE;
237 }
238
239 switch (fontsize)
240 {
241 case _FONT8:
242 case _FONT14:
243 break;
244 default:
245 pdc_bogus_adapter = TRUE;
246 }
247 break;
248
249 case _VGACOLOR:
250 case _VGAMONO:
251 break;
252
253 case _CGA:
254 case _MDA:
255 case _MCGACOLOR:
256 case _MCGAMONO:
257 switch (rows)
258 {
259 case 25:
260 break;
261 default:
262 pdc_bogus_adapter = TRUE;
263 }
264 break;
265
266 default:
267 pdc_bogus_adapter = TRUE;
268 }
269
270 if (pdc_bogus_adapter)
271 {
272 sizeable = FALSE;
273 pdc_direct_video = FALSE;
274 }
275
276 return adapter;
277 }
278
279 /* _query_adapter_type() - Determine PC video adapter type. */
280
281 static int _query_adapter_type(void)
282 {
283 PDCREGS regs;
284 int retval = _NONE;
285
286 /* thanks to paganini@ax.apc.org for the GO32 fix */
287
288 #if !defined(__DJGPP__) && !defined(__WATCOMC__)
289 struct SREGS segs;
290 #endif
291 short video_base = getdosmemword(0x463);
292
293 PDC_LOG(("_query_adapter_type() - called\n"));
294
295 /* attempt to call VGA Identify Adapter Function */
296
297 regs.W.ax = 0x1a00;
298 PDCINT(0x10, regs);
299
300 if ((regs.h.al == 0x1a) && (retval == _NONE))
301 {
302 /* We know that the PS/2 video BIOS is alive and well. */
303
304 switch (regs.h.al)
305 {
306 case 0:
307 retval = _NONE;
308 break;
309 case 1:
310 retval = _MDA;
311 break;
312 case 2:
313 retval = _CGA;
314 break;
315 case 4:
316 retval = _EGACOLOR;
317 sizeable = TRUE;
318 break;
319 case 5:
320 retval = _EGAMONO;
321 break;
322 case 26: /* ...alt. VGA BIOS... */
323 case 7:
324 retval = _VGACOLOR;
325 sizeable = TRUE;
326 break;
327 case 8:
328 retval = _VGAMONO;
329 break;
330 case 10:
331 case 13:
332 retval = _MCGACOLOR;
333 break;
334 case 12:
335 retval = _MCGAMONO;
336 break;
337 default:
338 retval = _CGA;
339 }
340 }
341 else
342 {
343 /* No VGA BIOS, check for an EGA BIOS by selecting an
344 Alternate Function Service...
345
346 bx == 0x0010 --> return EGA information */
347
348 regs.h.ah = 0x12;
349 regs.W.bx = 0x10;
350 PDCINT(0x10, regs);
351
352 if ((regs.h.bl != 0x10) && (retval == _NONE))
353 {
354 /* An EGA BIOS exists */
355
356 regs.h.ah = 0x12;
357 regs.h.bl = 0x10;
358 PDCINT(0x10, regs);
359
360 if (regs.h.bh == 0)
361 retval = _EGACOLOR;
362 else
363 retval = _EGAMONO;
364 }
365 else if (retval == _NONE)
366 {
367 /* Now we know we only have CGA or MDA */
368
369 PDCINT(0x11, regs);
370
371 switch (regs.h.al & 0x30)
372 {
373 case 0x10:
374 case 0x20:
375 retval = _CGA;
376 break;
377 case 0x30:
378 retval = _MDA;
379 break;
380 default:
381 retval = _NONE;
382 }
383 }
384 }
385
386 if (video_base == 0x3d4)
387 {
388 pdc_video_seg = 0xb800;
389 switch (retval)
390 {
391 case _EGAMONO:
392 retval = _EGACOLOR;
393 break;
394 case _VGAMONO:
395 retval = _VGACOLOR;
396 }
397 }
398
399 if (video_base == 0x3b4)
400 {
401 pdc_video_seg = 0xb000;
402 switch (retval)
403 {
404 case _EGACOLOR:
405 retval = _EGAMONO;
406 break;
407 case _VGACOLOR:
408 retval = _VGAMONO;
409 }
410 }
411
412 if ((retval == _NONE)
413 #ifndef CGA_DIRECT
414 || (retval == _CGA)
415 #endif
416 )
417 pdc_direct_video = FALSE;
418
419 if ((unsigned)pdc_video_seg == 0xb000)
420 SP->mono = TRUE;
421 else
422 SP->mono = FALSE;
423
424 /* Check for DESQview shadow buffer
425 thanks to paganini@ax.apc.org for the GO32 fix */
426
427 #ifndef __WATCOMC__
428 regs.h.ah = 0xfe;
429 regs.h.al = 0;
430 regs.x.di = pdc_video_ofs;
431 # ifdef __DJGPP__
432 regs.x.es = pdc_video_seg;
433 __dpmi_int(0x10, &regs);
434 pdc_video_seg = regs.x.es;
435 # else
436 segs.es = pdc_video_seg;
437 int86x(0x10, &regs, &regs, &segs);
438 pdc_video_seg = segs.es;
439 # endif
440 pdc_video_ofs = regs.x.di;
441 #endif
442 if (!pdc_adapter)
443 pdc_adapter = retval;
444
445 return _sanity_check(retval);
446 }
447
448 /* close the physical screen -- may restore the screen to its state
449 before PDC_scr_open(); miscellaneous cleanup */
450
451 void PDC_scr_close(void)
452 {
453 #if SMALL || MEDIUM
454 # ifndef __PACIFIC__
455 struct SREGS segregs;
456 # endif
457 int ds;
458 #endif
459 PDC_LOG(("PDC_scr_close() - called\n"));
460
461 if (getenv("PDC_RESTORE_SCREEN") && saved_screen)
462 {
463 #ifdef __DJGPP__
464 dosmemput(saved_screen, saved_lines * saved_cols * 2,
465 (unsigned long)_FAR_POINTER(pdc_video_seg,
466 pdc_video_ofs));
467 #else
468 # if (SMALL || MEDIUM)
469 # ifdef __PACIFIC__
470 ds = FP_SEG((void far *)saved_screen);
471 # else
472 segread(&segregs);
473 ds = segregs.ds;
474 # endif
475 movedata(ds, (int)saved_screen, pdc_video_seg, pdc_video_ofs,
476 (saved_lines * saved_cols * 2));
477 # else
478 memcpy((void *)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
479 (void *)saved_screen, (saved_lines * saved_cols * 2));
480 # endif
481 #endif
482 free(saved_screen);
483 saved_screen = NULL;
484 }
485
486 reset_shell_mode();
487
488 if (SP->visibility != 1)
489 curs_set(1);
490
491 /* Position cursor to the bottom left of the screen. */
492
493 PDC_gotoyx(PDC_get_rows() - 2, 0);
494 }
495
496 void PDC_scr_free(void)
497 {
498 if (SP)
499 free(SP);
500 if (pdc_atrtab)
501 free(pdc_atrtab);
502
503 pdc_atrtab = (unsigned char *)NULL;
504 }
505
506 /* open the physical screen -- allocate SP, miscellaneous intialization,
507 and may save the existing screen for later restoration */
508
509 int PDC_scr_open(int argc, char **argv)
510 {
511 #if SMALL || MEDIUM
512 # ifndef __PACIFIC__
513 struct SREGS segregs;
514 # endif
515 int ds;
516 #endif
517 int i;
518
519 PDC_LOG(("PDC_scr_open() - called\n"));
520
521 SP = calloc(1, sizeof(SCREEN));
522 pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
523
524 if (!SP || !pdc_atrtab)
525 return ERR;
526
527 for (i = 0; i < 16; i++)
528 curstoreal[realtocurs[i]] = i;
529
530 SP->orig_attr = FALSE;
531
532 pdc_direct_video = TRUE; /* Assume that we can */
533 pdc_video_seg = 0xb000; /* Base screen segment addr */
534 pdc_video_ofs = 0x0; /* Base screen segment ofs */
535
536 pdc_adapter = _query_adapter_type();
537 pdc_scrnmode = _get_scrn_mode();
538 pdc_font = _get_font();
539
540 SP->lines = PDC_get_rows();
541 SP->cols = PDC_get_columns();
542
543 SP->mouse_wait = PDC_CLICK_PERIOD;
544 SP->audible = TRUE;
545
546 /* If the environment variable PDCURSES_BIOS is set, the DOS int10()
547 BIOS calls are used in place of direct video memory access. */
548
549 if (getenv("PDCURSES_BIOS"))
550 pdc_direct_video = FALSE;
551
552 /* This code for preserving the current screen. */
553
554 if (getenv("PDC_RESTORE_SCREEN"))
555 {
556 saved_lines = SP->lines;
557 saved_cols = SP->cols;
558
559 saved_screen = malloc(saved_lines * saved_cols * 2);
560
561 if (!saved_screen)
562 {
563 SP->_preserve = FALSE;
564 return OK;
565 }
566 #ifdef __DJGPP__
567 dosmemget((unsigned long)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
568 saved_lines * saved_cols * 2, saved_screen);
569 #else
570 # if SMALL || MEDIUM
571 # ifdef __PACIFIC__
572 ds = FP_SEG((void far *) saved_screen);
573 # else
574 segread(&segregs);
575 ds = segregs.ds;
576 # endif
577 movedata(pdc_video_seg, pdc_video_ofs, ds, (int)saved_screen,
578 (saved_lines * saved_cols * 2));
579 # else
580 memcpy((void *)saved_screen,
581 (void *)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
582 (saved_lines * saved_cols * 2));
583 # endif
584 #endif
585 }
586
587 SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
588
589 return OK;
590 }
591
592 /* the core of resize_term() */
593
594 int PDC_resize_screen(int nlines, int ncols)
595 {
596 PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
597 nlines, ncols));
598
599 /* Trash the stored value of orig_cursor -- it's only good if the
600 video mode doesn't change */
601
602 SP->orig_cursor = 0x0607;
603
604 switch (pdc_adapter)
605 {
606 case _EGACOLOR:
607 if (nlines >= 43)
608 _set_font(_FONT8);
609 else
610 _set_80x25();
611 break;
612
613 case _VGACOLOR:
614 if (nlines > 28)
615 _set_font(_FONT8);
616 else
617 if (nlines > 25)
618 _set_font(_FONT14);
619 else
620 _set_80x25();
621 }
622
623 PDC_set_blink(COLORS == 8);
624
625 return OK;
626 }
627
628 void PDC_reset_prog_mode(void)
629 {
630 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
631 }
632
633 void PDC_reset_shell_mode(void)
634 {
635 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
636 }
637
638 void PDC_restore_screen_mode(int i)
639 {
640 if (i >= 0 && i <= 2)
641 {
642 pdc_font = _get_font();
643 _set_font(saved_font[i]);
644
645 if (_get_scrn_mode() != saved_scrnmode[i])
646 _set_scrn_mode(saved_scrnmode[i]);
647 }
648 }
649
650 void PDC_save_screen_mode(int i)
651 {
652 if (i >= 0 && i <= 2)
653 {
654 saved_font[i] = pdc_font;
655 saved_scrnmode[i] = pdc_scrnmode;
656 }
657 }
658
659 void PDC_init_pair(short pair, short fg, short bg)
660 {
661 unsigned char att, temp_bg;
662 chtype i;
663
664 fg = curstoreal[fg];
665 bg = curstoreal[bg];
666
667 for (i = 0; i < PDC_OFFSET; i++)
668 {
669 att = fg | (bg << 4);
670
671 if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
672 att = bg | (fg << 4);
673 if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
674 att = 1;
675 if (i & (A_INVIS >> PDC_ATTR_SHIFT))
676 {
677 temp_bg = att >> 4;
678 att = temp_bg << 4 | temp_bg;
679 }
680 if (i & (A_BOLD >> PDC_ATTR_SHIFT))
681 att |= 8;
682 if (i & (A_BLINK >> PDC_ATTR_SHIFT))
683 att |= 128;
684
685 pdc_atrtab[pair * PDC_OFFSET + i] = att;
686 }
687 }
688
689 int PDC_pair_content(short pair, short *fg, short *bg)
690 {
691 *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
692 *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
693
694 return OK;
695 }
696
697 /* _egapal() - Find the EGA palette value (0-63) for the color (0-15).
698 On VGA, this is an index into the DAC. */
699
700 static short _egapal(short color)
701 {
702 PDCREGS regs;
703
704 regs.W.ax = 0x1007;
705 regs.h.bl = curstoreal[color];
706
707 PDCINT(0x10, regs);
708
709 return regs.h.bh;
710 }
711
712 bool PDC_can_change_color(void)
713 {
714 return (pdc_adapter == _VGACOLOR);
715 }
716
717 /* These are only valid when pdc_adapter == _VGACOLOR */
718
719 int PDC_color_content(short color, short *red, short *green, short *blue)
720 {
721 PDCREGS regs;
722
723 /* Read single DAC register */
724
725 regs.W.ax = 0x1015;
726 regs.h.bl = _egapal(color);
727
728 PDCINT(0x10, regs);
729
730 /* Scale and store */
731
732 *red = DIVROUND((unsigned)(regs.h.dh) * 1000, 63);
733 *green = DIVROUND((unsigned)(regs.h.ch) * 1000, 63);
734 *blue = DIVROUND((unsigned)(regs.h.cl) * 1000, 63);
735
736 return OK;
737 }
738
739 int PDC_init_color(short color, short red, short green, short blue)
740 {
741 PDCREGS regs;
742
743 /* Scale */
744
745 regs.h.dh = DIVROUND((unsigned)red * 63, 1000);
746 regs.h.ch = DIVROUND((unsigned)green * 63, 1000);
747 regs.h.cl = DIVROUND((unsigned)blue * 63, 1000);
748
749 /* Set single DAC register */
750
751 regs.W.ax = 0x1010;
752 regs.W.bx = _egapal(color);
753
754 PDCINT(0x10, regs);
755
756 return OK;
757 }
File dos/pdcsetsc.c added (mode: 100644) (index 00000000..2180ef48)
1 /* Public Domain Curses */
2
3 #include "pdcdos.h"
4
5 RCSID("$Id: pdcsetsc.c,v 1.39 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: pdcsetsc
10
11 Synopsis:
12 int PDC_set_blink(bool blinkon);
13 void PDC_set_title(const char *title);
14
15 Description:
16 PDC_set_blink() toggles whether the A_BLINK attribute sets an
17 actual blink mode (TRUE), or sets the background color to high
18 intensity (FALSE). The default is platform-dependent (FALSE in
19 most cases). It returns OK if it could set the state to match
20 the given parameter, ERR otherwise. Current platforms also
21 adjust the value of COLORS according to this function -- 16 for
22 FALSE, and 8 for TRUE.
23
24 PDC_set_title() sets the title of the window in which the curses
25 program is running. This function may not do anything on some
26 platforms. (Currently it only works in Win32 and X11.)
27
28 Portability X/Open BSD SYS V
29 PDC_set_blink - - -
30 PDC_set_title - - -
31
32 **man-end****************************************************************/
33
34 int PDC_curs_set(int visibility)
35 {
36 PDCREGS regs;
37 int ret_vis, start, end;
38
39 PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
40
41 ret_vis = SP->visibility;
42 SP->visibility = visibility;
43
44 switch (visibility)
45 {
46 case 0: /* invisible */
47 start = 32;
48 end = 0; /* was 32 */
49 break;
50 case 2: /* highly visible */
51 start = 0; /* full-height block */
52 end = 7;
53 break;
54 default: /* normal visibility */
55 start = (SP->orig_cursor >> 8) & 0xff;
56 end = SP->orig_cursor & 0xff;
57 }
58
59 /* if scrnmode is not set, some BIOSes hang */
60
61 regs.h.ah = 0x01;
62 regs.h.al = (unsigned char)pdc_scrnmode;
63 regs.h.ch = (unsigned char)start;
64 regs.h.cl = (unsigned char)end;
65 PDCINT(0x10, regs);
66
67 return ret_vis;
68 }
69
70 void PDC_set_title(const char *title)
71 {
72 PDC_LOG(("PDC_set_title() - called: <%s>\n", title));
73 }
74
75 int PDC_set_blink(bool blinkon)
76 {
77 PDCREGS regs;
78
79 switch (pdc_adapter)
80 {
81 case _EGACOLOR:
82 case _EGAMONO:
83 case _VGACOLOR:
84 case _VGAMONO:
85 regs.W.ax = 0x1003;
86 regs.W.bx = blinkon;
87
88 PDCINT(0x10, regs);
89
90 if (pdc_color_started)
91 COLORS = blinkon ? 8 : 16;
92
93 break;
94 default:
95 COLORS = 8;
96 }
97
98 return (COLORS - (blinkon * 8) != 8) ? OK : ERR;
99 }
File dos/pdcutil.c added (mode: 100644) (index 00000000..b209352a)
1 /* Public Domain Curses */
2
3 #include "pdcdos.h"
4
5 RCSID("$Id: pdcutil.c,v 1.24 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 void PDC_beep(void)
8 {
9 PDCREGS regs;
10
11 PDC_LOG(("PDC_beep() - called\n"));
12
13 regs.W.ax = 0x0e07; /* Write ^G in TTY fashion */
14 regs.W.bx = 0;
15 PDCINT(0x10, regs);
16 }
17
18 void PDC_napms(int ms)
19 {
20 PDCREGS regs;
21 long goal, start, current;
22
23 PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
24
25 goal = DIVROUND((long)ms, 50);
26 if (!goal)
27 goal++;
28
29 start = getdosmemdword(0x46c);
30
31 goal += start;
32
33 while (goal > (current = getdosmemdword(0x46c)))
34 {
35 if (current < start) /* in case of midnight reset */
36 return;
37
38 regs.W.ax = 0x1680;
39 PDCINT(0x2f, regs);
40 PDCINT(0x28, regs);
41 }
42 }
43
44 const char *PDC_sysname(void)
45 {
46 return "DOS";
47 }
48
49 #ifdef __DJGPP__
50
51 unsigned char getdosmembyte(int offset)
52 {
53 unsigned char b;
54
55 dosmemget(offset, sizeof(unsigned char), &b);
56 return b;
57 }
58
59 unsigned short getdosmemword(int offset)
60 {
61 unsigned short w;
62
63 dosmemget(offset, sizeof(unsigned short), &w);
64 return w;
65 }
66
67 unsigned long getdosmemdword(int offset)
68 {
69 unsigned long dw;
70
71 dosmemget(offset, sizeof(unsigned long), &dw);
72 return dw;
73 }
74
75 void setdosmembyte(int offset, unsigned char b)
76 {
77 dosmemput(&b, sizeof(unsigned char), offset);
78 }
79
80 void setdosmemword(int offset, unsigned short w)
81 {
82 dosmemput(&w, sizeof(unsigned short), offset);
83 }
84
85 #endif
86
87 #if defined(__WATCOMC__) && defined(__386__)
88
89 void PDC_dpmi_int(int vector, pdc_dpmi_regs *rmregs)
90 {
91 union REGPACK regs = {0};
92
93 rmregs->w.ss = 0;
94 rmregs->w.sp = 0;
95 rmregs->w.flags = 0;
96
97 regs.w.ax = 0x300;
98 regs.h.bl = vector;
99 regs.x.edi = FP_OFF(rmregs);
100 regs.x.es = FP_SEG(rmregs);
101
102 intr(0x31, &regs);
103 }
104
105 #endif
File dos/wccdos16.mak added (mode: 100644) (index 00000000..a0cbb223)
1 # Watcom WMAKE Makefile for PDCurses library - DOS (16 bit) Watcom C/C++ 10.6+
2 #
3 # Usage: wmake -f [path\]wccdos16.mak [DEBUG=Y] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 # Change the memory MODEL here, if desired
9 MODEL = l
10
11 !ifdef %PDCURSES_SRCDIR
12 PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
13 !else
14 PDCURSES_SRCDIR = ..
15 !endif
16
17 !include $(PDCURSES_SRCDIR)\version.mif
18
19 osdir = $(PDCURSES_SRCDIR)\dos
20
21 CC = wcc
22 TARGET = dos
23
24 CFLAGS = /bt=$(TARGET) /zq /wx /m$(MODEL) /i=$(PDCURSES_SRCDIR)
25
26 !ifeq DEBUG Y
27 CFLAGS += /d2 /DPDCDEBUG
28 LDFLAGS = D W A op q sys $(TARGET)
29 !else
30 CFLAGS += /oneatx
31 LDFLAGS = op q sys $(TARGET)
32 !endif
33
34 LIBEXE = wlib /q /n /t
35
36 !include $(PDCURSES_SRCDIR)\watcom.mif
37
38 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
39 %write wccdos.lrf $(LIBOBJS) $(PDCOBJS)
40 $(LIBEXE) $@ @wccdos.lrf
41 -del wccdos.lrf
42 -copy $(LIBCURSES) panel.lib
43
44 PLATFORM1 = Watcom C++ 16-bit DOS
45 PLATFORM2 = Open Watcom 1.6 for 16-bit DOS
46 ARCNAME = pdc$(VER)16w
47
48 !include $(PDCURSES_SRCDIR)\makedist.mif
File dos/wccdos4g.mak added (mode: 100644) (index 00000000..e1ba1cde)
1 # Watcom WMAKE Makefile for PDCurses library - DOS/4GW Watcom C/C++ 10.6+
2 #
3 # Usage: wmake -f [path\]wccdos4g.mak [DEBUG=Y] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 !ifdef %PDCURSES_SRCDIR
9 PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
10 !else
11 PDCURSES_SRCDIR = ..
12 !endif
13
14 !include $(PDCURSES_SRCDIR)\version.mif
15
16 osdir = $(PDCURSES_SRCDIR)\dos
17
18 CC = wcc386
19 TARGET = dos4g
20
21 CFLAGS = /bt=$(TARGET) /zq /wx /mf /i=$(PDCURSES_SRCDIR)
22
23 !ifeq DEBUG Y
24 CFLAGS += /d2 /DPDCDEBUG
25 LDFLAGS = D W A op q sys $(TARGET)
26 !else
27 CFLAGS += /oneatx
28 LDFLAGS = op q sys $(TARGET)
29 !endif
30
31 LIBEXE = wlib /q /n /t
32
33 !include $(PDCURSES_SRCDIR)\watcom.mif
34
35 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
36 %write wccdos.lrf $(LIBOBJS) $(PDCOBJS)
37 $(LIBEXE) $@ @wccdos.lrf
38 -del wccdos.lrf
39 -copy $(LIBCURSES) panel.lib
40
41 PLATFORM1 = Watcom C++ 32-bit DOS
42 PLATFORM2 = Open Watcom 1.6 for 32-bit DOS
43 ARCNAME = pdc$(VER)32w
44
45 !include $(PDCURSES_SRCDIR)\makedist.mif
File exp-base.def added (mode: 100644) (index 00000000..222b1339)
1 LINES
2 COLS
3 stdscr
4 curscr
5 SP
6 Mouse_status
7 COLORS
8 COLOR_PAIRS
9 TABSIZE
10 acs_map
11 ttytype
12 addch
13 addchnstr
14 addchstr
15 addnstr
16 addstr
17 attroff
18 attron
19 attrset
20 attr_get
21 attr_off
22 attr_on
23 attr_set
24 baudrate
25 beep
26 bkgd
27 bkgdset
28 border
29 box
30 can_change_color
31 cbreak
32 chgat
33 clearok
34 clear
35 clrtobot
36 clrtoeol
37 color_content
38 color_set
39 copywin
40 curs_set
41 def_prog_mode
42 def_shell_mode
43 delay_output
44 delch
45 deleteln
46 delscreen
47 delwin
48 derwin
49 doupdate
50 dupwin
51 echochar
52 echo
53 endwin
54 erasechar
55 erase
56 filter
57 flash
58 flushinp
59 getbkgd
60 getnstr
61 getstr
62 getwin
63 halfdelay
64 has_colors
65 has_ic
66 has_il
67 hline
68 idcok
69 idlok
70 immedok
71 inchnstr
72 inchstr
73 inch
74 init_color
75 init_pair
76 initscr
77 innstr
78 insch
79 insdelln
80 insertln
81 insnstr
82 insstr
83 instr
84 intrflush
85 isendwin
86 is_linetouched
87 is_wintouched
88 keyname
89 keypad
90 killchar
91 leaveok
92 longname
93 meta
94 move
95 mvaddch
96 mvaddchnstr
97 mvaddchstr
98 mvaddnstr
99 mvaddstr
100 mvchgat
101 mvcur
102 mvdelch
103 mvderwin
104 mvgetch
105 mvgetnstr
106 mvgetstr
107 mvhline
108 mvinch
109 mvinchnstr
110 mvinchstr
111 mvinnstr
112 mvinsch
113 mvinsnstr
114 mvinsstr
115 mvinstr
116 mvprintw
117 mvscanw
118 mvvline
119 mvwaddchnstr
120 mvwaddchstr
121 mvwaddch
122 mvwaddnstr
123 mvwaddstr
124 mvwchgat
125 mvwdelch
126 mvwgetch
127 mvwgetnstr
128 mvwgetstr
129 mvwhline
130 mvwinchnstr
131 mvwinchstr
132 mvwinch
133 mvwinnstr
134 mvwinsch
135 mvwinsnstr
136 mvwinsstr
137 mvwinstr
138 mvwin
139 mvwprintw
140 mvwscanw
141 mvwvline
142 napms
143 newpad
144 newterm
145 newwin
146 nl
147 nocbreak
148 nodelay
149 noecho
150 nonl
151 noqiflush
152 noraw
153 notimeout
154 overlay
155 overwrite
156 pair_content
157 pechochar
158 pnoutrefresh
159 prefresh
160 printw
161 putwin
162 qiflush
163 raw
164 redrawwin
165 refresh
166 reset_prog_mode
167 reset_shell_mode
168 resetty
169 ripoffline
170 savetty
171 scanw
172 scr_dump
173 scr_init
174 scrl
175 scrollok
176 scroll
177 scr_restore
178 scr_set
179 setscrreg
180 setsyx
181 set_term
182 slk_attroff
183 slk_attr_off
184 slk_attron
185 slk_attr_on
186 slk_attrset
187 slk_attr_set
188 slk_clear
189 slk_color
190 slk_init
191 slk_label
192 slk_noutrefresh
193 slk_refresh
194 slk_restore
195 slk_set
196 slk_touch
197 standend
198 standout
199 start_color
200 subpad
201 subwin
202 syncok
203 termattrs
204 term_attrs
205 termname
206 timeout
207 touchline
208 touchwin
209 typeahead
210 untouchwin
211 use_env
212 vidattr
213 vid_attr
214 vidputs
215 vid_puts
216 vline
217 vw_printw
218 vwprintw
219 vw_scanw
220 vwscanw
221 waddchnstr
222 waddchstr
223 waddch
224 waddnstr
225 waddstr
226 wattroff
227 wattron
228 wattrset
229 wattr_get
230 wattr_off
231 wattr_on
232 wattr_set
233 wbkgdset
234 wbkgd
235 wborder
236 wchgat
237 wclear
238 wclrtobot
239 wclrtoeol
240 wcolor_set
241 wcursyncup
242 wdelch
243 wdeleteln
244 wechochar
245 werase
246 wgetch
247 wgetnstr
248 wgetstr
249 whline
250 winchnstr
251 winchstr
252 winch
253 winnstr
254 winsch
255 winsdelln
256 winsertln
257 winsnstr
258 winsstr
259 winstr
260 wmove
261 wnoutrefresh
262 wprintw
263 wredrawln
264 wrefresh
265 wscanw
266 wscrl
267 wsetscrreg
268 wstandend
269 wstandout
270 wsyncdown
271 wsyncup
272 wtimeout
273 wtouchln
274 wvline
275 getattrs
276 getbegx
277 getbegy
278 getmaxx
279 getmaxy
280 getparx
281 getpary
282 getcurx
283 getcury
284 traceoff
285 traceon
286 unctrl
287 crmode
288 nocrmode
289 draino
290 resetterm
291 fixterm
292 saveterm
293 mouse_set
294 mouse_on
295 mouse_off
296 request_mouse_pos
297 map_button
298 wmouse_position
299 getmouse
300 getbmap
301 assume_default_colors
302 curses_version
303 has_key
304 use_default_colors
305 wresize
306 mouseinterval
307 mousemask
308 mouse_trafo
309 nc_getmouse
310 ungetmouse
311 wenclose
312 wmouse_trafo
313 addrawch
314 insrawch
315 is_termresized
316 mvaddrawch
317 mvdeleteln
318 mvinsertln
319 mvinsrawch
320 mvwaddrawch
321 mvwdeleteln
322 mvwinsertln
323 mvwinsrawch
324 raw_output
325 resize_term
326 resize_window
327 waddrawch
328 winsrawch
329 wordchar
330 bottom_panel
331 del_panel
332 hide_panel
333 move_panel
334 new_panel
335 panel_above
336 panel_below
337 panel_hidden
338 panel_userptr
339 panel_window
340 replace_panel
341 set_panel_userptr
342 show_panel
343 top_panel
344 update_panels
345 PDC_debug
346 PDC_ungetch
347 PDC_set_blink
348 PDC_set_line_color
349 PDC_set_title
350 PDC_clearclipboard
351 PDC_freeclipboard
352 PDC_getclipboard
353 PDC_setclipboard
354 PDC_get_input_fd
355 PDC_get_key_modifiers
356 PDC_save_key_modifiers
357 PDC_return_key_modifiers
358 cur_term
359 del_curterm
360 putp
361 restartterm
362 set_curterm
363 setterm
364 setupterm
365 tgetent
366 tgetflag
367 tgetnum
368 tgetstr
369 tgoto
370 tigetflag
371 tigetnum
372 tigetstr
373 tparm
374 tputs
File exp-wide.def added (mode: 100644) (index 00000000..ebf6bc20)
1 addnwstr
2 addwstr
3 add_wch
4 add_wchnstr
5 add_wchstr
6 border_set
7 box_set
8 echo_wchar
9 erasewchar
10 getbkgrnd
11 getcchar
12 getn_wstr
13 get_wch
14 get_wstr
15 hline_set
16 innwstr
17 ins_nwstr
18 ins_wch
19 ins_wstr
20 inwstr
21 in_wch
22 in_wchnstr
23 in_wchstr
24 key_name
25 killwchar
26 mvaddnwstr
27 mvaddwstr
28 mvadd_wch
29 mvadd_wchnstr
30 mvadd_wchstr
31 mvgetn_wstr
32 mvget_wch
33 mvget_wstr
34 mvhline_set
35 mvinnwstr
36 mvins_nwstr
37 mvins_wch
38 mvins_wstr
39 mvinwstr
40 mvin_wch
41 mvin_wchnstr
42 mvin_wchstr
43 mvvline_set
44 mvwaddnwstr
45 mvwaddwstr
46 mvwadd_wch
47 mvwadd_wchnstr
48 mvwadd_wchstr
49 mvwgetn_wstr
50 mvwget_wch
51 mvwget_wstr
52 mvwhline_set
53 mvwinnwstr
54 mvwins_nwstr
55 mvwins_wch
56 mvwins_wstr
57 mvwin_wch
58 mvwin_wchnstr
59 mvwin_wchstr
60 mvwinwstr
61 mvwvline_set
62 pecho_wchar
63 setcchar
64 slk_wset
65 unget_wch
66 vline_set
67 waddnwstr
68 waddwstr
69 wadd_wch
70 wadd_wchnstr
71 wadd_wchstr
72 wbkgrnd
73 wbkgrndset
74 wborder_set
75 wecho_wchar
76 wgetbkgrnd
77 wgetn_wstr
78 wget_wch
79 wget_wstr
80 whline_set
81 winnwstr
82 wins_nwstr
83 wins_wch
84 wins_wstr
85 winwstr
86 win_wch
87 win_wchnstr
88 win_wchstr
89 wunctrl
90 wvline_set
File install-sh added (mode: 100755) (index 00000000..fb9e848a)
1 #! /bin/sh
2 #
3 # install - install a program, script, or datafile
4 # This comes from X11R5 (mit/util/scripts/install.sh).
5 #
6 # Copyright 1991 by the Massachusetts Institute of Technology
7 #
8 # Permission to use, copy, modify, distribute, and sell this software and its
9 # documentation for any purpose is hereby granted without fee, provided that
10 # the above copyright notice appear in all copies and that both that
11 # copyright notice and this permission notice appear in supporting
12 # documentation, and that the name of M.I.T. not be used in advertising or
13 # publicity pertaining to distribution of the software without specific,
14 # written prior permission. M.I.T. makes no representations about the
15 # suitability of this software for any purpose. It is provided "as is"
16 # without express or implied warranty.
17 #
18 # Calling this script install-sh is preferred over install.sh, to prevent
19 # `make' implicit rules from creating a file called install from it
20 # when there is no Makefile.
21 #
22 # This script is compatible with the BSD install script, but was written
23 # from scratch. It can only install one file at a time, a restriction
24 # shared with many OS's install programs.
25
26
27 # set DOITPROG to echo to test this script
28
29 # Don't use :- since 4.3BSD and earlier shells don't like it.
30 #
31 # Modified 1 Feb 2000 MHES to cater for mkdir -p
32 #
33 doit="${DOITPROG-}"
34
35
36 # put in absolute paths if you don't have them in your path; or use env. vars.
37
38 mvprog="${MVPROG-mv}"
39 cpprog="${CPPROG-cp}"
40 chmodprog="${CHMODPROG-chmod}"
41 chownprog="${CHOWNPROG-chown}"
42 chgrpprog="${CHGRPPROG-chgrp}"
43 stripprog="${STRIPPROG-strip}"
44 rmprog="${RMPROG-rm}"
45 mkdirprog="${MKDIRPROG-mkdir}"
46
47 transformbasename=""
48 transform_arg=""
49 instcmd="$mvprog"
50 chmodcmd="$chmodprog 0755"
51 chowncmd=""
52 chgrpcmd=""
53 stripcmd=""
54 rmcmd="$rmprog -f"
55 mvcmd="$mvprog"
56 mkdircmd="$mkdirprog -p"
57 src=""
58 dst=""
59 dir_arg=""
60
61 while [ x"$1" != x ]; do
62 case $1 in
63 -c) instcmd="$cpprog"
64 shift
65 continue;;
66
67 -d) dir_arg=true
68 shift
69 continue;;
70
71 -m) chmodcmd="$chmodprog $2"
72 shift
73 shift
74 continue;;
75
76 -o) chowncmd="$chownprog $2"
77 shift
78 shift
79 continue;;
80
81 -g) chgrpcmd="$chgrpprog $2"
82 shift
83 shift
84 continue;;
85
86 -s) stripcmd="$stripprog"
87 shift
88 continue;;
89
90 -t=*) transformarg=`echo $1 | sed 's/-t=//'`
91 shift
92 continue;;
93
94 -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
95 shift
96 continue;;
97
98 *) if [ x"$src" = x ]
99 then
100 src=$1
101 else
102 # this colon is to work around a 386BSD /bin/sh bug
103 :
104 dst=$1
105 fi
106 shift
107 continue;;
108 esac
109 done
110
111 if [ x"$src" = x ]
112 then
113 echo "install: no input file specified"
114 exit 1
115 else
116 true
117 fi
118
119 if [ x"$dir_arg" != x ]; then
120 dst=$src
121 src=""
122
123 if [ -d $dst ]; then
124 instcmd=:
125 else
126 instcmd=mkdir
127 fi
128 else
129
130 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
131 # might cause directories to be created, which would be especially bad
132 # if $src (and thus $dsttmp) contains '*'.
133
134 if [ -f $src -o -d $src ]
135 then
136 true
137 else
138 echo "install: $src does not exist"
139 exit 1
140 fi
141
142 if [ x"$dst" = x ]
143 then
144 echo "install: no destination specified"
145 exit 1
146 else
147 true
148 fi
149
150 # If destination is a directory, append the input filename; if your system
151 # does not like double slashes in filenames, you may need to add some logic
152
153 if [ -d $dst ]
154 then
155 dst="$dst"/`basename $src`
156 else
157 true
158 fi
159 fi
160
161 ## this sed command emulates the dirname command
162 dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
163
164 # Make sure that the destination directory exists.
165 # this part is taken from Noah Friedman's mkinstalldirs script
166
167 # Skip lots of stat calls in the usual case.
168 if [ ! -d "$dstdir" ]; then
169 defaultIFS='
170 '
171 IFS="${IFS-${defaultIFS}}"
172
173 oIFS="${IFS}"
174 # Some sh's can't handle IFS=/ for some reason.
175 IFS='%'
176 set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
177 IFS="${oIFS}"
178
179 pathcomp=''
180
181 while [ $# -ne 0 ] ; do
182 pathcomp="${pathcomp}${1}"
183 shift
184
185 if [ ! -d "${pathcomp}" ] ;
186 then
187 $mkdircmd "${pathcomp}"
188 else
189 true
190 fi
191
192 pathcomp="${pathcomp}/"
193 done
194 fi
195
196 if [ x"$dir_arg" != x ]
197 then
198 $doit $instcmd $dst &&
199
200 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
201 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
202 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
203 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
204 else
205
206 # If we're going to rename the final executable, determine the name now.
207
208 if [ x"$transformarg" = x ]
209 then
210 dstfile=`basename $dst`
211 else
212 dstfile=`basename $dst $transformbasename |
213 sed $transformarg`$transformbasename
214 fi
215
216 # don't allow the sed command to completely eliminate the filename
217
218 if [ x"$dstfile" = x ]
219 then
220 dstfile=`basename $dst`
221 else
222 true
223 fi
224
225 # Make a temp file name in the proper directory.
226
227 dsttmp=$dstdir/#inst.$$#
228
229 # Move or copy the file name to the temp name
230
231 $doit $instcmd $src $dsttmp &&
232
233 trap "rm -f ${dsttmp}" 0 &&
234
235 # and set any options; do chmod last to preserve setuid bits
236
237 # If any of these fail, we abort the whole thing. If we want to
238 # ignore errors from any of these, just make sure not to ignore
239 # errors from the above "$doit $instcmd $src $dsttmp" command.
240
241 if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
242 if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
243 if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
244 if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
245
246 # Now rename the file to the real destination.
247
248 $doit $rmcmd -f $dstdir/$dstfile &&
249 $doit $mvcmd $dsttmp $dstdir/$dstfile
250
251 fi &&
252
253 exit 0
File libobjs.mif added (mode: 100644) (index 00000000..67053235)
1 # Common elements for most of the DOS, OS/2 and Win32
2 # makefiles (not Watcom or LCC)
3
4 PDCURSES_CURSES_H = $(PDCURSES_SRCDIR)/curses.h
5 PDCURSES_CURSPRIV_H = $(PDCURSES_SRCDIR)/curspriv.h
6 PDCURSES_HEADERS = $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
7 PANEL_HEADER = $(PDCURSES_SRCDIR)/panel.h
8 TERM_HEADER = $(PDCURSES_SRCDIR)/term.h
9
10 srcdir = $(PDCURSES_SRCDIR)/pdcurses
11 demodir = $(PDCURSES_SRCDIR)/demos
12
13 LIBOBJS = addch.$(O) addchstr.$(O) addstr.$(O) attr.$(O) beep.$(O) \
14 bkgd.$(O) border.$(O) clear.$(O) color.$(O) delch.$(O) deleteln.$(O) \
15 deprec.$(O) getch.$(O) getstr.$(O) getyx.$(O) inch.$(O) inchstr.$(O) \
16 initscr.$(O) inopts.$(O) insch.$(O) insstr.$(O) instr.$(O) kernel.$(O) \
17 keyname.$(O) mouse.$(O) move.$(O) outopts.$(O) overlay.$(O) pad.$(O) \
18 panel.$(O) printw.$(O) refresh.$(O) scanw.$(O) scr_dump.$(O) scroll.$(O) \
19 slk.$(O) termattr.$(O) terminfo.$(O) touch.$(O) util.$(O) window.$(O) \
20 debug.$(O)
21
22 PDCOBJS = pdcclip.$(O) pdcdisp.$(O) pdcgetsc.$(O) pdckbd.$(O) pdcscrn.$(O) \
23 pdcsetsc.$(O) pdcutil.$(O)
24
25 DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe firework.exe \
26 ptest.exe rain.exe worm.exe
File makedist.mif added (mode: 100644) (index 00000000..e7495a50)
1 # Makefile include: build a binary archive with Info-ZIP
2 # under DOS, OS/2 or Win32
3
4 dist: $(PDCLIBS)
5 echo PDCurses $(VERDOT) for $(PLATFORM1) > file_id.diz
6 echo ------------------------------------------ >> file_id.diz
7 echo Public Domain Curses library for >> file_id.diz
8 echo $(PLATFORM2). >> file_id.diz
9 echo Source available in PDCURS$(VER).ZIP >> file_id.diz
10 echo Public Domain. >> file_id.diz
11 echo $(PDCURSES_SRCDIR)\README > flist
12 echo $(PDCURSES_SRCDIR)\HISTORY >> flist
13 echo $(PDCURSES_SRCDIR)\curses.h >> flist
14 echo $(PDCURSES_SRCDIR)\panel.h >> flist
15 echo $(PDCURSES_SRCDIR)\term.h >> flist
16 echo $(LIBCURSES) >> flist
17 echo file_id.diz >> flist
18 zip -9jX $(ARCNAME) -@ <flist
19 del flist
20 del file_id.diz
File os2/README added (mode: 100644) (index 00000000..7fde884e)
1 PDCurses for OS/2
2 =================
3
4 This directory contains PDCurses source code files specific to OS/2.
5
6
7 Building
8 --------
9
10 . Choose the appropriate makefile for your compiler:
11
12 bccos2.mak - Borland C++ 2.0
13 gccos2.mak - EMX 0.9b+
14 iccos2.mak - C Set/2
15 wccos2.mak - Watcom 10.6+ (32-bit)
16
17 . Optionally, you can build in a different directory than the platform
18 directory by setting PDCURSES_SRCDIR to point to the directory where
19 you unpacked PDCurses, and changing to your target directory:
20
21 set PDCURSES_SRCDIR=c:\pdcurses
22
23 . Build it:
24
25 make -f makefilename
26
27 (For Watcom, use "wmake" instead of "make"; for MSVC or C Set/2,
28 "nmake".) You'll get the libraries (pdcurses.lib or .a, depending on
29 your compiler; and panel.lib or .a), the demos (*.exe), and a lot of
30 object files. Note that the panel library is just a copy of the main
31 library, provided for convenience; both panel and curses functions are
32 in the main library.
33
34 You can also use the optional parameter "DLL=Y" with EMX, to build the
35 library as a DLL:
36
37 make -f gccos2.mak DLL=Y
38
39
40 Distribution Status
41 -------------------
42
43 The files in this directory are released to the Public Domain.
File os2/bccos2.mak added (mode: 100644) (index 00000000..1c7d77a3)
1 # Borland MAKE Makefile for PDCurses library - OS/2 BC++ 1.0+
2 #
3 # Usage: make -f [path\]bccos2.mak [DEBUG=] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 O = obj
9
10 !ifndef PDCURSES_SRCDIR
11 PDCURSES_SRCDIR = ..
12 !endif
13
14 !include $(PDCURSES_SRCDIR)\version.mif
15 !include $(PDCURSES_SRCDIR)\libobjs.mif
16
17 osdir = $(PDCURSES_SRCDIR)\os2
18
19 CC = bcc
20
21 !ifdef DEBUG
22 CFLAGS = -N -v -y -DPDCDEBUG
23 !else
24 CFLAGS = -O
25 !endif
26
27 CPPFLAGS = -I$(PDCURSES_SRCDIR)
28
29 BUILD = $(CC) -c $(CFLAGS) $(CPPFLAGS)
30
31 LINK = tlink
32
33 LIBEXE = tlib /C /E
34
35 LIBCURSES = pdcurses.lib
36
37 all: $(LIBCURSES) $(DEMOS)
38
39 clean:
40 -del *.obj
41 -del *.lib
42 -del *.exe
43
44 demos: $(DEMOS)
45
46 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
47 -del $@
48 $(LIBEXE) $@ \
49 +addch.obj +addchstr.obj +addstr.obj +attr.obj +beep.obj +bkgd.obj \
50 +border.obj +clear.obj +color.obj +delch.obj +deleteln.obj +deprec.obj \
51 +getch.obj +getstr.obj +getyx.obj +inch.obj +inchstr.obj +initscr.obj \
52 +inopts.obj +insch.obj +insstr.obj +instr.obj +kernel.obj +keyname.obj \
53 +mouse.obj +move.obj +outopts.obj +overlay.obj +pad.obj +panel.obj \
54 +printw.obj +refresh.obj +scanw.obj +scr_dump.obj +scroll.obj +slk.obj \
55 +termattr.obj +terminfo.obj +touch.obj +util.obj +window.obj +debug.obj \
56 +pdcclip.obj +pdcdisp.obj +pdcgetsc.obj +pdckbd.obj +pdcscrn.obj \
57 +pdcsetsc.obj +pdcutil.obj ,lib.map
58 -copy $(LIBCURSES) panel.lib
59
60 .autodepend
61
62 {$(srcdir)\}.c.obj:
63 $(BUILD) $<
64
65 {$(osdir)\}.c.obj:
66 $(BUILD) $<
67
68 {$(demodir)\}.c.obj:
69 $(BUILD) $<
70
71 .c.obj:
72 $(BUILD) $<
73
74 .obj.exe:
75 $(CC) -e$@ $** $(LIBCURSES)
76
77 tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
78 $(CC) -e$@ $**
79
80 tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
81 $(BUILD) -I$(demodir) $(demodir)\tui.c
82
83 tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
84 $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
85
86 PLATFORM1 = Borland C++ OS/2 1.0
87 PLATFORM2 = Borland C/C++ OS/2 1.0
88 ARCNAME = pdc$(VER)bcos2
89
90 !include $(PDCURSES_SRCDIR)\makedist.mif
File os2/gccos2.mak added (mode: 100644) (index 00000000..07d4dca4)
1 # GNU MAKE Makefile for PDCurses library - OS/2 emx 0.9c+
2 #
3 # Usage: make -f [path\]gccos2.mak [DEBUG=Y] [EMXVIDEO=Y] [DLL=Y] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.a|testcurs.exe...]
7 #
8 # The EMXVIDEO option compiles with the emx video library, which
9 # enables a PDCurses program to run under OS/2 and DOS.
10
11 O = o
12
13 ifndef PDCURSES_SRCDIR
14 PDCURSES_SRCDIR = ..
15 endif
16
17 include $(PDCURSES_SRCDIR)/version.mif
18 include $(PDCURSES_SRCDIR)/libobjs.mif
19
20 osdir = $(PDCURSES_SRCDIR)/os2
21
22 PDCURSES_OS2_H = $(osdir)/pdcos2.h
23
24 CC = gcc
25
26 CFLAGS = -I$(PDCURSES_SRCDIR) -c -Wall
27
28 ifeq ($(EMXVIDEO),Y)
29 CFLAGS += -DEMXVIDEO
30 CCLIBS = -lvideo
31 BINDFLAGS = -acm
32 else
33 CCLIBS =
34 BINDFLAGS =
35 endif
36
37 ifeq ($(DEBUG),Y)
38 CFLAGS += -g -DPDCDEBUG
39 LDFLAGS = -g
40 else
41 CFLAGS += -O2
42 LDFLAGS =
43 endif
44
45 BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
46
47 DEFDEPS = $(BASEDEF)
48
49 DEFFILE = pdcurses.def
50
51 DLLTARGET = pdcurses.dll
52 DLLFLAGS = -Zdll -Zcrtdll -Zomf
53
54 LINK = gcc
55 EMXBIND = emxbind
56 EMXOMF = emxomf
57
58 LIBEXE = ar
59 LIBFLAGS = rcv
60
61 ifeq ($(DLL),Y)
62 CFLAGS += -Zdll -Zcrtdll -Zomf
63 LDFLAGS += -Zlinker /PM:VIO -Zomf -Zcrtdll
64 LIBCURSES = pdcurses.lib
65 LIBDEPS = $(LIBOBJS) $(PDCOBJS) $(DEFFILE)
66 PDCLIBS = $(DLLTARGET)
67 EXEPOST =
68 TUIPOST =
69 CLEAN = *.dll *.lib $(DEFFILE)
70 else
71 LIBCURSES = pdcurses.a
72 LIBDEPS = $(LIBOBJS) $(PDCOBJS)
73 PDCLIBS = $(LIBCURSES)
74 EXEPOST = $(EMXBIND) $* $(BINDFLAGS)
75 TUIPOST = $(EMXBIND) tuidemo $(BINDFLAGS)
76 CLEAN = *.a testcurs newdemo xmas tuidemo firework ptest rain worm
77 endif
78
79 .PHONY: all libs clean demos dist
80
81 all: libs demos
82
83 libs: $(PDCLIBS)
84
85 clean:
86 -del *.o
87 -del *.exe
88 -del $(CLEAN)
89
90 demos: $(DEMOS)
91
92 DEMOOBJS = testcurs.o newdemo.o xmas.o tui.o tuidemo.o firework.o \
93 ptest.o rain.o worm.o
94
95 $(DEFFILE) : $(DEFDEPS)
96 echo LIBRARY PDCURSES > $@
97 echo DESCRIPTION 'PDCurses 3.4 Dynamic Linking library' >> $@
98 echo PROTMODE >>$@
99 echo DATA MULTIPLE READWRITE LOADONCALL >> $@
100 echo CODE LOADONCALL >> $@
101 echo EXPORTS >> $@
102 type $(BASEDEF) >> $@
103
104 $(LIBCURSES) : $(LIBDEPS)
105 $(LIBEXE) $(LIBFLAGS) $@ $?
106 -copy $(LIBCURSES) panel.a
107
108 $(DLLTARGET) : $(LIBDEPS)
109 $(LINK) $(DLLFLAGS) -o $(DLLTARGET) $? $(DEFFILE)
110 # lxlite $(DLLTARGET)
111 emximp -o $(LIBCURSES) $(DEFFILE)
112
113 $(LIBOBJS) $(PDCOBJS) $(DEMOOBJS) : $(PDCURSES_HEADERS)
114 $(PDCOBJS) : $(PDCURSES_OS2_H)
115 $(DEMOS) : $(LIBCURSES)
116 panel.o ptest.o: $(PANEL_HEADER)
117 terminfo.o: $(TERM_HEADER)
118
119 $(LIBOBJS) : %.o: $(srcdir)/%.c
120 $(CC) -c $(CFLAGS) -o$@ $<
121
122 $(PDCOBJS) : %.o: $(osdir)/%.c
123 $(CC) -c $(CFLAGS) -o$@ $<
124
125 firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
126 ptest.exe: %.exe: %.o
127 $(LINK) $(LDFLAGS) -o $* $< $(LIBCURSES) $(CCLIBS)
128 $(EXEPOST)
129
130 tuidemo.exe: tuidemo.o tui.o
131 $(LINK) $(LDFLAGS) -o tuidemo tuidemo.o tui.o $(LIBCURSES) $(CCLIBS)
132 $(TUIPOST)
133
134 firework.o newdemo.o ptest.o rain.o testcurs.o worm.o xmas.o: %.o: \
135 $(demodir)/%.c
136 $(CC) $(CFLAGS) -o$@ $<
137
138 tui.o: $(demodir)\tui.c $(demodir)\tui.h
139 $(CC) $(CFLAGS) -I$(demodir) -o $@ $<
140
141 tuidemo.o: $(demodir)\tuidemo.c
142 $(CC) $(CFLAGS) -I$(demodir) -o $@ $<
143
144 PLATFORM1 = EMX OS/2
145 PLATFORM2 = EMX 0.9d for OS/2
146 ARCNAME = pdc$(VER)_emx_os2
147
148 include $(PDCURSES_SRCDIR)/makedist.mif
File os2/iccos2.lrf added (mode: 100644) (index 00000000..b1fdf37e)
1 -+addch.obj &
2 -+addchstr.obj &
3 -+addstr.obj &
4 -+attr.obj &
5 -+beep.obj &
6 -+bkgd.obj &
7 -+border.obj &
8 -+clear.obj &
9 -+color.obj &
10 -+delch.obj &
11 -+deleteln.obj &
12 -+deprec.obj &
13 -+getch.obj &
14 -+getstr.obj &
15 -+getyx.obj &
16 -+inch.obj &
17 -+inchstr.obj &
18 -+initscr.obj &
19 -+inopts.obj &
20 -+insch.obj &
21 -+insstr.obj &
22 -+instr.obj &
23 -+kernel.obj &
24 -+keyname.obj &
25 -+mouse.obj &
26 -+move.obj &
27 -+outopts.obj &
28 -+overlay.obj &
29 -+pad.obj &
30 -+panel.obj &
31 -+printw.obj &
32 -+refresh.obj &
33 -+scanw.obj &
34 -+scr_dump.obj &
35 -+scroll.obj &
36 -+slk.obj &
37 -+termattr.obj &
38 -+terminfo.obj &
39 -+touch.obj &
40 -+util.obj &
41 -+window.obj &
42 -+debug.obj &
43 -+pdcclip.obj &
44 -+pdcdisp.obj &
45 -+pdcgetsc.obj &
46 -+pdckbd.obj &
47 -+pdcscrn.obj &
48 -+pdcsetsc.obj &
49 -+pdcutil.obj &
50 ,lib.map;
File os2/iccos2.mak added (mode: 100644) (index 00000000..06a2c1fe)
1 # NMAKE Makefile for PDCurses library - OS/2 C Set/2
2 #
3 # Usage: nmake -f [path\]iccos2.mak [DEBUG=] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 O = obj
9
10 !ifndef PDCURSES_SRCDIR
11 PDCURSES_SRCDIR = ..
12 !endif
13
14 !include $(PDCURSES_SRCDIR)\version.mif
15 !include $(PDCURSES_SRCDIR)\libobjs.mif
16
17 osdir = $(PDCURSES_SRCDIR)\os2
18
19 PDCURSES_OS2_H = $(osdir)\pdcos2.h
20
21 CC = icc
22
23 !ifdef DEBUG
24 CFLAGS = /Sm /Ti+ /O- /Q+ /dPDCDEBUG
25 LDFLAGS = /NOLOGO /NOE /SE:160 /DEBUG /PMTYPE:VIO
26 !else
27 CFLAGS = /Sm /Ti- /O+ /Q+
28 LDFLAGS = /NOLOGO /NOE /EXEPACK /PACKCODE /PACKDATA /PMTYPE:VIO
29 !endif
30
31 CPPFLAGS = -I$(PDCURSES_SRCDIR)
32
33 BUILD = $(CC) -c $(CFLAGS) $(CPPFLAGS)
34
35 LINK = link386
36
37 LIBEXE = lib
38
39 LIBCURSES = pdcurses.lib
40
41 all: $(LIBCURSES) $(DEMOS)
42
43 clean:
44 -del *.obj
45 -del *.lib
46 -del *.exe
47
48 demos: $(DEMOS)
49
50 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
51 $(LIBEXE) $@ @$(osdir)\iccos2.lrf
52 -copy $(LIBCURSES) panel.lib
53
54 addch.obj: $(srcdir)\addch.c $(PDCURSES_HEADERS)
55 $(BUILD) $(srcdir)\addch.c
56
57 addchstr.obj: $(srcdir)\addchstr.c $(PDCURSES_HEADERS)
58 $(BUILD) $(srcdir)\addchstr.c
59
60 addstr.obj: $(srcdir)\addstr.c $(PDCURSES_HEADERS)
61 $(BUILD) $(srcdir)\addstr.c
62
63 attr.obj: $(srcdir)\attr.c $(PDCURSES_HEADERS)
64 $(BUILD) $(srcdir)\attr.c
65
66 beep.obj: $(srcdir)\beep.c $(PDCURSES_HEADERS)
67 $(BUILD) $(srcdir)\beep.c
68
69 bkgd.obj: $(srcdir)\bkgd.c $(PDCURSES_HEADERS)
70 $(BUILD) $(srcdir)\bkgd.c
71
72 border.obj: $(srcdir)\border.c $(PDCURSES_HEADERS)
73 $(BUILD) $(srcdir)\border.c
74
75 clear.obj: $(srcdir)\clear.c $(PDCURSES_HEADERS)
76 $(BUILD) $(srcdir)\clear.c
77
78 color.obj: $(srcdir)\color.c $(PDCURSES_HEADERS)
79 $(BUILD) $(srcdir)\color.c
80
81 delch.obj: $(srcdir)\delch.c $(PDCURSES_HEADERS)
82 $(BUILD) $(srcdir)\delch.c
83
84 deleteln.obj: $(srcdir)\deleteln.c $(PDCURSES_HEADERS)
85 $(BUILD) $(srcdir)\deleteln.c
86
87 deprec.obj: $(srcdir)\deprec.c $(PDCURSES_HEADERS)
88 $(BUILD) $(srcdir)\deprec.c
89
90 getch.obj: $(srcdir)\getch.c $(PDCURSES_HEADERS)
91 $(BUILD) $(srcdir)\getch.c
92
93 getstr.obj: $(srcdir)\getstr.c $(PDCURSES_HEADERS)
94 $(BUILD) $(srcdir)\getstr.c
95
96 getyx.obj: $(srcdir)\getyx.c $(PDCURSES_HEADERS)
97 $(BUILD) $(srcdir)\getyx.c
98
99 inch.obj: $(srcdir)\inch.c $(PDCURSES_HEADERS)
100 $(BUILD) $(srcdir)\inch.c
101
102 inchstr.obj: $(srcdir)\inchstr.c $(PDCURSES_HEADERS)
103 $(BUILD) $(srcdir)\inchstr.c
104
105 initscr.obj: $(srcdir)\initscr.c $(PDCURSES_HEADERS)
106 $(BUILD) $(srcdir)\initscr.c
107
108 inopts.obj: $(srcdir)\inopts.c $(PDCURSES_HEADERS)
109 $(BUILD) $(srcdir)\inopts.c
110
111 insch.obj: $(srcdir)\insch.c $(PDCURSES_HEADERS)
112 $(BUILD) $(srcdir)\insch.c
113
114 insstr.obj: $(srcdir)\insstr.c $(PDCURSES_HEADERS)
115 $(BUILD) $(srcdir)\insstr.c
116
117 instr.obj: $(srcdir)\instr.c $(PDCURSES_HEADERS)
118 $(BUILD) $(srcdir)\instr.c
119
120 kernel.obj: $(srcdir)\kernel.c $(PDCURSES_HEADERS)
121 $(BUILD) $(srcdir)\kernel.c
122
123 keyname.obj: $(srcdir)\keyname.c $(PDCURSES_HEADERS)
124 $(BUILD) $(srcdir)\keyname.c
125
126 mouse.obj: $(srcdir)\mouse.c $(PDCURSES_HEADERS)
127 $(BUILD) $(srcdir)\mouse.c
128
129 move.obj: $(srcdir)\move.c $(PDCURSES_HEADERS)
130 $(BUILD) $(srcdir)\move.c
131
132 outopts.obj: $(srcdir)\outopts.c $(PDCURSES_HEADERS)
133 $(BUILD) $(srcdir)\outopts.c
134
135 overlay.obj: $(srcdir)\overlay.c $(PDCURSES_HEADERS)
136 $(BUILD) $(srcdir)\overlay.c
137
138 pad.obj: $(srcdir)\pad.c $(PDCURSES_HEADERS)
139 $(BUILD) $(srcdir)\pad.c
140
141 panel.obj: $(srcdir)\panel.c $(PDCURSES_HEADERS) $(PANEL_HEADER)
142 $(BUILD) $(srcdir)\panel.c
143
144 printw.obj: $(srcdir)\printw.c $(PDCURSES_HEADERS)
145 $(BUILD) $(srcdir)\printw.c
146
147 refresh.obj: $(srcdir)\refresh.c $(PDCURSES_HEADERS)
148 $(BUILD) $(srcdir)\refresh.c
149
150 scanw.obj: $(srcdir)\scanw.c $(PDCURSES_HEADERS)
151 $(BUILD) $(srcdir)\scanw.c
152
153 scr_dump.obj: $(srcdir)\scr_dump.c $(PDCURSES_HEADERS)
154 $(BUILD) $(srcdir)\scr_dump.c
155
156 scroll.obj: $(srcdir)\scroll.c $(PDCURSES_HEADERS)
157 $(BUILD) $(srcdir)\scroll.c
158
159 slk.obj: $(srcdir)\slk.c $(PDCURSES_HEADERS)
160 $(BUILD) $(srcdir)\slk.c
161
162 termattr.obj: $(srcdir)\termattr.c $(PDCURSES_HEADERS)
163 $(BUILD) $(srcdir)\termattr.c
164
165 terminfo.obj: $(srcdir)\terminfo.c $(PDCURSES_HEADERS) $(TERM_HEADER)
166 $(BUILD) $(srcdir)\terminfo.c
167
168 touch.obj: $(srcdir)\touch.c $(PDCURSES_HEADERS)
169 $(BUILD) $(srcdir)\touch.c
170
171 util.obj: $(srcdir)\util.c $(PDCURSES_HEADERS)
172 $(BUILD) $(srcdir)\util.c
173
174 window.obj: $(srcdir)\window.c $(PDCURSES_HEADERS)
175 $(BUILD) $(srcdir)\window.c
176
177 debug.obj: $(srcdir)\debug.c $(PDCURSES_HEADERS)
178 $(BUILD) $(srcdir)\debug.c
179
180 pdcclip.obj: $(osdir)\pdcclip.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
181 $(BUILD) $(osdir)\pdcclip.c
182
183 pdcdisp.obj: $(osdir)\pdcdisp.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
184 $(BUILD) $(osdir)\pdcdisp.c
185
186 pdcgetsc.obj: $(osdir)\pdcgetsc.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
187 $(BUILD) $(osdir)\pdcgetsc.c
188
189 pdckbd.obj: $(osdir)\pdckbd.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
190 $(BUILD) $(osdir)\pdckbd.c
191
192 pdcscrn.obj: $(osdir)\pdcscrn.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
193 $(BUILD) $(osdir)\pdcscrn.c
194
195 pdcsetsc.obj: $(osdir)\pdcsetsc.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
196 $(BUILD) $(osdir)\pdcsetsc.c
197
198 pdcutil.obj: $(osdir)\pdcutil.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
199 $(BUILD) $(osdir)\pdcutil.c
200
201 firework.exe: firework.obj $(LIBCURSES)
202 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
203
204 newdemo.exe: newdemo.obj $(LIBCURSES)
205 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
206
207 ptest.exe: ptest.obj $(LIBCURSES)
208 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
209
210 rain.exe: rain.obj $(LIBCURSES)
211 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
212
213 testcurs.exe: testcurs.obj $(LIBCURSES)
214 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
215
216 tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
217 $(LINK) $(LDFLAGS) $*.obj+tui.obj,$*,,$(LIBCURSES);
218
219 worm.exe: worm.obj $(LIBCURSES)
220 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
221
222 xmas.exe: xmas.obj $(LIBCURSES)
223 $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
224
225 firework.obj: $(demodir)\firework.c $(PDCURSES_CURSES_H)
226 $(BUILD) $(demodir)\firework.c
227
228 newdemo.obj: $(demodir)\newdemo.c $(PDCURSES_CURSES_H)
229 $(BUILD) $(demodir)\newdemo.c
230
231 ptest.obj: $(demodir)\ptest.c $(PANEL_HEADER) $(PDCURSES_CURSES_H)
232 $(BUILD) $(demodir)\ptest.c
233
234 rain.obj: $(demodir)\rain.c $(PDCURSES_CURSES_H)
235 $(BUILD) $(demodir)\rain.c
236
237 testcurs.obj: $(demodir)\testcurs.c $(PDCURSES_CURSES_H)
238 $(BUILD) $(demodir)\testcurs.c
239
240 tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
241 $(BUILD) $(demodir)\tui.c
242
243 tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
244 $(BUILD) $(demodir)\tuidemo.c
245
246 worm.obj: $(demodir)\worm.c $(PDCURSES_CURSES_H)
247 $(BUILD) $(demodir)\worm.c
248
249 xmas.obj: $(demodir)\xmas.c $(PDCURSES_CURSES_H)
250 $(BUILD) $(demodir)\xmas.c
251
252 PLATFORM1 = C Set/2 OS/2
253 PLATFORM2 = C Set/2 for OS/2
254 ARCNAME = pdc$(VER)_icc_os2
255
256 !include $(PDCURSES_SRCDIR)\makedist.mif
File os2/pdcclip.c added (mode: 100644) (index 00000000..ddc61d90)
1 /* Public Domain Curses */
2
3 #include "pdcos2.h"
4
5 RCSID("$Id: pdcclip.c,v 1.33 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: clipboard
10
11 Synopsis:
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 PDC_getclipboard() gets the textual contents of the system's
19 clipboard. This function returns the contents of the clipboard
20 in the contents argument. It is the responsibilitiy of the
21 caller to free the memory returned, via PDC_freeclipboard().
22 The length of the clipboard contents is returned in the length
23 argument.
24
25 PDC_setclipboard copies the supplied text into the system's
26 clipboard, emptying the clipboard prior to the copy.
27
28 PDC_clearclipboard() clears the internal clipboard.
29
30 Return Values:
31 indicator of success/failure of call.
32 PDC_CLIP_SUCCESS the call was successful
33 PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
34 the clipboard contents
35 PDC_CLIP_EMPTY the clipboard contains no text
36 PDC_CLIP_ACCESS_ERROR no clipboard support
37
38 Portability X/Open BSD SYS V
39 PDC_getclipboard - - -
40 PDC_setclipboard - - -
41 PDC_freeclipboard - - -
42 PDC_clearclipboard - - -
43
44 **man-end****************************************************************/
45
46 int PDC_getclipboard(char **contents, long *length)
47 {
48 #ifndef EMXVIDEO
49 HMQ hmq;
50 HAB hab;
51 PTIB ptib;
52 PPIB ppib;
53 ULONG ulRet;
54 long len;
55 int rc;
56 #endif
57 PDC_LOG(("PDC_getclipboard() - called\n"));
58
59 #ifndef EMXVIDEO
60 DosGetInfoBlocks(&ptib, &ppib);
61 ppib->pib_ultype = 3;
62 hab = WinInitialize(0);
63 hmq = WinCreateMsgQueue(hab, 0);
64
65 if (!WinOpenClipbrd(hab))
66 {
67 WinDestroyMsgQueue(hmq);
68 WinTerminate(hab);
69 return PDC_CLIP_ACCESS_ERROR;
70 }
71
72 rc = PDC_CLIP_EMPTY;
73
74 ulRet = WinQueryClipbrdData(hab, CF_TEXT);
75
76 if (ulRet)
77 {
78 len = strlen((char *)ulRet);
79 *contents = malloc(len + 1);
80
81 if (!*contents)
82 rc = PDC_CLIP_MEMORY_ERROR;
83 else
84 {
85 strcpy((char *)*contents, (char *)ulRet);
86 *length = len;
87 rc = PDC_CLIP_SUCCESS;
88 }
89 }
90
91 WinCloseClipbrd(hab);
92 WinDestroyMsgQueue(hmq);
93 WinTerminate(hab);
94
95 return rc;
96 #else
97 return PDC_CLIP_ACCESS_ERROR;
98 #endif
99 }
100
101 int PDC_setclipboard(const char *contents, long length)
102 {
103 #ifndef EMXVIDEO
104 HAB hab;
105 PTIB ptib;
106 PPIB ppib;
107 ULONG ulRC;
108 PSZ szTextOut = NULL;
109 int rc;
110 #endif
111 PDC_LOG(("PDC_setclipboard() - called\n"));
112
113 #ifndef EMXVIDEO
114 DosGetInfoBlocks(&ptib, &ppib);
115 ppib->pib_ultype = 3;
116 hab = WinInitialize(0);
117
118 if (!WinOpenClipbrd(hab))
119 {
120 WinTerminate(hab);
121 return PDC_CLIP_ACCESS_ERROR;
122 }
123
124 rc = PDC_CLIP_MEMORY_ERROR;
125
126 ulRC = DosAllocSharedMem((PVOID)&szTextOut, NULL, length + 1,
127 PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE);
128
129 if (ulRC == 0)
130 {
131 strcpy(szTextOut, contents);
132 WinEmptyClipbrd(hab);
133
134 if (WinSetClipbrdData(hab, (ULONG)szTextOut, CF_TEXT, CFI_POINTER))
135 rc = PDC_CLIP_SUCCESS;
136 else
137 {
138 DosFreeMem(szTextOut);
139 rc = PDC_CLIP_ACCESS_ERROR;
140 }
141 }
142
143 WinCloseClipbrd(hab);
144 WinTerminate(hab);
145
146 return rc;
147 #else
148 return PDC_CLIP_ACCESS_ERROR;
149 #endif
150 }
151
152 int PDC_freeclipboard(char *contents)
153 {
154 PDC_LOG(("PDC_freeclipboard() - called\n"));
155
156 if (contents)
157 free(contents);
158
159 return PDC_CLIP_SUCCESS;
160 }
161
162 int PDC_clearclipboard(void)
163 {
164 #ifndef EMXVIDEO
165 HAB hab;
166 PTIB ptib;
167 PPIB ppib;
168 #endif
169 PDC_LOG(("PDC_clearclipboard() - called\n"));
170
171 #ifndef EMXVIDEO
172 DosGetInfoBlocks(&ptib, &ppib);
173 ppib->pib_ultype = 3;
174 hab = WinInitialize(0);
175
176 WinEmptyClipbrd(hab);
177
178 WinCloseClipbrd(hab);
179 WinTerminate(hab);
180
181 return PDC_CLIP_SUCCESS;
182 #else
183 return PDC_CLIP_ACCESS_ERROR;
184 #endif
185 }
File os2/pdcdisp.c added (mode: 100644) (index 00000000..3c1b86e7)
1 /* Public Domain Curses */
2
3 #include "pdcos2.h"
4
5 RCSID("$Id: pdcdisp.c,v 1.49 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 /* ACS definitions originally by jshumate@wrdis01.robins.af.mil -- these
8 match code page 437 and compatible pages (CP850, CP852, etc.) */
9
10 #ifdef CHTYPE_LONG
11
12 # define A(x) ((chtype)x | A_ALTCHARSET)
13
14 chtype acs_map[128] =
15 {
16 A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9),
17 A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
18 A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27),
19 A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
20 '\'', '(', ')', '*',
21
22 A(0x1a), A(0x1b), A(0x18), A(0x19),
23
24 '/',
25
26 0xdb,
27
28 '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
29 '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
30 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
31 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
32
33 A(0x04), 0xb1,
34
35 'b', 'c', 'd', 'e',
36
37 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
38 0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3,
39 0xf2, 0xe3, 0xd8, 0x9c, 0xf9,
40
41 A(127)
42 };
43
44 # undef A
45
46 #endif
47
48 /* position hardware cursor at (y, x) */
49
50 void PDC_gotoyx(int row, int col)
51 {
52 PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
53
54 #ifdef EMXVIDEO
55 v_gotoxy(col, row);
56 #else
57 VioSetCurPos(row, col, 0);
58 #endif
59 }
60
61 /* update the given physical line to look like the corresponding line in
62 curscr */
63
64 void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
65 {
66 /* this should be enough for the maximum width of a screen. */
67
68 struct {unsigned char text, attr;} temp_line[256];
69 int j;
70
71 PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
72
73 /* replace the attribute part of the chtype with the
74 actual color value for each chtype in the line */
75
76 for (j = 0; j < len; j++)
77 {
78 chtype ch = srcp[j];
79
80 temp_line[j].attr = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
81
82 #ifdef CHTYPE_LONG
83 if (ch & A_ALTCHARSET && !(ch & 0xff80))
84 ch = acs_map[ch & 0x7f];
85 #endif
86 temp_line[j].text = ch & 0xff;
87 }
88
89 #ifdef EMXVIDEO
90 v_putline((char *)temp_line, x, lineno, len);
91 #else
92 VioWrtCellStr((PCH)temp_line, (USHORT)(len * sizeof(unsigned short)),
93 (USHORT)lineno, (USHORT)x, 0);
94 #endif
95 }
File os2/pdcgetsc.c added (mode: 100644) (index 00000000..d712dadf)
1 /* Public Domain Curses */
2
3 #include "pdcos2.h"
4
5 RCSID("$Id: pdcgetsc.c,v 1.39 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 /* return width of screen/viewport */
8
9 int PDC_get_columns(void)
10 {
11 #ifdef EMXVIDEO
12 int rows = 0;
13 #else
14 VIOMODEINFO modeInfo = {0};
15 #endif
16 int cols = 0;
17 const char *env_cols;
18
19 PDC_LOG(("PDC_get_columns() - called\n"));
20
21 #ifdef EMXVIDEO
22 v_dimen(&cols, &rows);
23 #else
24 modeInfo.cb = sizeof(modeInfo);
25 VioGetMode(&modeInfo, 0);
26 cols = modeInfo.col;
27 #endif
28 env_cols = getenv("COLS");
29
30 if (env_cols)
31 cols = min(atoi(env_cols), cols);
32
33 PDC_LOG(("PDC_get_columns() - returned: cols %d\n", cols));
34
35 return cols;
36 }
37
38 /* get the cursor size/shape */
39
40 int PDC_get_cursor_mode(void)
41 {
42 #ifdef EMXVIDEO
43 int curstart = 0, curend = 0;
44 #else
45 VIOCURSORINFO cursorInfo;
46 #endif
47 PDC_LOG(("PDC_get_cursor_mode() - called\n"));
48
49 #ifdef EMXVIDEO
50 v_getctype(&curstart, &curend);
51 return (curstart << 8) | curend;
52 #else
53 VioGetCurType (&cursorInfo, 0);
54
55 return (cursorInfo.yStart << 8) | cursorInfo.cEnd;
56 #endif
57 }
58
59 /* return number of screen rows */
60
61 int PDC_get_rows(void)
62 {
63 #ifdef EMXVIDEO
64 int cols = 0;
65 #else
66 VIOMODEINFO modeInfo = {0};
67 #endif
68 int rows = 0;
69 const char *env_rows;
70
71 PDC_LOG(("PDC_get_rows() - called\n"));
72
73 /* use the value from LINES environment variable, if set. MH 10-Jun-92 */
74 /* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */
75
76 #ifdef EMXVIDEO
77 v_dimen(&cols, &rows);
78 #else
79 modeInfo.cb = sizeof(modeInfo);
80 VioGetMode(&modeInfo, 0);
81 rows = modeInfo.row;
82 #endif
83 env_rows = getenv("LINES");
84
85 if (env_rows)
86 rows = min(atoi(env_rows), rows);
87
88 PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));
89
90 return rows;
91 }
File os2/pdckbd.c added (mode: 100644) (index 00000000..42c24ccd)
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 RCSID("$Id: pdckbd.c,v 1.89 2008/07/14 04:24:51 wmcbrine Exp $")
12
13 /*man-start**************************************************************
14
15 Name: pdckbd
16
17 Synopsis:
18 unsigned long PDC_get_input_fd(void);
19
20 Description:
21 PDC_get_input_fd() returns the file descriptor that PDCurses
22 reads its input from. It can be used for select().
23
24 Portability X/Open BSD SYS V
25 PDC_get_input_fd - - -
26
27 **man-end****************************************************************/
28
29 #ifdef EMXVIDEO
30 # include <termios.h>
31 static int tahead = -1;
32 #else
33 static KBDINFO kbdinfo; /* default keyboard mode */
34 static HMOU mouse_handle = 0;
35 static MOUSE_STATUS old_mouse_status;
36 static USHORT old_shift = 0;
37 static bool key_pressed = FALSE;
38 static int mouse_events = 0;
39 #endif
40
41 /************************************************************************
42 * Table for key code translation of function keys in keypad mode *
43 * These values are for strict IBM keyboard compatibles only *
44 ************************************************************************/
45
46 static short key_table[] =
47 {
48 -1, ALT_ESC, -1, 0,
49 -1, -1, -1, -1,
50 -1, -1, -1, -1,
51 -1, -1, ALT_BKSP, KEY_BTAB,
52 ALT_Q, ALT_W, ALT_E, ALT_R,
53 ALT_T, ALT_Y, ALT_U, ALT_I,
54 ALT_O, ALT_P, ALT_LBRACKET, ALT_RBRACKET,
55 ALT_ENTER, -1, ALT_A, ALT_S,
56 ALT_D, ALT_F, ALT_G, ALT_H,
57 ALT_J, ALT_K, ALT_L, ALT_SEMICOLON,
58 ALT_FQUOTE, ALT_BQUOTE, -1, ALT_BSLASH,
59 ALT_Z, ALT_X, ALT_C, ALT_V,
60 ALT_B, ALT_N, ALT_M, ALT_COMMA,
61 ALT_STOP, ALT_FSLASH, -1, ALT_PADSTAR,
62 -1, -1, -1, KEY_F(1),
63 KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
64 KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9),
65 KEY_F(10), -1, -1, KEY_HOME,
66 KEY_UP, KEY_PPAGE, ALT_PADMINUS, KEY_LEFT,
67 KEY_B2, KEY_RIGHT, ALT_PADPLUS, KEY_END,
68 KEY_DOWN, KEY_NPAGE, KEY_IC, KEY_DC,
69 KEY_F(13), KEY_F(14), KEY_F(15), KEY_F(16),
70 KEY_F(17), KEY_F(18), KEY_F(19), KEY_F(20),
71 KEY_F(21), KEY_F(22), KEY_F(25), KEY_F(26),
72 KEY_F(27), KEY_F(28), KEY_F(29), KEY_F(30),
73 KEY_F(31), KEY_F(32), KEY_F(33), KEY_F(34),
74 KEY_F(37), KEY_F(38), KEY_F(39), KEY_F(40),
75 KEY_F(41), KEY_F(42), KEY_F(43), KEY_F(44),
76 KEY_F(45), KEY_F(46), -1, CTL_LEFT,
77 CTL_RIGHT, CTL_END, CTL_PGDN, CTL_HOME,
78 ALT_1, ALT_2, ALT_3, ALT_4,
79 ALT_5, ALT_6, ALT_7, ALT_8,
80 ALT_9, ALT_0, ALT_MINUS, ALT_EQUAL,
81 CTL_PGUP, KEY_F(11), KEY_F(12), KEY_F(23),
82 KEY_F(24), KEY_F(35), KEY_F(36), KEY_F(47),
83 KEY_F(48), CTL_UP, CTL_PADMINUS, CTL_PADCENTER,
84 CTL_PADPLUS, CTL_DOWN, CTL_INS, CTL_DEL,
85 CTL_TAB, CTL_PADSLASH, CTL_PADSTAR, ALT_HOME,
86 ALT_UP, ALT_PGUP, -1, ALT_LEFT,
87 -1, ALT_RIGHT, -1, ALT_END,
88 ALT_DOWN, ALT_PGDN, ALT_INS, ALT_DEL,
89 ALT_PADSLASH, ALT_TAB, ALT_PADENTER, -1
90 };
91
92 unsigned long pdc_key_modifiers = 0L;
93
94 unsigned long PDC_get_input_fd(void)
95 {
96 PDC_LOG(("PDC_get_input_fd() - called\n"));
97
98 return (unsigned long)fileno(stdin);
99 }
100
101 #ifndef EMXVIDEO
102
103 void PDC_get_keyboard_info(void)
104 {
105 kbdinfo.cb = sizeof(kbdinfo);
106 KbdGetStatus(&kbdinfo, 0);
107 }
108
109 void PDC_set_keyboard_default(void)
110 {
111 KbdSetStatus(&kbdinfo, 0);
112 }
113
114 #endif /* ifndef EMXVIDEO */
115
116 void PDC_set_keyboard_binary(bool on)
117 {
118 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
119
120 #ifndef EMXVIDEO
121 if (on)
122 {
123 kbdinfo.fsMask &= ~(KEYBOARD_ASCII_MODE);
124 kbdinfo.fsMask |= KEYBOARD_BINARY_MODE;
125 }
126 else
127 {
128 kbdinfo.fsMask &= ~(KEYBOARD_BINARY_MODE);
129 kbdinfo.fsMask |= KEYBOARD_ASCII_MODE;
130 }
131
132 KbdSetStatus(&kbdinfo, 0);
133 #endif
134
135 #ifdef HAVE_SIGNAL
136 signal(SIGBREAK, on ? SIG_IGN : SIG_DFL);
137 #endif
138 }
139
140 /* check if a key or mouse event is waiting */
141
142 bool PDC_check_key(void)
143 {
144 #if !defined(_MSC_VER) && !defined(EMXVIDEO)
145 KBDKEYINFO keyInfo = {0};
146 #endif
147
148 #ifdef EMXVIDEO
149 if (tahead == -1) /* Nothing typed yet */
150 {
151 tahead = _read_kbd(0, 0, 0);
152
153 /* Read additional */
154
155 if (tahead == 0)
156 tahead = _read_kbd(0, 1, 0) << 8;
157 }
158
159 return (tahead != -1);
160 #else
161 # ifndef _MSC_VER
162
163 KbdGetStatus(&kbdinfo, 0);
164
165 if (mouse_handle)
166 {
167 MOUQUEINFO queue;
168
169 MouGetNumQueEl(&queue, mouse_handle);
170 mouse_events = queue.cEvents;
171
172 if (mouse_events)
173 return TRUE;
174 }
175
176 if (old_shift && !kbdinfo.fsState) /* modifier released */
177 {
178 if (!key_pressed && SP->return_key_modifiers)
179 return TRUE;
180 }
181 else if (!old_shift && kbdinfo.fsState) /* modifier pressed */
182 key_pressed = FALSE;
183
184 old_shift = kbdinfo.fsState;
185
186 KbdPeek(&keyInfo, 0); /* peek at keyboard */
187 return (keyInfo.fbStatus != 0);
188 # else
189 return kbhit();
190 # endif
191 #endif
192 }
193
194 #ifndef EMXVIDEO
195
196 static int _process_mouse_events(void)
197 {
198 MOUEVENTINFO event;
199 static const USHORT button_mask[] = {6, 96, 24},
200 move_mask[] = {2, 32, 8},
201 press_mask[] = {4, 64, 16};
202 USHORT count = 1;
203 short shift_flags = 0;
204 int i;
205
206 MouReadEventQue(&event, &count, mouse_handle);
207 mouse_events--;
208
209 for (i = 0; i < 3; i++)
210 {
211 pdc_mouse_status.button[i] =
212 ((event.fs & move_mask[i]) ? BUTTON_MOVED : 0) |
213 ((event.fs & press_mask[i]) ? BUTTON_PRESSED : 0);
214
215 /* PRESS events are sometimes mistakenly reported as MOVE
216 events. A MOVE should always follow a PRESS, so treat a MOVE
217 immediately after a RELEASE as a PRESS. */
218
219 if ((pdc_mouse_status.button[i] == BUTTON_MOVED) &&
220 (old_mouse_status.button[i] == BUTTON_RELEASED))
221 {
222 pdc_mouse_status.button[i] = BUTTON_PRESSED;
223 }
224
225 if (pdc_mouse_status.button[i] == BUTTON_PRESSED && SP->mouse_wait)
226 {
227 /* Check for a click -- a PRESS followed immediately by a
228 release */
229
230 if (!mouse_events)
231 {
232 MOUQUEINFO queue;
233
234 napms(SP->mouse_wait);
235
236 MouGetNumQueEl(&queue, mouse_handle);
237 mouse_events = queue.cEvents;
238 }
239
240 if (mouse_events)
241 {
242 MouReadEventQue(&event, &count, mouse_handle);
243
244 if (!(event.fs & button_mask[i]))
245 pdc_mouse_status.button[i] = BUTTON_CLICKED;
246 }
247 }
248 }
249
250 pdc_mouse_status.x = event.col;
251 pdc_mouse_status.y = event.row;
252
253 pdc_mouse_status.changes = 0;
254
255 for (i = 0; i < 3; i++)
256 {
257 if (old_mouse_status.button[i] != pdc_mouse_status.button[i])
258 pdc_mouse_status.changes |= (1 << i);
259
260 if (pdc_mouse_status.button[i] == BUTTON_MOVED)
261 {
262 /* Discard non-moved "moves" */
263
264 if (pdc_mouse_status.x == old_mouse_status.x &&
265 pdc_mouse_status.y == old_mouse_status.y)
266 return -1;
267
268 /* Motion events always flag the button as changed */
269
270 pdc_mouse_status.changes |= (1 << i);
271 pdc_mouse_status.changes |= PDC_MOUSE_MOVED;
272 break;
273 }
274 }
275
276 old_mouse_status = pdc_mouse_status;
277
278 /* Treat click events as release events for comparison purposes */
279
280 for (i = 0; i < 3; i++)
281 {
282 if (old_mouse_status.button[i] == BUTTON_CLICKED)
283 old_mouse_status.button[i] = BUTTON_RELEASED;
284 }
285
286 /* Check for SHIFT/CONTROL/ALT */
287
288 if (kbdinfo.fsState & KBDSTF_ALT)
289 shift_flags |= BUTTON_ALT;
290
291 if (kbdinfo.fsState & KBDSTF_CONTROL)
292 shift_flags |= BUTTON_CONTROL;
293
294 if (kbdinfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
295 shift_flags |= BUTTON_SHIFT;
296
297 if (shift_flags)
298 {
299 for (i = 0; i < 3; i++)
300 {
301 if (pdc_mouse_status.changes & (1 << i))
302 pdc_mouse_status.button[i] |= shift_flags;
303 }
304 }
305
306 old_shift = kbdinfo.fsState;
307 key_pressed = TRUE;
308
309 SP->key_code = TRUE;
310 return KEY_MOUSE;
311 }
312
313 #endif
314
315 /* return the next available key or mouse event */
316
317 int PDC_get_key(void)
318 {
319 int key, scan;
320 #ifndef EMXVIDEO
321 KBDKEYINFO keyInfo = {0};
322 #endif
323
324 #ifdef EMXVIDEO
325 if (tahead == -1)
326 {
327 tahead = _read_kbd(0, 1, 0);
328
329 /* Read additional */
330
331 if (tahead == 0)
332 tahead = _read_kbd(0, 1, 0) << 8;
333 }
334
335 key = tahead & 0xff;
336 scan = tahead >> 8;
337 pdc_key_modifiers = 0L;
338
339 tahead = -1;
340 #else
341 pdc_key_modifiers = 0L;
342
343 if (mouse_handle && mouse_events)
344 return _process_mouse_events();
345
346 if (old_shift && !kbdinfo.fsState)
347 {
348 key = -1;
349
350 if (old_shift & KBDSTF_LEFTALT)
351 {
352 key = KEY_ALT_L;
353 }
354 else if (old_shift & KBDSTF_RIGHTALT)
355 {
356 key = KEY_ALT_R;
357 }
358 else if (old_shift & KBDSTF_LEFTCONTROL)
359 {
360 key = KEY_CONTROL_L;
361 }
362 else if (old_shift & KBDSTF_RIGHTCONTROL)
363 {
364 key = KEY_CONTROL_R;
365 }
366 else if (old_shift & KBDSTF_LEFTSHIFT)
367 {
368 key = KEY_SHIFT_L;
369 }
370 else if (old_shift & KBDSTF_RIGHTSHIFT)
371 {
372 key = KEY_SHIFT_R;
373 }
374
375 key_pressed = FALSE;
376 old_shift = kbdinfo.fsState;
377
378 SP->key_code = TRUE;
379 return key;
380 }
381
382 KbdCharIn(&keyInfo, IO_WAIT, 0); /* get a character */
383
384 key = keyInfo.chChar;
385 scan = keyInfo.chScan;
386
387 if (SP->save_key_modifiers)
388 {
389 if (keyInfo.fsState & KBDSTF_ALT)
390 pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
391
392 if (keyInfo.fsState & KBDSTF_CONTROL)
393 pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
394
395 if (keyInfo.fsState & KBDSTF_NUMLOCK_ON)
396 pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
397
398 if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
399 pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
400 }
401 #endif
402 if (scan == 0x1c && key == 0x0a) /* ^Enter */
403 key = CTL_ENTER;
404 else if (scan == 0xe0 && key == 0x0d) /* PadEnter */
405 key = PADENTER;
406 else if (scan == 0xe0 && key == 0x0a) /* ^PadEnter */
407 key = CTL_PADENTER;
408 else if (scan == 0x37 && key == 0x2a) /* Star */
409 key = PADSTAR;
410 else if (scan == 0x4a && key == 0x2d) /* Minus */
411 key = PADMINUS;
412 else if (scan == 0x4e && key == 0x2b) /* Plus */
413 key = PADPLUS;
414 else if (scan == 0xe0 && key == 0x2f) /* Slash */
415 key = PADSLASH;
416 else if (key == 0x00 || (key == 0xe0 && scan > 53 && scan != 86))
417 key = (scan > 0xa7) ? -1 : key_table[scan];
418
419 if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
420 {
421 switch (key)
422 {
423 case KEY_HOME: /* Shift Home */
424 key = KEY_SHOME;
425 break;
426 case KEY_UP: /* Shift Up */
427 key = KEY_SUP;
428 break;
429 case KEY_PPAGE: /* Shift PgUp */
430 key = KEY_SPREVIOUS;
431 break;
432 case KEY_LEFT: /* Shift Left */
433 key = KEY_SLEFT;
434 break;
435 case KEY_RIGHT: /* Shift Right */
436 key = KEY_SRIGHT;
437 break;
438 case KEY_END: /* Shift End */
439 key = KEY_SEND;
440 break;
441 case KEY_DOWN: /* Shift Down */
442 key = KEY_SDOWN;
443 break;
444 case KEY_NPAGE: /* Shift PgDn */
445 key = KEY_SNEXT;
446 break;
447 case KEY_IC: /* Shift Ins */
448 key = KEY_SIC;
449 break;
450 case KEY_DC: /* Shift Del */
451 key = KEY_SDC;
452 }
453 }
454
455 key_pressed = TRUE;
456 SP->key_code = ((unsigned)key >= 256);
457
458 return key;
459 }
460
461 /* discard any pending keyboard or mouse input -- this is the core
462 routine for flushinp() */
463
464 void PDC_flushinp(void)
465 {
466 PDC_LOG(("PDC_flushinp() - called\n"));
467
468 #ifdef EMXVIDEO
469 tcflush(0, TCIFLUSH);
470 #else
471 if (mouse_handle)
472 MouFlushQue(mouse_handle);
473
474 KbdFlushBuffer(0);
475 #endif
476 }
477
478 int PDC_mouse_set(void)
479 {
480 #ifndef EMXVIDEO
481
482 unsigned long mbe = SP->_trap_mbe;
483
484 if (mbe && !mouse_handle)
485 {
486 memset(&old_mouse_status, 0, sizeof(MOUSE_STATUS));
487 MouOpen(NULL, &mouse_handle);
488 if (mouse_handle)
489 MouDrawPtr(mouse_handle);
490 }
491 else if (!mbe && mouse_handle)
492 {
493 MouClose(mouse_handle);
494 mouse_handle = 0;
495 }
496
497 if (mbe && mouse_handle)
498 {
499 USHORT mask = ((mbe & (BUTTON1_PRESSED | BUTTON1_CLICKED |
500 BUTTON1_MOVED)) ? 6 : 0) |
501
502 ((mbe & (BUTTON3_PRESSED | BUTTON3_CLICKED |
503 BUTTON3_MOVED)) ? 24 : 0) |
504
505 ((mbe & (BUTTON2_PRESSED | BUTTON2_CLICKED |
506 BUTTON2_MOVED)) ? 96 : 0);
507
508 MouSetEventMask(&mask, mouse_handle);
509 }
510 #endif
511 return OK;
512 }
513
514 int PDC_modifiers_set(void)
515 {
516 key_pressed = FALSE;
517
518 return OK;
519 }
File os2/pdcos2.h added (mode: 100644) (index 00000000..1c11d480)
1 /* Public Domain Curses */
2
3 /* $Id: pdcos2.h,v 1.9 2008/08/14 06:38:35 wmcbrine Exp $ */
4
5 #ifdef _MSC_VER
6 # define USE_OS2_H 1 /* Use the os2.h for the compiler */
7 # define APIRET USHORT
8 #endif
9
10 #include <stdlib.h>
11 #include <string.h>
12
13 #ifdef EMXVIDEO
14 # include <sys/video.h>
15 #else
16 # define INCL_DOS
17 # define INCL_DOSMISC
18 # define INCL_WIN
19 # define INCL_VIO
20 # define INCL_KBD
21 # define INCL_MOU
22 # include <os2.h>
23 #endif
24
25 #include <curspriv.h>
26
27 #ifdef __WATCOMC__
28 # define PDCTHUNK(x) ((ptr_16)(x))
29 # ifdef __386__
30 # define SEG16 _Seg16
31 # else
32 # define SEG16
33 # endif
34
35 typedef void * SEG16 ptr_16;
36
37 #else
38 # ifdef __EMX__
39 # ifdef __INNOTEK_LIBC__
40 # define PDCTHUNK(x) ((PCH)_libc_32to16(x))
41 # else
42 # define PDCTHUNK(x) ((PCH)_emx_32to16(x))
43 # endif
44 # endif
45 #endif
46
47 extern unsigned char *pdc_atrtab;
48 extern int pdc_font;
49
50 extern void PDC_get_keyboard_info(void);
51 extern void PDC_set_keyboard_default(void);
File os2/pdcscrn.c added (mode: 100644) (index 00000000..e2d68faa)
1 /* Public Domain Curses */
2
3 #include "pdcos2.h"
4
5 RCSID("$Id: pdcscrn.c,v 1.76 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 #ifdef CHTYPE_LONG
8 # define PDC_OFFSET 32
9 #else
10 # define PDC_OFFSET 8
11 #endif
12
13 /* COLOR_PAIR to attribute encoding table. */
14
15 unsigned char *pdc_atrtab = (unsigned char *)NULL;
16
17 int pdc_font; /* default font size */
18
19 static short curstoreal[16], realtocurs[16] =
20 {
21 COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
22 COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
23 COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
24 COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
25 };
26
27 #ifdef EMXVIDEO
28 static unsigned char *saved_screen = NULL;
29 static int saved_lines = 0;
30 static int saved_cols = 0;
31 #else
32 # ifdef PDCTHUNK
33 # ifdef __EMX__
34 # define THUNKEDVIO VIOCOLORREG
35 # else
36
37 typedef struct {
38 USHORT cb;
39 USHORT type;
40 USHORT firstcolorreg;
41 USHORT numcolorregs;
42 ptr_16 colorregaddr;
43 } THUNKEDVIO;
44
45 # endif
46 # endif
47
48 static PCH saved_screen = NULL;
49 static USHORT saved_lines = 0;
50 static USHORT saved_cols = 0;
51 static VIOMODEINFO scrnmode; /* default screen mode */
52 static VIOMODEINFO saved_scrnmode[3];
53 static int saved_font[3];
54 static bool can_change = FALSE;
55
56 static int _get_font(void)
57 {
58 VIOMODEINFO modeInfo = {0};
59
60 modeInfo.cb = sizeof(modeInfo);
61
62 VioGetMode(&modeInfo, 0);
63 return (modeInfo.vres / modeInfo.row);
64 }
65
66 static void _set_font(int size)
67 {
68 VIOMODEINFO modeInfo = {0};
69
70 if (pdc_font != size)
71 {
72 modeInfo.cb = sizeof(modeInfo);
73
74 /* set most parameters of modeInfo */
75
76 VioGetMode(&modeInfo, 0);
77 modeInfo.cb = 8; /* ignore horiz an vert resolution */
78 modeInfo.row = modeInfo.vres / size;
79 VioSetMode(&modeInfo, 0);
80 }
81
82 curs_set(SP->visibility);
83
84 pdc_font = _get_font();
85 }
86
87 #endif
88
89 /* close the physical screen -- may restore the screen to its state
90 before PDC_scr_open(); miscellaneous cleanup */
91
92 void PDC_scr_close(void)
93 {
94 PDC_LOG(("PDC_scr_close() - called\n"));
95
96 if (saved_screen && getenv("PDC_RESTORE_SCREEN"))
97 {
98 #ifdef EMXVIDEO
99 v_putline(saved_screen, 0, 0, saved_lines * saved_cols);
100 #else
101 VioWrtCellStr(saved_screen, saved_lines * saved_cols * 2,
102 0, 0, (HVIO)NULL);
103 #endif
104 free(saved_screen);
105 saved_screen = NULL;
106 }
107
108 reset_shell_mode();
109
110 if (SP->visibility != 1)
111 curs_set(1);
112
113 /* Position cursor to the bottom left of the screen. */
114
115 PDC_gotoyx(PDC_get_rows() - 2, 0);
116 }
117
118 void PDC_scr_free(void)
119 {
120 if (SP)
121 free(SP);
122 if (pdc_atrtab)
123 free(pdc_atrtab);
124
125 pdc_atrtab = (unsigned char *)NULL;
126 }
127
128 /* open the physical screen -- allocate SP, miscellaneous intialization,
129 and may save the existing screen for later restoration */
130
131 int PDC_scr_open(int argc, char **argv)
132 {
133 #ifdef EMXVIDEO
134 int adapter;
135 #else
136 USHORT totchars;
137 #endif
138 int i;
139 short r, g, b;
140
141 PDC_LOG(("PDC_scr_open() - called\n"));
142
143 SP = calloc(1, sizeof(SCREEN));
144 pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
145
146 if (!SP || !pdc_atrtab)
147 return ERR;
148
149 for (i = 0; i < 16; i++)
150 curstoreal[realtocurs[i]] = i;
151
152 #ifdef EMXVIDEO
153 v_init();
154 #endif
155 SP->orig_attr = FALSE;
156
157 #ifdef EMXVIDEO
158 adapter = v_hardware();
159 SP->mono = (adapter == V_MONOCHROME);
160
161 pdc_font = SP->mono ? 14 : (adapter == V_COLOR_8) ? 8 : 12;
162 #else
163 VioGetMode(&scrnmode, 0);
164 PDC_get_keyboard_info();
165
166 pdc_font = _get_font();
167 #endif
168 SP->lines = PDC_get_rows();
169 SP->cols = PDC_get_columns();
170
171 SP->mouse_wait = PDC_CLICK_PERIOD;
172 SP->audible = TRUE;
173
174 /* This code for preserving the current screen */
175
176 if (getenv("PDC_RESTORE_SCREEN"))
177 {
178 saved_lines = SP->lines;
179 saved_cols = SP->cols;
180
181 saved_screen = malloc(2 * saved_lines * saved_cols);
182
183 if (!saved_screen)
184 {
185 SP->_preserve = FALSE;
186 return OK;
187 }
188 #ifdef EMXVIDEO
189 v_getline(saved_screen, 0, 0, saved_lines * saved_cols);
190 #else
191 totchars = saved_lines * saved_cols * 2;
192 VioReadCellStr((PCH)saved_screen, &totchars, 0, 0, (HVIO)NULL);
193 #endif
194 }
195
196 SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
197
198 can_change = (PDC_color_content(0, &r, &g, &b) == OK);
199
200 return OK;
201 }
202
203 /* the core of resize_term() */
204
205 int PDC_resize_screen(int nlines, int ncols)
206 {
207 #ifndef EMXVIDEO
208 VIOMODEINFO modeInfo = {0};
209 USHORT result;
210 #endif
211
212 PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
213 nlines, ncols));
214
215 #ifdef EMXVIDEO
216 return ERR;
217 #else
218 modeInfo.cb = sizeof(modeInfo);
219
220 /* set most parameters of modeInfo */
221
222 VioGetMode(&modeInfo, 0);
223 modeInfo.fbType = 1;
224 modeInfo.row = nlines;
225 modeInfo.col = ncols;
226 result = VioSetMode(&modeInfo, 0);
227
228 LINES = PDC_get_rows();
229 COLS = PDC_get_columns();
230
231 return (result == 0) ? OK : ERR;
232 #endif
233 }
234
235 void PDC_reset_prog_mode(void)
236 {
237 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
238
239 #ifndef EMXVIDEO
240 PDC_set_keyboard_binary(TRUE);
241 #endif
242 }
243
244 void PDC_reset_shell_mode(void)
245 {
246 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
247
248 #ifndef EMXVIDEO
249 PDC_set_keyboard_default();
250 #endif
251 }
252
253 #ifndef EMXVIDEO
254
255 static bool _screen_mode_equals(VIOMODEINFO *oldmode)
256 {
257 VIOMODEINFO current = {0};
258
259 VioGetMode(&current, 0);
260
261 return ((current.cb == oldmode->cb) &&
262 (current.fbType == oldmode->fbType) &&
263 (current.color == oldmode->color) &&
264 (current.col == oldmode->col) &&
265 (current.row == oldmode->row) &&
266 (current.hres == oldmode->vres) &&
267 (current.vres == oldmode->vres));
268 }
269
270 #endif
271
272 void PDC_restore_screen_mode(int i)
273 {
274 #ifndef EMXVIDEO
275 if (i >= 0 && i <= 2)
276 {
277 pdc_font = _get_font();
278 _set_font(saved_font[i]);
279
280 if (!_screen_mode_equals(&saved_scrnmode[i]))
281 if (VioSetMode(&saved_scrnmode[i], 0) != 0)
282 {
283 pdc_font = _get_font();
284 scrnmode = saved_scrnmode[i];
285 LINES = PDC_get_rows();
286 COLS = PDC_get_columns();
287 }
288 }
289 #endif
290 }
291
292 void PDC_save_screen_mode(int i)
293 {
294 #ifndef EMXVIDEO
295 if (i >= 0 && i <= 2)
296 {
297 saved_font[i] = pdc_font;
298 saved_scrnmode[i] = scrnmode;
299 }
300 #endif
301 }
302
303 void PDC_init_pair(short pair, short fg, short bg)
304 {
305 unsigned char att, temp_bg;
306 chtype i;
307
308 fg = curstoreal[fg];
309 bg = curstoreal[bg];
310
311 for (i = 0; i < PDC_OFFSET; i++)
312 {
313 att = fg | (bg << 4);
314
315 if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
316 att = bg | (fg << 4);
317 if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
318 att = 1;
319 if (i & (A_INVIS >> PDC_ATTR_SHIFT))
320 {
321 temp_bg = att >> 4;
322 att = temp_bg << 4 | temp_bg;
323 }
324 if (i & (A_BOLD >> PDC_ATTR_SHIFT))
325 att |= 8;
326 if (i & (A_BLINK >> PDC_ATTR_SHIFT))
327 att |= 128;
328
329 pdc_atrtab[pair * PDC_OFFSET + i] = att;
330 }
331 }
332
333 int PDC_pair_content(short pair, short *fg, short *bg)
334 {
335 *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
336 *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
337
338 return OK;
339 }
340
341 bool PDC_can_change_color(void)
342 {
343 return can_change;
344 }
345
346 int PDC_color_content(short color, short *red, short *green, short *blue)
347 {
348 #ifdef PDCTHUNK
349 THUNKEDVIO vcr;
350 USHORT palbuf[4];
351 unsigned char pal[3];
352 int rc;
353
354 /* Read single DAC register */
355
356 palbuf[0] = 8;
357 palbuf[1] = 0;
358 palbuf[2] = curstoreal[color];
359
360 rc = VioGetState(&palbuf, 0);
361 if (rc)
362 return ERR;
363
364 vcr.cb = sizeof(vcr);
365 vcr.type = 3;
366 vcr.firstcolorreg = palbuf[3];
367 vcr.numcolorregs = 1;
368 vcr.colorregaddr = PDCTHUNK(pal);
369
370 rc = VioGetState(&vcr, 0);
371 if (rc)
372 return ERR;
373
374 /* Scale and store */
375
376 *red = DIVROUND((unsigned)(pal[0]) * 1000, 63);
377 *green = DIVROUND((unsigned)(pal[1]) * 1000, 63);
378 *blue = DIVROUND((unsigned)(pal[2]) * 1000, 63);
379
380 return OK;
381 #else
382 return ERR;
383 #endif
384 }
385
386 int PDC_init_color(short color, short red, short green, short blue)
387 {
388 #ifdef PDCTHUNK
389 THUNKEDVIO vcr;
390 USHORT palbuf[4];
391 unsigned char pal[3];
392 int rc;
393
394 /* Scale */
395
396 pal[0] = DIVROUND((unsigned)red * 63, 1000);
397 pal[1] = DIVROUND((unsigned)green * 63, 1000);
398 pal[2] = DIVROUND((unsigned)blue * 63, 1000);
399
400 /* Set single DAC register */
401
402 palbuf[0] = 8;
403 palbuf[1] = 0;
404 palbuf[2] = curstoreal[color];
405
406 rc = VioGetState(&palbuf, 0);
407 if (rc)
408 return ERR;
409
410 vcr.cb = sizeof(vcr);
411 vcr.type = 3;
412 vcr.firstcolorreg = palbuf[3];
413 vcr.numcolorregs = 1;
414 vcr.colorregaddr = PDCTHUNK(pal);
415
416 rc = VioSetState(&vcr, 0);
417
418 return rc ? ERR : OK;
419 #else
420 return ERR;
421 #endif
422 }
File os2/pdcsetsc.c added (mode: 100644) (index 00000000..2a770bd2)
1 /* Public Domain Curses */
2
3 #include "pdcos2.h"
4
5 RCSID("$Id: pdcsetsc.c,v 1.44 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: pdcsetsc
10
11 Synopsis:
12 int PDC_set_blink(bool blinkon);
13 void PDC_set_title(const char *title);
14
15 Description:
16 PDC_set_blink() toggles whether the A_BLINK attribute sets an
17 actual blink mode (TRUE), or sets the background color to high
18 intensity (FALSE). The default is platform-dependent (FALSE in
19 most cases). It returns OK if it could set the state to match
20 the given parameter, ERR otherwise. Current platforms also
21 adjust the value of COLORS according to this function -- 16 for
22 FALSE, and 8 for TRUE.
23
24 PDC_set_title() sets the title of the window in which the curses
25 program is running. This function may not do anything on some
26 platforms. (Currently it only works in Win32 and X11.)
27
28 Portability X/Open BSD SYS V
29 PDC_set_blink - - -
30 PDC_set_title - - -
31
32 **man-end****************************************************************/
33
34 int PDC_curs_set(int visibility)
35 {
36 #ifndef EMXVIDEO
37 VIOCURSORINFO pvioCursorInfo;
38 #endif
39 int ret_vis, hidden = 0, start = 0, end = 0;
40
41 PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
42
43 ret_vis = SP->visibility;
44 SP->visibility = visibility;
45
46 switch(visibility)
47 {
48 case 0: /* invisible */
49 #ifdef EMXVIDEO
50 start = end = 0;
51 #else
52 start = pdc_font / 4;
53 end = pdc_font;
54 hidden = -1;
55 #endif
56 break;
57
58 case 2: /* highly visible */
59 start = 2; /* almost full-height block */
60 end = pdc_font - 1;
61 break;
62
63 default: /* normal visibility */
64 start = (SP->orig_cursor >> 8) & 0xff;
65 end = SP->orig_cursor & 0xff;
66 }
67
68 #ifdef EMXVIDEO
69 if (!visibility)
70 v_hidecursor();
71 else
72 v_ctype(start, end);
73 #else
74 pvioCursorInfo.yStart = (USHORT)start;
75 pvioCursorInfo.cEnd = (USHORT)end;
76 pvioCursorInfo.cx = (USHORT)1;
77 pvioCursorInfo.attr = hidden;
78 VioSetCurType((PVIOCURSORINFO)&pvioCursorInfo, 0);
79 #endif
80 return ret_vis;
81 }
82
83 void PDC_set_title(const char *title)
84 {
85 PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
86 }
87
88 int PDC_set_blink(bool blinkon)
89 {
90 #ifndef EMXVIDEO
91 USHORT statebuf[3], result;
92
93 statebuf[0] = 6; /* length */
94 statebuf[1] = 2; /* blink/intensity */
95 statebuf[2] = !blinkon;
96
97 result = VioSetState(&statebuf, 0);
98 VioGetState(&statebuf, 0); /* needed? */
99
100 if (pdc_color_started)
101 COLORS = statebuf[2] ? 16 : 8;
102
103 return (result == 0) ? OK : ERR;
104 #else
105 if (pdc_color_started)
106 COLORS = 16;
107
108 return blinkon ? ERR : OK;
109 #endif
110 }
File os2/pdcutil.c added (mode: 100644) (index 00000000..290be359)
1 /* Public Domain Curses */
2
3 #include "pdcos2.h"
4
5 RCSID("$Id: pdcutil.c,v 1.14 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 #if defined(OS2) && !defined(__EMX__)
8 APIRET APIENTRY DosSleep(ULONG ulTime);
9 #endif
10
11 void PDC_beep(void)
12 {
13 PDC_LOG(("PDC_beep() - called\n"));
14
15 #ifdef EMXVIDEO
16 putchar('\007');
17 #else
18 DosBeep(1380, 100);
19 #endif
20 }
21
22 void PDC_napms(int ms)
23 {
24 PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
25
26 #ifdef __EMX__
27 _sleep2(ms);
28 #else
29 DosSleep(ms);
30 #endif
31 }
32
33 const char *PDC_sysname(void)
34 {
35 return "OS/2";
36 }
File os2/wccos2.mak added (mode: 100644) (index 00000000..d5900d30)
1 # Watcom WMAKE Makefile for PDCurses library - OS/2 Open Watcom 1.1+
2 #
3 # Usage: wmake -f [path\]wccos2.mak [DEBUG=Y] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 !ifdef %PDCURSES_SRCDIR
9 PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
10 !else
11 PDCURSES_SRCDIR = ..
12 !endif
13
14 !include $(PDCURSES_SRCDIR)\version.mif
15
16 osdir = $(PDCURSES_SRCDIR)\os2
17
18 CC = wcc386
19 TARGET = os2v2
20
21 CFLAGS = /bt=$(TARGET) /wx /s /zq /i=$(PDCURSES_SRCDIR)
22
23 !ifeq DEBUG Y
24 CFLAGS += /d2 /DPDCDEBUG
25 LDFLAGS = D A op q sys $(TARGET)
26 !else
27 CFLAGS += /oneatx
28 LDFLAGS = op q sys $(TARGET)
29 !endif
30
31 LIBEXE = wlib /q /n /b /c /t
32
33 !include $(PDCURSES_SRCDIR)\watcom.mif
34
35 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
36 $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
37 -copy $(LIBCURSES) panel.lib
38
39 PLATFORM1 = Watcom C++ OS/2
40 PLATFORM2 = Open Watcom 1.6 for OS/2
41 ARCNAME = pdc$(VER)_wcc_os2
42
43 !include $(PDCURSES_SRCDIR)\makedist.mif
File panel.h added (mode: 100644) (index 00000000..1d7cacef)
1 /* Public Domain Curses */
2
3 /* $Id: panel.h,v 1.19 2008/07/13 16:08:16 wmcbrine Exp $ */
4
5 /*----------------------------------------------------------------------*
6 * Panels for PDCurses *
7 *----------------------------------------------------------------------*/
8
9 #ifndef __PDCURSES_PANEL_H__
10 #define __PDCURSES_PANEL_H__ 1
11
12 #include <curses.h>
13
14 #if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
15 extern "C"
16 {
17 #endif
18
19 typedef struct panelobs
20 {
21 struct panelobs *above;
22 struct panel *pan;
23 } PANELOBS;
24
25 typedef struct panel
26 {
27 WINDOW *win;
28 int wstarty;
29 int wendy;
30 int wstartx;
31 int wendx;
32 struct panel *below;
33 struct panel *above;
34 const void *user;
35 struct panelobs *obscure;
36 } PANEL;
37
38 int bottom_panel(PANEL *pan);
39 int del_panel(PANEL *pan);
40 int hide_panel(PANEL *pan);
41 int move_panel(PANEL *pan, int starty, int startx);
42 PANEL *new_panel(WINDOW *win);
43 PANEL *panel_above(const PANEL *pan);
44 PANEL *panel_below(const PANEL *pan);
45 int panel_hidden(const PANEL *pan);
46 const void *panel_userptr(const PANEL *pan);
47 WINDOW *panel_window(const PANEL *pan);
48 int replace_panel(PANEL *pan, WINDOW *win);
49 int set_panel_userptr(PANEL *pan, const void *uptr);
50 int show_panel(PANEL *pan);
51 int top_panel(PANEL *pan);
52 void update_panels(void);
53
54 #if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
55 }
56 #endif
57
58 #endif /* __PDCURSES_PANEL_H__ */
File pdcurses/README added (mode: 100644) (index 00000000..bef1c4c4)
1 PDCurses Portable Core
2 ======================
3
4 This directory contains core PDCurses source code files common to all
5 platforms.
6
7
8 Building
9 --------
10
11 These modules are built by the platform-specific makefiles, in the
12 platform directories.
13
14
15 Distribution Status
16 -------------------
17
18 The files in this directory are released to the Public Domain.
19
20
21 Acknowledgements
22 ----------------
23
24 The panel library was originally provided by
25 Warren Tucker <wht@n4hgf.mt-park.ga.us>
File pdcurses/addch.c added (mode: 100644) (index 00000000..586d1a71)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: addch.c,v 1.54 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: addch
10
11 Synopsis:
12 int addch(const chtype ch);
13 int waddch(WINDOW *win, const chtype ch);
14 int mvaddch(int y, int x, const chtype ch);
15 int mvwaddch(WINDOW *win, int y, int x, const chtype ch);
16 int echochar(const chtype ch);
17 int wechochar(WINDOW *win, const chtype ch);
18
19 int addrawch(chtype ch);
20 int waddrawch(WINDOW *win, chtype ch);
21 int mvaddrawch(int y, int x, chtype ch);
22 int mvwaddrawch(WINDOW *win, int y, int x, chtype ch);
23
24 int add_wch(const cchar_t *wch);
25 int wadd_wch(WINDOW *win, const cchar_t *wch);
26 int mvadd_wch(int y, int x, const cchar_t *wch);
27 int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch);
28 int echo_wchar(const cchar_t *wch);
29 int wecho_wchar(WINDOW *win, const cchar_t *wch);
30
31 Description:
32 addch() adds the chtype ch to the default window (stdscr) at the
33 current cursor position, and advances the cursor. Note that
34 chtypes can convey both text (a single character) and
35 attributes, including a color pair. add_wch() is the wide-
36 character version of this function, taking a pointer to a
37 cchar_t instead of a chtype.
38
39 waddch() is like addch(), but also lets you specify the window.
40 (This is in fact the core output routine.) wadd_wch() is the
41 wide version.
42
43 mvaddch() moves the cursor to the specified (y, x) position, and
44 adds ch to stdscr. mvadd_wch() is the wide version.
45
46 mvwaddch() moves the cursor to the specified position and adds
47 ch to the specified window. mvwadd_wch() is the wide version.
48
49 echochar() adds ch to stdscr at the current cursor position and
50 calls refresh(). echo_wchar() is the wide version.
51
52 wechochar() adds ch to the specified window and calls
53 wrefresh(). wecho_wchar() is the wide version.
54
55 addrawch(), waddrawch(), mvaddrawch() and mvwaddrawch() are
56 PDCurses-specific wrappers for addch() etc. that disable the
57 translation of control characters.
58
59 The following applies to all these functions:
60
61 If the cursor moves on to the right margin, an automatic newline
62 is performed. If scrollok is enabled, and a character is added
63 to the bottom right corner of the window, the scrolling region
64 will be scrolled up one line. If scrolling is not allowed, ERR
65 will be returned.
66
67 If ch is a tab, newline, or backspace, the cursor will be moved
68 appropriately within the window. If ch is a newline, the
69 clrtoeol routine is called before the cursor is moved to the
70 beginning of the next line. If newline mapping is off, the
71 cursor will be moved to the next line, but the x coordinate will
72 be unchanged. If ch is a tab the cursor is moved to the next
73 tab position within the window. If ch is another control
74 character, it will be drawn in the ^X notation. Calling the
75 inch() routine after adding a control character returns the
76 representation of the control character, not the control
77 character.
78
79 Video attributes can be combined with a character by ORing them
80 into the parameter. Text, including attributes, can be copied
81 from one place to another by using inch() and addch().
82
83 Note that in PDCurses, for now, a cchar_t and a chtype are the
84 same. The text field is 16 bits wide, and is treated as Unicode
85 (UCS-2) when PDCurses is built with wide-character support
86 (define PDC_WIDE). So, in functions that take a chtype, like
87 addch(), both the wide and narrow versions will handle Unicode.
88 But for portability, you should use the wide functions.
89
90 Return Value:
91 All functions return OK on success and ERR on error.
92
93 Portability X/Open BSD SYS V
94 addch Y Y Y
95 waddch Y Y Y
96 mvaddch Y Y Y
97 mvwaddch Y Y Y
98 echochar Y - 3.0
99 wechochar Y - 3.0
100 addrawch - - -
101 waddrawch - - -
102 mvaddrawch - - -
103 mvwaddrawch - - -
104 add_wch Y
105 wadd_wch Y
106 mvadd_wch Y
107 mvwadd_wch Y
108 echo_wchar Y
109 wecho_wchar Y
110
111 **man-end****************************************************************/
112
113 int waddch(WINDOW *win, const chtype ch)
114 {
115 int x, y;
116 chtype text, attr;
117 bool xlat;
118
119 PDC_LOG(("waddch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
120 win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
121
122 if (!win)
123 return ERR;
124
125 x = win->_curx;
126 y = win->_cury;
127
128 if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
129 return ERR;
130
131 xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
132 text = ch & A_CHARTEXT;
133 attr = ch & A_ATTRIBUTES;
134
135 if (xlat && (text < ' ' || text == 0x7f))
136 {
137 int x2;
138
139 switch (text)
140 {
141 case '\t':
142 for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++)
143 {
144 if (waddch(win, attr | ' ') == ERR)
145 return ERR;
146
147 /* if tab to next line, exit the loop */
148
149 if (!win->_curx)
150 break;
151 }
152 return OK;
153
154 case '\n':
155 /* if lf -> crlf */
156
157 if (!SP->raw_out)
158 x = 0;
159
160 wclrtoeol(win);
161
162 if (++y > win->_bmarg)
163 {
164 y--;
165
166 if (wscrl(win, 1) == ERR)
167 return ERR;
168 }
169
170 break;
171
172 case '\b':
173 /* don't back over left margin */
174
175 if (--x < 0)
176 case '\r':
177 x = 0;
178
179 break;
180
181 case 0x7f:
182 if (waddch(win, attr | '^') == ERR)
183 return ERR;
184
185 return waddch(win, attr | '?');
186
187 default:
188 /* handle control chars */
189
190 if (waddch(win, attr | '^') == ERR)
191 return ERR;
192
193 return waddch(win, ch + '@');
194 }
195 }
196 else
197 {
198 /* If the incoming character doesn't have its own attribute,
199 then use the current attributes for the window. If it has
200 attributes but not a color component, OR the attributes to
201 the current attributes for the window. If it has a color
202 component, use the attributes solely from the incoming
203 character. */
204
205 if (!(attr & A_COLOR))
206 attr |= win->_attrs;
207
208 /* wrs (4/10/93): Apply the same sort of logic for the window
209 background, in that it only takes precedence if other color
210 attributes are not there and that the background character
211 will only print if the printing character is blank. */
212
213 if (!(attr & A_COLOR))
214 attr |= win->_bkgd & A_ATTRIBUTES;
215 else
216 attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
217
218 if (text == ' ')
219 text = win->_bkgd & A_CHARTEXT;
220
221 /* Add the attribute back into the character. */
222
223 text |= attr;
224
225 /* Only change _firstch/_lastch if the character to be added is
226 different from the character/attribute that is already in
227 that position in the window. */
228
229 if (win->_y[y][x] != text)
230 {
231 if (win->_firstch[y] == _NO_CHANGE)
232 win->_firstch[y] = win->_lastch[y] = x;
233 else
234 if (x < win->_firstch[y])
235 win->_firstch[y] = x;
236 else
237 if (x > win->_lastch[y])
238 win->_lastch[y] = x;
239
240 win->_y[y][x] = text;
241 }
242
243 if (++x >= win->_maxx)
244 {
245 /* wrap around test */
246
247 x = 0;
248
249 if (++y > win->_bmarg)
250 {
251 y--;
252
253 if (wscrl(win, 1) == ERR)
254 {
255 PDC_sync(win);
256 return ERR;
257 }
258 }
259 }
260 }
261
262 win->_curx = x;
263 win->_cury = y;
264
265 if (win->_immed)
266 wrefresh(win);
267 if (win->_sync)
268 wsyncup(win);
269
270 return OK;
271 }
272
273 int addch(const chtype ch)
274 {
275 PDC_LOG(("addch() - called: ch=%x\n", ch));
276
277 return waddch(stdscr, ch);
278 }
279
280 int mvaddch(int y, int x, const chtype ch)
281 {
282 PDC_LOG(("mvaddch() - called: y=%d x=%d ch=%x\n", y, x, ch));
283
284 if (move(y,x) == ERR)
285 return ERR;
286
287 return waddch(stdscr, ch);
288 }
289
290 int mvwaddch(WINDOW *win, int y, int x, const chtype ch)
291 {
292 PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d ch=%d\n", win, y, x, ch));
293
294 if (wmove(win, y, x) == ERR)
295 return ERR;
296
297 return waddch(win, ch);
298 }
299
300 int echochar(const chtype ch)
301 {
302 PDC_LOG(("echochar() - called: ch=%x\n", ch));
303
304 return wechochar(stdscr, ch);
305 }
306
307 int wechochar(WINDOW *win, const chtype ch)
308 {
309 PDC_LOG(("wechochar() - called: win=%p ch=%x\n", win, ch));
310
311 if (waddch(win, ch) == ERR)
312 return ERR;
313
314 return wrefresh(win);
315 }
316
317 int waddrawch(WINDOW *win, chtype ch)
318 {
319 PDC_LOG(("waddrawch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
320 win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
321
322 if ((ch & A_CHARTEXT) < ' ' || (ch & A_CHARTEXT) == 0x7f)
323 ch |= A_ALTCHARSET;
324
325 return waddch(win, ch);
326 }
327
328 int addrawch(chtype ch)
329 {
330 PDC_LOG(("addrawch() - called: ch=%x\n", ch));
331
332 return waddrawch(stdscr, ch);
333 }
334
335 int mvaddrawch(int y, int x, chtype ch)
336 {
337 PDC_LOG(("mvaddrawch() - called: y=%d x=%d ch=%d\n", y, x, ch));
338
339 if (move(y, x) == ERR)
340 return ERR;
341
342 return waddrawch(stdscr, ch);
343 }
344
345 int mvwaddrawch(WINDOW *win, int y, int x, chtype ch)
346 {
347 PDC_LOG(("mvwaddrawch() - called: win=%p y=%d x=%d ch=%d\n",
348 win, y, x, ch));
349
350 if (wmove(win, y, x) == ERR)
351 return ERR;
352
353 return waddrawch(win, ch);
354 }
355
356 #ifdef PDC_WIDE
357 int wadd_wch(WINDOW *win, const cchar_t *wch)
358 {
359 PDC_LOG(("wadd_wch() - called: win=%p wch=%x\n", win, *wch));
360
361 return wch ? waddch(win, *wch) : ERR;
362 }
363
364 int add_wch(const cchar_t *wch)
365 {
366 PDC_LOG(("add_wch() - called: wch=%x\n", *wch));
367
368 return wadd_wch(stdscr, wch);
369 }
370
371 int mvadd_wch(int y, int x, const cchar_t *wch)
372 {
373 PDC_LOG(("mvaddch() - called: y=%d x=%d wch=%x\n", y, x, *wch));
374
375 if (move(y,x) == ERR)
376 return ERR;
377
378 return wadd_wch(stdscr, wch);
379 }
380
381 int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch)
382 {
383 PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d wch=%d\n",
384 win, y, x, *wch));
385
386 if (wmove(win, y, x) == ERR)
387 return ERR;
388
389 return wadd_wch(win, wch);
390 }
391
392 int echo_wchar(const cchar_t *wch)
393 {
394 PDC_LOG(("echo_wchar() - called: wch=%x\n", *wch));
395
396 return wecho_wchar(stdscr, wch);
397 }
398
399 int wecho_wchar(WINDOW *win, const cchar_t *wch)
400 {
401 PDC_LOG(("wecho_wchar() - called: win=%p wch=%x\n", win, *wch));
402
403 if (!wch || (wadd_wch(win, wch) == ERR))
404 return ERR;
405
406 return wrefresh(win);
407 }
408 #endif
File pdcurses/addchstr.c added (mode: 100644) (index 00000000..0eea85a7)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: addchstr.c,v 1.43 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: addchstr
10
11 Synopsis:
12 int addchstr(const chtype *ch);
13 int addchnstr(const chtype *ch, int n);
14 int waddchstr(WINDOW *win, const chtype *ch);
15 int waddchnstr(WINDOW *win, const chtype *ch, int n);
16 int mvaddchstr(int y, int x, const chtype *ch);
17 int mvaddchnstr(int y, int x, const chtype *ch, int n);
18 int mvwaddchstr(WINDOW *, int y, int x, const chtype *ch);
19 int mvwaddchnstr(WINDOW *, int y, int x, const chtype *ch, int n);
20
21 int add_wchstr(const cchar_t *wch);
22 int add_wchnstr(const cchar_t *wch, int n);
23 int wadd_wchstr(WINDOW *win, const cchar_t *wch);
24 int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n);
25 int mvadd_wchstr(int y, int x, const cchar_t *wch);
26 int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n);
27 int mvwadd_wchstr(WINDOW *win, int y, int x, const cchar_t *wch);
28 int mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wch,
29 int n);
30
31 Description:
32 These routines write a chtype or cchar_t string directly into
33 the window structure, starting at the current or specified
34 position. The four routines with n as the last argument copy at
35 most n elements, but no more than will fit on the line. If n =
36 -1 then the whole string is copied, up to the maximum number
37 that will fit on the line.
38
39 The cursor position is not advanced. These routines do not check
40 for newline or other special characters, nor does any line
41 wrapping occur.
42
43 Return Value:
44 All functions return OK or ERR.
45
46 Portability X/Open BSD SYS V
47 addchstr Y - 4.0
48 waddchstr Y - 4.0
49 mvaddchstr Y - 4.0
50 mvwaddchstr Y - 4.0
51 addchnstr Y - 4.0
52 waddchnstr Y - 4.0
53 mvaddchnstr Y - 4.0
54 mvwaddchnstr Y - 4.0
55 add_wchstr Y
56 wadd_wchstr Y
57 mvadd_wchstr Y
58 mvwadd_wchstr Y
59 add_wchnstr Y
60 wadd_wchnstr Y
61 mvadd_wchnstr Y
62 mvwadd_wchnstr Y
63
64 **man-end****************************************************************/
65
66 #include <string.h>
67
68 int waddchnstr(WINDOW *win, const chtype *ch, int n)
69 {
70 int y, x, maxx, minx;
71 chtype *ptr;
72
73 PDC_LOG(("waddchnstr() - called: win=%p n=%d\n", win, n));
74
75 if (!win || !ch || !n || n < -1)
76 return ERR;
77
78 x = win->_curx;
79 y = win->_cury;
80 ptr = &(win->_y[y][x]);
81
82 if (n == -1 || n > win->_maxx - x)
83 n = win->_maxx - x;
84
85 minx = win->_firstch[y];
86 maxx = win->_lastch[y];
87
88 for (; n && *ch; n--, x++, ptr++, ch++)
89 {
90 if (*ptr != *ch)
91 {
92 if (x < minx || minx == _NO_CHANGE)
93 minx = x;
94
95 if (x > maxx)
96 maxx = x;
97
98 PDC_LOG(("y %d x %d minx %d maxx %d *ptr %x *ch"
99 " %x firstch: %d lastch: %d\n",
100 y, x, minx, maxx, *ptr, *ch,
101 win->_firstch[y], win->_lastch[y]));
102
103 *ptr = *ch;
104 }
105 }
106
107 win->_firstch[y] = minx;
108 win->_lastch[y] = maxx;
109
110 return OK;
111 }
112
113 int addchstr(const chtype *ch)
114 {
115 PDC_LOG(("addchstr() - called\n"));
116
117 return waddchnstr(stdscr, ch, -1);
118 }
119
120 int addchnstr(const chtype *ch, int n)
121 {
122 PDC_LOG(("addchnstr() - called\n"));
123
124 return waddchnstr(stdscr, ch, n);
125 }
126
127 int waddchstr(WINDOW *win, const chtype *ch)
128 {
129 PDC_LOG(("waddchstr() - called: win=%p\n", win));
130
131 return waddchnstr(win, ch, -1);
132 }
133
134 int mvaddchstr(int y, int x, const chtype *ch)
135 {
136 PDC_LOG(("mvaddchstr() - called: y %d x %d\n", y, x));
137
138 if (move(y, x) == ERR)
139 return ERR;
140
141 return waddchnstr(stdscr, ch, -1);
142 }
143
144 int mvaddchnstr(int y, int x, const chtype *ch, int n)
145 {
146 PDC_LOG(("mvaddchnstr() - called: y %d x %d n %d\n", y, x, n));
147
148 if (move(y, x) == ERR)
149 return ERR;
150
151 return waddchnstr(stdscr, ch, n);
152 }
153
154 int mvwaddchstr(WINDOW *win, int y, int x, const chtype *ch)
155 {
156 PDC_LOG(("mvwaddchstr() - called:\n"));
157
158 if (wmove(win, y, x) == ERR)
159 return ERR;
160
161 return waddchnstr(win, ch, -1);
162 }
163
164 int mvwaddchnstr(WINDOW *win, int y, int x, const chtype *ch, int n)
165 {
166 PDC_LOG(("mvwaddchnstr() - called: y %d x %d n %d \n", y, x, n));
167
168 if (wmove(win, y, x) == ERR)
169 return ERR;
170
171 return waddchnstr(win, ch, n);
172 }
173
174 #ifdef PDC_WIDE
175 int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n)
176 {
177 PDC_LOG(("wadd_wchnstr() - called: win=%p n=%d\n", win, n));
178
179 return waddchnstr(win, wch, n);
180 }
181
182 int add_wchstr(const cchar_t *wch)
183 {
184 PDC_LOG(("add_wchstr() - called\n"));
185
186 return wadd_wchnstr(stdscr, wch, -1);
187 }
188
189 int add_wchnstr(const cchar_t *wch, int n)
190 {
191 PDC_LOG(("add_wchnstr() - called\n"));
192
193 return wadd_wchnstr(stdscr, wch, n);
194 }
195
196 int wadd_wchstr(WINDOW *win, const cchar_t *wch)
197 {
198 PDC_LOG(("wadd_wchstr() - called: win=%p\n", win));
199
200 return wadd_wchnstr(win, wch, -1);
201 }
202
203 int mvadd_wchstr(int y, int x, const cchar_t *wch)
204 {
205 PDC_LOG(("mvadd_wchstr() - called: y %d x %d\n", y, x));
206
207 if (move(y, x) == ERR)
208 return ERR;
209
210 return wadd_wchnstr(stdscr, wch, -1);
211 }
212
213 int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n)
214 {
215 PDC_LOG(("mvadd_wchnstr() - called: y %d x %d n %d\n", y, x, n));
216
217 if (move(y, x) == ERR)
218 return ERR;
219
220 return wadd_wchnstr(stdscr, wch, n);
221 }
222
223 int mvwadd_wchstr(WINDOW *win, int y, int x, const cchar_t *wch)
224 {
225 PDC_LOG(("mvwadd_wchstr() - called:\n"));
226
227 if (wmove(win, y, x) == ERR)
228 return ERR;
229
230 return wadd_wchnstr(win, wch, -1);
231 }
232
233 int mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wch, int n)
234 {
235 PDC_LOG(("mvwadd_wchnstr() - called: y %d x %d n %d \n", y, x, n));
236
237 if (wmove(win, y, x) == ERR)
238 return ERR;
239
240 return wadd_wchnstr(win, wch, n);
241 }
242 #endif
File pdcurses/addstr.c added (mode: 100644) (index 00000000..ca19fd02)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: addstr.c,v 1.44 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: addstr
10
11 Synopsis:
12 int addstr(const char *str);
13 int addnstr(const char *str, int n);
14 int waddstr(WINDOW *win, const char *str);
15 int waddnstr(WINDOW *win, const char *str, int n);
16 int mvaddstr(int y, int x, const char *str);
17 int mvaddnstr(int y, int x, const char *str, int n);
18 int mvwaddstr(WINDOW *win, int y, int x, const char *str);
19 int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n);
20
21 int addwstr(const wchar_t *wstr);
22 int addnwstr(const wchar_t *wstr, int n);
23 int waddwstr(WINDOW *win, const wchar_t *wstr);
24 int waddnwstr(WINDOW *win, const wchar_t *wstr, int n);
25 int mvaddwstr(int y, int x, const wchar_t *wstr);
26 int mvaddnwstr(int y, int x, const wchar_t *wstr, int n);
27 int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr);
28 int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n);
29
30 Description:
31 These routines write all the characters of the null-terminated
32 string str or wide-character string wstr to the given window.
33 The functionality is similar to calling waddch() once for each
34 character in the string; except that, when PDCurses is built
35 with wide-character support enabled, the narrow-character
36 functions treat the string as a multibyte string in the current
37 locale, and convert it. The routines with n as the last
38 argument write at most n characters; if n is negative, then the
39 entire string will be added.
40
41 Return Value:
42 All functions return OK or ERR.
43
44 Portability X/Open BSD SYS V
45 addstr Y Y Y
46 waddstr Y Y Y
47 mvaddstr Y Y Y
48 mvwaddstr Y Y Y
49 addnstr Y - 4.0
50 waddnstr Y - 4.0
51 mvaddnstr Y - 4.0
52 mvwaddnstr Y - 4.0
53 addwstr Y
54 waddwstr Y
55 mvaddwstr Y
56 mvwaddwstr Y
57 addnwstr Y
58 waddnwstr Y
59 mvaddnwstr Y
60 mvwaddnwstr Y
61
62 **man-end****************************************************************/
63
64 int waddnstr(WINDOW *win, const char *str, int n)
65 {
66 int i = 0;
67
68 PDC_LOG(("waddnstr() - called: string=\"%s\" n %d \n", str, n));
69
70 if (!win || !str)
71 return ERR;
72
73 while (str[i] && (i < n || n < 0))
74 {
75 #ifdef PDC_WIDE
76 wchar_t wch;
77 int retval = PDC_mbtowc(&wch, str + i, n >= 0 ? n - i : 6);
78
79 if (retval <= 0)
80 return OK;
81
82 i += retval;
83 #else
84 chtype wch = (unsigned char)(str[i++]);
85 #endif
86 if (waddch(win, wch) == ERR)
87 return ERR;
88 }
89
90 return OK;
91 }
92
93 int addstr(const char *str)
94 {
95 PDC_LOG(("addstr() - called: string=\"%s\"\n", str));
96
97 return waddnstr(stdscr, str, -1);
98 }
99
100 int addnstr(const char *str, int n)
101 {
102 PDC_LOG(("addnstr() - called: string=\"%s\" n %d \n", str, n));
103
104 return waddnstr(stdscr, str, n);
105 }
106
107 int waddstr(WINDOW *win, const char *str)
108 {
109 PDC_LOG(("waddstr() - called: string=\"%s\"\n", str));
110
111 return waddnstr(win, str, -1);
112 }
113
114 int mvaddstr(int y, int x, const char *str)
115 {
116 PDC_LOG(("mvaddstr() - called: y %d x %d string=\"%s\"\n", y, x, str));
117
118 if (move(y, x) == ERR)
119 return ERR;
120
121 return waddnstr(stdscr, str, -1);
122 }
123
124 int mvaddnstr(int y, int x, const char *str, int n)
125 {
126 PDC_LOG(("mvaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
127 y, x, str, n));
128
129 if (move(y, x) == ERR)
130 return ERR;
131
132 return waddnstr(stdscr, str, n);
133 }
134
135 int mvwaddstr(WINDOW *win, int y, int x, const char *str)
136 {
137 PDC_LOG(("mvwaddstr() - called: string=\"%s\"\n", str));
138
139 if (wmove(win, y, x) == ERR)
140 return ERR;
141
142 return waddnstr(win, str, -1);
143 }
144
145 int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n)
146 {
147 PDC_LOG(("mvwaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
148 y, x, str, n));
149
150 if (wmove(win, y, x) == ERR)
151 return ERR;
152
153 return waddnstr(win, str, n);
154 }
155
156 #ifdef PDC_WIDE
157 int waddnwstr(WINDOW *win, const wchar_t *wstr, int n)
158 {
159 int i = 0;
160
161 PDC_LOG(("waddnwstr() - called\n"));
162
163 if (!win || !wstr)
164 return ERR;
165
166 while (wstr[i] && (i < n || n < 0))
167 {
168 chtype wch = wstr[i++];
169
170 if (waddch(win, wch) == ERR)
171 return ERR;
172 }
173
174 return OK;
175 }
176
177 int addwstr(const wchar_t *wstr)
178 {
179 PDC_LOG(("addwstr() - called\n"));
180
181 return waddnwstr(stdscr, wstr, -1);
182 }
183
184 int addnwstr(const wchar_t *wstr, int n)
185 {
186 PDC_LOG(("addnwstr() - called\n"));
187
188 return waddnwstr(stdscr, wstr, n);
189 }
190
191 int waddwstr(WINDOW *win, const wchar_t *wstr)
192 {
193 PDC_LOG(("waddwstr() - called\n"));
194
195 return waddnwstr(win, wstr, -1);
196 }
197
198 int mvaddwstr(int y, int x, const wchar_t *wstr)
199 {
200 PDC_LOG(("mvaddstr() - called\n"));
201
202 if (move(y, x) == ERR)
203 return ERR;
204
205 return waddnwstr(stdscr, wstr, -1);
206 }
207
208 int mvaddnwstr(int y, int x, const wchar_t *wstr, int n)
209 {
210 PDC_LOG(("mvaddnstr() - called\n"));
211
212 if (move(y, x) == ERR)
213 return ERR;
214
215 return waddnwstr(stdscr, wstr, n);
216 }
217
218 int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr)
219 {
220 PDC_LOG(("mvwaddstr() - called\n"));
221
222 if (wmove(win, y, x) == ERR)
223 return ERR;
224
225 return waddnwstr(win, wstr, -1);
226 }
227
228 int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n)
229 {
230 PDC_LOG(("mvwaddnstr() - called\n"));
231
232 if (wmove(win, y, x) == ERR)
233 return ERR;
234
235 return waddnwstr(win, wstr, n);
236 }
237 #endif
File pdcurses/attr.c added (mode: 100644) (index 00000000..532384b3)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: attr.c,v 1.41 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: attr
10
11 Synopsis:
12 int attroff(chtype attrs);
13 int wattroff(WINDOW *win, chtype attrs);
14 int attron(chtype attrs);
15 int wattron(WINDOW *win, chtype attrs);
16 int attrset(chtype attrs);
17 int wattrset(WINDOW *win, chtype attrs);
18 int standend(void);
19 int wstandend(WINDOW *win);
20 int standout(void);
21 int wstandout(WINDOW *win);
22
23 int color_set(short color_pair, void *opts);
24 int wcolor_set(WINDOW *win, short color_pair, void *opts);
25
26 int attr_get(attr_t *attrs, short *color_pair, void *opts);
27 int attr_off(attr_t attrs, void *opts);
28 int attr_on(attr_t attrs, void *opts);
29 int attr_set(attr_t attrs, short color_pair, void *opts);
30 int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair,
31 void *opts);
32 int wattr_off(WINDOW *win, attr_t attrs, void *opts);
33 int wattr_on(WINDOW *win, attr_t attrs, void *opts);
34 int wattr_set(WINDOW *win, attr_t attrs, short color_pair,
35 void *opts);
36
37 int chgat(int n, attr_t attr, short color, const void *opts);
38 int mvchgat(int y, int x, int n, attr_t attr, short color,
39 const void *opts);
40 int mvwchgat(WINDOW *win, int y, int x, int n, attr_t attr,
41 short color, const void *opts);
42 int wchgat(WINDOW *win, int n, attr_t attr, short color,
43 const void *opts);
44
45 chtype getattrs(WINDOW *win);
46
47 Description:
48 These functions manipulate the current attributes and/or colors
49 of the named window. These attributes can be any combination
50 of A_STANDOUT, A_REVERSE, A_BOLD, A_DIM, A_BLINK, A_UNDERLINE.
51
52 These constants are defined in <curses.h> and can be combined
53 with the bitwise-OR operator (|).
54
55 The current attributes of a window are applied to all chtypes
56 that are written into the window with waddch(). Attributes are
57 a property of the chtype, and move with the character through
58 any scrolling or insert/delete operations.
59
60 attrset() sets the current attributes of the given window to
61 attrs. attroff() turns off the named attributes without
62 affecting any other attributes; attron() turns them on.
63 color_set() sets the window color to the value of color_pair.
64
65 standout() is the same as attron(A_STANDOUT). standend() is the
66 same as attrset(A_NORMAL); that is, it turns off all attributes.
67
68 Return Value:
69 All functions return OK on success and ERR on error.
70
71 Portability X/Open BSD SYS V
72 attroff Y Y Y
73 wattroff Y Y Y
74 attron Y Y Y
75 wattron Y Y Y
76 attrset Y Y Y
77 wattrset Y Y Y
78 standend Y Y Y
79 wstandend Y Y Y
80 standout Y Y Y
81 wstandout Y Y Y
82 color_set Y
83 wcolor_set Y
84 attr_get Y
85 wattr_get Y
86 attr_on Y
87 wattr_on Y
88 attr_off Y
89 wattr_off Y
90 attr_set Y
91 wattr_set Y
92 chgat Y
93 wchgat Y
94 mvchgat Y
95 mvwchgat Y
96 getattrs -
97
98 **man-end****************************************************************/
99
100 int wattroff(WINDOW *win, chtype attrs)
101 {
102 PDC_LOG(("wattroff() - called\n"));
103
104 if (!win)
105 return ERR;
106
107 win->_attrs &= (~attrs & A_ATTRIBUTES);
108
109 return OK;
110 }
111
112 int attroff(chtype attrs)
113 {
114 PDC_LOG(("attroff() - called\n"));
115
116 return wattroff(stdscr, attrs);
117 }
118
119 int wattron(WINDOW *win, chtype attrs)
120 {
121 chtype newcolr, oldcolr, newattr, oldattr;
122
123 PDC_LOG(("wattron() - called\n"));
124
125 if (!win)
126 return ERR;
127
128 if ((win->_attrs & A_COLOR) && (attrs & A_COLOR))
129 {
130 oldcolr = win->_attrs & A_COLOR;
131 oldattr = win->_attrs ^ oldcolr;
132 newcolr = attrs & A_COLOR;
133 newattr = (attrs & A_ATTRIBUTES) ^ newcolr;
134 newattr |= oldattr;
135 win->_attrs = newattr | newcolr;
136 }
137 else
138 win->_attrs |= (attrs & A_ATTRIBUTES);
139
140 return OK;
141 }
142
143 int attron(chtype attrs)
144 {
145 PDC_LOG(("attron() - called\n"));
146
147 return wattron(stdscr, attrs);
148 }
149
150 int wattrset(WINDOW *win, chtype attrs)
151 {
152 PDC_LOG(("wattrset() - called\n"));
153
154 if (!win)
155 return ERR;
156
157 win->_attrs = attrs & A_ATTRIBUTES;
158
159 return OK;
160 }
161
162 int attrset(chtype attrs)
163 {
164 PDC_LOG(("attrset() - called\n"));
165
166 return wattrset(stdscr, attrs);
167 }
168
169 int standend(void)
170 {
171 PDC_LOG(("standend() - called\n"));
172
173 return wattrset(stdscr, A_NORMAL);
174 }
175
176 int standout(void)
177 {
178 PDC_LOG(("standout() - called\n"));
179
180 return wattrset(stdscr, A_STANDOUT);
181 }
182
183 int wstandend(WINDOW *win)
184 {
185 PDC_LOG(("wstandend() - called\n"));
186
187 return wattrset(win, A_NORMAL);
188 }
189
190 int wstandout(WINDOW *win)
191 {
192 PDC_LOG(("wstandout() - called\n"));
193
194 return wattrset(win, A_STANDOUT);
195 }
196
197 chtype getattrs(WINDOW *win)
198 {
199 return win ? win->_attrs : 0;
200 }
201
202 int wcolor_set(WINDOW *win, short color_pair, void *opts)
203 {
204 PDC_LOG(("wcolor_set() - called\n"));
205
206 if (!win)
207 return ERR;
208
209 win->_attrs = (win->_attrs & ~A_COLOR) | COLOR_PAIR(color_pair);
210
211 return OK;
212 }
213
214 int color_set(short color_pair, void *opts)
215 {
216 PDC_LOG(("color_set() - called\n"));
217
218 return wcolor_set(stdscr, color_pair, opts);
219 }
220
221 int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair, void *opts)
222 {
223 PDC_LOG(("wattr_get() - called\n"));
224
225 if (!win)
226 return ERR;
227
228 if (attrs)
229 *attrs = win->_attrs & (A_ATTRIBUTES & ~A_COLOR);
230
231 if (color_pair)
232 *color_pair = PAIR_NUMBER(win->_attrs);
233
234 return OK;
235 }
236
237 int attr_get(attr_t *attrs, short *color_pair, void *opts)
238 {
239 PDC_LOG(("attr_get() - called\n"));
240
241 return wattr_get(stdscr, attrs, color_pair, opts);
242 }
243
244 int wattr_off(WINDOW *win, attr_t attrs, void *opts)
245 {
246 PDC_LOG(("wattr_off() - called\n"));
247
248 return wattroff(win, attrs);
249 }
250
251 int attr_off(attr_t attrs, void *opts)
252 {
253 PDC_LOG(("attr_off() - called\n"));
254
255 return wattroff(stdscr, attrs);
256 }
257
258 int wattr_on(WINDOW *win, attr_t attrs, void *opts)
259 {
260 PDC_LOG(("wattr_off() - called\n"));
261
262 return wattron(win, attrs);
263 }
264
265 int attr_on(attr_t attrs, void *opts)
266 {
267 PDC_LOG(("attr_on() - called\n"));
268
269 return wattron(stdscr, attrs);
270 }
271
272 int wattr_set(WINDOW *win, attr_t attrs, short color_pair, void *opts)
273 {
274 PDC_LOG(("wattr_set() - called\n"));
275
276 if (!win)
277 return ERR;
278
279 win->_attrs = (attrs & (A_ATTRIBUTES & ~A_COLOR)) | COLOR_PAIR(color_pair);
280
281 return OK;
282 }
283
284 int attr_set(attr_t attrs, short color_pair, void *opts)
285 {
286 PDC_LOG(("attr_get() - called\n"));
287
288 return wattr_set(stdscr, attrs, color_pair, opts);
289 }
290
291 int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts)
292 {
293 chtype *dest, newattr;
294 int startpos, endpos;
295
296 PDC_LOG(("wchgat() - called\n"));
297
298 if (!win)
299 return ERR;
300
301 newattr = (attr & A_ATTRIBUTES) | COLOR_PAIR(color);
302
303 startpos = win->_curx;
304 endpos = ((n < 0) ? win->_maxx : min(startpos + n, win->_maxx)) - 1;
305 dest = win->_y[win->_cury];
306
307 for (n = startpos; n <= endpos; n++)
308 dest[n] = (dest[n] & A_CHARTEXT) | newattr;
309
310 n = win->_cury;
311
312 if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
313 win->_firstch[n] = startpos;
314
315 if (endpos > win->_lastch[n])
316 win->_lastch[n] = endpos;
317
318 PDC_sync(win);
319
320 return OK;
321 }
322
323 int chgat(int n, attr_t attr, short color, const void *opts)
324 {
325 PDC_LOG(("chgat() - called\n"));
326
327 return wchgat(stdscr, n, attr, color, opts);
328 }
329
330 int mvchgat(int y, int x, int n, attr_t attr, short color, const void *opts)
331 {
332 PDC_LOG(("mvchgat() - called\n"));
333
334 if (move(y, x) == ERR)
335 return ERR;
336
337 return wchgat(stdscr, n, attr, color, opts);
338 }
339
340 int mvwchgat(WINDOW *win, int y, int x, int n, attr_t attr, short color,
341 const void *opts)
342 {
343 PDC_LOG(("mvwchgat() - called\n"));
344
345 if (wmove(win, y, x) == ERR)
346 return ERR;
347
348 return wchgat(win, n, attr, color, opts);
349 }
File pdcurses/beep.c added (mode: 100644) (index 00000000..9e92f457)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: beep.c,v 1.34 2008/07/13 16:08:17 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: beep
10
11 Synopsis:
12 int beep(void);
13 int flash(void);
14
15 Description:
16 beep() sounds the audible bell on the terminal, if possible;
17 if not, it calls flash().
18
19 flash() "flashes" the screen, by inverting the foreground and
20 background of every cell, pausing, and then restoring the
21 original attributes.
22
23 Return Value:
24 These functions return OK.
25
26 Portability X/Open BSD SYS V
27 beep Y Y Y
28 flash Y Y Y
29
30 **man-end****************************************************************/
31
32 int beep(void)
33 {
34 PDC_LOG(("beep() - called\n"));
35
36 if (SP->audible)
37 PDC_beep();
38 else
39 flash();
40
41 return OK;
42 }
43
44 int flash(void)
45 {
46 int z, y, x;
47
48 PDC_LOG(("flash() - called\n"));
49
50 /* Reverse each cell; wait; restore the screen */
51
52 for (z = 0; z < 2; z++)
53 {
54 for (y = 0; y < LINES; y++)
55 for (x = 0; x < COLS; x++)
56 curscr->_y[y][x] ^= A_REVERSE;
57
58 wrefresh(curscr);
59
60 if (!z)
61 napms(50);
62 }
63
64 return OK;
65 }
File pdcurses/bkgd.c added (mode: 100644) (index 00000000..083239e1)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: bkgd.c,v 1.39 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: bkgd
10
11 Synopsis:
12 int bkgd(chtype ch);
13 void bkgdset(chtype ch);
14 chtype getbkgd(WINDOW *win);
15 int wbkgd(WINDOW *win, chtype ch);
16 void wbkgdset(WINDOW *win, chtype ch);
17
18 int bkgrnd(const cchar_t *wch);
19 void bkgrndset(const cchar_t *wch);
20 int getbkgrnd(cchar_t *wch);
21 int wbkgrnd(WINDOW *win, const cchar_t *wch);
22 void wbkgrndset(WINDOW *win, const cchar_t *wch);
23 int wgetbkgrnd(WINDOW *win, cchar_t *wch);
24
25 Description:
26 bkgdset() and wbkgdset() manipulate the background of a window.
27 The background is a chtype consisting of any combination of
28 attributes and a character; it is combined with each chtype
29 added or inserted to the window by waddch() or winsch(). Only
30 the attribute part is used to set the background of non-blank
31 characters, while both character and attributes are used for
32 blank positions.
33
34 bkgd() and wbkgd() not only change the background, but apply it
35 immediately to every cell in the window.
36
37 The attributes that are defined with the attrset()/attron() set
38 of functions take precedence over the background attributes if
39 there is a conflict (e.g., different color pairs).
40
41 Return Value:
42 bkgd() and wbkgd() return OK, unless the window is NULL, in
43 which case they return ERR.
44
45 Portability X/Open BSD SYS V
46 bkgd Y - 4.0
47 bkgdset Y - 4.0
48 getbkgd Y
49 wbkgd Y - 4.0
50 wbkgdset Y - 4.0
51 bkgrnd Y
52 bkgrndset Y
53 getbkgrnd Y
54 wbkgrnd Y
55 wbkgrndset Y
56 wgetbkgrnd Y
57
58 **man-end****************************************************************/
59
60 int wbkgd(WINDOW *win, chtype ch)
61 {
62 int x, y;
63 chtype oldcolr, oldch, newcolr, newch, colr, attr;
64 chtype oldattr = 0, newattr = 0;
65 chtype *winptr;
66
67 PDC_LOG(("wbkgd() - called\n"));
68
69 if (!win)
70 return ERR;
71
72 if (win->_bkgd == ch)
73 return OK;
74
75 oldcolr = win->_bkgd & A_COLOR;
76 if (oldcolr)
77 oldattr = (win->_bkgd & A_ATTRIBUTES) ^ oldcolr;
78
79 oldch = win->_bkgd & A_CHARTEXT;
80
81 wbkgdset(win, ch);
82
83 newcolr = win->_bkgd & A_COLOR;
84 if (newcolr)
85 newattr = (win->_bkgd & A_ATTRIBUTES) ^ newcolr;
86
87 newch = win->_bkgd & A_CHARTEXT;
88
89 /* what follows is what seems to occur in the System V
90 implementation of this routine */
91
92 for (y = 0; y < win->_maxy; y++)
93 {
94 for (x = 0; x < win->_maxx; x++)
95 {
96 winptr = win->_y[y] + x;
97
98 ch = *winptr;
99
100 /* determine the colors and attributes of the character read
101 from the window */
102
103 colr = ch & A_COLOR;
104 attr = ch & (A_ATTRIBUTES ^ A_COLOR);
105
106 /* if the color is the same as the old background color,
107 then make it the new background color, otherwise leave it */
108
109 if (colr == oldcolr)
110 colr = newcolr;
111
112 /* remove any attributes (non color) from the character that
113 were part of the old background, then combine the
114 remaining ones with the new background */
115
116 attr ^= oldattr;
117 attr |= newattr;
118
119 /* change character if it is there because it was the old
120 background character */
121
122 ch &= A_CHARTEXT;
123 if (ch == oldch)
124 ch = newch;
125
126 ch |= (attr | colr);
127
128 *winptr = ch;
129
130 }
131 }
132
133 touchwin(win);
134 PDC_sync(win);
135 return OK;
136 }
137
138 int bkgd(chtype ch)
139 {
140 PDC_LOG(("bkgd() - called\n"));
141
142 return wbkgd(stdscr, ch);
143 }
144
145 void wbkgdset(WINDOW *win, chtype ch)
146 {
147 PDC_LOG(("wbkgdset() - called\n"));
148
149 if (win)
150 {
151 if (!(ch & A_CHARTEXT))
152 ch |= ' ';
153
154 win->_bkgd = ch;
155 }
156 }
157
158 void bkgdset(chtype ch)
159 {
160 PDC_LOG(("bkgdset() - called\n"));
161
162 wbkgdset(stdscr, ch);
163 }
164
165 chtype getbkgd(WINDOW *win)
166 {
167 PDC_LOG(("getbkgd() - called\n"));
168
169 return win ? win->_bkgd : (chtype)ERR;
170 }
171
172 #ifdef PDC_WIDE
173 int wbkgrnd(WINDOW *win, const cchar_t *wch)
174 {
175 PDC_LOG(("wbkgrnd() - called\n"));
176
177 return wch ? wbkgd(win, *wch) : ERR;
178 }
179
180 int bkgrnd(const cchar_t *wch)
181 {
182 PDC_LOG(("bkgrnd() - called\n"));
183
184 return wbkgrnd(stdscr, wch);
185 }
186
187 void wbkgrndset(WINDOW *win, const cchar_t *wch)
188 {
189 PDC_LOG(("wbkgdset() - called\n"));
190
191 if (wch)
192 wbkgdset(win, *wch);
193 }
194
195 void bkgrndset(const cchar_t *wch)
196 {
197 PDC_LOG(("bkgrndset() - called\n"));
198
199 wbkgrndset(stdscr, wch);
200 }
201
202 int wgetbkgrnd(WINDOW *win, cchar_t *wch)
203 {
204 PDC_LOG(("wgetbkgrnd() - called\n"));
205
206 if (!win || !wch)
207 return ERR;
208
209 *wch = win->_bkgd;
210
211 return OK;
212 }
213
214 int getbkgrnd(cchar_t *wch)
215 {
216 PDC_LOG(("getbkgrnd() - called\n"));
217
218 return wgetbkgrnd(stdscr, wch);
219 }
220 #endif
File pdcurses/border.c added (mode: 100644) (index 00000000..ec86aafd)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: border.c,v 1.53 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: border
10
11 Synopsis:
12 int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl,
13 chtype tr, chtype bl, chtype br);
14 int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
15 chtype bs, chtype tl, chtype tr, chtype bl, chtype br);
16 int box(WINDOW *win, chtype verch, chtype horch);
17 int hline(chtype ch, int n);
18 int vline(chtype ch, int n);
19 int whline(WINDOW *win, chtype ch, int n);
20 int wvline(WINDOW *win, chtype ch, int n);
21 int mvhline(int y, int x, chtype ch, int n);
22 int mvvline(int y, int x, chtype ch, int n);
23 int mvwhline(WINDOW *win, int y, int x, chtype ch, int n);
24 int mvwvline(WINDOW *win, int y, int x, chtype ch, int n);
25
26 int border_set(const cchar_t *ls, const cchar_t *rs,
27 const cchar_t *ts, const cchar_t *bs,
28 const cchar_t *tl, const cchar_t *tr,
29 const cchar_t *bl, const cchar_t *br);
30 int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
31 const cchar_t *ts, const cchar_t *bs,
32 const cchar_t *tl, const cchar_t *tr,
33 const cchar_t *bl, const cchar_t *br);
34 int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch);
35 int hline_set(const cchar_t *wch, int n);
36 int vline_set(const cchar_t *wch, int n);
37 int whline_set(WINDOW *win, const cchar_t *wch, int n);
38 int wvline_set(WINDOW *win, const cchar_t *wch, int n);
39 int mvhline_set(int y, int x, const cchar_t *wch, int n);
40 int mvvline_set(int y, int x, const cchar_t *wch, int n);
41 int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n);
42 int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n);
43
44 Description:
45 border(), wborder(), and box() draw a border around the edge of
46 the window. If any argument is zero, an appropriate default is
47 used:
48
49 ls left side of border ACS_VLINE
50 rs right side of border ACS_VLINE
51 ts top side of border ACS_HLINE
52 bs bottom side of border ACS_HLINE
53 tl top left corner of border ACS_ULCORNER
54 tr top right corner of border ACS_URCORNER
55 bl bottom left corner of border ACS_LLCORNER
56 br bottom right corner of border ACS_LRCORNER
57
58 hline() and whline() draw a horizontal line, using ch, starting
59 from the current cursor position. The cursor position does not
60 change. The line is at most n characters long, or as many as
61 will fit in the window.
62
63 vline() and wvline() draw a vertical line, using ch, starting
64 from the current cursor position. The cursor position does not
65 change. The line is at most n characters long, or as many as
66 will fit in the window.
67
68 Return Value:
69 These functions return OK on success and ERR on error.
70
71 Portability X/Open BSD SYS V
72 border Y - 4.0
73 wborder Y - 4.0
74 box Y Y Y
75 hline Y - 4.0
76 vline Y - 4.0
77 whline Y - 4.0
78 wvline Y - 4.0
79 mvhline Y
80 mvvline Y
81 mvwhline Y
82 mvwvline Y
83 border_set Y
84 wborder_set Y
85 box_set Y
86 hline_set Y
87 vline_set Y
88 whline_set Y
89 wvline_set Y
90 mvhline_set Y
91 mvvline_set Y
92 mvwhline_set Y
93 mvwvline_set Y
94
95 **man-end****************************************************************/
96
97 /* _attr_passthru() -- Takes a single chtype 'ch' and checks if the
98 current attribute of window 'win', as set by wattrset(), and/or the
99 current background of win, as set by wbkgd(), should by combined with
100 it. Attributes set explicitly in ch take precedence. */
101
102 static chtype _attr_passthru(WINDOW *win, chtype ch)
103 {
104 chtype attr;
105
106 /* If the incoming character doesn't have its own attribute, then
107 use the current attributes for the window. If the incoming
108 character has attributes, but not a color component, OR the
109 attributes to the current attributes for the window. If the
110 incoming character has a color component, use only the attributes
111 from the incoming character. */
112
113 attr = ch & A_ATTRIBUTES;
114 if (!(attr & A_COLOR))
115 attr |= win->_attrs;
116
117 /* wrs (4/10/93) -- Apply the same sort of logic for the window
118 background, in that it only takes precedence if other color
119 attributes are not there. */
120
121 if (!(attr & A_COLOR))
122 attr |= win->_bkgd & A_ATTRIBUTES;
123 else
124 attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
125
126 ch = (ch & A_CHARTEXT) | attr;
127
128 return ch;
129 }
130
131 int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs,
132 chtype tl, chtype tr, chtype bl, chtype br)
133 {
134 int i, ymax, xmax;
135
136 PDC_LOG(("wborder() - called\n"));
137
138 if (!win)
139 return ERR;
140
141 ymax = win->_maxy - 1;
142 xmax = win->_maxx - 1;
143
144 ls = _attr_passthru(win, ls ? ls : ACS_VLINE);
145 rs = _attr_passthru(win, rs ? rs : ACS_VLINE);
146 ts = _attr_passthru(win, ts ? ts : ACS_HLINE);
147 bs = _attr_passthru(win, bs ? bs : ACS_HLINE);
148 tl = _attr_passthru(win, tl ? tl : ACS_ULCORNER);
149 tr = _attr_passthru(win, tr ? tr : ACS_URCORNER);
150 bl = _attr_passthru(win, bl ? bl : ACS_LLCORNER);
151 br = _attr_passthru(win, br ? br : ACS_LRCORNER);
152
153 for (i = 1; i < xmax; i++)
154 {
155 win->_y[0][i] = ts;
156 win->_y[ymax][i] = bs;
157 }
158
159 for (i = 1; i < ymax; i++)
160 {
161 win->_y[i][0] = ls;
162 win->_y[i][xmax] = rs;
163 }
164
165 win->_y[0][0] = tl;
166 win->_y[0][xmax] = tr;
167 win->_y[ymax][0] = bl;
168 win->_y[ymax][xmax] = br;
169
170 for (i = 0; i <= ymax; i++)
171 {
172 win->_firstch[i] = 0;
173 win->_lastch[i] = xmax;
174 }
175
176 PDC_sync(win);
177
178 return OK;
179 }
180
181 int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl,
182 chtype tr, chtype bl, chtype br)
183 {
184 PDC_LOG(("border() - called\n"));
185
186 return wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br);
187 }
188
189 int box(WINDOW *win, chtype verch, chtype horch)
190 {
191 PDC_LOG(("box() - called\n"));
192
193 return wborder(win, verch, verch, horch, horch, 0, 0, 0, 0);
194 }
195
196 int whline(WINDOW *win, chtype ch, int n)
197 {
198 chtype *dest;
199 int startpos, endpos;
200
201 PDC_LOG(("whline() - called\n"));
202
203 if (!win || n < 1)
204 return ERR;
205
206 startpos = win->_curx;
207 endpos = min(startpos + n, win->_maxx) - 1;
208 dest = win->_y[win->_cury];
209 ch = _attr_passthru(win, ch ? ch : ACS_HLINE);
210
211 for (n = startpos; n <= endpos; n++)
212 dest[n] = ch;
213
214 n = win->_cury;
215
216 if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
217 win->_firstch[n] = startpos;
218
219 if (endpos > win->_lastch[n])
220 win->_lastch[n] = endpos;
221
222 PDC_sync(win);
223
224 return OK;
225 }
226
227 int hline(chtype ch, int n)
228 {
229 PDC_LOG(("hline() - called\n"));
230
231 return whline(stdscr, ch, n);
232 }
233
234 int mvhline(int y, int x, chtype ch, int n)
235 {
236 PDC_LOG(("mvhline() - called\n"));
237
238 if (move(y, x) == ERR)
239 return ERR;
240
241 return whline(stdscr, ch, n);
242 }
243
244 int mvwhline(WINDOW *win, int y, int x, chtype ch, int n)
245 {
246 PDC_LOG(("mvwhline() - called\n"));
247
248 if (wmove(win, y, x) == ERR)
249 return ERR;
250
251 return whline(win, ch, n);
252 }
253
254 int wvline(WINDOW *win, chtype ch, int n)
255 {
256 int endpos, x;
257
258 PDC_LOG(("wvline() - called\n"));
259
260 if (!win || n < 1)
261 return ERR;
262
263 endpos = min(win->_cury + n, win->_maxy);
264 x = win->_curx;
265
266 ch = _attr_passthru(win, ch ? ch : ACS_VLINE);
267
268 for (n = win->_cury; n < endpos; n++)
269 {
270 win->_y[n][x] = ch;
271
272 if (x < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
273 win->_firstch[n] = x;
274
275 if (x > win->_lastch[n])
276 win->_lastch[n] = x;
277 }
278
279 PDC_sync(win);
280
281 return OK;
282 }
283
284 int vline(chtype ch, int n)
285 {
286 PDC_LOG(("vline() - called\n"));
287
288 return wvline(stdscr, ch, n);
289 }
290
291 int mvvline(int y, int x, chtype ch, int n)
292 {
293 PDC_LOG(("mvvline() - called\n"));
294
295 if (move(y, x) == ERR)
296 return ERR;
297
298 return wvline(stdscr, ch, n);
299 }
300
301 int mvwvline(WINDOW *win, int y, int x, chtype ch, int n)
302 {
303 PDC_LOG(("mvwvline() - called\n"));
304
305 if (wmove(win, y, x) == ERR)
306 return ERR;
307
308 return wvline(win, ch, n);
309 }
310
311 #ifdef PDC_WIDE
312 int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
313 const cchar_t *ts, const cchar_t *bs, const cchar_t *tl,
314 const cchar_t *tr, const cchar_t *bl, const cchar_t *br)
315 {
316 PDC_LOG(("wborder_set() - called\n"));
317
318 return wborder(win, ls ? *ls : 0, rs ? *rs : 0, ts ? *ts : 0,
319 bs ? *bs : 0, tl ? *tl : 0, tr ? *tr : 0,
320 bl ? *bl : 0, br ? *br : 0);
321 }
322
323 int border_set(const cchar_t *ls, const cchar_t *rs, const cchar_t *ts,
324 const cchar_t *bs, const cchar_t *tl, const cchar_t *tr,
325 const cchar_t *bl, const cchar_t *br)
326 {
327 PDC_LOG(("border_set() - called\n"));
328
329 return wborder_set(stdscr, ls, rs, ts, bs, tl, tr, bl, br);
330 }
331
332 int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch)
333 {
334 PDC_LOG(("box_set() - called\n"));
335
336 return wborder_set(win, verch, verch, horch, horch,
337 (const cchar_t *)NULL, (const cchar_t *)NULL,
338 (const cchar_t *)NULL, (const cchar_t *)NULL);
339 }
340
341 int whline_set(WINDOW *win, const cchar_t *wch, int n)
342 {
343 PDC_LOG(("whline_set() - called\n"));
344
345 return wch ? whline(win, *wch, n) : ERR;
346 }
347
348 int hline_set(const cchar_t *wch, int n)
349 {
350 PDC_LOG(("hline_set() - called\n"));
351
352 return whline_set(stdscr, wch, n);
353 }
354
355 int mvhline_set(int y, int x, const cchar_t *wch, int n)
356 {
357 PDC_LOG(("mvhline_set() - called\n"));
358
359 if (move(y, x) == ERR)
360 return ERR;
361
362 return whline_set(stdscr, wch, n);
363 }
364
365 int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n)
366 {
367 PDC_LOG(("mvwhline_set() - called\n"));
368
369 if (wmove(win, y, x) == ERR)
370 return ERR;
371
372 return whline_set(win, wch, n);
373 }
374
375 int wvline_set(WINDOW *win, const cchar_t *wch, int n)
376 {
377 PDC_LOG(("wvline_set() - called\n"));
378
379 return wch ? wvline(win, *wch, n) : ERR;
380 }
381
382 int vline_set(const cchar_t *wch, int n)
383 {
384 PDC_LOG(("vline_set() - called\n"));
385
386 return wvline_set(stdscr, wch, n);
387 }
388
389 int mvvline_set(int y, int x, const cchar_t *wch, int n)
390 {
391 PDC_LOG(("mvvline_set() - called\n"));
392
393 if (move(y, x) == ERR)
394 return ERR;
395
396 return wvline_set(stdscr, wch, n);
397 }
398
399 int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n)
400 {
401 PDC_LOG(("mvwvline_set() - called\n"));
402
403 if (wmove(win, y, x) == ERR)
404 return ERR;
405
406 return wvline_set(win, wch, n);
407 }
408 #endif
File pdcurses/clear.c added (mode: 100644) (index 00000000..eda33855)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: clear.c,v 1.35 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: clear
10
11 Synopsis:
12 int clear(void);
13 int wclear(WINDOW *win);
14 int erase(void);
15 int werase(WINDOW *win);
16 int clrtobot(void);
17 int wclrtobot(WINDOW *win);
18 int clrtoeol(void);
19 int wclrtoeol(WINDOW *win);
20
21 Description:
22 erase() and werase() copy blanks (i.e. the background chtype) to
23 every cell of the window.
24
25 clear() and wclear() are similar to erase() and werase(), but
26 they also call clearok() to ensure that the the window is
27 cleared on the next wrefresh().
28
29 clrtobot() and wclrtobot() clear the window from the current
30 cursor position to the end of the window.
31
32 clrtoeol() and wclrtoeol() clear the window from the current
33 cursor position to the end of the current line.
34
35 Return Value:
36 All functions return OK on success and ERR on error.
37
38 Portability X/Open BSD SYS V
39 clear Y Y Y
40 wclear Y Y Y
41 erase Y Y Y
42 werase Y Y Y
43 clrtobot Y Y Y
44 wclrtobot Y Y Y
45 clrtoeol Y Y Y
46 wclrtoeol Y Y Y
47
48 **man-end****************************************************************/
49
50 int wclrtoeol(WINDOW *win)
51 {
52 int x, y, minx;
53 chtype blank, *ptr;
54
55 PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n",
56 win->_cury, win->_curx));
57
58 if (!win)
59 return ERR;
60
61 y = win->_cury;
62 x = win->_curx;
63
64 /* wrs (4/10/93) account for window background */
65
66 blank = win->_bkgd;
67
68 for (minx = x, ptr = &win->_y[y][x]; minx < win->_maxx; minx++, ptr++)
69 *ptr = blank;
70
71 if (x < win->_firstch[y] || win->_firstch[y] == _NO_CHANGE)
72 win->_firstch[y] = x;
73
74 win->_lastch[y] = win->_maxx - 1;
75
76 PDC_sync(win);
77 return OK;
78 }
79
80 int clrtoeol(void)
81 {
82 PDC_LOG(("clrtoeol() - called\n"));
83
84 return wclrtoeol(stdscr);
85 }
86
87 int wclrtobot(WINDOW *win)
88 {
89 int savey = win->_cury;
90 int savex = win->_curx;
91
92 PDC_LOG(("wclrtobot() - called\n"));
93
94 if (!win)
95 return ERR;
96
97 /* should this involve scrolling region somehow ? */
98
99 if (win->_cury + 1 < win->_maxy)
100 {
101 win->_curx = 0;
102 win->_cury++;
103 for (; win->_maxy > win->_cury; win->_cury++)
104 wclrtoeol(win);
105 win->_cury = savey;
106 win->_curx = savex;
107 }
108 wclrtoeol(win);
109
110 PDC_sync(win);
111 return OK;
112 }
113
114 int clrtobot(void)
115 {
116 PDC_LOG(("clrtobot() - called\n"));
117
118 return wclrtobot(stdscr);
119 }
120
121 int werase(WINDOW *win)
122 {
123 PDC_LOG(("werase() - called\n"));
124
125 if (wmove(win, 0, 0) == ERR)
126 return ERR;
127
128 return wclrtobot(win);
129 }
130
131 int erase(void)
132 {
133 PDC_LOG(("erase() - called\n"));
134
135 return werase(stdscr);
136 }
137
138 int wclear(WINDOW *win)
139 {
140 PDC_LOG(("wclear() - called\n"));
141
142 if (!win)
143 return ERR;
144
145 win->_clear = TRUE;
146 return werase(win);
147 }
148
149 int clear(void)
150 {
151 PDC_LOG(("clear() - called\n"));
152
153 return wclear(stdscr);
154 }
File pdcurses/color.c added (mode: 100644) (index 00000000..038f7604)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: color.c,v 1.83 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: color
10
11 Synopsis:
12 int start_color(void);
13 int init_pair(short pair, short fg, short bg);
14 int init_color(short color, short red, short green, short blue);
15 bool has_colors(void);
16 bool can_change_color(void);
17 int color_content(short color, short *red, short *green, short *blue);
18 int pair_content(short pair, short *fg, short *bg);
19
20 int assume_default_colors(int f, int b);
21 int use_default_colors(void);
22
23 int PDC_set_line_color(short color);
24
25 Description:
26 To use these routines, start_color() must be called, usually
27 immediately after initscr(). Colors are always used in pairs,
28 referred to as color-pairs. A color-pair consists of a
29 foreground color and a background color. A color-pair is
30 initialized via init_pair(). After initialization, COLOR_PAIR(n)
31 can be used like any other video attribute.
32
33 start_color() initializes eight basic colors (black, red, green,
34 yellow, blue, magenta, cyan, and white), and two global
35 variables; COLORS and COLOR_PAIRS (respectively defining the
36 maximum number of colors and color-pairs the terminal is capable
37 of displaying).
38
39 init_pair() changes the definition of a color-pair. It takes
40 three arguments: the number of the color-pair to be redefined,
41 and the new values of the foreground and background colors. The
42 pair number must be between 0 and COLOR_PAIRS - 1, inclusive.
43 The foreground and background must be between 0 and COLORS - 1,
44 inclusive. If the color pair was previously initialized, the
45 screen is refreshed, and all occurrences of that color-pair are
46 changed to the new definition.
47
48 has_colors() indicates if the terminal supports, and can
49 maniplulate color. It returns TRUE or FALSE.
50
51 can_change_color() indicates if the terminal has the capability
52 to change the definition of its colors.
53
54 pair_content() is used to determine what the colors of a given
55 color-pair consist of.
56
57 assume_default_colors() and use_default_colors() emulate the
58 ncurses extensions of the same names. assume_default_colors(f,
59 b) is essentially the same as init_pair(0, f, b) (which isn't
60 allowed); it redefines the default colors. use_default_colors()
61 allows the use of -1 as a foreground or background color with
62 init_pair(), and calls assume_default_colors(-1, -1); -1
63 represents the foreground or background color that the terminal
64 had at startup. If the environment variable PDC_ORIGINAL_COLORS
65 is set at the time start_color() is called, that's equivalent to
66 calling use_default_colors().
67
68 PDC_set_line_color() is used to set the color, globally, for
69 the color of the lines drawn for the attributes: A_UNDERLINE,
70 A_OVERLINE, A_LEFTLINE and A_RIGHTLINE. A value of -1 (the
71 default) indicates that the current foreground color should be
72 used.
73
74 NOTE: COLOR_PAIR() and PAIR_NUMBER() are implemented as macros.
75
76 Return Value:
77 All functions return OK on success and ERR on error, except for
78 has_colors() and can_change_colors(), which return TRUE or FALSE.
79
80 Portability X/Open BSD SYS V
81 start_color Y - 3.2
82 init_pair Y - 3.2
83 init_color Y - 3.2
84 has_colors Y - 3.2
85 can_change_color Y - 3.2
86 color_content Y - 3.2
87 pair_content Y - 3.2
88 assume_default_colors - - -
89 use_default_colors - - -
90 PDC_set_line_color - - -
91
92 **man-end****************************************************************/
93
94 #include <stdlib.h>
95 #include <string.h>
96
97 int COLORS = 0;
98 int COLOR_PAIRS = PDC_COLOR_PAIRS;
99
100 bool pdc_color_started = FALSE;
101
102 /* pair_set[] tracks whether a pair has been set via init_pair() */
103
104 static bool pair_set[PDC_COLOR_PAIRS];
105 static bool default_colors = FALSE;
106 static short first_col = 0;
107
108 int start_color(void)
109 {
110 PDC_LOG(("start_color() - called\n"));
111
112 if (SP->mono)
113 return ERR;
114
115 pdc_color_started = TRUE;
116
117 PDC_set_blink(FALSE); /* Also sets COLORS, to 8 or 16 */
118
119 if (!default_colors && SP->orig_attr && getenv("PDC_ORIGINAL_COLORS"))
120 default_colors = TRUE;
121
122 PDC_init_atrtab();
123
124 memset(pair_set, 0, PDC_COLOR_PAIRS);
125
126 return OK;
127 }
128
129 static void _normalize(short *fg, short *bg)
130 {
131 if (*fg == -1)
132 *fg = SP->orig_attr ? SP->orig_fore : COLOR_WHITE;
133
134 if (*bg == -1)
135 *bg = SP->orig_attr ? SP->orig_back : COLOR_BLACK;
136 }
137
138 int init_pair(short pair, short fg, short bg)
139 {
140 PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
141
142 if (!pdc_color_started || pair < 1 || pair >= COLOR_PAIRS ||
143 fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS)
144 return ERR;
145
146 _normalize(&fg, &bg);
147
148 /* To allow the PDC_PRESERVE_SCREEN option to work, we only reset
149 curscr if this call to init_pair() alters a color pair created by
150 the user. */
151
152 if (pair_set[pair])
153 {
154 short oldfg, oldbg;
155
156 PDC_pair_content(pair, &oldfg, &oldbg);
157
158 if (oldfg != fg || oldbg != bg)
159 curscr->_clear = TRUE;
160 }
161
162 PDC_init_pair(pair, fg, bg);
163
164 pair_set[pair] = TRUE;
165
166 return OK;
167 }
168
169 bool has_colors(void)
170 {
171 PDC_LOG(("has_colors() - called\n"));
172
173 return !(SP->mono);
174 }
175
176 int init_color(short color, short red, short green, short blue)
177 {
178 PDC_LOG(("init_color() - called\n"));
179
180 if (color < 0 || color >= COLORS || !PDC_can_change_color() ||
181 red < 0 || red > 1000 || green < 0 || green > 1000 ||
182 blue < 0 || blue > 1000)
183 return ERR;
184
185 return PDC_init_color(color, red, green, blue);
186 }
187
188 int color_content(short color, short *red, short *green, short *blue)
189 {
190 PDC_LOG(("color_content() - called\n"));
191
192 if (color < 0 || color >= COLORS || !red || !green || !blue)
193 return ERR;
194
195 if (PDC_can_change_color())
196 return PDC_color_content(color, red, green, blue);
197 else
198 {
199 /* Simulated values for platforms that don't support palette
200 changing */
201
202 short maxval = (color & 8) ? 1000 : 680;
203
204 *red = (color & COLOR_RED) ? maxval : 0;
205 *green = (color & COLOR_GREEN) ? maxval : 0;
206 *blue = (color & COLOR_BLUE) ? maxval : 0;
207
208 return OK;
209 }
210 }
211
212 bool can_change_color(void)
213 {
214 PDC_LOG(("can_change_color() - called\n"));
215
216 return PDC_can_change_color();
217 }
218
219 int pair_content(short pair, short *fg, short *bg)
220 {
221 PDC_LOG(("pair_content() - called\n"));
222
223 if (pair < 0 || pair >= COLOR_PAIRS || !fg || !bg)
224 return ERR;
225
226 return PDC_pair_content(pair, fg, bg);
227 }
228
229 int assume_default_colors(int f, int b)
230 {
231 PDC_LOG(("assume_default_colors() - called: f %d b %d\n", f, b));
232
233 if (f < -1 || f >= COLORS || b < -1 || b >= COLORS)
234 return ERR;
235
236 if (pdc_color_started)
237 {
238 short fg, bg, oldfg, oldbg;
239
240 fg = f;
241 bg = b;
242
243 _normalize(&fg, &bg);
244
245 PDC_pair_content(0, &oldfg, &oldbg);
246
247 if (oldfg != fg || oldbg != bg)
248 curscr->_clear = TRUE;
249
250 PDC_init_pair(0, fg, bg);
251 }
252
253 return OK;
254 }
255
256 int use_default_colors(void)
257 {
258 PDC_LOG(("use_default_colors() - called\n"));
259
260 default_colors = TRUE;
261 first_col = -1;
262
263 return assume_default_colors(-1, -1);
264 }
265
266 int PDC_set_line_color(short color)
267 {
268 PDC_LOG(("PDC_set_line_color() - called: %d\n", color));
269
270 if (color < -1 || color >= COLORS)
271 return ERR;
272
273 SP->line_color = color;
274
275 return OK;
276 }
277
278 void PDC_init_atrtab(void)
279 {
280 int i;
281 short fg, bg;
282
283 if (pdc_color_started && !default_colors)
284 {
285 fg = COLOR_WHITE;
286 bg = COLOR_BLACK;
287 }
288 else
289 fg = bg = -1;
290
291 _normalize(&fg, &bg);
292
293 for (i = 0; i < PDC_COLOR_PAIRS; i++)
294 PDC_init_pair(i, fg, bg);
295 }
File pdcurses/debug.c added (mode: 100644) (index 00000000..95dc7d44)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: debug.c,v 1.7 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: debug
10
11 Synopsis:
12 void traceon(void);
13 void traceoff(void);
14 void PDC_debug(const char *, ...);
15
16 Description:
17 traceon() and traceoff() toggle the recording of debugging
18 information to the file "trace". Although not standard, similar
19 functions are in some other curses implementations.
20
21 PDC_debug() is the function that writes to the file, based on
22 whether traceon() has been called. It's used from the PDC_LOG()
23 macro.
24
25 Portability X/Open BSD SYS V
26 traceon - - -
27 traceoff - - -
28 PDC_debug - - -
29
30 **man-end****************************************************************/
31
32 #include <string.h>
33 #include <sys/types.h>
34 #include <time.h>
35
36 bool pdc_trace_on = FALSE;
37
38 void PDC_debug(const char *fmt, ...)
39 {
40 va_list args;
41 FILE *dbfp;
42 char hms[9];
43 time_t now;
44
45 if (!pdc_trace_on)
46 return;
47
48 /* open debug log file append */
49
50 dbfp = fopen("trace", "a");
51 if (!dbfp)
52 {
53 fprintf(stderr,
54 "PDC_debug(): Unable to open debug log file\n");
55 return;
56 }
57
58 time(&now);
59 strftime(hms, 9, "%H:%M:%S", localtime(&now));
60 fprintf(dbfp, "At: %8.8ld - %s ", (long) clock(), hms);
61
62 va_start(args, fmt);
63 vfprintf(dbfp, fmt, args);
64 va_end(args);
65
66 fclose(dbfp);
67 }
68
69 void traceon(void)
70 {
71 PDC_LOG(("traceon() - called\n"));
72
73 pdc_trace_on = TRUE;
74 }
75
76 void traceoff(void)
77 {
78 PDC_LOG(("traceoff() - called\n"));
79
80 pdc_trace_on = FALSE;
81 }
File pdcurses/delch.c added (mode: 100644) (index 00000000..9c2416ee)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: delch.c,v 1.33 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: delch
10
11 Synopsis:
12 int delch(void);
13 int wdelch(WINDOW *win);
14 int mvdelch(int y, int x);
15 int mvwdelch(WINDOW *win, int y, int x);
16
17 Description:
18 The character under the cursor in the window is deleted. All
19 characters to the right on the same line are moved to the left
20 one position and the last character on the line is filled with
21 a blank. The cursor position does not change (after moving to
22 y, x if coordinates are specified).
23
24 Return Value:
25 All functions return OK on success and ERR on error.
26
27 Portability X/Open BSD SYS V
28 delch Y Y Y
29 wdelch Y Y Y
30 mvdelch Y Y Y
31 mvwdelch Y Y Y
32
33 **man-end****************************************************************/
34
35 #include <string.h>
36
37 int wdelch(WINDOW *win)
38 {
39 int y, x, maxx;
40 chtype *temp1;
41
42 PDC_LOG(("wdelch() - called\n"));
43
44 if (!win)
45 return ERR;
46
47 y = win->_cury;
48 x = win->_curx;
49 maxx = win->_maxx - 1;
50 temp1 = &win->_y[y][x];
51
52 memmove(temp1, temp1 + 1, (maxx - x) * sizeof(chtype));
53
54 /* wrs (4/10/93) account for window background */
55
56 win->_y[y][maxx] = win->_bkgd;
57
58 win->_lastch[y] = maxx;
59
60 if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
61 win->_firstch[y] = x;
62
63 PDC_sync(win);
64
65 return OK;
66 }
67
68 int delch(void)
69 {
70 PDC_LOG(("delch() - called\n"));
71
72 return wdelch(stdscr);
73 }
74
75 int mvdelch(int y, int x)
76 {
77 PDC_LOG(("mvdelch() - called\n"));
78
79 if (move(y, x) == ERR)
80 return ERR;
81
82 return wdelch(stdscr);
83 }
84
85 int mvwdelch(WINDOW *win, int y, int x)
86 {
87 PDC_LOG(("mvwdelch() - called\n"));
88
89 if (wmove(win, y, x) == ERR)
90 return ERR;
91
92 return wdelch(win);
93 }
File pdcurses/deleteln.c added (mode: 100644) (index 00000000..c856e90a)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: deleteln.c,v 1.35 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: deleteln
10
11 Synopsis:
12 int deleteln(void);
13 int wdeleteln(WINDOW *win);
14 int insdelln(int n);
15 int winsdelln(WINDOW *win, int n);
16 int insertln(void);
17 int winsertln(WINDOW *win);
18
19 int mvdeleteln(int y, int x);
20 int mvwdeleteln(WINDOW *win, int y, int x);
21 int mvinsertln(int y, int x);
22 int mvwinsertln(WINDOW *win, int y, int x);
23
24 Description:
25 With the deleteln() and wdeleteln() functions, the line under
26 the cursor in the window is deleted. All lines below the
27 current line are moved up one line. The bottom line of the
28 window is cleared. The cursor position does not change.
29
30 With the insertln() and winsertn() functions, a blank line is
31 inserted above the current line and the bottom line is lost.
32
33 mvdeleteln(), mvwdeleteln(), mvinsertln() and mvwinsertln()
34 allow moving the cursor and inserting/deleting in one call.
35
36 Return Value:
37 All functions return OK on success and ERR on error.
38
39 Portability X/Open BSD SYS V
40 deleteln Y Y Y
41 wdeleteln Y Y Y
42 mvdeleteln - - -
43 mvwdeleteln - - -
44 insdelln Y - 4.0
45 winsdelln Y - 4.0
46 insertln Y Y Y
47 winsertln Y Y Y
48 mvinsertln - - -
49 mvwinsertln - - -
50
51 **man-end****************************************************************/
52
53 int wdeleteln(WINDOW *win)
54 {
55 chtype blank, *temp, *ptr;
56 int y;
57
58 PDC_LOG(("wdeleteln() - called\n"));
59
60 if (!win)
61 return ERR;
62
63 /* wrs (4/10/93) account for window background */
64
65 blank = win->_bkgd;
66
67 temp = win->_y[win->_cury];
68
69 for (y = win->_cury; y < win->_bmarg; y++)
70 {
71 win->_y[y] = win->_y[y + 1];
72 win->_firstch[y] = 0;
73 win->_lastch[y] = win->_maxx - 1;
74 }
75
76 for (ptr = temp; (ptr - temp < win->_maxx); ptr++)
77 *ptr = blank; /* make a blank line */
78
79 if (win->_cury <= win->_bmarg)
80 {
81 win->_firstch[win->_bmarg] = 0;
82 win->_lastch[win->_bmarg] = win->_maxx - 1;
83 win->_y[win->_bmarg] = temp;
84 }
85
86 return OK;
87 }
88
89 int deleteln(void)
90 {
91 PDC_LOG(("deleteln() - called\n"));
92
93 return wdeleteln(stdscr);
94 }
95
96 int mvdeleteln(int y, int x)
97 {
98 PDC_LOG(("mvdeleteln() - called\n"));
99
100 if (move(y, x) == ERR)
101 return ERR;
102
103 return wdeleteln(stdscr);
104 }
105
106 int mvwdeleteln(WINDOW *win, int y, int x)
107 {
108 PDC_LOG(("mvwdeleteln() - called\n"));
109
110 if (wmove(win, y, x) == ERR)
111 return ERR;
112
113 return wdeleteln(win);
114 }
115
116 int winsdelln(WINDOW *win, int n)
117 {
118 int i;
119
120 PDC_LOG(("winsdelln() - called\n"));
121
122 if (!win)
123 return ERR;
124
125 if (n > 0)
126 {
127 for (i = 0; i < n; i++)
128 if (winsertln(win) == ERR)
129 return ERR;
130 }
131 else if (n < 0)
132 {
133 n = -n;
134 for (i = 0; i < n; i++)
135 if (wdeleteln(win) == ERR)
136 return ERR;
137 }
138
139 return OK;
140 }
141
142 int insdelln(int n)
143 {
144 PDC_LOG(("insdelln() - called\n"));
145
146 return winsdelln(stdscr, n);
147 }
148
149 int winsertln(WINDOW *win)
150 {
151 chtype blank, *temp, *end;
152 int y;
153
154 PDC_LOG(("winsertln() - called\n"));
155
156 if (!win)
157 return ERR;
158
159 /* wrs (4/10/93) account for window background */
160
161 blank = win->_bkgd;
162
163 temp = win->_y[win->_maxy - 1];
164
165 for (y = win->_maxy - 1; y > win->_cury; y--)
166 {
167 win->_y[y] = win->_y[y - 1];
168 win->_firstch[y] = 0;
169 win->_lastch[y] = win->_maxx - 1;
170 }
171
172 win->_y[win->_cury] = temp;
173
174 for (end = &temp[win->_maxx - 1]; temp <= end; temp++)
175 *temp = blank;
176
177 win->_firstch[win->_cury] = 0;
178 win->_lastch[win->_cury] = win->_maxx - 1;
179
180 return OK;
181 }
182
183 int insertln(void)
184 {
185 PDC_LOG(("insertln() - called\n"));
186
187 return winsertln(stdscr);
188 }
189
190 int mvinsertln(int y, int x)
191 {
192 PDC_LOG(("mvinsertln() - called\n"));
193
194 if (move(y, x) == ERR)
195 return ERR;
196
197 return winsertln(stdscr);
198 }
199
200 int mvwinsertln(WINDOW *win, int y, int x)
201 {
202 PDC_LOG(("mvwinsertln() - called\n"));
203
204 if (wmove(win, y, x) == ERR)
205 return ERR;
206
207 return winsertln(win);
208 }
File pdcurses/deprec.c added (mode: 100644) (index 00000000..83e61311)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: deprec.c,v 1.6 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /* Deprecated functions. These should not be used, and will eventually
8 be removed. They're here solely for the benefit of applications that
9 linked to them in older versions of PDCurses. */
10
11 bool PDC_check_bios_key(void)
12 {
13 return PDC_check_key();
14 }
15
16 int PDC_get_bios_key(void)
17 {
18 return PDC_get_key();
19 }
20
21 bool PDC_get_ctrl_break(void)
22 {
23 return !SP->raw_inp;
24 }
25
26 int PDC_set_ctrl_break(bool setting)
27 {
28 return setting ? noraw() : raw();
29 }
File pdcurses/getch.c added (mode: 100644) (index 00000000..87677bae)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: getch.c,v 1.72 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: getch
10
11 Synopsis:
12 int getch(void);
13 int wgetch(WINDOW *win);
14 int mvgetch(int y, int x);
15 int mvwgetch(WINDOW *win, int y, int x);
16 int ungetch(int ch);
17 int flushinp(void);
18
19 int get_wch(wint_t *wch);
20 int wget_wch(WINDOW *win, wint_t *wch);
21 int mvget_wch(int y, int x, wint_t *wch);
22 int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch);
23 int unget_wch(const wchar_t wch);
24
25 unsigned long PDC_get_key_modifiers(void);
26 int PDC_save_key_modifiers(bool flag);
27 int PDC_return_key_modifiers(bool flag);
28
29 Description:
30 With the getch(), wgetch(), mvgetch(), and mvwgetch() functions,
31 a character is read from the terminal associated with the window.
32 In nodelay mode, if there is no input waiting, the value ERR is
33 returned. In delay mode, the program will hang until the system
34 passes text through to the program. Depending on the setting of
35 cbreak(), this will be after one character or after the first
36 newline. Unless noecho() has been set, the character will also
37 be echoed into the designated window.
38
39 If keypad() is TRUE, and a function key is pressed, the token for
40 that function key will be returned instead of the raw characters.
41 Possible function keys are defined in <curses.h> with integers
42 beginning with 0401, whose names begin with KEY_.
43
44 If nodelay(win, TRUE) has been called on the window and no input
45 is waiting, the value ERR is returned.
46
47 ungetch() places ch back onto the input queue to be returned by
48 the next call to wgetch().
49
50 flushinp() throws away any type-ahead that has been typed by the
51 user and has not yet been read by the program.
52
53 PDC_get_key_modifiers() returns the keyboard modifiers (shift,
54 control, alt, numlock) effective at the time of the last getch()
55 call, if PDC_save_key_modifiers(TRUE) has been called before the
56 getch(). Use the macros PDC_KEY_MODIFIER_* to determine which
57 modifier(s) were set. PDC_return_key_modifiers() tells getch()
58 to return modifier keys pressed alone as keystrokes (KEY_ALT_L,
59 etc.). These may not work on all platforms.
60
61 NOTE: getch() and ungetch() are implemented as macros, to avoid
62 conflict with many DOS compiler's runtime libraries.
63
64 Return Value:
65 These functions return ERR or the value of the character, meta
66 character or function key token.
67
68 Portability X/Open BSD SYS V
69 getch Y Y Y
70 wgetch Y Y Y
71 mvgetch Y Y Y
72 mvwgetch Y Y Y
73 ungetch Y Y Y
74 flushinp Y Y Y
75 get_wch Y
76 wget_wch Y
77 mvget_wch Y
78 mvwget_wch Y
79 unget_wch Y
80 PDC_get_key_modifiers - - -
81
82 **man-end****************************************************************/
83
84 #define _INBUFSIZ 512 /* size of terminal input buffer */
85 #define NUNGETCH 256 /* max # chars to ungetch() */
86
87 static int c_pindex = 0; /* putter index */
88 static int c_gindex = 1; /* getter index */
89 static int c_ungind = 0; /* ungetch() push index */
90 static int c_ungch[NUNGETCH]; /* array of ungotten chars */
91
92 static int _mouse_key(WINDOW *win)
93 {
94 int i, key = KEY_MOUSE;
95 unsigned long mbe = SP->_trap_mbe;
96
97 /* Filter unwanted mouse events */
98
99 for (i = 0; i < 3; i++)
100 {
101 if (pdc_mouse_status.changes & (1 << i))
102 {
103 int shf = i * 5;
104 short button = pdc_mouse_status.button[i] & BUTTON_ACTION_MASK;
105
106 if ( (!(mbe & (BUTTON1_PRESSED << shf)) &&
107 (button == BUTTON_PRESSED))
108
109 || (!(mbe & (BUTTON1_CLICKED << shf)) &&
110 (button == BUTTON_CLICKED))
111
112 || (!(mbe & (BUTTON1_DOUBLE_CLICKED << shf)) &&
113 (button == BUTTON_DOUBLE_CLICKED))
114
115 || (!(mbe & (BUTTON1_MOVED << shf)) &&
116 (button == BUTTON_MOVED))
117
118 || (!(mbe & (BUTTON1_RELEASED << shf)) &&
119 (button == BUTTON_RELEASED))
120 )
121 pdc_mouse_status.changes ^= (1 << i);
122 }
123 }
124
125 if (pdc_mouse_status.changes & PDC_MOUSE_MOVED)
126 {
127 if (!(mbe & (BUTTON1_MOVED|BUTTON2_MOVED|BUTTON3_MOVED)))
128 pdc_mouse_status.changes ^= PDC_MOUSE_MOVED;
129 }
130
131 if (pdc_mouse_status.changes &
132 (PDC_MOUSE_WHEEL_UP|PDC_MOUSE_WHEEL_DOWN))
133 {
134 if (!(mbe & MOUSE_WHEEL_SCROLL))
135 pdc_mouse_status.changes &=
136 ~(PDC_MOUSE_WHEEL_UP|PDC_MOUSE_WHEEL_DOWN);
137 }
138
139 if (!pdc_mouse_status.changes)
140 return -1;
141
142 /* Check for click in slk area */
143
144 i = PDC_mouse_in_slk(pdc_mouse_status.y, pdc_mouse_status.x);
145
146 if (i)
147 {
148 if (pdc_mouse_status.button[0] & (BUTTON_PRESSED|BUTTON_CLICKED))
149 key = KEY_F(i);
150 else
151 key = -1;
152 }
153
154 return key;
155 }
156
157 int wgetch(WINDOW *win)
158 {
159 static int buffer[_INBUFSIZ]; /* character buffer */
160 int key, waitcount;
161
162 PDC_LOG(("wgetch() - called\n"));
163
164 if (!win)
165 return ERR;
166
167 waitcount = 0;
168
169 /* set the number of 1/20th second napms() calls */
170
171 if (SP->delaytenths)
172 waitcount = 2 * SP->delaytenths;
173 else
174 if (win->_delayms)
175 {
176 /* Can't really do millisecond intervals, so delay in
177 1/20ths of a second (50ms) */
178
179 waitcount = win->_delayms / 50;
180 if (!waitcount)
181 waitcount = 1;
182 }
183
184 /* refresh window when wgetch is called if there have been changes
185 to it and it is not a pad */
186
187 if (!(win->_flags & _PAD) && ((!win->_leaveit &&
188 (win->_begx + win->_curx != SP->curscol ||
189 win->_begy + win->_cury != SP->cursrow)) || is_wintouched(win)))
190 wrefresh(win);
191
192 /* if ungotten char exists, remove and return it */
193
194 if (c_ungind)
195 return c_ungch[--c_ungind];
196
197 /* if normal and data in buffer */
198
199 if ((!SP->raw_inp && !SP->cbreak) && (c_gindex < c_pindex))
200 return buffer[c_gindex++];
201
202 /* prepare to buffer data */
203
204 c_pindex = 0;
205 c_gindex = 0;
206
207 /* to get here, no keys are buffered. go and get one. */
208
209 for (;;) /* loop for any buffering */
210 {
211 /* is there a keystroke ready? */
212
213 if (!PDC_check_key())
214 {
215 /* if not, handle timeout() and halfdelay() */
216
217 if (SP->delaytenths || win->_delayms)
218 {
219 if (!waitcount)
220 return ERR;
221
222 waitcount--;
223 }
224 else
225 if (win->_nodelay)
226 return ERR;
227
228 napms(50); /* sleep for 1/20th second */
229 continue; /* then check again */
230 }
231
232 /* if there is, fetch it */
233
234 key = PDC_get_key();
235
236 if (SP->key_code)
237 {
238 /* filter special keys if not in keypad mode */
239
240 if (!win->_use_keypad)
241 key = -1;
242
243 /* filter mouse events; translate mouse clicks in the slk
244 area to function keys */
245
246 else if (key == KEY_MOUSE)
247 key = _mouse_key(win);
248 }
249
250 /* unwanted key? loop back */
251
252 if (key == -1)
253 continue;
254
255 /* translate CR */
256
257 if (key == '\r' && SP->autocr && !SP->raw_inp)
258 key = '\n';
259
260 /* if echo is enabled */
261
262 if (SP->echo && !SP->key_code)
263 {
264 waddch(win, key);
265 wrefresh(win);
266 }
267
268 /* if no buffering */
269
270 if (SP->raw_inp || SP->cbreak)
271 return key;
272
273 /* if no overflow, put data in buffer */
274
275 if (key == '\b')
276 {
277 if (c_pindex > c_gindex)
278 c_pindex--;
279 }
280 else
281 if (c_pindex < _INBUFSIZ - 2)
282 buffer[c_pindex++] = key;
283
284 /* if we got a line */
285
286 if (key == '\n' || key == '\r')
287 return buffer[c_gindex++];
288 }
289 }
290
291 int mvgetch(int y, int x)
292 {
293 PDC_LOG(("mvgetch() - called\n"));
294
295 if (move(y, x) == ERR)
296 return ERR;
297
298 return wgetch(stdscr);
299 }
300
301 int mvwgetch(WINDOW *win, int y, int x)
302 {
303 PDC_LOG(("mvwgetch() - called\n"));
304
305 if (wmove(win, y, x) == ERR)
306 return ERR;
307
308 return wgetch(win);
309 }
310
311 int PDC_ungetch(int ch)
312 {
313 PDC_LOG(("ungetch() - called\n"));
314
315 if (c_ungind >= NUNGETCH) /* pushback stack full */
316 return ERR;
317
318 c_ungch[c_ungind++] = ch;
319
320 return OK;
321 }
322
323 int flushinp(void)
324 {
325 PDC_LOG(("flushinp() - called\n"));
326
327 PDC_flushinp();
328
329 c_gindex = 1; /* set indices to kill buffer */
330 c_pindex = 0;
331 c_ungind = 0; /* clear c_ungch array */
332
333 return OK;
334 }
335
336 unsigned long PDC_get_key_modifiers(void)
337 {
338 PDC_LOG(("PDC_get_key_modifiers() - called\n"));
339
340 return pdc_key_modifiers;
341 }
342
343 int PDC_save_key_modifiers(bool flag)
344 {
345 PDC_LOG(("PDC_save_key_modifiers() - called\n"));
346
347 SP->save_key_modifiers = flag;
348 return OK;
349 }
350
351 int PDC_return_key_modifiers(bool flag)
352 {
353 PDC_LOG(("PDC_return_key_modifiers() - called\n"));
354
355 SP->return_key_modifiers = flag;
356 return PDC_modifiers_set();
357 }
358
359 #ifdef PDC_WIDE
360 int wget_wch(WINDOW *win, wint_t *wch)
361 {
362 int key;
363
364 PDC_LOG(("wget_wch() - called\n"));
365
366 if (!wch)
367 return ERR;
368
369 key = wgetch(win);
370
371 if (key == ERR)
372 return ERR;
373
374 *wch = key;
375
376 return SP->key_code ? KEY_CODE_YES : OK;
377 }
378
379 int get_wch(wint_t *wch)
380 {
381 PDC_LOG(("get_wch() - called\n"));
382
383 return wget_wch(stdscr, wch);
384 }
385
386 int mvget_wch(int y, int x, wint_t *wch)
387 {
388 PDC_LOG(("mvget_wch() - called\n"));
389
390 if (move(y, x) == ERR)
391 return ERR;
392
393 return wget_wch(stdscr, wch);
394 }
395
396 int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch)
397 {
398 PDC_LOG(("mvwget_wch() - called\n"));
399
400 if (wmove(win, y, x) == ERR)
401 return ERR;
402
403 return wget_wch(win, wch);
404 }
405
406 int unget_wch(const wchar_t wch)
407 {
408 return PDC_ungetch(wch);
409 }
410 #endif
File pdcurses/getstr.c added (mode: 100644) (index 00000000..c6386d31)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: getstr.c,v 1.51 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: getstr
10
11 Synopsis:
12 int getstr(char *str);
13 int wgetstr(WINDOW *win, char *str);
14 int mvgetstr(int y, int x, char *str);
15 int mvwgetstr(WINDOW *win, int y, int x, char *str);
16 int getnstr(char *str, int n);
17 int wgetnstr(WINDOW *win, char *str, int n);
18 int mvgetnstr(int y, int x, char *str, int n);
19 int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n);
20
21 int get_wstr(wint_t *wstr);
22 int wget_wstr(WINDOW *win, wint_t *wstr);
23 int mvget_wstr(int y, int x, wint_t *wstr);
24 int mvwget_wstr(WINDOW *win, int, int, wint_t *wstr);
25 int getn_wstr(wint_t *wstr, int n);
26 int wgetn_wstr(WINDOW *win, wint_t *wstr, int n);
27 int mvgetn_wstr(int y, int x, wint_t *wstr, int n);
28 int mvwgetn_wstr(WINDOW *win, int y, int x, wint_t *wstr, int n);
29
30 Description:
31 These routines call wgetch() repeatedly to build a string,
32 interpreting erase and kill characters along the way, until a
33 newline or carriage return is received. When PDCurses is built
34 with wide-character support enabled, the narrow-character
35 functions convert the wgetch()'d values into a multibyte string
36 in the current locale before returning it. The resulting string
37 is placed in the area pointed to by *str. The routines with n as
38 the last argument read at most n characters.
39
40 Note that there's no way to know how long the buffer passed to
41 wgetstr() is, so use wgetnstr() to avoid buffer overflows.
42
43 Return Value:
44 This functions return ERR on failure or any other value on
45 success.
46
47 Portability X/Open BSD SYS V
48 getstr Y Y Y
49 wgetstr Y Y Y
50 mvgetstr Y Y Y
51 mvwgetstr Y Y Y
52 getnstr Y - 4.0
53 wgetnstr Y - 4.0
54 mvgetnstr Y - -
55 mvwgetnstr Y - -
56 get_wstr Y
57 wget_wstr Y
58 mvget_wstr Y
59 mvwget_wstr Y
60 getn_wstr Y
61 wgetn_wstr Y
62 mvgetn_wstr Y
63 mvwgetn_wstr Y
64
65 **man-end****************************************************************/
66
67 #define MAXLINE 255
68
69 int wgetnstr(WINDOW *win, char *str, int n)
70 {
71 #ifdef PDC_WIDE
72 wchar_t wstr[MAXLINE + 1];
73
74 if (n < 0 || n > MAXLINE)
75 n = MAXLINE;
76
77 if (wgetn_wstr(win, (wint_t *)wstr, n) == ERR)
78 return ERR;
79
80 return PDC_wcstombs(str, wstr, n);
81 #else
82 int ch, i, num, x, chars;
83 char *p;
84 bool stop, oldecho, oldcbreak, oldnodelay;
85
86 PDC_LOG(("wgetnstr() - called\n"));
87
88 if (!win || !str)
89 return ERR;
90
91 chars = 0;
92 p = str;
93 stop = FALSE;
94
95 x = win->_curx;
96
97 oldcbreak = SP->cbreak; /* remember states */
98 oldecho = SP->echo;
99 oldnodelay = win->_nodelay;
100
101 SP->echo = FALSE; /* we do echo ourselves */
102 cbreak(); /* ensure each key is returned immediately */
103 win->_nodelay = FALSE; /* don't return -1 */
104
105 wrefresh(win);
106
107 while (!stop)
108 {
109 ch = wgetch(win);
110
111 switch (ch)
112 {
113
114 case '\t':
115 ch = ' ';
116 num = TABSIZE - (win->_curx - x) % TABSIZE;
117 for (i = 0; i < num; i++)
118 {
119 if (chars < n)
120 {
121 if (oldecho)
122 waddch(win, ch);
123 *p++ = ch;
124 ++chars;
125 }
126 else
127 beep();
128 }
129 break;
130
131 case _ECHAR: /* CTRL-H -- Delete character */
132 if (p > str)
133 {
134 if (oldecho)
135 waddstr(win, "\b \b");
136 ch = (unsigned char)(*--p);
137 if ((ch < ' ') && (oldecho))
138 waddstr(win, "\b \b");
139 chars--;
140 }
141 break;
142
143 case _DLCHAR: /* CTRL-U -- Delete line */
144 while (p > str)
145 {
146 if (oldecho)
147 waddstr(win, "\b \b");
148 ch = (unsigned char)(*--p);
149 if ((ch < ' ') && (oldecho))
150 waddstr(win, "\b \b");
151 }
152 chars = 0;
153 break;
154
155 case _DWCHAR: /* CTRL-W -- Delete word */
156
157 while ((p > str) && (*(p - 1) == ' '))
158 {
159 if (oldecho)
160 waddstr(win, "\b \b");
161
162 --p; /* remove space */
163 chars--;
164 }
165 while ((p > str) && (*(p - 1) != ' '))
166 {
167 if (oldecho)
168 waddstr(win, "\b \b");
169
170 ch = (unsigned char)(*--p);
171 if ((ch < ' ') && (oldecho))
172 waddstr(win, "\b \b");
173 chars--;
174 }
175 break;
176
177 case '\n':
178 case '\r':
179 stop = TRUE;
180 if (oldecho)
181 waddch(win, '\n');
182 break;
183
184 default:
185 if (chars < n)
186 {
187 if (!SP->key_code && ch < 0x100)
188 {
189 *p++ = ch;
190 if (oldecho)
191 waddch(win, ch);
192 chars++;
193 }
194 }
195 else
196 beep();
197
198 break;
199
200 }
201
202 wrefresh(win);
203 }
204
205 *p = '\0';
206
207 SP->echo = oldecho; /* restore old settings */
208 SP->cbreak = oldcbreak;
209 win->_nodelay = oldnodelay;
210
211 return OK;
212 #endif
213 }
214
215 int getstr(char *str)
216 {
217 PDC_LOG(("getstr() - called\n"));
218
219 return wgetnstr(stdscr, str, MAXLINE);
220 }
221
222 int wgetstr(WINDOW *win, char *str)
223 {
224 PDC_LOG(("wgetstr() - called\n"));
225
226 return wgetnstr(win, str, MAXLINE);
227 }
228
229 int mvgetstr(int y, int x, char *str)
230 {
231 PDC_LOG(("mvgetstr() - called\n"));
232
233 if (move(y, x) == ERR)
234 return ERR;
235
236 return wgetnstr(stdscr, str, MAXLINE);
237 }
238
239 int mvwgetstr(WINDOW *win, int y, int x, char *str)
240 {
241 PDC_LOG(("mvwgetstr() - called\n"));
242
243 if (wmove(win, y, x) == ERR)
244 return ERR;
245
246 return wgetnstr(win, str, MAXLINE);
247 }
248
249 int getnstr(char *str, int n)
250 {
251 PDC_LOG(("getnstr() - called\n"));
252
253 return wgetnstr(stdscr, str, n);
254 }
255
256 int mvgetnstr(int y, int x, char *str, int n)
257 {
258 PDC_LOG(("mvgetnstr() - called\n"));
259
260 if (move(y, x) == ERR)
261 return ERR;
262
263 return wgetnstr(stdscr, str, n);
264 }
265
266 int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n)
267 {
268 PDC_LOG(("mvwgetnstr() - called\n"));
269
270 if (wmove(win, y, x) == ERR)
271 return ERR;
272
273 return wgetnstr(win, str, n);
274 }
275
276 #ifdef PDC_WIDE
277 int wgetn_wstr(WINDOW *win, wint_t *wstr, int n)
278 {
279 int ch, i, num, x, chars;
280 wint_t *p;
281 bool stop, oldecho, oldcbreak, oldnodelay;
282
283 PDC_LOG(("wgetn_wstr() - called\n"));
284
285 if (!win || !wstr)
286 return ERR;
287
288 chars = 0;
289 p = wstr;
290 stop = FALSE;
291
292 x = win->_curx;
293
294 oldcbreak = SP->cbreak; /* remember states */
295 oldecho = SP->echo;
296 oldnodelay = win->_nodelay;
297
298 SP->echo = FALSE; /* we do echo ourselves */
299 cbreak(); /* ensure each key is returned immediately */
300 win->_nodelay = FALSE; /* don't return -1 */
301
302 wrefresh(win);
303
304 while (!stop)
305 {
306 ch = wgetch(win);
307
308 switch (ch)
309 {
310
311 case '\t':
312 ch = ' ';
313 num = TABSIZE - (win->_curx - x) % TABSIZE;
314 for (i = 0; i < num; i++)
315 {
316 if (chars < n)
317 {
318 if (oldecho)
319 waddch(win, ch);
320 *p++ = ch;
321 ++chars;
322 }
323 else
324 beep();
325 }
326 break;
327
328 case _ECHAR: /* CTRL-H -- Delete character */
329 if (p > wstr)
330 {
331 if (oldecho)
332 waddstr(win, "\b \b");
333 ch = *--p;
334 if ((ch < ' ') && (oldecho))
335 waddstr(win, "\b \b");
336 chars--;
337 }
338 break;
339
340 case _DLCHAR: /* CTRL-U -- Delete line */
341 while (p > wstr)
342 {
343 if (oldecho)
344 waddstr(win, "\b \b");
345 ch = *--p;
346 if ((ch < ' ') && (oldecho))
347 waddstr(win, "\b \b");
348 }
349 chars = 0;
350 break;
351
352 case _DWCHAR: /* CTRL-W -- Delete word */
353
354 while ((p > wstr) && (*(p - 1) == ' '))
355 {
356 if (oldecho)
357 waddstr(win, "\b \b");
358
359 --p; /* remove space */
360 chars--;
361 }
362 while ((p > wstr) && (*(p - 1) != ' '))
363 {
364 if (oldecho)
365 waddstr(win, "\b \b");
366
367 ch = *--p;
368 if ((ch < ' ') && (oldecho))
369 waddstr(win, "\b \b");
370 chars--;
371 }
372 break;
373
374 case '\n':
375 case '\r':
376 stop = TRUE;
377 if (oldecho)
378 waddch(win, '\n');
379 break;
380
381 default:
382 if (chars < n)
383 {
384 if (!SP->key_code)
385 {
386 *p++ = ch;
387 if (oldecho)
388 waddch(win, ch);
389 chars++;
390 }
391 }
392 else
393 beep();
394
395 break;
396
397 }
398
399 wrefresh(win);
400 }
401
402 *p = '\0';
403
404 SP->echo = oldecho; /* restore old settings */
405 SP->cbreak = oldcbreak;
406 win->_nodelay = oldnodelay;
407
408 return OK;
409 }
410
411 int get_wstr(wint_t *wstr)
412 {
413 PDC_LOG(("get_wstr() - called\n"));
414
415 return wgetn_wstr(stdscr, wstr, MAXLINE);
416 }
417
418 int wget_wstr(WINDOW *win, wint_t *wstr)
419 {
420 PDC_LOG(("wget_wstr() - called\n"));
421
422 return wgetn_wstr(win, wstr, MAXLINE);
423 }
424
425 int mvget_wstr(int y, int x, wint_t *wstr)
426 {
427 PDC_LOG(("mvget_wstr() - called\n"));
428
429 if (move(y, x) == ERR)
430 return ERR;
431
432 return wgetn_wstr(stdscr, wstr, MAXLINE);
433 }
434
435 int mvwget_wstr(WINDOW *win, int y, int x, wint_t *wstr)
436 {
437 PDC_LOG(("mvwget_wstr() - called\n"));
438
439 if (wmove(win, y, x) == ERR)
440 return ERR;
441
442 return wgetn_wstr(win, wstr, MAXLINE);
443 }
444
445 int getn_wstr(wint_t *wstr, int n)
446 {
447 PDC_LOG(("getn_wstr() - called\n"));
448
449 return wgetn_wstr(stdscr, wstr, n);
450 }
451
452 int mvgetn_wstr(int y, int x, wint_t *wstr, int n)
453 {
454 PDC_LOG(("mvgetn_wstr() - called\n"));
455
456 if (move(y, x) == ERR)
457 return ERR;
458
459 return wgetn_wstr(stdscr, wstr, n);
460 }
461
462 int mvwgetn_wstr(WINDOW *win, int y, int x, wint_t *wstr, int n)
463 {
464 PDC_LOG(("mvwgetn_wstr() - called\n"));
465
466 if (wmove(win, y, x) == ERR)
467 return ERR;
468
469 return wgetn_wstr(win, wstr, n);
470 }
471 #endif
File pdcurses/getyx.c added (mode: 100644) (index 00000000..fd0564d9)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: getyx.c,v 1.29 2008/07/15 17:13:26 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: getyx
10
11 Synopsis:
12 void getyx(WINDOW *win, int y, int x);
13 void getparyx(WINDOW *win, int y, int x);
14 void getbegyx(WINDOW *win, int y, int x);
15 void getmaxyx(WINDOW *win, int y, int x);
16
17 void getsyx(int y, int x);
18 int setsyx(int y, int x);
19
20 int getbegy(WINDOW *win);
21 int getbegx(WINDOW *win);
22 int getcury(WINDOW *win);
23 int getcurx(WINDOW *win);
24 int getpary(WINDOW *win);
25 int getparx(WINDOW *win);
26 int getmaxy(WINDOW *win);
27 int getmaxx(WINDOW *win);
28
29 Description:
30 The getyx() macro (defined in curses.h -- the prototypes here
31 are merely illustrative) puts the current cursor position of the
32 specified window into y and x. getbegyx() and getmaxyx() return
33 the starting coordinates and size of the specified window,
34 respectively. getparyx() returns the starting coordinates of the
35 parent's window, if the specified window is a subwindow;
36 otherwise it sets y and x to -1. These are all macros.
37
38 getsyx() gets the coordinates of the virtual screen cursor, and
39 stores them in y and x. If leaveok() is TRUE, it returns -1, -1.
40 If lines have been removed with ripoffline(), then getsyx()
41 includes these lines in its count; so, the returned y and x
42 values should only be used with setsyx().
43
44 setsyx() sets the virtual screen cursor to the y, x coordinates.
45 If y, x are -1, -1, leaveok() is set TRUE.
46
47 getsyx() and setsyx() are meant to be used by a library routine
48 that manipulates curses windows without altering the position of
49 the cursor. Note that getsyx() is defined only as a macro.
50
51 getbegy(), getbegx(), getcurx(), getcury(), getmaxy(),
52 getmaxx(), getpary(), and getparx() return the appropriate
53 coordinate or size values, or ERR in the case of a NULL window.
54
55 Portability X/Open BSD SYS V
56 getyx Y Y Y
57 getparyx - - 4.0
58 getbegyx - - 3.0
59 getmaxyx - - 3.0
60 getsyx - - 3.0
61 setsyx - - 3.0
62 getbegy - - -
63 getbegx - - -
64 getcury - - -
65 getcurx - - -
66 getpary - - -
67 getparx - - -
68 getmaxy - - -
69 getmaxx - - -
70
71 **man-end****************************************************************/
72
73 int getbegy(WINDOW *win)
74 {
75 PDC_LOG(("getbegy() - called\n"));
76
77 return win ? win->_begy : ERR;
78 }
79
80 int getbegx(WINDOW *win)
81 {
82 PDC_LOG(("getbegx() - called\n"));
83
84 return win ? win->_begx : ERR;
85 }
86
87 int getcury(WINDOW *win)
88 {
89 PDC_LOG(("getcury() - called\n"));
90
91 return win ? win->_cury : ERR;
92 }
93
94 int getcurx(WINDOW *win)
95 {
96 PDC_LOG(("getcurx() - called\n"));
97
98 return win ? win->_curx : ERR;
99 }
100
101 int getpary(WINDOW *win)
102 {
103 PDC_LOG(("getpary() - called\n"));
104
105 return win ? win->_pary : ERR;
106 }
107
108 int getparx(WINDOW *win)
109 {
110 PDC_LOG(("getparx() - called\n"));
111
112 return win ? win->_parx : ERR;
113 }
114
115 int getmaxy(WINDOW *win)
116 {
117 PDC_LOG(("getmaxy() - called\n"));
118
119 return win ? win->_maxy : ERR;
120 }
121
122 int getmaxx(WINDOW *win)
123 {
124 PDC_LOG(("getmaxx() - called\n"));
125
126 return win ? win->_maxx : ERR;
127 }
128
129 int setsyx(int y, int x)
130 {
131 PDC_LOG(("setsyx() - called\n"));
132
133 if(y == -1 && x == -1)
134 {
135 curscr->_leaveit = TRUE;
136 return OK;
137 }
138 else
139 {
140 curscr->_leaveit = FALSE;
141 return wmove(curscr, y, x);
142 }
143 }
File pdcurses/inch.c added (mode: 100644) (index 00000000..7347e740)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: inch.c,v 1.33 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: inch
10
11 Synopsis:
12 chtype inch(void);
13 chtype winch(WINDOW *win);
14 chtype mvinch(int y, int x);
15 chtype mvwinch(WINDOW *win, int y, int x);
16
17 int in_wch(cchar_t *wcval);
18 int win_wch(WINDOW *win, cchar_t *wcval);
19 int mvin_wch(int y, int x, cchar_t *wcval);
20 int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval);
21
22 Description:
23 The inch() functions retrieve the character and attribute from
24 the current or specified window position, in the form of a
25 chtype. If a NULL window is specified, (chtype)ERR is returned.
26
27 The in_wch() functions are the wide-character versions; instead
28 of returning a chtype, they store a cchar_t at the address
29 specified by wcval, and return OK or ERR. (No value is stored
30 when ERR is returned.) Note that in PDCurses, chtype and cchar_t
31 are the same.
32
33 Portability X/Open BSD SYS V
34 inch Y Y Y
35 winch Y Y Y
36 mvinch Y Y Y
37 mvwinch Y Y Y
38 in_wch Y
39 win_wch Y
40 mvin_wch Y
41 mvwin_wch Y
42
43 **man-end****************************************************************/
44
45 chtype winch(WINDOW *win)
46 {
47 PDC_LOG(("winch() - called\n"));
48
49 if (!win)
50 return (chtype)ERR;
51
52 return win->_y[win->_cury][win->_curx];
53 }
54
55 chtype inch(void)
56 {
57 PDC_LOG(("inch() - called\n"));
58
59 return winch(stdscr);
60 }
61
62 chtype mvinch(int y, int x)
63 {
64 PDC_LOG(("mvinch() - called\n"));
65
66 if (move(y, x) == ERR)
67 return (chtype)ERR;
68
69 return stdscr->_y[stdscr->_cury][stdscr->_curx];
70 }
71
72 chtype mvwinch(WINDOW *win, int y, int x)
73 {
74 PDC_LOG(("mvwinch() - called\n"));
75
76 if (wmove(win, y, x) == ERR)
77 return (chtype)ERR;
78
79 return win->_y[win->_cury][win->_curx];
80 }
81
82 #ifdef PDC_WIDE
83 int win_wch(WINDOW *win, cchar_t *wcval)
84 {
85 PDC_LOG(("win_wch() - called\n"));
86
87 if (!win || !wcval)
88 return ERR;
89
90 *wcval = win->_y[win->_cury][win->_curx];
91
92 return OK;
93 }
94
95 int in_wch(cchar_t *wcval)
96 {
97 PDC_LOG(("in_wch() - called\n"));
98
99 return win_wch(stdscr, wcval);
100 }
101
102 int mvin_wch(int y, int x, cchar_t *wcval)
103 {
104 PDC_LOG(("mvin_wch() - called\n"));
105
106 if (!wcval || (move(y, x) == ERR))
107 return ERR;
108
109 *wcval = stdscr->_y[stdscr->_cury][stdscr->_curx];
110
111 return OK;
112 }
113
114 int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval)
115 {
116 PDC_LOG(("mvwin_wch() - called\n"));
117
118 if (!wcval || (wmove(win, y, x) == ERR))
119 return ERR;
120
121 *wcval = win->_y[win->_cury][win->_curx];
122
123 return OK;
124 }
125 #endif
File pdcurses/inchstr.c added (mode: 100644) (index 00000000..50b8cf5b)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: inchstr.c,v 1.34 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: inchstr
10
11 Synopsis:
12 int inchstr(chtype *ch);
13 int inchnstr(chtype *ch, int n);
14 int winchstr(WINDOW *win, chtype *ch);
15 int winchnstr(WINDOW *win, chtype *ch, int n);
16 int mvinchstr(int y, int x, chtype *ch);
17 int mvinchnstr(int y, int x, chtype *ch, int n);
18 int mvwinchstr(WINDOW *, int y, int x, chtype *ch);
19 int mvwinchnstr(WINDOW *, int y, int x, chtype *ch, int n);
20
21 int in_wchstr(cchar_t *wch);
22 int in_wchnstr(cchar_t *wch, int n);
23 int win_wchstr(WINDOW *win, cchar_t *wch);
24 int win_wchnstr(WINDOW *win, cchar_t *wch, int n);
25 int mvin_wchstr(int y, int x, cchar_t *wch);
26 int mvin_wchnstr(int y, int x, cchar_t *wch, int n);
27 int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch);
28 int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n);
29
30 Description:
31 These routines read a chtype or cchar_t string from the window,
32 starting at the current or specified position, and ending at the
33 right margin, or after n elements, whichever is less.
34
35 Return Value:
36 All functions return the number of elements read, or ERR on
37 error.
38
39 Portability X/Open BSD SYS V
40 inchstr Y - 4.0
41 winchstr Y - 4.0
42 mvinchstr Y - 4.0
43 mvwinchstr Y - 4.0
44 inchnstr Y - 4.0
45 winchnstr Y - 4.0
46 mvinchnstr Y - 4.0
47 mvwinchnstr Y - 4.0
48 in_wchstr Y
49 win_wchstr Y
50 mvin_wchstr Y
51 mvwin_wchstr Y
52 in_wchnstr Y
53 win_wchnstr Y
54 mvin_wchnstr Y
55 mvwin_wchnstr Y
56
57 **man-end****************************************************************/
58
59 int winchnstr(WINDOW *win, chtype *ch, int n)
60 {
61 chtype *src;
62 int i;
63
64 PDC_LOG(("winchnstr() - called\n"));
65
66 if (!win || !ch || n < 0)
67 return ERR;
68
69 if ((win->_curx + n) > win->_maxx)
70 n = win->_maxx - win->_curx;
71
72 src = win->_y[win->_cury] + win->_curx;
73
74 for (i = 0; i < n; i++)
75 *ch++ = *src++;
76
77 *ch = (chtype)0;
78
79 return OK;
80 }
81
82 int inchstr(chtype *ch)
83 {
84 PDC_LOG(("inchstr() - called\n"));
85
86 return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
87 }
88
89 int winchstr(WINDOW *win, chtype *ch)
90 {
91 PDC_LOG(("winchstr() - called\n"));
92
93 return winchnstr(win, ch, win->_maxx - win->_curx);
94 }
95
96 int mvinchstr(int y, int x, chtype *ch)
97 {
98 PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x));
99
100 if (move(y, x) == ERR)
101 return ERR;
102
103 return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
104 }
105
106 int mvwinchstr(WINDOW *win, int y, int x, chtype *ch)
107 {
108 PDC_LOG(("mvwinchstr() - called:\n"));
109
110 if (wmove(win, y, x) == ERR)
111 return ERR;
112
113 return winchnstr(win, ch, win->_maxx - win->_curx);
114 }
115
116 int inchnstr(chtype *ch, int n)
117 {
118 PDC_LOG(("inchnstr() - called\n"));
119
120 return winchnstr(stdscr, ch, n);
121 }
122
123 int mvinchnstr(int y, int x, chtype *ch, int n)
124 {
125 PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n));
126
127 if (move(y, x) == ERR)
128 return ERR;
129
130 return winchnstr(stdscr, ch, n);
131 }
132
133 int mvwinchnstr(WINDOW *win, int y, int x, chtype *ch, int n)
134 {
135 PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
136
137 if (wmove(win, y, x) == ERR)
138 return ERR;
139
140 return winchnstr(win, ch, n);
141 }
142
143 #ifdef PDC_WIDE
144 int win_wchnstr(WINDOW *win, cchar_t *wch, int n)
145 {
146 PDC_LOG(("win_wchnstr() - called\n"));
147
148 return winchnstr(win, wch, n);
149 }
150
151 int in_wchstr(cchar_t *wch)
152 {
153 PDC_LOG(("in_wchstr() - called\n"));
154
155 return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
156 }
157
158 int win_wchstr(WINDOW *win, cchar_t *wch)
159 {
160 PDC_LOG(("win_wchstr() - called\n"));
161
162 return win_wchnstr(win, wch, win->_maxx - win->_curx);
163 }
164
165 int mvin_wchstr(int y, int x, cchar_t *wch)
166 {
167 PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x));
168
169 if (move(y, x) == ERR)
170 return ERR;
171
172 return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
173 }
174
175 int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch)
176 {
177 PDC_LOG(("mvwin_wchstr() - called:\n"));
178
179 if (wmove(win, y, x) == ERR)
180 return ERR;
181
182 return win_wchnstr(win, wch, win->_maxx - win->_curx);
183 }
184
185 int in_wchnstr(cchar_t *wch, int n)
186 {
187 PDC_LOG(("in_wchnstr() - called\n"));
188
189 return win_wchnstr(stdscr, wch, n);
190 }
191
192 int mvin_wchnstr(int y, int x, cchar_t *wch, int n)
193 {
194 PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n));
195
196 if (move(y, x) == ERR)
197 return ERR;
198
199 return win_wchnstr(stdscr, wch, n);
200 }
201
202 int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n)
203 {
204 PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
205
206 if (wmove(win, y, x) == ERR)
207 return ERR;
208
209 return win_wchnstr(win, wch, n);
210 }
211 #endif
File pdcurses/initscr.c added (mode: 100644) (index 00000000..d80fa0cf)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: initscr.c,v 1.114 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: initscr
10
11 Synopsis:
12 WINDOW *initscr(void);
13 WINDOW *Xinitscr(int argc, char *argv[]);
14 int endwin(void);
15 bool isendwin(void);
16 SCREEN *newterm(const char *type, FILE *outfd, FILE *infd);
17 SCREEN *set_term(SCREEN *new);
18 void delscreen(SCREEN *sp);
19
20 int resize_term(int nlines, int ncols);
21 bool is_termresized(void);
22 const char *curses_version(void);
23
24 Description:
25 initscr() should be the first curses routine called. It will
26 initialize all curses data structures, and arrange that the
27 first call to refresh() will clear the screen. In case of
28 error, initscr() will write a message to standard error and end
29 the program.
30
31 endwin() should be called before exiting or escaping from curses
32 mode temporarily. It will restore tty modes, move the cursor to
33 the lower left corner of the screen and reset the terminal into
34 the proper non-visual mode. To resume curses after a temporary
35 escape, call refresh() or doupdate().
36
37 isendwin() returns TRUE if endwin() has been called without a
38 subsequent refresh, unless SP is NULL.
39
40 In some implementations of curses, newterm() allows the use of
41 multiple terminals. Here, it's just an alternative interface for
42 initscr(). It always returns SP, or NULL.
43
44 delscreen() frees the memory allocated by newterm() or
45 initscr(), since it's not freed by endwin(). This function is
46 usually not needed. In PDCurses, the parameter must be the
47 value of SP, and delscreen() sets SP to NULL.
48
49 set_term() does nothing meaningful in PDCurses, but is included
50 for compatibility with other curses implementations.
51
52 resize_term() is effectively two functions: When called with
53 nonzero values for nlines and ncols, it attempts to resize the
54 screen to the given size. When called with (0, 0), it merely
55 adjusts the internal structures to match the current size after
56 the screen is resized by the user. On the currently supported
57 platforms, this functionality is mutually exclusive: X11 allows
58 user resizing, while DOS, OS/2 and Win32 allow programmatic
59 resizing. If you want to support user resizing, you should check
60 for getch() returning KEY_RESIZE, and/or call is_termresized()
61 at appropriate times; if either condition occurs, call
62 resize_term(0, 0). Then, with either user or programmatic
63 resizing, you'll have to resize any windows you've created, as
64 appropriate; resize_term() only handles stdscr and curscr.
65
66 is_termresized() returns TRUE if the curses screen has been
67 resized by the user, and a call to resize_term() is needed.
68 Checking for KEY_RESIZE is generally preferable, unless you're
69 not handling the keyboard.
70
71 curses_version() returns a string describing the version of
72 PDCurses.
73
74 Return Value:
75 All functions return NULL on error, except endwin(), which
76 returns ERR on error.
77
78 Portability X/Open BSD SYS V
79 initscr Y Y Y
80 endwin Y Y Y
81 isendwin Y - 3.0
82 newterm Y - Y
83 set_term Y - Y
84 delscreen Y - 4.0
85 resize_term - - -
86 is_termresized - - -
87 curses_version - - -
88
89 **man-end****************************************************************/
90
91 #include <stdlib.h>
92
93 char ttytype[128];
94
95 const char *_curses_notice = "PDCurses 3.4 - Public Domain 2008";
96
97 SCREEN *SP = (SCREEN*)NULL; /* curses variables */
98 WINDOW *curscr = (WINDOW *)NULL; /* the current screen image */
99 WINDOW *stdscr = (WINDOW *)NULL; /* the default screen window */
100 WINDOW *pdc_lastscr = (WINDOW *)NULL; /* the last screen image */
101
102 int LINES = 0; /* current terminal height */
103 int COLS = 0; /* current terminal width */
104 int TABSIZE = 8;
105
106 MOUSE_STATUS Mouse_status, pdc_mouse_status;
107
108 extern RIPPEDOFFLINE linesripped[5];
109 extern char linesrippedoff;
110
111 WINDOW *Xinitscr(int argc, char *argv[])
112 {
113 int i;
114
115 PDC_LOG(("Xinitscr() - called\n"));
116
117 if (SP && SP->alive)
118 return NULL;
119
120 if (PDC_scr_open(argc, argv) == ERR)
121 {
122 fprintf(stderr, "initscr(): Unable to create SP\n");
123 exit(8);
124 }
125
126 SP->autocr = TRUE; /* cr -> lf by default */
127 SP->raw_out = FALSE; /* tty I/O modes */
128 SP->raw_inp = FALSE; /* tty I/O modes */
129 SP->cbreak = TRUE;
130 SP->save_key_modifiers = FALSE;
131 SP->return_key_modifiers = FALSE;
132 SP->echo = TRUE;
133 SP->visibility = 1;
134 SP->resized = FALSE;
135 SP->_trap_mbe = 0L;
136 SP->_map_mbe_to_key = 0L;
137 SP->linesrippedoff = 0;
138 SP->linesrippedoffontop = 0;
139 SP->delaytenths = 0;
140 SP->line_color = -1;
141
142 SP->orig_cursor = PDC_get_cursor_mode();
143
144 LINES = SP->lines;
145 COLS = SP->cols;
146
147 if (LINES < 2 || COLS < 2)
148 {
149 fprintf(stderr, "initscr(): LINES=%d COLS=%d: too small.\n",
150 LINES, COLS);
151 exit(4);
152 }
153
154 if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *)NULL)
155 {
156 fprintf(stderr, "initscr(): Unable to create curscr.\n");
157 exit(2);
158 }
159
160 if ((pdc_lastscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *)NULL)
161 {
162 fprintf(stderr, "initscr(): Unable to create pdc_lastscr.\n");
163 exit(2);
164 }
165
166 wattrset(pdc_lastscr, (chtype)(-1));
167 werase(pdc_lastscr);
168
169 PDC_slk_initialize();
170 LINES -= SP->slklines;
171
172 /* We have to sort out ripped off lines here, and reduce the height
173 of stdscr by the number of lines ripped off */
174
175 for (i = 0; i < linesrippedoff; i++)
176 {
177 if (linesripped[i].line < 0)
178 (*linesripped[i].init)(newwin(1, COLS, LINES - 1, 0), COLS);
179 else
180 (*linesripped[i].init)(newwin(1, COLS,
181 SP->linesrippedoffontop++, 0), COLS);
182
183 SP->linesrippedoff++;
184 LINES--;
185 }
186
187 linesrippedoff = 0;
188
189 if (!(stdscr = newwin(LINES, COLS, SP->linesrippedoffontop, 0)))
190 {
191 fprintf(stderr, "initscr(): Unable to create stdscr.\n");
192 exit(1);
193 }
194
195 wclrtobot(stdscr);
196
197 /* If preserving the existing screen, don't allow a screen clear */
198
199 if (SP->_preserve)
200 {
201 untouchwin(curscr);
202 untouchwin(stdscr);
203 stdscr->_clear = FALSE;
204 curscr->_clear = FALSE;
205 }
206 else
207 curscr->_clear = TRUE;
208
209 PDC_init_atrtab(); /* set up default colors */
210
211 MOUSE_X_POS = MOUSE_Y_POS = -1;
212 BUTTON_STATUS(1) = BUTTON_RELEASED;
213 BUTTON_STATUS(2) = BUTTON_RELEASED;
214 BUTTON_STATUS(3) = BUTTON_RELEASED;
215 Mouse_status.changes = 0;
216
217 SP->alive = TRUE;
218
219 def_shell_mode();
220
221 sprintf(ttytype, "pdcurses|PDCurses for %s", PDC_sysname());
222
223 return stdscr;
224 }
225
226 WINDOW *initscr(void)
227 {
228 PDC_LOG(("initscr() - called\n"));
229
230 return Xinitscr(0, NULL);
231 }
232
233 int endwin(void)
234 {
235 PDC_LOG(("endwin() - called\n"));
236
237 /* Allow temporary exit from curses using endwin() */
238
239 def_prog_mode();
240 PDC_scr_close();
241
242 SP->alive = FALSE;
243
244 return OK;
245 }
246
247 bool isendwin(void)
248 {
249 PDC_LOG(("isendwin() - called\n"));
250
251 return SP ? !(SP->alive) : FALSE;
252 }
253
254 SCREEN *newterm(const char *type, FILE *outfd, FILE *infd)
255 {
256 PDC_LOG(("newterm() - called\n"));
257
258 return Xinitscr(0, NULL) ? SP : NULL;
259 }
260
261 SCREEN *set_term(SCREEN *new)
262 {
263 PDC_LOG(("set_term() - called\n"));
264
265 /* We only support one screen */
266
267 return (new == SP) ? SP : NULL;
268 }
269
270 void delscreen(SCREEN *sp)
271 {
272 PDC_LOG(("delscreen() - called\n"));
273
274 if (sp != SP)
275 return;
276
277 PDC_slk_free(); /* free the soft label keys, if needed */
278
279 delwin(stdscr);
280 delwin(curscr);
281 delwin(pdc_lastscr);
282 stdscr = (WINDOW *)NULL;
283 curscr = (WINDOW *)NULL;
284 pdc_lastscr = (WINDOW *)NULL;
285
286 SP->alive = FALSE;
287
288 PDC_scr_free(); /* free SP and pdc_atrtab */
289
290 SP = (SCREEN *)NULL;
291 }
292
293 int resize_term(int nlines, int ncols)
294 {
295 PDC_LOG(("resize_term() - called: nlines %d\n", nlines));
296
297 if (!stdscr || PDC_resize_screen(nlines, ncols) == ERR)
298 return ERR;
299
300 SP->lines = PDC_get_rows();
301 LINES = SP->lines - SP->linesrippedoff - SP->slklines;
302 SP->cols = COLS = PDC_get_columns();
303
304 if (wresize(curscr, SP->lines, SP->cols) == ERR ||
305 wresize(stdscr, LINES, COLS) == ERR ||
306 wresize(pdc_lastscr, SP->lines, SP->cols) == ERR)
307 return ERR;
308
309 werase(pdc_lastscr);
310 curscr->_clear = TRUE;
311
312 if (SP->slk_winptr)
313 {
314 if (wresize(SP->slk_winptr, SP->slklines, COLS) == ERR)
315 return ERR;
316
317 wmove(SP->slk_winptr, 0, 0);
318 wclrtobot(SP->slk_winptr);
319 PDC_slk_initialize();
320 slk_noutrefresh();
321 }
322
323 touchwin(stdscr);
324 wnoutrefresh(stdscr);
325
326 return OK;
327 }
328
329 bool is_termresized(void)
330 {
331 PDC_LOG(("is_termresized() - called\n"));
332
333 return SP->resized;
334 }
335
336 const char *curses_version(void)
337 {
338 return _curses_notice;
339 }
File pdcurses/inopts.c added (mode: 100644) (index 00000000..6d33fc2a)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: inopts.c,v 1.43 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: inopts
10
11 Synopsis:
12 int cbreak(void);
13 int nocbreak(void);
14 int echo(void);
15 int noecho(void);
16 int halfdelay(int tenths);
17 int intrflush(WINDOW *win, bool bf);
18 int keypad(WINDOW *win, bool bf);
19 int meta(WINDOW *win, bool bf);
20 int nl(void);
21 int nonl(void);
22 int nodelay(WINDOW *win, bool bf);
23 int notimeout(WINDOW *win, bool bf);
24 int raw(void);
25 int noraw(void);
26 void noqiflush(void);
27 void qiflush(void);
28 void timeout(int delay);
29 void wtimeout(WINDOW *win, int delay);
30 int typeahead(int fildes);
31
32 int crmode(void);
33 int nocrmode(void);
34
35 Description:
36 cbreak() and nocbreak() toggle cbreak mode. In cbreak mode,
37 characters typed by the user are made available immediately, and
38 erase/kill character processing is not performed. In nocbreak
39 mode, typed characters are buffered until a newline or carriage
40 return. Interrupt and flow control characters are unaffected by
41 this mode. PDCurses always starts in cbreak mode.
42
43 echo() and noecho() control whether typed characters are echoed
44 by the input routine. Initially, input characters are echoed.
45 Subsequent calls to echo() and noecho() do not flush type-ahead.
46
47 halfdelay() is similar to cbreak(), but allows for a time limit
48 to be specified, in tenths of a second. This causes getch() to
49 block for that period before returning ERR if no key has been
50 received. tenths must be between 1 and 255.
51
52 keypad() controls whether getch() returns function/special keys
53 as single key codes (e.g., the left arrow key as KEY_LEFT). Per
54 X/Open, the default for keypad mode is OFF. You'll probably want
55 it on. With keypad mode off, if a special key is pressed,
56 getch() does nothing or returns ERR.
57
58 nodelay() controls whether wgetch() is a non-blocking call. If
59 the option is enabled, and no input is ready, wgetch() will
60 return ERR. If disabled, wgetch() will hang until input is
61 ready.
62
63 nl() enables the translation of a carriage return into a newline
64 on input. nonl() disables this. Initially, the translation does
65 occur.
66
67 raw() and noraw() toggle raw mode. Raw mode is similar to cbreak
68 mode, in that characters typed are immediately passed through to
69 the user program. The difference is that in raw mode, the INTR,
70 QUIT, SUSP, and STOP characters are passed through without being
71 interpreted, and without generating a signal.
72
73 In PDCurses, the meta() function sets raw mode on or off.
74
75 timeout() and wtimeout() set blocking or non-blocking reads for
76 the specified window. The delay is measured in milliseconds. If
77 it's negative, a blocking read is used; if zero, then non-
78 blocking reads are done -- if no input is waiting, ERR is
79 returned immediately. If the delay is positive, the read blocks
80 for the delay period; if the period expires, ERR is returned.
81
82 intrflush(), notimeout(), noqiflush(), qiflush() and typeahead()
83 do nothing in PDCurses, but are included for compatibility with
84 other curses implementations.
85
86 crmode() and nocrmode() are archaic equivalents to cbreak() and
87 nocbreak(), respectively.
88
89 Return Value:
90 All functions return OK on success and ERR on error.
91
92 Portability X/Open BSD SYS V
93 cbreak Y Y Y
94 nocbreak Y Y Y
95 echo Y Y Y
96 noecho Y Y Y
97 halfdelay Y - Y
98 intrflush Y - Y
99 keypad Y - Y
100 meta Y - Y
101 nl Y Y Y
102 nonl Y Y Y
103 nodelay Y - Y
104 notimeout Y - Y
105 raw Y Y Y
106 noraw Y Y Y
107 noqiflush Y - Y
108 qiflush Y - Y
109 timeout Y - Y
110 wtimeout Y - Y
111 typeahead Y - Y
112 crmode -
113 nocrmode -
114
115 **man-end****************************************************************/
116
117 int cbreak(void)
118 {
119 PDC_LOG(("cbreak() - called\n"));
120
121 SP->cbreak = TRUE;
122
123 return OK;
124 }
125
126 int nocbreak(void)
127 {
128 PDC_LOG(("nocbreak() - called\n"));
129
130 SP->cbreak = FALSE;
131 SP->delaytenths = 0;
132
133 return OK;
134 }
135
136 int echo(void)
137 {
138 PDC_LOG(("echo() - called\n"));
139
140 SP->echo = TRUE;
141
142 return OK;
143 }
144
145 int noecho(void)
146 {
147 PDC_LOG(("noecho() - called\n"));
148
149 SP->echo = FALSE;
150
151 return OK;
152 }
153
154 int halfdelay(int tenths)
155 {
156 PDC_LOG(("halfdelay() - called\n"));
157
158 if (tenths < 1 || tenths > 255)
159 return ERR;
160
161 SP->delaytenths = tenths;
162
163 return OK;
164 }
165
166 int intrflush(WINDOW *win, bool bf)
167 {
168 PDC_LOG(("intrflush() - called\n"));
169
170 return OK;
171 }
172
173 int keypad(WINDOW *win, bool bf)
174 {
175 PDC_LOG(("keypad() - called\n"));
176
177 if (!win)
178 return ERR;
179
180 win->_use_keypad = bf;
181
182 return OK;
183 }
184
185 int meta(WINDOW *win, bool bf)
186 {
187 PDC_LOG(("meta() - called\n"));
188
189 SP->raw_inp = bf;
190
191 return OK;
192 }
193
194 int nl(void)
195 {
196 PDC_LOG(("nl() - called\n"));
197
198 SP->autocr = TRUE;
199
200 return OK;
201 }
202
203 int nonl(void)
204 {
205 PDC_LOG(("nonl() - called\n"));
206
207 SP->autocr = FALSE;
208
209 return OK;
210 }
211
212 int nodelay(WINDOW *win, bool flag)
213 {
214 PDC_LOG(("nodelay() - called\n"));
215
216 if (!win)
217 return ERR;
218
219 win->_nodelay = flag;
220
221 return OK;
222 }
223
224 int notimeout(WINDOW *win, bool flag)
225 {
226 PDC_LOG(("notimeout() - called\n"));
227
228 return OK;
229 }
230
231 int raw(void)
232 {
233 PDC_LOG(("raw() - called\n"));
234
235 PDC_set_keyboard_binary(TRUE);
236 SP->raw_inp = TRUE;
237
238 return OK;
239 }
240
241 int noraw(void)
242 {
243 PDC_LOG(("noraw() - called\n"));
244
245 PDC_set_keyboard_binary(FALSE);
246 SP->raw_inp = FALSE;
247
248 return OK;
249 }
250
251 void noqiflush(void)
252 {
253 PDC_LOG(("noqiflush() - called\n"));
254 }
255
256 void qiflush(void)
257 {
258 PDC_LOG(("qiflush() - called\n"));
259 }
260
261 int typeahead(int fildes)
262 {
263 PDC_LOG(("typeahead() - called\n"));
264
265 return OK;
266 }
267
268 void wtimeout(WINDOW *win, int delay)
269 {
270 PDC_LOG(("wtimeout() - called\n"));
271
272 if (!win)
273 return;
274
275 if (delay < 0)
276 {
277 /* This causes a blocking read on the window, so turn on delay
278 mode */
279
280 win->_nodelay = FALSE;
281 win->_delayms = 0;
282 }
283 else if (!delay)
284 {
285 /* This causes a non-blocking read on the window, so turn off
286 delay mode */
287
288 win->_nodelay = TRUE;
289 win->_delayms = 0;
290 }
291 else
292 {
293 /* This causes the read on the window to delay for the number of
294 milliseconds. Also forces the window into non-blocking read
295 mode */
296
297 /*win->_nodelay = TRUE;*/
298 win->_delayms = delay;
299 }
300 }
301
302 void timeout(int delay)
303 {
304 PDC_LOG(("timeout() - called\n"));
305
306 wtimeout(stdscr, delay);
307 }
308
309 int crmode(void)
310 {
311 PDC_LOG(("crmode() - called\n"));
312
313 return cbreak();
314 }
315
316 int nocrmode(void)
317 {
318 PDC_LOG(("nocrmode() - called\n"));
319
320 return nocbreak();
321 }
File pdcurses/insch.c added (mode: 100644) (index 00000000..50527f2f)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: insch.c,v 1.44 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: insch
10
11 Synopsis:
12 int insch(chtype ch);
13 int winsch(WINDOW *win, chtype ch);
14 int mvinsch(int y, int x, chtype ch);
15 int mvwinsch(WINDOW *win, int y, int x, chtype ch);
16
17 int insrawch(chtype ch);
18 int winsrawch(WINDOW *win, chtype ch);
19 int mvinsrawch(int y, int x, chtype ch);
20 int mvwinsrawch(WINDOW *win, int y, int x, chtype ch);
21
22 int ins_wch(const cchar_t *wch);
23 int wins_wch(WINDOW *win, const cchar_t *wch);
24 int mvins_wch(int y, int x, const cchar_t *wch);
25 int mvwins_wch(WINDOW *win, int y, int x, const cchar_t *wch);
26
27 Description:
28 The insch() functions insert a chtype into the window at the
29 current or specified cursor position. The cursor is NOT
30 advanced. A newline is equivalent to clrtoeol(); tabs are
31 expanded; other control characters are converted as with
32 unctrl().
33
34 The ins_wch() functions are the wide-character
35 equivalents, taking cchar_t pointers rather than chtypes.
36
37 Video attributes can be combined with a character by ORing
38 them into the parameter. Text, including attributes, can be
39 copied from one place to another using inch() and insch().
40
41 insrawch() etc. are PDCurses-specific wrappers for insch() etc.
42 that disable the translation of control characters.
43
44 Return Value:
45 All functions return OK on success and ERR on error.
46
47 Portability X/Open BSD SYS V
48 insch Y Y Y
49 winsch Y Y Y
50 mvinsch Y Y Y
51 mvwinsch Y Y Y
52 insrawch - - -
53 winsrawch - - -
54 ins_wch Y
55 wins_wch Y
56 mvins_wch Y
57 mvwins_wch Y
58
59 **man-end****************************************************************/
60
61 #include <string.h>
62
63 int winsch(WINDOW *win, chtype ch)
64 {
65 int x, y;
66 chtype attr;
67 bool xlat;
68
69 PDC_LOG(("winsch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
70 win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
71
72 if (!win)
73 return ERR;
74
75 x = win->_curx;
76 y = win->_cury;
77
78 if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
79 return ERR;
80
81 xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
82 attr = ch & A_ATTRIBUTES;
83 ch &= A_CHARTEXT;
84
85 if (xlat && (ch < ' ' || ch == 0x7f))
86 {
87 int x2;
88
89 switch (ch)
90 {
91 case '\t':
92 for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++)
93 {
94 if (winsch(win, attr | ' ') == ERR)
95 return ERR;
96 }
97 return OK;
98
99 case '\n':
100 wclrtoeol(win);
101 break;
102
103 case 0x7f:
104 if (winsch(win, attr | '?') == ERR)
105 return ERR;
106
107 return winsch(win, attr | '^');
108
109 default:
110 /* handle control chars */
111
112 if (winsch(win, attr | (ch + '@')) == ERR)
113 return ERR;
114
115 return winsch(win, attr | '^');
116 }
117 }
118 else
119 {
120 int maxx;
121 chtype *temp;
122
123 /* If the incoming character doesn't have its own attribute,
124 then use the current attributes for the window. If it has
125 attributes but not a color component, OR the attributes to
126 the current attributes for the window. If it has a color
127 component, use the attributes solely from the incoming
128 character. */
129
130 if (!(attr & A_COLOR))
131 attr |= win->_attrs;
132
133 /* wrs (4/10/93): Apply the same sort of logic for the window
134 background, in that it only takes precedence if other color
135 attributes are not there and that the background character
136 will only print if the printing character is blank. */
137
138 if (!(attr & A_COLOR))
139 attr |= win->_bkgd & A_ATTRIBUTES;
140 else
141 attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
142
143 if (ch == ' ')
144 ch = win->_bkgd & A_CHARTEXT;
145
146 /* Add the attribute back into the character. */
147
148 ch |= attr;
149
150 maxx = win->_maxx;
151 temp = &win->_y[y][x];
152
153 memmove(temp + 1, temp, (maxx - x - 1) * sizeof(chtype));
154
155 win->_lastch[y] = maxx - 1;
156
157 if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
158 win->_firstch[y] = x;
159
160 *temp = ch;
161 }
162
163 PDC_sync(win);
164
165 return OK;
166 }
167
168 int insch(chtype ch)
169 {
170 PDC_LOG(("insch() - called\n"));
171
172 return winsch(stdscr, ch);
173 }
174
175 int mvinsch(int y, int x, chtype ch)
176 {
177 PDC_LOG(("mvinsch() - called\n"));
178
179 if (move(y, x) == ERR)
180 return ERR;
181
182 return winsch(stdscr, ch);
183 }
184
185 int mvwinsch(WINDOW *win, int y, int x, chtype ch)
186 {
187 PDC_LOG(("mvwinsch() - called\n"));
188
189 if (wmove(win, y, x) == ERR)
190 return ERR;
191
192 return winsch(win, ch);
193 }
194
195 int winsrawch(WINDOW *win, chtype ch)
196 {
197 PDC_LOG(("winsrawch() - called: win=%p ch=%x "
198 "(char=%c attr=0x%x)\n", win, ch,
199 ch & A_CHARTEXT, ch & A_ATTRIBUTES));
200
201 if ((ch & A_CHARTEXT) < ' ' || (ch & A_CHARTEXT) == 0x7f)
202 ch |= A_ALTCHARSET;
203
204 return winsch(win, ch);
205 }
206
207 int insrawch(chtype ch)
208 {
209 PDC_LOG(("insrawch() - called\n"));
210
211 return winsrawch(stdscr, ch);
212 }
213
214 int mvinsrawch(int y, int x, chtype ch)
215 {
216 PDC_LOG(("mvinsrawch() - called\n"));
217
218 if (move(y, x) == ERR)
219 return ERR;
220
221 return winsrawch(stdscr, ch);
222 }
223
224 int mvwinsrawch(WINDOW *win, int y, int x, chtype ch)
225 {
226 PDC_LOG(("mvwinsrawch() - called\n"));
227
228 if (wmove(win, y, x) == ERR)
229 return ERR;
230
231 return winsrawch(win, ch);
232 }
233
234 #ifdef PDC_WIDE
235 int wins_wch(WINDOW *win, const cchar_t *wch)
236 {
237 PDC_LOG(("wins_wch() - called\n"));
238
239 return wch ? winsch(win, *wch) : ERR;
240 }
241
242 int ins_wch(const cchar_t *wch)
243 {
244 PDC_LOG(("ins_wch() - called\n"));
245
246 return wins_wch(stdscr, wch);
247 }
248
249 int mvins_wch(int y, int x, const cchar_t *wch)
250 {
251 PDC_LOG(("mvins_wch() - called\n"));
252
253 if (move(y, x) == ERR)
254 return ERR;
255
256 return wins_wch(stdscr, wch);
257 }
258
259 int mvwins_wch(WINDOW *win, int y, int x, const cchar_t *wch)
260 {
261 PDC_LOG(("mvwins_wch() - called\n"));
262
263 if (wmove(win, y, x) == ERR)
264 return ERR;
265
266 return wins_wch(win, wch);
267 }
268 #endif
File pdcurses/insstr.c added (mode: 100644) (index 00000000..38fa3891)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: insstr.c,v 1.46 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: insstr
10
11 Synopsis:
12 int insstr(const char *str);
13 int insnstr(const char *str, int n);
14 int winsstr(WINDOW *win, const char *str);
15 int winsnstr(WINDOW *win, const char *str, int n);
16 int mvinsstr(int y, int x, const char *str);
17 int mvinsnstr(int y, int x, const char *str, int n);
18 int mvwinsstr(WINDOW *win, int y, int x, const char *str);
19 int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n);
20
21 int ins_wstr(const wchar_t *wstr);
22 int ins_nwstr(const wchar_t *wstr, int n);
23 int wins_wstr(WINDOW *win, const wchar_t *wstr);
24 int wins_nwstr(WINDOW *win, const wchar_t *wstr, int n);
25 int mvins_wstr(int y, int x, const wchar_t *wstr);
26 int mvins_nwstr(int y, int x, const wchar_t *wstr, int n);
27 int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr);
28 int mvwins_nwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n);
29
30 Description:
31 The insstr() functions insert a character string into a window
32 at the current cursor position, by repeatedly calling winsch().
33 When PDCurses is built with wide-character support enabled, the
34 narrow-character functions treat the string as a multibyte
35 string in the current locale, and convert it first. All
36 characters to the right of the cursor are moved to the right,
37 with the possibility of the rightmost characters on the line
38 being lost. The cursor position does not change (after moving
39 to y, x, if specified). The routines with n as the last
40 argument insert at most n characters; if n is negative, then the
41 entire string is inserted.
42
43 Return Value:
44 All functions return OK on success and ERR on error.
45
46 Portability X/Open BSD SYS V
47 insstr Y - 4.0
48 winsstr Y - 4.0
49 mvinsstr Y - 4.0
50 mvwinsstr Y - 4.0
51 insnstr Y - 4.0
52 winsnstr Y - 4.0
53 mvinsnstr Y - 4.0
54 mvwinsnstr Y - 4.0
55 ins_wstr Y
56 wins_wstr Y
57 mvins_wstr Y
58 mvwins_wstr Y
59 ins_nwstr Y
60 wins_nwstr Y
61 mvins_nwstr Y
62 mvwins_nwstr Y
63
64 **man-end****************************************************************/
65
66 #include <string.h>
67
68 int winsnstr(WINDOW *win, const char *str, int n)
69 {
70 #ifdef PDC_WIDE
71 wchar_t wstr[513], *p;
72 int i;
73 #endif
74 int len;
75
76 PDC_LOG(("winsnstr() - called: string=\"%s\" n %d \n", str, n));
77
78 if (!win || !str)
79 return ERR;
80
81 len = strlen(str);
82
83 if (n < 0 || n < len)
84 n = len;
85
86 #ifdef PDC_WIDE
87 if (n > 512)
88 n = 512;
89
90 p = wstr;
91 i = 0;
92
93 while (str[i] && i < n)
94 {
95 int retval = PDC_mbtowc(p, str + i, n - i);
96
97 if (retval <= 0)
98 break;
99 p++;
100 i += retval;
101 }
102
103 while (p > wstr)
104 if (winsch(win, *--p) == ERR)
105 #else
106 while (n)
107 if (winsch(win, (unsigned char)(str[--n])) == ERR)
108 #endif
109 return ERR;
110
111 return OK;
112 }
113
114 int insstr(const char *str)
115 {
116 PDC_LOG(("insstr() - called: string=\"%s\"\n", str));
117
118 return winsnstr(stdscr, str, -1);
119 }
120
121 int winsstr(WINDOW *win, const char *str)
122 {
123 PDC_LOG(("winsstr() - called: string=\"%s\"\n", str));
124
125 return winsnstr(win, str, -1);
126 }
127
128 int mvinsstr(int y, int x, const char *str)
129 {
130 PDC_LOG(("mvinsstr() - called: y %d x %d string=\"%s\"\n", y, x, str));
131
132 if (move(y, x) == ERR)
133 return ERR;
134
135 return winsnstr(stdscr, str, -1);
136 }
137
138 int mvwinsstr(WINDOW *win, int y, int x, const char *str)
139 {
140 PDC_LOG(("mvwinsstr() - called: string=\"%s\"\n", str));
141
142 if (wmove(win, y, x) == ERR)
143 return ERR;
144
145 return winsnstr(win, str, -1);
146 }
147
148 int insnstr(const char *str, int n)
149 {
150 PDC_LOG(("insnstr() - called: string=\"%s\" n %d \n", str, n));
151
152 return winsnstr(stdscr, str, n);
153 }
154
155 int mvinsnstr(int y, int x, const char *str, int n)
156 {
157 PDC_LOG(("mvinsnstr() - called: y %d x %d string=\"%s\" n %d \n",
158 y, x, str, n));
159
160 if (move(y, x) == ERR)
161 return ERR;
162
163 return winsnstr(stdscr, str, n);
164 }
165
166 int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n)
167 {
168 PDC_LOG(("mvwinsnstr() - called: y %d x %d string=\"%s\" n %d \n",
169 y, x, str, n));
170
171 if (wmove(win, y, x) == ERR)
172 return ERR;
173
174 return winsnstr(win, str, n);
175 }
176
177 #ifdef PDC_WIDE
178 int wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
179 {
180 const wchar_t *p;
181 int len;
182
183 PDC_LOG(("wins_nwstr() - called\n"));
184
185 if (!win || !wstr)
186 return ERR;
187
188 for (len = 0, p = wstr; *p; p++)
189 len++;
190
191 if (n < 0 || n < len)
192 n = len;
193
194 while (n)
195 if (winsch(win, wstr[--n]) == ERR)
196 return ERR;
197
198 return OK;
199 }
200
201 int ins_wstr(const wchar_t *wstr)
202 {
203 PDC_LOG(("ins_wstr() - called\n"));
204
205 return wins_nwstr(stdscr, wstr, -1);
206 }
207
208 int wins_wstr(WINDOW *win, const wchar_t *wstr)
209 {
210 PDC_LOG(("wins_wstr() - called\n"));
211
212 return wins_nwstr(win, wstr, -1);
213 }
214
215 int mvins_wstr(int y, int x, const wchar_t *wstr)
216 {
217 PDC_LOG(("mvins_wstr() - called\n"));
218
219 if (move(y, x) == ERR)
220 return ERR;
221
222 return wins_nwstr(stdscr, wstr, -1);
223 }
224
225 int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr)
226 {
227 PDC_LOG(("mvwinsstr() - called\n"));
228
229 if (wmove(win, y, x) == ERR)
230 return ERR;
231
232 return wins_nwstr(win, wstr, -1);
233 }
234
235 int ins_nwstr(const wchar_t *wstr, int n)
236 {
237 PDC_LOG(("ins_nwstr() - called\n"));
238
239 return wins_nwstr(stdscr, wstr, n);
240 }
241
242 int mvins_nwstr(int y, int x, const wchar_t *wstr, int n)
243 {
244 PDC_LOG(("mvinsnstr() - called\n"));
245
246 if (move(y, x) == ERR)
247 return ERR;
248
249 return wins_nwstr(stdscr, wstr, n);
250 }
251
252 int mvwins_nwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n)
253 {
254 PDC_LOG(("mvwinsnstr() - called\n"));
255
256 if (wmove(win, y, x) == ERR)
257 return ERR;
258
259 return wins_nwstr(win, wstr, n);
260 }
261 #endif
File pdcurses/instr.c added (mode: 100644) (index 00000000..bbf369cc)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: instr.c,v 1.44 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: instr
10
11 Synopsis:
12 int instr(char *str);
13 int innstr(char *str, int n);
14 int winstr(WINDOW *win, char *str);
15 int winnstr(WINDOW *win, char *str, int n);
16 int mvinstr(int y, int x, char *str);
17 int mvinnstr(int y, int x, char *str, int n);
18 int mvwinstr(WINDOW *win, int y, int x, char *str);
19 int mvwinnstr(WINDOW *win, int y, int x, char *str, int n);
20
21 int inwstr(wchar_t *wstr);
22 int innwstr(wchar_t *wstr, int n);
23 int winwstr(WINDOW *win, wchar_t *wstr);
24 int winnwstr(WINDOW *win, wchar_t *wstr, int n);
25 int mvinwstr(int y, int x, wchar_t *wstr);
26 int mvinnwstr(int y, int x, wchar_t *wstr, int n);
27 int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr);
28 int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n);
29
30 Description:
31 These functions take characters (or wide characters) from the
32 current or specified position in the window, and return them as
33 a string in str (or wstr). Attributes are ignored. The functions
34 with n as the last argument return a string at most n characters
35 long.
36
37 Return Value:
38 Upon successful completion, innstr(), mvinnstr(), mvwinnstr()
39 and winnstr() return the number of characters actually read into
40 the string; instr(), mvinstr(), mvwinstr() and winstr() return
41 OK. Otherwise, all these functions return ERR.
42
43 Portability X/Open BSD SYS V
44 instr Y - 4.0
45 winstr Y - 4.0
46 mvinstr Y - 4.0
47 mvwinstr Y - 4.0
48 innstr Y - 4.0
49 winnstr Y - 4.0
50 mvinnstr Y - 4.0
51 mvwinnstr Y - 4.0
52 inwstr Y
53 winwstr Y
54 mvinwstr Y
55 mvwinwstr Y
56 innwstr Y
57 winnwstr Y
58 mvinnwstr Y
59 mvwinnwstr Y
60
61 **man-end****************************************************************/
62
63 int winnstr(WINDOW *win, char *str, int n)
64 {
65 #ifdef PDC_WIDE
66 wchar_t wstr[513];
67
68 if (n < 0 || n > 512)
69 n = 512;
70
71 if (winnwstr(win, wstr, n) == ERR)
72 return ERR;
73
74 return PDC_wcstombs(str, wstr, n);
75 #else
76 chtype *src;
77 int i;
78
79 PDC_LOG(("winnstr() - called: n %d \n", n));
80
81 if (!win || !str)
82 return ERR;
83
84 if (n < 0 || (win->_curx + n) > win->_maxx)
85 n = win->_maxx - win->_curx;
86
87 src = win->_y[win->_cury] + win->_curx;
88
89 for (i = 0; i < n; i++)
90 str[i] = src[i] & A_CHARTEXT;
91
92 str[i] = '\0';
93
94 return i;
95 #endif
96 }
97
98 int instr(char *str)
99 {
100 PDC_LOG(("instr() - called: string=\"%s\"\n", str));
101
102 return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
103 }
104
105 int winstr(WINDOW *win, char *str)
106 {
107 PDC_LOG(("winstr() - called: \n"));
108
109 return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
110 }
111
112 int mvinstr(int y, int x, char *str)
113 {
114 PDC_LOG(("mvinstr() - called: y %d x %d \n", y, x));
115
116 if (move(y, x) == ERR)
117 return ERR;
118
119 return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
120 }
121
122 int mvwinstr(WINDOW *win, int y, int x, char *str)
123 {
124 PDC_LOG(("mvwinstr() - called: y %d x %d \n", y, x));
125
126 if (wmove(win, y, x) == ERR)
127 return ERR;
128
129 return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
130 }
131
132 int innstr(char *str, int n)
133 {
134 PDC_LOG(("innstr() - called: n %d \n", n));
135
136 return winnstr(stdscr, str, n);
137 }
138
139 int mvinnstr(int y, int x, char *str, int n)
140 {
141 PDC_LOG(("mvinnstr() - called: y %d x %d n %d \n", y, x, n));
142
143 if (move(y, x) == ERR)
144 return ERR;
145
146 return winnstr(stdscr, str, n);
147 }
148
149 int mvwinnstr(WINDOW *win, int y, int x, char *str, int n)
150 {
151 PDC_LOG(("mvwinnstr() - called: y %d x %d n %d \n", y, x, n));
152
153 if (wmove(win, y, x) == ERR)
154 return ERR;
155
156 return winnstr(win, str, n);
157 }
158
159 #ifdef PDC_WIDE
160 int winnwstr(WINDOW *win, wchar_t *wstr, int n)
161 {
162 chtype *src;
163 int i;
164
165 PDC_LOG(("winnstr() - called: n %d \n", n));
166
167 if (!win || !wstr)
168 return ERR;
169
170 if (n < 0 || (win->_curx + n) > win->_maxx)
171 n = win->_maxx - win->_curx;
172
173 src = win->_y[win->_cury] + win->_curx;
174
175 for (i = 0; i < n; i++)
176 wstr[i] = src[i] & A_CHARTEXT;
177
178 wstr[i] = L'\0';
179
180 return i;
181 }
182
183 int inwstr(wchar_t *wstr)
184 {
185 PDC_LOG(("inwstr() - called\n"));
186
187 return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
188 }
189
190 int winwstr(WINDOW *win, wchar_t *wstr)
191 {
192 PDC_LOG(("winwstr() - called\n"));
193
194 return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
195 }
196
197 int mvinwstr(int y, int x, wchar_t *wstr)
198 {
199 PDC_LOG(("mvinwstr() - called\n"));
200
201 if (move(y, x) == ERR)
202 return ERR;
203
204 return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
205 }
206
207 int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr)
208 {
209 PDC_LOG(("mvwinstr() - called\n"));
210
211 if (wmove(win, y, x) == ERR)
212 return ERR;
213
214 return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
215 }
216
217 int innwstr(wchar_t *wstr, int n)
218 {
219 PDC_LOG(("innwstr() - called\n"));
220
221 return winnwstr(stdscr, wstr, n);
222 }
223
224 int mvinnwstr(int y, int x, wchar_t *wstr, int n)
225 {
226 PDC_LOG(("mvinnstr() - called\n"));
227
228 if (move(y, x) == ERR)
229 return ERR;
230
231 return winnwstr(stdscr, wstr, n);
232 }
233
234 int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n)
235 {
236 PDC_LOG(("mvwinnwstr() - called\n"));
237
238 if (wmove(win, y, x) == ERR)
239 return ERR;
240
241 return winnwstr(win, wstr, n);
242 }
243 #endif
File pdcurses/kernel.c added (mode: 100644) (index 00000000..7e41ccfd)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: kernel.c,v 1.78 2008/07/15 17:13:26 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: kernel
10
11 Synopsis:
12 int def_prog_mode(void);
13 int def_shell_mode(void);
14 int reset_prog_mode(void);
15 int reset_shell_mode(void);
16 int resetty(void);
17 int savetty(void);
18 int ripoffline(int line, int (*init)(WINDOW *, int));
19 int curs_set(int visibility);
20 int napms(int ms);
21
22 int draino(int ms);
23 int resetterm(void);
24 int fixterm(void);
25 int saveterm(void);
26
27 Description:
28 def_prog_mode() and def_shell_mode() save the current terminal
29 modes as the "program" (in curses) or "shell" (not in curses)
30 state for use by the reset_prog_mode() and reset_shell_mode()
31 functions. This is done automatically by initscr().
32
33 reset_prog_mode() and reset_shell_mode() restore the terminal to
34 "program" (in curses) or "shell" (not in curses) state. These
35 are done automatically by endwin() and doupdate() after an
36 endwin(), so they would normally not be called before these
37 functions.
38
39 savetty() and resetty() save and restore the state of the
40 terminal modes. savetty() saves the current state in a buffer,
41 and resetty() restores the state to what it was at the last call
42 to savetty().
43
44 curs_set() alters the appearance of the cursor. A visibility of
45 0 makes it disappear; 1 makes it appear "normal" (usually an
46 underline) and 2 makes it "highly visible" (usually a block).
47
48 ripoffline() reduces the size of stdscr by one line. If the
49 "line" parameter is positive, the line is removed from the top
50 of the screen; if negative, from the bottom. Up to 5 lines can
51 be ripped off stdscr by calling ripoffline() repeatedly. The
52 function argument, init, is called from within initscr() or
53 newterm(), so ripoffline() must be called before either of these
54 functions. The init function receives a pointer to a one-line
55 WINDOW, and the width of the window. Calling ripoffline() with a
56 NULL init function pointer is an error.
57
58 napms() suspends the program for the specified number of
59 milliseconds. draino() is an archaic equivalent.
60
61 resetterm(), fixterm() and saveterm() are archaic equivalents
62 for reset_shell_mode(), reset_prog_mode() and def_prog_mode(),
63 respectively.
64
65 Return Value:
66 All functions return OK on success and ERR on error, except
67 curs_set(), which returns the previous visibility.
68
69 Portability X/Open BSD SYS V
70 def_prog_mode Y Y Y
71 def_shell_mode Y Y Y
72 reset_prog_mode Y Y Y
73 reset_shell_mode Y Y Y
74 resetty Y Y Y
75 savetty Y Y Y
76 ripoffline Y - 3.0
77 curs_set Y - 3.0
78 napms Y Y Y
79 draino -
80 resetterm -
81 fixterm -
82 saveterm -
83
84 **man-end****************************************************************/
85
86 #include <string.h>
87
88 RIPPEDOFFLINE linesripped[5];
89 char linesrippedoff = 0;
90
91 static struct cttyset
92 {
93 bool been_set;
94 SCREEN saved;
95 } ctty[3];
96
97 enum { PDC_SH_TTY, PDC_PR_TTY, PDC_SAVE_TTY };
98
99 static void _save_mode(int i)
100 {
101 ctty[i].been_set = TRUE;
102
103 memcpy(&(ctty[i].saved), SP, sizeof(SCREEN));
104
105 PDC_save_screen_mode(i);
106 }
107
108 static int _restore_mode(int i)
109 {
110 if (ctty[i].been_set == TRUE)
111 {
112 memcpy(SP, &(ctty[i].saved), sizeof(SCREEN));
113
114 if (ctty[i].saved.raw_out)
115 raw();
116
117 PDC_restore_screen_mode(i);
118
119 if ((LINES != ctty[i].saved.lines) ||
120 (COLS != ctty[i].saved.cols))
121 resize_term(ctty[i].saved.lines, ctty[i].saved.cols);
122
123 PDC_curs_set(ctty[i].saved.visibility);
124
125 PDC_gotoyx(ctty[i].saved.cursrow, ctty[i].saved.curscol);
126 }
127
128 return ctty[i].been_set ? OK : ERR;
129 }
130
131 int def_prog_mode(void)
132 {
133 PDC_LOG(("def_prog_mode() - called\n"));
134
135 _save_mode(PDC_PR_TTY);
136
137 return OK;
138 }
139
140 int def_shell_mode(void)
141 {
142 PDC_LOG(("def_shell_mode() - called\n"));
143
144 _save_mode(PDC_SH_TTY);
145
146 return OK;
147 }
148
149 int reset_prog_mode(void)
150 {
151 PDC_LOG(("reset_prog_mode() - called\n"));
152
153 _restore_mode(PDC_PR_TTY);
154 PDC_reset_prog_mode();
155
156 return OK;
157 }
158
159 int reset_shell_mode(void)
160 {
161 PDC_LOG(("reset_shell_mode() - called\n"));
162
163 _restore_mode(PDC_SH_TTY);
164 PDC_reset_shell_mode();
165
166 return OK;
167 }
168
169 int resetty(void)
170 {
171 PDC_LOG(("resetty() - called\n"));
172
173 return _restore_mode(PDC_SAVE_TTY);
174 }
175
176 int savetty(void)
177 {
178 PDC_LOG(("savetty() - called\n"));
179
180 _save_mode(PDC_SAVE_TTY);
181
182 return OK;
183 }
184
185 int curs_set(int visibility)
186 {
187 int ret_vis;
188
189 PDC_LOG(("curs_set() - called: visibility=%d\n", visibility));
190
191 if ((visibility < 0) || (visibility > 2))
192 return ERR;
193
194 ret_vis = PDC_curs_set(visibility);
195
196 /* If the cursor is changing from invisible to visible, update
197 its position */
198
199 if (visibility && !ret_vis)
200 PDC_gotoyx(SP->cursrow, SP->curscol);
201
202 return ret_vis;
203 }
204
205 int napms(int ms)
206 {
207 PDC_LOG(("napms() - called: ms=%d\n", ms));
208
209 if (ms)
210 PDC_napms(ms);
211
212 return OK;
213 }
214
215 int ripoffline(int line, int (*init)(WINDOW *, int))
216 {
217 PDC_LOG(("ripoffline() - called: line=%d\n", line));
218
219 if (linesrippedoff < 5 && line && init)
220 {
221 linesripped[(int)linesrippedoff].line = line;
222 linesripped[(int)linesrippedoff++].init = init;
223
224 return OK;
225 }
226
227 return ERR;
228 }
229
230 int draino(int ms)
231 {
232 PDC_LOG(("draino() - called\n"));
233
234 return napms(ms);
235 }
236
237 int resetterm(void)
238 {
239 PDC_LOG(("resetterm() - called\n"));
240
241 return reset_shell_mode();
242 }
243
244 int fixterm(void)
245 {
246 PDC_LOG(("fixterm() - called\n"));
247
248 return reset_prog_mode();
249 }
250
251 int saveterm(void)
252 {
253 PDC_LOG(("saveterm() - called\n"));
254
255 return def_prog_mode();
256 }
File pdcurses/keyname.c added (mode: 100644) (index 00000000..6d02cef8)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: keyname.c,v 1.8 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: keyname
10
11 Synopsis:
12 char *keyname(int key);
13
14 char *key_name(wchar_t c);
15
16 bool has_key(int key);
17
18 Description:
19 keyname() returns a string corresponding to the argument key.
20 key may be any key returned by wgetch().
21
22 key_name() is the wide-character version. It takes a wchar_t
23 parameter, but still returns a char *.
24
25 has_key() returns TRUE for recognized keys, FALSE otherwise.
26 This function is an ncurses extension.
27
28 Portability X/Open BSD SYS V
29 keyname Y - 3.0
30 key_name Y
31 has_key - - -
32
33 **man-end****************************************************************/
34
35 char *keyname(int key)
36 {
37 /* Key names must be in exactly the same order as in curses.h */
38
39 static char *key_name[] =
40 {
41 "KEY_BREAK", "KEY_DOWN", "KEY_UP", "KEY_LEFT", "KEY_RIGHT",
42 "KEY_HOME", "KEY_BACKSPACE", "KEY_F0", "KEY_F(1)", "KEY_F(2)",
43 "KEY_F(3)", "KEY_F(4)", "KEY_F(5)", "KEY_F(6)", "KEY_F(7)",
44 "KEY_F(8)", "KEY_F(9)", "KEY_F(10)", "KEY_F(11)", "KEY_F(12)",
45 "KEY_F(13)", "KEY_F(14)", "KEY_F(15)", "KEY_F(16)", "KEY_F(17)",
46 "KEY_F(18)", "KEY_F(19)", "KEY_F(20)", "KEY_F(21)", "KEY_F(22)",
47 "KEY_F(23)", "KEY_F(24)", "KEY_F(25)", "KEY_F(26)", "KEY_F(27)",
48 "KEY_F(28)", "KEY_F(29)", "KEY_F(30)", "KEY_F(31)", "KEY_F(32)",
49 "KEY_F(33)", "KEY_F(34)", "KEY_F(35)", "KEY_F(36)", "KEY_F(37)",
50 "KEY_F(38)", "KEY_F(39)", "KEY_F(40)", "KEY_F(41)", "KEY_F(42)",
51 "KEY_F(43)", "KEY_F(44)", "KEY_F(45)", "KEY_F(46)", "KEY_F(47)",
52 "KEY_F(48)", "KEY_F(49)", "KEY_F(50)", "KEY_F(51)", "KEY_F(52)",
53 "KEY_F(53)", "KEY_F(54)", "KEY_F(55)", "KEY_F(56)", "KEY_F(57)",
54 "KEY_F(58)", "KEY_F(59)", "KEY_F(60)", "KEY_F(61)", "KEY_F(62)",
55 "KEY_F(63)", "KEY_DL", "KEY_IL", "KEY_DC", "KEY_IC", "KEY_EIC",
56 "KEY_CLEAR", "KEY_EOS", "KEY_EOL", "KEY_SF", "KEY_SR",
57 "KEY_NPAGE", "KEY_PPAGE", "KEY_STAB", "KEY_CTAB", "KEY_CATAB",
58 "KEY_ENTER", "KEY_SRESET", "KEY_RESET", "KEY_PRINT", "KEY_LL",
59 "KEY_ABORT", "KEY_SHELP", "KEY_LHELP", "KEY_BTAB", "KEY_BEG",
60 "KEY_CANCEL", "KEY_CLOSE", "KEY_COMMAND", "KEY_COPY",
61 "KEY_CREATE", "KEY_END", "KEY_EXIT", "KEY_FIND", "KEY_HELP",
62 "KEY_MARK", "KEY_MESSAGE", "KEY_MOVE", "KEY_NEXT", "KEY_OPEN",
63 "KEY_OPTIONS", "KEY_PREVIOUS", "KEY_REDO", "KEY_REFERENCE",
64 "KEY_REFRESH", "KEY_REPLACE", "KEY_RESTART", "KEY_RESUME",
65 "KEY_SAVE", "KEY_SBEG", "KEY_SCANCEL", "KEY_SCOMMAND",
66 "KEY_SCOPY", "KEY_SCREATE", "KEY_SDC", "KEY_SDL", "KEY_SELECT",
67 "KEY_SEND", "KEY_SEOL", "KEY_SEXIT", "KEY_SFIND", "KEY_SHOME",
68 "KEY_SIC", "UNKNOWN KEY", "KEY_SLEFT", "KEY_SMESSAGE",
69 "KEY_SMOVE", "KEY_SNEXT", "KEY_SOPTIONS", "KEY_SPREVIOUS",
70 "KEY_SPRINT", "KEY_SREDO", "KEY_SREPLACE", "KEY_SRIGHT",
71 "KEY_SRSUME", "KEY_SSAVE", "KEY_SSUSPEND", "KEY_SUNDO",
72 "KEY_SUSPEND", "KEY_UNDO", "ALT_0", "ALT_1", "ALT_2", "ALT_3",
73 "ALT_4", "ALT_5", "ALT_6", "ALT_7", "ALT_8", "ALT_9", "ALT_A",
74 "ALT_B", "ALT_C", "ALT_D", "ALT_E", "ALT_F", "ALT_G", "ALT_H",
75 "ALT_I", "ALT_J", "ALT_K", "ALT_L", "ALT_M", "ALT_N", "ALT_O",
76 "ALT_P", "ALT_Q", "ALT_R", "ALT_S", "ALT_T", "ALT_U", "ALT_V",
77 "ALT_W", "ALT_X", "ALT_Y", "ALT_Z", "CTL_LEFT", "CTL_RIGHT",
78 "CTL_PGUP", "CTL_PGDN", "CTL_HOME", "CTL_END", "KEY_A1",
79 "KEY_A2", "KEY_A3", "KEY_B1", "KEY_B2", "KEY_B3", "KEY_C1",
80 "KEY_C2", "KEY_C3", "PADSLASH", "PADENTER", "CTL_PADENTER",
81 "ALT_PADENTER", "PADSTOP", "PADSTAR", "PADMINUS", "PADPLUS",
82 "CTL_PADSTOP", "CTL_PADCENTER", "CTL_PADPLUS", "CTL_PADMINUS",
83 "CTL_PADSLASH", "CTL_PADSTAR", "ALT_PADPLUS", "ALT_PADMINUS",
84 "ALT_PADSLASH", "ALT_PADSTAR", "ALT_PADSTOP", "CTL_INS",
85 "ALT_DEL", "ALT_INS", "CTL_UP", "CTL_DOWN", "CTL_TAB",
86 "ALT_TAB", "ALT_MINUS", "ALT_EQUAL", "ALT_HOME", "ALT_PGUP",
87 "ALT_PGDN", "ALT_END", "ALT_UP", "ALT_DOWN", "ALT_RIGHT",
88 "ALT_LEFT", "ALT_ENTER", "ALT_ESC", "ALT_BQUOTE",
89 "ALT_LBRACKET", "ALT_RBRACKET", "ALT_SEMICOLON", "ALT_FQUOTE",
90 "ALT_COMMA", "ALT_STOP", "ALT_FSLASH", "ALT_BKSP", "CTL_BKSP",
91 "PAD0", "CTL_PAD0", "CTL_PAD1", "CTL_PAD2", "CTL_PAD3",
92 "CTL_PAD4", "CTL_PAD5", "CTL_PAD6", "CTL_PAD7","CTL_PAD8",
93 "CTL_PAD9", "ALT_PAD0", "ALT_PAD1", "ALT_PAD2", "ALT_PAD3",
94 "ALT_PAD4", "ALT_PAD5", "ALT_PAD6", "ALT_PAD7", "ALT_PAD8",
95 "ALT_PAD9", "CTL_DEL", "ALT_BSLASH", "CTL_ENTER",
96 "SHF_PADENTER", "SHF_PADSLASH", "SHF_PADSTAR", "SHF_PADPLUS",
97 "SHF_PADMINUS", "SHF_UP", "SHF_DOWN", "SHF_IC", "SHF_DC",
98 "KEY_MOUSE", "KEY_SHIFT_L", "KEY_SHIFT_R", "KEY_CONTROL_L",
99 "KEY_CONTROL_R", "KEY_ALT_L", "KEY_ALT_R", "KEY_RESIZE",
100 "KEY_SUP", "KEY_SDOWN"
101 };
102
103 PDC_LOG(("keyname() - called: key %d\n", key));
104
105 if ((key >= 0) && (key < 0x80))
106 return unctrl((chtype)key);
107
108 return has_key(key) ? key_name[key - KEY_MIN] : "UNKNOWN KEY";
109 }
110
111 bool has_key(int key)
112 {
113 PDC_LOG(("has_key() - called: key %d\n", key));
114
115 return (key >= KEY_MIN && key <= KEY_MAX);
116 }
117
118 #ifdef PDC_WIDE
119 char *key_name(wchar_t c)
120 {
121 PDC_LOG(("key_name() - called\n"));
122
123 return keyname((int)c);
124 }
125 #endif
File pdcurses/mouse.c added (mode: 100644) (index 00000000..1f476dd4)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: mouse.c,v 1.45 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: mouse
10
11 Synopsis:
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 As of PDCurses 3.0, there are two separate mouse interfaces: the
31 classic interface, which is based on the undocumented Sys V
32 mouse functions; and an ncurses-compatible interface. Both are
33 active at all times, and you can mix and match functions from
34 each, though it's not recommended. The ncurses interface is
35 essentially an emulation layer built on top of the classic
36 interface; it's here to allow easier porting of ncurses apps.
37
38 The classic interface: mouse_set(), mouse_on(), mouse_off(),
39 request_mouse_pos(), map_button(), wmouse_position(),
40 getmouse(), and getbmap(). An application using this interface
41 would start by calling mouse_set() or mouse_on() with a non-zero
42 value, often ALL_MOUSE_EVENTS. Then it would check for a
43 KEY_MOUSE return from getch(). If found, it would call
44 request_mouse_pos() to get the current mouse status.
45
46 mouse_set(), mouse_on() and mouse_off() are analagous to
47 attrset(), attron() and attroff(). These functions set the
48 mouse button events to trap. The button masks used in these
49 functions are defined in curses.h and can be or'ed together.
50 They are the group of masks starting with BUTTON1_RELEASED.
51
52 request_mouse_pos() requests curses to fill in the Mouse_status
53 structure with the current state of the mouse.
54
55 map_button() enables the specified mouse action to activate the
56 Soft Label Keys if the action occurs over the area of the screen
57 where the Soft Label Keys are displayed. The mouse actions are
58 defined in curses.h in the group that starts with BUTTON_RELEASED.
59
60 wmouse_position() determines if the current mouse position is
61 within the window passed as an argument. If the mouse is
62 outside the current window, -1 is returned in the y and x
63 arguments; otherwise the y and x coordinates of the mouse
64 (relative to the top left corner of the window) are returned in
65 y and x.
66
67 getmouse() returns the current status of the trapped mouse
68 buttons as set by mouse_set() or mouse_on().
69
70 getbmap() returns the current status of the button action used
71 to map a mouse action to the Soft Label Keys as set by the
72 map_button() function.
73
74 The ncurses interface: mouseinterval(), wenclose(),
75 wmouse_trafo(), mouse_trafo(), mousemask(), nc_getmouse(), and
76 ungetmouse(). A typical application using this interface would
77 start by calling mousemask() with a non-zero value, often
78 ALL_MOUSE_EVENTS. Then it would check for a KEY_MOUSE return
79 from getch(). If found, it would call nc_getmouse() to get the
80 current mouse status.
81
82 mouseinterval() sets the timeout for a mouse click. On all
83 current platforms, PDCurses receives mouse button press and
84 release events, but must synthesize click events. It does this
85 by checking whether a release event is queued up after a press
86 event. If it gets a press event, and there are no more events
87 waiting, it will wait for the timeout interval, then check again
88 for a release. A press followed by a release is reported as
89 BUTTON_CLICKED; otherwise it's passed through as BUTTON_PRESSED.
90 The default timeout is 150ms; valid values are 0 (no clicks
91 reported) through 1000ms. In x11, the timeout can also be set
92 via the clickPeriod resource. The return value from
93 mouseinterval() is the old timeout. To check the old value
94 without setting a new one, call it with a parameter of -1. Note
95 that although there's no classic equivalent for this function
96 (apart from the clickPeriod resource), the value set applies in
97 both interfaces.
98
99 wenclose() reports whether the given screen-relative y, x
100 coordinates fall within the given window.
101
102 wmouse_trafo() converts between screen-relative and window-
103 relative coordinates. A to_screen parameter of TRUE means to
104 convert from window to screen; otherwise the reverse. The
105 function returns FALSE if the coordinates aren't within the
106 window, or if any of the parameters are NULL. The coordinates
107 have been converted when the function returns TRUE.
108
109 mouse_trafo() is the stdscr version of wmouse_trafo().
110
111 mousemask() is nearly equivalent to mouse_set(), but instead of
112 OK/ERR, it returns the value of the mask after setting it. (This
113 isn't necessarily the same value passed in, since the mask could
114 be altered on some platforms.) And if the second parameter is a
115 non-null pointer, mousemask() stores the previous mask value
116 there. Also, since the ncurses interface doesn't work with
117 PDCurses' BUTTON_MOVED events, mousemask() filters them out.
118
119 nc_getmouse() returns the current mouse status in an MEVENT
120 struct. This is equivalent to ncurses' getmouse(), renamed to
121 avoid conflict with PDCurses' getmouse(). But if you define
122 NCURSES_MOUSE_VERSION (preferably as 2) before including
123 curses.h, it defines getmouse() to nc_getmouse(), along with a
124 few other redefintions needed for compatibility with ncurses
125 code. nc_getmouse() calls request_mouse_pos(), which (not
126 getmouse()) is the classic equivalent.
127
128 ungetmouse() is the mouse equivalent of ungetch(). However,
129 PDCurses doesn't maintain a queue of mouse events; only one can
130 be pushed back, and it can overwrite or be overwritten by real
131 mouse events.
132
133 Portability X/Open BSD SYS V
134 mouse_set - - 4.0
135 mouse_on - - 4.0
136 mouse_off - - 4.0
137 request_mouse_pos - - 4.0
138 map_button - - 4.0
139 wmouse_position - - 4.0
140 getmouse - - 4.0
141 getbmap - - 4.0
142 mouseinterval - - -
143 wenclose - - -
144 wmouse_trafo - - -
145 mouse_trafo - - -
146 mousemask - - -
147 nc_getmouse - - -
148 ungetmouse - - -
149
150 **man-end****************************************************************/
151
152 #include <string.h>
153
154 static bool ungot = FALSE;
155
156 int mouse_set(unsigned long mbe)
157 {
158 PDC_LOG(("mouse_set() - called: event %x\n", mbe));
159
160 SP->_trap_mbe = mbe;
161 return PDC_mouse_set();
162 }
163
164 int mouse_on(unsigned long mbe)
165 {
166 PDC_LOG(("mouse_on() - called: event %x\n", mbe));
167
168 SP->_trap_mbe |= mbe;
169 return PDC_mouse_set();
170 }
171
172 int mouse_off(unsigned long mbe)
173 {
174 PDC_LOG(("mouse_off() - called: event %x\n", mbe));
175
176 SP->_trap_mbe &= ~mbe;
177 return PDC_mouse_set();
178 }
179
180 int map_button(unsigned long button)
181 {
182 PDC_LOG(("map_button() - called: button %x\n", button));
183
184 /****************** this does nothing at the moment ***************/
185 SP->_map_mbe_to_key = button;
186
187 return OK;
188 }
189
190 int request_mouse_pos(void)
191 {
192 PDC_LOG(("request_mouse_pos() - called\n"));
193
194 Mouse_status = pdc_mouse_status;
195
196 return OK;
197 }
198
199 void wmouse_position(WINDOW *win, int *y, int *x)
200 {
201 PDC_LOG(("wmouse_position() - called\n"));
202
203 if (win && wenclose(win, MOUSE_Y_POS, MOUSE_X_POS))
204 {
205 if (y)
206 *y = MOUSE_Y_POS - win->_begy;
207 if (x)
208 *x = MOUSE_X_POS - win->_begx;
209 }
210 else
211 {
212 if (y)
213 *y = -1;
214 if (x)
215 *x = -1;
216 }
217 }
218
219 unsigned long getmouse(void)
220 {
221 PDC_LOG(("getmouse() - called\n"));
222
223 return SP->_trap_mbe;
224 }
225
226 unsigned long getbmap(void)
227 {
228 PDC_LOG(("getbmap() - called\n"));
229
230 return SP->_map_mbe_to_key;
231 }
232
233 /* ncurses mouse interface */
234
235 int mouseinterval(int wait)
236 {
237 int old_wait;
238
239 PDC_LOG(("mouseinterval() - called: %d\n", wait));
240
241 old_wait = SP->mouse_wait;
242
243 if (wait >= 0 && wait <= 1000)
244 SP->mouse_wait = wait;
245
246 return old_wait;
247 }
248
249 bool wenclose(const WINDOW *win, int y, int x)
250 {
251 PDC_LOG(("wenclose() - called: %p %d %d\n", win, y, x));
252
253 return (win && y >= win->_begy && y < win->_begy + win->_maxy
254 && x >= win->_begx && x < win->_begx + win->_maxx);
255 }
256
257 bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen)
258 {
259 int newy, newx;
260
261 PDC_LOG(("wmouse_trafo() - called\n"));
262
263 if (!win || !y || !x)
264 return FALSE;
265
266 newy = *y;
267 newx = *x;
268
269 if (to_screen)
270 {
271 newy += win->_begy;
272 newx += win->_begx;
273
274 if (!wenclose(win, newy, newx))
275 return FALSE;
276 }
277 else
278 {
279 if (wenclose(win, newy, newx))
280 {
281 newy -= win->_begy;
282 newx -= win->_begx;
283 }
284 else
285 return FALSE;
286 }
287
288 *y = newy;
289 *x = newx;
290
291 return TRUE;
292 }
293
294 bool mouse_trafo(int *y, int *x, bool to_screen)
295 {
296 PDC_LOG(("mouse_trafo() - called\n"));
297
298 return wmouse_trafo(stdscr, y, x, to_screen);
299 }
300
301 mmask_t mousemask(mmask_t mask, mmask_t *oldmask)
302 {
303 PDC_LOG(("mousemask() - called\n"));
304
305 if (oldmask)
306 *oldmask = SP->_trap_mbe;
307
308 /* The ncurses interface doesn't work with our move events, so
309 filter them here */
310
311 mask &= ~(BUTTON1_MOVED | BUTTON2_MOVED | BUTTON3_MOVED);
312
313 mouse_set(mask);
314
315 return SP->_trap_mbe;
316 }
317
318 int nc_getmouse(MEVENT *event)
319 {
320 int i;
321 mmask_t bstate = 0;
322
323 PDC_LOG(("nc_getmouse() - called\n"));
324
325 if (!event)
326 return ERR;
327
328 ungot = FALSE;
329
330 request_mouse_pos();
331
332 event->id = 0;
333
334 event->x = Mouse_status.x;
335 event->y = Mouse_status.y;
336 event->z = 0;
337
338 for (i = 0; i < 3; i++)
339 {
340 if (Mouse_status.changes & (1 << i))
341 {
342 int shf = i * 5;
343 short button = Mouse_status.button[i] & BUTTON_ACTION_MASK;
344
345 if (button == BUTTON_RELEASED)
346 bstate |= (BUTTON1_RELEASED << shf);
347 else if (button == BUTTON_PRESSED)
348 bstate |= (BUTTON1_PRESSED << shf);
349 else if (button == BUTTON_CLICKED)
350 bstate |= (BUTTON1_CLICKED << shf);
351 else if (button == BUTTON_DOUBLE_CLICKED)
352 bstate |= (BUTTON1_DOUBLE_CLICKED << shf);
353
354 button = Mouse_status.button[i] & BUTTON_MODIFIER_MASK;
355
356 if (button & PDC_BUTTON_SHIFT)
357 bstate |= BUTTON_MODIFIER_SHIFT;
358 if (button & PDC_BUTTON_CONTROL)
359 bstate |= BUTTON_MODIFIER_CONTROL;
360 if (button & PDC_BUTTON_ALT)
361 bstate |= BUTTON_MODIFIER_ALT;
362 }
363 }
364
365 if (MOUSE_WHEEL_UP)
366 bstate |= BUTTON4_PRESSED;
367 else if (MOUSE_WHEEL_DOWN)
368 bstate |= BUTTON5_PRESSED;
369
370 /* extra filter pass -- mainly for button modifiers */
371
372 event->bstate = bstate & SP->_trap_mbe;
373
374 return OK;
375 }
376
377 int ungetmouse(MEVENT *event)
378 {
379 int i;
380 unsigned long bstate;
381
382 PDC_LOG(("ungetmouse() - called\n"));
383
384 if (!event || ungot)
385 return ERR;
386
387 ungot = TRUE;
388
389 pdc_mouse_status.x = event->x;
390 pdc_mouse_status.y = event->y;
391
392 pdc_mouse_status.changes = 0;
393 bstate = event->bstate;
394
395 for (i = 0; i < 3; i++)
396 {
397 int shf = i * 5;
398 short button = 0;
399
400 if (bstate & ((BUTTON1_RELEASED | BUTTON1_PRESSED |
401 BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED) << shf))
402 {
403 pdc_mouse_status.changes |= 1 << i;
404
405 if (bstate & (BUTTON1_PRESSED << shf))
406 button = BUTTON_PRESSED;
407 if (bstate & (BUTTON1_CLICKED << shf))
408 button = BUTTON_CLICKED;
409 if (bstate & (BUTTON1_DOUBLE_CLICKED << shf))
410 button = BUTTON_DOUBLE_CLICKED;
411
412 if (bstate & BUTTON_MODIFIER_SHIFT)
413 button |= PDC_BUTTON_SHIFT;
414 if (bstate & BUTTON_MODIFIER_CONTROL)
415 button |= PDC_BUTTON_CONTROL;
416 if (bstate & BUTTON_MODIFIER_ALT)
417 button |= PDC_BUTTON_ALT;
418 }
419
420 pdc_mouse_status.button[i] = button;
421 }
422
423 if (bstate & BUTTON4_PRESSED)
424 pdc_mouse_status.changes |= PDC_MOUSE_WHEEL_UP;
425 else if (bstate & BUTTON5_PRESSED)
426 pdc_mouse_status.changes |= PDC_MOUSE_WHEEL_DOWN;
427
428 return ungetch(KEY_MOUSE);
429 }
File pdcurses/move.c added (mode: 100644) (index 00000000..30e59084)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: move.c,v 1.28 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: move
10
11 Synopsis:
12 int move(int y, int x);
13 int wmove(WINDOW *win, int y, int x);
14
15 Description:
16 The cursor associated with the window is moved to the given
17 location. This does not move the physical cursor of the
18 terminal until refresh() is called. The position specified is
19 relative to the upper left corner of the window, which is (0,0).
20
21 Return Value:
22 All functions return OK on success and ERR on error.
23
24 Portability X/Open BSD SYS V
25 move Y Y Y
26 wmove Y Y Y
27
28 **man-end****************************************************************/
29
30 int move(int y, int x)
31 {
32 PDC_LOG(("move() - called: y=%d x=%d\n", y, x));
33
34 if (!stdscr || x < 0 || y < 0 || x >= stdscr->_maxx || y >= stdscr->_maxy)
35 return ERR;
36
37 stdscr->_curx = x;
38 stdscr->_cury = y;
39
40 return OK;
41 }
42
43 int wmove(WINDOW *win, int y, int x)
44 {
45 PDC_LOG(("wmove() - called: y=%d x=%d\n", y, x));
46
47 if (!win || x < 0 || y < 0 || x >= win->_maxx || y >= win->_maxy)
48 return ERR;
49
50 win->_curx = x;
51 win->_cury = y;
52
53 return OK;
54 }
File pdcurses/outopts.c added (mode: 100644) (index 00000000..0a8fd2d5)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: outopts.c,v 1.39 2008/07/14 12:22:13 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: outopts
10
11 Synopsis:
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 With clearok(), if bf is TRUE, the next call to wrefresh() with
25 this window will clear the screen completely and redraw the
26 entire screen.
27
28 immedok(), called with a second argument of TRUE, causes an
29 automatic wrefresh() every time a change is made to the
30 specified window.
31
32 Normally, the hardware cursor is left at the location of the
33 window being refreshed. leaveok() allows the cursor to be
34 left wherever the update happens to leave it. It's useful
35 for applications where the cursor is not used, since it reduces
36 the need for cursor motions. If possible, the cursor is made
37 invisible when this option is enabled.
38
39 wsetscrreg() sets a scrolling region in a window; "top" and
40 "bot" are the line numbers for the top and bottom margins. If
41 this option and scrollok() are enabled, any attempt to move off
42 the bottom margin will cause all lines in the scrolling region
43 to scroll up one line. setscrreg() is the stdscr version.
44
45 idlok() and idcok() do nothing in PDCurses, but are provided for
46 compatibility with other curses implementations.
47
48 raw_output() enables the output of raw characters using the
49 standard *add* and *ins* curses functions (that is, it disables
50 translation of control characters).
51
52 Return Value:
53 All functions return OK on success and ERR on error.
54
55 Portability X/Open BSD SYS V
56 clearok Y Y Y
57 idlok Y Y Y
58 idcok Y - 4.0
59 immedok Y - 4.0
60 leaveok Y Y Y
61 setscrreg Y Y Y
62 wsetscrreg Y Y Y
63 scrollok Y Y Y
64 raw_output - - -
65
66 **man-end****************************************************************/
67
68 int clearok(WINDOW *win, bool bf)
69 {
70 PDC_LOG(("clearok() - called\n"));
71
72 if (!win)
73 return ERR;
74
75 win->_clear = bf;
76
77 return OK;
78 }
79
80 int idlok(WINDOW *win, bool bf)
81 {
82 PDC_LOG(("idlok() - called\n"));
83
84 return OK;
85 }
86
87 void idcok(WINDOW *win, bool bf)
88 {
89 PDC_LOG(("idcok() - called\n"));
90 }
91
92 void immedok(WINDOW *win, bool bf)
93 {
94 PDC_LOG(("immedok() - called\n"));
95
96 if (win)
97 win->_immed = bf;
98 }
99
100 int leaveok(WINDOW *win, bool bf)
101 {
102 PDC_LOG(("leaveok() - called\n"));
103
104 if (!win)
105 return ERR;
106
107 win->_leaveit = bf;
108
109 curs_set(!bf);
110
111 return OK;
112 }
113
114 int setscrreg(int top, int bottom)
115 {
116 PDC_LOG(("setscrreg() - called: top %d bottom %d\n", top, bottom));
117
118 return wsetscrreg(stdscr, top, bottom);
119 }
120
121 int wsetscrreg(WINDOW *win, int top, int bottom)
122 {
123 PDC_LOG(("wsetscrreg() - called: top %d bottom %d\n", top, bottom));
124
125 if (win && 0 <= top && top <= win->_cury &&
126 win->_cury <= bottom && bottom < win->_maxy)
127 {
128 win->_tmarg = top;
129 win->_bmarg = bottom;
130
131 return OK;
132 }
133 else
134 return ERR;
135 }
136
137 int scrollok(WINDOW *win, bool bf)
138 {
139 PDC_LOG(("scrollok() - called\n"));
140
141 if (!win)
142 return ERR;
143
144 win->_scroll = bf;
145
146 return OK;
147 }
148
149 int raw_output(bool bf)
150 {
151 PDC_LOG(("raw_output() - called\n"));
152
153 SP->raw_out = bf;
154
155 return OK;
156 }
File pdcurses/overlay.c added (mode: 100644) (index 00000000..f9bba50f)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: overlay.c,v 1.36 2008/07/14 12:35:23 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: overlay
10
11 Synopsis:
12 int overlay(const WINDOW *src_w, WINDOW *dst_w)
13 int overwrite(const WINDOW *src_w, WINDOW *dst_w)
14 int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
15 int src_tc, int dst_tr, int dst_tc, int dst_br,
16 int dst_bc, bool overlay)
17
18 Description:
19 overlay() and overwrite() copy all the text from src_w into
20 dst_w. The windows need not be the same size. Those characters
21 in the source window that intersect with the destination window
22 are copied, so that the characters appear in the same physical
23 position on the screen. The difference between the two functions
24 is that overlay() is non-destructive (blanks are not copied)
25 while overwrite() is destructive (blanks are copied).
26
27 copywin() is similar, but doesn't require that the two windows
28 overlap. The arguments src_tc and src_tr specify the top left
29 corner of the region to be copied. dst_tc, dst_tr, dst_br, and
30 dst_bc specify the region within the destination window to copy
31 to. The argument "overlay", if TRUE, indicates that the copy is
32 done non-destructively (as in overlay()); blanks in the source
33 window are not copied to the destination window. When overlay is
34 FALSE, blanks are copied.
35
36 Return Value:
37 All functions return OK on success and ERR on error.
38
39 Portability X/Open BSD SYS V
40 overlay Y Y Y
41 overwrite Y Y Y
42 copywin Y - 3.0
43
44 **man-end****************************************************************/
45
46 /* Thanks to Andreas Otte <venn@@uni-paderborn.de> for the
47 corrected overlay()/overwrite() behavior. */
48
49 static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
50 int src_tc, int src_br, int src_bc, int dst_tr,
51 int dst_tc, bool overlay)
52 {
53 int col, line, y1, fc, *minchng, *maxchng;
54 chtype *w1ptr, *w2ptr;
55
56 int lc = 0;
57 int xdiff = src_bc - src_tc;
58 int ydiff = src_br - src_tr;
59
60 if (!src_w || !dst_w)
61 return ERR;
62
63 minchng = dst_w->_firstch;
64 maxchng = dst_w->_lastch;
65
66 for (y1 = 0; y1 < dst_tr; y1++)
67 {
68 minchng++;
69 maxchng++;
70 }
71
72 for (line = 0; line < ydiff; line++)
73 {
74 w1ptr = src_w->_y[line + src_tr] + src_tc;
75 w2ptr = dst_w->_y[line + dst_tr] + dst_tc;
76
77 fc = _NO_CHANGE;
78
79 for (col = 0; col < xdiff; col++)
80 {
81 if ((*w1ptr) != (*w2ptr) &&
82 !((*w1ptr & A_CHARTEXT) == ' ' && overlay))
83 {
84 *w2ptr = *w1ptr;
85
86 if (fc == _NO_CHANGE)
87 fc = col + dst_tc;
88
89 lc = col + dst_tc;
90 }
91
92 w1ptr++;
93 w2ptr++;
94 }
95
96 if (*minchng == _NO_CHANGE)
97 {
98 *minchng = fc;
99 *maxchng = lc;
100 }
101 else if (fc != _NO_CHANGE)
102 {
103 if (fc < *minchng)
104 *minchng = fc;
105 if (lc > *maxchng)
106 *maxchng = lc;
107 }
108
109 minchng++;
110 maxchng++;
111 }
112
113 return OK;
114 }
115
116 int overlay(const WINDOW *src_w, WINDOW *dst_w)
117 {
118 int first_line, first_col, last_line, last_col;
119 int src_start_x, src_start_y, dst_start_x, dst_start_y;
120 int xdiff, ydiff;
121
122 PDC_LOG(("overlay() - called\n"));
123
124 if (!src_w || !dst_w)
125 return ERR;
126
127 first_col = max(dst_w->_begx, src_w->_begx);
128 first_line = max(dst_w->_begy, src_w->_begy);
129
130 last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
131 last_line = min(src_w->_begy + src_w->_maxy, dst_w->_begy + dst_w->_maxy);
132
133 /* determine the overlapping region of the two windows in real
134 coordinates */
135
136 /* if no overlapping region, do nothing */
137
138 if ((last_col < first_col) || (last_line < first_line))
139 return OK;
140
141 /* size of overlapping region */
142
143 xdiff = last_col - first_col;
144 ydiff = last_line - first_line;
145
146 if (src_w->_begx <= dst_w->_begx)
147 {
148 src_start_x = dst_w->_begx - src_w->_begx;
149 dst_start_x = 0;
150 }
151 else
152 {
153 dst_start_x = src_w->_begx - dst_w->_begx;
154 src_start_x = 0;
155 }
156
157 if (src_w->_begy <= dst_w->_begy)
158 {
159 src_start_y = dst_w->_begy - src_w->_begy;
160 dst_start_y = 0;
161 }
162 else
163 {
164 dst_start_y = src_w->_begy - dst_w->_begy;
165 src_start_y = 0;
166 }
167
168 return _copy_win(src_w, dst_w, src_start_y, src_start_x,
169 src_start_y + ydiff, src_start_x + xdiff,
170 dst_start_y, dst_start_x, TRUE);
171 }
172
173 int overwrite(const WINDOW *src_w, WINDOW *dst_w)
174 {
175 int first_line, first_col, last_line, last_col;
176 int src_start_x, src_start_y, dst_start_x, dst_start_y;
177 int xdiff, ydiff;
178
179 PDC_LOG(("overwrite() - called\n"));
180
181 if (!src_w || !dst_w)
182 return ERR;
183
184 first_col = max(dst_w->_begx, src_w->_begx);
185 first_line = max(dst_w->_begy, src_w->_begy);
186
187 last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
188 last_line = min(src_w->_begy + src_w->_maxy, dst_w->_begy + dst_w->_maxy);
189
190 /* determine the overlapping region of the two windows in real
191 coordinates */
192
193 /* if no overlapping region, do nothing */
194
195 if ((last_col < first_col) || (last_line < first_line))
196 return OK;
197
198 /* size of overlapping region */
199
200 xdiff = last_col - first_col;
201 ydiff = last_line - first_line;
202
203 if (src_w->_begx <= dst_w->_begx)
204 {
205 src_start_x = dst_w->_begx - src_w->_begx;
206 dst_start_x = 0;
207 }
208 else
209 {
210 dst_start_x = src_w->_begx - dst_w->_begx;
211 src_start_x = 0;
212 }
213
214 if (src_w->_begy <= dst_w->_begy)
215 {
216 src_start_y = dst_w->_begy - src_w->_begy;
217 dst_start_y = 0;
218 }
219 else
220 {
221 dst_start_y = src_w->_begy - dst_w->_begy;
222 src_start_y = 0;
223 }
224
225 return _copy_win(src_w, dst_w, src_start_y, src_start_x,
226 src_start_y + ydiff, src_start_x + xdiff,
227 dst_start_y, dst_start_x, FALSE);
228 }
229
230 int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int src_tc,
231 int dst_tr, int dst_tc, int dst_br, int dst_bc, int overlay)
232 {
233 int src_end_x, src_end_y;
234 int src_rows, src_cols, dst_rows, dst_cols;
235 int min_rows, min_cols;
236
237 PDC_LOG(("copywin() - called\n"));
238
239 if (!src_w || !dst_w || dst_w == curscr || dst_br > dst_w->_maxy
240 || dst_bc > dst_w->_maxx || dst_tr < 0 || dst_tc < 0)
241 return ERR;
242
243 src_rows = src_w->_maxy - src_tr;
244 src_cols = src_w->_maxx - src_tc;
245 dst_rows = dst_br - dst_tr + 1;
246 dst_cols = dst_bc - dst_tc + 1;
247
248 min_rows = min(src_rows, dst_rows);
249 min_cols = min(src_cols, dst_cols);
250
251 src_end_y = src_tr + min_rows;
252 src_end_x = src_tc + min_cols;
253
254 return _copy_win(src_w, dst_w, src_tr, src_tc, src_end_y, src_end_x,
255 dst_tr, dst_tc, overlay);
256 }
File pdcurses/pad.c added (mode: 100644) (index 00000000..ccc5db20)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: pad.c,v 1.50 2008/07/14 12:22:13 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: pad
10
11 Synopsis:
12 WINDOW *newpad(int nlines, int ncols);
13 WINDOW *subpad(WINDOW *orig, int nlines, int ncols,
14 int begy, int begx);
15 int prefresh(WINDOW *win, int py, int px, int sy1, int sx1,
16 int sy2, int sx2);
17 int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1,
18 int sy2, int sx2);
19 int pechochar(WINDOW *pad, chtype ch);
20 int pecho_wchar(WINDOW *pad, const cchar_t *wch);
21
22 Description:
23 A pad is a special kind of window, which is not restricted by
24 the screen size, and is not necessarily associated with a
25 particular part of the screen. You can use a pad when you need
26 a large window, and only a part of the window will be on the
27 screen at one time. Pads are not refreshed automatically (e.g.,
28 from scrolling or echoing of input). You can't call wrefresh()
29 with a pad as an argument; use prefresh() or pnoutrefresh()
30 instead. Note that these routines require additional parameters
31 to specify the part of the pad to be displayed, and the location
32 to use on the screen.
33
34 newpad() creates a new pad data structure.
35
36 subpad() creates a new sub-pad within a pad, at position (begy,
37 begx), with dimensions of nlines lines and ncols columns. This
38 position is relative to the pad, and not to the screen as with
39 subwin. Changes to either the parent pad or sub-pad will affect
40 both. When using sub-pads, you may need to call touchwin()
41 before calling prefresh().
42
43 pnoutrefresh() copies the specified pad to the virtual screen.
44
45 prefresh() calls pnoutrefresh(), followed by doupdate().
46
47 These routines are analogous to wnoutrefresh() and wrefresh().
48 (py, px) specifies the upper left corner of the part of the pad
49 to be displayed; (sy1, sx1) and (sy2, sx2) describe the screen
50 rectangle that will contain the selected part of the pad.
51
52 pechochar() is functionally equivalent to addch() followed by
53 a call to prefresh(), with the last-used coordinates and
54 dimensions. pecho_wchar() is the wide-character version.
55
56 Return Value:
57 All functions return OK on success and ERR on error.
58
59 Portability X/Open BSD SYS V
60 newpad Y - Y
61 subpad Y - Y
62 prefresh Y - Y
63 pnoutrefresh Y - Y
64 pechochar Y - 3.0
65 pecho_wchar Y
66
67 **man-end****************************************************************/
68
69 #include <string.h>
70
71 /* save values for pechochar() */
72
73 static int save_pminrow, save_pmincol;
74 static int save_sminrow, save_smincol, save_smaxrow, save_smaxcol;
75
76 WINDOW *newpad(int nlines, int ncols)
77 {
78 WINDOW *win;
79
80 PDC_LOG(("newpad() - called: lines=%d cols=%d\n", nlines, ncols));
81
82 if ( !(win = PDC_makenew(nlines, ncols, -1, -1))
83 || !(win = PDC_makelines(win)) )
84 return (WINDOW *)NULL;
85
86 werase(win);
87
88 win->_flags = _PAD;
89
90 /* save default values in case pechochar() is the first call to
91 prefresh(). */
92
93 save_pminrow = 0;
94 save_pmincol = 0;
95 save_sminrow = 0;
96 save_smincol = 0;
97 save_smaxrow = min(LINES, nlines) - 1;
98 save_smaxcol = min(COLS, ncols) - 1;
99
100 return win;
101 }
102
103 WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx)
104 {
105 WINDOW *win;
106 int i;
107 int j = begy;
108 int k = begx;
109
110 PDC_LOG(("subpad() - called: lines=%d cols=%d begy=%d begx=%d\n",
111 nlines, ncols, begy, begx));
112
113 if (!orig || !(orig->_flags & _PAD))
114 return (WINDOW *)NULL;
115
116 /* make sure window fits inside the original one */
117
118 if ((begy < orig->_begy) || (begx < orig->_begx) ||
119 (begy + nlines) > (orig->_begy + orig->_maxy) ||
120 (begx + ncols) > (orig->_begx + orig->_maxx))
121 return (WINDOW *)NULL;
122
123 if (!nlines)
124 nlines = orig->_maxy - 1 - j;
125
126 if (!ncols)
127 ncols = orig->_maxx - 1 - k;
128
129 if ( !(win = PDC_makenew(nlines, ncols, begy, begx)) )
130 return (WINDOW *)NULL;
131
132 /* initialize window variables */
133
134 win->_attrs = orig->_attrs;
135 win->_leaveit = orig->_leaveit;
136 win->_scroll = orig->_scroll;
137 win->_nodelay = orig->_nodelay;
138 win->_use_keypad = orig->_use_keypad;
139 win->_parent = orig;
140
141 for (i = 0; i < nlines; i++)
142 win->_y[i] = (orig->_y[j++]) + k;
143
144 win->_flags = _SUBPAD;
145
146 /* save default values in case pechochar() is the first call
147 to prefresh(). */
148
149 save_pminrow = 0;
150 save_pmincol = 0;
151 save_sminrow = 0;
152 save_smincol = 0;
153 save_smaxrow = min(LINES, nlines) - 1;
154 save_smaxcol = min(COLS, ncols) - 1;
155
156 return win;
157 }
158
159 int prefresh(WINDOW *win, int py, int px, int sy1, int sx1, int sy2, int sx2)
160 {
161 PDC_LOG(("prefresh() - called\n"));
162
163 if (pnoutrefresh(win, py, px, sy1, sx1, sy2, sx2) == ERR)
164 return ERR;
165
166 doupdate();
167 return OK;
168 }
169
170 int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2)
171 {
172 int num_cols;
173 int sline = sy1;
174 int pline = py;
175
176 PDC_LOG(("pnoutrefresh() - called\n"));
177
178 if (!w || !(w->_flags & (_PAD|_SUBPAD)) || (sy2 >= LINES) || (sy2 >= COLS))
179 return ERR;
180
181 if (py < 0)
182 py = 0;
183 if (px < 0)
184 px = 0;
185 if (sy1 < 0)
186 sy1 = 0;
187 if (sx1 < 0)
188 sx1 = 0;
189
190 if (sy2 < sy1 || sx2 < sx1)
191 return ERR;
192
193 num_cols = min((sx2 - sx1 + 1), (w->_maxx - px));
194
195 while (sline <= sy2)
196 {
197 if (pline < w->_maxy)
198 {
199 memcpy(curscr->_y[sline] + sx1, w->_y[pline] + px,
200 num_cols * sizeof(chtype));
201
202 if ((curscr->_firstch[sline] == _NO_CHANGE)
203 || (curscr->_firstch[sline] > sx1))
204 curscr->_firstch[sline] = sx1;
205
206 if (sx2 > curscr->_lastch[sline])
207 curscr->_lastch[sline] = sx2;
208
209 w->_firstch[pline] = _NO_CHANGE; /* updated now */
210 w->_lastch[pline] = _NO_CHANGE; /* updated now */
211 }
212
213 sline++;
214 pline++;
215 }
216
217 if (w->_clear)
218 {
219 w->_clear = FALSE;
220 curscr->_clear = TRUE;
221 }
222
223 /* position the cursor to the pad's current position if possible --
224 is the pad current position going to end up displayed? if not,
225 then don't move the cursor; if so, move it to the correct place */
226
227 if (!w->_leaveit && w->_cury >= py && w->_curx >= px &&
228 w->_cury <= py + (sy2 - sy1) && w->_curx <= px + (sx2 - sx1))
229 {
230 curscr->_cury = (w->_cury - py) + sy1;
231 curscr->_curx = (w->_curx - px) + sx1;
232 }
233
234 return OK;
235 }
236
237 int pechochar(WINDOW *pad, chtype ch)
238 {
239 PDC_LOG(("pechochar() - called\n"));
240
241 if (waddch(pad, ch) == ERR)
242 return ERR;
243
244 return prefresh(pad, save_pminrow, save_pmincol, save_sminrow,
245 save_smincol, save_smaxrow, save_smaxcol);
246 }
247
248 #ifdef PDC_WIDE
249 int pecho_wchar(WINDOW *pad, const cchar_t *wch)
250 {
251 PDC_LOG(("pecho_wchar() - called\n"));
252
253 if (!wch || (waddch(pad, *wch) == ERR))
254 return ERR;
255
256 return prefresh(pad, save_pminrow, save_pmincol, save_sminrow,
257 save_smincol, save_smaxrow, save_smaxcol);
258 }
259 #endif
File pdcurses/panel.c added (mode: 100644) (index 00000000..77028c6f)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: panel.c,v 1.8 2008/07/14 12:35:23 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: panel
10
11 Synopsis:
12 int bottom_panel(PANEL *pan);
13 int del_panel(PANEL *pan);
14 int hide_panel(PANEL *pan);
15 int move_panel(PANEL *pan, int starty, int startx);
16 PANEL *new_panel(WINDOW *win);
17 PANEL *panel_above(const PANEL *pan);
18 PANEL *panel_below(const PANEL *pan);
19 int panel_hidden(const PANEL *pan);
20 const void *panel_userptr(const PANEL *pan);
21 WINDOW *panel_window(const PANEL *pan);
22 int replace_panel(PANEL *pan, WINDOW *win);
23 int set_panel_userptr(PANEL *pan, const void *uptr);
24 int show_panel(PANEL *pan);
25 int top_panel(PANEL *pan);
26 void update_panels(void);
27
28 Description:
29 The panel library is built using the curses library, and any
30 program using panels routines must call one of the curses
31 initialization routines such as initscr(). A program using these
32 routines must be linked with the panels and curses libraries.
33 The header <panel.h> includes the header <curses.h>.
34
35 The panels package gives the applications programmer a way to
36 have depth relationships between curses windows; a curses window
37 is associated with every panel. The panels routines allow curses
38 windows to overlap without making visible the overlapped
39 portions of underlying windows. The initial curses window,
40 stdscr, lies beneath all panels. The set of currently visible
41 panels is the 'deck' of panels.
42
43 The panels package allows the applications programmer to create
44 panels, fetch and set their associated windows, shuffle panels
45 in the deck, and manipulate panels in other ways.
46
47 bottom_panel() places pan at the bottom of the deck. The size,
48 location and contents of the panel are unchanged.
49
50 del_panel() deletes pan, but not its associated winwow.
51
52 hide_panel() removes a panel from the deck and thus hides it
53 from view.
54
55 move_panel() moves the curses window associated with pan, so
56 that its upper lefthand corner is at the supplied coordinates.
57 (Do not use mvwin() on the window.)
58
59 new_panel() creates a new panel associated with win and returns
60 the panel pointer. The new panel is placed at the top of the
61 deck.
62
63 panel_above() returns a pointer to the panel in the deck above
64 pan, or NULL if pan is the top panel. If the value of pan passed
65 is NULL, this function returns a pointer to the bottom panel in
66 the deck.
67
68 panel_below() returns a pointer to the panel in the deck below
69 pan, or NULL if pan is the bottom panel. If the value of pan
70 passed is NULL, this function returns a pointer to the top panel
71 in the deck.
72
73 panel_hidden() returns OK if pan is hidden and ERR if it is not.
74
75 panel_userptr() - Each panel has a user pointer available for
76 maintaining relevant information. This function returns a
77 pointer to that information previously set up by
78 set_panel_userptr().
79
80 panel_window() returns a pointer to the curses window associated
81 with the panel.
82
83 replace_panel() replaces the current window of pan with win.
84
85 set_panel_userptr() - Each panel has a user pointer available
86 for maintaining relevant information. This function sets the
87 value of that information.
88
89 show_panel() makes a previously hidden panel visible and places
90 it back in the deck on top.
91
92 top_panel() places pan on the top of the deck. The size,
93 location and contents of the panel are unchanged.
94
95 update_panels() refreshes the virtual screen to reflect the
96 depth relationships between the panels in the deck. The user
97 must use doupdate() to refresh the physical screen.
98
99 Return Value:
100 Each routine that returns a pointer to an object returns NULL if
101 an error occurs. Each panel routine that returns an integer,
102 returns OK if it executes successfully and ERR if it does not.
103
104 Portability X/Open BSD SYS V
105 bottom_panel - - Y
106 del_panel - - Y
107 hide_panel - - Y
108 move_panel - - Y
109 new_panel - - Y
110 panel_above - - Y
111 panel_below - - Y
112 panel_hidden - - Y
113 panel_userptr - - Y
114 panel_window - - Y
115 replace_panel - - Y
116 set_panel_userptr - - Y
117 show_panel - - Y
118 top_panel - - Y
119 update_panels - - Y
120
121 Credits:
122 Original Author - Warren Tucker <wht@n4hgf.mt-park.ga.us>
123
124 **man-end****************************************************************/
125
126 #include <panel.h>
127 #include <stdlib.h>
128
129 PANEL *_bottom_panel = (PANEL *)0;
130 PANEL *_top_panel = (PANEL *)0;
131 PANEL _stdscr_pseudo_panel = { (WINDOW *)0 };
132
133 #ifdef PANEL_DEBUG
134
135 static void dPanel(char *text, PANEL *pan)
136 {
137 PDC_LOG(("%s id=%s b=%s a=%s y=%d x=%d", text, pan->user,
138 pan->below ? pan->below->user : "--",
139 pan->above ? pan->above->user : "--",
140 pan->wstarty, pan->wstartx));
141 }
142
143 static void dStack(char *fmt, int num, PANEL *pan)
144 {
145 char s80[80];
146
147 sprintf(s80, fmt, num, pan);
148 PDC_LOG(("%s b=%s t=%s", s80, _bottom_panel ? _bottom_panel->user : "--",
149 _top_panel ? _top_panel->user : "--"));
150
151 if (pan)
152 PDC_LOG(("pan id=%s", pan->user));
153
154 pan = _bottom_panel;
155
156 while (pan)
157 {
158 dPanel("stk", pan);
159 pan = pan->above;
160 }
161 }
162
163 /* debugging hook for wnoutrefresh */
164
165 static void Wnoutrefresh(PANEL *pan)
166 {
167 dPanel("wnoutrefresh", pan);
168 wnoutrefresh(pan->win);
169 }
170
171 static void Touchpan(PANEL *pan)
172 {
173 dPanel("Touchpan", pan);
174 touchwin(pan->win);
175 }
176
177 static void Touchline(PANEL *pan, int start, int count)
178 {
179 char s80[80];
180
181 sprintf(s80, "Touchline s=%d c=%d", start, count);
182 dPanel(s80, pan);
183 touchline(pan->win, start, count);
184 }
185
186 #else /* PANEL_DEBUG */
187
188 #define dPanel(text, pan)
189 #define dStack(fmt, num, pan)
190 #define Wnoutrefresh(pan) wnoutrefresh((pan)->win)
191 #define Touchpan(pan) touchwin((pan)->win)
192 #define Touchline(pan, start, count) touchline((pan)->win, start, count)
193
194 #endif /* PANEL_DEBUG */
195
196 static bool _panels_overlapped(PANEL *pan1, PANEL *pan2)
197 {
198 if (!pan1 || !pan2)
199 return FALSE;
200
201 return ((pan1->wstarty >= pan2->wstarty && pan1->wstarty < pan2->wendy)
202 || (pan2->wstarty >= pan1->wstarty && pan2->wstarty < pan1->wendy))
203 && ((pan1->wstartx >= pan2->wstartx && pan1->wstartx < pan2->wendx)
204 || (pan2->wstartx >= pan1->wstartx && pan2->wstartx < pan1->wendx));
205 }
206
207 static void _free_obscure(PANEL *pan)
208 {
209 PANELOBS *tobs = pan->obscure; /* "this" one */
210 PANELOBS *nobs; /* "next" one */
211
212 while (tobs)
213 {
214 nobs = tobs->above;
215 free((char *)tobs);
216 tobs = nobs;
217 }
218 pan->obscure = (PANELOBS *)0;
219 }
220
221 static void _override(PANEL *pan, int show)
222 {
223 int y;
224 PANEL *pan2;
225 PANELOBS *tobs = pan->obscure; /* "this" one */
226
227 if (show == 1)
228 Touchpan(pan);
229 else if (!show)
230 {
231 Touchpan(pan);
232 Touchpan(&_stdscr_pseudo_panel);
233 }
234 else if (show == -1)
235 while (tobs && (tobs->pan != pan))
236 tobs = tobs->above;
237
238 while (tobs)
239 {
240 if ((pan2 = tobs->pan) != pan)
241 for (y = pan->wstarty; y < pan->wendy; y++)
242 if ((y >= pan2->wstarty) && (y < pan2->wendy) &&
243 ((is_linetouched(pan->win, y - pan->wstarty)) ||
244 (is_linetouched(stdscr, y))))
245 Touchline(pan2, y - pan2->wstarty, 1);
246
247 tobs = tobs->above;
248 }
249 }
250
251 static void _calculate_obscure(void)
252 {
253 PANEL *pan, *pan2;
254 PANELOBS *tobs; /* "this" one */
255 PANELOBS *lobs; /* last one */
256
257 pan = _bottom_panel;
258
259 while (pan)
260 {
261 if (pan->obscure)
262 _free_obscure(pan);
263
264 lobs = (PANELOBS *)0;
265 pan2 = _bottom_panel;
266
267 while (pan2)
268 {
269 if (_panels_overlapped(pan, pan2))
270 {
271 if ((tobs = malloc(sizeof(PANELOBS))) == NULL)
272 return;
273
274 tobs->pan = pan2;
275 dPanel("obscured", pan2);
276 tobs->above = (PANELOBS *)0;
277
278 if (lobs)
279 lobs->above = tobs;
280 else
281 pan->obscure = tobs;
282
283 lobs = tobs;
284 }
285
286 pan2 = pan2->above;
287 }
288
289 _override(pan, 1);
290 pan = pan->above;
291 }
292 }
293
294 /* check to see if panel is in the stack */
295
296 static bool _panel_is_linked(const PANEL *pan)
297 {
298 PANEL *pan2 = _bottom_panel;
299
300 while (pan2)
301 {
302 if (pan2 == pan)
303 return TRUE;
304
305 pan2 = pan2->above;
306 }
307
308 return FALSE;
309 }
310
311 /* link panel into stack at top */
312
313 static void _panel_link_top(PANEL *pan)
314 {
315 #ifdef PANEL_DEBUG
316 dStack("<lt%d>", 1, pan);
317 if (_panel_is_linked(pan))
318 return;
319 #endif
320 pan->above = (PANEL *)0;
321 pan->below = (PANEL *)0;
322
323 if (_top_panel)
324 {
325 _top_panel->above = pan;
326 pan->below = _top_panel;
327 }
328
329 _top_panel = pan;
330
331 if (!_bottom_panel)
332 _bottom_panel = pan;
333
334 _calculate_obscure();
335 dStack("<lt%d>", 9, pan);
336 }
337
338 /* link panel into stack at bottom */
339
340 static void _panel_link_bottom(PANEL *pan)
341 {
342 #ifdef PANEL_DEBUG
343 dStack("<lb%d>", 1, pan);
344 if (_panel_is_linked(pan))
345 return;
346 #endif
347 pan->above = (PANEL *)0;
348 pan->below = (PANEL *)0;
349
350 if (_bottom_panel)
351 {
352 _bottom_panel->below = pan;
353 pan->above = _bottom_panel;
354 }
355
356 _bottom_panel = pan;
357
358 if (!_top_panel)
359 _top_panel = pan;
360
361 _calculate_obscure();
362 dStack("<lb%d>", 9, pan);
363 }
364
365 static void _panel_unlink(PANEL *pan)
366 {
367 PANEL *prev;
368 PANEL *next;
369
370 #ifdef PANEL_DEBUG
371 dStack("<u%d>", 1, pan);
372 if (!_panel_is_linked(pan))
373 return;
374 #endif
375 _override(pan, 0);
376 _free_obscure(pan);
377
378 prev = pan->below;
379 next = pan->above;
380
381 /* if non-zero, we will not update the list head */
382
383 if (prev)
384 {
385 prev->above = next;
386 if(next)
387 next->below = prev;
388 }
389 else if (next)
390 next->below = prev;
391
392 if (pan == _bottom_panel)
393 _bottom_panel = next;
394
395 if (pan == _top_panel)
396 _top_panel = prev;
397
398 _calculate_obscure();
399
400 pan->above = (PANEL *)0;
401 pan->below = (PANEL *)0;
402 dStack("<u%d>", 9, pan);
403
404 }
405
406 /************************************************************************
407 * The following are the public functions for the panels library. *
408 ************************************************************************/
409
410 int bottom_panel(PANEL *pan)
411 {
412 if (!pan)
413 return ERR;
414
415 if (pan == _bottom_panel)
416 return OK;
417
418 if (_panel_is_linked(pan))
419 hide_panel(pan);
420
421 _panel_link_bottom(pan);
422
423 return OK;
424 }
425
426 int del_panel(PANEL *pan)
427 {
428 if (pan)
429 {
430 if (_panel_is_linked(pan))
431 hide_panel(pan);
432
433 free((char *)pan);
434 return OK;
435 }
436
437 return ERR;
438 }
439
440 int hide_panel(PANEL *pan)
441 {
442 if (!pan)
443 return ERR;
444
445 if (!_panel_is_linked(pan))
446 {
447 pan->above = (PANEL *)0;
448 pan->below = (PANEL *)0;
449 return ERR;
450 }
451
452 _panel_unlink(pan);
453
454 return OK;
455 }
456
457 int move_panel(PANEL *pan, int starty, int startx)
458 {
459 WINDOW *win;
460 int maxy, maxx;
461
462 if (!pan)
463 return ERR;
464
465 if (_panel_is_linked(pan))
466 _override(pan, 0);
467
468 win = pan->win;
469
470 if (mvwin(win, starty, startx) == ERR)
471 return ERR;
472
473 getbegyx(win, pan->wstarty, pan->wstartx);
474 getmaxyx(win, maxy, maxx);
475 pan->wendy = pan->wstarty + maxy;
476 pan->wendx = pan->wstartx + maxx;
477
478 if (_panel_is_linked(pan))
479 _calculate_obscure();
480
481 return OK;
482 }
483
484 PANEL *new_panel(WINDOW *win)
485 {
486 PANEL *pan = malloc(sizeof(PANEL));
487
488 if (!_stdscr_pseudo_panel.win)
489 {
490 _stdscr_pseudo_panel.win = stdscr;
491 _stdscr_pseudo_panel.wstarty = 0;
492 _stdscr_pseudo_panel.wstartx = 0;
493 _stdscr_pseudo_panel.wendy = LINES;
494 _stdscr_pseudo_panel.wendx = COLS;
495 _stdscr_pseudo_panel.user = "stdscr";
496 _stdscr_pseudo_panel.obscure = (PANELOBS *)0;
497 }
498
499 if (pan)
500 {
501 int maxy, maxx;
502
503 pan->win = win;
504 pan->above = (PANEL *)0;
505 pan->below = (PANEL *)0;
506 getbegyx(win, pan->wstarty, pan->wstartx);
507 getmaxyx(win, maxy, maxx);
508 pan->wendy = pan->wstarty + maxy;
509 pan->wendx = pan->wstartx + maxx;
510 #ifdef PANEL_DEBUG
511 pan->user = "new";
512 #else
513 pan->user = (char *)0;
514 #endif
515 pan->obscure = (PANELOBS *)0;
516 show_panel(pan);
517 }
518
519 return pan;
520 }
521
522 PANEL *panel_above(const PANEL *pan)
523 {
524 return pan ? pan->above : _bottom_panel;
525 }
526
527 PANEL *panel_below(const PANEL *pan)
528 {
529 return pan ? pan->below : _top_panel;
530 }
531
532 int panel_hidden(const PANEL *pan)
533 {
534 if (!pan)
535 return ERR;
536
537 return _panel_is_linked(pan) ? ERR : OK;
538 }
539
540 const void *panel_userptr(const PANEL *pan)
541 {
542 return pan ? pan->user : NULL;
543 }
544
545 WINDOW *panel_window(const PANEL *pan)
546 {
547 PDC_LOG(("panel_window() - called\n"));
548
549 return pan->win;
550 }
551
552 int replace_panel(PANEL *pan, WINDOW *win)
553 {
554 int maxy, maxx;
555
556 if (!pan)
557 return ERR;
558
559 if (_panel_is_linked(pan))
560 _override(pan, 0);
561
562 pan->win = win;
563 getbegyx(win, pan->wstarty, pan->wstartx);
564 getmaxyx(win, maxy, maxx);
565 pan->wendy = pan->wstarty + maxy;
566 pan->wendx = pan->wstartx + maxx;
567
568 if (_panel_is_linked(pan))
569 _calculate_obscure();
570
571 return OK;
572 }
573
574 int set_panel_userptr(PANEL *pan, const void *uptr)
575 {
576 if (!pan)
577 return ERR;
578
579 pan->user = uptr;
580 return OK;
581 }
582
583 int show_panel(PANEL *pan)
584 {
585 if (!pan)
586 return ERR;
587
588 if (pan == _top_panel)
589 return OK;
590
591 if (_panel_is_linked(pan))
592 hide_panel(pan);
593
594 _panel_link_top(pan);
595
596 return OK;
597 }
598
599 int top_panel(PANEL *pan)
600 {
601 return show_panel(pan);
602 }
603
604 void update_panels(void)
605 {
606 PANEL *pan;
607
608 PDC_LOG(("update_panels() - called\n"));
609
610 pan = _bottom_panel;
611
612 while (pan)
613 {
614 _override(pan, -1);
615 pan = pan->above;
616 }
617
618 if (is_wintouched(stdscr))
619 Wnoutrefresh(&_stdscr_pseudo_panel);
620
621 pan = _bottom_panel;
622
623 while (pan)
624 {
625 if (is_wintouched(pan->win) || !pan->above)
626 Wnoutrefresh(pan);
627
628 pan = pan->above;
629 }
630 }
File pdcurses/printw.c added (mode: 100644) (index 00000000..9be0c5fc)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: printw.c,v 1.40 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: printw
10
11 Synopsis:
12 int printw(const char *fmt, ...);
13 int wprintw(WINDOW *win, const char *fmt, ...);
14 int mvprintw(int y, int x, const char *fmt, ...);
15 int mvwprintw(WINDOW *win, int y, int x, const char *fmt,...);
16 int vwprintw(WINDOW *win, const char *fmt, va_list varglist);
17 int vw_printw(WINDOW *win, const char *fmt, va_list varglist);
18
19 Description:
20 The printw() functions add a formatted string to the window at
21 the current or specified cursor position. The format strings are
22 the same as used in the standard C library's printf(). (printw()
23 can be used as a drop-in replacement for printf().)
24
25 Return Value:
26 All functions return the number of characters printed, or
27 ERR on error.
28
29 Portability X/Open BSD SYS V
30 printw Y Y Y
31 wprintw Y Y Y
32 mvprintw Y Y Y
33 mvwprintw Y Y Y
34 vwprintw Y - 4.0
35 vw_printw Y
36
37 **man-end****************************************************************/
38
39 #include <string.h>
40
41 int vwprintw(WINDOW *win, const char *fmt, va_list varglist)
42 {
43 char printbuf[513];
44 int len;
45
46 PDC_LOG(("vwprintw() - called\n"));
47
48 #ifdef HAVE_VSNPRINTF
49 len = vsnprintf(printbuf, 512, fmt, varglist);
50 #else
51 len = vsprintf(printbuf, fmt, varglist);
52 #endif
53 return (waddstr(win, printbuf) == ERR) ? ERR : len;
54 }
55
56 int printw(const char *fmt, ...)
57 {
58 va_list args;
59 int retval;
60
61 PDC_LOG(("printw() - called\n"));
62
63 va_start(args, fmt);
64 retval = vwprintw(stdscr, fmt, args);
65 va_end(args);
66
67 return retval;
68 }
69
70 int wprintw(WINDOW *win, const char *fmt, ...)
71 {
72 va_list args;
73 int retval;
74
75 PDC_LOG(("wprintw() - called\n"));
76
77 va_start(args, fmt);
78 retval = vwprintw(win, fmt, args);
79 va_end(args);
80
81 return retval;
82 }
83
84 int mvprintw(int y, int x, const char *fmt, ...)
85 {
86 va_list args;
87 int retval;
88
89 PDC_LOG(("mvprintw() - called\n"));
90
91 if (move(y, x) == ERR)
92 return ERR;
93
94 va_start(args, fmt);
95 retval = vwprintw(stdscr, fmt, args);
96 va_end(args);
97
98 return retval;
99 }
100
101 int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
102 {
103 va_list args;
104 int retval;
105
106 PDC_LOG(("mvwprintw() - called\n"));
107
108 if (wmove(win, y, x) == ERR)
109 return ERR;
110
111 va_start(args, fmt);
112 retval = vwprintw(win, fmt, args);
113 va_end(args);
114
115 return retval;
116 }
117
118 int vw_printw(WINDOW *win, const char *fmt, va_list varglist)
119 {
120 PDC_LOG(("vw_printw() - called\n"));
121
122 return vwprintw(win, fmt, varglist);
123 }
File pdcurses/refresh.c added (mode: 100644) (index 00000000..0b8e1ca5)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: refresh.c,v 1.56 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: refresh
10
11 Synopsis:
12 int refresh(void);
13 int wrefresh(WINDOW *win);
14 int wnoutrefresh(WINDOW *win);
15 int doupdate(void);
16 int redrawwin(WINDOW *win);
17 int wredrawln(WINDOW *win, int beg_line, int num_lines);
18
19 Description:
20 wrefresh() copies the named window to the physical terminal
21 screen, taking into account what is already there in order to
22 optimize cursor movement. refresh() does the same, using stdscr.
23 These routines must be called to get any output on the terminal,
24 as other routines only manipulate data structures. Unless
25 leaveok() has been enabled, the physical cursor of the terminal
26 is left at the location of the window's cursor.
27
28 wnoutrefresh() and doupdate() allow multiple updates with more
29 efficiency than wrefresh() alone. wrefresh() works by first
30 calling wnoutrefresh(), which copies the named window to the
31 virtual screen. It then calls doupdate(), which compares the
32 virtual screen to the physical screen and does the actual
33 update. A series of calls to wrefresh() will result in
34 alternating calls to wnoutrefresh() and doupdate(), causing
35 several bursts of output to the screen. By first calling
36 wnoutrefresh() for each window, it is then possible to call
37 doupdate() only once.
38
39 In PDCurses, redrawwin() is equivalent to touchwin(), and
40 wredrawln() is the same as touchline(). In some other curses
41 implementations, there's a subtle distinction, but it has no
42 meaning in PDCurses.
43
44 Return Value:
45 All functions return OK on success and ERR on error.
46
47 Portability X/Open BSD SYS V
48 refresh Y Y Y
49 wrefresh Y Y Y
50 wnoutrefresh Y Y Y
51 doupdate Y Y Y
52 redrawwin Y - 4.0
53 wredrawln Y - 4.0
54
55 **man-end****************************************************************/
56
57 #include <string.h>
58
59 int wnoutrefresh(WINDOW *win)
60 {
61 int begy, begx; /* window's place on screen */
62 int i, j;
63
64 PDC_LOG(("wnoutrefresh() - called: win=%p\n", win));
65
66 if ( !win || (win->_flags & (_PAD|_SUBPAD)) )
67 return ERR;
68
69 begy = win->_begy;
70 begx = win->_begx;
71
72 for (i = 0, j = begy; i < win->_maxy; i++, j++)
73 {
74 if (win->_firstch[i] != _NO_CHANGE)
75 {
76 chtype *src = win->_y[i];
77 chtype *dest = curscr->_y[j] + begx;
78
79 int first = win->_firstch[i]; /* first changed */
80 int last = win->_lastch[i]; /* last changed */
81
82 /* ignore areas on the outside that are marked as changed,
83 but really aren't */
84
85 while (first <= last && src[first] == dest[first])
86 first++;
87
88 while (last >= first && src[last] == dest[last])
89 last--;
90
91 /* if any have really changed... */
92
93 if (first <= last)
94 {
95 memcpy(dest + first, src + first,
96 (last - first + 1) * sizeof(chtype));
97
98 first += begx;
99 last += begx;
100
101 if (first < curscr->_firstch[j] ||
102 curscr->_firstch[j] == _NO_CHANGE)
103 curscr->_firstch[j] = first;
104
105 if (last > curscr->_lastch[j])
106 curscr->_lastch[j] = last;
107 }
108
109 win->_firstch[i] = _NO_CHANGE; /* updated now */
110 }
111
112 win->_lastch[i] = _NO_CHANGE; /* updated now */
113 }
114
115 if (win->_clear)
116 win->_clear = FALSE;
117
118 if (!win->_leaveit)
119 {
120 curscr->_cury = win->_cury + begy;
121 curscr->_curx = win->_curx + begx;
122 }
123
124 return OK;
125 }
126
127 int doupdate(void)
128 {
129 int y;
130 bool clearall;
131
132 PDC_LOG(("doupdate() - called\n"));
133
134 if (!curscr)
135 return ERR;
136
137 if (isendwin()) /* coming back after endwin() called */
138 {
139 reset_prog_mode();
140 clearall = TRUE;
141 SP->alive = TRUE; /* so isendwin() result is correct */
142 }
143 else
144 clearall = curscr->_clear;
145
146 for (y = 0; y < SP->lines; y++)
147 {
148 PDC_LOG(("doupdate() - Transforming line %d of %d: %s\n",
149 y, SP->lines, (curscr->_firstch[y] != _NO_CHANGE) ?
150 "Yes" : "No"));
151
152 if (clearall || curscr->_firstch[y] != _NO_CHANGE)
153 {
154 int first, last;
155
156 chtype *src = curscr->_y[y];
157 chtype *dest = pdc_lastscr->_y[y];
158
159 if (clearall)
160 {
161 first = 0;
162 last = COLS - 1;
163 }
164 else
165 {
166 first = curscr->_firstch[y];
167 last = curscr->_lastch[y];
168 }
169
170 while (first <= last)
171 {
172 int len = 0;
173
174 /* build up a run of changed cells; if two runs are
175 separated by a single unchanged cell, ignore the
176 break */
177
178 if (clearall)
179 len = last - first + 1;
180 else
181 while (first + len <= last &&
182 (src[first + len] != dest[first + len] ||
183 (len && first + len < last &&
184 src[first + len + 1] != dest[first + len + 1])
185 )
186 )
187 len++;
188
189 /* update the screen, and pdc_lastscr */
190
191 if (len)
192 {
193 PDC_transform_line(y, first, len, src + first);
194 memcpy(dest + first, src + first, len * sizeof(chtype));
195 first += len;
196 }
197
198 /* skip over runs of unchanged cells */
199
200 while (first <= last && src[first] == dest[first])
201 first++;
202 }
203
204 curscr->_firstch[y] = _NO_CHANGE;
205 curscr->_lastch[y] = _NO_CHANGE;
206 }
207 }
208
209 curscr->_clear = FALSE;
210
211 if (SP->visibility)
212 PDC_gotoyx(curscr->_cury, curscr->_curx);
213
214 SP->cursrow = curscr->_cury;
215 SP->curscol = curscr->_curx;
216
217 return OK;
218 }
219
220 int wrefresh(WINDOW *win)
221 {
222 bool save_clear;
223
224 PDC_LOG(("wrefresh() - called\n"));
225
226 if ( !win || (win->_flags & (_PAD|_SUBPAD)) )
227 return ERR;
228
229 save_clear = win->_clear;
230
231 if (win == curscr)
232 curscr->_clear = TRUE;
233 else
234 wnoutrefresh(win);
235
236 if (save_clear && win->_maxy == SP->lines && win->_maxx == SP->cols)
237 curscr->_clear = TRUE;
238
239 return doupdate();
240 }
241
242 int refresh(void)
243 {
244 PDC_LOG(("refresh() - called\n"));
245
246 return wrefresh(stdscr);
247 }
248
249 int wredrawln(WINDOW *win, int start, int num)
250 {
251 int i;
252
253 PDC_LOG(("wredrawln() - called: win=%p start=%d num=%d\n",
254 win, start, num));
255
256 if (!win || start > win->_maxy || start + num > win->_maxy)
257 return ERR;
258
259 for (i = start; i < start + num; i++)
260 {
261 win->_firstch[i] = 0;
262 win->_lastch[i] = win->_maxx - 1;
263 }
264
265 return OK;
266 }
267
268 int redrawwin(WINDOW *win)
269 {
270 PDC_LOG(("redrawwin() - called: win=%p\n", win));
271
272 if (!win)
273 return ERR;
274
275 return wredrawln(win, 0, win->_maxy);
276 }
File pdcurses/scanw.c added (mode: 100644) (index 00000000..af2bcb9e)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: scanw.c,v 1.42 2008/07/14 12:22:13 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: scanw
10
11 Synopsis:
12 int scanw(const char *fmt, ...);
13 int wscanw(WINDOW *win, const char *fmt, ...);
14 int mvscanw(int y, int x, const char *fmt, ...);
15 int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...);
16 int vwscanw(WINDOW *win, const char *fmt, va_list varglist);
17 int vw_scanw(WINDOW *win, const char *fmt, va_list varglist);
18
19 Description:
20 These routines correspond to the standard C library's scanf()
21 family. Each gets a string from the window via wgetnstr(), and
22 uses the resulting line as input for the scan.
23
24 Return Value:
25 On successful completion, these functions return the number of
26 items successfully matched. Otherwise they return ERR.
27
28 Portability X/Open BSD SYS V
29 scanw Y Y Y
30 wscanw Y Y Y
31 mvscanw Y Y Y
32 mvwscanw Y Y Y
33 vwscanw Y - 4.0
34 vw_scanw Y
35
36 **man-end****************************************************************/
37
38 #include <string.h>
39
40 #ifndef HAVE_VSSCANF
41 # include <stdlib.h>
42 # include <ctype.h>
43 # include <limits.h>
44
45 static int _pdc_vsscanf(const char *, const char *, va_list);
46
47 # define vsscanf _pdc_vsscanf
48 #endif
49
50 int vwscanw(WINDOW *win, const char *fmt, va_list varglist)
51 {
52 char scanbuf[256];
53
54 PDC_LOG(("vwscanw() - called\n"));
55
56 if (wgetnstr(win, scanbuf, 255) == ERR)
57 return ERR;
58
59 return vsscanf(scanbuf, fmt, varglist);
60 }
61
62 int scanw(const char *fmt, ...)
63 {
64 va_list args;
65 int retval;
66
67 PDC_LOG(("scanw() - called\n"));
68
69 va_start(args, fmt);
70 retval = vwscanw(stdscr, fmt, args);
71 va_end(args);
72
73 return retval;
74 }
75
76 int wscanw(WINDOW *win, const char *fmt, ...)
77 {
78 va_list args;
79 int retval;
80
81 PDC_LOG(("wscanw() - called\n"));
82
83 va_start(args, fmt);
84 retval = vwscanw(win, fmt, args);
85 va_end(args);
86
87 return retval;
88 }
89
90 int mvscanw(int y, int x, const char *fmt, ...)
91 {
92 va_list args;
93 int retval;
94
95 PDC_LOG(("mvscanw() - called\n"));
96
97 if (move(y, x) == ERR)
98 return ERR;
99
100 va_start(args, fmt);
101 retval = vwscanw(stdscr, fmt, args);
102 va_end(args);
103
104 return retval;
105 }
106
107 int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...)
108 {
109 va_list args;
110 int retval;
111
112 PDC_LOG(("mvscanw() - called\n"));
113
114 if (wmove(win, y, x) == ERR)
115 return ERR;
116
117 va_start(args, fmt);
118 retval = vwscanw(win, fmt, args);
119 va_end(args);
120
121 return retval;
122 }
123
124 int vw_scanw(WINDOW *win, const char *fmt, va_list varglist)
125 {
126 PDC_LOG(("vw_scanw() - called\n"));
127
128 return vwscanw(win, fmt, varglist);
129 }
130
131 #ifndef HAVE_VSSCANF
132
133 /* _pdc_vsscanf() - Internal routine to parse and format an input
134 buffer. It scans a series of input fields; each field is formatted
135 according to a supplied format string and the formatted input is
136 stored in the variable number of addresses passed. Returns the number
137 of input fields or EOF on error.
138
139 Don't compile this unless required. Some compilers (at least Borland
140 C++ 3.0) have to link with math libraries due to the use of floats.
141
142 Based on vsscanf.c and input.c from emx 0.8f library source,
143 Copyright (c) 1990-1992 by Eberhard Mattes, who has kindly agreed to
144 its inclusion in PDCurses. */
145
146 #define WHITE(x) ((x) == ' ' || (x) == '\t' || (x) == '\n')
147
148 #define NEXT(x) \
149 do { \
150 x = *buf++; \
151 if (!x) \
152 return (count ? count : EOF); \
153 ++chars; \
154 } while (0)
155
156 #define UNGETC() \
157 do { \
158 --buf; --chars; \
159 } while (0)
160
161 static int _pdc_vsscanf(const char *buf, const char *fmt, va_list arg_ptr)
162 {
163 int count, chars, c, width, radix, d, i;
164 int *int_ptr;
165 long *long_ptr;
166 short *short_ptr;
167 char *char_ptr;
168 unsigned char f;
169 char neg, assign, ok, size;
170 long n;
171 char map[256], end;
172 double dx, dd, *dbl_ptr;
173 float *flt_ptr;
174 int exp;
175 char eneg;
176
177 count = 0;
178 chars = 0;
179 c = 0;
180 while ((f = *fmt) != 0)
181 {
182 if (WHITE(f))
183 {
184 do
185 {
186 ++fmt;
187 f = *fmt;
188 }
189 while (WHITE(f));
190 do
191 {
192 c = *buf++;
193 if (!c)
194 {
195 if (!f || count)
196 return count;
197 else
198 return EOF;
199 } else
200 ++chars;
201 }
202 while (WHITE(c));
203 UNGETC();
204 } else if (f != '%')
205 {
206 NEXT(c);
207 if (c != f)
208 return count;
209 ++fmt;
210 } else
211 {
212 assign = TRUE;
213 width = INT_MAX;
214 char_ptr = NULL;
215 ++fmt;
216 if (*fmt == '*')
217 {
218 assign = FALSE;
219 ++fmt;
220 }
221 if (isdigit(*fmt))
222 {
223 width = 0;
224 while (isdigit(*fmt))
225 width = width * 10 + (*fmt++ - '0');
226 if (!width)
227 width = INT_MAX;
228 }
229 size = 0;
230 if (*fmt == 'h' || *fmt == 'l')
231 size = *fmt++;
232 f = *fmt;
233 switch (f)
234 {
235 case 'c':
236 if (width == INT_MAX)
237 width = 1;
238 if (assign)
239 char_ptr = va_arg(arg_ptr, char *);
240 while (width > 0)
241 {
242 --width;
243 NEXT(c);
244 if (assign)
245 {
246 *char_ptr++ = (char) c;
247 ++count;
248 }
249 }
250 break;
251 case '[':
252 memset(map, 0, 256);
253 end = 0;
254 ++fmt;
255 if (*fmt == '^')
256 {
257 ++fmt;
258 end = 1;
259 }
260 i = 0;
261 for (;;)
262 {
263 f = (unsigned char) *fmt;
264 switch (f)
265 {
266 case 0:
267 /* avoid skipping past 0 */
268 --fmt;
269 NEXT(c);
270 goto string;
271 case ']':
272 if (i > 0)
273 {
274 NEXT(c);
275 goto string;
276 }
277 /* no break */
278 default:
279 if (fmt[1] == '-' && fmt[2]
280 && f < (unsigned char)fmt[2])
281 {
282 memset(map + f, 1, (unsigned char)fmt[2] - f);
283 fmt += 2;
284 }
285 else
286 map[f] = 1;
287 break;
288 }
289 ++fmt;
290 ++i;
291 }
292 case 's':
293 memset(map, 0, 256);
294 map[' '] = 1;
295 map['\n'] = 1;
296 map['\r'] = 1;
297 map['\t'] = 1;
298 end = 1;
299 do
300 {
301 NEXT(c);
302 }
303 while (WHITE(c));
304 string:
305 if (assign)
306 char_ptr = va_arg(arg_ptr, char *);
307 while (width > 0 && map[(unsigned char) c] != end)
308 {
309 --width;
310 if (assign)
311 *char_ptr++ = (char) c;
312 c = *buf++;
313 if (!c)
314 break;
315 else
316 ++chars;
317 }
318 if (assign)
319 {
320 *char_ptr = 0;
321 ++count;
322 }
323 if (!c)
324 return count;
325 else
326 UNGETC();
327 break;
328 case 'f':
329 case 'e':
330 case 'E':
331 case 'g':
332 case 'G':
333 neg = ok = FALSE;
334 dx = 0.0;
335 do
336 {
337 NEXT(c);
338 }
339 while (WHITE(c));
340 if (c == '+')
341 {
342 NEXT(c);
343 --width;
344 } else if (c == '-')
345 {
346 neg = TRUE;
347 NEXT(c);
348 --width;
349 }
350 while (width > 0 && isdigit(c))
351 {
352 --width;
353 dx = dx * 10.0 + (double) (c - '0');
354 ok = TRUE;
355 c = *buf++;
356 if (!c)
357 break;
358 else
359 ++chars;
360 }
361 if (width > 0 && c == '.')
362 {
363 --width;
364 dd = 10.0;
365 NEXT(c);
366 while (width > 0 && isdigit(c))
367 {
368 --width;
369 dx += (double) (c - '0') / dd;
370 dd *= 10.0;
371 ok = TRUE;
372 c = *buf++;
373 if (!c)
374 break;
375 else
376 ++chars;
377 }
378 }
379 if (!ok)
380 return count;
381 if (width > 0 && (c == 'e' || c == 'E'))
382 {
383 eneg = FALSE;
384 exp = 0;
385 NEXT(c);
386 --width;
387 if (width > 0 && c == '+')
388 {
389 NEXT(c);
390 --width;
391 } else if (width > 0 && c == '-')
392 {
393 eneg = TRUE;
394 NEXT(c);
395 --width;
396 }
397 if (!(width > 0 && isdigit(c)))
398 {
399 UNGETC();
400 return count;
401 }
402 while (width > 0 && isdigit(c))
403 {
404 --width;
405 exp = exp * 10 + (c - '0');
406 c = *buf++;
407 if (!c)
408 break;
409 else
410 ++chars;
411 }
412 if (eneg)
413 exp = -exp;
414 while (exp > 0)
415 {
416 dx *= 10.0;
417 --exp;
418 }
419 while (exp < 0)
420 {
421 dx /= 10.0;
422 ++exp;
423 }
424 }
425 if (assign)
426 {
427 if (neg)
428 dx = -dx;
429 if (size == 'l')
430 {
431 dbl_ptr = va_arg(arg_ptr, double *);
432 *dbl_ptr = dx;
433 }
434 else
435 {
436 flt_ptr = va_arg(arg_ptr, float *);
437 *flt_ptr = (float)dx;
438 }
439 ++count;
440 }
441 if (!c)
442 return count;
443 else
444 UNGETC();
445 break;
446 case 'i':
447 neg = FALSE;
448 radix = 10;
449 do
450 {
451 NEXT(c);
452 }
453 while (WHITE(c));
454 if (!(width > 0 && c == '0'))
455 goto scan_complete_number;
456 NEXT(c);
457 --width;
458 if (width > 0 && (c == 'x' || c == 'X'))
459 {
460 NEXT(c);
461 radix = 16;
462 --width;
463 }
464 else if (width > 0 && (c >= '0' && c <= '7'))
465 radix = 8;
466 goto scan_unsigned_number;
467 case 'd':
468 case 'u':
469 case 'o':
470 case 'x':
471 case 'X':
472 do
473 {
474 NEXT(c);
475 }
476 while (WHITE(c));
477 switch (f)
478 {
479 case 'o':
480 radix = 8;
481 break;
482 case 'x':
483 case 'X':
484 radix = 16;
485 break;
486 default:
487 radix = 10;
488 break;
489 }
490 scan_complete_number:
491 neg = FALSE;
492 if (width > 0 && c == '+')
493 {
494 NEXT(c);
495 --width;
496 }
497 else if (width > 0 && c == '-' && radix == 10)
498 {
499 neg = TRUE;
500 NEXT(c);
501 --width;
502 }
503 scan_unsigned_number:
504 n = 0;
505 ok = FALSE;
506 while (width > 0)
507 {
508 --width;
509 if (isdigit(c))
510 d = c - '0';
511 else if (isupper(c))
512 d = c - 'A' + 10;
513 else if (islower(c))
514 d = c - 'a' + 10;
515 else
516 break;
517 if (d < 0 || d >= radix)
518 break;
519 ok = TRUE;
520 n = n * radix + d;
521 c = *buf++;
522 if (!c)
523 break;
524 else
525 ++chars;
526 }
527 if (!ok)
528 return count;
529 if (assign)
530 {
531 if (neg)
532 n = -n;
533 switch (size)
534 {
535 case 'h':
536 short_ptr = va_arg(arg_ptr, short *);
537 *short_ptr = (short) n;
538 break;
539 case 'l':
540 long_ptr = va_arg(arg_ptr, long *);
541 *long_ptr = (long) n;
542 break;
543 default:
544 int_ptr = va_arg(arg_ptr, int *);
545 *int_ptr = (int) n;
546 }
547 ++count;
548 }
549 if (!c)
550 return count;
551 else
552 UNGETC();
553 break;
554 case 'n':
555 if (assign)
556 {
557 int_ptr = va_arg(arg_ptr, int *);
558 *int_ptr = chars;
559 ++count;
560 }
561 break;
562 default:
563 if (!f) /* % at end of string */
564 return count;
565 NEXT(c);
566 if (c != f)
567 return count;
568 break;
569 }
570 ++fmt;
571 }
572 }
573 return count;
574 }
575 #endif /* HAVE_VSSCANF */
File pdcurses/scr_dump.c added (mode: 100644) (index 00000000..e02046e5)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: scr_dump.c,v 1.30 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: scr_dump
10
11 Synopsis:
12 int putwin(WINDOW *win, FILE *filep);
13 WINDOW *getwin(FILE *filep);
14 int scr_dump(const char *filename);
15 int scr_init(const char *filename);
16 int scr_restore(const char *filename);
17 int scr_set(const char *filename);
18
19 Description:
20 getwin() reads window-related data previously stored in a file
21 by putwin(). It then creates and initialises a new window using
22 that data.
23
24 putwin() writes all data associated with a window into a file,
25 using an unspecified format. This information can be retrieved
26 later using getwin().
27
28 scr_dump() writes the current contents of the virtual screen to
29 the file named by filename in an unspecified format.
30
31 scr_restore() function sets the virtual screen to the contents
32 of the file named by filename, which must have been written
33 using scr_dump(). The next refresh operation restores the screen
34 to the way it looked in the dump file.
35
36 In PDCurses, scr_init() does nothing, and scr_set() is a synonym
37 for scr_restore(). Also, scr_dump() and scr_restore() save and
38 load from curscr. This differs from some other implementations,
39 where scr_init() works with curscr, and scr_restore() works with
40 newscr; but the effect should be the same. (PDCurses has no
41 newscr.)
42
43 Return Value:
44 On successful completion, getwin() returns a pointer to the
45 window it created. Otherwise, it returns a null pointer. Other
46 functions return OK or ERR.
47
48 Portability X/Open BSD SYS V
49 putwin Y
50 getwin Y
51 scr_dump Y
52 scr_init Y
53 scr_restore Y
54 scr_set Y
55
56 **man-end****************************************************************/
57
58 #include <stdlib.h>
59 #include <string.h>
60
61 #define DUMPVER 1 /* Should be updated whenever the WINDOW struct is
62 changed */
63
64 int putwin(WINDOW *win, FILE *filep)
65 {
66 static const char *marker = "PDC";
67 static const unsigned char version = DUMPVER;
68
69 PDC_LOG(("putwin() - called\n"));
70
71 /* write the marker and the WINDOW struct */
72
73 if (filep && fwrite(marker, strlen(marker), 1, filep)
74 && fwrite(&version, 1, 1, filep)
75 && fwrite(win, sizeof(WINDOW), 1, filep))
76 {
77 int i;
78
79 /* write each line */
80
81 for (i = 0; i < win->_maxy && win->_y[i]; i++)
82 if (!fwrite(win->_y[i], win->_maxx * sizeof(chtype), 1, filep))
83 return ERR;
84
85 return OK;
86 }
87
88 return ERR;
89 }
90
91 WINDOW *getwin(FILE *filep)
92 {
93 WINDOW *win;
94 char marker[4];
95 int i, nlines, ncols;
96
97 PDC_LOG(("getwin() - called\n"));
98
99 if ( !(win = malloc(sizeof(WINDOW))) )
100 return (WINDOW *)NULL;
101
102 /* check for the marker, and load the WINDOW struct */
103
104 if (!filep || !fread(marker, 4, 1, filep) || strncmp(marker, "PDC", 3)
105 || marker[3] != DUMPVER || !fread(win, sizeof(WINDOW), 1, filep))
106 {
107 free(win);
108 return (WINDOW *)NULL;
109 }
110
111 nlines = win->_maxy;
112 ncols = win->_maxx;
113
114 /* allocate the line pointer array */
115
116 if ( !(win->_y = malloc(nlines * sizeof(chtype *))) )
117 {
118 free(win);
119 return (WINDOW *)NULL;
120 }
121
122 /* allocate the minchng and maxchng arrays */
123
124 if ( !(win->_firstch = malloc(nlines * sizeof(int))) )
125 {
126 free(win->_y);
127 free(win);
128 return (WINDOW *)NULL;
129 }
130
131 if ( !(win->_lastch = malloc(nlines * sizeof(int))) )
132 {
133 free(win->_firstch);
134 free(win->_y);
135 free(win);
136 return (WINDOW *)NULL;
137 }
138
139 /* allocate the lines */
140
141 if ( !(win = PDC_makelines(win)) )
142 return (WINDOW *)NULL;
143
144 /* read them */
145
146 for (i = 0; i < nlines; i++)
147 {
148 if (!fread(win->_y[i], ncols * sizeof(chtype), 1, filep))
149 {
150 delwin(win);
151 return (WINDOW *)NULL;
152 }
153 }
154
155 touchwin(win);
156
157 return win;
158 }
159
160 int scr_dump(const char *filename)
161 {
162 FILE *filep;
163
164 PDC_LOG(("scr_dump() - called: filename %s\n", filename));
165
166 if (filename && (filep = fopen(filename, "wb")) != NULL)
167 {
168 int result = putwin(curscr, filep);
169 fclose(filep);
170 return result;
171 }
172
173 return ERR;
174 }
175
176 int scr_init(const char *filename)
177 {
178 PDC_LOG(("scr_init() - called: filename %s\n", filename));
179
180 return OK;
181 }
182
183 int scr_restore(const char *filename)
184 {
185 FILE *filep;
186
187 PDC_LOG(("scr_restore() - called: filename %s\n", filename));
188
189 if (filename && (filep = fopen(filename, "rb")) != NULL)
190 {
191 WINDOW *replacement = getwin(filep);
192 fclose(filep);
193
194 if (replacement)
195 {
196 int result = overwrite(replacement, curscr);
197 delwin(replacement);
198 return result;
199 }
200 }
201
202 return ERR;
203 }
204
205 int scr_set(const char *filename)
206 {
207 PDC_LOG(("scr_set() - called: filename %s\n", filename));
208
209 return scr_restore(filename);
210 }
File pdcurses/scroll.c added (mode: 100644) (index 00000000..c53e2954)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: scroll.c,v 1.36 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: scroll
10
11 Synopsis:
12 int scroll(WINDOW *win);
13 int scrl(int n);
14 int wscrl(WINDOW *win, int n);
15
16 Description:
17 scroll() causes the window to scroll up one line. This involves
18 moving the lines in the window data strcture.
19
20 With a positive n, scrl() and wscrl() scroll the window up n
21 lines (line i + n becomes i); otherwise they scroll the window
22 down n lines.
23
24 For these functions to work, scrolling must be enabled via
25 scrollok(). Note also that scrolling is not allowed if the
26 supplied window is a pad.
27
28 Return Value:
29 All functions return OK on success and ERR on error.
30
31 Portability X/Open BSD SYS V
32 scroll Y Y Y
33 scrl Y - 4.0
34 wscrl Y - 4.0
35
36 **man-end****************************************************************/
37
38 int wscrl(WINDOW *win, int n)
39 {
40 int i, l, dir, start, end;
41 chtype blank, *temp;
42
43 /* Check if window scrolls. Valid for window AND pad */
44
45 if (!win || !win->_scroll || !n)
46 return ERR;
47
48 blank = win->_bkgd;
49
50 if (n > 0)
51 {
52 start = win->_tmarg;
53 end = win->_bmarg;
54 dir = 1;
55 }
56 else
57 {
58 start = win->_bmarg;
59 end = win->_tmarg;
60 dir = -1;
61 }
62
63 for (l = 0; l < (n * dir); l++)
64 {
65 temp = win->_y[start];
66
67 /* re-arrange line pointers */
68
69 for (i = start; i != end; i += dir)
70 win->_y[i] = win->_y[i + dir];
71
72 win->_y[end] = temp;
73
74 /* make a blank line */
75
76 for (i = 0; i < win->_maxx; i++)
77 *temp++ = blank;
78 }
79
80 touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1);
81
82 PDC_sync(win);
83 return OK;
84 }
85
86 int scrl(int n)
87 {
88 PDC_LOG(("scrl() - called\n"));
89
90 return wscrl(stdscr, n);
91 }
92
93 int scroll(WINDOW *win)
94 {
95 PDC_LOG(("scroll() - called\n"));
96
97 return wscrl(win, 1);
98 }
File pdcurses/slk.c added (mode: 100644) (index 00000000..f97f406e)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: slk.c,v 1.61 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: slk
10
11 Synopsis:
12 int slk_init(int fmt);
13 int slk_set(int labnum, const char *label, int justify);
14 int slk_refresh(void);
15 int slk_noutrefresh(void);
16 char *slk_label(int labnum);
17 int slk_clear(void);
18 int slk_restore(void);
19 int slk_touch(void);
20 int slk_attron(const chtype attrs);
21 int slk_attr_on(const attr_t attrs, void *opts);
22 int slk_attrset(const chtype attrs);
23 int slk_attr_set(const attr_t attrs, short color_pair, void *opts);
24 int slk_attroff(const chtype attrs);
25 int slk_attr_off(const attr_t attrs, void *opts);
26 int slk_color(short color_pair);
27
28 int slk_wset(int labnum, const wchar_t *label, int justify);
29
30 int PDC_mouse_in_slk(int y, int x);
31 void PDC_slk_free(void);
32 void PDC_slk_initialize(void);
33
34 wchar_t *slk_wlabel(int labnum)
35
36 Description:
37 These functions manipulate a window that contain Soft Label Keys
38 (SLK). To use the SLK functions, a call to slk_init() must be
39 made BEFORE initscr() or newterm(). slk_init() removes 1 or 2
40 lines from the useable screen, depending on the format selected.
41
42 The line(s) removed from the screen are used as a separate
43 window, in which SLKs are displayed.
44
45 slk_init() requires a single parameter which describes the
46 format of the SLKs as follows:
47
48 0 3-2-3 format
49 1 4-4 format
50 2 4-4-4 format (ncurses extension)
51 3 4-4-4 format with index line (ncurses extension)
52 2 lines used
53 55 5-5 format (pdcurses format)
54
55 slk_refresh(), slk_noutrefresh() and slk_touch() are analogous
56 to refresh(), noutrefresh() and touch().
57
58 Return Value:
59 All functions return OK on success and ERR on error.
60
61 Portability X/Open BSD SYS V
62 slk_init Y - Y
63 slk_set Y - Y
64 slk_refresh Y - Y
65 slk_noutrefresh Y - Y
66 slk_label Y - Y
67 slk_clear Y - Y
68 slk_restore Y - Y
69 slk_touch Y - Y
70 slk_attron Y - Y
71 slk_attrset Y - Y
72 slk_attroff Y - Y
73 slk_attr_on Y
74 slk_attr_set Y
75 slk_attr_off Y
76 slk_wset Y
77 PDC_mouse_in_slk - - -
78 PDC_slk_free - - -
79 PDC_slk_initialize - - -
80 slk_wlabel - - -
81
82 **man-end****************************************************************/
83
84 #include <stdlib.h>
85
86 enum { LABEL_NORMAL = 8, LABEL_EXTENDED = 10, LABEL_NCURSES_EXTENDED = 12 };
87
88 static int label_length = 0;
89 static int labels = 0;
90 static int label_fmt = 0;
91 static int label_line = 0;
92 static bool hidden = FALSE;
93
94 static struct SLK {
95 chtype label[32];
96 int len;
97 int format;
98 int start_col;
99 } *slk = (struct SLK *)NULL;
100
101 /* slk_init() is the slk initialization routine.
102 This must be called before initscr().
103
104 label_fmt = 0, 1 or 55.
105 0 = 3-2-3 format
106 1 = 4 - 4 format
107 2 = 4-4-4 format (ncurses extension for PC 12 function keys)
108 3 = 4-4-4 format (ncurses extension for PC 12 function keys -
109 with index line)
110 55 = 5 - 5 format (extended for PC, 10 function keys) */
111
112 int slk_init(int fmt)
113 {
114 PDC_LOG(("slk_init() - called\n"));
115
116 if (SP)
117 return ERR;
118
119 switch (fmt)
120 {
121 case 0: /* 3 - 2 - 3 */
122 labels = LABEL_NORMAL;
123 break;
124
125 case 1: /* 4 - 4 */
126 labels = LABEL_NORMAL;
127 break;
128
129 case 2: /* 4 4 4 */
130 labels = LABEL_NCURSES_EXTENDED;
131 break;
132
133 case 3: /* 4 4 4 with index */
134 labels = LABEL_NCURSES_EXTENDED;
135 break;
136
137 case 55: /* 5 - 5 */
138 labels = LABEL_EXTENDED;
139 break;
140
141 default:
142 return ERR;
143 }
144
145 label_fmt = fmt;
146
147 slk = calloc(labels, sizeof(struct SLK));
148
149 if (!slk)
150 labels = 0;
151
152 return slk ? OK : ERR;
153 }
154
155 /* draw a single button */
156
157 static void _drawone(int num)
158 {
159 int i, col, slen;
160
161 if (hidden)
162 return;
163
164 slen = slk[num].len;
165
166 switch (slk[num].format)
167 {
168 case 0: /* LEFT */
169 col = 0;
170 break;
171
172 case 1: /* CENTER */
173 col = (label_length - slen) / 2;
174
175 if (col + slen > label_length)
176 --col;
177 break;
178
179 default: /* RIGHT */
180 col = label_length - slen;
181 }
182
183 wmove(SP->slk_winptr, label_line, slk[num].start_col);
184
185 for (i = 0; i < label_length; ++i)
186 waddch(SP->slk_winptr, (i >= col && i < (col + slen)) ?
187 slk[num].label[i - col] : ' ');
188 }
189
190 /* redraw each button */
191
192 static void _redraw(void)
193 {
194 int i;
195
196 for (i = 0; i < labels; ++i)
197 _drawone(i);
198 }
199
200 /* slk_set() Used to set a slk label to a string.
201
202 labnum = 1 - 8 (or 10) (number of the label)
203 label = string (8 or 7 bytes total), or NULL
204 justify = 0 : left, 1 : center, 2 : right */
205
206 int slk_set(int labnum, const char *label, int justify)
207 {
208 #ifdef PDC_WIDE
209 wchar_t wlabel[32];
210
211 PDC_mbstowcs(wlabel, label, 31);
212 return slk_wset(labnum, wlabel, justify);
213 #else
214 PDC_LOG(("slk_set() - called\n"));
215
216 if (labnum < 1 || labnum > labels || justify < 0 || justify > 2)
217 return ERR;
218
219 labnum--;
220
221 if (!label || !(*label))
222 {
223 /* Clear the label */
224
225 *slk[labnum].label = 0;
226 slk[labnum].format = 0;
227 slk[labnum].len = 0;
228 }
229 else
230 {
231 int i, j = 0;
232
233 /* Skip leading spaces */
234
235 while (label[j] == ' ')
236 j++;
237
238 /* Copy it */
239
240 for (i = 0; i < label_length; i++)
241 {
242 chtype ch = label[i + j];
243
244 slk[labnum].label[i] = ch;
245
246 if (!ch)
247 break;
248 }
249
250 /* Drop trailing spaces */
251
252 while ((i + j) && (label[i + j - 1] == ' '))
253 i--;
254
255 slk[labnum].label[i] = 0;
256 slk[labnum].format = justify;
257 slk[labnum].len = i;
258 }
259
260 _drawone(labnum);
261
262 return OK;
263 #endif
264 }
265
266 int slk_refresh(void)
267 {
268 PDC_LOG(("slk_refresh() - called\n"));
269
270 return (slk_noutrefresh() == ERR) ? ERR : doupdate();
271 }
272
273 int slk_noutrefresh(void)
274 {
275 PDC_LOG(("slk_noutrefresh() - called\n"));
276
277 return wnoutrefresh(SP->slk_winptr);
278 }
279
280 char *slk_label(int labnum)
281 {
282 static char temp[33];
283 #ifdef PDC_WIDE
284 wchar_t *wtemp = slk_wlabel(labnum);
285
286 PDC_wcstombs(temp, wtemp, 32);
287 #else
288 chtype *p;
289 int i;
290
291 PDC_LOG(("slk_label() - called\n"));
292
293 if (labnum < 1 || labnum > labels)
294 return (char *)0;
295
296 for (i = 0, p = slk[labnum - 1].label; *p; i++)
297 temp[i] = *p++;
298
299 temp[i] = '\0';
300 #endif
301 return temp;
302 }
303
304 int slk_clear(void)
305 {
306 PDC_LOG(("slk_clear() - called\n"));
307
308 hidden = TRUE;
309 werase(SP->slk_winptr);
310 return wrefresh(SP->slk_winptr);
311 }
312
313 int slk_restore(void)
314 {
315 PDC_LOG(("slk_restore() - called\n"));
316
317 hidden = FALSE;
318 _redraw();
319 return wrefresh(SP->slk_winptr);
320 }
321
322 int slk_touch(void)
323 {
324 PDC_LOG(("slk_touch() - called\n"));
325
326 return touchwin(SP->slk_winptr);
327 }
328
329 int slk_attron(const chtype attrs)
330 {
331 int rc;
332
333 PDC_LOG(("slk_attron() - called\n"));
334
335 rc = wattron(SP->slk_winptr, attrs);
336 _redraw();
337
338 return rc;
339 }
340
341 int slk_attr_on(const attr_t attrs, void *opts)
342 {
343 PDC_LOG(("slk_attr_on() - called\n"));
344
345 return slk_attron(attrs);
346 }
347
348 int slk_attroff(const chtype attrs)
349 {
350 int rc;
351
352 PDC_LOG(("slk_attroff() - called\n"));
353
354 rc = wattroff(SP->slk_winptr, attrs);
355 _redraw();
356
357 return rc;
358 }
359
360 int slk_attr_off(const attr_t attrs, void *opts)
361 {
362 PDC_LOG(("slk_attr_off() - called\n"));
363
364 return slk_attroff(attrs);
365 }
366
367 int slk_attrset(const chtype attrs)
368 {
369 int rc;
370
371 PDC_LOG(("slk_attrset() - called\n"));
372
373 rc = wattrset(SP->slk_winptr, attrs);
374 _redraw();
375
376 return rc;
377 }
378
379 int slk_color(short color_pair)
380 {
381 int rc;
382
383 PDC_LOG(("slk_color() - called\n"));
384
385 rc = wcolor_set(SP->slk_winptr, color_pair, NULL);
386 _redraw();
387
388 return rc;
389 }
390
391 int slk_attr_set(const attr_t attrs, short color_pair, void *opts)
392 {
393 PDC_LOG(("slk_attr_set() - called\n"));
394
395 return slk_attrset(attrs | COLOR_PAIR(color_pair));
396 }
397
398 static void _slk_calc(void)
399 {
400 int i, center, col = 0;
401 label_length = COLS / labels;
402
403 if (label_length > 31)
404 label_length = 31;
405
406 switch (label_fmt)
407 {
408 case 0: /* 3 - 2 - 3 F-Key layout */
409
410 --label_length;
411
412 slk[0].start_col = col;
413 slk[1].start_col = (col += label_length);
414 slk[2].start_col = (col += label_length);
415
416 center = COLS / 2;
417
418 slk[3].start_col = center - label_length + 1;
419 slk[4].start_col = center + 1;
420
421 col = COLS - (label_length * 3) + 1;
422
423 slk[5].start_col = col;
424 slk[6].start_col = (col += label_length);
425 slk[7].start_col = (col += label_length);
426 break;
427
428 case 1: /* 4 - 4 F-Key layout */
429
430 for (i = 0; i < 8; i++)
431 {
432 slk[i].start_col = col;
433 col += label_length;
434
435 if (i == 3)
436 col = COLS - (label_length * 4) + 1;
437 }
438
439 break;
440
441 case 2: /* 4 4 4 F-Key layout */
442 case 3: /* 4 4 4 F-Key layout with index */
443
444 for (i = 0; i < 4; i++)
445 {
446 slk[i].start_col = col;
447 col += label_length;
448 }
449
450 center = COLS/2;
451
452 slk[4].start_col = center - (label_length * 2) + 1;
453 slk[5].start_col = center - label_length - 1;
454 slk[6].start_col = center + 1;
455 slk[7].start_col = center + label_length + 1;
456
457 col = COLS - (label_length * 4) + 1;
458
459 for (i = 8; i < 12; i++)
460 {
461 slk[i].start_col = col;
462 col += label_length;
463 }
464
465 break;
466
467 default: /* 5 - 5 F-Key layout */
468
469 for (i = 0; i < 10; i++)
470 {
471 slk[i].start_col = col;
472 col += label_length;
473
474 if (i == 4)
475 col = COLS - (label_length * 5) + 1;
476 }
477 }
478
479 --label_length;
480
481 /* make sure labels are all in window */
482
483 _redraw();
484 }
485
486 void PDC_slk_initialize(void)
487 {
488 if (slk)
489 {
490 if (label_fmt == 3)
491 {
492 SP->slklines = 2;
493 label_line = 1;
494 }
495 else
496 SP->slklines = 1;
497
498 if (!SP->slk_winptr)
499 {
500 if ( !(SP->slk_winptr = newwin(SP->slklines, COLS,
501 LINES - SP->slklines, 0)) )
502 return;
503
504 wattrset(SP->slk_winptr, A_REVERSE);
505 }
506
507 _slk_calc();
508
509 /* if we have an index line, display it now */
510
511 if (label_fmt == 3)
512 {
513 chtype save_attr;
514 int i;
515
516 save_attr = SP->slk_winptr->_attrs;
517 wattrset(SP->slk_winptr, A_NORMAL);
518 wmove(SP->slk_winptr, 0, 0);
519 whline(SP->slk_winptr, 0, COLS);
520
521 for (i = 0; i < labels; i++)
522 mvwprintw(SP->slk_winptr, 0, slk[i].start_col, "F%d", i + 1);
523
524 SP->slk_winptr->_attrs = save_attr;
525 }
526
527 touchwin(SP->slk_winptr);
528 }
529 }
530
531 void PDC_slk_free(void)
532 {
533 if (slk)
534 {
535 if (SP->slk_winptr)
536 {
537 delwin(SP->slk_winptr);
538 SP->slk_winptr = (WINDOW *)NULL;
539 }
540
541 free(slk);
542 slk = (struct SLK *)NULL;
543
544 label_length = 0;
545 labels = 0;
546 label_fmt = 0;
547 label_line = 0;
548 hidden = FALSE;
549 }
550 }
551
552 int PDC_mouse_in_slk(int y, int x)
553 {
554 int i;
555
556 PDC_LOG(("PDC_mouse_in_slk() - called: y->%d x->%d\n", y, x));
557
558 /* If the line on which the mouse was clicked is NOT the last line
559 of the screen, we are not interested in it. */
560
561 if (!slk || !SP->slk_winptr || (y != SP->slk_winptr->_begy + label_line))
562 return 0;
563
564 for (i = 0; i < labels; i++)
565 if (x >= slk[i].start_col && x < (slk[i].start_col + label_length))
566 return i + 1;
567
568 return 0;
569 }
570
571 #ifdef PDC_WIDE
572 int slk_wset(int labnum, const wchar_t *label, int justify)
573 {
574 PDC_LOG(("slk_wset() - called\n"));
575
576 if (labnum < 1 || labnum > labels || justify < 0 || justify > 2)
577 return ERR;
578
579 labnum--;
580
581 if (!label || !(*label))
582 {
583 /* Clear the label */
584
585 *slk[labnum].label = 0;
586 slk[labnum].format = 0;
587 slk[labnum].len = 0;
588 }
589 else
590 {
591 int i, j = 0;
592
593 /* Skip leading spaces */
594
595 while (label[j] == L' ')
596 j++;
597
598 /* Copy it */
599
600 for (i = 0; i < label_length; i++)
601 {
602 chtype ch = label[i + j];
603
604 slk[labnum].label[i] = ch;
605
606 if (!ch)
607 break;
608 }
609
610 /* Drop trailing spaces */
611
612 while ((i + j) && (label[i + j - 1] == L' '))
613 i--;
614
615 slk[labnum].label[i] = 0;
616 slk[labnum].format = justify;
617 slk[labnum].len = i;
618 }
619
620 _drawone(labnum);
621
622 return OK;
623 }
624
625 wchar_t *slk_wlabel(int labnum)
626 {
627 static wchar_t temp[33];
628 chtype *p;
629 int i;
630
631 PDC_LOG(("slk_wlabel() - called\n"));
632
633 if (labnum < 1 || labnum > labels)
634 return (wchar_t *)0;
635
636 for (i = 0, p = slk[labnum - 1].label; *p; i++)
637 temp[i] = *p++;
638
639 temp[i] = '\0';
640
641 return temp;
642 }
643 #endif
File pdcurses/termattr.c added (mode: 100644) (index 00000000..06e9ee85)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: termattr.c,v 1.54 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: termattr
10
11 Synopsis:
12 int baudrate(void);
13 char erasechar(void);
14 bool has_ic(void);
15 bool has_il(void);
16 char killchar(void);
17 char *longname(void);
18 chtype termattrs(void);
19 attr_t term_attrs(void);
20 char *termname(void);
21
22 int erasewchar(wchar_t *ch);
23 int killwchar(wchar_t *ch);
24
25 char wordchar(void);
26
27 Description:
28 baudrate() is supposed to return the output speed of the
29 terminal. In PDCurses, it simply returns INT_MAX.
30
31 has_ic and has_il() return TRUE. These functions have meaning in
32 some other implementations of curses.
33
34 erasechar() and killchar() return ^H and ^U, respectively -- the
35 ERASE and KILL characters. In other curses implementations,
36 these may vary by terminal type. erasewchar() and killwchar()
37 are the wide-character versions; they take a pointer to a
38 location in which to store the character, and return OK or ERR.
39
40 longname() returns a pointer to a static area containing a
41 verbose description of the current terminal. The maximum length
42 of the string is 128 characters. It is defined only after the
43 call to initscr() or newterm().
44
45 termname() returns a pointer to a static area containing a
46 short description of the current terminal (14 characters).
47
48 termattrs() returns a logical OR of all video attributes
49 supported by the terminal.
50
51 wordchar() is a PDCurses extension of the concept behind the
52 functions erasechar() and killchar(), returning the "delete
53 word" character, ^W.
54
55 Portability X/Open BSD SYS V
56 baudrate Y Y Y
57 erasechar Y Y Y
58 has_ic Y Y Y
59 has_il Y Y Y
60 killchar Y Y Y
61 longname Y Y Y
62 termattrs Y Y Y
63 termname Y Y Y
64 erasewchar Y
65 killwchar Y
66 term_attrs Y
67 wordchar - - -
68
69 **man-end****************************************************************/
70
71 #include <string.h>
72 #include <limits.h>
73
74 int baudrate(void)
75 {
76 PDC_LOG(("baudrate() - called\n"));
77
78 return INT_MAX;
79 }
80
81 char erasechar(void)
82 {
83 PDC_LOG(("erasechar() - called\n"));
84
85 return _ECHAR; /* character delete char (^H) */
86 }
87
88 bool has_ic(void)
89 {
90 PDC_LOG(("has_ic() - called\n"));
91
92 return TRUE;
93 }
94
95 bool has_il(void)
96 {
97 PDC_LOG(("has_il() - called\n"));
98
99 return TRUE;
100 }
101
102 char killchar(void)
103 {
104 PDC_LOG(("killchar() - called\n"));
105
106 return _DLCHAR; /* line delete char (^U) */
107 }
108
109 char *longname(void)
110 {
111 PDC_LOG(("longname() - called\n"));
112
113 return ttytype + 9; /* skip "pdcurses|" */
114 }
115
116 chtype termattrs(void)
117 {
118 chtype temp = A_BLINK | A_BOLD | A_INVIS | A_REVERSE | A_UNDERLINE;
119
120 /* note: blink is bold background on some platforms */
121
122 PDC_LOG(("termattrs() - called\n"));
123
124 if (!SP->mono)
125 temp |= A_COLOR;
126
127 return temp;
128 }
129
130 attr_t term_attrs(void)
131 {
132 PDC_LOG(("term_attrs() - called\n"));
133
134 return WA_BLINK | WA_BOLD | WA_INVIS | WA_LEFT | WA_REVERSE |
135 WA_RIGHT | WA_UNDERLINE;
136 }
137
138 char *termname(void)
139 {
140 PDC_LOG(("termname() - called\n"));
141
142 return "pdcurses";
143 }
144
145 char wordchar(void)
146 {
147 PDC_LOG(("wordchar() - called\n"));
148
149 return _DWCHAR; /* word delete char */
150 }
151
152 #ifdef PDC_WIDE
153 int erasewchar(wchar_t *ch)
154 {
155 PDC_LOG(("erasewchar() - called\n"));
156
157 if (!ch)
158 return ERR;
159
160 *ch = (wchar_t)_ECHAR;
161
162 return OK;
163 }
164
165 int killwchar(wchar_t *ch)
166 {
167 PDC_LOG(("killwchar() - called\n"));
168
169 if (!ch)
170 return ERR;
171
172 *ch = (wchar_t)_DLCHAR;
173
174 return OK;
175 }
176 #endif
File pdcurses/terminfo.c added (mode: 100644) (index 00000000..c099ada7)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: terminfo.c,v 1.37 2008/07/21 12:29:20 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: terminfo
10
11 Synopsis:
12 int mvcur(int oldrow, int oldcol, int newrow, int newcol);
13 int vidattr(chtype attr);
14 int vid_attr(attr_t attr, short color_pair, void *opt);
15 int vidputs(chtype attr, int (*putfunc)(int));
16 int vid_puts(attr_t attr, short color_pair, void *opt,
17 int (*putfunc)(int));
18
19 int del_curterm(TERMINAL *);
20 int putp(const char *);
21 int restartterm(const char *, int, int *);
22 TERMINAL *set_curterm(TERMINAL *);
23 int setterm(const char *term);
24 int setupterm(const char *, int, int *);
25 int tgetent(char *, const char *);
26 int tgetflag(const char *);
27 int tgetnum(const char *);
28 char *tgetstr(const char *, char **);
29 char *tgoto(const char *, int, int);
30 int tigetflag(const char *);
31 int tigetnum(const char *);
32 char *tigetstr(const char *);
33 char *tparm(const char *,long, long, long, long, long, long,
34 long, long, long);
35 int tputs(const char *, int, int (*)(int));
36
37 Description:
38 mvcur() lets you move the physical cursor without updating any
39 window cursor positions. It returns OK or ERR.
40
41 The rest of these functions are currently implemented as stubs,
42 returning the appropriate errors and doing nothing else.
43
44 Portability X/Open BSD SYS V
45 mvcur Y Y Y
46
47 **man-end****************************************************************/
48
49 #include <term.h>
50
51 TERMINAL *cur_term = NULL;
52
53 int mvcur(int oldrow, int oldcol, int newrow, int newcol)
54 {
55 PDC_LOG(("mvcur() - called: oldrow %d oldcol %d newrow %d newcol %d\n",
56 oldrow, oldcol, newrow, newcol));
57
58 if ((newrow >= LINES) || (newcol >= COLS) || (newrow < 0) || (newcol < 0))
59 return ERR;
60
61 PDC_gotoyx(newrow, newcol);
62 SP->cursrow = newrow;
63 SP->curscol = newcol;
64
65 return OK;
66 }
67
68 int vidattr(chtype attr)
69 {
70 PDC_LOG(("vidattr() - called: attr %d\n", attr));
71
72 return ERR;
73 }
74
75 int vid_attr(attr_t attr, short color_pair, void *opt)
76 {
77 PDC_LOG(("vid_attr() - called\n"));
78
79 return ERR;
80 }
81
82 int vidputs(chtype attr, int (*putfunc)(int))
83 {
84 PDC_LOG(("vidputs() - called: attr %d\n", attr));
85
86 return ERR;
87 }
88
89 int vid_puts(attr_t attr, short color_pair, void *opt, int (*putfunc)(int))
90 {
91 PDC_LOG(("vid_puts() - called\n"));
92
93 return ERR;
94 }
95
96 int del_curterm(TERMINAL *oterm)
97 {
98 PDC_LOG(("del_curterm() - called\n"));
99
100 return ERR;
101 }
102
103 int putp(const char *str)
104 {
105 PDC_LOG(("putp() - called: str %s\n", str));
106
107 return ERR;
108 }
109
110 int restartterm(const char *term, int filedes, int *errret)
111 {
112 PDC_LOG(("restartterm() - called\n"));
113
114 if (errret)
115 *errret = -1;
116
117 return ERR;
118 }
119
120 TERMINAL *set_curterm(TERMINAL *nterm)
121 {
122 PDC_LOG(("set_curterm() - called\n"));
123
124 return (TERMINAL *)NULL;
125 }
126
127 int setterm(const char *term)
128 {
129 PDC_LOG(("setterm() - called\n"));
130
131 return ERR;
132 }
133
134 int setupterm(const char *term, int filedes, int *errret)
135 {
136 PDC_LOG(("setupterm() - called\n"));
137
138 if (errret)
139 *errret = -1;
140 else
141 fprintf(stderr, "There is no terminfo database\n");
142
143 return ERR;
144 }
145
146 int tgetent(char *bp, const char *name)
147 {
148 PDC_LOG(("tgetent() - called: name %s\n", name));
149
150 return ERR;
151 }
152
153 int tgetflag(const char *id)
154 {
155 PDC_LOG(("tgetflag() - called: id %s\n", id));
156
157 return ERR;
158 }
159
160 int tgetnum(const char *id)
161 {
162 PDC_LOG(("tgetnum() - called: id %s\n", id));
163
164 return ERR;
165 }
166
167 char *tgetstr(const char *id, char **area)
168 {
169 PDC_LOG(("tgetstr() - called: id %s\n", id));
170
171 return (char *)NULL;
172 }
173
174 char *tgoto(const char *cap, int col, int row)
175 {
176 PDC_LOG(("tgoto() - called\n"));
177
178 return (char *)NULL;
179 }
180
181 int tigetflag(const char *capname)
182 {
183 PDC_LOG(("tigetflag() - called: capname %s\n", capname));
184
185 return -1;
186 }
187
188 int tigetnum(const char *capname)
189 {
190 PDC_LOG(("tigetnum() - called: capname %s\n", capname));
191
192 return -2;
193 }
194
195 char *tigetstr(const char *capname)
196 {
197 PDC_LOG(("tigetstr() - called: capname %s\n", capname));
198
199 return (char *)(-1);
200 }
201
202 char *tparm(const char *cap, long p1, long p2, long p3, long p4,
203 long p5, long p6, long p7, long p8, long p9)
204 {
205 PDC_LOG(("tparm() - called: cap %s\n", cap));
206
207 return (char *)NULL;
208 }
209
210 int tputs(const char *str, int affcnt, int (*putfunc)(int))
211 {
212 PDC_LOG(("tputs() - called\n"));
213
214 return ERR;
215 }
File pdcurses/touch.c added (mode: 100644) (index 00000000..9355aa1f)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: touch.c,v 1.29 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: touch
10
11 Synopsis:
12 int touchwin(WINDOW *win);
13 int touchline(WINDOW *win, int start, int count);
14 int untouchwin(WINDOW *win);
15 int wtouchln(WINDOW *win, int y, int n, int changed);
16 bool is_linetouched(WINDOW *win, int line);
17 bool is_wintouched(WINDOW *win);
18
19 Description:
20 touchwin() and touchline() throw away all information about
21 which parts of the window have been touched, pretending that the
22 entire window has been drawn on. This is sometimes necessary
23 when using overlapping windows, since a change to one window
24 will affect the other window, but the records of which lines
25 have been changed in the other window will not reflect the
26 change.
27
28 untouchwin() marks all lines in the window as unchanged since
29 the last call to wrefresh().
30
31 wtouchln() makes n lines in the window, starting at line y, look
32 as if they have (changed == 1) or have not (changed == 0) been
33 changed since the last call to wrefresh().
34
35 is_linetouched() returns TRUE if the specified line in the
36 specified window has been changed since the last call to
37 wrefresh().
38
39 is_wintouched() returns TRUE if the specified window
40 has been changed since the last call to wrefresh().
41
42 Return Value:
43 All functions return OK on success and ERR on error except
44 is_wintouched() and is_linetouched().
45
46 Portability X/Open BSD SYS V
47 touchwin Y Y Y
48 touchline Y - 3.0
49 untouchwin Y - 4.0
50 wtouchln Y Y Y
51 is_linetouched Y - 4.0
52 is_wintouched Y - 4.0
53
54 **man-end****************************************************************/
55
56 int touchwin(WINDOW *win)
57 {
58 int i;
59
60 PDC_LOG(("touchwin() - called: Win=%x\n", win));
61
62 if (!win)
63 return ERR;
64
65 for (i = 0; i < win->_maxy; i++)
66 {
67 win->_firstch[i] = 0;
68 win->_lastch[i] = win->_maxx - 1;
69 }
70
71 return OK;
72 }
73
74 int touchline(WINDOW *win, int start, int count)
75 {
76 int i;
77
78 PDC_LOG(("touchline() - called: win=%p start %d count %d\n",
79 win, start, count));
80
81 if (!win || start > win->_maxy || start + count > win->_maxy)
82 return ERR;
83
84 for (i = start; i < start + count; i++)
85 {
86 win->_firstch[i] = 0;
87 win->_lastch[i] = win->_maxx - 1;
88 }
89
90 return OK;
91 }
92
93 int untouchwin(WINDOW *win)
94 {
95 int i;
96
97 PDC_LOG(("untouchwin() - called: win=%p", win));
98
99 if (!win)
100 return ERR;
101
102 for (i = 0; i < win->_maxy; i++)
103 {
104 win->_firstch[i] = _NO_CHANGE;
105 win->_lastch[i] = _NO_CHANGE;
106 }
107
108 return OK;
109 }
110
111 int wtouchln(WINDOW *win, int y, int n, int changed)
112 {
113 int i;
114
115 PDC_LOG(("wtouchln() - called: win=%p y=%d n=%d changed=%d\n",
116 win, y, n, changed));
117
118 if (!win || y > win->_maxy || y + n > win->_maxy)
119 return ERR;
120
121 for (i = y; i < y + n; i++)
122 {
123 if (changed)
124 {
125 win->_firstch[i] = 0;
126 win->_lastch[i] = win->_maxx - 1;
127 }
128 else
129 {
130 win->_firstch[i] = _NO_CHANGE;
131 win->_lastch[i] = _NO_CHANGE;
132 }
133 }
134
135 return OK;
136 }
137
138 bool is_linetouched(WINDOW *win, int line)
139 {
140 PDC_LOG(("is_linetouched() - called: win=%p line=%d\n", win, line));
141
142 if (!win || line > win->_maxy || line < 0)
143 return FALSE;
144
145 return (win->_firstch[line] != _NO_CHANGE) ? TRUE : FALSE;
146 }
147
148 bool is_wintouched(WINDOW *win)
149 {
150 int i;
151
152 PDC_LOG(("is_wintouched() - called: win=%p\n", win));
153
154 if (win)
155 for (i = 0; i < win->_maxy; i++)
156 if (win->_firstch[i] != _NO_CHANGE)
157 return TRUE;
158
159 return FALSE;
160 }
File pdcurses/util.c added (mode: 100644) (index 00000000..f0673fca)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: util.c,v 1.71 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: util
10
11 Synopsis:
12 char *unctrl(chtype c);
13 void filter(void);
14 void use_env(bool x);
15 int delay_output(int ms);
16
17 int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs,
18 short *color_pair, void *opts);
19 int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs,
20 short color_pair, const void *opts);
21 wchar_t *wunctrl(cchar_t *wc);
22
23 int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n);
24 size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n);
25 size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n);
26
27 Description:
28 unctrl() expands the text portion of the chtype c into a
29 printable string. Control characters are changed to the "^X"
30 notation; others are passed through. wunctrl() is the wide-
31 character version of the function.
32
33 filter() and use_env() are no-ops in PDCurses.
34
35 delay_output() inserts an ms millisecond pause in output.
36
37 getcchar() works in two modes: When wch is not NULL, it reads
38 the cchar_t pointed to by wcval and stores the attributes in
39 attrs, the color pair in color_pair, and the text in the
40 wide-character string wch. When wch is NULL, getcchar() merely
41 returns the number of wide characters in wcval. In either mode,
42 the opts argument is unused.
43
44 setcchar constructs a cchar_t at wcval from the wide-character
45 text at wch, the attributes in attr and the color pair in
46 color_pair. The opts argument is unused.
47
48 Currently, the length returned by getcchar() is always 1 or 0.
49 Similarly, setcchar() will only take the first wide character
50 from wch, and ignore any others that it "should" take (i.e.,
51 combining characters). Nor will it correctly handle any
52 character outside the basic multilingual plane (UCS-2).
53
54 Return Value:
55 unctrl() and wunctrl() return NULL on failure. delay_output()
56 always returns OK.
57
58 getcchar() returns the number of wide characters wcval points to
59 when wch is NULL; when it's not, getcchar() returns OK or ERR.
60
61 setcchar() returns OK or ERR.
62
63 Portability X/Open BSD SYS V
64 unctrl Y Y Y
65 filter Y - 3.0
66 use_env Y - 4.0
67 delay_output Y Y Y
68 getcchar Y
69 setcchar Y
70 wunctrl Y
71 PDC_mbtowc - - -
72 PDC_mbstowcs - - -
73 PDC_wcstombs - - -
74
75 **man-end****************************************************************/
76
77 #ifdef PDC_WIDE
78 # ifdef PDC_FORCE_UTF8
79 # include <string.h>
80 # else
81 # include <stdlib.h>
82 # endif
83 #endif
84
85 char *unctrl(chtype c)
86 {
87 static char strbuf[3] = {0, 0, 0};
88
89 chtype ic;
90
91 PDC_LOG(("unctrl() - called\n"));
92
93 ic = c & A_CHARTEXT;
94
95 if (ic >= 0x20 && ic != 0x7f) /* normal characters */
96 {
97 strbuf[0] = (char)ic;
98 strbuf[1] = '\0';
99 return strbuf;
100 }
101
102 strbuf[0] = '^'; /* '^' prefix */
103
104 if (ic == 0x7f) /* 0x7f == DEL */
105 strbuf[1] = '?';
106 else /* other control */
107 strbuf[1] = (char)(ic + '@');
108
109 return strbuf;
110 }
111
112 void filter(void)
113 {
114 PDC_LOG(("filter() - called\n"));
115 }
116
117 void use_env(bool x)
118 {
119 PDC_LOG(("use_env() - called: x %d\n", x));
120 }
121
122 int delay_output(int ms)
123 {
124 PDC_LOG(("delay_output() - called: ms %d\n", ms));
125
126 return napms(ms);
127 }
128
129 #ifdef PDC_WIDE
130 int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs,
131 short *color_pair, void *opts)
132 {
133 if (!wcval)
134 return ERR;
135
136 if (wch)
137 {
138 if (!attrs || !color_pair)
139 return ERR;
140
141 *wch = (*wcval & A_CHARTEXT);
142 *attrs = (*wcval & (A_ATTRIBUTES & ~A_COLOR));
143 *color_pair = PAIR_NUMBER(*wcval & A_COLOR);
144
145 if (*wch)
146 *++wch = L'\0';
147
148 return OK;
149 }
150 else
151 return ((*wcval & A_CHARTEXT) != L'\0');
152 }
153
154 int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs,
155 short color_pair, const void *opts)
156 {
157 if (!wcval || !wch)
158 return ERR;
159
160 *wcval = *wch | attrs | COLOR_PAIR(color_pair);
161
162 return OK;
163 }
164
165 wchar_t *wunctrl(cchar_t *wc)
166 {
167 static wchar_t strbuf[3] = {0, 0, 0};
168
169 cchar_t ic;
170
171 PDC_LOG(("wunctrl() - called\n"));
172
173 ic = *wc & A_CHARTEXT;
174
175 if (ic >= 0x20 && ic != 0x7f) /* normal characters */
176 {
177 strbuf[0] = (wchar_t)ic;
178 strbuf[1] = L'\0';
179 return strbuf;
180 }
181
182 strbuf[0] = '^'; /* '^' prefix */
183
184 if (ic == 0x7f) /* 0x7f == DEL */
185 strbuf[1] = '?';
186 else /* other control */
187 strbuf[1] = (wchar_t)(ic + '@');
188
189 return strbuf;
190 }
191
192 int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n)
193 {
194 # ifdef PDC_FORCE_UTF8
195 wchar_t key;
196 int i = -1;
197 const unsigned char *string;
198
199 if (!s || (n < 1))
200 return -1;
201
202 if (!*s)
203 return 0;
204
205 string = (const unsigned char *)s;
206
207 key = string[0];
208
209 /* Simplistic UTF-8 decoder -- only does the BMP, minimal validation */
210
211 if (key & 0x80)
212 {
213 if ((key & 0xe0) == 0xc0)
214 {
215 if (1 < n)
216 {
217 key = ((key & 0x1f) << 6) | (string[1] & 0x3f);
218 i = 2;
219 }
220 }
221 else if ((key & 0xe0) == 0xe0)
222 {
223 if (2 < n)
224 {
225 key = ((key & 0x0f) << 12) | ((string[1] & 0x3f) << 6) |
226 (string[2] & 0x3f);
227 i = 3;
228 }
229 }
230 }
231 else
232 i = 1;
233
234 if (i)
235 *pwc = key;
236
237 return i;
238 # else
239 return mbtowc(pwc, s, n);
240 # endif
241 }
242
243 size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n)
244 {
245 # ifdef PDC_FORCE_UTF8
246 size_t i = 0, len;
247
248 if (!src || !dest)
249 return 0;
250
251 len = strlen(src);
252
253 while (*src && i < n)
254 {
255 int retval = PDC_mbtowc(dest + i, src, len);
256
257 if (retval < 1)
258 return -1;
259
260 src += retval;
261 len -= retval;
262 i++;
263 }
264 # else
265 size_t i = mbstowcs(dest, src, n);
266 # endif
267 dest[i] = 0;
268 return i;
269 }
270
271 size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n)
272 {
273 # ifdef PDC_FORCE_UTF8
274 size_t i = 0;
275
276 if (!src || !dest)
277 return 0;
278
279 while (*src && i < n)
280 {
281 chtype code = *src++;
282
283 if (code < 0x80)
284 {
285 dest[i] = code;
286 i++;
287 }
288 else
289 if (code < 0x800)
290 {
291 dest[i] = ((code & 0x07c0) >> 6) | 0xc0;
292 dest[i + 1] = (code & 0x003f) | 0x80;
293 i += 2;
294 }
295 else
296 {
297 dest[i] = ((code & 0xf000) >> 12) | 0xe0;
298 dest[i + 1] = ((code & 0x0fc0) >> 6) | 0x80;
299 dest[i + 2] = (code & 0x003f) | 0x80;
300 i += 3;
301 }
302 }
303 # else
304 size_t i = wcstombs(dest, src, n);
305 # endif
306 dest[i] = '\0';
307 return i;
308 }
309 #endif
File pdcurses/window.c added (mode: 100644) (index 00000000..dbfd5849)
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: window.c,v 1.62 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: window
10
11 Synopsis:
12 WINDOW *newwin(int nlines, int ncols, int begy, int begx);
13 WINDOW *derwin(WINDOW* orig, int nlines, int ncols,
14 int begy, int begx);
15 WINDOW *subwin(WINDOW* orig, int nlines, int ncols,
16 int begy, int begx);
17 WINDOW *dupwin(WINDOW *win);
18 int delwin(WINDOW *win);
19 int mvwin(WINDOW *win, int y, int x);
20 int mvderwin(WINDOW *win, int pary, int parx);
21 int syncok(WINDOW *win, bool bf);
22 void wsyncup(WINDOW *win);
23 void wcursyncup(WINDOW *win);
24 void wsyncdown(WINDOW *win);
25
26 WINDOW *resize_window(WINDOW *win, int nlines, int ncols);
27 int wresize(WINDOW *win, int nlines, int ncols);
28 WINDOW *PDC_makelines(WINDOW *win);
29 WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx);
30 void PDC_sync(WINDOW *win);
31
32 Description:
33 newwin() creates a new window with the given number of lines,
34 nlines and columns, ncols. The upper left corner of the window
35 is at line begy, column begx. If nlines is zero, it defaults to
36 LINES - begy; ncols to COLS - begx. Create a new full-screen
37 window by calling newwin(0, 0, 0, 0).
38
39 delwin() deletes the named window, freeing all associated
40 memory. In the case of overlapping windows, subwindows should be
41 deleted before the main window.
42
43 mvwin() moves the window so that the upper left-hand corner is
44 at position (y,x). If the move would cause the window to be off
45 the screen, it is an error and the window is not moved. Moving
46 subwindows is allowed.
47
48 subwin() creates a new subwindow within a window. The
49 dimensions of the subwindow are nlines lines and ncols columns.
50 The subwindow is at position (begy, begx) on the screen. This
51 position is relative to the screen, and not to the window orig.
52 Changes made to either window will affect both. When using this
53 routine, you will often need to call touchwin() before calling
54 wrefresh().
55
56 derwin() is the same as subwin(), except that begy and begx are
57 relative to the origin of the window orig rather than the
58 screen. There is no difference between subwindows and derived
59 windows.
60
61 mvderwin() moves a derived window (or subwindow) inside its
62 parent window. The screen-relative parameters of the window are
63 not changed. This routine is used to display different parts of
64 the parent window at the same physical position on the screen.
65
66 dupwin() creates an exact duplicate of the window win.
67
68 wsyncup() causes a touchwin() of all of the window's parents.
69
70 If wsyncok() is called with a second argument of TRUE, this
71 causes a wsyncup() to be called every time the window is
72 changed.
73
74 wcursyncup() causes the current cursor position of all of a
75 window's ancestors to reflect the current cursor position of the
76 current window.
77
78 wsyncdown() causes a touchwin() of the current window if any of
79 its parent's windows have been touched.
80
81 resize_window() allows the user to resize an existing window. It
82 returns the pointer to the new window, or NULL on failure.
83
84 wresize() is an ncurses-compatible wrapper for resize_window().
85 Note that, unlike ncurses, it will NOT process any subwindows of
86 the window. (However, you still can call it _on_ subwindows.) It
87 returns OK or ERR.
88
89 PDC_makenew() allocates all data for a new WINDOW * except the
90 actual lines themselves. If it's unable to allocate memory for
91 the window structure, it will free all allocated memory and
92 return a NULL pointer.
93
94 PDC_makelines() allocates the memory for the lines.
95
96 PDC_sync() handles wrefresh() and wsyncup() calls when a window
97 is changed.
98
99 Return Value:
100 newwin(), subwin(), derwin() and dupwin() return a pointer
101 to the new window, or NULL on failure. delwin(), mvwin(),
102 mvderwin() and syncok() return OK or ERR. wsyncup(),
103 wcursyncup() and wsyncdown() return nothing.
104
105 Errors:
106 It is an error to call resize_window() before calling initscr().
107 Also, an error will be generated if we fail to create a newly
108 sized replacement window for curscr, or stdscr. This could
109 happen when increasing the window size. NOTE: If this happens,
110 the previously successfully allocated windows are left alone;
111 i.e., the resize is NOT cancelled for those windows.
112
113 Portability X/Open BSD SYS V
114 newwin Y Y Y
115 delwin Y Y Y
116 mvwin Y Y Y
117 subwin Y Y Y
118 derwin Y - Y
119 mvderwin Y - Y
120 dupwin Y - 4.0
121 wsyncup Y - 4.0
122 syncok Y - 4.0
123 wcursyncup Y - 4.0
124 wsyncdown Y - 4.0
125 resize_window - - -
126 wresize - - -
127 PDC_makelines - - -
128 PDC_makenew - - -
129 PDC_sync - - -
130
131 **man-end****************************************************************/
132
133 #include <stdlib.h>
134
135 WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx)
136 {
137 WINDOW *win;
138
139 PDC_LOG(("PDC_makenew() - called: lines %d cols %d begy %d begx %d\n",
140 nlines, ncols, begy, begx));
141
142 /* allocate the window structure itself */
143
144 if ((win = calloc(1, sizeof(WINDOW))) == (WINDOW *)NULL)
145 return win;
146
147 /* allocate the line pointer array */
148
149 if ((win->_y = malloc(nlines * sizeof(chtype *))) == NULL)
150 {
151 free(win);
152 return (WINDOW *)NULL;
153 }
154
155 /* allocate the minchng and maxchng arrays */
156
157 if ((win->_firstch = malloc(nlines * sizeof(int))) == NULL)
158 {
159 free(win->_y);
160 free(win);
161 return (WINDOW *)NULL;
162 }
163
164 if ((win->_lastch = malloc(nlines * sizeof(int))) == NULL)
165 {
166 free(win->_firstch);
167 free(win->_y);
168 free(win);
169 return (WINDOW *)NULL;
170 }
171
172 /* initialize window variables */
173
174 win->_maxy = nlines; /* real max screen size */
175 win->_maxx = ncols; /* real max screen size */
176 win->_begy = begy;
177 win->_begx = begx;
178 win->_bkgd = ' '; /* wrs 4/10/93 -- initialize background to blank */
179 win->_clear = (bool) ((nlines == LINES) && (ncols == COLS));
180 win->_bmarg = nlines - 1;
181 win->_parx = win->_pary = -1;
182
183 /* init to say window all changed */
184
185 touchwin(win);
186
187 return win;
188 }
189
190 WINDOW *PDC_makelines(WINDOW *win)
191 {
192 int i, j, nlines, ncols;
193
194 PDC_LOG(("PDC_makelines() - called: lines %d cols %d\n", nlines, ncols));
195
196 if (!win)
197 return (WINDOW *)NULL;
198
199 nlines = win->_maxy;
200 ncols = win->_maxx;
201
202 for (i = 0; i < nlines; i++)
203 {
204 if ((win->_y[i] = malloc(ncols * sizeof(chtype))) == NULL)
205 {
206 /* if error, free all the data */
207
208 for (j = 0; j < i; j++)
209 free(win->_y[j]);
210
211 free(win->_firstch);
212 free(win->_lastch);
213 free(win->_y);
214 free(win);
215
216 return (WINDOW *)NULL;
217 }
218 }
219
220 return win;
221 }
222
223 void PDC_sync(WINDOW *win)
224 {
225 PDC_LOG(("PDC_sync() - called:\n"));
226
227 if (win->_immed)
228 wrefresh(win);
229 if (win->_sync)
230 wsyncup(win);
231 }
232
233 WINDOW *newwin(int nlines, int ncols, int begy, int begx)
234 {
235 WINDOW *win;
236
237 PDC_LOG(("newwin() - called:lines=%d cols=%d begy=%d begx=%d\n",
238 nlines, ncols, begy, begx));
239
240 if (!nlines)
241 nlines = LINES - begy;
242 if (!ncols)
243 ncols = COLS - begx;
244
245 if ( (begy + nlines > SP->lines || begx + ncols > SP->cols)
246 || !(win = PDC_makenew(nlines, ncols, begy, begx))
247 || !(win = PDC_makelines(win)) )
248 return (WINDOW *)NULL;
249
250 werase(win);
251
252 return win;
253 }
254
255 int delwin(WINDOW *win)
256 {
257 int i;
258
259 PDC_LOG(("delwin() - called\n"));
260
261 if (!win)
262 return ERR;
263
264 /* subwindows use parents' lines */
265
266 if (!(win->_flags & (_SUBWIN|_SUBPAD)))
267 for (i = 0; i < win->_maxy && win->_y[i]; i++)
268 if (win->_y[i])
269 free(win->_y[i]);
270
271 free(win->_firstch);
272 free(win->_lastch);
273 free(win->_y);
274 free(win);
275
276 return OK;
277 }
278
279 int mvwin(WINDOW *win, int y, int x)
280 {
281 PDC_LOG(("mvwin() - called\n"));
282
283 if (!win || (y + win->_maxy > LINES || y < 0)
284 || (x + win->_maxx > COLS || x < 0))
285 return ERR;
286
287 win->_begy = y;
288 win->_begx = x;
289 touchwin(win);
290
291 return OK;
292 }
293
294 WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
295 {
296 WINDOW *win;
297 int i;
298 int j = begy - orig->_begy;
299 int k = begx - orig->_begx;
300
301 PDC_LOG(("subwin() - called: lines %d cols %d begy %d begx %d\n",
302 nlines, ncols, begy, begx));
303
304 /* make sure window fits inside the original one */
305
306 if (!orig || (begy < orig->_begy) || (begx < orig->_begx) ||
307 (begy + nlines) > (orig->_begy + orig->_maxy) ||
308 (begx + ncols) > (orig->_begx + orig->_maxx))
309 return (WINDOW *)NULL;
310
311 if (!nlines)
312 nlines = orig->_maxy - 1 - j;
313 if (!ncols)
314 ncols = orig->_maxx - 1 - k;
315
316 if ( !(win = PDC_makenew(nlines, ncols, begy, begx)) )
317 return (WINDOW *)NULL;
318
319 /* initialize window variables */
320
321 win->_attrs = orig->_attrs;
322 win->_bkgd = orig->_bkgd;
323 win->_leaveit = orig->_leaveit;
324 win->_scroll = orig->_scroll;
325 win->_nodelay = orig->_nodelay;
326 win->_use_keypad = orig->_use_keypad;
327 win->_immed = orig->_immed;
328 win->_sync = orig->_sync;
329 win->_pary = j;
330 win->_parx = k;
331 win->_parent = orig;
332
333 for (i = 0; i < nlines; i++, j++)
334 win->_y[i] = orig->_y[j] + k;
335
336 win->_flags |= _SUBWIN;
337
338 return win;
339 }
340
341 WINDOW *derwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
342 {
343 return subwin(orig, nlines, ncols, begy + orig->_begy, begx + orig->_begx);
344 }
345
346 int mvderwin(WINDOW *win, int pary, int parx)
347 {
348 int i, j;
349 WINDOW *mypar;
350
351 if (!win || !(win->_parent))
352 return ERR;
353
354 mypar = win->_parent;
355
356 if (pary < 0 || parx < 0 || (pary + win->_maxy) > mypar->_maxy ||
357 (parx + win->_maxx) > mypar->_maxx)
358 return ERR;
359
360 j = pary;
361
362 for (i = 0; i < win->_maxy; i++)
363 win->_y[i] = (mypar->_y[j++]) + parx;
364
365 win->_pary = pary;
366 win->_parx = parx;
367
368 return OK;
369 }
370
371 WINDOW *dupwin(WINDOW *win)
372 {
373 WINDOW *new;
374 chtype *ptr, *ptr1;
375 int nlines, ncols, begy, begx, i;
376
377 if (!win)
378 return (WINDOW *)NULL;
379
380 nlines = win->_maxy;
381 ncols = win->_maxx;
382 begy = win->_begy;
383 begx = win->_begx;
384
385 if ( !(new = PDC_makenew(nlines, ncols, begy, begx))
386 || !(new = PDC_makelines(new)) )
387 return (WINDOW *)NULL;
388
389 /* copy the contents of win into new */
390
391 for (i = 0; i < nlines; i++)
392 {
393 for (ptr = new->_y[i], ptr1 = win->_y[i];
394 ptr < new->_y[i] + ncols; ptr++, ptr1++)
395 *ptr = *ptr1;
396
397 new->_firstch[i] = 0;
398 new->_lastch[i] = ncols - 1;
399 }
400
401 new->_curx = win->_curx;
402 new->_cury = win->_cury;
403 new->_maxy = win->_maxy;
404 new->_maxx = win->_maxx;
405 new->_begy = win->_begy;
406 new->_begx = win->_begx;
407 new->_flags = win->_flags;
408 new->_attrs = win->_attrs;
409 new->_clear = win->_clear;
410 new->_leaveit = win->_leaveit;
411 new->_scroll = win->_scroll;
412 new->_nodelay = win->_nodelay;
413 new->_use_keypad = win->_use_keypad;
414 new->_tmarg = win->_tmarg;
415 new->_bmarg = win->_bmarg;
416 new->_parx = win->_parx;
417 new->_pary = win->_pary;
418 new->_parent = win->_parent;
419 new->_bkgd = win->_bkgd;
420 new->_flags = win->_flags;
421
422 return new;
423 }
424
425 WINDOW *resize_window(WINDOW *win, int nlines, int ncols)
426 {
427 WINDOW *new;
428 int i, save_cury, save_curx, new_begy, new_begx;
429
430 PDC_LOG(("resize_window() - called: nlines %d ncols %d\n",
431 nlines, ncols));
432
433 if (!win)
434 return (WINDOW *)NULL;
435
436 if (win->_flags & _SUBPAD)
437 {
438 if ( !(new = subpad(win->_parent, nlines, ncols,
439 win->_begy, win->_begx)) )
440 return (WINDOW *)NULL;
441 }
442 else if (win->_flags & _SUBWIN)
443 {
444 if ( !(new = subwin(win->_parent, nlines, ncols,
445 win->_begy, win->_begx)) )
446 return (WINDOW *)NULL;
447 }
448 else
449 {
450 if (win == SP->slk_winptr)
451 {
452 new_begy = SP->lines - SP->slklines;
453 new_begx = 0;
454 }
455 else
456 {
457 new_begy = win->_begy;
458 new_begx = win->_begx;
459 }
460
461 if ( !(new = PDC_makenew(nlines, ncols, new_begy, new_begx)) )
462 return (WINDOW *)NULL;
463 }
464
465 save_curx = min(win->_curx, new->_maxx);
466 save_cury = min(win->_cury, new->_maxy);
467
468 if (!(win->_flags & (_SUBPAD|_SUBWIN)))
469 {
470 if ( !(new = PDC_makelines(new)) )
471 return (WINDOW *)NULL;
472
473 werase(new);
474
475 copywin(win, new, 0, 0, 0, 0, min(win->_maxy, new->_maxy) - 1,
476 min(win->_maxx, new->_maxx) - 1, FALSE);
477
478 for (i = 0; i < win->_maxy && win->_y[i]; i++)
479 if (win->_y[i])
480 free(win->_y[i]);
481 }
482
483 new->_flags = win->_flags;
484 new->_attrs = win->_attrs;
485 new->_clear = win->_clear;
486 new->_leaveit = win->_leaveit;
487 new->_scroll = win->_scroll;
488 new->_nodelay = win->_nodelay;
489 new->_use_keypad = win->_use_keypad;
490 new->_tmarg = (win->_tmarg > new->_maxy - 1) ? 0 : win->_tmarg;
491 new->_bmarg = (win->_bmarg == win->_maxy - 1) ?
492 new->_maxy - 1 : min(win->_bmarg, (new->_maxy - 1));
493 new->_parent = win->_parent;
494 new->_immed = win->_immed;
495 new->_sync = win->_sync;
496 new->_bkgd = win->_bkgd;
497
498 new->_curx = save_curx;
499 new->_cury = save_cury;
500
501 free(win->_firstch);
502 free(win->_lastch);
503 free(win->_y);
504
505 *win = *new;
506 free(new);
507
508 return win;
509 }
510
511 int wresize(WINDOW *win, int nlines, int ncols)
512 {
513 return (resize_window(win, nlines, ncols) ? OK : ERR);
514 }
515
516 void wsyncup(WINDOW *win)
517 {
518 WINDOW *tmp;
519
520 PDC_LOG(("wsyncup() - called\n"));
521
522 for (tmp = win; tmp; tmp = tmp->_parent)
523 touchwin(tmp);
524 }
525
526 int syncok(WINDOW *win, bool bf)
527 {
528 PDC_LOG(("syncok() - called\n"));
529
530 if (!win)
531 return ERR;
532
533 win->_sync = bf;
534
535 return OK;
536 }
537
538 void wcursyncup(WINDOW *win)
539 {
540 WINDOW *tmp;
541
542 PDC_LOG(("wcursyncup() - called\n"));
543
544 for (tmp = win; tmp && tmp->_parent; tmp = tmp->_parent)
545 wmove(tmp->_parent, tmp->_pary + tmp->_cury, tmp->_parx + tmp->_curx);
546 }
547
548 void wsyncdown(WINDOW *win)
549 {
550 WINDOW *tmp;
551
552 PDC_LOG(("wsyncdown() - called\n"));
553
554 for (tmp = win; tmp; tmp = tmp->_parent)
555 {
556 if (is_wintouched(tmp))
557 {
558 touchwin(win);
559 break;
560 }
561 }
562 }
File sdl1/Makefile added (mode: 100644) (index 00000000..a8393f0b)
1 # Makefile for PDCurses library for SDL
2
3 O = o
4
5 ifndef PDCURSES_SRCDIR
6 PDCURSES_SRCDIR = ..
7 endif
8
9 include $(PDCURSES_SRCDIR)/libobjs.mif
10
11 osdir = $(PDCURSES_SRCDIR)/sdl1
12
13 PDCURSES_SDL_H = $(osdir)/pdcsdl.h
14
15 SFLAGS = $(shell sdl-config --cflags)
16 SLIBS = $(shell sdl-config --libs)
17
18 # If your system doesn't have these, remove the defines here
19 SFLAGS += -DHAVE_VSNPRINTF -DHAVE_VSSCANF
20
21 ifeq ($(DEBUG),Y)
22 CFLAGS = -g -Wall -DPDCDEBUG
23 else
24 CFLAGS = -O2 -Wall
25 endif
26
27 BUILD = $(CC) $(CFLAGS) -I$(PDCURSES_SRCDIR)
28
29 ifeq ($(shell uname),Darwin)
30 DEMOFLAGS = -Dmain=SDL_main
31 endif
32
33 LINK = $(CC)
34 LDFLAGS = $(LIBCURSES) $(SLIBS)
35 RANLIB = ranlib
36 LIBCURSES = libpdcurses.a
37
38 DEMOS = firework newdemo ptest rain testcurs tuidemo worm xmas \
39 sdltest
40
41 .PHONY: all libs clean demos
42
43 all: libs demos
44
45 libs: $(LIBCURSES)
46
47 clean:
48 -rm -rf *.o trace $(LIBCURSES) $(DEMOS)
49
50 demos: $(DEMOS)
51 strip $(DEMOS)
52
53 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
54 ar rv $@ $?
55 -$(RANLIB) $@
56
57 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
58 $(PDCOBJS) : $(PDCURSES_SDL_H)
59 $(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
60 tui.o tuidemo.o : $(PDCURSES_CURSES_H)
61 terminfo.o: $(TERM_HEADER)
62 panel.o ptest: $(PANEL_HEADER)
63
64 $(LIBOBJS) : %.o: $(srcdir)/%.c
65 $(BUILD) $(SFLAGS) -c $<
66
67 $(PDCOBJS) : %.o: $(osdir)/%.c
68 $(BUILD) $(SFLAGS) -c $<
69
70 firework: $(demodir)/firework.c
71 $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
72
73 newdemo: $(demodir)/newdemo.c
74 $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
75
76 ptest: $(demodir)/ptest.c
77 $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
78
79 rain: $(demodir)/rain.c
80 $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
81
82 testcurs: $(demodir)/testcurs.c
83 $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
84
85 tuidemo: tuidemo.o tui.o
86 $(LINK) tui.o tuidemo.o -o $@ $(LDFLAGS)
87
88 worm: $(demodir)/worm.c
89 $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
90
91 xmas: $(demodir)/xmas.c
92 $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
93
94 sdltest: $(osdir)/sdltest.c
95 $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
96
97 tui.o: $(demodir)/tui.c $(demodir)/tui.h
98 $(BUILD) -c $(DEMOFLAGS) $(demodir)/tui.c
99
100 tuidemo.o: $(demodir)/tuidemo.c
101 $(BUILD) -c $(DEMOFLAGS) $(demodir)/tuidemo.c
File sdl1/Makefile.mng added (mode: 100644) (index 00000000..427edc67)
1 # Makefile for PDCurses library for SDL
2
3 O = o
4
5 ifndef PDCURSES_SRCDIR
6 PDCURSES_SRCDIR = ..
7 endif
8
9 include $(PDCURSES_SRCDIR)/libobjs.mif
10
11 osdir = $(PDCURSES_SRCDIR)/sdl1
12
13 PDCURSES_SDL_H = $(osdir)/pdcsdl.h
14
15 ifeq ($(DEBUG),Y)
16 CFLAGS = -g -Wall -DPDCDEBUG
17 else
18 CFLAGS = -O2 -Wall
19 endif
20
21 CC = gcc
22 BUILD = $(CC) $(CFLAGS) -I$(PDCURSES_SRCDIR)
23 LDFLAGS = -mwindows $(LIBCURSES)
24
25 BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
26
27 DEFDEPS = $(BASEDEF)
28
29 DEFFILE = pdcurses.def
30
31 ifeq ($(DLL),Y)
32 BUILD += -DPDC_DLL_BUILD
33 LIBEXE = gcc $(DEFFILE)
34 LIBFLAGS = -Wl,--out-implib,libpdcurses.a -shared -o
35 LIBCURSES = pdcurses.dll
36 CLEAN = $(LIBCURSES) *.a $(DEFFILE)
37 POST = -lSDL
38 else
39 LIBEXE = ar
40 LIBFLAGS = rcv
41 LIBCURSES = libpdcurses.a
42 CLEAN = *.a
43 LDFLAGS += -lSDL
44 endif
45
46 DEMOS += sdltest.exe
47
48 .PHONY: all libs clean demos
49
50 all: libs demos
51
52 libs: $(LIBCURSES)
53
54 clean:
55 -del *.o $(CLEAN) *.exe
56
57 demos: $(DEMOS)
58 strip *.exe
59
60 pdcurses.dll: $(DEFFILE)
61
62 $(DEFFILE): $(DEFDEPS)
63 echo LIBRARY pdcurses > $@
64 echo EXPORTS >> $@
65 type $(BASEDEF) >> $@
66 echo pdc_screen >> $@
67 echo pdc_font >> $@
68 echo pdc_icon >> $@
69 echo pdc_back >> $@
70 echo pdc_sheight >> $@
71 echo pdc_swidth >> $@
72 echo pdc_yoffset >> $@
73 echo pdc_xoffset >> $@
74
75 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
76 $(LIBEXE) $(LIBFLAGS) $@ $? $(POST)
77
78 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
79 $(PDCOBJS) : $(PDCURSES_SDL_H)
80 $(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
81 tui.o tuidemo.o : $(PDCURSES_CURSES_H)
82 terminfo.o: $(TERM_HEADER)
83 panel.o ptest.exe: $(PANEL_HEADER)
84
85 $(LIBOBJS) : %.o: $(srcdir)/%.c
86 $(BUILD) -c $<
87
88 $(PDCOBJS) : %.o: $(osdir)/%.c
89 $(BUILD) -c $<
90
91 firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
92 ptest.exe: %.exe: $(demodir)/%.c
93 $(BUILD) -o $@ $< $(LDFLAGS)
94
95 tuidemo.exe: tuidemo.o tui.o
96 $(CC) -o $@ tuidemo.o tui.o $(LDFLAGS)
97
98 tui.o: $(demodir)/tui.c $(demodir)/tui.h
99 $(BUILD) -c $<
100
101 tuidemo.o: $(demodir)/tuidemo.c $(demodir)/tui.h
102 $(BUILD) -c $<
103
104 sdltest.exe: $(osdir)/sdltest.c
105 $(BUILD) -o $@ $< -mwindows $(LIBCURSES) -lmingw32 -lSDLmain -lSDL
File sdl1/README added (mode: 100644) (index 00000000..35234d39)
1 PDCurses for SDL
2 ================
3
4 This is a port of PDCurses for SDL.
5
6
7 Building
8 --------
9
10 . On *nix (including Linux and Mac OS X), run "make" in the sdl1
11 directory. There is no configure script (yet?) for this port. This
12 assumes a working sdl-config, and GNU make. It builds the library
13 libpdcurses.a (dynamic lib not implemented).
14
15 With MinGW, run "make -f Makefile.mng". This assumes SDL is installed
16 in the standard directories. The MinGW makefile accepts the optional
17 parameters "DLL=Y" and "DEBUG=Y", as with the console version. (Wide-
18 character support is not yet implemented for SDL.) Both makefiles
19 recognize the optional PDCURSES_SRCDIR environment variable, as with
20 the console ports. Makefile.mng builds libpdcurses.a, along with
21 pdcurses.dll, if specified.
22
23
24 Distribution Status
25 -------------------
26
27 The files in this directory are released to the Public Domain.
28
29
30 Acknowledgements
31 ----------------
32
33 SDL port was provided by William McBrine <wmcbrine@users.sf.net>
File sdl1/deffont.h added (mode: 100644) (index 00000000..cf9cab19)
1 /* Default font -- this is simply a 256x128x1 BMP, in #include'able form.
2 The font is 8x16, code page 437, and is based on the pc8x16s.bdf font
3 from the vgafonts.tar.gz package, by "Myrlin". */
4
5 unsigned char deffont[] =
6 {
7 0x42, 0x4d, 0x3e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
8 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
9 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10 0x00, 0x00, 0x10, 0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x12, 0x0b,
11 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
12 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
13 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
15 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
17 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00,
19 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x60,
22 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23 0x00, 0x00, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x76, 0xf8, 0xc0, 0x6c, 0xfe, 0x70, 0x7c, 0x18,
25 0x7e, 0x38, 0xee, 0x3c, 0x00, 0xc0, 0x1c, 0xc6, 0x00, 0x7e, 0x7e,
26 0x7e, 0x18, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00,
27 0x00, 0x00, 0xdc, 0xcc, 0xc0, 0x6c, 0xc6, 0xd8, 0x66, 0x18, 0x18,
28 0x6c, 0x6c, 0x66, 0x00, 0x60, 0x30, 0xc6, 0xfe, 0x00, 0x00, 0x00,
29 0x18, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x7e,
30 0x00, 0xd8, 0xcc, 0xc0, 0x6c, 0x60, 0xd8, 0x66, 0x18, 0x3c, 0xc6,
31 0x6c, 0x66, 0x7e, 0x7e, 0x60, 0xc6, 0x00, 0x00, 0x30, 0x0c, 0x18,
32 0xd8, 0x18, 0xdc, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x7e, 0x00,
33 0xd8, 0xcc, 0xc0, 0x6c, 0x30, 0xd8, 0x66, 0x18, 0x66, 0xc6, 0x6c,
34 0x66, 0xdb, 0xf3, 0x60, 0xc6, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18,
35 0x00, 0x76, 0x00, 0x18, 0x00, 0x6c, 0x00, 0x00, 0x7e, 0x00, 0xd8,
36 0xc8, 0xc0, 0x6c, 0x18, 0xd8, 0x66, 0x18, 0x66, 0xc6, 0x6c, 0x66,
37 0xdb, 0xdb, 0x60, 0xc6, 0xfe, 0x18, 0x0c, 0x30, 0x18, 0x18, 0x7e,
38 0x00, 0x00, 0x18, 0x18, 0xec, 0x00, 0x00, 0x7e, 0x00, 0xdc, 0xdc,
39 0xc0, 0x6c, 0x18, 0xd8, 0x66, 0x18, 0x66, 0xfe, 0xc6, 0x3e, 0xdb,
40 0xdb, 0x7c, 0xc6, 0x00, 0x7e, 0x06, 0x60, 0x18, 0x18, 0x00, 0xdc,
41 0x00, 0x00, 0x00, 0x0c, 0x36, 0x7e, 0x7e, 0x00, 0x76, 0xce, 0xc0,
42 0xfe, 0x30, 0x7e, 0x66, 0xdc, 0x66, 0xc6, 0xc6, 0x0c, 0x7e, 0x7e,
43 0x60, 0xc6, 0x00, 0x18, 0x0c, 0x30, 0x18, 0x18, 0x18, 0x76, 0x00,
44 0x00, 0x00, 0x0c, 0x36, 0x32, 0x7e, 0x00, 0x00, 0xc6, 0xc6, 0x00,
45 0x60, 0x00, 0x00, 0x76, 0x3c, 0xc6, 0xc6, 0x18, 0x00, 0x06, 0x60,
46 0xc6, 0xfe, 0x18, 0x18, 0x18, 0x1b, 0x18, 0x00, 0x00, 0x38, 0x00,
47 0x00, 0x0c, 0x36, 0x18, 0x7e, 0x00, 0x00, 0xce, 0xc6, 0x00, 0xc6,
48 0x00, 0x00, 0x00, 0x18, 0x6c, 0x6c, 0x30, 0x00, 0x03, 0x30, 0x7c,
49 0x00, 0x00, 0x30, 0x0c, 0x1b, 0x18, 0x00, 0x00, 0x6c, 0x00, 0x00,
50 0x0c, 0x36, 0x0c, 0x00, 0x00, 0x00, 0x7c, 0xfe, 0x00, 0xfe, 0x00,
51 0x00, 0x00, 0x7e, 0x38, 0x38, 0x1e, 0x00, 0x00, 0x1c, 0x00, 0x00,
52 0x00, 0x00, 0x00, 0x0e, 0x18, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x0c,
53 0x36, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0f, 0x6c,
56 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00,
60 0x36, 0x00, 0x36, 0x36, 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00,
61 0x00, 0x18, 0x36, 0x36, 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f,
62 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36,
63 0x00, 0x36, 0x36, 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00,
64 0x18, 0x36, 0x36, 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00,
65 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00,
66 0x36, 0x36, 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18,
67 0x36, 0x36, 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00,
68 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36,
69 0x36, 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36,
70 0x36, 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00, 0x00,
71 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36, 0x36,
72 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36, 0x36,
73 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x18,
74 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36, 0x36, 0x00,
75 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36, 0x36, 0x18,
76 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x18, 0x18,
77 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36, 0x36, 0x00, 0x36,
78 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36, 0x36, 0x18, 0x00,
79 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
80 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36, 0x36, 0x00, 0x36, 0x00,
81 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36, 0x36, 0x18, 0x00, 0x18,
82 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x1f, 0xff, 0xff, 0x1f, 0xff, 0xff,
83 0x1f, 0x37, 0x3f, 0x37, 0xff, 0xf7, 0x37, 0xff, 0xf7, 0xff, 0xff,
84 0xff, 0xff, 0x3f, 0x1f, 0x1f, 0x3f, 0xff, 0xff, 0xf8, 0x1f, 0xff,
85 0xff, 0xf0, 0x0f, 0x00, 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x18,
86 0x36, 0x30, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x36, 0x00,
87 0x00, 0x36, 0x18, 0x18, 0x00, 0x36, 0x18, 0x18, 0x00, 0xff, 0x00,
88 0xf0, 0x0f, 0xff, 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x1f, 0x36,
89 0x37, 0x3f, 0xf7, 0xff, 0x37, 0xff, 0xf7, 0xff, 0x36, 0xff, 0x00,
90 0x36, 0x1f, 0x1f, 0x00, 0x36, 0xff, 0x18, 0x00, 0xff, 0x00, 0xf0,
91 0x0f, 0xff, 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36,
92 0x00, 0x36, 0x00, 0x36, 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36,
93 0x18, 0x00, 0x00, 0x36, 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f,
94 0xff, 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36, 0x00,
95 0x36, 0x00, 0x36, 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36, 0x18,
96 0x00, 0x00, 0x36, 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f, 0xff,
97 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36, 0x00, 0x36,
98 0x00, 0x36, 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36, 0x18, 0x00,
99 0x00, 0x36, 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f, 0xff, 0x18,
100 0x18, 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36, 0x00, 0x36, 0x00,
101 0x36, 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36, 0x18, 0x00, 0x00,
102 0x36, 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f, 0xff, 0x18, 0x18,
103 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36, 0x00, 0x36, 0x00, 0x36,
104 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36, 0x18, 0x00, 0x00, 0x36,
105 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f, 0xff, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x44, 0xaa, 0x77, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18,
108 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110 0x00, 0x11, 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36,
111 0x36, 0x36, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x06, 0x00, 0x00, 0x00,
113 0x44, 0xaa, 0x77, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36,
114 0x36, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
115 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x06, 0x00, 0x00, 0x00, 0x11,
116 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36,
117 0x00, 0x00, 0x00, 0x18, 0x76, 0x18, 0x7c, 0x78, 0x66, 0xc6, 0x00,
118 0x00, 0x7c, 0x00, 0x00, 0x0c, 0x3f, 0x18, 0x00, 0x00, 0x44, 0xaa,
119 0x77, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36, 0x00,
120 0x00, 0x00, 0x18, 0xcc, 0x18, 0xc6, 0xcc, 0x66, 0xc6, 0x00, 0x00,
121 0xc6, 0xc0, 0x06, 0x86, 0x9a, 0x3c, 0x00, 0x00, 0x11, 0x55, 0xdd,
122 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36, 0x00, 0x00,
123 0x00, 0x18, 0xcc, 0x18, 0xc6, 0xcc, 0x66, 0xc6, 0x00, 0x00, 0xc6,
124 0xc0, 0x06, 0xdc, 0xce, 0x3c, 0x36, 0xd8, 0x44, 0xaa, 0x77, 0x18,
125 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00,
126 0x18, 0xcc, 0x18, 0xc6, 0xcc, 0x66, 0xce, 0x00, 0x00, 0xc0, 0xc0,
127 0x06, 0x60, 0x66, 0x3c, 0x6c, 0x6c, 0x11, 0x55, 0xdd, 0x18, 0x18,
128 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x18,
129 0x7c, 0x18, 0xc6, 0xcc, 0x66, 0xde, 0x7e, 0x7c, 0x60, 0xc0, 0x06,
130 0x30, 0x30, 0x18, 0xd8, 0x36, 0x44, 0xaa, 0x77, 0x18, 0xf8, 0xf8,
131 0xf6, 0xfe, 0xf8, 0xf6, 0x36, 0xf6, 0xfe, 0xfe, 0xf8, 0xf8, 0x0c,
132 0x18, 0xc6, 0xcc, 0x66, 0xfe, 0x00, 0x00, 0x30, 0xfe, 0xfe, 0x18,
133 0x18, 0x18, 0x6c, 0x6c, 0x11, 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36,
134 0x00, 0x18, 0x06, 0x36, 0x06, 0x06, 0x36, 0x18, 0x00, 0x78, 0x38,
135 0x7c, 0xcc, 0x5c, 0xf6, 0x3e, 0x38, 0x30, 0x00, 0x00, 0x6c, 0x6c,
136 0x18, 0x36, 0xd8, 0x44, 0xaa, 0x77, 0x18, 0x18, 0xf8, 0x36, 0x00,
137 0xf8, 0xf6, 0x36, 0xfe, 0xf6, 0x36, 0xf8, 0x00, 0x00, 0x00, 0x00,
138 0x00, 0x00, 0xe6, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00,
139 0x00, 0x00, 0x11, 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00,
140 0x36, 0x36, 0x00, 0x36, 0x36, 0x18, 0x00, 0x60, 0x30, 0x60, 0x60,
141 0xdc, 0xc6, 0x6c, 0x6c, 0x30, 0x00, 0x00, 0x62, 0x62, 0x18, 0x00,
142 0x00, 0x44, 0xaa, 0x77, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00, 0x36,
143 0x36, 0x00, 0x36, 0x36, 0x18, 0x00, 0x30, 0x18, 0x30, 0x30, 0x76,
144 0x00, 0x3c, 0x38, 0x30, 0x00, 0x00, 0xe0, 0xe0, 0x18, 0x00, 0x00,
145 0x11, 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00, 0x36, 0x36,
146 0x00, 0x36, 0x36, 0x18, 0x00, 0x18, 0x0c, 0x18, 0x18, 0x00, 0xdc,
147 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x44,
148 0xaa, 0x77, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00, 0x36, 0x36, 0x00,
149 0x36, 0x36, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00,
150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x55,
151 0xdd, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00, 0x36, 0x36, 0x00, 0x36,
152 0x36, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
158 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00,
159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
160 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
161 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
162 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
163 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
164 0x78, 0x7c, 0x76, 0x76, 0x76, 0x76, 0x7c, 0x7c, 0x7c, 0x7c, 0x18,
165 0x18, 0x18, 0xc6, 0xc6, 0xfc, 0x6e, 0xce, 0x7c, 0x7c, 0x7c, 0x78,
166 0x78, 0x76, 0x7c, 0x7c, 0x18, 0xfe, 0x18, 0xc6, 0x70, 0x3c, 0xcc,
167 0xc2, 0xcc, 0xcc, 0xcc, 0xcc, 0xc6, 0xc2, 0xc2, 0xc2, 0x18, 0x18,
168 0x18, 0xc6, 0xc6, 0xc0, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc,
169 0xce, 0xc6, 0xc6, 0x18, 0x60, 0x7e, 0xcc, 0xd8, 0x66, 0xcc, 0xc0,
170 0xcc, 0xcc, 0xcc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x18, 0x18, 0x18,
171 0xc6, 0xc6, 0xc0, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc, 0xc6,
172 0xc6, 0xc6, 0x7c, 0x60, 0x18, 0xcc, 0x18, 0xc6, 0xcc, 0xc0, 0xcc,
173 0xcc, 0xcc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x18, 0x18, 0x18, 0xfe,
174 0xc6, 0xc0, 0x7e, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc, 0xc6, 0xc6,
175 0xc6, 0xc6, 0x60, 0x7e, 0xcc, 0x18, 0xc0, 0xcc, 0xfe, 0x7c, 0x7c,
176 0x7c, 0x7c, 0xc0, 0xfe, 0xfe, 0xfe, 0x18, 0x18, 0x18, 0xc6, 0xfe,
177 0xf0, 0x36, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc, 0xc6, 0xc6, 0xc6,
178 0xc0, 0x60, 0x18, 0xde, 0x18, 0xc0, 0xcc, 0xc6, 0x0c, 0x0c, 0x0c,
179 0x0c, 0xc6, 0xc6, 0xc6, 0xc6, 0x18, 0x18, 0x18, 0xc6, 0xc6, 0xc0,
180 0x36, 0xfe, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc, 0xc6, 0xc6, 0xc6, 0xc0,
181 0xf8, 0x3c, 0xcc, 0x7e, 0xc0, 0xcc, 0x7c, 0x78, 0x78, 0x78, 0x78,
182 0x7c, 0x7c, 0x7c, 0x7c, 0x38, 0x38, 0x38, 0x6c, 0x6c, 0xc0, 0xec,
183 0xcc, 0x7c, 0x7c, 0x7c, 0xcc, 0xcc, 0xc6, 0xc6, 0xc6, 0xc0, 0x60,
184 0x66, 0xc4, 0x18, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0xc0, 0x00, 0xcc,
186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x60, 0x66,
187 0xf8, 0x18, 0x3c, 0xcc, 0x30, 0x6c, 0x00, 0x18, 0x38, 0x00, 0x6c,
188 0x00, 0x18, 0x00, 0x66, 0x18, 0x10, 0x10, 0xfc, 0x00, 0x6c, 0x6c,
189 0x00, 0x18, 0xcc, 0x18, 0x00, 0x7c, 0xc6, 0x7c, 0x62, 0x66, 0xcc,
190 0x18, 0x00, 0xcc, 0x18, 0x38, 0xcc, 0x30, 0x6c, 0x00, 0x38, 0xc6,
191 0x30, 0x66, 0x3c, 0x30, 0x00, 0x38, 0x00, 0x00, 0x3e, 0x38, 0xc6,
192 0x30, 0x78, 0x30, 0xc6, 0x00, 0x00, 0x18, 0x3c, 0x66, 0xcc, 0x1b,
193 0x00, 0x00, 0x0c, 0x10, 0x00, 0x60, 0x38, 0x00, 0x10, 0x00, 0x60,
194 0x00, 0x18, 0x60, 0xc6, 0x6c, 0x30, 0x00, 0x00, 0x10, 0x00, 0x60,
195 0x30, 0x60, 0x00, 0xc6, 0xc6, 0x18, 0x00, 0x00, 0xf8, 0x0e, 0x00,
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x00, 0x00, 0x00, 0x38, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
203 0x00, 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00,
206 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x0c, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0xc0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xf8, 0x78, 0x7c, 0x7c,
211 0x30, 0x7c, 0xcc, 0x18, 0x0c, 0xcc, 0x18, 0xc6, 0xcc, 0x78, 0xf8,
212 0x7c, 0xc0, 0x7c, 0x30, 0x78, 0x10, 0x6c, 0xc6, 0x76, 0xfe, 0x0e,
213 0x18, 0x70, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xc4, 0xcc, 0xc2, 0x30,
214 0xcc, 0xcc, 0x18, 0x0c, 0xcc, 0x18, 0xd6, 0xcc, 0xcc, 0xcc, 0xcc,
215 0xc0, 0x86, 0x30, 0xcc, 0x6c, 0xfe, 0x6c, 0xce, 0xc0, 0x18, 0x18,
216 0x18, 0x00, 0xfe, 0x00, 0xcc, 0xcc, 0xc0, 0xcc, 0xc0, 0x30, 0xcc,
217 0xcc, 0x18, 0x0c, 0xd8, 0x18, 0xd6, 0xcc, 0xcc, 0xcc, 0xcc, 0xc0,
218 0x06, 0x30, 0xcc, 0xc6, 0xd6, 0x38, 0xc6, 0x60, 0x18, 0x18, 0x18,
219 0x00, 0xc6, 0x00, 0xcc, 0xcc, 0xc0, 0xcc, 0xc0, 0x30, 0xcc, 0xcc,
220 0x18, 0x0c, 0xf0, 0x18, 0xd6, 0xcc, 0xcc, 0xcc, 0xcc, 0xc0, 0x1c,
221 0x30, 0xcc, 0xc6, 0xd6, 0x38, 0xc6, 0x30, 0x18, 0x18, 0x18, 0x00,
222 0xc6, 0x00, 0x7c, 0xcc, 0xc0, 0xcc, 0xfe, 0x30, 0xcc, 0xcc, 0x18,
223 0x0c, 0xf0, 0x18, 0xd6, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x70, 0x30,
224 0xcc, 0xc6, 0xd6, 0x38, 0xc6, 0x18, 0x18, 0x18, 0x18, 0x00, 0xc6,
225 0x00, 0x0c, 0xcc, 0xc4, 0xcc, 0xc6, 0x78, 0xcc, 0xec, 0x18, 0x0c,
226 0xd8, 0x18, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xec, 0xc2, 0x30, 0xcc,
227 0xc6, 0xc6, 0x6c, 0xc6, 0x0c, 0x70, 0x18, 0x0e, 0x00, 0x6c, 0x00,
228 0x78, 0xf8, 0x78, 0x7c, 0x7c, 0x30, 0x7c, 0xd8, 0x38, 0x0c, 0xcc,
229 0x18, 0xec, 0xb8, 0x78, 0xf8, 0x7c, 0xb8, 0x7c, 0xfc, 0xcc, 0xc6,
230 0xc6, 0xc6, 0xc6, 0xfe, 0x18, 0x18, 0x18, 0x00, 0x38, 0x00, 0x00,
231 0xc0, 0x00, 0x0c, 0x00, 0x32, 0x00, 0xc0, 0x00, 0x00, 0xc0, 0x18,
232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
233 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x10, 0x0c, 0x00, 0xc0,
234 0x00, 0x0c, 0x00, 0x36, 0x00, 0xc0, 0x18, 0x0c, 0xc0, 0x18, 0x00,
235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
236 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00, 0xc0, 0x00,
237 0x0c, 0x00, 0x1c, 0x00, 0xc0, 0x18, 0x0c, 0xc0, 0x38, 0x00, 0x00,
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
239 0x00, 0x0e, 0x18, 0x70, 0xdc, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
242 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
253 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
254 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
255 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257 0x7c, 0xc6, 0xfc, 0x3c, 0xf8, 0xfc, 0xc0, 0x3e, 0xc6, 0x18, 0x78,
258 0xc2, 0xfc, 0xc6, 0xc6, 0x7c, 0xc0, 0x7c, 0xc6, 0x7c, 0x18, 0x7c,
259 0x10, 0x6c, 0xc6, 0x18, 0xfe, 0x3c, 0x02, 0x3c, 0x00, 0x00, 0xc0,
260 0xc6, 0xc6, 0x66, 0xdc, 0xc0, 0xc0, 0x66, 0xc6, 0x18, 0xcc, 0xc6,
261 0xc0, 0xc6, 0xc6, 0xc6, 0xc0, 0xde, 0xc6, 0x86, 0x18, 0xc6, 0x38,
262 0xee, 0xc6, 0x18, 0xc0, 0x30, 0x06, 0x0c, 0x00, 0x00, 0xdc, 0xc6,
263 0xc6, 0xc2, 0xce, 0xc0, 0xc0, 0xc6, 0xc6, 0x18, 0xcc, 0xcc, 0xc0,
264 0xc6, 0xc6, 0xc6, 0xc0, 0xd6, 0xcc, 0x06, 0x18, 0xc6, 0x6c, 0xfe,
265 0x6c, 0x18, 0xc0, 0x30, 0x0e, 0x0c, 0x00, 0x00, 0xde, 0xc6, 0xc6,
266 0xc0, 0xc6, 0xc0, 0xc0, 0xc6, 0xc6, 0x18, 0xcc, 0xd8, 0xc0, 0xc6,
267 0xc6, 0xc6, 0xc0, 0xc6, 0xcc, 0x06, 0x18, 0xc6, 0xc6, 0xd6, 0x7c,
268 0x18, 0x60, 0x30, 0x1c, 0x0c, 0x00, 0x00, 0xde, 0xfe, 0xc6, 0xc0,
269 0xc6, 0xc0, 0xc0, 0xde, 0xc6, 0x18, 0x0c, 0xf0, 0xc0, 0xc6, 0xce,
270 0xc6, 0xc0, 0xc6, 0xd8, 0x0c, 0x18, 0xc6, 0xc6, 0xd6, 0x38, 0x18,
271 0x30, 0x30, 0x38, 0x0c, 0x00, 0x00, 0xde, 0xc6, 0xfc, 0xc0, 0xc6,
272 0xf8, 0xf8, 0xc0, 0xfe, 0x18, 0x0c, 0xf0, 0xc0, 0xd6, 0xde, 0xc6,
273 0xfc, 0xc6, 0xfc, 0x38, 0x18, 0xc6, 0xc6, 0xd6, 0x38, 0x3c, 0x18,
274 0x30, 0x70, 0x0c, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc0, 0xc6, 0xc0,
275 0xc0, 0xc0, 0xc6, 0x18, 0x0c, 0xd8, 0xc0, 0xfe, 0xfe, 0xc6, 0xc6,
276 0xc6, 0xc6, 0x60, 0x18, 0xc6, 0xc6, 0xc6, 0x7c, 0x66, 0x0c, 0x30,
277 0xe0, 0x0c, 0x00, 0x00, 0xc6, 0x6c, 0xc6, 0xc2, 0xce, 0xc0, 0xc0,
278 0xc0, 0xc6, 0x18, 0x0c, 0xcc, 0xc0, 0xfe, 0xf6, 0xc6, 0xc6, 0xc6,
279 0xc6, 0xc0, 0x18, 0xc6, 0xc6, 0xc6, 0x6c, 0x66, 0x06, 0x30, 0xc0,
280 0x0c, 0x00, 0x00, 0x7c, 0x38, 0xc6, 0x66, 0xdc, 0xc0, 0xc0, 0x62,
281 0xc6, 0x18, 0x0c, 0xc6, 0xc0, 0xee, 0xe6, 0xc6, 0xc6, 0xc6, 0xc6,
282 0xc2, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0x66, 0x06, 0x30, 0x80, 0x0c,
283 0xc6, 0x00, 0x00, 0x10, 0xfc, 0x3c, 0xf8, 0xfc, 0xfc, 0x3c, 0xc6,
284 0x18, 0x1e, 0xc2, 0xc0, 0xc6, 0xc6, 0x7c, 0xfc, 0x7c, 0xfc, 0x7c,
285 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0x66, 0xfe, 0x3c, 0x00, 0x3c, 0x6c,
286 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
288 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
291 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
298 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
300 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
301 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
302 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
303 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6c, 0x7c,
304 0x86, 0x76, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x18, 0x00, 0x18, 0x80,
305 0x38, 0x18, 0xfe, 0x7c, 0x0c, 0x7c, 0x7c, 0x30, 0x7c, 0x78, 0x00,
306 0x30, 0x06, 0x00, 0x60, 0x18, 0x00, 0x18, 0x00, 0x6c, 0xc6, 0xc6,
307 0xcc, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00, 0x18, 0xc0, 0x6c,
308 0x18, 0xc0, 0x86, 0x0c, 0x86, 0xc6, 0x30, 0xc6, 0x8c, 0x18, 0x18,
309 0x0c, 0x00, 0x30, 0x18, 0x00, 0x00, 0x00, 0xfe, 0x86, 0x60, 0xcc,
310 0x00, 0x30, 0x0c, 0x66, 0x18, 0x18, 0x00, 0x00, 0x60, 0xc6, 0x18,
311 0xc0, 0x06, 0x0c, 0x06, 0xc6, 0x30, 0xc6, 0x06, 0x18, 0x18, 0x18,
312 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x6c, 0x06, 0x30, 0xcc, 0x00,
313 0x30, 0x0c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x30, 0xe6, 0x18, 0x60,
314 0x06, 0x0c, 0x06, 0xc6, 0x30, 0xc6, 0x06, 0x00, 0x00, 0x30, 0x7e,
315 0x0c, 0x18, 0x00, 0x18, 0x00, 0x6c, 0x06, 0x18, 0xdc, 0x00, 0x30,
316 0x0c, 0xff, 0x7e, 0x00, 0xfe, 0x00, 0x18, 0xf6, 0x18, 0x30, 0x06,
317 0xfe, 0x06, 0xe6, 0x18, 0xc6, 0x06, 0x00, 0x00, 0x60, 0x00, 0x06,
318 0x18, 0x00, 0x18, 0x00, 0x6c, 0x7c, 0x0c, 0x76, 0x00, 0x30, 0x0c,
319 0x3c, 0x18, 0x00, 0x00, 0x00, 0x0c, 0xde, 0x18, 0x18, 0x3c, 0xcc,
320 0xfc, 0xdc, 0x0c, 0x7c, 0x7e, 0x00, 0x00, 0x30, 0x00, 0x0c, 0x18,
321 0x00, 0x3c, 0x00, 0xfe, 0xc0, 0xc6, 0x38, 0x00, 0x30, 0x0c, 0x66,
322 0x18, 0x00, 0x00, 0x00, 0x06, 0xce, 0x18, 0x0c, 0x06, 0x6c, 0xc0,
323 0xc0, 0x06, 0xc6, 0xc6, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x0c, 0x00,
324 0x3c, 0x24, 0x6c, 0xc2, 0xc2, 0x6c, 0x60, 0x30, 0x0c, 0x00, 0x00,
325 0x00, 0x00, 0x00, 0x02, 0xc6, 0x78, 0x06, 0x06, 0x3c, 0xc0, 0xc0,
326 0x06, 0xc6, 0xc6, 0x18, 0x18, 0x0c, 0x00, 0x30, 0xc6, 0x00, 0x3c,
327 0x66, 0x6c, 0xc6, 0x00, 0x6c, 0x30, 0x18, 0x18, 0x00, 0x00, 0x00,
328 0x00, 0x00, 0x00, 0x6c, 0x38, 0xc6, 0x86, 0x1c, 0xc0, 0x60, 0x06,
329 0xc6, 0xc6, 0x00, 0x00, 0x06, 0x00, 0x60, 0xc6, 0x00, 0x18, 0x66,
330 0x00, 0x7c, 0x00, 0x38, 0x30, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00,
331 0x00, 0x00, 0x38, 0x18, 0x7c, 0x7c, 0x0c, 0xfe, 0x3c, 0xfe, 0x7c,
332 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x66, 0x00,
333 0x18, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
334 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
335 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
336 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
339 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
341 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
342 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
343 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
344 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
345 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
346 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
347 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
348 0x00, 0xff, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
349 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
350 0x00, 0x00, 0x7e, 0x7e, 0x10, 0x00, 0x3c, 0x3c, 0x00, 0xff, 0x00,
351 0xff, 0x78, 0x18, 0xe0, 0xe6, 0x18, 0x80, 0x02, 0x00, 0x66, 0x1b,
352 0xc6, 0xfe, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
353 0x00, 0x81, 0xff, 0x38, 0x10, 0x18, 0x18, 0x00, 0xff, 0x3c, 0xc3,
354 0xcc, 0x18, 0xf0, 0xe7, 0x18, 0xc0, 0x06, 0x18, 0x66, 0x1b, 0x0c,
355 0xfe, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x10, 0x00,
356 0x81, 0xff, 0x7c, 0x38, 0x18, 0x18, 0x18, 0xe7, 0x66, 0x99, 0xcc,
357 0x7e, 0x70, 0x67, 0xdb, 0xe0, 0x0e, 0x3c, 0x00, 0x1b, 0x38, 0xfe,
358 0x3c, 0x18, 0x7e, 0x18, 0x30, 0xfe, 0x28, 0xfe, 0x38, 0x00, 0x99,
359 0xe7, 0xfe, 0x7c, 0xe7, 0x7e, 0x3c, 0xc3, 0x42, 0xbd, 0xcc, 0x18,
360 0x30, 0x63, 0x3c, 0xf0, 0x1e, 0x7e, 0x66, 0x1b, 0x6c, 0xfe, 0x7e,
361 0x18, 0x18, 0x0c, 0x60, 0xc0, 0x6c, 0x7c, 0x38, 0x00, 0xbd, 0xc3,
362 0xfe, 0xfe, 0xe7, 0xff, 0x3c, 0xc3, 0x42, 0xbd, 0xcc, 0x3c, 0x30,
363 0x63, 0xe7, 0xf8, 0x3e, 0x18, 0x66, 0x1b, 0xc6, 0x00, 0x18, 0x18,
364 0x18, 0xfe, 0xfe, 0xc0, 0xfe, 0x7c, 0x7c, 0x00, 0x81, 0xff, 0xfe,
365 0x7c, 0xe7, 0xff, 0x18, 0xe7, 0x66, 0x99, 0x78, 0x66, 0x30, 0x63,
366 0x3c, 0xfe, 0xfe, 0x18, 0x66, 0x7b, 0xc6, 0x00, 0x18, 0x18, 0x18,
367 0x0c, 0x60, 0xc0, 0x6c, 0x38, 0x7c, 0x00, 0x81, 0xff, 0xfe, 0x38,
368 0x3c, 0x7e, 0x00, 0xff, 0x3c, 0xc3, 0x32, 0x66, 0x30, 0x63, 0xdb,
369 0xf8, 0x3e, 0x18, 0x66, 0xdb, 0x6c, 0x00, 0x18, 0x18, 0x18, 0x18,
370 0x30, 0x00, 0x28, 0x38, 0xfe, 0x00, 0xa5, 0xdb, 0x6c, 0x10, 0x3c,
371 0x3c, 0x00, 0xff, 0x00, 0xff, 0x1a, 0x66, 0x3f, 0x7f, 0x18, 0xf0,
372 0x1e, 0x7e, 0x66, 0xdb, 0x38, 0x00, 0x7e, 0x7e, 0x18, 0x00, 0x00,
373 0x00, 0x00, 0x10, 0xfe, 0x00, 0x81, 0xff, 0x00, 0x00, 0x18, 0x18,
374 0x00, 0xff, 0x00, 0xff, 0x0e, 0x66, 0x33, 0x63, 0x18, 0xe0, 0x0e,
375 0x3c, 0x66, 0xdb, 0x60, 0x00, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00,
376 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00,
377 0xff, 0x00, 0xff, 0x1e, 0x3c, 0x3f, 0x7f, 0x00, 0xc0, 0x06, 0x18,
378 0x66, 0x7f, 0xc6, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
380 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00,
381 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
382 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
383 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
384 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
385 };
File sdl1/deficon.h added (mode: 100644) (index 00000000..7248ab50)
1 /* The PDCurses logo as #include'able BMP (from ../x11/little_icon.xbm) */
2
3 unsigned char deficon[] =
4 {
5 0x42, 0x4d, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
6 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
7 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
8 0x00, 0x80, 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b,
9 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
10 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
11 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0x6f, 0x9c,
12 0xe7, 0xb5, 0xaf, 0x6b, 0x5b, 0xbd, 0xaf, 0xeb, 0xfb, 0xbd, 0xaf,
13 0x98, 0xe7, 0xbd, 0xaf, 0x7b, 0x5f, 0xb5, 0xa5, 0x6b, 0x5b, 0xcd,
14 0xab, 0x9c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
15 0xff, 0xcf, 0x03, 0xff, 0xff, 0xce, 0x03, 0xff, 0xff, 0xcc, 0x73,
16 0xff, 0xff, 0xcc, 0xf3, 0xff, 0xff, 0xcc, 0xf3, 0xff, 0xff, 0xcc,
17 0x73, 0xff, 0xff, 0xc6, 0x33, 0xff, 0xff, 0xc3, 0x13, 0xff, 0xff,
18 0xc1, 0x83, 0xff, 0xff, 0xc8, 0xc3, 0xff, 0xff, 0xcc, 0x63, 0xff,
19 0xff, 0xce, 0x33, 0xff, 0xff, 0xcf, 0x33, 0xff, 0xff, 0xcf, 0x33,
20 0xff, 0xff, 0xce, 0x33, 0xff, 0xff, 0xc0, 0x73, 0xff, 0xff, 0xc0,
21 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
22 0xff, 0xff, 0xff
23 };
File sdl1/pdcclip.c added (mode: 100644) (index 00000000..203c975d)
1 /* Public Domain Curses */
2
3 #include "pdcsdl.h"
4
5 RCSID("$Id: pdcclip.c,v 1.6 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <stdlib.h>
8
9 /*man-start**************************************************************
10
11 Name: clipboard
12
13 Synopsis:
14 int PDC_getclipboard(char **contents, long *length);
15 int PDC_setclipboard(const char *contents, long length);
16 int PDC_freeclipboard(char *contents);
17 int PDC_clearclipboard(void);
18
19 Description:
20 PDC_getclipboard() gets the textual contents of the system's
21 clipboard. This function returns the contents of the clipboard
22 in the contents argument. It is the responsibilitiy of the
23 caller to free the memory returned, via PDC_freeclipboard().
24 The length of the clipboard contents is returned in the length
25 argument.
26
27 PDC_setclipboard copies the supplied text into the system's
28 clipboard, emptying the clipboard prior to the copy.
29
30 PDC_clearclipboard() clears the internal clipboard.
31
32 Return Values:
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 X/Open BSD SYS V
41 PDC_getclipboard - - -
42 PDC_setclipboard - - -
43 PDC_freeclipboard - - -
44 PDC_clearclipboard - - -
45
46 **man-end****************************************************************/
47
48 /* global clipboard contents, should be NULL if none set */
49
50 static char *pdc_SDL_clipboard = NULL;
51
52 int PDC_getclipboard(char **contents, long *length)
53 {
54 int len;
55
56 PDC_LOG(("PDC_getclipboard() - called\n"));
57
58 if (!pdc_SDL_clipboard)
59 return PDC_CLIP_EMPTY;
60
61 len = strlen(pdc_SDL_clipboard);
62 if ((*contents = malloc(len + 1)) == NULL)
63 return PDC_CLIP_MEMORY_ERROR;
64
65 strcpy(*contents, pdc_SDL_clipboard);
66 *length = len;
67
68 return PDC_CLIP_SUCCESS;
69 }
70
71 int PDC_setclipboard(const char *contents, long length)
72 {
73 PDC_LOG(("PDC_setclipboard() - called\n"));
74
75 if (pdc_SDL_clipboard)
76 {
77 free(pdc_SDL_clipboard);
78 pdc_SDL_clipboard = NULL;
79 }
80
81 if (contents)
82 {
83 if ((pdc_SDL_clipboard = malloc(length + 1)) == NULL)
84 return PDC_CLIP_MEMORY_ERROR;
85
86 strcpy(pdc_SDL_clipboard, contents);
87 }
88
89 return PDC_CLIP_SUCCESS;
90 }
91
92 int PDC_freeclipboard(char *contents)
93 {
94 PDC_LOG(("PDC_freeclipboard() - called\n"));
95
96 /* should we also free empty the system clipboard? probably not */
97
98 if (contents)
99 {
100 /* NOTE: We free the memory, but we can not set caller's pointer
101 to NULL, so if caller calls again then will try to access
102 free'd memory. We 1st overwrite memory with a string so if
103 caller tries to use free memory they won't get what they
104 expect & hopefully notice. */
105
106 /* memset(contents, 0xFD, strlen(contents)); */
107
108 if (strlen(contents) >= strlen("PDCURSES"))
109 strcpy(contents, "PDCURSES");
110
111 free(contents);
112 }
113
114 return PDC_CLIP_SUCCESS;
115 }
116
117 int PDC_clearclipboard(void)
118 {
119 PDC_LOG(("PDC_clearclipboard() - called\n"));
120
121 if (pdc_SDL_clipboard)
122 {
123 free(pdc_SDL_clipboard);
124 pdc_SDL_clipboard = NULL;
125 }
126
127 return PDC_CLIP_SUCCESS;
128 }
File sdl1/pdcdisp.c added (mode: 100644) (index 00000000..3712e662)
1 /* Public Domain Curses */
2
3 #include "pdcsdl.h"
4
5 RCSID("$Id: pdcdisp.c,v 1.35 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <stdlib.h>
8 #include <string.h>
9
10 #ifdef CHTYPE_LONG
11
12 # define A(x) ((chtype)x | A_ALTCHARSET)
13
14 chtype acs_map[128] =
15 {
16 A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9),
17 A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
18 A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27),
19 A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
20 '\'', '(', ')', '*',
21
22 A(0x1a), A(0x1b), A(0x18), A(0x19),
23
24 '/',
25
26 0xdb,
27
28 '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
29 '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
30 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
31 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
32
33 A(0x04), 0xb1,
34
35 'b', 'c', 'd', 'e',
36
37 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
38 0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3,
39 0xf2, 0xe3, 0xd8, 0x9c, 0xf9,
40
41 A(127)
42 };
43
44 # undef A
45
46 #endif
47
48 Uint32 pdc_lastupdate = 0;
49
50 #define MAXRECT 200 /* maximum number of rects to queue up before
51 an update is forced; the number was chosen
52 arbitrarily */
53
54 static SDL_Rect uprect[MAXRECT]; /* table of rects to update */
55 static chtype oldch = (chtype)(-1); /* current attribute */
56 static int rectcount = 0; /* index into uprect */
57 static short foregr = -2, backgr = -2; /* current foreground, background */
58
59 /* do the real updates on a delay */
60
61 void PDC_update_rects(void)
62 {
63 if (rectcount)
64 {
65 /* if the maximum number of rects has been reached, we're
66 probably better off doing a full screen update */
67
68 if (rectcount == MAXRECT)
69 SDL_Flip(pdc_screen);
70 else
71 SDL_UpdateRects(pdc_screen, rectcount, uprect);
72
73 pdc_lastupdate = SDL_GetTicks();
74 rectcount = 0;
75 }
76 }
77
78 /* set the font colors to match the chtype's attribute */
79
80 static void _set_attr(chtype ch)
81 {
82 ch &= (A_COLOR|A_BOLD|A_BLINK|A_REVERSE);
83
84 if (oldch != ch)
85 {
86 short newfg, newbg;
87
88 if (SP->mono)
89 return;
90
91 PDC_pair_content(PAIR_NUMBER(ch), &newfg, &newbg);
92
93 newfg |= (ch & A_BOLD) ? 8 : 0;
94 newbg |= (ch & A_BLINK) ? 8 : 0;
95
96 if (ch & A_REVERSE)
97 {
98 short tmp = newfg;
99 newfg = newbg;
100 newbg = tmp;
101 }
102
103 if (newfg != foregr)
104 {
105 SDL_SetPalette(pdc_font, SDL_LOGPAL,
106 pdc_color + newfg, pdc_flastc, 1);
107 foregr = newfg;
108 }
109
110 if (newbg != backgr)
111 {
112 if (newbg == -1)
113 SDL_SetColorKey(pdc_font, SDL_SRCCOLORKEY, 0);
114 else
115 {
116 if (backgr == -1)
117 SDL_SetColorKey(pdc_font, 0, 0);
118
119 SDL_SetPalette(pdc_font, SDL_LOGPAL,
120 pdc_color + newbg, 0, 1);
121 }
122
123 backgr = newbg;
124 }
125
126 oldch = ch;
127 }
128 }
129
130 /* draw a cursor at (y, x) */
131
132 void PDC_gotoyx(int row, int col)
133 {
134 SDL_Rect src, dest;
135 chtype ch;
136 int oldrow, oldcol;
137
138 PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
139 row, col, SP->cursrow, SP->curscol));
140
141 if (SP->mono)
142 return;
143
144 oldrow = SP->cursrow;
145 oldcol = SP->curscol;
146
147 /* clear the old cursor */
148
149 PDC_transform_line(oldrow, oldcol, 1, curscr->_y[oldrow] + oldcol);
150
151 if (!SP->visibility)
152 return;
153
154 /* draw a new cursor by overprinting the existing character in
155 reverse, either the full cell (when visibility == 2) or the
156 lowest quarter of it (when visibility == 1) */
157
158 ch = curscr->_y[row][col] ^ A_REVERSE;
159
160 _set_attr(ch);
161
162 #ifdef CHTYPE_LONG
163 if (ch & A_ALTCHARSET && !(ch & 0xff80))
164 ch = acs_map[ch & 0x7f];
165 #endif
166 src.h = (SP->visibility == 1) ? pdc_fheight >> 2 : pdc_fheight;
167 src.w = pdc_fwidth;
168
169 dest.y = (row + 1) * pdc_fheight - src.h + pdc_yoffset;
170 dest.x = col * pdc_fwidth + pdc_xoffset;
171
172 src.x = (ch & 0xff) % 32 * pdc_fwidth;
173 src.y = (ch & 0xff) / 32 * pdc_fheight + (pdc_fheight - src.h);
174
175 SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
176
177 if (oldrow != row || oldcol != col)
178 {
179 if (rectcount == MAXRECT)
180 PDC_update_rects();
181
182 uprect[rectcount++] = dest;
183 }
184 }
185
186 /* handle the A_*LINE attributes */
187
188 static void _highlight(SDL_Rect *src, SDL_Rect *dest, chtype ch)
189 {
190 short col = SP->line_color;
191
192 if (SP->mono)
193 return;
194
195 if (ch & A_UNDERLINE)
196 {
197 if (col != -1)
198 SDL_SetPalette(pdc_font, SDL_LOGPAL,
199 pdc_color + col, pdc_flastc, 1);
200
201 src->x = '_' % 32 * pdc_fwidth;
202 src->y = '_' / 32 * pdc_fheight;
203
204 if (backgr != -1)
205 SDL_SetColorKey(pdc_font, SDL_SRCCOLORKEY, 0);
206
207 SDL_BlitSurface(pdc_font, src, pdc_screen, dest);
208
209 if (backgr != -1)
210 SDL_SetColorKey(pdc_font, 0, 0);
211
212 if (col != -1)
213 SDL_SetPalette(pdc_font, SDL_LOGPAL,
214 pdc_color + foregr, pdc_flastc, 1);
215 }
216
217 if (ch & (A_LEFTLINE|A_RIGHTLINE))
218 {
219 if (col == -1)
220 col = foregr;
221
222 dest->w = 1;
223
224 if (ch & A_LEFTLINE)
225 SDL_FillRect(pdc_screen, dest, pdc_mapped[col]);
226
227 if (ch & A_RIGHTLINE)
228 {
229 dest->x += pdc_fwidth - 1;
230 SDL_FillRect(pdc_screen, dest, pdc_mapped[col]);
231 dest->x -= pdc_fwidth - 1;
232 }
233
234 dest->w = pdc_fwidth;
235 }
236 }
237
238 /* update the given physical line to look like the corresponding line in
239 curscr */
240
241 void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
242 {
243 SDL_Rect src, dest, lastrect;
244 int j;
245
246 PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
247
248 if (rectcount == MAXRECT)
249 PDC_update_rects();
250
251 src.h = pdc_fheight;
252 src.w = pdc_fwidth;
253
254 dest.y = pdc_fheight * lineno + pdc_yoffset;
255 dest.x = pdc_fwidth * x + pdc_xoffset;
256 dest.h = pdc_fheight;
257 dest.w = pdc_fwidth * len;
258
259 /* if the previous rect was just above this one, with the same width
260 and horizontal position, then merge the new one with it instead
261 of adding a new entry */
262
263 if (rectcount)
264 lastrect = uprect[rectcount - 1];
265
266 if (rectcount && lastrect.x == dest.x && lastrect.w == dest.w)
267 {
268 if (lastrect.y + lastrect.h == dest.y)
269 uprect[rectcount - 1].h = lastrect.h + pdc_fheight;
270 else
271 if (lastrect.y != dest.y)
272 uprect[rectcount++] = dest;
273 }
274 else
275 uprect[rectcount++] = dest;
276
277 dest.w = pdc_fwidth;
278
279 for (j = 0; j < len; j++)
280 {
281 chtype ch = srcp[j];
282
283 _set_attr(ch);
284 #ifdef CHTYPE_LONG
285 if (ch & A_ALTCHARSET && !(ch & 0xff80))
286 ch = (ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) | acs_map[ch & 0x7f];
287 #endif
288 if (backgr == -1)
289 SDL_LowerBlit(pdc_tileback, &dest, pdc_screen, &dest);
290
291 src.x = (ch & 0xff) % 32 * pdc_fwidth;
292 src.y = (ch & 0xff) / 32 * pdc_fheight;
293
294 SDL_LowerBlit(pdc_font, &src, pdc_screen, &dest);
295
296 if (ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE))
297 _highlight(&src, &dest, ch);
298
299 dest.x += pdc_fwidth;
300 }
301 }
File sdl1/pdcgetsc.c added (mode: 100644) (index 00000000..43192350)
1 /* Public Domain Curses */
2
3 #include "pdcsdl.h"
4
5 RCSID("$Id: pdcgetsc.c,v 1.8 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /* get the cursor size/shape */
8
9 int PDC_get_cursor_mode(void)
10 {
11 PDC_LOG(("PDC_get_cursor_mode() - called\n"));
12
13 return 0;
14 }
15
16 /* return number of screen rows */
17
18 int PDC_get_rows(void)
19 {
20 PDC_LOG(("PDC_get_rows() - called\n"));
21
22 return pdc_sheight / pdc_fheight;
23 }
24
25 /* return width of screen/viewport */
26
27 int PDC_get_columns(void)
28 {
29 PDC_LOG(("PDC_get_columns() - called\n"));
30
31 return pdc_swidth / pdc_fwidth;
32 }
File sdl1/pdckbd.c added (mode: 100644) (index 00000000..56bf1e47)
1 /* Public Domain Curses */
2
3 #include "pdcsdl.h"
4
5 RCSID("$Id: pdckbd.c,v 1.20 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: pdckbd
10
11 Synopsis:
12 unsigned long PDC_get_input_fd(void);
13
14 Description:
15 PDC_get_input_fd() returns the file descriptor that PDCurses
16 reads its input from. It can be used for select().
17
18 Portability X/Open BSD SYS V
19 PDC_get_input_fd - - -
20
21 **man-end****************************************************************/
22
23 #include <string.h>
24
25 unsigned long pdc_key_modifiers = 0L;
26
27 static SDL_Event event;
28 static SDLKey oldkey;
29 static MOUSE_STATUS old_mouse_status;
30
31 static struct
32 {
33 SDLKey keycode;
34 bool numkeypad;
35 unsigned short normal;
36 unsigned short shifted;
37 unsigned short control;
38 unsigned short alt;
39 } key_table[] =
40 {
41 /* keycode keypad normal shifted control alt*/
42 {SDLK_LEFT, FALSE, KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT},
43 {SDLK_RIGHT, FALSE, KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT},
44 {SDLK_UP, FALSE, KEY_UP, KEY_SUP, CTL_UP, ALT_UP},
45 {SDLK_DOWN, FALSE, KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN},
46 {SDLK_HOME, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
47 {SDLK_END, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
48 {SDLK_PAGEUP, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
49 {SDLK_PAGEDOWN,FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
50 {SDLK_INSERT, FALSE, KEY_IC, KEY_SIC, CTL_INS, ALT_INS},
51 {SDLK_DELETE, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
52 {SDLK_F1, FALSE, KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37)},
53 {SDLK_F2, FALSE, KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38)},
54 {SDLK_F3, FALSE, KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39)},
55 {SDLK_F4, FALSE, KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40)},
56 {SDLK_F5, FALSE, KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41)},
57 {SDLK_F6, FALSE, KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42)},
58 {SDLK_F7, FALSE, KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43)},
59 {SDLK_F8, FALSE, KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44)},
60 {SDLK_F9, FALSE, KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45)},
61 {SDLK_F10, FALSE, KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46)},
62 {SDLK_F11, FALSE, KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47)},
63 {SDLK_F12, FALSE, KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48)},
64 {SDLK_F13, FALSE, KEY_F(13), KEY_F(25), KEY_F(37), KEY_F(49)},
65 {SDLK_F14, FALSE, KEY_F(14), KEY_F(26), KEY_F(38), KEY_F(50)},
66 {SDLK_F15, FALSE, KEY_F(15), KEY_F(27), KEY_F(39), KEY_F(51)},
67 {SDLK_BACKSPACE,FALSE, 0x08, 0x08, CTL_BKSP, ALT_BKSP},
68 {SDLK_TAB, FALSE, 0x09, KEY_BTAB, CTL_TAB, ALT_TAB},
69 {SDLK_PRINT, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
70 {SDLK_PAUSE, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
71 {SDLK_CLEAR, FALSE, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR},
72 {SDLK_BREAK, FALSE, KEY_BREAK, KEY_BREAK, KEY_BREAK, KEY_BREAK},
73 {SDLK_HELP, FALSE, KEY_HELP, KEY_SHELP, KEY_LHELP, KEY_HELP},
74 {SDLK_MENU, FALSE, KEY_OPTIONS, KEY_SOPTIONS, KEY_OPTIONS, KEY_OPTIONS},
75 {SDLK_ESCAPE, FALSE, 0x1B, 0x1B, 0x1B, ALT_ESC},
76 {SDLK_KP_ENTER,TRUE, PADENTER, PADENTER, CTL_PADENTER,ALT_PADENTER},
77 {SDLK_KP_PLUS, TRUE, PADPLUS, '+', CTL_PADPLUS, ALT_PADPLUS},
78 {SDLK_KP_MINUS,TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
79 {SDLK_KP_MULTIPLY,TRUE,PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
80 {SDLK_KP_DIVIDE,TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
81 {SDLK_KP_PERIOD,TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
82 {SDLK_KP0, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
83 {SDLK_KP1, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
84 {SDLK_KP2, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
85 {SDLK_KP3, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
86 {SDLK_KP4, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
87 {SDLK_KP5, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
88 {SDLK_KP6, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
89 {SDLK_KP7, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
90 {SDLK_KP8, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
91 {SDLK_KP9, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
92 {0, 0, 0, 0, 0, 0}
93 };
94
95 unsigned long PDC_get_input_fd(void)
96 {
97 PDC_LOG(("PDC_get_input_fd() - called\n"));
98
99 return 0L; /* test this */
100 }
101
102 void PDC_set_keyboard_binary(bool on)
103 {
104 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
105 }
106
107 /* check if a key or mouse event is waiting */
108
109 bool PDC_check_key(void)
110 {
111 Uint32 current = SDL_GetTicks();
112 int haveevent = SDL_PollEvent(&event);
113
114 /* if we have an event, or 30 ms have passed without a screen
115 update, or the timer has wrapped, update now */
116
117 if (haveevent ||
118 current < pdc_lastupdate || ((current - pdc_lastupdate) > 30))
119 PDC_update_rects();
120
121 return haveevent;
122 }
123
124 static int _process_key_event(void)
125 {
126 int i, key = 0;
127
128 pdc_key_modifiers = 0L;
129 SP->key_code = FALSE;
130
131 if (event.type == SDL_KEYUP)
132 {
133 if (SP->return_key_modifiers && event.key.keysym.sym == oldkey)
134 {
135 switch (oldkey)
136 {
137 case SDLK_RSHIFT:
138 return KEY_SHIFT_R;
139 case SDLK_LSHIFT:
140 return KEY_SHIFT_L;
141 case SDLK_RCTRL:
142 return KEY_CONTROL_R;
143 case SDLK_LCTRL:
144 return KEY_CONTROL_L;
145 case SDLK_RALT:
146 return KEY_ALT_R;
147 case SDLK_LALT:
148 return KEY_ALT_L;
149 default:
150 break;
151 }
152 }
153
154 return -1;
155 }
156
157 oldkey = event.key.keysym.sym;
158
159 if (SP->save_key_modifiers)
160 {
161 if (event.key.keysym.mod & KMOD_NUM)
162 pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
163
164 if (event.key.keysym.mod & KMOD_SHIFT)
165 pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
166
167 if (event.key.keysym.mod & KMOD_CTRL)
168 pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
169
170 if (event.key.keysym.mod & KMOD_ALT)
171 pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
172 }
173
174 for (i = 0; key_table[i].keycode; i++)
175 {
176 if (key_table[i].keycode == event.key.keysym.sym)
177 {
178 if ((event.key.keysym.mod & KMOD_SHIFT) ||
179 (key_table[i].numkeypad && (event.key.keysym.mod & KMOD_NUM)))
180 {
181 key = key_table[i].shifted;
182 }
183 else if (event.key.keysym.mod & KMOD_CTRL)
184 {
185 key = key_table[i].control;
186 }
187 else if (event.key.keysym.mod & KMOD_ALT)
188 {
189 key = key_table[i].alt;
190 }
191
192 /* To get here, we ignore all other modifiers */
193
194 else
195 key = key_table[i].normal;
196
197 SP->key_code = (key > 0x100);
198 break;
199 }
200 }
201
202 if (!key)
203 {
204 key = event.key.keysym.unicode;
205
206 if (key > 0x7f)
207 key = 0;
208 }
209
210 /* Handle ALT letters and numbers */
211
212 if (event.key.keysym.mod & KMOD_ALT)
213 {
214 if (key >= 'A' && key <= 'Z')
215 {
216 key += ALT_A - 'A';
217 SP->key_code = TRUE;
218 }
219
220 if (key >= 'a' && key <= 'z')
221 {
222 key += ALT_A - 'a';
223 SP->key_code = TRUE;
224 }
225
226 if (key >= '0' && key <= '9')
227 {
228 key += ALT_0 - '0';
229 SP->key_code = TRUE;
230 }
231 }
232
233 return key ? key : -1;
234 }
235
236 static int _process_mouse_event(void)
237 {
238 SDLMod keymods;
239 short shift_flags = 0;
240
241 memset(&pdc_mouse_status, 0, sizeof(MOUSE_STATUS));
242
243 keymods = SDL_GetModState();
244
245 if (keymods & KMOD_SHIFT)
246 shift_flags |= BUTTON_SHIFT;
247
248 if (keymods & KMOD_CTRL)
249 shift_flags |= BUTTON_CONTROL;
250
251 if (keymods & KMOD_ALT)
252 shift_flags |= BUTTON_ALT;
253
254 if (event.type == SDL_MOUSEMOTION)
255 {
256 int i;
257
258 pdc_mouse_status.x = event.motion.x / pdc_fwidth;
259 pdc_mouse_status.y = event.motion.y / pdc_fheight;
260
261 if (!event.motion.state ||
262 (pdc_mouse_status.x == old_mouse_status.x &&
263 pdc_mouse_status.y == old_mouse_status.y))
264 return -1;
265
266 pdc_mouse_status.changes = PDC_MOUSE_MOVED;
267
268 for (i = 0; i < 3; i++)
269 {
270 if (event.motion.state & SDL_BUTTON(i + 1))
271 {
272 pdc_mouse_status.button[i] = BUTTON_MOVED | shift_flags;
273 pdc_mouse_status.changes |= (1 << i);
274 }
275 }
276 }
277 else
278 {
279 short action = (event.button.state == SDL_PRESSED) ?
280 BUTTON_PRESSED : BUTTON_RELEASED;
281 Uint8 btn = event.button.button;
282
283 /* handle scroll wheel */
284
285 if ((btn == 4 || btn == 5) && action == BUTTON_RELEASED)
286 {
287 pdc_mouse_status.x = pdc_mouse_status.y = -1;
288
289 pdc_mouse_status.changes = (btn == 5) ?
290 PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
291
292 return KEY_MOUSE;
293 }
294
295 if (btn < 1 || btn > 3)
296 return -1;
297
298 /* check for a click -- a press followed immediately by a release */
299
300 if (action == BUTTON_PRESSED && SP->mouse_wait)
301 {
302 SDL_Event rel;
303
304 napms(SP->mouse_wait);
305
306 if (SDL_PollEvent(&rel))
307 {
308 if (rel.type == SDL_MOUSEBUTTONUP && rel.button.button == btn)
309 action = BUTTON_CLICKED;
310 else
311 SDL_PushEvent(&rel);
312 }
313 }
314
315 pdc_mouse_status.x = event.button.x / pdc_fwidth;
316 pdc_mouse_status.y = event.button.y / pdc_fheight;
317
318 btn--;
319
320 pdc_mouse_status.button[btn] = action | shift_flags;
321 pdc_mouse_status.changes = (1 << btn);
322 }
323
324 old_mouse_status = pdc_mouse_status;
325
326 return KEY_MOUSE;
327 }
328
329 /* return the next available key or mouse event */
330
331 int PDC_get_key(void)
332 {
333 switch (event.type)
334 {
335 case SDL_QUIT:
336 exit(1);
337 case SDL_VIDEORESIZE:
338 if (pdc_own_screen &&
339 (event.resize.h / pdc_fheight != LINES ||
340 event.resize.w / pdc_fwidth != COLS))
341 {
342 pdc_sheight = event.resize.h;
343 pdc_swidth = event.resize.w;
344
345 if (!SP->resized)
346 {
347 SP->resized = TRUE;
348 return KEY_RESIZE;
349 }
350 }
351 break;
352 case SDL_MOUSEMOTION:
353 SDL_ShowCursor(SDL_ENABLE);
354 case SDL_MOUSEBUTTONUP:
355 case SDL_MOUSEBUTTONDOWN:
356 oldkey = SDLK_SPACE;
357 if (SP->_trap_mbe)
358 return _process_mouse_event();
359 break;
360 case SDL_KEYUP:
361 case SDL_KEYDOWN:
362 PDC_mouse_set();
363 return _process_key_event();
364 }
365
366 return -1;
367 }
368
369 /* discard any pending keyboard or mouse input -- this is the core
370 routine for flushinp() */
371
372 void PDC_flushinp(void)
373 {
374 PDC_LOG(("PDC_flushinp() - called\n"));
375
376 while (PDC_check_key());
377 }
378
379 int PDC_mouse_set(void)
380 {
381 SDL_ShowCursor(SP->_trap_mbe ? SDL_ENABLE : SDL_DISABLE);
382
383 return OK;
384 }
385
386 int PDC_modifiers_set(void)
387 {
388 return OK;
389 }
File sdl1/pdcscrn.c added (mode: 100644) (index 00000000..e422b25c)
1 /* Public Domain Curses */
2
3 #include "pdcsdl.h"
4
5 RCSID("$Id: pdcscrn.c,v 1.34 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <stdlib.h>
8 #include "deffont.h"
9 #include "deficon.h"
10
11 SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL,
12 *pdc_back = NULL, *pdc_tileback = NULL;
13 int pdc_sheight = 0, pdc_swidth = 0, pdc_yoffset = 0, pdc_xoffset = 0;
14
15 SDL_Color pdc_color[16];
16 Uint32 pdc_mapped[16];
17 int pdc_fheight, pdc_fwidth, pdc_flastc;
18 bool pdc_own_screen;
19
20 /* COLOR_PAIR to attribute encoding table. */
21
22 static struct {short f, b;} atrtab[PDC_COLOR_PAIRS];
23
24 void PDC_retile(void)
25 {
26 if (pdc_tileback)
27 SDL_FreeSurface(pdc_tileback);
28
29 pdc_tileback = SDL_DisplayFormat(pdc_screen);
30
31 if (pdc_back)
32 {
33 SDL_Rect dest;
34
35 dest.y = 0;
36
37 while (dest.y < pdc_tileback->h)
38 {
39 dest.x = 0;
40
41 while (dest.x < pdc_tileback->w)
42 {
43 SDL_BlitSurface(pdc_back, 0, pdc_tileback, &dest);
44 dest.x += pdc_back->w;
45 }
46
47 dest.y += pdc_back->h;
48 }
49
50 SDL_BlitSurface(pdc_tileback, 0, pdc_screen, 0);
51 }
52 }
53
54 void PDC_scr_close(void)
55 {
56 PDC_LOG(("PDC_scr_close() - called\n"));
57 }
58
59 void PDC_scr_free(void)
60 {
61 if (SP)
62 free(SP);
63 }
64
65 /* open the physical screen -- allocate SP, miscellaneous intialization */
66
67 int PDC_scr_open(int argc, char **argv)
68 {
69 int i;
70
71 PDC_LOG(("PDC_scr_open() - called\n"));
72
73 SP = calloc(1, sizeof(SCREEN));
74
75 if (!SP)
76 return ERR;
77
78 pdc_own_screen = !pdc_screen;
79
80 if (pdc_own_screen)
81 {
82 if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0)
83 {
84 fprintf(stderr, "Could not start SDL: %s\n", SDL_GetError());
85 return ERR;
86 }
87
88 atexit(SDL_Quit);
89 }
90
91 if (!pdc_font)
92 {
93 const char *fname = getenv("PDC_FONT");
94 pdc_font = SDL_LoadBMP(fname ? fname : "pdcfont.bmp");
95 }
96
97 if (!pdc_font)
98 pdc_font = SDL_LoadBMP_RW(SDL_RWFromMem(deffont, sizeof(deffont)), 0);
99
100 if (!pdc_font)
101 {
102 fprintf(stderr, "Could not load font\n");
103 return ERR;
104 }
105
106 SP->mono = !pdc_font->format->palette;
107
108 if (!SP->mono && !pdc_back)
109 {
110 const char *bname = getenv("PDC_BACKGROUND");
111 pdc_back = SDL_LoadBMP(bname ? bname : "pdcback.bmp");
112 }
113
114 if (!SP->mono && (pdc_back || !pdc_own_screen))
115 {
116 SP->orig_attr = TRUE;
117 SP->orig_fore = COLOR_WHITE;
118 SP->orig_back = -1;
119 }
120 else
121 SP->orig_attr = FALSE;
122
123 pdc_fheight = pdc_font->h / 8;
124 pdc_fwidth = pdc_font->w / 32;
125
126 if (!SP->mono)
127 pdc_flastc = pdc_font->format->palette->ncolors - 1;
128
129 if (pdc_own_screen && !pdc_icon)
130 {
131 const char *iname = getenv("PDC_ICON");
132 pdc_icon = SDL_LoadBMP(iname ? iname : "pdcicon.bmp");
133
134 if (!pdc_icon)
135 pdc_icon = SDL_LoadBMP_RW(SDL_RWFromMem(deficon,
136 sizeof(deficon)), 0);
137
138 if (pdc_icon)
139 SDL_WM_SetIcon(pdc_icon, NULL);
140 }
141
142 if (pdc_own_screen)
143 {
144 const char *env = getenv("PDC_LINES");
145 pdc_sheight = (env ? atoi(env) : 25) * pdc_fheight;
146
147 env = getenv("PDC_COLS");
148 pdc_swidth = (env ? atoi(env) : 80) * pdc_fwidth;
149
150 pdc_screen = SDL_SetVideoMode(pdc_swidth, pdc_sheight, 0,
151 SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE);
152 }
153 else
154 {
155 if (!pdc_sheight)
156 pdc_sheight = pdc_screen->h - pdc_yoffset;
157
158 if (!pdc_swidth)
159 pdc_swidth = pdc_screen->w - pdc_xoffset;
160 }
161
162 if (!pdc_screen)
163 {
164 fprintf(stderr, "Couldn't create a surface: %s\n", SDL_GetError());
165 return ERR;
166 }
167
168 if (SP->orig_attr)
169 PDC_retile();
170
171 for (i = 0; i < 8; i++)
172 {
173 pdc_color[i].r = (i & COLOR_RED) ? 0xc0 : 0;
174 pdc_color[i].g = (i & COLOR_GREEN) ? 0xc0 : 0;
175 pdc_color[i].b = (i & COLOR_BLUE) ? 0xc0 : 0;
176
177 pdc_color[i + 8].r = (i & COLOR_RED) ? 0xff : 0x40;
178 pdc_color[i + 8].g = (i & COLOR_GREEN) ? 0xff : 0x40;
179 pdc_color[i + 8].b = (i & COLOR_BLUE) ? 0xff : 0x40;
180 }
181
182 for (i = 0; i < 16; i++)
183 pdc_mapped[i] = SDL_MapRGB(pdc_screen->format, pdc_color[i].r,
184 pdc_color[i].g, pdc_color[i].b);
185
186 SDL_EnableUNICODE(1);
187
188 PDC_mouse_set();
189
190 if (pdc_own_screen)
191 PDC_set_title(argc ? argv[0] : "PDCurses");
192
193 SP->lines = PDC_get_rows();
194 SP->cols = PDC_get_columns();
195
196 SP->mouse_wait = PDC_CLICK_PERIOD;
197 SP->audible = FALSE;
198
199 PDC_reset_prog_mode();
200
201 return OK;
202 }
203
204 /* the core of resize_term() */
205
206 int PDC_resize_screen(int nlines, int ncols)
207 {
208 if (!pdc_own_screen)
209 return ERR;
210
211 if (nlines && ncols)
212 {
213 pdc_sheight = nlines * pdc_fheight;
214 pdc_swidth = ncols * pdc_fwidth;
215 }
216
217 SDL_FreeSurface(pdc_screen);
218
219 pdc_screen = SDL_SetVideoMode(pdc_swidth, pdc_sheight, 0,
220 SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE);
221
222 if (pdc_tileback)
223 PDC_retile();
224
225 SP->resized = FALSE;
226 SP->cursrow = SP->curscol = 0;
227
228 return OK;
229 }
230
231 void PDC_reset_prog_mode(void)
232 {
233 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
234
235 PDC_flushinp();
236 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
237 }
238
239 void PDC_reset_shell_mode(void)
240 {
241 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
242
243 SDL_EnableKeyRepeat(0, 0);
244 PDC_flushinp();
245 }
246
247 void PDC_restore_screen_mode(int i)
248 {
249 }
250
251 void PDC_save_screen_mode(int i)
252 {
253 }
254
255 void PDC_init_pair(short pair, short fg, short bg)
256 {
257 atrtab[pair].f = fg;
258 atrtab[pair].b = bg;
259 }
260
261 int PDC_pair_content(short pair, short *fg, short *bg)
262 {
263 *fg = atrtab[pair].f;
264 *bg = atrtab[pair].b;
265
266 return OK;
267 }
268
269 bool PDC_can_change_color(void)
270 {
271 return TRUE;
272 }
273
274 int PDC_color_content(short color, short *red, short *green, short *blue)
275 {
276 *red = DIVROUND(pdc_color[color].r * 1000, 255);
277 *green = DIVROUND(pdc_color[color].g * 1000, 255);
278 *blue = DIVROUND(pdc_color[color].b * 1000, 255);
279
280 return OK;
281 }
282
283 int PDC_init_color(short color, short red, short green, short blue)
284 {
285 pdc_color[color].r = DIVROUND(red * 255, 1000);
286 pdc_color[color].g = DIVROUND(green * 255, 1000);
287 pdc_color[color].b = DIVROUND(blue * 255, 1000);
288
289 pdc_mapped[color] = SDL_MapRGB(pdc_screen->format, pdc_color[color].r,
290 pdc_color[color].g, pdc_color[color].b);
291
292 wrefresh(curscr);
293
294 return OK;
295 }
File sdl1/pdcsdl.h added (mode: 100644) (index 00000000..79df21a5)
1 /* Public Domain Curses */
2
3 /* $Id: pdcsdl.h,v 1.17 2008/07/14 04:24:52 wmcbrine Exp $ */
4
5 #include <curspriv.h>
6
7 #include <SDL/SDL.h>
8
9 PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back;
10 PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset;
11
12 extern SDL_Surface *pdc_tileback; /* used to regenerate the background
13 of "transparent" cells */
14 extern SDL_Color pdc_color[16]; /* colors for font palette */
15 extern Uint32 pdc_mapped[16]; /* colors for FillRect(), as
16 used in _highlight() */
17 extern int pdc_fheight, pdc_fwidth; /* font height and width */
18 extern int pdc_flastc; /* font palette's last color
19 (treated as the foreground) */
20 extern bool pdc_own_screen; /* if pdc_screen was not set
21 before initscr(), PDCurses is
22 responsible for (owns) it */
23 extern Uint32 pdc_lastupdate; /* time of last update, in ticks */
24
25 void PDC_update_rects(void);
26 void PDC_retile(void);
File sdl1/pdcsetsc.c added (mode: 100644) (index 00000000..0df97ab7)
1 /* Public Domain Curses */
2
3 #include "pdcsdl.h"
4
5 RCSID("$Id: pdcsetsc.c,v 1.7 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: pdcsetsc
10
11 Synopsis:
12 int PDC_set_blink(bool blinkon);
13 void PDC_set_title(const char *title);
14
15 Description:
16 PDC_set_blink() toggles whether the A_BLINK attribute sets an
17 actual blink mode (TRUE), or sets the background color to high
18 intensity (FALSE). The default is platform-dependent (FALSE in
19 most cases). It returns OK if it could set the state to match
20 the given parameter, ERR otherwise. Current platforms also
21 adjust the value of COLORS according to this function -- 16 for
22 FALSE, and 8 for TRUE.
23
24 PDC_set_title() sets the title of the window in which the curses
25 program is running. This function may not do anything on some
26 platforms. (Currently it only works in Win32 and X11.)
27
28 Portability X/Open BSD SYS V
29 PDC_set_blink - - -
30 PDC_set_title - - -
31
32 **man-end****************************************************************/
33
34 int PDC_curs_set(int visibility)
35 {
36 int ret_vis;
37
38 PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
39
40 ret_vis = SP->visibility;
41
42 SP->visibility = visibility;
43
44 PDC_gotoyx(SP->cursrow, SP->curscol);
45
46 return ret_vis;
47 }
48
49 void PDC_set_title(const char *title)
50 {
51 PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
52
53 SDL_WM_SetCaption(title, title);
54 }
55
56 int PDC_set_blink(bool blinkon)
57 {
58 if (pdc_color_started)
59 COLORS = 16;
60
61 return blinkon ? ERR : OK;
62 }
File sdl1/pdcutil.c added (mode: 100644) (index 00000000..b2d84045)
1 /* Public Domain Curses */
2
3 #include "pdcsdl.h"
4
5 RCSID("$Id: pdcutil.c,v 1.6 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 void PDC_beep(void)
8 {
9 PDC_LOG(("PDC_beep() - called\n"));
10 }
11
12 void PDC_napms(int ms)
13 {
14 PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
15
16 PDC_update_rects();
17 SDL_Delay(ms);
18 }
19
20 const char *PDC_sysname(void)
21 {
22 return "SDL";
23 }
File sdl1/sdltest.c added (mode: 100644) (index 00000000..d39533b3)
1 /* Here's a simple example of combining SDL and PDCurses functionality.
2 The top portion of the window is devoted to SDL, with a four-line
3 (assuming the default 8x16 font) stdscr at the bottom.
4
5 $Id: sdltest.c,v 1.2 2008/07/14 04:24:52 wmcbrine Exp $
6 */
7
8 #include <SDL/SDL.h>
9 #include <curses.h>
10 #include <stdlib.h>
11 #include <time.h>
12
13 /* You could #include pdcsdl.h, or just add the relevant declarations
14 here: */
15
16 PDCEX SDL_Surface *pdc_screen;
17 PDCEX int pdc_yoffset;
18
19 int main(int argc, char **argv)
20 {
21 char inp[60];
22 int i, j, seed;
23
24 seed = time((time_t *)0);
25 srand(seed);
26
27 /* Initialize SDL */
28
29 if (SDL_Init(SDL_INIT_VIDEO) < 0)
30 exit(1);
31
32 atexit(SDL_Quit);
33
34 pdc_screen = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE|SDL_ANYFORMAT);
35
36 /* Initialize PDCurses */
37
38 pdc_yoffset = 416; /* 480 - 4 * 16 */
39
40 initscr();
41 start_color();
42 scrollok(stdscr, TRUE);
43
44 PDC_set_title("PDCurses for SDL");
45
46 /* Do some SDL stuff */
47
48 for (i = 640, j = 416; j; i -= 2, j -= 2)
49 {
50 SDL_Rect dest;
51
52 dest.x = (640 - i) / 2;
53 dest.y = (416 - j) / 2;
54 dest.w = i;
55 dest.h = j;
56
57 SDL_FillRect(pdc_screen, &dest,
58 SDL_MapRGB(pdc_screen->format, rand() % 256,
59 rand() % 256, rand() % 256));
60 }
61
62 SDL_UpdateRect(pdc_screen, 0, 0, 640, 416);
63
64 /* Do some curses stuff */
65
66 init_pair(1, COLOR_WHITE + 8, COLOR_BLUE);
67 bkgd(COLOR_PAIR(1));
68
69 addstr("This is a demo of ");
70 attron(A_UNDERLINE);
71 addstr("PDCurses for SDL");
72 attroff(A_UNDERLINE);
73 addstr(".\nYour comments here: ");
74 getnstr(inp, 59);
75 addstr("Press any key to exit.");
76
77 getch();
78 endwin();
79
80 return 0;
81 }
File term.h added (mode: 100644) (index 00000000..ce6bc4fa)
1 /* Public Domain Curses */
2
3 /* $Id: term.h,v 1.16 2008/07/13 16:08:16 wmcbrine Exp $ */
4
5 /* PDCurses doesn't operate with terminfo, but we need these functions for
6 compatibility, to allow some things (notably, interface libraries for
7 other languages) to be compiled. Anyone who tries to actually _use_
8 them will be disappointed, since they only return ERR. */
9
10 #ifndef __PDCURSES_TERM_H__
11 #define __PDCURSES_TERM_H__ 1
12
13 #include <curses.h>
14
15 #if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
16 extern "C"
17 {
18 #endif
19
20 typedef struct
21 {
22 const char *_termname;
23 } TERMINAL;
24
25 #ifdef PDC_DLL_BUILD
26 # ifndef CURSES_LIBRARY
27 __declspec(dllimport) TERMINAL *cur_term;
28 # else
29 __declspec(dllexport) extern TERMINAL *cur_term;
30 # endif
31 #else
32 extern TERMINAL *cur_term;
33 #endif
34
35 int del_curterm(TERMINAL *);
36 int putp(const char *);
37 int restartterm(const char *, int, int *);
38 TERMINAL *set_curterm(TERMINAL *);
39 int setterm(const char *);
40 int setupterm(const char *, int, int *);
41 int tgetent(char *, const char *);
42 int tgetflag(const char *);
43 int tgetnum(const char *);
44 char *tgetstr(const char *, char **);
45 char *tgoto(const char *, int, int);
46 int tigetflag(const char *);
47 int tigetnum(const char *);
48 char *tigetstr(const char *);
49 char *tparm(const char *, long, long, long, long, long,
50 long, long, long, long);
51 int tputs(const char *, int, int (*)(int));
52
53 #if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
54 }
55 #endif
56
57 #endif /* __PDCURSES_TERM_H__ */
File version.mif added (mode: 100644) (index 00000000..9ff7335b)
1 # Version number macros for inclusion from makefiles
2
3 VER = 34
4 VERDOT = 3.4
File watcom.mif added (mode: 100644) (index 00000000..023ea37e)
1 # Common elements for the Watcom makefiles
2
3 srcdir = $(PDCURSES_SRCDIR)\pdcurses
4 demodir = $(PDCURSES_SRCDIR)\demos
5
6 LIBOBJS = addch.obj addchstr.obj addstr.obj attr.obj beep.obj bkgd.obj &
7 border.obj clear.obj color.obj delch.obj deleteln.obj deprec.obj &
8 getch.obj getstr.obj getyx.obj inch.obj inchstr.obj initscr.obj inopts.obj &
9 insch.obj insstr.obj instr.obj kernel.obj keyname.obj mouse.obj move.obj &
10 outopts.obj overlay.obj pad.obj panel.obj printw.obj refresh.obj &
11 scanw.obj scr_dump.obj scroll.obj slk.obj termattr.obj terminfo.obj &
12 touch.obj util.obj window.obj debug.obj
13
14 PDCOBJS = pdcclip.obj pdcdisp.obj pdcgetsc.obj pdckbd.obj pdcscrn.obj &
15 pdcsetsc.obj pdcutil.obj
16
17 DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe firework.exe &
18 ptest.exe rain.exe worm.exe
19
20 LIBCURSES = pdcurses.lib
21
22 LINK = wlink
23
24 !ifdef __LOADDLL__
25 ! loaddll wcc wccd
26 ! loaddll wcc386 wccd386
27 ! loaddll wlink wlink
28 ! loaddll wlib wlibd
29 !endif
30
31 all: $(LIBCURSES) $(DEMOS)
32
33 clean
34 -del *.obj
35 -del *.lib
36 -del *.exe
37 -del *.err
38
39 demos: $(DEMOS)
40
41 .c: $(srcdir);$(osdir);$(demodir)
42 .c.obj: .autodepend
43 $(CC) $(CFLAGS) $<
44
45 .obj.exe:
46 $(LINK) $(LDFLAGS) n $@ f $*.obj l $(LIBCURSES)
47
48 testcurs.exe: testcurs.obj $(LIBCURSES)
49 newdemo.exe: newdemo.obj $(LIBCURSES)
50 xmas.exe: xmas.obj $(LIBCURSES)
51 firework.exe: firework.obj $(LIBCURSES)
52 rain.exe: rain.obj $(LIBCURSES)
53 worm.exe: worm.obj $(LIBCURSES)
54 ptest.exe: ptest.obj $(LIBCURSES)
55
56 tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
57 $(LINK) $(LDFLAGS) n $@ f tuidemo.obj f tui.obj l $(LIBCURSES)
58
59 dist: .symbolic
File win32/README added (mode: 100644) (index 00000000..bfe2ad95)
1 PDCurses for Win32
2 ==================
3
4 This directory contains PDCurses source code files specific to Win32
5 console mode (Win9x/Me/NT/2k/XP/Vista).
6
7
8 Building
9 --------
10
11 . Choose the appropriate makefile for your compiler:
12
13 bccwin32.mak - Borland C++ 4.0.2+
14 dmcwin32.mak - Digital Mars
15 gccwin32.mak - Cygnus GNU Compiler
16 lccwin32.mak - LCC-Win32
17 mingwin32.mak - MinGW
18 vcwin32.mak - Microsoft Visual C++ 2.0+
19 wccwin32.mak - Watcom 10.6+
20
21 . Optionally, you can build in a different directory than the platform
22 directory by setting PDCURSES_SRCDIR to point to the directory where
23 you unpacked PDCurses, and changing to your target directory:
24
25 set PDCURSES_SRCDIR=c:\pdcurses
26
27 This won't work with the LCC or Digital Mars makefiles, nor will the
28 options described below.
29
30 . Build it:
31
32 make -f makefilename
33
34 (For Watcom, use "wmake" instead of "make"; for MSVC, "nmake".) You'll
35 get the libraries (pdcurses.lib or .a, depending on your compiler; and
36 panel.lib or .a), the demos (*.exe), and a lot of object files. Note
37 that the panel library is just a copy of the main library, provided
38 for convenience; both panel and curses functions are in the main
39 library.
40
41 You can also give the optional parameter "WIDE=Y", to build the
42 library with wide-character (Unicode) support:
43
44 make -f mingwin32.mak WIDE=Y
45
46 When built this way, the library is not compatible with Windows 9x,
47 unless you also link with the Microsoft Layer for Unicode (not
48 tested).
49
50 Another option, "UTF8=Y", makes PDCurses ignore the system locale, and
51 treat all narrow-character strings as UTF-8. This option has no effect
52 unless WIDE=Y is also set. Use it to get around the poor support for
53 UTF-8 in the Win32 console:
54
55 make -f mingwin32.mak WIDE=Y UTF8=Y
56
57 You can also use the optional parameter "DLL=Y" with Visual C++,
58 MinGW or Cygwin, to build the library as a DLL:
59
60 nmake -f vcwin32.mak WIDE=Y DLL=Y
61
62 When you build the library as a Windows DLL, you must always define
63 PDCURSES_DLL_BUILD when linking against it. (Or, if you only want to
64 use the DLL, you could add this definition to your curses.h.)
65
66
67 Distribution Status
68 -------------------
69
70 The files in this directory are released to the Public Domain.
71
72
73 Acknowledgements
74 ----------------
75
76 Generic Win32 port was provided by Chris Szurgot <szurgot@itribe.net>
File win32/bccwin32.mak added (mode: 100644) (index 00000000..229ab4be)
1 # Borland MAKE Makefile for PDCurses library - Win32 BC++ 4.0+
2 #
3 # Usage: make -f [path\]bccwin32.mak [DEBUG=] [WIDE=] [UTF8=] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 O = obj
9
10 !ifndef PDCURSES_SRCDIR
11 PDCURSES_SRCDIR = ..
12 !endif
13
14 !include $(PDCURSES_SRCDIR)\version.mif
15 !include $(PDCURSES_SRCDIR)\libobjs.mif
16
17 osdir = $(PDCURSES_SRCDIR)\win32
18
19 CC = bcc32 -q
20
21 !ifdef DEBUG
22 CFLAGS = -N -v -y -DPDCDEBUG
23 !else
24 CFLAGS = -O
25 !endif
26
27 !ifdef WIDE
28 WIDEOPT = -DPDC_WIDE
29 !endif
30
31 !ifdef UTF8
32 UTF8OPT = -DPDC_FORCE_UTF8
33 !endif
34
35 BUILD = $(CC) -I$(PDCURSES_SRCDIR) -c -Tpe -w32 $(CFLAGS) -w-par \
36 $(WIDEOPT) $(UTF8OPT)
37
38 LIBEXE = tlib /C /E /0 /a
39
40 LIBCURSES = pdcurses.lib
41
42 all: $(LIBCURSES) $(DEMOS)
43
44 clean:
45 -del *.obj
46 -del *.lib
47 -del *.tds
48 -del *.exe
49
50 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
51 -del $@
52 $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
53 -copy $(LIBCURSES) panel.lib
54
55 .autodepend
56
57 {$(srcdir)\}.c.obj:
58 $(BUILD) $<
59
60 {$(osdir)\}.c.obj:
61 $(BUILD) $<
62
63 {$(demodir)\}.c.obj:
64 $(BUILD) $<
65
66 .c.obj:
67 $(BUILD) $<
68
69 .obj.exe:
70 $(CC) -e$@ $** $(LIBCURSES)
71
72 tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
73 $(CC) -e$@ $**
74
75 tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
76 $(BUILD) -I$(demodir) $(demodir)\tui.c
77
78 tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
79 $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
80
81 PLATFORM1 = Borland C++ Win32
82 PLATFORM2 = Borland C/C++ 5.5 for Win32
83 ARCNAME = pdc$(VER)_bcc_w32
84
85 !include $(PDCURSES_SRCDIR)\makedist.mif
File win32/dmcwin32.mak added (mode: 100644) (index 00000000..23522cc9)
1 # Makefile for PDCurses library - WIN32 Digital Mars
2 #
3 # Usage: make -f dmcwin32.mak [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 PDCURSES_SRCDIR = ..
9
10 PDCURSES_CURSES_H = $(PDCURSES_SRCDIR)\curses.h
11 PDCURSES_CURSPRIV_H = $(PDCURSES_SRCDIR)\curspriv.h
12 PDCURSES_HEADERS = $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
13
14 PANEL_HEADER = $(PDCURSES_SRCDIR)\panel.h
15 TERM_HEADER = $(PDCURSES_SRCDIR)\term.h
16
17 srcdir = $(PDCURSES_SRCDIR)\pdcurses
18 osdir = $(PDCURSES_SRCDIR)\win32
19 demodir = $(PDCURSES_SRCDIR)\demos
20
21 PDCURSES_WIN_H = $(osdir)\pdcwin.h
22
23 CC = dmc
24
25 CFLAGS = -c -o+space -Nc
26
27 CPPFLAGS = -I$(PDCURSES_SRCDIR) #-DPDC_WIDE -DPDC_FORCE_UTF8
28
29 LINK = dmc
30 LIBEXE = lib
31
32 LIBCURSES = pdcurses.lib
33
34 BUILD = $(CC) $(CFLAGS) $(CPPFLAGS)
35
36 DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe \
37 firework.exe ptest.exe rain.exe worm.exe
38
39 all: $(LIBCURSES) $(DEMOS)
40
41 clean:
42 -del *.obj
43 -del *.lib
44 -del *.exe
45 -del *.map
46 -del advapi32.def
47
48 LIBOBJS = addch.obj addchstr.obj addstr.obj attr.obj beep.obj bkgd.obj \
49 border.obj clear.obj color.obj delch.obj deleteln.obj deprec.obj getch.obj \
50 getstr.obj getyx.obj inch.obj inchstr.obj initscr.obj inopts.obj \
51 insch.obj insstr.obj instr.obj kernel.obj keyname.obj mouse.obj move.obj \
52 outopts.obj overlay.obj pad.obj panel.obj printw.obj refresh.obj \
53 scanw.obj scr_dump.obj scroll.obj slk.obj termattr.obj terminfo.obj \
54 touch.obj util.obj window.obj debug.obj
55
56 PDCOBJS = pdcclip.obj pdcdisp.obj pdcgetsc.obj pdckbd.obj pdcscrn.obj \
57 pdcsetsc.obj pdcutil.obj
58
59 DEMOOBJS = testcurs.obj newdemo.obj xmas.obj tuidemo.obj tui.obj \
60 firework.obj ptest.obj rain.obj worm.obj
61
62 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
63 $(PDCOBJS) : $(PDCURSES_WIN_H)
64 panel.obj ptest.obj: $(PANEL_HEADER)
65 terminfo.obj: $(TERM_HEADER)
66
67 $(DEMOOBJS) : $(PDCURSES_CURSES_H)
68 $(DEMOS) : $(LIBCURSES)
69
70 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
71 $(LIBEXE) -c $@ $(LIBOBJS) $(PDCOBJS)
72 -copy $(LIBCURSES) panel.lib
73
74 SRCBUILD = $(BUILD) $(srcdir)\$*.c
75 OSBUILD = $(BUILD) $(osdir)\$*.c
76 DEMOBUILD = $(LINK) $(CPPFLAGS) -o+space $@ $**
77
78 addch.obj: $(srcdir)\addch.c
79 $(SRCBUILD)
80
81 addchstr.obj: $(srcdir)\addchstr.c
82 $(SRCBUILD)
83
84 addstr.obj: $(srcdir)\addstr.c
85 $(SRCBUILD)
86
87 attr.obj: $(srcdir)\attr.c
88 $(SRCBUILD)
89
90 beep.obj: $(srcdir)\beep.c
91 $(SRCBUILD)
92
93 bkgd.obj: $(srcdir)\bkgd.c
94 $(SRCBUILD)
95
96 border.obj: $(srcdir)\border.c
97 $(SRCBUILD)
98
99 clear.obj: $(srcdir)\clear.c
100 $(SRCBUILD)
101
102 color.obj: $(srcdir)\color.c
103 $(SRCBUILD)
104
105 delch.obj: $(srcdir)\delch.c
106 $(SRCBUILD)
107
108 deleteln.obj: $(srcdir)\deleteln.c
109 $(SRCBUILD)
110
111 deprec.obj: $(srcdir)\deprec.c
112 $(SRCBUILD)
113
114 getch.obj: $(srcdir)\getch.c
115 $(SRCBUILD)
116
117 getstr.obj: $(srcdir)\getstr.c
118 $(SRCBUILD)
119
120 getyx.obj: $(srcdir)\getyx.c
121 $(SRCBUILD)
122
123 inch.obj: $(srcdir)\inch.c
124 $(SRCBUILD)
125
126 inchstr.obj: $(srcdir)\inchstr.c
127 $(SRCBUILD)
128
129 initscr.obj: $(srcdir)\initscr.c
130 $(SRCBUILD)
131
132 inopts.obj: $(srcdir)\inopts.c
133 $(SRCBUILD)
134
135 insch.obj: $(srcdir)\insch.c
136 $(SRCBUILD)
137
138 insstr.obj: $(srcdir)\insstr.c
139 $(SRCBUILD)
140
141 instr.obj: $(srcdir)\instr.c
142 $(SRCBUILD)
143
144 kernel.obj: $(srcdir)\kernel.c
145 $(SRCBUILD)
146
147 keyname.obj: $(srcdir)\keyname.c
148 $(SRCBUILD)
149
150 mouse.obj: $(srcdir)\mouse.c
151 $(SRCBUILD)
152
153 move.obj: $(srcdir)\move.c
154 $(SRCBUILD)
155
156 outopts.obj: $(srcdir)\outopts.c
157 $(SRCBUILD)
158
159 overlay.obj: $(srcdir)\overlay.c
160 $(SRCBUILD)
161
162 pad.obj: $(srcdir)\pad.c
163 $(SRCBUILD)
164
165 panel.obj: $(srcdir)\panel.c
166 $(SRCBUILD)
167
168 printw.obj: $(srcdir)\printw.c
169 $(SRCBUILD)
170
171 refresh.obj: $(srcdir)\refresh.c
172 $(SRCBUILD)
173
174 scanw.obj: $(srcdir)\scanw.c
175 $(SRCBUILD)
176
177 scr_dump.obj: $(srcdir)\scr_dump.c
178 $(SRCBUILD)
179
180 scroll.obj: $(srcdir)\scroll.c
181 $(SRCBUILD)
182
183 slk.obj: $(srcdir)\slk.c
184 $(SRCBUILD)
185
186 termattr.obj: $(srcdir)\termattr.c
187 $(SRCBUILD)
188
189 terminfo.obj: $(srcdir)\terminfo.c
190 $(SRCBUILD)
191
192 touch.obj: $(srcdir)\touch.c
193 $(SRCBUILD)
194
195 util.obj: $(srcdir)\util.c
196 $(SRCBUILD)
197
198 window.obj: $(srcdir)\window.c
199 $(SRCBUILD)
200
201 debug.obj: $(srcdir)\debug.c
202 $(SRCBUILD)
203
204 pdcclip.obj: $(osdir)\pdcclip.c
205 $(OSBUILD)
206
207 pdcdisp.obj: $(osdir)\pdcdisp.c
208 $(OSBUILD)
209
210 pdcgetsc.obj: $(osdir)\pdcgetsc.c
211 $(OSBUILD)
212
213 pdckbd.obj: $(osdir)\pdckbd.c
214 $(OSBUILD)
215
216 pdcscrn.obj: $(osdir)\pdcscrn.c
217 $(OSBUILD)
218
219 pdcsetsc.obj: $(osdir)\pdcsetsc.c
220 $(OSBUILD)
221
222 pdcutil.obj: $(osdir)\pdcutil.c
223 $(OSBUILD)
224
225 firework.exe: $(demodir)\firework.c
226 $(DEMOBUILD)
227
228 newdemo.exe: $(demodir)\newdemo.c
229 $(DEMOBUILD)
230
231 ptest.exe: $(demodir)\ptest.c
232 $(DEMOBUILD)
233
234 rain.exe: $(demodir)\rain.c
235 $(DEMOBUILD)
236
237 testcurs.exe: $(demodir)\testcurs.c
238 $(DEMOBUILD) advapi32.lib
239
240 tuidemo.exe: tuidemo.obj tui.obj
241 $(DEMOBUILD)
242
243 worm.exe: $(demodir)\worm.c
244 $(DEMOBUILD)
245
246 xmas.exe: $(demodir)\xmas.c
247 $(DEMOBUILD)
248
249 tui.obj: $(demodir)\tui.c $(demodir)\tui.h
250 $(BUILD) -I$(demodir) $(demodir)\$*.c
251
252 tuidemo.obj: $(demodir)\tuidemo.c
253 $(BUILD) -I$(demodir) $(demodir)\$*.c
File win32/gccwin32.mak added (mode: 100644) (index 00000000..7504bb34)
1 # GNU MAKE Makefile for PDCurses library - WIN32 Cygnus GCC
2 #
3 # Usage: make -f [path\]gccwin32.mak [DEBUG=Y] [DLL=Y] [WIDE=Y] [UTF8=Y] [tgt]
4 #
5 # where tgt can be any of:
6 # [all|demos|pdcurses.a|testcurs.exe...]
7
8 O = o
9
10 ifndef PDCURSES_SRCDIR
11 PDCURSES_SRCDIR = ..
12 endif
13
14 include $(PDCURSES_SRCDIR)/version.mif
15 include $(PDCURSES_SRCDIR)/libobjs.mif
16
17 osdir = $(PDCURSES_SRCDIR)/win32
18
19 PDCURSES_WIN_H = $(osdir)/pdcwin.h
20
21 CC = gcc
22
23 ifeq ($(DEBUG),Y)
24 CFLAGS = -g -Wall -DPDCDEBUG
25 LDFLAGS = -g
26 else
27 CFLAGS = -O2 -Wall
28 LDFLAGS =
29 endif
30
31 CFLAGS += -I$(PDCURSES_SRCDIR)
32
33 BASEDEF = $(PDCURSES_SRCDIR)/exp-base.def
34 WIDEDEF = $(PDCURSES_SRCDIR)/exp-wide.def
35
36 DEFDEPS = $(BASEDEF)
37
38 ifeq ($(WIDE),Y)
39 CFLAGS += -DPDC_WIDE
40 DEFDEPS += $(WIDEDEF)
41 endif
42
43 ifeq ($(UTF8),Y)
44 CFLAGS += -DPDC_FORCE_UTF8
45 endif
46
47 DEFFILE = pdcurses.def
48
49 LINK = gcc
50
51 ifeq ($(DLL),Y)
52 CFLAGS += -DPDC_DLL_BUILD
53 LIBEXE = gcc $(DEFFILE)
54 LIBFLAGS = -Wl,--out-implib,pdcurses.a -shared -o
55 LIBCURSES = pdcurses.dll
56 LIBDEPS = $(LIBOBJS) $(PDCOBJS) $(DEFFILE)
57 CLEAN = $(LIBCURSES) *.a $(DEFFILE)
58 else
59 LIBEXE = ar
60 LIBFLAGS = rcv
61 LIBCURSES = pdcurses.a
62 LIBDEPS = $(LIBOBJS) $(PDCOBJS)
63 CLEAN = *.a
64 endif
65
66 .PHONY: all libs clean demos dist
67
68 all: libs demos
69
70 libs: $(LIBCURSES)
71
72 clean:
73 -rm -f *.o
74 -rm -f *.exe
75 -rm -f $(CLEAN)
76
77 demos: $(DEMOS)
78 strip *.exe
79
80 $(DEFFILE): $(DEFDEPS)
81 echo LIBRARY pdcurses > $@
82 echo EXPORTS >> $@
83 cat $(BASEDEF) >> $@
84 ifeq ($(WIDE),Y)
85 cat $(WIDEDEF) >> $@
86 endif
87
88 $(LIBCURSES) : $(LIBDEPS)
89 $(LIBEXE) $(LIBFLAGS) $@ $?
90 -cp pdcurses.a panel.a
91
92 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
93 $(PDCOBJS) : $(PDCURSES_WIN_H)
94 $(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
95 panel.o : $(PANEL_HEADER)
96 terminfo.o: $(TERM_HEADER)
97
98 $(LIBOBJS) : %.o: $(srcdir)/%.c
99 $(CC) -c $(CFLAGS) $<
100
101 $(PDCOBJS) : %.o: $(osdir)/%.c
102 $(CC) -c $(CFLAGS) $<
103
104 firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
105 ptest.exe: %.exe: $(demodir)/%.c
106 $(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)
107
108 tuidemo.exe: tuidemo.o tui.o
109 $(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)
110
111 tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
112 $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
113
114 tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
115 $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
116
117 dist: $(PDCLIBS)
118 echo PDCurses $(VERDOT) for Cygnus Win32 > file_id.diz
119 echo ------------------------------------------ >> file_id.diz
120 echo Public Domain Curses library for >> file_id.diz
121 echo Cygnus GCC for Win32. >> file_id.diz
122 echo Source available in PDCURS$(VER).ZIP >> file_id.diz
123 echo Public Domain. >> file_id.diz
124 zip -9jX pdc$(VER)_cyg_w32 \
125 $(PDCURSES_SRCDIR)/README $(PDCURSES_SRCDIR)/HISTORY \
126 $(PDCURSES_SRCDIR)/curses.h $(PDCURSES_SRCDIR)/panel.h \
127 $(LIBCURSES) $(LIBPANEL) file_id.diz
128 rm file_id.diz
File win32/lccwin32.mak added (mode: 100644) (index 00000000..90c1c894)
1 # Makefile for PDCurses library - WIN32 LCC-Win32
2 #
3 # Usage: make -f lccwin32.mak [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 PDCURSES_SRCDIR = ..
9
10 PDCURSES_CURSES_H = $(PDCURSES_SRCDIR)\curses.h
11 PDCURSES_CURSPRIV_H = $(PDCURSES_SRCDIR)\curspriv.h
12 PDCURSES_HEADERS = $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
13
14 PANEL_HEADER = $(PDCURSES_SRCDIR)\panel.h
15 TERM_HEADER = $(PDCURSES_SRCDIR)\term.h
16
17 srcdir = $(PDCURSES_SRCDIR)\pdcurses
18 osdir = $(PDCURSES_SRCDIR)\win32
19 demodir = $(PDCURSES_SRCDIR)\demos
20
21 PDCURSES_WIN_H = $(osdir)\pdcwin.h
22
23 CC = lcc
24
25 #CFLAGS = -c -g3 -A -ansic
26 CFLAGS = -c -O -A -ansic
27
28 CPPFLAGS = -I$(PDCURSES_SRCDIR) #-DPDC_WIDE -DPDC_FORCE_UTF8
29
30 LINK = lcclnk
31 LIBEXE = lcclib
32
33 LIBCURSES = pdcurses.lib
34
35 BUILD = $(CC) $(CFLAGS) $(CPPFLAGS)
36 PDCLIBS = $(LIBCURSES)
37
38 DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe \
39 firework.exe ptest.exe rain.exe worm.exe
40
41 all: $(PDCLIBS) $(DEMOS)
42
43 clean:
44 -del *.obj
45 -del *.lib
46 -del *.exe
47
48 LIBOBJS = addch.obj addchstr.obj addstr.obj attr.obj beep.obj bkgd.obj \
49 border.obj clear.obj color.obj delch.obj deleteln.obj deprec.obj getch.obj \
50 getstr.obj getyx.obj inch.obj inchstr.obj initscr.obj inopts.obj \
51 insch.obj insstr.obj instr.obj kernel.obj keyname.obj mouse.obj move.obj \
52 outopts.obj overlay.obj pad.obj panel.obj printw.obj refresh.obj \
53 scanw.obj scr_dump.obj scroll.obj slk.obj termattr.obj terminfo.obj \
54 touch.obj util.obj window.obj debug.obj
55
56 PDCOBJS = pdcclip.obj pdcdisp.obj pdcgetsc.obj pdckbd.obj pdcscrn.obj \
57 pdcsetsc.obj pdcutil.obj
58
59 DEMOOBJS = testcurs.obj newdemo.obj xmas.obj tuidemo.obj tui.obj \
60 firework.obj ptest.obj rain.obj worm.obj
61
62 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
63 $(PDCOBJS) : $(PDCURSES_WIN_H)
64 panel.obj ptest.obj: $(PANEL_HEADER)
65 terminfo.obj: $(TERM_HEADER)
66
67 $(DEMOOBJS) : $(PDCURSES_CURSES_H)
68 $(DEMOS) : $(LIBCURSES)
69
70 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
71 $(LIBEXE) /out:$@ $(LIBOBJS) $(PDCOBJS)
72 -copy $(LIBCURSES) panel.lib
73
74 SRCBUILD = $(BUILD) $(srcdir)\$*.c
75 OSBUILD = $(BUILD) $(osdir)\$*.c
76
77 addch.obj: $(srcdir)\addch.c
78 $(SRCBUILD)
79
80 addchstr.obj: $(srcdir)\addchstr.c
81 $(SRCBUILD)
82
83 addstr.obj: $(srcdir)\addstr.c
84 $(SRCBUILD)
85
86 attr.obj: $(srcdir)\attr.c
87 $(SRCBUILD)
88
89 beep.obj: $(srcdir)\beep.c
90 $(SRCBUILD)
91
92 bkgd.obj: $(srcdir)\bkgd.c
93 $(SRCBUILD)
94
95 border.obj: $(srcdir)\border.c
96 $(SRCBUILD)
97
98 clear.obj: $(srcdir)\clear.c
99 $(SRCBUILD)
100
101 color.obj: $(srcdir)\color.c
102 $(SRCBUILD)
103
104 delch.obj: $(srcdir)\delch.c
105 $(SRCBUILD)
106
107 deleteln.obj: $(srcdir)\deleteln.c
108 $(SRCBUILD)
109
110 deprec.obj: $(srcdir)\deprec.c
111 $(SRCBUILD)
112
113 getch.obj: $(srcdir)\getch.c
114 $(SRCBUILD)
115
116 getstr.obj: $(srcdir)\getstr.c
117 $(SRCBUILD)
118
119 getyx.obj: $(srcdir)\getyx.c
120 $(SRCBUILD)
121
122 inch.obj: $(srcdir)\inch.c
123 $(SRCBUILD)
124
125 inchstr.obj: $(srcdir)\inchstr.c
126 $(SRCBUILD)
127
128 initscr.obj: $(srcdir)\initscr.c
129 $(SRCBUILD)
130
131 inopts.obj: $(srcdir)\inopts.c
132 $(SRCBUILD)
133
134 insch.obj: $(srcdir)\insch.c
135 $(SRCBUILD)
136
137 insstr.obj: $(srcdir)\insstr.c
138 $(SRCBUILD)
139
140 instr.obj: $(srcdir)\instr.c
141 $(SRCBUILD)
142
143 kernel.obj: $(srcdir)\kernel.c
144 $(SRCBUILD)
145
146 keyname.obj: $(srcdir)\keyname.c
147 $(SRCBUILD)
148
149 mouse.obj: $(srcdir)\mouse.c
150 $(SRCBUILD)
151
152 move.obj: $(srcdir)\move.c
153 $(SRCBUILD)
154
155 outopts.obj: $(srcdir)\outopts.c
156 $(SRCBUILD)
157
158 overlay.obj: $(srcdir)\overlay.c
159 $(SRCBUILD)
160
161 pad.obj: $(srcdir)\pad.c
162 $(SRCBUILD)
163
164 panel.obj: $(srcdir)\panel.c
165 $(SRCBUILD)
166
167 printw.obj: $(srcdir)\printw.c
168 $(SRCBUILD)
169
170 refresh.obj: $(srcdir)\refresh.c
171 $(SRCBUILD)
172
173 scanw.obj: $(srcdir)\scanw.c
174 $(SRCBUILD)
175
176 scr_dump.obj: $(srcdir)\scr_dump.c
177 $(SRCBUILD)
178
179 scroll.obj: $(srcdir)\scroll.c
180 $(SRCBUILD)
181
182 slk.obj: $(srcdir)\slk.c
183 $(SRCBUILD)
184
185 termattr.obj: $(srcdir)\termattr.c
186 $(SRCBUILD)
187
188 terminfo.obj: $(srcdir)\terminfo.c
189 $(SRCBUILD)
190
191 touch.obj: $(srcdir)\touch.c
192 $(SRCBUILD)
193
194 util.obj: $(srcdir)\util.c
195 $(SRCBUILD)
196
197 window.obj: $(srcdir)\window.c
198 $(SRCBUILD)
199
200 debug.obj: $(srcdir)\debug.c
201 $(SRCBUILD)
202
203 pdcclip.obj: $(osdir)\pdcclip.c
204 $(OSBUILD)
205
206 pdcdisp.obj: $(osdir)\pdcdisp.c
207 $(OSBUILD)
208
209 pdcgetsc.obj: $(osdir)\pdcgetsc.c
210 $(OSBUILD)
211
212 pdckbd.obj: $(osdir)\pdckbd.c
213 $(OSBUILD)
214
215 pdcscrn.obj: $(osdir)\pdcscrn.c
216 $(OSBUILD)
217
218 pdcsetsc.obj: $(osdir)\pdcsetsc.c
219 $(OSBUILD)
220
221 pdcutil.obj: $(osdir)\pdcutil.c
222 $(OSBUILD)
223
224 firework.exe: firework.obj
225 $(LINK) -o $@ firework.obj $(LIBCURSES)
226
227 newdemo.exe: newdemo.obj
228 $(LINK) -o $@ newdemo.obj $(LIBCURSES)
229
230 ptest.exe: ptest.obj
231 $(LINK) -o $@ ptest.obj $(LIBCURSES)
232
233 rain.exe: rain.obj
234 $(LINK) -o $@ rain.obj $(LIBCURSES)
235
236 testcurs.exe: testcurs.obj
237 $(LINK) -o $@ testcurs.obj $(LIBCURSES)
238
239 tuidemo.exe: tuidemo.obj tui.obj
240 $(LINK) -o $@ tuidemo.obj tui.obj $(LIBCURSES)
241
242 worm.exe: worm.obj
243 $(LINK) -o $@ worm.obj $(LIBCURSES)
244
245 xmas.exe: xmas.obj
246 $(LINK) -o $@ xmas.obj $(LIBCURSES)
247
248 firework.obj: $(demodir)\firework.c
249 $(BUILD) $(demodir)\$*.c
250
251 newdemo.obj: $(demodir)\newdemo.c
252 $(BUILD) $(demodir)\$*.c
253
254 ptest.obj: $(demodir)\ptest.c
255 $(BUILD) $(demodir)\$*.c
256
257 rain.obj: $(demodir)\rain.c
258 $(BUILD) $(demodir)\$*.c
259
260 testcurs.obj: $(demodir)\testcurs.c
261 $(BUILD) $(demodir)\$*.c
262
263 tui.obj: $(demodir)\tui.c $(demodir)\tui.h
264 $(BUILD) -I$(demodir) $(demodir)\$*.c
265
266 tuidemo.obj: $(demodir)\tuidemo.c
267 $(BUILD) -I$(demodir) $(demodir)\$*.c
268
269 worm.obj: $(demodir)\worm.c
270 $(BUILD) $(demodir)\$*.c
271
272 xmas.obj: $(demodir)\xmas.c
273 $(BUILD) $(demodir)\$*.c
File win32/mingwin32.mak added (mode: 100644) (index 00000000..7fb17e8f)
1 # GNU MAKE Makefile for PDCurses library - WIN32 MinGW GCC
2 #
3 # Usage: make -f [path\]mingwin32.mak [DEBUG=Y] [DLL=Y] [WIDE=Y] [UTF8=Y] [tgt]
4 #
5 # where tgt can be any of:
6 # [all|demos|pdcurses.a|testcurs.exe...]
7
8 O = o
9
10 ifndef PDCURSES_SRCDIR
11 PDCURSES_SRCDIR = ..
12 endif
13
14 include $(PDCURSES_SRCDIR)/version.mif
15 include $(PDCURSES_SRCDIR)/libobjs.mif
16
17 osdir = $(PDCURSES_SRCDIR)/win32
18
19 PDCURSES_WIN_H = $(osdir)/pdcwin.h
20
21 CC = gcc
22
23 ifeq ($(DEBUG),Y)
24 CFLAGS = -g -Wall -DPDCDEBUG
25 LDFLAGS = -g
26 else
27 CFLAGS = -O2 -Wall
28 LDFLAGS =
29 endif
30
31 CFLAGS += -I$(PDCURSES_SRCDIR)
32
33 BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
34 WIDEDEF = $(PDCURSES_SRCDIR)\exp-wide.def
35
36 DEFDEPS = $(BASEDEF)
37
38 ifeq ($(WIDE),Y)
39 CFLAGS += -DPDC_WIDE
40 DEFDEPS += $(WIDEDEF)
41 endif
42
43 ifeq ($(UTF8),Y)
44 CFLAGS += -DPDC_FORCE_UTF8
45 endif
46
47 DEFFILE = pdcurses.def
48
49 LINK = gcc
50
51 ifeq ($(DLL),Y)
52 CFLAGS += -DPDC_DLL_BUILD
53 LIBEXE = gcc $(DEFFILE)
54 LIBFLAGS = -Wl,--out-implib,pdcurses.a -shared -o
55 LIBCURSES = pdcurses.dll
56 LIBDEPS = $(LIBOBJS) $(PDCOBJS) $(DEFFILE)
57 CLEAN = $(LIBCURSES) *.a $(DEFFILE)
58 else
59 LIBEXE = ar
60 LIBFLAGS = rcv
61 LIBCURSES = pdcurses.a
62 LIBDEPS = $(LIBOBJS) $(PDCOBJS)
63 CLEAN = *.a
64 endif
65
66 .PHONY: all libs clean demos dist
67
68 all: libs demos
69
70 libs: $(LIBCURSES)
71
72 clean:
73 -del *.o
74 -del *.exe
75 -del $(CLEAN)
76
77 demos: $(DEMOS)
78 strip *.exe
79
80 $(DEFFILE): $(DEFDEPS)
81 echo LIBRARY pdcurses > $@
82 echo EXPORTS >> $@
83 type $(BASEDEF) >> $@
84 ifeq ($(WIDE),Y)
85 type $(WIDEDEF) >> $@
86 endif
87
88 $(LIBCURSES) : $(LIBDEPS)
89 $(LIBEXE) $(LIBFLAGS) $@ $?
90 -copy pdcurses.a panel.a
91
92 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
93 $(PDCOBJS) : $(PDCURSES_WIN_H)
94 $(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
95 panel.o : $(PANEL_HEADER)
96 terminfo.o: $(TERM_HEADER)
97
98 $(LIBOBJS) : %.o: $(srcdir)/%.c
99 $(CC) -c $(CFLAGS) $<
100
101 $(PDCOBJS) : %.o: $(osdir)/%.c
102 $(CC) -c $(CFLAGS) $<
103
104 firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
105 ptest.exe: %.exe: $(demodir)/%.c
106 $(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)
107
108 tuidemo.exe: tuidemo.o tui.o
109 $(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)
110
111 tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
112 $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
113
114 tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
115 $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
116
117 PLATFORM1 = MinGW Win32
118 PLATFORM2 = MinGW for Win32
119 ARCNAME = pdc$(VER)_ming_w32
120
121 include $(PDCURSES_SRCDIR)/makedist.mif
File win32/pdcclip.c added (mode: 100644) (index 00000000..35b6bba5)
1 /* Public Domain Curses */
2
3 #include "pdcwin.h"
4
5 RCSID("$Id: pdcclip.c,v 1.30 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: clipboard
10
11 Synopsis:
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 PDC_getclipboard() gets the textual contents of the system's
19 clipboard. This function returns the contents of the clipboard
20 in the contents argument. It is the responsibilitiy of the
21 caller to free the memory returned, via PDC_freeclipboard().
22 The length of the clipboard contents is returned in the length
23 argument.
24
25 PDC_setclipboard copies the supplied text into the system's
26 clipboard, emptying the clipboard prior to the copy.
27
28 PDC_clearclipboard() clears the internal clipboard.
29
30 Return Values:
31 indicator of success/failure of call.
32 PDC_CLIP_SUCCESS the call was successful
33 PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
34 the clipboard contents
35 PDC_CLIP_EMPTY the clipboard contains no text
36 PDC_CLIP_ACCESS_ERROR no clipboard support
37
38 Portability X/Open BSD SYS V
39 PDC_getclipboard - - -
40 PDC_setclipboard - - -
41 PDC_freeclipboard - - -
42 PDC_clearclipboard - - -
43
44 **man-end****************************************************************/
45
46 #ifdef PDC_WIDE
47 # define PDC_TEXT CF_UNICODETEXT
48 #else
49 # define PDC_TEXT CF_OEMTEXT
50 #endif
51
52 int PDC_getclipboard(char **contents, long *length)
53 {
54 HANDLE handle;
55 long len;
56
57 PDC_LOG(("PDC_getclipboard() - called\n"));
58
59 if (!OpenClipboard(NULL))
60 return PDC_CLIP_ACCESS_ERROR;
61
62 if ((handle = GetClipboardData(PDC_TEXT)) == NULL)
63 {
64 CloseClipboard();
65 return PDC_CLIP_EMPTY;
66 }
67
68 #ifdef PDC_WIDE
69 len = wcslen((wchar_t *)handle) * 3;
70 #else
71 len = strlen((char *)handle);
72 #endif
73 *contents = (char *)GlobalAlloc(GMEM_FIXED, len + 1);
74
75 if (!*contents)
76 {
77 CloseClipboard();
78 return PDC_CLIP_MEMORY_ERROR;
79 }
80
81 #ifdef PDC_WIDE
82 len = PDC_wcstombs((char *)*contents, (wchar_t *)handle, len);
83 #else
84 strcpy((char *)*contents, (char *)handle);
85 #endif
86 *length = len;
87 CloseClipboard();
88
89 return PDC_CLIP_SUCCESS;
90 }
91
92 int PDC_setclipboard(const char *contents, long length)
93 {
94 HGLOBAL ptr1;
95 LPTSTR ptr2;
96
97 PDC_LOG(("PDC_setclipboard() - called\n"));
98
99 if (!OpenClipboard(NULL))
100 return PDC_CLIP_ACCESS_ERROR;
101
102 ptr1 = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
103 (length + 1) * sizeof(TCHAR));
104
105 if (!ptr1)
106 return PDC_CLIP_MEMORY_ERROR;
107
108 ptr2 = GlobalLock(ptr1);
109
110 #ifdef PDC_WIDE
111 PDC_mbstowcs((wchar_t *)ptr2, contents, length);
112 #else
113 memcpy((char *)ptr2, contents, length + 1);
114 #endif
115 GlobalUnlock(ptr1);
116 EmptyClipboard();
117
118 if (!SetClipboardData(PDC_TEXT, ptr1))
119 {
120 GlobalFree(ptr1);
121 return PDC_CLIP_ACCESS_ERROR;
122 }
123
124 CloseClipboard();
125 GlobalFree(ptr1);
126
127 return PDC_CLIP_SUCCESS;
128 }
129
130 int PDC_freeclipboard(char *contents)
131 {
132 PDC_LOG(("PDC_freeclipboard() - called\n"));
133
134 GlobalFree(contents);
135 return PDC_CLIP_SUCCESS;
136 }
137
138 int PDC_clearclipboard(void)
139 {
140 PDC_LOG(("PDC_clearclipboard() - called\n"));
141
142 EmptyClipboard();
143
144 return PDC_CLIP_SUCCESS;
145 }
File win32/pdcdisp.c added (mode: 100644) (index 00000000..c2ad8142)
1 /* Public Domain Curses */
2
3 #include "pdcwin.h"
4
5 RCSID("$Id: pdcdisp.c,v 1.47 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <stdlib.h>
8 #include <string.h>
9
10 #ifdef CHTYPE_LONG
11
12 # define A(x) ((chtype)x | A_ALTCHARSET)
13
14 chtype acs_map[128] =
15 {
16 A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
17 A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
18 A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
19 A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
20 ')', '*',
21
22 # ifdef PDC_WIDE
23 0x2192, 0x2190, 0x2191, 0x2193,
24 # else
25 A(0x1a), A(0x1b), A(0x18), A(0x19),
26 # endif
27
28 '/',
29
30 # ifdef PDC_WIDE
31 0x2588,
32 # else
33 0xdb,
34 # endif
35
36 '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
37 '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
38 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
39 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
40
41 # ifdef PDC_WIDE
42 0x2666, 0x2592,
43 # else
44 A(0x04), 0xb1,
45 # endif
46
47 'b', 'c', 'd', 'e',
48
49 # ifdef PDC_WIDE
50 0x00b0, 0x00b1, 0x2591, 0x00a4, 0x2518, 0x2510, 0x250c, 0x2514,
51 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524,
52 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3,
53 0x00b7,
54 # else
55 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d, 0x2d,
56 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3, 0xf2, 0xe3,
57 0xd8, 0x9c, 0xf9,
58 # endif
59
60 A(127)
61 };
62
63 # undef A
64
65 #endif
66
67 /* position hardware cursor at (y, x) */
68
69 void PDC_gotoyx(int row, int col)
70 {
71 COORD coord;
72
73 PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
74 row, col, SP->cursrow, SP->curscol));
75
76 coord.X = col;
77 coord.Y = row;
78
79 SetConsoleCursorPosition(pdc_con_out, coord);
80 }
81
82 /* update the given physical line to look like the corresponding line in
83 curscr */
84
85 void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
86 {
87 CHAR_INFO ci[512];
88 int j;
89 COORD bufSize, bufPos;
90 SMALL_RECT sr;
91
92 PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
93
94 bufPos.X = bufPos.Y = 0;
95
96 bufSize.X = len;
97 bufSize.Y = 1;
98
99 sr.Top = lineno;
100 sr.Bottom = lineno;
101 sr.Left = x;
102 sr.Right = x + len - 1;
103
104 for (j = 0; j < len; j++)
105 {
106 chtype ch = srcp[j];
107
108 ci[j].Attributes = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
109 #ifdef CHTYPE_LONG
110 if (ch & A_ALTCHARSET && !(ch & 0xff80))
111 ch = acs_map[ch & 0x7f];
112 #endif
113 ci[j].Char.UnicodeChar = ch & A_CHARTEXT;
114 }
115
116 WriteConsoleOutput(pdc_con_out, ci, bufSize, bufPos, &sr);
117 }
File win32/pdcgetsc.c added (mode: 100644) (index 00000000..15f0dc5f)
1 /* Public Domain Curses */
2
3 #include "pdcwin.h"
4
5 RCSID("$Id: pdcgetsc.c,v 1.36 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /* get the cursor size/shape */
8
9 int PDC_get_cursor_mode(void)
10 {
11 CONSOLE_CURSOR_INFO ci;
12
13 PDC_LOG(("PDC_get_cursor_mode() - called\n"));
14
15 GetConsoleCursorInfo(pdc_con_out, &ci);
16
17 return ci.dwSize;
18 }
19
20 /* return number of screen rows */
21
22 int PDC_get_rows(void)
23 {
24 CONSOLE_SCREEN_BUFFER_INFO scr;
25
26 PDC_LOG(("PDC_get_rows() - called\n"));
27
28 GetConsoleScreenBufferInfo(pdc_con_out, &scr);
29
30 return scr.srWindow.Bottom - scr.srWindow.Top + 1;
31 }
32
33 /* return number of buffer rows */
34
35 int PDC_get_buffer_rows(void)
36 {
37 CONSOLE_SCREEN_BUFFER_INFO scr;
38
39 PDC_LOG(("PDC_get_buffer_rows() - called\n"));
40
41 GetConsoleScreenBufferInfo(pdc_con_out, &scr);
42
43 return scr.dwSize.Y;
44 }
45
46 /* return width of screen/viewport */
47
48 int PDC_get_columns(void)
49 {
50 CONSOLE_SCREEN_BUFFER_INFO scr;
51
52 PDC_LOG(("PDC_get_columns() - called\n"));
53
54 GetConsoleScreenBufferInfo(pdc_con_out, &scr);
55
56 return scr.srWindow.Right - scr.srWindow.Left + 1;
57 }
File win32/pdckbd.c added (mode: 100644) (index 00000000..1c5b05b0)
1 /* Public Domain Curses */
2
3 #include "pdcwin.h"
4
5 RCSID("$Id: pdckbd.c,v 1.115 2008/07/20 20:12:04 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: pdckbd
10
11 Synopsis:
12 unsigned long PDC_get_input_fd(void);
13
14 Description:
15 PDC_get_input_fd() returns the file descriptor that PDCurses
16 reads its input from. It can be used for select().
17
18 Portability X/Open BSD SYS V
19 PDC_get_input_fd - - -
20
21 **man-end****************************************************************/
22
23 unsigned long pdc_key_modifiers = 0L;
24
25 /* These variables are used to store information about the next
26 Input Event. */
27
28 static INPUT_RECORD save_ip;
29 static MOUSE_STATUS old_mouse_status;
30 static DWORD event_count = 0;
31 static SHORT left_key;
32 static int key_count = 0;
33 static int save_press = 0;
34
35 #define KEV save_ip.Event.KeyEvent
36 #define MEV save_ip.Event.MouseEvent
37
38 /************************************************************************
39 * Table for key code translation of function keys in keypad mode *
40 * These values are for strict IBM keyboard compatibles only *
41 ************************************************************************/
42
43 typedef struct
44 {
45 unsigned short normal;
46 unsigned short shift;
47 unsigned short control;
48 unsigned short alt;
49 unsigned short extended;
50 } KPTAB;
51
52 static KPTAB kptab[] =
53 {
54 {0, 0, 0, 0, 0 }, /* 0 */
55 {0, 0, 0, 0, 0 }, /* 1 VK_LBUTTON */
56 {0, 0, 0, 0, 0 }, /* 2 VK_RBUTTON */
57 {0, 0, 0, 0, 0 }, /* 3 VK_CANCEL */
58 {0, 0, 0, 0, 0 }, /* 4 VK_MBUTTON */
59 {0, 0, 0, 0, 0 }, /* 5 */
60 {0, 0, 0, 0, 0 }, /* 6 */
61 {0, 0, 0, 0, 0 }, /* 7 */
62 {0x08, 0x08, 0x7F, ALT_BKSP, 0 }, /* 8 VK_BACK */
63 {0x09, KEY_BTAB, CTL_TAB, ALT_TAB, 999 }, /* 9 VK_TAB */
64 {0, 0, 0, 0, 0 }, /* 10 */
65 {0, 0, 0, 0, 0 }, /* 11 */
66 {KEY_B2, 0x35, CTL_PAD5, ALT_PAD5, 0 }, /* 12 VK_CLEAR */
67 {0x0D, 0x0D, CTL_ENTER, ALT_ENTER, 1 }, /* 13 VK_RETURN */
68 {0, 0, 0, 0, 0 }, /* 14 */
69 {0, 0, 0, 0, 0 }, /* 15 */
70 {0, 0, 0, 0, 0 }, /* 16 VK_SHIFT HANDLED SEPARATELY */
71 {0, 0, 0, 0, 0 }, /* 17 VK_CONTROL HANDLED SEPARATELY */
72 {0, 0, 0, 0, 0 }, /* 18 VK_MENU HANDLED SEPARATELY */
73 {0, 0, 0, 0, 0 }, /* 19 VK_PAUSE */
74 {0, 0, 0, 0, 0 }, /* 20 VK_CAPITAL HANDLED SEPARATELY */
75 {0, 0, 0, 0, 0 }, /* 21 VK_HANGUL */
76 {0, 0, 0, 0, 0 }, /* 22 */
77 {0, 0, 0, 0, 0 }, /* 23 VK_JUNJA */
78 {0, 0, 0, 0, 0 }, /* 24 VK_FINAL */
79 {0, 0, 0, 0, 0 }, /* 25 VK_HANJA */
80 {0, 0, 0, 0, 0 }, /* 26 */
81 {0x1B, 0x1B, 0x1B, ALT_ESC, 0 }, /* 27 VK_ESCAPE */
82 {0, 0, 0, 0, 0 }, /* 28 VK_CONVERT */
83 {0, 0, 0, 0, 0 }, /* 29 VK_NONCONVERT */
84 {0, 0, 0, 0, 0 }, /* 30 VK_ACCEPT */
85 {0, 0, 0, 0, 0 }, /* 31 VK_MODECHANGE */
86 {0x20, 0x20, 0x20, 0x20, 0 }, /* 32 VK_SPACE */
87 {KEY_A3, 0x39, CTL_PAD9, ALT_PAD9, 3 }, /* 33 VK_PRIOR */
88 {KEY_C3, 0x33, CTL_PAD3, ALT_PAD3, 4 }, /* 34 VK_NEXT */
89 {KEY_C1, 0x31, CTL_PAD1, ALT_PAD1, 5 }, /* 35 VK_END */
90 {KEY_A1, 0x37, CTL_PAD7, ALT_PAD7, 6 }, /* 36 VK_HOME */
91 {KEY_B1, 0x34, CTL_PAD4, ALT_PAD4, 7 }, /* 37 VK_LEFT */
92 {KEY_A2, 0x38, CTL_PAD8, ALT_PAD8, 8 }, /* 38 VK_UP */
93 {KEY_B3, 0x36, CTL_PAD6, ALT_PAD6, 9 }, /* 39 VK_RIGHT */
94 {KEY_C2, 0x32, CTL_PAD2, ALT_PAD2, 10 }, /* 40 VK_DOWN */
95 {0, 0, 0, 0, 0 }, /* 41 VK_SELECT */
96 {0, 0, 0, 0, 0 }, /* 42 VK_PRINT */
97 {0, 0, 0, 0, 0 }, /* 43 VK_EXECUTE */
98 {0, 0, 0, 0, 0 }, /* 44 VK_SNAPSHOT*/
99 {PAD0, 0x30, CTL_PAD0, ALT_PAD0, 11 }, /* 45 VK_INSERT */
100 {PADSTOP, 0x2E, CTL_PADSTOP, ALT_PADSTOP,12 }, /* 46 VK_DELETE */
101 {0, 0, 0, 0, 0 }, /* 47 VK_HELP */
102 {0x30, 0x29, 0, ALT_0, 0 }, /* 48 */
103 {0x31, 0x21, 0, ALT_1, 0 }, /* 49 */
104 {0x32, 0x40, 0, ALT_2, 0 }, /* 50 */
105 {0x33, 0x23, 0, ALT_3, 0 }, /* 51 */
106 {0x34, 0x24, 0, ALT_4, 0 }, /* 52 */
107 {0x35, 0x25, 0, ALT_5, 0 }, /* 53 */
108 {0x36, 0x5E, 0, ALT_6, 0 }, /* 54 */
109 {0x37, 0x26, 0, ALT_7, 0 }, /* 55 */
110 {0x38, 0x2A, 0, ALT_8, 0 }, /* 56 */
111 {0x39, 0x28, 0, ALT_9, 0 }, /* 57 */
112 {0, 0, 0, 0, 0 }, /* 58 */
113 {0, 0, 0, 0, 0 }, /* 59 */
114 {0, 0, 0, 0, 0 }, /* 60 */
115 {0, 0, 0, 0, 0 }, /* 61 */
116 {0, 0, 0, 0, 0 }, /* 62 */
117 {0, 0, 0, 0, 0 }, /* 63 */
118 {0, 0, 0, 0, 0 }, /* 64 */
119 {0x61, 0x41, 0x01, ALT_A, 0 }, /* 65 */
120 {0x62, 0x42, 0x02, ALT_B, 0 }, /* 66 */
121 {0x63, 0x43, 0x03, ALT_C, 0 }, /* 67 */
122 {0x64, 0x44, 0x04, ALT_D, 0 }, /* 68 */
123 {0x65, 0x45, 0x05, ALT_E, 0 }, /* 69 */
124 {0x66, 0x46, 0x06, ALT_F, 0 }, /* 70 */
125 {0x67, 0x47, 0x07, ALT_G, 0 }, /* 71 */
126 {0x68, 0x48, 0x08, ALT_H, 0 }, /* 72 */
127 {0x69, 0x49, 0x09, ALT_I, 0 }, /* 73 */
128 {0x6A, 0x4A, 0x0A, ALT_J, 0 }, /* 74 */
129 {0x6B, 0x4B, 0x0B, ALT_K, 0 }, /* 75 */
130 {0x6C, 0x4C, 0x0C, ALT_L, 0 }, /* 76 */
131 {0x6D, 0x4D, 0x0D, ALT_M, 0 }, /* 77 */
132 {0x6E, 0x4E, 0x0E, ALT_N, 0 }, /* 78 */
133 {0x6F, 0x4F, 0x0F, ALT_O, 0 }, /* 79 */
134 {0x70, 0x50, 0x10, ALT_P, 0 }, /* 80 */
135 {0x71, 0x51, 0x11, ALT_Q, 0 }, /* 81 */
136 {0x72, 0x52, 0x12, ALT_R, 0 }, /* 82 */
137 {0x73, 0x53, 0x13, ALT_S, 0 }, /* 83 */
138 {0x74, 0x54, 0x14, ALT_T, 0 }, /* 84 */
139 {0x75, 0x55, 0x15, ALT_U, 0 }, /* 85 */
140 {0x76, 0x56, 0x16, ALT_V, 0 }, /* 86 */
141 {0x77, 0x57, 0x17, ALT_W, 0 }, /* 87 */
142 {0x78, 0x58, 0x18, ALT_X, 0 }, /* 88 */
143 {0x79, 0x59, 0x19, ALT_Y, 0 }, /* 89 */
144 {0x7A, 0x5A, 0x1A, ALT_Z, 0 }, /* 90 */
145 {0, 0, 0, 0, 0 }, /* 91 VK_LWIN */
146 {0, 0, 0, 0, 0 }, /* 92 VK_RWIN */
147 {0, 0, 0, 0, 0 }, /* 93 VK_APPS */
148 {0, 0, 0, 0, 0 }, /* 94 */
149 {0, 0, 0, 0, 0 }, /* 95 */
150 {0x30, 0, CTL_PAD0, ALT_PAD0, 0 }, /* 96 VK_NUMPAD0 */
151 {0x31, 0, CTL_PAD1, ALT_PAD1, 0 }, /* 97 VK_NUMPAD1 */
152 {0x32, 0, CTL_PAD2, ALT_PAD2, 0 }, /* 98 VK_NUMPAD2 */
153 {0x33, 0, CTL_PAD3, ALT_PAD3, 0 }, /* 99 VK_NUMPAD3 */
154 {0x34, 0, CTL_PAD4, ALT_PAD4, 0 }, /* 100 VK_NUMPAD4 */
155 {0x35, 0, CTL_PAD5, ALT_PAD5, 0 }, /* 101 VK_NUMPAD5 */
156 {0x36, 0, CTL_PAD6, ALT_PAD6, 0 }, /* 102 VK_NUMPAD6 */
157 {0x37, 0, CTL_PAD7, ALT_PAD7, 0 }, /* 103 VK_NUMPAD7 */
158 {0x38, 0, CTL_PAD8, ALT_PAD8, 0 }, /* 104 VK_NUMPAD8 */
159 {0x39, 0, CTL_PAD9, ALT_PAD9, 0 }, /* 105 VK_NUMPAD9 */
160 {PADSTAR, SHF_PADSTAR,CTL_PADSTAR, ALT_PADSTAR,999 }, /* 106 VK_MULTIPLY*/
161 {PADPLUS, SHF_PADPLUS,CTL_PADPLUS, ALT_PADPLUS,999 }, /* 107 VK_ADD */
162 {0, 0, 0, 0, 0 }, /* 108 VK_SEPARATOR */
163 {PADMINUS, SHF_PADMINUS,CTL_PADMINUS,ALT_PADMINUS,999}, /* 109 VK_SUBTRACT*/
164 {0x2E, 0, CTL_PADSTOP, ALT_PADSTOP,0 }, /* 110 VK_DECIMAL */
165 {PADSLASH, SHF_PADSLASH,CTL_PADSLASH,ALT_PADSLASH,2 }, /* 111 VK_DIVIDE */
166 {KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37), 0 }, /* 112 VK_F1 */
167 {KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38), 0 }, /* 113 VK_F2 */
168 {KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39), 0 }, /* 114 VK_F3 */
169 {KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40), 0 }, /* 115 VK_F4 */
170 {KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41), 0 }, /* 116 VK_F5 */
171 {KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42), 0 }, /* 117 VK_F6 */
172 {KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43), 0 }, /* 118 VK_F7 */
173 {KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44), 0 }, /* 119 VK_F8 */
174 {KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45), 0 }, /* 120 VK_F9 */
175 {KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46), 0 }, /* 121 VK_F10 */
176 {KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47), 0 }, /* 122 VK_F11 */
177 {KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48), 0 }, /* 123 VK_F12 */
178
179 /* 124 through 218 */
180
181 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
182 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
183 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
184 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
185 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
186 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
187 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
188 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
189 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
190 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
191 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
192 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
193 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
194 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
195 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
196 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
197 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
198 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
199 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
200 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
201 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
202 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
203 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
204 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
205
206 {0x5B, 0x7B, 0x1B, ALT_LBRACKET,0 }, /* 219 */
207 {0x5C, 0x7C, 0x1C, ALT_BSLASH, 0 }, /* 220 */
208 {0x5D, 0x7D, 0x1D, ALT_RBRACKET,0 }, /* 221 */
209 {0, 0, 0x27, ALT_FQUOTE, 0 }, /* 222 */
210 {0, 0, 0, 0, 0 }, /* 223 */
211 {0, 0, 0, 0, 0 }, /* 224 */
212 {0, 0, 0, 0, 0 } /* 225 */
213 };
214
215 static KPTAB ext_kptab[] =
216 {
217 {0, 0, 0, 0, }, /* MUST BE EMPTY */
218 {PADENTER, SHF_PADENTER, CTL_PADENTER, ALT_PADENTER}, /* 13 */
219 {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 111 */
220 {KEY_PPAGE, KEY_SPREVIOUS, CTL_PGUP, ALT_PGUP }, /* 33 */
221 {KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN }, /* 34 */
222 {KEY_END, KEY_SEND, CTL_END, ALT_END }, /* 35 */
223 {KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME }, /* 36 */
224 {KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT }, /* 37 */
225 {KEY_UP, KEY_SUP, CTL_UP, ALT_UP }, /* 38 */
226 {KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT }, /* 39 */
227 {KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN }, /* 40 */
228 {KEY_IC, KEY_SIC, CTL_INS, ALT_INS }, /* 45 */
229 {KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL }, /* 46 */
230 {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 191 */
231 };
232
233 /* End of kptab[] */
234
235 unsigned long PDC_get_input_fd(void)
236 {
237 PDC_LOG(("PDC_get_input_fd() - called\n"));
238
239 return 0L;
240 }
241
242 void PDC_set_keyboard_binary(bool on)
243 {
244 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
245 }
246
247 /* check if a key or mouse event is waiting */
248
249 bool PDC_check_key(void)
250 {
251 if (key_count > 0)
252 return TRUE;
253
254 GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
255
256 return (event_count != 0);
257 }
258
259 /* _get_key_count returns 0 if save_ip doesn't contain an event which
260 should be passed back to the user. This function filters "useless"
261 events.
262
263 The function returns the number of keys waiting. This may be > 1
264 if the repetition of real keys pressed so far are > 1.
265
266 Returns 0 on NUMLOCK, CAPSLOCK, SCROLLLOCK.
267
268 Returns 1 for SHIFT, ALT, CTRL only if no other key has been pressed
269 in between, and SP->return_key_modifiers is set; these are returned
270 on keyup.
271
272 Normal keys are returned on keydown only. The number of repetitions
273 are returned. Dead keys (diacritics) are omitted. See below for a
274 description.
275 */
276
277 static int _get_key_count(void)
278 {
279 int num_keys = 0, vk;
280
281 PDC_LOG(("_get_key_count() - called\n"));
282
283 vk = KEV.wVirtualKeyCode;
284
285 if (KEV.bKeyDown)
286 {
287 /* key down */
288
289 save_press = 0;
290
291 if (vk == VK_CAPITAL || vk == VK_NUMLOCK || vk == VK_SCROLL)
292 {
293 /* throw away these modifiers */
294 }
295 else if (vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU)
296 {
297 /* These keys are returned on keyup only. */
298
299 save_press = vk;
300 switch (vk)
301 {
302 case VK_SHIFT:
303 left_key = GetKeyState(VK_LSHIFT);
304 break;
305 case VK_CONTROL:
306 left_key = GetKeyState(VK_LCONTROL);
307 break;
308 case VK_MENU:
309 left_key = GetKeyState(VK_LMENU);
310 }
311 }
312 else
313 {
314 /* Check for diacritics. These are dead keys. Some locales
315 have modified characters like umlaut-a, which is an "a"
316 with two dots on it. In some locales you have to press a
317 special key (the dead key) immediately followed by the
318 "a" to get a composed umlaut-a. The special key may have
319 a normal meaning with different modifiers. */
320
321 if (KEV.uChar.UnicodeChar || !(MapVirtualKey(vk, 2) & 0x80000000))
322 num_keys = KEV.wRepeatCount;
323 }
324 }
325 else
326 {
327 /* key up */
328
329 /* Only modifier keys or the results of ALT-numpad entry are
330 returned on keyup */
331
332 if ((vk == VK_MENU && KEV.uChar.UnicodeChar) ||
333 ((vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU) &&
334 vk == save_press))
335 {
336 save_press = 0;
337 num_keys = 1;
338 }
339 }
340
341 PDC_LOG(("_get_key_count() - returning: num_keys %d\n", num_keys));
342
343 return num_keys;
344 }
345
346 /* _process_key_event returns -1 if the key in save_ip should be
347 ignored. Otherwise it returns the keycode which should be returned
348 by PDC_get_key(). save_ip must be a key event.
349
350 CTRL-ALT support has been disabled, when is it emitted plainly? */
351
352 static int _process_key_event(void)
353 {
354 int key = (unsigned short)KEV.uChar.UnicodeChar;
355 WORD vk = KEV.wVirtualKeyCode;
356 DWORD state = KEV.dwControlKeyState;
357
358 int idx;
359 BOOL enhanced;
360
361 SP->key_code = TRUE;
362
363 /* Save the key modifiers if required. Do this first to allow to
364 detect e.g. a pressed CTRL key after a hit of NUMLOCK. */
365
366 if (SP->save_key_modifiers)
367 {
368 if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
369 pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
370
371 if (state & SHIFT_PRESSED)
372 pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
373
374 if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
375 pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
376
377 if (state & NUMLOCK_ON)
378 pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
379 }
380
381 /* Handle modifier keys hit by themselves */
382
383 switch (vk)
384 {
385 case VK_SHIFT: /* shift */
386 if (!SP->return_key_modifiers)
387 return -1;
388
389 return (left_key & 0x8000) ? KEY_SHIFT_L : KEY_SHIFT_R;
390
391 case VK_CONTROL: /* control */
392 if (!SP->return_key_modifiers)
393 return -1;
394
395 return (left_key & 0x8000) ? KEY_CONTROL_L : KEY_CONTROL_R;
396
397 case VK_MENU: /* alt */
398 if (!key)
399 {
400 if (!SP->return_key_modifiers)
401 return -1;
402
403 return (left_key & 0x8000) ? KEY_ALT_L : KEY_ALT_R;
404 }
405 }
406
407 /* The system may emit Ascii or Unicode characters depending on
408 whether ReadConsoleInputA or ReadConsoleInputW is used.
409
410 Normally, if key != 0 then the system did the translation
411 successfully. But this is not true for LEFT_ALT (different to
412 RIGHT_ALT). In case of LEFT_ALT we can get key != 0. So
413 check for this first. */
414
415 if (key && ( !(state & LEFT_ALT_PRESSED) ||
416 (state & RIGHT_ALT_PRESSED) ))
417 {
418 /* This code should catch all keys returning a printable
419 character. Characters above 0x7F should be returned as
420 positive codes. But if'ndef NUMKEYPAD we have to return
421 extended keycodes for keypad codes. */
422
423 #ifndef NUMKEYPAD
424 if (kptab[vk].extended == 0)
425 #endif
426 {
427 SP->key_code = FALSE;
428 return key;
429 }
430 }
431
432 /* This case happens if a functional key has been entered. */
433
434 if ((state & ENHANCED_KEY) && (kptab[vk].extended != 999))
435 {
436 enhanced = TRUE;
437 idx = kptab[vk].extended;
438 }
439 else
440 {
441 enhanced = FALSE;
442 idx = vk;
443 }
444
445 if (state & SHIFT_PRESSED)
446 key = enhanced ? ext_kptab[idx].shift : kptab[idx].shift;
447
448 else if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
449 key = enhanced ? ext_kptab[idx].control : kptab[idx].control;
450
451 else if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
452 key = enhanced ? ext_kptab[idx].alt : kptab[idx].alt;
453
454 else
455 key = enhanced ? ext_kptab[idx].normal : kptab[idx].normal;
456
457 if (key < KEY_CODE_YES)
458 SP->key_code = FALSE;
459
460 return key;
461 }
462
463 static int _process_mouse_event(void)
464 {
465 static const DWORD button_mask[] = {1, 4, 2};
466 short action, shift_flags = 0;
467 int i;
468
469 save_press = 0;
470 SP->key_code = TRUE;
471
472 memset(&pdc_mouse_status, 0, sizeof(MOUSE_STATUS));
473
474 /* Handle scroll wheel */
475
476 if (MEV.dwEventFlags == 4)
477 {
478 pdc_mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ?
479 PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
480
481 pdc_mouse_status.x = -1;
482 pdc_mouse_status.y = -1;
483
484 memset(&old_mouse_status, 0, sizeof(old_mouse_status));
485
486 return KEY_MOUSE;
487 }
488
489 action = (MEV.dwEventFlags == 2) ? BUTTON_DOUBLE_CLICKED :
490 ((MEV.dwEventFlags == 1) ? BUTTON_MOVED : BUTTON_PRESSED);
491
492 for (i = 0; i < 3; i++)
493 pdc_mouse_status.button[i] =
494 (MEV.dwButtonState & button_mask[i]) ? action : 0;
495
496 if (action == BUTTON_PRESSED && MEV.dwButtonState & 7 && SP->mouse_wait)
497 {
498 /* Check for a click -- a PRESS followed immediately by a release */
499
500 if (!event_count)
501 {
502 napms(SP->mouse_wait);
503
504 GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
505 }
506
507 if (event_count)
508 {
509 INPUT_RECORD ip;
510 DWORD count;
511 bool have_click = FALSE;
512
513 PeekConsoleInput(pdc_con_in, &ip, 1, &count);
514
515 for (i = 0; i < 3; i++)
516 {
517 if (pdc_mouse_status.button[i] == BUTTON_PRESSED &&
518 !(ip.Event.MouseEvent.dwButtonState & button_mask[i]))
519 {
520 pdc_mouse_status.button[i] = BUTTON_CLICKED;
521 have_click = TRUE;
522 }
523 }
524
525 /* If a click was found, throw out the event */
526
527 if (have_click)
528 ReadConsoleInput(pdc_con_in, &ip, 1, &count);
529 }
530 }
531
532 pdc_mouse_status.x = MEV.dwMousePosition.X;
533 pdc_mouse_status.y = MEV.dwMousePosition.Y;
534
535 pdc_mouse_status.changes = 0;
536
537 for (i = 0; i < 3; i++)
538 {
539 if (old_mouse_status.button[i] != pdc_mouse_status.button[i])
540 pdc_mouse_status.changes |= (1 << i);
541
542 if (pdc_mouse_status.button[i] == BUTTON_MOVED)
543 {
544 /* Discard non-moved "moves" */
545
546 if (pdc_mouse_status.x == old_mouse_status.x &&
547 pdc_mouse_status.y == old_mouse_status.y)
548 return -1;
549
550 /* Motion events always flag the button as changed */
551
552 pdc_mouse_status.changes |= (1 << i);
553 pdc_mouse_status.changes |= PDC_MOUSE_MOVED;
554 break;
555 }
556 }
557
558 old_mouse_status = pdc_mouse_status;
559
560 /* Treat click events as release events for comparison purposes */
561
562 for (i = 0; i < 3; i++)
563 {
564 if (old_mouse_status.button[i] == BUTTON_CLICKED ||
565 old_mouse_status.button[i] == BUTTON_DOUBLE_CLICKED)
566 old_mouse_status.button[i] = BUTTON_RELEASED;
567 }
568
569 /* Check for SHIFT/CONTROL/ALT */
570
571 if (MEV.dwControlKeyState & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
572 shift_flags |= BUTTON_ALT;
573
574 if (MEV.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
575 shift_flags |= BUTTON_CONTROL;
576
577 if (MEV.dwControlKeyState & SHIFT_PRESSED)
578 shift_flags |= BUTTON_SHIFT;
579
580 if (shift_flags)
581 {
582 for (i = 0; i < 3; i++)
583 {
584 if (pdc_mouse_status.changes & (1 << i))
585 pdc_mouse_status.button[i] |= shift_flags;
586 }
587 }
588
589 return KEY_MOUSE;
590 }
591
592 /* return the next available key or mouse event */
593
594 int PDC_get_key(void)
595 {
596 pdc_key_modifiers = 0L;
597
598 if (!key_count)
599 {
600 DWORD count;
601
602 ReadConsoleInput(pdc_con_in, &save_ip, 1, &count);
603 event_count--;
604
605 if (save_ip.EventType == MOUSE_EVENT)
606 key_count = 1;
607 else if (save_ip.EventType == KEY_EVENT)
608 key_count = _get_key_count();
609 }
610
611 if (key_count)
612 {
613 key_count--;
614
615 switch (save_ip.EventType)
616 {
617 case KEY_EVENT:
618 return _process_key_event();
619
620 case MOUSE_EVENT:
621 return _process_mouse_event();
622 }
623 }
624
625 return -1;
626 }
627
628 /* discard any pending keyboard or mouse input -- this is the core
629 routine for flushinp() */
630
631 void PDC_flushinp(void)
632 {
633 PDC_LOG(("PDC_flushinp() - called\n"));
634
635 FlushConsoleInputBuffer(pdc_con_in);
636 }
637
638 int PDC_mouse_set(void)
639 {
640 /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear
641 all other flags, including the extended flags;
642 If turning off the mouse: Set QuickEdit Mode to the status it
643 had on startup, and clear all other flags */
644
645 SetConsoleMode(pdc_con_in, SP->_trap_mbe ?
646 (ENABLE_MOUSE_INPUT|0x0080) : (pdc_quick_edit|0x0080));
647
648 memset(&old_mouse_status, 0, sizeof(old_mouse_status));
649
650 return OK;
651 }
652
653 int PDC_modifiers_set(void)
654 {
655 return OK;
656 }
File win32/pdcscrn.c added (mode: 100644) (index 00000000..b48ddaaf)
1 /* Public Domain Curses */
2
3 #include "pdcwin.h"
4
5 RCSID("$Id: pdcscrn.c,v 1.92 2008/07/20 20:12:04 wmcbrine Exp $")
6
7 #ifdef CHTYPE_LONG
8 # define PDC_OFFSET 32
9 #else
10 # define PDC_OFFSET 8
11 #endif
12
13 /* COLOR_PAIR to attribute encoding table. */
14
15 unsigned char *pdc_atrtab = (unsigned char *)NULL;
16
17 HANDLE pdc_con_out = INVALID_HANDLE_VALUE;
18 HANDLE pdc_con_in = INVALID_HANDLE_VALUE;
19
20 DWORD pdc_quick_edit;
21
22 static short curstoreal[16], realtocurs[16] =
23 {
24 COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
25 COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
26 COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
27 COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
28 };
29
30 enum { PDC_RESTORE_NONE, PDC_RESTORE_BUFFER, PDC_RESTORE_WINDOW };
31
32 /* Struct for storing console registry keys, and for use with the
33 undocumented WM_SETCONSOLEINFO message. Originally by James Brown,
34 www.catch22.net. */
35
36 static struct
37 {
38 ULONG Length;
39 COORD ScreenBufferSize;
40 COORD WindowSize;
41 ULONG WindowPosX;
42 ULONG WindowPosY;
43
44 COORD FontSize;
45 ULONG FontFamily;
46 ULONG FontWeight;
47 WCHAR FaceName[32];
48
49 ULONG CursorSize;
50 ULONG FullScreen;
51 ULONG QuickEdit;
52 ULONG AutoPosition;
53 ULONG InsertMode;
54
55 USHORT ScreenColors;
56 USHORT PopupColors;
57 ULONG HistoryNoDup;
58 ULONG HistoryBufferSize;
59 ULONG NumberOfHistoryBuffers;
60
61 COLORREF ColorTable[16];
62
63 ULONG CodePage;
64 HWND Hwnd;
65
66 WCHAR ConsoleTitle[0x100];
67 } console_info;
68
69 static CONSOLE_SCREEN_BUFFER_INFO orig_scr;
70
71 static CHAR_INFO *ci_save = NULL;
72 static DWORD old_console_mode = 0;
73
74 static bool is_nt;
75
76 static HWND _find_console_handle(void)
77 {
78 TCHAR orgtitle[1024], temptitle[1024];
79 HWND wnd;
80
81 GetConsoleTitle(orgtitle, 1024);
82
83 wsprintf(temptitle, TEXT("%d/%d"), GetTickCount(), GetCurrentProcessId());
84 SetConsoleTitle(temptitle);
85
86 Sleep(40);
87
88 wnd = FindWindow(NULL, temptitle);
89
90 SetConsoleTitle(orgtitle);
91
92 return wnd;
93 }
94
95 /* Undocumented console message */
96
97 #define WM_SETCONSOLEINFO (WM_USER + 201)
98
99 /* Wrapper around WM_SETCONSOLEINFO. We need to create the necessary
100 section (file-mapping) object in the context of the process which
101 owns the console, before posting the message. Originally by JB. */
102
103 static void _set_console_info(void)
104 {
105 CONSOLE_SCREEN_BUFFER_INFO csbi;
106 CONSOLE_CURSOR_INFO cci;
107 DWORD dwConsoleOwnerPid;
108 HANDLE hProcess;
109 HANDLE hSection, hDupSection;
110 PVOID ptrView;
111
112 /* Each-time initialization for console_info */
113
114 GetConsoleCursorInfo(pdc_con_out, &cci);
115 console_info.CursorSize = cci.dwSize;
116
117 GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
118 console_info.ScreenBufferSize = csbi.dwSize;
119
120 console_info.WindowSize.X = csbi.srWindow.Right - csbi.srWindow.Left + 1;
121 console_info.WindowSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
122
123 console_info.WindowPosX = csbi.srWindow.Left;
124 console_info.WindowPosY = csbi.srWindow.Top;
125
126 /* Open the process which "owns" the console */
127
128 GetWindowThreadProcessId(console_info.Hwnd, &dwConsoleOwnerPid);
129
130 hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwConsoleOwnerPid);
131
132 /* Create a SECTION object backed by page-file, then map a view of
133 this section into the owner process so we can write the contents
134 of the CONSOLE_INFO buffer into it */
135
136 hSection = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE,
137 0, sizeof(console_info), 0);
138
139 /* Copy our console structure into the section-object */
140
141 ptrView = MapViewOfFile(hSection, FILE_MAP_WRITE|FILE_MAP_READ,
142 0, 0, sizeof(console_info));
143
144 memcpy(ptrView, &console_info, sizeof(console_info));
145
146 UnmapViewOfFile(ptrView);
147
148 /* Map the memory into owner process */
149
150 DuplicateHandle(GetCurrentProcess(), hSection, hProcess, &hDupSection,
151 0, FALSE, DUPLICATE_SAME_ACCESS);
152
153 /* Send console window the "update" message */
154
155 SendMessage(console_info.Hwnd, WM_SETCONSOLEINFO, (WPARAM)hDupSection, 0);
156
157 CloseHandle(hSection);
158 CloseHandle(hProcess);
159 }
160
161 /* One-time initialization for console_info -- color table and font info
162 from the registry; other values from functions. */
163
164 static void _init_console_info(void)
165 {
166 DWORD scrnmode, len;
167 HKEY reghnd;
168 int i;
169
170 console_info.Hwnd = _find_console_handle();
171 console_info.Length = sizeof(console_info);
172
173 GetConsoleMode(pdc_con_in, &scrnmode);
174 console_info.QuickEdit = !!(scrnmode & 0x0040);
175 console_info.InsertMode = !!(scrnmode & 0x0020);
176
177 console_info.FullScreen = FALSE;
178 console_info.AutoPosition = 0x10000;
179 console_info.ScreenColors = SP->orig_back << 4 | SP->orig_fore;
180 console_info.PopupColors = 0xf5;
181
182 console_info.HistoryNoDup = FALSE;
183 console_info.HistoryBufferSize = 50;
184 console_info.NumberOfHistoryBuffers = 4;
185
186 console_info.CodePage = GetConsoleOutputCP();
187
188 RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Console"), 0,
189 KEY_QUERY_VALUE, &reghnd);
190
191 len = sizeof(DWORD);
192
193 /* Default color table */
194
195 for (i = 0; i < 16; i++)
196 {
197 char tname[13];
198
199 sprintf(tname, "ColorTable%02d", i);
200 RegQueryValueExA(reghnd, tname, NULL, NULL,
201 (LPBYTE)(&(console_info.ColorTable[i])), &len);
202 }
203
204 /* Font info */
205
206 RegQueryValueEx(reghnd, TEXT("FontSize"), NULL, NULL,
207 (LPBYTE)(&console_info.FontSize), &len);
208 RegQueryValueEx(reghnd, TEXT("FontFamily"), NULL, NULL,
209 (LPBYTE)(&console_info.FontFamily), &len);
210 RegQueryValueEx(reghnd, TEXT("FontWeight"), NULL, NULL,
211 (LPBYTE)(&console_info.FontWeight), &len);
212
213 len = sizeof(WCHAR) * 32;
214 RegQueryValueExW(reghnd, L"FaceName", NULL, NULL,
215 (LPBYTE)(console_info.FaceName), &len);
216
217 RegCloseKey(reghnd);
218 }
219
220 /* close the physical screen -- may restore the screen to its state
221 before PDC_scr_open(); miscellaneous cleanup */
222
223 void PDC_scr_close(void)
224 {
225 COORD origin;
226 SMALL_RECT rect;
227
228 PDC_LOG(("PDC_scr_close() - called\n"));
229
230 PDC_reset_shell_mode();
231
232 if (SP->_restore != PDC_RESTORE_NONE)
233 {
234 if (SP->_restore == PDC_RESTORE_WINDOW)
235 {
236 rect.Top = orig_scr.srWindow.Top;
237 rect.Left = orig_scr.srWindow.Left;
238 rect.Bottom = orig_scr.srWindow.Bottom;
239 rect.Right = orig_scr.srWindow.Right;
240 }
241 else /* PDC_RESTORE_BUFFER */
242 {
243 rect.Top = rect.Left = 0;
244 rect.Bottom = orig_scr.dwSize.Y - 1;
245 rect.Right = orig_scr.dwSize.X - 1;
246 }
247
248 origin.X = origin.Y = 0;
249
250 if (!WriteConsoleOutput(pdc_con_out, ci_save, orig_scr.dwSize,
251 origin, &rect))
252 return;
253 }
254
255 if (SP->visibility != 1)
256 curs_set(1);
257
258 /* Position cursor to the bottom left of the screen. */
259
260 PDC_gotoyx(PDC_get_buffer_rows() - 2, 0);
261 }
262
263 void PDC_scr_free(void)
264 {
265 if (SP)
266 free(SP);
267 if (pdc_atrtab)
268 free(pdc_atrtab);
269
270 pdc_atrtab = (unsigned char *)NULL;
271 }
272
273 /* open the physical screen -- allocate SP, miscellaneous intialization,
274 and may save the existing screen for later restoration */
275
276 int PDC_scr_open(int argc, char **argv)
277 {
278 COORD bufsize, origin;
279 SMALL_RECT rect;
280 const char *str;
281 CONSOLE_SCREEN_BUFFER_INFO csbi;
282 int i;
283
284 PDC_LOG(("PDC_scr_open() - called\n"));
285
286 SP = calloc(1, sizeof(SCREEN));
287 pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
288
289 if (!SP || !pdc_atrtab)
290 return ERR;
291
292 for (i = 0; i < 16; i++)
293 curstoreal[realtocurs[i]] = i;
294
295 pdc_con_out = GetStdHandle(STD_OUTPUT_HANDLE);
296 pdc_con_in = GetStdHandle(STD_INPUT_HANDLE);
297
298 if (GetFileType(pdc_con_in) != FILE_TYPE_CHAR)
299 {
300 fprintf(stderr, "\nRedirection is not supported.\n");
301 exit(1);
302 }
303
304 is_nt = !(GetVersion() & 0x80000000);
305
306 GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
307 GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr);
308 GetConsoleMode(pdc_con_in, &old_console_mode);
309
310 /* preserve QuickEdit Mode setting for use in PDC_mouse_set() when
311 the mouse is not enabled -- other console input settings are
312 cleared */
313
314 pdc_quick_edit = old_console_mode & 0x0040;
315
316 SP->lines = (str = getenv("LINES")) ? atoi(str) : PDC_get_rows();
317 SP->cols = (str = getenv("COLS")) ? atoi(str) : PDC_get_columns();
318
319 SP->mouse_wait = PDC_CLICK_PERIOD;
320 SP->audible = TRUE;
321
322 if (SP->lines < 2 || SP->lines > csbi.dwMaximumWindowSize.Y)
323 {
324 fprintf(stderr, "LINES value must be >= 2 and <= %d: got %d\n",
325 csbi.dwMaximumWindowSize.Y, SP->lines);
326
327 return ERR;
328 }
329
330 if (SP->cols < 2 || SP->cols > csbi.dwMaximumWindowSize.X)
331 {
332 fprintf(stderr, "COLS value must be >= 2 and <= %d: got %d\n",
333 csbi.dwMaximumWindowSize.X, SP->cols);
334
335 return ERR;
336 }
337
338 SP->orig_fore = csbi.wAttributes & 0x0f;
339 SP->orig_back = (csbi.wAttributes & 0xf0) >> 4;
340
341 SP->orig_attr = TRUE;
342
343 SP->_restore = PDC_RESTORE_NONE;
344
345 if (getenv("PDC_RESTORE_SCREEN"))
346 {
347 /* Attempt to save the complete console buffer */
348
349 ci_save = malloc(orig_scr.dwSize.X * orig_scr.dwSize.Y *
350 sizeof(CHAR_INFO));
351
352 if (!ci_save)
353 {
354 PDC_LOG(("PDC_scr_open() - malloc failure (1)\n"));
355
356 return ERR;
357 }
358
359 bufsize.X = orig_scr.dwSize.X;
360 bufsize.Y = orig_scr.dwSize.Y;
361
362 origin.X = origin.Y = 0;
363
364 rect.Top = rect.Left = 0;
365 rect.Bottom = orig_scr.dwSize.Y - 1;
366 rect.Right = orig_scr.dwSize.X - 1;
367
368 if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize, origin, &rect))
369 {
370 /* We can't save the complete buffer, so try and save just
371 the displayed window */
372
373 free(ci_save);
374 ci_save = NULL;
375
376 bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
377 bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
378
379 ci_save = malloc(bufsize.X * bufsize.Y * sizeof(CHAR_INFO));
380
381 if (!ci_save)
382 {
383 PDC_LOG(("PDC_scr_open() - malloc failure (2)\n"));
384
385 return ERR;
386 }
387
388 origin.X = origin.Y = 0;
389
390 rect.Top = orig_scr.srWindow.Top;
391 rect.Left = orig_scr.srWindow.Left;
392 rect.Bottom = orig_scr.srWindow.Bottom;
393 rect.Right = orig_scr.srWindow.Right;
394
395 if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize,
396 origin, &rect))
397 {
398 #ifdef PDCDEBUG
399 CHAR LastError[256];
400
401 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL,
402 GetLastError(), MAKELANGID(LANG_NEUTRAL,
403 SUBLANG_DEFAULT), LastError, 256, NULL);
404
405 PDC_LOG(("PDC_scr_open() - %s\n", LastError));
406 #endif
407 free(ci_save);
408 ci_save = NULL;
409
410 return ERR;
411 }
412
413 SP->_restore = PDC_RESTORE_WINDOW;
414 }
415 else
416 SP->_restore = PDC_RESTORE_BUFFER;
417 }
418
419 SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
420
421 PDC_reset_prog_mode();
422
423 SP->mono = FALSE;
424
425 return OK;
426 }
427
428 /* Calls SetConsoleWindowInfo with the given parameters, but fits them
429 if a scoll bar shrinks the maximum possible value. The rectangle
430 must at least fit in a half-sized window. */
431
432 static BOOL _fit_console_window(HANDLE con_out, CONST SMALL_RECT *rect)
433 {
434 SMALL_RECT run;
435 SHORT mx, my;
436
437 if (SetConsoleWindowInfo(con_out, TRUE, rect))
438 return TRUE;
439
440 run = *rect;
441 run.Right /= 2;
442 run.Bottom /= 2;
443
444 mx = run.Right;
445 my = run.Bottom;
446
447 if (!SetConsoleWindowInfo(con_out, TRUE, &run))
448 return FALSE;
449
450 for (run.Right = rect->Right; run.Right >= mx; run.Right--)
451 if (SetConsoleWindowInfo(con_out, TRUE, &run))
452 break;
453
454 if (run.Right < mx)
455 return FALSE;
456
457 for (run.Bottom = rect->Bottom; run.Bottom >= my; run.Bottom--)
458 if (SetConsoleWindowInfo(con_out, TRUE, &run))
459 return TRUE;
460
461 return FALSE;
462 }
463
464 /* the core of resize_term() */
465
466 int PDC_resize_screen(int nlines, int ncols)
467 {
468 SMALL_RECT rect;
469 COORD size, max;
470
471 if (nlines < 2 || ncols < 2)
472 return ERR;
473
474 max = GetLargestConsoleWindowSize(pdc_con_out);
475
476 rect.Left = rect.Top = 0;
477 rect.Right = ncols - 1;
478
479 if (rect.Right > max.X)
480 rect.Right = max.X;
481
482 rect.Bottom = nlines - 1;
483
484 if (rect.Bottom > max.Y)
485 rect.Bottom = max.Y;
486
487 size.X = rect.Right + 1;
488 size.Y = rect.Bottom + 1;
489
490 _fit_console_window(pdc_con_out, &rect);
491 SetConsoleScreenBufferSize(pdc_con_out, size);
492 _fit_console_window(pdc_con_out, &rect);
493 SetConsoleScreenBufferSize(pdc_con_out, size);
494 SetConsoleActiveScreenBuffer(pdc_con_out);
495
496 return OK;
497 }
498
499 void PDC_reset_prog_mode(void)
500 {
501 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
502
503 if (is_nt)
504 {
505 COORD bufsize;
506 SMALL_RECT rect;
507
508 bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
509 bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
510
511 rect.Top = rect.Left = 0;
512 rect.Bottom = bufsize.Y - 1;
513 rect.Right = bufsize.X - 1;
514
515 SetConsoleScreenBufferSize(pdc_con_out, bufsize);
516 SetConsoleWindowInfo(pdc_con_out, TRUE, &rect);
517 SetConsoleScreenBufferSize(pdc_con_out, bufsize);
518 SetConsoleActiveScreenBuffer(pdc_con_out);
519 }
520
521 PDC_mouse_set();
522 }
523
524 void PDC_reset_shell_mode(void)
525 {
526 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
527
528 if (is_nt)
529 {
530 SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
531 SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
532 SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
533 SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
534 SetConsoleActiveScreenBuffer(pdc_con_out);
535 }
536
537 SetConsoleMode(pdc_con_in, old_console_mode);
538 }
539
540 void PDC_restore_screen_mode(int i)
541 {
542 }
543
544 void PDC_save_screen_mode(int i)
545 {
546 }
547
548 void PDC_init_pair(short pair, short fg, short bg)
549 {
550 unsigned char att, temp_bg;
551 chtype i;
552
553 fg = curstoreal[fg];
554 bg = curstoreal[bg];
555
556 for (i = 0; i < PDC_OFFSET; i++)
557 {
558 att = fg | (bg << 4);
559
560 if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
561 att = bg | (fg << 4);
562 if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
563 att = 1;
564 if (i & (A_INVIS >> PDC_ATTR_SHIFT))
565 {
566 temp_bg = att >> 4;
567 att = temp_bg << 4 | temp_bg;
568 }
569 if (i & (A_BOLD >> PDC_ATTR_SHIFT))
570 att |= 8;
571 if (i & (A_BLINK >> PDC_ATTR_SHIFT))
572 att |= 128;
573
574 pdc_atrtab[pair * PDC_OFFSET + i] = att;
575 }
576 }
577
578 int PDC_pair_content(short pair, short *fg, short *bg)
579 {
580 *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
581 *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
582
583 return OK;
584 }
585
586 bool PDC_can_change_color(void)
587 {
588 return is_nt;
589 }
590
591 int PDC_color_content(short color, short *red, short *green, short *blue)
592 {
593 DWORD col;
594
595 if (!console_info.Hwnd)
596 _init_console_info();
597
598 col = console_info.ColorTable[curstoreal[color]];
599
600 *red = DIVROUND(GetRValue(col) * 1000, 255);
601 *green = DIVROUND(GetGValue(col) * 1000, 255);
602 *blue = DIVROUND(GetBValue(col) * 1000, 255);
603
604 return OK;
605 }
606
607 int PDC_init_color(short color, short red, short green, short blue)
608 {
609 if (!console_info.Hwnd)
610 _init_console_info();
611
612 console_info.ColorTable[curstoreal[color]] =
613 RGB(DIVROUND(red * 255, 1000),
614 DIVROUND(green * 255, 1000),
615 DIVROUND(blue * 255, 1000));
616
617 _set_console_info();
618
619 return OK;
620 }
File win32/pdcsetsc.c added (mode: 100644) (index 00000000..cfb12315)
1 /* Public Domain Curses */
2
3 #include "pdcwin.h"
4
5 RCSID("$Id: pdcsetsc.c,v 1.40 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: pdcsetsc
10
11 Synopsis:
12 int PDC_set_blink(bool blinkon);
13 void PDC_set_title(const char *title);
14
15 Description:
16 PDC_set_blink() toggles whether the A_BLINK attribute sets an
17 actual blink mode (TRUE), or sets the background color to high
18 intensity (FALSE). The default is platform-dependent (FALSE in
19 most cases). It returns OK if it could set the state to match
20 the given parameter, ERR otherwise. Current platforms also
21 adjust the value of COLORS according to this function -- 16 for
22 FALSE, and 8 for TRUE.
23
24 PDC_set_title() sets the title of the window in which the curses
25 program is running. This function may not do anything on some
26 platforms. (Currently it only works in Win32 and X11.)
27
28 Portability X/Open BSD SYS V
29 PDC_set_blink - - -
30 PDC_set_title - - -
31
32 **man-end****************************************************************/
33
34 int PDC_curs_set(int visibility)
35 {
36 CONSOLE_CURSOR_INFO cci;
37 int ret_vis;
38
39 PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
40
41 ret_vis = SP->visibility;
42
43 if (GetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
44 return ERR;
45
46 switch(visibility)
47 {
48 case 0: /* invisible */
49 cci.bVisible = FALSE;
50 break;
51 case 2: /* highly visible */
52 cci.bVisible = TRUE;
53 cci.dwSize = 95;
54 break;
55 default: /* normal visibility */
56 cci.bVisible = TRUE;
57 cci.dwSize = SP->orig_cursor;
58 break;
59 }
60
61 if (SetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
62 return ERR;
63
64 SP->visibility = visibility;
65 return ret_vis;
66 }
67
68 void PDC_set_title(const char *title)
69 {
70 #ifdef PDC_WIDE
71 wchar_t wtitle[512];
72 #endif
73 PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
74
75 #ifdef PDC_WIDE
76 PDC_mbstowcs(wtitle, title, 511);
77 SetConsoleTitleW(wtitle);
78 #else
79 SetConsoleTitleA(title);
80 #endif
81 }
82
83 int PDC_set_blink(bool blinkon)
84 {
85 if (pdc_color_started)
86 COLORS = 16;
87
88 return blinkon ? ERR : OK;
89 }
File win32/pdcurses.ico added (mode: 100644) (index 00000000..53a6dde3)
File win32/pdcurses.rc added (mode: 100644) (index 00000000..1b8bba4b)
1 #include "winver.h"
2
3 1 VERSIONINFO
4 FILEVERSION 3,4,0,0
5 PRODUCTVERSION 3,4,0,0
6 FILEFLAGSMASK 0x3fL
7 FILEFLAGS 0x0L
8 FILEOS VOS_UNKNOWN
9 FILETYPE VFT_DLL
10 FILESUBTYPE 0x0L
11 BEGIN
12 BLOCK "StringFileInfo"
13 BEGIN
14 BLOCK "040904b0"
15 BEGIN
16 VALUE "Maintainer", "William McBrine\0"
17 VALUE "FileDescription", "Public Domain Curses\0"
18 VALUE "FileVersion", "3.4.0\0"
19 VALUE "InternalName", "PDCurses\0"
20 VALUE "LegalCopyright", "Public Domain\0"
21 VALUE "OriginalFilename", "PDCURSES.DLL\0"
22 VALUE "ProductName", "Public Domain Curses Library\0"
23 VALUE "ProductVersion", "3.4.0\0"
24 END
25 END
26 END
27
28 1 ICON DISCARDABLE "PDCURSES.ico"
File win32/pdcutil.c added (mode: 100644) (index 00000000..f7be019e)
1 /* Public Domain Curses */
2
3 #include "pdcwin.h"
4
5 RCSID("$Id: pdcutil.c,v 1.14 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 void PDC_beep(void)
8 {
9 PDC_LOG(("PDC_beep() - called\n"));
10
11 /* MessageBeep(MB_OK); */
12 MessageBeep(0XFFFFFFFF);
13 }
14
15 void PDC_napms(int ms)
16 {
17 PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
18
19 Sleep(ms);
20 }
21
22 const char *PDC_sysname(void)
23 {
24 return "Win32";
25 }
File win32/pdcwin.h added (mode: 100644) (index 00000000..bb3396f0)
1 /* Public Domain Curses */
2
3 /* $Id: pdcwin.h,v 1.6 2008/07/13 06:36:32 wmcbrine Exp $ */
4
5 #ifdef PDC_WIDE
6 # define UNICODE
7 #endif
8
9 #include <windows.h>
10 #undef MOUSE_MOVED
11 #include <curspriv.h>
12
13 extern unsigned char *pdc_atrtab;
14 extern HANDLE pdc_con_out, pdc_con_in;
15 extern DWORD pdc_quick_edit;
16
17 extern int PDC_get_buffer_rows(void);
File win32/vcwin32.mak added (mode: 100644) (index 00000000..b8dc4043)
1 # Visual C++ NMakefile for PDCurses library - Win32 VC++ 2.0+
2 #
3 # Usage: nmake -f [path\]vcwin32.mak [DEBUG=] [DLL=] [WIDE=] [UTF8=] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 O = obj
9
10 !ifndef PDCURSES_SRCDIR
11 PDCURSES_SRCDIR = ..
12 !endif
13
14 !include $(PDCURSES_SRCDIR)\version.mif
15 !include $(PDCURSES_SRCDIR)\libobjs.mif
16
17 osdir = $(PDCURSES_SRCDIR)\win32
18
19 PDCURSES_WIN_H = $(osdir)\pdcwin.h
20
21 CC = cl.exe -nologo
22
23 !ifdef DEBUG
24 CFLAGS = -Z7 -DPDCDEBUG
25 LDFLAGS = -debug -pdb:none
26 !else
27 CFLAGS = -O1
28 LDFLAGS =
29 !endif
30
31 BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
32 WIDEDEF = $(PDCURSES_SRCDIR)\exp-wide.def
33
34 DEFDEPS = $(BASEDEF)
35
36 !ifdef WIDE
37 WIDEOPT = -DPDC_WIDE
38 DEFDEPS = $(DEFDEPS) $(WIDEDEF)
39 !endif
40
41 !ifdef UTF8
42 UTF8OPT = -DPDC_FORCE_UTF8
43 !endif
44
45 DEFFILE = pdcurses.def
46 SHL_LD = link $(LDFLAGS) /NOLOGO /DLL /OUT:pdcurses.dll /DEF:$(DEFFILE)
47
48 LINK = link.exe -nologo
49
50 CCLIBS = user32.lib advapi32.lib
51 # may need to add msvcrt.lib for VC 2.x, VC 5.0 doesn't want it
52 #CCLIBS = msvcrt.lib user32.lib advapi32.lib
53
54 LIBEXE = lib -nologo
55
56 LIBCURSES = pdcurses.lib
57 CURSESDLL = pdcurses.dll
58
59 !ifdef DLL
60 DLLOPT = -DPDC_DLL_BUILD
61 PDCLIBS = $(CURSESDLL)
62 !else
63 PDCLIBS = $(LIBCURSES)
64 !endif
65
66 BUILD = $(CC) -I$(PDCURSES_SRCDIR) -c $(CFLAGS) $(DLLOPT) \
67 $(WIDEOPT) $(UTF8OPT)
68
69 all: $(PDCLIBS) $(DEMOS)
70
71 clean:
72 -del *.obj
73 -del *.lib
74 -del *.exe
75 -del *.dll
76 -del *.exp
77 -del *.res
78 -del *.def
79
80 DEMOOBJS = $(DEMOS:.exe=.obj) tui.obj
81
82 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
83 $(PDCOBJS) : $(PDCURSES_WIN_H)
84 $(DEMOOBJS) : $(PDCURSES_CURSES_H)
85 $(DEMOS) : $(LIBCURSES)
86 panel.obj : $(PANEL_HEADER)
87 terminfo.obj: $(TERM_HEADER)
88
89 !ifndef DLL
90 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
91 $(LIBEXE) -out:$@ $(LIBOBJS) $(PDCOBJS)
92 -copy $(LIBCURSES) panel.lib
93 !endif
94
95 $(DEFFILE) : $(DEFDEPS)
96 echo LIBRARY pdcurses > $(DEFFILE)
97 echo EXPORTS >> $(DEFFILE)
98 type $(BASEDEF) >> $(DEFFILE)
99 !ifdef WIDE
100 type $(WIDEDEF) >> $(DEFFILE)
101 !endif
102
103 $(CURSESDLL) : $(LIBOBJS) $(PDCOBJS) $(DEFFILE) pdcurses.obj
104 $(SHL_LD) $(LIBOBJS) $(PDCOBJS) pdcurses.obj $(CCLIBS)
105 -copy $(LIBCURSES) panel.lib
106
107 pdcurses.res pdcurses.obj: $(osdir)\pdcurses.rc $(osdir)\pdcurses.ico
108 rc /r /fopdcurses.res $(osdir)\pdcurses.rc
109 cvtres /MACHINE:IX86 /NOLOGO /OUT:pdcurses.obj pdcurses.res
110
111 {$(srcdir)\}.c{}.obj::
112 $(BUILD) $<
113
114 {$(osdir)\}.c{}.obj::
115 $(BUILD) $<
116
117 {$(demodir)\}.c{}.obj::
118 $(BUILD) $<
119
120 .obj.exe:
121 $(LINK) $(LDFLAGS) $< $(LIBCURSES) $(CCLIBS)
122
123 tuidemo.exe: tuidemo.obj tui.obj
124 $(LINK) $(LDFLAGS) $*.obj tui.obj $(LIBCURSES) $(CCLIBS)
125
126 tui.obj: $(demodir)\tui.c $(demodir)\tui.h
127 $(BUILD) -I$(demodir) $(demodir)\tui.c
128
129 tuidemo.obj: $(demodir)\tuidemo.c
130 $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
131
132 PLATFORM1 = Visual C++
133 PLATFORM2 = Microsoft Visual C/C++ for Win32
134 ARCNAME = pdc$(VER)_vc_w32
135
136 !include $(PDCURSES_SRCDIR)\makedist.mif
File win32/wccwin32.mak added (mode: 100644) (index 00000000..1363897b)
1 # Watcom WMAKE Makefile for PDCurses library - Win32 Watcom C/C++ 10.6+
2 #
3 # Usage: wmake -f [win32\]wccwin32.mak [DEBUG=Y] [WIDE=Y] [UTF8=Y] [target]
4 #
5 # where target can be any of:
6 # [all|demos|pdcurses.lib|testcurs.exe...]
7
8 !ifdef %PDCURSES_SRCDIR
9 PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
10 !else
11 PDCURSES_SRCDIR = ..
12 !endif
13
14 !include $(PDCURSES_SRCDIR)\version.mif
15
16 osdir = $(PDCURSES_SRCDIR)\win32
17
18 CC = wcc386
19 TARGET = nt
20
21 CFLAGS = /ei /zq /wx /i=$(PDCURSES_SRCDIR)
22
23 !ifeq DEBUG Y
24 CFLAGS += /d2 /DPDCDEBUG
25 LDFLAGS = D W A op q sys $(TARGET)
26 !else
27 CFLAGS += /oneatx
28 LDFLAGS = op q sys $(TARGET)
29 !endif
30
31 !ifeq WIDE Y
32 CFLAGS += /DPDC_WIDE
33 !endif
34
35 !ifeq UTF8 Y
36 CFLAGS += /DPDC_FORCE_UTF8
37 !endif
38
39 LIBEXE = wlib /q /n /t
40
41 !include $(PDCURSES_SRCDIR)\watcom.mif
42
43 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
44 $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
45 -copy $(LIBCURSES) panel.lib
46
47 PLATFORM1 = Watcom C++ Win32
48 PLATFORM2 = Open Watcom 1.6 for Win32
49 ARCNAME = pdc$(VER)_wcc_w32
50
51 !include $(PDCURSES_SRCDIR)\makedist.mif
File x11/Makefile.aix.in added (mode: 100644) (index 00000000..0fe5db78)
1 # Makefile for PDCurses library for AIX/X11
2
3 SHELL = @SHELL@
4 THIS = Makefile
5
6 @SET_MAKE@
7
8 PDCURSES_SRCDIR = ..
9
10 osdir = .
11 srcdir = $(PDCURSES_SRCDIR)/pdcurses
12
13 PDCURSES_CONFIG_H =$(PDCURSES_SRCDIR)/config.h
14 PDCURSES_CURSES_H =$(PDCURSES_SRCDIR)/curses.h
15 PDCURSES_CURSPRIV_H =$(PDCURSES_SRCDIR)/curspriv.h
16 PDCURSES_HEADERS =$(PDCURSES_CONFIG_H) $(PDCURSES_CURSES_H) \
17 $(PDCURSES_CURSPRIV_H)
18 PDCURSES_X11_H =$(osdir)/pdcx11.h
19
20 MH_EXTRA_LIBS = @MH_EXTRA_LIBS@
21
22 CFLAGS = @CFLAGS@ @DYN_COMP@
23
24 CPPFLAGS = @DEFS@ -DXCURSES @SYS_DEFS@ -I$(PDCURSES_SRCDIR)
25
26 BUILD = @CC@ -c $(CFLAGS) $(CPPFLAGS) @MH_XINC_DIR@
27
28 LINK = @CC@
29 LDFLAGS =
30
31 LIBCURSES = libXCurses.a
32
33 all : $(LIBCURSES)
34
35 install :
36 echo Does nothing at the moment
37
38 clean :
39 -rm -rf *.o *.sho trace $(LIBCURSES)
40
41 distclean: clean
42 -rm -f Makefile
43
44 mostlyclean: clean
45
46 realclean: distclean
47
48 LIBOBJS = addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o \
49 clear.o color.o delch.o deleteln.o deprec.o getch.o getstr.o getyx.o \
50 inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o \
51 keyname.o mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o \
52 refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o terminfo.o \
53 touch.o util.o window.o debug.o
54
55 PDCOBJS = pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o \
56 pdcutil.o pdcx11.o x11.o sb.o ScrollBox.o
57
58 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS) curses.exp
59 ld -bnoentry -bM:SRE -bE:curses.exp $(MH_LIBS) $(MH_EXTRA_LIBS) \
60 $(LIBOBJS) $(PDCOBJS) -o $@
61
62 $(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
63 $(PDCOBJS) : $(PDCURSES_X11_H)
64 terminfo.o: $(TERM_HEADER)
65
66 curses.exp: ../exp-base.def
67 cat ../exp-base.def > curses.exp
68 echo Xinitscr >> curses.exp
69 echo XCursesExit >> curses.exp
70 echo sb_init >> curses.exp
71 echo sb_set_horz >> curses.exp
72 echo sb_set_vert >> curses.exp
73 echo sb_get_horz >> curses.exp
74 echo sb_get_vert >> curses.exp
75 echo sb_refresh >> curses.exp
76
77 addch.o: $(srcdir)/addch.c
78 $(BUILD) $(srcdir)/addch.c
79
80 addchstr.o: $(srcdir)/addchstr.c
81 $(BUILD) $(srcdir)/addchstr.c
82
83 addstr.o: $(srcdir)/addstr.c
84 $(BUILD) $(srcdir)/addstr.c
85
86 attr.o: $(srcdir)/attr.c
87 $(BUILD) $(srcdir)/attr.c
88
89 beep.o: $(srcdir)/beep.c
90 $(BUILD) $(srcdir)/beep.c
91
92 bkgd.o: $(srcdir)/bkgd.c
93 $(BUILD) $(srcdir)/bkgd.c
94
95 border.o: $(srcdir)/border.c
96 $(BUILD) $(srcdir)/border.c
97
98 clear.o: $(srcdir)/clear.c
99 $(BUILD) $(srcdir)/clear.c
100
101 color.o: $(srcdir)/color.c
102 $(BUILD) $(srcdir)/color.c
103
104 delch.o: $(srcdir)/delch.c
105 $(BUILD) $(srcdir)/delch.c
106
107 deleteln.o: $(srcdir)/deleteln.c
108 $(BUILD) $(srcdir)/deleteln.c
109
110 deprec.o: $(srcdir)/deprec.c
111 $(BUILD) $(srcdir)/deprec.c
112
113 getch.o: $(srcdir)/getch.c
114 $(BUILD) $(srcdir)/getch.c
115
116 getstr.o: $(srcdir)/getstr.c
117 $(BUILD) $(srcdir)/getstr.c
118
119 getyx.o: $(srcdir)/getyx.c
120 $(BUILD) $(srcdir)/getyx.c
121
122 inch.o: $(srcdir)/inch.c
123 $(BUILD) $(srcdir)/inch.c
124
125 inchstr.o: $(srcdir)/inchstr.c
126 $(BUILD) $(srcdir)/inchstr.c
127
128 initscr.o: $(srcdir)/initscr.c
129 $(BUILD) $(srcdir)/initscr.c
130
131 inopts.o: $(srcdir)/inopts.c
132 $(BUILD) $(srcdir)/inopts.c
133
134 insch.o: $(srcdir)/insch.c
135 $(BUILD) $(srcdir)/insch.c
136
137 insstr.o: $(srcdir)/insstr.c
138 $(BUILD) $(srcdir)/insstr.c
139
140 instr.o: $(srcdir)/instr.c
141 $(BUILD) $(srcdir)/instr.c
142
143 kernel.o: $(srcdir)/kernel.c
144 $(BUILD) $(srcdir)/kernel.c
145
146 keyname.o: $(srcdir)/keyname.c
147 $(BUILD) $(srcdir)/keyname.c
148
149 mouse.o: $(srcdir)/mouse.c
150 $(BUILD) $(srcdir)/mouse.c
151
152 move.o: $(srcdir)/move.c
153 $(BUILD) $(srcdir)/move.c
154
155 outopts.o: $(srcdir)/outopts.c
156 $(BUILD) $(srcdir)/outopts.c
157
158 overlay.o: $(srcdir)/overlay.c
159 $(BUILD) $(srcdir)/overlay.c
160
161 pad.o: $(srcdir)/pad.c
162 $(BUILD) $(srcdir)/pad.c
163
164 panel.o: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
165 $(BUILD) $(srcdir)/panel.c
166
167 printw.o: $(srcdir)/printw.c
168 $(BUILD) $(srcdir)/printw.c
169
170 refresh.o: $(srcdir)/refresh.c
171 $(BUILD) $(srcdir)/refresh.c
172
173 scanw.o: $(srcdir)/scanw.c
174 $(BUILD) $(srcdir)/scanw.c
175
176 scr_dump.o: $(srcdir)/scr_dump.c
177 $(BUILD) $(srcdir)/scr_dump.c
178
179 scroll.o: $(srcdir)/scroll.c
180 $(BUILD) $(srcdir)/scroll.c
181
182 slk.o: $(srcdir)/slk.c
183 $(BUILD) $(srcdir)/slk.c
184
185 termattr.o: $(srcdir)/termattr.c
186 $(BUILD) $(srcdir)/termattr.c
187
188 terminfo.o: $(srcdir)/terminfo.c
189 $(BUILD) $(srcdir)/terminfo.c
190
191 touch.o: $(srcdir)/touch.c
192 $(BUILD) $(srcdir)/touch.c
193
194 util.o: $(srcdir)/util.c
195 $(BUILD) $(srcdir)/util.c
196
197 window.o: $(srcdir)/window.c
198 $(BUILD) $(srcdir)/window.c
199
200 debug.o: $(srcdir)/debug.c
201 $(BUILD) $(srcdir)/debug.c
202
203 pdcclip.o: $(osdir)/pdcclip.c
204 $(BUILD) $(osdir)/pdcclip.c
205
206 pdcdisp.o: $(osdir)/pdcdisp.c
207 $(BUILD) $(osdir)/pdcdisp.c
208
209 pdcgetsc.o: $(osdir)/pdcgetsc.c
210 $(BUILD) $(osdir)/pdcgetsc.c
211
212 pdckbd.o: $(osdir)/pdckbd.c
213 $(BUILD) $(osdir)/pdckbd.c
214
215 pdcscrn.o: $(osdir)/pdcscrn.c
216 $(BUILD) $(osdir)/pdcscrn.c
217
218 pdcsetsc.o: $(osdir)/pdcsetsc.c
219 $(BUILD) $(osdir)/pdcsetsc.c
220
221 pdcutil.o: $(osdir)/pdcutil.c
222 $(BUILD) $(osdir)/pdcutil.c
223
224 pdcx11.o: $(osdir)/pdcx11.c
225 $(BUILD) $(osdir)/pdcx11.c
226
227 ScrollBox.o: $(osdir)/ScrollBox.c
228 $(BUILD) $(osdir)/ScrollBox.c
229
230 sb.o: $(osdir)/sb.c
231 $(BUILD) $(osdir)/sb.c
232
233 x11.o: $(osdir)/x11.c
234 $(BUILD) $(osdir)/x11.c
File x11/Makefile.in added (mode: 100644) (index 00000000..d23a214f)
1 # Makefile for PDCurses library for X11
2
3 SHELL = @SHELL@
4 THIS = Makefile
5
6 @SET_MAKE@
7
8 PDCURSES_SRCDIR = ..
9
10 osdir = .
11 srcdir = $(PDCURSES_SRCDIR)/pdcurses
12 demodir = $(PDCURSES_SRCDIR)/demos
13
14 PDCURSES_CONFIG_H =$(PDCURSES_SRCDIR)/config.h
15 PDCURSES_CURSES_H =$(PDCURSES_SRCDIR)/curses.h
16 PDCURSES_CURSPRIV_H =$(PDCURSES_SRCDIR)/curspriv.h
17 PDCURSES_HEADERS =$(PDCURSES_CONFIG_H) $(PDCURSES_CURSES_H) \
18 $(PDCURSES_CURSPRIV_H)
19 PDCURSES_X11_H =$(osdir)/pdcx11.h
20
21 SHLPRE = @SHLPRE@
22 SHLPST = @SHLPST@
23 LD_RXLIB1 = @LD_RXLIB1@
24 LD_RXLIB2 = @MH_XLIBS@ @MH_EXTRA_LIBS@ -lc
25
26 CFLAGS = @CFLAGS@
27
28 CPPFLAGS = @DEFS@ -DXCURSES @SYS_DEFS@ -I$(PDCURSES_SRCDIR)
29
30 BUILD = @CC@ -c $(CFLAGS) $(CPPFLAGS) @MH_XINC_DIR@
31 DYN_BUILD = @O2SAVE@ $(BUILD) @DYN_COMP@ @CC2O@
32
33 LINK = @PURIFY@ @CC@
34 #LDFLAGS = $(LIB_DEPS) @LDFLAGS@ @LIBS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
35 LDFLAGS = $(LIBCURSES) @LDFLAGS@ @LIBS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
36
37 RANLIB = @RANLIB@
38
39 LIBCURSES = libXCurses.a
40
41 LIB_DEPS = -L$(PDCURSES_SRCDIR)/x11 -lXCurses
42
43 PDCLIBS = $(LIBCURSES) @SHL_TARGETS@
44
45 DEMOS = firework newdemo ptest rain testcurs tuidemo worm xmas
46 DEMOOBJS = firework.o newdemo.o ptest.o rain.o testcurs.o tui.o \
47 tuidemo.o worm.o xmas.o
48
49 SHLFILE = XCurses
50
51 all: $(PDCLIBS) $(DEMOS)
52
53 install:
54 echo Does nothing at the moment
55
56 clean:
57 -rm -rf *.o *.sho trace $(PDCLIBS) $(DEMOS)
58
59 demos: $(DEMOS)
60
61 distclean: clean
62 -rm -f Makefile
63
64 mostlyclean: clean
65
66 realclean: distclean
67
68 LIBOBJS = addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o \
69 clear.o color.o delch.o deleteln.o deprec.o getch.o getstr.o getyx.o \
70 inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o \
71 keyname.o mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o \
72 refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o terminfo.o \
73 touch.o util.o window.o debug.o
74
75 PDCOBJS = pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o \
76 pdcutil.o pdcx11.o x11.o sb.o ScrollBox.o
77
78 LIBSHOBJS = $(LIBOBJS:.o=.sho)
79 PDCSHOBJS = $(PDCOBJS:.o=.sho)
80
81 SHOFILES = $(LIBSHOBJS) $(PDCSHOBJS)
82
83 $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
84 ar rv $@ $?
85 -$(RANLIB) $@
86
87 $(SHLPRE)$(SHLFILE)$(SHLPST) : $(SHOFILES)
88 $(LD_RXLIB1) -o $@ $(SHOFILES) $(LD_RXLIB2)
89
90 $(LIBOBJS) $(PDCOBJS) $(SHOFILES) : $(PDCURSES_HEADERS)
91 $(PDCOBJS) $(PDCSHOBJS) : $(PDCURSES_X11_H)
92 $(DEMOOBJS) : $(PDCURSES_CURSES_H)
93 $(DEMOS) : $(LIBCURSES)
94 terminfo.o terminfo.sho: $(TERM_HEADER)
95
96 addch.o: $(srcdir)/addch.c
97 $(BUILD) $(srcdir)/addch.c
98
99 addchstr.o: $(srcdir)/addchstr.c
100 $(BUILD) $(srcdir)/addchstr.c
101
102 addstr.o: $(srcdir)/addstr.c
103 $(BUILD) $(srcdir)/addstr.c
104
105 attr.o: $(srcdir)/attr.c
106 $(BUILD) $(srcdir)/attr.c
107
108 beep.o: $(srcdir)/beep.c
109 $(BUILD) $(srcdir)/beep.c
110
111 bkgd.o: $(srcdir)/bkgd.c
112 $(BUILD) $(srcdir)/bkgd.c
113
114 border.o: $(srcdir)/border.c
115 $(BUILD) $(srcdir)/border.c
116
117 clear.o: $(srcdir)/clear.c
118 $(BUILD) $(srcdir)/clear.c
119
120 color.o: $(srcdir)/color.c
121 $(BUILD) $(srcdir)/color.c
122
123 delch.o: $(srcdir)/delch.c
124 $(BUILD) $(srcdir)/delch.c
125
126 deleteln.o: $(srcdir)/deleteln.c
127 $(BUILD) $(srcdir)/deleteln.c
128
129 deprec.o: $(srcdir)/deprec.c
130 $(BUILD) $(srcdir)/deprec.c
131
132 getch.o: $(srcdir)/getch.c
133 $(BUILD) $(srcdir)/getch.c
134
135 getstr.o: $(srcdir)/getstr.c
136 $(BUILD) $(srcdir)/getstr.c
137
138 getyx.o: $(srcdir)/getyx.c
139 $(BUILD) $(srcdir)/getyx.c
140
141 inch.o: $(srcdir)/inch.c
142 $(BUILD) $(srcdir)/inch.c
143
144 inchstr.o: $(srcdir)/inchstr.c
145 $(BUILD) $(srcdir)/inchstr.c
146
147 initscr.o: $(srcdir)/initscr.c
148 $(BUILD) $(srcdir)/initscr.c
149
150 inopts.o: $(srcdir)/inopts.c
151 $(BUILD) $(srcdir)/inopts.c
152
153 insch.o: $(srcdir)/insch.c
154 $(BUILD) $(srcdir)/insch.c
155
156 insstr.o: $(srcdir)/insstr.c
157 $(BUILD) $(srcdir)/insstr.c
158
159 instr.o: $(srcdir)/instr.c
160 $(BUILD) $(srcdir)/instr.c
161
162 kernel.o: $(srcdir)/kernel.c
163 $(BUILD) $(srcdir)/kernel.c
164
165 keyname.o: $(srcdir)/keyname.c
166 $(BUILD) $(srcdir)/keyname.c
167
168 mouse.o: $(srcdir)/mouse.c
169 $(BUILD) $(srcdir)/mouse.c
170
171 move.o: $(srcdir)/move.c
172 $(BUILD) $(srcdir)/move.c
173
174 outopts.o: $(srcdir)/outopts.c
175 $(BUILD) $(srcdir)/outopts.c
176
177 overlay.o: $(srcdir)/overlay.c
178 $(BUILD) $(srcdir)/overlay.c
179
180 pad.o: $(srcdir)/pad.c
181 $(BUILD) $(srcdir)/pad.c
182
183 panel.o: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
184 $(BUILD) $(srcdir)/panel.c
185
186 printw.o: $(srcdir)/printw.c
187 $(BUILD) $(srcdir)/printw.c
188
189 refresh.o: $(srcdir)/refresh.c
190 $(BUILD) $(srcdir)/refresh.c
191
192 scanw.o: $(srcdir)/scanw.c
193 $(BUILD) $(srcdir)/scanw.c
194
195 scr_dump.o: $(srcdir)/scr_dump.c
196 $(BUILD) $(srcdir)/scr_dump.c
197
198 scroll.o: $(srcdir)/scroll.c
199 $(BUILD) $(srcdir)/scroll.c
200
201 slk.o: $(srcdir)/slk.c
202 $(BUILD) $(srcdir)/slk.c
203
204 termattr.o: $(srcdir)/termattr.c
205 $(BUILD) $(srcdir)/termattr.c
206
207 terminfo.o: $(srcdir)/terminfo.c
208 $(BUILD) $(srcdir)/terminfo.c
209
210 touch.o: $(srcdir)/touch.c
211 $(BUILD) $(srcdir)/touch.c
212
213 util.o: $(srcdir)/util.c
214 $(BUILD) $(srcdir)/util.c
215
216 window.o: $(srcdir)/window.c
217 $(BUILD) $(srcdir)/window.c
218
219 debug.o: $(srcdir)/debug.c
220 $(BUILD) $(srcdir)/debug.c
221
222 pdcclip.o: $(osdir)/pdcclip.c
223 $(BUILD) $(osdir)/pdcclip.c
224
225 pdcdisp.o: $(osdir)/pdcdisp.c
226 $(BUILD) $(osdir)/pdcdisp.c
227
228 pdcgetsc.o: $(osdir)/pdcgetsc.c
229 $(BUILD) $(osdir)/pdcgetsc.c
230
231 pdckbd.o: $(osdir)/pdckbd.c
232 $(BUILD) $(osdir)/pdckbd.c
233
234 pdcscrn.o: $(osdir)/pdcscrn.c
235 $(BUILD) $(osdir)/pdcscrn.c
236
237 pdcsetsc.o: $(osdir)/pdcsetsc.c
238 $(BUILD) $(osdir)/pdcsetsc.c
239
240 pdcutil.o: $(osdir)/pdcutil.c
241 $(BUILD) $(osdir)/pdcutil.c
242
243 pdcx11.o: $(osdir)/pdcx11.c
244 $(BUILD) $(osdir)/pdcx11.c
245
246 ScrollBox.o: $(osdir)/ScrollBox.c
247 $(BUILD) $(osdir)/ScrollBox.c
248
249 sb.o: $(osdir)/sb.c
250 $(BUILD) $(osdir)/sb.c
251
252 x11.o: $(osdir)/x11.c
253 $(BUILD) $(osdir)/x11.c
254
255 addch.sho: $(srcdir)/addch.c
256 $(DYN_BUILD) $(srcdir)/addch.c
257 @SAVE2O@
258
259 addchstr.sho: $(srcdir)/addchstr.c
260 $(DYN_BUILD) $(srcdir)/addchstr.c
261 @SAVE2O@
262
263 addstr.sho: $(srcdir)/addstr.c
264 $(DYN_BUILD) $(srcdir)/addstr.c
265 @SAVE2O@
266
267 attr.sho: $(srcdir)/attr.c
268 $(DYN_BUILD) $(srcdir)/attr.c
269 @SAVE2O@
270
271 beep.sho: $(srcdir)/beep.c
272 $(DYN_BUILD) $(srcdir)/beep.c
273 @SAVE2O@
274
275 bkgd.sho: $(srcdir)/bkgd.c
276 $(DYN_BUILD) $(srcdir)/bkgd.c
277 @SAVE2O@
278
279 border.sho: $(srcdir)/border.c
280 $(DYN_BUILD) $(srcdir)/border.c
281 @SAVE2O@
282
283 clear.sho: $(srcdir)/clear.c
284 $(DYN_BUILD) $(srcdir)/clear.c
285 @SAVE2O@
286
287 color.sho: $(srcdir)/color.c
288 $(DYN_BUILD) $(srcdir)/color.c
289 @SAVE2O@
290
291 delch.sho: $(srcdir)/delch.c
292 $(DYN_BUILD) $(srcdir)/delch.c
293 @SAVE2O@
294
295 deleteln.sho: $(srcdir)/deleteln.c
296 $(DYN_BUILD) $(srcdir)/deleteln.c
297 @SAVE2O@
298
299 deprec.sho: $(srcdir)/deprec.c
300 $(DYN_BUILD) $(srcdir)/deprec.c
301 @SAVE2O@
302
303 getch.sho: $(srcdir)/getch.c
304 $(DYN_BUILD) $(srcdir)/getch.c
305 @SAVE2O@
306
307 getstr.sho: $(srcdir)/getstr.c
308 $(DYN_BUILD) $(srcdir)/getstr.c
309 @SAVE2O@
310
311 getyx.sho: $(srcdir)/getyx.c
312 $(DYN_BUILD) $(srcdir)/getyx.c
313 @SAVE2O@
314
315 inch.sho: $(srcdir)/inch.c
316 $(DYN_BUILD) $(srcdir)/inch.c
317 @SAVE2O@
318
319 inchstr.sho: $(srcdir)/inchstr.c
320 $(DYN_BUILD) $(srcdir)/inchstr.c
321 @SAVE2O@
322
323 initscr.sho: $(srcdir)/initscr.c
324 $(DYN_BUILD) $(srcdir)/initscr.c
325 @SAVE2O@
326
327 inopts.sho: $(srcdir)/inopts.c
328 $(DYN_BUILD) $(srcdir)/inopts.c
329 @SAVE2O@
330
331 insch.sho: $(srcdir)/insch.c
332 $(DYN_BUILD) $(srcdir)/insch.c
333 @SAVE2O@
334
335 insstr.sho: $(srcdir)/insstr.c
336 $(DYN_BUILD) $(srcdir)/insstr.c
337 @SAVE2O@
338
339 instr.sho: $(srcdir)/instr.c
340 $(DYN_BUILD) $(srcdir)/instr.c
341 @SAVE2O@
342
343 kernel.sho: $(srcdir)/kernel.c
344 $(DYN_BUILD) $(srcdir)/kernel.c
345 @SAVE2O@
346
347 keyname.sho: $(srcdir)/keyname.c
348 $(DYN_BUILD) $(srcdir)/keyname.c
349 @SAVE2O@
350
351 mouse.sho: $(srcdir)/mouse.c
352 $(DYN_BUILD) $(srcdir)/mouse.c
353 @SAVE2O@
354
355 move.sho: $(srcdir)/move.c
356 $(DYN_BUILD) $(srcdir)/move.c
357 @SAVE2O@
358
359 outopts.sho: $(srcdir)/outopts.c
360 $(DYN_BUILD) $(srcdir)/outopts.c
361 @SAVE2O@
362
363 overlay.sho: $(srcdir)/overlay.c
364 $(DYN_BUILD) $(srcdir)/overlay.c
365 @SAVE2O@
366
367 pad.sho: $(srcdir)/pad.c
368 $(DYN_BUILD) $(srcdir)/pad.c
369 @SAVE2O@
370
371 panel.sho: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
372 $(DYN_BUILD) $(srcdir)/panel.c
373 @SAVE2O@
374
375 printw.sho: $(srcdir)/printw.c
376 $(DYN_BUILD) $(srcdir)/printw.c
377 @SAVE2O@
378
379 refresh.sho: $(srcdir)/refresh.c
380 $(DYN_BUILD) $(srcdir)/refresh.c
381 @SAVE2O@
382
383 scanw.sho: $(srcdir)/scanw.c
384 $(DYN_BUILD) $(srcdir)/scanw.c
385 @SAVE2O@
386
387 scr_dump.sho: $(srcdir)/scr_dump.c
388 $(DYN_BUILD) $(srcdir)/scr_dump.c
389 @SAVE2O@
390
391 scroll.sho: $(srcdir)/scroll.c
392 $(DYN_BUILD) $(srcdir)/scroll.c
393 @SAVE2O@
394
395 slk.sho: $(srcdir)/slk.c
396 $(DYN_BUILD) $(srcdir)/slk.c
397 @SAVE2O@
398
399 termattr.sho: $(srcdir)/termattr.c
400 $(DYN_BUILD) $(srcdir)/termattr.c
401 @SAVE2O@
402
403 terminfo.sho: $(srcdir)/terminfo.c
404 $(DYN_BUILD) $(srcdir)/terminfo.c
405 @SAVE2O@
406
407 touch.sho: $(srcdir)/touch.c
408 $(DYN_BUILD) $(srcdir)/touch.c
409 @SAVE2O@
410
411 util.sho: $(srcdir)/util.c
412 $(DYN_BUILD) $(srcdir)/util.c
413 @SAVE2O@
414
415 window.sho: $(srcdir)/window.c
416 $(DYN_BUILD) $(srcdir)/window.c
417 @SAVE2O@
418
419 debug.sho: $(srcdir)/debug.c
420 $(DYN_BUILD) $(srcdir)/debug.c
421 @SAVE2O@
422
423 pdcclip.sho: $(osdir)/pdcclip.c
424 $(DYN_BUILD) $(osdir)/pdcclip.c
425 @SAVE2O@
426
427 pdcdisp.sho: $(osdir)/pdcdisp.c
428 $(DYN_BUILD) $(osdir)/pdcdisp.c
429 @SAVE2O@
430
431 pdcgetsc.sho: $(osdir)/pdcgetsc.c
432 $(DYN_BUILD) $(osdir)/pdcgetsc.c
433 @SAVE2O@
434
435 pdckbd.sho: $(osdir)/pdckbd.c
436 $(DYN_BUILD) $(osdir)/pdckbd.c
437 @SAVE2O@
438
439 pdcscrn.sho: $(osdir)/pdcscrn.c
440 $(DYN_BUILD) $(osdir)/pdcscrn.c
441 @SAVE2O@
442
443 pdcsetsc.sho: $(osdir)/pdcsetsc.c
444 $(DYN_BUILD) $(osdir)/pdcsetsc.c
445 @SAVE2O@
446
447 pdcutil.sho: $(osdir)/pdcutil.c
448 $(DYN_BUILD) $(osdir)/pdcutil.c
449 @SAVE2O@
450
451 pdcx11.sho: $(osdir)/pdcx11.c
452 $(DYN_BUILD) $(osdir)/pdcx11.c
453 @SAVE2O@
454
455 ScrollBox.sho: $(osdir)/ScrollBox.c
456 $(DYN_BUILD) $(osdir)/ScrollBox.c
457 @SAVE2O@
458
459 sb.sho: $(osdir)/sb.c
460 $(DYN_BUILD) $(osdir)/sb.c
461 @SAVE2O@
462
463 x11.sho: $(osdir)/x11.c
464 $(DYN_BUILD) $(osdir)/x11.c
465 @SAVE2O@
466
467 firework: firework.o
468 $(LINK) firework.o -o $@ $(LDFLAGS)
469
470 newdemo: newdemo.o
471 $(LINK) newdemo.o -o $@ $(LDFLAGS)
472
473 ptest: ptest.o
474 $(LINK) ptest.o -o $@ $(LDFLAGS)
475
476 rain: rain.o
477 $(LINK) rain.o -o $@ $(LDFLAGS)
478
479 testcurs: testcurs.o
480 $(LINK) testcurs.o -o $@ $(LDFLAGS)
481
482 tuidemo: tuidemo.o tui.o
483 $(LINK) tui.o tuidemo.o -o $@ $(LDFLAGS)
484
485 worm: worm.o
486 $(LINK) worm.o -o $@ $(LDFLAGS)
487
488 xmas: xmas.o
489 $(LINK) xmas.o -o $@ $(LDFLAGS)
490
491 firework.o: $(demodir)/firework.c
492 $(BUILD) $(demodir)/firework.c
493
494 newdemo.o: $(demodir)/newdemo.c
495 $(BUILD) $(demodir)/newdemo.c
496
497 ptest.o: $(demodir)/ptest.c $(PDCURSES_SRCDIR)/panel.h
498 $(BUILD) $(demodir)/ptest.c
499
500 rain.o: $(demodir)/rain.c
501 $(BUILD) $(demodir)/rain.c
502
503 testcurs.o: $(demodir)/testcurs.c
504 $(BUILD) $(demodir)/testcurs.c
505
506 tui.o: $(demodir)/tui.c $(demodir)/tui.h
507 $(BUILD) $(demodir)/tui.c
508
509 tuidemo.o: $(demodir)/tuidemo.c
510 $(BUILD) $(demodir)/tuidemo.c
511
512 worm.o: $(demodir)/worm.c
513 $(BUILD) $(demodir)/worm.c
514
515 xmas.o: $(demodir)/xmas.c
516 $(BUILD) $(demodir)/xmas.c
517
518 # This section provides for compiling and linking the
519 # ncurses test programs.
520
521 ncurses_testdir = $(HOME)/ncurses-5.6/test
522
523 NCURSES_TESTS = bs gdc hanoi knight tclock ncurses
524
525 ncurses_tests: $(NCURSES_TESTS)
526
527 ncurses_clean:
528 -rm -f *.o trace $(NCURSES_TESTS)
529
530 NCFLAGS = -I. -I$(ncurses_testdir)
531
532 bs: bs.o $(LIBCURSES)
533 $(LINK) bs.o -o $@ $(LDFLAGS)
534
535 gdc: gdc.o $(LIBCURSES)
536 $(LINK) gdc.o -o $@ $(LDFLAGS)
537
538 hanoi: hanoi.o $(LIBCURSES)
539 $(LINK) hanoi.o -o $@ $(LDFLAGS)
540
541 knight: knight.o $(LIBCURSES)
542 $(LINK) knight.o -o $@ $(LDFLAGS)
543
544 tclock: tclock.o $(LIBCURSES)
545 $(LINK) tclock.o -o $@ $(LDFLAGS) -lm
546
547 view: view.o $(LIBCURSES)
548 $(LINK) view.o -o $@ $(LDFLAGS)
549
550 ncurses: ncurses.o $(LIBCURSES)
551 $(LINK) ncurses.o -o $@ $(LDFLAGS)
552
553 bs.o: $(ncurses_testdir)/bs.c $(PDCURSES_CURSES_H)
554 $(BUILD) $(NCFLAGS) $(ncurses_testdir)/bs.c
555
556 gdc.o: $(ncurses_testdir)/gdc.c $(PDCURSES_CURSES_H)
557 $(BUILD) $(NCFLAGS) $(ncurses_testdir)/gdc.c
558
559 hanoi.o: $(ncurses_testdir)/hanoi.c $(PDCURSES_CURSES_H)
560 $(BUILD) $(NCFLAGS) $(ncurses_testdir)/hanoi.c
561
562 knight.o: $(ncurses_testdir)/knight.c $(PDCURSES_CURSES_H)
563 $(BUILD) $(NCFLAGS) $(ncurses_testdir)/knight.c
564
565 tclock.o: $(ncurses_testdir)/tclock.c $(PDCURSES_CURSES_H)
566 $(BUILD) $(NCFLAGS) $(ncurses_testdir)/tclock.c
567
568 view.o: $(ncurses_testdir)/view.c $(PDCURSES_CURSES_H)
569 $(BUILD) $(NCFLAGS) $(ncurses_testdir)/view.c
570
571 ncurses.o: $(ncurses_testdir)/ncurses.c $(PDCURSES_CURSES_H)
572 $(BUILD) $(NCFLAGS) $(ncurses_testdir)/ncurses.c
File x11/README added (mode: 100644) (index 00000000..37b45d06)
1 PDCurses for X11
2 ================
3
4 This is a port of PDCurses for X11, aka XCurses. It is designed to
5 allow existing curses programs to be re-compiled with PDCurses,
6 resulting in native X11 programs.
7
8
9 Building
10 --------
11
12 . Run "./configure" in the top-level directory.
13
14 To build the wide-character version of the library, specify
15 "--enable-widec" as a parameter. To use X Input Methods, add
16 "--enable-xim". I recommend these options, but I haven't yet made
17 them the defaults, for the sake of backwards compatibility and due to
18 their new and relatively untested status.
19
20 If your system is lacking in UTF-8 support, you can force the use of
21 UTF-8 instead of the system locale via "--enable-force-utf8". This is
22 generally more useful in Windows.
23
24 If configure can't find your X include files or X libraries, you can
25 specify the paths with the arguments "--x-includes=inc_path" and/or
26 "--x-libraries=lib_path".
27
28 By default, the library and demo programs are built with the optimizer
29 switch -O2. You can turn this off, and turn on debugging (-g), by
30 adding "--with-debug" to the configure command.
31
32 . Run "make". This should build libXCurses and all the demo programs.
33
34 . Optionally, run "make install". curses.h and panel.h will be renamed
35 when installed (to xcurses.h and xpanel.h), to avoid conflicts with
36 any existing curses installations. Unrenamed copies of curses.h and
37 panel.h are installed in (by default) /usr/local/include/xcurses.
38
39 libXpanel is just a symlink to libXCurses. Both curses and panel
40 functions are in the main library.
41
42
43 Distribution Status
44 -------------------
45
46 As of April 13, 2006, the files in this directory are released to the
47 Public Domain, except for ScrollBox*, which are under essentially the
48 MIT X License.
49
50
51 To be Done
52 ----------
53
54 - have newterm() create a new X window
55
56 - provide a command line parsing function to enable X command line
57 arguments to be parsed and stripped from the arguments passed back
58 to the calling procedure.
59
60
61 Acknowledgements
62 ----------------
63
64 X11 port was provided by Mark Hessling <mark@rexx.org>
File x11/ScrollBox.c added (mode: 100644) (index 00000000..48ea38fd)
1 /*
2 * Copyright 1989 O'Reilly and Associates, Inc.
3
4 The X Consortium, and any party obtaining a copy of these files from
5 the X Consortium, directly or indirectly, is granted, free of charge, a
6 full and unrestricted irrevocable, world-wide, paid up, royalty-free,
7 nonexclusive right and license to deal in this software and
8 documentation files (the "Software"), including without limitation the
9 rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons who receive
11 copies from any such party to do so. This license includes without
12 limitation a license to do the foregoing actions under any patents of
13 the party supplying this software to the X Consortium.
14
15 $Id: ScrollBox.c,v 1.15 2008/07/14 04:24:52 wmcbrine Exp $
16 */
17
18 /* ScrollBox.c - scrollBox composite widget */
19
20 #include <X11/IntrinsicP.h>
21 #include <X11/StringDefs.h>
22 #include <X11/Shell.h>
23
24 #include "x11/ScrollBoxP.h"
25
26 #include <stdio.h>
27
28 #define INITIAL_WIDTH 300
29 #define INITIAL_HEIGHT 300
30
31 /************************************************************************
32 * *
33 * scrollBox Resources *
34 * *
35 ************************************************************************/
36
37 static XtResource resources[] =
38 {
39 { XtNhSpace, XtCHSpace, XtRDimension, sizeof(Dimension),
40 XtOffset(ScrollBoxWidget, scrollBox.h_space),
41 XtRImmediate, (XtPointer)4 },
42 { XtNvSpace, XtCVSpace, XtRDimension, sizeof(Dimension),
43 XtOffset(ScrollBoxWidget, scrollBox.v_space),
44 XtRImmediate, (XtPointer)4 },
45 { XtNheightInc, XtCHeightInc, XtRDimension, sizeof(Dimension),
46 XtOffset(ScrollBoxWidget, scrollBox.increment_height),
47 XtRImmediate, (XtPointer)13 },
48 { XtNwidthInc, XtCWidthInc, XtRDimension, sizeof(Dimension),
49 XtOffset(ScrollBoxWidget, scrollBox.increment_width),
50 XtRImmediate, (XtPointer)7 },
51 };
52
53 /************************************************************************
54 * *
55 * Full class record constant *
56 * *
57 ************************************************************************/
58
59 static void Initialize(Widget, Widget, ArgList, Cardinal *);
60 static void Resize(Widget);
61 static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
62 static void ChangeManaged(Widget);
63 static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
64 XtWidgetGeometry *);
65 static XtGeometryResult GeometryManager(Widget, XtWidgetGeometry *,
66 XtWidgetGeometry *);
67 static void RefigureLocations(Widget);
68
69 ScrollBoxClassRec scrollBoxClassRec = {
70 {
71 /* core_class fields */
72 /* superclass */ (WidgetClass) &compositeClassRec,
73 /* class_name */ "scrollBox",
74 /* widget_size */ sizeof(ScrollBoxRec),
75 /* class_initialize */ NULL,
76 /* class_part_init */ NULL,
77 /* class_inited */ FALSE,
78 /* initialize */ Initialize,
79 /* initialize_hook */ NULL,
80 /* realize */ XtInheritRealize,
81 /* actions */ NULL,
82 /* num_actions */ 0,
83 /* resources */ resources,
84 /* num_resources */ XtNumber(resources),
85 /* xrm_class */ NULLQUARK,
86 /* compress_motion */ TRUE,
87 /* compress_exposure */ TRUE,
88 /* compress_enterleave */ TRUE,
89 /* visible_interest */ FALSE,
90 /* destroy */ NULL,
91 /* resize */ Resize,
92 /* expose */ NULL,
93 /* set_values */ SetValues,
94 /* set_values_hook */ NULL,
95 /* set_values_almost */ XtInheritSetValuesAlmost,
96 /* get_values_hook */ NULL,
97 /* accept_focus */ NULL,
98 /* version */ XtVersion,
99 /* callback_private */ NULL,
100 /* tm_table */ NULL,
101 /* query_geometry */ QueryGeometry,
102 /* display_accelerator */ XtInheritDisplayAccelerator,
103 /* extension */ NULL
104 },{
105 /* composite_class fields */
106 /* geometry_manager */ GeometryManager,
107 /* change_managed */ ChangeManaged,
108 /* insert_child */ XtInheritInsertChild,
109 /* delete_child */ XtInheritDeleteChild,
110 /* extension */ NULL
111 },{
112 /* scrollBox class fields */
113 /* empty */ 0,
114 }
115 };
116
117 WidgetClass scrollBoxWidgetClass = (WidgetClass)&scrollBoxClassRec;
118
119
120 /************************************************************************
121 * *
122 * Private Routines *
123 * *
124 ************************************************************************/
125
126 /* Do a layout, either actually assigning positions, or just
127 calculating size. */
128
129 static void DoLayout(Widget w, Boolean doit)
130 {
131 ScrollBoxWidget sbw = (ScrollBoxWidget)w;
132 Widget wmain, vscroll, hscroll, child;
133 Dimension mw, mh; /* main window */
134 Dimension vh; /* vertical scrollbar length (height) */
135 Dimension hw; /* horizontal scrollbar length (width) */
136 Position vx;
137 Position hy;
138 Cardinal i;
139
140 if (sbw->composite.num_children != 3)
141 XtAppError(XtWidgetToApplicationContext(w),
142 "ScrollBox: must manage exactly three widgets.");
143
144 for (i = 0; i < sbw->composite.num_children; i++)
145 {
146 child = sbw->composite.children[i];
147
148 if (!XtIsManaged(child))
149 XtAppError(XtWidgetToApplicationContext(w),
150 "ScrollBox: all three widgets must be managed.");
151 }
152
153 /* Child one is the main window, two is the vertical scrollbar,
154 and three is the horizontal scrollbar. */
155
156 wmain = sbw->composite.children[0];
157 vscroll = sbw->composite.children[1];
158 hscroll = sbw->composite.children[2];
159
160 /* Size all three widgets so that space is fully utilized. */
161
162 mw = sbw->core.width - (2 * sbw->scrollBox.h_space) -
163 vscroll->core.width - (2 * vscroll->core.border_width) -
164 (2 * wmain->core.border_width);
165
166 mh = sbw->core.height - (2 * sbw->scrollBox.v_space) -
167 hscroll->core.height - (2 * hscroll->core.border_width) -
168 (2 * wmain->core.border_width);
169
170 /* Force the main window to be sized to the appropriate increment. */
171
172 mw = (mw / sbw->scrollBox.increment_width) *
173 sbw->scrollBox.increment_width;
174
175 mh = ((mh / sbw->scrollBox.increment_height) *
176 sbw->scrollBox.increment_height) +
177 sbw->scrollBox.increment_height;
178
179 vx = wmain->core.x + mw + sbw->scrollBox.h_space +
180 wmain->core.border_width + vscroll->core.border_width;
181
182 hy = wmain->core.y + mh + sbw->scrollBox.v_space +
183 wmain->core.border_width + hscroll->core.border_width;
184
185 vh = mh; /* scrollbars are always same length as main window */
186 hw = mw;
187
188 if (doit)
189 {
190 XtResizeWidget(wmain, mw, mh, 1);
191
192 XtResizeWidget(vscroll, vscroll->core.width, vh, 1);
193 XtMoveWidget(vscroll, vx, vscroll->core.y);
194
195 XtResizeWidget(hscroll, hw, hscroll->core.height, 1);
196 XtMoveWidget(hscroll, hscroll->core.x, hy);
197 }
198 }
199
200 static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *request,
201 XtWidgetGeometry *reply)
202 {
203 XtWidgetGeometry allowed;
204
205 if (request->request_mode & ~(XtCWQueryOnly | CWWidth | CWHeight))
206 return XtGeometryNo;
207
208 if (request->request_mode & CWWidth)
209 allowed.width = request->width;
210 else
211 allowed.width = w->core.width;
212
213 if (request->request_mode & CWHeight)
214 allowed.height = request->height;
215 else
216 allowed.height = w->core.height;
217
218 if (allowed.width == w->core.width && allowed.height == w->core.height)
219 return XtGeometryNo;
220
221 if (!(request->request_mode & XtCWQueryOnly))
222 RefigureLocations(w);
223
224 return XtGeometryYes;
225 }
226
227 static void RefigureLocations(Widget w)
228 {
229 DoLayout(w, False);
230 }
231
232 /* Calculate preferred size. We can't just use the current sizes
233 of the children, because that calculation would always end up with
234 our current size. Could query each child, and use that size to
235 recalculate a size for us, then if it ends up being larger than width
236 and height passed in, accept bounding box. However, we know our
237 children and they don't have any particular preferred geometry,
238 except the bigger the better. Therefore, if the parent suggested a
239 size, we'll take it. */
240
241 static XtGeometryResult QueryGeometry(Widget w, XtWidgetGeometry *request,
242 XtWidgetGeometry *reply_return)
243 {
244 XtGeometryResult result=XtGeometryNo;
245
246 request->request_mode &= CWWidth | CWHeight;
247
248 /* parent isn't going to change w or h, so nothing to re-compute */
249
250 if (request->request_mode == 0)
251 return XtGeometryYes;
252
253 /* if proposed size is large enough, accept it. Otherwise, suggest
254 our arbitrary initial size. */
255
256 if (request->request_mode & CWHeight)
257 {
258 if (request->height < INITIAL_HEIGHT)
259 {
260 result = XtGeometryAlmost;
261 reply_return->height = INITIAL_HEIGHT;
262 reply_return->request_mode &= CWHeight;
263 }
264 else
265 result = XtGeometryYes;
266 }
267
268 if (request->request_mode & CWWidth)
269 {
270 if (request->width < INITIAL_WIDTH)
271 {
272 result = XtGeometryAlmost;
273 reply_return->width = INITIAL_WIDTH;
274 reply_return->request_mode &= CWWidth;
275 }
276 else
277 result = XtGeometryYes;
278 }
279
280 return result;
281 }
282
283 /* Actually layout the scrollBox */
284
285 static void Resize(Widget w)
286 {
287 DoLayout(w, True);
288 }
289
290 static void ChangeManaged(Widget w)
291 {
292 DoLayout(w, True);
293 }
294
295 static void Initialize(Widget request, Widget new,
296 ArgList args, Cardinal *num_args)
297 {
298 ScrollBoxWidget newsbw = (ScrollBoxWidget)new;
299
300 if (newsbw->core.width == 0)
301 newsbw->core.width = INITIAL_WIDTH;
302
303 if (newsbw->core.height == 0)
304 newsbw->core.height = INITIAL_HEIGHT;
305
306 }
307
308 static Boolean SetValues(Widget current, Widget request, Widget new,
309 ArgList args, Cardinal *num_args)
310 {
311 ScrollBoxWidget sbwcurrent = (ScrollBoxWidget)current;
312 ScrollBoxWidget sbwnew = (ScrollBoxWidget)new;
313
314 /* need to relayout if h_space or v_space change */
315
316 if ((sbwnew->scrollBox.h_space != sbwcurrent->scrollBox.h_space) ||
317 (sbwnew->scrollBox.v_space != sbwcurrent->scrollBox.v_space))
318 DoLayout(new, True);
319
320 return False;
321 }
File x11/ScrollBox.h added (mode: 100644) (index 00000000..58258627)
1 /*
2 * Copyright 1989 O'Reilly and Associates, Inc.
3
4 The X Consortium, and any party obtaining a copy of these files from
5 the X Consortium, directly or indirectly, is granted, free of charge, a
6 full and unrestricted irrevocable, world-wide, paid up, royalty-free,
7 nonexclusive right and license to deal in this software and
8 documentation files (the "Software"), including without limitation the
9 rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons who receive
11 copies from any such party to do so. This license includes without
12 limitation a license to do the foregoing actions under any patents of
13 the party supplying this software to the X Consortium.
14
15 $Id: ScrollBox.h,v 1.4 2008/07/14 04:24:52 wmcbrine Exp $
16 */
17
18 #ifndef _XORAscrollBox_h
19 #define _XORAscrollBox_h
20
21 /************************************************************************
22 * *
23 * scrollBox Widget (subclass of CompositeClass) *
24 * *
25 ************************************************************************/
26
27 /* Parameters:
28
29 Name Class RepType Default Value
30 ---- ----- ------- -------------
31 background Background Pixel XtDefaultBackground
32 border BorderColor Pixel XtDefaultForeground
33 borderWidth BorderWidth Dimension 1
34 destroyCallback Callback Pointer NULL
35 hSpace HSpace Dimension 4
36 height Height Dimension 0
37 mappedWhenManaged MappedWhenManaged Boolean True
38 vSpace VSpace Dimension 4
39 width Width Dimension 0
40 x Position Position 0
41 y Position Position 0
42
43 */
44
45
46 /* Class record constants */
47
48 extern WidgetClass scrollBoxWidgetClass;
49
50 typedef struct _ScrollBoxClassRec *ScrollBoxWidgetClass;
51 typedef struct _ScrollBoxRec *ScrollBoxWidget;
52
53 #endif /* _XORAscrollBox_h */
File x11/ScrollBoxP.h added (mode: 100644) (index 00000000..069666da)
1 /*
2 * Copyright 1989 O'Reilly and Associates, Inc.
3
4 The X Consortium, and any party obtaining a copy of these files from
5 the X Consortium, directly or indirectly, is granted, free of charge, a
6 full and unrestricted irrevocable, world-wide, paid up, royalty-free,
7 nonexclusive right and license to deal in this software and
8 documentation files (the "Software"), including without limitation the
9 rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons who receive
11 copies from any such party to do so. This license includes without
12 limitation a license to do the foregoing actions under any patents of
13 the party supplying this software to the X Consortium.
14
15 $Id: ScrollBoxP.h,v 1.5 2008/07/14 04:24:52 wmcbrine Exp $
16 */
17
18 /*
19 * scrollBoxP.h - Private definitions for scrollBox widget
20 *
21 */
22
23 #ifndef _XORAscrollBoxP_h
24 #define _XORAscrollBoxP_h
25
26 /************************************************************************
27 * *
28 * scrollBox Widget Private Data *
29 * *
30 ************************************************************************/
31
32 #include "x11/ScrollBox.h"
33
34 #include <X11/CompositeP.h>
35
36 /* New fields for the scrollBox widget class record */
37 typedef struct _ScrollBoxClass {
38 int empty;
39 } ScrollBoxClassPart;
40
41 /* Full class record declaration */
42 typedef struct _ScrollBoxClassRec {
43 CoreClassPart core_class;
44 CompositeClassPart composite_class;
45 ScrollBoxClassPart scrollBox_class;
46 } ScrollBoxClassRec;
47
48 extern ScrollBoxClassRec scrollBoxClassRec;
49
50 /* New fields for the scrollBox widget record */
51 typedef struct {
52 Dimension h_space, v_space;
53 Dimension preferred_width, preferred_height;
54 Dimension last_query_width, last_query_height;
55 Dimension increment_width, increment_height;
56 XtGeometryMask last_query_mode;
57 } ScrollBoxPart;
58
59
60 /************************************************************************
61 * *
62 * Full instance record declaration *
63 * *
64 ************************************************************************/
65
66 typedef struct _ScrollBoxRec {
67 CorePart core;
68 CompositePart composite;
69 ScrollBoxPart scrollBox;
70 } ScrollBoxRec;
71
72 #endif /* _XORAscrollBoxP_h */
File x11/big_icon.xbm added (mode: 100644) (index 00000000..04b98a5b)
1 #define big_icon_width 64
2 #define big_icon_height 64
3 static unsigned char big_icon_bits[] = {
4 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
9 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xc1, 0x03, 0x00, 0x00,
10 0x00, 0x00, 0xf0, 0xff, 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
11 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0, 0xc7, 0x03, 0x00, 0x00,
12 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x80,
13 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00,
14 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0,
15 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe0, 0xc3, 0x03, 0x00, 0x00,
16 0x00, 0x00, 0xf0, 0xf0, 0xe3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8,
17 0xf1, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xfc, 0xf8, 0x03, 0x00, 0x00,
18 0x00, 0x00, 0xf0, 0x7e, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f,
19 0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0xff, 0x03, 0x00, 0x00,
20 0x00, 0x00, 0xf0, 0x8f, 0xdf, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc7,
21 0xcf, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe3, 0xc7, 0x03, 0x00, 0x00,
22 0x00, 0x00, 0xf0, 0xf1, 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0,
23 0xc1, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8, 0xc0, 0x03, 0x00, 0x00,
24 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78,
25 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00,
26 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8,
27 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xff, 0x03, 0x00, 0x00,
28 0x00, 0x00, 0xf0, 0xf0, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe0,
29 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0, 0xff, 0x03, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x23, 0x50, 0x1e,
33 0x7c, 0xf0, 0xe0, 0x03, 0x60, 0x26, 0x50, 0x33, 0xc6, 0x98, 0x31, 0x06,
34 0x30, 0x2c, 0xd0, 0x61, 0x83, 0x0d, 0x1b, 0x0c, 0x10, 0x28, 0xd0, 0x40,
35 0x01, 0x05, 0x0a, 0x08, 0x10, 0x20, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08,
36 0x10, 0x20, 0x50, 0x00, 0x03, 0x04, 0x1a, 0x00, 0x10, 0x20, 0x50, 0x00,
37 0x06, 0x04, 0x32, 0x00, 0x10, 0x20, 0x50, 0x00, 0x7c, 0xfc, 0xe3, 0x03,
38 0x10, 0x20, 0x50, 0x00, 0xc0, 0x04, 0x00, 0x06, 0x10, 0x20, 0x50, 0x00,
39 0x80, 0x05, 0x00, 0x0c, 0x10, 0x20, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08,
40 0x10, 0x28, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08, 0x30, 0x6c, 0x58, 0x00,
41 0x83, 0x0d, 0x1b, 0x0c, 0x60, 0xc6, 0x4c, 0x00, 0xc6, 0x98, 0x31, 0x06,
42 0xc0, 0x83, 0x47, 0x00, 0x7c, 0xf0, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
File x11/compose.h added (mode: 100644) (index 00000000..12b85fa1)
1 /* Public Domain Curses */
2
3 /* $Id: compose.h,v 1.3 2008/07/14 04:24:52 wmcbrine Exp $ */
4
5 /* Tables and variables for the built-in compose key system. This file
6 is not included when PDCurses is built with XIM support. */
7
8 #define MAX_COMPOSE_CHARS 14
9 #define MAX_COMPOSE_PRE 60
10
11 static const char *compose_chars =
12 "`'~^,/\"AaPpSs!?0123CcRr-_<>Xx.=Yy |EeIiOoUu+NnLlgDd:*TtMmVv";
13
14 /*
15 ` : À È Ì Ò Ù à è ì ò ù
16 ' : ´ Á É Í Ó Ú Ý á é í ó ú ý ´
17 ~ : Ã Ñ Õ ã ñ õ
18 ^ : Â Ê Î Ô Û â ê î ô û ° ¹ ² ³
19 , : ¸ Ç ç ¸
20 / : Ø ø µ µ
21 " : ¨ Ä Ë Ï Ö Ü ä ë ï ö ü ÿ ¨
22 A : Æ À Á Ã Â Å Å Ã Â ª
23 a : æ à á ã â å å ã â ª
24 P : Þ ¶ ¶
25 p : þ ¶ ¶
26 S : § § § º ª
27 s : ß § ª ¹ ² ³ º §
28 ! : ¡ ¡
29 ? : ¿ ¿
30 0 : ° °
31 1 : ¹ ½ ¼ ¹
32 2 : ² ²
33 3 : ³ ¾ ³
34 C : © Ç ¢ ¢
35 c : ¢ © ç ¢ ¢
36 R : ®
37 r : ®
38 - : ­ ± ¬ ­ ¯ ÷
39 _ : ¯ ¯
40 < : «
41 > : «
42 X : ¤ ×
43 x : × ¤ ×
44 . : · · ·
45 = : ¥ ¥
46 Y : ¥ Ý ¥
47 y : ¥ ý ÿ ¥ ¥
48 :
49 | : ¦ ¢ ¦ Þ þ ¦ £
50 E : È É Ê Ë Ê
51 e : è é ê ë ê
52 I : Ì Í Î Ï Î
53 i : ì í î ï î
54 O : Ò Ó Ô Õ Ö Ø © ® Õ Ô Å å
55 o : ° Å å ¤ õ ò ó ô õ ö ø ô º
56 U : Ù Ú Û Ü Û
57 u : ù ú û ü µ û
58 + : ±
59 N : Ñ Ñ ¬
60 n : ñ ñ ¬
61 L : £ £ £
62 l : £ £ £
63 g : ¤
64 D : ° Ð
65 d : ° ð
66 : : ÷
67 * : µ µ å Å
68 T : Þ
69 t : þ
70 M : ×
71 m : ×
72 V : ¦
73 v : ¦
74 */
75
76 static const char compose_lookups[MAX_COMPOSE_PRE][MAX_COMPOSE_CHARS] =
77 {
78 /* ` */ {'A','E','I','O','U','a','e','i','o','u', 0, 0, 0, 0},
79 /* ' */ {' ','A','E','I','O','U','Y','a','e','i','o','u','y', 39},
80 /* ~ */ {'A','N','O','a','n','o', 0, 0, 0, 0, 0, 0, 0, 0},
81 /* ^ */ {'A','E','I','O','U','a','e','i','o','u','0','1','2','3'},
82 /* , */ {' ','C','c',',', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
83 /* / */ {'O','o','u','U', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
84 /* " */ {' ','A','E','I','O','U','a','e','i','o','u','y','\"', 0},
85 /* A */ {'E','`', 39,'~','^','"','o','*','-','>','_', 0, 0, 0},
86 /* a */ {'e','`', 39,'~','^','"','o','*','-','>','_', 0, 0, 0},
87 /* P */ {' ','G','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
88 /* p */ {' ','g','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
89 /* S */ {'S','!','O','0','A', 0, 0, 0, 0, 0, 0, 0, 0, 0},
90 /* s */ {'s','!','a','1','2','3','0','o', 0, 0, 0, 0, 0, 0},
91 /* ! */ {' ','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
92 /* ? */ {' ','?', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
93 /* 0 */ {'^','*', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
94 /* 1 */ {' ','2','4','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
95 /* 2 */ {' ','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
96 /* 3 */ {' ','4','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
97 /* C */ {'O',',','$','|', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
98 /* c */ {'|','o',',','/','$', 0, 0, 0, 0, 0, 0, 0, 0, 0},
99 /* R */ {'O', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
100 /* r */ {'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
101 /* - */ {' ','+',',','-','^',':', 0, 0, 0, 0, 0, 0, 0, 0},
102 /* _ */ {'_','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
103 /* < */ {'<', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
104 /* > */ {'>', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
105 /* X */ {'O','X', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
106 /* x */ {' ','o','x', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
107 /* . */ {' ','^','.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
108 /* = */ {'Y','y', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
109 /* Y */ {'=', 39,'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
110 /* y */ {'=', 39,'"','$','-', 0, 0, 0, 0, 0, 0, 0, 0, 0},
111 /* */ {' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
112 /* | */ {' ','c','|','P','p','^','-', 0, 0, 0, 0, 0, 0, 0},
113 /* E */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
114 /* e */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
115 /* I */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
116 /* i */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
117 /* O */ {'`', 39,'^','~','"','/','C','R','-','>','A','a', 0, 0},
118 /* o */ {' ','A','a','x','-','`', 39,'^','~','"','/','>','_', 0},
119 /* U */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
120 /* u */ {'`', 39,'^','"',' ','>', 0, 0, 0, 0, 0, 0, 0, 0},
121 /* + */ {'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
122 /* N */ {'~','-','O', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
123 /* n */ {'~','-','o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
124 /* L */ {'$','=','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
125 /* l */ {'$','=','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
126 /* g */ {'$', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
127 /* D */ {'E','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
128 /* d */ {'e','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
129 /* : */ {'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
130 /* * */ {'m','M','a','A', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
131 /* T */ {'H', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
132 /* t */ {'h', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
133 /* M */ {'U', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
134 /* m */ {'u', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
135 /* V */ {'B', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
136 /* v */ {'b', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
137 };
138
139 static const unsigned char compose_keys[MAX_COMPOSE_PRE][MAX_COMPOSE_CHARS] =
140 {
141 /* ` */ {192,200,204,210,217,224,232,236,242,249, 0, 0, 0, 0},
142 /* ' */ {180,193,201,205,211,218,221,225,233,237,243,250,253,180},
143 /* ~ */ {195,209,213,227,241,245, 0, 0, 0, 0, 0, 0, 0, 0},
144 /* ^ */ {194,202,206,212,219,226,234,238,244,251,176,185,178,179},
145 /* , */ {184,199,231,184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
146 /* / */ {216,248,181,181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
147 /* " */ {168,196,203,207,214,220,228,235,239,246,252,255,168, 0},
148 /* A */ {198,192,193,195,194,196,197,197,195,194,170, 0, 0, 0},
149 /* a */ {230,224,225,227,226,228,229,229,227,226,170, 0, 0, 0},
150 /* P */ {222,182,182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
151 /* p */ {254,182,182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
152 /* S */ {167,167,167,186,170, 0, 0, 0, 0, 0, 0, 0, 0, 0},
153 /* s */ {223,167,170,185,178,179,186,167, 0, 0, 0, 0, 0, 0},
154 /* ! */ {161,161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
155 /* ? */ {191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
156 /* 0 */ {176,176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
157 /* 1 */ {185,189,188,185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
158 /* 2 */ {178,178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
159 /* 3 */ {179,190,179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
160 /* C */ {169,199,162,162, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
161 /* c */ {162,169,231,162,162, 0, 0, 0, 0, 0, 0, 0, 0, 0},
162 /* R */ {174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
163 /* r */ {174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
164 /* - */ {173,177,172,173,175,247, 0, 0, 0, 0, 0, 0, 0, 0},
165 /* _ */ {175,175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
166 /* < */ {171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
167 /* > */ {187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
168 /* X */ {164,215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
169 /* x */ {215,164,215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
170 /* . */ {183,183,183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
171 /* = */ {165,165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
172 /* Y */ {165,221,165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
173 /* y */ {165,253,255,165,165, 0, 0, 0, 0, 0, 0, 0, 0, 0},
174 /* */ {160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
175 /* | */ {166,162,166,222,254,166,163, 0, 0, 0, 0, 0, 0, 0},
176 /* E */ {200,201,202,203,202, 0, 0, 0, 0, 0, 0, 0, 0, 0},
177 /* e */ {232,233,234,235,234, 0, 0, 0, 0, 0, 0, 0, 0, 0},
178 /* I */ {204,205,206,207,206, 0, 0, 0, 0, 0, 0, 0, 0, 0},
179 /* i */ {236,237,238,239,238, 0, 0, 0, 0, 0, 0, 0, 0, 0},
180 /* O */ {210,211,212,213,214,216,169,174,213,212,197,229, 0, 0},
181 /* o */ {176,197,229,164,245,242,243,244,245,246,248,244,186, 0},
182 /* U */ {217,218,219,220,219, 0, 0, 0, 0, 0, 0, 0, 0, 0},
183 /* u */ {249,250,251,252,181,251, 0, 0, 0, 0, 0, 0, 0, 0},
184 /* + */ {177, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
185 /* N */ {209,209,172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
186 /* n */ {241,241,172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
187 /* L */ {163,163,163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
188 /* l */ {163,163,163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
189 /* g */ {164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
190 /* D */ {176,208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
191 /* d */ {176,240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
192 /* : */ {247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
193 /* * */ {181,181,229,197, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
194 /* T */ {222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
195 /* t */ {254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
196 /* M */ {215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
197 /* u */ {215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
198 /* V */ {166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
199 /* v */ {166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
200 };
201
202 static KeySym compose_key = 0;
203 static int compose_mask = 0;
File x11/little_icon.xbm added (mode: 100644) (index 00000000..d3e777e8)
1 #define little_icon_width 32
2 #define little_icon_height 32
3 static unsigned char little_icon_bits[] = {
4 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5 0x00, 0xfc, 0x30, 0x00, 0x00, 0xfc, 0x31, 0x00, 0x00, 0x8c, 0x33, 0x00,
6 0x00, 0x0c, 0x33, 0x00, 0x00, 0x0c, 0x33, 0x00, 0x00, 0x8c, 0x33, 0x00,
7 0x00, 0xcc, 0x39, 0x00, 0x00, 0xec, 0x3c, 0x00, 0x00, 0x7c, 0x3e, 0x00,
8 0x00, 0x3c, 0x37, 0x00, 0x00, 0x9c, 0x33, 0x00, 0x00, 0xcc, 0x31, 0x00,
9 0x00, 0xcc, 0x30, 0x00, 0x00, 0xcc, 0x30, 0x00, 0x00, 0xcc, 0x31, 0x00,
10 0x00, 0x8c, 0x3f, 0x00, 0x00, 0x0c, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
11 0x00, 0x00, 0x00, 0x00, 0x4c, 0x2a, 0xc6, 0x18, 0x52, 0x5a, 0x29, 0x25,
12 0x42, 0x0a, 0x21, 0x05, 0x42, 0x0a, 0xe6, 0x18, 0x42, 0x0a, 0x28, 0x20,
13 0x52, 0x0a, 0x29, 0x25, 0x8c, 0x09, 0xc6, 0x18, 0x00, 0x00, 0x00, 0x00,
14 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
File x11/ncurses_cfg.h added (mode: 100644) (index 00000000..42571180)
1 /* $Id: ncurses_cfg.h,v 1.8 2006/12/28 01:02:03 wmcbrine Exp $
2 *
3 * This file is only used with the ncurses test programs.
4 *
5 * Have ncurses-5.6 unpacked in your $(HOME) (you don't need to build
6 * it), or edit ncurses_testdir appropriately in the Makefile. Configure
7 * and build PDCurses for X11. (Sorry, other ports won't work yet.)
8 * Change to this directory, and:
9 *
10 * "make ncurses_tests" to start.
11 * "make ncurses_clean" when you're done.
12 *
13 * Builds: bs gdc hanoi knight tclock ncurses
14 */
15
16 #define NCURSES_MOUSE_VERSION 2
17
18 #include "../config.h"
19 #include <curses.h>
20
21 #define ExitProgram exit
22
23 #define HAVE_CURSES_VERSION 1
24 #define HAVE_GETBEGX 1
25 #define HAVE_GETCURX 1
26 #define HAVE_GETMAXX 1
27 #define HAVE_GETNSTR 1
28 #define HAVE_GETTIMEOFDAY 1
29 #define HAVE_GETWIN 1
30 #define HAVE_LIBPANEL 1
31 #define HAVE_LOCALE_H 1
32 #define HAVE_NAPMS 1
33 #define HAVE_PANEL_H 1
34 #define HAVE_PUTWIN 1
35 #define HAVE_SLK_COLOR 1
36 #define HAVE_SLK_INIT 1
37 #define HAVE_WRESIZE 1
38
39 #ifdef PDC_WIDE
40 # define USE_WIDEC_SUPPORT 1
41 #endif
42
43 /* Fool ncurses.c so it gives us all the tests, and doesn't redefine
44 ACS_ chars
45 */
46
47 #define NCURSES_VERSION PDCURSES
File x11/pdcclip.c added (mode: 100644) (index 00000000..1a3ce92a)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdcclip.c,v 1.35 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <stdlib.h>
8
9 /*man-start**************************************************************
10
11 Name: clipboard
12
13 Synopsis:
14 int PDC_getclipboard(char **contents, long *length);
15 int PDC_setclipboard(const char *contents, long length);
16 int PDC_freeclipboard(char *contents);
17 int PDC_clearclipboard(void);
18
19 Description:
20 PDC_getclipboard() gets the textual contents of the system's
21 clipboard. This function returns the contents of the clipboard
22 in the contents argument. It is the responsibilitiy of the
23 caller to free the memory returned, via PDC_freeclipboard().
24 The length of the clipboard contents is returned in the length
25 argument.
26
27 PDC_setclipboard copies the supplied text into the system's
28 clipboard, emptying the clipboard prior to the copy.
29
30 PDC_clearclipboard() clears the internal clipboard.
31
32 Return Values:
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 X/Open BSD SYS V
41 PDC_getclipboard - - -
42 PDC_setclipboard - - -
43 PDC_freeclipboard - - -
44 PDC_clearclipboard - - -
45
46 **man-end****************************************************************/
47
48 int PDC_getclipboard(char **contents, long *length)
49 {
50 #ifdef PDC_WIDE
51 wchar_t *wcontents;
52 #endif
53 int result = 0;
54 int len;
55
56 PDC_LOG(("PDC_getclipboard() - called\n"));
57
58 XCursesInstructAndWait(CURSES_GET_SELECTION);
59
60 if (XC_read_socket(xc_display_sock, &result, sizeof(int)) < 0)
61 XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
62
63 if (result == PDC_CLIP_SUCCESS)
64 {
65 if (XC_read_socket(xc_display_sock, &len, sizeof(int)) < 0)
66 XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
67 #ifdef PDC_WIDE
68 wcontents = malloc((len + 1) * sizeof(wchar_t));
69 *contents = malloc(len * 3 + 1);
70
71 if (!wcontents || !*contents)
72 #else
73 *contents = malloc(len + 1);
74
75 if (!*contents)
76 #endif
77 XCursesExitCursesProcess(6, "exiting from PDC_getclipboard - "
78 "synchronization error");
79
80 if (len)
81 {
82 if (XC_read_socket(xc_display_sock,
83 #ifdef PDC_WIDE
84 wcontents, len * sizeof(wchar_t)) < 0)
85 #else
86 *contents, len) < 0)
87 #endif
88 XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
89 }
90
91 #ifdef PDC_WIDE
92 wcontents[len] = 0;
93 len = PDC_wcstombs(*contents, wcontents, len * 3);
94 free(wcontents);
95 #endif
96 (*contents)[len] = '\0';
97 *length = len;
98 }
99
100 return result;
101 }
102
103 int PDC_setclipboard(const char *contents, long length)
104 {
105 #ifdef PDC_WIDE
106 wchar_t *wcontents;
107 #endif
108 int rc;
109
110 PDC_LOG(("PDC_setclipboard() - called\n"));
111
112 #ifdef PDC_WIDE
113 wcontents = malloc((length + 1) * sizeof(wchar_t));
114 if (!wcontents)
115 return PDC_CLIP_MEMORY_ERROR;
116
117 length = PDC_mbstowcs(wcontents, contents, length);
118 #endif
119 XCursesInstruct(CURSES_SET_SELECTION);
120
121 /* Write, then wait for X to do its stuff; expect return code. */
122
123 if (XC_write_socket(xc_display_sock, &length, sizeof(long)) >= 0)
124 {
125 if (XC_write_socket(xc_display_sock,
126 #ifdef PDC_WIDE
127 wcontents, length * sizeof(wchar_t)) >= 0)
128 {
129 free(wcontents);
130 #else
131 contents, length) >= 0)
132 {
133 #endif
134 if (XC_read_socket(xc_display_sock, &rc, sizeof(int)) >= 0)
135 return rc;
136 }
137 }
138
139 XCursesExitCursesProcess(5, "exiting from PDC_setclipboard");
140
141 return PDC_CLIP_ACCESS_ERROR; /* not reached */
142 }
143
144 int PDC_freeclipboard(char *contents)
145 {
146 PDC_LOG(("PDC_freeclipboard() - called\n"));
147
148 free(contents);
149 return PDC_CLIP_SUCCESS;
150 }
151
152 int PDC_clearclipboard(void)
153 {
154 int rc;
155 long len = 0;
156
157 PDC_LOG(("PDC_clearclipboard() - called\n"));
158
159 XCursesInstruct(CURSES_CLEAR_SELECTION);
160
161 /* Write, then wait for X to do its stuff; expect return code. */
162
163 if (XC_write_socket(xc_display_sock, &len, sizeof(long)) >= 0)
164 if (XC_read_socket(xc_display_sock, &rc, sizeof(int)) >= 0)
165 return rc;
166
167 XCursesExitCursesProcess(5, "exiting from PDC_clearclipboard");
168
169 return PDC_CLIP_ACCESS_ERROR; /* not reached */
170 }
File x11/pdcdisp.c added (mode: 100644) (index 00000000..3700edb5)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdcdisp.c,v 1.46 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <string.h>
8
9 #ifdef CHTYPE_LONG
10
11 # define A(x) ((chtype)x | A_ALTCHARSET)
12
13 chtype acs_map[128] =
14 {
15 A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
16 A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
17 A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
18 A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
19 ')', '*',
20
21 # ifdef PDC_WIDE
22 0x2192, 0x2190, 0x2191, 0x2193,
23 # else
24 '>', '<', '^', 'v',
25 # endif
26
27 '/',
28
29 # ifdef PDC_WIDE
30 0x2588,
31 # else
32 A(0),
33 # endif
34
35 '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
36 '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
37 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
38 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
39
40 # ifdef PDC_WIDE
41 0x2666, 0x2592,
42 # else
43 A(1), A(2),
44 # endif
45
46 'b', 'c', 'd', 'e',
47
48 # ifdef PDC_WIDE
49 0x00b0, 0x00b1, 0x2591, 0x00a4, 0x2518, 0x2510, 0x250c, 0x2514,
50 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524,
51 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3,
52 0x00b7,
53 # else
54 A(7), A(8), '#', 0xa4, A(11), A(12), A(13), A(14), A(15), A(16),
55 A(17), A(18), A(19), A(20), A(21), A(22), A(23), A(24), A(25),
56 A(26), A(27), A(28), A(29), A(30), 0xb7,
57 # endif
58
59 A(127)
60 };
61
62 # undef A
63
64 #endif
65
66 int PDC_display_cursor(int oldrow, int oldcol, int newrow, int newcol,
67 int visibility)
68 {
69 char buf[30];
70 int idx, pos;
71
72 PDC_LOG(("%s:PDC_display_cursor() - called: NEW row %d col %d, vis %d\n",
73 XCLOGMSG, newrow, newcol, visibility));
74
75 if (visibility == -1)
76 {
77 /* Only send the CURSES_DISPLAY_CURSOR message, no data */
78
79 idx = CURSES_DISPLAY_CURSOR;
80 memcpy(buf, &idx, sizeof(int));
81 idx = sizeof(int);
82 }
83 else
84 {
85 idx = CURSES_CURSOR;
86 memcpy(buf, &idx, sizeof(int));
87
88 idx = sizeof(int);
89 pos = oldrow + (oldcol << 8);
90 memcpy(buf + idx, &pos, sizeof(int));
91
92 idx += sizeof(int);
93 pos = newrow + (newcol << 8);
94 memcpy(buf + idx, &pos, sizeof(int));
95
96 idx += sizeof(int);
97 }
98
99 if (XC_write_socket(xc_display_sock, buf, idx) < 0)
100 XCursesExitCursesProcess(1, "exiting from PDC_display_cursor");
101
102 return OK;
103 }
104
105 /* position hardware cursor at (y, x) */
106
107 void PDC_gotoyx(int row, int col)
108 {
109 PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
110
111 PDC_display_cursor(SP->cursrow, SP->curscol, row, col, SP->visibility);
112 }
113
114 /* update the given physical line to look like the corresponding line in
115 curscr */
116
117 void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
118 {
119 PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
120
121 XC_get_line_lock(lineno);
122
123 memcpy(Xcurscr + XCURSCR_Y_OFF(lineno) + (x * sizeof(chtype)), srcp,
124 len * sizeof(chtype));
125
126 *(Xcurscr + XCURSCR_START_OFF + lineno) = x;
127 *(Xcurscr + XCURSCR_LENGTH_OFF + lineno) = len;
128
129 XC_release_line_lock(lineno);
130
131 XCursesInstructAndWait(CURSES_REFRESH);
132 }
File x11/pdcgetsc.c added (mode: 100644) (index 00000000..8f7c0ad9)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdcgetsc.c,v 1.26 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /* return width of screen/viewport */
8
9 int PDC_get_columns(void)
10 {
11 PDC_LOG(("PDC_get_columns() - called\n"));
12
13 return XCursesCOLS;
14 }
15
16 /* get the cursor size/shape */
17
18 int PDC_get_cursor_mode(void)
19 {
20 return 0;
21 }
22
23 /* return number of screen rows */
24
25 int PDC_get_rows(void)
26 {
27 PDC_LOG(("PDC_get_rows() - called\n"));
28
29 return XCursesLINES;
30 }
File x11/pdckbd.c added (mode: 100644) (index 00000000..30c37a87)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdckbd.c,v 1.62 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: pdckbd
10
11 Synopsis:
12 unsigned long PDC_get_input_fd(void);
13
14 Description:
15 PDC_get_input_fd() returns the file descriptor that PDCurses
16 reads its input from. It can be used for select().
17
18 Portability X/Open BSD SYS V
19 PDC_get_input_fd - - -
20
21 **man-end****************************************************************/
22
23 /* check if a key or mouse event is waiting */
24
25 bool PDC_check_key(void)
26 {
27 struct timeval socket_timeout = {0};
28 int s;
29
30 /* Is something ready to be read on the socket ? Must be a key. */
31
32 FD_ZERO(&xc_readfds);
33 FD_SET(xc_key_sock, &xc_readfds);
34
35 if ((s = select(FD_SETSIZE, (FD_SET_CAST)&xc_readfds, NULL,
36 NULL, &socket_timeout)) < 0)
37 XCursesExitCursesProcess(3, "child - exiting from "
38 "PDC_check_key select failed");
39
40 PDC_LOG(("%s:PDC_check_key() - returning %s\n", XCLOGMSG,
41 s ? "TRUE" : "FALSE"));
42
43 return !!s;
44 }
45
46 /* return the next available key or mouse event */
47
48 int PDC_get_key(void)
49 {
50 unsigned long newkey = 0;
51 int key = 0;
52
53 if (XC_read_socket(xc_key_sock, &newkey, sizeof(unsigned long)) < 0)
54 XCursesExitCursesProcess(2, "exiting from PDC_get_key");
55
56 pdc_key_modifiers = (newkey >> 24) & 0xFF;
57 key = (int)(newkey & 0x00FFFFFF);
58
59 if (key == KEY_MOUSE && SP->key_code)
60 {
61 if (XC_read_socket(xc_key_sock, &pdc_mouse_status,
62 sizeof(MOUSE_STATUS)) < 0)
63 XCursesExitCursesProcess(2, "exiting from PDC_get_key");
64 }
65
66 PDC_LOG(("%s:PDC_get_key() - key %d returned\n", XCLOGMSG, key));
67
68 return key;
69 }
70
71 unsigned long PDC_get_input_fd(void)
72 {
73 PDC_LOG(("PDC_get_input_fd() - called\n"));
74
75 return xc_key_sock;
76 }
77
78 void PDC_set_keyboard_binary(bool on)
79 {
80 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
81 }
82
83 /* discard any pending keyboard or mouse input -- this is the core
84 routine for flushinp() */
85
86 void PDC_flushinp(void)
87 {
88 PDC_LOG(("PDC_flushinp() - called\n"));
89
90 while (PDC_check_key())
91 PDC_get_key();
92 }
93
94 int PDC_mouse_set(void)
95 {
96 return OK;
97 }
98
99 int PDC_modifiers_set(void)
100 {
101 return OK;
102 }
File x11/pdcscrn.c added (mode: 100644) (index 00000000..07b1a042)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdcscrn.c,v 1.55 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /* COLOR_PAIR to attribute encoding table. */
8
9 short *xc_atrtab = (short *)NULL;
10
11 /* close the physical screen */
12
13 void PDC_scr_close(void)
14 {
15 PDC_LOG(("PDC_scr_close() - called\n"));
16 }
17
18 void PDC_scr_free(void)
19 {
20 XCursesExit();
21
22 xc_atrtab = (short *)NULL;
23 }
24
25 /* open the physical screen -- allocate SP, miscellaneous intialization */
26
27 int PDC_scr_open(int argc, char **argv)
28 {
29 extern bool sb_started;
30
31 PDC_LOG(("PDC_scr_open() - called\n"));
32
33 if ((XCursesInitscr(argc, argv) == ERR) || !SP)
34 return ERR;
35
36 SP->cursrow = SP->curscol = 0;
37 SP->orig_attr = FALSE;
38 SP->sb_on = sb_started;
39 SP->sb_total_y = 0;
40 SP->sb_viewport_y = 0;
41 SP->sb_cur_y = 0;
42 SP->sb_total_x = 0;
43 SP->sb_viewport_x = 0;
44 SP->sb_cur_x = 0;
45
46 return OK;
47 }
48
49 /* the core of resize_term() */
50
51 int PDC_resize_screen(int nlines, int ncols)
52 {
53 PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
54 nlines, ncols));
55
56 if (nlines || ncols || !SP->resized)
57 return ERR;
58
59 shmdt((char *)Xcurscr);
60 XCursesInstructAndWait(CURSES_RESIZE);
61
62 if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
63 SP->XcurscrSize + XCURSESSHMMIN, 0700)) < 0)
64 {
65 perror("Cannot allocate shared memory for curscr");
66 kill(xc_otherpid, SIGKILL);
67 return ERR;
68 }
69
70 XCursesLINES = SP->lines;
71 XCursesCOLS = SP->cols;
72
73 PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d SP->lines %d "
74 "SP->cols %d\n", XCLOGMSG, shmid_Xcurscr,
75 shmkey_Xcurscr, SP->lines, SP->cols));
76
77 Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
78 xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
79
80 SP->resized = FALSE;
81
82 return OK;
83 }
84
85 void PDC_reset_prog_mode(void)
86 {
87 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
88 }
89
90 void PDC_reset_shell_mode(void)
91 {
92 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
93 }
94
95 void PDC_restore_screen_mode(int i)
96 {
97 }
98
99 void PDC_save_screen_mode(int i)
100 {
101 }
102
103 void PDC_init_pair(short pair, short fg, short bg)
104 {
105 xc_atrtab[pair * 2] = fg;
106 xc_atrtab[pair * 2 + 1] = bg;
107 }
108
109 int PDC_pair_content(short pair, short *fg, short *bg)
110 {
111 *fg = xc_atrtab[pair * 2];
112 *bg = xc_atrtab[pair * 2 + 1];
113
114 return OK;
115 }
116
117 bool PDC_can_change_color(void)
118 {
119 return TRUE;
120 }
121
122 int PDC_color_content(short color, short *red, short *green, short *blue)
123 {
124 XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
125
126 tmp->pixel = color;
127
128 XCursesInstructAndWait(CURSES_GET_COLOR);
129
130 *red = ((double)(tmp->red) * 1000 / 65535) + 0.5;
131 *green = ((double)(tmp->green) * 1000 / 65535) + 0.5;
132 *blue = ((double)(tmp->blue) * 1000 / 65535) + 0.5;
133
134 return OK;
135 }
136
137 int PDC_init_color(short color, short red, short green, short blue)
138 {
139 XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
140
141 tmp->pixel = color;
142
143 tmp->red = ((double)red * 65535 / 1000) + 0.5;
144 tmp->green = ((double)green * 65535 / 1000) + 0.5;
145 tmp->blue = ((double)blue * 65535 / 1000) + 0.5;
146
147 XCursesInstructAndWait(CURSES_SET_COLOR);
148
149 return OK;
150 }
File x11/pdcsetsc.c added (mode: 100644) (index 00000000..395060e8)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdcsetsc.c,v 1.33 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <string.h>
8
9 /*man-start**************************************************************
10
11 Name: pdcsetsc
12
13 Synopsis:
14 int PDC_set_blink(bool blinkon);
15 void PDC_set_title(const char *title);
16
17 Description:
18 PDC_set_blink() toggles whether the A_BLINK attribute sets an
19 actual blink mode (TRUE), or sets the background color to high
20 intensity (FALSE). The default is platform-dependent (FALSE in
21 most cases). It returns OK if it could set the state to match
22 the given parameter, ERR otherwise. Current platforms also
23 adjust the value of COLORS according to this function -- 16 for
24 FALSE, and 8 for TRUE.
25
26 PDC_set_title() sets the title of the window in which the curses
27 program is running. This function may not do anything on some
28 platforms. (Currently it only works in Win32 and X11.)
29
30 Portability X/Open BSD SYS V
31 PDC_set_blink - - -
32 PDC_set_title - - -
33
34 **man-end****************************************************************/
35
36 int PDC_curs_set(int visibility)
37 {
38 int ret_vis = SP->visibility;
39
40 PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
41
42 if (visibility != -1)
43 SP->visibility = visibility;
44
45 PDC_display_cursor(SP->cursrow, SP->curscol, SP->cursrow,
46 SP->curscol, visibility);
47
48 return ret_vis;
49 }
50
51 void PDC_set_title(const char *title)
52 {
53 int len;
54
55 PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
56
57 len = strlen(title) + 1; /* write nul character */
58
59 XCursesInstruct(CURSES_TITLE);
60
61 if (XC_write_display_socket_int(len) >= 0)
62 if (XC_write_socket(xc_display_sock, title, len) >= 0)
63 return;
64
65 XCursesExitCursesProcess(1, "exiting from PDC_set_title");
66 }
67
68 int PDC_set_blink(bool blinkon)
69 {
70 if (pdc_color_started)
71 COLORS = 16;
72
73 return blinkon ? ERR : OK;
74 }
File x11/pdcutil.c added (mode: 100644) (index 00000000..5b5109f8)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdcutil.c,v 1.10 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #if defined(HAVE_POLL) && !defined(HAVE_USLEEP)
8 # include <poll.h>
9 #endif
10
11 void PDC_beep(void)
12 {
13 PDC_LOG(("PDC_beep() - called\n"));
14
15 XCursesInstruct(CURSES_BELL);
16 }
17
18 void PDC_napms(int ms)
19 {
20 PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
21
22 #if defined(HAVE_USLEEP)
23
24 usleep(1000 * ms);
25
26 #elif defined(HAVE_POLL)
27 {
28 struct pollfd fd;
29 fd.fd = -1;
30 fd.events = 0;
31 poll(&fd, 1, ms);
32 }
33 #endif
34 }
35
36 const char *PDC_sysname(void)
37 {
38 return "X11";
39 }
File x11/pdcx11.c added (mode: 100644) (index 00000000..1e8d0d16)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdcx11.c,v 1.96 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <errno.h>
8 #include <stdlib.h>
9
10 /*** Functions that are called by both processes ***/
11
12 unsigned char *Xcurscr;
13
14 int XCursesProcess = 1;
15 int shmidSP;
16 int shmid_Xcurscr;
17 int shmkeySP;
18 int shmkey_Xcurscr;
19 int xc_otherpid;
20 int XCursesLINES = 24;
21 int XCursesCOLS = 80;
22 int xc_display_sock;
23 int xc_key_sock;
24 int xc_display_sockets[2];
25 int xc_key_sockets[2];
26 int xc_exit_sock;
27
28 fd_set xc_readfds;
29
30 static void _dummy_function(void)
31 {
32 }
33
34 void XC_get_line_lock(int row)
35 {
36 /* loop until we can write to the line -- Patch by:
37 Georg Fuchs, georg.fuchs@rz.uni-regensburg.de */
38
39 while (*(Xcurscr + XCURSCR_FLAG_OFF + row))
40 _dummy_function();
41
42 *(Xcurscr + XCURSCR_FLAG_OFF + row) = 1;
43 }
44
45 void XC_release_line_lock(int row)
46 {
47 *(Xcurscr + XCURSCR_FLAG_OFF + row) = 0;
48 }
49
50 int XC_write_socket(int sock_num, const void *buf, int len)
51 {
52 int start = 0, rc;
53
54 PDC_LOG(("%s:XC_write_socket called: sock_num %d len %d\n",
55 XCLOGMSG, sock_num, len));
56
57 #ifdef MOUSE_DEBUG
58 if (sock_num == xc_key_sock)
59 printf("%s:XC_write_socket(key) len: %d\n", XCLOGMSG, len);
60 #endif
61 while (1)
62 {
63 rc = write(sock_num, buf + start, len);
64
65 if (rc < 0 || rc == len)
66 return rc;
67
68 len -= rc;
69 start = rc;
70 }
71 }
72
73 int XC_read_socket(int sock_num, void *buf, int len)
74 {
75 int start = 0, length = len, rc;
76
77 PDC_LOG(("%s:XC_read_socket called: sock_num %d len %d\n",
78 XCLOGMSG, sock_num, len));
79
80 while (1)
81 {
82 rc = read(sock_num, buf + start, length);
83
84 #ifdef MOUSE_DEBUG
85 if (sock_num == xc_key_sock)
86 printf("%s:XC_read_socket(key) rc %d errno %d "
87 "resized: %d\n", XCLOGMSG, rc, errno, SP->resized);
88 #endif
89 if (rc < 0 && sock_num == xc_key_sock && errno == EINTR
90 && SP->resized != FALSE)
91 {
92 MOUSE_LOG(("%s:continuing\n", XCLOGMSG));
93
94 rc = 0;
95
96 if (SP->resized > 1)
97 SP->resized = TRUE;
98 else
99 SP->resized = FALSE;
100
101 memcpy(buf, &rc, sizeof(int));
102
103 return 0;
104 }
105
106 if (rc <= 0 || rc == length)
107 return rc;
108
109 length -= rc;
110 start = rc;
111 }
112 }
113
114 int XC_write_display_socket_int(int x)
115 {
116 return XC_write_socket(xc_display_sock, &x, sizeof(int));
117 }
118
119 #ifdef PDCDEBUG
120 void XC_say(const char *msg)
121 {
122 PDC_LOG(("%s:%s", XCLOGMSG, msg));
123 }
124 #endif
125
126 /*** Functions that are called by the "curses" process ***/
127
128 int XCursesInstruct(int flag)
129 {
130 PDC_LOG(("%s:XCursesInstruct() - called flag %d\n", XCLOGMSG, flag));
131
132 /* Send a request to X */
133
134 if (XC_write_display_socket_int(flag) < 0)
135 XCursesExitCursesProcess(4, "exiting from XCursesInstruct");
136
137 return OK;
138 }
139
140 int XCursesInstructAndWait(int flag)
141 {
142 int result;
143
144 XC_LOG(("XCursesInstructAndWait() - called\n"));
145
146 /* tell X we want to do something */
147
148 XCursesInstruct(flag);
149
150 /* wait for X to say the refresh has occurred*/
151
152 if (XC_read_socket(xc_display_sock, &result, sizeof(int)) < 0)
153 XCursesExitCursesProcess(5, "exiting from XCursesInstructAndWait");
154
155 if (result != CURSES_CONTINUE)
156 XCursesExitCursesProcess(6, "exiting from XCursesInstructAndWait"
157 " - synchronization error");
158
159 return OK;
160 }
161
162 static int _setup_curses(void)
163 {
164 int wait_value;
165
166 XC_LOG(("_setup_curses called\n"));
167
168 close(xc_display_sockets[1]);
169 close(xc_key_sockets[1]);
170
171 xc_display_sock = xc_display_sockets[0];
172 xc_key_sock = xc_key_sockets[0];
173
174 FD_ZERO(&xc_readfds);
175
176 XC_read_socket(xc_display_sock, &wait_value, sizeof(int));
177
178 if (wait_value != CURSES_CHILD)
179 return ERR;
180
181 /* Set LINES and COLS now so that the size of the shared memory
182 segment can be allocated */
183
184 if ((shmidSP = shmget(shmkeySP, sizeof(SCREEN) + XCURSESSHMMIN, 0700)) < 0)
185 {
186 perror("Cannot allocate shared memory for SCREEN");
187 kill(xc_otherpid, SIGKILL);
188 return ERR;
189 }
190
191 SP = (SCREEN*)shmat(shmidSP, 0, 0);
192
193 XCursesLINES = SP->lines;
194 LINES = XCursesLINES - SP->linesrippedoff - SP->slklines;
195 XCursesCOLS = COLS = SP->cols;
196
197 if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
198 SP->XcurscrSize + XCURSESSHMMIN, 0700)) < 0)
199 {
200 perror("Cannot allocate shared memory for curscr");
201 kill(xc_otherpid, SIGKILL);
202 return ERR;
203 }
204
205 PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d LINES %d COLS %d\n",
206 XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));
207
208 Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
209 xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
210
211 XC_LOG(("cursesprocess exiting from Xinitscr\n"));
212
213 /* Always trap SIGWINCH if the C library supports SIGWINCH */
214
215 XCursesSetSignal(SIGWINCH, XCursesSigwinchHandler);
216
217 atexit(XCursesExit);
218
219 return OK;
220 }
221
222 int XCursesInitscr(int argc, char *argv[])
223 {
224 int pid, rc;
225
226 XC_LOG(("XCursesInitscr() - called\n"));
227
228 shmkeySP = getpid();
229
230 if (socketpair(AF_UNIX, SOCK_STREAM, 0, xc_display_sockets) < 0)
231 {
232 fprintf(stderr, "ERROR: cannot create display socketpair\n");
233 return ERR;
234 }
235
236 if (socketpair(AF_UNIX, SOCK_STREAM, 0, xc_key_sockets) < 0)
237 {
238 fprintf(stderr, "ERROR: cannot create key socketpair\n");
239 return ERR;
240 }
241
242 pid = fork();
243
244 switch(pid)
245 {
246 case -1:
247 fprintf(stderr, "ERROR: cannot fork()\n");
248 return ERR;
249 break;
250
251 case 0: /* child */
252 shmkey_Xcurscr = getpid();
253 #ifdef XISPARENT
254 XCursesProcess = 0;
255 rc = _setup_curses();
256 #else
257 XCursesProcess = 1;
258 xc_otherpid = getppid();
259 rc = XCursesSetupX(argc, argv);
260 #endif
261 break;
262
263 default: /* parent */
264 shmkey_Xcurscr = pid;
265 #ifdef XISPARENT
266 XCursesProcess = 1;
267 xc_otherpid = pid;
268 rc = XCursesSetupX(argc, argv);
269 #else
270 XCursesProcess = 0;
271 rc = _setup_curses();
272 #endif
273 }
274
275 return rc;
276 }
277
278 static void _cleanup_curses_process(int rc)
279 {
280 PDC_LOG(("%s:_cleanup_curses_process() - called: %d\n", XCLOGMSG, rc));
281
282 shutdown(xc_display_sock, 2);
283 close(xc_display_sock);
284
285 shutdown(xc_key_sock, 2);
286 close(xc_key_sock);
287
288 shmdt((char *)SP);
289 shmdt((char *)Xcurscr);
290
291 if (rc)
292 _exit(rc);
293 }
294
295 void XCursesExitCursesProcess(int rc, char *msg)
296 {
297 PDC_LOG(("%s:XCursesExitCursesProcess() - called: %d %s\n",
298 XCLOGMSG, rc, msg));
299
300 endwin();
301 _cleanup_curses_process(rc);
302 }
303
304 void XCursesExit(void)
305 {
306 static bool called = FALSE;
307
308 XC_LOG(("XCursesExit() - called\n"));
309
310 if (FALSE == called)
311 {
312 XCursesInstruct(CURSES_EXIT);
313 _cleanup_curses_process(0);
314
315 called = TRUE;
316 }
317 }
File x11/pdcx11.h added (mode: 100644) (index 00000000..0b66c880)
1 /* Public Domain Curses */
2
3 /* $Id: pdcx11.h,v 1.64 2008/07/14 04:24:52 wmcbrine Exp $ */
4
5 #include <curspriv.h>
6
7 #ifdef HAVE_UNISTD_H
8 # include <unistd.h>
9 #endif
10
11 #include <signal.h>
12 #include <ctype.h>
13 #include <pwd.h>
14
15 #include <sys/types.h>
16 #include <sys/socket.h>
17 #ifdef HAVE_FCNTL_H
18 # include <fcntl.h>
19 #endif
20 #ifdef HAVE_SYS_SELECT_H
21 # include <sys/select.h> /* AIX needs this for FD_ZERO etc macros */
22 #endif
23 #include <sys/ipc.h>
24 #include <sys/shm.h>
25
26 #ifdef TIME_WITH_SYS_TIME
27 # include <sys/time.h>
28 # include <time.h>
29 #else
30 # ifdef HAVE_SYS_TIME_H
31 # include <sys/time.h>
32 # else
33 # include <time.h>
34 # endif
35 #endif
36
37 #include <Intrinsic.h>
38 #include <StringDefs.h>
39 #include <Shell.h>
40
41 #ifdef USE_XAW3D
42 # include <Xaw3d/Box.h>
43 # include <Xaw3d/Scrollbar.h>
44 #elif defined(USE_NEXTAW)
45 # include <neXtaw/Box.h>
46 # include <neXtaw/Scrollbar.h>
47 #else
48 # include <Xaw/Box.h>
49 # include <Xaw/Scrollbar.h>
50 #endif
51 #include "x11/ScrollBox.h"
52
53 #include "Xmu/StdSel.h"
54 #include "Xmu/Atoms.h"
55
56 #include <keysym.h>
57 #include <Xatom.h>
58
59 #define XCURSCR_Y_SIZE (XCursesLINES * XCursesCOLS * sizeof(chtype))
60 #define XCURSCR_FLAG_SIZE (XCursesLINES * sizeof(int))
61 #define XCURSCR_START_SIZE (XCursesLINES * sizeof(int))
62 #define XCURSCR_LENGTH_SIZE (XCursesLINES * sizeof(int))
63 #define XCURSCR_ATRTAB_SIZE (PDC_COLOR_PAIRS * 2 * sizeof(short))
64 #define XCURSCR_SIZE (XCURSCR_FLAG_SIZE + XCURSCR_START_SIZE + \
65 XCURSCR_LENGTH_SIZE + XCURSCR_Y_SIZE + XCURSCR_ATRTAB_SIZE + \
66 sizeof(XColor))
67
68 #define XCURSCR_Y_OFF(y) ((y) * XCursesCOLS * sizeof(chtype))
69 #define XCURSCR_FLAG_OFF (XCURSCR_Y_OFF(0) + XCURSCR_Y_SIZE)
70 #define XCURSCR_START_OFF (XCURSCR_FLAG_OFF + XCURSCR_FLAG_SIZE)
71 #define XCURSCR_LENGTH_OFF (XCURSCR_START_OFF + XCURSCR_START_SIZE)
72 #define XCURSCR_ATRTAB_OFF (XCURSCR_LENGTH_OFF + XCURSCR_LENGTH_SIZE)
73 #define XCURSCR_XCOLOR_OFF (XCURSCR_ATRTAB_OFF + XCURSCR_ATRTAB_SIZE)
74
75 typedef struct
76 {
77 int lines;
78 int cols;
79 Pixel cursorColor;
80 Pixel colorBlack;
81 Pixel colorRed;
82 Pixel colorGreen;
83 Pixel colorYellow;
84 Pixel colorBlue;
85 Pixel colorMagenta;
86 Pixel colorCyan;
87 Pixel colorWhite;
88 Pixel colorBoldBlack;
89 Pixel colorBoldRed;
90 Pixel colorBoldGreen;
91 Pixel colorBoldYellow;
92 Pixel colorBoldBlue;
93 Pixel colorBoldMagenta;
94 Pixel colorBoldCyan;
95 Pixel colorBoldWhite;
96 Pixel pointerForeColor;
97 Pixel pointerBackColor;
98 XFontStruct *normalFont;
99 XFontStruct *italicFont;
100 char *bitmap;
101 #ifdef HAVE_XPM_H
102 char *pixmap;
103 #endif
104 char *composeKey;
105 Cursor pointer;
106 int shmmin;
107 int borderWidth;
108 int borderColor;
109 int clickPeriod;
110 int doubleClickPeriod;
111 int scrollbarWidth;
112 int cursorBlinkRate;
113 char *textCursor;
114 } XCursesAppData;
115
116 extern XCursesAppData xc_app_data;
117
118 #define XCURSESSHMMIN xc_app_data.shmmin
119
120 #define XCLOGMSG (XCursesProcess ? " X" : "CURSES")
121
122 void XC_get_line_lock(int);
123 void XC_release_line_lock(int);
124
125 int PDC_display_cursor(int, int, int, int, int);
126
127 void XCursesExitCursesProcess(int, char *);
128 int XCursesInstruct(int);
129 int XCursesInstructAndWait(int);
130 int XCursesInitscr(int, char **);
131
132 int XC_write_socket(int, const void *, int);
133 int XC_read_socket(int, void *, int);
134 int XC_write_display_socket_int(int);
135
136 int XCursesSetupX(int argc, char *argv[]);
137 RETSIGTYPE XCursesSigwinchHandler(int signo);
138
139 #ifdef _HPUX_SOURCE
140 # define FD_SET_CAST int *
141 #else
142 # define FD_SET_CAST fd_set *
143 #endif
144
145 extern fd_set xc_readfds;
146
147 extern unsigned char *Xcurscr;
148 extern int XCursesProcess;
149 extern int shmidSP;
150 extern int shmid_Xcurscr;
151 extern int shmkeySP;
152 extern int shmkey_Xcurscr;
153 extern int xc_otherpid;
154 extern int XCursesLINES;
155 extern int XCursesCOLS;
156 extern int xc_display_sock;
157 extern int xc_key_sock;
158 extern int xc_display_sockets[2];
159 extern int xc_key_sockets[2];
160 extern int xc_exit_sock;
161
162 typedef RETSIGTYPE (*signal_handler)();
163
164 signal_handler XCursesSetSignal(int, signal_handler);
165
166 #ifdef PDCDEBUG
167 void XC_say(const char *msg);
168 # define XC_LOG(x) XC_say x
169 #else
170 # define XC_LOG(x)
171 #endif
172
173 #ifdef MOUSE_DEBUG
174 # define MOUSE_LOG(x) printf x
175 #else
176 # define MOUSE_LOG(x)
177 #endif
178
179 enum
180 {
181 CURSES_CLEAR_SELECTION, CURSES_DISPLAY_CURSOR, CURSES_SET_SELECTION,
182 CURSES_GET_SELECTION, CURSES_TITLE, CURSES_REFRESH_SCROLLBAR,
183 CURSES_RESIZE, CURSES_BELL, CURSES_CONTINUE, CURSES_CURSOR,
184 CURSES_CHILD, CURSES_REFRESH, CURSES_GET_COLOR, CURSES_SET_COLOR,
185 CURSES_EXIT
186 };
187
188 extern short *xc_atrtab;
File x11/sb.c added (mode: 100644) (index 00000000..a34f502b)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: sb.c,v 1.27 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9 Name: sb
10
11 Synopsis:
12 int sb_init(void)
13 int sb_set_horz(int total, int viewport, int cur)
14 int sb_set_vert(int total, int viewport, int cur)
15 int sb_get_horz(int *total, int *viewport, int *cur)
16 int sb_get_vert(int *total, int *viewport, int *cur)
17 int sb_refresh(void);
18
19 Description:
20 These functions manipulate the scrollbar.
21
22 Return Value:
23 All functions return OK on success and ERR on error.
24
25 Portability X/Open BSD SYS V
26 sb_init - - -
27 sb_set_horz - - -
28 sb_set_vert - - -
29 sb_get_horz - - -
30 sb_get_vert - - -
31 sb_refresh - - -
32
33 **man-end****************************************************************/
34
35 bool sb_started = FALSE;
36
37 /* sb_init() is the sb initialization routine.
38 This must be called before initscr(). */
39
40 int sb_init(void)
41 {
42 PDC_LOG(("sb_init() - called\n"));
43
44 if (SP)
45 return ERR;
46
47 sb_started = TRUE;
48
49 return OK;
50 }
51
52 /* sb_set_horz() - Used to set horizontal scrollbar.
53
54 total = total number of columns
55 viewport = size of viewport in columns
56 cur = current column in total */
57
58 int sb_set_horz(int total, int viewport, int cur)
59 {
60 PDC_LOG(("sb_set_horz() - called: total %d viewport %d cur %d\n",
61 total, viewport, cur));
62
63 if (!SP)
64 return ERR;
65
66 SP->sb_total_x = total;
67 SP->sb_viewport_x = viewport;
68 SP->sb_cur_x = cur;
69
70 return OK;
71 }
72
73 /* sb_set_vert() - Used to set vertical scrollbar.
74
75 total = total number of columns on line
76 viewport = size of viewport in columns
77 cur = current column in total */
78
79 int sb_set_vert(int total, int viewport, int cur)
80 {
81 PDC_LOG(("sb_set_vert() - called: total %d viewport %d cur %d\n",
82 total, viewport, cur));
83
84 if (!SP)
85 return ERR;
86
87 SP->sb_total_y = total;
88 SP->sb_viewport_y = viewport;
89 SP->sb_cur_y = cur;
90
91 return OK;
92 }
93
94 /* sb_get_horz() - Used to get horizontal scrollbar.
95
96 total = total number of lines
97 viewport = size of viewport in lines
98 cur = current line in total */
99
100 int sb_get_horz(int *total, int *viewport, int *cur)
101 {
102 PDC_LOG(("sb_get_horz() - called\n"));
103
104 if (!SP)
105 return ERR;
106
107 if (total)
108 *total = SP->sb_total_x;
109 if (viewport)
110 *viewport = SP->sb_viewport_x;
111 if (cur)
112 *cur = SP->sb_cur_x;
113
114 return OK;
115 }
116
117 /* sb_get_vert() - Used to get vertical scrollbar.
118
119 total = total number of lines
120 viewport = size of viewport in lines
121 cur = current line in total */
122
123 int sb_get_vert(int *total, int *viewport, int *cur)
124 {
125 PDC_LOG(("sb_get_vert() - called\n"));
126
127 if (!SP)
128 return ERR;
129
130 if (total)
131 *total = SP->sb_total_y;
132 if (viewport)
133 *viewport = SP->sb_viewport_y;
134 if (cur)
135 *cur = SP->sb_cur_y;
136
137 return OK;
138 }
139
140 /* sb_refresh() - Used to draw the scrollbars. */
141
142 int sb_refresh(void)
143 {
144 PDC_LOG(("sb_refresh() - called\n"));
145
146 if (!SP)
147 return ERR;
148
149 XCursesInstruct(CURSES_REFRESH_SCROLLBAR);
150
151 return OK;
152 }
153
File x11/x11.c added (mode: 100644) (index 00000000..97d44985)
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: x11.c,v 1.94 2008/07/14 04:33:26 wmcbrine Exp $")
6
7 #ifdef HAVE_DECKEYSYM_H
8 # include <DECkeysym.h>
9 #endif
10
11 #ifdef HAVE_SUNKEYSYM_H
12 # include <Sunkeysym.h>
13 #endif
14
15 #ifdef HAVE_XPM_H
16 # include <xpm.h>
17 #endif
18
19 #if defined PDC_XIM
20 # include <Xlocale.h>
21 #endif
22
23 #include <stdlib.h>
24 #include <string.h>
25
26 #ifndef XPOINTER_TYPEDEFED
27 typedef char * XPointer;
28 #endif
29
30 #ifndef MAX_PATH
31 # define MAX_PATH 256
32 #endif
33
34 XCursesAppData xc_app_data;
35
36 #if NeedWidePrototypes
37 # define PDC_SCROLLBAR_TYPE double
38 #else
39 # define PDC_SCROLLBAR_TYPE float
40 #endif
41
42 #define MAX_COLORS 16 /* maximum of "normal" colors */
43 #define COLOR_CURSOR MAX_COLORS /* color of cursor */
44 #define COLOR_BORDER MAX_COLORS + 1 /* color of border */
45
46 #define XCURSESDISPLAY (XtDisplay(drawing))
47 #define XCURSESWIN (XtWindow(drawing))
48
49 /* Default icons for XCurses applications. */
50
51 #include "big_icon.xbm"
52 #include "little_icon.xbm"
53
54 static void _selection_off(void);
55 static void _display_cursor(int, int, int, int);
56 static void _redraw_cursor(void);
57 static void _exit_process(int, int, char *);
58 static void _send_key_to_curses(unsigned long, MOUSE_STATUS *, bool);
59
60 static void XCursesButton(Widget, XEvent *, String *, Cardinal *);
61 static void XCursesHandleString(Widget, XEvent *, String *, Cardinal *);
62 static void XCursesKeyPress(Widget, XEvent *, String *, Cardinal *);
63 static void XCursesPasteSelection(Widget, XButtonEvent *);
64
65 static struct
66 {
67 KeySym keycode;
68 bool numkeypad;
69 unsigned short normal;
70 unsigned short shifted;
71 unsigned short control;
72 unsigned short alt;
73 } key_table[] =
74 {
75 /* keycode keypad normal shifted control alt*/
76 {XK_Left, FALSE, KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT},
77 {XK_Right, FALSE, KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT},
78 {XK_Up, FALSE, KEY_UP, KEY_SUP, CTL_UP, ALT_UP},
79 {XK_Down, FALSE, KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN},
80 {XK_Home, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
81 /* Sun Type 4 keyboard */
82 {XK_R7, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
83 {XK_End, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
84 /* Sun Type 4 keyboard */
85 {XK_R13, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
86 {XK_Prior, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
87 /* Sun Type 4 keyboard */
88 {XK_R9, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
89 {XK_Next, FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
90 /* Sun Type 4 keyboard */
91 {XK_R15, FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
92 {XK_Insert, FALSE, KEY_IC, KEY_SIC, CTL_INS, ALT_INS},
93 {XK_Delete, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
94 {XK_F1, FALSE, KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37)},
95 {XK_F2, FALSE, KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38)},
96 {XK_F3, FALSE, KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39)},
97 {XK_F4, FALSE, KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40)},
98 {XK_F5, FALSE, KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41)},
99 {XK_F6, FALSE, KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42)},
100 {XK_F7, FALSE, KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43)},
101 {XK_F8, FALSE, KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44)},
102 {XK_F9, FALSE, KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45)},
103 {XK_F10, FALSE, KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46)},
104 {XK_F11, FALSE, KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47)},
105 {XK_F12, FALSE, KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48)},
106 {XK_F13, FALSE, KEY_F(13), KEY_F(25), KEY_F(37), KEY_F(49)},
107 {XK_F14, FALSE, KEY_F(14), KEY_F(26), KEY_F(38), KEY_F(50)},
108 {XK_F15, FALSE, KEY_F(15), KEY_F(27), KEY_F(39), KEY_F(51)},
109 {XK_F16, FALSE, KEY_F(16), KEY_F(28), KEY_F(40), KEY_F(52)},
110 {XK_F17, FALSE, KEY_F(17), KEY_F(29), KEY_F(41), KEY_F(53)},
111 {XK_F18, FALSE, KEY_F(18), KEY_F(30), KEY_F(42), KEY_F(54)},
112 {XK_F19, FALSE, KEY_F(19), KEY_F(31), KEY_F(43), KEY_F(55)},
113 {XK_F20, FALSE, KEY_F(20), KEY_F(32), KEY_F(44), KEY_F(56)},
114 {XK_BackSpace, FALSE, 0x08, 0x08, CTL_BKSP, ALT_BKSP},
115 {XK_Tab, FALSE, 0x09, KEY_BTAB, CTL_TAB, ALT_TAB},
116 {XK_Select, FALSE, KEY_SELECT, KEY_SELECT, KEY_SELECT, KEY_SELECT},
117 {XK_Print, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
118 {XK_Find, FALSE, KEY_FIND, KEY_SFIND, KEY_FIND, KEY_FIND},
119 {XK_Pause, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
120 {XK_Clear, FALSE, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR},
121 {XK_Cancel, FALSE, KEY_CANCEL, KEY_SCANCEL, KEY_CANCEL, KEY_CANCEL},
122 {XK_Break, FALSE, KEY_BREAK, KEY_BREAK, KEY_BREAK, KEY_BREAK},
123 {XK_Help, FALSE, KEY_HELP, KEY_SHELP, KEY_LHELP, KEY_HELP},
124 {XK_L4, FALSE, KEY_UNDO, KEY_SUNDO, KEY_UNDO, KEY_UNDO},
125 {XK_L6, FALSE, KEY_COPY, KEY_SCOPY, KEY_COPY, KEY_COPY},
126 {XK_L9, FALSE, KEY_FIND, KEY_SFIND, KEY_FIND, KEY_FIND},
127 {XK_Menu, FALSE, KEY_OPTIONS, KEY_SOPTIONS, KEY_OPTIONS, KEY_OPTIONS},
128 #ifdef HAVE_SUNKEYSYM_H
129 {SunXK_F36, FALSE, KEY_F(41), KEY_F(43), KEY_F(45), KEY_F(47)},
130 {SunXK_F37, FALSE, KEY_F(42), KEY_F(44), KEY_F(46), KEY_F(48)},
131 #endif
132 #ifdef HAVE_DECKEYSYM_H
133 {DXK_Remove, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
134 #endif
135 {XK_Escape, FALSE, 0x1B, 0x1B, 0x1B, ALT_ESC},
136 {XK_KP_Enter, TRUE, PADENTER, PADENTER, CTL_PADENTER,ALT_PADENTER},
137 {XK_KP_Add, TRUE, PADPLUS, '+', CTL_PADPLUS, ALT_PADPLUS},
138 {XK_KP_Subtract,TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
139 {XK_KP_Multiply,TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
140 /* Sun Type 4 keyboard */
141 {XK_R6, TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
142 {XK_KP_Divide, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
143 /* Sun Type 4 keyboard */
144 {XK_R5, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
145 {XK_KP_Decimal,TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
146 {XK_KP_0, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
147 {XK_KP_1, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
148 {XK_KP_2, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
149 {XK_KP_3, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
150 {XK_KP_4, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
151 {XK_KP_5, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
152 /* Sun Type 4 keyboard */
153 {XK_R11, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
154 {XK_KP_6, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
155 {XK_KP_7, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
156 {XK_KP_8, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
157 {XK_KP_9, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
158 /* the following added to support Sun Type 5 keyboards */
159 {XK_F21, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
160 {XK_F22, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
161 {XK_F24, TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
162 /* Sun Type 4 keyboard */
163 {XK_F25, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
164 /* Sun Type 4 keyboard */
165 {XK_F26, TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
166 {XK_F27, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
167 {XK_F29, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
168 {XK_F31, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
169 {XK_F35, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
170 #ifdef HAVE_XK_KP_DELETE
171 {XK_KP_Delete, TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
172 #endif
173 #ifdef HAVE_XK_KP_INSERT
174 {XK_KP_Insert, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
175 #endif
176 #ifdef HAVE_XK_KP_END
177 {XK_KP_End, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
178 #endif
179 #ifdef HAVE_XK_KP_DOWN
180 {XK_KP_Down, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
181 #endif
182 #ifdef HAVE_XK_KP_NEXT
183 {XK_KP_Next, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
184 #endif
185 #ifdef HAVE_XK_KP_LEFT
186 {XK_KP_Left, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
187 #endif
188 #ifdef HAVE_XK_KP_BEGIN
189 {XK_KP_Begin, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
190 #endif
191 #ifdef HAVE_XK_KP_RIGHT
192 {XK_KP_Right, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
193 #endif
194 #ifdef HAVE_XK_KP_HOME
195 {XK_KP_Home, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
196 #endif
197 #ifdef HAVE_XK_KP_UP
198 {XK_KP_Up, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
199 #endif
200 #ifdef HAVE_XK_KP_PRIOR
201 {XK_KP_Prior, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
202 #endif
203 {0, 0, 0, 0, 0, 0}
204 };
205
206 #ifndef PDC_XIM
207 # include "compose.h"
208 #endif
209
210 #define BITMAPDEPTH 1
211
212 unsigned long pdc_key_modifiers = 0L;
213
214 static GC normal_gc, block_cursor_gc, rect_cursor_gc, italic_gc, border_gc;
215 static int font_height, font_width, font_ascent, font_descent,
216 window_width, window_height;
217 static int resize_window_width = 0, resize_window_height = 0;
218 static char *bitmap_file = NULL;
219 #ifdef HAVE_XPM_H
220 static char *pixmap_file = NULL;
221 #endif
222 static KeySym keysym = 0;
223
224 static int state_mask[8] =
225 {
226 ShiftMask,
227 LockMask,
228 ControlMask,
229 Mod1Mask,
230 Mod2Mask,
231 Mod3Mask,
232 Mod4Mask,
233 Mod5Mask
234 };
235
236 static Atom wm_atom[2];
237 static String class_name = "XCurses";
238 static XtAppContext app_context;
239 static Widget topLevel, drawing, scrollBox, scrollVert, scrollHoriz;
240 static int received_map_notify = 0;
241 static bool mouse_selection = FALSE;
242 static chtype *tmpsel = NULL;
243 static unsigned long tmpsel_length = 0;
244 static int selection_start_x = 0, selection_start_y = 0,
245 selection_end_x = 0, selection_end_y = 0;
246 static Pixmap icon_bitmap;
247 #ifdef HAVE_XPM_H
248 static Pixmap icon_pixmap;
249 static Pixmap icon_pixmap_mask;
250 #endif
251 static bool visible_cursor = FALSE;
252 static bool window_entered = TRUE;
253 static char *program_name;
254
255 /* Macros just for app_resources */
256
257 #ifdef PDC_WIDE
258 # define DEFFONT "-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1"
259 #else
260 # define DEFFONT "7x13"
261 #endif
262
263 #define APPDATAOFF(n) XtOffsetOf(XCursesAppData, n)
264
265 #define RINT(name1, name2, value) { \
266 #name1, #name2, XtRInt, \
267 sizeof(int), APPDATAOFF(name1), XtRImmediate, \
268 (XtPointer)value \
269 }
270
271 #define RPIXEL(name1, name2, value) { \
272 #name1, #name2, XtRPixel, \
273 sizeof(Pixel), APPDATAOFF(name1), XtRString, \
274 (XtPointer)#value \
275 }
276
277 #define RCOLOR(name, value) RPIXEL(color##name, Color##name, value)
278
279
280 #define RSTRINGP(name1, name2, param) { \
281 #name1, #name2, XtRString, \
282 MAX_PATH, APPDATAOFF(name1), XtRString, (XtPointer)param \
283 }
284
285 #define RSTRING(name1, name2) RSTRINGP(name1, name2, "")
286
287 #define RFONT(name1, name2, value) { \
288 #name1, #name2, XtRFontStruct, \
289 sizeof(XFontStruct), APPDATAOFF(name1), XtRString, \
290 (XtPointer)value \
291 }
292
293 #define RCURSOR(name1, name2, value) { \
294 #name1, #name2, XtRCursor, \
295 sizeof(Cursor), APPDATAOFF(name1), XtRString, \
296 (XtPointer)#value \
297 }
298
299 static XtResource app_resources[] =
300 {
301 RINT(lines, Lines, 24),
302 RINT(cols, Cols, 80),
303
304 RPIXEL(cursorColor, CursorColor, Red),
305
306 RCOLOR(Black, Black),
307 RCOLOR(Red, red3),
308 RCOLOR(Green, green3),
309 RCOLOR(Yellow, yellow3),
310 RCOLOR(Blue, blue3),
311 RCOLOR(Magenta, magenta3),
312 RCOLOR(Cyan, cyan3),
313 RCOLOR(White, Grey),
314
315 RCOLOR(BoldBlack, grey40),
316 RCOLOR(BoldRed, red1),
317 RCOLOR(BoldGreen, green1),
318 RCOLOR(BoldYellow, yellow1),
319 RCOLOR(BoldBlue, blue1),
320 RCOLOR(BoldMagenta, magenta1),
321 RCOLOR(BoldCyan, cyan1),
322 RCOLOR(BoldWhite, White),
323
324 RFONT(normalFont, NormalFont, DEFFONT),
325 RFONT(italicFont, ItalicFont, DEFFONT),
326
327 RSTRING(bitmap, Bitmap),
328 #ifdef HAVE_XPM_H
329 RSTRING(pixmap, Pixmap),
330 #endif
331 RSTRINGP(composeKey, ComposeKey, "Multi_key"),
332
333 RCURSOR(pointer, Pointer, xterm),
334
335 RPIXEL(pointerForeColor, PointerForeColor, Black),
336 RPIXEL(pointerBackColor, PointerBackColor, White),
337
338 RINT(shmmin, Shmmin, 0),
339 RINT(borderWidth, BorderWidth, 0),
340
341 RPIXEL(borderColor, BorderColor, Black),
342
343 RINT(doubleClickPeriod, DoubleClickPeriod, (PDC_CLICK_PERIOD * 2)),
344 RINT(clickPeriod, ClickPeriod, PDC_CLICK_PERIOD),
345 RINT(scrollbarWidth, ScrollbarWidth, 15),
346 RINT(cursorBlinkRate, CursorBlinkRate, 0),
347
348 RSTRING(textCursor, TextCursor)
349 };
350
351 #undef RCURSOR
352 #undef RFONT
353 #undef RSTRING
354 #undef RCOLOR
355 #undef RPIXEL
356 #undef RINT
357 #undef APPDATAOFF
358 #undef DEFFONT
359
360 /* Macros for options */
361
362 #define COPT(name) {"-" #name, "*" #name, XrmoptionSepArg, NULL}
363 #define CCOLOR(name) COPT(color##name)
364
365 static XrmOptionDescRec options[] =
366 {
367 COPT(lines), COPT(cols), COPT(normalFont), COPT(italicFont),
368 COPT(bitmap),
369 #ifdef HAVE_XPM_H
370 COPT(pixmap),
371 #endif
372 COPT(pointer), COPT(shmmin), COPT(composeKey), COPT(clickPeriod),
373 COPT(doubleClickPeriod), COPT(scrollbarWidth),
374 COPT(pointerForeColor), COPT(pointerBackColor),
375 COPT(cursorBlinkRate), COPT(cursorColor), COPT(textCursor),
376
377 CCOLOR(Black), CCOLOR(Red), CCOLOR(Green), CCOLOR(Yellow),
378 CCOLOR(Blue), CCOLOR(Magenta), CCOLOR(Cyan), CCOLOR(White),
379
380 CCOLOR(BoldBlack), CCOLOR(BoldRed), CCOLOR(BoldGreen),
381 CCOLOR(BoldYellow), CCOLOR(BoldBlue), CCOLOR(BoldMagenta),
382 CCOLOR(BoldCyan), CCOLOR(BoldWhite)
383 };
384
385 #undef CCOLOR
386 #undef COPT
387
388 static XtActionsRec action_table[] =
389 {
390 {"XCursesButton", (XtActionProc)XCursesButton},
391 {"XCursesKeyPress", (XtActionProc)XCursesKeyPress},
392 {"XCursesPasteSelection", (XtActionProc)XCursesPasteSelection},
393 {"string", (XtActionProc)XCursesHandleString}
394 };
395
396 static bool after_first_curses_request = FALSE;
397 static Pixel colors[MAX_COLORS + 2];
398 static bool vertical_cursor = FALSE;
399
400 #ifdef PDC_XIM
401 static XIM Xim = NULL;
402 static XIC Xic = NULL;
403 #endif
404
405 static const char *default_translations =
406 {
407 "<Key>: XCursesKeyPress() \n" \
408 "<KeyUp>: XCursesKeyPress() \n" \
409 "<BtnDown>: XCursesButton() \n" \
410 "<BtnUp>: XCursesButton() \n" \
411 "<BtnMotion>: XCursesButton()"
412 };
413
414 static int _to_utf8(char *outcode, chtype code)
415 {
416 #ifdef PDC_WIDE
417 if (code & A_ALTCHARSET && !(code & 0xff80))
418 code = acs_map[code & 0x7f];
419 #endif
420 code &= A_CHARTEXT;
421
422 if (code < 0x80)
423 {
424 outcode[0] = code;
425 return 1;
426 }
427 else
428 if (code < 0x800)
429 {
430 outcode[0] = ((code & 0x07c0) >> 6) | 0xc0;
431 outcode[1] = (code & 0x003f) | 0x80;
432 return 2;
433 }
434 else
435 {
436 outcode[0] = ((code & 0xf000) >> 12) | 0xe0;
437 outcode[1] = ((code & 0x0fc0) >> 6) | 0x80;
438 outcode[2] = (code & 0x003f) | 0x80;
439 return 3;
440 }
441 }
442
443 static int _from_utf8(wchar_t *pwc, const char *s, size_t n)
444 {
445 wchar_t key;
446 int i = -1;
447 const unsigned char *string;
448
449 if (!s || (n < 1))
450 return -1;
451
452 if (!*s)
453 return 0;
454
455 string = (const unsigned char *)s;
456
457 key = string[0];
458
459 /* Simplistic UTF-8 decoder -- only does the BMP, minimal validation */
460
461 if (key & 0x80)
462 {
463 if ((key & 0xe0) == 0xc0)
464 {
465 if (1 < n)
466 {
467 key = ((key & 0x1f) << 6) | (string[1] & 0x3f);
468 i = 2;
469 }
470 }
471 else if ((key & 0xe0) == 0xe0)
472 {
473 if (2 < n)
474 {
475 key = ((key & 0x0f) << 12) |
476 ((string[1] & 0x3f) << 6) | (string[2] & 0x3f);
477 i = 3;
478 }
479 }
480 }
481 else
482 i = 1;
483
484 if (i)
485 *pwc = key;
486
487 return i;
488 }
489
490 #ifndef X_HAVE_UTF8_STRING
491 static Atom XA_UTF8_STRING(Display *dpy)
492 {
493 static AtomPtr p = NULL;
494
495 if (!p)
496 p = XmuMakeAtom("UTF8_STRING");
497
498 return XmuInternAtom(dpy, p);
499 }
500 #endif
501
502 signal_handler XCursesSetSignal(int signo, signal_handler action)
503 {
504 #if defined(SA_INTERRUPT) || defined(SA_RESTART)
505 struct sigaction sigact, osigact;
506
507 sigact.sa_handler = action;
508
509 sigact.sa_flags =
510 # ifdef SA_INTERRUPT
511 # ifdef SA_RESTART
512 SA_INTERRUPT | SA_RESTART;
513 # else
514 SA_INTERRUPT;
515 # endif
516 # else /* must be SA_RESTART */
517 SA_RESTART;
518 # endif
519 sigemptyset(&sigact.sa_mask);
520
521 if (sigaction(signo, &sigact, &osigact))
522 return SIG_ERR;
523
524 return osigact.sa_handler;
525
526 #else /* not SA_INTERRUPT or SA_RESTART, use plain signal */
527 return signal(signo, action);
528 #endif
529 }
530
531 RETSIGTYPE XCursesSigwinchHandler(int signo)
532 {
533 PDC_LOG(("%s:XCursesSigwinchHandler() - called: SIGNO: %d\n",
534 XCLOGMSG, signo));
535
536 /* Patch by: Georg Fuchs, georg.fuchs@rz.uni-regensburg.de
537 02-Feb-1999 */
538
539 SP->resized += 1;
540
541 /* Always trap SIGWINCH if the C library supports SIGWINCH */
542
543 #ifdef SIGWINCH
544 XCursesSetSignal(SIGWINCH, XCursesSigwinchHandler);
545 #endif
546 }
547
548 /* Convert character positions x and y to pixel positions, stored in
549 xpos and ypos */
550
551 static void _make_xy(int x, int y, int *xpos, int *ypos)
552 {
553 *xpos = (x * font_width) + xc_app_data.borderWidth;
554 *ypos = xc_app_data.normalFont->ascent + (y * font_height) +
555 xc_app_data.borderWidth;
556 }
557
558 /* Output a block of characters with common attributes */
559
560 static int _new_packet(chtype attr, bool rev, int len, int col, int row,
561 #ifdef PDC_WIDE
562 XChar2b *text)
563 #else
564 char *text)
565 #endif
566 {
567 GC gc;
568 int xpos, ypos;
569 short fore, back;
570
571 PDC_pair_content(PAIR_NUMBER(attr), &fore, &back);
572
573 #ifdef PDC_WIDE
574 text[len].byte1 = text[len].byte2 = 0;
575 #else
576 text[len] = '\0';
577 #endif
578
579 /* Specify the color table offsets */
580
581 fore |= (attr & A_BOLD) ? 8 : 0;
582 back |= (attr & A_BLINK) ? 8 : 0;
583
584 /* Reverse flag = highlighted selection XOR A_REVERSE set */
585
586 rev ^= !!(attr & A_REVERSE);
587
588 /* Determine which GC to use - normal or italic */
589
590 gc = (attr & A_ITALIC) ? italic_gc : normal_gc;
591
592 /* Draw it */
593
594 XSetForeground(XCURSESDISPLAY, gc, colors[rev ? back : fore]);
595 XSetBackground(XCURSESDISPLAY, gc, colors[rev ? fore : back]);
596
597 _make_xy(col, row, &xpos, &ypos);
598
599 #ifdef PDC_WIDE
600 XDrawImageString16(
601 #else
602 XDrawImageString(
603 #endif
604 XCURSESDISPLAY, XCURSESWIN, gc, xpos, ypos, text, len);
605
606 /* Underline, etc. */
607
608 if (attr & (A_LEFTLINE|A_RIGHTLINE|A_UNDERLINE))
609 {
610 int k;
611
612 if (SP->line_color != -1)
613 XSetForeground(XCURSESDISPLAY, gc, colors[SP->line_color]);
614
615 if (attr & A_UNDERLINE) /* UNDER */
616 XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
617 xpos, ypos + 1, xpos + font_width * len, ypos + 1);
618
619 if (attr & A_LEFTLINE) /* LEFT */
620 for (k = 0; k < len; k++)
621 {
622 int x = xpos + font_width * k - 1;
623 XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
624 x, ypos - font_ascent, x, ypos + font_descent);
625 }
626
627 if (attr & A_RIGHTLINE) /* RIGHT */
628 for (k = 0; k < len; k++)
629 {
630 int x = xpos + font_width * (k + 1) - 1;
631 XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
632 x, ypos - font_ascent, x, ypos + font_descent);
633 }
634 }
635
636 PDC_LOG(("%s:_new_packet() - row: %d col: %d "
637 "num_cols: %d fore: %d back: %d text:<%s>\n",
638 XCLOGMSG, row, col, len, fore, back, text));
639
640 return OK;
641 }
642
643 /* The core display routine -- update one line of text */
644
645 static int _display_text(const chtype *ch, int row, int col,
646 int num_cols, bool highlight)
647 {
648 #ifdef PDC_WIDE
649 XChar2b text[513];
650 #else
651 char text[513];
652 #endif
653 chtype old_attr, attr;
654 int i, j;
655
656 PDC_LOG(("%s:_display_text() - called: row: %d col: %d "
657 "num_cols: %d\n", XCLOGMSG, row, col, num_cols));
658
659 if (!num_cols)
660 return OK;
661
662 old_attr = *ch & A_ATTRIBUTES;
663
664 for (i = 0, j = 0; j < num_cols; j++)
665 {
666 chtype curr = ch[j];
667
668 attr = curr & A_ATTRIBUTES;
669
670 #ifdef CHTYPE_LONG
671 if (attr & A_ALTCHARSET && !(curr & 0xff80))
672 {
673 attr ^= A_ALTCHARSET;
674 curr = acs_map[curr & 0x7f];
675 }
676 #endif
677
678 #ifndef PDC_WIDE
679 /* Special handling for ACS_BLOCK */
680
681 if (!(curr & A_CHARTEXT))
682 {
683 curr |= ' ';
684 attr ^= A_REVERSE;
685 }
686 #endif
687 if (attr != old_attr)
688 {
689 if (_new_packet(old_attr, highlight, i, col, row, text) == ERR)
690 return ERR;
691
692 old_attr = attr;
693 col += i;
694 i = 0;
695 }
696
697 #ifdef PDC_WIDE
698 text[i].byte1 = (curr & 0xff00) >> 8;
699 text[i++].byte2 = curr & 0x00ff;
700 #else
701 text[i++] = curr & 0xff;
702 #endif
703 }
704
705 return _new_packet(old_attr, highlight, i, col, row, text);
706 }
707
708 static void _get_gc(GC *gc, XFontStruct *font_info, int fore, int back)
709 {
710 XGCValues values;
711
712 /* Create default Graphics Context */
713
714 *gc = XCreateGC(XCURSESDISPLAY, XCURSESWIN, 0L, &values);
715
716 /* specify font */
717
718 XSetFont(XCURSESDISPLAY, *gc, font_info->fid);
719
720 XSetForeground(XCURSESDISPLAY, *gc, colors[fore]);
721 XSetBackground(XCURSESDISPLAY, *gc, colors[back]);
722 }
723
724 static void _initialize_colors(void)
725 {
726 colors[COLOR_BLACK] = xc_app_data.colorBlack;
727 colors[COLOR_RED] = xc_app_data.colorRed;
728 colors[COLOR_GREEN] = xc_app_data.colorGreen;
729 colors[COLOR_YELLOW] = xc_app_data.colorYellow;
730 colors[COLOR_BLUE] = xc_app_data.colorBlue;
731 colors[COLOR_MAGENTA] = xc_app_data.colorMagenta;
732 colors[COLOR_CYAN] = xc_app_data.colorCyan;
733 colors[COLOR_WHITE] = xc_app_data.colorWhite;
734
735 colors[COLOR_BLACK + 8] = xc_app_data.colorBoldBlack;
736 colors[COLOR_RED + 8] = xc_app_data.colorBoldRed;
737 colors[COLOR_GREEN + 8] = xc_app_data.colorBoldGreen;
738 colors[COLOR_YELLOW + 8] = xc_app_data.colorBoldYellow;
739 colors[COLOR_BLUE + 8] = xc_app_data.colorBoldBlue;
740 colors[COLOR_MAGENTA + 8] = xc_app_data.colorBoldMagenta;
741 colors[COLOR_CYAN + 8] = xc_app_data.colorBoldCyan;
742 colors[COLOR_WHITE + 8] = xc_app_data.colorBoldWhite;
743
744 colors[COLOR_CURSOR] = xc_app_data.cursorColor;
745 colors[COLOR_BORDER] = xc_app_data.borderColor;
746 }
747
748 static void _refresh_scrollbar(void)
749 {
750 XC_LOG(("_refresh_scrollbar() - called\n"));
751
752 if (SP->sb_on)
753 {
754 PDC_SCROLLBAR_TYPE total_y = SP->sb_total_y;
755 PDC_SCROLLBAR_TYPE total_x = SP->sb_total_x;
756
757 if (total_y)
758 XawScrollbarSetThumb(scrollVert,
759 (PDC_SCROLLBAR_TYPE)(SP->sb_cur_y) / total_y,
760 (PDC_SCROLLBAR_TYPE)(SP->sb_viewport_y) / total_y);
761
762 if (total_x)
763 XawScrollbarSetThumb(scrollHoriz,
764 (PDC_SCROLLBAR_TYPE)(SP->sb_cur_x) / total_x,
765 (PDC_SCROLLBAR_TYPE)(SP->sb_viewport_x) / total_x);
766 }
767 }
768
769 static void _set_cursor_color(chtype *ch, short *fore, short *back)
770 {
771 int attr;
772 short f, b;
773
774 attr = PAIR_NUMBER(*ch);
775
776 if (attr)
777 {
778 PDC_pair_content(attr, &f, &b);
779 *fore = 7 - (f % 8);
780 *back = 7 - (b % 8);
781 }
782 else
783 {
784 if (*ch & A_REVERSE)
785 {
786 *back = COLOR_BLACK;
787 *fore = COLOR_WHITE;
788 }
789 else
790 {
791 *back = COLOR_WHITE;
792 *fore = COLOR_BLACK;
793 }
794 }
795 }
796
797 static void _get_icon(void)
798 {
799 XIconSize *icon_size;
800 int size_count = 0;
801 Status rc;
802 unsigned char *bitmap_bits = NULL;
803 unsigned icon_bitmap_width = 0, icon_bitmap_height = 0,
804 file_bitmap_width = 0, file_bitmap_height = 0;
805
806 XC_LOG(("_get_icon() - called\n"));
807
808 icon_size = XAllocIconSize();
809
810 rc = XGetIconSizes(XtDisplay(topLevel),
811 RootWindowOfScreen(XtScreen(topLevel)),
812 &icon_size, &size_count);
813
814 /* if the WM can advise on icon sizes... */
815
816 if (rc && size_count)
817 {
818 int i, max_height = 0, max_width = 0;
819
820 PDC_LOG(("%s:size_count: %d rc: %d\n", XCLOGMSG, size_count, rc));
821
822 for (i = 0; i < size_count; i++)
823 {
824 if (icon_size[i].max_width > max_width)
825 max_width = icon_size[i].max_width;
826 if (icon_size[i].max_height > max_height)
827 max_height = icon_size[i].max_height;
828
829 PDC_LOG(("%s:min: %d %d\n", XCLOGMSG,
830 icon_size[i].min_width, icon_size[i].min_height));
831
832 PDC_LOG(("%s:max: %d %d\n", XCLOGMSG,
833 icon_size[i].max_width, icon_size[i].max_height));
834
835 PDC_LOG(("%s:inc: %d %d\n", XCLOGMSG,
836 icon_size[i].width_inc, icon_size[i].height_inc));
837 }
838
839 if (max_width >= big_icon_width && max_height >= big_icon_height)
840 {
841 icon_bitmap_width = big_icon_width;
842 icon_bitmap_height = big_icon_height;
843 bitmap_bits = (unsigned char *)big_icon_bits;
844 }
845 else
846 {
847 icon_bitmap_width = little_icon_width;
848 icon_bitmap_height = little_icon_height;
849 bitmap_bits = (unsigned char *)little_icon_bits;
850 }
851
852 }
853 else /* use small icon */
854 {
855 icon_bitmap_width = little_icon_width;
856 icon_bitmap_height = little_icon_height;
857 bitmap_bits = (unsigned char *)little_icon_bits;
858 }
859
860 XFree(icon_size);
861
862 #ifdef HAVE_XPM_H
863 if (xc_app_data.pixmap && xc_app_data.pixmap[0]) /* supplied pixmap */
864 {
865 XpmReadFileToPixmap(XtDisplay(topLevel),
866 RootWindowOfScreen(XtScreen(topLevel)),
867 (char *)xc_app_data.pixmap,
868 &icon_pixmap, &icon_pixmap_mask, NULL);
869 return;
870 }
871 #endif
872
873 if (xc_app_data.bitmap && xc_app_data.bitmap[0]) /* supplied bitmap */
874 {
875 int x_hot = 0, y_hot = 0;
876
877 rc = XReadBitmapFile(XtDisplay(topLevel),
878 RootWindowOfScreen(XtScreen(topLevel)),
879 (char *)xc_app_data.bitmap,
880 &file_bitmap_width, &file_bitmap_height,
881 &icon_bitmap, &x_hot, &y_hot);
882
883 switch(rc)
884 {
885 case BitmapOpenFailed:
886 fprintf(stderr, "bitmap file %s: not found\n",
887 xc_app_data.bitmap);
888 break;
889 case BitmapFileInvalid:
890 fprintf(stderr, "bitmap file %s: contents invalid\n",
891 xc_app_data.bitmap);
892 break;
893 default:
894 return;
895 }
896 }
897
898 icon_bitmap = XCreateBitmapFromData(XtDisplay(topLevel),
899 RootWindowOfScreen(XtScreen(topLevel)),
900 (char *)bitmap_bits, icon_bitmap_width, icon_bitmap_height);
901 }
902
903 static void _draw_border(void)
904 {
905 /* Draw the border if required */
906
907 if (xc_app_data.borderWidth)
908 XDrawRectangle(XCURSESDISPLAY, XCURSESWIN, border_gc,
909 xc_app_data.borderWidth / 2,
910 xc_app_data.borderWidth / 2,
911 window_width - xc_app_data.borderWidth,
912 window_height - xc_app_data.borderWidth);
913 }
914
915 /* Redraw the entire screen */
916
917 static void _display_screen(void)
918 {
919 int row;
920
921 XC_LOG(("_display_screen() - called\n"));
922
923 for (row = 0; row < XCursesLINES; row++)
924 {
925 XC_get_line_lock(row);
926
927 _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row)),
928 row, 0, COLS, FALSE);
929
930 XC_release_line_lock(row);
931 }
932
933 _redraw_cursor();
934 _draw_border();
935 }
936
937 /* Draw changed portions of the screen */
938
939 static void _refresh_screen(void)
940 {
941 int row, start_col, num_cols;
942
943 XC_LOG(("_refresh_screen() - called\n"));
944
945 for (row = 0; row < XCursesLINES; row++)
946 {
947 num_cols = (int)*(Xcurscr + XCURSCR_LENGTH_OFF + row);
948
949 if (num_cols)
950 {
951 XC_get_line_lock(row);
952
953 start_col = (int)*(Xcurscr + XCURSCR_START_OFF + row);
954
955 _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
956 (start_col * sizeof(chtype))), row, start_col,
957 num_cols, FALSE);
958
959 *(Xcurscr + XCURSCR_LENGTH_OFF + row) = 0;
960
961 XC_release_line_lock(row);
962 }
963 }
964
965 if (mouse_selection)
966 _selection_off();
967 }
968
969 static void _handle_expose(Widget w, XtPointer client_data, XEvent *event,
970 Boolean *unused)
971 {
972 XC_LOG(("_handle_expose() - called\n"));
973
974 /* ignore all Exposes except last */
975
976 if (event->xexpose.count)
977 return;
978
979 if (after_first_curses_request && received_map_notify)
980 _display_screen();
981 }
982
983 static void _handle_nonmaskable(Widget w, XtPointer client_data, XEvent *event,
984 Boolean *unused)
985 {
986 XClientMessageEvent *client_event = (XClientMessageEvent *)event;
987
988 PDC_LOG(("%s:_handle_nonmaskable called: xc_otherpid %d event %d\n",
989 XCLOGMSG, xc_otherpid, event->type));
990
991 if (event->type == ClientMessage)
992 {
993 XC_LOG(("ClientMessage received\n"));
994
995 /* This code used to include handling of WM_SAVE_YOURSELF, but
996 it resulted in continual failure of THE on my Toshiba laptop.
997 Removed on 3-3-2001. Now only exits on WM_DELETE_WINDOW. */
998
999 if ((Atom)client_event->data.s[0] == wm_atom[0])
1000 _exit_process(0, SIGKILL, "");
1001 }
1002 }
1003
1004 static void XCursesKeyPress(Widget w, XEvent *event, String *params,
1005 Cardinal *nparams)
1006 {
1007 enum { STATE_NORMAL, STATE_COMPOSE, STATE_CHAR };
1008
1009 #ifdef PDC_XIM
1010 Status status;
1011 wchar_t buffer[120];
1012 #else
1013 unsigned char buffer[120];
1014 XComposeStatus compose;
1015 static int compose_state = STATE_NORMAL;
1016 static int compose_index = 0;
1017 int char_idx = 0;
1018 #endif
1019 unsigned long key = 0;
1020 int buflen = 40;
1021 int i, count;
1022 unsigned long modifier = 0;
1023 bool key_code = FALSE;
1024
1025 XC_LOG(("XCursesKeyPress() - called\n"));
1026
1027 /* Handle modifier keys first; ignore other KeyReleases */
1028
1029 if (event->type == KeyRelease)
1030 {
1031 /* The keysym value was set by a previous call to this function
1032 with a KeyPress event (or reset by the mouse event handler) */
1033
1034 if (SP->return_key_modifiers &&
1035 #ifndef PDC_XIM
1036 keysym != compose_key &&
1037 #endif
1038 IsModifierKey(keysym))
1039 {
1040 switch (keysym) {
1041 case XK_Shift_L:
1042 key = KEY_SHIFT_L;
1043 break;
1044 case XK_Shift_R:
1045 key = KEY_SHIFT_R;
1046 break;
1047 case XK_Control_L:
1048 key = KEY_CONTROL_L;
1049 break;
1050 case XK_Control_R:
1051 key = KEY_CONTROL_R;
1052 break;
1053 case XK_Alt_L:
1054 key = KEY_ALT_L;
1055 break;
1056 case XK_Alt_R:
1057 key = KEY_ALT_R;
1058 }
1059
1060 if (key)
1061 _send_key_to_curses(key, NULL, TRUE);
1062 }
1063
1064 return;
1065 }
1066
1067 buffer[0] = '\0';
1068
1069 #ifdef PDC_XIM
1070 count = XwcLookupString(Xic, &(event->xkey), buffer, buflen,
1071 &keysym, &status);
1072 #else
1073 count = XLookupString(&(event->xkey), (char *)buffer, buflen,
1074 &keysym, &compose);
1075 #endif
1076
1077 /* translate keysym into curses key code */
1078
1079 PDC_LOG(("%s:Key mask: %x\n", XCLOGMSG, event->xkey.state));
1080
1081 #ifdef PDCDEBUG
1082 for (i = 0; i < 4; i++)
1083 PDC_debug("%s:Keysym %x %d\n", XCLOGMSG,
1084 XKeycodeToKeysym(XCURSESDISPLAY, event->xkey.keycode, i), i);
1085 #endif
1086
1087 #ifndef PDC_XIM
1088
1089 /* Check if the key just pressed is the user-specified compose
1090 key; if it is, set the compose state and exit. */
1091
1092 if (keysym == compose_key)
1093 {
1094 chtype *ch;
1095 int xpos, ypos, save_visibility = SP->visibility;
1096 short fore = 0, back = 0;
1097
1098 /* Change the shape of the cursor to an outline rectangle to
1099 indicate we are in "compose" status */
1100
1101 SP->visibility = 0;
1102
1103 _redraw_cursor();
1104
1105 SP->visibility = save_visibility;
1106 _make_xy(SP->curscol, SP->cursrow, &xpos, &ypos);
1107
1108 ch = (chtype *)(Xcurscr + XCURSCR_Y_OFF(SP->cursrow) +
1109 (SP->curscol * sizeof(chtype)));
1110
1111 _set_cursor_color(ch, &fore, &back);
1112
1113 XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
1114
1115 XDrawRectangle(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
1116 xpos + 1, ypos - font_height +
1117 xc_app_data.normalFont->descent + 1,
1118 font_width - 2, font_height - 2);
1119
1120 compose_state = STATE_COMPOSE;
1121 return;
1122 }
1123
1124 switch (compose_state)
1125 {
1126 case STATE_COMPOSE:
1127 if (IsModifierKey(keysym))
1128 return;
1129
1130 if (event->xkey.state & compose_mask)
1131 {
1132 compose_state = STATE_NORMAL;
1133 _redraw_cursor();
1134 break;
1135 }
1136
1137 if (buffer[0] && count == 1)
1138 key = buffer[0];
1139
1140 compose_index = -1;
1141
1142 for (i = 0; i < (int)strlen(compose_chars); i++)
1143 if (compose_chars[i] == key)
1144 {
1145 compose_index = i;
1146 break;
1147 }
1148
1149 if (compose_index == -1)
1150 {
1151 compose_state = STATE_NORMAL;
1152 compose_index = 0;
1153 _redraw_cursor();
1154 break;
1155 }
1156
1157 compose_state = STATE_CHAR;
1158 return;
1159
1160 case STATE_CHAR:
1161 if (IsModifierKey(keysym))
1162 return;
1163
1164 if (event->xkey.state & compose_mask)
1165 {
1166 compose_state = STATE_NORMAL;
1167 _redraw_cursor();
1168 break;
1169 }
1170
1171 if (buffer[0] && count == 1)
1172 key = buffer[0];
1173
1174 char_idx = -1;
1175
1176 for (i = 0; i < MAX_COMPOSE_CHARS; i++)
1177 if (compose_lookups[compose_index][i] == key)
1178 {
1179 char_idx = i;
1180 break;
1181 }
1182
1183 if (char_idx == -1)
1184 {
1185 compose_state = STATE_NORMAL;
1186 compose_index = 0;
1187 _redraw_cursor();
1188 break;
1189 }
1190
1191 _send_key_to_curses(compose_keys[compose_index][char_idx],
1192 NULL, FALSE);
1193
1194 compose_state = STATE_NORMAL;
1195 compose_index = 0;
1196
1197 _redraw_cursor();
1198
1199 return;
1200 }
1201
1202 #endif /* PDC_XIM */
1203
1204 /* To get here we are procesing "normal" keys */
1205
1206 PDC_LOG(("%s:Keysym %x %d\n", XCLOGMSG,
1207 XKeycodeToKeysym(XCURSESDISPLAY, event->xkey.keycode, key), key));
1208
1209 if (SP->save_key_modifiers)
1210 {
1211 /* 0x10: usually, numlock modifier */
1212
1213 if (event->xkey.state & Mod2Mask)
1214 modifier |= PDC_KEY_MODIFIER_NUMLOCK;
1215
1216 /* 0x01: shift modifier */
1217
1218 if (event->xkey.state & ShiftMask)
1219 modifier |= PDC_KEY_MODIFIER_SHIFT;
1220
1221 /* 0x04: control modifier */
1222
1223 if (event->xkey.state & ControlMask)
1224 modifier |= PDC_KEY_MODIFIER_CONTROL;
1225
1226 /* 0x08: usually, alt modifier */
1227
1228 if (event->xkey.state & Mod1Mask)
1229 modifier |= PDC_KEY_MODIFIER_ALT;
1230 }
1231
1232 for (i = 0; key_table[i].keycode; i++)
1233 {
1234 if (key_table[i].keycode == keysym)
1235 {
1236 PDC_LOG(("%s:State %x\n", XCLOGMSG, event->xkey.state));
1237
1238 /* ControlMask: 0x04: control modifier
1239 Mod1Mask: 0x08: usually, alt modifier
1240 Mod2Mask: 0x10: usually, numlock modifier
1241 ShiftMask: 0x01: shift modifier */
1242
1243 if ((event->xkey.state & ShiftMask) ||
1244 (key_table[i].numkeypad &&
1245 (event->xkey.state & Mod2Mask)))
1246 {
1247 key = key_table[i].shifted;
1248 }
1249 else if (event->xkey.state & ControlMask)
1250 {
1251 key = key_table[i].control;
1252 }
1253 else if (event->xkey.state & Mod1Mask)
1254 {
1255 key = key_table[i].alt;
1256 }
1257
1258 /* To get here, we ignore all other modifiers */
1259
1260 else
1261 key = key_table[i].normal;
1262
1263 key_code = (key > 0x100);
1264 break;
1265 }
1266 }
1267
1268 if (!key && buffer[0] && count == 1)
1269 key = buffer[0];
1270
1271 PDC_LOG(("%s:Key: %s pressed - %x Mod: %x\n", XCLOGMSG,
1272 XKeysymToString(keysym), key, event->xkey.state));
1273
1274 /* Handle ALT letters and numbers */
1275
1276 if (event->xkey.state == Mod1Mask)
1277 {
1278 if (key >= 'A' && key <= 'Z')
1279 {
1280 key += ALT_A - 'A';
1281 key_code = TRUE;
1282 }
1283
1284 if (key >= 'a' && key <= 'z')
1285 {
1286 key += ALT_A - 'a';
1287 key_code = TRUE;
1288 }
1289
1290 if (key >= '0' && key <= '9')
1291 {
1292 key += ALT_0 - '0';
1293 key_code = TRUE;
1294 }
1295 }
1296
1297 /* After all that, send the key back to the application if is
1298 NOT zero. */
1299
1300 if (key)
1301 {
1302 key |= (modifier << 24);
1303
1304 _send_key_to_curses(key, NULL, key_code);
1305 }
1306 }
1307
1308 static void XCursesHandleString(Widget w, XEvent *event, String *params,
1309 Cardinal *nparams)
1310 {
1311 unsigned char *ptr;
1312
1313 if (*nparams != 1)
1314 return;
1315
1316 ptr = (unsigned char *)*params;
1317
1318 if (ptr[0] == '0' && ptr[1] == 'x' && ptr[2] != '\0')
1319 {
1320 unsigned char c;
1321 unsigned long total = 0;
1322
1323 for (ptr += 2; (c = tolower(*ptr)); ptr++)
1324 {
1325 total <<= 4;
1326
1327 if (c >= '0' && c <= '9')
1328 total += c - '0';
1329 else
1330 if (c >= 'a' && c <= 'f')
1331 total += c - ('a' - 10);
1332 else
1333 break;
1334 }
1335
1336 if (c == '\0')
1337 _send_key_to_curses(total, NULL, FALSE);
1338 }
1339 else
1340 for (; *ptr; ptr++)
1341 _send_key_to_curses((unsigned long)*ptr, NULL, FALSE);
1342 }
1343
1344 static void _paste_string(Widget w, XtPointer data, Atom *selection, Atom *type,
1345 XtPointer value, unsigned long *length, int *format)
1346 {
1347 unsigned long i, key;
1348 unsigned char *string = value;
1349
1350 XC_LOG(("_paste_string() - called\n"));
1351
1352 if (!*type || !*length || !string)
1353 return;
1354
1355 for (i = 0; string[i] && (i < (*length)); i++)
1356 {
1357 key = string[i];
1358
1359 if (key == 10) /* new line - convert to ^M */
1360 key = 13;
1361
1362 _send_key_to_curses(key, NULL, FALSE);
1363 }
1364
1365 XtFree(value);
1366 }
1367
1368 static void _paste_utf8(Widget w, XtPointer event, Atom *selection, Atom *type,
1369 XtPointer value, unsigned long *length, int *format)
1370 {
1371 wchar_t key;
1372 size_t i = 0, len;
1373 char *string = value;
1374
1375 XC_LOG(("_paste_utf8() - called\n"));
1376
1377 if (!*type || !*length)
1378 {
1379 XtGetSelectionValue(w, XA_PRIMARY, XA_STRING, _paste_string,
1380 event, ((XButtonEvent *)event)->time);
1381 return;
1382 }
1383
1384 len = *length;
1385
1386 if (!string)
1387 return;
1388
1389 while (string[i] && (i < len))
1390 {
1391 int retval = _from_utf8(&key, string + i, len - i);
1392
1393 if (retval < 1)
1394 return;
1395
1396 if (key == 10) /* new line - convert to ^M */
1397 key = 13;
1398
1399 _send_key_to_curses(key, NULL, FALSE);
1400
1401 i += retval;
1402 }
1403
1404 XtFree(value);
1405 }
1406
1407 static void XCursesPasteSelection(Widget w, XButtonEvent *button_event)
1408 {
1409 XC_LOG(("XCursesPasteSelection() - called\n"));
1410
1411 XtGetSelectionValue(w, XA_PRIMARY, XA_UTF8_STRING(XtDisplay(w)),
1412 _paste_utf8, (XtPointer)button_event,
1413 button_event->time);
1414 }
1415
1416 static Boolean _convert_proc(Widget w, Atom *selection, Atom *target,
1417 Atom *type_return, XtPointer *value_return,
1418 unsigned long *length_return, int *format_return)
1419 {
1420 XC_LOG(("_convert_proc() - called\n"));
1421
1422 if (*target == XA_TARGETS(XtDisplay(topLevel)))
1423 {
1424 XSelectionRequestEvent *req = XtGetSelectionRequest(w,
1425 *selection, (XtRequestId)NULL);
1426
1427 Atom *targetP;
1428 XPointer std_targets;
1429 unsigned long std_length;
1430
1431 XmuConvertStandardSelection(topLevel, req->time, selection,
1432 target, type_return, &std_targets,
1433 &std_length, format_return);
1434
1435 *length_return = std_length + 2;
1436 *value_return = XtMalloc(sizeof(Atom) * (*length_return));
1437
1438 targetP = *(Atom**)value_return;
1439 *targetP++ = XA_STRING;
1440 *targetP++ = XA_UTF8_STRING(XtDisplay(topLevel));
1441
1442 memmove((void *)targetP, (const void *)std_targets,
1443 sizeof(Atom) * std_length);
1444
1445 XtFree((char *)std_targets);
1446 *type_return = XA_ATOM;
1447 *format_return = sizeof(Atom) * 8;
1448
1449 return True;
1450 }
1451 else if (*target == XA_UTF8_STRING(XtDisplay(topLevel)) ||
1452 *target == XA_STRING)
1453 {
1454 bool utf8 = !(*target == XA_STRING);
1455 char *data = XtMalloc(tmpsel_length * 3 + 1);
1456 chtype *tmp = tmpsel;
1457 int ret_length = 0;
1458
1459 if (utf8)
1460 {
1461 while (*tmp)
1462 ret_length += _to_utf8(data + ret_length, *tmp++);
1463 }
1464 else
1465 while (*tmp)
1466 data[ret_length++] = *tmp++ & 0xff;
1467
1468 data[ret_length++] = '\0';
1469
1470 *value_return = data;
1471 *length_return = ret_length;
1472 *format_return = 8;
1473 *type_return = *target;
1474
1475 return True;
1476 }
1477 else
1478 return XmuConvertStandardSelection(topLevel, CurrentTime,
1479 selection, target, type_return, (XPointer*)value_return,
1480 length_return, format_return);
1481 }
1482
1483 static void _lose_ownership(Widget w, Atom *type)
1484 {
1485 XC_LOG(("_lose_ownership() - called\n"));
1486
1487 if (tmpsel)
1488 free(tmpsel);
1489
1490 tmpsel = NULL;
1491 tmpsel_length = 0;
1492 _selection_off();
1493 }
1494
1495 static void _show_selection(int start_x, int start_y, int end_x, int end_y,
1496 bool highlight)
1497 {
1498 int i, num_cols, start_col, row;
1499
1500 PDC_LOG(("%s:_show_selection() - called StartX: %d StartY: %d "
1501 "EndX: %d EndY: %d Highlight: %d\n", XCLOGMSG,
1502 start_x, start_y, end_x, end_y, highlight));
1503
1504 for (i = 0; i < end_y - start_y + 1; i++)
1505 {
1506 if (start_y == end_y) /* only one line */
1507 {
1508 start_col = start_x;
1509 num_cols = end_x - start_x + 1;
1510 row = start_y;
1511 }
1512 else if (!i) /* first line */
1513 {
1514 start_col = start_x;
1515 num_cols = COLS - start_x;
1516 row = start_y;
1517 }
1518 else if (start_y + i == end_y) /* last line */
1519 {
1520 start_col = 0;
1521 num_cols = end_x + 1;
1522 row = end_y;
1523 }
1524 else /* full line */
1525 {
1526 start_col = 0;
1527 num_cols = COLS;
1528 row = start_y + i;
1529 }
1530
1531 XC_get_line_lock(row);
1532
1533 _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
1534 (start_col * sizeof(chtype))), row, start_col,
1535 num_cols, highlight);
1536
1537 XC_release_line_lock(row);
1538 }
1539 }
1540
1541 static void _selection_off(void)
1542 {
1543 XC_LOG(("_selection_off() - called\n"));
1544
1545 _display_screen();
1546
1547 selection_start_x = selection_start_y = selection_end_x =
1548 selection_end_y = 0;
1549
1550 mouse_selection = FALSE;
1551 }
1552
1553 static void _selection_on(int x, int y)
1554 {
1555 XC_LOG(("_selection_on() - called\n"));
1556
1557 selection_start_x = selection_end_x = x;
1558 selection_start_y = selection_end_y = y;
1559 }
1560
1561 static void _selection_extend(int x, int y)
1562 {
1563 int temp, current_start, current_end, current_start_x,
1564 current_end_x, current_start_y, current_end_y, new_start,
1565 new_end, new_start_x, new_end_x, new_start_y, new_end_y;
1566
1567 XC_LOG(("_selection_extend() - called\n"));
1568
1569 mouse_selection = TRUE;
1570
1571 /* convert x/y coordinates into start/stop */
1572
1573 current_start = (selection_start_y * COLS) + selection_start_x;
1574 current_end = (selection_end_y * COLS) + selection_end_x;
1575
1576 if (current_start > current_end)
1577 {
1578 current_start_x = selection_end_x;
1579 current_start_y = selection_end_y;
1580 current_end_x = selection_start_x;
1581 current_end_y = selection_start_y;
1582 temp = current_start;
1583 current_start = current_end;
1584 current_end = temp;
1585 }
1586 else
1587 {
1588 current_end_x = selection_end_x;
1589 current_end_y = selection_end_y;
1590 current_start_x = selection_start_x;
1591 current_start_y = selection_start_y;
1592 }
1593
1594 /* Now we have the current selection as a linear expression.
1595 Convert the new position to a linear expression. */
1596
1597 selection_end_x = x;
1598 selection_end_y = y;
1599
1600 /* convert x/y coordinates into start/stop */
1601
1602 new_start = (selection_start_y * COLS) + selection_start_x;
1603 new_end = (selection_end_y * COLS) + selection_end_x;
1604
1605 if (new_start > new_end)
1606 {
1607 new_start_x = selection_end_x;
1608 new_start_y = selection_end_y;
1609 new_end_x = selection_start_x;
1610 new_end_y = selection_start_y;
1611 temp = new_start;
1612 new_start = new_end;
1613 new_end = temp;
1614 }
1615 else
1616 {
1617 new_end_x = selection_end_x;
1618 new_end_y = selection_end_y;
1619 new_start_x = selection_start_x;
1620 new_start_y = selection_start_y;
1621 }
1622
1623 if (new_end > current_end)
1624 _show_selection(current_end_x, current_end_y, new_end_x,
1625 new_end_y, TRUE);
1626 else if (new_end < current_end)
1627 _show_selection(new_end_x, new_end_y, current_end_x,
1628 current_end_y, FALSE);
1629 else if (new_start < current_start)
1630 _show_selection(new_start_x, new_start_y, current_start_x,
1631 current_start_y, TRUE);
1632 else if (new_start > current_start)
1633 _show_selection(current_start_x, current_start_y,
1634 new_start_x, new_start_y, FALSE);
1635 else
1636 _show_selection(current_start_x, current_start_y,
1637 new_start_x, new_start_y, TRUE);
1638 }
1639
1640 static void _selection_set(void)
1641 {
1642 int i, j, start, end, start_x, end_x, start_y, end_y, num_cols,
1643 start_col, row, num_chars, ch, last_nonblank, length, newlen;
1644 chtype *ptr = NULL;
1645
1646 XC_LOG(("_selection_set() - called\n"));
1647
1648 /* convert x/y coordinates into start/stop */
1649
1650 start = (selection_start_y * COLS) + selection_start_x;
1651 end = (selection_end_y * COLS) + selection_end_x;
1652
1653 if (start == end)
1654 {
1655 if (tmpsel)
1656 free(tmpsel);
1657
1658 tmpsel = NULL;
1659 tmpsel_length = 0;
1660
1661 return;
1662 }
1663
1664 if (start > end)
1665 {
1666 start_x = selection_end_x;
1667 start_y = selection_end_y;
1668 end_x = selection_start_x;
1669 end_y = selection_start_y;
1670 length = start - end + 1;
1671 }
1672 else
1673 {
1674 end_x = selection_end_x;
1675 end_y = selection_end_y;
1676 start_x = selection_start_x;
1677 start_y = selection_start_y;
1678 length = end - start + 1;
1679 }
1680
1681 newlen = length + end_y - start_y + 2;
1682
1683 if (length > (int)tmpsel_length)
1684 {
1685 if (!tmpsel_length)
1686 tmpsel = malloc(newlen * sizeof(chtype));
1687 else
1688 tmpsel = realloc(tmpsel, newlen * sizeof(chtype));
1689 }
1690
1691 if (!tmpsel)
1692 {
1693 tmpsel_length = 0;
1694 return;
1695 }
1696
1697 tmpsel_length = length;
1698 num_chars = 0;
1699
1700 for (i = 0; i < end_y - start_y + 1; i++)
1701 {
1702
1703 if (start_y == end_y) /* only one line */
1704 {
1705 start_col = start_x;
1706 num_cols = end_x - start_x + 1;
1707 row = start_y;
1708 }
1709 else if (!i) /* first line */
1710 {
1711 start_col = start_x;
1712 num_cols = COLS - start_x;
1713 row = start_y;
1714 }
1715 else if (start_y + i == end_y) /* last line */
1716 {
1717 start_col = 0;
1718 num_cols = end_x + 1;
1719 row = end_y;
1720 }
1721 else /* full line */
1722 {
1723 start_col = 0;
1724 num_cols = COLS;
1725 row = start_y + i;
1726 }
1727
1728 XC_get_line_lock(row);
1729
1730 ptr = (chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
1731 start_col * sizeof(chtype));
1732
1733 if (i < end_y - start_y)
1734 {
1735 last_nonblank = 0;
1736
1737 for (j = 0; j < num_cols; j++)
1738 {
1739 ch = (int)(ptr[j] & A_CHARTEXT);
1740 if (ch != (int)' ')
1741 last_nonblank = j;
1742 }
1743 }
1744 else
1745 last_nonblank = num_cols - 1;
1746
1747 for (j = 0; j <= last_nonblank; j++)
1748 tmpsel[num_chars++] = ptr[j];
1749
1750 XC_release_line_lock(row);
1751
1752 if (i < end_y - start_y)
1753 tmpsel[num_chars++] = '\n';
1754 }
1755
1756 tmpsel[num_chars] = '\0';
1757 tmpsel_length = num_chars;
1758 }
1759
1760 static void _display_cursor(int old_row, int old_x, int new_row, int new_x)
1761 {
1762 int xpos, ypos, i;
1763 chtype *ch;
1764 short fore = 0, back = 0;
1765
1766 PDC_LOG(("%s:_display_cursor() - draw char at row: %d col %d\n",
1767 XCLOGMSG, old_row, old_x));
1768
1769 /* if the cursor position is outside the boundary of the screen,
1770 ignore the request */
1771
1772 if (old_row >= XCursesLINES || old_x >= COLS ||
1773 new_row >= XCursesLINES || new_x >= COLS)
1774 return;
1775
1776 /* display the character at the current cursor position */
1777
1778 PDC_LOG(("%s:_display_cursor() - draw char at row: %d col %d\n",
1779 XCLOGMSG, old_row, old_x));
1780
1781 _display_text((const chtype *)(Xcurscr + (XCURSCR_Y_OFF(old_row) +
1782 (old_x * sizeof(chtype)))), old_row, old_x, 1, FALSE);
1783
1784 /* display the cursor at the new cursor position */
1785
1786 if (!SP->visibility)
1787 return; /* cursor not displayed, no more to do */
1788
1789 _make_xy(new_x, new_row, &xpos, &ypos);
1790
1791 ch = (chtype *)(Xcurscr + XCURSCR_Y_OFF(new_row) + new_x * sizeof(chtype));
1792
1793 _set_cursor_color(ch, &fore, &back);
1794
1795 if (vertical_cursor)
1796 {
1797 XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
1798
1799 for (i = 1; i <= SP->visibility; i++)
1800 XDrawLine(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
1801 xpos + i, ypos - xc_app_data.normalFont->ascent,
1802 xpos + i, ypos - xc_app_data.normalFont->ascent +
1803 font_height - 1);
1804 }
1805 else
1806 {
1807 if (SP->visibility == 1)
1808 {
1809 /* cursor visibility normal */
1810
1811 XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
1812
1813 for (i = 0; i < xc_app_data.normalFont->descent + 2; i++)
1814 XDrawLine(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
1815 xpos, ypos - 2 + i, xpos + font_width, ypos - 2 + i);
1816 }
1817 else
1818 {
1819 /* cursor visibility high */
1820 #ifdef PDC_WIDE
1821 XChar2b buf[2];
1822
1823 buf[0].byte1 = (*ch & 0xff00) >> 8;
1824 buf[0].byte2 = *ch & 0x00ff;
1825
1826 buf[1].byte1 = buf[1].byte2 = 0;
1827 #else
1828 char buf[2];
1829
1830 buf[0] = *ch & 0xff;
1831 buf[1] = '\0';
1832 #endif
1833 XSetForeground(XCURSESDISPLAY, block_cursor_gc, colors[fore]);
1834 XSetBackground(XCURSESDISPLAY, block_cursor_gc, colors[back]);
1835 #ifdef PDC_WIDE
1836 XDrawImageString16(
1837 #else
1838 XDrawImageString(
1839 #endif
1840 XCURSESDISPLAY, XCURSESWIN, block_cursor_gc,
1841 xpos, ypos, buf, 1);
1842 }
1843 }
1844
1845 PDC_LOG(("%s:_display_cursor() - draw cursor at row %d col %d\n",
1846 XCLOGMSG, new_row, new_x));
1847 }
1848
1849 static void _redraw_cursor(void)
1850 {
1851 _display_cursor(SP->cursrow, SP->curscol, SP->cursrow, SP->curscol);
1852 }
1853
1854 static void _handle_enter_leave(Widget w, XtPointer client_data,
1855 XEvent *event, Boolean *unused)
1856 {
1857 XC_LOG(("_handle_enter_leave called\n"));
1858
1859 switch(event->type)
1860 {
1861 case EnterNotify:
1862 XC_LOG(("EnterNotify received\n"));
1863
1864 window_entered = TRUE;
1865 break;
1866
1867 case LeaveNotify:
1868 XC_LOG(("LeaveNotify received\n"));
1869
1870 window_entered = FALSE;
1871
1872 /* Display the cursor so it stays on while the window is
1873 not current */
1874
1875 _redraw_cursor();
1876 break;
1877
1878 default:
1879 PDC_LOG(("%s:_handle_enter_leave - unknown event %d\n",
1880 XCLOGMSG, event->type));
1881 }
1882 }
1883
1884 static void _send_key_to_curses(unsigned long key, MOUSE_STATUS *ms,
1885 bool key_code)
1886 {
1887 PDC_LOG(("%s:_send_key_to_curses() - called: sending %d\n",
1888 XCLOGMSG, key));
1889
1890 SP->key_code = key_code;
1891
1892 if (XC_write_socket(xc_key_sock, &key, sizeof(unsigned long)) < 0)
1893 _exit_process(1, SIGKILL, "exiting from _send_key_to_curses");
1894
1895 if (ms)
1896 {
1897 MOUSE_LOG(("%s:writing mouse stuff\n", XCLOGMSG));
1898
1899 if (XC_write_socket(xc_key_sock, ms, sizeof(MOUSE_STATUS)) < 0)
1900 _exit_process(1, SIGKILL, "exiting from _send_key_to_curses");
1901 }
1902 }
1903
1904 static void _blink_cursor(XtPointer unused, XtIntervalId *id)
1905 {
1906 XC_LOG(("_blink_cursor() - called:\n"));
1907
1908 if (window_entered)
1909 {
1910 if (visible_cursor)
1911 {
1912 /* Cursor currently ON, turn it off */
1913
1914 int save_visibility = SP->visibility;
1915 SP->visibility = 0;
1916 _redraw_cursor();
1917 SP->visibility = save_visibility;
1918 visible_cursor = FALSE;
1919 }
1920 else
1921 {
1922 /* Cursor currently OFF, turn it on */
1923
1924 _redraw_cursor();
1925 visible_cursor = TRUE;
1926 }
1927 }
1928
1929 XtAppAddTimeOut(app_context, xc_app_data.cursorBlinkRate,
1930 _blink_cursor, NULL);
1931 }
1932
1933 static void XCursesButton(Widget w, XEvent *event, String *params,
1934 Cardinal *nparams)
1935 {
1936 int button_no;
1937 static int last_button_no = 0;
1938 static Time last_button_press_time = 0;
1939 MOUSE_STATUS save_mouse_status;
1940 bool send_key = TRUE;
1941 static bool remove_release;
1942 static bool handle_real_release;
1943
1944 XC_LOG(("XCursesButton() - called\n"));
1945
1946 keysym = 0; /* suppress any modifier key return */
1947
1948 save_mouse_status = Mouse_status;
1949 button_no = event->xbutton.button;
1950
1951 /* It appears that under X11R6 (at least on Linux), that an
1952 event_type of ButtonMotion does not include the mouse button in
1953 the event. The following code is designed to cater for this
1954 situation. */
1955
1956 if (!button_no)
1957 button_no = last_button_no;
1958
1959 last_button_no = button_no;
1960
1961 Mouse_status.changes = 0;
1962
1963 switch(event->type)
1964 {
1965 case ButtonPress:
1966 /* Handle button 4 and 5, which are normally mapped to the wheel
1967 mouse scroll up and down */
1968
1969 if (button_no == 4 || button_no == 5)
1970 {
1971 /* Send the KEY_MOUSE to curses program */
1972
1973 memset(&Mouse_status, 0, sizeof(Mouse_status));
1974
1975 Mouse_status.changes = (button_no == 5) ?
1976 PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
1977
1978 MOUSE_X_POS = MOUSE_Y_POS = -1;
1979 _send_key_to_curses(KEY_MOUSE, &Mouse_status, TRUE);
1980 remove_release = TRUE;
1981
1982 return;
1983 }
1984
1985 if (button_no == 2 &&
1986 (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
1987 {
1988 XCursesPasteSelection(drawing, (XButtonEvent *)event);
1989 remove_release = TRUE;
1990
1991 return;
1992 }
1993
1994 remove_release = False;
1995 handle_real_release = False;
1996
1997 MOUSE_LOG(("\nButtonPress\n"));
1998
1999 if ((event->xbutton.time - last_button_press_time) <
2000 xc_app_data.doubleClickPeriod)
2001 {
2002 MOUSE_X_POS = save_mouse_status.x;
2003 MOUSE_Y_POS = save_mouse_status.y;
2004 BUTTON_STATUS(button_no) = BUTTON_DOUBLE_CLICKED;
2005
2006 _selection_off();
2007 remove_release = True;
2008 }
2009 else
2010 {
2011 napms(SP->mouse_wait);
2012 event->type = ButtonRelease;
2013 XSendEvent(event->xbutton.display, event->xbutton.window,
2014 True, 0, event);
2015 last_button_press_time = event->xbutton.time;
2016
2017 return;
2018 }
2019
2020 last_button_press_time = event->xbutton.time;
2021 break;
2022
2023 case MotionNotify:
2024 MOUSE_LOG(("\nMotionNotify: y: %d x: %d Width: %d "
2025 "Height: %d\n", event->xbutton.y, event->xbutton.x,
2026 font_width, font_height));
2027
2028 MOUSE_X_POS = (event->xbutton.x - xc_app_data.borderWidth) /
2029 font_width;
2030 MOUSE_Y_POS = (event->xbutton.y - xc_app_data.borderWidth) /
2031 font_height;
2032
2033 if (button_no == 1 &&
2034 (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
2035 {
2036 _selection_extend(MOUSE_X_POS, MOUSE_Y_POS);
2037 send_key = FALSE;
2038 }
2039 else
2040 _selection_off();
2041
2042 /* Throw away mouse movements if they are in the same character
2043 position as the last mouse event, or if we are currently in
2044 the middle of a double click event. */
2045
2046 if ((MOUSE_X_POS == save_mouse_status.x &&
2047 MOUSE_Y_POS == save_mouse_status.y) ||
2048 save_mouse_status.button[button_no - 1] == BUTTON_DOUBLE_CLICKED)
2049 {
2050 send_key = FALSE;
2051 break;
2052 }
2053
2054 Mouse_status.changes |= PDC_MOUSE_MOVED;
2055 break;
2056
2057 case ButtonRelease:
2058 if (remove_release)
2059 {
2060 MOUSE_LOG(("Release at: %ld - removed\n", event->xbutton.time));
2061 return;
2062 }
2063 else
2064 {
2065 MOUSE_X_POS = (event->xbutton.x - xc_app_data.borderWidth) /
2066 font_width;
2067 MOUSE_Y_POS = (event->xbutton.y - xc_app_data.borderWidth) /
2068 font_height;
2069
2070 if (!handle_real_release)
2071 {
2072 if ((event->xbutton.time - last_button_press_time) <
2073 SP->mouse_wait &&
2074 (event->xbutton.time != last_button_press_time))
2075 {
2076 /* The "real" release was shorter than usleep() time;
2077 therefore generate a click event */
2078
2079 MOUSE_LOG(("Release at: %ld - click\n",
2080 event->xbutton.time));
2081
2082 BUTTON_STATUS(button_no) = BUTTON_CLICKED;
2083
2084 if (button_no == 1 && mouse_selection &&
2085 (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
2086 {
2087 send_key = FALSE;
2088
2089 if (XtOwnSelection(topLevel, XA_PRIMARY,
2090 event->xbutton.time, _convert_proc,
2091 _lose_ownership, NULL) == False)
2092 _selection_off();
2093 }
2094 else
2095 _selection_off();
2096
2097 /* Ensure the "pseudo" release event is ignored */
2098
2099 remove_release = True;
2100 handle_real_release = False;
2101 break;
2102 }
2103 else
2104 {
2105 /* Button release longer than usleep() time;
2106 therefore generate a press and wait for the real
2107 release to occur later. */
2108
2109 MOUSE_LOG(("Generated Release at: %ld - "
2110 "press & release\n", event->xbutton.time));
2111
2112 BUTTON_STATUS(button_no) = BUTTON_PRESSED;
2113
2114 if (button_no == 1 &&
2115 (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
2116 {
2117 _selection_off();
2118 _selection_on(MOUSE_X_POS, MOUSE_Y_POS);
2119 }
2120
2121 handle_real_release = True;
2122 break;
2123 }
2124 }
2125 else
2126 {
2127 MOUSE_LOG(("Release at: %ld - released\n",
2128 event->xbutton.time));
2129 }
2130 }
2131
2132 MOUSE_LOG(("\nButtonRelease\n"));
2133
2134 BUTTON_STATUS(button_no) = BUTTON_RELEASED;
2135
2136 if (button_no == 1 && mouse_selection &&
2137 (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
2138 {
2139 send_key = FALSE;
2140
2141 if (XtOwnSelection(topLevel, XA_PRIMARY,
2142 event->xbutton.time, _convert_proc,
2143 _lose_ownership, NULL) == False)
2144 _selection_off();
2145
2146 _selection_set();
2147 }
2148 else
2149 _selection_off();
2150
2151 break;
2152 }
2153
2154 /* Set up the mouse status fields in preparation for sending */
2155
2156 Mouse_status.changes |= 1 << (button_no - 1);
2157
2158 if (Mouse_status.changes & PDC_MOUSE_MOVED &&
2159 BUTTON_STATUS(button_no) == BUTTON_PRESSED)
2160 BUTTON_STATUS(button_no) = BUTTON_MOVED;
2161
2162 if (event->xbutton.state & ShiftMask)
2163 BUTTON_STATUS(button_no) |= BUTTON_SHIFT;
2164 if (event->xbutton.state & ControlMask)
2165 BUTTON_STATUS(button_no) |= BUTTON_CONTROL;
2166 if (event->xbutton.state & Mod1Mask)
2167 BUTTON_STATUS(button_no) |= BUTTON_ALT;
2168
2169 /* If we are ignoring the event, or the mouse position is outside
2170 the bounds of the screen (because of the border), return here */
2171
2172 MOUSE_LOG(("Button: %d x: %d y: %d Button status: %x "
2173 "Mouse status: %x\n", button_no, MOUSE_X_POS, MOUSE_Y_POS,
2174 BUTTON_STATUS(button_no), Mouse_status.changes));
2175
2176 MOUSE_LOG(("Send: %d Button1: %x Button2: %x Button3: %x %d %d\n",
2177 send_key, BUTTON_STATUS(1), BUTTON_STATUS(2),
2178 BUTTON_STATUS(3), XCursesLINES, XCursesCOLS));
2179
2180 if (!send_key || MOUSE_X_POS < 0 || MOUSE_X_POS >= XCursesCOLS ||
2181 MOUSE_Y_POS < 0 || MOUSE_Y_POS >= XCursesLINES)
2182 return;
2183
2184 /* Send the KEY_MOUSE to curses program */
2185
2186 _send_key_to_curses(KEY_MOUSE, &Mouse_status, TRUE);
2187 }
2188
2189 static void _scroll_up_down(Widget w, XtPointer client_data,
2190 XtPointer call_data)
2191 {
2192 int pixels = (long) call_data;
2193 int total_y = SP->sb_total_y * font_height;
2194 int viewport_y = SP->sb_viewport_y * font_height;
2195 int cur_y = SP->sb_cur_y * font_height;
2196
2197 /* When pixels is negative, right button pressed, move data down,
2198 thumb moves up. Otherwise, left button pressed, pixels positive,
2199 move data up, thumb down. */
2200
2201 cur_y += pixels;
2202
2203 /* limit panning to size of overall */
2204
2205 if (cur_y < 0)
2206 cur_y = 0;
2207 else
2208 if (cur_y > (total_y - viewport_y))
2209 cur_y = total_y - viewport_y;
2210
2211 SP->sb_cur_y = cur_y / font_height;
2212
2213 XawScrollbarSetThumb(w, (double)((double)cur_y / (double)total_y),
2214 (double)((double)viewport_y / (double)total_y));
2215
2216 /* Send a key: if pixels negative, send KEY_SCROLL_DOWN */
2217
2218 _send_key_to_curses(KEY_SF, NULL, TRUE);
2219 }
2220
2221 static void _scroll_left_right(Widget w, XtPointer client_data,
2222 XtPointer call_data)
2223 {
2224 int pixels = (long) call_data;
2225 int total_x = SP->sb_total_x * font_width;
2226 int viewport_x = SP->sb_viewport_x * font_width;
2227 int cur_x = SP->sb_cur_x * font_width;
2228
2229 cur_x += pixels;
2230
2231 /* limit panning to size of overall */
2232
2233 if (cur_x < 0)
2234 cur_x = 0;
2235 else
2236 if (cur_x > (total_x - viewport_x))
2237 cur_x = total_x - viewport_x;
2238
2239 SP->sb_cur_x = cur_x / font_width;
2240
2241 XawScrollbarSetThumb(w, (double)((double)cur_x / (double)total_x),
2242 (double)((double)viewport_x / (double)total_x));
2243
2244 _send_key_to_curses(KEY_SR, NULL, TRUE);
2245 }
2246
2247 static void _thumb_up_down(Widget w, XtPointer client_data,
2248 XtPointer call_data)
2249 {
2250 double percent = *(double *) call_data;
2251 double total_y = (double)SP->sb_total_y;
2252 double viewport_y = (double)SP->sb_viewport_y;
2253 int cur_y = SP->sb_cur_y;
2254
2255 /* If the size of the viewport is > overall area simply return,
2256 as no scrolling is permitted. */
2257
2258 if (SP->sb_viewport_y >= SP->sb_total_y)
2259 return;
2260
2261 if ((SP->sb_cur_y = (int)((double)total_y * percent)) >=
2262 (total_y - viewport_y))
2263 SP->sb_cur_y = total_y - viewport_y;
2264
2265 XawScrollbarSetThumb(w, (double)(cur_y / total_y),
2266 (double)(viewport_y / total_y));
2267
2268 _send_key_to_curses(KEY_SF, NULL, TRUE);
2269 }
2270
2271 static void _thumb_left_right(Widget w, XtPointer client_data,
2272 XtPointer call_data)
2273 {
2274 double percent = *(double *) call_data;
2275 double total_x = (double)SP->sb_total_x;
2276 double viewport_x = (double)SP->sb_viewport_x;
2277 int cur_x = SP->sb_cur_x;
2278
2279 if (SP->sb_viewport_x >= SP->sb_total_x)
2280 return;
2281
2282 if ((SP->sb_cur_x = (int)((float)total_x * percent)) >=
2283 (total_x - viewport_x))
2284 SP->sb_cur_x = total_x - viewport_x;
2285
2286 XawScrollbarSetThumb(w, (double)(cur_x / total_x),
2287 (double)(viewport_x / total_x));
2288
2289 _send_key_to_curses(KEY_SR, NULL, TRUE);
2290 }
2291
2292 static void _exit_process(int rc, int sig, char *msg)
2293 {
2294 if (rc || sig)
2295 fprintf(stderr, "%s:_exit_process() - called: rc:%d sig:%d <%s>\n",
2296 XCLOGMSG, rc, sig, msg);
2297
2298 shmdt((char *)SP);
2299 shmdt((char *)Xcurscr);
2300 shmctl(shmidSP, IPC_RMID, 0);
2301 shmctl(shmid_Xcurscr, IPC_RMID, 0);
2302
2303 if (bitmap_file)
2304 {
2305 XFreePixmap(XCURSESDISPLAY, icon_bitmap);
2306 free(bitmap_file);
2307 }
2308
2309 #ifdef HAVE_XPM_H
2310 if (pixmap_file)
2311 {
2312 XFreePixmap(XCURSESDISPLAY, icon_pixmap);
2313 XFreePixmap(XCURSESDISPLAY, icon_pixmap_mask);
2314 free(pixmap_file);
2315 }
2316 #endif
2317 XFreeGC(XCURSESDISPLAY, normal_gc);
2318 XFreeGC(XCURSESDISPLAY, italic_gc);
2319 XFreeGC(XCURSESDISPLAY, block_cursor_gc);
2320 XFreeGC(XCURSESDISPLAY, rect_cursor_gc);
2321 XFreeGC(XCURSESDISPLAY, border_gc);
2322 #ifdef PDC_XIM
2323 XDestroyIC(Xic);
2324 #endif
2325
2326 shutdown(xc_display_sock, 2);
2327 close(xc_display_sock);
2328
2329 shutdown(xc_exit_sock, 2);
2330 close(xc_exit_sock);
2331
2332 shutdown(xc_key_sock, 2);
2333 close(xc_key_sock);
2334
2335 if (sig)
2336 kill(xc_otherpid, sig); /* to kill parent process */
2337
2338 _exit(rc);
2339 }
2340
2341 static void _resize(void)
2342 {
2343 short save_atrtab[PDC_COLOR_PAIRS * 2];
2344
2345 after_first_curses_request = FALSE;
2346
2347 SP->lines = XCursesLINES = ((resize_window_height -
2348 (2 * xc_app_data.borderWidth)) / font_height);
2349
2350 LINES = XCursesLINES - SP->linesrippedoff - SP->slklines;
2351
2352 SP->cols = COLS = XCursesCOLS = ((resize_window_width -
2353 (2 * xc_app_data.borderWidth)) / font_width);
2354
2355 window_width = resize_window_width;
2356 window_height = resize_window_height;
2357 visible_cursor = TRUE;
2358
2359 _draw_border();
2360
2361 /* Detach and drop the current shared memory segment and create and
2362 attach to a new segment */
2363
2364 memcpy(save_atrtab, xc_atrtab, sizeof(save_atrtab));
2365
2366 SP->XcurscrSize = XCURSCR_SIZE;
2367 shmdt((char *)Xcurscr);
2368 shmctl(shmid_Xcurscr, IPC_RMID, 0);
2369
2370 if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
2371 SP->XcurscrSize + XCURSESSHMMIN, 0700 | IPC_CREAT)) < 0)
2372 {
2373 perror("Cannot allocate shared memory for curscr");
2374
2375 _exit_process(4, SIGKILL, "exiting from _process_curses_requests");
2376 }
2377
2378 Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
2379 memset(Xcurscr, 0, SP->XcurscrSize);
2380 xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
2381 memcpy(xc_atrtab, save_atrtab, sizeof(save_atrtab));
2382 }
2383
2384 /* For PDC_set_title() */
2385
2386 static void _set_title(void)
2387 {
2388 char title[1024]; /* big enough for window title */
2389 int pos;
2390
2391 if ((XC_read_socket(xc_display_sock, &pos, sizeof(int)) < 0) ||
2392 (XC_read_socket(xc_display_sock, title, pos) < 0))
2393 {
2394 _exit_process(5, SIGKILL, "exiting from _set_title");
2395 }
2396
2397 XtVaSetValues(topLevel, XtNtitle, title, NULL);
2398 }
2399
2400 /* For color_content() */
2401
2402 static void _get_color(void)
2403 {
2404 XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
2405 int index = tmp->pixel;
2406 Colormap cmap = DefaultColormap(XCURSESDISPLAY,
2407 DefaultScreen(XCURSESDISPLAY));
2408
2409 if (index < 0 || index >= MAX_COLORS)
2410 _exit_process(4, SIGKILL, "exiting from _get_color");
2411
2412 tmp->pixel = colors[index];
2413 XQueryColor(XCURSESDISPLAY, cmap, tmp);
2414 }
2415
2416 /* For init_color() */
2417
2418 static void _set_color(void)
2419 {
2420 XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
2421 int index = tmp->pixel;
2422 Colormap cmap = DefaultColormap(XCURSESDISPLAY,
2423 DefaultScreen(XCURSESDISPLAY));
2424
2425 if (index < 0 || index >= MAX_COLORS)
2426 _exit_process(4, SIGKILL, "exiting from _set_color");
2427
2428 if (XAllocColor(XCURSESDISPLAY, cmap, tmp))
2429 {
2430 XFreeColors(XCURSESDISPLAY, cmap, colors + index, 1, 0);
2431 colors[index] = tmp->pixel;
2432
2433 _display_screen();
2434 }
2435 }
2436
2437 /* For PDC_getclipboard() */
2438
2439 static void _get_selection(Widget w, XtPointer data, Atom *selection,
2440 Atom *type, XtPointer value,
2441 unsigned long *length, int *format)
2442 {
2443 unsigned char *src = value;
2444 int pos, len = *length;
2445
2446 XC_LOG(("_get_selection() - called\n"));
2447
2448 if (!value && !len)
2449 {
2450 if (XC_write_display_socket_int(PDC_CLIP_EMPTY) < 0)
2451 _exit_process(4, SIGKILL, "exiting from _get_selection");
2452 }
2453 else
2454 {
2455 /* Here all is OK, send PDC_CLIP_SUCCESS, then length, then
2456 contents */
2457
2458 if (XC_write_display_socket_int(PDC_CLIP_SUCCESS) < 0)
2459 _exit_process(4, SIGKILL, "exiting from _get_selection");
2460
2461 if (XC_write_display_socket_int(len) < 0)
2462 _exit_process(4, SIGKILL, "exiting from _get_selection");
2463
2464 for (pos = 0; pos < len; pos++)
2465 {
2466 #ifdef PDC_WIDE
2467 wchar_t c;
2468 #else
2469 unsigned char c;
2470 #endif
2471 c = *src++;
2472
2473 if (XC_write_socket(xc_display_sock, &c, sizeof(c)) < 0)
2474 _exit_process(4, SIGKILL, "exiting from _get_selection");
2475 }
2476 }
2477 }
2478
2479 #ifdef PDC_WIDE
2480 static void _get_selection_utf8(Widget w, XtPointer data, Atom *selection,
2481 Atom *type, XtPointer value,
2482 unsigned long *length, int *format)
2483 {
2484 int len = *length;
2485
2486 XC_LOG(("_get_selection_utf8() - called\n"));
2487
2488 if (!*type || !*length)
2489 {
2490 XtGetSelectionValue(w, XA_PRIMARY, XA_STRING, _get_selection,
2491 (XtPointer)NULL, 0);
2492 return;
2493 }
2494
2495 if (!value && !len)
2496 {
2497 if (XC_write_display_socket_int(PDC_CLIP_EMPTY) >= 0)
2498 return;
2499 }
2500 else
2501 {
2502 wchar_t *wcontents = malloc((len + 1) * sizeof(wchar_t));
2503 char *src = value;
2504 int i = 0;
2505
2506 while (*src && i < (*length))
2507 {
2508 int retval = _from_utf8(wcontents + i, src, len);
2509
2510 src += retval;
2511 len -= retval;
2512 i++;
2513 }
2514
2515 wcontents[i] = 0;
2516 len = i;
2517
2518 /* Here all is OK, send PDC_CLIP_SUCCESS, then length, then
2519 contents */
2520
2521 if (XC_write_display_socket_int(PDC_CLIP_SUCCESS) >= 0)
2522 if (XC_write_display_socket_int(len) >= 0)
2523 if (XC_write_socket(xc_display_sock,
2524 wcontents, len * sizeof(wchar_t)) >= 0)
2525 {
2526 free(wcontents);
2527 return;
2528 }
2529 }
2530
2531 _exit_process(4, SIGKILL, "exiting from _get_selection_utf8");
2532 }
2533 #endif
2534
2535 /* For PDC_setclipboard() */
2536
2537 static void _set_selection(void)
2538 {
2539 long length, pos;
2540 int status;
2541
2542 if (XC_read_socket(xc_display_sock, &length, sizeof(long)) < 0)
2543 _exit_process(5, SIGKILL, "exiting from _set_selection");
2544
2545 if (length > (long)tmpsel_length)
2546 {
2547 if (!tmpsel_length)
2548 tmpsel = malloc((length + 1) * sizeof(chtype));
2549 else
2550 tmpsel = realloc(tmpsel, (length + 1) * sizeof(chtype));
2551 }
2552
2553 if (!tmpsel)
2554 if (XC_write_display_socket_int(PDC_CLIP_MEMORY_ERROR) < 0)
2555 _exit_process(4, SIGKILL, "exiting from _set_selection");
2556
2557 for (pos = 0; pos < length; pos++)
2558 {
2559 #ifdef PDC_WIDE
2560 wchar_t c;
2561 #else
2562 unsigned char c;
2563 #endif
2564 if (XC_read_socket(xc_display_sock, &c, sizeof(c)) < 0)
2565 _exit_process(5, SIGKILL, "exiting from _set_selection");
2566
2567 tmpsel[pos] = c;
2568 }
2569
2570 tmpsel_length = length;
2571 tmpsel[length] = 0;
2572
2573 if (XtOwnSelection(topLevel, XA_PRIMARY, CurrentTime,
2574 _convert_proc, _lose_ownership, NULL) == False)
2575 {
2576 status = PDC_CLIP_ACCESS_ERROR;
2577 free(tmpsel);
2578 tmpsel = NULL;
2579 tmpsel_length = 0;
2580 }
2581 else
2582 status = PDC_CLIP_SUCCESS;
2583
2584 _selection_off();
2585
2586 if (XC_write_display_socket_int(status) < 0)
2587 _exit_process(4, SIGKILL, "exiting from _set_selection");
2588 }
2589
2590 /* The curses process is waiting; tell it to continue */
2591
2592 static void _resume_curses(void)
2593 {
2594 if (XC_write_display_socket_int(CURSES_CONTINUE) < 0)
2595 _exit_process(4, SIGKILL, "exiting from _process_curses_requests");
2596 }
2597
2598 /* The curses process sent us a message */
2599
2600 static void _process_curses_requests(XtPointer client_data, int *fid,
2601 XtInputId *id)
2602 {
2603 struct timeval socket_timeout = {0};
2604 int s;
2605 int old_row, new_row;
2606 int old_x, new_x;
2607 int pos, num_cols;
2608
2609 char buf[12]; /* big enough for 2 integers */
2610
2611 XC_LOG(("_process_curses_requests() - called\n"));
2612
2613 if (!received_map_notify)
2614 return;
2615
2616 FD_ZERO(&xc_readfds);
2617 FD_SET(xc_display_sock, &xc_readfds);
2618
2619 if ((s = select(FD_SETSIZE, (FD_SET_CAST)&xc_readfds, NULL,
2620 NULL, &socket_timeout)) < 0)
2621 _exit_process(2, SIGKILL, "exiting from _process_curses_requests"
2622 " - select failed");
2623
2624 if (!s) /* no requests pending - should never happen! */
2625 return;
2626
2627 if (FD_ISSET(xc_display_sock, &xc_readfds))
2628 {
2629 /* read first integer to determine total message has been
2630 received */
2631
2632 XC_LOG(("_process_curses_requests() - before XC_read_socket()\n"));
2633
2634 if (XC_read_socket(xc_display_sock, &num_cols, sizeof(int)) < 0)
2635 _exit_process(3, SIGKILL, "exiting from _process_curses_requests"
2636 " - first read");
2637
2638 XC_LOG(("_process_curses_requests() - after XC_read_socket()\n"));
2639
2640 after_first_curses_request = TRUE;
2641
2642 switch(num_cols)
2643 {
2644 case CURSES_EXIT: /* request from curses to stop */
2645 XC_LOG(("CURSES_EXIT received from child\n"));
2646 _exit_process(0, 0, "XCursesProcess requested to exit by child");
2647 break;
2648
2649 case CURSES_BELL:
2650 XC_LOG(("CURSES_BELL received from child\n"));
2651 XBell(XCURSESDISPLAY, 50);
2652 break;
2653
2654 /* request from curses to confirm completion of display */
2655
2656 case CURSES_REFRESH:
2657 XC_LOG(("CURSES_REFRESH received from child\n"));
2658 _refresh_screen();
2659 _resume_curses();
2660 break;
2661
2662 case CURSES_REFRESH_SCROLLBAR:
2663 _refresh_scrollbar();
2664 break;
2665
2666 case CURSES_CURSOR:
2667 XC_LOG(("CURSES_CURSOR received from child\n"));
2668
2669 if (XC_read_socket(xc_display_sock, buf, sizeof(int) * 2) < 0)
2670 _exit_process(5, SIGKILL, "exiting from CURSES_CURSOR "
2671 "_process_curses_requests");
2672
2673 memcpy(&pos, buf, sizeof(int));
2674 old_row = pos & 0xFF;
2675 old_x = pos >> 8;
2676
2677 memcpy(&pos, buf + sizeof(int), sizeof(int));
2678 new_row = pos & 0xFF;
2679 new_x = pos >> 8;
2680
2681 visible_cursor = TRUE;
2682 _display_cursor(old_row, old_x, new_row, new_x);
2683 break;
2684
2685 case CURSES_DISPLAY_CURSOR:
2686 XC_LOG(("CURSES_DISPLAY_CURSOR received from child. Vis now: "));
2687 XC_LOG((visible_cursor ? "1\n" : "0\n"));
2688
2689 /* If the window is not active, ignore this command. The
2690 cursor will stay solid. */
2691
2692 if (window_entered)
2693 {
2694 if (visible_cursor)
2695 {
2696 /* Cursor currently ON, turn it off */
2697
2698 int save_visibility = SP->visibility;
2699 SP->visibility = 0;
2700 _redraw_cursor();
2701 SP->visibility = save_visibility;
2702 visible_cursor = FALSE;
2703 }
2704 else
2705 {
2706 /* Cursor currently OFF, turn it on */
2707
2708 _redraw_cursor();
2709 visible_cursor = TRUE;
2710 }
2711 }
2712
2713 break;
2714
2715 case CURSES_TITLE:
2716 XC_LOG(("CURSES_TITLE received from child\n"));
2717 _set_title();
2718 break;
2719
2720 case CURSES_RESIZE:
2721 XC_LOG(("CURSES_RESIZE received from child\n"));
2722 _resize();
2723 _resume_curses();
2724 break;
2725
2726 case CURSES_GET_SELECTION:
2727 XC_LOG(("CURSES_GET_SELECTION received from child\n"));
2728
2729 _resume_curses();
2730
2731 XtGetSelectionValue(topLevel, XA_PRIMARY,
2732 #ifdef PDC_WIDE
2733 XA_UTF8_STRING(XtDisplay(topLevel)),
2734 _get_selection_utf8,
2735 #else
2736 XA_STRING, _get_selection,
2737 #endif
2738 (XtPointer)NULL, 0);
2739
2740 break;
2741
2742 case CURSES_SET_SELECTION:
2743 XC_LOG(("CURSES_SET_SELECTION received from child\n"));
2744 _set_selection();
2745 break;
2746
2747 case CURSES_CLEAR_SELECTION:
2748 XC_LOG(("CURSES_CLEAR_SELECTION received from child\n"));
2749 _resume_curses();
2750 _selection_off();
2751 break;
2752
2753 case CURSES_GET_COLOR:
2754 XC_LOG(("CURSES_GET_COLOR recieved from child\n"));
2755 _get_color();
2756 _resume_curses();
2757 break;
2758
2759 case CURSES_SET_COLOR:
2760 XC_LOG(("CURSES_SET_COLOR recieved from child\n"));
2761 _set_color();
2762 _resume_curses();
2763 break;
2764
2765 default:
2766 PDC_LOG(("%s:Unknown request %d\n", XCLOGMSG, num_cols));
2767 }
2768 }
2769 }
2770
2771 static void _handle_structure_notify(Widget w, XtPointer client_data,
2772 XEvent *event, Boolean *unused)
2773 {
2774 XC_LOG(("_handle_structure_notify() - called\n"));
2775
2776 switch(event->type)
2777 {
2778 case ConfigureNotify:
2779 XC_LOG(("ConfigureNotify received\n"));
2780
2781 /* Window has been resized, change width and height to send to
2782 place_text and place_graphics in next Expose. Also will need
2783 to kill (SIGWINCH) curses process if screen size changes. */
2784
2785 resize_window_width = event->xconfigure.width;
2786 resize_window_height = event->xconfigure.height;
2787
2788 after_first_curses_request = FALSE;
2789
2790 #ifdef SIGWINCH
2791 SP->resized = 1;
2792
2793 kill(xc_otherpid, SIGWINCH);
2794 #endif
2795 _send_key_to_curses(KEY_RESIZE, NULL, TRUE);
2796 break;
2797
2798 case MapNotify:
2799 XC_LOG(("MapNotify received\n"));
2800
2801 received_map_notify = 1;
2802
2803 _draw_border();
2804 break;
2805
2806 default:
2807 PDC_LOG(("%s:_handle_structure_notify - unknown event %d\n",
2808 XCLOGMSG, event->type));
2809 }
2810 }
2811
2812 static RETSIGTYPE _handle_signals(int signo)
2813 {
2814 int flag = CURSES_EXIT;
2815
2816 PDC_LOG(("%s:_handle_signals() - called: %d\n", XCLOGMSG, signo));
2817
2818 /* Patch by: Georg Fuchs */
2819
2820 XCursesSetSignal(signo, _handle_signals);
2821
2822 #ifdef SIGTSTP
2823 if (signo == SIGTSTP)
2824 {
2825 pause();
2826 return;
2827 }
2828 #endif
2829 #ifdef SIGCONT
2830 if (signo == SIGCONT)
2831 return;
2832 #endif
2833 #ifdef SIGCLD
2834 if (signo == SIGCLD)
2835 return;
2836 #endif
2837 #ifdef SIGTTIN
2838 if (signo == SIGTTIN)
2839 return;
2840 #endif
2841 #ifdef SIGWINCH
2842 if (signo == SIGWINCH)
2843 return;
2844 #endif
2845
2846 /* End of patch by: Georg Fuchs */
2847
2848 XCursesSetSignal(signo, SIG_IGN);
2849
2850 /* Send a CURSES_EXIT to myself */
2851
2852 if (XC_write_socket(xc_exit_sock, &flag, sizeof(int)) < 0)
2853 _exit_process(7, signo, "exiting from _handle_signals");
2854 }
2855
2856 #ifdef PDC_XIM
2857 static void _dummy_handler(Widget w, XtPointer client_data,
2858 XEvent *event, Boolean *unused)
2859 {
2860 }
2861 #endif
2862
2863 int XCursesSetupX(int argc, char *argv[])
2864 {
2865 char *myargv[] = {"PDCurses", NULL};
2866 extern bool sb_started;
2867
2868 int italic_font_valid;
2869 XColor pointerforecolor, pointerbackcolor;
2870 XrmValue rmfrom, rmto;
2871 int i = 0;
2872 int minwidth, minheight;
2873
2874 XC_LOG(("XCursesSetupX called\n"));
2875
2876 if (!argv)
2877 {
2878 argv = myargv;
2879 argc = 1;
2880 }
2881
2882 program_name = argv[0];
2883
2884 /* Keep open the 'write' end of the socket so the XCurses process
2885 can send a CURSES_EXIT to itself from within the signal handler */
2886
2887 xc_exit_sock = xc_display_sockets[0];
2888 xc_display_sock = xc_display_sockets[1];
2889
2890 close(xc_key_sockets[0]);
2891 xc_key_sock = xc_key_sockets[1];
2892
2893 /* Trap all signals when XCurses is the child process, but only if
2894 they haven't already been ignored by the application. */
2895
2896 for (i = 0; i < PDC_MAX_SIGNALS; i++)
2897 if (XCursesSetSignal(i, _handle_signals) == SIG_IGN)
2898 XCursesSetSignal(i, SIG_IGN);
2899
2900 /* Start defining X Toolkit things */
2901
2902 #if XtSpecificationRelease > 4
2903 XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
2904 #endif
2905
2906 /* Exit if no DISPLAY variable set */
2907
2908 if (!getenv("DISPLAY"))
2909 {
2910 fprintf(stderr, "Error: no DISPLAY variable set\n");
2911 kill(xc_otherpid, SIGKILL);
2912 return ERR;
2913 }
2914
2915 /* Initialise the top level widget */
2916
2917 topLevel = XtVaAppInitialize(&app_context, class_name, options,
2918 XtNumber(options), &argc, argv, NULL, NULL);
2919
2920 XtVaGetApplicationResources(topLevel, &xc_app_data, app_resources,
2921 XtNumber(app_resources), NULL);
2922
2923 /* Check application resource values here */
2924
2925 font_width = xc_app_data.normalFont->max_bounds.rbearing -
2926 xc_app_data.normalFont->min_bounds.lbearing;
2927
2928 font_height = xc_app_data.normalFont->max_bounds.ascent +
2929 xc_app_data.normalFont->max_bounds.descent;
2930
2931 font_ascent = xc_app_data.normalFont->max_bounds.ascent;
2932 font_descent = xc_app_data.normalFont->max_bounds.descent;
2933
2934 /* Check that the italic font and normal fonts are the same size */
2935 /* This appears backwards */
2936
2937 italic_font_valid = font_width !=
2938 xc_app_data.italicFont->max_bounds.rbearing -
2939 xc_app_data.italicFont->min_bounds.lbearing ||
2940 font_height !=
2941 xc_app_data.italicFont->max_bounds.ascent +
2942 xc_app_data.italicFont->max_bounds.descent;
2943
2944 /* Calculate size of display window */
2945
2946 XCursesCOLS = xc_app_data.cols;
2947 XCursesLINES = xc_app_data.lines;
2948
2949 window_width = font_width * XCursesCOLS +
2950 2 * xc_app_data.borderWidth;
2951
2952 window_height = font_height * XCursesLINES +
2953 2 * xc_app_data.borderWidth;
2954
2955 minwidth = font_width * 2 + xc_app_data.borderWidth * 2;
2956 minheight = font_height * 2 + xc_app_data.borderWidth * 2;
2957
2958 /* Set up the icon for the application; the default is an internal
2959 one for PDCurses. Then set various application level resources. */
2960
2961 _get_icon();
2962
2963 #ifdef HAVE_XPM_H
2964 if (xc_app_data.pixmap && xc_app_data.pixmap[0])
2965 XtVaSetValues(topLevel, XtNminWidth, minwidth, XtNminHeight,
2966 minheight, XtNbaseWidth, xc_app_data.borderWidth * 2,
2967 XtNbaseHeight, xc_app_data.borderWidth * 2,
2968 XtNiconPixmap, icon_pixmap,
2969 XtNiconMask, icon_pixmap_mask, NULL);
2970 else
2971 #endif
2972 XtVaSetValues(topLevel, XtNminWidth, minwidth, XtNminHeight,
2973 minheight, XtNbaseWidth, xc_app_data.borderWidth * 2,
2974 XtNbaseHeight, xc_app_data.borderWidth * 2,
2975 XtNiconPixmap, icon_bitmap, NULL);
2976
2977 /* Create a BOX widget in which to draw */
2978
2979 if (xc_app_data.scrollbarWidth && sb_started)
2980 {
2981 scrollBox = XtVaCreateManagedWidget(program_name,
2982 scrollBoxWidgetClass, topLevel, XtNwidth,
2983 window_width + xc_app_data.scrollbarWidth,
2984 XtNheight, window_height + xc_app_data.scrollbarWidth,
2985 XtNwidthInc, font_width, XtNheightInc, font_height, NULL);
2986
2987 drawing = XtVaCreateManagedWidget(program_name,
2988 boxWidgetClass, scrollBox, XtNwidth,
2989 window_width, XtNheight, window_height, XtNwidthInc,
2990 font_width, XtNheightInc, font_height, NULL);
2991
2992 scrollVert = XtVaCreateManagedWidget("scrollVert",
2993 scrollbarWidgetClass, scrollBox, XtNorientation,
2994 XtorientVertical, XtNheight, window_height, XtNwidth,
2995 xc_app_data.scrollbarWidth, NULL);
2996
2997 XtAddCallback(scrollVert, XtNscrollProc, _scroll_up_down, drawing);
2998 XtAddCallback(scrollVert, XtNjumpProc, _thumb_up_down, drawing);
2999
3000 scrollHoriz = XtVaCreateManagedWidget("scrollHoriz",
3001 scrollbarWidgetClass, scrollBox, XtNorientation,
3002 XtorientHorizontal, XtNwidth, window_width, XtNheight,
3003 xc_app_data.scrollbarWidth, NULL);
3004
3005 XtAddCallback(scrollHoriz, XtNscrollProc, _scroll_left_right, drawing);
3006 XtAddCallback(scrollHoriz, XtNjumpProc, _thumb_left_right, drawing);
3007 }
3008 else
3009 {
3010 drawing = XtVaCreateManagedWidget(program_name, boxWidgetClass,
3011 topLevel, XtNwidth, window_width, XtNheight, window_height,
3012 XtNwidthInc, font_width, XtNheightInc, font_height, NULL);
3013
3014 XtVaSetValues(topLevel, XtNwidthInc, font_width, XtNheightInc,
3015 font_height, NULL);
3016 }
3017
3018 /* Process any default translations */
3019
3020 XtAugmentTranslations(drawing,
3021 XtParseTranslationTable(default_translations));
3022 XtAppAddActions(app_context, action_table, XtNumber(action_table));
3023
3024 /* Process the supplied colors */
3025
3026 _initialize_colors();
3027
3028 /* Determine text cursor alignment from resources */
3029
3030 if (!strcmp(xc_app_data.textCursor, "vertical"))
3031 vertical_cursor = TRUE;
3032
3033 /* Now have LINES and COLS. Set these in the shared SP so the curses
3034 program can find them. */
3035
3036 LINES = XCursesLINES;
3037 COLS = XCursesCOLS;
3038
3039 if ((shmidSP = shmget(shmkeySP, sizeof(SCREEN) + XCURSESSHMMIN,
3040 0700 | IPC_CREAT)) < 0)
3041 {
3042 perror("Cannot allocate shared memory for SCREEN");
3043 kill(xc_otherpid, SIGKILL);
3044 return ERR;
3045 }
3046
3047 SP = (SCREEN*)shmat(shmidSP, 0, 0);
3048 memset(SP, 0, sizeof(SCREEN));
3049 SP->XcurscrSize = XCURSCR_SIZE;
3050 SP->lines = XCursesLINES;
3051 SP->cols = XCursesCOLS;
3052
3053 SP->mouse_wait = xc_app_data.clickPeriod;
3054 SP->audible = TRUE;
3055
3056 PDC_LOG(("%s:SHM size for curscr %d\n", XCLOGMSG, SP->XcurscrSize));
3057
3058 if ((shmid_Xcurscr = shmget(shmkey_Xcurscr, SP->XcurscrSize +
3059 XCURSESSHMMIN, 0700 | IPC_CREAT)) < 0)
3060 {
3061 perror("Cannot allocate shared memory for curscr");
3062 kill(xc_otherpid, SIGKILL);
3063 shmdt((char *)SP);
3064 shmctl(shmidSP, IPC_RMID, 0);
3065 return ERR;
3066 }
3067
3068 Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
3069 memset(Xcurscr, 0, SP->XcurscrSize);
3070 xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
3071
3072 PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d LINES %d COLS %d\n",
3073 XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));
3074
3075 /* Add Event handlers to the drawing widget */
3076
3077 XtAddEventHandler(drawing, ExposureMask, False, _handle_expose, NULL);
3078 XtAddEventHandler(drawing, StructureNotifyMask, False,
3079 _handle_structure_notify, NULL);
3080 XtAddEventHandler(drawing, EnterWindowMask | LeaveWindowMask, False,
3081 _handle_enter_leave, NULL);
3082 XtAddEventHandler(topLevel, 0, True, _handle_nonmaskable, NULL);
3083
3084 /* Add input handler from xc_display_sock (requests from curses
3085 program) */
3086
3087 XtAppAddInput(app_context, xc_display_sock, (XtPointer)XtInputReadMask,
3088 _process_curses_requests, NULL);
3089
3090 /* If there is a cursorBlink resource, start the Timeout event */
3091
3092 if (xc_app_data.cursorBlinkRate)
3093 XtAppAddTimeOut(app_context, xc_app_data.cursorBlinkRate,
3094 _blink_cursor, NULL);
3095
3096 /* Leave telling the curses process that it can start to here so
3097 that when the curses process makes a request, the Xcurses
3098 process can service the request. */
3099
3100 XC_write_display_socket_int(CURSES_CHILD);
3101
3102 XtRealizeWidget(topLevel);
3103
3104 /* Handle trapping of the WM_DELETE_WINDOW property */
3105
3106 wm_atom[0] = XInternAtom(XtDisplay(topLevel), "WM_DELETE_WINDOW", False);
3107
3108 XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel), wm_atom, 1);
3109
3110 /* Create the Graphics Context for drawing. This MUST be done AFTER
3111 the associated widget has been realized. */
3112
3113 XC_LOG(("before _get_gc\n"));
3114
3115 _get_gc(&normal_gc, xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
3116
3117 _get_gc(&italic_gc, italic_font_valid ? xc_app_data.italicFont :
3118 xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
3119
3120 _get_gc(&block_cursor_gc, xc_app_data.normalFont,
3121 COLOR_BLACK, COLOR_CURSOR);
3122
3123 _get_gc(&rect_cursor_gc, xc_app_data.normalFont,
3124 COLOR_CURSOR, COLOR_BLACK);
3125
3126 _get_gc(&border_gc, xc_app_data.normalFont, COLOR_BORDER, COLOR_BLACK);
3127
3128 XSetLineAttributes(XCURSESDISPLAY, rect_cursor_gc, 2,
3129 LineSolid, CapButt, JoinMiter);
3130
3131 XSetLineAttributes(XCURSESDISPLAY, border_gc, xc_app_data.borderWidth,
3132 LineSolid, CapButt, JoinMiter);
3133
3134 /* Set the cursor for the application */
3135
3136 XDefineCursor(XCURSESDISPLAY, XCURSESWIN, xc_app_data.pointer);
3137 rmfrom.size = sizeof(Pixel);
3138 rmto.size = sizeof(XColor);
3139
3140 rmto.addr = (XPointer)&pointerforecolor;
3141 rmfrom.addr = (XPointer)&(xc_app_data.pointerForeColor);
3142 XtConvertAndStore(drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
3143
3144 rmfrom.size = sizeof(Pixel);
3145 rmto.size = sizeof(XColor);
3146
3147 rmfrom.addr = (XPointer)&(xc_app_data.pointerBackColor);
3148 rmto.addr = (XPointer)&pointerbackcolor;
3149 XtConvertAndStore(drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
3150
3151 XRecolorCursor(XCURSESDISPLAY, xc_app_data.pointer,
3152 &pointerforecolor, &pointerbackcolor);
3153
3154 #ifndef PDC_XIM
3155
3156 /* Convert the supplied compose key to a Keysym */
3157
3158 compose_key = XStringToKeysym(xc_app_data.composeKey);
3159
3160 if (compose_key && IsModifierKey(compose_key))
3161 {
3162 int i, j;
3163 KeyCode *kcp;
3164 XModifierKeymap *map;
3165 KeyCode compose_keycode = XKeysymToKeycode(XCURSESDISPLAY, compose_key);
3166
3167 map = XGetModifierMapping(XCURSESDISPLAY);
3168 kcp = map->modifiermap;
3169
3170 for (i = 0; i < 8; i++)
3171 {
3172 for (j = 0; j < map->max_keypermod; j++, kcp++)
3173 {
3174 if (!*kcp)
3175 continue;
3176
3177 if (compose_keycode == *kcp)
3178 {
3179 compose_mask = state_mask[i];
3180 break;
3181 }
3182 }
3183
3184 if (compose_mask)
3185 break;
3186 }
3187
3188 XFreeModifiermap(map);
3189 }
3190
3191 #else
3192 Xim = XOpenIM(XCURSESDISPLAY, NULL, NULL, NULL);
3193
3194 if (Xim)
3195 {
3196 Xic = XCreateIC(Xim, XNInputStyle,
3197 XIMPreeditNothing | XIMStatusNothing,
3198 XNClientWindow, XCURSESWIN, NULL);
3199 }
3200
3201 if (Xic)
3202 {
3203 long im_event_mask;
3204
3205 XGetICValues(Xic, XNFilterEvents, &im_event_mask, NULL);
3206 if (im_event_mask)
3207 XtAddEventHandler(drawing, im_event_mask, False,
3208 _dummy_handler, NULL);
3209
3210 XSetICFocus(Xic);
3211 }
3212 else
3213 {
3214 perror("ERROR: Cannot create input context");
3215 kill(xc_otherpid, SIGKILL);
3216 shmdt((char *)SP);
3217 shmdt((char *)Xcurscr);
3218 shmctl(shmidSP, IPC_RMID, 0);
3219 shmctl(shmid_Xcurscr, IPC_RMID, 0);
3220 return ERR;
3221 }
3222
3223 #endif
3224
3225 /* Wait for events */
3226
3227 XtAppMainLoop(app_context);
3228 return OK; /* won't get here */
3229 }
File x11/xcurses-config.in added (mode: 100644) (index 00000000..55b4704c)
1 #! /bin/sh
2 #
3 # The idea to this kind of setup info script was stolen from numerous
4 # other packages, such as neon, libxml and gnome.
5 #
6 # $Id: xcurses-config.in,v 1.6 2007/11/07 23:33:07 wmcbrine Exp $
7 #
8
9 verdot=3.4
10
11 prefix=@prefix@
12 exec_prefix=@exec_prefix@
13 includedir=@includedir@/xcurses
14
15 usage()
16 {
17 echo "Usage: xcurses-config [OPTION]"
18 echo ""
19 echo "Available values for OPTION include:"
20 echo ""
21 echo " --help display this help and exit"
22 echo " --cflags pre-processor and compiler flags"
23 echo " [-I$includedir]"
24 echo " --libs library linking information"
25 echo " [-L$prefix/lib -lXCurses @LDFLAGS@ @MH_XLIBS@ @MH_EXTRA_LIBS@"
26 echo " --prefix PDCurses install prefix"
27 echo " [$prefix]"
28 echo " --version output version information"
29 echo " [$verdot]"
30 exit $1
31 }
32
33 if test $# -eq 0; then
34 usage 1
35 fi
36
37 while test $# -gt 0; do
38 case "$1" in
39 # this deals with options in the style
40 # --option=value and extracts the value part
41 # [not currently used]
42 -*=*) value=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
43 *) value= ;;
44 esac
45
46 case "$1" in
47 --prefix)
48 echo $prefix
49 ;;
50
51 --version)
52 echo $verdot
53 exit 0
54 ;;
55
56 --help)
57 usage 0
58 ;;
59
60 --cflags)
61 echo -I$includedir
62 ;;
63
64 --libs)
65 echo -L$prefix/lib -lXCurses @LDFLAGS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
66 ;;
67
68 *)
69 usage
70 exit 1
71 ;;
72 esac
73 shift
74 done
75
76 exit 0
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm-pdcurses

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm-pdcurses

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master