wintty.h

Go to the documentation of this file.
00001 /*      SCCS Id: @(#)wintty.h   3.4     1996/02/18      */
00002 /* Copyright (c) David Cohrs, 1991,1992                           */
00003 /* NetHack may be freely redistributed.  See license for details. */
00004 
00005 #ifndef WINTTY_H
00006 #define WINTTY_H
00007 
00008 #define E extern
00009 
00010 #ifndef WINDOW_STRUCTS
00011 #define WINDOW_STRUCTS
00012 
00013 /* menu structure */
00014 typedef struct tty_mi {
00015     struct tty_mi *next;
00016     anything identifier;        /* user identifier */
00017     long count;                 /* user count */
00018     char *str;                  /* description string (including accelerator) */
00019     int attr;                   /* string attribute */
00020     boolean selected;           /* TRUE if selected by user */
00021     char selector;              /* keyboard accelerator */
00022     char gselector;             /* group accelerator */
00023 } tty_menu_item;
00024 
00025 /* descriptor for tty-based windows */
00026 struct WinDesc {
00027     int flags;                  /* window flags */
00028     xchar type;                 /* type of window */
00029     boolean active;             /* true if window is active */
00030     uchar offx, offy;           /* offset from topleft of display */
00031     short rows, cols;           /* dimensions */
00032     short curx, cury;           /* current cursor position */
00033     short maxrow, maxcol;       /* the maximum size used -- for MENU wins */
00034                                 /* maxcol is also used by WIN_MESSAGE for */
00035                                 /* tracking the ^P command */
00036     short *datlen;              /* allocation size for *data */
00037     char **data;                /* window data [row][column] */
00038     char *morestr;              /* string to display instead of default */
00039     tty_menu_item *mlist;       /* menu information (MENU) */
00040     tty_menu_item **plist;      /* menu page pointers (MENU) */
00041     short plist_size;           /* size of allocated plist (MENU) */
00042     short npages;               /* number of pages in menu (MENU) */
00043     short nitems;               /* total number of items (MENU) */
00044     short how;                  /* menu mode - pick 1 or N (MENU) */
00045     char menu_ch;               /* menu char (MENU) */
00046 };
00047 
00048 /* window flags */
00049 #define WIN_CANCELLED 1
00050 #define WIN_STOP 1              /* for NHW_MESSAGE; stops output */
00051 
00052 /* descriptor for tty-based displays -- all the per-display data */
00053 struct DisplayDesc {
00054     uchar rows, cols;           /* width and height of tty display */
00055     uchar curx, cury;           /* current cursor position on the screen */
00056 #ifdef TEXTCOLOR
00057     int color;                  /* current color */
00058 #endif
00059     int attrs;                  /* attributes in effect */
00060     int toplin;                 /* flag for topl stuff */
00061     int rawprint;               /* number of raw_printed lines since synch */
00062     int inmore;                 /* non-zero if more() is active */
00063     int inread;                 /* non-zero if reading a character */
00064     int intr;                   /* non-zero if inread was interrupted */
00065     winid lastwin;              /* last window used for I/O */
00066     char dismiss_more;          /* extra character accepted at --More-- */
00067 };
00068 
00069 #endif /* WINDOW_STRUCTS */
00070 
00071 #define MAXWIN 20               /* maximum number of windows, cop-out */
00072 
00073 /* tty dependent window types */
00074 #ifdef NHW_BASE
00075 #undef NHW_BASE
00076 #endif
00077 #define NHW_BASE    6
00078 
00079 extern struct window_procs tty_procs;
00080 
00081 /* port specific variable declarations */
00082 extern winid BASE_WINDOW;
00083 
00084 extern struct WinDesc *wins[MAXWIN];
00085 
00086 extern struct DisplayDesc *ttyDisplay;  /* the tty display descriptor */
00087 
00088 extern char morc;               /* last character typed to xwaitforspace */
00089 extern char defmorestr[];       /* default --more-- prompt */
00090 
00091 /* port specific external function references */
00092 
00093 /* ### getline.c ### */
00094 E void FDECL(xwaitforspace, (const char *));
00095 
00096 /* ### termcap.c, video.c ### */
00097 
00098 E void FDECL(tty_startup,(int*, int*));
00099 #ifndef NO_TERMS
00100 E void NDECL(tty_shutdown);
00101 #endif
00102 #if defined(apollo)
00103 /* Apollos don't widen old-style function definitions properly -- they try to
00104  * be smart and use the prototype, or some such strangeness.  So we have to
00105  * define UNWIDENDED_PROTOTYPES (in tradstdc.h), which makes CHAR_P below a
00106  * char.  But the tputs termcap call was compiled as if xputc's argument
00107  * actually would be expanded.  So here, we have to make an exception. */
00108 E void FDECL(xputc, (int));
00109 #else
00110 E void FDECL(xputc, (CHAR_P));
00111 #endif
00112 E void FDECL(xputs, (const char *));
00113 #if defined(SCREEN_VGA) || defined(SCREEN_8514)
00114 E void FDECL(xputg, (int, int, unsigned));
00115 #endif
00116 E void NDECL(cl_end);
00117 E void NDECL(clear_screen);
00118 E void NDECL(home);
00119 E void NDECL(standoutbeg);
00120 E void NDECL(standoutend);
00121 # if 0
00122 E void NDECL(revbeg);
00123 E void NDECL(boldbeg);
00124 E void NDECL(blinkbeg);
00125 E void NDECL(dimbeg);
00126 E void NDECL(m_end);
00127 # endif
00128 E void NDECL(backsp);
00129 E void NDECL(graph_on);
00130 E void NDECL(graph_off);
00131 E void NDECL(cl_eos);
00132 
00133 /*
00134  * termcap.c (or facsimiles in other ports) is the right place for doing
00135  * strange and arcane things such as outputting escape sequences to select
00136  * a color or whatever.  wintty.c should concern itself with WHERE to put
00137  * stuff in a window.
00138  */
00139 E void FDECL(term_start_attr,(int attr));
00140 E void FDECL(term_end_attr,(int attr));
00141 E void NDECL(term_start_raw_bold);
00142 E void NDECL(term_end_raw_bold);
00143 
00144 #ifdef TEXTCOLOR
00145 E void NDECL(term_end_color);
00146 E void FDECL(term_start_color,(int color));
00147 E int FDECL(has_color,(int color));
00148 #endif /* TEXTCOLOR */
00149 
00150 #ifdef STATUS_COLORS
00151 E boolean FDECL(parse_status_color_options, (char *));
00152 #endif /* STATUS_COLOR */
00153 
00154 /* ### topl.c ### */
00155 
00156 E void FDECL(addtopl, (const char *));
00157 E void NDECL(more);
00158 E void FDECL(update_topl, (const char *));
00159 E void FDECL(putsyms, (const char*));
00160 
00161 /* ### wintty.c ### */
00162 #ifdef CLIPPING
00163 E void NDECL(setclipped);
00164 #endif
00165 E void FDECL(docorner, (int, int));
00166 E void NDECL(end_glyphout);
00167 E void FDECL(g_putch, (int));
00168 E void NDECL(win_tty_init);
00169 
00170 /* external declarations */
00171 E void FDECL(tty_init_nhwindows, (int *, char **));
00172 E void NDECL(tty_player_selection);
00173 E void NDECL(tty_askname);
00174 E void NDECL(tty_get_nh_event) ;
00175 E void FDECL(tty_exit_nhwindows, (const char *));
00176 E void FDECL(tty_suspend_nhwindows, (const char *));
00177 E void NDECL(tty_resume_nhwindows);
00178 E winid FDECL(tty_create_nhwindow, (int));
00179 E void FDECL(tty_clear_nhwindow, (winid));
00180 E void FDECL(tty_display_nhwindow, (winid, BOOLEAN_P));
00181 E void FDECL(tty_dismiss_nhwindow, (winid));
00182 E void FDECL(tty_destroy_nhwindow, (winid));
00183 E void FDECL(tty_curs, (winid,int,int));
00184 E void FDECL(tty_putstr, (winid, int, const char *));
00185 E void FDECL(tty_display_file, (const char *, BOOLEAN_P));
00186 E void FDECL(tty_start_menu, (winid));
00187 E void FDECL(tty_add_menu, (winid,int,const ANY_P *,
00188                         CHAR_P,CHAR_P,int,const char *, BOOLEAN_P));
00189 E void FDECL(tty_end_menu, (winid, const char *));
00190 E int FDECL(tty_select_menu, (winid, int, MENU_ITEM_P **));
00191 E char FDECL(tty_message_menu, (CHAR_P,int,const char *));
00192 E void NDECL(tty_update_inventory);
00193 E void NDECL(tty_mark_synch);
00194 E void NDECL(tty_wait_synch);
00195 #ifdef CLIPPING
00196 E void FDECL(tty_cliparound, (int, int));
00197 #endif
00198 #ifdef POSITIONBAR
00199 E void FDECL(tty_update_positionbar, (char *));
00200 #endif
00201 E void FDECL(tty_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
00202 E void FDECL(tty_raw_print, (const char *));
00203 E void FDECL(tty_raw_print_bold, (const char *));
00204 E int NDECL(tty_nhgetch);
00205 E int FDECL(tty_nh_poskey, (int *, int *, int *));
00206 E void NDECL(tty_nhbell);
00207 E int NDECL(tty_doprev_message);
00208 E char FDECL(tty_yn_function, (const char *, const char *, CHAR_P));
00209 E void FDECL(tty_getlin, (const char *,char *));
00210 E int NDECL(tty_get_ext_cmd);
00211 E void FDECL(tty_number_pad, (int));
00212 E void NDECL(tty_delay_output);
00213 #ifdef CHANGE_COLOR
00214 E void FDECL(tty_change_color,(int color,long rgb,int reverse));
00215 #ifdef MAC
00216 E void FDECL(tty_change_background,(int white_or_black));
00217 E short FDECL(set_tty_font_name, (winid, char *));
00218 #endif
00219 E char * NDECL(tty_get_color_string);
00220 #endif
00221 
00222 /* other defs that really should go away (they're tty specific) */
00223 E void NDECL(tty_start_screen);
00224 E void NDECL(tty_end_screen);
00225 
00226 E void FDECL(genl_outrip, (winid,int));
00227 
00228 #ifdef NO_TERMS
00229 # ifdef MAC
00230 #  ifdef putchar
00231 #   undef putchar
00232 #   undef putc
00233 #  endif
00234 #  define putchar term_putc
00235 #  define fflush term_flush
00236 #  define puts term_puts
00237 E int FDECL(term_putc, (int c));
00238 E int FDECL(term_flush, (void *desc));
00239 E int FDECL(term_puts, (const char *str));
00240 # endif /* MAC */
00241 # if defined(MSDOS) || defined(WIN32CON)
00242 #  if defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST) || defined(WIN32CON)
00243 #   undef putchar
00244 #   undef putc
00245 #   undef puts
00246 #   define putchar(x) xputc(x)  /* these are in video.c, nttty.c */
00247 #   define putc(x) xputc(x)
00248 #   define puts(x) xputs(x)
00249 #  endif/*SCREEN_BIOS || SCREEN_DJGPPFAST || WIN32CON */
00250 #  ifdef POSITIONBAR
00251 E void FDECL(video_update_positionbar, (char *));
00252 #  endif
00253 # endif/*MSDOS*/
00254 #endif/*NO_TERMS*/
00255 
00256 #undef E
00257 
00258 #endif /* WINTTY_H */