curses 1.2.6 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +19 -0
- data/.github/workflows/ubuntu.yml +26 -0
- data/.github/workflows/windows.yml +28 -0
- data/.gitmodules +1 -1
- data/.travis.yml +6 -3
- data/History.md +40 -0
- data/README.md +4 -1
- data/Rakefile +0 -83
- data/curses.gemspec +2 -3
- data/ext/curses/curses.c +1271 -151
- data/ext/curses/extconf.rb +140 -17
- data/lib/curses.rb +5 -12
- data/sample/form.rb +52 -0
- data/sample/menu.rb +1 -1
- data/vendor/PDCurses/.gitignore +47 -0
- data/vendor/PDCurses/.travis.yml +49 -0
- data/vendor/PDCurses/CMakeLists.txt +68 -0
- data/vendor/PDCurses/HISTORY.md +2036 -0
- data/vendor/PDCurses/IMPLEMNT.md +327 -0
- data/vendor/PDCurses/README.md +77 -0
- data/vendor/PDCurses/acs_defs.h +265 -0
- data/vendor/PDCurses/appveyor.yml +218 -0
- data/vendor/PDCurses/cmake/README.md +71 -0
- data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
- data/vendor/PDCurses/cmake/build_options.cmake +25 -0
- data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
- data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
- data/vendor/PDCurses/cmake/get_version.cmake +17 -0
- data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
- data/vendor/PDCurses/cmake/project_common.cmake +121 -0
- data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
- data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
- data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
- data/vendor/PDCurses/cmake/version.in.cmake +73 -0
- data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
- data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
- data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
- data/vendor/PDCurses/curses.h +1846 -0
- data/vendor/PDCurses/curspriv.h +134 -0
- data/vendor/PDCurses/demos/README.md +25 -0
- data/vendor/PDCurses/demos/firework.c +144 -0
- data/vendor/PDCurses/demos/newtest.c +581 -0
- data/vendor/PDCurses/demos/ozdemo.c +447 -0
- data/vendor/PDCurses/demos/ptest.c +283 -0
- data/vendor/PDCurses/demos/rain.c +157 -0
- data/vendor/PDCurses/demos/testcurs.c +1607 -0
- data/vendor/PDCurses/demos/tui.c +1048 -0
- data/vendor/PDCurses/demos/tui.h +65 -0
- data/vendor/PDCurses/demos/tuidemo.c +233 -0
- data/vendor/PDCurses/demos/version.c +61 -0
- data/vendor/PDCurses/demos/worm.c +432 -0
- data/vendor/PDCurses/demos/xmas.c +955 -0
- data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
- data/vendor/PDCurses/dos/Makefile.bcc +83 -0
- data/vendor/PDCurses/dos/Makefile.dmc +257 -0
- data/vendor/PDCurses/dos/Makefile.msc +113 -0
- data/vendor/PDCurses/dos/Makefile.wcc +107 -0
- data/vendor/PDCurses/dos/README.md +51 -0
- data/vendor/PDCurses/dos/bccdos.lrf +9 -0
- data/vendor/PDCurses/dos/mscdos.lrf +50 -0
- data/vendor/PDCurses/dos/pdcclip.c +132 -0
- data/vendor/PDCurses/dos/pdcdisp.c +135 -0
- data/vendor/PDCurses/dos/pdcdos.h +194 -0
- data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
- data/vendor/PDCurses/dos/pdckbd.c +513 -0
- data/vendor/PDCurses/dos/pdcscrn.c +785 -0
- data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
- data/vendor/PDCurses/dos/pdcutil.c +212 -0
- data/vendor/PDCurses/libobjs.mif +26 -0
- data/vendor/PDCurses/makedist.mif +20 -0
- data/vendor/PDCurses/man/README.md +21 -0
- data/vendor/PDCurses/man/intro.md +361 -0
- data/vendor/PDCurses/man/manext.c +119 -0
- data/vendor/PDCurses/man/sdl.md +152 -0
- data/vendor/PDCurses/man/sdl2.md +58 -0
- data/vendor/PDCurses/man/x11.md +407 -0
- data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
- data/vendor/PDCurses/ncurses/README.md +26 -0
- data/vendor/PDCurses/ncurses/makefile +29 -0
- data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
- data/vendor/PDCurses/os2/Makefile.bcc +90 -0
- data/vendor/PDCurses/os2/Makefile.wcc +43 -0
- data/vendor/PDCurses/os2/README.md +43 -0
- data/vendor/PDCurses/os2/iccos2.lrf +50 -0
- data/vendor/PDCurses/os2/iccos2.mak +256 -0
- data/vendor/PDCurses/os2/pdcclip.c +188 -0
- data/vendor/PDCurses/os2/pdcdisp.c +93 -0
- data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
- data/vendor/PDCurses/os2/pdckbd.c +521 -0
- data/vendor/PDCurses/os2/pdcos2.h +55 -0
- data/vendor/PDCurses/os2/pdcscrn.c +449 -0
- data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
- data/vendor/PDCurses/os2/pdcutil.c +52 -0
- data/vendor/PDCurses/panel.h +56 -0
- data/vendor/PDCurses/pdcurses/README.md +25 -0
- data/vendor/PDCurses/pdcurses/addch.c +693 -0
- data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
- data/vendor/PDCurses/pdcurses/addstr.c +240 -0
- data/vendor/PDCurses/pdcurses/attr.c +359 -0
- data/vendor/PDCurses/pdcurses/beep.c +68 -0
- data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
- data/vendor/PDCurses/pdcurses/border.c +411 -0
- data/vendor/PDCurses/pdcurses/clear.c +159 -0
- data/vendor/PDCurses/pdcurses/color.c +298 -0
- data/vendor/PDCurses/pdcurses/debug.c +109 -0
- data/vendor/PDCurses/pdcurses/delch.c +96 -0
- data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
- data/vendor/PDCurses/pdcurses/deprec.c +27 -0
- data/vendor/PDCurses/pdcurses/getch.c +417 -0
- data/vendor/PDCurses/pdcurses/getstr.c +474 -0
- data/vendor/PDCurses/pdcurses/getyx.c +139 -0
- data/vendor/PDCurses/pdcurses/inch.c +127 -0
- data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
- data/vendor/PDCurses/pdcurses/initscr.c +367 -0
- data/vendor/PDCurses/pdcurses/inopts.c +324 -0
- data/vendor/PDCurses/pdcurses/insch.c +271 -0
- data/vendor/PDCurses/pdcurses/insstr.c +264 -0
- data/vendor/PDCurses/pdcurses/instr.c +246 -0
- data/vendor/PDCurses/pdcurses/kernel.c +259 -0
- data/vendor/PDCurses/pdcurses/keyname.c +157 -0
- data/vendor/PDCurses/pdcurses/mouse.c +438 -0
- data/vendor/PDCurses/pdcurses/move.c +57 -0
- data/vendor/PDCurses/pdcurses/outopts.c +159 -0
- data/vendor/PDCurses/pdcurses/overlay.c +214 -0
- data/vendor/PDCurses/pdcurses/pad.c +260 -0
- data/vendor/PDCurses/pdcurses/panel.c +633 -0
- data/vendor/PDCurses/pdcurses/printw.c +126 -0
- data/vendor/PDCurses/pdcurses/refresh.c +279 -0
- data/vendor/PDCurses/pdcurses/scanw.c +578 -0
- data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
- data/vendor/PDCurses/pdcurses/scroll.c +101 -0
- data/vendor/PDCurses/pdcurses/slk.c +591 -0
- data/vendor/PDCurses/pdcurses/termattr.c +182 -0
- data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
- data/vendor/PDCurses/pdcurses/touch.c +163 -0
- data/vendor/PDCurses/pdcurses/util.c +312 -0
- data/vendor/PDCurses/pdcurses/window.c +569 -0
- data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
- data/vendor/PDCurses/sdl1/README.md +31 -0
- data/vendor/PDCurses/sdl1/deffont.h +385 -0
- data/vendor/PDCurses/sdl1/deficon.h +23 -0
- data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
- data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
- data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
- data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
- data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
- data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
- data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
- data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
- data/vendor/PDCurses/sdl1/sdltest.c +79 -0
- data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
- data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
- data/vendor/PDCurses/sdl2/README.md +34 -0
- data/vendor/PDCurses/sdl2/deffont.h +385 -0
- data/vendor/PDCurses/sdl2/deficon.h +23 -0
- data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
- data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
- data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
- data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
- data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
- data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
- data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
- data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
- data/vendor/PDCurses/sdl2/sdltest.c +81 -0
- data/vendor/PDCurses/term.h +48 -0
- data/vendor/PDCurses/version.mif +7 -0
- data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
- data/vendor/PDCurses/vt/Makefile.bcc +111 -0
- data/vendor/PDCurses/vt/Makefile.dmc +258 -0
- data/vendor/PDCurses/vt/Makefile.vc +144 -0
- data/vendor/PDCurses/vt/Makefile.wcc +107 -0
- data/vendor/PDCurses/vt/README.md +64 -0
- data/vendor/PDCurses/vt/pdcclip.c +20 -0
- data/vendor/PDCurses/vt/pdcdisp.c +284 -0
- data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
- data/vendor/PDCurses/vt/pdckbd.c +394 -0
- data/vendor/PDCurses/vt/pdcscrn.c +434 -0
- data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
- data/vendor/PDCurses/vt/pdcutil.c +43 -0
- data/vendor/PDCurses/vt/pdcvt.h +16 -0
- data/vendor/PDCurses/watcom.mif +68 -0
- data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
- data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
- data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
- data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
- data/vendor/PDCurses/wincon/Makefile.mng +176 -0
- data/vendor/PDCurses/wincon/Makefile.vc +144 -0
- data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
- data/vendor/PDCurses/wincon/README.md +85 -0
- data/vendor/PDCurses/wincon/pdcclip.c +174 -0
- data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
- data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
- data/vendor/PDCurses/wincon/pdckbd.c +786 -0
- data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
- data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
- data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
- data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
- data/vendor/PDCurses/wincon/pdcutil.c +41 -0
- data/vendor/PDCurses/wincon/pdcwin.h +31 -0
- data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
- data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
- data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
- data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
- data/vendor/PDCurses/wingui/Makefile.mng +171 -0
- data/vendor/PDCurses/wingui/Makefile.vc +144 -0
- data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
- data/vendor/PDCurses/wingui/README.md +93 -0
- data/vendor/PDCurses/wingui/pdcclip.c +174 -0
- data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
- data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
- data/vendor/PDCurses/wingui/pdckbd.c +143 -0
- data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
- data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
- data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
- data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
- data/vendor/PDCurses/wingui/pdcutil.c +61 -0
- data/vendor/PDCurses/wingui/pdcwin.h +122 -0
- data/vendor/PDCurses/x11/Makefile.in +754 -0
- data/vendor/PDCurses/x11/PDCurses.spec +82 -0
- data/vendor/PDCurses/x11/README.md +62 -0
- data/vendor/PDCurses/x11/ScrollBox.c +319 -0
- data/vendor/PDCurses/x11/ScrollBox.h +51 -0
- data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
- data/vendor/PDCurses/x11/aclocal.m4 +994 -0
- data/vendor/PDCurses/x11/big_icon.xbm +46 -0
- data/vendor/PDCurses/x11/compose.h +201 -0
- data/vendor/PDCurses/x11/config.guess +1500 -0
- data/vendor/PDCurses/x11/config.h.in +100 -0
- data/vendor/PDCurses/x11/config.sub +1616 -0
- data/vendor/PDCurses/x11/configure +6700 -0
- data/vendor/PDCurses/x11/configure.ac +295 -0
- data/vendor/PDCurses/x11/debian/changelog +6 -0
- data/vendor/PDCurses/x11/debian/compat +1 -0
- data/vendor/PDCurses/x11/debian/control +11 -0
- data/vendor/PDCurses/x11/debian/copyright +27 -0
- data/vendor/PDCurses/x11/debian/rules +98 -0
- data/vendor/PDCurses/x11/install-sh +253 -0
- data/vendor/PDCurses/x11/little_icon.xbm +14 -0
- data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
- data/vendor/PDCurses/x11/pdcclip.c +173 -0
- data/vendor/PDCurses/x11/pdcdisp.c +85 -0
- data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
- data/vendor/PDCurses/x11/pdckbd.c +104 -0
- data/vendor/PDCurses/x11/pdcscrn.c +258 -0
- data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
- data/vendor/PDCurses/x11/pdcutil.c +52 -0
- data/vendor/PDCurses/x11/pdcx11.c +316 -0
- data/vendor/PDCurses/x11/pdcx11.h +191 -0
- data/vendor/PDCurses/x11/sb.c +155 -0
- data/vendor/PDCurses/x11/x11.c +3686 -0
- data/vendor/PDCurses/x11/xcurses-config.in +81 -0
- metadata +255 -21
@@ -0,0 +1,717 @@
|
|
1
|
+
/* Public Domain Curses */
|
2
|
+
|
3
|
+
#include "pdcwin.h"
|
4
|
+
|
5
|
+
#ifdef CHTYPE_LONG
|
6
|
+
# define PDC_OFFSET 32
|
7
|
+
#else
|
8
|
+
# define PDC_OFFSET 8
|
9
|
+
#endif
|
10
|
+
|
11
|
+
#ifndef ENABLE_EXTENDED_FLAGS
|
12
|
+
# define ENABLE_EXTENDED_FLAGS 0x80
|
13
|
+
#endif
|
14
|
+
|
15
|
+
/* special purpose function keys */
|
16
|
+
static int PDC_shutdown_key[PDC_MAX_FUNCTION_KEYS] = { 0, 0, 0, 0, 0 };
|
17
|
+
|
18
|
+
/* COLOR_PAIR to attribute encoding table. */
|
19
|
+
|
20
|
+
unsigned char *pdc_atrtab = (unsigned char *)NULL;
|
21
|
+
|
22
|
+
HANDLE std_con_out = INVALID_HANDLE_VALUE;
|
23
|
+
HANDLE pdc_con_out = INVALID_HANDLE_VALUE;
|
24
|
+
HANDLE pdc_con_in = INVALID_HANDLE_VALUE;
|
25
|
+
|
26
|
+
DWORD pdc_quick_edit;
|
27
|
+
|
28
|
+
static short curstoreal[16], realtocurs[16] =
|
29
|
+
{
|
30
|
+
COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
|
31
|
+
COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
|
32
|
+
COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
|
33
|
+
COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
|
34
|
+
};
|
35
|
+
|
36
|
+
enum { PDC_RESTORE_NONE, PDC_RESTORE_BUFFER };
|
37
|
+
|
38
|
+
/* Struct for storing console registry keys, and for use with the
|
39
|
+
undocumented WM_SETCONSOLEINFO message. Originally by James Brown,
|
40
|
+
www.catch22.net. */
|
41
|
+
|
42
|
+
static struct
|
43
|
+
{
|
44
|
+
ULONG Length;
|
45
|
+
COORD ScreenBufferSize;
|
46
|
+
COORD WindowSize;
|
47
|
+
ULONG WindowPosX;
|
48
|
+
ULONG WindowPosY;
|
49
|
+
|
50
|
+
COORD FontSize;
|
51
|
+
ULONG FontFamily;
|
52
|
+
ULONG FontWeight;
|
53
|
+
WCHAR FaceName[32];
|
54
|
+
|
55
|
+
ULONG CursorSize;
|
56
|
+
ULONG FullScreen;
|
57
|
+
ULONG QuickEdit;
|
58
|
+
ULONG AutoPosition;
|
59
|
+
ULONG InsertMode;
|
60
|
+
|
61
|
+
USHORT ScreenColors;
|
62
|
+
USHORT PopupColors;
|
63
|
+
ULONG HistoryNoDup;
|
64
|
+
ULONG HistoryBufferSize;
|
65
|
+
ULONG NumberOfHistoryBuffers;
|
66
|
+
|
67
|
+
COLORREF ColorTable[16];
|
68
|
+
|
69
|
+
ULONG CodePage;
|
70
|
+
HWND Hwnd;
|
71
|
+
|
72
|
+
WCHAR ConsoleTitle[0x100];
|
73
|
+
} console_info;
|
74
|
+
|
75
|
+
#ifndef HAVE_INFOEX
|
76
|
+
/* Console screen buffer information (extended version) */
|
77
|
+
typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX {
|
78
|
+
ULONG cbSize;
|
79
|
+
COORD dwSize;
|
80
|
+
COORD dwCursorPosition;
|
81
|
+
WORD wAttributes;
|
82
|
+
SMALL_RECT srWindow;
|
83
|
+
COORD dwMaximumWindowSize;
|
84
|
+
WORD wPopupAttributes;
|
85
|
+
BOOL bFullscreenSupported;
|
86
|
+
COLORREF ColorTable[16];
|
87
|
+
} CONSOLE_SCREEN_BUFFER_INFOEX;
|
88
|
+
typedef CONSOLE_SCREEN_BUFFER_INFOEX *PCONSOLE_SCREEN_BUFFER_INFOEX;
|
89
|
+
#endif
|
90
|
+
|
91
|
+
typedef BOOL (WINAPI *SetConsoleScreenBufferInfoExFn)(HANDLE hConsoleOutput,
|
92
|
+
PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
|
93
|
+
typedef BOOL (WINAPI *GetConsoleScreenBufferInfoExFn)(HANDLE hConsoleOutput,
|
94
|
+
PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
|
95
|
+
|
96
|
+
static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL;
|
97
|
+
static GetConsoleScreenBufferInfoExFn pGetConsoleScreenBufferInfoEx = NULL;
|
98
|
+
|
99
|
+
static CONSOLE_SCREEN_BUFFER_INFO orig_scr;
|
100
|
+
static CONSOLE_SCREEN_BUFFER_INFOEX console_infoex;
|
101
|
+
|
102
|
+
static LPTOP_LEVEL_EXCEPTION_FILTER xcpt_filter;
|
103
|
+
|
104
|
+
static DWORD old_console_mode = 0;
|
105
|
+
|
106
|
+
static bool is_nt;
|
107
|
+
|
108
|
+
static HWND _find_console_handle(void)
|
109
|
+
{
|
110
|
+
TCHAR orgtitle[1024], temptitle[1024];
|
111
|
+
HWND wnd;
|
112
|
+
|
113
|
+
GetConsoleTitle(orgtitle, 1024);
|
114
|
+
|
115
|
+
wsprintf(temptitle, TEXT("%d/%d"), GetTickCount(), GetCurrentProcessId());
|
116
|
+
SetConsoleTitle(temptitle);
|
117
|
+
|
118
|
+
Sleep(40);
|
119
|
+
|
120
|
+
wnd = FindWindow(NULL, temptitle);
|
121
|
+
|
122
|
+
SetConsoleTitle(orgtitle);
|
123
|
+
|
124
|
+
return wnd;
|
125
|
+
}
|
126
|
+
|
127
|
+
/* Undocumented console message */
|
128
|
+
|
129
|
+
#define WM_SETCONSOLEINFO (WM_USER + 201)
|
130
|
+
|
131
|
+
/* Wrapper around WM_SETCONSOLEINFO. We need to create the necessary
|
132
|
+
section (file-mapping) object in the context of the process which
|
133
|
+
owns the console, before posting the message. Originally by JB. */
|
134
|
+
|
135
|
+
static void _set_console_info(void)
|
136
|
+
{
|
137
|
+
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
138
|
+
CONSOLE_CURSOR_INFO cci;
|
139
|
+
DWORD dwConsoleOwnerPid;
|
140
|
+
HANDLE hProcess;
|
141
|
+
HANDLE hSection, hDupSection;
|
142
|
+
PVOID ptrView;
|
143
|
+
|
144
|
+
/* Each-time initialization for console_info */
|
145
|
+
|
146
|
+
GetConsoleCursorInfo(pdc_con_out, &cci);
|
147
|
+
console_info.CursorSize = cci.dwSize;
|
148
|
+
|
149
|
+
GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
|
150
|
+
console_info.ScreenBufferSize = csbi.dwSize;
|
151
|
+
|
152
|
+
console_info.WindowSize.X = csbi.srWindow.Right - csbi.srWindow.Left + 1;
|
153
|
+
console_info.WindowSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
|
154
|
+
|
155
|
+
console_info.WindowPosX = csbi.srWindow.Left;
|
156
|
+
console_info.WindowPosY = csbi.srWindow.Top;
|
157
|
+
|
158
|
+
/* Open the process which "owns" the console */
|
159
|
+
|
160
|
+
GetWindowThreadProcessId(console_info.Hwnd, &dwConsoleOwnerPid);
|
161
|
+
|
162
|
+
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwConsoleOwnerPid);
|
163
|
+
|
164
|
+
/* Create a SECTION object backed by page-file, then map a view of
|
165
|
+
this section into the owner process so we can write the contents
|
166
|
+
of the CONSOLE_INFO buffer into it */
|
167
|
+
|
168
|
+
hSection = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE,
|
169
|
+
0, sizeof(console_info), 0);
|
170
|
+
|
171
|
+
/* Copy our console structure into the section-object */
|
172
|
+
|
173
|
+
ptrView = MapViewOfFile(hSection, FILE_MAP_WRITE|FILE_MAP_READ,
|
174
|
+
0, 0, sizeof(console_info));
|
175
|
+
|
176
|
+
memcpy(ptrView, &console_info, sizeof(console_info));
|
177
|
+
|
178
|
+
UnmapViewOfFile(ptrView);
|
179
|
+
|
180
|
+
/* Map the memory into owner process */
|
181
|
+
|
182
|
+
DuplicateHandle(GetCurrentProcess(), hSection, hProcess, &hDupSection,
|
183
|
+
0, FALSE, DUPLICATE_SAME_ACCESS);
|
184
|
+
|
185
|
+
/* Send console window the "update" message */
|
186
|
+
|
187
|
+
SendMessage(console_info.Hwnd, WM_SETCONSOLEINFO, (WPARAM)hDupSection, 0);
|
188
|
+
|
189
|
+
CloseHandle(hSection);
|
190
|
+
CloseHandle(hProcess);
|
191
|
+
}
|
192
|
+
|
193
|
+
static int _set_console_infoex(void)
|
194
|
+
{
|
195
|
+
if (!pSetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex))
|
196
|
+
return ERR;
|
197
|
+
|
198
|
+
return OK;
|
199
|
+
}
|
200
|
+
|
201
|
+
static int _set_colors(void)
|
202
|
+
{
|
203
|
+
if (pSetConsoleScreenBufferInfoEx)
|
204
|
+
return _set_console_infoex();
|
205
|
+
else
|
206
|
+
{
|
207
|
+
_set_console_info();
|
208
|
+
return OK;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
/* One-time initialization for console_info -- color table and font info
|
213
|
+
from the registry; other values from functions. */
|
214
|
+
|
215
|
+
static void _init_console_info(void)
|
216
|
+
{
|
217
|
+
DWORD scrnmode, len;
|
218
|
+
HKEY reghnd;
|
219
|
+
int i;
|
220
|
+
|
221
|
+
console_info.Hwnd = _find_console_handle();
|
222
|
+
console_info.Length = sizeof(console_info);
|
223
|
+
|
224
|
+
GetConsoleMode(pdc_con_in, &scrnmode);
|
225
|
+
console_info.QuickEdit = !!(scrnmode & 0x0040);
|
226
|
+
console_info.InsertMode = !!(scrnmode & 0x0020);
|
227
|
+
|
228
|
+
console_info.FullScreen = FALSE;
|
229
|
+
console_info.AutoPosition = 0x10000;
|
230
|
+
console_info.ScreenColors = SP->orig_back << 4 | SP->orig_fore;
|
231
|
+
console_info.PopupColors = 0xf5;
|
232
|
+
|
233
|
+
console_info.HistoryNoDup = FALSE;
|
234
|
+
console_info.HistoryBufferSize = 50;
|
235
|
+
console_info.NumberOfHistoryBuffers = 4;
|
236
|
+
|
237
|
+
console_info.CodePage = GetConsoleOutputCP();
|
238
|
+
|
239
|
+
RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Console"), 0,
|
240
|
+
KEY_QUERY_VALUE, ®hnd);
|
241
|
+
|
242
|
+
len = sizeof(DWORD);
|
243
|
+
|
244
|
+
/* Default color table */
|
245
|
+
|
246
|
+
for (i = 0; i < 16; i++)
|
247
|
+
{
|
248
|
+
char tname[13];
|
249
|
+
|
250
|
+
sprintf(tname, "ColorTable%02d", i);
|
251
|
+
RegQueryValueExA(reghnd, tname, NULL, NULL,
|
252
|
+
(LPBYTE)(&(console_info.ColorTable[i])), &len);
|
253
|
+
}
|
254
|
+
|
255
|
+
/* Font info */
|
256
|
+
|
257
|
+
RegQueryValueEx(reghnd, TEXT("FontSize"), NULL, NULL,
|
258
|
+
(LPBYTE)(&console_info.FontSize), &len);
|
259
|
+
RegQueryValueEx(reghnd, TEXT("FontFamily"), NULL, NULL,
|
260
|
+
(LPBYTE)(&console_info.FontFamily), &len);
|
261
|
+
RegQueryValueEx(reghnd, TEXT("FontWeight"), NULL, NULL,
|
262
|
+
(LPBYTE)(&console_info.FontWeight), &len);
|
263
|
+
|
264
|
+
len = sizeof(WCHAR) * 32;
|
265
|
+
RegQueryValueExW(reghnd, L"FaceName", NULL, NULL,
|
266
|
+
(LPBYTE)(console_info.FaceName), &len);
|
267
|
+
|
268
|
+
RegCloseKey(reghnd);
|
269
|
+
}
|
270
|
+
|
271
|
+
static int _init_console_infoex(void)
|
272
|
+
{
|
273
|
+
console_infoex.cbSize = sizeof(console_infoex);
|
274
|
+
|
275
|
+
if (!pGetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex))
|
276
|
+
return ERR;
|
277
|
+
|
278
|
+
console_infoex.srWindow.Right++;
|
279
|
+
console_infoex.srWindow.Bottom++;
|
280
|
+
|
281
|
+
return OK;
|
282
|
+
}
|
283
|
+
|
284
|
+
static COLORREF *_get_colors(void)
|
285
|
+
{
|
286
|
+
if (pGetConsoleScreenBufferInfoEx)
|
287
|
+
{
|
288
|
+
int status = OK;
|
289
|
+
if (!console_infoex.cbSize)
|
290
|
+
status = _init_console_infoex();
|
291
|
+
return (status == ERR) ? NULL :
|
292
|
+
(COLORREF *)(&(console_infoex.ColorTable));
|
293
|
+
}
|
294
|
+
else
|
295
|
+
{
|
296
|
+
if (!console_info.Hwnd)
|
297
|
+
_init_console_info();
|
298
|
+
return (COLORREF *)(&(console_info.ColorTable));
|
299
|
+
}
|
300
|
+
}
|
301
|
+
|
302
|
+
/* restore the original console buffer in the event of a crash */
|
303
|
+
|
304
|
+
static LONG WINAPI _restore_console(LPEXCEPTION_POINTERS ep)
|
305
|
+
{
|
306
|
+
PDC_scr_close();
|
307
|
+
|
308
|
+
return EXCEPTION_CONTINUE_SEARCH;
|
309
|
+
}
|
310
|
+
|
311
|
+
/* restore the original console buffer on Ctrl+Break (or Ctrl+C,
|
312
|
+
if it gets re-enabled) */
|
313
|
+
|
314
|
+
static BOOL WINAPI _ctrl_break(DWORD dwCtrlType)
|
315
|
+
{
|
316
|
+
if (dwCtrlType == CTRL_BREAK_EVENT || dwCtrlType == CTRL_C_EVENT)
|
317
|
+
PDC_scr_close();
|
318
|
+
|
319
|
+
return FALSE;
|
320
|
+
}
|
321
|
+
|
322
|
+
/* close the physical screen -- may restore the screen to its state
|
323
|
+
before PDC_scr_open(); miscellaneous cleanup */
|
324
|
+
|
325
|
+
void PDC_scr_close(void)
|
326
|
+
{
|
327
|
+
PDC_LOG(("PDC_scr_close() - called\n"));
|
328
|
+
|
329
|
+
if (SP->visibility != 1)
|
330
|
+
curs_set(1);
|
331
|
+
|
332
|
+
PDC_reset_shell_mode();
|
333
|
+
|
334
|
+
/* Position cursor to the bottom left of the screen. */
|
335
|
+
|
336
|
+
if (SP->_restore == PDC_RESTORE_NONE)
|
337
|
+
{
|
338
|
+
SMALL_RECT win;
|
339
|
+
|
340
|
+
win.Left = orig_scr.srWindow.Left;
|
341
|
+
win.Right = orig_scr.srWindow.Right;
|
342
|
+
win.Top = 0;
|
343
|
+
win.Bottom = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top;
|
344
|
+
SetConsoleWindowInfo(pdc_con_out, TRUE, &win);
|
345
|
+
PDC_gotoyx(win.Bottom, 0);
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
void PDC_scr_free(void)
|
350
|
+
{
|
351
|
+
if (SP)
|
352
|
+
free(SP);
|
353
|
+
if (pdc_atrtab)
|
354
|
+
free(pdc_atrtab);
|
355
|
+
|
356
|
+
pdc_atrtab = (unsigned char *)NULL;
|
357
|
+
|
358
|
+
if (pdc_con_out != std_con_out)
|
359
|
+
{
|
360
|
+
CloseHandle(pdc_con_out);
|
361
|
+
pdc_con_out = std_con_out;
|
362
|
+
}
|
363
|
+
|
364
|
+
SetUnhandledExceptionFilter(xcpt_filter);
|
365
|
+
SetConsoleCtrlHandler(_ctrl_break, FALSE);
|
366
|
+
}
|
367
|
+
|
368
|
+
/* open the physical screen -- allocate SP, miscellaneous intialization,
|
369
|
+
and may save the existing screen for later restoration */
|
370
|
+
|
371
|
+
int PDC_scr_open(int argc, char **argv)
|
372
|
+
{
|
373
|
+
const char *str;
|
374
|
+
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
375
|
+
HMODULE h_kernel;
|
376
|
+
int i;
|
377
|
+
|
378
|
+
PDC_LOG(("PDC_scr_open() - called\n"));
|
379
|
+
|
380
|
+
SP = calloc(1, sizeof(SCREEN));
|
381
|
+
pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
|
382
|
+
|
383
|
+
if (!SP || !pdc_atrtab)
|
384
|
+
return ERR;
|
385
|
+
|
386
|
+
for (i = 0; i < 16; i++)
|
387
|
+
curstoreal[realtocurs[i]] = i;
|
388
|
+
|
389
|
+
std_con_out =
|
390
|
+
pdc_con_out = GetStdHandle(STD_OUTPUT_HANDLE);
|
391
|
+
pdc_con_in = GetStdHandle(STD_INPUT_HANDLE);
|
392
|
+
|
393
|
+
if (GetFileType(pdc_con_in) != FILE_TYPE_CHAR)
|
394
|
+
{
|
395
|
+
fprintf(stderr, "\nRedirection is not supported.\n");
|
396
|
+
exit(1);
|
397
|
+
}
|
398
|
+
|
399
|
+
#if defined(_MSC_VER) && _MSC_VER >= 1800 /* VS2013 and above can't build */
|
400
|
+
is_nt = TRUE; /* non-NT (Win9x/3.1/ME) targets anyway, so always true */
|
401
|
+
#else
|
402
|
+
is_nt = !(GetVersion() & 0x80000000);
|
403
|
+
#endif
|
404
|
+
|
405
|
+
GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
|
406
|
+
GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr);
|
407
|
+
GetConsoleMode(pdc_con_in, &old_console_mode);
|
408
|
+
|
409
|
+
/* preserve QuickEdit Mode setting for use in PDC_mouse_set() when
|
410
|
+
the mouse is not enabled -- other console input settings are
|
411
|
+
cleared */
|
412
|
+
|
413
|
+
pdc_quick_edit = old_console_mode & 0x0040;
|
414
|
+
|
415
|
+
SP->lines = (str = getenv("LINES")) ? atoi(str) : PDC_get_rows();
|
416
|
+
SP->cols = (str = getenv("COLS")) ? atoi(str) : PDC_get_columns();
|
417
|
+
|
418
|
+
SP->mouse_wait = PDC_CLICK_PERIOD;
|
419
|
+
SP->audible = TRUE;
|
420
|
+
|
421
|
+
if (SP->lines < 2 || SP->lines > csbi.dwMaximumWindowSize.Y)
|
422
|
+
{
|
423
|
+
fprintf(stderr, "LINES value must be >= 2 and <= %d: got %d\n",
|
424
|
+
csbi.dwMaximumWindowSize.Y, SP->lines);
|
425
|
+
|
426
|
+
return ERR;
|
427
|
+
}
|
428
|
+
|
429
|
+
if (SP->cols < 2 || SP->cols > csbi.dwMaximumWindowSize.X)
|
430
|
+
{
|
431
|
+
fprintf(stderr, "COLS value must be >= 2 and <= %d: got %d\n",
|
432
|
+
csbi.dwMaximumWindowSize.X, SP->cols);
|
433
|
+
|
434
|
+
return ERR;
|
435
|
+
}
|
436
|
+
|
437
|
+
SP->orig_fore = csbi.wAttributes & 0x0f;
|
438
|
+
SP->orig_back = (csbi.wAttributes & 0xf0) >> 4;
|
439
|
+
|
440
|
+
SP->orig_attr = TRUE;
|
441
|
+
|
442
|
+
SP->_restore = PDC_RESTORE_NONE;
|
443
|
+
|
444
|
+
if ((str = getenv("PDC_RESTORE_SCREEN")) == NULL || *str != '0')
|
445
|
+
{
|
446
|
+
/* Create a new console buffer */
|
447
|
+
|
448
|
+
pdc_con_out =
|
449
|
+
CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
|
450
|
+
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
451
|
+
NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
|
452
|
+
|
453
|
+
if (pdc_con_out == INVALID_HANDLE_VALUE)
|
454
|
+
{
|
455
|
+
PDC_LOG(("PDC_scr_open() - screen buffer failure\n"));
|
456
|
+
|
457
|
+
pdc_con_out = std_con_out;
|
458
|
+
}
|
459
|
+
else
|
460
|
+
SP->_restore = PDC_RESTORE_BUFFER;
|
461
|
+
}
|
462
|
+
|
463
|
+
xcpt_filter = SetUnhandledExceptionFilter(_restore_console);
|
464
|
+
SetConsoleCtrlHandler(_ctrl_break, TRUE);
|
465
|
+
|
466
|
+
SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
|
467
|
+
|
468
|
+
PDC_reset_prog_mode();
|
469
|
+
|
470
|
+
SP->mono = FALSE;
|
471
|
+
|
472
|
+
h_kernel = GetModuleHandleA("kernel32.dll");
|
473
|
+
pGetConsoleScreenBufferInfoEx =
|
474
|
+
(GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
|
475
|
+
"GetConsoleScreenBufferInfoEx");
|
476
|
+
pSetConsoleScreenBufferInfoEx =
|
477
|
+
(SetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
|
478
|
+
"SetConsoleScreenBufferInfoEx");
|
479
|
+
|
480
|
+
return OK;
|
481
|
+
}
|
482
|
+
|
483
|
+
/* Calls SetConsoleWindowInfo with the given parameters, but fits them
|
484
|
+
if a scoll bar shrinks the maximum possible value. The rectangle
|
485
|
+
must at least fit in a half-sized window. */
|
486
|
+
|
487
|
+
static BOOL _fit_console_window(HANDLE con_out, CONST SMALL_RECT *rect)
|
488
|
+
{
|
489
|
+
SMALL_RECT run;
|
490
|
+
SHORT mx, my;
|
491
|
+
|
492
|
+
if (SetConsoleWindowInfo(con_out, TRUE, rect))
|
493
|
+
return TRUE;
|
494
|
+
|
495
|
+
run = *rect;
|
496
|
+
run.Right /= 2;
|
497
|
+
run.Bottom /= 2;
|
498
|
+
|
499
|
+
mx = run.Right;
|
500
|
+
my = run.Bottom;
|
501
|
+
|
502
|
+
if (!SetConsoleWindowInfo(con_out, TRUE, &run))
|
503
|
+
return FALSE;
|
504
|
+
|
505
|
+
for (run.Right = rect->Right; run.Right >= mx; run.Right--)
|
506
|
+
if (SetConsoleWindowInfo(con_out, TRUE, &run))
|
507
|
+
break;
|
508
|
+
|
509
|
+
if (run.Right < mx)
|
510
|
+
return FALSE;
|
511
|
+
|
512
|
+
for (run.Bottom = rect->Bottom; run.Bottom >= my; run.Bottom--)
|
513
|
+
if (SetConsoleWindowInfo(con_out, TRUE, &run))
|
514
|
+
return TRUE;
|
515
|
+
|
516
|
+
return FALSE;
|
517
|
+
}
|
518
|
+
|
519
|
+
/* the core of resize_term() */
|
520
|
+
|
521
|
+
int PDC_resize_screen(int nlines, int ncols)
|
522
|
+
{
|
523
|
+
SMALL_RECT rect;
|
524
|
+
COORD size, max;
|
525
|
+
|
526
|
+
if( nlines || ncols)
|
527
|
+
{
|
528
|
+
if (nlines < 2 || ncols < 2)
|
529
|
+
return ERR;
|
530
|
+
|
531
|
+
if( !stdscr) /* window hasn't been created yet; we're */
|
532
|
+
{ /* specifying its size before doing so */
|
533
|
+
return OK; /* ...which doesn't work (yet) on Win32 */
|
534
|
+
}
|
535
|
+
|
536
|
+
max = GetLargestConsoleWindowSize(pdc_con_out);
|
537
|
+
|
538
|
+
rect.Left = rect.Top = 0;
|
539
|
+
rect.Right = ncols - 1;
|
540
|
+
|
541
|
+
if (rect.Right > max.X)
|
542
|
+
rect.Right = max.X;
|
543
|
+
|
544
|
+
rect.Bottom = nlines - 1;
|
545
|
+
|
546
|
+
if (rect.Bottom > max.Y)
|
547
|
+
rect.Bottom = max.Y;
|
548
|
+
|
549
|
+
size.X = rect.Right + 1;
|
550
|
+
size.Y = rect.Bottom + 1;
|
551
|
+
|
552
|
+
_fit_console_window(pdc_con_out, &rect);
|
553
|
+
SetConsoleScreenBufferSize(pdc_con_out, size);
|
554
|
+
_fit_console_window(pdc_con_out, &rect);
|
555
|
+
SetConsoleScreenBufferSize(pdc_con_out, size);
|
556
|
+
SetConsoleActiveScreenBuffer(pdc_con_out);
|
557
|
+
}
|
558
|
+
|
559
|
+
PDC_flushinp();
|
560
|
+
|
561
|
+
SP->resized = FALSE;
|
562
|
+
SP->cursrow = SP->curscol = 0;
|
563
|
+
|
564
|
+
return OK;
|
565
|
+
}
|
566
|
+
|
567
|
+
void PDC_reset_prog_mode(void)
|
568
|
+
{
|
569
|
+
PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
|
570
|
+
|
571
|
+
if (pdc_con_out != std_con_out)
|
572
|
+
SetConsoleActiveScreenBuffer(pdc_con_out);
|
573
|
+
else if (is_nt)
|
574
|
+
{
|
575
|
+
COORD bufsize;
|
576
|
+
SMALL_RECT rect;
|
577
|
+
|
578
|
+
bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
|
579
|
+
bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
|
580
|
+
|
581
|
+
rect.Top = rect.Left = 0;
|
582
|
+
rect.Bottom = bufsize.Y - 1;
|
583
|
+
rect.Right = bufsize.X - 1;
|
584
|
+
|
585
|
+
SetConsoleScreenBufferSize(pdc_con_out, bufsize);
|
586
|
+
SetConsoleWindowInfo(pdc_con_out, TRUE, &rect);
|
587
|
+
SetConsoleScreenBufferSize(pdc_con_out, bufsize);
|
588
|
+
SetConsoleActiveScreenBuffer(pdc_con_out);
|
589
|
+
}
|
590
|
+
|
591
|
+
PDC_mouse_set();
|
592
|
+
}
|
593
|
+
|
594
|
+
void PDC_reset_shell_mode(void)
|
595
|
+
{
|
596
|
+
PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
|
597
|
+
|
598
|
+
if (pdc_con_out != std_con_out)
|
599
|
+
SetConsoleActiveScreenBuffer(std_con_out);
|
600
|
+
else if (is_nt)
|
601
|
+
{
|
602
|
+
SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
|
603
|
+
SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
|
604
|
+
SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
|
605
|
+
SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
|
606
|
+
SetConsoleActiveScreenBuffer(pdc_con_out);
|
607
|
+
}
|
608
|
+
|
609
|
+
SetConsoleMode(pdc_con_in, old_console_mode | ENABLE_EXTENDED_FLAGS);
|
610
|
+
}
|
611
|
+
|
612
|
+
void PDC_restore_screen_mode(int i)
|
613
|
+
{
|
614
|
+
}
|
615
|
+
|
616
|
+
void PDC_save_screen_mode(int i)
|
617
|
+
{
|
618
|
+
}
|
619
|
+
|
620
|
+
void PDC_init_pair(short pair, short fg, short bg)
|
621
|
+
{
|
622
|
+
unsigned char att, temp_bg;
|
623
|
+
chtype i;
|
624
|
+
|
625
|
+
fg = curstoreal[fg];
|
626
|
+
bg = curstoreal[bg];
|
627
|
+
|
628
|
+
for (i = 0; i < PDC_OFFSET; i++)
|
629
|
+
{
|
630
|
+
att = fg | (bg << 4);
|
631
|
+
|
632
|
+
if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
|
633
|
+
att = bg | (fg << 4);
|
634
|
+
if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
|
635
|
+
att = 1;
|
636
|
+
if (i & (A_INVIS >> PDC_ATTR_SHIFT))
|
637
|
+
{
|
638
|
+
temp_bg = att >> 4;
|
639
|
+
att = temp_bg << 4 | temp_bg;
|
640
|
+
}
|
641
|
+
if (i & (A_BOLD >> PDC_ATTR_SHIFT))
|
642
|
+
att |= 8;
|
643
|
+
if (i & (A_BLINK >> PDC_ATTR_SHIFT))
|
644
|
+
att |= 128;
|
645
|
+
|
646
|
+
pdc_atrtab[pair * PDC_OFFSET + i] = att;
|
647
|
+
}
|
648
|
+
}
|
649
|
+
|
650
|
+
int PDC_pair_content(short pair, short *fg, short *bg)
|
651
|
+
{
|
652
|
+
*fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
|
653
|
+
*bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
|
654
|
+
|
655
|
+
return OK;
|
656
|
+
}
|
657
|
+
|
658
|
+
bool PDC_can_change_color(void)
|
659
|
+
{
|
660
|
+
return is_nt;
|
661
|
+
}
|
662
|
+
|
663
|
+
int PDC_color_content(short color, short *red, short *green, short *blue)
|
664
|
+
{
|
665
|
+
COLORREF *color_table = _get_colors();
|
666
|
+
|
667
|
+
if (color_table)
|
668
|
+
{
|
669
|
+
DWORD col = color_table[curstoreal[color]];
|
670
|
+
|
671
|
+
*red = DIVROUND(GetRValue(col) * 1000, 255);
|
672
|
+
*green = DIVROUND(GetGValue(col) * 1000, 255);
|
673
|
+
*blue = DIVROUND(GetBValue(col) * 1000, 255);
|
674
|
+
|
675
|
+
return OK;
|
676
|
+
}
|
677
|
+
|
678
|
+
return ERR;
|
679
|
+
}
|
680
|
+
|
681
|
+
int PDC_init_color(short color, short red, short green, short blue)
|
682
|
+
{
|
683
|
+
COLORREF *color_table = _get_colors();
|
684
|
+
|
685
|
+
if (color_table)
|
686
|
+
{
|
687
|
+
color_table[curstoreal[color]] =
|
688
|
+
RGB(DIVROUND(red * 255, 1000),
|
689
|
+
DIVROUND(green * 255, 1000),
|
690
|
+
DIVROUND(blue * 255, 1000));
|
691
|
+
|
692
|
+
return _set_colors();
|
693
|
+
}
|
694
|
+
|
695
|
+
return ERR;
|
696
|
+
}
|
697
|
+
|
698
|
+
/* Does nothing in the Win32 flavor of PDCurses. Included solely because
|
699
|
+
without this, we get an unresolved external... */
|
700
|
+
|
701
|
+
void PDC_set_resize_limits( const int new_min_lines, const int new_max_lines,
|
702
|
+
const int new_min_cols, const int new_max_cols)
|
703
|
+
{
|
704
|
+
}
|
705
|
+
|
706
|
+
/* PDC_set_function_key() does nothing on this platform */
|
707
|
+
int PDC_set_function_key( const unsigned function, const int new_key)
|
708
|
+
{
|
709
|
+
int old_key = -1;
|
710
|
+
|
711
|
+
if( function < PDC_MAX_FUNCTION_KEYS)
|
712
|
+
{
|
713
|
+
old_key = PDC_shutdown_key[function];
|
714
|
+
PDC_shutdown_key[function] = new_key;
|
715
|
+
}
|
716
|
+
return( old_key);
|
717
|
+
}
|