]> git.proxmox.com Git - spiceterm.git/blame - spiceterm.h
d/control: fix priority-extra-is-replaced-by-priority-optional
[spiceterm.git] / spiceterm.h
CommitLineData
e3759a34
DM
1#include <glib.h>
2#include <spice.h>
22e5ba02
DM
3
4#define IBUFSIZE 1024
5#define MAX_ESC_PARAMS 16
6
e3759a34 7typedef struct TextAttributes {
44a22215
DM
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;
1d11aa12 15 unsigned int selected:1;
e3759a34 16} TextAttributes;
22e5ba02
DM
17
18typedef struct TextCell {
44a22215
DM
19 gunichar2 ch;
20 TextAttributes attrib;
22e5ba02
DM
21} TextCell;
22
c783f726 23#define COMMANDS_SIZE (1024)
baa9598b
DM
24#define MAX_HEIGHT 1440
25#define MAX_WIDTH 2560
e3759a34 26
68c2b067
DM
27typedef struct SpiceTermOptions {
28 guint timeout;
29 int port;
30 char *addr;
7f3ff8c0 31 char *keymap;
68c2b067 32 gboolean noauth;
68c2b067
DM
33} SpiceTermOptions;
34
64bc7a2f 35typedef struct SpiceScreen SpiceScreen;
e3759a34 36
e70e45a9
DM
37typedef struct CachedImage {
38 uint8_t *bitmap;
39 int cache_id;
40} CachedImage;
41
64bc7a2f 42struct SpiceScreen {
e3759a34
DM
43 SpiceCoreInterface *core;
44 SpiceServer *server;
45
46 QXLInstance qxl_instance;
47 QXLWorker *qxl_worker;
48
e3759a34
DM
49 uint8_t primary_surface[MAX_HEIGHT * MAX_WIDTH * 4];
50 int primary_height;
51 int primary_width;
52
53 SpiceTimer *conn_timeout_timer;
54 SpiceWatch *mwatch; /* watch master pty */
55
e3759a34
DM
56 // Current mode (set by create_primary)
57 int width;
58 int height;
59
b52b9534
DM
60 GCond command_cond;
61 GMutex command_mutex;
e3759a34
DM
62
63 int commands_end;
64 int commands_start;
65 struct QXLCommandExt* commands[COMMANDS_SIZE];
66
e70e45a9
DM
67 //cache for glyphs bitmaps
68 GHashTable *image_cache;
6508981f
DM
69
70 gboolean cursor_set;
e70e45a9 71
e3759a34 72 // callbacks
64bc7a2f
DM
73 void (*on_client_connected)(SpiceScreen *spice_screen);
74 void (*on_client_disconnected)(SpiceScreen *spice_screen);
e3759a34
DM
75};
76
68c2b067 77SpiceScreen* spice_screen_new(SpiceCoreInterface* core, uint32_t width, uint32_t height, SpiceTermOptions *opts);
e3759a34 78
8f53ae81 79void spice_screen_resize(SpiceScreen *spice_screen, uint32_t width, uint32_t height);
b052e9c7 80void spice_screen_draw_char(SpiceScreen *spice_screen, int x, int y, gunichar2 ch, TextAttributes attrib);
64bc7a2f
DM
81void spice_screen_scroll(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2, int src_x, int src_y);
82void spice_screen_clear(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2);
64bc7a2f
DM
83uint32_t spice_screen_get_width(void);
84uint32_t spice_screen_get_height(void);
e3759a34 85
d6a5f5a9 86typedef struct spiceTerm {
8f53ae81 87 int pty; // pty file descriptor
22e5ba02 88
44a22215
DM
89 int width;
90 int height;
22e5ba02 91
44a22215
DM
92 int total_height;
93 int scroll_height;
94 int y_base;
95 int y_displ;
96 int altbuf:1;
97
98 unsigned int utf8:1; // utf8 mode
05f253a6 99 gunichar utf_char; // used by utf8 parser
44a22215
DM
100 int utf_count; // used by utf8 parser
101
102 TextAttributes default_attrib;
103
104 TextCell *cells;
105 TextCell *altcells;
106
107 SpiceScreen *screen;
108 SpiceKbdInstance keyboard_sin;
109 SpiceCharDeviceInstance vdagent_sin;
110
111 // cursor
112 TextAttributes cur_attrib;
113 TextAttributes cur_attrib_saved;
5a100bdd 114 unsigned int tty_state; // 0 - normal, 1 - ESC, 2 - CSI
44a22215
DM
115 int cx; // cursor x position
116 int cy; // cursor y position
117 int cx_saved; // saved cursor x position
118 int cy_saved; // saved cursor y position
5a100bdd
DC
119 unsigned int esc_buf[MAX_ESC_PARAMS];
120 unsigned int esc_count;
121 unsigned int esc_ques;
122 unsigned int esc_has_par;
44a22215
DM
123 char osc_textbuf[4096];
124 char osc_cmd;
5a100bdd
DC
125 unsigned int region_top;
126 unsigned int region_bottom;
44a22215
DM
127
128 unsigned int charset:1; // G0 or G1
129 unsigned int charset_saved:1; // G0 or G1
130 unsigned int g0enc:2;
131 unsigned int g0enc_saved:2;
132 unsigned int g1enc:2;
133 unsigned int g1enc_saved:2;
134 unsigned int cur_enc:2;
135 unsigned int cur_enc_saved:2;
136
137 // input buffer
138 char ibuf[IBUFSIZE];
139 int ibuf_count;
140
141 gunichar2 *selection;
142 int selection_len;
143
144 unsigned int mark_active:1;
145
146 unsigned int report_mouse:1;
147
148} spiceTerm;
f424be98
DM
149
150void init_spiceterm(spiceTerm *vt, uint32_t width, uint32_t height);
151void spiceterm_refresh(spiceTerm *vt);
152
153void spiceterm_resize(spiceTerm *vt, uint32_t width, uint32_t height);
154void spiceterm_virtual_scroll(spiceTerm *vt, int lines);
155void spiceterm_clear_selection(spiceTerm *vt);
156void spiceterm_motion_event(spiceTerm *vt, uint32_t x, uint32_t y,
157 uint32_t buttons);
158
159void spiceterm_respond_esc(spiceTerm *vt, const char *esc);
160void spiceterm_respond_data(spiceTerm *vt, int len, uint8_t *data);
161void spiceterm_update_watch_mask(spiceTerm *vt, gboolean writable);
162
68c2b067 163spiceTerm *spiceterm_create(uint32_t width, uint32_t height, SpiceTermOptions *opts);
f424be98
DM
164
165gboolean vdagent_owns_clipboard(spiceTerm *vt);
166void vdagent_request_clipboard(spiceTerm *vt);
167void vdagent_grab_clipboard(spiceTerm *vt);
168
1631c5a9 169int pve_auth_verify(const char *clientip, const char *username, const char *passwd);
68c2b067
DM
170void pve_auth_set_path(char *path);
171void pve_auth_set_permissions(char *perm);
f424be98 172