9cd1b153755830ee212a806efccec41e837db071
[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 #define ATTR_RESETFG    0x0100
7 #define ATTR_RESETBG    0x0200
8 #define ATTR_BOLD       0x0400
9 #define ATTR_BLINK      0x0800
10 #define ATTR_UNDERLINE  0x1000
11 #define ATTR_REVERSE    0x2000
12
13 #define ATTR_RESET      (ATTR_RESETFG|ATTR_RESETBG)
14
15 #define ATTR_NOCOLORS (ATTR_UNDERLINE|ATTR_REVERSE)
16
17 #ifdef WANT_BIG5
18 /* XXX I didn't check the encoding range of big5+. This is standard big5. */
19 #  define is_big5_los(lo) (((char)0x40<=lo)&&(lo<=(char)0x7E))  /* standard */
20 #  define is_big5_lox(lo) (((char)0x80<=lo)&&(lo<=(char)0xFE))  /* extended */
21 #  define is_big5_hi(hi)  (((char)0x81<=hi)&&(hi<=(char)0xFE))
22 #  define is_big5(hi,lo) is_big5_hi(hi) && (is_big5_los(lo) || is_big5_lox(lo))
23 #endif
24
25 extern TERM_WINDOW *root_window;
26 extern int term_width, term_height, term_use_colors, term_detached;
27
28 /* Initialize / deinitialize terminal */
29 int term_init(void);
30 void term_deinit(void);
31
32 /* Resize terminal - if width or height is negative,
33    the new size is unknown and should be figured out somehow */
34 void term_resize(int width, int height);
35 void term_resize_final(int width, int height);
36 /* Resize the terminal if needed */
37 void term_resize_dirty(void);
38
39 /* Returns TRUE if terminal has colors */
40 int term_has_colors(void);
41 /* Force the colors on any way you can */
42 void term_force_colors(int set);
43
44 /* Clear screen */
45 void term_clear(void);
46 /* Beep */
47 void term_beep(void);
48
49 /* Create a new window in terminal */
50 TERM_WINDOW *term_window_create(int x, int y, int width, int height);
51 /* Destroy a terminal window */
52 void term_window_destroy(TERM_WINDOW *window);
53
54 /* Move/resize window */
55 void term_window_move(TERM_WINDOW *window, int x, int y,
56                       int width, int height);
57 /* Clear window */
58 void term_window_clear(TERM_WINDOW *window);
59 /* Scroll window up/down */
60 void term_window_scroll(TERM_WINDOW *window, int count);
61
62 void term_set_color(TERM_WINDOW *window, int col);
63
64 void term_move(TERM_WINDOW *window, int x, int y);
65 void term_addch(TERM_WINDOW *window, int chr);
66 void term_addstr(TERM_WINDOW *window, const char *str);
67 void term_clrtoeol(TERM_WINDOW *window);
68
69 void term_move_cursor(int x, int y);
70
71 void term_refresh_freeze(void);
72 void term_refresh_thaw(void);
73 void term_refresh(TERM_WINDOW *window);
74
75 /* Automatically detach irssi when terminal is lost */
76 void term_auto_detach(int set);
77 void term_detach(void);
78 void term_attach(FILE *in, FILE *out);
79
80 void term_stop(void);
81 int term_gets(unsigned char *buffer, int size);
82
83 /* internal */
84 void term_common_init(void);
85 void term_common_deinit(void);
86
87 #endif