summaryrefslogtreecommitdiffstats
path: root/src/windows/wintel/screen.h
blob: e3e7460c850cdb99045d53f952dc4fef237d6bbd (plain)
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
extern long PASCAL ScreenWndProc(HWND,UINT,WPARAM,LPARAM);

/*
*          Definition of attribute bits in the Virtual Screen
*
*          0   -   Bold
*          1   -
*          2   -
*          3   -   Underline
*          4   -   Blink
*          5   -
*          6   -   Reverse
*          7   -   Graphics character set
*
*/
#define SCR_isbold(x)   (x & 0x01)
#define SCR_isundl(x)   (x & 0x08)
#define SCR_isblnk(x)   (x & 0x10)
#define SCR_isrev(x)    (x & 0x40)
#define SCR_setrev(x)   (x ^= 0x40)
#define SCR_isgrph(x)   (x & 0x80)
#define SCR_inattr(x)   (x & 0xd9)
#define SCR_graph(x)    (x | 0x80)
#define SCR_notgraph(x) (x & 0x7F)

#define SCREEN_HANDLE            0    /* offset in extra window info */

#define WM_MYSCREENCHAR			(WM_USER+1)
#define WM_MYSCREENBLOCK		(WM_USER+2)
#define WM_MYSYSCHAR 			(WM_USER+3)
#define WM_MYSCREENCLOSE		(WM_USER+4)
#define WM_MYSCREENCHANGEBKSP	(WM_USER+5)
#define WM_MYSCREENSIZE			(WM_USER+6)
#define WM_NETWORKEVENT			(WM_USER+7)
#define WM_HOSTNAMEFOUND		(WM_USER+8)
#define WM_MYCURSORKEY			(WM_USER+9)

#define FRAME_HEIGHT ((2* GetSystemMetrics(SM_CYFRAME))+GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYMENU)+3)
#define FRAME_WIDTH  (2*GetSystemMetrics(SM_CXFRAME)+GetSystemMetrics(SM_CXVSCROLL))
#define TAB_SPACES 8
#define SPACE 32
#define ALERT 0x21
#define MAX_LINE_WIDTH 512 /* not restricted to 1 byte */

typedef struct SCREENLINE {
	struct SCREENLINE *next;
	struct SCREENLINE *prev;
	int width;
	char *text;
	char *attrib;
	char buffer[0];
} SCREENLINE;

typedef struct SCREEN {
	LPSTR title;
	HWND hWnd;
	HWND hwndTel;
	SCREENLINE *screen_top;
	SCREENLINE *screen_bottom;
	SCREENLINE *buffer_top;
	SCREENLINE *buffer_bottom;
	int ID;
	int type;
	int width;
	int height;
	int maxlines;       /* Maximum number of scrollback lines */
	int numlines;       /* Current number of scrollback lines */
	int savelines;      /* Save lines off top? */
	int ESscroll;       /* Scroll screen when ES received */
	int attrib;         /* current attribute */
	int x;              /* current cursor position */
	int y;              /* current cursor position */
	int Oldx;           /* internally used to redraw cursor */
	int Oldy;
	int Px;             /* saved cursor pos and attribute */
	int Py;
	int Pattrib;
	int VSIDC;          /* Insert/Delete character mode 0=draw line */
	int DECAWM;         /* AutoWrap mode 0=off */
	BOOL bWrapPending;  /* AutoWrap mode is on - wrap on next character */
	int DECCKM;         /* Cursor key mode */
	int DECPAM;         /* keyPad Application mode */
	int IRM;            /* Insert/Replace mode */
	int escflg;         /* Current Escape level */
	int top;            /* Vertical bounds of screen */
	int bottom;
	int parmptr;
	int cxChar;         /* Width of the current font */
	int cyChar;         /* Height of the current font */
	BOOL bAlert;
	int parms[6];       /* Ansi Params */
	LOGFONT lf;
	HFONT hSelectedFont;
	HFONT hSelectedULFont;
	char tabs[MAX_LINE_WIDTH];
	struct SCREEN *next;
	struct SCREEN *prev;
} SCREEN;

typedef struct CONFIG {
	LPSTR title;
	HWND hwndTel;
	int ID;
	int type;
	int height;
	int width;
	int maxlines;       /* Maximum number of scrollback lines */
	int backspace;
	int ESscroll;       /* Scroll screen when ES received */
	int VSIDC;          /* Insert/Delete character mode 0=draw line */
	int DECAWM;         /* AutoWrap mode 0=off */
	int IRM;            /* Insert/Replace mode */
} CONFIG;

#define TELNET_SCREEN   0
#define CONSOLE_SCREEN  1

#define IDM_FONT        100
#define IDM_BACKSPACE   101
#define IDM_DELETE      102
#define IDM_ABOUT       103
#define IDM_HELP_INDEX  104
#define IDM_EXIT        105

#define HELP_FILE "ktelnet.hlp"

#define IDM_COPY        200
#define IDM_PASTE       201
#define IDM_DEBUG       202

#define TIMER_TRIPLECLICK 1000

#define IDC_ALLOCFAIL           1
#define IDC_LOCKFAIL            2
#define IDC_LOADSTRINGFAIL      3
#define IDC_FONT                6

#define DESIREDPOINTSIZE 12

/*
Prototypes
*/
	void NEAR InitializeStruct(
		WORD wCommDlgType,
		LPSTR lpStruct,
		HWND hWnd);

	void ScreenInit(
		HINSTANCE hInstance);

	void SetScreenInstance(
		HINSTANCE hInstance);

	SCREENLINE *ScreenNewLine();

	void ScreenBell(
		SCREEN *pScr);

	void ScreenBackspace(
		SCREEN *pScr);

	void ScreenTab(
		SCREEN *pScr);

	void ScreenCarriageFeed(
		SCREEN *pScr);

	int ScreenScroll(
		SCREEN *pScr);

	void DeleteTopLine(
		SCREEN *pScr);

/*
emul.c
*/
	void ScreenEm(
		LPSTR c,
		int len,
		SCREEN *pScr);

/*
intern.c
*/
	SCREENLINE *GetScreenLineFromY(
		SCREEN *pScr,
		int y);

	SCREENLINE *ScreenClearLine(
		SCREEN *pScr,
		SCREENLINE *pScrLine);

	void ScreenUnscroll(
		SCREEN *pScr);

	void ScreenELO(
		SCREEN *pScr,
		int s);

	void ScreenEraseScreen(
		SCREEN *pScr);

	void ScreenTabClear(
		SCREEN *pScr);

	void ScreenTabInit(
		SCREEN *pScr);

	void ScreenReset(
		SCREEN *pScr);

	void ScreenIndex(
		SCREEN *pScr);

	void ScreenWrapNow(
		SCREEN *pScr,
		int *xp,
		int *yp);

	void ScreenEraseToEOL(
		SCREEN *pScr);

	void ScreenEraseToBOL(
		SCREEN *pScr);

	void ScreenEraseLine(
		SCREEN *pScr,
		int s);

	void ScreenEraseToEndOfScreen(
		SCREEN *pScr);

	void ScreenRange(
		SCREEN *pScr);

	void ScreenAlign(
		SCREEN *pScr);

	void ScreenApClear(
		SCREEN *pScr);

	void ScreenSetOption(
		SCREEN *pScr,
		int toggle);

	BOOL ScreenInsChar(
		SCREEN *pScr,
		int x);

	void ScreenSaveCursor(
		SCREEN *pScr);

	void ScreenRestoreCursor(
		SCREEN *pScr);

	void ScreenDraw(
		SCREEN *pScr,
		int x,
		int y,
		int a,
		int len,
		char *c);

	void ScreenCursorOff(
		SCREEN *pScr);

	void ScreenCursorOn(
		SCREEN *pScr);

	void ScreenDelChars(
		SCREEN *pScr,
		int n);

	void ScreenRevIndex(
		SCREEN *pScr);

	void ScreenDelLines(
		SCREEN *pScr,
		int n,
		int s);

	void ScreenInsLines(
		SCREEN *pScr,
		int n,
		int s);

	#if ! defined(NDEBUG)
		BOOL CheckScreen(
			SCREEN *pScr);
	#endif

	void ProcessFontChange(
		HWND hWnd);

	void Edit_LbuttonDown(
		HWND hWnd,
		LPARAM lParam);

	void Edit_LbuttonDblclk(
		HWND hWnd,
		LPARAM lParam);

	void Edit_LbuttonUp(
		HWND hWnd,
		LPARAM lParam);

	void Edit_TripleClick(
		HWND hWnd,
		LPARAM lParam);

	void Edit_MouseMove(
		HWND hWnd,
		LPARAM lParam);

	void Edit_ClearSelection(
		SCREEN *pScr);

	void Edit_Copy(
		HWND hWnd);

	void Edit_Paste(
		HWND hWnd);

	SCREEN *InitNewScreen(
		CONFIG *Config);