/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
/*
- * $Id: curses.priv.h,v 1.228 2002/10/12 15:49:10 tom Exp $
+ * $Id: curses.priv.h,v 1.255 2004/02/01 01:05:58 Stanislav.Ievlev Exp $
*
* curses.priv.h
*
/* EMX mouse support */
#ifdef __EMX__
-#define USE_EMX_MOUSE
+#define USE_EMX_MOUSE 1
+#else
+#define USE_EMX_MOUSE 0
#endif
#define DEFAULT_MAXCLICK 166
struct ldat
{
- NCURSES_CH_T *text; /* text of the line */
- NCURSES_SIZE_T firstchar; /* first changed character in the line */
- NCURSES_SIZE_T lastchar; /* last changed character in the line */
- NCURSES_SIZE_T oldindex; /* index of the line at last update */
+ NCURSES_CH_T *text; /* text of the line */
+ NCURSES_SIZE_T firstchar; /* first changed character in the line */
+ NCURSES_SIZE_T lastchar; /* last changed character in the line */
+ NCURSES_SIZE_T oldindex; /* index of the line at last update */
};
+typedef enum {
+ M_XTERM = -1 /* use xterm's mouse tracking? */
+ ,M_NONE = 0 /* no mouse device */
+#if USE_GPM_SUPPORT
+ ,M_GPM /* use GPM */
+#endif
+#if USE_SYSMOUSE
+ ,M_SYSMOUSE /* FreeBSD sysmouse on console */
+#endif
+} MouseType;
+
/*
* Structure for soft labels.
*/
typedef struct
{
- char *text; /* text for the label */
+ char *ent_text; /* text for the label */
char *form_text; /* formatted text (left/center/...) */
- int x; /* x coordinate of this field */
+ int ent_x; /* x coordinate of this field */
char dirty; /* this label has changed */
char visible; /* field is visible */
} slk_ent;
char hidden; /* soft labels are hidden */
WINDOW *win;
slk_ent *ent;
- char* buffer; /* buffer for labels */
- short maxlab; /* number of available labels */
- short labcnt; /* number of allocated labels */
- short maxlen; /* length of labels */
- chtype attr; /* soft label attribute */
+ short maxlab; /* number of available labels */
+ short labcnt; /* number of allocated labels */
+ short maxlen; /* length of labels */
+ chtype attr; /* soft label attribute */
} SLK;
typedef struct {
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 */
+ TERMINAL *_term; /* terminal type information */
short _lines; /* screen lines */
short _columns; /* screen columns */
bool _tried; /* keypad mode was initialized */
bool _keypad_on; /* keypad mode is currently on */
+ bool _called_wgetch; /* check for recursion in wgetch() */
int _fifo[FIFO_SIZE]; /* input push-back buffer */
short _fifohead, /* head of fifo queue */
_fifotail, /* tail of fifo queue */
int _cursor; /* visibility of the cursor */
int _cursrow; /* physical cursor row */
int _curscol; /* physical cursor column */
+ bool _notty; /* true if we cannot switch non-tty */
int _nl; /* True if NL -> CR/NL is on */
int _raw; /* True if in raw mode */
int _cbreak; /* 1 if in cbreak mode */
#endif
chtype _xmc_suppress; /* attributes to suppress if xmc */
chtype _xmc_triggers; /* attributes to process if xmc */
- chtype _acs_map[ACS_LEN];
+ chtype _acs_map[ACS_LEN]; /* the real alternate-charset map */
/* used in lib_vidattr.c */
bool _use_rmso; /* true if we may use 'rmso' */
/*
* These are the data that support the mouse interface.
*/
+ MouseType _mouse_type;
int _maxclick;
bool (*_mouse_event) (SCREEN *);
bool (*_mouse_inline)(SCREEN *);
void (*_mouse_resume)(SCREEN *);
void (*_mouse_wrap) (SCREEN *);
int _mouse_fd; /* file-descriptor, if any */
+ NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
+#if USE_SYSMOUSE
+ MEVENT _sysmouse_fifo[FIFO_SIZE];
+ int _sysmouse_head;
+ int _sysmouse_tail;
+ int _sysmouse_char_width; /* character width */
+ int _sysmouse_char_height; /* character height */
+ int _sysmouse_old_buttons;
+ int _sysmouse_new_buttons;
+#endif
/*
* This supports automatic resizing
bool _cleanup; /* cleanup after int/quit signal */
int (*_outch)(int); /* output handler if not putc */
+
+ /* recent versions of 'screen' have partially-working support for
+ * UTF-8, but do not permit ACS at the same time (see tty_update.c).
+ */
+#if USE_WIDEC_SUPPORT
+ bool _posix_locale;
+ bool _screen_acs_fix;
+#endif
};
extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
#include <nomacros.h>
#endif
-/*
- * The margins are used in resizeterm() to retain the original layout after
- * resizing.
- */
WINDOWLIST {
+ WINDOW win; /* first, so WINDOW_EXT() works */
WINDOWLIST *next;
-#if HAVE_RESIZETERM
- int l_margin;
- int r_margin;
- int t_margin;
- int b_margin;
+#ifdef _XOPEN_SOURCE_EXTENDED
+ char addch_work[(MB_LEN_MAX * 9) + 1];
+ int addch_used;
+ int addch_x;
+ int addch_y;
#endif
- WINDOW win;
};
+#define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
+
/* The terminfo source is assumed to be 7-bit ASCII */
#define is7bits(c) ((unsigned)(c) < 128)
#define O_BINARY 0
#endif
+#ifdef TRACE
+#define TRACE_OUTCHARS(n) _nc_outchars += (n);
+#else
+#define TRACE_OUTCHARS(n) /* nothing */
+#endif
+
#define UChar(c) ((unsigned char)(c))
#define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
#define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
+#endif
+
#if USE_WIDEC_SUPPORT /* { */
+#define NulChar 0,0,0,0 /* FIXME: see CCHARW_MAX */
#define CharOf(c) ((c).chars[0])
#define AttrOf(c) ((c).attr)
#define AddAttr(c,a) (c).attr |= a
#define RemAttr(c,a) (c).attr &= ~(a)
#define SetAttr(c,a) (c).attr = a
-#define NewChar(ch) { ChAttrOf(ch), { ChCharOf(ch) } }
-#define NewChar2(c,a) { a, { c } }
+#define NewChar(ch) { ChAttrOf(ch), { ChCharOf(ch), NulChar } }
+#define NewChar2(c,a) { a, { c, NulChar } }
#define CharEq(a,b) (!memcmp(&a, &b, sizeof(a)))
#define SetChar(ch,c,a) do { \
NCURSES_CH_T *_cp = &ch; \
#define CARG_CH_T const NCURSES_CH_T *
#define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
mbstate_t PUT_st; wchar_t PUTC_ch
+#define PUTC_INIT memset (&PUT_st, '\0', sizeof (PUT_st)); \
+ PUTC_i = 0
#define PUTC(ch,b) do { if(!isnac(ch)) { \
- memset (&PUT_st, '\0', sizeof (PUT_st)); \
- PUTC_i = 0; \
+ if (Charable(ch)) { \
+ fputc(CharOf(ch), b); \
+ TRACE_OUTCHARS(1); \
+ } else { \
+ PUTC_INIT; \
do { \
PUTC_ch = PUTC_i < CCHARW_MAX ? \
(ch).chars[PUTC_i] : L'\0'; \
fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \
++PUTC_i; \
} while (PUTC_ch != L'\0'); \
- } } while (0)
+ TRACE_OUTCHARS(PUTC_i); \
+ } } } while (0)
#define BLANK { WA_NORMAL, ' ' }
#define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
#define WA_NAC 1
#define isnac(ch) (AttrOf(ch) & WA_NAC)
#define if_WIDEC(code) code
-#define Charable(ch) (!isnac(ch) && \
- (ch).chars[1] == L'\0' && \
- (wctob(CharOf(ch)) == (char)CharOf(ch)))
+#define Charable(ch) ((SP != 0 && SP->_posix_locale) \
+ || (!isnac(ch) && \
+ (ch).chars[1] == L'\0' && \
+ _nc_is_charable(CharOf(ch))))
#define L(ch) L ## ch
#else /* }{ */
#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
#define IGNORE_COLOR_OFF FALSE
-#define NONBLANK_ATTR (A_BOLD|A_DIM|A_BLINK)
+#define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
#define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
#define toggle_attr_on(S,at) {\
: ((enter_insert_mode && exit_insert_mode) \
? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
: ((insert_character != 0) \
- ? (SP->_ich1_cost * count) \
+ ? ((SP->_ich1_cost + SP->_ip_cost) * count) \
: INFINITY)))
#if USE_XMC_SUPPORT
#define getcwd(buf,len) getwd(buf)
#endif
+/* charable.c */
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t);
+extern NCURSES_EXPORT(int) _nc_to_char(wint_t);
+extern NCURSES_EXPORT(wint_t) _nc_to_widechar(int);
+#endif
+
/* doupdate.c */
#if USE_XMC_SUPPORT
extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t);
/* lib_getch.c */
extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
+/* lib_insch.c */
+extern NCURSES_EXPORT(void) _nc_insert_ch(WINDOW *, chtype);
+
/* lib_mvcur.c */
#define INFINITY 1000000 /* cost: too high to use */
/* lib_mvcur.c */
#define INFINITY 1000000 /* cost: too high to use */
+#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */
+
+/* lib_setup.c */
+extern NCURSES_EXPORT(char *) _nc_get_locale(void);
+extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
+extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(void);
/* lib_wacs.c */
#if USE_WIDEC_SUPPORT
#endif
typedef struct {
- char *s_head;
- char *s_tail;
- size_t s_size;
+ char *s_head; /* beginning of the string (may be null) */
+ char *s_tail; /* end of the string (may be null) */
+ size_t s_size; /* current remaining size available */
+ size_t s_init; /* total size available */
} string_desc;
/* strings.c */
extern NCURSES_EXPORT(void) _nc_add_to_try (struct tries **, const char *, unsigned short);
extern NCURSES_EXPORT(char *) _nc_expand_try (struct tries *, unsigned short, int *, size_t);
extern NCURSES_EXPORT(int) _nc_remove_key (struct tries **, unsigned short);
-extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **, char *);
+extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **, const char *);
/* elsewhere ... */
+extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
-extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
-extern NCURSES_EXPORT(int) _nc_access (const char *, int);
+extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
+extern NCURSES_EXPORT(int) _nc_access (const char *, int);
extern NCURSES_EXPORT(int) _nc_baudrate (int);
extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
extern NCURSES_EXPORT(void) _nc_init_keytry (void);
extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
-extern NCURSES_EXPORT(void) _nc_outstr (const char *str);
extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, NCURSES_CH_T);
#define USE_SETBUF_0 0
-#define NC_BUFFERED(flag) \
- if ((SP->_buffered != 0) != flag) \
- _nc_set_buffer(SP->_ofp, flag)
+#define NC_BUFFERED(flag) _nc_set_buffer(SP->_ofp, flag)
#define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)