Clear the remainder of the page when mapping a section whose size on
[wine/multimedia.git] / win32 / console.c
blob743c1749c8059412d71badb42218e75b44dc678a
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 * Copyright 1997 Karl Garrison
6 * Copyright 1998 John Richardson
7 * Copyright 1998 Marcus Meissner
8 */
10 /* FIXME:
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 ?)
17 /* Reference applications:
18 * - IDA (interactive disassembler) full version 3.75. Works.
19 * - LYNX/W32. Works mostly, some keys crash it.
22 #include "config.h"
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <unistd.h>
27 #include <termios.h>
28 #include <string.h>
29 #include <sys/ioctl.h>
30 #include <sys/types.h>
31 #include <sys/time.h>
32 #include <fcntl.h>
33 #include <errno.h>
34 #ifdef HAVE_SYS_ERRNO_H
35 #include <sys/errno.h>
36 #endif
37 #include <signal.h>
38 #include <assert.h>
40 #include "winbase.h"
41 #include "windef.h"
42 #include "wingdi.h"
43 #include "wine/winuser16.h"
44 #include "wine/keyboard16.h"
45 #include "thread.h"
46 #include "file.h"
47 #include "process.h"
48 #include "winerror.h"
49 #include "wincon.h"
50 #include "heap.h"
51 #include "server.h"
52 #include "debugtools.h"
53 #include "winnls.h"
55 DEFAULT_DEBUG_CHANNEL(console)
58 /* FIXME: Should be in an internal header file. OK, so which one?
59 Used by CONSOLE_makecomplex. */
60 int wine_openpty(int *master, int *slave, char *name,
61 struct termios *term, struct winsize *winsize);
63 /****************************************************************************
64 * CONSOLE_GetPid
66 static int CONSOLE_GetPid( HANDLE handle )
68 struct get_console_info_request *req = get_req_buffer();
69 req->handle = handle;
70 if (server_call( REQ_GET_CONSOLE_INFO )) return 0;
71 return req->pid;
74 /****************************************************************************
75 * XTERM_string_to_IR [internal]
77 * Transfers a string read from XTERM to INPUT_RECORDs and adds them to the
78 * queue. Does translation of vt100 style function keys and xterm-mouse clicks.
80 static void
81 CONSOLE_string_to_IR( HANDLE hConsoleInput,unsigned char *buf,int len) {
82 int j,k;
83 INPUT_RECORD ir;
84 DWORD junk;
86 for (j=0;j<len;j++) {
87 unsigned char inchar = buf[j];
89 if (inchar!=27) { /* no escape -> 'normal' keyboard event */
90 ir.EventType = 1; /* Key_event */
92 ir.Event.KeyEvent.bKeyDown = 1;
93 ir.Event.KeyEvent.wRepeatCount = 0;
95 ir.Event.KeyEvent.dwControlKeyState = 0;
96 if (inchar & 0x80) {
97 ir.Event.KeyEvent.dwControlKeyState|=LEFT_ALT_PRESSED;
98 inchar &= ~0x80;
100 ir.Event.KeyEvent.wVirtualKeyCode = VkKeyScan16(inchar);
101 if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0100)
102 ir.Event.KeyEvent.dwControlKeyState|=SHIFT_PRESSED;
103 if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0200)
104 ir.Event.KeyEvent.dwControlKeyState|=LEFT_CTRL_PRESSED;
105 if (ir.Event.KeyEvent.wVirtualKeyCode & 0x0400)
106 ir.Event.KeyEvent.dwControlKeyState|=LEFT_ALT_PRESSED;
107 ir.Event.KeyEvent.wVirtualScanCode = MapVirtualKey16(
108 ir.Event.KeyEvent.wVirtualKeyCode & 0x00ff,
109 0 /* VirtualKeyCodes to ScanCode */
111 ir.Event.KeyEvent.uChar.AsciiChar = inchar;
113 if ((inchar==127)||(inchar=='\b')) { /* backspace */
114 ir.Event.KeyEvent.uChar.AsciiChar = '\b'; /* FIXME: hmm */
115 ir.Event.KeyEvent.wVirtualScanCode = 0x0e;
116 ir.Event.KeyEvent.wVirtualKeyCode = VK_BACK;
117 } else {
118 if ((inchar=='\n')||(inchar=='\r')) {
119 ir.Event.KeyEvent.uChar.AsciiChar = '\r';
120 ir.Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
121 ir.Event.KeyEvent.wVirtualScanCode = 0x1c;
122 ir.Event.KeyEvent.dwControlKeyState = 0;
123 } else {
124 if (inchar<' ') {
125 /* FIXME: find good values for ^X */
126 ir.Event.KeyEvent.wVirtualKeyCode = 0xdead;
127 ir.Event.KeyEvent.wVirtualScanCode = 0xbeef;
132 assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
133 ir.Event.KeyEvent.bKeyDown = 0;
134 assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
135 continue;
137 /* inchar is ESC */
138 if ((j==len-1) || (buf[j+1]!='[')) {/* add ESCape on its own */
139 ir.EventType = 1; /* Key_event */
140 ir.Event.KeyEvent.bKeyDown = 1;
141 ir.Event.KeyEvent.wRepeatCount = 0;
143 ir.Event.KeyEvent.wVirtualKeyCode = VkKeyScan16(27);
144 ir.Event.KeyEvent.wVirtualScanCode = MapVirtualKey16(
145 ir.Event.KeyEvent.wVirtualKeyCode,0
147 ir.Event.KeyEvent.dwControlKeyState = 0;
148 ir.Event.KeyEvent.uChar.AsciiChar = 27;
149 assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
150 ir.Event.KeyEvent.bKeyDown = 0;
151 assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
152 continue;
154 for (k=j;k<len;k++) {
155 if (((buf[k]>='A') && (buf[k]<='Z')) ||
156 ((buf[k]>='a') && (buf[k]<='z')) ||
157 (buf[k]=='~')
159 break;
161 if (k<len) {
162 int subid,scancode=0;
164 ir.EventType = 1; /* Key_event */
165 ir.Event.KeyEvent.bKeyDown = 1;
166 ir.Event.KeyEvent.wRepeatCount = 0;
167 ir.Event.KeyEvent.dwControlKeyState = 0;
169 ir.Event.KeyEvent.wVirtualKeyCode = 0xad; /* FIXME */
170 ir.Event.KeyEvent.wVirtualScanCode = 0xad; /* FIXME */
171 ir.Event.KeyEvent.uChar.AsciiChar = 0;
173 switch (buf[k]) {
174 case '~':
175 sscanf(&buf[j+2],"%d",&subid);
176 switch (subid) {
177 case 2:/*INS */scancode = 0xe052;break;
178 case 3:/*DEL */scancode = 0xe053;break;
179 case 6:/*PGDW*/scancode = 0xe051;break;
180 case 5:/*PGUP*/scancode = 0xe049;break;
181 case 11:/*F1 */scancode = 0x003b;break;
182 case 12:/*F2 */scancode = 0x003c;break;
183 case 13:/*F3 */scancode = 0x003d;break;
184 case 14:/*F4 */scancode = 0x003e;break;
185 case 15:/*F5 */scancode = 0x003f;break;
186 case 17:/*F6 */scancode = 0x0040;break;
187 case 18:/*F7 */scancode = 0x0041;break;
188 case 19:/*F8 */scancode = 0x0042;break;
189 case 20:/*F9 */scancode = 0x0043;break;
190 case 21:/*F10 */scancode = 0x0044;break;
191 case 23:/*F11 */scancode = 0x00d9;break;
192 case 24:/*F12 */scancode = 0x00da;break;
193 /* FIXME: Shift-Fx */
194 default:
195 FIXME("parse ESC[%d~\n",subid);
196 break;
198 break;
199 case 'A': /* Cursor Up */scancode = 0xe048;break;
200 case 'B': /* Cursor Down */scancode = 0xe050;break;
201 case 'D': /* Cursor Left */scancode = 0xe04b;break;
202 case 'C': /* Cursor Right */scancode = 0xe04d;break;
203 case 'F': /* End */scancode = 0xe04f;break;
204 case 'H': /* Home */scancode = 0xe047;break;
205 case 'M':
206 /* Mouse Button Press (ESCM<button+'!'><x+'!'><y+'!'>) or
207 * Release (ESCM#<x+'!'><y+'!'>
209 if (k<len-3) {
210 ir.EventType = MOUSE_EVENT;
211 ir.Event.MouseEvent.dwMousePosition.x = buf[k+2]-'!';
212 ir.Event.MouseEvent.dwMousePosition.y = buf[k+3]-'!';
213 if (buf[k+1]=='#')
214 ir.Event.MouseEvent.dwButtonState = 0;
215 else
216 ir.Event.MouseEvent.dwButtonState = 1<<(buf[k+1]-' ');
217 ir.Event.MouseEvent.dwEventFlags = 0; /* FIXME */
218 assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk));
219 j=k+3;
221 break;
222 case 'c':
223 j=k;
224 break;
226 if (scancode) {
227 ir.Event.KeyEvent.wVirtualScanCode = scancode;
228 ir.Event.KeyEvent.wVirtualKeyCode = MapVirtualKey16(scancode,1);
229 assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
230 ir.Event.KeyEvent.bKeyDown = 0;
231 assert(WriteConsoleInputA( hConsoleInput, &ir, 1, &junk ));
232 j=k;
233 continue;
239 /****************************************************************************
240 * CONSOLE_get_input (internal)
242 * Reads (nonblocking) as much input events as possible and stores them
243 * in an internal queue.
245 static void
246 CONSOLE_get_input( HANDLE handle, BOOL blockwait )
248 char *buf = HeapAlloc(GetProcessHeap(),0,1);
249 int len = 0, escape_seen = 0;
251 while (1)
253 DWORD res;
254 char inchar;
256 /* If we have at one time seen escape in this loop, we are
257 * within an Escape sequence, so wait for a bit more input for the
258 * rest of the loop.
260 if (WaitForSingleObject( handle, escape_seen*10 )) break;
261 if (!ReadFile( handle, &inchar, 1, &res, NULL )) break;
262 if (!res) /* res 0 but readable means EOF? Hmm. */
263 break;
264 buf = HeapReAlloc(GetProcessHeap(),0,buf,len+1);
265 buf[len++]=inchar;
266 if (inchar == 27) {
267 if (len>1) {
268 /* If we spot an ESC, we flush all up to it
269 * since we can be sure that we have a complete
270 * sequence.
272 CONSOLE_string_to_IR(handle,buf,len-1);
273 buf = HeapReAlloc(GetProcessHeap(),0,buf,1);
274 buf[0] = 27;
275 len = 1;
277 escape_seen = 1;
280 CONSOLE_string_to_IR(handle,buf,len);
281 HeapFree(GetProcessHeap(),0,buf);
284 /******************************************************************************
285 * SetConsoleCtrlHandler [KERNEL32.459] Adds function to calling process list
287 * PARAMS
288 * func [I] Address of handler function
289 * add [I] Handler to add or remove
291 * RETURNS
292 * Success: TRUE
293 * Failure: FALSE
295 * CHANGED
296 * James Sutherland (JamesSutherland@gmx.de)
297 * Added global variables console_ignore_ctrl_c and handlers[]
298 * Does not yet do any error checking, or set LastError if failed.
299 * This doesn't yet matter, since these handlers are not yet called...!
301 static unsigned int console_ignore_ctrl_c = 0;
302 static HANDLER_ROUTINE *handlers[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
303 BOOL WINAPI SetConsoleCtrlHandler( HANDLER_ROUTINE *func, BOOL add )
305 unsigned int alloc_loop = sizeof(handlers)/sizeof(HANDLER_ROUTINE *);
306 unsigned int done = 0;
307 FIXME("(%p,%i) - no error checking or testing yet\n", func, add);
308 if (!func)
310 console_ignore_ctrl_c = add;
311 return TRUE;
313 if (add)
315 for (;alloc_loop--;)
316 if (!handlers[alloc_loop] && !done)
318 handlers[alloc_loop] = func;
319 done++;
321 if (!done)
322 FIXME("Out of space on CtrlHandler table\n");
323 return(done);
325 else
327 for (;alloc_loop--;)
328 if (handlers[alloc_loop] == func && !done)
330 handlers[alloc_loop] = 0;
331 done++;
333 if (!done)
334 WARN("Attempt to remove non-installed CtrlHandler %p\n",
335 func);
336 return (done);
338 return (done);
342 /******************************************************************************
343 * GenerateConsoleCtrlEvent [KERNEL32.275] Simulate a CTRL-C or CTRL-BREAK
345 * PARAMS
346 * dwCtrlEvent [I] Type of event
347 * dwProcessGroupID [I] Process group ID to send event to
349 * NOTES
350 * Doesn't yet work...!
352 * RETURNS
353 * Success: True
354 * Failure: False (and *should* [but doesn't] set LastError)
356 BOOL WINAPI GenerateConsoleCtrlEvent( DWORD dwCtrlEvent,
357 DWORD dwProcessGroupID )
359 if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
361 ERR("invalid event %d for PGID %ld\n",
362 (unsigned short)dwCtrlEvent, dwProcessGroupID );
363 return FALSE;
365 if (dwProcessGroupID == GetCurrentProcessId() )
367 FIXME("Attempt to send event %d to self - stub\n",
368 (unsigned short)dwCtrlEvent );
369 return FALSE;
371 FIXME("event %d to external PGID %ld - not implemented yet\n",
372 (unsigned short)dwCtrlEvent, dwProcessGroupID );
373 return FALSE;
377 /******************************************************************************
378 * CreateConsoleScreenBuffer [KERNEL32.151] Creates a console screen buffer
380 * PARAMS
381 * dwDesiredAccess [I] Access flag
382 * dwShareMode [I] Buffer share mode
383 * sa [I] Security attributes
384 * dwFlags [I] Type of buffer to create
385 * lpScreenBufferData [I] Reserved
387 * NOTES
388 * Should call SetLastError
390 * RETURNS
391 * Success: Handle to new console screen buffer
392 * Failure: INVALID_HANDLE_VALUE
394 HANDLE WINAPI CreateConsoleScreenBuffer( DWORD dwDesiredAccess,
395 DWORD dwShareMode, LPSECURITY_ATTRIBUTES sa,
396 DWORD dwFlags, LPVOID lpScreenBufferData )
398 FIXME("(%ld,%ld,%p,%ld,%p): stub\n",dwDesiredAccess,
399 dwShareMode, sa, dwFlags, lpScreenBufferData);
400 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
401 return INVALID_HANDLE_VALUE;
405 /***********************************************************************
406 * GetConsoleScreenBufferInfo (KERNEL32.190)
408 BOOL WINAPI GetConsoleScreenBufferInfo( HANDLE hConsoleOutput,
409 LPCONSOLE_SCREEN_BUFFER_INFO csbi )
411 csbi->dwSize.x = 80;
412 csbi->dwSize.y = 24;
413 csbi->dwCursorPosition.x = 0;
414 csbi->dwCursorPosition.y = 0;
415 csbi->wAttributes = 0;
416 csbi->srWindow.Left = 0;
417 csbi->srWindow.Right = 79;
418 csbi->srWindow.Top = 0;
419 csbi->srWindow.Bottom = 23;
420 csbi->dwMaximumWindowSize.x = 80;
421 csbi->dwMaximumWindowSize.y = 24;
422 return TRUE;
426 /******************************************************************************
427 * SetConsoleActiveScreenBuffer [KERNEL32.623] Sets buffer to current console
429 * RETURNS
430 * Success: TRUE
431 * Failure: FALSE
433 BOOL WINAPI SetConsoleActiveScreenBuffer(
434 HANDLE hConsoleOutput) /* [in] Handle to console screen buffer */
436 FIXME("(%x): stub\n", hConsoleOutput);
437 return FALSE;
441 /***********************************************************************
442 * GetLargestConsoleWindowSize (KERNEL32.226)
444 COORD WINAPI GetLargestConsoleWindowSize( HANDLE hConsoleOutput )
446 COORD c;
447 c.x = 80;
448 c.y = 24;
449 return c;
452 /***********************************************************************
453 * FreeConsole (KERNEL32.267)
455 BOOL WINAPI FreeConsole(VOID)
457 return !server_call( REQ_FREE_CONSOLE );
461 /*************************************************************************
462 * CONSOLE_OpenHandle
464 * Open a handle to the current process console.
466 HANDLE CONSOLE_OpenHandle( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES sa )
468 int ret = -1;
469 struct open_console_request *req = get_req_buffer();
471 req->output = output;
472 req->access = access;
473 req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
474 SetLastError(0);
475 if (!server_call( REQ_OPEN_CONSOLE )) ret = req->handle;
476 return ret;
480 /*************************************************************************
481 * CONSOLE_make_complex [internal]
483 * Turns a CONSOLE kernel object into a complex one.
484 * (switches from output/input using the terminal where WINE was started to
485 * its own xterm).
487 * This makes simple commandline tools pipeable, while complex commandline
488 * tools work without getting messed up by debugoutput.
490 * All other functions should work indedependend from this call.
492 * To test for complex console: pid == 0 -> simple, otherwise complex.
494 static BOOL CONSOLE_make_complex(HANDLE handle)
496 struct set_console_fd_request *req = get_req_buffer();
497 struct termios term;
498 char buf[256];
499 char c = '\0';
500 int i,xpid,master,slave,pty_handle;
502 if (CONSOLE_GetPid( handle )) return TRUE; /* already complex */
504 MESSAGE("Console: Making console complex (creating an xterm)...\n");
506 if (tcgetattr(0, &term) < 0) {
507 /* ignore failure, or we can't run from a script */
509 term.c_lflag = ~(ECHO|ICANON);
511 if (wine_openpty(&master, &slave, NULL, &term, NULL) < 0)
512 return FALSE;
514 if ((xpid=fork()) == 0) {
515 tcsetattr(slave, TCSADRAIN, &term);
516 close( slave );
517 sprintf(buf, "-Sxx%d", master);
518 /* "-fn vga" for VGA font. Harmless if vga is not present:
519 * xterm: unable to open font "vga", trying "fixed"....
521 execlp("xterm", "xterm", buf, "-fn","vga",NULL);
522 ERR("error creating AllocConsole xterm\n");
523 exit(1);
525 pty_handle = FILE_DupUnixHandle( slave, GENERIC_READ | GENERIC_WRITE );
526 close( master );
527 close( slave );
528 if (pty_handle == -1) return FALSE;
530 /* most xterms like to print their window ID when used with -S;
531 * read it and continue before the user has a chance...
533 for (i = 0; i < 10000; i++)
535 BOOL ok = ReadFile( pty_handle, &c, 1, NULL, NULL );
536 if (!ok && !c) usleep(100); /* wait for xterm to be created */
537 else if (c == '\n') break;
539 if (i == 10000)
541 ERR("can't read xterm WID\n");
542 CloseHandle( pty_handle );
543 return FALSE;
545 req->handle = handle;
546 req->file_handle = pty_handle;
547 req->pid = xpid;
548 server_call( REQ_SET_CONSOLE_FD );
549 CloseHandle( pty_handle );
551 /* enable mouseclicks */
552 strcpy( buf, "\033[?1001s\033[?1000h" );
553 WriteFile(handle,buf,strlen(buf),NULL,NULL);
555 strcpy( buf, "\033]2;" );
556 if (GetConsoleTitleA( buf + 4, sizeof(buf) - 5 ))
558 strcat( buf, "\a" );
559 WriteFile(handle,buf,strlen(buf),NULL,NULL);
561 return TRUE;
566 /***********************************************************************
567 * AllocConsole (KERNEL32.103)
569 * creates an xterm with a pty to our program
571 BOOL WINAPI AllocConsole(VOID)
573 struct alloc_console_request *req = get_req_buffer();
574 HANDLE hStderr;
575 int handle_in, handle_out;
577 TRACE("()\n");
578 req->access = GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE;
579 req->inherit = FALSE;
580 if (server_call( REQ_ALLOC_CONSOLE )) return FALSE;
581 handle_in = req->handle_in;
582 handle_out = req->handle_out;
584 if (!DuplicateHandle( GetCurrentProcess(), req->handle_out, GetCurrentProcess(), &hStderr,
585 0, TRUE, DUPLICATE_SAME_ACCESS ))
587 CloseHandle( handle_in );
588 CloseHandle( handle_out );
589 FreeConsole();
590 return FALSE;
593 /* NT resets the STD_*_HANDLEs on console alloc */
594 SetStdHandle( STD_INPUT_HANDLE, handle_in );
595 SetStdHandle( STD_OUTPUT_HANDLE, handle_out );
596 SetStdHandle( STD_ERROR_HANDLE, hStderr );
598 SetLastError(ERROR_SUCCESS);
599 SetConsoleTitleA("Wine Console");
600 return TRUE;
604 /******************************************************************************
605 * GetConsoleCP [KERNEL32.295] Returns the OEM code page for the console
607 * RETURNS
608 * Code page code
610 UINT WINAPI GetConsoleCP(VOID)
612 return GetACP();
616 /***********************************************************************
617 * GetConsoleOutputCP (KERNEL32.189)
619 UINT WINAPI GetConsoleOutputCP(VOID)
621 return GetConsoleCP();
624 /***********************************************************************
625 * GetConsoleMode (KERNEL32.188)
627 BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
629 BOOL ret = FALSE;
630 struct get_console_mode_request *req = get_req_buffer();
631 req->handle = hcon;
632 if (!server_call( REQ_GET_CONSOLE_MODE ))
634 if (mode) *mode = req->mode;
635 ret = TRUE;
637 return ret;
641 /******************************************************************************
642 * SetConsoleMode [KERNEL32.628] Sets input mode of console's input buffer
644 * PARAMS
645 * hcon [I] Handle to console input or screen buffer
646 * mode [I] Input or output mode to set
648 * RETURNS
649 * Success: TRUE
650 * Failure: FALSE
652 BOOL WINAPI SetConsoleMode( HANDLE hcon, DWORD mode )
654 struct set_console_mode_request *req = get_req_buffer();
655 req->handle = hcon;
656 req->mode = mode;
657 return !server_call( REQ_SET_CONSOLE_MODE );
661 /***********************************************************************
662 * GetConsoleTitleA (KERNEL32.191)
664 DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size)
666 struct get_console_info_request *req = get_req_buffer();
667 DWORD ret = 0;
668 HANDLE hcon;
670 if ((hcon = CreateFileA( "CONOUT$", GENERIC_READ, 0, NULL,
671 OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
672 return 0;
673 req->handle = hcon;
674 if (!server_call( REQ_GET_CONSOLE_INFO ))
676 lstrcpynA( title, req->title, size );
677 ret = strlen(req->title);
679 CloseHandle( hcon );
680 return ret;
684 /******************************************************************************
685 * GetConsoleTitleW [KERNEL32.192] Retrieves title string for console
687 * PARAMS
688 * title [O] Address of buffer for title
689 * size [I] Size of buffer
691 * RETURNS
692 * Success: Length of string copied
693 * Failure: 0
695 DWORD WINAPI GetConsoleTitleW( LPWSTR title, DWORD size )
697 char *tmp;
698 DWORD ret;
700 if (!(tmp = HeapAlloc( GetProcessHeap(), 0, size ))) return 0;
701 ret = GetConsoleTitleA( tmp, size );
702 lstrcpyAtoW( title, tmp );
703 HeapFree( GetProcessHeap(), 0, tmp );
704 return ret;
708 /***********************************************************************
709 * WriteConsoleA (KERNEL32.729)
711 BOOL WINAPI WriteConsoleA( HANDLE hConsoleOutput,
712 LPCVOID lpBuffer,
713 DWORD nNumberOfCharsToWrite,
714 LPDWORD lpNumberOfCharsWritten,
715 LPVOID lpReserved )
717 /* FIXME: should I check if this is a console handle? */
718 return WriteFile(hConsoleOutput, lpBuffer, nNumberOfCharsToWrite,
719 lpNumberOfCharsWritten, NULL);
723 #define CADD(c) \
724 if (bufused==curbufsize-1) \
725 buffer = HeapReAlloc(GetProcessHeap(),0,buffer,(curbufsize+=100));\
726 buffer[bufused++]=c;
727 #define SADD(s) { char *x=s;while (*x) {CADD(*x);x++;}}
729 /***********************************************************************
730 * WriteConsoleOutputA (KERNEL32.732)
732 BOOL WINAPI WriteConsoleOutputA( HANDLE hConsoleOutput,
733 LPCHAR_INFO lpBuffer,
734 COORD dwBufferSize,
735 COORD dwBufferCoord,
736 LPSMALL_RECT lpWriteRegion)
738 int i,j,off=0,lastattr=-1;
739 int offbase;
740 char sbuf[20],*buffer=NULL;
741 int bufused=0,curbufsize = 100;
742 DWORD res;
743 CONSOLE_SCREEN_BUFFER_INFO csbi;
744 const int colormap[8] = {
745 0,4,2,6,
746 1,5,3,7,
748 CONSOLE_make_complex(hConsoleOutput);
749 buffer = HeapAlloc(GetProcessHeap(),0,curbufsize);
750 offbase = (dwBufferCoord.y - 1) * dwBufferSize.x +
751 (dwBufferCoord.x - lpWriteRegion->Left);
753 TRACE("orig rect top = %d, bottom=%d, left=%d, right=%d\n",
754 lpWriteRegion->Top,
755 lpWriteRegion->Bottom,
756 lpWriteRegion->Left,
757 lpWriteRegion->Right
760 GetConsoleScreenBufferInfo(hConsoleOutput, &csbi);
761 sprintf(sbuf,"%c7",27);SADD(sbuf);
763 /* Step 1. Make (Bottom,Right) offset of intersection with
764 Screen Buffer */
765 lpWriteRegion->Bottom = min(lpWriteRegion->Bottom, csbi.dwSize.y-1) -
766 lpWriteRegion->Top;
767 lpWriteRegion->Right = min(lpWriteRegion->Right, csbi.dwSize.x-1) -
768 lpWriteRegion->Left;
770 /* Step 2. If either offset is negative, then no action
771 should be performed. (Implies that requested rectangle is
772 outside the current screen buffer rectangle.) */
773 if ((lpWriteRegion->Bottom < 0) ||
774 (lpWriteRegion->Right < 0)) {
775 /* readjust (Bottom Right) for rectangle */
776 lpWriteRegion->Bottom += lpWriteRegion->Top;
777 lpWriteRegion->Right += lpWriteRegion->Left;
779 TRACE("invisible rect top = %d, bottom=%d, left=%d, right=%d\n",
780 lpWriteRegion->Top,
781 lpWriteRegion->Bottom,
782 lpWriteRegion->Left,
783 lpWriteRegion->Right
786 HeapFree(GetProcessHeap(),0,buffer);
787 return TRUE;
790 /* Step 3. Intersect with source rectangle */
791 lpWriteRegion->Bottom = lpWriteRegion->Top - dwBufferCoord.y +
792 min(lpWriteRegion->Bottom + dwBufferCoord.y, dwBufferSize.y-1);
793 lpWriteRegion->Right = lpWriteRegion->Left - dwBufferCoord.x +
794 min(lpWriteRegion->Right + dwBufferCoord.x, dwBufferSize.x-1);
796 TRACE("clipped rect top = %d, bottom=%d, left=%d,right=%d\n",
797 lpWriteRegion->Top,
798 lpWriteRegion->Bottom,
799 lpWriteRegion->Left,
800 lpWriteRegion->Right
803 /* Validate above computations made sense, if not then issue
804 error and fudge to single character rectangle */
805 if ((lpWriteRegion->Bottom < lpWriteRegion->Top) ||
806 (lpWriteRegion->Right < lpWriteRegion->Left)) {
807 ERR("Invalid clipped rectangle top = %d, bottom=%d, left=%d,right=%d\n",
808 lpWriteRegion->Top,
809 lpWriteRegion->Bottom,
810 lpWriteRegion->Left,
811 lpWriteRegion->Right
813 lpWriteRegion->Bottom = lpWriteRegion->Top;
814 lpWriteRegion->Right = lpWriteRegion->Left;
817 /* Now do the real processing and move the characters */
818 for (i=lpWriteRegion->Top;i<=lpWriteRegion->Bottom;i++) {
819 offbase += dwBufferSize.x;
820 sprintf(sbuf,"%c[%d;%dH",27,i+1,lpWriteRegion->Left+1);
821 SADD(sbuf);
822 for (j=lpWriteRegion->Left;j<=lpWriteRegion->Right;j++) {
823 off = j + offbase;
824 if (lastattr!=lpBuffer[off].Attributes) {
825 lastattr = lpBuffer[off].Attributes;
826 sprintf(sbuf,"%c[0;%s3%d;4%dm",
828 (lastattr & FOREGROUND_INTENSITY)?"1;":"",
829 colormap[lastattr&7],
830 colormap[(lastattr&0x70)>>4]
832 /* FIXME: BACKGROUND_INTENSITY */
833 SADD(sbuf);
835 CADD(lpBuffer[off].Char.AsciiChar);
838 sprintf(sbuf,"%c[0m%c8",27,27);SADD(sbuf);
839 WriteFile(hConsoleOutput,buffer,bufused,&res,NULL);
840 HeapFree(GetProcessHeap(),0,buffer);
841 return TRUE;
844 /***********************************************************************
845 * WriteConsoleW (KERNEL32.577)
847 BOOL WINAPI WriteConsoleW( HANDLE hConsoleOutput,
848 LPCVOID lpBuffer,
849 DWORD nNumberOfCharsToWrite,
850 LPDWORD lpNumberOfCharsWritten,
851 LPVOID lpReserved )
853 BOOL ret;
854 LPSTR xstring;
855 DWORD n;
857 n = WideCharToMultiByte(CP_ACP,0,lpBuffer,nNumberOfCharsToWrite,NULL,0,NULL,NULL);
858 xstring=HeapAlloc( GetProcessHeap(), 0, n );
860 n = WideCharToMultiByte(CP_ACP,0,lpBuffer,nNumberOfCharsToWrite,xstring,n,NULL,NULL);
862 /* FIXME: should I check if this is a console handle? */
863 ret= WriteFile(hConsoleOutput, xstring, n,
864 lpNumberOfCharsWritten, NULL);
865 /* FIXME: lpNumberOfCharsWritten should be converted to numofchars in UNICODE */
866 HeapFree( GetProcessHeap(), 0, xstring );
867 return ret;
871 /***********************************************************************
872 * ReadConsoleA (KERNEL32.419)
874 BOOL WINAPI ReadConsoleA( HANDLE hConsoleInput,
875 LPVOID lpBuffer,
876 DWORD nNumberOfCharsToRead,
877 LPDWORD lpNumberOfCharsRead,
878 LPVOID lpReserved )
880 int charsread = 0;
881 LPSTR xbuf = (LPSTR)lpBuffer;
882 LPINPUT_RECORD ir;
884 TRACE("(%d,%p,%ld,%p,%p)\n",
885 hConsoleInput,lpBuffer,nNumberOfCharsToRead,
886 lpNumberOfCharsRead,lpReserved
889 CONSOLE_get_input(hConsoleInput,FALSE);
891 /* FIXME: should we read at least 1 char? The SDK does not say */
892 while (charsread<nNumberOfCharsToRead)
894 struct read_console_input_request *req = get_req_buffer();
895 req->handle = hConsoleInput;
896 req->count = 1;
897 req->flush = 1;
898 if (server_call( REQ_READ_CONSOLE_INPUT )) return FALSE;
899 if (!req->read) break;
900 ir = (LPINPUT_RECORD)(req+1);
901 if (!ir->Event.KeyEvent.bKeyDown)
902 continue;
903 if (ir->EventType != KEY_EVENT)
904 continue;
905 *xbuf++ = ir->Event.KeyEvent.uChar.AsciiChar;
906 charsread++;
908 if (lpNumberOfCharsRead)
909 *lpNumberOfCharsRead = charsread;
910 return TRUE;
913 /***********************************************************************
914 * ReadConsoleW (KERNEL32.427)
916 BOOL WINAPI ReadConsoleW( HANDLE hConsoleInput,
917 LPVOID lpBuffer,
918 DWORD nNumberOfCharsToRead,
919 LPDWORD lpNumberOfCharsRead,
920 LPVOID lpReserved )
922 BOOL ret;
923 LPSTR buf = (LPSTR)HeapAlloc(GetProcessHeap(), 0, nNumberOfCharsToRead);
925 ret = ReadConsoleA(
926 hConsoleInput,
927 buf,
928 nNumberOfCharsToRead,
929 lpNumberOfCharsRead,
930 lpReserved
932 if (ret)
933 lstrcpynAtoW(lpBuffer,buf,nNumberOfCharsToRead);
934 HeapFree( GetProcessHeap(), 0, buf );
935 return ret;
939 /******************************************************************************
940 * ReadConsoleInputA [KERNEL32.569] Reads data from a console
942 * PARAMS
943 * hConsoleInput [I] Handle to console input buffer
944 * lpBuffer [O] Address of buffer for read data
945 * nLength [I] Number of records to read
946 * lpNumberOfEventsRead [O] Address of number of records read
948 * RETURNS
949 * Success: TRUE
950 * Failure: FALSE
952 BOOL WINAPI ReadConsoleInputA(HANDLE hConsoleInput, LPINPUT_RECORD lpBuffer,
953 DWORD nLength, LPDWORD lpNumberOfEventsRead)
955 struct read_console_input_request *req = get_req_buffer();
957 /* loop until we get at least one event */
958 for (;;)
960 req->handle = hConsoleInput;
961 req->count = nLength;
962 req->flush = 1;
963 if (server_call( REQ_READ_CONSOLE_INPUT )) return FALSE;
964 if (req->read)
966 memcpy( lpBuffer, req + 1, req->read * sizeof(*lpBuffer) );
967 if (lpNumberOfEventsRead) *lpNumberOfEventsRead = req->read;
968 return TRUE;
970 CONSOLE_get_input(hConsoleInput,TRUE);
971 /*WaitForSingleObject( hConsoleInput, INFINITE32 );*/
976 /***********************************************************************
977 * ReadConsoleInputW (KERNEL32.570)
979 BOOL WINAPI ReadConsoleInputW( HANDLE handle, LPINPUT_RECORD buffer,
980 DWORD count, LPDWORD read )
982 /* FIXME: Fix this if we get UNICODE input. */
983 return ReadConsoleInputA( handle, buffer, count, read );
987 /***********************************************************************
988 * FlushConsoleInputBuffer (KERNEL32.132)
990 BOOL WINAPI FlushConsoleInputBuffer( HANDLE handle )
992 struct read_console_input_request *req = get_req_buffer();
993 req->handle = handle;
994 req->count = -1; /* get all records */
995 req->flush = 1;
996 return !server_call( REQ_READ_CONSOLE_INPUT );
1000 /***********************************************************************
1001 * PeekConsoleInputA (KERNEL32.550)
1003 * Gets 'count' first events (or less) from input queue.
1005 * Does not need a complex console.
1007 BOOL WINAPI PeekConsoleInputA( HANDLE handle, LPINPUT_RECORD buffer,
1008 DWORD count, LPDWORD read )
1010 struct read_console_input_request *req = get_req_buffer();
1012 CONSOLE_get_input(handle,FALSE);
1014 req->handle = handle;
1015 req->count = count;
1016 req->flush = 0;
1017 if (server_call( REQ_READ_CONSOLE_INPUT )) return FALSE;
1018 if (req->read) memcpy( buffer, req + 1, req->read * sizeof(*buffer) );
1019 if (read) *read = req->read;
1020 return TRUE;
1024 /***********************************************************************
1025 * PeekConsoleInputW (KERNEL32.551)
1027 BOOL WINAPI PeekConsoleInputW(HANDLE hConsoleInput,
1028 LPINPUT_RECORD pirBuffer,
1029 DWORD cInRecords,
1030 LPDWORD lpcRead)
1032 /* FIXME: Hmm. Fix this if we get UNICODE input. */
1033 return PeekConsoleInputA(hConsoleInput,pirBuffer,cInRecords,lpcRead);
1037 /******************************************************************************
1038 * WriteConsoleInputA [KERNEL32.730] Write data to a console input buffer
1041 BOOL WINAPI WriteConsoleInputA( HANDLE handle, INPUT_RECORD *buffer,
1042 DWORD count, LPDWORD written )
1044 struct write_console_input_request *req = get_req_buffer();
1045 const DWORD max = server_remaining( req + 1 ) / sizeof(INPUT_RECORD);
1047 if (written) *written = 0;
1048 while (count)
1050 DWORD len = count < max ? count : max;
1051 req->count = len;
1052 req->handle = handle;
1053 memcpy( req + 1, buffer, len * sizeof(*buffer) );
1054 if (server_call( REQ_WRITE_CONSOLE_INPUT )) return FALSE;
1055 if (written) *written += req->written;
1056 count -= len;
1057 buffer += len;
1059 return TRUE;
1063 /***********************************************************************
1064 * SetConsoleTitleA (KERNEL32.476)
1066 * Sets the console title.
1068 * We do not necessarily need to create a complex console for that,
1069 * but should remember the title and set it on creation of the latter.
1070 * (not fixed at this time).
1072 BOOL WINAPI SetConsoleTitleA(LPCSTR title)
1074 struct set_console_info_request *req = get_req_buffer();
1075 HANDLE hcon;
1076 DWORD written;
1078 if ((hcon = CreateFileA( "CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL,
1079 OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
1080 return FALSE;
1081 req->handle = hcon;
1082 req->mask = SET_CONSOLE_INFO_TITLE;
1083 lstrcpynA( req->title, title, server_remaining(req->title) );
1084 if (server_call( REQ_SET_CONSOLE_INFO )) goto error;
1085 if (CONSOLE_GetPid( hcon ))
1087 /* only set title for complex console (own xterm) */
1088 WriteFile( hcon, "\033]2;", 4, &written, NULL );
1089 WriteFile( hcon, title, strlen(title), &written, NULL );
1090 WriteFile( hcon, "\a", 1, &written, NULL );
1092 CloseHandle( hcon );
1093 return TRUE;
1094 error:
1095 CloseHandle( hcon );
1096 return FALSE;
1100 /******************************************************************************
1101 * SetConsoleTitleW [KERNEL32.477] Sets title bar string for console
1103 * PARAMS
1104 * title [I] Address of new title
1106 * NOTES
1107 * This should not be calling the A version
1109 * RETURNS
1110 * Success: TRUE
1111 * Failure: FALSE
1113 BOOL WINAPI SetConsoleTitleW( LPCWSTR title )
1115 BOOL ret;
1117 LPSTR titleA = HEAP_strdupWtoA( GetProcessHeap(), 0, title );
1118 ret = SetConsoleTitleA(titleA);
1119 HeapFree( GetProcessHeap(), 0, titleA );
1120 return ret;
1123 /******************************************************************************
1124 * SetConsoleCursorPosition [KERNEL32.627]
1125 * Sets the cursor position in console
1127 * PARAMS
1128 * hConsoleOutput [I] Handle of console screen buffer
1129 * dwCursorPosition [I] New cursor position coordinates
1131 * RETURNS STD
1133 BOOL WINAPI SetConsoleCursorPosition( HANDLE hcon, COORD pos )
1135 char xbuf[20];
1136 DWORD xlen;
1138 /* make console complex only if we change lines, not just in the line */
1139 if (pos.y)
1140 CONSOLE_make_complex(hcon);
1142 TRACE("%d (%dx%d)\n", hcon, pos.x , pos.y );
1143 /* x are columns, y rows */
1144 if (pos.y)
1145 /* full screen cursor absolute positioning */
1146 sprintf(xbuf,"%c[%d;%dH", 0x1B, pos.y+1, pos.x+1);
1147 else
1148 /* relative cursor positioning in line (\r to go to 0) */
1149 sprintf(xbuf,"\r%c[%dC", 0x1B, pos.x);
1150 /* FIXME: store internal if we start using own console buffers */
1151 WriteFile(hcon,xbuf,strlen(xbuf),&xlen,NULL);
1152 return TRUE;
1155 /***********************************************************************
1156 * GetNumberOfConsoleInputEvents (KERNEL32.246)
1158 BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hcon,LPDWORD nrofevents)
1160 struct read_console_input_request *req = get_req_buffer();
1162 CONSOLE_get_input(hcon,FALSE);
1164 req->handle = hcon;
1165 req->count = -1;
1166 req->flush = 0;
1167 if (server_call( REQ_READ_CONSOLE_INPUT )) return FALSE;
1168 if (nrofevents) *nrofevents = req->read;
1169 return TRUE;
1172 /***********************************************************************
1173 * GetNumberOfConsoleMouseButtons (KERNEL32.358)
1175 BOOL WINAPI GetNumberOfConsoleMouseButtons(LPDWORD nrofbuttons)
1177 FIXME("(%p): stub\n", nrofbuttons);
1178 *nrofbuttons = 2;
1179 return TRUE;
1182 /******************************************************************************
1183 * GetConsoleCursorInfo [KERNEL32.296] Gets size and visibility of console
1185 * PARAMS
1186 * hcon [I] Handle to console screen buffer
1187 * cinfo [O] Address of cursor information
1189 * RETURNS
1190 * Success: TRUE
1191 * Failure: FALSE
1193 BOOL WINAPI GetConsoleCursorInfo( HANDLE hcon, LPCONSOLE_CURSOR_INFO cinfo )
1195 struct get_console_info_request *req = get_req_buffer();
1196 req->handle = hcon;
1197 if (server_call( REQ_GET_CONSOLE_INFO )) return FALSE;
1198 if (cinfo)
1200 cinfo->dwSize = req->cursor_size;
1201 cinfo->bVisible = req->cursor_visible;
1203 return TRUE;
1207 /******************************************************************************
1208 * SetConsoleCursorInfo [KERNEL32.626] Sets size and visibility of cursor
1210 * RETURNS
1211 * Success: TRUE
1212 * Failure: FALSE
1214 BOOL WINAPI SetConsoleCursorInfo(
1215 HANDLE hcon, /* [in] Handle to console screen buffer */
1216 LPCONSOLE_CURSOR_INFO cinfo) /* [in] Address of cursor information */
1218 struct set_console_info_request *req = get_req_buffer();
1219 char buf[8];
1220 DWORD xlen;
1222 CONSOLE_make_complex(hcon);
1223 sprintf(buf,"\033[?25%c",cinfo->bVisible?'h':'l');
1224 WriteFile(hcon,buf,strlen(buf),&xlen,NULL);
1226 req->handle = hcon;
1227 req->cursor_size = cinfo->dwSize;
1228 req->cursor_visible = cinfo->bVisible;
1229 req->mask = SET_CONSOLE_INFO_CURSOR;
1230 return !server_call( REQ_SET_CONSOLE_INFO );
1234 /******************************************************************************
1235 * SetConsoleWindowInfo [KERNEL32.634] Sets size and position of console
1237 * RETURNS
1238 * Success: TRUE
1239 * Failure: FALSE
1241 BOOL WINAPI SetConsoleWindowInfo(
1242 HANDLE hcon, /* [in] Handle to console screen buffer */
1243 BOOL bAbsolute, /* [in] Coordinate type flag */
1244 LPSMALL_RECT window) /* [in] Address of new window rectangle */
1246 FIXME("(%x,%d,%p): stub\n", hcon, bAbsolute, window);
1247 return TRUE;
1251 /******************************************************************************
1252 * SetConsoleTextAttribute [KERNEL32.631] Sets colors for text
1254 * Sets the foreground and background color attributes of characters
1255 * written to the screen buffer.
1257 * RETURNS
1258 * Success: TRUE
1259 * Failure: FALSE
1261 BOOL WINAPI SetConsoleTextAttribute(HANDLE hConsoleOutput,WORD wAttr)
1263 const int colormap[8] = {
1264 0,4,2,6,
1265 1,5,3,7,
1267 DWORD xlen;
1268 char buffer[20];
1270 TRACE("(%d,%d)\n",hConsoleOutput,wAttr);
1271 sprintf(buffer,"%c[0;%s3%d;4%dm",
1273 (wAttr & FOREGROUND_INTENSITY)?"1;":"",
1274 colormap[wAttr&7],
1275 colormap[(wAttr&0x70)>>4]
1277 WriteFile(hConsoleOutput,buffer,strlen(buffer),&xlen,NULL);
1278 return TRUE;
1282 /******************************************************************************
1283 * SetConsoleScreenBufferSize [KERNEL32.630] Changes size of console
1285 * PARAMS
1286 * hConsoleOutput [I] Handle to console screen buffer
1287 * dwSize [I] New size in character rows and cols
1289 * RETURNS
1290 * Success: TRUE
1291 * Failure: FALSE
1293 BOOL WINAPI SetConsoleScreenBufferSize( HANDLE hConsoleOutput,
1294 COORD dwSize )
1296 FIXME("(%d,%dx%d): stub\n",hConsoleOutput,dwSize.x,dwSize.y);
1297 return TRUE;
1301 /******************************************************************************
1302 * FillConsoleOutputCharacterA [KERNEL32.242]
1304 * PARAMS
1305 * hConsoleOutput [I] Handle to screen buffer
1306 * cCharacter [I] Character to write
1307 * nLength [I] Number of cells to write to
1308 * dwCoord [I] Coords of first cell
1309 * lpNumCharsWritten [O] Pointer to number of cells written
1311 * RETURNS
1312 * Success: TRUE
1313 * Failure: FALSE
1315 BOOL WINAPI FillConsoleOutputCharacterA(
1316 HANDLE hConsoleOutput,
1317 BYTE cCharacter,
1318 DWORD nLength,
1319 COORD dwCoord,
1320 LPDWORD lpNumCharsWritten)
1322 long count;
1323 DWORD xlen;
1325 SetConsoleCursorPosition(hConsoleOutput,dwCoord);
1326 for(count=0;count<nLength;count++)
1327 WriteFile(hConsoleOutput,&cCharacter,1,&xlen,NULL);
1328 *lpNumCharsWritten = nLength;
1329 return TRUE;
1333 /******************************************************************************
1334 * FillConsoleOutputCharacterW [KERNEL32.243] Writes characters to console
1336 * PARAMS
1337 * hConsoleOutput [I] Handle to screen buffer
1338 * cCharacter [I] Character to write
1339 * nLength [I] Number of cells to write to
1340 * dwCoord [I] Coords of first cell
1341 * lpNumCharsWritten [O] Pointer to number of cells written
1343 * RETURNS
1344 * Success: TRUE
1345 * Failure: FALSE
1347 BOOL WINAPI FillConsoleOutputCharacterW(HANDLE hConsoleOutput,
1348 WCHAR cCharacter,
1349 DWORD nLength,
1350 COORD dwCoord,
1351 LPDWORD lpNumCharsWritten)
1353 long count;
1354 DWORD xlen;
1356 SetConsoleCursorPosition(hConsoleOutput,dwCoord);
1357 /* FIXME: not quite correct ... but the lower part of UNICODE char comes
1358 * first
1360 for(count=0;count<nLength;count++)
1361 WriteFile(hConsoleOutput,&cCharacter,1,&xlen,NULL);
1362 *lpNumCharsWritten = nLength;
1363 return TRUE;
1367 /******************************************************************************
1368 * FillConsoleOutputAttribute [KERNEL32.241] Sets attributes for console
1370 * PARAMS
1371 * hConsoleOutput [I] Handle to screen buffer
1372 * wAttribute [I] Color attribute to write
1373 * nLength [I] Number of cells to write to
1374 * dwCoord [I] Coords of first cell
1375 * lpNumAttrsWritten [O] Pointer to number of cells written
1377 * RETURNS
1378 * Success: TRUE
1379 * Failure: FALSE
1381 BOOL WINAPI FillConsoleOutputAttribute( HANDLE hConsoleOutput,
1382 WORD wAttribute, DWORD nLength, COORD dwCoord,
1383 LPDWORD lpNumAttrsWritten)
1385 FIXME("(%d,%d,%ld,%dx%d,%p): stub\n", hConsoleOutput,
1386 wAttribute,nLength,dwCoord.x,dwCoord.y,lpNumAttrsWritten);
1387 *lpNumAttrsWritten = nLength;
1388 return TRUE;
1391 /******************************************************************************
1392 * ReadConsoleOutputCharacterA [KERNEL32.573]
1394 * BUGS
1395 * Unimplemented
1397 BOOL WINAPI ReadConsoleOutputCharacterA(HANDLE hConsoleOutput,
1398 LPSTR lpstr, DWORD dword, COORD coord, LPDWORD lpdword)
1400 FIXME("(%d,%p,%ld,%dx%d,%p): stub\n", hConsoleOutput,lpstr,
1401 dword,coord.x,coord.y,lpdword);
1402 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1403 return FALSE;
1407 /******************************************************************************
1408 * ScrollConsoleScreenBufferA [KERNEL32.612]
1410 * BUGS
1411 * Unimplemented
1413 BOOL WINAPI ScrollConsoleScreenBufferA( HANDLE hConsoleOutput,
1414 LPSMALL_RECT lpScrollRect, LPSMALL_RECT lpClipRect,
1415 COORD dwDestOrigin, LPCHAR_INFO lpFill)
1417 FIXME("(%d,%p,%p,%dx%d,%p): stub\n", hConsoleOutput,lpScrollRect,
1418 lpClipRect,dwDestOrigin.x,dwDestOrigin.y,lpFill);
1419 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1420 return FALSE;