2001-10-28 06:30:26 -05:00
|
|
|
#ifndef __TERM_H
|
|
|
|
#define __TERM_H
|
|
|
|
|
|
|
|
typedef struct _TERM_WINDOW TERM_WINDOW;
|
|
|
|
|
2011-05-03 10:40:34 -04:00
|
|
|
#define FG_MASK ( 0x00ff )
|
|
|
|
#define BG_MASK ( 0xff00 )
|
2014-01-09 09:20:29 -05:00
|
|
|
#define BG_SHIFT 8
|
2011-05-03 10:40:34 -04:00
|
|
|
|
2014-01-09 09:20:29 -05:00
|
|
|
/* text attributes */
|
2011-05-03 10:40:34 -04:00
|
|
|
#define ATTR_RESETFG ( 0x010000 )
|
|
|
|
#define ATTR_RESETBG ( 0x020000 )
|
|
|
|
#define ATTR_BOLD ( 0x040000 )
|
2014-01-09 09:20:29 -05:00
|
|
|
#define ATTR_BLINK ( 0x080000 )
|
2011-05-03 10:40:34 -04:00
|
|
|
#define ATTR_UNDERLINE ( 0x100000 )
|
|
|
|
#define ATTR_REVERSE ( 0x200000 )
|
2011-11-06 14:40:25 -05:00
|
|
|
#define ATTR_ITALIC ( 0x400000 )
|
|
|
|
#define ATTR_FGCOLOR24 ( 0x1000000 )
|
|
|
|
#define ATTR_BGCOLOR24 ( 0x2000000 )
|
2001-10-28 06:30:26 -05:00
|
|
|
|
|
|
|
#define ATTR_RESET (ATTR_RESETFG|ATTR_RESETBG)
|
|
|
|
|
2011-11-06 14:40:25 -05:00
|
|
|
#define ATTR_NOCOLORS (ATTR_UNDERLINE|ATTR_REVERSE|ATTR_BLINK|ATTR_BOLD|ATTR_ITALIC)
|
2001-10-28 06:30:26 -05:00
|
|
|
|
2002-02-15 08:38:24 -05:00
|
|
|
/* terminal types */
|
|
|
|
#define TERM_TYPE_8BIT 0 /* normal 8bit text */
|
|
|
|
#define TERM_TYPE_UTF8 1
|
|
|
|
#define TERM_TYPE_BIG5 2
|
|
|
|
|
2016-05-12 19:26:33 -04:00
|
|
|
#include "utf8.h"
|
2001-10-28 06:30:26 -05:00
|
|
|
|
|
|
|
extern TERM_WINDOW *root_window;
|
2002-02-15 08:38:24 -05:00
|
|
|
extern int term_width, term_height;
|
2008-04-19 11:01:16 -04:00
|
|
|
extern int term_use_colors, term_type;
|
2014-01-09 09:20:29 -05:00
|
|
|
extern int term_use_colors24;
|
|
|
|
extern int term_color256map[];
|
2001-10-28 06:30:26 -05:00
|
|
|
|
|
|
|
/* Initialize / deinitialize terminal */
|
|
|
|
int term_init(void);
|
|
|
|
void term_deinit(void);
|
|
|
|
|
2002-03-14 18:46:48 -05:00
|
|
|
/* Gets the current terminal size, returns TRUE if ok. */
|
|
|
|
int term_get_size(int *width, int *height);
|
|
|
|
|
2001-10-28 06:30:26 -05:00
|
|
|
/* Resize terminal - if width or height is negative,
|
|
|
|
the new size is unknown and should be figured out somehow */
|
|
|
|
void term_resize(int width, int height);
|
2001-10-28 16:17:34 -05:00
|
|
|
void term_resize_final(int width, int height);
|
|
|
|
/* Resize the terminal if needed */
|
|
|
|
void term_resize_dirty(void);
|
2001-10-28 06:30:26 -05:00
|
|
|
|
|
|
|
/* Returns TRUE if terminal has colors */
|
|
|
|
int term_has_colors(void);
|
|
|
|
/* Force the colors on any way you can */
|
|
|
|
void term_force_colors(int set);
|
|
|
|
|
|
|
|
/* Clear screen */
|
|
|
|
void term_clear(void);
|
|
|
|
/* Beep */
|
|
|
|
void term_beep(void);
|
|
|
|
|
|
|
|
/* Create a new window in terminal */
|
|
|
|
TERM_WINDOW *term_window_create(int x, int y, int width, int height);
|
|
|
|
/* Destroy a terminal window */
|
|
|
|
void term_window_destroy(TERM_WINDOW *window);
|
|
|
|
|
|
|
|
/* Move/resize window */
|
|
|
|
void term_window_move(TERM_WINDOW *window, int x, int y,
|
|
|
|
int width, int height);
|
|
|
|
/* Clear window */
|
|
|
|
void term_window_clear(TERM_WINDOW *window);
|
|
|
|
/* Scroll window up/down */
|
|
|
|
void term_window_scroll(TERM_WINDOW *window, int count);
|
|
|
|
|
2014-07-04 06:46:51 -04:00
|
|
|
#ifdef TERM_TRUECOLOR
|
|
|
|
#define term_set_color(window, col) term_set_color2(window, (col) &~(ATTR_FGCOLOR24|ATTR_BGCOLOR24), UINT_MAX, UINT_MAX)
|
2014-01-09 09:20:29 -05:00
|
|
|
void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigned int bgcol24);
|
2014-07-04 06:46:51 -04:00
|
|
|
#else
|
|
|
|
#define term_set_color2(window, col, unused1, unused2) term_set_color(window, col)
|
2001-10-28 06:30:26 -05:00
|
|
|
void term_set_color(TERM_WINDOW *window, int col);
|
2014-07-04 06:46:51 -04:00
|
|
|
#endif
|
2001-10-28 06:30:26 -05:00
|
|
|
|
|
|
|
void term_move(TERM_WINDOW *window, int x, int y);
|
2008-04-04 04:41:44 -04:00
|
|
|
void term_addch(TERM_WINDOW *window, char chr);
|
2002-02-15 08:38:24 -05:00
|
|
|
void term_add_unichar(TERM_WINDOW *window, unichar chr);
|
2015-10-02 08:04:04 -04:00
|
|
|
int term_addstr(TERM_WINDOW *window, const char *str);
|
2001-10-28 06:30:26 -05:00
|
|
|
void term_clrtoeol(TERM_WINDOW *window);
|
|
|
|
|
|
|
|
void term_move_cursor(int x, int y);
|
|
|
|
|
|
|
|
void term_refresh_freeze(void);
|
|
|
|
void term_refresh_thaw(void);
|
|
|
|
void term_refresh(TERM_WINDOW *window);
|
|
|
|
|
|
|
|
void term_stop(void);
|
2002-02-15 08:38:24 -05:00
|
|
|
|
2016-03-22 11:54:34 -04:00
|
|
|
void term_set_appkey_mode(int enable);
|
2015-09-09 16:35:11 -04:00
|
|
|
void term_set_bracketed_paste_mode(int enable);
|
|
|
|
|
2002-02-15 08:38:24 -05:00
|
|
|
/* keyboard input handling */
|
|
|
|
void term_set_input_type(int type);
|
2010-02-27 09:57:16 -05:00
|
|
|
void term_gets(GArray *buffer, int *line_count);
|
2001-10-28 06:30:26 -05:00
|
|
|
|
|
|
|
/* internal */
|
|
|
|
void term_common_init(void);
|
|
|
|
void term_common_deinit(void);
|
|
|
|
|
|
|
|
#endif
|