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