Source:NetHack 3.3.0/mactty.h

Below is the full text to mactty.h from the source code of NetHack 3.3.0. To link to a particular line, write [[NetHack 3.3.0/mactty.h#line123 ]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

1.   /*	SCCS Id: @(#)mactty.h	3.3	93/03/01	*/ 2.   /* Copyright (c) Jon W{tte 1993. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    /*  6.     * This header is the supported external interface for the "tty" window 7.    * package. This package sports care-free handling of "dumb" tty windows 8.    * (preferrably using monospaced fonts) - it does NOT remember the strings 9.    * sent to it; rather, it uses an offscreen bitmap. 10.   *  11.    * For best performance, make sure it is aligned on a 32-pixel boundary 12.   * (or at least a 16-pixel one) in black & white. For 24bit color, 13.   * alignment doesn't matter, and for 8-bit color, alignment to every 14.   * fourth pixel is most efficient. 15.   *  16.    * (c) Copyright 1993 Jon W{tte 17.   */  18.    19.   /*  20.    * You should really not poke in the structures used by the tty window. 21.   * However, since it uses the wRefCon of windows (by calling GetWRefCon  22.    * and SetWRefCon) you lose that possibility. If you still want to store 23.   * information about a window, the FIRST location _pointed to_ by the 24.   * wRefCon will be a void * that you can use for whatever reasons. Don't 25. * take the address of this variable and expect it to stay the same 26.   * across calls to the tty window. 27.   *  28.    * void * my_config_ptr = * ( void * * ) GetWRefCon ( tty_window ) ; 29.   */  30.    31.   /*  32.    * The library uses the window's port temporarily through SetPortBits; 33.   * that means you shouldn't do any funky things to the clipping region 34.   * etc. Actually, you shouldn't even resize the window, as that will clip 35.   * new drawing. 36.   *  37.    * Also, if you use this library under Pascal, remember that the string 38.   * passed to add_tty_string is a "C" style string with NO length byte, 39.   * and a terminating zero byte at the end instead. 40.   */  41.    42.   #ifndef _H_tty_public 43.  # define _H_tty_public 44.   45.   /*  46.    * Error code returned when it's probably our fault, or  47. * bad parameters. 48.   */  49.   #define general_failure 1 50.   51.   /*  52.    * Base resource id's for window types 53.   */  54.   #define WIN_BASE_RES 128 55.  #define WIN_BASE_KIND 128 56.   57.   /*  58.    * Commonly used characters 59.   */  60.   #define CHAR_ENTER ((char)3) 61.  #define CHAR_BELL ((char)7) 62.  #define CHAR_BS ((char)8) 63.  #define CHAR_LF ((char)10) 64.  #define CHAR_CR ((char)13) 65.  #define CHAR_ESC ((char)27) 66.  #define CHAR_BLANK ((char)32) 67.  #define CHAR_DELETE ((char)127) 68.   69.   typedef struct NhWindow1 { 70.  	WindowPtr		its_window ; 71.  //	short			kind ; 72.   73.   	short			font_number ; 74.  	short			font_size ; 75.  	short			char_width ; 76.  	short			row_height ; 77.  	short			ascent_height ; 78.  	  79.   	short			x_size; 80.  	short			y_size; 81.  	short			x_curs; 82.  	short			y_curs; 83.  } NhWindow1; 84.   85.   /*  86.    * If you want some fancy operations that not a normal TTY device normally 87.   * supports, use EXTENDED_SUPPORT. For frames, area erases and area scrolls, 88.   * plus bitmap graphics - RESOLUTION DEPENDENT, be sure to call 89.   * get_tty_metrics and use those limits. 90.   */  91.   #define EXTENDED_SUPPORT 0 92.  /*  93.    * if you print a lot of single characters, accumulating each one in a  94. * clipping region will take too much time. Instead, define this, which 95.   * will clip in rects. 96.   */  97.   #define CLIP_RECT_ONLY 1 98.   99.   typedef enum tty_attrib { 100.  101.  /*  102.   * Flags relating to the general functioning of the window. 103.  * These flags are passed at create_tty time, and changing them 104.  * later will clear the screen. 105.  */  106.  	TTY_ATTRIB_FLAGS , 107. /*  108.   * When using proportional fonts, this will place each character 109.  * separately, ensuring aligned columns (but looking ugly and taking  110.   * time) 111.  */  112.  # define TA_MOVE_EACH_CHAR 1L 113. /*  114.   * This means draw each change as it occurs instead of collecting the area 115.  * and draw it all at once at update_tty - slower, but more reliable. 116.  */  117.  # define TA_ALWAYS_REFRESH 2L 118. /*  119.   * When reaching the right end, we either just stop drawing, or wrap to the 120.  * next line. 121.  */  122.  # define TA_WRAP_AROUND 4L 123. /*  124.   * Overstrike means that characters are added on top of each other; i e don't  125. * clear the letter beneath. This is faster, using srcOr under QuickDraw 126.  */  127.  # define TA_OVERSTRIKE 8L 128. /*  129.   * We may want the window not to scroll when we reach the end line, 130.  * but stop drawing instead. 131.  */  132.  # define TA_INHIBIT_VERT_SCROLL 16L 133.  134.  /*  135.   * Foreground and background colors. These only affect characters 136.  * drawn by subsequent calls; not what's already there (but it does  137.   * affect clears) 138.  * On b/w screens these do nothing. 139.  */  140.  	TTY_ATTRIB_FOREGROUND , 141. 	TTY_ATTRIB_BACKGROUND , 142. # define TA_RGB_TO_TTY(r) ((((long)((r).red>>8)&0xff)<<16)+\  143.  	(((long)((r).green>>8)&0xff)<<8)+((long)((r).blue>>8)&0xff)) 144.  145.  /*  146.   * Attributes relating to the cursor, and character set mappings 147.  */  148.  	TTY_ATTRIB_CURSOR , 149. /*  150.   * Blinking cursor is more noticeable when it's idle 151.  */  152.  # define TA_BLINKING_CURSOR 1L 153. /*  154.   * When handling input, do we echo characters as they are typed? 155.  */  156.  # define TA_ECHO_INPUT 2L 157. /*  158.   * Do we return each character code separately, or map delete etc? Note 159.  * that non-raw input means getchar won't return anything until the user 160.  * has typed a return. 161.  */  162.  # define TA_RAW_INPUT 4L 163. /*  164.   * Do we print every character as it is (including BS, NL and CR!) or do  165. * do we interpret characters such as NL, BS and CR? 166.  */  167.  # define TA_RAW_OUTPUT 8L 168. /*  169.   * When getting a NL, do we also move to the left? 170.  */  171.  # define TA_NL_ADD_CR 16L 172. /*  173.   * When getting a CR, do we also move down? 174.  */  175.  # define TA_CR_ADD_NL 32L 176. /*  177.   * Wait for input or return what we've got? 178.  */  179.  # define TA_NONBLOCKING_IO 64L 180.  181.  /*  182.   * Use this macro to cast a function pointer to a tty attribute; this will help 183.  * portability to systems where a function pointer doesn't fit in a long 184.  */  185.  # define TA_ATTRIB_FUNC(x) ((long)(x)) 186.  187.  /*  188.   * This symbolic constant is used to check the number of attributes 189.  */  190.  	TTY_NUMBER_ATTRIBUTES 191.  192.  } tty_attrib ; 193.  194.  /*  195.   * Character returned by end-of-file condition 196.  */  197.  # define TTY_EOF -1 198.  199.   200.  /*  201.   * Create the window according to a resource WIND template. 202.  * The window pointer pointed to by window should be NULL to  203. * allocate the window record dynamically, or point to a 204. * WindowRecord structure already allocated. 205.  *  206.   * Passing in_color means you have to be sure there's color support; 207.  * on the Mac, this means 32bit QuickDraw present, else it will 208.  * crash. Not passing in_color means everything's rendered in 209. * black & white. 210.  */  211.  extern short create_tty ( WindowPtr * window, short resource_id ,  212.  	Boolean in_color ) ; 213.  214.  /*  215.   * Use init_tty_name or init_tty_number to initialize a window 216.  * once allocated by create_tty. Size parameters are in characters. 217.  */  218.   219.  extern short init_tty_number ( WindowPtr window, short font_number ,  220.  	short font_size , short x_size , short y_size ) ; 221.  222.  /*  223.   * Close and deallocate a window and its data 224.  */  225.  extern short destroy_tty ( WindowPtr window ) ; 226.  227.  /*  228.   * Change the font and font size used in the window for drawing after 229.  * the calls are made. To change the coordinate system, be sure to call 230.  * force_tty_coordinate_system_recalc - else it may look strange if  231. * the new font doesn't match the old one. 232.  */  233.  extern short set_tty_font_name (winid window_type, char * name ) ; 234. extern short force_tty_coordinate_system_recalc ( WindowPtr window ) ; 235.  236.  /*  237.   * Getting some metrics about the tty and its drawing. 238.  */  239.  extern short get_tty_metrics ( WindowPtr window, short * x_size ,  240.  	short * y_size , short * x_size_pixels , short * y_size_pixels ,  241.  	short * font_number , short * font_size ,  242.  	short * char_width , short * row_height ) ; 243.  244.  /*  245.   * The basic move cursor function. 0,0 is topleft. 246.  */  247.  extern short move_tty_cursor ( WindowPtr window, short x_pos ,  248.  	short y_pos ) ; 249.  250.  /*  251.   * Flush all changes done to a tty to the screen (see TA_ALWAYS_UPDATE above) 252.  */  253.  extern short update_tty ( WindowPtr window ) ; 254.  255.  /*  256.   * Add a character to the tty and update the cursor position 257.  */  258.  extern short add_tty_char ( WindowPtr window, short character ) ; 259.  260.  /*  261.   * Add a string of characters to the tty and update the cursor 262.  * position. The string is 0-terminated! 263.  */  264.  extern short add_tty_string ( WindowPtr window, const char * string ) ; 265.  266.  /*  267.   * Change or read an attribute of the tty. Note that some attribute changes 268.  * may clear the screen. See the above enum and defines for values. 269.  * Attributes can be both function pointers and special flag values. 270.  */  271.  extern short get_tty_attrib ( WindowPtr window, tty_attrib attrib ,  272.  	long * value ) ; 273. extern short set_tty_attrib ( WindowPtr window, tty_attrib attrib ,  274.  	long value ) ; 275.  276.  /*  277.   * Scroll the actual TTY image, in characters, positive means up/left 278.  * scroll_tty ( my_tty, 0 , 1 ) means a linefeed. Is always carried out 279.  * directly, regardless of the wait-update setting. Does updates before 280.  * scrolling. 281.  */  282.  extern short scroll_tty ( WindowPtr window, short delta_x ,  283.  	short delta_y ) ; 284.  285.  /*  286.   * Erase the offscreen bitmap and move the cursor to 0,0. Re-init some window 287.  * values (font etc) Is always carried out directly on-screen, regardless of  288. * the wait-for-update setting. Clears update area. 289.  */  290.  extern short clear_tty ( WindowPtr window ) ; 291.  292.  /*  293.   * Call this routine with a window (always _mt_window) and a time (usually  294.   * from most recent event) to determine if cursor in window should be blinked 295.  */  296.  extern short blink_cursor ( WindowPtr window, long when ) ; 297.  298.  /*  299.   * For screen dumps, open the printer port and call this function. Can be used 300.  * for clipboard as well (only for a PICT, though; this library doesn't concern  301.   * itself with characters, just bitmaps) 302.  */  303.  extern short image_tty ( EventRecord *theEvent, WindowPtr window ) ; 304.  305.  /*  306.   * For erasing just an area of characters 307.  */  308.  extern short clear_tty_window ( WindowPtr window, short from_row ,  309.  	short from_col , short to_row , short to_col ) ; 310.  311.  /*  312.   * Now in macsnd.c, which seemed like a good place 313.  */  314.  extern void tty_nhbell ; 315.  316.  #if EXTENDED_SUPPORT 317.  318.  /*  319.   * Various versions of delete character/s, insert line/s etc can be handled by  320. * this general-purpose function. Negative num_ means delete, positive means 321.  * insert, and you can never be sure which of row and col operations come first 322.  * if you specify both...  323. */ 324.  extern short mangle_tty_rows_columns ( WindowPtr window,  325.  	short from_row , short num_rows , short from_col , short num_cols ) ; 326.  327.  /*  328.   * For framing an area without using grahpics characters. 329.  * Note that the given limits are those used for framing, you should not 330.  * draw in them. frame_fatness should typically be 1-5, and may be clipped 331.  * if it is too large. 332.  */  333.  extern short frame_tty_window ( WindowPtr window, short from_row ,  334.  	short from_col , short to_row , short to_col , short frame_fatness ) ; 335.  336.  /*  337.   * For inverting specific characters after the fact. May look funny in color. 338.  */  339.  extern short invert_tty_window ( WindowPtr window, short from_row ,  340.  	short from_col , short to_row , short to_col ) ; 341.  342.  /*  343.   * For drawing lines on the tty - VERY DEVICE DEPENDENT. Use get_tty_metrics. 344.  */  345.  extern short draw_tty_line ( WindowPtr window, short from_x ,  346.  	short from_y , short to_x , short to_y ) ; 347.  348.  #endif /* EXTENDED_SUPPORT */ 349.  350.  #endif /* _H_tty_public */