Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Win32 kernel functions |
| 3 | * |
| 4 | * Copyright 1995 Martin von Loewis and Cameron Heide |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 5 | * Copyright 1997 Karl Garrison |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 6 | * Copyright 1998 John Richardson |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 7 | * Copyright 1998 Marcus Meissner |
| 8 | */ |
| 9 | |
| 10 | /* FIXME: |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 11 | * - Completely lacks SCREENBUFFER interface. |
| 12 | * - No abstraction for something other than xterm. |
| 13 | * - Key input translation shouldn't use VkKeyScan and MapVirtualKey, since |
| 14 | * they are window (USER) driver dependend. |
| 15 | * - Output sometimes is buffered (We switched off buffering by ~ICANON ?) |
| 16 | */ |
| 17 | /* Reference applications: |
| 18 | * - IDA (interactive disassembler) full version 3.75. Works. |
| 19 | * - LYNX/W32. Works mostly, some keys crash it. |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 22 | #include <stdlib.h> |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 23 | #include <unistd.h> |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 24 | #include <termios.h> |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 25 | #include <strings.h> |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 26 | #include <sys/ioctl.h> |
| 27 | #include <sys/types.h> |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 28 | #include <sys/time.h> |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 29 | #include <unistd.h> |
| 30 | #include <fcntl.h> |
| 31 | #include <errno.h> |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 32 | #include <sys/errno.h> |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 33 | #include <signal.h> |
| 34 | #include <assert.h> |
Marcus Meissner | ad7538b | 1998-12-14 18:15:10 +0000 | [diff] [blame] | 35 | |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 36 | #include "windows.h" |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 37 | #include "k32obj.h" |
Marcus Meissner | ad7538b | 1998-12-14 18:15:10 +0000 | [diff] [blame] | 38 | #include "thread.h" |
| 39 | #include "async.h" |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 40 | #include "file.h" |
| 41 | #include "process.h" |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 42 | #include "winerror.h" |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 43 | #include "wincon.h" |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 44 | #include "heap.h" |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 45 | #include "debug.h" |
| 46 | |
Alexandre Julliard | b2340ea | 1998-12-30 12:10:49 +0000 | [diff] [blame] | 47 | #include "server/request.h" |
| 48 | #include "server.h" |
| 49 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 50 | /* The CONSOLE kernel32 Object */ |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 51 | typedef struct _CONSOLE { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 52 | K32OBJ header; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 53 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 54 | INPUT_RECORD *irs; /* buffered input records */ |
| 55 | int nrofirs;/* nr of buffered input records */ |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 56 | } CONSOLE; |
| 57 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 58 | static void CONSOLE_Destroy( K32OBJ *obj ); |
| 59 | |
| 60 | const K32OBJ_OPS CONSOLE_Ops = |
| 61 | { |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 62 | CONSOLE_Destroy /* destroy */ |
| 63 | }; |
| 64 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 65 | /*********************************************************************** |
| 66 | * CONSOLE_Destroy |
| 67 | */ |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 68 | static void CONSOLE_Destroy(K32OBJ *obj) |
| 69 | { |
| 70 | CONSOLE *console = (CONSOLE *)obj; |
| 71 | assert(obj->type == K32OBJ_CONSOLE); |
| 72 | |
| 73 | obj->type = K32OBJ_UNKNOWN; |
| 74 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 75 | HeapFree(SystemHeap, 0, console); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 79 | /*********************************************************************** |
| 80 | * CONSOLE_GetPtr |
| 81 | */ |
| 82 | static CONSOLE *CONSOLE_GetPtr( HANDLE32 handle ) |
| 83 | { |
| 84 | return (CONSOLE*)HANDLE_GetObjPtr( PROCESS_Current(), handle, |
| 85 | K32OBJ_CONSOLE, 0, NULL ); |
| 86 | } |
| 87 | |
| 88 | /**************************************************************************** |
| 89 | * CONSOLE_GetInfo |
| 90 | */ |
| 91 | static BOOL32 CONSOLE_GetInfo( HANDLE32 handle, struct get_console_info_reply *reply ) |
| 92 | { |
| 93 | struct get_console_info_request req; |
| 94 | |
| 95 | if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), handle, |
| 96 | K32OBJ_CONSOLE, GENERIC_READ )) == -1) |
| 97 | return FALSE; |
| 98 | CLIENT_SendRequest( REQ_GET_CONSOLE_INFO, -1, 1, &req, sizeof(req) ); |
| 99 | return !CLIENT_WaitSimpleReply( reply, sizeof(*reply), NULL ); |
| 100 | } |
| 101 | |
| 102 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 103 | /**************************************************************************** |
| 104 | * CONSOLE_add_input_record [internal] |
| 105 | * |
| 106 | * Adds an INPUT_RECORD to the CONSOLEs input queue. |
| 107 | */ |
| 108 | static void |
| 109 | CONSOLE_add_input_record(CONSOLE *console,INPUT_RECORD *inp) { |
| 110 | console->irs = HeapReAlloc(GetProcessHeap(),0,console->irs,sizeof(INPUT_RECORD)*(console->nrofirs+1)); |
| 111 | console->irs[console->nrofirs++]=*inp; |
| 112 | } |
| 113 | |
| 114 | /**************************************************************************** |
| 115 | * XTERM_string_to_IR [internal] |
| 116 | * |
| 117 | * Transfers a string read from XTERM to INPUT_RECORDs and adds them to the |
| 118 | * queue. Does translation of vt100 style function keys and xterm-mouse clicks. |
| 119 | */ |
| 120 | static void |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 121 | CONSOLE_string_to_IR( HANDLE32 hConsoleInput,unsigned char *buf,int len) { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 122 | int j,k; |
| 123 | INPUT_RECORD ir; |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 124 | CONSOLE *console = CONSOLE_GetPtr( hConsoleInput ); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 125 | |
| 126 | for (j=0;j<len;j++) { |
| 127 | unsigned char inchar = buf[j]; |
| 128 | |
| 129 | if (inchar!=27) { /* no escape -> 'normal' keyboard event */ |
| 130 | ir.EventType = 1; /* Key_event */ |
| 131 | |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 132 | ir.Event.KeyEvent.bKeyDown = 1; |
| 133 | ir.Event.KeyEvent.wRepeatCount = 0; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 134 | |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 135 | ir.Event.KeyEvent.dwControlKeyState = 0; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 136 | if (inchar & 0x80) { |
| 137 | ir.Event.KeyEvent.dwControlKeyState|=LEFT_ALT_PRESSED; |
| 138 | inchar &= ~0x80; |
| 139 | } |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 140 | ir.Event.KeyEvent.wVirtualKeyCode = VkKeyScan16(inchar); |
| 141 | if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0100) |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 142 | ir.Event.KeyEvent.dwControlKeyState|=SHIFT_PRESSED; |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 143 | if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0200) |
| 144 | ir.Event.KeyEvent.dwControlKeyState|=LEFT_CTRL_PRESSED; |
| 145 | if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0400) |
| 146 | ir.Event.KeyEvent.dwControlKeyState|=LEFT_ALT_PRESSED; |
| 147 | ir.Event.KeyEvent.wVirtualScanCode = MapVirtualKey16( |
| 148 | ir.Event.KeyEvent.wVirtualKeyCode & 0x00ff, |
| 149 | 0 /* VirtualKeyCodes to ScanCode */ |
| 150 | ); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 151 | if (inchar=='\n') { |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 152 | ir.Event.KeyEvent.uChar.AsciiChar = '\r'; |
| 153 | ir.Event.KeyEvent.wVirtualKeyCode = 0x0d; |
| 154 | ir.Event.KeyEvent.wVirtualScanCode = 0x1c; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 155 | } else { |
| 156 | ir.Event.KeyEvent.uChar.AsciiChar = inchar; |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 157 | if (inchar<' ') { |
| 158 | /* FIXME: find good values for ^X */ |
| 159 | ir.Event.KeyEvent.wVirtualKeyCode = 0xdead; |
| 160 | ir.Event.KeyEvent.wVirtualScanCode = 0xbeef; |
| 161 | } |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | CONSOLE_add_input_record(console,&ir); |
| 165 | ir.Event.KeyEvent.bKeyDown = 0; |
| 166 | CONSOLE_add_input_record(console,&ir); |
| 167 | continue; |
| 168 | } |
| 169 | /* inchar is ESC */ |
| 170 | if ((j==len-1) || (buf[j+1]!='[')) {/* add ESCape on its own */ |
| 171 | ir.EventType = 1; /* Key_event */ |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 172 | ir.Event.KeyEvent.bKeyDown = 1; |
| 173 | ir.Event.KeyEvent.wRepeatCount = 0; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 174 | |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 175 | ir.Event.KeyEvent.wVirtualKeyCode = VkKeyScan16(27); |
| 176 | ir.Event.KeyEvent.wVirtualScanCode = MapVirtualKey16( |
| 177 | ir.Event.KeyEvent.wVirtualKeyCode,0 |
| 178 | ); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 179 | ir.Event.KeyEvent.dwControlKeyState = 0; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 180 | ir.Event.KeyEvent.uChar.AsciiChar = 27; |
| 181 | CONSOLE_add_input_record(console,&ir); |
| 182 | ir.Event.KeyEvent.bKeyDown = 0; |
| 183 | CONSOLE_add_input_record(console,&ir); |
| 184 | continue; |
| 185 | } |
| 186 | for (k=j;k<len;k++) { |
| 187 | if (((buf[k]>='A') && (buf[k]<='Z')) || |
| 188 | ((buf[k]>='a') && (buf[k]<='z')) || |
| 189 | (buf[k]=='~') |
| 190 | ) |
| 191 | break; |
| 192 | } |
| 193 | if (k<len) { |
| 194 | int subid,scancode=0; |
| 195 | |
| 196 | ir.EventType = 1; /* Key_event */ |
| 197 | ir.Event.KeyEvent.bKeyDown = 1; |
| 198 | ir.Event.KeyEvent.wRepeatCount = 0; |
| 199 | ir.Event.KeyEvent.dwControlKeyState = 0; |
| 200 | |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 201 | ir.Event.KeyEvent.wVirtualKeyCode = 0xad; /* FIXME */ |
| 202 | ir.Event.KeyEvent.wVirtualScanCode = 0xad; /* FIXME */ |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 203 | ir.Event.KeyEvent.uChar.AsciiChar = 0; |
| 204 | |
| 205 | switch (buf[k]) { |
| 206 | case '~': |
| 207 | sscanf(&buf[j+2],"%d",&subid); |
| 208 | switch (subid) { |
| 209 | case 2:/*INS */scancode = 0xe052;break; |
| 210 | case 3:/*DEL */scancode = 0xe053;break; |
| 211 | case 6:/*PGDW*/scancode = 0xe051;break; |
| 212 | case 5:/*PGUP*/scancode = 0xe049;break; |
| 213 | case 11:/*F1 */scancode = 0x003b;break; |
| 214 | case 12:/*F2 */scancode = 0x003c;break; |
| 215 | case 13:/*F3 */scancode = 0x003d;break; |
| 216 | case 14:/*F4 */scancode = 0x003e;break; |
| 217 | case 15:/*F5 */scancode = 0x003f;break; |
| 218 | case 17:/*F6 */scancode = 0x0040;break; |
| 219 | case 18:/*F7 */scancode = 0x0041;break; |
| 220 | case 19:/*F8 */scancode = 0x0042;break; |
| 221 | case 20:/*F9 */scancode = 0x0043;break; |
| 222 | case 21:/*F10 */scancode = 0x0044;break; |
| 223 | case 23:/*F11 */scancode = 0x00d9;break; |
| 224 | case 24:/*F12 */scancode = 0x00da;break; |
| 225 | /* FIXME: Shift-Fx */ |
| 226 | default: |
| 227 | FIXME(console,"parse ESC[%d~\n",subid); |
| 228 | break; |
| 229 | } |
| 230 | break; |
| 231 | case 'A': /* Cursor Up */scancode = 0xe048;break; |
| 232 | case 'B': /* Cursor Down */scancode = 0xe050;break; |
| 233 | case 'D': /* Cursor Left */scancode = 0xe04b;break; |
| 234 | case 'C': /* Cursor Right */scancode = 0xe04d;break; |
| 235 | case 'F': /* End */scancode = 0xe04f;break; |
| 236 | case 'H': /* Home */scancode = 0xe047;break; |
| 237 | case 'M': |
| 238 | /* Mouse Button Press (ESCM<button+'!'><x+'!'><y+'!'>) or |
| 239 | * Release (ESCM#<x+'!'><y+'!'> |
| 240 | */ |
| 241 | if (k<len-3) { |
| 242 | ir.EventType = MOUSE_EVENT; |
| 243 | ir.Event.MouseEvent.dwMousePosition.x = buf[k+2]-'!'; |
| 244 | ir.Event.MouseEvent.dwMousePosition.y = buf[k+3]-'!'; |
| 245 | if (buf[k+1]=='#') |
| 246 | ir.Event.MouseEvent.dwButtonState = 0; |
| 247 | else |
| 248 | ir.Event.MouseEvent.dwButtonState = 1<<(buf[k+1]-' '); |
| 249 | ir.Event.MouseEvent.dwEventFlags = 0; /* FIXME */ |
| 250 | CONSOLE_add_input_record(console,&ir); |
| 251 | j=k+3; |
| 252 | } |
| 253 | break; |
| 254 | |
| 255 | } |
| 256 | if (scancode) { |
| 257 | ir.Event.KeyEvent.wVirtualScanCode = scancode; |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 258 | ir.Event.KeyEvent.wVirtualKeyCode = MapVirtualKey16(scancode,1); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 259 | CONSOLE_add_input_record(console,&ir); |
| 260 | ir.Event.KeyEvent.bKeyDown = 0; |
| 261 | CONSOLE_add_input_record(console,&ir); |
| 262 | j=k; |
| 263 | continue; |
| 264 | } |
| 265 | } |
| 266 | } |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 267 | K32OBJ_DecCount(&console->header); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 268 | } |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 269 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 270 | /**************************************************************************** |
| 271 | * CONSOLE_get_input (internal) |
| 272 | * |
| 273 | * Reads (nonblocking) as much input events as possible and stores them |
| 274 | * in an internal queue. |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 275 | */ |
| 276 | static void |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 277 | CONSOLE_get_input( HANDLE32 handle ) |
| 278 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 279 | char *buf = HeapAlloc(GetProcessHeap(),0,1); |
| 280 | int len = 0; |
| 281 | |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 282 | while (1) |
| 283 | { |
| 284 | DWORD res; |
| 285 | char inchar; |
Marcus Meissner | ba8e2a3 | 1999-01-03 16:18:33 +0000 | [diff] [blame] | 286 | if (WaitForSingleObject( handle, 0 )) break; |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 287 | if (!ReadFile( handle, &inchar, 1, &res, NULL )) break; |
Marcus Meissner | 03f10f4 | 1999-01-26 10:08:36 +0000 | [diff] [blame^] | 288 | if (!res) /* res 0 but readable means EOF? Hmm. */ |
| 289 | break; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 290 | buf = HeapReAlloc(GetProcessHeap(),0,buf,len+1); |
| 291 | buf[len++]=inchar; |
| 292 | } |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 293 | CONSOLE_string_to_IR(handle,buf,len); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 294 | HeapFree(GetProcessHeap(),0,buf); |
| 295 | } |
| 296 | |
| 297 | /**************************************************************************** |
| 298 | * CONSOLE_drain_input (internal) |
| 299 | * |
| 300 | * Drains 'n' console input events from the queue. |
| 301 | */ |
| 302 | static void |
| 303 | CONSOLE_drain_input(CONSOLE *console,int n) { |
| 304 | assert(n<=console->nrofirs); |
| 305 | if (n) { |
| 306 | console->nrofirs-=n; |
| 307 | memcpy( &console->irs[0], |
| 308 | &console->irs[n], |
| 309 | console->nrofirs*sizeof(INPUT_RECORD) |
| 310 | ); |
| 311 | console->irs = HeapReAlloc( |
| 312 | GetProcessHeap(), |
| 313 | 0, |
| 314 | console->irs, |
| 315 | console->nrofirs*sizeof(INPUT_RECORD) |
| 316 | ); |
| 317 | } |
| 318 | } |
| 319 | |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 320 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 321 | /****************************************************************************** |
| 322 | * SetConsoleCtrlHandler [KERNEL32.459] Adds function to calling process list |
| 323 | * |
| 324 | * PARAMS |
| 325 | * func [I] Address of handler function |
| 326 | * add [I] Handler to add or remove |
| 327 | * |
| 328 | * RETURNS |
| 329 | * Success: TRUE |
| 330 | * Failure: FALSE |
James Sutherland | 577db37 | 1998-11-08 15:09:08 +0000 | [diff] [blame] | 331 | * |
| 332 | * CHANGED |
| 333 | * James Sutherland (JamesSutherland@gmx.de) |
| 334 | * Added global variables console_ignore_ctrl_c and handlers[] |
| 335 | * Does not yet do any error checking, or set LastError if failed. |
| 336 | * This doesn't yet matter, since these handlers are not yet called...! |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 337 | */ |
James Sutherland | 577db37 | 1998-11-08 15:09:08 +0000 | [diff] [blame] | 338 | static unsigned int console_ignore_ctrl_c = 0; |
| 339 | static HANDLER_ROUTINE *handlers[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 340 | BOOL32 WINAPI SetConsoleCtrlHandler( HANDLER_ROUTINE *func, BOOL32 add ) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 341 | { |
James Sutherland | 577db37 | 1998-11-08 15:09:08 +0000 | [diff] [blame] | 342 | unsigned int alloc_loop = sizeof(handlers)/sizeof(HANDLER_ROUTINE *); |
| 343 | unsigned int done = 0; |
| 344 | FIXME(console, "(%p,%i) - no error checking or testing yet\n", func, add); |
| 345 | if (!func) |
| 346 | { |
| 347 | console_ignore_ctrl_c = add; |
| 348 | return TRUE; |
| 349 | } |
| 350 | if (add) |
| 351 | { |
| 352 | for (;alloc_loop--;) |
| 353 | if (!handlers[alloc_loop] && !done) |
| 354 | { |
| 355 | handlers[alloc_loop] = func; |
| 356 | done++; |
| 357 | } |
| 358 | if (!done) |
| 359 | FIXME(console, "Out of space on CtrlHandler table\n"); |
| 360 | return(done); |
| 361 | } |
| 362 | else |
| 363 | { |
| 364 | for (;alloc_loop--;) |
| 365 | if (handlers[alloc_loop] == func && !done) |
| 366 | { |
| 367 | handlers[alloc_loop] = 0; |
| 368 | done++; |
| 369 | } |
| 370 | if (!done) |
Huw D M Davies | 7b06d98 | 1998-11-14 17:13:51 +0000 | [diff] [blame] | 371 | WARN(console, "Attempt to remove non-installed CtrlHandler %p\n", |
| 372 | func); |
James Sutherland | 577db37 | 1998-11-08 15:09:08 +0000 | [diff] [blame] | 373 | return (done); |
| 374 | } |
| 375 | return (done); |
| 376 | } |
| 377 | |
| 378 | |
| 379 | /****************************************************************************** |
| 380 | * GenerateConsoleCtrlEvent [KERNEL32.275] Simulate a CTRL-C or CTRL-BREAK |
| 381 | * |
| 382 | * PARAMS |
| 383 | * dwCtrlEvent [I] Type of event |
| 384 | * dwProcessGroupID [I] Process group ID to send event to |
| 385 | * |
| 386 | * NOTES |
| 387 | * Doesn't yet work...! |
| 388 | * |
| 389 | * RETURNS |
| 390 | * Success: True |
| 391 | * Failure: False (and *should* [but doesn't] set LastError) |
| 392 | */ |
| 393 | BOOL32 WINAPI GenerateConsoleCtrlEvent( DWORD dwCtrlEvent, |
| 394 | DWORD dwProcessGroupID ) |
| 395 | { |
| 396 | if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT) |
| 397 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 398 | ERR( console, "invalid event %d for PGID %ld\n", |
James Sutherland | 577db37 | 1998-11-08 15:09:08 +0000 | [diff] [blame] | 399 | (unsigned short)dwCtrlEvent, dwProcessGroupID ); |
| 400 | return FALSE; |
| 401 | } |
| 402 | if (dwProcessGroupID == GetCurrentProcessId() ) |
| 403 | { |
| 404 | FIXME( console, "Attempt to send event %d to self - stub\n", |
| 405 | (unsigned short)dwCtrlEvent ); |
| 406 | return FALSE; |
| 407 | } |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 408 | FIXME( console,"event %d to external PGID %ld - not implemented yet\n", |
James Sutherland | 577db37 | 1998-11-08 15:09:08 +0000 | [diff] [blame] | 409 | (unsigned short)dwCtrlEvent, dwProcessGroupID ); |
| 410 | return FALSE; |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 411 | } |
| 412 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 413 | |
| 414 | /****************************************************************************** |
| 415 | * CreateConsoleScreenBuffer [KERNEL32.151] Creates a console screen buffer |
| 416 | * |
| 417 | * PARAMS |
| 418 | * dwDesiredAccess [I] Access flag |
| 419 | * dwShareMode [I] Buffer share mode |
| 420 | * sa [I] Security attributes |
| 421 | * dwFlags [I] Type of buffer to create |
| 422 | * lpScreenBufferData [I] Reserved |
| 423 | * |
| 424 | * NOTES |
| 425 | * Should call SetLastError |
| 426 | * |
| 427 | * RETURNS |
| 428 | * Success: Handle to new console screen buffer |
| 429 | * Failure: INVALID_HANDLE_VALUE |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 430 | */ |
| 431 | HANDLE32 WINAPI CreateConsoleScreenBuffer( DWORD dwDesiredAccess, |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 432 | DWORD dwShareMode, LPSECURITY_ATTRIBUTES sa, |
| 433 | DWORD dwFlags, LPVOID lpScreenBufferData ) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 434 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 435 | FIXME(console, "(%ld,%ld,%p,%ld,%p): stub\n",dwDesiredAccess, |
| 436 | dwShareMode, sa, dwFlags, lpScreenBufferData); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 437 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); |
| 438 | return INVALID_HANDLE_VALUE32; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 439 | } |
| 440 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 441 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 442 | /*********************************************************************** |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 443 | * GetConsoleScreenBufferInfo (KERNEL32.190) |
| 444 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 445 | BOOL32 WINAPI GetConsoleScreenBufferInfo( HANDLE32 hConsoleOutput, |
| 446 | LPCONSOLE_SCREEN_BUFFER_INFO csbi ) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 447 | { |
| 448 | csbi->dwSize.x = 80; |
| 449 | csbi->dwSize.y = 24; |
| 450 | csbi->dwCursorPosition.x = 0; |
| 451 | csbi->dwCursorPosition.y = 0; |
| 452 | csbi->wAttributes = 0; |
| 453 | csbi->srWindow.Left = 0; |
| 454 | csbi->srWindow.Right = 79; |
| 455 | csbi->srWindow.Top = 0; |
| 456 | csbi->srWindow.Bottom = 23; |
| 457 | csbi->dwMaximumWindowSize.x = 80; |
| 458 | csbi->dwMaximumWindowSize.y = 24; |
| 459 | return TRUE; |
| 460 | } |
| 461 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 462 | |
| 463 | /****************************************************************************** |
| 464 | * SetConsoleActiveScreenBuffer [KERNEL32.623] Sets buffer to current console |
| 465 | * |
| 466 | * RETURNS |
| 467 | * Success: TRUE |
| 468 | * Failure: FALSE |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 469 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 470 | BOOL32 WINAPI SetConsoleActiveScreenBuffer( |
| 471 | HANDLE32 hConsoleOutput) /* [in] Handle to console screen buffer */ |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 472 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 473 | FIXME(console, "(%x): stub\n", hConsoleOutput); |
| 474 | return FALSE; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 475 | } |
| 476 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 477 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 478 | /*********************************************************************** |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 479 | * GetLargestConsoleWindowSize (KERNEL32.226) |
| 480 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 481 | DWORD WINAPI GetLargestConsoleWindowSize( HANDLE32 hConsoleOutput ) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 482 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 483 | return (DWORD)MAKELONG(80,24); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 484 | } |
| 485 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 486 | /*********************************************************************** |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 487 | * FreeConsole (KERNEL32.267) |
| 488 | */ |
| 489 | BOOL32 WINAPI FreeConsole(VOID) |
| 490 | { |
| 491 | |
| 492 | PDB32 *pdb = PROCESS_Current(); |
| 493 | CONSOLE *console; |
| 494 | |
| 495 | SYSTEM_LOCK(); |
| 496 | |
| 497 | console = (CONSOLE *)pdb->console; |
| 498 | |
| 499 | if (console == NULL) { |
| 500 | SetLastError(ERROR_INVALID_PARAMETER); |
| 501 | return FALSE; |
| 502 | } |
| 503 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 504 | CLIENT_SendRequest( REQ_FREE_CONSOLE, -1, 0 ); |
| 505 | if (CLIENT_WaitReply( NULL, NULL, 0 ) != ERROR_SUCCESS) |
| 506 | { |
| 507 | K32OBJ_DecCount(&console->header); |
| 508 | SYSTEM_UNLOCK(); |
| 509 | return FALSE; |
| 510 | } |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 511 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 512 | HANDLE_CloseAll( pdb, &console->header ); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 513 | K32OBJ_DecCount( &console->header ); |
| 514 | pdb->console = NULL; |
| 515 | SYSTEM_UNLOCK(); |
| 516 | return TRUE; |
| 517 | } |
| 518 | |
| 519 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 520 | /************************************************************************* |
| 521 | * CONSOLE_OpenHandle |
| 522 | * |
| 523 | * Open a handle to the current process console. |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 524 | */ |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 525 | HANDLE32 CONSOLE_OpenHandle( BOOL32 output, DWORD access, LPSECURITY_ATTRIBUTES sa ) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 526 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 527 | struct open_console_request req; |
| 528 | struct open_console_reply reply; |
| 529 | CONSOLE *console; |
| 530 | HANDLE32 handle; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 531 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 532 | req.output = output; |
| 533 | req.access = access; |
| 534 | req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); |
| 535 | CLIENT_SendRequest( REQ_OPEN_CONSOLE, -1, 1, &req, sizeof(req) ); |
| 536 | CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ); |
| 537 | if (reply.handle == -1) return INVALID_HANDLE_VALUE32; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 538 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 539 | SYSTEM_LOCK(); |
| 540 | if (!(console = (CONSOLE*)HeapAlloc( SystemHeap, 0, sizeof(*console)))) |
| 541 | { |
| 542 | SYSTEM_UNLOCK(); |
| 543 | return FALSE; |
| 544 | } |
| 545 | console->header.type = K32OBJ_CONSOLE; |
| 546 | console->header.refcount = 1; |
| 547 | console->nrofirs = 0; |
| 548 | console->irs = HeapAlloc(GetProcessHeap(),0,1);; |
| 549 | handle = HANDLE_Alloc( PROCESS_Current(), &console->header, req.access, |
| 550 | req.inherit, reply.handle ); |
| 551 | SYSTEM_UNLOCK(); |
| 552 | K32OBJ_DecCount(&console->header); |
| 553 | return handle; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 556 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 557 | /************************************************************************* |
| 558 | * CONSOLE_make_complex [internal] |
| 559 | * |
| 560 | * Turns a CONSOLE kernel object into a complex one. |
| 561 | * (switches from output/input using the terminal where WINE was started to |
| 562 | * its own xterm). |
| 563 | * |
| 564 | * This makes simple commandline tools pipeable, while complex commandline |
| 565 | * tools work without getting messed up by debugoutput. |
| 566 | * |
| 567 | * All other functions should work indedependend from this call. |
| 568 | * |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 569 | * To test for complex console: pid == 0 -> simple, otherwise complex. |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 570 | */ |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 571 | static BOOL32 CONSOLE_make_complex(HANDLE32 handle) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 572 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 573 | struct set_console_fd_request req; |
| 574 | struct get_console_info_reply info; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 575 | struct termios term; |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 576 | char buf[256]; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 577 | char c = '\0'; |
| 578 | int status = 0; |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 579 | int i,xpid,master,slave; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 580 | DWORD xlen; |
| 581 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 582 | if (!CONSOLE_GetInfo( handle, &info )) return FALSE; |
| 583 | if (info.pid) return TRUE; /* already complex */ |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 584 | |
| 585 | MSG("Console: Making console complex (creating an xterm)...\n"); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 586 | |
Marcus Meissner | 03f10f4 | 1999-01-26 10:08:36 +0000 | [diff] [blame^] | 587 | if (tcgetattr(0, &term) < 0) { |
| 588 | /* ignore failure, or we can't run from a script */ |
| 589 | } |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 590 | term.c_lflag = ~(ECHO|ICANON); |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 591 | |
| 592 | if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), handle, |
| 593 | K32OBJ_CONSOLE, 0 )) == -1) |
| 594 | return FALSE; |
| 595 | |
| 596 | if (wine_openpty(&master, &slave, NULL, &term, NULL) < 0) |
| 597 | return FALSE; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 598 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 599 | if ((xpid=fork()) == 0) { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 600 | tcsetattr(slave, TCSADRAIN, &term); |
| 601 | sprintf(buf, "-Sxx%d", master); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 602 | /* "-fn vga" for VGA font. Harmless if vga is not present: |
| 603 | * xterm: unable to open font "vga", trying "fixed".... |
| 604 | */ |
| 605 | execlp("xterm", "xterm", buf, "-fn","vga",NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 606 | ERR(console, "error creating AllocConsole xterm\n"); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 607 | exit(1); |
| 608 | } |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 609 | |
| 610 | req.pid = xpid; |
| 611 | CLIENT_SendRequest( REQ_SET_CONSOLE_FD, dup(slave), 1, &req, sizeof(req) ); |
| 612 | CLIENT_WaitReply( NULL, NULL, 0 ); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 613 | |
| 614 | /* most xterms like to print their window ID when used with -S; |
| 615 | * read it and continue before the user has a chance... |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 616 | */ |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 617 | for (i=0; c!='\n'; (status=read(slave, &c, 1)), i++) { |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 618 | if (status == -1 && c == '\0') { |
| 619 | /* wait for xterm to be created */ |
| 620 | usleep(100); |
| 621 | } |
| 622 | if (i > 10000) { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 623 | ERR(console, "can't read xterm WID\n"); |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 624 | kill(xpid, SIGKILL); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 625 | return FALSE; |
| 626 | } |
| 627 | } |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 628 | /* enable mouseclicks */ |
| 629 | sprintf(buf,"%c[?1001s%c[?1000h",27,27); |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 630 | WriteFile(handle,buf,strlen(buf),&xlen,NULL); |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 631 | |
| 632 | if (GetConsoleTitle32A( buf, sizeof(buf) )) |
| 633 | { |
| 634 | WriteFile(handle,"\033]2;",4,&xlen,NULL); |
| 635 | WriteFile(handle,buf,strlen(buf),&xlen,NULL); |
| 636 | WriteFile(handle,"\a",1,&xlen,NULL); |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 637 | } |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 638 | return TRUE; |
| 639 | |
| 640 | } |
| 641 | |
| 642 | |
| 643 | /*********************************************************************** |
| 644 | * AllocConsole (KERNEL32.103) |
| 645 | * |
| 646 | * creates an xterm with a pty to our program |
| 647 | */ |
| 648 | BOOL32 WINAPI AllocConsole(VOID) |
| 649 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 650 | struct open_console_request req; |
| 651 | struct open_console_reply reply; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 652 | PDB32 *pdb = PROCESS_Current(); |
| 653 | CONSOLE *console; |
| 654 | HANDLE32 hIn, hOut, hErr; |
| 655 | |
| 656 | SYSTEM_LOCK(); /* FIXME: really only need to lock the process */ |
| 657 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 658 | console = (CONSOLE *)pdb->console; |
| 659 | |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 660 | /* don't create a console if we already have one */ |
| 661 | if (console != NULL) { |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 662 | SetLastError(ERROR_ACCESS_DENIED); |
| 663 | SYSTEM_UNLOCK(); |
| 664 | return FALSE; |
| 665 | } |
| 666 | |
| 667 | if (!(console = (CONSOLE*)HeapAlloc( SystemHeap, 0, sizeof(*console)))) |
| 668 | { |
| 669 | SYSTEM_UNLOCK(); |
| 670 | return FALSE; |
| 671 | } |
| 672 | |
| 673 | console->header.type = K32OBJ_CONSOLE; |
| 674 | console->header.refcount = 1; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 675 | console->nrofirs = 0; |
| 676 | console->irs = HeapAlloc(GetProcessHeap(),0,1);; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 677 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 678 | CLIENT_SendRequest( REQ_ALLOC_CONSOLE, -1, 0 ); |
| 679 | if (CLIENT_WaitReply( NULL, NULL, 0 ) != ERROR_SUCCESS) |
| 680 | { |
| 681 | K32OBJ_DecCount(&console->header); |
| 682 | SYSTEM_UNLOCK(); |
| 683 | return FALSE; |
| 684 | } |
| 685 | |
| 686 | req.output = 0; |
Marcus Meissner | fbc5625 | 1999-01-20 14:46:49 +0000 | [diff] [blame] | 687 | req.access = GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE; |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 688 | req.inherit = FALSE; |
| 689 | CLIENT_SendRequest( REQ_OPEN_CONSOLE, -1, 1, &req, sizeof(req) ); |
Alexandre Julliard | 6ebbe3c | 1999-01-01 17:04:00 +0000 | [diff] [blame] | 690 | if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ) != ERROR_SUCCESS) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 691 | { |
| 692 | K32OBJ_DecCount(&console->header); |
| 693 | SYSTEM_UNLOCK(); |
| 694 | return FALSE; |
Alexandre Julliard | b2340ea | 1998-12-30 12:10:49 +0000 | [diff] [blame] | 695 | } |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 696 | if ((hIn = HANDLE_Alloc(pdb,&console->header, req.access, |
| 697 | FALSE, reply.handle)) == INVALID_HANDLE_VALUE32) |
Alexandre Julliard | b2340ea | 1998-12-30 12:10:49 +0000 | [diff] [blame] | 698 | { |
Alexandre Julliard | b2340ea | 1998-12-30 12:10:49 +0000 | [diff] [blame] | 699 | K32OBJ_DecCount(&console->header); |
| 700 | SYSTEM_UNLOCK(); |
| 701 | return FALSE; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 702 | } |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 703 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 704 | req.output = 1; |
| 705 | CLIENT_SendRequest( REQ_OPEN_CONSOLE, -1, 1, &req, sizeof(req) ); |
| 706 | if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ) != ERROR_SUCCESS) |
| 707 | { |
| 708 | CloseHandle(hIn); |
| 709 | K32OBJ_DecCount(&console->header); |
| 710 | SYSTEM_UNLOCK(); |
| 711 | return FALSE; |
| 712 | } |
| 713 | if ((hOut = HANDLE_Alloc(pdb,&console->header, req.access, |
| 714 | FALSE, reply.handle)) == INVALID_HANDLE_VALUE32) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 715 | { |
| 716 | CloseHandle(hIn); |
| 717 | K32OBJ_DecCount(&console->header); |
| 718 | SYSTEM_UNLOCK(); |
| 719 | return FALSE; |
| 720 | } |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 721 | |
Alexandre Julliard | b2340ea | 1998-12-30 12:10:49 +0000 | [diff] [blame] | 722 | if (!DuplicateHandle( GetCurrentProcess(), hOut, |
| 723 | GetCurrentProcess(), &hErr, |
| 724 | 0, TRUE, DUPLICATE_SAME_ACCESS )) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 725 | { |
| 726 | CloseHandle(hIn); |
| 727 | CloseHandle(hOut); |
| 728 | K32OBJ_DecCount(&console->header); |
| 729 | SYSTEM_UNLOCK(); |
| 730 | return FALSE; |
| 731 | } |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 732 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 733 | if (pdb->console) K32OBJ_DecCount( pdb->console ); |
| 734 | pdb->console = (K32OBJ *)console; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 735 | K32OBJ_IncCount( pdb->console ); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 736 | |
| 737 | /* NT resets the STD_*_HANDLEs on console alloc */ |
| 738 | SetStdHandle(STD_INPUT_HANDLE, hIn); |
| 739 | SetStdHandle(STD_OUTPUT_HANDLE, hOut); |
| 740 | SetStdHandle(STD_ERROR_HANDLE, hErr); |
| 741 | |
| 742 | SetLastError(ERROR_SUCCESS); |
| 743 | SYSTEM_UNLOCK(); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 744 | SetConsoleTitle32A("Wine Console"); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 745 | return TRUE; |
| 746 | } |
| 747 | |
| 748 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 749 | /****************************************************************************** |
| 750 | * GetConsoleCP [KERNEL32.295] Returns the OEM code page for the console |
| 751 | * |
| 752 | * RETURNS |
| 753 | * Code page code |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 754 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 755 | UINT32 WINAPI GetConsoleCP(VOID) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 756 | { |
| 757 | return GetACP(); |
| 758 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 759 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 760 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 761 | /*********************************************************************** |
| 762 | * GetConsoleOutputCP (KERNEL32.189) |
| 763 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 764 | UINT32 WINAPI GetConsoleOutputCP(VOID) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 765 | { |
| 766 | return GetConsoleCP(); |
| 767 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 768 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 769 | /*********************************************************************** |
| 770 | * GetConsoleMode (KERNEL32.188) |
| 771 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 772 | BOOL32 WINAPI GetConsoleMode(HANDLE32 hcon,LPDWORD mode) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 773 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 774 | struct get_console_mode_request req; |
| 775 | struct get_console_mode_reply reply; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 776 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 777 | if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hcon, |
| 778 | K32OBJ_CONSOLE, GENERIC_READ )) == -1) |
| 779 | return FALSE; |
| 780 | CLIENT_SendRequest( REQ_GET_CONSOLE_MODE, -1, 1, &req, sizeof(req)); |
| 781 | if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return FALSE; |
| 782 | *mode = reply.mode; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 783 | return TRUE; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 784 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 785 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 786 | |
| 787 | /****************************************************************************** |
| 788 | * SetConsoleMode [KERNEL32.628] Sets input mode of console's input buffer |
| 789 | * |
| 790 | * PARAMS |
| 791 | * hcon [I] Handle to console input or screen buffer |
| 792 | * mode [I] Input or output mode to set |
| 793 | * |
| 794 | * RETURNS |
| 795 | * Success: TRUE |
| 796 | * Failure: FALSE |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 797 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 798 | BOOL32 WINAPI SetConsoleMode( HANDLE32 hcon, DWORD mode ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 799 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 800 | struct set_console_mode_request req; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 801 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 802 | if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hcon, |
| 803 | K32OBJ_CONSOLE, GENERIC_READ )) == -1) |
| 804 | return FALSE; |
| 805 | req.mode = mode; |
| 806 | CLIENT_SendRequest( REQ_SET_CONSOLE_MODE, -1, 1, &req, sizeof(req)); |
| 807 | return !CLIENT_WaitReply( NULL, NULL, 0 ); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 808 | } |
| 809 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 810 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 811 | /*********************************************************************** |
| 812 | * GetConsoleTitleA (KERNEL32.191) |
| 813 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 814 | DWORD WINAPI GetConsoleTitle32A(LPSTR title,DWORD size) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 815 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 816 | struct get_console_info_request req; |
| 817 | struct get_console_info_reply reply; |
| 818 | int len; |
| 819 | DWORD ret = 0; |
| 820 | HANDLE32 hcon; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 821 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 822 | if ((hcon = CreateFile32A( "CONOUT$", GENERIC_READ, 0, NULL, |
| 823 | OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE32) |
| 824 | return 0; |
| 825 | if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hcon, |
| 826 | K32OBJ_CONSOLE, GENERIC_READ )) == -1) |
| 827 | { |
| 828 | CloseHandle( hcon ); |
| 829 | return 0; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 830 | } |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 831 | CLIENT_SendRequest( REQ_GET_CONSOLE_INFO, -1, 1, &req, sizeof(req) ); |
| 832 | if (!CLIENT_WaitReply( &len, NULL, 2, &reply, sizeof(reply), title, size )) |
| 833 | { |
| 834 | if (len > sizeof(reply)+size) title[size-1] = 0; |
| 835 | ret = strlen(title); |
| 836 | } |
| 837 | CloseHandle( hcon ); |
| 838 | return ret; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 839 | } |
| 840 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 841 | |
| 842 | /****************************************************************************** |
| 843 | * GetConsoleTitle32W [KERNEL32.192] Retrieves title string for console |
| 844 | * |
| 845 | * PARAMS |
| 846 | * title [O] Address of buffer for title |
| 847 | * size [I] Size of buffer |
| 848 | * |
| 849 | * RETURNS |
| 850 | * Success: Length of string copied |
| 851 | * Failure: 0 |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 852 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 853 | DWORD WINAPI GetConsoleTitle32W( LPWSTR title, DWORD size ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 854 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 855 | char *tmp; |
| 856 | DWORD ret; |
| 857 | |
| 858 | if (!(tmp = HeapAlloc( GetProcessHeap(), 0, size ))) return 0; |
| 859 | ret = GetConsoleTitle32A( tmp, size ); |
| 860 | lstrcpyAtoW( title, tmp ); |
| 861 | HeapFree( GetProcessHeap(), 0, tmp ); |
| 862 | return ret; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 863 | } |
| 864 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 865 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 866 | /*********************************************************************** |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 867 | * WriteConsoleA (KERNEL32.729) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 868 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 869 | BOOL32 WINAPI WriteConsole32A( HANDLE32 hConsoleOutput, |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 870 | LPCVOID lpBuffer, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 871 | DWORD nNumberOfCharsToWrite, |
| 872 | LPDWORD lpNumberOfCharsWritten, |
| 873 | LPVOID lpReserved ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 874 | { |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 875 | /* FIXME: should I check if this is a console handle? */ |
| 876 | return WriteFile(hConsoleOutput, lpBuffer, nNumberOfCharsToWrite, |
| 877 | lpNumberOfCharsWritten, NULL); |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 878 | } |
| 879 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 880 | |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 881 | #define CADD(c) \ |
| 882 | if (bufused==curbufsize-1) \ |
| 883 | buffer = HeapReAlloc(GetProcessHeap(),0,buffer,(curbufsize+=100));\ |
| 884 | buffer[bufused++]=c; |
| 885 | #define SADD(s) { char *x=s;while (*x) {CADD(*x);x++;}} |
| 886 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 887 | /*********************************************************************** |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 888 | * WriteConsoleOutputA (KERNEL32.732) |
| 889 | */ |
| 890 | BOOL32 WINAPI WriteConsoleOutput32A( HANDLE32 hConsoleOutput, |
| 891 | LPCHAR_INFO lpBuffer, |
| 892 | COORD dwBufferSize, |
| 893 | COORD dwBufferCoord, |
| 894 | LPSMALL_RECT lpWriteRegion) |
| 895 | { |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 896 | int i,j,off=0,lastattr=-1; |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 897 | char sbuf[20],*buffer=NULL; |
| 898 | int bufused=0,curbufsize = 100; |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 899 | DWORD res; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 900 | const int colormap[8] = { |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 901 | 0,4,2,6, |
| 902 | 1,5,3,7, |
| 903 | }; |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 904 | CONSOLE_make_complex(hConsoleOutput); |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 905 | buffer = HeapAlloc(GetProcessHeap(),0,100);; |
| 906 | curbufsize = 100; |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 907 | |
| 908 | TRACE(console,"wr: top = %d, bottom=%d, left=%d,right=%d\n", |
| 909 | lpWriteRegion->Top, |
| 910 | lpWriteRegion->Bottom, |
| 911 | lpWriteRegion->Left, |
| 912 | lpWriteRegion->Right |
| 913 | ); |
| 914 | |
| 915 | for (i=lpWriteRegion->Top;i<=lpWriteRegion->Bottom;i++) { |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 916 | sprintf(sbuf,"%c[%d;%dH",27,i+1,lpWriteRegion->Left+1); |
| 917 | SADD(sbuf); |
| 918 | for (j=lpWriteRegion->Left;j<=lpWriteRegion->Right;j++) { |
| 919 | if (lastattr!=lpBuffer[off].Attributes) { |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 920 | lastattr = lpBuffer[off].Attributes; |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 921 | sprintf(sbuf,"%c[0;%s3%d;4%dm", |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 922 | 27, |
| 923 | (lastattr & FOREGROUND_INTENSITY)?"1;":"", |
| 924 | colormap[lastattr&7], |
| 925 | colormap[(lastattr&0x70)>>4] |
| 926 | ); |
| 927 | /* FIXME: BACKGROUND_INTENSITY */ |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 928 | SADD(sbuf); |
| 929 | } |
| 930 | CADD(lpBuffer[off].Char.AsciiChar); |
| 931 | off++; |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 932 | } |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 933 | } |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 934 | sprintf(sbuf,"%c[0m",27);SADD(sbuf); |
| 935 | WriteFile(hConsoleOutput,buffer,bufused,&res,NULL); |
| 936 | HeapFree(GetProcessHeap(),0,buffer); |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 937 | return TRUE; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | /*********************************************************************** |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 941 | * WriteConsoleW (KERNEL32.577) |
| 942 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 943 | BOOL32 WINAPI WriteConsole32W( HANDLE32 hConsoleOutput, |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 944 | LPCVOID lpBuffer, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 945 | DWORD nNumberOfCharsToWrite, |
| 946 | LPDWORD lpNumberOfCharsWritten, |
| 947 | LPVOID lpReserved ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 948 | { |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 949 | BOOL32 ret; |
| 950 | LPSTR xstring=HeapAlloc( GetProcessHeap(), 0, nNumberOfCharsToWrite ); |
| 951 | |
| 952 | lstrcpynWtoA( xstring, lpBuffer,nNumberOfCharsToWrite); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 953 | |
| 954 | /* FIXME: should I check if this is a console handle? */ |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 955 | ret= WriteFile(hConsoleOutput, xstring, nNumberOfCharsToWrite, |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 956 | lpNumberOfCharsWritten, NULL); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 957 | HeapFree( GetProcessHeap(), 0, xstring ); |
| 958 | return ret; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 959 | } |
| 960 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 961 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 962 | /*********************************************************************** |
| 963 | * ReadConsoleA (KERNEL32.419) |
| 964 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 965 | BOOL32 WINAPI ReadConsole32A( HANDLE32 hConsoleInput, |
| 966 | LPVOID lpBuffer, |
| 967 | DWORD nNumberOfCharsToRead, |
| 968 | LPDWORD lpNumberOfCharsRead, |
| 969 | LPVOID lpReserved ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 970 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 971 | CONSOLE *console = CONSOLE_GetPtr( hConsoleInput ); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 972 | int i,charsread = 0; |
| 973 | LPSTR xbuf = (LPSTR)lpBuffer; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 974 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 975 | if (!console) { |
| 976 | SetLastError(ERROR_INVALID_HANDLE); |
| 977 | FIXME(console,"(%d,...), no console handle!\n",hConsoleInput); |
| 978 | return FALSE; |
| 979 | } |
| 980 | TRACE(console,"(%d,%p,%ld,%p,%p)\n", |
| 981 | hConsoleInput,lpBuffer,nNumberOfCharsToRead, |
| 982 | lpNumberOfCharsRead,lpReserved |
| 983 | ); |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 984 | CONSOLE_get_input(hConsoleInput); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 985 | |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 986 | /* FIXME: should we read at least 1 char? The SDK does not say */ |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 987 | for (i=0;(i<console->nrofirs)&&(charsread<nNumberOfCharsToRead);i++) { |
| 988 | if (console->irs[i].EventType != KEY_EVENT) |
| 989 | continue; |
| 990 | if (!console->irs[i].Event.KeyEvent.bKeyDown) |
| 991 | continue; |
| 992 | *xbuf++ = console->irs[i].Event.KeyEvent.uChar.AsciiChar; |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 993 | charsread++; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 994 | } |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 995 | /* SDK says: Drains all other input events from queue. */ |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 996 | CONSOLE_drain_input(console,i); |
| 997 | if (lpNumberOfCharsRead) |
| 998 | *lpNumberOfCharsRead = charsread; |
| 999 | K32OBJ_DecCount(&console->header); |
| 1000 | return TRUE; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | /*********************************************************************** |
| 1004 | * ReadConsoleW (KERNEL32.427) |
| 1005 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1006 | BOOL32 WINAPI ReadConsole32W( HANDLE32 hConsoleInput, |
| 1007 | LPVOID lpBuffer, |
| 1008 | DWORD nNumberOfCharsToRead, |
| 1009 | LPDWORD lpNumberOfCharsRead, |
| 1010 | LPVOID lpReserved ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1011 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1012 | BOOL32 ret; |
| 1013 | LPSTR buf = (LPSTR)HeapAlloc(GetProcessHeap(), 0, nNumberOfCharsToRead); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 1014 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1015 | ret = ReadConsole32A( |
| 1016 | hConsoleInput, |
| 1017 | buf, |
| 1018 | nNumberOfCharsToRead, |
| 1019 | lpNumberOfCharsRead, |
| 1020 | lpReserved |
| 1021 | ); |
| 1022 | if (ret) |
| 1023 | lstrcpynAtoW(lpBuffer,buf,nNumberOfCharsToRead); |
| 1024 | HeapFree( GetProcessHeap(), 0, buf ); |
| 1025 | return ret; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1026 | } |
| 1027 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1028 | |
| 1029 | /****************************************************************************** |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1030 | * ReadConsoleInput32A [KERNEL32.569] Reads data from a console |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1031 | * |
| 1032 | * PARAMS |
| 1033 | * hConsoleInput [I] Handle to console input buffer |
| 1034 | * lpBuffer [O] Address of buffer for read data |
| 1035 | * nLength [I] Number of records to read |
| 1036 | * lpNumberOfEventsRead [O] Address of number of records read |
| 1037 | * |
| 1038 | * RETURNS |
| 1039 | * Success: TRUE |
| 1040 | * Failure: FALSE |
| 1041 | */ |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1042 | BOOL32 WINAPI ReadConsoleInput32A(HANDLE32 hConsoleInput, |
| 1043 | LPINPUT_RECORD lpBuffer, |
| 1044 | DWORD nLength, LPDWORD lpNumberOfEventsRead) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1045 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1046 | CONSOLE *console = CONSOLE_GetPtr( hConsoleInput ); |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1047 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1048 | TRACE(console, "(%d,%p,%ld,%p)\n",hConsoleInput, lpBuffer, nLength, |
| 1049 | lpNumberOfEventsRead); |
| 1050 | if (!console) { |
| 1051 | FIXME(console, "(%d,%p,%ld,%p), No console handle!\n",hConsoleInput, |
| 1052 | lpBuffer, nLength, lpNumberOfEventsRead); |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 1053 | |
| 1054 | /* Indicate that nothing was read */ |
| 1055 | *lpNumberOfEventsRead = 0; |
| 1056 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1057 | return FALSE; |
| 1058 | } |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 1059 | CONSOLE_get_input(hConsoleInput); |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 1060 | /* SDK: return at least 1 input record */ |
| 1061 | while (!console->nrofirs) { |
| 1062 | DWORD res; |
| 1063 | |
| 1064 | res=WaitForSingleObject(hConsoleInput,0); |
| 1065 | switch (res) { |
| 1066 | case STATUS_TIMEOUT: continue; |
| 1067 | case 0: break; /*ok*/ |
| 1068 | case WAIT_FAILED: return 0;/*FIXME: SetLastError?*/ |
| 1069 | default: break; /*hmm*/ |
| 1070 | } |
| 1071 | CONSOLE_get_input(hConsoleInput); |
| 1072 | } |
| 1073 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1074 | if (nLength>console->nrofirs) |
| 1075 | nLength = console->nrofirs; |
| 1076 | memcpy(lpBuffer,console->irs,sizeof(INPUT_RECORD)*nLength); |
| 1077 | if (lpNumberOfEventsRead) |
| 1078 | *lpNumberOfEventsRead = nLength; |
| 1079 | CONSOLE_drain_input(console,nLength); |
| 1080 | K32OBJ_DecCount(&console->header); |
| 1081 | return TRUE; |
| 1082 | } |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1083 | |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1084 | /*********************************************************************** |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1085 | * SetConsoleTitle32A (KERNEL32.476) |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1086 | * |
| 1087 | * Sets the console title. |
| 1088 | * |
| 1089 | * We do not necessarily need to create a complex console for that, |
| 1090 | * but should remember the title and set it on creation of the latter. |
| 1091 | * (not fixed at this time). |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1092 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1093 | BOOL32 WINAPI SetConsoleTitle32A(LPCSTR title) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1094 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1095 | #if 0 |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1096 | PDB32 *pdb = PROCESS_Current(); |
| 1097 | CONSOLE *console; |
| 1098 | DWORD written; |
| 1099 | char titleformat[]="\033]2;%s\a"; /*this should work for xterms*/ |
| 1100 | LPSTR titlestring; |
| 1101 | BOOL32 ret=FALSE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1102 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1103 | TRACE(console,"(%s)\n",title); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1104 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1105 | console = (CONSOLE *)pdb->console; |
| 1106 | if (!console) |
| 1107 | return FALSE; |
| 1108 | if(console->title) /* Free old title, if there is one */ |
| 1109 | HeapFree( SystemHeap, 0, console->title ); |
| 1110 | console->title = (LPSTR)HeapAlloc(SystemHeap, 0,strlen(title)+1); |
| 1111 | if(console->title) strcpy(console->title,title); |
| 1112 | titlestring = HeapAlloc(GetProcessHeap(), 0,strlen(title)+strlen(titleformat)+1); |
| 1113 | if (!titlestring) { |
| 1114 | K32OBJ_DecCount(&console->header); |
| 1115 | return FALSE; |
| 1116 | } |
| 1117 | |
| 1118 | sprintf(titlestring,titleformat,title); |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1119 | #if 0 |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 1120 | /* only set title for complex console (own xterm) */ |
| 1121 | if (console->pid != -1) { |
| 1122 | WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),titlestring,strlen(titlestring),&written,NULL); |
| 1123 | if (written == strlen(titlestring)) |
| 1124 | ret =TRUE; |
| 1125 | } else |
| 1126 | ret = TRUE; |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1127 | #endif |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1128 | HeapFree( GetProcessHeap(), 0, titlestring ); |
| 1129 | K32OBJ_DecCount(&console->header); |
| 1130 | return ret; |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1131 | |
| 1132 | |
| 1133 | |
| 1134 | #endif |
| 1135 | |
| 1136 | struct set_console_info_request req; |
| 1137 | struct get_console_info_reply info; |
| 1138 | HANDLE32 hcon; |
| 1139 | DWORD written; |
| 1140 | |
| 1141 | if ((hcon = CreateFile32A( "CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, |
| 1142 | OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE32) |
| 1143 | return FALSE; |
| 1144 | if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hcon, |
| 1145 | K32OBJ_CONSOLE, GENERIC_WRITE )) == -1) |
| 1146 | goto error; |
| 1147 | req.mask = SET_CONSOLE_INFO_TITLE; |
| 1148 | CLIENT_SendRequest( REQ_SET_CONSOLE_INFO, -1, 2, &req, sizeof(req), |
| 1149 | title, strlen(title)+1 ); |
| 1150 | if (CLIENT_WaitReply( NULL, NULL, 0 )) goto error; |
| 1151 | if (CONSOLE_GetInfo( hcon, &info ) && info.pid) |
| 1152 | { |
| 1153 | /* only set title for complex console (own xterm) */ |
| 1154 | WriteFile( hcon, "\033]2;", 4, &written, NULL ); |
| 1155 | WriteFile( hcon, title, strlen(title), &written, NULL ); |
| 1156 | WriteFile( hcon, "\a", 1, &written, NULL ); |
| 1157 | } |
| 1158 | return TRUE; |
| 1159 | error: |
| 1160 | CloseHandle( hcon ); |
| 1161 | return FALSE; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1162 | } |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1163 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1164 | |
| 1165 | /****************************************************************************** |
| 1166 | * SetConsoleTitle32W [KERNEL32.477] Sets title bar string for console |
| 1167 | * |
| 1168 | * PARAMS |
| 1169 | * title [I] Address of new title |
| 1170 | * |
| 1171 | * NOTES |
| 1172 | * This should not be calling the A version |
| 1173 | * |
| 1174 | * RETURNS |
| 1175 | * Success: TRUE |
| 1176 | * Failure: FALSE |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1177 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1178 | BOOL32 WINAPI SetConsoleTitle32W( LPCWSTR title ) |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1179 | { |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1180 | BOOL32 ret; |
| 1181 | |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1182 | LPSTR titleA = HEAP_strdupWtoA( GetProcessHeap(), 0, title ); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1183 | ret = SetConsoleTitle32A(titleA); |
Alexandre Julliard | 7ebe1a4 | 1996-12-22 18:27:48 +0000 | [diff] [blame] | 1184 | HeapFree( GetProcessHeap(), 0, titleA ); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1185 | return ret; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1186 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1187 | |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 1188 | /*********************************************************************** |
| 1189 | * ReadConsoleInput32W (KERNEL32.570) |
| 1190 | */ |
| 1191 | BOOL32 WINAPI ReadConsoleInput32W(HANDLE32 hConsoleInput, |
| 1192 | LPINPUT_RECORD lpBuffer, |
| 1193 | DWORD nLength, LPDWORD lpNumberOfEventsRead) |
| 1194 | { |
| 1195 | FIXME(console, "(%d,%p,%ld,%p): stub\n",hConsoleInput, lpBuffer, nLength, |
| 1196 | lpNumberOfEventsRead); |
| 1197 | return 0; |
| 1198 | } |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1199 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1200 | /*********************************************************************** |
| 1201 | * FlushConsoleInputBuffer (KERNEL32.132) |
| 1202 | */ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1203 | BOOL32 WINAPI FlushConsoleInputBuffer(HANDLE32 hConsoleInput) |
| 1204 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1205 | CONSOLE *console = CONSOLE_GetPtr( hConsoleInput ); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1206 | |
| 1207 | if (!console) |
| 1208 | return FALSE; |
| 1209 | CONSOLE_drain_input(console,console->nrofirs); |
| 1210 | K32OBJ_DecCount(&console->header); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1211 | return TRUE; |
| 1212 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1213 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1214 | |
| 1215 | /****************************************************************************** |
| 1216 | * SetConsoleCursorPosition [KERNEL32.627] |
| 1217 | * Sets the cursor position in console |
| 1218 | * |
| 1219 | * PARAMS |
| 1220 | * hConsoleOutput [I] Handle of console screen buffer |
| 1221 | * dwCursorPosition [I] New cursor position coordinates |
| 1222 | * |
| 1223 | * RETURNS STD |
| 1224 | */ |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1225 | BOOL32 WINAPI SetConsoleCursorPosition( HANDLE32 hcon, COORD pos ) |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1226 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1227 | char xbuf[20]; |
| 1228 | DWORD xlen; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1229 | |
Marcus Meissner | 03f10f4 | 1999-01-26 10:08:36 +0000 | [diff] [blame^] | 1230 | /* make console complex only if we change lines, not just in the line */ |
| 1231 | if (pos.y) |
| 1232 | CONSOLE_make_complex(hcon); |
| 1233 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1234 | TRACE(console, "%d (%dx%d)\n", hcon, pos.x , pos.y ); |
| 1235 | /* x are columns, y rows */ |
Marcus Meissner | 03f10f4 | 1999-01-26 10:08:36 +0000 | [diff] [blame^] | 1236 | if (pos.y) |
| 1237 | /* full screen cursor absolute positioning */ |
| 1238 | sprintf(xbuf,"%c[%d;%dH", 0x1B, pos.y+1, pos.x+1); |
| 1239 | else |
| 1240 | /* relative cursor positioning in line (\r to go to 0) */ |
| 1241 | sprintf(xbuf,"\r%c[%dC", 0x1B, pos.x); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1242 | /* FIXME: store internal if we start using own console buffers */ |
| 1243 | WriteFile(hcon,xbuf,strlen(xbuf),&xlen,NULL); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1244 | return TRUE; |
| 1245 | } |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1246 | |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1247 | /*********************************************************************** |
| 1248 | * GetNumberOfConsoleInputEvents (KERNEL32.246) |
| 1249 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1250 | BOOL32 WINAPI GetNumberOfConsoleInputEvents(HANDLE32 hcon,LPDWORD nrofevents) |
| 1251 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1252 | CONSOLE *console = CONSOLE_GetPtr( hcon ); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1253 | |
| 1254 | if (!console) { |
| 1255 | FIXME(console,"(%d,%p), no console handle!\n",hcon,nrofevents); |
| 1256 | return FALSE; |
| 1257 | } |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 1258 | CONSOLE_get_input(hcon); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1259 | *nrofevents = console->nrofirs; |
| 1260 | K32OBJ_DecCount(&console->header); |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1261 | return TRUE; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 1262 | } |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1263 | |
| 1264 | /*********************************************************************** |
| 1265 | * GetNumberOfConsoleMouseButtons (KERNEL32.358) |
| 1266 | */ |
| 1267 | BOOL32 WINAPI GetNumberOfConsoleMouseButtons(LPDWORD nrofbuttons) |
| 1268 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1269 | FIXME(console,"(%p): stub\n", nrofbuttons); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1270 | *nrofbuttons = 2; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1271 | return TRUE; |
| 1272 | } |
| 1273 | |
| 1274 | /*********************************************************************** |
| 1275 | * PeekConsoleInputA (KERNEL32.550) |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1276 | * |
| 1277 | * Gets 'cInRecords' first events (or less) from input queue. |
| 1278 | * |
| 1279 | * Does not need a complex console. |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1280 | */ |
| 1281 | BOOL32 WINAPI PeekConsoleInput32A(HANDLE32 hConsoleInput, |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1282 | LPINPUT_RECORD pirBuffer, |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1283 | DWORD cInRecords, |
| 1284 | LPDWORD lpcRead) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1285 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1286 | CONSOLE *console = CONSOLE_GetPtr( hConsoleInput ); |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 1287 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1288 | if (!console) { |
| 1289 | FIXME(console,"(%d,%p,%ld,%p), No console handle passed!\n",hConsoleInput, pirBuffer, cInRecords, lpcRead); |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 1290 | |
| 1291 | /* Indicate that nothing was read */ |
| 1292 | *lpcRead = 0; |
| 1293 | |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1294 | return FALSE; |
Marcus Meissner | b02ffc7 | 1998-10-11 10:49:46 +0000 | [diff] [blame] | 1295 | } |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1296 | TRACE(console,"(%d,%p,%ld,%p)\n",hConsoleInput, pirBuffer, cInRecords, lpcRead); |
Alexandre Julliard | 5544387 | 1998-12-31 15:52:06 +0000 | [diff] [blame] | 1297 | CONSOLE_get_input(hConsoleInput); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1298 | if (cInRecords>console->nrofirs) |
| 1299 | cInRecords = console->nrofirs; |
| 1300 | if (pirBuffer) |
| 1301 | memcpy(pirBuffer,console->irs,cInRecords*sizeof(INPUT_RECORD)); |
| 1302 | if (lpcRead) |
| 1303 | *lpcRead = cInRecords; |
| 1304 | K32OBJ_DecCount(&console->header); |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1305 | return TRUE; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1306 | } |
| 1307 | |
| 1308 | /*********************************************************************** |
| 1309 | * PeekConsoleInputW (KERNEL32.551) |
| 1310 | */ |
| 1311 | BOOL32 WINAPI PeekConsoleInput32W(HANDLE32 hConsoleInput, |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1312 | LPINPUT_RECORD pirBuffer, |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1313 | DWORD cInRecords, |
| 1314 | LPDWORD lpcRead) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1315 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1316 | /* FIXME: Hmm. Fix this if we get UNICODE input. */ |
| 1317 | return PeekConsoleInput32A(hConsoleInput,pirBuffer,cInRecords,lpcRead); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1318 | } |
| 1319 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1320 | |
| 1321 | /****************************************************************************** |
| 1322 | * GetConsoleCursorInfo32 [KERNEL32.296] Gets size and visibility of console |
| 1323 | * |
| 1324 | * PARAMS |
| 1325 | * hcon [I] Handle to console screen buffer |
| 1326 | * cinfo [O] Address of cursor information |
| 1327 | * |
| 1328 | * RETURNS |
| 1329 | * Success: TRUE |
| 1330 | * Failure: FALSE |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1331 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1332 | BOOL32 WINAPI GetConsoleCursorInfo32( HANDLE32 hcon, |
| 1333 | LPCONSOLE_CURSOR_INFO cinfo ) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1334 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1335 | struct get_console_info_reply reply; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1336 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1337 | if (!CONSOLE_GetInfo( hcon, &reply )) return FALSE; |
| 1338 | if (cinfo) |
| 1339 | { |
| 1340 | cinfo->dwSize = reply.cursor_size; |
| 1341 | cinfo->bVisible = reply.cursor_visible; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1342 | } |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1343 | return TRUE; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1344 | } |
| 1345 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1346 | |
| 1347 | /****************************************************************************** |
| 1348 | * SetConsoleCursorInfo32 [KERNEL32.626] Sets size and visibility of cursor |
| 1349 | * |
| 1350 | * RETURNS |
| 1351 | * Success: TRUE |
| 1352 | * Failure: FALSE |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1353 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1354 | BOOL32 WINAPI SetConsoleCursorInfo32( |
| 1355 | HANDLE32 hcon, /* [in] Handle to console screen buffer */ |
| 1356 | LPCONSOLE_CURSOR_INFO cinfo) /* [in] Address of cursor information */ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1357 | { |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1358 | struct set_console_info_request req; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1359 | char buf[8]; |
| 1360 | DWORD xlen; |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1361 | |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1362 | if ((req.handle = HANDLE_GetServerHandle( PROCESS_Current(), hcon, |
| 1363 | K32OBJ_CONSOLE, GENERIC_WRITE )) == -1) |
| 1364 | return FALSE; |
| 1365 | CONSOLE_make_complex(hcon); |
| 1366 | sprintf(buf,"\033[?25%c",cinfo->bVisible?'h':'l'); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1367 | WriteFile(hcon,buf,strlen(buf),&xlen,NULL); |
Alexandre Julliard | 62a8b43 | 1999-01-19 17:48:23 +0000 | [diff] [blame] | 1368 | |
| 1369 | req.cursor_size = cinfo->dwSize; |
| 1370 | req.cursor_visible = cinfo->bVisible; |
| 1371 | req.mask = SET_CONSOLE_INFO_CURSOR; |
| 1372 | CLIENT_SendRequest( REQ_SET_CONSOLE_INFO, -1, 1, &req, sizeof(req) ); |
| 1373 | return !CLIENT_WaitReply( NULL, NULL, 0 ); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1374 | } |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1375 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1376 | |
| 1377 | /****************************************************************************** |
| 1378 | * SetConsoleWindowInfo [KERNEL32.634] Sets size and position of console |
| 1379 | * |
| 1380 | * RETURNS |
| 1381 | * Success: TRUE |
| 1382 | * Failure: FALSE |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1383 | */ |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1384 | BOOL32 WINAPI SetConsoleWindowInfo( |
| 1385 | HANDLE32 hcon, /* [in] Handle to console screen buffer */ |
| 1386 | BOOL32 bAbsolute, /* [in] Coordinate type flag */ |
| 1387 | LPSMALL_RECT window) /* [in] Address of new window rectangle */ |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1388 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1389 | FIXME(console, "(%x,%d,%p): stub\n", hcon, bAbsolute, window); |
| 1390 | return TRUE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1391 | } |
| 1392 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1393 | |
| 1394 | /****************************************************************************** |
| 1395 | * SetConsoleTextAttribute32 [KERNEL32.631] Sets colors for text |
| 1396 | * |
| 1397 | * Sets the foreground and background color attributes of characters |
| 1398 | * written to the screen buffer. |
| 1399 | * |
| 1400 | * RETURNS |
| 1401 | * Success: TRUE |
| 1402 | * Failure: FALSE |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1403 | */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1404 | BOOL32 WINAPI SetConsoleTextAttribute32(HANDLE32 hConsoleOutput,WORD wAttr) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1405 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1406 | const int colormap[8] = { |
| 1407 | 0,4,2,6, |
| 1408 | 1,5,3,7, |
| 1409 | }; |
| 1410 | DWORD xlen; |
| 1411 | char buffer[20]; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1412 | |
Marcus Meissner | 8bc54b6 | 1998-12-14 14:48:09 +0000 | [diff] [blame] | 1413 | TRACE(console,"(%d,%d)\n",hConsoleOutput,wAttr); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1414 | sprintf(buffer,"%c[0;%s3%d;4%dm", |
| 1415 | 27, |
| 1416 | (wAttr & FOREGROUND_INTENSITY)?"1;":"", |
| 1417 | colormap[wAttr&7], |
| 1418 | colormap[(wAttr&0x70)>>4] |
| 1419 | ); |
| 1420 | WriteFile(hConsoleOutput,buffer,strlen(buffer),&xlen,NULL); |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1421 | return TRUE; |
| 1422 | } |
| 1423 | |
| 1424 | |
| 1425 | /****************************************************************************** |
| 1426 | * SetConsoleScreenBufferSize [KERNEL32.630] Changes size of console |
| 1427 | * |
| 1428 | * PARAMS |
| 1429 | * hConsoleOutput [I] Handle to console screen buffer |
| 1430 | * dwSize [I] New size in character rows and cols |
| 1431 | * |
| 1432 | * RETURNS |
| 1433 | * Success: TRUE |
| 1434 | * Failure: FALSE |
| 1435 | */ |
| 1436 | BOOL32 WINAPI SetConsoleScreenBufferSize( HANDLE32 hConsoleOutput, |
| 1437 | COORD dwSize ) |
| 1438 | { |
| 1439 | FIXME(console, "(%d,%dx%d): stub\n",hConsoleOutput,dwSize.x,dwSize.y); |
| 1440 | return TRUE; |
| 1441 | } |
| 1442 | |
| 1443 | |
| 1444 | /****************************************************************************** |
| 1445 | * FillConsoleOutputCharacterA [KERNEL32.242] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1446 | * |
| 1447 | * PARAMS |
| 1448 | * hConsoleOutput [I] Handle to screen buffer |
| 1449 | * cCharacter [I] Character to write |
| 1450 | * nLength [I] Number of cells to write to |
| 1451 | * dwCoord [I] Coords of first cell |
| 1452 | * lpNumCharsWritten [O] Pointer to number of cells written |
| 1453 | * |
| 1454 | * RETURNS |
| 1455 | * Success: TRUE |
| 1456 | * Failure: FALSE |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1457 | */ |
| 1458 | BOOL32 WINAPI FillConsoleOutputCharacterA( |
| 1459 | HANDLE32 hConsoleOutput, |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1460 | BYTE cCharacter, |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1461 | DWORD nLength, |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1462 | COORD dwCoord, |
| 1463 | LPDWORD lpNumCharsWritten) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1464 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1465 | long count; |
| 1466 | DWORD xlen; |
| 1467 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1468 | SetConsoleCursorPosition(hConsoleOutput,dwCoord); |
| 1469 | for(count=0;count<nLength;count++) |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1470 | WriteFile(hConsoleOutput,&cCharacter,1,&xlen,NULL); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1471 | *lpNumCharsWritten = nLength; |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1472 | return TRUE; |
| 1473 | } |
| 1474 | |
| 1475 | |
| 1476 | /****************************************************************************** |
| 1477 | * FillConsoleOutputCharacterW [KERNEL32.243] Writes characters to console |
| 1478 | * |
| 1479 | * PARAMS |
| 1480 | * hConsoleOutput [I] Handle to screen buffer |
| 1481 | * cCharacter [I] Character to write |
| 1482 | * nLength [I] Number of cells to write to |
| 1483 | * dwCoord [I] Coords of first cell |
| 1484 | * lpNumCharsWritten [O] Pointer to number of cells written |
| 1485 | * |
| 1486 | * RETURNS |
| 1487 | * Success: TRUE |
| 1488 | * Failure: FALSE |
| 1489 | */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1490 | BOOL32 WINAPI FillConsoleOutputCharacterW(HANDLE32 hConsoleOutput, |
| 1491 | WCHAR cCharacter, |
| 1492 | DWORD nLength, |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1493 | COORD dwCoord, |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1494 | LPDWORD lpNumCharsWritten) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1495 | { |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1496 | long count; |
| 1497 | DWORD xlen; |
| 1498 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1499 | SetConsoleCursorPosition(hConsoleOutput,dwCoord); |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1500 | /* FIXME: not quite correct ... but the lower part of UNICODE char comes |
| 1501 | * first |
| 1502 | */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1503 | for(count=0;count<nLength;count++) |
Marcus Meissner | 537772a | 1998-12-09 16:37:04 +0000 | [diff] [blame] | 1504 | WriteFile(hConsoleOutput,&cCharacter,1,&xlen,NULL); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1505 | *lpNumCharsWritten = nLength; |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1506 | return TRUE; |
| 1507 | } |
| 1508 | |
| 1509 | |
| 1510 | /****************************************************************************** |
| 1511 | * FillConsoleOutputAttribute [KERNEL32.241] Sets attributes for console |
| 1512 | * |
| 1513 | * PARAMS |
| 1514 | * hConsoleOutput [I] Handle to screen buffer |
| 1515 | * wAttribute [I] Color attribute to write |
| 1516 | * nLength [I] Number of cells to write to |
| 1517 | * dwCoord [I] Coords of first cell |
| 1518 | * lpNumAttrsWritten [O] Pointer to number of cells written |
| 1519 | * |
| 1520 | * RETURNS |
| 1521 | * Success: TRUE |
| 1522 | * Failure: FALSE |
| 1523 | */ |
| 1524 | BOOL32 WINAPI FillConsoleOutputAttribute( HANDLE32 hConsoleOutput, |
| 1525 | WORD wAttribute, DWORD nLength, COORD dwCoord, |
| 1526 | LPDWORD lpNumAttrsWritten) |
| 1527 | { |
| 1528 | FIXME(console, "(%d,%d,%ld,%dx%d,%p): stub\n", hConsoleOutput, |
| 1529 | wAttribute,nLength,dwCoord.x,dwCoord.y,lpNumAttrsWritten); |
| 1530 | *lpNumAttrsWritten = nLength; |
| 1531 | return TRUE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1532 | } |
| 1533 | |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1534 | /****************************************************************************** |
| 1535 | * ReadConsoleOutputCharacter32A [KERNEL32.573] |
| 1536 | * |
| 1537 | * BUGS |
| 1538 | * Unimplemented |
| 1539 | */ |
| 1540 | BOOL32 WINAPI ReadConsoleOutputCharacter32A(HANDLE32 hConsoleOutput, |
| 1541 | LPSTR lpstr, DWORD dword, COORD coord, LPDWORD lpdword) |
| 1542 | { |
| 1543 | FIXME(console, "(%d,%p,%ld,%dx%d,%p): stub\n", hConsoleOutput,lpstr, |
| 1544 | dword,coord.x,coord.y,lpdword); |
| 1545 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); |
| 1546 | return FALSE; |
| 1547 | } |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 1548 | |
| 1549 | |
| 1550 | /****************************************************************************** |
| 1551 | * ScrollConsoleScreenBuffer [KERNEL32.612] |
| 1552 | * |
| 1553 | * BUGS |
| 1554 | * Unimplemented |
| 1555 | */ |
| 1556 | BOOL32 WINAPI ScrollConsoleScreenBuffer( HANDLE32 hConsoleOutput, |
| 1557 | LPSMALL_RECT lpScrollRect, LPSMALL_RECT lpClipRect, |
| 1558 | COORD dwDestOrigin, LPCHAR_INFO lpFill) |
| 1559 | { |
| 1560 | FIXME(console, "(%d,%p,%p,%dx%d,%p): stub\n", hConsoleOutput,lpScrollRect, |
| 1561 | lpClipRect,dwDestOrigin.x,dwDestOrigin.y,lpFill); |
| 1562 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); |
| 1563 | return FALSE; |
| 1564 | } |