3607fad551209a3a0bb8e9d6fc4ae0ed87f50880
[silc.git] / apps / irssi / src / fe-text / term.h
1 #ifndef __TERM_H
2 #define __TERM_H
3
4 typedef struct _TERM_WINDOW TERM_WINDOW;
5
6 /* text attributes */
7 #define ATTR_RESETFG    0x0100
8 #define ATTR_RESETBG    0x0200
9 #define ATTR_BOLD       0x0400
10 #define ATTR_BLINK      0x0800
11 #define ATTR_UNDERLINE  0x1000
12 #define ATTR_REVERSE    0x2000
13
14 #define ATTR_RESET      (ATTR_RESETFG|ATTR_RESETBG)
15
16 #define ATTR_NOCOLORS (ATTR_UNDERLINE|ATTR_REVERSE)
17
18 /* terminal types */
19 #define TERM_TYPE_8BIT          0 /* normal 8bit text */
20 #define TERM_TYPE_UTF8          1
21 #define TERM_TYPE_BIG5          2
22
23 typedef guint32 unichar;
24
25 extern TERM_WINDOW *root_window;
26 extern int term_width, term_height;
27 extern int term_use_colors, term_type, term_detached;
28
29 /* Initialize / deinitialize terminal */
30 int term_init(void);
31 void term_deinit(void);
32
33 /* Resize terminal - if width or height is negative,
34    the new size is unknown and should be figured out somehow */
35 void term_resize(int width, int height);
36 void term_resize_final(int width, int height);
37 /* Resize the terminal if needed */
38 void term_resize_dirty(void);
39
40 /* Returns TRUE if terminal has colors */
41 int term_has_colors(void);
42 /* Force the colors on any way you can */
43 void term_force_colors(int set);
44
45 /* Clear screen */
46 void term_clear(void);
47 /* Beep */
48 void term_beep(void);
49
50 /* Create a new window in terminal */
51 TERM_WINDOW *term_window_create(int x, int y, int width, int height);
52 /* Destroy a terminal window */
53 void term_window_destroy(TERM_WINDOW *window);
54
55 /* Move/resize window */
56 void term_window_move(TERM_WINDOW *window, int x, int y,
57                       int width, int height);
58 /* Clear window */
59 void term_window_clear(TERM_WINDOW *window);
60 /* Scroll window up/down */
61 void term_window_scroll(TERM_WINDOW *window, int count);
62
63 void term_set_color(TERM_WINDOW *window, int col);
64
65 void term_move(TERM_WINDOW *window, int x, int y);
66 void term_addch(TERM_WINDOW *window, int chr);
67 void term_add_unichar(TERM_WINDOW *window, unichar chr);
68 void term_addstr(TERM_WINDOW *window, const char *str);
69 void term_clrtoeol(TERM_WINDOW *window);
70
71 void term_move_cursor(int x, int y);
72
73 void term_refresh_freeze(void);
74 void term_refresh_thaw(void);
75 void term_refresh(TERM_WINDOW *window);
76
77 /* Automatically detach irssi when terminal is lost */
78 void term_auto_detach(int set);
79 void term_detach(void);
80 void term_attach(FILE *in, FILE *out);
81
82 void term_stop(void);
83
84 /* keyboard input handling */
85 void term_set_input_type(int type);
86 int term_gets(unichar *buffer, int size);
87
88 /* internal */
89 void term_common_init(void);
90 void term_common_deinit(void);
91
92 #endif