ReactOS  0.4.13-dev-464-g6b95727
guiterm.c File Reference
#include "consrv.h"
#include "include/conio.h"
#include "include/console.h"
#include "include/settings.h"
#include "conoutput.h"
#include "guiterm.h"
#include "guisettings.h"
#include "resource.h"
#include <windowsx.h>
#include <shlwapi.h>
#include <shlobj.h>
#include <debug.h>
Include dependency graph for guiterm.c:

Go to the source code of this file.

Classes

struct  _GUI_INIT_INFO
 
struct  _GUICONSOLE_MENUITEM
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define NDEBUG
 
#define GUI_CONSOLE_WINDOW_CLASS   L"ConsoleWindowClass"
 
#define PM_CREATE_CONSOLE   (WM_APP + 1)
 
#define PM_DESTROY_CONSOLE   (WM_APP + 2)
 
#define PM_RESIZE_TERMINAL   (WM_APP + 3)
 
#define PM_CONSOLE_BEEP   (WM_APP + 4)
 
#define PM_CONSOLE_SET_TITLE   (WM_APP + 5)
 
#define GWLP_CONSOLEWND_ALLOC   (2 * sizeof(LONG_PTR))
 
#define GWLP_CONSOLE_LEADER_PID   0
 
#define GWLP_CONSOLE_LEADER_TID   4
 
#define SetConsoleWndConsoleLeaderCID(GuiData)
 
#define PATH_SEPARATOR   L'\\'
 

Typedefs

typedef struct _GUI_INIT_INFO GUI_INIT_INFO
 
typedef struct _GUI_INIT_INFOPGUI_INIT_INFO
 
typedef struct _GUICONSOLE_MENUITEM GUICONSOLE_MENUITEM
 
typedef struct _GUICONSOLE_MENUITEMPGUICONSOLE_MENUITEM
 

Functions

VOID WINAPI PrivateCsrssManualGuiCheck (LONG Check)
 
static VOID GetScreenBufferSizeUnits (IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
 
static VOID GuiConsoleAppendMenuItems (HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
 
static VOID GuiConsoleCreateSysMenu (HWND hWnd)
 
static VOID GuiSendMenuEvent (PCONSOLE Console, UINT CmdId)
 
static VOID GuiConsoleCopy (PGUI_CONSOLE_DATA GuiData)
 
static VOID GuiConsolePaste (PGUI_CONSOLE_DATA GuiData)
 
static VOID GuiConsoleUpdateSelection (PCONSOLE Console, PCOORD coord)
 
static VOID WINAPI GuiDrawRegion (IN OUT PFRONTEND This, SMALL_RECT *Region)
 
static VOID GuiConsoleResizeWindow (PGUI_CONSOLE_DATA GuiData)
 
static LRESULT GuiConsoleHandleSysMenuCommand (PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
 
static PGUI_CONSOLE_DATA GuiGetGuiData (HWND hWnd)
 
VOID GuiConsoleMoveWindow (PGUI_CONSOLE_DATA GuiData)
 
static VOID GuiConsoleSwitchFullScreen (PGUI_CONSOLE_DATA GuiData)
 
static BOOL GuiConsoleHandleNcCreate (HWND hWnd, LPCREATESTRUCTW Create)
 
static VOID SmallRectToRect (PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
 
VOID GuiPaintTextModeBuffer (PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, HDC hDC, PRECT rc)
 
VOID GuiPaintGraphicsBuffer (PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, HDC hDC, PRECT rc)
 
static VOID GuiConsoleHandlePaint (PGUI_CONSOLE_DATA GuiData)
 
static BOOL IsSystemKey (WORD VirtualKeyCode)
 
static VOID GuiConsoleHandleKey (PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
 
static VOID GuiInvalidateCell (IN OUT PFRONTEND This, SHORT x, SHORT y)
 
static VOID GuiConsoleHandleTimer (PGUI_CONSOLE_DATA GuiData)
 
static BOOL GuiConsoleHandleClose (PGUI_CONSOLE_DATA GuiData)
 
static LRESULT GuiConsoleHandleNcDestroy (HWND hWnd)
 
static COORD PointToCoord (PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
 
static LRESULT GuiConsoleHandleMouse (PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
 
VOID GuiCopyFromTextModeBuffer (PTEXTMODE_SCREEN_BUFFER Buffer)
 
VOID GuiCopyFromGraphicsBuffer (PGRAPHICS_SCREEN_BUFFER Buffer)
 
VOID GuiPasteToTextModeBuffer (PTEXTMODE_SCREEN_BUFFER Buffer)
 
VOID GuiPasteToGraphicsBuffer (PGRAPHICS_SCREEN_BUFFER Buffer)
 
static VOID GuiConsoleGetMinMaxInfo (PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
 
static VOID GuiConsoleResize (PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
 
static LRESULT GuiConsoleHandleScroll (PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
 
static LRESULT CALLBACK GuiConsoleWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK GuiConsoleNotifyWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static DWORD WINAPI GuiConsoleGuiThread (PVOID Data)
 
static BOOL GuiInit (VOID)
 
static VOID WINAPI GuiDeinitFrontEnd (IN OUT PFRONTEND This)
 
NTSTATUS NTAPI GuiInitFrontEnd (IN OUT PFRONTEND This, IN PCONSOLE Console)
 
static VOID WINAPI GuiWriteStream (IN OUT PFRONTEND This, SMALL_RECT *Region, SHORT CursorStartX, SHORT CursorStartY, UINT ScrolledLines, PWCHAR Buffer, UINT Length)
 
static BOOL WINAPI GuiSetCursorInfo (IN OUT PFRONTEND This, PCONSOLE_SCREEN_BUFFER Buff)
 
static BOOL WINAPI GuiSetScreenInfo (IN OUT PFRONTEND This, PCONSOLE_SCREEN_BUFFER Buff, SHORT OldCursorX, SHORT OldCursorY)
 
static VOID WINAPI GuiResizeTerminal (IN OUT PFRONTEND This)
 
static BOOL WINAPI GuiProcessKeyCallback (IN OUT PFRONTEND This, MSG *msg, BYTE KeyStateMenu, DWORD ShiftState, UINT VirtualKeyCode, BOOL Down)
 
static BOOL WINAPI GuiSetMouseCursor (IN OUT PFRONTEND This, HCURSOR hCursor)
 
static VOID WINAPI GuiRefreshInternalInfo (IN OUT PFRONTEND This)
 
static VOID WINAPI GuiChangeTitle (IN OUT PFRONTEND This)
 
static BOOL WINAPI GuiChangeIcon (IN OUT PFRONTEND This, HICON hWindowIcon)
 
static HWND WINAPI GuiGetConsoleWindowHandle (IN OUT PFRONTEND This)
 
static VOID WINAPI GuiGetLargestConsoleWindowSize (IN OUT PFRONTEND This, PCOORD pSize)
 
static ULONG WINAPI GuiGetDisplayMode (IN OUT PFRONTEND This)
 
static BOOL WINAPI GuiSetDisplayMode (IN OUT PFRONTEND This, ULONG NewMode)
 
static INT WINAPI GuiShowMouseCursor (IN OUT PFRONTEND This, BOOL Show)
 
static HMENU WINAPI GuiMenuControl (IN OUT PFRONTEND This, UINT cmdIdLow, UINT cmdIdHigh)
 
static BOOL WINAPI GuiSetMenuClose (IN OUT PFRONTEND This, BOOL Enable)
 
static BOOL LoadShellLinkConsoleInfo (IN OUT PCONSOLE_START_INFO ConsoleStartInfo, IN OUT PCONSOLE_INFO ConsoleInfo)
 
NTSTATUS NTAPI GuiLoadFrontEnd (IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_INFO ConsoleInfo, IN OUT PVOID ExtraConsoleInfo, IN ULONG ProcessId)
 
NTSTATUS NTAPI GuiUnloadFrontEnd (IN OUT PFRONTEND FrontEnd)
 

Variables

static BOOL ConsInitialized = FALSE
 
static HICON ghDefaultIcon = NULL
 
static HICON ghDefaultIconSm = NULL
 
static HCURSOR ghDefaultCursor = NULL
 
static HWND NotifyWnd = NULL
 
static const GUICONSOLE_MENUITEM GuiConsoleEditMenuItems []
 
static const GUICONSOLE_MENUITEM GuiConsoleMainMenuItems []
 
const COLORREF s_Colors [16]
 
static FRONTEND_VTBL GuiVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 14 of file guiterm.c.

◆ GUI_CONSOLE_WINDOW_CLASS

#define GUI_CONSOLE_WINDOW_CLASS   L"ConsoleWindowClass"

Definition at line 35 of file guiterm.c.

◆ GWLP_CONSOLE_LEADER_PID

#define GWLP_CONSOLE_LEADER_PID   0

Definition at line 64 of file guiterm.c.

◆ GWLP_CONSOLE_LEADER_TID

#define GWLP_CONSOLE_LEADER_TID   4

Definition at line 65 of file guiterm.c.

◆ GWLP_CONSOLEWND_ALLOC

#define GWLP_CONSOLEWND_ALLOC   (2 * sizeof(LONG_PTR))

Definition at line 63 of file guiterm.c.

◆ NDEBUG

#define NDEBUG

Definition at line 31 of file guiterm.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 15 of file guiterm.c.

◆ PATH_SEPARATOR

#define PATH_SEPARATOR   L'\\'

◆ PM_CONSOLE_BEEP

#define PM_CONSOLE_BEEP   (WM_APP + 4)

Definition at line 43 of file guiterm.c.

◆ PM_CONSOLE_SET_TITLE

#define PM_CONSOLE_SET_TITLE   (WM_APP + 5)

Definition at line 44 of file guiterm.c.

◆ PM_CREATE_CONSOLE

#define PM_CREATE_CONSOLE   (WM_APP + 1)

Definition at line 40 of file guiterm.c.

◆ PM_DESTROY_CONSOLE

#define PM_DESTROY_CONSOLE   (WM_APP + 2)

Definition at line 41 of file guiterm.c.

◆ PM_RESIZE_TERMINAL

#define PM_RESIZE_TERMINAL   (WM_APP + 3)

Definition at line 42 of file guiterm.c.

◆ SetConsoleWndConsoleLeaderCID

#define SetConsoleWndConsoleLeaderCID (   GuiData)
Value:
do { \
PCONSOLE_PROCESS_DATA ProcessData; \
CLIENT_ID ConsoleLeaderCID; \
ProcessData = CONTAINING_RECORD((GuiData)->Console->ProcessList.Blink, \
ConsoleLink); \
ConsoleLeaderCID = ProcessData->Process->ClientId; \
SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_PID, (LONG_PTR)(ConsoleLeaderCID.UniqueProcess)); \
SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_TID, (LONG_PTR)(ConsoleLeaderCID.UniqueThread )); \
} while (0)
#define GWLP_CONSOLE_LEADER_TID
Definition: guiterm.c:65
#define GWLP_CONSOLE_LEADER_PID
Definition: guiterm.c:64
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
CConsole Console

Definition at line 67 of file guiterm.c.

Typedef Documentation

◆ GUI_INIT_INFO

◆ GUICONSOLE_MENUITEM

◆ PGUI_INIT_INFO

◆ PGUICONSOLE_MENUITEM

Function Documentation

◆ GetScreenBufferSizeUnits()

static VOID GetScreenBufferSizeUnits ( IN PCONSOLE_SCREEN_BUFFER  Buffer,
IN PGUI_CONSOLE_DATA  GuiData,
OUT PUINT  WidthUnit,
OUT PUINT  HeightUnit 
)
static

Definition at line 142 of file guiterm.c.

146 {
147  if (Buffer == NULL || GuiData == NULL ||
148  WidthUnit == NULL || HeightUnit == NULL)
149  {
150  return;
151  }
152 
154  {
155  *WidthUnit = GuiData->CharWidth ;
156  *HeightUnit = GuiData->CharHeight;
157  }
158  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
159  {
160  *WidthUnit = 1;
161  *HeightUnit = 1;
162  }
163 }
#define TEXTMODE_BUFFER
Definition: pccons.c:21
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129

Referenced by GuiConsoleGetMinMaxInfo(), GuiConsoleHandleScroll(), GuiConsoleResize(), GuiConsoleResizeWindow(), GuiGetLargestConsoleWindowSize(), PointToCoord(), and SmallRectToRect().

◆ GuiChangeIcon()

static BOOL WINAPI GuiChangeIcon ( IN OUT PFRONTEND  This,
HICON  hWindowIcon 
)
static

Definition at line 2582 of file guiterm.c.

2584 {
2585  PGUI_CONSOLE_DATA GuiData = This->Data;
2586  HICON hIcon, hIconSm;
2587 
2588  if (hWindowIcon == NULL)
2589  {
2590  hIcon = ghDefaultIcon;
2592  }
2593  else
2594  {
2595  hIcon = CopyIcon(hWindowIcon);
2596  hIconSm = CopyIcon(hWindowIcon);
2597  }
2598 
2599  if (hIcon == NULL)
2600  {
2601  return FALSE;
2602  }
2603 
2604  if (hIcon != GuiData->hIcon)
2605  {
2606  if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon)
2607  {
2608  DestroyIcon(GuiData->hIcon);
2609  }
2610  if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm)
2611  {
2612  DestroyIcon(GuiData->hIconSm);
2613  }
2614 
2615  GuiData->hIcon = hIcon;
2616  GuiData->hIconSm = hIconSm;
2617 
2618  DPRINT("Set icons in GuiChangeIcon\n");
2619  PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG, (LPARAM)GuiData->hIcon);
2620  PostMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
2621  }
2622 
2623  return TRUE;
2624 }
HICON ghDefaultIcon
Definition: conwnd.c:62
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
HICON ghDefaultIconSm
Definition: conwnd.c:63
#define ICON_SMALL
Definition: tnclass.cpp:48
HICON hIconSm
Definition: conwnd.h:67
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
HICON WINAPI CopyIcon(_In_ HICON)
Definition: cursoricon.c:1980
HICON hIcon
Definition: msconfig.c:44
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HICON hIconSm
Definition: msconfig.c:44
#define ICON_BIG
Definition: tnclass.cpp:51

◆ GuiChangeTitle()

static VOID WINAPI GuiChangeTitle ( IN OUT PFRONTEND  This)
static

Definition at line 2574 of file guiterm.c.

2575 {
2576  PGUI_CONSOLE_DATA GuiData = This->Data;
2577  // PostMessageW(GuiData->hWindow, PM_CONSOLE_SET_TITLE, 0, 0);
2578  SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer);
2579 }
#define SetWindowText
Definition: winuser.h:5723
PCONSRV_CONSOLE Console
Definition: conwnd.h:90

◆ GuiConsoleAppendMenuItems()

static VOID GuiConsoleAppendMenuItems ( HMENU  hMenu,
const GUICONSOLE_MENUITEM Items 
)
static

Definition at line 168 of file guiterm.c.

170 {
171  UINT i = 0;
172  WCHAR szMenuString[255];
173  HMENU hSubMenu;
174 
175  do
176  {
177  if (Items[i].uID != (UINT)-1)
178  {
180  Items[i].uID,
181  szMenuString,
182  sizeof(szMenuString) / sizeof(szMenuString[0])) > 0)
183  {
184  if (Items[i].SubMenu != NULL)
185  {
186  hSubMenu = CreatePopupMenu();
187  if (hSubMenu != NULL)
188  {
189  GuiConsoleAppendMenuItems(hSubMenu,
190  Items[i].SubMenu);
191 
192  if (!AppendMenuW(hMenu,
194  (UINT_PTR)hSubMenu,
195  szMenuString))
196  {
197  DestroyMenu(hSubMenu);
198  }
199  }
200  }
201  else
202  {
203  AppendMenuW(hMenu,
204  MF_STRING,
205  Items[i].wCmdID,
206  szMenuString);
207  }
208  }
209  }
210  else
211  {
212  AppendMenuW(hMenu,
213  MF_SEPARATOR,
214  0,
215  NULL);
216  }
217  i++;
218  } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].wCmdID == 0));
219 }
static VOID GuiConsoleAppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: guiterm.c:168
#define MF_STRING
Definition: winuser.h:138
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define MF_SEPARATOR
Definition: winuser.h:137
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define MF_POPUP
Definition: winuser.h:136
BOOL WINAPI DestroyMenu(_In_ HMENU)
unsigned int UINT
Definition: ndis.h:50
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
HINSTANCE ConSrvDllInstance
Definition: init.c:21
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by GuiConsoleCreateSysMenu(), and GuiConsoleWndProc().

◆ GuiConsoleCopy()

static VOID GuiConsoleCopy ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1337 of file guiterm.c.

1338 {
1339  if (OpenClipboard(GuiData->hWindow))
1340  {
1341  PCONSOLE Console = GuiData->Console;
1343 
1344  if (GetType(Buffer) == TEXTMODE_BUFFER)
1345  {
1347  }
1348  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
1349  {
1351  }
1352 
1353  CloseClipboard();
1354 
1355  /* Clear the selection */
1357  SetWindowText(GuiData->hWindow, Console->Title.Buffer);
1358  }
1359 }
VOID GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer)
Definition: graphics.c:23
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
#define TEXTMODE_BUFFER
Definition: pccons.c:21
VOID GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer)
Definition: text.c:26
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
static VOID GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
Definition: guiterm.c:600
#define SetWindowText
Definition: winuser.h:5723
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
BOOL WINAPI OpenClipboard(_In_opt_ HWND)

Referenced by GuiConsoleHandleKey(), GuiConsoleHandleMouse(), and GuiConsoleHandleSysMenuCommand().

◆ GuiConsoleCreateSysMenu()

static VOID GuiConsoleCreateSysMenu ( HWND  hWnd)
static

Definition at line 222 of file guiterm.c.

223 {
224  HMENU hMenu = GetSystemMenu(hWnd, FALSE);
225  if (hMenu != NULL)
226  {
228  DrawMenuBar(hWnd);
229  }
230 }
BOOL WINAPI DrawMenuBar(_In_ HWND)
static VOID GuiConsoleAppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: guiterm.c:168
HWND hWnd
Definition: settings.c:17
static const GUICONSOLE_MENUITEM GuiConsoleMainMenuItems[]
Definition: guiterm.c:105
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by GuiConsoleHandleNcCreate().

◆ GuiConsoleGetMinMaxInfo()

static VOID GuiConsoleGetMinMaxInfo ( PGUI_CONSOLE_DATA  GuiData,
PMINMAXINFO  minMaxInfo 
)
static

Definition at line 1386 of file guiterm.c.

1387 {
1388  PCONSOLE Console = GuiData->Console;
1389  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
1390  DWORD windx, windy;
1391  UINT WidthUnit, HeightUnit;
1392 
1394 
1395  ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
1396 
1397  GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
1398 
1399  windx = CONGUI_MIN_WIDTH * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
1401 
1402  minMaxInfo->ptMinTrackSize.x = windx;
1403  minMaxInfo->ptMinTrackSize.y = windy;
1404 
1405  windx = (ActiveBuffer->ScreenBufferSize.X) * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
1406  windy = (ActiveBuffer->ScreenBufferSize.Y) * HeightUnit + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION);
1407 
1408  if (ActiveBuffer->ViewSize.X < ActiveBuffer->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // window currently has a horizontal scrollbar
1409  if (ActiveBuffer->ViewSize.Y < ActiveBuffer->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // window currently has a vertical scrollbar
1410 
1411  minMaxInfo->ptMaxTrackSize.x = windx;
1412  minMaxInfo->ptMaxTrackSize.y = windy;
1413 
1414  LeaveCriticalSection(&Console->Lock);
1415 }
POINT ptMinTrackSize
Definition: winuser.h:3572
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
#define CONGUI_MIN_HEIGHT
Definition: conwnd.c:34
long x
Definition: polytest.cpp:48
#define SM_CXEDGE
Definition: winuser.h:998
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
COORD ScreenBufferSize
Definition: conio.h:87
#define SM_CYEDGE
Definition: winuser.h:999
ULONG X
Definition: bl.h:1340
#define SM_CYCAPTION
Definition: winuser.h:953
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
unsigned int UINT
Definition: ndis.h:50
#define SM_CXVSCROLL
Definition: winuser.h:951
CConsole Console
static VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.c:142
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
POINT ptMaxTrackSize
Definition: winuser.h:3573
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define CONGUI_MIN_WIDTH
Definition: conwnd.c:33
ULONG Y
Definition: bl.h:1341

Referenced by GuiConsoleWndProc().

◆ GuiConsoleGuiThread()

static DWORD WINAPI GuiConsoleGuiThread ( PVOID  Data)
static

Definition at line 2038 of file guiterm.c.

2039 {
2040  MSG msg;
2041  PHANDLE GraphicsStartupEvent = (PHANDLE)Data;
2042 
2043  /*
2044  * This thread dispatches all the console notifications to the notify window.
2045  * It is common for all the console windows.
2046  */
2047 
2049 
2050  NotifyWnd = CreateWindowW(L"ConSrvCreateNotify",
2051  L"",
2053  CW_USEDEFAULT,
2054  CW_USEDEFAULT,
2055  CW_USEDEFAULT,
2056  CW_USEDEFAULT,
2057  NULL,
2058  NULL,
2060  NULL);
2061  if (NULL == NotifyWnd)
2062  {
2064  SetEvent(*GraphicsStartupEvent);
2065  return 1;
2066  }
2067 
2068  SetEvent(*GraphicsStartupEvent);
2069 
2070  while (GetMessageW(&msg, NULL, 0, 0))
2071  {
2074  }
2075 
2076  DPRINT("CONSRV: Quit the Gui Thread!!\n");
2078 
2079  return 1;
2080 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4185
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HINSTANCE ConSrvDllInstance
Definition: init.c:21
#define msg(x)
Definition: auth_time.c:54
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
VOID WINAPI PrivateCsrssManualGuiCheck(LONG Check)
static HWND NotifyWnd
Definition: guiterm.c:84

Referenced by GuiInit().

◆ GuiConsoleHandleClose()

static BOOL GuiConsoleHandleClose ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1027 of file guiterm.c.

1028 {
1029  PCONSOLE Console = GuiData->Console;
1030 
1032  return TRUE;
1033 
1034  // TODO: Prompt for termination ? (Warn the user about possible apps running in this console)
1035 
1036  /*
1037  * FIXME: Windows will wait up to 5 seconds for the thread to exit.
1038  * We shouldn't wait here, though, since the console lock is entered.
1039  * A copy of the thread list probably needs to be made.
1040  */
1042 
1043  LeaveCriticalSection(&Console->Lock);
1044  return FALSE;
1045 }
NTSTATUS NTAPI ConDrvConsoleProcessCtrlEvent(IN PCONSOLE Console, IN ULONG ProcessGroupId, IN ULONG Event)
Definition: console.c:1069
#define TRUE
Definition: types.h:120
#define CTRL_CLOSE_EVENT
Definition: wincon.h:67
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by GuiConsoleWndProc().

◆ GuiConsoleHandleKey()

static VOID GuiConsoleHandleKey ( PGUI_CONSOLE_DATA  GuiData,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 760 of file guiterm.c.

761 {
762  PCONSOLE Console = GuiData->Console;
763  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
764 
766 
767  ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
768 
769  if (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS)
770  {
771  WORD VirtualKeyCode = LOWORD(wParam);
772 
773  if (msg != WM_KEYDOWN) goto Quit;
774 
775  if (VirtualKeyCode == VK_RETURN)
776  {
777  /* Copy (and clear) selection if ENTER is pressed */
778  GuiConsoleCopy(GuiData);
779  goto Quit;
780  }
781  else if ( VirtualKeyCode == VK_ESCAPE ||
782  (VirtualKeyCode == 'C' && GetKeyState(VK_CONTROL) & 0x8000) )
783  {
784  /* Cancel selection if ESC or Ctrl-C are pressed */
786  SetWindowText(GuiData->hWindow, Console->Title.Buffer);
787 
788  goto Quit;
789  }
790 
791  if ((Console->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0)
792  {
793  /* Keyboard selection mode */
794  BOOL Interpreted = FALSE;
795  BOOL MajPressed = (GetKeyState(VK_SHIFT) & 0x8000);
796 
797  switch (VirtualKeyCode)
798  {
799  case VK_LEFT:
800  {
801  Interpreted = TRUE;
802  if (Console->dwSelectionCursor.X > 0)
803  Console->dwSelectionCursor.X--;
804 
805  break;
806  }
807 
808  case VK_RIGHT:
809  {
810  Interpreted = TRUE;
811  if (Console->dwSelectionCursor.X < ActiveBuffer->ScreenBufferSize.X - 1)
812  Console->dwSelectionCursor.X++;
813 
814  break;
815  }
816 
817  case VK_UP:
818  {
819  Interpreted = TRUE;
820  if (Console->dwSelectionCursor.Y > 0)
821  Console->dwSelectionCursor.Y--;
822 
823  break;
824  }
825 
826  case VK_DOWN:
827  {
828  Interpreted = TRUE;
829  if (Console->dwSelectionCursor.Y < ActiveBuffer->ScreenBufferSize.Y - 1)
830  Console->dwSelectionCursor.Y++;
831 
832  break;
833  }
834 
835  case VK_HOME:
836  {
837  Interpreted = TRUE;
838  Console->dwSelectionCursor.X = 0;
839  Console->dwSelectionCursor.Y = 0;
840  break;
841  }
842 
843  case VK_END:
844  {
845  Interpreted = TRUE;
846  Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
847  break;
848  }
849 
850  case VK_PRIOR:
851  {
852  Interpreted = TRUE;
853  Console->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y;
854  if (Console->dwSelectionCursor.Y < 0)
855  Console->dwSelectionCursor.Y = 0;
856 
857  break;
858  }
859 
860  case VK_NEXT:
861  {
862  Interpreted = TRUE;
863  Console->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y;
864  if (Console->dwSelectionCursor.Y >= ActiveBuffer->ScreenBufferSize.Y)
865  Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
866 
867  break;
868  }
869 
870  default:
871  break;
872  }
873 
874  if (Interpreted)
875  {
876  if (!MajPressed)
877  Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
878 
879  GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
880  }
881  else if (!IsSystemKey(VirtualKeyCode))
882  {
883  /* Emit an error beep sound */
884  SendNotifyMessage(GuiData->hWindow, PM_CONSOLE_BEEP, 0, 0);
885  }
886 
887  goto Quit;
888  }
889  else
890  {
891  /* Mouse selection mode */
892 
893  if (!IsSystemKey(VirtualKeyCode))
894  {
895  /* Clear the selection and send the key into the input buffer */
897  SetWindowText(GuiData->hWindow, Console->Title.Buffer);
898  }
899  else
900  {
901  goto Quit;
902  }
903  }
904  }
905 
906  if ((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
907  {
908  MSG Message;
909 
910  Message.hwnd = GuiData->hWindow;
911  Message.message = msg;
912  Message.wParam = wParam;
913  Message.lParam = lParam;
914 
916  }
917 
918 Quit:
920 }
#define TRUE
Definition: types.h:120
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define VK_LEFT
Definition: winuser.h:2178
#define VK_DOWN
Definition: winuser.h:2181
#define VK_PRIOR
Definition: winuser.h:2174
#define VK_ESCAPE
Definition: winuser.h:2168
#define VK_RETURN
Definition: winuser.h:2155
WPARAM wParam
Definition: combotst.c:138
#define VK_NEXT
Definition: winuser.h:2175
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:99
#define VK_HOME
Definition: winuser.h:2177
#define VK_UP
Definition: winuser.h:2179
COORD ScreenBufferSize
Definition: conio.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
#define VK_SHIFT
Definition: winuser.h:2156
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
SHORT WINAPI GetKeyState(_In_ int)
ULONG X
Definition: bl.h:1340
unsigned short WORD
Definition: ntddk_ex.h:93
#define PM_CONSOLE_BEEP
Definition: guiterm.c:43
CHAR Message[80]
Definition: alive.c:5
static BOOL IsSystemKey(WORD VirtualKeyCode)
Definition: guiterm.c:737
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
static VOID GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
Definition: guiterm.c:600
#define VK_RIGHT
Definition: winuser.h:2180
VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG *msg)
Definition: input.c:57
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
#define SetWindowText
Definition: winuser.h:5723
#define VK_CONTROL
Definition: winuser.h:2157
CConsole Console
#define msg(x)
Definition: auth_time.c:54
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
static VOID GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1337
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1341
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define VK_END
Definition: winuser.h:2176
#define SendNotifyMessage
Definition: winuser.h:5712

Referenced by GuiConsoleWndProc().

◆ GuiConsoleHandleMouse()

static LRESULT GuiConsoleHandleMouse ( PGUI_CONSOLE_DATA  GuiData,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1087 of file guiterm.c.

1088 {
1089  BOOL Err = FALSE;
1090  PCONSOLE Console = GuiData->Console;
1091 
1092  if (GuiData->IgnoreNextMouseSignal)
1093  {
1094  if (msg != WM_LBUTTONDOWN &&
1095  msg != WM_MBUTTONDOWN &&
1096  msg != WM_RBUTTONDOWN)
1097  {
1098  /*
1099  * If this mouse signal is not a button-down action,
1100  * then it is the last signal being ignored.
1101  */
1102  GuiData->IgnoreNextMouseSignal = FALSE;
1103  }
1104  else
1105  {
1106  /*
1107  * This mouse signal is a button-down action.
1108  * Ignore it and perform default action.
1109  */
1110  Err = TRUE;
1111  }
1112  goto Quit;
1113  }
1114 
1116  {
1117  Err = TRUE;
1118  goto Quit;
1119  }
1120 
1121  if ( (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) ||
1122  (Console->QuickEdit) )
1123  {
1124  switch (msg)
1125  {
1126  case WM_LBUTTONDOWN:
1127  {
1128  LPWSTR WindowTitle = NULL;
1129  SIZE_T Length = 0;
1130 
1131  Console->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam);
1132  SetCapture(GuiData->hWindow);
1134  GuiConsoleUpdateSelection(Console, &Console->Selection.dwSelectionAnchor);
1135 
1136  Length = Console->Title.Length + sizeof(L"Selection - ")/sizeof(WCHAR) + 1;
1137  WindowTitle = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
1138  wcscpy(WindowTitle, L"Selection - ");
1139  wcscat(WindowTitle, Console->Title.Buffer);
1140  SetWindowText(GuiData->hWindow, WindowTitle);
1141  ConsoleFreeHeap(WindowTitle);
1142 
1143  break;
1144  }
1145 
1146  case WM_LBUTTONUP:
1147  {
1148  COORD c;
1149 
1150  if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1151 
1152  c = PointToCoord(GuiData, lParam);
1153  Console->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
1155  ReleaseCapture();
1156 
1157  break;
1158  }
1159 
1160  case WM_LBUTTONDBLCLK:
1161  {
1162  DPRINT1("Handle left-double-click for selecting a word\n");
1163  break;
1164  }
1165 
1166  case WM_RBUTTONDOWN:
1167  case WM_RBUTTONDBLCLK:
1168  {
1169  if (!(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
1170  {
1171  GuiConsolePaste(GuiData);
1172  }
1173  else
1174  {
1175  GuiConsoleCopy(GuiData);
1176  }
1177 
1178  GuiData->IgnoreNextMouseSignal = TRUE;
1179  break;
1180  }
1181 
1182  case WM_MOUSEMOVE:
1183  {
1184  COORD c;
1185 
1186  if (!(wParam & MK_LBUTTON)) break;
1187  if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1188 
1189  c = PointToCoord(GuiData, lParam); /* TODO: Scroll buffer to bring c into view */
1191 
1192  break;
1193  }
1194 
1195  default:
1196  Err = FALSE; // TRUE;
1197  break;
1198  }
1199  }
1200  else if (Console->InputBuffer.Mode & ENABLE_MOUSE_INPUT)
1201  {
1202  INPUT_RECORD er;
1203  WORD wKeyState = GET_KEYSTATE_WPARAM(wParam);
1204  DWORD dwButtonState = 0;
1205  DWORD dwControlKeyState = 0;
1206  DWORD dwEventFlags = 0;
1207 
1208  switch (msg)
1209  {
1210  case WM_LBUTTONDOWN:
1211  SetCapture(GuiData->hWindow);
1212  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1213  dwEventFlags = 0;
1214  break;
1215 
1216  case WM_MBUTTONDOWN:
1217  SetCapture(GuiData->hWindow);
1218  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1219  dwEventFlags = 0;
1220  break;
1221 
1222  case WM_RBUTTONDOWN:
1223  SetCapture(GuiData->hWindow);
1224  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1225  dwEventFlags = 0;
1226  break;
1227 
1228  case WM_LBUTTONUP:
1229  ReleaseCapture();
1230  dwButtonState = 0;
1231  dwEventFlags = 0;
1232  break;
1233 
1234  case WM_MBUTTONUP:
1235  ReleaseCapture();
1236  dwButtonState = 0;
1237  dwEventFlags = 0;
1238  break;
1239 
1240  case WM_RBUTTONUP:
1241  ReleaseCapture();
1242  dwButtonState = 0;
1243  dwEventFlags = 0;
1244  break;
1245 
1246  case WM_LBUTTONDBLCLK:
1247  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1248  dwEventFlags = DOUBLE_CLICK;
1249  break;
1250 
1251  case WM_MBUTTONDBLCLK:
1252  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1253  dwEventFlags = DOUBLE_CLICK;
1254  break;
1255 
1256  case WM_RBUTTONDBLCLK:
1257  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1258  dwEventFlags = DOUBLE_CLICK;
1259  break;
1260 
1261  case WM_MOUSEMOVE:
1262  dwButtonState = 0;
1263  dwEventFlags = MOUSE_MOVED;
1264  break;
1265 
1266  case WM_MOUSEWHEEL:
1267  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1268  dwEventFlags = MOUSE_WHEELED;
1269  break;
1270 
1271  case WM_MOUSEHWHEEL:
1272  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1273  dwEventFlags = MOUSE_HWHEELED;
1274  break;
1275 
1276  default:
1277  Err = TRUE;
1278  break;
1279  }
1280 
1281  if (!Err)
1282  {
1283  if (wKeyState & MK_LBUTTON)
1284  dwButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
1285  if (wKeyState & MK_MBUTTON)
1286  dwButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
1287  if (wKeyState & MK_RBUTTON)
1288  dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
1289 
1290  if (GetKeyState(VK_RMENU) & 0x8000)
1291  dwControlKeyState |= RIGHT_ALT_PRESSED;
1292  if (GetKeyState(VK_LMENU) & 0x8000)
1293  dwControlKeyState |= LEFT_ALT_PRESSED;
1294  if (GetKeyState(VK_RCONTROL) & 0x8000)
1295  dwControlKeyState |= RIGHT_CTRL_PRESSED;
1296  if (GetKeyState(VK_LCONTROL) & 0x8000)
1297  dwControlKeyState |= LEFT_CTRL_PRESSED;
1298  if (GetKeyState(VK_SHIFT) & 0x8000)
1299  dwControlKeyState |= SHIFT_PRESSED;
1300  if (GetKeyState(VK_NUMLOCK) & 0x0001)
1301  dwControlKeyState |= NUMLOCK_ON;
1302  if (GetKeyState(VK_SCROLL) & 0x0001)
1303  dwControlKeyState |= SCROLLLOCK_ON;
1304  if (GetKeyState(VK_CAPITAL) & 0x0001)
1305  dwControlKeyState |= CAPSLOCK_ON;
1306  /* See WM_CHAR MSDN documentation for instance */
1307  if (lParam & 0x01000000)
1308  dwControlKeyState |= ENHANCED_KEY;
1309 
1310  er.EventType = MOUSE_EVENT;
1312  er.Event.MouseEvent.dwButtonState = dwButtonState;
1313  er.Event.MouseEvent.dwControlKeyState = dwControlKeyState;
1314  er.Event.MouseEvent.dwEventFlags = dwEventFlags;
1315 
1317  }
1318  }
1319  else
1320  {
1321  Err = TRUE;
1322  }
1323 
1324  LeaveCriticalSection(&Console->Lock);
1325 
1326 Quit:
1327  if (Err)
1328  return DefWindowProcW(GuiData->hWindow, msg, wParam, lParam);
1329  else
1330  return 0;
1331 }
#define WM_MBUTTONUP
Definition: winuser.h:1759
#define FROM_LEFT_1ST_BUTTON_PRESSED
Definition: wincon.h:144
#define SCROLLLOCK_ON
Definition: wincon.h:137
#define TRUE
Definition: types.h:120
DWORD dwEventFlags
Definition: wincon.h:245
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
#define MK_LBUTTON
Definition: winuser.h:2321
static COORD PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
Definition: guiterm.c:1060
#define RIGHTMOST_BUTTON_PRESSED
Definition: wincon.h:145
#define VK_RMENU
Definition: winuser.h:2241
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define MK_MBUTTON
Definition: winuser.h:2325
#define FROM_LEFT_2ND_BUTTON_PRESSED
Definition: wincon.h:146
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
BOOL IgnoreNextMouseSignal
Definition: conwnd.h:72
#define SHIFT_PRESSED
Definition: wincon.h:135
#define CONSOLE_MOUSE_DOWN
Definition: wincon.h:100
DWORD dwButtonState
Definition: wincon.h:243
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static VOID GuiConsolePaste(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1365
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:99
#define MOUSE_MOVED
Definition: wincon.h:153
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DOUBLE_CLICK
Definition: wincon.h:154
#define VK_SHIFT
Definition: winuser.h:2156
COORD dwMousePosition
Definition: wincon.h:242
smooth NULL
Definition: ftsmooth.c:416
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
#define MK_RBUTTON
Definition: winuser.h:2322
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
SHORT WINAPI GetKeyState(_In_ int)
#define LEFT_ALT_PRESSED
Definition: wincon.h:132
union _INPUT_RECORD::@3149 Event
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ENHANCED_KEY
Definition: wincon.h:139
#define MOUSE_EVENT
Definition: wincon.h:123
const GLubyte * c
Definition: glext.h:8905
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define WM_RBUTTONUP
Definition: winuser.h:1756
#define ENABLE_MOUSE_INPUT
Definition: wincon.h:79
#define LEFT_CTRL_PRESSED
Definition: wincon.h:134
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define VK_RCONTROL
Definition: winuser.h:2239
#define VK_LMENU
Definition: winuser.h:2240
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1760
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
Definition: bl.h:1338
static VOID GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
Definition: guiterm.c:600
ULONG_PTR SIZE_T
Definition: typedefs.h:78
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define VK_SCROLL
Definition: winuser.h:2234
#define VK_NUMLOCK
Definition: winuser.h:2233
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
#define WM_LBUTTONUP
Definition: winuser.h:1753
DWORD dwControlKeyState
Definition: wincon.h:244
#define WM_MBUTTONDOWN
Definition: winuser.h:1758
#define VK_CAPITAL
Definition: winuser.h:2160
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SetWindowText
Definition: winuser.h:5723
#define WM_MOUSEMOVE
Definition: winuser.h:1751
CConsole Console
WORD EventType
Definition: wincon.h:261
#define DPRINT1
Definition: precomp.h:8
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
MOUSE_EVENT_RECORD MouseEvent
Definition: wincon.h:264
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1757
#define c
Definition: ke_i.h:80
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
#define MOUSE_WHEELED
Definition: wincon.h:155
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:133
static VOID GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1337
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define VK_LCONTROL
Definition: winuser.h:2238
LPARAM lParam
Definition: combotst.c:139
#define NUMLOCK_ON
Definition: wincon.h:136
#define RIGHT_ALT_PRESSED
Definition: wincon.h:131
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:195
#define CAPSLOCK_ON
Definition: wincon.h:138

Referenced by GuiConsoleWndProc().

◆ GuiConsoleHandleNcCreate()

static BOOL GuiConsoleHandleNcCreate ( HWND  hWnd,
LPCREATESTRUCTW  Create 
)
static

Definition at line 485 of file guiterm.c.

486 {
487  PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
489  HDC Dc;
490  HFONT OldFont;
491  TEXTMETRICW Metrics;
492  SIZE CharSize;
493 
494  DPRINT("GuiConsoleHandleNcCreate\n");
495 
496  if (NULL == GuiData)
497  {
498  DPRINT1("GuiConsoleNcCreate: No GUI data\n");
499  return FALSE;
500  }
501 
502  Console = GuiData->Console;
503 
504  GuiData->hWindow = hWnd;
505 
506  GuiData->Font = CreateFontW(LOWORD(GuiData->GuiInfo.FontSize),
507  0, // HIWORD(GuiData->GuiInfo.FontSize),
508  0,
509  TA_BASELINE,
510  GuiData->GuiInfo.FontWeight,
511  FALSE,
512  FALSE,
513  FALSE,
514  OEM_CHARSET,
518  FIXED_PITCH | GuiData->GuiInfo.FontFamily /* FF_DONTCARE */,
519  GuiData->GuiInfo.FaceName);
520 
521  if (NULL == GuiData->Font)
522  {
523  DPRINT1("GuiConsoleNcCreate: CreateFont failed\n");
524  GuiData->hWindow = NULL;
525  SetEvent(GuiData->hGuiInitEvent);
526  return FALSE;
527  }
528  Dc = GetDC(GuiData->hWindow);
529  if (NULL == Dc)
530  {
531  DPRINT1("GuiConsoleNcCreate: GetDC failed\n");
532  DeleteObject(GuiData->Font);
533  GuiData->hWindow = NULL;
534  SetEvent(GuiData->hGuiInitEvent);
535  return FALSE;
536  }
537  OldFont = SelectObject(Dc, GuiData->Font);
538  if (NULL == OldFont)
539  {
540  DPRINT1("GuiConsoleNcCreate: SelectObject failed\n");
541  ReleaseDC(GuiData->hWindow, Dc);
542  DeleteObject(GuiData->Font);
543  GuiData->hWindow = NULL;
544  SetEvent(GuiData->hGuiInitEvent);
545  return FALSE;
546  }
547  if (!GetTextMetricsW(Dc, &Metrics))
548  {
549  DPRINT1("GuiConsoleNcCreate: GetTextMetrics failed\n");
550  SelectObject(Dc, OldFont);
551  ReleaseDC(GuiData->hWindow, Dc);
552  DeleteObject(GuiData->Font);
553  GuiData->hWindow = NULL;
554  SetEvent(GuiData->hGuiInitEvent);
555  return FALSE;
556  }
557  GuiData->CharWidth = Metrics.tmMaxCharWidth;
558  GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
559 
560  /* Measure real char width more precisely if possible. */
561  if (GetTextExtentPoint32W(Dc, L"R", 1, &CharSize))
562  GuiData->CharWidth = CharSize.cx;
563 
564  SelectObject(Dc, OldFont);
565 
566  ReleaseDC(GuiData->hWindow, Dc);
567 
568  // FIXME: Keep these instructions here ? ///////////////////////////////////
569  Console->ActiveBuffer->CursorBlinkOn = TRUE;
570  Console->ActiveBuffer->ForceCursorOff = FALSE;
572 
573  SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
574 
577 
578  DPRINT("GuiConsoleHandleNcCreate - setting start event\n");
579  SetEvent(GuiData->hGuiInitEvent);
580 
581  return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
582 }
#define TRUE
Definition: types.h:120
HFONT WINAPI CreateFontW(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR)
HANDLE hGuiInitEvent
Definition: conwnd.h:44
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HDC WINAPI GetDC(_In_opt_ HWND)
_In_ BOOLEAN Create
Definition: pstypes.h:511
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define WM_NCCREATE
Definition: winuser.h:1665
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
UINT CharHeight
Definition: conwnd.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXED_PITCH
Definition: wingdi.h:443
#define TA_BASELINE
Definition: wingdi.h:927
#define CONGUI_UPDATE_TIMER
Definition: guiterm.c:25
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
#define NONANTIALIASED_QUALITY
Definition: wingdi.h:438
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
HFONT Font[FONT_MAXNO]
Definition: conwnd.h:85
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
#define CONGUI_UPDATE_TIME
Definition: guiterm.c:24
static VOID GuiConsoleCreateSysMenu(HWND hWnd)
Definition: guiterm.c:222
#define OEM_CHARSET
Definition: wingdi.h:399
static const WCHAR L[]
Definition: oid.c:1250
uint32_t DWORD_PTR
Definition: typedefs.h:63
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
UINT CharWidth
Definition: conwnd.h:86
CConsole Console
#define DPRINT1
Definition: precomp.h:8
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
#define SetWindowLongPtrW
Definition: winuser.h:5215
#define LOWORD(l)
Definition: pedump.c:82
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)

Referenced by GuiConsoleWndProc().

◆ GuiConsoleHandleNcDestroy()

static LRESULT GuiConsoleHandleNcDestroy ( HWND  hWnd)
static

Definition at line 1048 of file guiterm.c.

1049 {
1052 
1053  /* Free the GuiData registration */
1055 
1056  return DefWindowProcW(hWnd, WM_NCDESTROY, 0, 0);
1057 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CONGUI_UPDATE_TIMER
Definition: guiterm.c:25
#define GWLP_USERDATA
Definition: treelist.c:63
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
#define WM_NCDESTROY
Definition: winuser.h:1666
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define SetWindowLongPtrW
Definition: winuser.h:5215

Referenced by GuiConsoleWndProc().

◆ GuiConsoleHandlePaint()

static VOID GuiConsoleHandlePaint ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 673 of file guiterm.c.

674 {
675  BOOL Success = TRUE;
676  PCONSOLE Console = GuiData->Console;
677  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
678  HDC hDC;
679  PAINTSTRUCT ps;
680 
682  {
683  Success = FALSE;
684  goto Quit;
685  }
686  ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
687 
688  hDC = BeginPaint(GuiData->hWindow, &ps);
689  if (hDC != NULL &&
690  ps.rcPaint.left < ps.rcPaint.right &&
691  ps.rcPaint.top < ps.rcPaint.bottom)
692  {
693  EnterCriticalSection(&GuiData->Lock);
694 
695  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
696  {
698  GuiData, hDC, &ps.rcPaint);
699  }
700  else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
701  {
703  GuiData, hDC, &ps.rcPaint);
704  }
705 
706  if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
707  {
708  RECT rc;
709  SmallRectToRect(GuiData, &rc, &Console->Selection.srSelection);
710 
711  /* invert the selection */
712  if (IntersectRect(&rc, &ps.rcPaint, &rc))
713  {
714  PatBlt(hDC,
715  rc.left,
716  rc.top,
717  rc.right - rc.left,
718  rc.bottom - rc.top,
719  DSTINVERT);
720  }
721  }
722 
723  LeaveCriticalSection(&GuiData->Lock);
724  }
725  EndPaint(GuiData->hWindow, &ps);
726 
727 Quit:
728  if (Success)
730  else
731  DefWindowProcW(GuiData->hWindow, WM_PAINT, 0, 0);
732 
733  return;
734 }
#define TRUE
Definition: types.h:120
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
#define TEXTMODE_BUFFER
Definition: pccons.c:21
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
LONG right
Definition: windef.h:293
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
unsigned int BOOL
Definition: ntddk_ex.h:94
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
smooth NULL
Definition: ftsmooth.c:416
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
#define DSTINVERT
Definition: wingdi.h:326
CRITICAL_SECTION Lock
Definition: conwnd.h:42
VOID GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, HDC hDC, PRECT rc)
Definition: text.c:186
#define WM_PAINT
Definition: winuser.h:1602
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
VOID GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, HDC hDC, PRECT rc)
Definition: graphics.c:47
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
static HDC hDC
Definition: 3dtext.c:33
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
static VOID SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
Definition: guiterm.c:585
CConsole Console
LONG bottom
Definition: windef.h:294
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by GuiConsoleWndProc().

◆ GuiConsoleHandleScroll()

static LRESULT GuiConsoleHandleScroll ( PGUI_CONSOLE_DATA  GuiData,
UINT  uMsg,
WPARAM  wParam 
)
static

Definition at line 1510 of file guiterm.c.

1511 {
1512  PCONSOLE Console = GuiData->Console;
1514  SCROLLINFO sInfo;
1515  int fnBar;
1516  int old_pos, Maximum;
1517  PSHORT pShowXY;
1518 
1520 
1522 
1523  if (uMsg == WM_HSCROLL)
1524  {
1525  fnBar = SB_HORZ;
1526  Maximum = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
1527  pShowXY = &Buff->ViewOrigin.X;
1528  }
1529  else
1530  {
1531  fnBar = SB_VERT;
1532  Maximum = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
1533  pShowXY = &Buff->ViewOrigin.Y;
1534  }
1535 
1536  /* set scrollbar sizes */
1537  sInfo.cbSize = sizeof(SCROLLINFO);
1539 
1540  if (!GetScrollInfo(GuiData->hWindow, fnBar, &sInfo)) goto Quit;
1541 
1542  old_pos = sInfo.nPos;
1543 
1544  switch (LOWORD(wParam))
1545  {
1546  case SB_LINELEFT:
1547  sInfo.nPos -= 1;
1548  break;
1549 
1550  case SB_LINERIGHT:
1551  sInfo.nPos += 1;
1552  break;
1553 
1554  case SB_PAGELEFT:
1555  sInfo.nPos -= sInfo.nPage;
1556  break;
1557 
1558  case SB_PAGERIGHT:
1559  sInfo.nPos += sInfo.nPage;
1560  break;
1561 
1562  case SB_THUMBTRACK:
1563  sInfo.nPos = sInfo.nTrackPos;
1565  break;
1566 
1567  case SB_THUMBPOSITION:
1569  break;
1570 
1571  case SB_TOP:
1572  sInfo.nPos = sInfo.nMin;
1573  break;
1574 
1575  case SB_BOTTOM:
1576  sInfo.nPos = sInfo.nMax;
1577  break;
1578 
1579  default:
1580  break;
1581  }
1582 
1583  sInfo.nPos = max(sInfo.nPos, 0);
1584  sInfo.nPos = min(sInfo.nPos, Maximum);
1585 
1586  if (old_pos != sInfo.nPos)
1587  {
1588  USHORT OldX = Buff->ViewOrigin.X;
1589  USHORT OldY = Buff->ViewOrigin.Y;
1590  UINT WidthUnit, HeightUnit;
1591 
1592  *pShowXY = sInfo.nPos;
1593 
1594  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
1595 
1596  ScrollWindowEx(GuiData->hWindow,
1597  (OldX - Buff->ViewOrigin.X) * WidthUnit ,
1598  (OldY - Buff->ViewOrigin.Y) * HeightUnit,
1599  NULL,
1600  NULL,
1601  NULL,
1602  NULL,
1603  SW_INVALIDATE);
1604 
1605  sInfo.fMask = SIF_POS;
1606  SetScrollInfo(GuiData->hWindow, fnBar, &sInfo, TRUE);
1607 
1608  UpdateWindow(GuiData->hWindow);
1609  }
1610 
1611 Quit:
1612  LeaveCriticalSection(&Console->Lock);
1613  return 0;
1614 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:250
#define SIF_RANGE
Definition: winuser.h:1221
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
signed short * PSHORT
Definition: retypes.h:6
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SIF_PAGE
Definition: winuser.h:1219
WPARAM wParam
Definition: combotst.c:138
COORD ScreenBufferSize
Definition: conio.h:87
smooth NULL
Definition: ftsmooth.c:416
#define SB_THUMBPOSITION
Definition: winuser.h:572
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
ULONG X
Definition: bl.h:1340
struct tagSCROLLINFO SCROLLINFO
#define SB_THUMBTRACK
Definition: winuser.h:573
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SB_PAGELEFT
Definition: winuser.h:570
#define SB_LINERIGHT
Definition: winuser.h:567
#define SW_INVALIDATE
Definition: winuser.h:2533
#define SIF_POS
Definition: winuser.h:1220
#define SB_TOP
Definition: winuser.h:578
#define PAUSED_FROM_SCROLLBAR
Definition: conio_winsrv.h:127
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define SB_PAGERIGHT
Definition: winuser.h:571
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define WM_HSCROLL
Definition: winuser.h:1719
#define SB_BOTTOM
Definition: winuser.h:577
CConsole Console
VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:243
static VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.c:142
#define SB_LINELEFT
Definition: winuser.h:566
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1341
#define LOWORD(l)
Definition: pedump.c:82
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by GuiConsoleWndProc().

◆ GuiConsoleHandleSysMenuCommand()

static LRESULT GuiConsoleHandleSysMenuCommand ( PGUI_CONSOLE_DATA  GuiData,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 256 of file guiterm.c.

257 {
258  LRESULT Ret = TRUE;
259  PCONSOLE Console = GuiData->Console;
260  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
261 
263  {
264  Ret = FALSE;
265  goto Quit;
266  }
267  ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
268 
269  /*
270  * In case the selected menu item belongs to the user-reserved menu id range,
271  * send to him a menu event and return directly. The user must handle those
272  * reserved menu commands...
273  */
274  if (GuiData->cmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->cmdIdHigh)
275  {
277  goto Unlock_Quit;
278  }
279 
280  /* ... otherwise, perform actions. */
281  switch (wParam)
282  {
283  case ID_SYSTEM_EDIT_MARK:
284  {
285  LPWSTR WindowTitle = NULL;
286  SIZE_T Length = 0;
287 
288  Console->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
289  Console->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
290  Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
291  Console->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS;
292  GuiConsoleUpdateSelection(Console, &Console->Selection.dwSelectionAnchor);
293 
294  Length = Console->Title.Length + sizeof(L"Mark - ")/sizeof(WCHAR) + 1;
295  WindowTitle = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
296  wcscpy(WindowTitle, L"Mark - ");
297  wcscat(WindowTitle, Console->Title.Buffer);
298  SetWindowText(GuiData->hWindow, WindowTitle);
299  ConsoleFreeHeap(WindowTitle);
300 
301  break;
302  }
303 
304  case ID_SYSTEM_EDIT_COPY:
305  GuiConsoleCopy(GuiData);
306  break;
307 
309  GuiConsolePaste(GuiData);
310  break;
311 
313  {
314  LPWSTR WindowTitle = NULL;
315  SIZE_T Length = 0;
316 
317  Console->Selection.dwSelectionAnchor.X = 0;
318  Console->Selection.dwSelectionAnchor.Y = 0;
319  Console->dwSelectionCursor.X = ActiveBuffer->ViewSize.X - 1;
320  Console->dwSelectionCursor.Y = ActiveBuffer->ViewSize.Y - 1;
322  GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
323 
324  Length = Console->Title.Length + sizeof(L"Selection - ")/sizeof(WCHAR) + 1;
325  WindowTitle = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
326  wcscpy(WindowTitle, L"Selection - ");
327  wcscat(WindowTitle, Console->Title.Buffer);
328  SetWindowText(GuiData->hWindow, WindowTitle);
329  ConsoleFreeHeap(WindowTitle);
330 
331  break;
332  }
333 
335  DPRINT1("Scrolling is not handled yet\n");
336  break;
337 
338  case ID_SYSTEM_EDIT_FIND:
339  DPRINT1("Finding is not handled yet\n");
340  break;
341 
342  case ID_SYSTEM_DEFAULTS:
344  break;
345 
348  break;
349 
350  default:
351  Ret = FALSE;
352  break;
353  }
354 
355 Unlock_Quit:
357 Quit:
358  if (!Ret)
359  Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam);
360 
361  return Ret;
362 }
#define ID_SYSTEM_EDIT_SCROLL
Definition: resource.h:16
#define TRUE
Definition: types.h:120
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
#define ID_SYSTEM_EDIT_COPY
Definition: resource.h:13
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static VOID GuiConsolePaste(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1365
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:99
#define ID_SYSTEM_PROPERTIES
Definition: resource.h:19
#define ID_SYSTEM_EDIT_MARK
Definition: resource.h:12
#define ID_SYSTEM_DEFAULTS
Definition: resource.h:18
smooth NULL
Definition: ftsmooth.c:416
ULONG X
Definition: bl.h:1340
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
#define ID_SYSTEM_EDIT_SELECTALL
Definition: resource.h:15
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults)
Definition: guisettings.c:44
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
static VOID GuiSendMenuEvent(PCONSOLE Console, UINT CmdId)
Definition: guiterm.c:233
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
static VOID GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
Definition: guiterm.c:600
ULONG_PTR SIZE_T
Definition: typedefs.h:78
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SetWindowText
Definition: winuser.h:5723
unsigned int UINT
Definition: ndis.h:50
CConsole Console
#define DPRINT1
Definition: precomp.h:8
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
#define ID_SYSTEM_EDIT_FIND
Definition: resource.h:17
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
static VOID GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1337
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
ULONG Y
Definition: bl.h:1341
#define WM_SYSCOMMAND
Definition: winuser.h:1717
LPARAM lParam
Definition: combotst.c:139

Referenced by GuiConsoleWndProc().

◆ GuiConsoleHandleTimer()

static VOID GuiConsoleHandleTimer ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 930 of file guiterm.c.

931 {
932  PCONSOLE Console = GuiData->Console;
934 
936 
938 
940 
941  if (GetType(Buff) == TEXTMODE_BUFFER)
942  {
943  GuiInvalidateCell(&Console->TermIFace, Buff->CursorPosition.X, Buff->CursorPosition.Y);
944  Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
945 
946  if ((GuiData->OldCursor.x != Buff->CursorPosition.X) || (GuiData->OldCursor.y != Buff->CursorPosition.Y))
947  {
948  SCROLLINFO xScroll;
949  int OldScrollX = -1, OldScrollY = -1;
950  int NewScrollX = -1, NewScrollY = -1;
951 
952  xScroll.cbSize = sizeof(SCROLLINFO);
953  xScroll.fMask = SIF_POS;
954  // Capture the original position of the scroll bars and save them.
955  if (GetScrollInfo(GuiData->hWindow, SB_HORZ, &xScroll)) OldScrollX = xScroll.nPos;
956  if (GetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll)) OldScrollY = xScroll.nPos;
957 
958  // If we successfully got the info for the horizontal scrollbar
959  if (OldScrollX >= 0)
960  {
961  if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) || (Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X)))
962  {
963  // Handle the horizontal scroll bar
964  if (Buff->CursorPosition.X >= Buff->ViewSize.X) NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1;
965  else NewScrollX = 0;
966  }
967  else
968  {
969  NewScrollX = OldScrollX;
970  }
971  }
972  // If we successfully got the info for the vertical scrollbar
973  if (OldScrollY >= 0)
974  {
975  if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) || (Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y)))
976  {
977  // Handle the vertical scroll bar
978  if (Buff->CursorPosition.Y >= Buff->ViewSize.Y) NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1;
979  else NewScrollY = 0;
980  }
981  else
982  {
983  NewScrollY = OldScrollY;
984  }
985  }
986 
987  // Adjust scroll bars and refresh the window if the cursor has moved outside the visible area
988  // NOTE: OldScroll# and NewScroll# will both be -1 (initial value) if the info for the respective scrollbar
989  // was not obtained successfully in the previous steps. This means their difference is 0 (no scrolling)
990  // and their associated scrollbar is left alone.
991  if ((OldScrollX != NewScrollX) || (OldScrollY != NewScrollY))
992  {
993  Buff->ViewOrigin.X = NewScrollX;
994  Buff->ViewOrigin.Y = NewScrollY;
995  ScrollWindowEx(GuiData->hWindow,
996  (OldScrollX - NewScrollX) * GuiData->CharWidth,
997  (OldScrollY - NewScrollY) * GuiData->CharHeight,
998  NULL,
999  NULL,
1000  NULL,
1001  NULL,
1002  SW_INVALIDATE);
1003  if (NewScrollX >= 0)
1004  {
1005  xScroll.nPos = NewScrollX;
1006  SetScrollInfo(GuiData->hWindow, SB_HORZ, &xScroll, TRUE);
1007  }
1008  if (NewScrollY >= 0)
1009  {
1010  xScroll.nPos = NewScrollY;
1011  SetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll, TRUE);
1012  }
1013  UpdateWindow(GuiData->hWindow);
1014  GuiData->OldCursor.x = Buff->CursorPosition.X;
1015  GuiData->OldCursor.y = Buff->CursorPosition.Y;
1016  }
1017  }
1018  }
1019  else /* if (GetType(Buff) == GRAPHICS_BUFFER) */
1020  {
1021  }
1022 
1023  LeaveCriticalSection(&Console->Lock);
1024 }
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
BOOLEAN CursorBlinkOn
Definition: conio.h:99
long x
Definition: polytest.cpp:48
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
COORD CursorPosition
Definition: conio.h:98
BOOL WINAPI UpdateWindow(_In_ HWND)
#define TEXTMODE_BUFFER
Definition: pccons.c:21
UINT CharHeight
Definition: conwnd.h:87
#define CONGUI_UPDATE_TIMER
Definition: guiterm.c:25
smooth NULL
Definition: ftsmooth.c:416
#define CURSOR_BLINK_TIME
Definition: conwnd.c:38
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
ULONG X
Definition: bl.h:1340
struct tagSCROLLINFO SCROLLINFO
static VOID GuiInvalidateCell(IN OUT PFRONTEND This, SHORT x, SHORT y)
Definition: guiterm.c:923
if(!(yy_init))
Definition: macro.lex.yy.c:714
POINT OldCursor
Definition: conwnd.h:54
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
#define SW_INVALIDATE
Definition: winuser.h:2533
#define SIF_POS
Definition: winuser.h:1220
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
UINT CharWidth
Definition: conwnd.h:86
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1341
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by GuiConsoleWndProc().

◆ GuiConsoleMoveWindow()

VOID GuiConsoleMoveWindow ( PGUI_CONSOLE_DATA  GuiData)

Definition at line 373 of file guiterm.c.

374 {
375  /* Move the window if needed (not positioned by the system) */
376  if (!GuiData->GuiInfo.AutoPosition)
377  {
378  SetWindowPos(GuiData->hWindow,
379  NULL,
380  GuiData->GuiInfo.WindowOrigin.x,
381  GuiData->GuiInfo.WindowOrigin.y,
382  0,
383  0,
385  }
386 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define SWP_NOZORDER
Definition: winuser.h:1232
smooth NULL
Definition: ftsmooth.c:416
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define SWP_NOSIZE
Definition: winuser.h:1230
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)

Referenced by GuiApplyUserSettings().

◆ GuiConsoleNotifyWndProc()

static LRESULT CALLBACK GuiConsoleNotifyWndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1930 of file guiterm.c.

1931 {
1932  HWND NewWindow;
1933  LONG WindowCount;
1934  MSG Msg;
1935 
1936  switch (msg)
1937  {
1938  case WM_CREATE:
1939  {
1941  return 0;
1942  }
1943 
1944  case PM_CREATE_CONSOLE:
1945  {
1947  PCONSOLE Console = GuiData->Console;
1948 
1949  NewWindow = CreateWindowExW(WS_EX_CLIENTEDGE,
1951  Console->Title.Buffer,
1953  CW_USEDEFAULT,
1954  CW_USEDEFAULT,
1955  CW_USEDEFAULT,
1956  CW_USEDEFAULT,
1957  NULL,
1958  NULL,
1960  (PVOID)GuiData);
1961  if (NULL != NewWindow)
1962  {
1964  WindowCount++;
1966 
1967  DPRINT("Set icons via PM_CREATE_CONSOLE\n");
1968  if (GuiData->hIcon == NULL)
1969  {
1970  DPRINT("Not really /o\\...\n");
1971  GuiData->hIcon = ghDefaultIcon;
1972  GuiData->hIconSm = ghDefaultIconSm;
1973  }
1974  else if (GuiData->hIcon != ghDefaultIcon)
1975  {
1976  DPRINT("Yes \\o/\n");
1977  SendMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG, (LPARAM)GuiData->hIcon);
1978  SendMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
1979  }
1980 
1981  /* Move and resize the window to the user's values */
1982  /* CAN WE DEADLOCK ?? */
1983  GuiConsoleMoveWindow(GuiData);
1984  GuiData->WindowSizeLock = TRUE;
1985  GuiConsoleResizeWindow(GuiData);
1986  GuiData->WindowSizeLock = FALSE;
1987 
1988  // ShowWindow(NewWindow, (int)wParam);
1989  ShowWindowAsync(NewWindow, (int)wParam);
1990  DPRINT("Window showed\n");
1991  }
1992 
1993  return (LRESULT)NewWindow;
1994  }
1995 
1996  case PM_DESTROY_CONSOLE:
1997  {
1999 
2000  /*
2001  * Window creation is done using a PostMessage(), so it's possible
2002  * that the window that we want to destroy doesn't exist yet.
2003  * So first empty the message queue.
2004  */
2005  /*
2006  while (PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE))
2007  {
2008  TranslateMessage(&Msg);
2009  DispatchMessageW(&Msg);
2010  }*/
2011  while (PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE)) ;
2012 
2013  if (GuiData->hWindow != NULL) /* && DestroyWindow(GuiData->hWindow) */
2014  {
2015  DestroyWindow(GuiData->hWindow);
2016 
2018  WindowCount--;
2020  if (0 == WindowCount)
2021  {
2022  NotifyWnd = NULL;
2024  DPRINT("CONSRV: Going to quit the Gui Thread!!\n");
2025  PostQuitMessage(0);
2026  }
2027  }
2028 
2029  return 0;
2030  }
2031 
2032  default:
2033  return DefWindowProcW(hWnd, msg, wParam, lParam);
2034  }
2035 }
HICON ghDefaultIcon
Definition: conwnd.c:62
#define TRUE
Definition: types.h:120
static VOID GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:389
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define PM_DESTROY_CONSOLE
Definition: guiterm.c:41
HWND hWnd
Definition: settings.c:17
#define GWL_USERDATA
Definition: winuser.h:855
static UINT WindowCount
Definition: multiwin.c:4
HICON ghDefaultIconSm
Definition: conwnd.c:63
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
struct @1571 Msg[]
#define ICON_SMALL
Definition: tnclass.cpp:48
BOOL WindowSizeLock
Definition: conwnd.h:43
BOOL WINAPI ShowWindowAsync(_In_ HWND, _In_ int)
long LONG
Definition: pedump.c:60
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
HICON hIconSm
Definition: conwnd.h:67
#define CW_USEDEFAULT
Definition: winuser.h:225
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
#define PM_CREATE_CONSOLE
Definition: guiterm.c:40
#define WS_HSCROLL
Definition: pedump.c:628
#define GUI_CONSOLE_WINDOW_CLASS
Definition: guiterm.c:35
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
VOID GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:61
#define WS_VSCROLL
Definition: pedump.c:627
CConsole Console
HINSTANCE ConSrvDllInstance
Definition: init.c:21
#define msg(x)
Definition: auth_time.c:54
#define WM_CREATE
Definition: winuser.h:1590
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define ICON_BIG
Definition: tnclass.cpp:51
static HWND NotifyWnd
Definition: guiterm.c:84

Referenced by GuiInit().

◆ GuiConsolePaste()

static VOID GuiConsolePaste ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1365 of file guiterm.c.

1366 {
1367  if (OpenClipboard(GuiData->hWindow))
1368  {
1369  PCONSOLE Console = GuiData->Console;
1371 
1372  if (GetType(Buffer) == TEXTMODE_BUFFER)
1373  {
1375  }
1376  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
1377  {
1379  }
1380 
1381  CloseClipboard();
1382  }
1383 }
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
VOID GuiPasteToTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer)
Definition: text.c:117
#define TEXTMODE_BUFFER
Definition: pccons.c:21
VOID GuiPasteToGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer)
Definition: graphics.c:35
Definition: bufpool.h:45
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
BOOL WINAPI OpenClipboard(_In_opt_ HWND)

Referenced by GuiConsoleHandleMouse(), and GuiConsoleHandleSysMenuCommand().

◆ GuiConsoleResize()

static VOID GuiConsoleResize ( PGUI_CONSOLE_DATA  GuiData,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1418 of file guiterm.c.

1419 {
1420  PCONSOLE Console = GuiData->Console;
1421 
1423 
1424  if ((GuiData->WindowSizeLock == FALSE) &&
1426  {
1428  DWORD windx, windy, charx, chary;
1429  UINT WidthUnit, HeightUnit;
1430 
1431  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
1432 
1433  GuiData->WindowSizeLock = TRUE;
1434 
1435  windx = LOWORD(lParam);
1436  windy = HIWORD(lParam);
1437 
1438  // Compensate for existing scroll bars (because lParam values do not accommodate scroll bar)
1439  if (Buff->ViewSize.X < Buff->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // window currently has a horizontal scrollbar
1440  if (Buff->ViewSize.Y < Buff->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // window currently has a vertical scrollbar
1441 
1442  charx = windx / (int)WidthUnit ;
1443  chary = windy / (int)HeightUnit;
1444 
1445  // Character alignment (round size up or down)
1446  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
1447  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
1448 
1449  // Compensate for added scroll bars in new window
1450  if (charx < Buff->ScreenBufferSize.X) windy -= GetSystemMetrics(SM_CYHSCROLL); // new window will have a horizontal scroll bar
1451  if (chary < Buff->ScreenBufferSize.Y) windx -= GetSystemMetrics(SM_CXVSCROLL); // new window will have a vertical scroll bar
1452 
1453  charx = windx / (int)WidthUnit ;
1454  chary = windy / (int)HeightUnit;
1455 
1456  // Character alignment (round size up or down)
1457  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
1458  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
1459 
1460  // Resize window
1461  if ((charx != Buff->ViewSize.X) || (chary != Buff->ViewSize.Y))
1462  {
1463  Buff->ViewSize.X = (charx <= Buff->ScreenBufferSize.X) ? charx : Buff->ScreenBufferSize.X;
1464  Buff->ViewSize.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
1465  }
1466 
1467  GuiConsoleResizeWindow(GuiData);
1468 
1469  // Adjust the start of the visible area if we are attempting to show nonexistent areas
1470  if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) < Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
1471  if ((Buff->ScreenBufferSize.Y - Buff->ViewOrigin.Y) < Buff->ViewSize.Y) Buff->ViewOrigin.Y = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
1472  InvalidateRect(GuiData->hWindow, NULL, TRUE);
1473 
1474  GuiData->WindowSizeLock = FALSE;
1475  }
1476 
1477  LeaveCriticalSection(&Console->Lock);
1478 }
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
static VOID GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:389
#define SIZE_MAXIMIZED
Definition: winuser.h:2461
#define SIZE_RESTORED
Definition: winuser.h:2459
WPARAM wParam
Definition: combotst.c:138
BOOL WindowSizeLock
Definition: conwnd.h:43
COORD ScreenBufferSize
Definition: conio.h:87
smooth NULL
Definition: ftsmooth.c:416
ULONG X
Definition: bl.h:1340
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SIZE_MINIMIZED
Definition: winuser.h:2460
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
unsigned int UINT
Definition: ndis.h:50
#define SM_CXVSCROLL
Definition: winuser.h:951
CConsole Console
static VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.c:142
#define HIWORD(l)
Definition: typedefs.h:246
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1341
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by GuiConsoleWndProc().

◆ GuiConsoleResizeWindow()

static VOID GuiConsoleResizeWindow ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 389 of file guiterm.c.

390 {
391  PCONSOLE Console = GuiData->Console;
393  SCROLLINFO sInfo;
394 
395  DWORD Width, Height;
396  UINT WidthUnit, HeightUnit;
397 
398  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
399 
400  Width = Buff->ViewSize.X * WidthUnit +
402  Height = Buff->ViewSize.Y * HeightUnit +
404 
405  /* Set scrollbar sizes */
406  sInfo.cbSize = sizeof(SCROLLINFO);
407  sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
408  sInfo.nMin = 0;
409  if (Buff->ScreenBufferSize.Y > Buff->ViewSize.Y)
410  {
411  sInfo.nMax = Buff->ScreenBufferSize.Y - 1;
412  sInfo.nPage = Buff->ViewSize.Y;
413  sInfo.nPos = Buff->ViewOrigin.Y;
414  SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
415  Width += GetSystemMetrics(SM_CXVSCROLL);
416  ShowScrollBar(GuiData->hWindow, SB_VERT, TRUE);
417  }
418  else
419  {
420  ShowScrollBar(GuiData->hWindow, SB_VERT, FALSE);
421  }
422 
423  if (Buff->ScreenBufferSize.X > Buff->ViewSize.X)
424  {
425  sInfo.nMax = Buff->ScreenBufferSize.X - 1;
426  sInfo.nPage = Buff->ViewSize.X;
427  sInfo.nPos = Buff->ViewOrigin.X;
428  SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
429  Height += GetSystemMetrics(SM_CYHSCROLL);
430  ShowScrollBar(GuiData->hWindow, SB_HORZ, TRUE);
431  }
432  else
433  {
434  ShowScrollBar(GuiData->hWindow, SB_HORZ, FALSE);
435  }
436 
437  /* Resize the window */
438  SetWindowPos(GuiData->hWindow, NULL, 0, 0, Width, Height,
440  // NOTE: The SWP_NOCOPYBITS flag can be replaced by a subsequent call
441  // to: InvalidateRect(GuiData->hWindow, NULL, TRUE);
442 }
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
#define SM_CXEDGE
Definition: winuser.h:998
#define SWP_NOZORDER
Definition: winuser.h:1232
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
#define SIF_PAGE
Definition: winuser.h:1219
#define SWP_NOCOPYBITS
Definition: winuser.h:1228
COORD ScreenBufferSize
Definition: conio.h:87
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYEDGE
Definition: winuser.h:999
ULONG X
Definition: bl.h:1340
struct tagSCROLLINFO SCROLLINFO
#define SM_CYCAPTION
Definition: winuser.h:953
#define SWP_NOACTIVATE
Definition: winuser.h:1227
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SIF_POS
Definition: winuser.h:1220
unsigned int UINT
Definition: ndis.h:50
#define SM_CXVSCROLL
Definition: winuser.h:951
CConsole Console
static VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.c:142
#define SWP_NOMOVE
Definition: winuser.h:1229
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
ULONG Y
Definition: bl.h:1341
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by GuiConsoleNotifyWndProc(), GuiConsoleResize(), and GuiConsoleWndProc().

◆ GuiConsoleSwitchFullScreen()

static VOID GuiConsoleSwitchFullScreen ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 445 of file guiterm.c.

446 {
447  PCONSOLE Console = GuiData->Console;
448  // DEVMODE dmScreenSettings;
449 
451 
452  /* Switch to full-screen or to windowed mode */
453  GuiData->GuiInfo.FullScreen = !GuiData->GuiInfo.FullScreen;
454  DPRINT1("GuiConsoleSwitchFullScreen - Switch to %s ...\n",
455  (GuiData->GuiInfo.FullScreen ? "full-screen" : "windowed mode"));
456 
457  // TODO: Change window appearance.
458  // See:
459  // http://stackoverflow.com/questions/2382464/win32-full-screen-and-hiding-taskbar
460  // http://stackoverflow.com/questions/3549148/fullscreen-management-with-winapi
461  // http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
462  // http://stackoverflow.com/questions/1400654/how-do-i-put-my-opengl-app-into-fullscreen-mode
463  // http://nehe.gamedev.net/tutorial/creating_an_opengl_window_win32/13001/
464 #if 0
465  if (GuiData->GuiInfo.FullScreen)
466  {
467  memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
468  dmScreenSettings.dmSize = sizeof(dmScreenSettings);
469  dmScreenSettings.dmDisplayFixedOutput = DMDFO_CENTER; // DMDFO_STRETCH // DMDFO_DEFAULT
470  dmScreenSettings.dmPelsWidth = 640; // Console->ActiveBuffer->ViewSize.X * GuiData->CharWidth;
471  dmScreenSettings.dmPelsHeight = 480; // Console->ActiveBuffer->ViewSize.Y * GuiData->CharHeight;
472  dmScreenSettings.dmBitsPerPel = 32;
473  dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
474  ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
475  }
476  else
477  {
478  }
479 #endif
480 
482 }
#define TRUE
Definition: types.h:120
#define CDS_FULLSCREEN
Definition: winuser.h:183
#define DM_PELSWIDTH
Definition: wingdi.h:1251
#define DMDFO_CENTER
Definition: wingdi.h:1206
#define DM_PELSHEIGHT
Definition: wingdi.h:1252
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
CConsole Console
#define DPRINT1
Definition: precomp.h:8
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
#define DM_BITSPERPEL
Definition: wingdi.h:1250
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define memset(x, y, z)
Definition: compat.h:39

Referenced by GuiConsoleWndProc().

◆ GuiConsoleUpdateSelection()

static VOID GuiConsoleUpdateSelection ( PCONSOLE  Console,
PCOORD  coord 
)
static

Definition at line 600 of file guiterm.c.

601 {
602  PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
603  RECT oldRect, newRect;
604 
605  SmallRectToRect(GuiData, &oldRect, &Console->Selection.srSelection);
606 
607  if (coord != NULL)
608  {
609  SMALL_RECT rc;
610  /* exchange left/top with right/bottom if required */
611  rc.Left = min(Console->Selection.dwSelectionAnchor.X, coord->X);
612  rc.Top = min(Console->Selection.dwSelectionAnchor.Y, coord->Y);
613  rc.Right = max(Console->Selection.dwSelectionAnchor.X, coord->X);
614  rc.Bottom = max(Console->Selection.dwSelectionAnchor.Y, coord->Y);
615 
616  SmallRectToRect(GuiData, &newRect, &rc);
617 
618  if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
619  {
620  if (memcmp(&rc, &Console->Selection.srSelection, sizeof(SMALL_RECT)) != 0)
621  {
622  HRGN rgn1, rgn2;
623 
624  /* calculate the region that needs to be updated */
625  if ((rgn1 = CreateRectRgnIndirect(&oldRect)))
626  {
627  if ((rgn2 = CreateRectRgnIndirect(&newRect)))
628  {
629  if (CombineRgn(rgn1, rgn2, rgn1, RGN_XOR) != ERROR)
630  {
631  InvalidateRgn(GuiData->hWindow, rgn1, FALSE);
632  }
633  DeleteObject(rgn2);
634  }
635  DeleteObject(rgn1);
636  }
637  }
638  }
639  else
640  {
641  InvalidateRect(GuiData->hWindow, &newRect, FALSE);
642  }
643  Console->Selection.dwFlags |= CONSOLE_SELECTION_NOT_EMPTY;
644  Console->Selection.srSelection = rc;
645  Console->dwSelectionCursor = *coord;
647  }
648  else
649  {
650  /* clear the selection */
651  if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
652  {
653  InvalidateRect(GuiData->hWindow, &oldRect, FALSE);
654  }
655  Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
657  }
658 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define max(a, b)
Definition: svc.c:63
VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:250
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERROR(name)
Definition: error_private.h:53
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define CONSOLE_NO_SELECTION
Definition: wincon.h:96
#define PAUSED_FROM_SELECTION
Definition: conio_winsrv.h:128
GLuint coord
Definition: glext.h:9511
#define RGN_XOR
Definition: wingdi.h:359
smooth NULL
Definition: ftsmooth.c:416
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
SHORT Left
Definition: blue.h:25
SHORT Bottom
Definition: blue.h:28
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
SHORT Top
Definition: blue.h:26
static VOID SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
Definition: guiterm.c:585
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:243
SHORT Right
Definition: blue.h:27

Referenced by GuiConsoleCopy(), GuiConsoleHandleKey(), GuiConsoleHandleMouse(), and GuiConsoleHandleSysMenuCommand().

◆ GuiConsoleWndProc()

static LRESULT CALLBACK GuiConsoleWndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1617 of file guiterm.c.

1618 {
1619  LRESULT Result = 0;
1620  PGUI_CONSOLE_DATA GuiData = NULL;
1621  PCONSOLE Console = NULL;
1622 
1623  /*
1624  * - If it's the first time we create a window for the terminal,
1625  * just initialize it and return.
1626  *
1627  * - If we are destroying the window, just do it and return.
1628  */
1629  if (msg == WM_NCCREATE)
1630  {
1632  }
1633  else if (msg == WM_NCDESTROY)
1634  {
1636  }
1637 
1638  /*
1639  * Now the terminal window is initialized.
1640  * Get the terminal data via the window's data.
1641  * If there is no data, just go away.
1642  */
1643  GuiData = GuiGetGuiData(hWnd);
1644  if (GuiData == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
1645 
1646  /*
1647  * Just retrieve a pointer to the console in case somebody needs it.
1648  * It is not NULL because it was checked in GuiGetGuiData.
1649  * Each helper function which needs the console has to validate and lock it.
1650  */
1651  Console = GuiData->Console;
1652 
1653  /* We have a console, start message dispatching */
1654  switch (msg)
1655  {
1656  case WM_ACTIVATE:
1657  {
1659  break;
1660  }
1661 
1662  case WM_CLOSE:
1663  if (GuiConsoleHandleClose(GuiData)) goto Default;
1664  break;
1665 
1666  case WM_PAINT:
1667  GuiConsoleHandlePaint(GuiData);
1668  break;
1669 
1670  case WM_KEYDOWN:
1671  case WM_KEYUP:
1672  case WM_CHAR:
1673  case WM_DEADCHAR:
1674  case WM_SYSKEYDOWN:
1675  case WM_SYSKEYUP:
1676  case WM_SYSCHAR:
1677  case WM_SYSDEADCHAR:
1678  {
1679  /* Detect Alt-Enter presses and switch back and forth to fullscreen mode */
1680  if (msg == WM_SYSKEYDOWN && (HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN)
1681  {
1682  /* Switch only at first Alt-Enter press, and ignore subsequent key repetitions */
1684  break;
1685  }
1686 
1687  GuiConsoleHandleKey(GuiData, msg, wParam, lParam);
1688  break;
1689  }
1690 
1691  case WM_TIMER:
1692  GuiConsoleHandleTimer(GuiData);
1693  break;
1694 
1695  case WM_SETCURSOR:
1696  {
1697  /*
1698  * The message was sent because we are manually triggering a change.
1699  * Check whether the mouse is indeed present on this console window
1700  * and take appropriate decisions.
1701  */
1702  if (wParam == -1 && lParam == -1)
1703  {
1704  POINT mouseCoords;
1705  HWND hWndHit;
1706 
1707  /* Get the placement of the mouse */
1708  GetCursorPos(&mouseCoords);
1709 
1710  /* On which window is placed the mouse ? */
1711  hWndHit = WindowFromPoint(mouseCoords);
1712 
1713  /* It's our window. Perform the hit-test to be used later on. */
1714  if (hWndHit == hWnd)
1715  {
1716  wParam = (WPARAM)hWnd;
1717  lParam = DefWindowProcW(hWndHit, WM_NCHITTEST, 0,
1718  MAKELPARAM(mouseCoords.x, mouseCoords.y));
1719  }
1720  }
1721 
1722  /* Set the mouse cursor only when we are in the client area */
1723  if ((HWND)wParam == hWnd && LOWORD(lParam) == HTCLIENT)
1724  {
1725  if (GuiData->MouseCursorRefCount >= 0)
1726  {
1727  /* Show the cursor */
1728  SetCursor(GuiData->hCursor);
1729  }
1730  else
1731  {
1732  /* Hide the cursor if the reference count is negative */
1733  SetCursor(NULL);
1734  }
1735  return TRUE;
1736  }
1737  else
1738  {
1739  goto Default;
1740  }
1741  }
1742 
1743  case WM_LBUTTONDOWN:
1744  case WM_MBUTTONDOWN:
1745  case WM_RBUTTONDOWN:
1746  case WM_LBUTTONUP:
1747  case WM_MBUTTONUP:
1748  case WM_RBUTTONUP:
1749  case WM_LBUTTONDBLCLK:
1750  case WM_MBUTTONDBLCLK:
1751  case WM_RBUTTONDBLCLK:
1752  case WM_MOUSEMOVE:
1753  case WM_MOUSEWHEEL:
1754  case WM_MOUSEHWHEEL:
1755  {
1757  break;
1758  }
1759 
1760  case WM_HSCROLL:
1761  case WM_VSCROLL:
1762  {
1763  Result = GuiConsoleHandleScroll(GuiData, msg, wParam);
1764  break;
1765  }
1766 
1767  case WM_NCRBUTTONDOWN:
1768  {
1769  DPRINT1("WM_NCRBUTTONDOWN\n");
1770  /*
1771  * HACK: !! Because, when we deal with WM_RBUTTON* and we do not
1772  * call after that DefWindowProc, on ReactOS, right-clicks on the
1773  * (non-client) application title-bar does not display the system
1774  * menu and does not trigger a WM_NCRBUTTONUP message too.
1775  * See: http://git.reactos.org/?p=reactos.git;a=blob;f=reactos/win32ss/user/user32/windows/defwnd.c;hb=HEAD#l1103
1776  * and line 1135 too.
1777  */
1779  {
1780  /* Call DefWindowProcW with the WM_CONTEXTMENU message */
1781  msg = WM_CONTEXTMENU;
1782  }
1783  goto Default;
1784  }
1785  // case WM_NCRBUTTONUP:
1786  // DPRINT1("WM_NCRBUTTONUP\n");
1787  // goto Default;
1788 
1789  case WM_CONTEXTMENU:
1790  {
1791  if (DefWindowProcW(hWnd /*GuiData->hWindow*/, WM_NCHITTEST, 0, lParam) == HTCLIENT)
1792  {
1793  HMENU hMenu = CreatePopupMenu();
1794  if (hMenu != NULL)
1795  {
1797  TrackPopupMenuEx(hMenu,
1801  hWnd,
1802  NULL);
1803  DestroyMenu(hMenu);
1804  }
1805  break;
1806  }
1807  else
1808  {
1809  goto Default;
1810  }
1811  }
1812 
1813  case WM_INITMENU:
1814  {
1815  HMENU hMenu = (HMENU)wParam;
1816  if (hMenu != NULL)
1817  {
1818  /* Enable or disable the Close menu item */
1820  (GuiData->IsCloseButtonEnabled ? MF_ENABLED : MF_GRAYED));
1821 
1822  /* Enable or disable the Copy and Paste items */
1824  ((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
1825  (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) ? MF_ENABLED : MF_GRAYED));
1827  (!(Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
1829  }
1830 
1832  {
1834  LeaveCriticalSection(&Console->Lock);
1835  }
1836  break;
1837  }
1838 
1839  case WM_MENUSELECT:
1840  {
1841  if (HIWORD(wParam) == 0xFFFF) // Allow all the menu flags
1842  {
1844  {
1846  LeaveCriticalSection(&Console->Lock);
1847  }
1848  }
1849  break;
1850  }
1851 
1852  case WM_COMMAND:
1853  case WM_SYSCOMMAND:
1854  {
1856  break;
1857  }
1858 
1859  case WM_SETFOCUS:
1860  case WM_KILLFOCUS:
1861  {
1863  {
1864  INPUT_RECORD er;
1865  er.EventType = FOCUS_EVENT;
1868 
1869  if (msg == WM_SETFOCUS)
1870  DPRINT1("TODO: Create console caret\n");
1871  else // if (msg == WM_KILLFOCUS)
1872  DPRINT1("TODO: Destroy console caret\n");
1873 
1874  LeaveCriticalSection(&Console->Lock);
1875  }
1876  break;
1877  }
1878 
1879  case WM_GETMINMAXINFO:
1881  break;
1882 
1883  case WM_SIZE:
1884  GuiConsoleResize(GuiData, wParam, lParam);
1885  break;
1886 
1887  case PM_RESIZE_TERMINAL:
1888  {
1889  /* Resize the window to the user's values */
1890  GuiData->WindowSizeLock = TRUE;
1891  GuiConsoleResizeWindow(GuiData);
1892  GuiData->WindowSizeLock = FALSE;
1893  break;
1894  }
1895 
1896  case PM_APPLY_CONSOLE_INFO:
1897  {
1899  {
1901  LeaveCriticalSection(&Console->Lock);
1902  }
1903  break;
1904  }
1905 
1906  case PM_CONSOLE_BEEP:
1907  DPRINT1("Beep !!\n");
1908  Beep(800, 200);
1909  break;
1910 
1911  // case PM_CONSOLE_SET_TITLE:
1912  // SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer);
1913  // break;
1914 
1915  default: Default:
1917  break;
1918  }
1919 
1920  return Result;
1921 }
#define WM_MBUTTONUP
Definition: winuser.h:1759
VOID GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData, HANDLE hClientSection)
Definition: guisettings.c:258
#define TRUE
Definition: types.h:120
INT MouseCursorRefCount
Definition: conwnd.h:71
BOOL IsCloseButtonEnabled
Definition: conwnd.h:77
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
static PGUI_CONSOLE_DATA GuiGetGuiData(HWND hWnd)
Definition: guiterm.c:365
long y
Definition: polytest.cpp:48
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_CHAR
Definition: winuser.h:1693
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
static LRESULT GuiConsoleHandleMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:1087
long x
Definition: polytest.cpp:48
static VOID GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:389
static VOID GuiConsoleAppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: guiterm.c:168
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
#define ID_SYSTEM_EDIT_COPY
Definition: resource.h:13
HWND hWnd
Definition: settings.c:17
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
#define WM_NCRBUTTONDOWN
Definition: winuser.h:1677
BOOL IgnoreNextMouseSignal
Definition: conwnd.h:72
#define KF_UP
Definition: winuser.h:2405
#define WM_NCHITTEST
Definition: winuser.h:1668
UINT_PTR WPARAM
Definition: windef.h:207
static VOID GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:445
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define WM_NCCREATE
Definition: winuser.h:1665
static BOOL GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
Definition: guiterm.c:485
#define VK_RETURN
Definition: winuser.h:2155
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WindowSizeLock
Definition: conwnd.h:43
static const GUICONSOLE_MENUITEM GuiConsoleEditMenuItems[]
Definition: guiterm.c:93
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
#define PM_APPLY_CONSOLE_INFO
Definition: guisettings.h:17
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
static LRESULT GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
Definition: guiterm.c:1510
static VOID GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:1418
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_SETCURSOR
Definition: winuser.h:1618
#define WM_MENUSELECT
Definition: winuser.h:1723
#define WM_SYSCHAR
Definition: winuser.h:1697
static BOOL GuiConsoleHandleClose(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1027
#define CF_UNICODETEXT
Definition: constants.h:408
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define WM_KEYDOWN
Definition: winuser.h:1691
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
#define FOCUS_EVENT
Definition: wincon.h:126
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
#define KF_REPEAT
Definition: winuser.h:2404
#define WM_DEADCHAR
Definition: winuser.h:1694
union _INPUT_RECORD::@3149 Event
#define WM_KILLFOCUS
Definition: winuser.h:1596
#define WM_SIZE
Definition: winuser.h:1593
#define WM_TIMER
Definition: winuser.h:1718
#define MF_ENABLED
Definition: winuser.h:128
#define WM_CLOSE
Definition: winuser.h:1603
#define WM_NCDESTROY
Definition: winuser.h:1666
#define WM_KEYUP
Definition: winuser.h:1692
#define WA_CLICKACTIVE
Definition: winuser.h:2578
#define WM_RBUTTONUP
Definition: winuser.h:1756
FOCUS_EVENT_RECORD FocusEvent
Definition: wincon.h:267
#define WM_PAINT
Definition: winuser.h:1602
#define PM_CONSOLE_BEEP
Definition: guiterm.c:43
static VOID GuiSendMenuEvent(PCONSOLE Console, UINT CmdId)
Definition: guiterm.c:233
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
static VOID GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:930
static VOID GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:673
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1760
#define WM_COMMAND
Definition: winuser.h:1716
static VOID GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:760
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define HTCAPTION
Definition: winuser.h:2430
#define WM_INITMENU
Definition: winuser.h:1721
#define WM_ACTIVATE
Definition: winuser.h:1594
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_SYSDEADCHAR
Definition: winuser.h:1698
#define PM_RESIZE_TERMINAL
Definition: guiterm.c:42
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
#define WM_SYSKEYUP
Definition: winuser.h:1696
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define WM_MBUTTONDOWN
Definition: winuser.h:1758
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define WM_HSCROLL
Definition: winuser.h:1719
HWND WINAPI WindowFromPoint(_In_ POINT)
#define KF_ALTDOWN
Definition: winuser.h:2403
HCURSOR hCursor
Definition: conwnd.h:70
CConsole Console
WORD EventType
Definition: wincon.h:261
#define DPRINT1
Definition: precomp.h:8
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
#define msg(x)
Definition: auth_time.c:54
#define SC_CLOSE
Definition: winuser.h:2546
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1757
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
static LRESULT GuiConsoleHandleNcDestroy(HWND hWnd)
Definition: guiterm.c:1048
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define HIWORD(l)
Definition: typedefs.h:246
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
static LRESULT GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:256
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HTCLIENT
Definition: winuser.h:2429
LONG_PTR LRESULT
Definition: windef.h:209
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WM_SYSCOMMAND
Definition: winuser.h:1717
LPARAM lParam
Definition: combotst.c:139
#define WM_GETMINMAXINFO
Definition: winuser.h:1622
#define LOWORD(l)
Definition: pedump.c:82
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:195
static VOID GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
Definition: guiterm.c:1386
#define WM_VSCROLL
Definition: winuser.h:1720

Referenced by GuiInit().

◆ GuiCopyFromGraphicsBuffer()

VOID GuiCopyFromGraphicsBuffer ( PGRAPHICS_SCREEN_BUFFER  Buffer)

Definition at line 23 of file graphics.c.

24 {
25  /*
26  * This function supposes that the system clipboard was opened.
27  */
28 
29  // PCONSOLE Console = Buffer->Header.Console;
30 
32 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by GuiConsoleCopy().

◆ GuiCopyFromTextModeBuffer()

VOID GuiCopyFromTextModeBuffer ( PTEXTMODE_SCREEN_BUFFER  Buffer)

Definition at line 26 of file text.c.

27 {
28  /*
29  * This function supposes that the system clipboard was opened.
30  */
31 
32  PCONSOLE Console = Buffer->Header.Console;
33 
34  /*
35  * Pressing the Shift key while copying text, allows us to copy
36  * text without newline characters (inline-text copy mode).
37  */
38  BOOL InlineCopyMode = (GetKeyState(VK_SHIFT) & 0x8000);
39 
40  HANDLE hData;
42  LPWSTR data, dstPos;
43  ULONG selWidth, selHeight;
44  ULONG xPos, yPos, size;
45 
46  selWidth = Console->Selection.srSelection.Right - Console->Selection.srSelection.Left + 1;
47  selHeight = Console->Selection.srSelection.Bottom - Console->Selection.srSelection.Top + 1;
48  DPRINT("Selection is (%d|%d) to (%d|%d)\n",
49  Console->Selection.srSelection.Left,
50  Console->Selection.srSelection.Top,
51  Console->Selection.srSelection.Right,
52  Console->Selection.srSelection.Bottom);
53 
54  /* Basic size for one line... */
55  size = selWidth;
56  /* ... and for the other lines, add newline characters if needed. */
57  if (selHeight > 0)
58  {
59  /*
60  * If we are not in inline-text copy mode, each selected line must
61  * finish with \r\n . Otherwise, the lines will be just concatenated.
62  */
63  size += (selWidth + (!InlineCopyMode ? 2 : 0)) * (selHeight - 1);
64  }
65  size += 1; /* Null-termination */
66  size *= sizeof(WCHAR);
67 
68  /* Allocate memory, it will be passed to the system and may not be freed here */
70  if (hData == NULL) return;
71 
72  data = GlobalLock(hData);
73  if (data == NULL) return;
74 
75  DPRINT("Copying %dx%d selection\n", selWidth, selHeight);
76  dstPos = data;
77 
78  for (yPos = 0; yPos < selHeight; yPos++)
79  {
81  Console->Selection.srSelection.Left,
82  yPos + Console->Selection.srSelection.Top);
83  /* Copy only the characters, leave attributes alone */
84  for (xPos = 0; xPos < selWidth; xPos++)
85  {
86  /*
87  * Sometimes, applications can put NULL chars into the screen-buffer
88  * (this behaviour is allowed). Detect this and replace by a space.
89  * FIXME - HACK: Improve the way we're doing that (i.e., put spaces
90  * instead of NULLs (or even, nothing) only if it exists a non-null
91  * char *after* those NULLs, before the end-of-line of the selection.
92  * Do the same concerning spaces -- i.e. trailing spaces --).
93  */
94  dstPos[xPos] = (ptr[xPos].Char.UnicodeChar ? ptr[xPos].Char.UnicodeChar : L' ');
95  }
96  dstPos += selWidth;
97 
98  /* Add newline characters if we are not in inline-text copy mode */
99  if (!InlineCopyMode)
100  {
101  if (yPos != (selHeight - 1))
102  {
103  wcscat(data, L"\r\n");
104  dstPos += 2;
105  }
106  }
107  }
108 
109  DPRINT("Setting data <%S> to clipboard\n", data);
110  GlobalUnlock(hData);
111 
112  EmptyClipboard();
114 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
#define VK_SHIFT
Definition: winuser.h:2156
#define CF_UNICODETEXT
Definition: constants.h:408
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
SHORT WINAPI GetKeyState(_In_ int)
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const WCHAR L[]
Definition: oid.c:1250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define GMEM_MOVEABLE
Definition: winbase.h:291
#define GMEM_ZEROINIT
Definition: winbase.h:303

Referenced by GuiConsoleCopy().

◆ GuiDeinitFrontEnd()

static VOID WINAPI GuiDeinitFrontEnd ( IN OUT PFRONTEND  This)
static

Definition at line 2385 of file guiterm.c.

2386 {
2387  PGUI_CONSOLE_DATA GuiData = This->Data;
2388 
2390 
2391  DPRINT("Destroying icons !! - GuiData->hIcon = 0x%p ; ghDefaultIcon = 0x%p ; GuiData->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n",
2392  GuiData->hIcon, ghDefaultIcon, GuiData->hIconSm, ghDefaultIconSm);
2393  if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon)
2394  {
2395  DPRINT("Destroy hIcon\n");
2396  DestroyIcon(GuiData->hIcon);
2397  }
2398  if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm)
2399  {
2400  DPRINT("Destroy hIconSm\n");
2401  DestroyIcon(GuiData->hIconSm);
2402  }
2403 
2404  This->Data = NULL;
2405  DeleteCriticalSection(&GuiData->Lock);
2406  ConsoleFreeHeap(GuiData);
2407 
2408  DPRINT("Quit GuiDeinitFrontEnd\n");
2409 }
HICON ghDefaultIcon
Definition: conwnd.c:62
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define PM_DESTROY_CONSOLE
Definition: guiterm.c:41
HICON ghDefaultIconSm
Definition: conwnd.c:63
HICON hIconSm
Definition: conwnd.h:67
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
CRITICAL_SECTION Lock
Definition: conwnd.h:42
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
static HWND NotifyWnd
Definition: guiterm.c:84

Referenced by GuiInitFrontEnd(), and GuiUnloadFrontEnd().

◆ GuiDrawRegion()

static VOID WINAPI GuiDrawRegion ( IN OUT PFRONTEND  This,
SMALL_RECT Region 
)
static

Definition at line 2412 of file guiterm.c.

2414 {
2415  PGUI_CONSOLE_DATA GuiData = This->Data;
2416  RECT RegionRect;
2417 
2418  SmallRectToRect(GuiData, &RegionRect, Region);
2419  /* Do not erase the background: it speeds up redrawing and reduce flickering */
2420  InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
2421 }
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static VOID SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
Definition: guiterm.c:585

Referenced by GuiInvalidateCell(), and GuiWriteStream().

◆ GuiGetConsoleWindowHandle()

static HWND WINAPI GuiGetConsoleWindowHandle ( IN OUT PFRONTEND  This)
static

Definition at line 2627 of file guiterm.c.

2628 {
2629  PGUI_CONSOLE_DATA GuiData = This->Data;
2630  return GuiData->hWindow;
2631 }

◆ GuiGetDisplayMode()

static ULONG WINAPI GuiGetDisplayMode ( IN OUT PFRONTEND  This)
static

Definition at line 2677 of file guiterm.c.

2678 {
2679  PGUI_CONSOLE_DATA GuiData = This->Data;
2680  ULONG DisplayMode = 0;
2681 
2682  if (GuiData->GuiInfo.FullScreen)
2683  DisplayMode |= CONSOLE_FULLSCREEN_HARDWARE; // CONSOLE_FULLSCREEN
2684  else
2686 
2687  return DisplayMode;
2688 }
#define CONSOLE_FULLSCREEN_HARDWARE
Definition: wincon.h:30
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:116
#define CONSOLE_WINDOWED
Definition: wincon.h:28
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
unsigned int ULONG
Definition: retypes.h:1

◆ GuiGetGuiData()

static PGUI_CONSOLE_DATA GuiGetGuiData ( HWND  hWnd)
static

Definition at line 365 of file guiterm.c.

366 {
367  /* This function ensures that the console pointer is not NULL */
369  return ( ((GuiData == NULL) || (GuiData->hWindow == hWnd && GuiData->Console != NULL)) ? GuiData : NULL );
370 }
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
HWND hWnd
Definition: settings.c:17
#define GetWindowLongPtrW
Definition: winuser.h:4698
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
PCONSRV_CONSOLE Console
Definition: conwnd.h:90

Referenced by GuiConsoleWndProc().

◆ GuiGetLargestConsoleWindowSize()

static VOID WINAPI GuiGetLargestConsoleWindowSize ( IN OUT PFRONTEND  This,
PCOORD  pSize 
)
static

Definition at line 2634 of file guiterm.c.

2636 {
2637  PGUI_CONSOLE_DATA GuiData = This->Data;
2638  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
2639  RECT WorkArea;
2640  LONG width, height;
2641  UINT WidthUnit, HeightUnit;
2642 
2643  if (!pSize) return;
2644 
2645  if (!SystemParametersInfoW(SPI_GETWORKAREA, 0, &WorkArea, 0))
2646  {
2647  DPRINT1("SystemParametersInfoW failed - What to do ??\n");
2648  return;
2649  }
2650 
2651  ActiveBuffer = ConDrvGetActiveScreenBuffer(GuiData->Console);
2652  if (ActiveBuffer)
2653  {
2654  GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
2655  }
2656  else
2657  {
2658  /* Default: text mode */
2659  WidthUnit = GuiData->CharWidth ;
2660  HeightUnit = GuiData->CharHeight;
2661  }
2662 
2663  width = WorkArea.right;
2664  height = WorkArea.bottom;
2665 
2668 
2669  if (width < 0) width = 0;
2670  if (height < 0) height = 0;
2671 
2672  pSize->X = (SHORT)(width / (int)WidthUnit ) /* HACK */ + 2;
2673  pSize->Y = (SHORT)(height / (int)HeightUnit) /* HACK */ + 1;
2674 }
GLint GLint GLsizei width
Definition: gl.h:1546
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
#define SM_CXEDGE
Definition: winuser.h:998
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
LONG right
Definition: windef.h:293
UINT CharHeight
Definition: conwnd.h:87
long LONG
Definition: pedump.c:60
short SHORT
Definition: pedump.c:59
#define SM_CYEDGE
Definition: winuser.h:999
ULONG X
Definition: bl.h:1340
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
#define SM_CYCAPTION
Definition: winuser.h:953
int WINAPI GetSystemMetrics(_In_ int)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
unsigned int UINT
Definition: ndis.h:50
UINT CharWidth
Definition: conwnd.h:86
#define DPRINT1
Definition: precomp.h:8
static VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.c:142
LONG bottom
Definition: windef.h:294
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
ULONG Y
Definition: bl.h:1341

◆ GuiInit()

static BOOL GuiInit ( VOID  )
static

Definition at line 2083 of file guiterm.c.

2084 {
2085  WNDCLASSEXW wc;
2086  ATOM ConsoleClassAtom;
2087 
2088  /* Exit if we were already initialized */
2089  // if (ConsInitialized) return TRUE;
2090 
2091  /*
2092  * Initialize and register the different window classes, if needed.
2093  */
2094  if (!ConsInitialized)
2095  {
2096  /* Initialize the notification window class */
2097  wc.cbSize = sizeof(WNDCLASSEXW);
2098  wc.lpszClassName = L"ConSrvCreateNotify";
2100  wc.style = 0;
2102  wc.hIcon = NULL;
2103  wc.hIconSm = NULL;
2104  wc.hCursor = NULL;
2105  wc.hbrBackground = NULL;
2106  wc.lpszMenuName = NULL;
2107  wc.cbClsExtra = 0;
2108  wc.cbWndExtra = 0;
2109  if (RegisterClassExW(&wc) == 0)
2110  {
2111  DPRINT1("Failed to register GUI notify wndproc\n");
2112  return FALSE;
2113  }
2114 
2115  /* Initialize the console window class */
2118  IMAGE_ICON,
2121  LR_SHARED);
2124  IMAGE_ICON,
2127  LR_SHARED);
2129  wc.cbSize = sizeof(WNDCLASSEXW);
2132  wc.style = CS_DBLCLKS /* | CS_HREDRAW | CS_VREDRAW */;
2134  wc.hIcon = ghDefaultIcon;
2135  wc.hIconSm = ghDefaultIconSm;
2136  wc.hCursor = ghDefaultCursor;
2137  wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); // The color of a terminal when it is switch off.
2138  wc.lpszMenuName = NULL;
2139  wc.cbClsExtra = 0;
2141 
2142  ConsoleClassAtom = RegisterClassExW(&wc);
2143  if (ConsoleClassAtom == 0)
2144  {
2145  DPRINT1("Failed to register GUI console wndproc\n");
2146  return FALSE;
2147  }
2148  else
2149  {
2150  NtUserConsoleControl(GuiConsoleWndClassAtom, &ConsoleClassAtom, sizeof(ATOM));
2151  }
2152 
2154  }
2155 
2156  /*
2157  * Set-up the notification window
2158  */
2159  if (NULL == NotifyWnd)
2160  {
2161  HANDLE ThreadHandle;
2162  HANDLE GraphicsStartupEvent;
2163 
2164  GraphicsStartupEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
2165  if (NULL == GraphicsStartupEvent) return FALSE;
2166 
2167  ThreadHandle = CreateThread(NULL,
2168  0,
2170  (PVOID)&GraphicsStartupEvent,
2171  0,
2172  NULL);
2173  if (NULL == ThreadHandle)
2174  {
2175  CloseHandle(GraphicsStartupEvent);
2176  DPRINT1("CONSRV: Failed to create graphics console thread. Expect problems\n");
2177  return FALSE;
2178  }
2180  CloseHandle(ThreadHandle);
2181 
2182  WaitForSingleObject(GraphicsStartupEvent, INFINITE);
2183  CloseHandle(GraphicsStartupEvent);
2184 
2185  if (NULL == NotifyWnd)
2186  {
2187  DPRINT1("CONSRV: Failed to create notification window.\n");
2188  return FALSE;
2189  }
2190  }
2191 
2192  // ConsInitialized = TRUE;
2193 
2194  return TRUE;
2195 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HICON ghDefaultIcon
Definition: conwnd.c:62
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
int cbWndExtra
Definition: winuser.h:3173
WORD ATOM
Definition: dimm.idl:113
#define SM_CYSMICON
Definition: winuser.h:1003
HICON hIcon
Definition: winuser.h:3175
HICON ghDefaultIconSm
Definition: conwnd.c:63
struct _WNDCLASSEXW WNDCLASSEXW
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LPCWSTR lpszMenuName
Definition: winuser.h:3178
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:274
NTSTATUS APIENTRY NtUserConsoleControl(IN CONSOLECONTROL ConsoleCtrl, IN PVOID ConsoleCtrlInfo, IN ULONG ConsoleCtrlInfoLength)
Definition: console.c:14
#define SM_CXICON
Definition: winuser.h:962
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:111
smooth NULL
Definition: ftsmooth.c:416
#define IDI_TERMINAL
Definition: resource.h:44
int cbClsExtra
Definition: winuser.h:3172
static DWORD WINAPI GuiConsoleGuiThread(PVOID Data)
Definition: guiterm.c:2038
LPCWSTR lpszClassName
Definition: winuser.h:3179
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:661
#define BLACK_BRUSH
Definition: wingdi.h:895
HBRUSH hbrBackground
Definition: winuser.h:3177
UINT cbSize
Definition: winuser.h:3169
int WINAPI GetSystemMetrics(_In_ int)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
HINSTANCE hInstance
Definition: winuser.h:3174
#define GUI_CONSOLE_WINDOW_CLASS
Definition: guiterm.c:35
#define SM_CXSMICON
Definition: winuser.h:1002
#define SM_CYICON
Definition: winuser.h:963
static const WCHAR L[]
Definition: oid.c:1250
static BOOL ConsInitialized
Definition: guiterm.c:80
HCURSOR hCursor
Definition: winuser.h:3176
#define CS_DBLCLKS
Definition: winuser.h:646
UINT style
Definition: winuser.h:3170
WNDPROC lpfnWndProc
Definition: winuser.h:3171
HCURSOR ghDefaultCursor
Definition: conwnd.c:64
static LRESULT CALLBACK GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:1930
#define DPRINT1
Definition: precomp.h:8
HICON hIconSm
Definition: winuser.h:3180
HINSTANCE ConSrvDllInstance
Definition: init.c:21
#define IDC_ARROW
Definition: winuser.h:682
#define GWLP_CONSOLEWND_ALLOC
Definition: guiterm.c:63
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define INFINITE
Definition: serial.h:102
static HWND NotifyWnd
Definition: guiterm.c:84
static LRESULT CALLBACK GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:1617

Referenced by GuiLoadFrontEnd().

◆ GuiInitFrontEnd()

NTSTATUS NTAPI GuiInitFrontEnd ( IN OUT PFRONTEND  This,
IN PCONSOLE  Console 
)

Definition at line 2207 of file guiterm.c.

2209 {
2210  PGUI_INIT_INFO GuiInitInfo;
2212  PCONSOLE_START_INFO ConsoleStartInfo;
2213 
2214  PGUI_CONSOLE_DATA GuiData;
2215  GUI_CONSOLE_INFO TermInfo;
2216 
2217  SIZE_T Length = 0;
2218  LPWSTR IconPath = NULL;
2219  INT IconIndex = 0;
2220 
2221  if (This == NULL || Console == NULL || This->OldData == NULL)
2222  return STATUS_INVALID_PARAMETER;
2223 
2224  ASSERT(This->Console == Console);
2225 
2226  GuiInitInfo = This->OldData;
2227 
2228  if (GuiInitInfo->ConsoleInfo == NULL || GuiInitInfo->ConsoleStartInfo == NULL)
2229  return STATUS_INVALID_PARAMETER;
2230 
2231  ConsoleInfo = GuiInitInfo->ConsoleInfo;
2232  ConsoleStartInfo = GuiInitInfo->ConsoleStartInfo;
2233 
2234  IconPath = ConsoleStartInfo->IconPath;
2235  IconIndex = ConsoleStartInfo->IconIndex;
2236 
2237 
2238  /* Terminal data allocation */
2240  if (!GuiData)
2241  {
2242  DPRINT1("CONSRV: Failed to create GUI_CONSOLE_DATA\n");
2243  return STATUS_UNSUCCESSFUL;
2244  }
2245  /* HACK */ Console->TermIFace.Data = (PVOID)GuiData; /* HACK */
2246  GuiData->Console = Console;
2247  GuiData->hWindow = NULL;
2248 
2249  /* The console can be resized */
2250  Console->FixedSize = FALSE;
2251 
2252  InitializeCriticalSection(&GuiData->Lock);
2253 
2254 
2255  /*
2256  * Load terminal settings
2257  */
2258 
2259  /* 1. Load the default settings */
2260  GuiConsoleGetDefaultSettings(&TermInfo, GuiInitInfo->ProcessId);
2261 
2262  /* 3. Load the remaining console settings via the registry. */
2263  if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
2264  {
2265  /* Load the terminal infos from the registry. */
2266  GuiConsoleReadUserSettings(&TermInfo,
2267  ConsoleInfo->ConsoleTitle,
2268  GuiInitInfo->ProcessId);
2269 
2270  /*
2271  * Now, update them with the properties the user might gave to us
2272  * via the STARTUPINFO structure before calling CreateProcess
2273  * (and which was transmitted via the ConsoleStartInfo structure).
2274  * We therefore overwrite the values read in the registry.
2275  */
2276  if (ConsoleStartInfo->dwStartupFlags & STARTF_USESHOWWINDOW)
2277  {
2278  TermInfo.ShowWindow = ConsoleStartInfo->ShowWindow;
2279  }
2280  if (ConsoleStartInfo->dwStartupFlags & STARTF_USEPOSITION)
2281  {
2282  TermInfo.AutoPosition = FALSE;
2283  TermInfo.WindowOrigin = ConsoleStartInfo->ConsoleWindowOrigin;
2284  }
2285  if (ConsoleStartInfo->dwStartupFlags & STARTF_RUNFULLSCREEN)
2286  {
2287  TermInfo.FullScreen = TRUE;
2288  }
2289  }
2290 
2291 
2292  /*
2293  * Set up GUI data
2294  */
2295 
2296  Length = min(wcslen(TermInfo.FaceName) + 1, LF_FACESIZE); // wcsnlen
2297  wcsncpy(GuiData->GuiInfo.FaceName, TermInfo.FaceName, LF_FACESIZE);
2298  GuiData->GuiInfo.FaceName[Length] = L'\0';
2299  GuiData->GuiInfo.FontFamily = TermInfo.FontFamily;
2300  GuiData->GuiInfo.FontSize = TermInfo.FontSize;
2301  GuiData->GuiInfo.FontWeight = TermInfo.FontWeight;
2302  GuiData->GuiInfo.UseRasterFonts = TermInfo.UseRasterFonts;
2303  GuiData->GuiInfo.FullScreen = TermInfo.FullScreen;
2304  GuiData->GuiInfo.ShowWindow = TermInfo.ShowWindow;
2305  GuiData->GuiInfo.AutoPosition = TermInfo.AutoPosition;
2306  GuiData->GuiInfo.WindowOrigin = TermInfo.WindowOrigin;
2307 
2308  /* Initialize the icon handles to their default values */
2309  GuiData->hIcon = ghDefaultIcon;
2310  GuiData->hIconSm = ghDefaultIconSm;
2311 
2312  /* Get the associated icon, if any */
2313  if (IconPath == NULL || IconPath[0] == L'\0')
2314  {
2315  IconPath = ConsoleStartInfo->AppPath;
2316  IconIndex = 0;
2317  }
2318  DPRINT("IconPath = %S ; IconIndex = %lu\n", (IconPath ? IconPath : L"n/a"), IconIndex);
2319  if (IconPath && IconPath[0] != L'\0')
2320  {
2321  HICON hIcon = NULL, hIconSm = NULL;
2323  IconIndex,
2324  &hIcon,
2325  &hIconSm,
2326  1);
2327  DPRINT("hIcon = 0x%p ; hIconSm = 0x%p\n", hIcon, hIconSm);
2328  if (hIcon != NULL)
2329  {
2330  DPRINT("Effectively set the icons\n");
2331  GuiData->hIcon = hIcon;
2332  GuiData->hIconSm = hIconSm;
2333  }
2334  }
2335 
2336  /* Mouse is shown by default with its default cursor shape */
2337  GuiData->hCursor = ghDefaultCursor;
2338  GuiData->MouseCursorRefCount = 0;
2339 
2340  /* A priori don't ignore mouse signals */
2341  GuiData->IgnoreNextMouseSignal = FALSE;
2342 
2343  /* Close button and the corresponding system menu item are enabled by default */
2344  GuiData->IsCloseButtonEnabled = TRUE;
2345 
2346  /* There is no user-reserved menu id range by default */
2347  GuiData->cmdIdLow = GuiData->cmdIdHigh = 0;
2348 
2349  /*
2350  * We need to wait until the GUI has been fully initialized
2351  * to retrieve custom settings i.e. WindowSize etc...
2352  * Ideally we could use SendNotifyMessage for this but its not
2353  * yet implemented.
2354  */
2355  GuiData->hGuiInitEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
2356 
2357  DPRINT("GUI - Checkpoint\n");
2358 
2359  /* Create the terminal window */
2361 
2362  /* Wait until initialization has finished */
2364  DPRINT("OK we created the console window\n");
2365  CloseHandle(GuiData->hGuiInitEvent);
2366  GuiData->hGuiInitEvent = NULL;
2367 
2368  /* Check whether we really succeeded in initializing the terminal window */
2369  if (GuiData->hWindow == NULL)
2370  {
2371  DPRINT("GuiInitConsole - We failed at creating a new terminal window\n");
2373  return STATUS_UNSUCCESSFUL;
2374  }
2375 
2376  /* Finally, finish to initialize the frontend structure */
2377  This->Data = GuiData;
2378  if (This->OldData) ConsoleFreeHeap(This->OldData);
2379  This->OldData = NULL;
2380 
2381  return STATUS_SUCCESS;
2382 }
HICON ghDefaultIcon
Definition: conwnd.c:62
#define STARTF_RUNFULLSCREEN
Definition: winbase.h:477
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define LF_FACESIZE
Definition: dimm.idl:39
INT MouseCursorRefCount
Definition: conwnd.h:71
HANDLE hGuiInitEvent
Definition: conwnd.h:44
BOOL IsCloseButtonEnabled
Definition: conwnd.h:77
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135