]> git.proxmox.com Git - spiceterm.git/blob - spiceterm.h
0473712e201949ee8382b21016528128966e1892
[spiceterm.git] / spiceterm.h
1 #ifndef __SPICETERM_H__
2 #define __SPICETERM_H__
3
4 #include <glib.h>
5 #include <spice.h>
6
7 #define IBUFSIZE 1024
8 #define MAX_ESC_PARAMS 16
9
10 typedef unsigned short unicode; // fixme
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;
21
22 typedef struct TextCell {
23 unicode ch;
24 TextAttributes attrib;
25 } TextCell;
26
27 #define COMMANDS_SIZE 1024
28 #define MAX_HEIGHT 2048
29 #define MAX_WIDTH 2048
30
31 typedef struct Test Test;
32
33 struct Test {
34 SpiceCoreInterface *core;
35 SpiceServer *server;
36
37 QXLInstance qxl_instance;
38 QXLWorker *qxl_worker;
39
40 SpiceKbdInstance keyboard_sin;
41
42 uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4];
43 int primary_height;
44 int primary_width;
45
46 SpiceTimer *conn_timeout_timer;
47 SpiceWatch *mwatch; /* watch master pty */
48
49 int cursor_notify;
50
51 // Current mode (set by create_primary)
52 int width;
53 int height;
54
55 int target_surface;
56
57 GCond* command_cond;
58 GMutex* command_mutex;
59
60 int commands_end;
61 int commands_start;
62 struct QXLCommandExt* commands[COMMANDS_SIZE];
63
64 // callbacks
65 void (*on_client_connected)(Test *test);
66 void (*on_client_disconnected)(Test *test);
67 };
68
69 void test_add_display_interface(Test *test);
70 void test_add_agent_interface(SpiceServer *server); // TODO - Test *test
71 void test_add_keyboard_interface(Test *test);
72 Test* test_new(SpiceCoreInterface* core);
73
74 void test_draw_update_char(Test *test, int x, int y, gunichar ch, TextAttributes attrib);
75 void test_spice_scroll(Test *test, int x1, int y1, int x2, int y2, int src_x, int src_y);
76 void test_spice_clear(Test *test, int x1, int y1, int x2, int y2);
77
78
79 uint32_t test_get_width(void);
80 uint32_t test_get_height(void);
81
82 void spice_test_config_parse_args(int argc, char **argv);
83
84 typedef struct spiceTerm {
85 int maxx;
86 int maxy;
87
88 int width;
89 int height;
90
91 int total_height;
92 int scroll_height;
93 int y_base;
94 int y_displ;
95 int altbuf:1;
96
97 unsigned int utf8:1; // utf8 mode
98 long utf_char; // used by utf8 parser
99 int utf_count; // used by utf8 parser
100
101
102 TextAttributes default_attrib;
103
104 TextCell *cells;
105 TextCell *altcells;
106
107 Test *screen;
108 SpiceKbdInstance keyboard_sin;
109
110 // cursor
111 TextAttributes cur_attrib;
112 TextAttributes cur_attrib_saved;
113 int tty_state; // 0 - normal, 1 - ESC, 2 - CSI
114 int cx; // cursor x position
115 int cy; // cursor y position
116 int cx_saved; // saved cursor x position
117 int cy_saved; // saved cursor y position
118 int esc_buf[MAX_ESC_PARAMS];
119 int esc_count;
120 int esc_ques;
121 int esc_has_par;
122 char osc_textbuf[4096];
123 char osc_cmd;
124 int region_top;
125 int region_bottom;
126
127 unsigned int charset:1; // G0 or G1
128 unsigned int charset_saved:1; // G0 or G1
129 unsigned int g0enc:2;
130 unsigned int g0enc_saved:2;
131 unsigned int g1enc:2;
132 unsigned int g1enc_saved:2;
133 unsigned int cur_enc:2;
134 unsigned int cur_enc_saved:2;
135
136 // input buffer
137 char ibuf[IBUFSIZE];
138 int ibuf_count;
139
140 unicode *selection;
141 int selection_len;
142
143 unsigned int mark_active:1;
144
145 unsigned int report_mouse:1;
146
147 } spiceTerm;
148
149 #endif /* __SPICETERM_H__ */