Merge Irssi 0.8.16-rc1
[silc.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 != 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, char 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_blink)(TERM_REC *term);
39         void (*set_bold)(TERM_REC *term);
40         void (*set_uline)(TERM_REC *term, int set);
41         void (*set_standout)(TERM_REC *term, int set);
42
43         void (*beep)(TERM_REC *term);
44
45 #ifndef HAVE_TERMINFO
46         char buffer1[1024], buffer2[1024];
47 #endif
48         FILE *in, *out;
49         struct termios tio, old_tio;
50
51         /* Terminal size */
52         int width, height;
53
54         /* Cursor movement */
55         const char *TI_smcup, *TI_rmcup, *TI_cup;
56         const char *TI_hpa, *TI_vpa, *TI_cub1, *TI_cuf1;
57         const char *TI_civis, *TI_cnorm;
58
59         /* Scrolling */
60         const char *TI_csr, *TI_wind;
61         const char *TI_ri, *TI_rin, *TI_ind, *TI_indn;
62         const char *TI_il, *TI_il1, *TI_dl, *TI_dl1;
63
64         /* Clearing screen */
65         const char *TI_clear, *TI_ed; /* + *TI_dl, *TI_dl1; */
66
67         /* Clearing to end of line */
68         const char *TI_el;
69
70         /* Repeating character */
71         const char *TI_rep;
72
73         /* Colors */
74         int TI_colors; /* numbers of colors in TI_fg[] and TI_bg[] */
75         const char *TI_sgr0; /* turn off all attributes */
76         const char *TI_smul, *TI_rmul; /* underline on/off */
77         const char *TI_smso, *TI_rmso; /* standout on/off */
78         const char *TI_bold, *TI_blink;
79         const char *TI_setaf, *TI_setab, *TI_setf, *TI_setb;
80
81         /* Colors - generated and dynamically allocated */
82         char **TI_fg, **TI_bg, *TI_normal;
83
84         /* Beep */
85         char *TI_bel;
86 };
87
88 extern TERM_REC *current_term;
89
90 TERM_REC *terminfo_core_init(FILE *in, FILE *out);
91 void terminfo_core_deinit(TERM_REC *term);
92
93 /* Setup colors - if force is set, use ANSI-style colors if
94    terminal capabilities don't contain color codes */
95 void terminfo_setup_colors(TERM_REC *term, int force);
96
97 void terminfo_cont(TERM_REC *term);
98 void terminfo_stop(TERM_REC *term);
99
100 #endif