conhost.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. #ifndef RC_INVOKED
  22. #include <stdarg.h>
  23. #include <stdlib.h>
  24. #include <ntstatus.h>
  25. #define WIN32_NO_STATUS
  26. #include <windef.h>
  27. #include <winbase.h>
  28. #include <winuser.h>
  29. #include <winnls.h>
  30. #include <winternl.h>
  31. #include "wine/condrv.h"
  32. #include "wine/rbtree.h"
  33. struct history_line
  34. {
  35. size_t len;
  36. WCHAR text[1];
  37. };
  38. struct font_info
  39. {
  40. short int width;
  41. short int height;
  42. short int weight;
  43. short int pitch_family;
  44. WCHAR *face_name;
  45. size_t face_len;
  46. };
  47. struct edit_line
  48. {
  49. NTSTATUS status; /* edit status */
  50. WCHAR *buf; /* the line being edited */
  51. unsigned int len; /* number of chars in line */
  52. size_t size; /* buffer size */
  53. unsigned int cursor; /* offset for cursor in current line */
  54. WCHAR *yanked; /* yanked line */
  55. unsigned int mark; /* marked point (emacs mode only) */
  56. unsigned int history_index; /* history index */
  57. WCHAR *current_history; /* buffer for the recent history entry */
  58. BOOL insert_key; /* insert key state */
  59. BOOL insert_mode; /* insert mode */
  60. unsigned int update_begin; /* update region */
  61. unsigned int update_end;
  62. unsigned int end_offset; /* offset of the last written char */
  63. unsigned int home_x; /* home position */
  64. unsigned int home_y;
  65. };
  66. struct console
  67. {
  68. HANDLE server; /* console server handle */
  69. unsigned int mode; /* input mode */
  70. struct screen_buffer *active; /* active screen buffer */
  71. int is_unix; /* UNIX terminal mode */
  72. INPUT_RECORD *records; /* input records */
  73. unsigned int record_count; /* number of input records */
  74. unsigned int record_size; /* size of input records buffer */
  75. int signaled; /* is server in signaled state */
  76. WCHAR *read_buffer; /* buffer of data available for read */
  77. size_t read_buffer_count; /* size of available data */
  78. size_t read_buffer_size; /* size of buffer */
  79. unsigned int read_ioctl; /* current read ioctl */
  80. size_t pending_read; /* size of pending read buffer */
  81. struct edit_line edit_line; /* edit line context */
  82. struct console_window *window;
  83. WCHAR *title; /* console title */
  84. struct history_line **history; /* lines history */
  85. unsigned int history_size; /* number of entries in history array */
  86. unsigned int history_index; /* number of used entries in history array */
  87. unsigned int history_mode; /* mode of history (non zero means remove doubled strings */
  88. unsigned int edition_mode; /* index to edition mode flavors */
  89. unsigned int input_cp; /* console input codepage */
  90. unsigned int output_cp; /* console output codepage */
  91. HWND win; /* window handle if backend supports it */
  92. HANDLE input_thread; /* input thread handle */
  93. HANDLE tty_input; /* handle to tty input stream */
  94. HANDLE tty_output; /* handle to tty output stream */
  95. char tty_buffer[4096]; /* tty output buffer */
  96. size_t tty_buffer_count; /* tty buffer size */
  97. unsigned int tty_cursor_x; /* tty cursor position */
  98. unsigned int tty_cursor_y;
  99. unsigned int tty_attr; /* current tty char attributes */
  100. int tty_cursor_visible; /* tty cursor visibility flag */
  101. };
  102. struct screen_buffer
  103. {
  104. struct console *console; /* console reference */
  105. unsigned int id; /* screen buffer id */
  106. unsigned int mode; /* output mode */
  107. unsigned int width; /* size (w-h) of the screen buffer */
  108. unsigned int height;
  109. unsigned int cursor_size; /* size of cursor (percentage filled) */
  110. unsigned int cursor_visible; /* cursor visibility flag */
  111. unsigned int cursor_x; /* position of cursor */
  112. unsigned int cursor_y; /* position of cursor */
  113. unsigned short attr; /* default fill attributes (screen colors) */
  114. unsigned short popup_attr; /* pop-up color attributes */
  115. unsigned int max_width; /* size (w-h) of the window given font size */
  116. unsigned int max_height;
  117. char_info_t *data; /* the data for each cell - a width x height matrix */
  118. unsigned int color_map[16]; /* color table */
  119. RECT win; /* current visible window on the screen buffer */
  120. struct font_info font; /* console font information */
  121. struct wine_rb_entry entry; /* map entry */
  122. };
  123. BOOL init_window( struct console *console );
  124. void init_message_window( struct console *console );
  125. void update_window_region( struct console *console, const RECT *update );
  126. void update_window_config( struct console *console, BOOL delay );
  127. NTSTATUS write_console_input( struct console *console, const INPUT_RECORD *records,
  128. unsigned int count, BOOL flush );
  129. void notify_screen_buffer_size( struct screen_buffer *screen_buffer );
  130. NTSTATUS change_screen_buffer_size( struct screen_buffer *screen_buffer, int new_width, int new_height );
  131. static inline void empty_update_rect( struct screen_buffer *screen_buffer, RECT *rect )
  132. {
  133. SetRect( rect, screen_buffer->width, screen_buffer->height, 0, 0 );
  134. }
  135. static inline unsigned int get_bounded_cursor_x( struct screen_buffer *screen_buffer )
  136. {
  137. return min( screen_buffer->cursor_x, screen_buffer->width - 1 );
  138. }
  139. #endif /* RC_INVOKED */
  140. /* strings */
  141. #define IDS_EDIT 0x100
  142. #define IDS_DEFAULT 0x101
  143. #define IDS_PROPERTIES 0x102
  144. #define IDS_MARK 0x110
  145. #define IDS_COPY 0x111
  146. #define IDS_PASTE 0x112
  147. #define IDS_SELECTALL 0x113
  148. #define IDS_SCROLL 0x114
  149. #define IDS_SEARCH 0x115
  150. #define IDS_DLG_TIT_DEFAULT 0x120
  151. #define IDS_DLG_TIT_CURRENT 0x121
  152. #define IDS_DLG_TIT_ERROR 0x122
  153. #define IDS_DLG_ERR_SBWINSIZE 0x130
  154. #define IDS_FNT_DISPLAY 0x200
  155. #define IDS_FNT_PREVIEW 0x201
  156. /* dialog boxes */
  157. #define IDD_OPTION 0x0100
  158. #define IDD_FONT 0x0200
  159. #define IDD_CONFIG 0x0300
  160. #define IDD_SAVE_SETTINGS 0x0400
  161. /* dialog boxes controls */
  162. #define IDC_OPT_CURSOR_SMALL 0x0101
  163. #define IDC_OPT_CURSOR_MEDIUM 0x0102
  164. #define IDC_OPT_CURSOR_LARGE 0x0103
  165. #define IDC_OPT_HIST_SIZE 0x0104
  166. #define IDC_OPT_HIST_SIZE_UD 0x0105
  167. #define IDC_OPT_HIST_NODOUBLE 0x0106
  168. #define IDC_OPT_CONF_CTRL 0x0107
  169. #define IDC_OPT_CONF_SHIFT 0x0108
  170. #define IDC_OPT_QUICK_EDIT 0x0109
  171. #define IDC_OPT_INSERT_MODE 0x0110
  172. #define IDC_FNT_LIST_FONT 0x0201
  173. #define IDC_FNT_LIST_SIZE 0x0202
  174. #define IDC_FNT_COLOR_BK 0x0203
  175. #define IDC_FNT_COLOR_FG 0x0204
  176. #define IDC_FNT_FONT_INFO 0x0205
  177. #define IDC_FNT_PREVIEW 0x0206
  178. #define IDC_CNF_SB_WIDTH 0x0301
  179. #define IDC_CNF_SB_WIDTH_UD 0x0302
  180. #define IDC_CNF_SB_HEIGHT 0x0303
  181. #define IDC_CNF_SB_HEIGHT_UD 0x0304
  182. #define IDC_CNF_WIN_WIDTH 0x0305
  183. #define IDC_CNF_WIN_WIDTH_UD 0x0306
  184. #define IDC_CNF_WIN_HEIGHT 0x0307
  185. #define IDC_CNF_WIN_HEIGHT_UD 0x0308
  186. #define IDC_CNF_CLOSE_EXIT 0x0309
  187. #define IDC_CNF_EDITION_MODE 0x030a
  188. #define IDC_SAV_SAVE 0x0401
  189. #define IDC_SAV_SESSION 0x0402