From 96ec49213ff249633a02f2675a7b24c53a97da68 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 16 Nov 2018 19:32:00 -0500 Subject: [PATCH] Add some windows command line option hooks --- include/decl.h | 6 +++++- src/allmain.c | 15 +++++++++++++++ sys/share/pcmain.c | 7 +++++++ sys/winnt/winnt.c | 25 ++++++++++++++++++++++++- win/win32/mhmap.c | 1 + 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/include/decl.h b/include/decl.h index 53902a07f..992e86ad5 100644 --- a/include/decl.h +++ b/include/decl.h @@ -424,7 +424,11 @@ E struct plinemsg_type *plinemsg_types; E const char *ARGV0; #endif -enum earlyarg {ARG_DEBUG, ARG_VERSION}; +enum earlyarg {ARG_DEBUG, ARG_VERSION +#ifdef WIN32 + ,ARG_WINDOWS +#endif +}; struct early_opt { enum earlyarg e; diff --git a/src/allmain.c b/src/allmain.c index 9c76b2c00..9aa2f93c4 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -755,8 +755,15 @@ const char *msg; static struct early_opt earlyopts[] = { {ARG_DEBUG, "debug", 5, TRUE}, {ARG_VERSION, "version", 4, TRUE}, +#ifdef WIN32 + {ARG_WINDOWS, "windows", 4, TRUE}, +#endif }; +#ifdef WIN32 +extern int FDECL(windows_early_options, (const char *)); +#endif + /* * Returns: * 0 = no match @@ -826,6 +833,14 @@ enum earlyarg e_arg; early_version_info(insert_into_pastebuf); return 2; } +#ifdef WIN32 + case ARG_WINDOWS: { + if (extended_opt) { + extended_opt++; + return windows_early_options(extended_opt); + } + } +#endif default: break; } diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index cc60b3b3c..393dd0d8d 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -345,6 +345,13 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ argv++; } +#ifdef WIN32 + if (argcheck(argc, argv, ARG_WINDOWS) == 1) { + argc--; + argv++; + } +#endif + if (argc > 1 && !strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') { /* avoid matching "-dec" for DECgraphics; since the man page * says -d directory, hope nobody's using -desomething_else diff --git a/sys/winnt/winnt.c b/sys/winnt/winnt.c index e3aaf640e..5b0fd8bc8 100644 --- a/sys/winnt/winnt.c +++ b/sys/winnt/winnt.c @@ -37,9 +37,13 @@ * */ +/* runtime cursor display control switch */ +boolean win32_cursorblink; + /* globals required within here */ HANDLE ffhandle = (HANDLE) 0; WIN32_FIND_DATA ffd; + typedef HWND(WINAPI *GETCONSOLEWINDOW)(); static HWND GetConsoleHandle(void); static HWND GetConsoleHwnd(void); @@ -581,6 +585,25 @@ BOOL winos_font_support_cp437(HFONT hFont) return allFound; } +int +windows_early_options(window_opt) +const char *window_opt; +{ + /* + * If you return 2, the game will exit before it begins. + * Return 1, to say the option parsed okay. + * Return 0, to say the option was bad. + */ + + if (match_optname(window_opt, "cursorblink", 5, FALSE)) { + win32_cursorblink = TRUE; + return 1; + } else { + raw_printf( + "-%swindows:cursorblink is the only supported option.\n"); + } + return 0; +} #endif /* WIN32 */ -/*winnt.c*/ \ No newline at end of file +/*winnt.c*/ diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index a1690ef8e..233e02ed1 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -88,6 +88,7 @@ static void clearAll(PNHMapWindow data); #if (VERSION_MAJOR < 4) && (VERSION_MINOR < 4) && (PATCHLEVEL < 2) static void nhglyph2charcolor(short glyph, uchar *ch, int *color); #endif +extern boolean win32_cursorblink; /* from sys\winnt\winnt.c */ HWND mswin_init_map_window()