curses 1.4.4 → 1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/macos.yml +1 -1
- data/.github/workflows/push_gem.yml +48 -0
- data/.github/workflows/ubuntu.yml +2 -2
- data/.github/workflows/windows.yml +2 -2
- data/History.md +23 -0
- data/README.md +7 -0
- data/curses.gemspec +1 -1
- data/ext/curses/curses.c +7 -7
- data/sample/colors.rb +6 -1
- data/sample/form.rb +1 -1
- data/sample/menu.rb +2 -0
- metadata +9 -251
- data/vendor/PDCurses/.gitignore +0 -47
- data/vendor/PDCurses/.travis.yml +0 -49
- data/vendor/PDCurses/CMakeLists.txt +0 -68
- data/vendor/PDCurses/HISTORY.md +0 -2036
- data/vendor/PDCurses/IMPLEMNT.md +0 -327
- data/vendor/PDCurses/Makefile +0 -27
- data/vendor/PDCurses/README.md +0 -77
- data/vendor/PDCurses/acs_defs.h +0 -265
- data/vendor/PDCurses/appveyor.yml +0 -218
- data/vendor/PDCurses/cmake/README.md +0 -71
- data/vendor/PDCurses/cmake/build_dependencies.cmake +0 -178
- data/vendor/PDCurses/cmake/build_options.cmake +0 -25
- data/vendor/PDCurses/cmake/dll_version.cmake +0 -26
- data/vendor/PDCurses/cmake/gen_config_header.cmake +0 -43
- data/vendor/PDCurses/cmake/get_version.cmake +0 -17
- data/vendor/PDCurses/cmake/make_uninstall.cmake +0 -19
- data/vendor/PDCurses/cmake/project_common.cmake +0 -121
- data/vendor/PDCurses/cmake/resource.in.cmake +0 -52
- data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +0 -83
- data/vendor/PDCurses/cmake/target_arch.cmake +0 -36
- data/vendor/PDCurses/cmake/version.in.cmake +0 -73
- data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +0 -96
- data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +0 -106
- data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +0 -105
- data/vendor/PDCurses/curses.h +0 -1846
- data/vendor/PDCurses/curspriv.h +0 -134
- data/vendor/PDCurses/demos/README.md +0 -25
- data/vendor/PDCurses/demos/firework.c +0 -144
- data/vendor/PDCurses/demos/newtest.c +0 -581
- data/vendor/PDCurses/demos/ozdemo.c +0 -447
- data/vendor/PDCurses/demos/ptest.c +0 -283
- data/vendor/PDCurses/demos/rain.c +0 -157
- data/vendor/PDCurses/demos/testcurs.c +0 -1607
- data/vendor/PDCurses/demos/tui.c +0 -1048
- data/vendor/PDCurses/demos/tui.h +0 -65
- data/vendor/PDCurses/demos/tuidemo.c +0 -233
- data/vendor/PDCurses/demos/version.c +0 -61
- data/vendor/PDCurses/demos/worm.c +0 -432
- data/vendor/PDCurses/demos/xmas.c +0 -955
- data/vendor/PDCurses/dos/CMakeLists.txt +0 -47
- data/vendor/PDCurses/dos/Makefile +0 -105
- data/vendor/PDCurses/dos/Makefile.bcc +0 -83
- data/vendor/PDCurses/dos/Makefile.dmc +0 -257
- data/vendor/PDCurses/dos/Makefile.msc +0 -113
- data/vendor/PDCurses/dos/Makefile.wcc +0 -107
- data/vendor/PDCurses/dos/README.md +0 -51
- data/vendor/PDCurses/dos/bccdos.lrf +0 -9
- data/vendor/PDCurses/dos/mscdos.lrf +0 -50
- data/vendor/PDCurses/dos/pdcclip.c +0 -132
- data/vendor/PDCurses/dos/pdcdisp.c +0 -135
- data/vendor/PDCurses/dos/pdcdos.h +0 -194
- data/vendor/PDCurses/dos/pdcgetsc.c +0 -98
- data/vendor/PDCurses/dos/pdckbd.c +0 -513
- data/vendor/PDCurses/dos/pdcscrn.c +0 -785
- data/vendor/PDCurses/dos/pdcsetsc.c +0 -101
- data/vendor/PDCurses/dos/pdcutil.c +0 -212
- data/vendor/PDCurses/libobjs.mif +0 -26
- data/vendor/PDCurses/makedist.mif +0 -20
- data/vendor/PDCurses/man/Makefile +0 -37
- data/vendor/PDCurses/man/README.md +0 -21
- data/vendor/PDCurses/man/intro.md +0 -361
- data/vendor/PDCurses/man/manext.c +0 -119
- data/vendor/PDCurses/man/sdl.md +0 -152
- data/vendor/PDCurses/man/sdl2.md +0 -58
- data/vendor/PDCurses/man/x11.md +0 -407
- data/vendor/PDCurses/ncurses/CMakeLists.txt +0 -66
- data/vendor/PDCurses/ncurses/README.md +0 -26
- data/vendor/PDCurses/ncurses/makefile +0 -29
- data/vendor/PDCurses/os2/CMakeLists.txt +0 -41
- data/vendor/PDCurses/os2/Makefile +0 -132
- data/vendor/PDCurses/os2/Makefile.bcc +0 -90
- data/vendor/PDCurses/os2/Makefile.wcc +0 -43
- data/vendor/PDCurses/os2/README.md +0 -43
- data/vendor/PDCurses/os2/iccos2.lrf +0 -50
- data/vendor/PDCurses/os2/iccos2.mak +0 -256
- data/vendor/PDCurses/os2/pdcclip.c +0 -188
- data/vendor/PDCurses/os2/pdcdisp.c +0 -93
- data/vendor/PDCurses/os2/pdcgetsc.c +0 -89
- data/vendor/PDCurses/os2/pdckbd.c +0 -521
- data/vendor/PDCurses/os2/pdcos2.h +0 -55
- data/vendor/PDCurses/os2/pdcscrn.c +0 -449
- data/vendor/PDCurses/os2/pdcsetsc.c +0 -112
- data/vendor/PDCurses/os2/pdcutil.c +0 -52
- data/vendor/PDCurses/panel.h +0 -56
- data/vendor/PDCurses/pdcurses/README.md +0 -25
- data/vendor/PDCurses/pdcurses/addch.c +0 -693
- data/vendor/PDCurses/pdcurses/addchstr.c +0 -245
- data/vendor/PDCurses/pdcurses/addstr.c +0 -240
- data/vendor/PDCurses/pdcurses/attr.c +0 -359
- data/vendor/PDCurses/pdcurses/beep.c +0 -68
- data/vendor/PDCurses/pdcurses/bkgd.c +0 -223
- data/vendor/PDCurses/pdcurses/border.c +0 -411
- data/vendor/PDCurses/pdcurses/clear.c +0 -159
- data/vendor/PDCurses/pdcurses/color.c +0 -298
- data/vendor/PDCurses/pdcurses/debug.c +0 -109
- data/vendor/PDCurses/pdcurses/delch.c +0 -96
- data/vendor/PDCurses/pdcurses/deleteln.c +0 -211
- data/vendor/PDCurses/pdcurses/deprec.c +0 -27
- data/vendor/PDCurses/pdcurses/getch.c +0 -417
- data/vendor/PDCurses/pdcurses/getstr.c +0 -474
- data/vendor/PDCurses/pdcurses/getyx.c +0 -139
- data/vendor/PDCurses/pdcurses/inch.c +0 -127
- data/vendor/PDCurses/pdcurses/inchstr.c +0 -214
- data/vendor/PDCurses/pdcurses/initscr.c +0 -367
- data/vendor/PDCurses/pdcurses/inopts.c +0 -324
- data/vendor/PDCurses/pdcurses/insch.c +0 -271
- data/vendor/PDCurses/pdcurses/insstr.c +0 -264
- data/vendor/PDCurses/pdcurses/instr.c +0 -246
- data/vendor/PDCurses/pdcurses/kernel.c +0 -259
- data/vendor/PDCurses/pdcurses/keyname.c +0 -157
- data/vendor/PDCurses/pdcurses/mouse.c +0 -438
- data/vendor/PDCurses/pdcurses/move.c +0 -57
- data/vendor/PDCurses/pdcurses/outopts.c +0 -159
- data/vendor/PDCurses/pdcurses/overlay.c +0 -214
- data/vendor/PDCurses/pdcurses/pad.c +0 -260
- data/vendor/PDCurses/pdcurses/panel.c +0 -633
- data/vendor/PDCurses/pdcurses/printw.c +0 -126
- data/vendor/PDCurses/pdcurses/refresh.c +0 -279
- data/vendor/PDCurses/pdcurses/scanw.c +0 -578
- data/vendor/PDCurses/pdcurses/scr_dump.c +0 -213
- data/vendor/PDCurses/pdcurses/scroll.c +0 -101
- data/vendor/PDCurses/pdcurses/slk.c +0 -591
- data/vendor/PDCurses/pdcurses/termattr.c +0 -182
- data/vendor/PDCurses/pdcurses/terminfo.c +0 -217
- data/vendor/PDCurses/pdcurses/touch.c +0 -163
- data/vendor/PDCurses/pdcurses/util.c +0 -312
- data/vendor/PDCurses/pdcurses/window.c +0 -569
- data/vendor/PDCurses/sdl1/Makefile +0 -129
- data/vendor/PDCurses/sdl1/Makefile.mng +0 -110
- data/vendor/PDCurses/sdl1/README.md +0 -31
- data/vendor/PDCurses/sdl1/deffont.h +0 -385
- data/vendor/PDCurses/sdl1/deficon.h +0 -23
- data/vendor/PDCurses/sdl1/pdcclip.c +0 -131
- data/vendor/PDCurses/sdl1/pdcdisp.c +0 -373
- data/vendor/PDCurses/sdl1/pdcgetsc.c +0 -30
- data/vendor/PDCurses/sdl1/pdckbd.c +0 -405
- data/vendor/PDCurses/sdl1/pdcscrn.c +0 -414
- data/vendor/PDCurses/sdl1/pdcsdl.h +0 -31
- data/vendor/PDCurses/sdl1/pdcsetsc.c +0 -64
- data/vendor/PDCurses/sdl1/pdcutil.c +0 -40
- data/vendor/PDCurses/sdl1/sdltest.c +0 -79
- data/vendor/PDCurses/sdl2/CMakeLists.txt +0 -76
- data/vendor/PDCurses/sdl2/Makefile +0 -135
- data/vendor/PDCurses/sdl2/Makefile.vc +0 -164
- data/vendor/PDCurses/sdl2/README.md +0 -34
- data/vendor/PDCurses/sdl2/deffont.h +0 -385
- data/vendor/PDCurses/sdl2/deficon.h +0 -23
- data/vendor/PDCurses/sdl2/pdcclip.c +0 -93
- data/vendor/PDCurses/sdl2/pdcdisp.c +0 -534
- data/vendor/PDCurses/sdl2/pdcgetsc.c +0 -30
- data/vendor/PDCurses/sdl2/pdckbd.c +0 -480
- data/vendor/PDCurses/sdl2/pdcscrn.c +0 -443
- data/vendor/PDCurses/sdl2/pdcsdl.h +0 -33
- data/vendor/PDCurses/sdl2/pdcsetsc.c +0 -67
- data/vendor/PDCurses/sdl2/pdcutil.c +0 -39
- data/vendor/PDCurses/sdl2/sdltest.c +0 -81
- data/vendor/PDCurses/term.h +0 -48
- data/vendor/PDCurses/version.mif +0 -7
- data/vendor/PDCurses/vt/CMakeLists.txt +0 -28
- data/vendor/PDCurses/vt/Makefile +0 -135
- data/vendor/PDCurses/vt/Makefile.bcc +0 -111
- data/vendor/PDCurses/vt/Makefile.dmc +0 -258
- data/vendor/PDCurses/vt/Makefile.vc +0 -144
- data/vendor/PDCurses/vt/Makefile.wcc +0 -107
- data/vendor/PDCurses/vt/README.md +0 -64
- data/vendor/PDCurses/vt/pdcclip.c +0 -20
- data/vendor/PDCurses/vt/pdcdisp.c +0 -284
- data/vendor/PDCurses/vt/pdcgetsc.c +0 -27
- data/vendor/PDCurses/vt/pdckbd.c +0 -394
- data/vendor/PDCurses/vt/pdcscrn.c +0 -434
- data/vendor/PDCurses/vt/pdcsetsc.c +0 -45
- data/vendor/PDCurses/vt/pdcutil.c +0 -43
- data/vendor/PDCurses/vt/pdcvt.h +0 -16
- data/vendor/PDCurses/watcom.mif +0 -68
- data/vendor/PDCurses/wincon/CMakeLists.txt +0 -27
- data/vendor/PDCurses/wincon/Makefile.bcc +0 -88
- data/vendor/PDCurses/wincon/Makefile.dmc +0 -256
- data/vendor/PDCurses/wincon/Makefile.lcc +0 -273
- data/vendor/PDCurses/wincon/Makefile.mng +0 -176
- data/vendor/PDCurses/wincon/Makefile.vc +0 -144
- data/vendor/PDCurses/wincon/Makefile.wcc +0 -51
- data/vendor/PDCurses/wincon/README.md +0 -85
- data/vendor/PDCurses/wincon/pdcclip.c +0 -174
- data/vendor/PDCurses/wincon/pdcdisp.c +0 -143
- data/vendor/PDCurses/wincon/pdcgetsc.c +0 -55
- data/vendor/PDCurses/wincon/pdckbd.c +0 -786
- data/vendor/PDCurses/wincon/pdcscrn.c +0 -717
- data/vendor/PDCurses/wincon/pdcsetsc.c +0 -91
- data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
- data/vendor/PDCurses/wincon/pdcurses.rc +0 -28
- data/vendor/PDCurses/wincon/pdcutil.c +0 -41
- data/vendor/PDCurses/wincon/pdcwin.h +0 -31
- data/vendor/PDCurses/wingui/CMakeLists.txt +0 -27
- data/vendor/PDCurses/wingui/Makefile.bcc +0 -85
- data/vendor/PDCurses/wingui/Makefile.dmc +0 -259
- data/vendor/PDCurses/wingui/Makefile.lcc +0 -273
- data/vendor/PDCurses/wingui/Makefile.mng +0 -171
- data/vendor/PDCurses/wingui/Makefile.vc +0 -144
- data/vendor/PDCurses/wingui/Makefile.wcc +0 -51
- data/vendor/PDCurses/wingui/README.md +0 -93
- data/vendor/PDCurses/wingui/pdcclip.c +0 -174
- data/vendor/PDCurses/wingui/pdcdisp.c +0 -718
- data/vendor/PDCurses/wingui/pdcgetsc.c +0 -30
- data/vendor/PDCurses/wingui/pdckbd.c +0 -143
- data/vendor/PDCurses/wingui/pdcscrn.c +0 -2797
- data/vendor/PDCurses/wingui/pdcsetsc.c +0 -89
- data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
- data/vendor/PDCurses/wingui/pdcurses.rc +0 -28
- data/vendor/PDCurses/wingui/pdcutil.c +0 -61
- data/vendor/PDCurses/wingui/pdcwin.h +0 -122
- data/vendor/PDCurses/x11/Makefile.in +0 -754
- data/vendor/PDCurses/x11/PDCurses.spec +0 -82
- data/vendor/PDCurses/x11/README.md +0 -62
- data/vendor/PDCurses/x11/ScrollBox.c +0 -319
- data/vendor/PDCurses/x11/ScrollBox.h +0 -51
- data/vendor/PDCurses/x11/ScrollBoxP.h +0 -70
- data/vendor/PDCurses/x11/aclocal.m4 +0 -994
- data/vendor/PDCurses/x11/big_icon.xbm +0 -46
- data/vendor/PDCurses/x11/compose.h +0 -201
- data/vendor/PDCurses/x11/config.guess +0 -1500
- data/vendor/PDCurses/x11/config.h.in +0 -100
- data/vendor/PDCurses/x11/config.sub +0 -1616
- data/vendor/PDCurses/x11/configure +0 -6700
- data/vendor/PDCurses/x11/configure.ac +0 -295
- data/vendor/PDCurses/x11/debian/changelog +0 -6
- data/vendor/PDCurses/x11/debian/compat +0 -1
- data/vendor/PDCurses/x11/debian/control +0 -11
- data/vendor/PDCurses/x11/debian/copyright +0 -27
- data/vendor/PDCurses/x11/debian/rules +0 -98
- data/vendor/PDCurses/x11/install-sh +0 -253
- data/vendor/PDCurses/x11/little_icon.xbm +0 -14
- data/vendor/PDCurses/x11/ncurses_cfg.h +0 -45
- data/vendor/PDCurses/x11/pdcclip.c +0 -173
- data/vendor/PDCurses/x11/pdcdisp.c +0 -85
- data/vendor/PDCurses/x11/pdcgetsc.c +0 -28
- data/vendor/PDCurses/x11/pdckbd.c +0 -104
- data/vendor/PDCurses/x11/pdcscrn.c +0 -258
- data/vendor/PDCurses/x11/pdcsetsc.c +0 -95
- data/vendor/PDCurses/x11/pdcutil.c +0 -52
- data/vendor/PDCurses/x11/pdcx11.c +0 -316
- data/vendor/PDCurses/x11/pdcx11.h +0 -191
- data/vendor/PDCurses/x11/sb.c +0 -155
- data/vendor/PDCurses/x11/x11.c +0 -3686
- data/vendor/PDCurses/x11/xcurses-config.in +0 -81
@@ -1,717 +0,0 @@
|
|
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
|
-
}
|