]> granicus.if.org Git - nethack/commitdiff
curses changes to existing files
authornhmall <nhmall@nethack.org>
Sat, 17 Nov 2018 01:51:22 +0000 (20:51 -0500)
committernhmall <nhmall@nethack.org>
Sat, 17 Nov 2018 01:51:22 +0000 (20:51 -0500)
18 files changed:
doc/window.doc
include/config.h
include/flag.h
include/ntconf.h
include/rm.h
include/winprocs.h
src/cmd.c
src/drawing.c
src/options.c
src/rip.c
src/windows.c
sys/share/pcmain.c
sys/unix/Makefile.src
sys/unix/hints/linux
sys/unix/hints/macosx10.10
sys/winnt/Makefile.msc
util/makedefs.c
win/tty/termcap.c

index a564d5b7bf2c09d734733b94fc41d35d494760a2..0b7cbf52f2e1335564a6ab789124ef3ba936129c 100644 (file)
@@ -774,6 +774,9 @@ to support:
   |  wraptext          | WC2_WRAPTEXT       | wc2_wraptext       |boolean |
   |  selectsaved       | WC2_SELECTSAVED    | wc2_selectsaved    |boolean |
   |  hitpointbar       | WC2_HITPOINTBAR    | wc2_hitpointbar    |boolean |
+  |  term_cols         | WC2_TERM_COLS      | wc2_term_cols      |int     |
+  |  term_rows         | WC2_TERM_ROWS      | wc2_term_rows      |int     |
+  |  windowborders     | WC2_WINDOWBORDERS  | wc2_windowborders  |int     |
   +--------------------+--------------------+--------------------+--------+
 
   more wincap2 for STATUS_HILITES support and control
@@ -820,6 +823,8 @@ scroll_margin       -- port should scroll the display when the hero or cursor
 selectsaved     -- if port can display a menu of the user's saved games do so.
 softkeyboard    -- handhelds should display an on-screen keyboard if possible.
 splash_screen   -- port should/should not display an opening splashscreen.
+term_cols       -- Terminal should size itself to specified width, if possible.
+term_rows       -- Terminal should size itself to specified height, if possible.
 tiled_map      -- port should display a tiled map if it can.
 tile_width     -- port should display tiles with this width or round to closest
                   if it can.
@@ -830,6 +835,8 @@ tile_file   -- open this alternative tile file. The file name is likely to be
 use_inverse    -- port should display inverse when NetHack asks for it.
 vary_msgcount  -- port should display this number of messages at a time in
                   the message window.
+windowborders   -- port should display borders around main NetHack windows.
+                Can be set to (1) on, (2) off, or (3) auto.
 windowcolors
                -- port should use these colors for window foreground/background
                   colors.  Syntax:
index ef6d0e534f99420307401ec584a2a7fcc467643c..4f242679aa7fb14bd28e586dcacd4fbdf74137ee 100644 (file)
@@ -45,6 +45,7 @@
 #if !defined(NOTTYGRAPHICS)
 #define TTY_GRAPHICS /* good old tty based graphics */
 #endif
+/* #define CURSES_GRAPHICS *//* Curses interface - Karl Garrison*/
 /* #define X11_GRAPHICS */   /* X11 interface */
 /* #define QT_GRAPHICS */    /* Qt interface */
 /* #define GNOME_GRAPHICS */ /* Gnome interface */
 #define DEFAULT_WINDOW_SYS "tty"
 #endif
 
+#ifdef CURSES_GRAPHICS
+#ifndef DEFAULT_WINDOW_SYS
+#define DEFAULT_WINDOW_SYS "curses"
+#endif
+#endif
+
 #ifdef X11_GRAPHICS
 /*
  * There are two ways that X11 tiles may be defined.  (1) using a custom
index b8c6a5993839f60b220524745dca76b5b804b9ed..b0be1a0f9f171e06ce6e77263350ac83a9e56702 100644 (file)
@@ -312,6 +312,7 @@ struct instance_flags {
     boolean rlecomp;          /* alternative to zerocomp; run-length encoding
                                * compression of levels when writing savefile */
     uchar num_pad_mode;
+    boolean cursesgraphics;     /* Use portable curses extended characters */
 #if 0   /* XXXgraphics superseded by symbol sets */
     boolean  DECgraphics;       /* use DEC VT-xxx extended character set */
     boolean  IBMgraphics;       /* use IBM extended character set */
@@ -323,6 +324,8 @@ struct instance_flags {
     uchar bouldersym; /* symbol for boulder display */
 #ifdef TTY_GRAPHICS
     char prevmsg_window; /* type of old message window to use */
+#endif
+#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
     boolean extmenu;     /* extended commands use menu interface */
 #endif
 #ifdef MFLOPPY
@@ -363,8 +366,12 @@ struct instance_flags {
 #ifdef TTY_TILES_ESCCODES
     boolean vt_tiledata;     /* output console codes for tile support in TTY */
 #endif
-    boolean wizweight;        /* display weight of everything in wizard mode */
-
+    boolean wizweight;       /* display weight of everything in wizard mode */
+    boolean cmdassist;       /* provide detailed assistance for some commands */
+    boolean clicklook;          /* allow right-clicking for look */
+    boolean msg_is_alert;    /* suggest windowport should grab player's attention
+                              * and request <TAB> acknowlegement */
+    int statuslines;         /* default = 2, code support for alternative 3 */
     /*
      * Window capability support.
      */
@@ -416,8 +423,11 @@ struct instance_flags {
     boolean wc2_selectsaved;    /* display a menu of user's saved games */
     boolean wc2_darkgray;    /* try to use dark-gray color for black glyphs */
     boolean wc2_hitpointbar;  /* show graphical bar representing hit points */
-    boolean cmdassist;     /* provide detailed assistance for some commands */
-    boolean clicklook;          /* allow right-clicking for look */
+    int wc2_term_cols;         /* terminal width, in characters */
+    int wc2_term_rows;         /* terminal height, in characters */
+    int wc2_windowborders;     /* display borders on NetHack windows */
+    int wc2_petattr;            /* text attributes for pet */
+    boolean wc2_guicolor;   /* allow colours in gui (outside map) */
     boolean obsolete;  /* obsolete options can point at this, it isn't used */
     struct autopickup_exception *autopickup_exceptions[2];
 #define AP_LEAVE 0
@@ -438,6 +448,7 @@ struct instance_flags {
     short soko_prize_type1;     /* bag of holding or    */
     short soko_prize_type2;     /* amulet of reflection */
     struct debug_flags debug;
+    boolean windowtype_locked;  /* windowtype can't change from configfile */
 };
 
 /*
index c0e2f77c0adea5e991fbacf0c0316bea723af3a7..73d421fd86314c84c1987c13f18c81616c1750b1 100644 (file)
@@ -93,6 +93,7 @@ extern void FDECL(interject, (int));
  * Compiler-specific adjustments
  *===============================================
  */
+
 #ifdef _MSC_VER
 #if (_MSC_VER > 1000)
 /* Visual C 8 warning elimination */
@@ -227,7 +228,9 @@ open(const char _FAR *__path, int __access, ... /*unsigned mode*/);
 long _RTLENTRY _EXPFUNC lseek(int __handle, long __offset, int __fromwhere);
 int _RTLENTRY _EXPFUNC read(int __handle, void _FAR *__buf, unsigned __len);
 #endif
-#include <conio.h>
+#ifndef CURSES_GRAPHICS
+#include <conio.h>      /* conflicting definitions with curses.h */
+#endif
 #undef kbhit /* Use our special NT kbhit */
 #define kbhit (*nt_kbhit)
 
index 7fd41c47cd8da90df432726c0514e5a6c3c837d9..1406e5723f6e0ba8366f4ff83df1974301415fb7 100644 (file)
@@ -108,7 +108,7 @@ enum levl_typ_types {
 /*
  * The screen symbols may be the default or defined at game startup time.
  * See drawing.c for defaults.
- * Note: {ibm|dec}_graphics[] arrays (also in drawing.c) must be kept in
+ * Note: {ibm|dec|curses}_graphics[] arrays (also in drawing.c) must be kept in
  * synch.
  */
 
@@ -294,9 +294,10 @@ struct symsetentry {
  * Must match the order of the known_handlers strings
  * in drawing.c
  */
-#define H_UNK 0
-#define H_IBM 1
-#define H_DEC 2
+#define H_UNK     0
+#define H_IBM     1
+#define H_DEC     2
+#define H_CURS    3
 
 extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
 extern const struct symdef def_warnsyms[WARNCOUNT];
index a0c490f11887f1d8d2351ba373f5efcf356a0a91..326f44eb2f61b9c8a4077a9d7ddef65a2e298f91 100644 (file)
@@ -216,7 +216,11 @@ extern
                                         after updating status window fields */
 #define WC2_RESET_STATUS  0x0100L /* 09 call status_update(BL_RESET) to indicate
                                         draw everything */
-                                  /* 23 free bits */
+#define WC2_TERM_SIZE     0x0100L /* 10 support setting terminal size   */
+#define WC2_WINDOWBORDERS 0x0200L /* 11 display borders on nh windows   */
+#define WC2_PETATTR       0x0400L /* 12 attributes for hilite_pet       */
+#define WC2_GUICOLOR      0x0800L /* 13 display colours outside map win */
+                                  /* 19 free bits */
 
 #define ALIGN_LEFT   1
 #define ALIGN_RIGHT  2
index b2debe3373654871be0de98bb20519119bb10ac1..8c830b9c3ce497adfebde5987a24d8e99729ca81 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -533,7 +533,7 @@ doextlist(VOID_ARGS)
     return 0;
 }
 
-#ifdef TTY_GRAPHICS
+#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
 #define MAX_EXT_CMD 200 /* Change if we ever have more ext cmds */
 
 /*
index 68fdebdadb76f4f79f29b7a372be806346a2b54d..5a73d4c3f0fdb842d9dfd6650ee250b89f8dc7d9 100644 (file)
@@ -264,6 +264,10 @@ void NDECL((*ibmgraphics_mode_callback)) = 0; /* set in tty_start_screen() */
 void NDECL((*ascgraphics_mode_callback)) = 0; /* set in tty_start_screen() */
 #endif
 
+#ifdef CURSES_GRAPHICS
+void NDECL((*cursesgraphics_mode_callback)) = 0;
+#endif
+
 /*
  * Convert the given character to an object class.  If the character is not
  * recognized, then MAXOCLASSES is returned.  Used in detect.c, invent.c,
@@ -495,6 +499,10 @@ int nondefault;
         if (SYMHANDLING(H_DEC) && decgraphics_mode_callback)
             (*decgraphics_mode_callback)();
 #endif
+# ifdef CURSES_GRAPHICS
+        if (SYMHANDLING(H_CURS) && cursesgraphics_mode_callback)
+            (*cursesgraphics_mode_callback)();         
+# endif
     } else
         init_symbols();
 }
@@ -544,9 +552,10 @@ boolean name_too;
  * to this array at the matching offset.
  */
 const char *known_handling[] = {
-    "UNKNOWN", /* H_UNK */
-    "IBM",     /* H_IBM */
-    "DEC",     /* H_DEC */
+    "UNKNOWN", /* H_UNK  */
+    "IBM",     /* H_IBM  */
+    "DEC",     /* H_DEC  */
+    "CURS",    /* H_CURS */
     (const char *) 0,
 };
 
index e337b4c36e6e0fe0e413e60ae448686eb9c9c008..21dc510a998f840420db233416c44bad9a41723b 100644 (file)
@@ -28,6 +28,10 @@ NEARDATA struct instance_flags iflags; /* provide linkage */
 #define PREFER_TILED FALSE
 #endif
 
+#ifdef CURSES_GRAPHICS
+extern int curses_read_attrs(char *attrs);
+#endif
+
 enum window_option_types {
     MESSAGE_OPTION = 1,
     STATUS_OPTION,
@@ -110,7 +114,7 @@ static struct Bool_Opt {
     { "confirm", &flags.confirm, TRUE, SET_IN_GAME },
     { "dark_room", &flags.dark_room, TRUE, SET_IN_GAME },
     { "eight_bit_tty", &iflags.wc_eight_bit_input, FALSE, SET_IN_GAME }, /*WC*/
-#ifdef TTY_GRAPHICS
+#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
     { "extmenu", &iflags.extmenu, FALSE, SET_IN_GAME },
 #else
     { "extmenu", (boolean *) 0, FALSE, SET_IN_FILE },
@@ -130,6 +134,7 @@ static struct Bool_Opt {
     { "force_invmenu", &iflags.force_invmenu, FALSE, SET_IN_GAME },
     { "fullscreen", &iflags.wc2_fullscreen, FALSE, SET_IN_FILE },
     { "goldX", &iflags.goldX, FALSE, SET_IN_GAME },
+    { "guicolor", &iflags.wc2_guicolor, TRUE, SET_IN_GAME},
     { "help", &flags.help, TRUE, SET_IN_GAME },
     { "herecmd_menu", &iflags.herecmd_menu, FALSE, SET_IN_GAME },
     { "hilite_pet", &iflags.wc_hilite_pet, FALSE, SET_IN_GAME }, /*WC*/
@@ -161,7 +166,11 @@ static struct Bool_Opt {
     { "menu_overlay", (boolean *) 0, FALSE, SET_IN_FILE },
 #endif
     { "monpolycontrol", &iflags.mon_polycontrol, FALSE, SET_IN_WIZGAME },
+#ifdef CURSES_GRAPHICS
+    { "mouse_support", &iflags.wc_mouse_support, FALSE, DISP_IN_GAME }, /*WC*/
+#else
     { "mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME }, /*WC*/
+#endif
 #ifdef NEWS
     { "news", &iflags.news, TRUE, DISP_IN_GAME },
 #else
@@ -326,7 +335,7 @@ static struct Comp_Opt {
     { "monsters", "the symbols to use for monsters", MAXMCLASSES,
       SET_IN_FILE },
     { "msghistory", "number of top line messages to save", 5, DISP_IN_GAME },
-#ifdef TTY_GRAPHICS
+#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS)
     { "msg_window", "the type of message window required", 1, SET_IN_GAME },
 #else
     { "msg_window", "the type of message window required", 1, SET_IN_FILE },
@@ -352,6 +361,7 @@ static struct Comp_Opt {
 #endif
     { "paranoid_confirmation", "extra prompting in certain situations", 28,
       SET_IN_GAME },
+    { "petattr",  "attributes for highlighting pets", 12, SET_IN_FILE },
     { "pettype", "your preferred initial pet type", 4, DISP_IN_GAME },
     { "pickup_burden", "maximum burden picked up before prompt", 20,
       SET_IN_GAME },
@@ -386,6 +396,13 @@ static struct Comp_Opt {
       20, SET_IN_GAME },
 #else
     { "statushilites", "highlight control", 20, SET_IN_FILE },
+#endif
+#ifdef CURSES_GRAPHICS
+    { "statuslines",
+      "0,1,2 = classic behavior, 3 = alternative behavior",
+      20, DISP_IN_GAME },
+#else
+    { "statuslines", "# of status lines", 20, SET_IN_FILE },
 #endif
     { "symset", "load a set of display symbols from the symbols file", 70,
       SET_IN_GAME },
@@ -427,6 +444,9 @@ static struct Comp_Opt {
 #ifdef BACKWARD_COMPAT
     { "DECgraphics", "load DECGraphics display symbols", 70, SET_IN_FILE },
     { "IBMgraphics", "load IBMGraphics display symbols", 70, SET_IN_FILE },
+#ifdef CURSES_GRAPHICS
+    {"cursesgraphics", "load curses display symbols", 70, SET_IN_FILE},
+#endif
 #ifdef MAC_GRAPHICS_ENV
     { "Macgraphics", "load MACGraphics display symbols", 70, SET_IN_FILE },
 #endif
@@ -3462,6 +3482,8 @@ boolean tinitial, tfrom_file;
      */
     fullname = "windowtype";
     if (match_optname(opts, fullname, 3, TRUE)) {
+        if (iflags.windowtype_locked)
+            return retval;
         if (duplicate)
             complain_about_duplicate(opts, 1);
         if (negated) {
@@ -3509,6 +3531,74 @@ boolean tinitial, tfrom_file;
             bad_negation(fullname, TRUE);
         return retval;
     }
+#ifdef CURSES_GRAPHICS
+    /* WINCAP2
+     * term_cols:amount */
+    fullname = "term_cols";
+    if (match_optname(opts, fullname, sizeof("term_cols")-1, TRUE)) {
+        op = string_for_opt(opts, negated);
+        iflags.wc2_term_cols = atoi(op);
+        if (negated)
+           bad_negation(fullname, FALSE);
+        return retval;
+    }
+
+    /* WINCAP2
+     * term_rows:amount */
+    fullname = "term_rows";
+    if (match_optname(opts, fullname, sizeof("term_rows")-1, TRUE)) {
+        op = string_for_opt(opts, negated);
+        iflags.wc2_term_rows = atoi(op);
+        if (negated)
+            bad_negation(fullname, FALSE);
+        return retval;
+    }
+
+    /* WINCAP2
+     * petattr:string */
+    fullname = "petattr";
+    if (match_optname(opts, fullname, sizeof("petattr")-1, TRUE)) {
+        op = string_for_opt(opts, negated);
+        if (op && !negated) {
+#ifdef CURSES_GRAPHICS
+            iflags.wc2_petattr = curses_read_attrs(op);
+            if (!curses_read_attrs(op))
+                config_error_add("Unknown %s parameter '%s'", fullname, opts);
+                return FALSE;
+#else
+            /* non-curses windowports will not use this flag anyway
+             * but the above will not compile if we don't have curses.
+             * Just set it to a sensible default: */
+            iflags.wc2_petattr = ATR_INVERSE
+#endif
+        } else if (negated) bad_negation(fullname, TRUE);
+        return retval;
+    }
+
+    /* WINCAP2
+     * windowborders:n */
+    fullname = "windowborders";
+    if (match_optname(opts, fullname, sizeof("windowborders")-1, TRUE)) {
+        op = string_for_opt(opts, negated);
+        if (negated && op)
+            bad_negation(fullname, TRUE);
+        else {
+            if (negated)
+                iflags.wc2_windowborders = 2; /* Off */
+            else if (!op)
+                iflags.wc2_windowborders = 1; /* On */
+            else    /* Value supplied */
+                iflags.wc2_windowborders = atoi(op);
+            if ((iflags.wc2_windowborders > 3)
+                 || (iflags.wc2_windowborders < 1)) {
+                    iflags.wc2_windowborders = 0;
+                    config_error_add(
+                        "Badoption - windowborders %s.", opts);
+            }
+        }
+        return retval;
+    }
+#endif
 
     /* menustyle:traditional or combination or full or partial */
     fullname = "menustyle";
@@ -3852,6 +3942,10 @@ boolean tinitial, tfrom_file;
                 status_initialize(REASSESS_ONLY);
                 need_redraw = TRUE;
 #endif
+#ifdef CURSES_GRAPHICS
+            } else if ((boolopt[i].addr) == &iflags.cursesgraphics) {
+                need_redraw = TRUE;
+#endif
 #ifdef TEXTCOLOR
             } else if (boolopt[i].addr == &iflags.use_color) {
                 need_redraw = TRUE;
@@ -5514,6 +5608,18 @@ char *buf;
                 symset[PRIMARY].name ? symset[PRIMARY].name : "default");
         if (currentgraphics == PRIMARY && symset[PRIMARY].name)
             Strcat(buf, ", active");
+#ifdef CURSES_GRAPHICS
+    } else if (!strcmp(optname, "term_cols")) {
+        if (iflags.wc2_term_cols)
+            Sprintf(buf, "%d", iflags.wc2_term_cols);
+        else
+            Strcpy(buf, defopt);
+    } else if (!strcmp(optname, "term_rows")) {
+        if (iflags.wc2_term_rows)
+            Sprintf(buf, "%d",iflags.wc2_term_rows);
+        else
+            Strcpy(buf, defopt);
+#endif
     } else if (!strcmp(optname, "tile_file")) {
         Sprintf(buf, "%s",
                 iflags.wc_tile_file ? iflags.wc_tile_file : defopt);
@@ -5550,6 +5656,13 @@ char *buf;
                 ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
                 ttycolors[CLR_BRIGHT_MAGENTA], ttycolors[CLR_BRIGHT_CYAN]);
 #endif /* VIDEOSHADES */
+#ifdef CURSES_GRAPHICS
+    } else if (!strcmp(optname,"windowborders")) {
+        Sprintf(buf, "%s",
+                iflags.wc2_windowborders == 1 ? "1=on" :
+                iflags.wc2_windowborders == 2 ? "2=off" :
+                iflags.wc2_windowborders == 3 ? "3=auto" : defopt);
+#endif
     } else if (!strcmp(optname, "windowtype")) {
         Sprintf(buf, "%s", windowprocs.name);
     } else if (!strcmp(optname, "windowcolors")) {
@@ -6217,6 +6330,9 @@ static struct wc_Opt wc2_options[] = {
     { "status hilite rules", WC2_HILITE_STATUS },
     /* statushilites doesn't have its own bit */
     { "statushilites", WC2_HILITE_STATUS },
+#ifdef CURSES_GRAPHICS
+    {"windowborders", WC2_WINDOWBORDERS},
+#endif
     { (char *) 0, 0L }
 };
 
index 6e48dde45126c90e6316e83e4cca847640204b9a..f6fba01bc1be8bb63f807def6502ded7049d299f 100644 (file)
--- a/src/rip.c
+++ b/src/rip.c
@@ -6,7 +6,7 @@
 #include "hack.h"
 
 #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) \
-    || defined(MSWIN_GRAPHICS) || defined(DUMPLOG)
+    || defined(MSWIN_GRAPHICS) || defined(DUMPLOG) || defined(CURSES_GRAPHICS)
 #define TEXT_TOMBSTONE
 #endif
 #if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
index 3a94712243f752e8a7b561ca6d919448a0a805ed..9e7ffe5b399b3c418de4c0354527c42c54a56987 100644 (file)
@@ -6,6 +6,9 @@
 #ifdef TTY_GRAPHICS
 #include "wintty.h"
 #endif
+#ifdef CURSES_GRAPHICS
+extern struct window_procs curses_procs;
+#endif
 #ifdef X11_GRAPHICS
 /* Cannot just blindly include winX.h without including all of X11 stuff
    and must get the order of include files right.  Don't bother. */
@@ -92,6 +95,9 @@ static struct win_choices {
 #ifdef TTY_GRAPHICS
     { &tty_procs, win_tty_init CHAINR(0) },
 #endif
+#ifdef CURSES_GRAPHICS
+    { &curses_procs, 0 },
+#endif
 #ifdef X11_GRAPHICS
     { &X11_procs, win_X11_init CHAINR(0) },
 #endif
index 393dd0d8df24024834e0fdbf5d3079bf7faa9824..93674ab341dd2e7c191d0a6fb607bd061db87390 100644 (file)
@@ -98,8 +98,12 @@ char *argv[];
     nethack_enter(argc, argv);
 
     sys_early_init();
-#ifdef WIN32
+#if defined(WIN32) && defined(TTY_GRAPHICS)
     Strcpy(default_window_sys, "tty");
+#else
+#if defined(CURSES_GRAPHICS)
+    Strcpy(default_window_sys, "curses");    
+#endif
 #endif
 
     resuming = pcmain(argc, argv);
@@ -173,6 +177,10 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
     choose_windows(DEFAULT_WINDOW_SYS);
 #else
     choose_windows(default_window_sys);
+    if (argc > 1
+        && !strcmpi(default_window_sys, "mswin")
+        && strstri(argv[0], "nethackw.exe"))
+        iflags.windowtype_locked = TRUE;
 #endif
 
 #if !defined(AMIGA) && !defined(GNUDOS)
@@ -500,9 +508,9 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
     } else {
         iflags.use_background_glyph = TRUE;
     }
-#endif
-#endif
-#endif
+#endif /* TTY_GRAPHICS */
+#endif /* WIN32 */
+#endif /* MSDOS || WIN32 */
 
 #if defined(MSDOS) || defined(WIN32)
     init_nhwindows(&argc, argv);
index 4fac84eecb080320cac6f955fdec1a76d308139c..bfe32f285f378156b175890e734cd2a1b693f3e9 100644 (file)
@@ -146,6 +146,15 @@ SYSOBJ = ioctl.o unixmain.o unixtty.o unixunix.o unixres.o
 #LINK = gcc
 #LFLAGS = -Xlinker -soname=_APP_
 
+# Compile with PDCurses installed in a separate directory that doesn't
+# conflict with the system curses/ncurses library
+#CFLAGS = -O -I../include -I/usr/local/include/pdcurses
+# Same as above, but for XCurses
+#CFLAGS = -O -DXCURSES -I../include -I/usr/local/include/pdcurses
+# Compile against system curses library, such as ncurses
+#CFLAGS = -O -I../include
+
+
 # Only used for the Gnome interface.
 # When including the Gnome interface, you need to include gnome specific
 # directories.  The ones given below is the usual spot for linux systems.
@@ -190,6 +199,14 @@ WINTTYSRC = ../win/tty/getline.c ../win/tty/termcap.c ../win/tty/topl.c \
        ../win/tty/wintty.c
 WINTTYOBJ = getline.o termcap.o topl.o wintty.o
 #
+# Files for curses interface
+WINCURSESSRC = ../win/curses/cursmain.c ../win/curses/curswins.c \
+       ../win/curses/cursmisc.c ../win/curses/cursdial.c \
+       ../win/curses/cursstat.c ../win/curses/cursinit.c \
+       ../win/curses/cursmesg.c ../win/curses/cursinvt.c
+WINCURSESOBJ = cursmain.o curswins.o cursmisc.o cursdial.o cursstat.o \
+       cursinit.o cursmesg.o cursinvt.o
+#
 # files for an X11 port
 # (tile.c is a generated source file)
 WINX11SRC = ../win/X11/Window.c ../win/X11/dialogs.c ../win/X11/winX.c \
@@ -243,12 +260,15 @@ WINBEOBJ =
 #WINBESRC = ../win/BeOS/winbe.cpp ../win/BeOS/NHWindow.cpp \
 #      ../win/BeOS/NHMenuWindow.cpp ../win/BeOS/NHMapWindow.cpp tile.c
 #WINBEOBJ = winbe.o NHWindow.o NHMenuWindow.o NHMapWindow.o tile.o
-
 #
 #
 #WINSRC = $(WINTTYSRC)
 #WINOBJ = $(WINTTYOBJ)
-
+#
+# Curses - Karl Garrison, Tangles
+#WINSRC = $(WINCURSESSRC)
+#WINOBJ = $(WINCURSESOBJ)
+#
 # on some systems the termcap library is in -ltermcap or -lcurses
 # on 386 Xenix, the -ltermlib tputs() seems not to work; use -lcurses instead
 # Sysatt uses shared library in lieu of this option
@@ -272,6 +292,7 @@ WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
 # WINX11LIB = -lXaw -lXmu -lXext -lXt -lXpm -lX11 -lm
 # WINX11LIB = -lXaw -lXmu -lXpm -lXext -lXt -lX11 -lSM -lICE -lm # BSD/OS 2.0
 #
+#
 # libraries for Qt 3
 WINQTLIB = -L$(QTDIR)/lib -lqt
 #
@@ -292,9 +313,20 @@ WINGEMLIB = -le_gem -lgem
 #
 # libraries for BeOS 
 WINBELIB = -lbe
-
+#
+# libraries for curses port
+# link with ncurses
+WINCURSESLIB = -lncurses
+# link with pdcurses for SDL, installed in a separate directory
+#WINCURSESLIB = -L/usr/local/lib/pdcurses -lpdcurses -lSDL
+# same as above, for XCurses
+#WINCURSESLIB = -L/usr/local/lib/pdcurses -lXCurses -lXawM -lXmu -lXext -lXt -lX11
+#
 #WINLIB = $(WINTTYLIB)
-
+#
+# For Curses
+#WINLIB = $(WINCURSESLIB)
+#
 # any other strange libraries your system needs (for Sysunix only -- the more
 # specialized targets should already be right)
 #
@@ -743,6 +775,29 @@ topl.o: ../win/tty/topl.c $(HACK_H) ../include/tcap.h
        $(CC) $(CFLAGS) -c ../win/tty/topl.c
 wintty.o: ../win/tty/wintty.c $(HACK_H) ../include/dlb.h ../include/tcap.h
        $(CC) $(CFLAGS) -c ../win/tty/wintty.c
+cursmain.o: ../win/curses/cursmain.c $(HACK_H) ../include/wincurs.h
+       $(CC) $(CFLAGS) -c ../win/curses/cursmain.c
+curswins.o: ../win/curses/curswins.c $(HACK_H) ../include/func_tab.h \
+               ../include/wincurs.h ../win/curses/curswins.h
+       $(CC) $(CFLAGS) -c ../win/curses/curswins.c
+cursmisc.o: ../win/curses/cursmisc.c $(HACK_H) ../include/wincurs.h \
+               ../win/curses/cursmisc.h
+       $(CC) $(CFLAGS) -c ../win/curses/cursmisc.c
+cursdial.o: ../win/curses/cursdial.c $(HACK_H) ../include/func_tab.h \
+               ../include/wincurs.h ../win/curses/cursdial.h
+       $(CC) $(CFLAGS) -c ../win/curses/cursdial.c
+cursstat.o: ../win/curses/cursstat.c $(HACK_H) ../include/wincurs.h \
+               ../win/curses/cursstat.h
+       $(CC) $(CFLAGS) -c ../win/curses/cursstat.c
+cursinit.o: ../win/curses/cursinit.c $(HACK_H) ../include/wincurs.h \
+               ../win/curses/cursinit.h
+       $(CC) $(CFLAGS) -c ../win/curses/cursinit.c
+cursinvt.o: ../win/curses/cursinvt.c $(HACK_H) ../include/wincurs.h \
+               ../win/curses/cursinvt.h
+       $(CC) $(CFLAGS) -c ../win/curses/cursinvt.c
+cursmesg.o: ../win/curses/cursmesg.c $(HACK_H) ../include/wincurs.h \
+               ../win/curses/cursmesg.h
+       $(CC) $(CFLAGS) -c ../win/curses/cursmesg.c
 Window.o: ../win/X11/Window.c ../include/xwindowp.h ../include/xwindow.h \
                $(CONFIG_H) ../include/lint.h
        $(CC) $(CFLAGS) -c ../win/X11/Window.c
index 4dc6b2f536bb6e166121e03f4a782c199537ac7e..cb03179462e8daf7772ca4bb97d0caaf85cadc82 100644 (file)
@@ -27,14 +27,15 @@ CFLAGS+=-DTIMED_DELAY
 CFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
 CFLAGS+=-DDUMPLOG
 CFLAGS+=-DCONFIG_ERROR_SECURE=FALSE
+CFLAGS+=-DCURSES_GRAPHICS
 
 LINK=$(CC)
 # Only needed for GLIBC stack trace:
 LFLAGS=-rdynamic
 
-WINSRC = $(WINTTYSRC)
-WINOBJ = $(WINTTYOBJ)
-WINLIB = $(WINTTYLIB)
+WINSRC = $(WINTTYSRC) $(WINCURSESSRC)
+WINOBJ = $(WINTTYOBJ) $(WINCURSESOBJ)
+WINLIB = $(WINTTYLIB) $(WINCURSESLIB)
 
 WINTTYLIB=-lcurses
 
index f320e25fbed1376fa06d72a7cf818f87e1a56848..a08b27acc5be387e3fcce8dd12e766641c26cd03 100644 (file)
 WANT_WIN_TTY=1
 #WANT_WIN_X11=1
 #WANT_WIN_QT=1
+#WANT_WIN_CURSES=1
 
 # 1a. What is the default window system?
 WANT_DEFAULT=tty
 #WANT_DEFAULT=x11
 #WANT_DEFAULT=qt
+#WANT_DEFAULT=curses
 
 # 1b. If you set WANT_WIN_QT, you need to
 #  A) set QTDIR either here or in the environment to point to the Qt2 or Qt3
@@ -96,6 +98,13 @@ else # !WANT_WIN_TTY
 CFLAGS += -DNOTTYGRAPHICS
 endif  # !WANT_WIN_TTY
 
+ifdef WANT_WIN_CURSES
+CFLAGS += -DCURSES_GRAPHICS
+WINSRC += $(WINCURSESSRC)
+WINOBJ += $(WINCURSESOBJ)
+WINLIB += -lncurses
+endif
+
 ifdef WANT_WIN_X11
 WINSRC += $(WINX11SRC)
 WINOBJ += $(WINX11OBJ)
index f86a67acc58ffa529987484d66849e4c23f8d45a..7f908c6377e299b102821ed6a1211406d10d05cb 100644 (file)
@@ -61,6 +61,19 @@ DEBUGINFO = Y
 #TARGET_CPU=x64
 #TARGET_CPU=x86
 
+#---------------------------------------------------------------
+# OPTIONAL - Curses window port support 
+#
+# 4. Uncomment these and set them appropriate if you want to
+#    include curses port support alongside TTY support in your
+#    console binary. You'll have to set CURSESINCL to the location
+#    of your curses header (.h) files and CURSESDLL to the location
+#    of your pdcurses.dll.
+#
+ADD_CURSES=Y
+CURSESINCL=..\..\pdcurses
+CURSESLIB=..\..\pdcurses\wincon\pdcurses.lib
+#
 #==============================================================================
 # This marks the end of the BUILD DECISIONS section.
 #==============================================================================
@@ -85,16 +98,17 @@ DEBUGINFO = Y
 #  Source directories.    Makedefs hardcodes these, don't change them.
 #
 
-INCL  = ..\include   # NetHack include files
-DAT   = ..\dat       # NetHack data files
-DOC   = ..\doc       # NetHack documentation files
-UTIL  = ..\util      # Utility source
-SRC   = ..\src       # Main source
-SSYS  = ..\sys\share # Shared system files
-MSWSYS= ..\sys\winnt # mswin specific files
-TTY   = ..\win\tty   # window port files (tty)
-MSWIN = ..\win\win32 # window port files (WIN32)
-WSHR  = ..\win\share # Tile support files 
+INCL   = ..\include    # NetHack include files
+DAT    = ..\dat        # NetHack data files
+DOC    = ..\doc        # NetHack documentation files
+UTIL   = ..\util       # Utility source
+SRC    = ..\src        # Main source
+SSYS   = ..\sys\share  # Shared system files
+MSWSYS = ..\sys\winnt  # mswin specific files
+TTY    = ..\win\tty    # window port files (tty)
+MSWIN  = ..\win\win32  # window port files (win32)
+CURSES = ..\win\curses # window port files (curses) 
+WSHR   = ..\win\share  # Tile support files 
 
 #
 #  Object directory.
@@ -203,6 +217,15 @@ VSVER=2999              #untested future version
 
 #----------------------------------------------------------------
 
+!IF "$(ADD_CURSES)" == "Y"
+#CURSESDEF=-D"PDC_DLL_BUILD" -D"CURSES_GRAPHICS" -D"CURSES_BRIEF_INCLUDE"
+CURSESDEF=-D"CURSES_GRAPHICS" -D"CURSES_BRIEF_INCLUDE"
+!ELSE
+CURSDEF=
+CURSESLIB=
+CURSESINCL=
+!ENDIF
+
 #These will be in the environment variables with one of the VS2017
 #developer command prompts.
 #VSCMD_ARG_HOST_ARCH=x64
@@ -234,7 +257,8 @@ CL_RECENT=-sdl
 
 ccommon= -c -nologo -D"_CONSOLE" -D"_CRT_NONSTDC_NO_DEPRECATE" -D"_CRT_SECURE_NO_DEPRECATE" \
        -D"_LIB" -D"_SCL_SECURE_NO_DEPRECATE" -D"_VC80_UPGRADE=0x0600" -D"DLB" -D"_MBCS" \
-       -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -D"NDEBUG" -D"YY_NO_UNISTD_H" -EHsc -fp:precise -Gd -GF -GS -Gy \
+       -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -D"NDEBUG" -D"YY_NO_UNISTD_H" $(CURSESDEF) \
+       -EHsc -fp:precise -Gd -GF -GS -Gy \
        $(CL_RECENT) -WX- -Zc:forScope -Zc:wchar_t -Zi
 cdebug= -analyze- -D"_DEBUG" -Gm -MTd -RTC1 -Od
 crelease= -analyze- -D"_MBCS" -errorReport:prompt -Gm- -MT -O2 -Ot -Ox -Oy
@@ -300,7 +324,12 @@ conlibs     = $(baselibs)
 guilibs     = $(winlibs)
 #
 
+!IFNDEF ADD_CURSES
 INCLDIR= /I..\include /I..\sys\winnt
+!ELSE
+INCLDIR= /I..\include /I..\sys\winnt /I$(CURSESINCL)
+!ENDIF
+  
 
 #==========================================
 # Util builds
@@ -313,7 +342,7 @@ lflagsBuild = $(lflags) $(conlibs) $(MACHINE)
 # - Game build
 #==========================================
 
-LIBS= user32.lib winmm.lib $(ZLIB)
+LIBS= user32.lib winmm.lib $(ZLIB) $(CURSESLIB)
 
 ! IF ("$(USE_DLB)"=="Y")
 DLB = nhdat
@@ -406,6 +435,13 @@ REGEX  = $(O)cppregex.o
 
 TTYOBJ = $(O)topl.o     $(O)getline.o  $(O)wintty.o
 
+!IFNDEF ADD_CURSES
+CURSESOBJ=
+!ELSE
+CURSESOBJ= $(O)cursdial.o $(O)cursinit.o $(O)cursinvt.o $(O)cursmain.o \
+          $(O)cursmesg.o $(O)cursmisc.o $(O)cursstat.o $(O)curswins.o
+!ENDIF
+
 SOBJ   = $(O)winnt.o    $(O)pcsys.o      $(O)pcunix.o  \
           $(SOUND)     $(O)nhlan.o
 
@@ -414,7 +450,8 @@ OBJS   = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
          $(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \
          $(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \
          $(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \
-         $(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(REGEX)
+         $(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(REGEX)  \
+         $(CURSESOBJ)
 
 GUIOBJ = $(O)mhaskyn.o $(O)mhdlg.o \
        $(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \
@@ -524,6 +561,19 @@ DATABASE = $(DAT)\data.base
 {$(UTIL)}.c{$(OBJ)}.o:
        @$(cc) $(cflagsBuild) -Fo$@ $<
 
+#==========================================
+# Rules for files in win\curses
+#==========================================
+
+{$(CURSES)}.c{$(OBJ)}.o:
+       @$(cc) $(cflagsBuild)  -Fo$@ $<
+
+{$(CURSES)}.h{$(INCL)}.h:
+       @copy $< $@
+
+#{$(CURSES)}.txt{$(DAT)}.txt:
+#      @copy $< $@
+
 #==========================================
 # Rules for files in win\share
 #==========================================
@@ -592,7 +642,7 @@ $(O)install.tag:    $(DAT)\data     $(DAT)\rumors    $(DAT)\dungeon \
        if exist $(DOC)\nethack.txt copy $(DOC)\nethack.txt $(GAMEDIR)\NetHack.txt
        @if exist $(GAMEDIR)\NetHack.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHack.PDB to conserve space
        @if exist $(GAMEDIR)\NetHackW.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHackW.PDB to conserve space
-       -copy $(MSWSYS)\defaults.nh   $(GAMEDIR)\defaults.nh
+       -if not exist $(GAMEDIR)\defaults.nh copy $(MSWSYS)\defaults.nh   $(GAMEDIR)\defaults.nh
        -if not exist $(GAMEDIR)\record. goto>$(GAMEDIR)\record.
        echo install done > $@
 
@@ -987,6 +1037,12 @@ $(O)envchk.tag: $(O)obj.tag
 !      ELSE
        @echo Windows x86 32-bit target build
 !      ENDIF
+!IFDEF TTYOBJ
+       @echo tty window support included
+! IF "$(ADD_CURSES)"=="Y"
+       @echo curses window support also included
+! ENDIF
+!ENDIF
 !      IF "$(CL)"!=""
 #         @echo Warning, the CL Environment variable is defined:
 #         @echo CL=$(CL)
index c41471b2ce5701bbb5b7a5315fe5637f5ffb3a0a..39816cb1238bd2b480755d92253d010fd01b8fd4 100644 (file)
@@ -1650,6 +1650,9 @@ static struct win_info window_opts[] = {
 #ifdef TTY_GRAPHICS
     { "tty", "traditional tty-based graphics" },
 #endif
+#ifdef CURSES_GRAPHICS
+    { "curses", "terminal-based graphics using curses libraries" },
+#endif
 #ifdef X11_GRAPHICS
     { "X11", "X11" },
 #endif
index 5f344f04b144cb53f816809c198273e7a67a3a6b..c373df04c5ee85ba19a25c39dcdd7cfa705c34b9 100644 (file)
@@ -1271,6 +1271,13 @@ int color;
     if (windowprocs.name != NULL && !strcmpi(windowprocs.name, "Qt"))
         return 1;
 #endif
+#ifdef CURSES_GRAPHICS
+    /* XXX has_color() should be added to windowprocs */
+    /* iflags.wc_color is set to false and the option disabled if the
+     terminal cannot display color */
+    if (windowprocs.name != NULL && !strcmpi(windowprocs.name, "curses"))
+        return iflags.wc_color;
+#endif
 #ifdef AMII_GRAPHICS
     /* hilites[] not used */
     return iflags.use_color ? 1 : 0;