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