]>
Commit | Line | Data |
---|---|---|
e3759a34 DM |
1 | #ifndef __SPICETERM_H__ |
2 | #define __SPICETERM_H__ | |
3 | ||
4 | #include <glib.h> | |
5 | #include <spice.h> | |
22e5ba02 DM |
6 | |
7 | #define IBUFSIZE 1024 | |
8 | #define MAX_ESC_PARAMS 16 | |
9 | ||
e3759a34 DM |
10 | typedef struct TextAttributes { |
11 | unsigned int fgcol:4; | |
12 | unsigned int bgcol:4; | |
13 | unsigned int bold:1; | |
14 | unsigned int uline:1; | |
15 | unsigned int blink:1; | |
16 | unsigned int invers:1; | |
17 | unsigned int unvisible:1; | |
18 | } TextAttributes; | |
22e5ba02 DM |
19 | |
20 | typedef struct TextCell { | |
b052e9c7 | 21 | gunichar2 ch; |
22e5ba02 DM |
22 | TextAttributes attrib; |
23 | } TextCell; | |
24 | ||
e3759a34 DM |
25 | #define COMMANDS_SIZE 1024 |
26 | #define MAX_HEIGHT 2048 | |
27 | #define MAX_WIDTH 2048 | |
28 | ||
64bc7a2f | 29 | typedef struct SpiceScreen SpiceScreen; |
e3759a34 | 30 | |
64bc7a2f | 31 | struct SpiceScreen { |
e3759a34 DM |
32 | SpiceCoreInterface *core; |
33 | SpiceServer *server; | |
34 | ||
35 | QXLInstance qxl_instance; | |
36 | QXLWorker *qxl_worker; | |
37 | ||
e3759a34 DM |
38 | uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4]; |
39 | int primary_height; | |
40 | int primary_width; | |
41 | ||
42 | SpiceTimer *conn_timeout_timer; | |
43 | SpiceWatch *mwatch; /* watch master pty */ | |
44 | ||
45 | int cursor_notify; | |
46 | ||
47 | // Current mode (set by create_primary) | |
48 | int width; | |
49 | int height; | |
50 | ||
e3759a34 DM |
51 | GCond* command_cond; |
52 | GMutex* command_mutex; | |
53 | ||
54 | int commands_end; | |
55 | int commands_start; | |
56 | struct QXLCommandExt* commands[COMMANDS_SIZE]; | |
57 | ||
58 | // callbacks | |
64bc7a2f DM |
59 | void (*on_client_connected)(SpiceScreen *spice_screen); |
60 | void (*on_client_disconnected)(SpiceScreen *spice_screen); | |
e3759a34 DM |
61 | }; |
62 | ||
11ba14dc | 63 | SpiceScreen* spice_screen_new(SpiceCoreInterface* core, guint timeout); |
e3759a34 | 64 | |
b052e9c7 | 65 | void spice_screen_draw_char(SpiceScreen *spice_screen, int x, int y, gunichar2 ch, TextAttributes attrib); |
64bc7a2f DM |
66 | void spice_screen_scroll(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2, int src_x, int src_y); |
67 | void spice_screen_clear(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2); | |
e3759a34 DM |
68 | |
69 | ||
64bc7a2f DM |
70 | uint32_t spice_screen_get_width(void); |
71 | uint32_t spice_screen_get_height(void); | |
e3759a34 | 72 | |
d6a5f5a9 | 73 | typedef struct spiceTerm { |
22e5ba02 DM |
74 | int maxx; |
75 | int maxy; | |
76 | ||
77 | int width; | |
78 | int height; | |
79 | ||
80 | int total_height; | |
81 | int scroll_height; | |
82 | int y_base; | |
83 | int y_displ; | |
84 | int altbuf:1; | |
85 | ||
86 | unsigned int utf8:1; // utf8 mode | |
87 | long utf_char; // used by utf8 parser | |
88 | int utf_count; // used by utf8 parser | |
89 | ||
22e5ba02 DM |
90 | TextAttributes default_attrib; |
91 | ||
92 | TextCell *cells; | |
93 | TextCell *altcells; | |
94 | ||
64bc7a2f | 95 | SpiceScreen *screen; |
22e5ba02 | 96 | SpiceKbdInstance keyboard_sin; |
60b9ef63 | 97 | SpiceCharDeviceInstance vdagent_sin; |
22e5ba02 DM |
98 | |
99 | // cursor | |
100 | TextAttributes cur_attrib; | |
101 | TextAttributes cur_attrib_saved; | |
102 | int tty_state; // 0 - normal, 1 - ESC, 2 - CSI | |
103 | int cx; // cursor x position | |
104 | int cy; // cursor y position | |
105 | int cx_saved; // saved cursor x position | |
106 | int cy_saved; // saved cursor y position | |
107 | int esc_buf[MAX_ESC_PARAMS]; | |
108 | int esc_count; | |
109 | int esc_ques; | |
110 | int esc_has_par; | |
111 | char osc_textbuf[4096]; | |
112 | char osc_cmd; | |
113 | int region_top; | |
114 | int region_bottom; | |
115 | ||
116 | unsigned int charset:1; // G0 or G1 | |
117 | unsigned int charset_saved:1; // G0 or G1 | |
118 | unsigned int g0enc:2; | |
119 | unsigned int g0enc_saved:2; | |
120 | unsigned int g1enc:2; | |
121 | unsigned int g1enc_saved:2; | |
122 | unsigned int cur_enc:2; | |
123 | unsigned int cur_enc_saved:2; | |
124 | ||
125 | // input buffer | |
126 | char ibuf[IBUFSIZE]; | |
127 | int ibuf_count; | |
128 | ||
b052e9c7 | 129 | gunichar2 *selection; |
22e5ba02 DM |
130 | int selection_len; |
131 | ||
132 | unsigned int mark_active:1; | |
133 | ||
134 | unsigned int report_mouse:1; | |
135 | ||
d6a5f5a9 | 136 | } spiceTerm; |
22e5ba02 | 137 | |
e3759a34 | 138 | #endif /* __SPICETERM_H__ */ |