-
Notifications
You must be signed in to change notification settings - Fork 1
/
console.h
166 lines (137 loc) · 4.64 KB
/
console.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* console.h
*
* Copyright (c) 2003 Johannes E. Schindelin <[email protected]>
* Copyright (c) 2015-2017, Parallels International GmbH
* Copyright (c) 2017-2019 Virtuozzo International GmbH. All rights reserved.
*
* This file is part of OpenVZ. OpenVZ is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* Our contact details: Virtuozzo International GmbH, Vordergasse 59, 8200
* Schaffhausen, Switzerland.
*/
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <rfb/rfb.h>
/*
* * Possible attributes.
* */
#define XA_NORMAL 0
#define XA_BLINK 1
#define XA_BOLD 2
#define XA_REVERSE 4
#define XA_STANDOUT 8
#define XA_UNDERLINE 16
#define XA_ALTCHARSET 32
#define XA_BLANK 64
/*
* * Possible colors
* */
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define WHITE 7
/* this is now the default */
#define USE_ATTRIBUTE_BUFFER
typedef struct vncConsole {
/* width and height in cells (=characters) */
int width, height;
/* current position */
int x,y;
/* characters */
char *screenBuffer;
#ifdef USE_ATTRIBUTE_BUFFER
/* attributes: colours. If NULL, default to gray on black, else
for each cell an unsigned char holds foreColour|(backColour<<4) */
char *attributeBuffer;
#endif
/* if this is set, the screen doesn't scroll. */
rfbBool wrapBottomToTop;
/* height and width of one character */
int cWidth, cHeight;
/* offset of characters */
int xhot,yhot;
/* scroll region */
int sstart, sheight;
/* colour */
unsigned char foreColour,backColour;
int8_t cx1,cy1,cx2,cy2;
/* input buffer */
char *inputBuffer;
int inputCount;
int inputSize;
long selectTimeOut;
rfbBool doEcho; /* if reading input, do output directly? */
/* selection */
char *selection;
/* mouse */
rfbBool wasRightButtonDown;
rfbBool currentlyMarking;
int markStart,markEnd;
/* should text cursor be drawn? (an underscore at current position) */
rfbBool cursorActive;
rfbBool cursorIsDrawn;
rfbBool dontDrawCursor; /* for example, while scrolling */
rfbFontDataPtr font;
rfbScreenInfoPtr screen;
} vncConsole, *vncConsolePtr;
#ifdef USE_ATTRIBUTE_BUFFER
vncConsolePtr vcGetConsole(int *argc,char **argv,
int width,int height,rfbFontDataPtr font,
rfbBool withAttributes);
#else
vncConsolePtr vcGetConsole(int *argc,char **argv,
int width,int height,rfbFontDataPtr font);
#endif
void vcDrawCursor(vncConsolePtr c);
void vcHideCursor(vncConsolePtr c);
void vcCheckCoordinates(vncConsolePtr c);
void vcPutChar(vncConsolePtr c,unsigned char ch);
void vcPrint(vncConsolePtr c,unsigned char* str);
void vcPrintF(vncConsolePtr c,char* format,...);
void vcPutCharColour(vncConsolePtr c,unsigned char ch,
unsigned char foreColour,unsigned char backColour);
void vcPrintColour(vncConsolePtr c,unsigned char* str,
unsigned char foreColour,unsigned char backColour);
void vcPrintFColour(vncConsolePtr c,unsigned char foreColour,
unsigned char backColour,char* format,...);
char vcGetCh(vncConsolePtr c);
char vcGetChar(vncConsolePtr c); /* blocking */
char *vcGetString(vncConsolePtr c,char *buffer,int maxLen);
void vcInsertCharacters(vncConsolePtr c, int n);
void vcDeleteCharacters(vncConsolePtr c, int n);
void vcInsertLines(vncConsolePtr c, int from, int count);
void vcDeleteLines(vncConsolePtr c, int from, int count);
void vcKbdAddEventProc(rfbBool down,rfbKeySym keySym,rfbClientPtr cl);
void vcPtrAddEventProc(int buttonMask,int x,int y,rfbClientPtr cl);
void vcSetXCutTextProc(char* str,int len, struct _rfbClientRec* cl);
void vcToggleMarkCell(vncConsolePtr c,int pos);
void vcUnmark(vncConsolePtr c);
void vcProcessEvents(vncConsolePtr c);
/* before using this function, hide the cursor */
void vcScroll(vncConsolePtr c,int lineCount);
void vcReset(vncConsolePtr c);
#ifdef __cplusplus
}
#endif
#endif /* __CONSOLE_H__ */