curses 1.3.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +19 -0
- data/.github/workflows/ubuntu.yml +26 -0
- data/.github/workflows/windows.yml +25 -0
- data/History.md +34 -0
- data/README.md +14 -46
- data/Rakefile +0 -86
- data/curses.gemspec +2 -3
- data/ext/curses/curses.c +70 -58
- data/ext/curses/extconf.rb +134 -21
- data/lib/curses.rb +5 -12
- data/sample/addch.rb +16 -0
- data/sample/attr_demo.rb +32 -0
- data/sample/colors.rb +26 -0
- data/sample/menu.rb +3 -3
- data/sample/mouse_move.rb +75 -0
- data/vendor/PDCurses/.gitignore +47 -0
- data/vendor/PDCurses/.travis.yml +49 -0
- data/vendor/PDCurses/CMakeLists.txt +68 -0
- data/vendor/PDCurses/HISTORY.md +2036 -0
- data/vendor/PDCurses/IMPLEMNT.md +327 -0
- data/vendor/PDCurses/README.md +77 -0
- data/vendor/PDCurses/acs_defs.h +265 -0
- data/vendor/PDCurses/appveyor.yml +218 -0
- data/vendor/PDCurses/cmake/README.md +71 -0
- data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
- data/vendor/PDCurses/cmake/build_options.cmake +25 -0
- data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
- data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
- data/vendor/PDCurses/cmake/get_version.cmake +17 -0
- data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
- data/vendor/PDCurses/cmake/project_common.cmake +121 -0
- data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
- data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
- data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
- data/vendor/PDCurses/cmake/version.in.cmake +73 -0
- data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
- data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
- data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
- data/vendor/PDCurses/curses.h +1846 -0
- data/vendor/PDCurses/curspriv.h +134 -0
- data/vendor/PDCurses/demos/README.md +25 -0
- data/vendor/PDCurses/demos/firework.c +144 -0
- data/vendor/PDCurses/demos/newtest.c +581 -0
- data/vendor/PDCurses/demos/ozdemo.c +447 -0
- data/vendor/PDCurses/demos/ptest.c +283 -0
- data/vendor/PDCurses/demos/rain.c +157 -0
- data/vendor/PDCurses/demos/testcurs.c +1607 -0
- data/vendor/PDCurses/demos/tui.c +1048 -0
- data/vendor/PDCurses/demos/tui.h +65 -0
- data/vendor/PDCurses/demos/tuidemo.c +233 -0
- data/vendor/PDCurses/demos/version.c +61 -0
- data/vendor/PDCurses/demos/worm.c +432 -0
- data/vendor/PDCurses/demos/xmas.c +955 -0
- data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
- data/vendor/PDCurses/dos/Makefile.bcc +83 -0
- data/vendor/PDCurses/dos/Makefile.dmc +257 -0
- data/vendor/PDCurses/dos/Makefile.msc +113 -0
- data/vendor/PDCurses/dos/Makefile.wcc +107 -0
- data/vendor/PDCurses/dos/README.md +51 -0
- data/vendor/PDCurses/dos/bccdos.lrf +9 -0
- data/vendor/PDCurses/dos/mscdos.lrf +50 -0
- data/vendor/PDCurses/dos/pdcclip.c +132 -0
- data/vendor/PDCurses/dos/pdcdisp.c +135 -0
- data/vendor/PDCurses/dos/pdcdos.h +194 -0
- data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
- data/vendor/PDCurses/dos/pdckbd.c +513 -0
- data/vendor/PDCurses/dos/pdcscrn.c +785 -0
- data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
- data/vendor/PDCurses/dos/pdcutil.c +212 -0
- data/vendor/PDCurses/libobjs.mif +26 -0
- data/vendor/PDCurses/makedist.mif +20 -0
- data/vendor/PDCurses/man/README.md +21 -0
- data/vendor/PDCurses/man/intro.md +361 -0
- data/vendor/PDCurses/man/manext.c +119 -0
- data/vendor/PDCurses/man/sdl.md +152 -0
- data/vendor/PDCurses/man/sdl2.md +58 -0
- data/vendor/PDCurses/man/x11.md +407 -0
- data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
- data/vendor/PDCurses/ncurses/README.md +26 -0
- data/vendor/PDCurses/ncurses/makefile +29 -0
- data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
- data/vendor/PDCurses/os2/Makefile.bcc +90 -0
- data/vendor/PDCurses/os2/Makefile.wcc +43 -0
- data/vendor/PDCurses/os2/README.md +43 -0
- data/vendor/PDCurses/os2/iccos2.lrf +50 -0
- data/vendor/PDCurses/os2/iccos2.mak +256 -0
- data/vendor/PDCurses/os2/pdcclip.c +188 -0
- data/vendor/PDCurses/os2/pdcdisp.c +93 -0
- data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
- data/vendor/PDCurses/os2/pdckbd.c +521 -0
- data/vendor/PDCurses/os2/pdcos2.h +55 -0
- data/vendor/PDCurses/os2/pdcscrn.c +449 -0
- data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
- data/vendor/PDCurses/os2/pdcutil.c +52 -0
- data/vendor/PDCurses/panel.h +56 -0
- data/vendor/PDCurses/pdcurses/README.md +25 -0
- data/vendor/PDCurses/pdcurses/addch.c +693 -0
- data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
- data/vendor/PDCurses/pdcurses/addstr.c +240 -0
- data/vendor/PDCurses/pdcurses/attr.c +359 -0
- data/vendor/PDCurses/pdcurses/beep.c +68 -0
- data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
- data/vendor/PDCurses/pdcurses/border.c +411 -0
- data/vendor/PDCurses/pdcurses/clear.c +159 -0
- data/vendor/PDCurses/pdcurses/color.c +298 -0
- data/vendor/PDCurses/pdcurses/debug.c +109 -0
- data/vendor/PDCurses/pdcurses/delch.c +96 -0
- data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
- data/vendor/PDCurses/pdcurses/deprec.c +27 -0
- data/vendor/PDCurses/pdcurses/getch.c +417 -0
- data/vendor/PDCurses/pdcurses/getstr.c +474 -0
- data/vendor/PDCurses/pdcurses/getyx.c +139 -0
- data/vendor/PDCurses/pdcurses/inch.c +127 -0
- data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
- data/vendor/PDCurses/pdcurses/initscr.c +367 -0
- data/vendor/PDCurses/pdcurses/inopts.c +324 -0
- data/vendor/PDCurses/pdcurses/insch.c +271 -0
- data/vendor/PDCurses/pdcurses/insstr.c +264 -0
- data/vendor/PDCurses/pdcurses/instr.c +246 -0
- data/vendor/PDCurses/pdcurses/kernel.c +259 -0
- data/vendor/PDCurses/pdcurses/keyname.c +157 -0
- data/vendor/PDCurses/pdcurses/mouse.c +438 -0
- data/vendor/PDCurses/pdcurses/move.c +57 -0
- data/vendor/PDCurses/pdcurses/outopts.c +159 -0
- data/vendor/PDCurses/pdcurses/overlay.c +214 -0
- data/vendor/PDCurses/pdcurses/pad.c +260 -0
- data/vendor/PDCurses/pdcurses/panel.c +633 -0
- data/vendor/PDCurses/pdcurses/printw.c +126 -0
- data/vendor/PDCurses/pdcurses/refresh.c +279 -0
- data/vendor/PDCurses/pdcurses/scanw.c +578 -0
- data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
- data/vendor/PDCurses/pdcurses/scroll.c +101 -0
- data/vendor/PDCurses/pdcurses/slk.c +591 -0
- data/vendor/PDCurses/pdcurses/termattr.c +182 -0
- data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
- data/vendor/PDCurses/pdcurses/touch.c +163 -0
- data/vendor/PDCurses/pdcurses/util.c +312 -0
- data/vendor/PDCurses/pdcurses/window.c +569 -0
- data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
- data/vendor/PDCurses/sdl1/README.md +31 -0
- data/vendor/PDCurses/sdl1/deffont.h +385 -0
- data/vendor/PDCurses/sdl1/deficon.h +23 -0
- data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
- data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
- data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
- data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
- data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
- data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
- data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
- data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
- data/vendor/PDCurses/sdl1/sdltest.c +79 -0
- data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
- data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
- data/vendor/PDCurses/sdl2/README.md +34 -0
- data/vendor/PDCurses/sdl2/deffont.h +385 -0
- data/vendor/PDCurses/sdl2/deficon.h +23 -0
- data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
- data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
- data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
- data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
- data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
- data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
- data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
- data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
- data/vendor/PDCurses/sdl2/sdltest.c +81 -0
- data/vendor/PDCurses/term.h +48 -0
- data/vendor/PDCurses/version.mif +7 -0
- data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
- data/vendor/PDCurses/vt/Makefile.bcc +111 -0
- data/vendor/PDCurses/vt/Makefile.dmc +258 -0
- data/vendor/PDCurses/vt/Makefile.vc +144 -0
- data/vendor/PDCurses/vt/Makefile.wcc +107 -0
- data/vendor/PDCurses/vt/README.md +64 -0
- data/vendor/PDCurses/vt/pdcclip.c +20 -0
- data/vendor/PDCurses/vt/pdcdisp.c +284 -0
- data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
- data/vendor/PDCurses/vt/pdckbd.c +394 -0
- data/vendor/PDCurses/vt/pdcscrn.c +434 -0
- data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
- data/vendor/PDCurses/vt/pdcutil.c +43 -0
- data/vendor/PDCurses/vt/pdcvt.h +16 -0
- data/vendor/PDCurses/watcom.mif +68 -0
- data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
- data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
- data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
- data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
- data/vendor/PDCurses/wincon/Makefile.mng +176 -0
- data/vendor/PDCurses/wincon/Makefile.vc +144 -0
- data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
- data/vendor/PDCurses/wincon/README.md +85 -0
- data/vendor/PDCurses/wincon/pdcclip.c +174 -0
- data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
- data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
- data/vendor/PDCurses/wincon/pdckbd.c +786 -0
- data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
- data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
- data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
- data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
- data/vendor/PDCurses/wincon/pdcutil.c +41 -0
- data/vendor/PDCurses/wincon/pdcwin.h +31 -0
- data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
- data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
- data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
- data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
- data/vendor/PDCurses/wingui/Makefile.mng +171 -0
- data/vendor/PDCurses/wingui/Makefile.vc +144 -0
- data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
- data/vendor/PDCurses/wingui/README.md +93 -0
- data/vendor/PDCurses/wingui/pdcclip.c +174 -0
- data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
- data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
- data/vendor/PDCurses/wingui/pdckbd.c +143 -0
- data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
- data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
- data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
- data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
- data/vendor/PDCurses/wingui/pdcutil.c +61 -0
- data/vendor/PDCurses/wingui/pdcwin.h +122 -0
- data/vendor/PDCurses/x11/Makefile.in +754 -0
- data/vendor/PDCurses/x11/PDCurses.spec +82 -0
- data/vendor/PDCurses/x11/README.md +62 -0
- data/vendor/PDCurses/x11/ScrollBox.c +319 -0
- data/vendor/PDCurses/x11/ScrollBox.h +51 -0
- data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
- data/vendor/PDCurses/x11/aclocal.m4 +994 -0
- data/vendor/PDCurses/x11/big_icon.xbm +46 -0
- data/vendor/PDCurses/x11/compose.h +201 -0
- data/vendor/PDCurses/x11/config.guess +1500 -0
- data/vendor/PDCurses/x11/config.h.in +100 -0
- data/vendor/PDCurses/x11/config.sub +1616 -0
- data/vendor/PDCurses/x11/configure +6700 -0
- data/vendor/PDCurses/x11/configure.ac +295 -0
- data/vendor/PDCurses/x11/debian/changelog +6 -0
- data/vendor/PDCurses/x11/debian/compat +1 -0
- data/vendor/PDCurses/x11/debian/control +11 -0
- data/vendor/PDCurses/x11/debian/copyright +27 -0
- data/vendor/PDCurses/x11/debian/rules +98 -0
- data/vendor/PDCurses/x11/install-sh +253 -0
- data/vendor/PDCurses/x11/little_icon.xbm +14 -0
- data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
- data/vendor/PDCurses/x11/pdcclip.c +173 -0
- data/vendor/PDCurses/x11/pdcdisp.c +85 -0
- data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
- data/vendor/PDCurses/x11/pdckbd.c +104 -0
- data/vendor/PDCurses/x11/pdcscrn.c +258 -0
- data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
- data/vendor/PDCurses/x11/pdcutil.c +52 -0
- data/vendor/PDCurses/x11/pdcx11.c +316 -0
- data/vendor/PDCurses/x11/pdcx11.h +191 -0
- data/vendor/PDCurses/x11/sb.c +155 -0
- data/vendor/PDCurses/x11/x11.c +3686 -0
- data/vendor/PDCurses/x11/xcurses-config.in +81 -0
- metadata +258 -24
- data/.travis.yml +0 -16
- data/appveyor.yml +0 -16
| @@ -0,0 +1,312 @@ | |
| 1 | 
            +
            /* Public Domain Curses */
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            #include <curspriv.h>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            /*man-start**************************************************************
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            util
         | 
| 8 | 
            +
            ----
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ### Synopsis
         | 
| 11 | 
            +
             | 
| 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 | 
            +
             | 
| 29 | 
            +
               unctrl() expands the text portion of the chtype c into a
         | 
| 30 | 
            +
               printable string. Control characters are changed to the "^X"
         | 
| 31 | 
            +
               notation; others are passed through. wunctrl() is the wide-
         | 
| 32 | 
            +
               character version of the function.
         | 
| 33 | 
            +
             | 
| 34 | 
            +
               filter() and use_env() are no-ops in PDCurses.
         | 
| 35 | 
            +
             | 
| 36 | 
            +
               delay_output() inserts an ms millisecond pause in output.
         | 
| 37 | 
            +
             | 
| 38 | 
            +
               getcchar() works in two modes: When wch is not NULL, it reads
         | 
| 39 | 
            +
               the cchar_t pointed to by wcval and stores the attributes in
         | 
| 40 | 
            +
               attrs, the color pair in color_pair, and the text in the
         | 
| 41 | 
            +
               wide-character string wch. When wch is NULL, getcchar() merely
         | 
| 42 | 
            +
               returns the number of wide characters in wcval. In either mode,
         | 
| 43 | 
            +
               the opts argument is unused.
         | 
| 44 | 
            +
             | 
| 45 | 
            +
               setcchar constructs a cchar_t at wcval from the wide-character
         | 
| 46 | 
            +
               text at wch, the attributes in attr and the color pair in
         | 
| 47 | 
            +
               color_pair. The opts argument is unused.
         | 
| 48 | 
            +
             | 
| 49 | 
            +
               Currently, the length returned by getcchar() is always 1 or 0.
         | 
| 50 | 
            +
               Similarly, setcchar() will only take the first wide character
         | 
| 51 | 
            +
               from wch, and ignore any others that it "should" take (i.e.,
         | 
| 52 | 
            +
               combining characters). Nor will it correctly handle any
         | 
| 53 | 
            +
               character outside the basic multilingual plane (UCS-2).
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            ### Return Value
         | 
| 56 | 
            +
             | 
| 57 | 
            +
               unctrl() and wunctrl() return NULL on failure. delay_output()
         | 
| 58 | 
            +
               always returns OK.
         | 
| 59 | 
            +
             | 
| 60 | 
            +
               getcchar() returns the number of wide characters wcval points to
         | 
| 61 | 
            +
               when wch is NULL; when it's not, getcchar() returns OK or ERR.
         | 
| 62 | 
            +
             | 
| 63 | 
            +
               setcchar() returns OK or ERR.
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            ### Portability
         | 
| 66 | 
            +
                                         X/Open    BSD    SYS V
         | 
| 67 | 
            +
                unctrl                      Y       Y       Y
         | 
| 68 | 
            +
                filter                      Y       -      3.0
         | 
| 69 | 
            +
                use_env                     Y       -      4.0
         | 
| 70 | 
            +
                delay_output                Y       Y       Y
         | 
| 71 | 
            +
                getcchar                    Y
         | 
| 72 | 
            +
                setcchar                    Y
         | 
| 73 | 
            +
                wunctrl                     Y
         | 
| 74 | 
            +
                PDC_mbtowc                  -       -       -
         | 
| 75 | 
            +
                PDC_mbstowcs                -       -       -
         | 
| 76 | 
            +
                PDC_wcstombs                -       -       -
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            **man-end****************************************************************/
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            #ifdef PDC_WIDE
         | 
| 81 | 
            +
            # ifdef PDC_FORCE_UTF8
         | 
| 82 | 
            +
            #  include <string.h>
         | 
| 83 | 
            +
            # else
         | 
| 84 | 
            +
            #  include <stdlib.h>
         | 
| 85 | 
            +
            # endif
         | 
| 86 | 
            +
            #endif
         | 
| 87 | 
            +
             | 
| 88 | 
            +
            char *unctrl(chtype c)
         | 
| 89 | 
            +
            {
         | 
| 90 | 
            +
                static char strbuf[3] = {0, 0, 0};
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                chtype ic;
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                PDC_LOG(("unctrl() - called\n"));
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                ic = c & A_CHARTEXT;
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                if (ic >= 0x20 && ic != 0x7f)       /* normal characters */
         | 
| 99 | 
            +
                {
         | 
| 100 | 
            +
                    strbuf[0] = (char)ic;
         | 
| 101 | 
            +
                    strbuf[1] = '\0';
         | 
| 102 | 
            +
                    return strbuf;
         | 
| 103 | 
            +
                }
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                strbuf[0] = '^';            /* '^' prefix */
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                if (ic == 0x7f)             /* 0x7f == DEL */
         | 
| 108 | 
            +
                    strbuf[1] = '?';
         | 
| 109 | 
            +
                else                    /* other control */
         | 
| 110 | 
            +
                    strbuf[1] = (char)(ic + '@');
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                return strbuf;
         | 
| 113 | 
            +
            }
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            void filter(void)
         | 
| 116 | 
            +
            {
         | 
| 117 | 
            +
                PDC_LOG(("filter() - called\n"));
         | 
| 118 | 
            +
            }
         | 
| 119 | 
            +
             | 
| 120 | 
            +
            void use_env(bool x)
         | 
| 121 | 
            +
            {
         | 
| 122 | 
            +
                PDC_LOG(("use_env() - called: x %d\n", x));
         | 
| 123 | 
            +
            }
         | 
| 124 | 
            +
             | 
| 125 | 
            +
            int delay_output(int ms)
         | 
| 126 | 
            +
            {
         | 
| 127 | 
            +
                PDC_LOG(("delay_output() - called: ms %d\n", ms));
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                return napms(ms);
         | 
| 130 | 
            +
            }
         | 
| 131 | 
            +
             | 
| 132 | 
            +
            #ifdef PDC_WIDE
         | 
| 133 | 
            +
            int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs,
         | 
| 134 | 
            +
                         short *color_pair, void *opts)
         | 
| 135 | 
            +
            {
         | 
| 136 | 
            +
                if (!wcval)
         | 
| 137 | 
            +
                    return ERR;
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                if (wch)
         | 
| 140 | 
            +
                {
         | 
| 141 | 
            +
                    if (!attrs || !color_pair)
         | 
| 142 | 
            +
                        return ERR;
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                    *wch = (wchar_t)(*wcval & A_CHARTEXT);
         | 
| 145 | 
            +
                    *attrs = (*wcval & (A_ATTRIBUTES & ~A_COLOR));
         | 
| 146 | 
            +
                    *color_pair = (short)( PAIR_NUMBER(*wcval & A_COLOR));
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                    if (*wch)
         | 
| 149 | 
            +
                        *++wch = L'\0';
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                    return OK;
         | 
| 152 | 
            +
                }
         | 
| 153 | 
            +
                else
         | 
| 154 | 
            +
                    return ((*wcval & A_CHARTEXT) != L'\0');
         | 
| 155 | 
            +
            }
         | 
| 156 | 
            +
             | 
| 157 | 
            +
            int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs,
         | 
| 158 | 
            +
                         short color_pair, const void *opts)
         | 
| 159 | 
            +
            {
         | 
| 160 | 
            +
                if (!wcval || !wch)
         | 
| 161 | 
            +
                    return ERR;
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                *wcval = *wch | attrs | COLOR_PAIR(color_pair);
         | 
| 164 | 
            +
             | 
| 165 | 
            +
                return OK;
         | 
| 166 | 
            +
            }
         | 
| 167 | 
            +
             | 
| 168 | 
            +
            wchar_t *wunctrl(cchar_t *wc)
         | 
| 169 | 
            +
            {
         | 
| 170 | 
            +
                static wchar_t strbuf[3] = {0, 0, 0};
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                cchar_t ic;
         | 
| 173 | 
            +
             | 
| 174 | 
            +
                PDC_LOG(("wunctrl() - called\n"));
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                ic = *wc & A_CHARTEXT;
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                if (ic >= 0x20 && ic != 0x7f)       /* normal characters */
         | 
| 179 | 
            +
                {
         | 
| 180 | 
            +
                    strbuf[0] = (wchar_t)ic;
         | 
| 181 | 
            +
                    strbuf[1] = L'\0';
         | 
| 182 | 
            +
                    return strbuf;
         | 
| 183 | 
            +
                }
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                strbuf[0] = '^';            /* '^' prefix */
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                if (ic == 0x7f)             /* 0x7f == DEL */
         | 
| 188 | 
            +
                    strbuf[1] = '?';
         | 
| 189 | 
            +
                else                    /* other control */
         | 
| 190 | 
            +
                    strbuf[1] = (wchar_t)(ic + '@');
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                return strbuf;
         | 
| 193 | 
            +
            }
         | 
| 194 | 
            +
             | 
| 195 | 
            +
            int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n)
         | 
| 196 | 
            +
            {
         | 
| 197 | 
            +
            # ifdef PDC_FORCE_UTF8
         | 
| 198 | 
            +
                wchar_t key;
         | 
| 199 | 
            +
                int i = -1;
         | 
| 200 | 
            +
                const unsigned char *string;
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                if (!s || (n < 1))
         | 
| 203 | 
            +
                    return -1;
         | 
| 204 | 
            +
             | 
| 205 | 
            +
                if (!*s)
         | 
| 206 | 
            +
                    return 0;
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                string = (const unsigned char *)s;
         | 
| 209 | 
            +
             | 
| 210 | 
            +
                key = string[0];
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                /* Simplistic UTF-8 decoder -- only does the BMP, minimal validation */
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                if (key & 0x80)
         | 
| 215 | 
            +
                {
         | 
| 216 | 
            +
                    if ((key & 0xe0) == 0xc0)
         | 
| 217 | 
            +
                    {
         | 
| 218 | 
            +
                        if (1 < n)
         | 
| 219 | 
            +
                        {
         | 
| 220 | 
            +
                            key = ((key & 0x1f) << 6) | (string[1] & 0x3f);
         | 
| 221 | 
            +
                            i = 2;
         | 
| 222 | 
            +
                        }
         | 
| 223 | 
            +
                    }
         | 
| 224 | 
            +
                    else if ((key & 0xe0) == 0xe0)
         | 
| 225 | 
            +
                    {
         | 
| 226 | 
            +
                        if (2 < n)
         | 
| 227 | 
            +
                        {
         | 
| 228 | 
            +
                            key = ((key & 0x0f) << 12) | ((string[1] & 0x3f) << 6) |
         | 
| 229 | 
            +
                                  (string[2] & 0x3f);
         | 
| 230 | 
            +
                            i = 3;
         | 
| 231 | 
            +
                        }
         | 
| 232 | 
            +
                    }
         | 
| 233 | 
            +
                }
         | 
| 234 | 
            +
                else
         | 
| 235 | 
            +
                    i = 1;
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                if (i)
         | 
| 238 | 
            +
                    *pwc = key;
         | 
| 239 | 
            +
             | 
| 240 | 
            +
                return i;
         | 
| 241 | 
            +
            # else
         | 
| 242 | 
            +
                return mbtowc(pwc, s, n);
         | 
| 243 | 
            +
            # endif
         | 
| 244 | 
            +
            }
         | 
| 245 | 
            +
             | 
| 246 | 
            +
            size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n)
         | 
| 247 | 
            +
            {
         | 
| 248 | 
            +
            # ifdef PDC_FORCE_UTF8
         | 
| 249 | 
            +
                size_t i = 0, len;
         | 
| 250 | 
            +
             | 
| 251 | 
            +
                if (!src || !dest)
         | 
| 252 | 
            +
                    return 0;
         | 
| 253 | 
            +
             | 
| 254 | 
            +
                len = strlen(src);
         | 
| 255 | 
            +
             | 
| 256 | 
            +
                while (*src && i < n)
         | 
| 257 | 
            +
                {
         | 
| 258 | 
            +
                    int retval = PDC_mbtowc(dest + i, src, len);
         | 
| 259 | 
            +
             | 
| 260 | 
            +
                    if (retval < 1)
         | 
| 261 | 
            +
                        return -1;
         | 
| 262 | 
            +
             | 
| 263 | 
            +
                    src += retval;
         | 
| 264 | 
            +
                    len -= retval;
         | 
| 265 | 
            +
                    i++;
         | 
| 266 | 
            +
                }
         | 
| 267 | 
            +
            # else
         | 
| 268 | 
            +
                size_t i = mbstowcs(dest, src, n);
         | 
| 269 | 
            +
            # endif
         | 
| 270 | 
            +
                dest[i] = 0;
         | 
| 271 | 
            +
                return i;
         | 
| 272 | 
            +
            }
         | 
| 273 | 
            +
             | 
| 274 | 
            +
            size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n)
         | 
| 275 | 
            +
            {
         | 
| 276 | 
            +
            # ifdef PDC_FORCE_UTF8
         | 
| 277 | 
            +
                size_t i = 0;
         | 
| 278 | 
            +
             | 
| 279 | 
            +
                if (!src || !dest)
         | 
| 280 | 
            +
                    return 0;
         | 
| 281 | 
            +
             | 
| 282 | 
            +
                while (*src && i < n)
         | 
| 283 | 
            +
                {
         | 
| 284 | 
            +
                    chtype code = *src++;
         | 
| 285 | 
            +
             | 
| 286 | 
            +
                    if (code < 0x80)
         | 
| 287 | 
            +
                    {
         | 
| 288 | 
            +
                        dest[i] = (char)code;
         | 
| 289 | 
            +
                        i++;
         | 
| 290 | 
            +
                    }
         | 
| 291 | 
            +
                    else
         | 
| 292 | 
            +
                        if (code < 0x800)
         | 
| 293 | 
            +
                        {
         | 
| 294 | 
            +
                            dest[i] = (char)((code & 0x07c0) >> 6) | 0xc0;
         | 
| 295 | 
            +
                            dest[i + 1] = (char)( (code & 0x003f) | 0x80);
         | 
| 296 | 
            +
                            i += 2;
         | 
| 297 | 
            +
                        }
         | 
| 298 | 
            +
                        else
         | 
| 299 | 
            +
                        {
         | 
| 300 | 
            +
                            dest[i] = (char)( ((code & 0xf000) >> 12) | 0xe0);
         | 
| 301 | 
            +
                            dest[i + 1] = (char)((code & 0x0fc0) >> 6) | 0x80;
         | 
| 302 | 
            +
                            dest[i + 2] = (char)( (code & 0x003f) | 0x80);
         | 
| 303 | 
            +
                            i += 3;
         | 
| 304 | 
            +
                        }
         | 
| 305 | 
            +
                }
         | 
| 306 | 
            +
            # else
         | 
| 307 | 
            +
                size_t i = wcstombs(dest, src, n);
         | 
| 308 | 
            +
            # endif
         | 
| 309 | 
            +
                dest[i] = '\0';
         | 
| 310 | 
            +
                return i;
         | 
| 311 | 
            +
            }
         | 
| 312 | 
            +
            #endif
         | 
| @@ -0,0 +1,569 @@ | |
| 1 | 
            +
            /* Public Domain Curses */
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            #include <curspriv.h>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            /*man-start**************************************************************
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            window
         | 
| 8 | 
            +
            ------
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ### Synopsis
         | 
| 11 | 
            +
             | 
| 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 | 
            +
             | 
| 34 | 
            +
               newwin() creates a new window with the given number of lines,
         | 
| 35 | 
            +
               nlines and columns, ncols. The upper left corner of the window
         | 
| 36 | 
            +
               is at line begy, column begx. If nlines is zero, it defaults to
         | 
| 37 | 
            +
               LINES - begy; ncols to COLS - begx. Create a new full-screen
         | 
| 38 | 
            +
               window by calling newwin(0, 0, 0, 0).
         | 
| 39 | 
            +
             | 
| 40 | 
            +
               delwin() deletes the named window, freeing all associated
         | 
| 41 | 
            +
               memory. In the case of overlapping windows, subwindows should be
         | 
| 42 | 
            +
               deleted before the main window.
         | 
| 43 | 
            +
             | 
| 44 | 
            +
               mvwin() moves the window so that the upper left-hand corner is
         | 
| 45 | 
            +
               at position (y,x). If the move would cause the window to be off
         | 
| 46 | 
            +
               the screen, it is an error and the window is not moved. Moving
         | 
| 47 | 
            +
               subwindows is allowed.
         | 
| 48 | 
            +
             | 
| 49 | 
            +
               subwin() creates a new subwindow within a window.  The
         | 
| 50 | 
            +
               dimensions of the subwindow are nlines lines and ncols columns.
         | 
| 51 | 
            +
               The subwindow is at position (begy, begx) on the screen.  This
         | 
| 52 | 
            +
               position is relative to the screen, and not to the window orig.
         | 
| 53 | 
            +
               Changes made to either window will affect both.  When using this
         | 
| 54 | 
            +
               routine, you will often need to call touchwin() before calling
         | 
| 55 | 
            +
               wrefresh().
         | 
| 56 | 
            +
             | 
| 57 | 
            +
               derwin() is the same as subwin(), except that begy and begx are
         | 
| 58 | 
            +
               relative to the origin of the window orig rather than the
         | 
| 59 | 
            +
               screen.  There is no difference between subwindows and derived
         | 
| 60 | 
            +
               windows.
         | 
| 61 | 
            +
             | 
| 62 | 
            +
               mvderwin() moves a derived window (or subwindow) inside its
         | 
| 63 | 
            +
               parent window.  The screen-relative parameters of the window are
         | 
| 64 | 
            +
               not changed.  This routine is used to display different parts of
         | 
| 65 | 
            +
               the parent window at the same physical position on the screen.
         | 
| 66 | 
            +
             | 
| 67 | 
            +
               dupwin() creates an exact duplicate of the window win.
         | 
| 68 | 
            +
             | 
| 69 | 
            +
               wsyncup() causes a touchwin() of all of the window's parents.
         | 
| 70 | 
            +
             | 
| 71 | 
            +
               If wsyncok() is called with a second argument of TRUE, this
         | 
| 72 | 
            +
               causes a wsyncup() to be called every time the window is
         | 
| 73 | 
            +
               changed.
         | 
| 74 | 
            +
             | 
| 75 | 
            +
               wcursyncup() causes the current cursor position of all of a
         | 
| 76 | 
            +
               window's ancestors to reflect the current cursor position of the
         | 
| 77 | 
            +
               current window.
         | 
| 78 | 
            +
             | 
| 79 | 
            +
               wsyncdown() causes a touchwin() of the current window if any of
         | 
| 80 | 
            +
               its parent's windows have been touched.
         | 
| 81 | 
            +
             | 
| 82 | 
            +
               resize_window() allows the user to resize an existing window. It
         | 
| 83 | 
            +
               returns the pointer to the new window, or NULL on failure.
         | 
| 84 | 
            +
             | 
| 85 | 
            +
               wresize() is an ncurses-compatible wrapper for resize_window().
         | 
| 86 | 
            +
               Note that, unlike ncurses, it will NOT process any subwindows of
         | 
| 87 | 
            +
               the window. (However, you still can call it _on_ subwindows.) It
         | 
| 88 | 
            +
               returns OK or ERR.
         | 
| 89 | 
            +
             | 
| 90 | 
            +
               PDC_makenew() allocates all data for a new WINDOW * except the
         | 
| 91 | 
            +
               actual lines themselves. If it's unable to allocate memory for
         | 
| 92 | 
            +
               the window structure, it will free all allocated memory and
         | 
| 93 | 
            +
               return a NULL pointer.
         | 
| 94 | 
            +
             | 
| 95 | 
            +
               PDC_makelines() allocates the memory for the lines.
         | 
| 96 | 
            +
             | 
| 97 | 
            +
               PDC_sync() handles wrefresh() and wsyncup() calls when a window
         | 
| 98 | 
            +
               is changed.
         | 
| 99 | 
            +
             | 
| 100 | 
            +
            ### Return Value
         | 
| 101 | 
            +
             | 
| 102 | 
            +
               newwin(), subwin(), derwin() and dupwin() return a pointer
         | 
| 103 | 
            +
               to the new window, or NULL on failure. delwin(), mvwin(),
         | 
| 104 | 
            +
               mvderwin() and syncok() return OK or ERR. wsyncup(),
         | 
| 105 | 
            +
               wcursyncup() and wsyncdown() return nothing.
         | 
| 106 | 
            +
             | 
| 107 | 
            +
            ### Errors
         | 
| 108 | 
            +
             | 
| 109 | 
            +
               It is an error to call resize_window() before calling initscr().
         | 
| 110 | 
            +
               Also, an error will be generated if we fail to create a newly
         | 
| 111 | 
            +
               sized replacement window for curscr, or stdscr. This could
         | 
| 112 | 
            +
               happen when increasing the window size. NOTE: If this happens,
         | 
| 113 | 
            +
               the previously successfully allocated windows are left alone;
         | 
| 114 | 
            +
               i.e., the resize is NOT cancelled for those windows.
         | 
| 115 | 
            +
             | 
| 116 | 
            +
            ### Portability
         | 
| 117 | 
            +
                                         X/Open    BSD    SYS V
         | 
| 118 | 
            +
                newwin                      Y       Y       Y
         | 
| 119 | 
            +
                delwin                      Y       Y       Y
         | 
| 120 | 
            +
                mvwin                       Y       Y       Y
         | 
| 121 | 
            +
                subwin                      Y       Y       Y
         | 
| 122 | 
            +
                derwin                      Y       -       Y
         | 
| 123 | 
            +
                mvderwin                    Y       -       Y
         | 
| 124 | 
            +
                dupwin                      Y       -      4.0
         | 
| 125 | 
            +
                wsyncup                     Y       -      4.0
         | 
| 126 | 
            +
                syncok                      Y       -      4.0
         | 
| 127 | 
            +
                wcursyncup                  Y       -      4.0
         | 
| 128 | 
            +
                wsyncdown                   Y       -      4.0
         | 
| 129 | 
            +
                resize_window               -       -       -
         | 
| 130 | 
            +
                wresize                     -       -       -
         | 
| 131 | 
            +
                PDC_makelines               -       -       -
         | 
| 132 | 
            +
                PDC_makenew                 -       -       -
         | 
| 133 | 
            +
                PDC_sync                    -       -       -
         | 
| 134 | 
            +
             | 
| 135 | 
            +
            **man-end****************************************************************/
         | 
| 136 | 
            +
             | 
| 137 | 
            +
            #include <stdlib.h>
         | 
| 138 | 
            +
             | 
| 139 | 
            +
            WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx)
         | 
| 140 | 
            +
            {
         | 
| 141 | 
            +
                WINDOW *win;
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                PDC_LOG(("PDC_makenew() - called: lines %d cols %d begy %d begx %d\n",
         | 
| 144 | 
            +
                         nlines, ncols, begy, begx));
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                /* allocate the window structure itself */
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                if ((win = calloc(1, sizeof(WINDOW))) == (WINDOW *)NULL)
         | 
| 149 | 
            +
                    return win;
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                /* allocate the line pointer array */
         | 
| 152 | 
            +
             | 
| 153 | 
            +
                if ((win->_y = malloc(nlines * sizeof(chtype *))) == NULL)
         | 
| 154 | 
            +
                {
         | 
| 155 | 
            +
                    free(win);
         | 
| 156 | 
            +
                    return (WINDOW *)NULL;
         | 
| 157 | 
            +
                }
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                /* allocate the minchng and maxchng arrays */
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                if ((win->_firstch = malloc(nlines * sizeof(int))) == NULL)
         | 
| 162 | 
            +
                {
         | 
| 163 | 
            +
                    free(win->_y);
         | 
| 164 | 
            +
                    free(win);
         | 
| 165 | 
            +
                    return (WINDOW *)NULL;
         | 
| 166 | 
            +
                }
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                if ((win->_lastch = malloc(nlines * sizeof(int))) == NULL)
         | 
| 169 | 
            +
                {
         | 
| 170 | 
            +
                    free(win->_firstch);
         | 
| 171 | 
            +
                    free(win->_y);
         | 
| 172 | 
            +
                    free(win);
         | 
| 173 | 
            +
                    return (WINDOW *)NULL;
         | 
| 174 | 
            +
                }
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                /* initialize window variables */
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                win->_maxy = nlines;  /* real max screen size */
         | 
| 179 | 
            +
                win->_maxx = ncols;   /* real max screen size */
         | 
| 180 | 
            +
                win->_begy = begy;
         | 
| 181 | 
            +
                win->_begx = begx;
         | 
| 182 | 
            +
                win->_bkgd = ' ';     /* wrs 4/10/93 -- initialize background to blank */
         | 
| 183 | 
            +
                win->_clear = (bool) ((nlines == LINES) && (ncols == COLS));
         | 
| 184 | 
            +
                win->_bmarg = nlines - 1;
         | 
| 185 | 
            +
                win->_parx = win->_pary = -1;
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                /* init to say window all changed */
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                touchwin(win);
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                return win;
         | 
| 192 | 
            +
            }
         | 
| 193 | 
            +
             | 
| 194 | 
            +
            WINDOW *PDC_makelines(WINDOW *win)
         | 
| 195 | 
            +
            {
         | 
| 196 | 
            +
                int i, j, nlines, ncols;
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                PDC_LOG(("PDC_makelines() - called\n"));
         | 
| 199 | 
            +
             | 
| 200 | 
            +
                if (!win)
         | 
| 201 | 
            +
                    return (WINDOW *)NULL;
         | 
| 202 | 
            +
             | 
| 203 | 
            +
                nlines = win->_maxy;
         | 
| 204 | 
            +
                ncols = win->_maxx;
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                for (i = 0; i < nlines; i++)
         | 
| 207 | 
            +
                {
         | 
| 208 | 
            +
                    if ((win->_y[i] = malloc(ncols * sizeof(chtype))) == NULL)
         | 
| 209 | 
            +
                    {
         | 
| 210 | 
            +
                        /* if error, free all the data */
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                        for (j = 0; j < i; j++)
         | 
| 213 | 
            +
                            free(win->_y[j]);
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                        free(win->_firstch);
         | 
| 216 | 
            +
                        free(win->_lastch);
         | 
| 217 | 
            +
                        free(win->_y);
         | 
| 218 | 
            +
                        free(win);
         | 
| 219 | 
            +
             | 
| 220 | 
            +
                        return (WINDOW *)NULL;
         | 
| 221 | 
            +
                    }
         | 
| 222 | 
            +
                }
         | 
| 223 | 
            +
             | 
| 224 | 
            +
                return win;
         | 
| 225 | 
            +
            }
         | 
| 226 | 
            +
             | 
| 227 | 
            +
            void PDC_sync(WINDOW *win)
         | 
| 228 | 
            +
            {
         | 
| 229 | 
            +
                PDC_LOG(("PDC_sync() - called:\n"));
         | 
| 230 | 
            +
             | 
| 231 | 
            +
                if (win->_immed)
         | 
| 232 | 
            +
                    wrefresh(win);
         | 
| 233 | 
            +
                if (win->_sync)
         | 
| 234 | 
            +
                    wsyncup(win);
         | 
| 235 | 
            +
            }
         | 
| 236 | 
            +
             | 
| 237 | 
            +
            WINDOW *newwin(int nlines, int ncols, int begy, int begx)
         | 
| 238 | 
            +
            {
         | 
| 239 | 
            +
                WINDOW *win;
         | 
| 240 | 
            +
             | 
| 241 | 
            +
                PDC_LOG(("newwin() - called:lines=%d cols=%d begy=%d begx=%d\n",
         | 
| 242 | 
            +
                         nlines, ncols, begy, begx));
         | 
| 243 | 
            +
             | 
| 244 | 
            +
                if (!nlines)
         | 
| 245 | 
            +
                    nlines = LINES - begy;
         | 
| 246 | 
            +
                if (!ncols)
         | 
| 247 | 
            +
                    ncols  = COLS  - begx;
         | 
| 248 | 
            +
             | 
| 249 | 
            +
                if ( (begy + nlines > SP->lines || begx + ncols > SP->cols)
         | 
| 250 | 
            +
                    || !(win = PDC_makenew(nlines, ncols, begy, begx))
         | 
| 251 | 
            +
                    || !(win = PDC_makelines(win)) )
         | 
| 252 | 
            +
                    return (WINDOW *)NULL;
         | 
| 253 | 
            +
             | 
| 254 | 
            +
                werase(win);
         | 
| 255 | 
            +
             | 
| 256 | 
            +
                return win;
         | 
| 257 | 
            +
            }
         | 
| 258 | 
            +
             | 
| 259 | 
            +
            int delwin(WINDOW *win)
         | 
| 260 | 
            +
            {
         | 
| 261 | 
            +
                int i;
         | 
| 262 | 
            +
             | 
| 263 | 
            +
                PDC_LOG(("delwin() - called\n"));
         | 
| 264 | 
            +
             | 
| 265 | 
            +
                if (!win)
         | 
| 266 | 
            +
                    return ERR;
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                /* subwindows use parents' lines */
         | 
| 269 | 
            +
             | 
| 270 | 
            +
                if (!(win->_flags & (_SUBWIN|_SUBPAD)))
         | 
| 271 | 
            +
                    for (i = 0; i < win->_maxy && win->_y[i]; i++)
         | 
| 272 | 
            +
                        if (win->_y[i])
         | 
| 273 | 
            +
                            free(win->_y[i]);
         | 
| 274 | 
            +
             | 
| 275 | 
            +
                free(win->_firstch);
         | 
| 276 | 
            +
                free(win->_lastch);
         | 
| 277 | 
            +
                free(win->_y);
         | 
| 278 | 
            +
                free(win);
         | 
| 279 | 
            +
             | 
| 280 | 
            +
                return OK;
         | 
| 281 | 
            +
            }
         | 
| 282 | 
            +
             | 
| 283 | 
            +
            int mvwin(WINDOW *win, int y, int x)
         | 
| 284 | 
            +
            {
         | 
| 285 | 
            +
                PDC_LOG(("mvwin() - called\n"));
         | 
| 286 | 
            +
             | 
| 287 | 
            +
                if (!win || (y + win->_maxy > LINES || y < 0)
         | 
| 288 | 
            +
                         || (x + win->_maxx > COLS || x < 0))
         | 
| 289 | 
            +
                    return ERR;
         | 
| 290 | 
            +
             | 
| 291 | 
            +
                win->_begy = y;
         | 
| 292 | 
            +
                win->_begx = x;
         | 
| 293 | 
            +
                touchwin(win);
         | 
| 294 | 
            +
             | 
| 295 | 
            +
                return OK;
         | 
| 296 | 
            +
            }
         | 
| 297 | 
            +
             | 
| 298 | 
            +
            WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
         | 
| 299 | 
            +
            {
         | 
| 300 | 
            +
                WINDOW *win;
         | 
| 301 | 
            +
                int i;
         | 
| 302 | 
            +
                int j = begy - orig->_begy;
         | 
| 303 | 
            +
                int k = begx - orig->_begx;
         | 
| 304 | 
            +
             | 
| 305 | 
            +
                PDC_LOG(("subwin() - called: lines %d cols %d begy %d begx %d\n",
         | 
| 306 | 
            +
                         nlines, ncols, begy, begx));
         | 
| 307 | 
            +
             | 
| 308 | 
            +
                /* make sure window fits inside the original one */
         | 
| 309 | 
            +
             | 
| 310 | 
            +
                if (!orig || (begy < orig->_begy) || (begx < orig->_begx) ||
         | 
| 311 | 
            +
                    (begy + nlines) > (orig->_begy + orig->_maxy) ||
         | 
| 312 | 
            +
                    (begx + ncols) > (orig->_begx + orig->_maxx))
         | 
| 313 | 
            +
                    return (WINDOW *)NULL;
         | 
| 314 | 
            +
             | 
| 315 | 
            +
                if (!nlines)
         | 
| 316 | 
            +
                    nlines = orig->_maxy - 1 - j;
         | 
| 317 | 
            +
                if (!ncols)
         | 
| 318 | 
            +
                    ncols  = orig->_maxx - 1 - k;
         | 
| 319 | 
            +
             | 
| 320 | 
            +
                if ( !(win = PDC_makenew(nlines, ncols, begy, begx)) )
         | 
| 321 | 
            +
                    return (WINDOW *)NULL;
         | 
| 322 | 
            +
             | 
| 323 | 
            +
                /* initialize window variables */
         | 
| 324 | 
            +
             | 
| 325 | 
            +
                win->_attrs = orig->_attrs;
         | 
| 326 | 
            +
                win->_bkgd = orig->_bkgd;
         | 
| 327 | 
            +
                win->_leaveit = orig->_leaveit;
         | 
| 328 | 
            +
                win->_scroll = orig->_scroll;
         | 
| 329 | 
            +
                win->_nodelay = orig->_nodelay;
         | 
| 330 | 
            +
                win->_delayms = orig->_delayms;
         | 
| 331 | 
            +
                win->_use_keypad = orig->_use_keypad;
         | 
| 332 | 
            +
                win->_immed = orig->_immed;
         | 
| 333 | 
            +
                win->_sync = orig->_sync;
         | 
| 334 | 
            +
                win->_pary = j;
         | 
| 335 | 
            +
                win->_parx = k;
         | 
| 336 | 
            +
                win->_parent = orig;
         | 
| 337 | 
            +
             | 
| 338 | 
            +
                for (i = 0; i < nlines; i++, j++)
         | 
| 339 | 
            +
                    win->_y[i] = orig->_y[j] + k;
         | 
| 340 | 
            +
             | 
| 341 | 
            +
                win->_flags |= _SUBWIN;
         | 
| 342 | 
            +
             | 
| 343 | 
            +
                return win;
         | 
| 344 | 
            +
            }
         | 
| 345 | 
            +
             | 
| 346 | 
            +
            WINDOW *derwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
         | 
| 347 | 
            +
            {
         | 
| 348 | 
            +
                return subwin(orig, nlines, ncols, begy + orig->_begy, begx + orig->_begx);
         | 
| 349 | 
            +
            }
         | 
| 350 | 
            +
             | 
| 351 | 
            +
            int mvderwin(WINDOW *win, int pary, int parx)
         | 
| 352 | 
            +
            {
         | 
| 353 | 
            +
                int i, j;
         | 
| 354 | 
            +
                WINDOW *mypar;
         | 
| 355 | 
            +
             | 
| 356 | 
            +
                if (!win || !(win->_parent))
         | 
| 357 | 
            +
                    return ERR;
         | 
| 358 | 
            +
             | 
| 359 | 
            +
                mypar = win->_parent;
         | 
| 360 | 
            +
             | 
| 361 | 
            +
                if (pary < 0 || parx < 0 || (pary + win->_maxy) > mypar->_maxy ||
         | 
| 362 | 
            +
                                            (parx + win->_maxx) > mypar->_maxx)
         | 
| 363 | 
            +
                    return ERR;
         | 
| 364 | 
            +
             | 
| 365 | 
            +
                j = pary;
         | 
| 366 | 
            +
             | 
| 367 | 
            +
                for (i = 0; i < win->_maxy; i++)
         | 
| 368 | 
            +
                    win->_y[i] = (mypar->_y[j++]) + parx;
         | 
| 369 | 
            +
             | 
| 370 | 
            +
                win->_pary = pary;
         | 
| 371 | 
            +
                win->_parx = parx;
         | 
| 372 | 
            +
             | 
| 373 | 
            +
                return OK;
         | 
| 374 | 
            +
            }
         | 
| 375 | 
            +
             | 
| 376 | 
            +
            WINDOW *dupwin(WINDOW *win)
         | 
| 377 | 
            +
            {
         | 
| 378 | 
            +
                WINDOW *new;
         | 
| 379 | 
            +
                chtype *ptr, *ptr1;
         | 
| 380 | 
            +
                int nlines, ncols, begy, begx, i;
         | 
| 381 | 
            +
             | 
| 382 | 
            +
                if (!win)
         | 
| 383 | 
            +
                    return (WINDOW *)NULL;
         | 
| 384 | 
            +
             | 
| 385 | 
            +
                nlines = win->_maxy;
         | 
| 386 | 
            +
                ncols = win->_maxx;
         | 
| 387 | 
            +
                begy = win->_begy;
         | 
| 388 | 
            +
                begx = win->_begx;
         | 
| 389 | 
            +
             | 
| 390 | 
            +
                if ( !(new = PDC_makenew(nlines, ncols, begy, begx))
         | 
| 391 | 
            +
                    || !(new = PDC_makelines(new)) )
         | 
| 392 | 
            +
                    return (WINDOW *)NULL;
         | 
| 393 | 
            +
             | 
| 394 | 
            +
                /* copy the contents of win into new */
         | 
| 395 | 
            +
             | 
| 396 | 
            +
                for (i = 0; i < nlines; i++)
         | 
| 397 | 
            +
                {
         | 
| 398 | 
            +
                    for (ptr = new->_y[i], ptr1 = win->_y[i];
         | 
| 399 | 
            +
                         ptr < new->_y[i] + ncols; ptr++, ptr1++)
         | 
| 400 | 
            +
                        *ptr = *ptr1;
         | 
| 401 | 
            +
             | 
| 402 | 
            +
                    new->_firstch[i] = 0;
         | 
| 403 | 
            +
                    new->_lastch[i] = ncols - 1;
         | 
| 404 | 
            +
                }
         | 
| 405 | 
            +
             | 
| 406 | 
            +
                new->_curx = win->_curx;
         | 
| 407 | 
            +
                new->_cury = win->_cury;
         | 
| 408 | 
            +
                new->_maxy = win->_maxy;
         | 
| 409 | 
            +
                new->_maxx = win->_maxx;
         | 
| 410 | 
            +
                new->_begy = win->_begy;
         | 
| 411 | 
            +
                new->_begx = win->_begx;
         | 
| 412 | 
            +
                new->_flags = win->_flags;
         | 
| 413 | 
            +
                new->_attrs = win->_attrs;
         | 
| 414 | 
            +
                new->_clear = win->_clear;
         | 
| 415 | 
            +
                new->_leaveit = win->_leaveit;
         | 
| 416 | 
            +
                new->_scroll = win->_scroll;
         | 
| 417 | 
            +
                new->_nodelay = win->_nodelay;
         | 
| 418 | 
            +
                new->_delayms = win->_delayms;
         | 
| 419 | 
            +
                new->_use_keypad = win->_use_keypad;
         | 
| 420 | 
            +
                new->_tmarg = win->_tmarg;
         | 
| 421 | 
            +
                new->_bmarg = win->_bmarg;
         | 
| 422 | 
            +
                new->_parx = win->_parx;
         | 
| 423 | 
            +
                new->_pary = win->_pary;
         | 
| 424 | 
            +
                new->_parent = win->_parent;
         | 
| 425 | 
            +
                new->_bkgd = win->_bkgd;
         | 
| 426 | 
            +
                new->_flags = win->_flags;
         | 
| 427 | 
            +
             | 
| 428 | 
            +
                return new;
         | 
| 429 | 
            +
            }
         | 
| 430 | 
            +
             | 
| 431 | 
            +
            WINDOW *resize_window(WINDOW *win, int nlines, int ncols)
         | 
| 432 | 
            +
            {
         | 
| 433 | 
            +
                WINDOW *new;
         | 
| 434 | 
            +
                int i, save_cury, save_curx, new_begy, new_begx;
         | 
| 435 | 
            +
             | 
| 436 | 
            +
                PDC_LOG(("resize_window() - called: nlines %d ncols %d\n",
         | 
| 437 | 
            +
                         nlines, ncols));
         | 
| 438 | 
            +
             | 
| 439 | 
            +
                if (!win)
         | 
| 440 | 
            +
                    return (WINDOW *)NULL;
         | 
| 441 | 
            +
             | 
| 442 | 
            +
                if (win->_flags & _SUBPAD)
         | 
| 443 | 
            +
                {
         | 
| 444 | 
            +
                    if ( !(new = subpad(win->_parent, nlines, ncols,
         | 
| 445 | 
            +
                                        win->_begy, win->_begx)) )
         | 
| 446 | 
            +
                        return (WINDOW *)NULL;
         | 
| 447 | 
            +
                }
         | 
| 448 | 
            +
                else if (win->_flags & _SUBWIN)
         | 
| 449 | 
            +
                {
         | 
| 450 | 
            +
                    if ( !(new = subwin(win->_parent, nlines, ncols,
         | 
| 451 | 
            +
                                        win->_begy, win->_begx)) )
         | 
| 452 | 
            +
                        return (WINDOW *)NULL;
         | 
| 453 | 
            +
                }
         | 
| 454 | 
            +
                else
         | 
| 455 | 
            +
                {
         | 
| 456 | 
            +
                    if (win == SP->slk_winptr)
         | 
| 457 | 
            +
                    {
         | 
| 458 | 
            +
                        new_begy = SP->lines - SP->slklines;
         | 
| 459 | 
            +
                        new_begx = 0;
         | 
| 460 | 
            +
                    }
         | 
| 461 | 
            +
                    else
         | 
| 462 | 
            +
                    {
         | 
| 463 | 
            +
                        new_begy = win->_begy;
         | 
| 464 | 
            +
                        new_begx = win->_begx;
         | 
| 465 | 
            +
                    }
         | 
| 466 | 
            +
             | 
| 467 | 
            +
                    if ( !(new = PDC_makenew(nlines, ncols, new_begy, new_begx)) )
         | 
| 468 | 
            +
                        return (WINDOW *)NULL;
         | 
| 469 | 
            +
                }
         | 
| 470 | 
            +
             | 
| 471 | 
            +
                save_curx = min(win->_curx, (new->_maxx - 1));
         | 
| 472 | 
            +
                save_cury = min(win->_cury, (new->_maxy - 1));
         | 
| 473 | 
            +
             | 
| 474 | 
            +
                if (!(win->_flags & (_SUBPAD|_SUBWIN)))
         | 
| 475 | 
            +
                {
         | 
| 476 | 
            +
                    if ( !(new = PDC_makelines(new)) )
         | 
| 477 | 
            +
                        return (WINDOW *)NULL;
         | 
| 478 | 
            +
             | 
| 479 | 
            +
                    werase(new);
         | 
| 480 | 
            +
             | 
| 481 | 
            +
                    copywin(win, new, 0, 0, 0, 0, min(win->_maxy, new->_maxy) - 1,
         | 
| 482 | 
            +
                            min(win->_maxx, new->_maxx) - 1, FALSE);
         | 
| 483 | 
            +
             | 
| 484 | 
            +
                    for (i = 0; i < win->_maxy && win->_y[i]; i++)
         | 
| 485 | 
            +
                        if (win->_y[i])
         | 
| 486 | 
            +
                            free(win->_y[i]);
         | 
| 487 | 
            +
                }
         | 
| 488 | 
            +
             | 
| 489 | 
            +
                new->_flags = win->_flags;
         | 
| 490 | 
            +
                new->_attrs = win->_attrs;
         | 
| 491 | 
            +
                new->_clear = win->_clear;
         | 
| 492 | 
            +
                new->_leaveit = win->_leaveit;
         | 
| 493 | 
            +
                new->_scroll = win->_scroll;
         | 
| 494 | 
            +
                new->_nodelay = win->_nodelay;
         | 
| 495 | 
            +
                new->_delayms = win->_delayms;
         | 
| 496 | 
            +
                new->_use_keypad = win->_use_keypad;
         | 
| 497 | 
            +
                new->_tmarg = (win->_tmarg > new->_maxy - 1) ? 0 : win->_tmarg;
         | 
| 498 | 
            +
                new->_bmarg = (win->_bmarg == win->_maxy - 1) ?
         | 
| 499 | 
            +
                              new->_maxy - 1 : min(win->_bmarg, (new->_maxy - 1));
         | 
| 500 | 
            +
                new->_parent = win->_parent;
         | 
| 501 | 
            +
                new->_immed = win->_immed;
         | 
| 502 | 
            +
                new->_sync = win->_sync;
         | 
| 503 | 
            +
                new->_bkgd = win->_bkgd;
         | 
| 504 | 
            +
             | 
| 505 | 
            +
                new->_curx = save_curx;
         | 
| 506 | 
            +
                new->_cury = save_cury;
         | 
| 507 | 
            +
             | 
| 508 | 
            +
                free(win->_firstch);
         | 
| 509 | 
            +
                free(win->_lastch);
         | 
| 510 | 
            +
                free(win->_y);
         | 
| 511 | 
            +
             | 
| 512 | 
            +
                *win = *new;
         | 
| 513 | 
            +
                free(new);
         | 
| 514 | 
            +
             | 
| 515 | 
            +
                return win;
         | 
| 516 | 
            +
            }
         | 
| 517 | 
            +
             | 
| 518 | 
            +
            int wresize(WINDOW *win, int nlines, int ncols)
         | 
| 519 | 
            +
            {
         | 
| 520 | 
            +
                return (resize_window(win, nlines, ncols) ? OK : ERR);
         | 
| 521 | 
            +
            }
         | 
| 522 | 
            +
             | 
| 523 | 
            +
            void wsyncup(WINDOW *win)
         | 
| 524 | 
            +
            {
         | 
| 525 | 
            +
                WINDOW *tmp;
         | 
| 526 | 
            +
             | 
| 527 | 
            +
                PDC_LOG(("wsyncup() - called\n"));
         | 
| 528 | 
            +
             | 
| 529 | 
            +
                for (tmp = win; tmp; tmp = tmp->_parent)
         | 
| 530 | 
            +
                    touchwin(tmp);
         | 
| 531 | 
            +
            }
         | 
| 532 | 
            +
             | 
| 533 | 
            +
            int syncok(WINDOW *win, bool bf)
         | 
| 534 | 
            +
            {
         | 
| 535 | 
            +
                PDC_LOG(("syncok() - called\n"));
         | 
| 536 | 
            +
             | 
| 537 | 
            +
                if (!win)
         | 
| 538 | 
            +
                    return ERR;
         | 
| 539 | 
            +
             | 
| 540 | 
            +
                win->_sync = bf;
         | 
| 541 | 
            +
             | 
| 542 | 
            +
                return OK;
         | 
| 543 | 
            +
            }
         | 
| 544 | 
            +
             | 
| 545 | 
            +
            void wcursyncup(WINDOW *win)
         | 
| 546 | 
            +
            {
         | 
| 547 | 
            +
                WINDOW *tmp;
         | 
| 548 | 
            +
             | 
| 549 | 
            +
                PDC_LOG(("wcursyncup() - called\n"));
         | 
| 550 | 
            +
             | 
| 551 | 
            +
                for (tmp = win; tmp && tmp->_parent; tmp = tmp->_parent)
         | 
| 552 | 
            +
                    wmove(tmp->_parent, tmp->_pary + tmp->_cury, tmp->_parx + tmp->_curx);
         | 
| 553 | 
            +
            }
         | 
| 554 | 
            +
             | 
| 555 | 
            +
            void wsyncdown(WINDOW *win)
         | 
| 556 | 
            +
            {
         | 
| 557 | 
            +
                WINDOW *tmp;
         | 
| 558 | 
            +
             | 
| 559 | 
            +
                PDC_LOG(("wsyncdown() - called\n"));
         | 
| 560 | 
            +
             | 
| 561 | 
            +
                for (tmp = win; tmp; tmp = tmp->_parent)
         | 
| 562 | 
            +
                {
         | 
| 563 | 
            +
                    if (is_wintouched(tmp))
         | 
| 564 | 
            +
                    {
         | 
| 565 | 
            +
                        touchwin(win);
         | 
| 566 | 
            +
                        break;
         | 
| 567 | 
            +
                    }
         | 
| 568 | 
            +
                }
         | 
| 569 | 
            +
            }
         |