[CONSOLE.CPL-KERNEL32]

Fix some compilation warnings with MSVC.

[KERNEL32-CONSRV]
- Implement console graphics screen buffers, as described in http://blog.airesoft.co.uk/2012/10/things-ms-can-do-that-they-dont-tell-you-about-console-graphics/ .
  The idea is that the console server creates a memory shared section to be shared with the client console application (it increases performance). A mutex is used to "say" to the console server that he can repaint the screen. The function InvalidateConsoleDIBits is implemented too. The definition of the structure CONSOLE_GRAPHICS_BUFFER_INFO comes directly from the site.
- CreateConsoleScreenBuffer was modified to be able to create such buffers.
This is needed for a working NTVDM-like application.

[CONSRV]
- Rework the console buffer structures so that text-mode buffers and graphics-mode buffers can "inherit" from an "abstract" structure, CONSOLE_SCREEN_BUFFER. Add few helper functions for manipulating them.
- Reorganize the output code in "graphics.c" and "text.c" files to separate text-mode only code from graphics-mode only code, both in the console server and in the GUI front-end.

Other fixes:
- Fix mouse handling (left and right clicks when one goes away from the "Selection" mode); do not handle mouse signal when we reactivate the GUI front-end window by a click.
- Fix GetLargestConsoleWindowSize API in console server side. Now pressing Alt+F9 in Far Manager to "change" the "video" mode works correctly.

Finally:
- Start to implement a (fake, i.e. not using directly a VGA driver) console fullscreen mode. Currently Alt-Enter key presses call a stub which just alternates DPRINTing between "switch to fullscreen mode" and "switch to windowed mode".

Images here:
- Example of an application (a 16-bit emulator by Mysoft) which uses the console graphics screen-buffer functionality: http://img577.imageshack.us/img577/1693/mysoftemulatorargon.png
- A potpourri of console applications which use graphics screen-buffers: http://img571.imageshack.us/img571/6526/consoledelirium.png

Enjoy :)

svn path=/trunk/; revision=59099
This commit is contained in:
Hermès Bélusca-Maïto
2013-05-29 00:29:07 +00:00
parent 7791dc4bd9
commit 7c2b066810
30 changed files with 3392 additions and 2105 deletions
-1
View File
@@ -194,7 +194,6 @@ extern "C" {
#define PROFILE_USER 0x10000000
#define PROFILE_KERNEL 0x20000000
#define PROFILE_SERVER 0x40000000
#define CONSOLE_TEXTMODE_BUFFER 1
#define CREATE_NEW 1
#define CREATE_ALWAYS 2
#define OPEN_EXISTING 3
+39 -4
View File
@@ -24,12 +24,15 @@ extern "C" {
/*
* Console display modes
*/
// These codes are answered by GetConsoleDisplayMode
#define CONSOLE_WINDOWED 0
#define CONSOLE_FULLSCREEN 1
#define CONSOLE_FULLSCREEN_HARDWARE 2
#if (_WIN32_WINNT >= 0x0600)
#define CONSOLE_OVERSTRIKE 1
#endif
#define CONSOLE_FULLSCREEN_HARDWARE 2
// These codes should be given to SetConsoleDisplayMode
#define CONSOLE_FULLSCREEN_MODE 1
#define CONSOLE_WINDOWED_MODE 2
@@ -53,6 +56,12 @@ extern "C" {
#define COMMON_LVB_REVERSE_VIDEO 0x4000
#define COMMON_LVB_UNDERSCORE 0x8000
/*
* Screen buffer types
*/
#define CONSOLE_TEXTMODE_BUFFER 1
#define CONSOLE_GRAPHICS_BUFFER 2 /* Undocumented, see http://blog.airesoft.co.uk/2012/10/things-ms-can-do-that-they-dont-tell-you-about-console-graphics/ */
/*
* Control handler codes
*/
@@ -154,29 +163,35 @@ typedef struct _CHAR_INFO {
} Char;
WORD Attributes;
} CHAR_INFO,*PCHAR_INFO;
typedef struct _SMALL_RECT {
SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
} SMALL_RECT,*PSMALL_RECT;
typedef struct _CONSOLE_CURSOR_INFO {
DWORD dwSize;
BOOL bVisible;
} CONSOLE_CURSOR_INFO,*PCONSOLE_CURSOR_INFO;
typedef struct _COORD {
SHORT X;
SHORT Y;
} COORD, *PCOORD;
typedef struct _CONSOLE_SELECTION_INFO {
DWORD dwFlags;
COORD dwSelectionAnchor;
SMALL_RECT srSelection;
} CONSOLE_SELECTION_INFO, *PCONSOLE_SELECTION_INFO;
typedef struct _CONSOLE_FONT_INFO {
DWORD nFont;
COORD dwFontSize;
} CONSOLE_FONT_INFO, *PCONSOLE_FONT_INFO;
typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
COORD dwSize;
COORD dwCursorPosition;
@@ -184,7 +199,20 @@ typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
SMALL_RECT srWindow;
COORD dwMaximumWindowSize;
} CONSOLE_SCREEN_BUFFER_INFO,*PCONSOLE_SCREEN_BUFFER_INFO;
/* Undocumented, see http://blog.airesoft.co.uk/2012/10/things-ms-can-do-that-they-dont-tell-you-about-console-graphics/ */
#if defined(_WINGDI_) && !defined(NOGDI)
typedef struct _CONSOLE_GRAPHICS_BUFFER_INFO {
DWORD dwBitMapInfoLength;
LPBITMAPINFO lpBitMapInfo;
DWORD dwUsage; // DIB_PAL_COLORS or DIB_RGB_COLORS
HANDLE hMutex;
PVOID lpBitMap;
} CONSOLE_GRAPHICS_BUFFER_INFO, *PCONSOLE_GRAPHICS_BUFFER_INFO;
#endif
typedef BOOL(CALLBACK *PHANDLER_ROUTINE)(_In_ DWORD);
typedef struct _KEY_EVENT_RECORD {
BOOL bKeyDown;
WORD wRepeatCount;
@@ -198,18 +226,21 @@ typedef struct _KEY_EVENT_RECORD {
}
#ifdef __GNUC__
/* gcc's alignment is not what win32 expects */
PACKED
PACKED
#endif
KEY_EVENT_RECORD;
typedef struct _MOUSE_EVENT_RECORD {
COORD dwMousePosition;
DWORD dwButtonState;
DWORD dwControlKeyState;
DWORD dwEventFlags;
} MOUSE_EVENT_RECORD;
typedef struct _WINDOW_BUFFER_SIZE_RECORD { COORD dwSize; } WINDOW_BUFFER_SIZE_RECORD;
typedef struct _MENU_EVENT_RECORD { UINT dwCommandId; } MENU_EVENT_RECORD,*PMENU_EVENT_RECORD;
typedef struct _WINDOW_BUFFER_SIZE_RECORD { COORD dwSize; } WINDOW_BUFFER_SIZE_RECORD;
typedef struct _MENU_EVENT_RECORD { UINT dwCommandId; } MENU_EVENT_RECORD,*PMENU_EVENT_RECORD;
typedef struct _FOCUS_EVENT_RECORD { BOOL bSetFocus; } FOCUS_EVENT_RECORD;
typedef struct _INPUT_RECORD {
WORD EventType;
union {
@@ -322,6 +353,9 @@ BOOL WINAPI GetConsoleMode(HANDLE,PDWORD);
UINT WINAPI GetConsoleOutputCP(VOID);
BOOL WINAPI GetConsoleScreenBufferInfo(_In_ HANDLE, _Out_ PCONSOLE_SCREEN_BUFFER_INFO);
/* Undocumented, see http://blog.airesoft.co.uk/2012/10/things-ms-can-do-that-they-dont-tell-you-about-console-graphics/ */
BOOL WINAPI InvalidateConsoleDIBits(_In_ HANDLE, _In_ PSMALL_RECT);
DWORD
WINAPI
GetConsoleTitleA(
@@ -342,6 +376,7 @@ BOOL APIENTRY SetConsoleDisplayMode(_In_ HANDLE hConsoleOutput, _In_ DWORD dwFla
COORD WINAPI GetLargestConsoleWindowSize(_In_ HANDLE);
BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE,PDWORD);
BOOL WINAPI GetNumberOfConsoleMouseButtons(_Out_ PDWORD);
BOOL WINAPI PeekConsoleInputA(HANDLE,PINPUT_RECORD,DWORD,PDWORD);
BOOL
+16 -5
View File
@@ -60,7 +60,7 @@ typedef enum _CONSRV_API_NUMBER
ConsolepGetTitle,
ConsolepSetTitle,
ConsolepCreateScreenBuffer,
// ConsolepInvalidateBitMapRect,
ConsolepInvalidateBitMapRect,
// ConsolepVDMOperation,
// ConsolepSetCursor,
// ConsolepShowCursor,
@@ -236,8 +236,6 @@ typedef struct
DWORD ConsoleMode;
} CONSOLE_GETSETCONSOLEMODE, *PCONSOLE_GETSETCONSOLEMODE;
#define CONSOLE_WINDOWED 0 /* Internal console hardware state */
typedef struct
{
// HANDLE OutputHandle;
@@ -266,11 +264,17 @@ typedef struct
typedef struct
{
HANDLE OutputHandle; /* Handle to newly created screen buffer */
HANDLE OutputHandle; /* Handle to newly created screen buffer */
DWORD ScreenBufferType; /* Type of the screen buffer: CONSOLE_TEXTMODE_BUFFER or CONSOLE_GRAPHICS_BUFFER */
/*
* If we are creating a graphics screen buffer,
* this structure holds the initialization information.
*/
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo;
DWORD Access;
DWORD ShareMode;
BOOL Inheritable;
BOOL Inheritable;
} CONSOLE_CREATESCREENBUFFER, *PCONSOLE_CREATESCREENBUFFER;
typedef struct
@@ -278,6 +282,12 @@ typedef struct
HANDLE OutputHandle; /* Handle to screen buffer to switch to */
} CONSOLE_SETACTIVESCREENBUFFER, *PCONSOLE_SETACTIVESCREENBUFFER;
typedef struct
{
HANDLE OutputHandle;
SMALL_RECT Region;
} CONSOLE_INVALIDATEDIBITS, *PCONSOLE_INVALIDATEDIBITS;
typedef struct
{
DWORD Length;
@@ -624,6 +634,7 @@ typedef struct _CONSOLE_API_MESSAGE
CONSOLE_GETSETHWSTATE HardwareStateRequest;
/* Console window */
CONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest;
CONSOLE_GETSETCONSOLETITLE TitleRequest;
CONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest;
CONSOLE_SETWINDOWINFO SetWindowInfoRequest;