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