Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/programs/conhost/conhost.h
4387 views
1
/*
2
* Copyright 1998 Alexandre Julliard
3
* Copyright 2001 Eric Pouech
4
* Copyright 2012 Detlef Riekenberg
5
* Copyright 2020 Jacek Caban
6
*
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20
*/
21
22
#ifndef RC_INVOKED
23
24
#include <stdarg.h>
25
#include <stdlib.h>
26
27
#include <ntstatus.h>
28
#define WIN32_NO_STATUS
29
#include <windef.h>
30
#include <winbase.h>
31
#include <winuser.h>
32
#include <winnls.h>
33
#include <winternl.h>
34
35
#include "wine/condrv.h"
36
#include "wine/rbtree.h"
37
38
struct history_line
39
{
40
size_t len;
41
WCHAR text[1];
42
};
43
44
struct font_info
45
{
46
short int width;
47
short int height;
48
short int weight;
49
short int pitch_family;
50
WCHAR *face_name;
51
size_t face_len;
52
};
53
54
struct edit_line
55
{
56
NTSTATUS status; /* edit status */
57
WCHAR *buf; /* the line being edited */
58
unsigned int len; /* number of chars in line */
59
size_t size; /* buffer size */
60
unsigned int cursor; /* offset for cursor in current line */
61
WCHAR *yanked; /* yanked line */
62
unsigned int mark; /* marked point (emacs mode only) */
63
unsigned int history_index; /* history index */
64
WCHAR *current_history; /* buffer for the recent history entry */
65
BOOL insert_key; /* insert key state */
66
BOOL insert_mode; /* insert mode */
67
unsigned int update_begin; /* update region */
68
unsigned int update_end;
69
unsigned int end_offset; /* offset of the last written char */
70
unsigned int home_x; /* home position */
71
unsigned int home_y;
72
unsigned int ctrl_mask; /* mask for ctrl characters for completion */
73
};
74
75
struct console
76
{
77
HANDLE server; /* console server handle */
78
unsigned int mode; /* input mode */
79
struct screen_buffer *active; /* active screen buffer */
80
int is_unix; /* UNIX terminal mode */
81
int use_relative_cursor; /* use relative cursor positioning */
82
int no_window; /* don't create console window */
83
INPUT_RECORD *records; /* input records */
84
unsigned int record_count; /* number of input records */
85
unsigned int record_size; /* size of input records buffer */
86
int signaled; /* is server in signaled state */
87
WCHAR *read_buffer; /* buffer of data available for read */
88
size_t read_buffer_count; /* size of available data */
89
size_t read_buffer_size; /* size of buffer */
90
unsigned int read_ioctl; /* current read ioctl */
91
size_t pending_read; /* size of pending read buffer */
92
struct edit_line edit_line; /* edit line context */
93
unsigned int key_state;
94
struct console_window *window;
95
WCHAR *title; /* console title */
96
WCHAR *title_orig; /* original console title */
97
struct history_line **history; /* lines history */
98
unsigned int history_size; /* number of entries in history array */
99
unsigned int history_index; /* number of used entries in history array */
100
unsigned int history_mode; /* mode of history (non zero means remove doubled strings */
101
unsigned int edition_mode; /* index to edition mode flavors */
102
unsigned int input_cp; /* console input codepage */
103
unsigned int output_cp; /* console output codepage */
104
HWND win; /* window handle if backend supports it */
105
HANDLE input_thread; /* input thread handle */
106
HANDLE tty_input; /* handle to tty input stream */
107
HANDLE tty_output; /* handle to tty output stream */
108
char tty_buffer[4096]; /* tty output buffer */
109
size_t tty_buffer_count; /* tty buffer size */
110
unsigned int tty_cursor_x; /* tty cursor position */
111
unsigned int tty_cursor_y;
112
unsigned int tty_attr; /* current tty char attributes */
113
int tty_cursor_visible; /* tty cursor visibility flag */
114
};
115
116
struct screen_buffer
117
{
118
struct console *console; /* console reference */
119
unsigned int id; /* screen buffer id */
120
unsigned int mode; /* output mode */
121
unsigned int width; /* size (w-h) of the screen buffer */
122
unsigned int height;
123
unsigned int cursor_size; /* size of cursor (percentage filled) */
124
unsigned int cursor_visible; /* cursor visibility flag */
125
unsigned int cursor_x; /* position of cursor */
126
unsigned int cursor_y; /* position of cursor */
127
unsigned short attr; /* default fill attributes (screen colors) */
128
unsigned short popup_attr; /* pop-up color attributes */
129
unsigned int max_width; /* size (w-h) of the window given font size */
130
unsigned int max_height;
131
char_info_t *data; /* the data for each cell - a width x height matrix */
132
unsigned int color_map[16]; /* color table */
133
RECT win; /* current visible window on the screen buffer */
134
struct font_info font; /* console font information */
135
struct wine_rb_entry entry; /* map entry */
136
};
137
138
/* conhost.c */
139
NTSTATUS write_console_input( struct console *console, const INPUT_RECORD *records,
140
unsigned int count, BOOL flush );
141
142
void notify_screen_buffer_size( struct screen_buffer *screen_buffer );
143
NTSTATUS change_screen_buffer_size( struct screen_buffer *screen_buffer, int new_width, int new_height );
144
145
/* window.c */
146
void update_console_font( struct console *console, const WCHAR *face_name, size_t face_name_size,
147
unsigned int height, unsigned int weight );
148
BOOL init_window( struct console *console );
149
void init_message_window( struct console *console );
150
void update_window_region( struct console *console, const RECT *update );
151
void update_window_config( struct console *console, BOOL delay );
152
153
static inline void empty_update_rect( struct screen_buffer *screen_buffer, RECT *rect )
154
{
155
SetRect( rect, screen_buffer->width, screen_buffer->height, 0, 0 );
156
}
157
158
static inline unsigned int get_bounded_cursor_x( struct screen_buffer *screen_buffer )
159
{
160
return min( screen_buffer->cursor_x, screen_buffer->width - 1 );
161
}
162
163
#endif /* RC_INVOKED */
164
165
/* strings */
166
#define IDS_EDIT 0x100
167
#define IDS_DEFAULT 0x101
168
#define IDS_PROPERTIES 0x102
169
170
#define IDS_MARK 0x110
171
#define IDS_COPY 0x111
172
#define IDS_PASTE 0x112
173
#define IDS_SELECTALL 0x113
174
#define IDS_SCROLL 0x114
175
#define IDS_SEARCH 0x115
176
177
#define IDS_DLG_TIT_DEFAULT 0x120
178
#define IDS_DLG_TIT_CURRENT 0x121
179
#define IDS_DLG_TIT_ERROR 0x122
180
181
#define IDS_DLG_ERR_SBWINSIZE 0x130
182
183
#define IDS_FNT_DISPLAY 0x200
184
#define IDS_FNT_PREVIEW 0x201
185
186
/* dialog boxes */
187
#define IDD_OPTION 0x0100
188
#define IDD_FONT 0x0200
189
#define IDD_CONFIG 0x0300
190
191
/* dialog boxes controls */
192
#define IDC_OPT_CURSOR_SMALL 0x0101
193
#define IDC_OPT_CURSOR_MEDIUM 0x0102
194
#define IDC_OPT_CURSOR_LARGE 0x0103
195
#define IDC_OPT_HIST_SIZE 0x0104
196
#define IDC_OPT_HIST_SIZE_UD 0x0105
197
#define IDC_OPT_HIST_NODOUBLE 0x0106
198
#define IDC_OPT_CONF_CTRL 0x0107
199
#define IDC_OPT_CONF_SHIFT 0x0108
200
#define IDC_OPT_QUICK_EDIT 0x0109
201
#define IDC_OPT_INSERT_MODE 0x0110
202
203
#define IDC_FNT_LIST_FONT 0x0201
204
#define IDC_FNT_LIST_SIZE 0x0202
205
#define IDC_FNT_COLOR_BK 0x0203
206
#define IDC_FNT_COLOR_FG 0x0204
207
#define IDC_FNT_FONT_INFO 0x0205
208
#define IDC_FNT_PREVIEW 0x0206
209
210
#define IDC_CNF_SB_WIDTH 0x0301
211
#define IDC_CNF_SB_WIDTH_UD 0x0302
212
#define IDC_CNF_SB_HEIGHT 0x0303
213
#define IDC_CNF_SB_HEIGHT_UD 0x0304
214
#define IDC_CNF_WIN_WIDTH 0x0305
215
#define IDC_CNF_WIN_WIDTH_UD 0x0306
216
#define IDC_CNF_WIN_HEIGHT 0x0307
217
#define IDC_CNF_WIN_HEIGHT_UD 0x0308
218
#define IDC_CNF_CLOSE_EXIT 0x0309
219
#define IDC_CNF_EDITION_MODE 0x030a
220
221