Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / fe-text / terminfo-core.h
1 #ifndef __TERMINFO_CORE_H
2 #define __TERMINFO_CORE_H
3
4 #include <termios.h>
5
6 #define terminfo_move(x, y) current_term->move(current_term, x, y)
7 #define terminfo_move_relative(oldx, oldy, x, y) current_term->move_relative(current_term, oldx, oldy, x, y)
8 #define terminfo_set_cursor_visible(set) current_term->set_cursor_visible(current_term, set)
9 #define terminfo_scroll(y1, y2, count) current_term->scroll(current_term, y1, y2, count)
10 #define terminfo_clear() current_term->clear(current_term)
11 #define terminfo_clrtoeol() current_term->clrtoeol(current_term)
12 #define terminfo_repeat(chr, count) current_term->repeat(current_term, chr, count)
13 #define terminfo_set_fg(color) current_term->set_fg(current_term, color)
14 #define terminfo_set_bg(color) current_term->set_bg(current_term, color)
15 #define terminfo_set_normal() current_term->set_normal(current_term)
16 #define terminfo_set_bold() current_term->set_bold(current_term)
17 #define terminfo_set_uline(set) current_term->set_uline(current_term, set)
18 #define terminfo_set_standout(set) current_term->set_standout(current_term, set)
19 #define terminfo_is_colors_set(term) (term->TI_fg[0] != NULL)
20 #define terminfo_beep(term) current_term->beep(current_term)
21
22 typedef struct _TERM_REC TERM_REC;
23
24 struct _TERM_REC {
25         /* Functions */
26         void (*move)(TERM_REC *term, int x, int y);
27         void (*move_relative)(TERM_REC *term, int oldx, int oldy, int x, int y);
28         void (*set_cursor_visible)(TERM_REC *term, int set);
29         void (*scroll)(TERM_REC *term, int y1, int y2, int count);
30
31         void (*clear)(TERM_REC *term);
32         void (*clrtoeol)(TERM_REC *term);
33         void (*repeat)(TERM_REC *term, int chr, int count);
34
35         void (*set_fg)(TERM_REC *term, int color);
36         void (*set_bg)(TERM_REC *term, int color);
37         void (*set_normal)(TERM_REC *term);
38         void (*set_bold)(TERM_REC *term);
39         void (*set_uline)(TERM_REC *term, int set);
40         void (*set_standout)(TERM_REC *term, int set);
41
42         void (*beep)(TERM_REC *term);
43
44 #ifndef HAVE_TERMINFO
45         char buffer1[1024], buffer2[1024];
46 #endif
47         FILE *in, *out;
48         struct termios tio, old_tio;
49
50         /* Terminal size */
51         int width, height;
52
53         /* Cursor movement */
54         const char *TI_smcup, *TI_rmcup, *TI_cup;
55         const char *TI_hpa, *TI_vpa, *TI_cub1, *TI_cuf1;
56         const char *TI_civis, *TI_cnorm;
57
58         /* Scrolling */
59         const char *TI_csr, *TI_wind;
60         const char *TI_ri, *TI_rin, *TI_ind, *TI_indn;
61         const char *TI_il, *TI_il1, *TI_dl, *TI_dl1;
62
63         /* Clearing screen */
64         const char *TI_clear, *TI_ed; /* + *TI_dl, *TI_dl1; */
65
66         /* Clearing to end of line */
67         const char *TI_el;
68
69         /* Repeating character */
70         const char *TI_rep;
71
72         /* Colors */
73         int has_colors;
74         const char *TI_sgr0; /* turn off all attributes */
75         const char *TI_smul, *TI_rmul; /* underline on/off */
76         const char *TI_smso, *TI_rmso; /* standout on/off */
77         const char *TI_bold, *TI_blink;
78         const char *TI_setaf, *TI_setab, *TI_setf, *TI_setb;
79
80         /* Colors - generated and dynamically allocated */
81         char *TI_fg[16], *TI_bg[16], *TI_normal;
82
83         /* Beep */
84         char *TI_bel;
85 };
86
87 extern TERM_REC *current_term;
88
89 TERM_REC *terminfo_core_init(FILE *in, FILE *out);
90 void terminfo_core_deinit(TERM_REC *term);
91
92 /* Setup colors - if force is set, use ANSI-style colors if
93    terminal capabilities don't contain color codes */
94 void terminfo_setup_colors(TERM_REC *term, int force);
95
96 /* Terminal was resized - ask the width/height from terminfo again */
97 void terminfo_resize(TERM_REC *term);
98
99 void terminfo_cont(TERM_REC *term);
100 void terminfo_stop(TERM_REC *term);
101
102 #endif