/*
- * $Id: curses.priv.h,v 1.101 1998/02/11 12:13:57 tom Exp $
+ * $Id: curses.priv.h,v 1.144 1999/10/22 23:15:37 tom Exp $
*
* curses.priv.h
*
#define USE_QNX_MOUSE 0
#endif
+/* EMX mouse support */
+#ifdef __EMX__
+#define USE_EMX_MOUSE
+#endif
+
#define DEFAULT_MAXCLICK 166
#define EV_MAX 8 /* size of mouse circular event queue */
#endif
/*
- * As currently coded, hashmap relies on the scroll-hints logic.
+ * Not all platforms have memmove; some have an equivalent bcopy. (Some may
+ * have neither).
+ */
+#if USE_OK_BCOPY
+#define memmove(d,s,n) bcopy(s,d,n)
+#elif USE_MY_MEMMOVE
+#define memmove(d,s,n) _nc_memmove(d,s,n)
+extern void * _nc_memmove(void *, const void *, size_t);
+#endif
+
+/*
+ * Scroll hints are useless when hashmap is used
*/
#if !USE_SCROLL_HINTS
-#if USE_HASHMAP
+#if !USE_HASHMAP
#define USE_SCROLL_HINTS 1
#else
#define USE_SCROLL_HINTS 0
#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
+/*
+ * Common/troublesome character definitions
+ */
+#define L_BRACE '{'
+#define R_BRACE '}'
+#define S_QUOTE '\''
+
/*
* Structure for palette tables
*/
int _ifd; /* input file ptr for screen */
FILE *_ofp; /* output file ptr for screen */
char *_setbuf; /* buffered I/O for output */
+ int _buffered; /* setvbuf uses _setbuf data */
int _checkfd; /* filedesc for typeahead check */
struct term *_term; /* terminal type information */
short _lines; /* screen lines */
int _echo; /* True if echo on */
int _use_meta; /* use the meta key? */
SLK *_slk; /* ptr to soft key struct / NULL */
-
+ int slk_format; /* selected format for this screen */
/* cursor movement costs; units are 10ths of milliseconds */
+#ifdef NCURSES_NO_PADDING
+ int _no_padding; /* flag to set if padding disabled */
+#endif
int _char_padding; /* cost of character put */
int _cr_cost; /* cost of (carriage_return) */
int _cup_cost; /* cost of (cursor_address) */
int _rep_cost; /* cost of (repeat_char) */
int _hpa_ch_cost; /* cost of (column_address) */
int _cup_ch_cost; /* cost of (cursor_address) */
+ int _smir_cost; /* cost of (enter_insert_mode) */
+ int _rmir_cost; /* cost of (exit_insert_mode) */
+ int _ip_cost; /* cost of (insert_padding) */
/* used in lib_mvcur.c */
char * _address_cursor;
int _carriage_return_length;
chtype _xmc_triggers; /* attributes to process if xmc */
chtype _acs_map[ACS_LEN];
+ /* used in lib_vidattr.c */
+ bool _use_rmso; /* true if we may use 'rmso' */
+ bool _use_rmul; /* true if we may use 'rmul' */
+
/*
* These data correspond to the state of the idcok() and idlok()
* functions. A caveat is in order here: the XSI and SVr4
bool _sig_winch;
SCREEN *_next_screen;
+
+ /* hashes for old and new lines */
+ unsigned long *oldhash, *newhash;
+
+ bool _cleanup; /* cleanup after int/quit signal */
};
extern SCREEN *_nc_screen_chain;
#endif
/* usually in <unistd.h> */
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#define CHANGED -1
+#define CHANGED_CELL(line,col) \
+ if (line->firstchar == _NOCHANGE) \
+ line->firstchar = line->lastchar = col; \
+ else if ((col) < line->firstchar) \
+ line->firstchar = col; \
+ else if ((col) > line->lastchar) \
+ line->lastchar = col
+
+#define CHANGED_RANGE(line,start,end) \
+ if (line->firstchar == _NOCHANGE \
+ || line->firstchar > (start)) \
+ line->firstchar = start; \
+ if (line->lastchar == _NOCHANGE \
+ || line->lastchar < (end)) \
+ line->lastchar = end
+
+#define CHANGED_TO_EOL(line,start,end) \
+ if (line->firstchar == _NOCHANGE \
+ || line->firstchar > (start)) \
+ line->firstchar = start; \
+ line->lastchar = end
+
#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
-#define typeCalloc(type,elts) (type *)calloc(elts,sizeof(type))
+#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type))
+#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type))
+#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type))
#define FreeIfNeeded(p) if(p != 0) free(p)
#define FreeAndNull(p) free(p); p = 0
#define returnPtr(code) TRACE_RETURN(code,ptr)
#define returnVoid T((T_RETURN(""))); return
#define returnWin(code) TRACE_RETURN(code,win)
-extern unsigned _nc_tracing;
extern WINDOW * _nc_retrace_win(WINDOW *);
extern attr_t _nc_retrace_attr_t(attr_t);
extern char *_nc_retrace_ptr(char *);
extern const char *_nc_tputs_trace;
-extern const char *_nc_visbuf(const char *);
-extern const char *_nc_visbuf2(int, const char *);
extern int _nc_retrace_int(int);
extern long _nc_outchars;
extern void _nc_fifo_dump(void);
#define returnWin(code) return code
#endif
+extern unsigned _nc_tracing;
+extern const char *_nc_visbuf2(int, const char *);
+
#define _trace_key(ch) ((ch > KEY_MIN) ? keyname(ch) : _tracechar((unsigned char)ch))
#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
#define InsCharCost(count) \
((parm_ich != 0) \
? SP->_ich_cost \
- : ((insert_character != 0) \
- ? (SP->_ich1_cost * count) \
- : INFINITY))
+ : ((enter_insert_mode && exit_insert_mode) \
+ ? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
+ : ((insert_character != 0) \
+ ? (SP->_ich1_cost * count) \
+ : INFINITY)))
#if USE_XMC_SUPPORT
#define UpdateAttrs(c) if (SP->_current_attr != AttrOf(c)) { \
#endif
+#if !HAVE_GETCWD
+#define getcwd(buf,len) getwd(buf)
+#endif
+
+/* doalloc.c */
+extern void *_nc_doalloc(void *, size_t);
+#if !HAVE_STRDUP
+#define strdup _nc_strdup
+extern char *_nc_strdup(const char *);
+#endif
+
/* doupdate.c */
#if USE_XMC_SUPPORT
extern void _nc_do_xmc_glitch(attr_t);
#endif
/* hardscroll.c */
-#if defined(TRACE) || defined(SCROLLDEBUG)
-extern void _nc_linedump(void);
-#endif
-
-/* hardscroll.c */
-#if defined(TRACE) || defined(SCROLLDEBUG)
+#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
extern void _nc_linedump(void);
#endif
/* lib_acs.c */
-extern void init_acs(void); /* no prefix, this name is traditional */
+extern void _nc_init_acs(void); /* corresponds to traditional 'init_acs()' */
extern int _nc_msec_cost(const char *const, int); /* used by 'tack' program */
/* lib_mvcur.c */
extern void _nc_screen_resume(void);
extern void _nc_screen_wrap(void);
+#if !HAVE_STRSTR
+#define strstr _nc_strstr
+extern char *_nc_strstr(const char *, const char *);
+#endif
+
/* lib_mouse.c */
extern int _nc_has_mouse(void);
/* safe_sprintf.c */
extern char * _nc_printf_string(const char *fmt, va_list ap);
-/* softscroll.c */
-extern void _nc_setup_scroll(void);
-extern void _nc_perform_scroll(void);
-
/* tries.c */
extern void _nc_add_to_try(struct tries **tree, char *str, unsigned short code);
-extern char *_nc_expand_try(struct tries *tree, unsigned short code, size_t len);
+extern char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len);
extern int _nc_remove_key(struct tries **tree, unsigned short code);
+extern int _nc_remove_string(struct tries **tree, char *string);
/* elsewhere ... */
extern WINDOW *_nc_makenew(int, int, int, int, int);
+extern char *_nc_home_terminfo(void);
extern char *_nc_trace_buf(int, size_t);
extern chtype _nc_background(WINDOW *);
extern chtype _nc_render(WINDOW *, chtype);
+extern int _nc_access(const char *, int);
+extern int _nc_baudrate(int);
+extern int _nc_getenv_num(const char *);
extern int _nc_keypad(bool);
+extern int _nc_ospeed(int);
extern int _nc_outch(int);
extern int _nc_setupscreen(short, short const, FILE *);
extern int _nc_timed_wait(int, int, int *);
extern int _nc_waddch_nosync(WINDOW *, const chtype);
extern void _nc_do_color(int, bool, int (*)(int));
-extern void _nc_free_and_exit(int);
extern void _nc_freeall(void);
extern void _nc_freewin(WINDOW *win);
extern void _nc_hash_map(void);
+extern void _nc_init_keytry(void);
+extern void _nc_keep_tic_dir(const char *);
+extern void _nc_make_oldhash(int i);
extern void _nc_outstr(const char *str);
+extern void _nc_scroll_oldhash(int n, int top, int bot);
extern void _nc_scroll_optimize(void);
extern void _nc_scroll_window(WINDOW *, int const, short const, short const, chtype);
extern void _nc_set_buffer(FILE *ofp, bool buffered);
extern void _nc_signal_handler(bool);
extern void _nc_synchook(WINDOW *win);
+extern void _nc_trace_tries(struct tries *tree);
#if USE_SIZECHANGE
extern void _nc_update_screensize(void);
#endif
+/* scroll indices */
+extern int *_nc_oldnums;
+
+#define USE_SETBUF_0 0
+
+#define NC_BUFFERED(flag) \
+ if ((SP->_buffered != 0) != flag) \
+ _nc_set_buffer(SP->_ofp, flag)
+
+#define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)
+#define _nc_flush() (void)fflush(NC_OUTPUT)
+
/*
* On systems with a broken linker, define 'SP' as a function to force the
* linker to pull in the data-only module with 'SP'.
extern int _nc_slk_format; /* != 0 if slk_init() called */
extern int _nc_slk_initialize(WINDOW *, int);
-/*
- * Some constants related to SLK's
+/*
+ * Some constants related to SLK's
*/
#define MAX_SKEY_OLD 8 /* count of soft keys */
#define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */
#define MAX_SKEY_PC 12 /* This is what most PC's have */
#define MAX_SKEY_LEN_PC 5
-#define MAX_SKEY (SLK_STDFMT ? MAX_SKEY_OLD : MAX_SKEY_PC)
-#define MAX_SKEY_LEN (SLK_STDFMT ? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
-
/* Macro to check whether or not we use a standard format */
-#define SLK_STDFMT (_nc_slk_format < 3)
+#define SLK_STDFMT(fmt) (fmt < 3)
/* Macro to determine height of label window */
-#define SLK_LINES (SLK_STDFMT ? 1 : (_nc_slk_format - 2))
+#define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2))
+
+#define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC)
+#define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
extern int _nc_ripoffline(int line, int (*init)(WINDOW *,int));