]> git.proxmox.com Git - spiceterm.git/blame - spiceterm.h
use reasonable names (instead of 'test')
[spiceterm.git] / spiceterm.h
CommitLineData
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
e3759a34
DM
10typedef unsigned short unicode; // fixme
11
12typedef 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
22typedef struct TextCell {
23 unicode ch;
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 31typedef struct SpiceScreen SpiceScreen;
e3759a34 32
64bc7a2f 33struct SpiceScreen {
e3759a34
DM
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
64bc7a2f
DM
65 void (*on_client_connected)(SpiceScreen *spice_screen);
66 void (*on_client_disconnected)(SpiceScreen *spice_screen);
e3759a34
DM
67};
68
64bc7a2f 69SpiceScreen* spice_screen_new(SpiceCoreInterface* core);
e3759a34 70
64bc7a2f
DM
71void spice_screen_add_display_interface(SpiceScreen *spice_screen);
72void spice_screen_add_agent_interface(SpiceServer *server);
73void spice_screen_draw_char(SpiceScreen *spice_screen, int x, int y, gunichar ch, TextAttributes attrib);
74void spice_screen_scroll(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2, int src_x, int src_y);
75void spice_screen_clear(SpiceScreen *spice_screen, int x1, int y1, int x2, int y2);
e3759a34
DM
76
77
64bc7a2f
DM
78uint32_t spice_screen_get_width(void);
79uint32_t spice_screen_get_height(void);
e3759a34 80
d6a5f5a9 81typedef struct spiceTerm {
22e5ba02
DM
82 int maxx;
83 int maxy;
84
85 int width;
86 int height;
87
88 int total_height;
89 int scroll_height;
90 int y_base;
91 int y_displ;
92 int altbuf:1;
93
94 unsigned int utf8:1; // utf8 mode
95 long utf_char; // used by utf8 parser
96 int utf_count; // used by utf8 parser
97
98
99 TextAttributes default_attrib;
100
101 TextCell *cells;
102 TextCell *altcells;
103
64bc7a2f 104 SpiceScreen *screen;
22e5ba02
DM
105 SpiceKbdInstance keyboard_sin;
106
107 // cursor
108 TextAttributes cur_attrib;
109 TextAttributes cur_attrib_saved;
110 int tty_state; // 0 - normal, 1 - ESC, 2 - CSI
111 int cx; // cursor x position
112 int cy; // cursor y position
113 int cx_saved; // saved cursor x position
114 int cy_saved; // saved cursor y position
115 int esc_buf[MAX_ESC_PARAMS];
116 int esc_count;
117 int esc_ques;
118 int esc_has_par;
119 char osc_textbuf[4096];
120 char osc_cmd;
121 int region_top;
122 int region_bottom;
123
124 unsigned int charset:1; // G0 or G1
125 unsigned int charset_saved:1; // G0 or G1
126 unsigned int g0enc:2;
127 unsigned int g0enc_saved:2;
128 unsigned int g1enc:2;
129 unsigned int g1enc_saved:2;
130 unsigned int cur_enc:2;
131 unsigned int cur_enc_saved:2;
132
133 // input buffer
134 char ibuf[IBUFSIZE];
135 int ibuf_count;
136
137 unicode *selection;
138 int selection_len;
139
140 unsigned int mark_active:1;
141
142 unsigned int report_mouse:1;
143
d6a5f5a9 144} spiceTerm;
22e5ba02 145
e3759a34 146#endif /* __SPICETERM_H__ */