ReactOS  0.4.15-dev-4616-g17e0e44
conwnd.c File Reference
#include <consrv.h>
#include <intrin.h>
#include <windowsx.h>
#include <shellapi.h>
#include <debug.h>
#include "concfg/font.h"
#include "guiterm.h"
#include "resource.h"
Include dependency graph for conwnd.c:

Go to the source code of this file.

Classes

struct  _GUICONSOLE_MENUITEM
 

Macros

#define NDEBUG
 
#define CONGUI_MIN_WIDTH   10
 
#define CONGUI_MIN_HEIGHT   10
 
#define CONGUI_UPDATE_TIME   0
 
#define CONGUI_UPDATE_TIMER   1
 
#define CURSOR_BLINK_TIME   500
 
#define GWLP_CONWND_ALLOC   (2 * sizeof(LONG_PTR))
 
#define GWLP_CONSOLE_LEADER_PID   0
 
#define GWLP_CONSOLE_LEADER_TID   4
 
#define IS_WORD_SEP(c)   ((c) == L'\0' || (c) == L' ' || (c) == L'\t' || (c) == L'\r' || (c) == L'\n')
 

Typedefs

typedef struct _GUICONSOLE_MENUITEM GUICONSOLE_MENUITEM
 
typedef struct _GUICONSOLE_MENUITEMPGUICONSOLE_MENUITEM
 

Functions

VOID SetConWndConsoleLeaderCID (IN PGUI_CONSOLE_DATA GuiData)
 
static LRESULT CALLBACK ConWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
BOOLEAN RegisterConWndClass (IN HINSTANCE hInstance)
 
BOOLEAN UnRegisterConWndClass (HINSTANCE hInstance)
 
static VOID AppendMenuItems (HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
 
VOID CreateSysMenu (HWND hWnd)
 
static VOID SendMenuEvent (PCONSRV_CONSOLE Console, UINT CmdId)
 
static VOID Copy (PGUI_CONSOLE_DATA GuiData)
 
static VOID Paste (PGUI_CONSOLE_DATA GuiData)
 
static VOID UpdateSelection (PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
 
static VOID Mark (PGUI_CONSOLE_DATA GuiData)
 
static VOID SelectAll (PGUI_CONSOLE_DATA GuiData)
 
static LRESULT OnCommand (PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
 
static PGUI_CONSOLE_DATA GuiGetGuiData (HWND hWnd)
 
static VOID ResizeConWnd (PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
 
VOID DeleteFonts (PGUI_CONSOLE_DATA GuiData)
 
static HFONT CreateDerivedFont (HFONT OrgFont, ULONG FontWeight, BOOLEAN bUnderline, BOOLEAN bStrikeOut)
 
BOOL InitFonts (_Inout_ PGUI_CONSOLE_DATA GuiData, _In_reads_or_z_(LF_FACESIZE) PCWSTR FaceName, _In_ ULONG FontWeight, _In_ ULONG FontFamily, _In_ COORD FontSize, _In_opt_ UINT CodePage, _In_ BOOL UseDefaultFallback)
 
static BOOL OnNcCreate (HWND hWnd, LPCREATESTRUCTW Create)
 
static VOID OnActivate (PGUI_CONSOLE_DATA GuiData, WPARAM wParam)
 
static VOID OnFocus (PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
 
VOID GetSelectionBeginEnd (PCOORD Begin, PCOORD End, PCOORD SelectionAnchor, PSMALL_RECT SmallRect)
 
static HRGN CreateSelectionRgn (PGUI_CONSOLE_DATA GuiData, BOOL LineSelection, PCOORD SelectionAnchor, PSMALL_RECT SmallRect)
 
static VOID PaintSelectionRect (PGUI_CONSOLE_DATA GuiData, PPAINTSTRUCT pps)
 
static VOID OnPaint (PGUI_CONSOLE_DATA GuiData)
 
static VOID OnPaletteChanged (PGUI_CONSOLE_DATA GuiData)
 
static BOOL IsSystemKey (WORD VirtualKeyCode)
 
static VOID OnKey (PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
 
VOID InvalidateCell (PGUI_CONSOLE_DATA GuiData, SHORT x, SHORT y)
 
static VOID OnTimer (PGUI_CONSOLE_DATA GuiData)
 
static BOOL OnClose (PGUI_CONSOLE_DATA GuiData)
 
static LRESULT OnNcDestroy (HWND hWnd)
 
static VOID OnScroll (PGUI_CONSOLE_DATA GuiData, INT nBar, WORD sbCode)
 
static COORD PointToCoord (PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
 
static LRESULT OnMouse (PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
 
static VOID OnGetMinMaxInfo (PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
 
static VOID OnSize (PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
 
static VOID OnMove (PGUI_CONSOLE_DATA GuiData)
 
static VOID OnDropFiles (PCONSRV_CONSOLE Console, HDROP hDrop)
 
HBITMAP CreateFrameBufferBitmap (HDC hDC, int width, int height)
 

Variables

HICON ghDefaultIcon = NULL
 
HICON ghDefaultIconSm = NULL
 
HCURSOR ghDefaultCursor = NULL
 
static const GUICONSOLE_MENUITEM GuiConsoleEditMenuItems []
 
static const GUICONSOLE_MENUITEM GuiConsoleMainMenuItems []
 
const COLORREF s_Colors [16]
 

Macro Definition Documentation

◆ CONGUI_MIN_HEIGHT

#define CONGUI_MIN_HEIGHT   10

Definition at line 34 of file conwnd.c.

◆ CONGUI_MIN_WIDTH

#define CONGUI_MIN_WIDTH   10

Definition at line 33 of file conwnd.c.

◆ CONGUI_UPDATE_TIME

#define CONGUI_UPDATE_TIME   0

Definition at line 35 of file conwnd.c.

◆ CONGUI_UPDATE_TIMER

#define CONGUI_UPDATE_TIMER   1

Definition at line 36 of file conwnd.c.

◆ CURSOR_BLINK_TIME

#define CURSOR_BLINK_TIME   500

Definition at line 38 of file conwnd.c.

◆ GWLP_CONSOLE_LEADER_PID

#define GWLP_CONSOLE_LEADER_PID   0

Definition at line 44 of file conwnd.c.

◆ GWLP_CONSOLE_LEADER_TID

#define GWLP_CONSOLE_LEADER_TID   4

Definition at line 45 of file conwnd.c.

◆ GWLP_CONWND_ALLOC

#define GWLP_CONWND_ALLOC   (2 * sizeof(LONG_PTR))

Definition at line 43 of file conwnd.c.

◆ IS_WORD_SEP

#define IS_WORD_SEP (   c)    ((c) == L'\0' || (c) == L' ' || (c) == L'\t' || (c) == L'\r' || (c) == L'\n')

◆ NDEBUG

#define NDEBUG

Definition at line 20 of file conwnd.c.

Typedef Documentation

◆ GUICONSOLE_MENUITEM

◆ PGUICONSOLE_MENUITEM

Function Documentation

◆ AppendMenuItems()

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

Definition at line 188 of file conwnd.c.

190 {
191  UINT i = 0;
192  WCHAR szMenuString[255];
193  HMENU hSubMenu;
194 
195  do
196  {
197  if (Items[i].uID != (UINT)-1)
198  {
200  Items[i].uID,
201  szMenuString,
202  ARRAYSIZE(szMenuString)) > 0)
203  {
204  if (Items[i].SubMenu != NULL)
205  {
206  hSubMenu = CreatePopupMenu();
207  if (hSubMenu != NULL)
208  {
209  AppendMenuItems(hSubMenu, Items[i].SubMenu);
210 
211  if (!AppendMenuW(hMenu,
213  (UINT_PTR)hSubMenu,
214  szMenuString))
215  {
216  DestroyMenu(hSubMenu);
217  }
218  }
219  }
220  else
221  {
222  AppendMenuW(hMenu,
223  MF_STRING,
224  Items[i].wCmdID,
225  szMenuString);
226  }
227  }
228  }
229  else
230  {
231  AppendMenuW(hMenu,
232  MF_SEPARATOR,
233  0,
234  NULL);
235  }
236  i++;
237  } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].wCmdID == 0));
238 }
#define MF_STRING
Definition: winuser.h:138
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
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)
#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)
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
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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
static VOID AppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: conwnd.c:188

Referenced by ConWndProc(), and CreateSysMenu().

◆ ConWndProc()

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

Definition at line 2250 of file conwnd.c.

2251 {
2252  LRESULT Result = 0;
2253  PGUI_CONSOLE_DATA GuiData = NULL;
2255 
2256  /*
2257  * - If it's the first time we create a window for the terminal,
2258  * just initialize it and return.
2259  *
2260  * - If we are destroying the window, just do it and return.
2261  */
2262  if (msg == WM_NCCREATE)
2263  {
2265  }
2266  else if (msg == WM_NCDESTROY)
2267  {
2268  return OnNcDestroy(hWnd);
2269  }
2270 
2271  /*
2272  * Now the terminal window is initialized.
2273  * Get the terminal data via the window's data.
2274  * If there is no data, just go away.
2275  */
2276  GuiData = GuiGetGuiData(hWnd);
2277  if (GuiData == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
2278 
2279  // TEMPORARY HACK until all of the functions can deal with a NULL GuiData->ActiveBuffer ...
2280  if (GuiData->ActiveBuffer == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
2281 
2282  /*
2283  * Just retrieve a pointer to the console in case somebody needs it.
2284  * It is not NULL because it was checked in GuiGetGuiData.
2285  * Each helper function which needs the console has to validate and lock it.
2286  */
2287  Console = GuiData->Console;
2288 
2289  /* We have a console, start message dispatching */
2290  switch (msg)
2291  {
2292  case WM_ACTIVATE:
2293  OnActivate(GuiData, wParam);
2294  break;
2295 
2296  case WM_CLOSE:
2297  if (OnClose(GuiData)) goto Default;
2298  break;
2299 
2300  case WM_ERASEBKGND:
2301  return TRUE;
2302 
2303  case WM_PAINT:
2304  OnPaint(GuiData);
2305  break;
2306 
2307  case WM_TIMER:
2308  OnTimer(GuiData);
2309  break;
2310 
2311  case WM_PALETTECHANGED:
2312  {
2313  DPRINT("WM_PALETTECHANGED called\n");
2314 
2315  /*
2316  * Protects against infinite loops:
2317  * "... A window that receives this message must not realize
2318  * its palette, unless it determines that wParam does not contain
2319  * its own window handle." (WM_PALETTECHANGED description - MSDN)
2320  *
2321  * This message is sent to all windows, including the one that
2322  * changed the system palette and caused this message to be sent.
2323  * The wParam of this message contains the handle of the window
2324  * that caused the system palette to change. To avoid an infinite
2325  * loop, care must be taken to check that the wParam of this message
2326  * does not match the window's handle.
2327  */
2328  if ((HWND)wParam == hWnd) break;
2329 
2330  DPRINT("WM_PALETTECHANGED ok\n");
2331  OnPaletteChanged(GuiData);
2332  DPRINT("WM_PALETTECHANGED quit\n");
2333  break;
2334  }
2335 
2336  case WM_KEYDOWN:
2337  case WM_KEYUP:
2338  case WM_CHAR:
2339  case WM_DEADCHAR:
2340  case WM_SYSKEYDOWN:
2341  case WM_SYSKEYUP:
2342  case WM_SYSCHAR:
2343  case WM_SYSDEADCHAR:
2344  {
2345  /* Detect Alt-Enter presses and switch back and forth to fullscreen mode */
2346  if (msg == WM_SYSKEYDOWN && (HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN)
2347  {
2348  /* Switch only at first Alt-Enter press, and ignore subsequent key repetitions */
2349  if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) != KF_REPEAT)
2350  GuiConsoleSwitchFullScreen(GuiData);
2351 
2352  break;
2353  }
2354  /* Detect Alt-Esc/Space/Tab presses defer to DefWindowProc */
2355  if ( (HIWORD(lParam) & KF_ALTDOWN) && (wParam == VK_ESCAPE || wParam == VK_SPACE || wParam == VK_TAB))
2356  {
2357  return DefWindowProcW(hWnd, msg, wParam, lParam);
2358  }
2359 
2360  OnKey(GuiData, msg, wParam, lParam);
2361  break;
2362  }
2363 
2364  case WM_SETCURSOR:
2365  {
2366  /* Do nothing if the window is hidden */
2367  if (!GuiData->IsWindowVisible) goto Default;
2368 
2369  /*
2370  * The message was sent because we are manually triggering a change.
2371  * Check whether the mouse is indeed present on this console window
2372  * and take appropriate decisions.
2373  */
2374  if (wParam == -1 && lParam == -1)
2375  {
2376  POINT mouseCoords;
2377  HWND hWndHit;
2378 
2379  /* Get the placement of the mouse */
2380  GetCursorPos(&mouseCoords);
2381 
2382  /* On which window is placed the mouse ? */
2383  hWndHit = WindowFromPoint(mouseCoords);
2384 
2385  /* It's our window. Perform the hit-test to be used later on. */
2386  if (hWndHit == hWnd)
2387  {
2388  wParam = (WPARAM)hWnd;
2389  lParam = DefWindowProcW(hWndHit, WM_NCHITTEST, 0,
2390  MAKELPARAM(mouseCoords.x, mouseCoords.y));
2391  }
2392  }
2393 
2394  /* Set the mouse cursor only when we are in the client area */
2395  if ((HWND)wParam == hWnd && LOWORD(lParam) == HTCLIENT)
2396  {
2397  if (GuiData->MouseCursorRefCount >= 0)
2398  {
2399  /* Show the cursor */
2400  SetCursor(GuiData->hCursor);
2401  }
2402  else
2403  {
2404  /* Hide the cursor if the reference count is negative */
2405  SetCursor(NULL);
2406  }
2407  return TRUE;
2408  }
2409  else
2410  {
2411  goto Default;
2412  }
2413  }
2414 
2415  case WM_LBUTTONDOWN:
2416  case WM_MBUTTONDOWN:
2417  case WM_RBUTTONDOWN:
2418  case WM_XBUTTONDOWN:
2419  case WM_LBUTTONUP:
2420  case WM_MBUTTONUP:
2421  case WM_RBUTTONUP:
2422  case WM_XBUTTONUP:
2423  case WM_LBUTTONDBLCLK:
2424  case WM_MBUTTONDBLCLK:
2425  case WM_RBUTTONDBLCLK:
2426  case WM_XBUTTONDBLCLK:
2427  case WM_MOUSEMOVE:
2428  case WM_MOUSEWHEEL:
2429  case WM_MOUSEHWHEEL:
2430  {
2431  Result = OnMouse(GuiData, msg, wParam, lParam);
2432  break;
2433  }
2434 
2435  case WM_HSCROLL:
2436  OnScroll(GuiData, SB_HORZ, LOWORD(wParam));
2437  break;
2438 
2439  case WM_VSCROLL:
2440  OnScroll(GuiData, SB_VERT, LOWORD(wParam));
2441  break;
2442 
2443  case WM_CONTEXTMENU:
2444  {
2445  /* Do nothing if the window is hidden */
2446  if (!GuiData->IsWindowVisible) break;
2447 
2448  if (DefWindowProcW(hWnd /*GuiData->hWindow*/, WM_NCHITTEST, 0, lParam) == HTCLIENT)
2449  {
2450  HMENU hMenu = CreatePopupMenu();
2451  if (hMenu != NULL)
2452  {
2454  TrackPopupMenuEx(hMenu,
2458  hWnd,
2459  NULL);
2460  DestroyMenu(hMenu);
2461  }
2462  break;
2463  }
2464  else
2465  {
2466  goto Default;
2467  }
2468  }
2469 
2470  case WM_INITMENU:
2471  {
2472  HMENU hMenu = (HMENU)wParam;
2473  if (hMenu != NULL)
2474  {
2475  /* Enable or disable the Close menu item */
2477  (GuiData->IsCloseButtonEnabled ? MF_ENABLED : MF_GRAYED));
2478 
2479  /* Enable or disable the Copy and Paste items */
2483  // FIXME: Following whether the active screen buffer is text-mode
2484  // or graphics-mode, search for CF_UNICODETEXT or CF_BITMAP formats.
2488  }
2489 
2491  break;
2492  }
2493 
2494  case WM_MENUSELECT:
2495  {
2496  if (HIWORD(wParam) == 0xFFFF) // Allow all the menu flags
2497  {
2499  }
2500  break;
2501  }
2502 
2503  case WM_COMMAND:
2504  case WM_SYSCOMMAND:
2505  {
2506  Result = OnCommand(GuiData, wParam, lParam);
2507  break;
2508  }
2509 
2510  case WM_DROPFILES:
2511  OnDropFiles(Console, (HDROP)wParam);
2512  break;
2513 
2514  case WM_SETFOCUS:
2515  case WM_KILLFOCUS:
2516  OnFocus(GuiData, (msg == WM_SETFOCUS));
2517  break;
2518 
2519  case WM_GETMINMAXINFO:
2520  OnGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam);
2521  break;
2522 
2523  case WM_MOVE:
2524  OnMove(GuiData);
2525  break;
2526 
2527 #if 0 // This code is here to prepare & control dynamic console SB resizing.
2528  case WM_SIZING:
2529  {
2530  PRECT dragRect = (PRECT)lParam;
2531  switch (wParam)
2532  {
2533  case WMSZ_LEFT:
2534  DPRINT1("WMSZ_LEFT\n");
2535  break;
2536  case WMSZ_RIGHT:
2537  DPRINT1("WMSZ_RIGHT\n");
2538  break;
2539  case WMSZ_TOP:
2540  DPRINT1("WMSZ_TOP\n");
2541  break;
2542  case WMSZ_TOPLEFT:
2543  DPRINT1("WMSZ_TOPLEFT\n");
2544  break;
2545  case WMSZ_TOPRIGHT:
2546  DPRINT1("WMSZ_TOPRIGHT\n");
2547  break;
2548  case WMSZ_BOTTOM:
2549  DPRINT1("WMSZ_BOTTOM\n");
2550  break;
2551  case WMSZ_BOTTOMLEFT:
2552  DPRINT1("WMSZ_BOTTOMLEFT\n");
2553  break;
2554  case WMSZ_BOTTOMRIGHT:
2555  DPRINT1("WMSZ_BOTTOMRIGHT\n");
2556  break;
2557  default:
2558  DPRINT1("wParam = %d\n", wParam);
2559  break;
2560  }
2561  DPRINT1("dragRect = {.left = %d ; .top = %d ; .right = %d ; .bottom = %d}\n",
2562  dragRect->left, dragRect->top, dragRect->right, dragRect->bottom);
2563  break;
2564  }
2565 #endif
2566 
2567  case WM_SIZE:
2568  OnSize(GuiData, wParam, lParam);
2569  break;
2570 
2571  case PM_RESIZE_TERMINAL:
2572  {
2573  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
2574  HDC hDC;
2575  HBITMAP hnew, hold;
2576 
2577  DWORD Width, Height;
2578  UINT WidthUnit, HeightUnit;
2579 
2580  /* Do nothing if the window is hidden */
2581  if (!GuiData->IsWindowVisible) break;
2582 
2583  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
2584 
2585  Width = Buff->ScreenBufferSize.X * WidthUnit ;
2586  Height = Buff->ScreenBufferSize.Y * HeightUnit;
2587 
2588  /* Recreate the framebuffer */
2589  hDC = GetDC(GuiData->hWindow);
2591  ReleaseDC(GuiData->hWindow, hDC);
2592  hold = SelectObject(GuiData->hMemDC, hnew);
2593  if (GuiData->hBitmap)
2594  {
2595  if (hold == GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
2596  }
2597  GuiData->hBitmap = hnew;
2598 
2599  /* Resize the window to the user's values */
2600  GuiData->WindowSizeLock = TRUE;
2601  ResizeConWnd(GuiData, WidthUnit, HeightUnit);
2602  GuiData->WindowSizeLock = FALSE;
2603  break;
2604  }
2605 
2606  /*
2607  * Undocumented message sent by Windows' console.dll for applying console info.
2608  * See http://www.catch22.net/sites/default/source/files/setconsoleinfo.c
2609  * and http://www.scn.rain.com/~neighorn/PDF/MSBugPaper.pdf
2610  * for more information.
2611  */
2612  case WM_SETCONSOLEINFO:
2613  {
2614  GuiApplyUserSettings(GuiData, (HANDLE)wParam);
2615  break;
2616  }
2617 
2618  case PM_CONSOLE_BEEP:
2619  DPRINT1("Beep\n");
2620  Beep(800, 200);
2621  break;
2622 
2623  case PM_CONSOLE_SET_TITLE:
2624  SetWindowTextW(GuiData->hWindow, GuiData->Console->Title.Buffer);
2625  break;
2626 
2627  default: Default:
2629  break;
2630  }
2631 
2632  return Result;
2633 }
#define WM_MBUTTONUP
Definition: winuser.h:1770
static VOID OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
Definition: conwnd.c:759
#define WMSZ_BOTTOMRIGHT
Definition: winuser.h:2451
static VOID OnSize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:2104
static PGUI_CONSOLE_DATA GuiGetGuiData(HWND hWnd)
Definition: conwnd.c:420
INT MouseCursorRefCount
Definition: conwnd.h:71
BOOL IsCloseButtonEnabled
Definition: conwnd.h:77
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
long y
Definition: polytest.cpp:48
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_CHAR
Definition: winuser.h:1704
#define WM_LBUTTONDOWN
Definition: winuser.h:1763
long x
Definition: polytest.cpp:48
HDC WINAPI GetDC(_In_opt_ HWND)
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:124
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define PM_CONSOLE_BEEP
Definition: conwnd.h:21
#define SB_HORZ
Definition: winuser.h:552
#define MAKELPARAM(l, h)
Definition: winuser.h:3988
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
static HDC
Definition: imagelist.c:92
#define ID_SYSTEM_EDIT_COPY
Definition: resource.h:13
HWND hWnd
Definition: settings.c:17
static VOID ResizeConWnd(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
Definition: conwnd.c:428
LONG top
Definition: windef.h:307
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static LRESULT OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:356
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
static VOID OnMove(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:2170
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define WM_MOVE
Definition: winuser.h:1597
#define WMSZ_TOP
Definition: winuser.h:2446
#define KF_UP
Definition: winuser.h:2431
#define WM_NCHITTEST
Definition: winuser.h:1673
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
#define VK_TAB
Definition: winuser.h:2179
_In_ HFONT _Out_ PUINT Height
Definition: font.h:124
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
#define PM_RESIZE_TERMINAL
Definition: conwnd.h:20
LONG left
Definition: windef.h:306
#define VK_ESCAPE
Definition: winuser.h:2194
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2639
static VOID OnTimer(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1310
LONG right
Definition: windef.h:308
#define WM_NCCREATE
Definition: winuser.h:1670
#define VK_RETURN
Definition: winuser.h:2181
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WMSZ_TOPLEFT
Definition: winuser.h:2447
static VOID SendMenuEvent(PCONSRV_CONSOLE Console, UINT CmdId)
Definition: conwnd.c:274
static LRESULT OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:1600
BOOL WindowSizeLock
Definition: conwnd.h:43
#define TPM_RIGHTBUTTON
Definition: winuser.h:2360
UNICODE_STRING Title
Definition: conio_winsrv.h:178
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HBITMAP CreateFrameBufferBitmap(HDC hDC, int width, int height)
Definition: conwnd.c:2236
#define FALSE
Definition: types.h:117
COORD ScreenBufferSize
Definition: conio.h:62
#define WM_SETCURSOR
Definition: winuser.h:1623
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_MENUSELECT
Definition: winuser.h:1734
#define WM_DROPFILES
Definition: winuser.h:1812
#define WM_SYSCHAR
Definition: winuser.h:1708
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
static VOID OnActivate(PGUI_CONSOLE_DATA GuiData, WPARAM wParam)
Definition: conwnd.c:722
#define WM_SIZING
Definition: winuser.h:1794
#define CF_UNICODETEXT
Definition: constants.h:408
_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:1702
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:104
static VOID OnScroll(PGUI_CONSOLE_DATA GuiData, INT nBar, WORD sbCode)
Definition: conwnd.c:1466
#define WM_RBUTTONDOWN
Definition: winuser.h:1766
ULONG X
Definition: bl.h:1339
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
#define KF_REPEAT
Definition: winuser.h:2430
#define WM_DEADCHAR
Definition: winuser.h:1705
static VOID OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:1145
static BOOL OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
Definition: conwnd.c:630
#define WM_KILLFOCUS
Definition: winuser.h:1601
#define WM_SIZE
Definition: winuser.h:1598
#define WM_TIMER
Definition: winuser.h:1729
#define MF_ENABLED
Definition: winuser.h:128
#define WMSZ_RIGHT
Definition: winuser.h:2445
#define WM_CLOSE
Definition: winuser.h:1608
#define WM_NCDESTROY
Definition: winuser.h:1671
#define WM_PALETTECHANGED
Definition: winuser.h:1864
#define WM_KEYUP
Definition: winuser.h:1703
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_RBUTTONUP
Definition: winuser.h:1767
#define WM_PAINT
Definition: winuser.h:1607
VOID GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:175
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1765
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1771
#define WM_COMMAND
Definition: winuser.h:1727
static VOID OnPaint(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1043
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:103
#define WMSZ_BOTTOM
Definition: winuser.h:2449
BOOL WINAPI DestroyMenu(_In_ HMENU)
static VOID OnDropFiles(PCONSRV_CONSOLE Console, HDROP hDrop)
Definition: conwnd.c:2184
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.h:22
#define WM_INITMENU
Definition: winuser.h:1732
#define WM_ACTIVATE
Definition: winuser.h:1599
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_SYSDEADCHAR
Definition: winuser.h:1709
#define WM_SYSKEYUP
Definition: winuser.h:1707
#define WM_LBUTTONUP
Definition: winuser.h:1764
static VOID OnPaletteChanged(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1098
#define WM_MBUTTONDOWN
Definition: winuser.h:1769
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1762
#define NULL
Definition: types.h:112
#define WM_HSCROLL
Definition: winuser.h:1730
#define VK_SPACE
Definition: winuser.h:2199
HWND WINAPI WindowFromPoint(_In_ POINT)
static VOID OnGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
Definition: conwnd.c:2072
#define KF_ALTDOWN
Definition: winuser.h:2429
HCURSOR hCursor
Definition: conwnd.h:70
CConsole Console
#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:2572
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1768
#define WM_SYSKEYDOWN
Definition: winuser.h:1706
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define HIWORD(l)
Definition: typedefs.h:247
LONG bottom
Definition: windef.h:309
#define PM_CONSOLE_SET_TITLE
Definition: conwnd.h:22
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
struct tagRECT * PRECT
static HBITMAP
Definition: button.c:44
static const GUICONSOLE_MENUITEM GuiConsoleEditMenuItems[]
Definition: conwnd.c:84
HBITMAP hBitmap
Definition: conwnd.h:63
#define WM_ERASEBKGND
Definition: winuser.h:1612
#define WM_SETFOCUS
Definition: winuser.h:1600
#define MF_GRAYED
Definition: winuser.h:129
#define HTCLIENT
Definition: winuser.h:2455
#define DPRINT
Definition: sndvol32.h:71
LONG_PTR LRESULT
Definition: windef.h:209
ULONG Y
Definition: bl.h:1340
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:1728
VOID GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData, HANDLE hClientSection)
Definition: guisettings.c:258
LPARAM lParam
Definition: combotst.c:139
#define WM_GETMINMAXINFO
Definition: winuser.h:1627
#define LOWORD(l)
Definition: pedump.c:82
static VOID AppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: conwnd.c:188
#define WMSZ_LEFT
Definition: winuser.h:2444
#define WMSZ_TOPRIGHT
Definition: winuser.h:2448
#define WMSZ_BOTTOMLEFT
Definition: winuser.h:2450
static LRESULT OnNcDestroy(HWND hWnd)
Definition: conwnd.c:1440
#define WM_VSCROLL
Definition: winuser.h:1731
#define WM_SETCONSOLEINFO
Definition: settings.h:21
static BOOL OnClose(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1419

Referenced by RegisterConWndClass().

◆ Copy()

static VOID Copy ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 2029 of file conwnd.c.

2030 {
2031  if (OpenClipboard(GuiData->hWindow))
2032  {
2034 
2035  if (GetType(Buffer) == TEXTMODE_BUFFER)
2036  {
2038  }
2039  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
2040  {
2042  }
2043 
2044  CloseClipboard();
2045  }
2046 
2047  /* Clear the selection */
2048  UpdateSelection(GuiData, NULL, NULL);
2049 }
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:920
VOID GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: graphics.c:21
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
Definition: bufpool.h:45
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
#define GetType(This)
Definition: conio.h:54
#define NULL
Definition: types.h:112
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
VOID GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: text.c:306

Referenced by OnCommand(), OnKey(), and OnMouse().

◆ CreateDerivedFont()

static HFONT CreateDerivedFont ( HFONT  OrgFont,
ULONG  FontWeight,
BOOLEAN  bUnderline,
BOOLEAN  bStrikeOut 
)
static

Definition at line 492 of file conwnd.c.

498 {
499  LOGFONTW lf;
500 
501  /* Initialize the LOGFONT structure */
502  RtlZeroMemory(&lf, sizeof(lf));
503 
504  /* Retrieve the details of the current font */
505  if (GetObjectW(OrgFont, sizeof(lf), &lf) == 0)
506  return NULL;
507 
508  /* Change the font attributes */
509  // lf.lfHeight = FontSize.Y;
510  // lf.lfWidth = FontSize.X;
511  lf.lfWeight = FontWeight;
512  // lf.lfItalic = bItalic;
513  lf.lfUnderline = bUnderline;
514  lf.lfStrikeOut = bStrikeOut;
515 
516  /* Build a new font */
517  return CreateFontIndirectW(&lf);
518 }
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BYTE lfStrikeOut
Definition: dimm.idl:66
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
LONG lfWeight
Definition: dimm.idl:63
BYTE lfUnderline
Definition: dimm.idl:65

Referenced by InitFonts().

◆ CreateFrameBufferBitmap()

HBITMAP CreateFrameBufferBitmap ( HDC  hDC,
int  width,
int  height 
)

Definition at line 2236 of file conwnd.c.

2237 {
2238  BITMAPINFO bmi;
2239  ZeroMemory(&bmi, sizeof(BITMAPINFO));
2240  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
2241  bmi.bmiHeader.biWidth = width;
2242  bmi.bmiHeader.biHeight = height;
2243  bmi.bmiHeader.biPlanes = 1;
2246  return CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
2247 }
#define BITSPIXEL
Definition: wingdi.h:720
GLint GLint GLsizei width
Definition: gl.h:1546
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
#define ZeroMemory
Definition: winbase.h:1667
DWORD biCompression
Definition: amvideo.idl:35
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
static HDC hDC
Definition: 3dtext.c:33
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
#define NULL
Definition: types.h:112
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define BI_RGB
Definition: precomp.h:47

Referenced by ConWndProc().

◆ CreateSelectionRgn()

static HRGN CreateSelectionRgn ( PGUI_CONSOLE_DATA  GuiData,
BOOL  LineSelection,
PCOORD  SelectionAnchor,
PSMALL_RECT  SmallRect 
)
static

Definition at line 810 of file conwnd.c.

814 {
815  if (!LineSelection)
816  {
817  RECT rect;
818  SmallRectToRect(GuiData, &rect, SmallRect);
819  return CreateRectRgnIndirect(&rect);
820  }
821  else
822  {
823  HRGN SelRgn;
824  COORD Begin, End;
825 
826  GetSelectionBeginEnd(&Begin, &End, SelectionAnchor, SmallRect);
827 
828  if (Begin.Y == End.Y)
829  {
830  SMALL_RECT sr;
831  RECT r ;
832 
833  sr.Left = Begin.X;
834  sr.Top = Begin.Y;
835  sr.Right = End.X;
836  sr.Bottom = End.Y;
837 
838  // Debug thingie to see whether I can put this corner case
839  // together with the previous one.
840  if (SmallRect->Left != sr.Left ||
841  SmallRect->Top != sr.Top ||
842  SmallRect->Right != sr.Right ||
843  SmallRect->Bottom != sr.Bottom)
844  {
845  DPRINT1("\n"
846  "SmallRect = (%d, %d, %d, %d)\n"
847  "sr = (%d, %d, %d, %d)\n"
848  "\n",
849  SmallRect->Left, SmallRect->Top, SmallRect->Right, SmallRect->Bottom,
850  sr.Left, sr.Top, sr.Right, sr.Bottom);
851  }
852 
853  SmallRectToRect(GuiData, &r, &sr);
854  SelRgn = CreateRectRgnIndirect(&r);
855  }
856  else
857  {
858  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
859 
860  HRGN rg1, rg2, rg3;
861  SMALL_RECT sr1, sr2, sr3;
862  RECT r1 , r2 , r3 ;
863 
864  sr1.Left = Begin.X;
865  sr1.Top = Begin.Y;
866  sr1.Right = ActiveBuffer->ScreenBufferSize.X - 1;
867  sr1.Bottom = Begin.Y;
868 
869  sr2.Left = 0;
870  sr2.Top = Begin.Y + 1;
871  sr2.Right = ActiveBuffer->ScreenBufferSize.X - 1;
872  sr2.Bottom = End.Y - 1;
873 
874  sr3.Left = 0;
875  sr3.Top = End.Y;
876  sr3.Right = End.X;
877  sr3.Bottom = End.Y;
878 
879  SmallRectToRect(GuiData, &r1, &sr1);
880  SmallRectToRect(GuiData, &r2, &sr2);
881  SmallRectToRect(GuiData, &r3, &sr3);
882 
883  rg1 = CreateRectRgnIndirect(&r1);
884  rg2 = CreateRectRgnIndirect(&r2);
885  rg3 = CreateRectRgnIndirect(&r3);
886 
887  CombineRgn(rg1, rg1, rg2, RGN_XOR);
888  CombineRgn(rg1, rg1, rg3, RGN_XOR);
889  DeleteObject(rg3);
890  DeleteObject(rg2);
891 
892  SelRgn = rg1;
893  }
894 
895  return SelRgn;
896  }
897 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
static DNS_RECORDW r3
Definition: record.c:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
static DNS_RECORDW r1
Definition: record.c:37
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
VOID GetSelectionBeginEnd(PCOORD Begin, PCOORD End, PCOORD SelectionAnchor, PSMALL_RECT SmallRect)
Definition: conwnd.c:789
& rect
Definition: startmenu.cpp:1413
SHORT Right
Definition: wincon.h:193
SHORT Left
Definition: wincon.h:191
COORD ScreenBufferSize
Definition: conio.h:62
#define RGN_XOR
Definition: wingdi.h:360
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
SHORT Left
Definition: blue.h:32
ULONG X
Definition: bl.h:1339
SHORT Bottom
Definition: blue.h:35
static DNS_RECORDW r2
Definition: record.c:38
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: wincon.h:194
Definition: bl.h:1337
SHORT Top
Definition: wincon.h:192
#define DPRINT1
Definition: precomp.h:8
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN Begin
Definition: acpixf.h:1297
SHORT Right
Definition: blue.h:34
ULONG Y
Definition: bl.h:1340
FORCEINLINE VOID SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
Definition: guiterm.h:43

Referenced by PaintSelectionRect(), and UpdateSelection().

◆ CreateSysMenu()

VOID CreateSysMenu ( HWND  hWnd)

Definition at line 242 of file conwnd.c.

243 {
244  MENUITEMINFOW mii;
245  HMENU hMenu;
246  PWCHAR ptrTab;
247  WCHAR szMenuStringBack[255];
248 
249  hMenu = GetSystemMenu(hWnd, FALSE);
250  if (hMenu == NULL)
251  return;
252 
253  mii.cbSize = sizeof(mii);
254  mii.fMask = MIIM_STRING;
255  mii.dwTypeData = szMenuStringBack;
256  mii.cch = ARRAYSIZE(szMenuStringBack);
257 
258  GetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
259 
260  ptrTab = wcschr(szMenuStringBack, L'\t');
261  if (ptrTab)
262  {
263  *ptrTab = L'\0';
264  mii.cch = (UINT)wcslen(szMenuStringBack);
265 
266  SetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
267  }
268 
270  DrawMenuBar(hWnd);
271 }
BOOL WINAPI DrawMenuBar(_In_ HWND)
HWND hWnd
Definition: settings.c:17
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LPWSTR dwTypeData
Definition: winuser.h:3249
uint16_t * PWCHAR
Definition: typedefs.h:56
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const GUICONSOLE_MENUITEM GuiConsoleMainMenuItems[]
Definition: conwnd.c:96
#define MIIM_STRING
Definition: winuser.h:722
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SC_CLOSE
Definition: winuser.h:2572
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
static VOID AppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: conwnd.c:188

Referenced by GuiConsoleInputThread().

◆ DeleteFonts()

VOID DeleteFonts ( PGUI_CONSOLE_DATA  GuiData)

Definition at line 481 of file conwnd.c.

482 {
483  ULONG i;
484  for (i = 0; i < ARRAYSIZE(GuiData->Font); ++i)
485  {
486  if (GuiData->Font[i] != NULL) DeleteObject(GuiData->Font[i]);
487  GuiData->Font[i] = NULL;
488  }
489 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
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
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
HFONT Font[FONT_MAXNO]
Definition: conwnd.h:85

Referenced by InitFonts(), and OnNcDestroy().

◆ GetSelectionBeginEnd()

VOID GetSelectionBeginEnd ( PCOORD  Begin,
PCOORD  End,
PCOORD  SelectionAnchor,
PSMALL_RECT  SmallRect 
)

Definition at line 789 of file conwnd.c.

792 {
793  if (Begin == NULL || End == NULL) return;
794 
795  *Begin = *SelectionAnchor;
796  End->X = (SelectionAnchor->X == SmallRect->Left) ? SmallRect->Right
797  /* Case X != Left, must be == Right */ : SmallRect->Left;
798  End->Y = (SelectionAnchor->Y == SmallRect->Top ) ? SmallRect->Bottom
799  /* Case Y != Top, must be == Bottom */ : SmallRect->Top;
800 
801  /* Exchange Begin / End if Begin > End lexicographically */
802  if (Begin->Y > End->Y || (Begin->Y == End->Y && Begin->X > End->X))
803  {
804  End->X = _InterlockedExchange16(&Begin->X, End->X);
805  End->Y = _InterlockedExchange16(&Begin->Y, End->Y);
806  }
807 }
SHORT Right
Definition: wincon.h:193
SHORT Left
Definition: wincon.h:191
short _InterlockedExchange16(_Interlocked_operand_ short volatile *_Target, short _Value)
ULONG X
Definition: bl.h:1339
SHORT Bottom
Definition: wincon.h:194
SHORT Top
Definition: wincon.h:192
#define NULL
Definition: types.h:112
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN Begin
Definition: acpixf.h:1297
ULONG Y
Definition: bl.h:1340

Referenced by CreateSelectionRgn(), and GuiCopyFromTextModeBuffer().

◆ GuiGetGuiData()

static PGUI_CONSOLE_DATA GuiGetGuiData ( HWND  hWnd)
static

Definition at line 420 of file conwnd.c.

421 {
422  /* This function ensures that the console pointer is not NULL */
424  return ( ((GuiData == NULL) || (GuiData->hWindow == hWnd && GuiData->Console != NULL)) ? GuiData : NULL );
425 }
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
HWND hWnd
Definition: settings.c:17
#define GetWindowLongPtrW
Definition: winuser.h:4809
#define GWLP_USERDATA
Definition: treelist.c:63
#define NULL
Definition: types.h:112
PCONSRV_CONSOLE Console
Definition: conwnd.h:90

Referenced by ConWndProc(), and OnNcDestroy().

◆ InitFonts()

BOOL InitFonts ( _Inout_ PGUI_CONSOLE_DATA  GuiData,
_In_reads_or_z_(LF_FACESIZE) PCWSTR  FaceName,
_In_ ULONG  FontWeight,
_In_ ULONG  FontFamily,
_In_ COORD  FontSize,
_In_opt_ UINT  CodePage,
_In_ BOOL  UseDefaultFallback 
)

Definition at line 521 of file conwnd.c.

530 {
531  HDC hDC;
532  HFONT hFont;
533  FONT_DATA FontData;
534  UINT OldCharWidth = GuiData->CharWidth;
535  UINT OldCharHeight = GuiData->CharHeight;
536  COORD OldFontSize = GuiData->GuiInfo.FontSize;
537  WCHAR NewFaceName[LF_FACESIZE];
538 
539  /* Default to current code page if none has been provided */
540  if (!CodePage)
541  CodePage = GuiData->Console->OutputCodePage;
542 
543  /*
544  * Initialize a new NORMAL font.
545  */
546 
547  /* Copy the requested face name into the local buffer.
548  * It will be modified in output by CreateConsoleFontEx()
549  * to hold a possible fallback font face name. */
550  StringCchCopyNW(NewFaceName, ARRAYSIZE(NewFaceName),
551  FaceName, LF_FACESIZE);
552 
553  /* NOTE: FontSize is always in cell height/width units (pixels) */
554  hFont = CreateConsoleFontEx((LONG)(ULONG)FontSize.Y,
555  (LONG)(ULONG)FontSize.X,
556  NewFaceName,
557  FontWeight,
558  FontFamily,
559  CodePage,
560  UseDefaultFallback,
561  &FontData);
562  if (!hFont)
563  {
564  DPRINT1("InitFonts: CreateConsoleFontEx('%S') failed\n", NewFaceName);
565  return FALSE;
566  }
567 
568  /* Retrieve its character cell size */
569  hDC = GetDC(GuiData->hWindow);
570  if (!GetFontCellSize(hDC, hFont, &GuiData->CharHeight, &GuiData->CharWidth))
571  {
572  DPRINT1("InitFonts: GetFontCellSize failed\n");
573  ReleaseDC(GuiData->hWindow, hDC);
575  return FALSE;
576  }
577  ReleaseDC(GuiData->hWindow, hDC);
578 
579  /*
580  * Initialization succeeded.
581  */
582  // Delete all the old fonts first.
583  DeleteFonts(GuiData);
584  GuiData->Font[FONT_NORMAL] = hFont;
585 
586  /*
587  * Now build the optional fonts (bold, underlined, mixed).
588  * Do not error in case they fail to be created.
589  */
590  GuiData->Font[FONT_BOLD] =
591  CreateDerivedFont(GuiData->Font[FONT_NORMAL],
592  max(FW_BOLD, FontData.Weight),
593  FALSE,
594  FALSE);
595  GuiData->Font[FONT_UNDERLINE] =
596  CreateDerivedFont(GuiData->Font[FONT_NORMAL],
597  FontData.Weight,
598  TRUE,
599  FALSE);
600  GuiData->Font[FONT_BOLD | FONT_UNDERLINE] =
601  CreateDerivedFont(GuiData->Font[FONT_NORMAL],
602  max(FW_BOLD, FontData.Weight),
603  TRUE,
604  FALSE);
605 
606  /*
607  * Save the new font characteristics.
608  */
609  StringCchCopyNW(GuiData->GuiInfo.FaceName,
610  ARRAYSIZE(GuiData->GuiInfo.FaceName),
611  NewFaceName, ARRAYSIZE(NewFaceName));
612  GuiData->GuiInfo.FontWeight = FontData.Weight;
613  GuiData->GuiInfo.FontFamily = FontData.Family;
614  GuiData->GuiInfo.FontSize = FontData.Size;
615 
616  /* Resize the terminal, in case the new font has a different size */
617  if ((OldCharWidth != GuiData->CharWidth) ||
618  (OldCharHeight != GuiData->CharHeight) ||
619  (OldFontSize.X != FontData.Size.X ||
620  OldFontSize.Y != FontData.Size.Y))
621  {
622  TermResizeTerminal(GuiData->Console);
623  }
624 
625  return TRUE;
626 }
#define max(a, b)
Definition: svc.c:63
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
#define LF_FACESIZE
Definition: dimm.idl:39
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
VOID DeleteFonts(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:481
static HDC
Definition: imagelist.c:92
#define TermResizeTerminal(Console)
Definition: term.h:28
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HFONT hFont
Definition: main.c:53
#define FONT_NORMAL
Definition: conwnd.h:35
#define FALSE
Definition: types.h:117
HFONT CreateConsoleFontEx(_In_ LONG Height, _In_opt_ LONG Width, _Inout_updates_z_(LF_FACESIZE) PWSTR FaceName, _In_ ULONG FontWeight, _In_ ULONG FontFamily, _In_ UINT CodePage, _In_ BOOL UseDefaultFallback, _Out_ PFONT_DATA FontData)
Validates and creates a suitable console font based on the font characteristics given in input.
Definition: font.c:505
long LONG
Definition: pedump.c:60
ULONG Family
Definition: font.h:93
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
COORD Size
Definition: font.h:94
ULONG X
Definition: bl.h:1339
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG Weight
Definition: font.h:92
Definition: bl.h:1337
static HDC hDC
Definition: 3dtext.c:33
#define FW_BOLD
Definition: wingdi.h:378
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
unsigned int ULONG
Definition: retypes.h:1
static HFONT CreateDerivedFont(HFONT OrgFont, ULONG FontWeight, BOOLEAN bUnderline, BOOLEAN bStrikeOut)
Definition: conwnd.c:492
ULONG Y
Definition: bl.h:1340

Referenced by GuiApplyUserSettings(), GuiSetCodePage(), and OnNcCreate().

◆ InvalidateCell()

VOID InvalidateCell ( PGUI_CONSOLE_DATA  GuiData,
SHORT  x,
SHORT  y 
)

Definition at line 88 of file guiterm.c.

90 {
91  SMALL_RECT CellRect = { x, y, x, y };
92  DrawRegion(GuiData, &CellRect);
93 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static VOID DrawRegion(PGUI_CONSOLE_DATA GuiData, SMALL_RECT *Region)
Definition: guiterm.c:76

Referenced by GuiSetCursorInfo(), GuiSetScreenInfo(), GuiWriteStream(), and OnTimer().

◆ IsSystemKey()

static BOOL IsSystemKey ( WORD  VirtualKeyCode)
static

Definition at line 1122 of file conwnd.c.

1123 {
1124  switch (VirtualKeyCode)
1125  {
1126  /* From MSDN, "Virtual-Key Codes" */
1127  case VK_RETURN:
1128  case VK_SHIFT:
1129  case VK_CONTROL:
1130  case VK_MENU:
1131  case VK_PAUSE:
1132  case VK_CAPITAL:
1133  case VK_ESCAPE:
1134  case VK_LWIN:
1135  case VK_RWIN:
1136  case VK_NUMLOCK:
1137  case VK_SCROLL:
1138  return TRUE;
1139  default:
1140  return FALSE;
1141  }
1142 }
#define TRUE
Definition: types.h:120
#define VK_LWIN
Definition: winuser.h:2215
#define VK_MENU
Definition: winuser.h:2184
#define VK_ESCAPE
Definition: winuser.h:2194
#define VK_RETURN
Definition: winuser.h:2181
#define FALSE
Definition: types.h:117
#define VK_SHIFT
Definition: winuser.h:2182
#define VK_RWIN
Definition: winuser.h:2216
#define VK_SCROLL
Definition: winuser.h:2260
#define VK_NUMLOCK
Definition: winuser.h:2259
#define VK_CAPITAL
Definition: winuser.h:2186
#define VK_CONTROL
Definition: winuser.h:2183
#define VK_PAUSE
Definition: winuser.h:2185

Referenced by OnKey().

◆ Mark()

static VOID Mark ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 300 of file conwnd.c.

301 {
302  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
303 
304  /* Clear the old selection */
306 
307  /* Restart a new selection */
308  GuiData->dwSelectionCursor = ActiveBuffer->ViewOrigin;
309  UpdateSelection(GuiData,
310  &GuiData->dwSelectionCursor,
311  &GuiData->dwSelectionCursor);
312 }
COORD dwSelectionCursor
Definition: conwnd.h:93
#define CONSOLE_NO_SELECTION
Definition: wincon.h:102
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:920
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91

Referenced by EmbeddedPointerMarshall(), EmbeddedPointerMemorySize(), EmbeddedPointerUnmarshall(), OnCommand(), and WmipIoControl().

◆ OnActivate()

static VOID OnActivate ( PGUI_CONSOLE_DATA  GuiData,
WPARAM  wParam 
)
static

Definition at line 722 of file conwnd.c.

723 {
724  WORD ActivationState = LOWORD(wParam);
725 
726  DPRINT("WM_ACTIVATE - ActivationState = %d\n", ActivationState);
727 
728  if ( ActivationState == WA_ACTIVE ||
729  ActivationState == WA_CLICKACTIVE )
730  {
731  if (GuiData->GuiInfo.FullScreen)
732  {
733  EnterFullScreen(GuiData);
734  // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
735  // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
736  }
737  }
738  else // if (ActivationState == WA_INACTIVE)
739  {
740  if (GuiData->GuiInfo.FullScreen)
741  {
743  LeaveFullScreen(GuiData);
744  // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
745  // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
746  }
747  }
748 
749  /*
750  * Ignore the next mouse signal when we are going to be enabled again via
751  * the mouse, in order to prevent, e.g. when we are in Edit mode, erroneous
752  * mouse actions from the user that could spoil text selection or copy/pastes.
753  */
754  if (ActivationState == WA_CLICKACTIVE)
755  GuiData->IgnoreNextMouseSignal = TRUE;
756 }
#define TRUE
Definition: types.h:120
VOID LeaveFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:39
BOOL IgnoreNextMouseSignal
Definition: conwnd.h:72
WPARAM wParam
Definition: combotst.c:138
#define WA_ACTIVE
Definition: winuser.h:2603
unsigned short WORD
Definition: ntddk_ex.h:93
#define WA_CLICKACTIVE
Definition: winuser.h:2604
BOOL EnterFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:21
#define SC_MINIMIZE
Definition: winuser.h:2566
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
#define DPRINT
Definition: sndvol32.h:71
#define WM_SYSCOMMAND
Definition: winuser.h:1728
#define LOWORD(l)
Definition: pedump.c:82

Referenced by ConWndProc().

◆ OnClose()

static BOOL OnClose ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1419 of file conwnd.c.

1420 {
1421  PCONSRV_CONSOLE Console = GuiData->Console;
1422 
1424  return TRUE;
1425 
1426  // TODO: Prompt for termination ? (Warn the user about possible apps running in this console)
1427 
1428  /*
1429  * FIXME: Windows will wait up to 5 seconds for the thread to exit.
1430  * We shouldn't wait here, though, since the console lock is entered.
1431  * A copy of the thread list probably needs to be made.
1432  */
1434 
1435  LeaveCriticalSection(&Console->Lock);
1436  return FALSE;
1437 }
#define CTRL_CLOSE_EVENT
Definition: wincon.h:70
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console, IN ULONG ProcessGroupId, IN ULONG CtrlEvent)
Definition: console.c:1402
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by ConWndProc().

◆ OnCommand()

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

Definition at line 356 of file conwnd.c.

357 {
358  LRESULT Ret = TRUE;
359  PCONSRV_CONSOLE Console = GuiData->Console;
360 
361  /*
362  * In case the selected menu item belongs to the user-reserved menu id range,
363  * send to him a menu event and return directly. The user must handle those
364  * reserved menu commands...
365  */
366  if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->CmdIdHigh)
367  {
369  goto Quit;
370  }
371 
372  /* ... otherwise, perform actions. */
373  switch (wParam)
374  {
375  case ID_SYSTEM_EDIT_MARK:
376  Mark(GuiData);
377  break;
378 
379  case ID_SYSTEM_EDIT_COPY:
380  Copy(GuiData);
381  break;
382 
384  Paste(GuiData);
385  break;
386 
388  SelectAll(GuiData);
389  break;
390 
392  DPRINT1("Scrolling is not handled yet\n");
393  break;
394 
395  case ID_SYSTEM_EDIT_FIND:
396  DPRINT1("Finding is not handled yet\n");
397  break;
398 
399  case ID_SYSTEM_DEFAULTS:
401  break;
402 
405  break;
406 
407  default:
408  Ret = FALSE;
409  break;
410  }
411 
412 Quit:
413  if (!Ret)
414  Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam);
415 
416  return Ret;
417 }
#define ID_SYSTEM_EDIT_SCROLL
Definition: resource.h:16
static VOID Paste(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:2052
#define TRUE
Definition: types.h:120
#define ID_SYSTEM_EDIT_COPY
Definition: resource.h:13
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static VOID SendMenuEvent(PCONSRV_CONSOLE Console, UINT CmdId)
Definition: conwnd.c:274
#define ID_SYSTEM_PROPERTIES
Definition: resource.h:19
#define ID_SYSTEM_EDIT_MARK
Definition: resource.h:12
#define FALSE
Definition: types.h:117
#define ID_SYSTEM_DEFAULTS
Definition: resource.h:18
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
static VOID Mark(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:300
#define ID_SYSTEM_EDIT_SELECTALL
Definition: resource.h:15
static VOID SelectAll(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:315
VOID GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults)
Definition: guisettings.c:44
static VOID Copy(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:2029
unsigned int UINT
Definition: ndis.h:50
CConsole Console
#define DPRINT1
Definition: precomp.h:8
#define ID_SYSTEM_EDIT_FIND
Definition: resource.h:17
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_SYSCOMMAND
Definition: winuser.h:1728
LPARAM lParam
Definition: combotst.c:139

Referenced by ConWndProc().

◆ OnDropFiles()

static VOID OnDropFiles ( PCONSRV_CONSOLE  Console,
HDROP  hDrop 
)
static

Definition at line 2184 of file conwnd.c.

2185 {
2186  LPWSTR pszPath;
2187  WCHAR szPath[MAX_PATH + 2];
2188 
2189  szPath[0] = L'"';
2190 
2191  DragQueryFileW(hDrop, 0, &szPath[1], ARRAYSIZE(szPath) - 1);
2192  DragFinish(hDrop);
2193 
2194  if (wcschr(&szPath[1], L' ') != NULL)
2195  {
2197  pszPath = szPath;
2198  }
2199  else
2200  {
2201  pszPath = &szPath[1];
2202  }
2203 
2204  PasteText(Console, pszPath, wcslen(pszPath));
2205 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
VOID PasteText(IN PCONSRV_CONSOLE Console, IN PWCHAR Buffer, IN SIZE_T cchSize)
Definition: text.c:238
#define L(x)
Definition: ntvdm.h:50
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
LPCWSTR szPath
Definition: env.c:37
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
CConsole Console
void WINAPI DragFinish(HDROP h)
Definition: shellole.c:538
WCHAR * LPWSTR
Definition: xmlstorage.h:184
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:622

Referenced by ConWndProc().

◆ OnFocus()

static VOID OnFocus ( PGUI_CONSOLE_DATA  GuiData,
BOOL  SetFocus 
)
static

Definition at line 759 of file conwnd.c.

760 {
761  PCONSRV_CONSOLE Console = GuiData->Console;
762  INPUT_RECORD er;
763 
765 
766  /* Set console focus state */
767  Console->HasFocus = SetFocus;
768 
769  /*
770  * Set the priority of the processes of this console
771  * in accordance with the console focus state.
772  */
774 
775  /* Send a focus event */
776  er.EventType = FOCUS_EVENT;
779 
781 
782  if (SetFocus)
783  DPRINT("TODO: Create console caret\n");
784  else
785  DPRINT("TODO: Destroy console caret\n");
786 }
#define TRUE
Definition: types.h:120
HWND WINAPI SetFocus(_In_opt_ HWND)
#define FOCUS_EVENT
Definition: wincon.h:132
FOCUS_EVENT_RECORD FocusEvent
Definition: wincon.h:279
NTSTATUS NTAPI ConSrvSetConsoleProcessFocus(IN PCONSRV_CONSOLE Console, IN BOOLEAN SetForeground)
Definition: console.c:1453
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
CConsole Console
WORD EventType
Definition: wincon.h:273
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define DPRINT
Definition: sndvol32.h:71
union _INPUT_RECORD::@3236 Event
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:201

Referenced by ConWndProc().

◆ OnGetMinMaxInfo()

static VOID OnGetMinMaxInfo ( PGUI_CONSOLE_DATA  GuiData,
PMINMAXINFO  minMaxInfo 
)
static

Definition at line 2072 of file conwnd.c.

2073 {
2074  PCONSRV_CONSOLE Console = GuiData->Console;
2075  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
2076  DWORD windx, windy;
2077  UINT WidthUnit, HeightUnit;
2078 
2080 
2081  ActiveBuffer = GuiData->ActiveBuffer;
2082 
2083  GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
2084 
2085  windx = CONGUI_MIN_WIDTH * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
2087 
2088  minMaxInfo->ptMinTrackSize.x = windx;
2089  minMaxInfo->ptMinTrackSize.y = windy;
2090 
2091  windx = (ActiveBuffer->ScreenBufferSize.X) * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
2092  windy = (ActiveBuffer->ScreenBufferSize.Y) * HeightUnit + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION);
2093 
2094  if (ActiveBuffer->ViewSize.X < ActiveBuffer->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // Window currently has a horizontal scrollbar
2095  if (ActiveBuffer->ViewSize.Y < ActiveBuffer->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // Window currently has a vertical scrollbar
2096 
2097  minMaxInfo->ptMaxTrackSize.x = windx;
2098  minMaxInfo->ptMaxTrackSize.y = windy;
2099 
2100  LeaveCriticalSection(&Console->Lock);
2101 }
POINT ptMinTrackSize
Definition: winuser.h:3610
#define SM_CYHSCROLL
Definition: winuser.h:956
long y
Definition: polytest.cpp:48
#define CONGUI_MIN_HEIGHT
Definition: conwnd.c:34
long x
Definition: polytest.cpp:48
#define TRUE
Definition: types.h:120
#define SM_CXEDGE
Definition: winuser.h:1002
#define SM_CYFRAME
Definition: winuser.h:990
#define SM_CXFRAME
Definition: winuser.h:988
COORD ScreenBufferSize
Definition: conio.h:62
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#define SM_CYEDGE
Definition: winuser.h:1003
ULONG X
Definition: bl.h:1339
#define SM_CYCAPTION
Definition: winuser.h:957
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
FORCEINLINE VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.h:22
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
unsigned int UINT
Definition: ndis.h:50
#define SM_CXVSCROLL
Definition: winuser.h:955
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
POINT ptMaxTrackSize
Definition: winuser.h:3611
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define CONGUI_MIN_WIDTH
Definition: conwnd.c:33
ULONG Y
Definition: bl.h:1340

Referenced by ConWndProc().

◆ OnKey()

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

Definition at line 1145 of file conwnd.c.

1146 {
1147  PCONSRV_CONSOLE Console = GuiData->Console;
1148  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
1149 
1151 
1152  ActiveBuffer = GuiData->ActiveBuffer;
1153 
1155  {
1156  WORD VirtualKeyCode = LOWORD(wParam);
1157 
1158  if (msg != WM_KEYDOWN) goto Quit;
1159 
1160  if (VirtualKeyCode == VK_RETURN)
1161  {
1162  /* Copy (and clear) selection if ENTER is pressed */
1163  Copy(GuiData);
1164  goto Quit;
1165  }
1166  else if ( VirtualKeyCode == VK_ESCAPE ||
1167  (VirtualKeyCode == 'C' && (GetKeyState(VK_CONTROL) & KEY_PRESSED)) )
1168  {
1169  /* Cancel selection if ESC or Ctrl-C are pressed */
1170  UpdateSelection(GuiData, NULL, NULL);
1171  goto Quit;
1172  }
1173 
1174  if ((GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0)
1175  {
1176  /* Keyboard selection mode */
1177  BOOL Interpreted = FALSE;
1178  BOOL MajPressed = !!(GetKeyState(VK_SHIFT) & KEY_PRESSED);
1179 
1180  switch (VirtualKeyCode)
1181  {
1182  case VK_LEFT:
1183  {
1184  Interpreted = TRUE;
1185  if (GuiData->dwSelectionCursor.X > 0)
1186  GuiData->dwSelectionCursor.X--;
1187 
1188  break;
1189  }
1190 
1191  case VK_RIGHT:
1192  {
1193  Interpreted = TRUE;
1194  if (GuiData->dwSelectionCursor.X < ActiveBuffer->ScreenBufferSize.X - 1)
1195  GuiData->dwSelectionCursor.X++;
1196 
1197  break;
1198  }
1199 
1200  case VK_UP:
1201  {
1202  Interpreted = TRUE;
1203  if (GuiData->dwSelectionCursor.Y > 0)
1204  GuiData->dwSelectionCursor.Y--;
1205 
1206  break;
1207  }
1208 
1209  case VK_DOWN:
1210  {
1211  Interpreted = TRUE;
1212  if (GuiData->dwSelectionCursor.Y < ActiveBuffer->ScreenBufferSize.Y - 1)
1213  GuiData->dwSelectionCursor.Y++;
1214 
1215  break;
1216  }
1217 
1218  case VK_HOME:
1219  {
1220  Interpreted = TRUE;
1221  GuiData->dwSelectionCursor.X = 0;
1222  GuiData->dwSelectionCursor.Y = 0;
1223  break;
1224  }
1225 
1226  case VK_END:
1227  {
1228  Interpreted = TRUE;
1229  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
1230  break;
1231  }
1232 
1233  case VK_PRIOR:
1234  {
1235  Interpreted = TRUE;
1236  GuiData->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y;
1237  if (GuiData->dwSelectionCursor.Y < 0)
1238  GuiData->dwSelectionCursor.Y = 0;
1239 
1240  break;
1241  }
1242 
1243  case VK_NEXT:
1244  {
1245  Interpreted = TRUE;
1246  GuiData->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y;
1247  if (GuiData->dwSelectionCursor.Y >= ActiveBuffer->ScreenBufferSize.Y)
1248  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
1249 
1250  break;
1251  }
1252 
1253  default:
1254  break;
1255  }
1256 
1257  if (Interpreted)
1258  {
1259  UpdateSelection(GuiData,
1260  !MajPressed ? &GuiData->dwSelectionCursor : NULL,
1261  &GuiData->dwSelectionCursor);
1262  }
1263  else if (!IsSystemKey(VirtualKeyCode))
1264  {
1265  /* Emit an error beep sound */
1266  SendNotifyMessage(GuiData->hWindow, PM_CONSOLE_BEEP, 0, 0);
1267  }
1268 
1269  goto Quit;
1270  }
1271  else
1272  {
1273  /* Mouse selection mode */
1274 
1275  if (!IsSystemKey(VirtualKeyCode))
1276  {
1277  /* Clear the selection and send the key into the input buffer */
1278  UpdateSelection(GuiData, NULL, NULL);
1279  }
1280  else
1281  {
1282  goto Quit;
1283  }
1284  }
1285  }
1286 
1287  if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
1288  {
1289  MSG Message;
1290 
1291  Message.hwnd = GuiData->hWindow;
1292  Message.message = msg;
1293  Message.wParam = wParam;
1294  Message.lParam = lParam;
1295 
1297  }
1298 
1299 Quit:
1300  LeaveCriticalSection(&Console->Lock);
1301 }
COORD dwSelectionCursor
Definition: conwnd.h:93
#define TRUE
Definition: types.h:120
#define PM_CONSOLE_BEEP
Definition: conwnd.h:21
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define VK_LEFT
Definition: winuser.h:2204
#define VK_DOWN
Definition: winuser.h:2207
#define VK_PRIOR
Definition: winuser.h:2200
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:920
#define VK_ESCAPE
Definition: winuser.h:2194
#define VK_RETURN
Definition: winuser.h:2181
WPARAM wParam
Definition: combotst.c:138
#define VK_NEXT
Definition: winuser.h:2201
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:105
#define VK_HOME
Definition: winuser.h:2203
#define VK_UP
Definition: winuser.h:2205
#define FALSE
Definition: types.h:117
COORD ScreenBufferSize
Definition: conio.h:62
unsigned int BOOL
Definition: ntddk_ex.h:94
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#define VK_SHIFT
Definition: winuser.h:2182
#define WM_KEYDOWN
Definition: winuser.h:1702
SHORT WINAPI GetKeyState(_In_ int)
ULONG X
Definition: bl.h:1339
#define KEY_PRESSED
Definition: conwnd.h:26
static BOOL IsSystemKey(WORD VirtualKeyCode)
Definition: conwnd.c:1122
unsigned short WORD
Definition: ntddk_ex.h:93
CHAR Message[80]
Definition: alive.c:5
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:103
#define VK_RIGHT
Definition: winuser.h:2206
VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG *msg)
Definition: input.c:60
static VOID Copy(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:2029
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
#define NULL
Definition: types.h:112
#define VK_CONTROL
Definition: winuser.h:2183
CConsole Console
#define msg(x)
Definition: auth_time.c:54
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1340
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define VK_END
Definition: winuser.h:2202
#define SendNotifyMessage
Definition: winuser.h:5826

Referenced by ConWndProc().

◆ OnMouse()

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

Definition at line 1600 of file conwnd.c.

1601 {
1602  BOOL DoDefault = FALSE;
1603  PCONSRV_CONSOLE Console = GuiData->Console;
1604 
1605  /*
1606  * HACK FOR CORE-8394 (Part 2):
1607  *
1608  * Check whether we should ignore the next mouse move event.
1609  * In either case we reset the HACK flag.
1610  *
1611  * See Part 1 of this hack below.
1612  */
1613  if (GuiData->HackCORE8394IgnoreNextMove && msg == WM_MOUSEMOVE)
1614  {
1615  GuiData->HackCORE8394IgnoreNextMove = FALSE;
1616  goto Quit;
1617  }
1618  GuiData->HackCORE8394IgnoreNextMove = FALSE;
1619 
1620  // FIXME: It's here that we need to check whether we have focus or not
1621  // and whether we are or not in edit mode, in order to know if we need
1622  // to deal with the mouse.
1623 
1624  if (GuiData->IgnoreNextMouseSignal)
1625  {
1626  if (msg != WM_LBUTTONDOWN &&
1627  msg != WM_MBUTTONDOWN &&
1628  msg != WM_RBUTTONDOWN &&
1629  msg != WM_XBUTTONDOWN)
1630  {
1631  /*
1632  * If this mouse signal is not a button-down action
1633  * then this is the last one being ignored.
1634  */
1635  GuiData->IgnoreNextMouseSignal = FALSE;
1636  }
1637  else
1638  {
1639  /*
1640  * This mouse signal is a button-down action.
1641  * Ignore it and perform default action.
1642  */
1643  DoDefault = TRUE;
1644  }
1645  goto Quit;
1646  }
1647 
1649  {
1650  DoDefault = TRUE;
1651  goto Quit;
1652  }
1653 
1654  if ( (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) ||
1655  (Console->QuickEdit) )
1656  {
1657  switch (msg)
1658  {
1659  case WM_LBUTTONDOWN:
1660  {
1661  /* Check for selection state */
1662  if ( (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
1663  (GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) &&
1665  {
1666  /*
1667  * A mouse selection is currently in progress and the user
1668  * has pressed the SHIFT key and clicked somewhere, update
1669  * the selection.
1670  */
1671  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1672  UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1673  }
1674  else
1675  {
1676  /* Clear the old selection */
1678 
1679  /* Restart a new selection */
1680  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1681  SetCapture(GuiData->hWindow);
1683  UpdateSelection(GuiData,
1684  &GuiData->dwSelectionCursor,
1685  &GuiData->dwSelectionCursor);
1686  }
1687 
1688  break;
1689  }
1690 
1691  case WM_LBUTTONUP:
1692  {
1693  if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1694 
1695  // GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1696  GuiData->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
1697  // UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1698  ReleaseCapture();
1699 
1700  break;
1701  }
1702 
1703  case WM_LBUTTONDBLCLK:
1704  {
1706 
1707  if (GetType(Buffer) == TEXTMODE_BUFFER)
1708  {
1709 #define IS_WORD_SEP(c) \
1710  ((c) == L'\0' || (c) == L' ' || (c) == L'\t' || (c) == L'\r' || (c) == L'\n')
1711 
1713  COORD cL, cR;
1714  PCHAR_INFO ptrL, ptrR;
1715 
1716  /* Starting point */
1717  cL = cR = PointToCoord(GuiData, lParam);
1718  ptrL = ptrR = ConioCoordToPointer(TextBuffer, cL.X, cL.Y);
1719 
1720  /* Enlarge the selection by checking for whitespace */
1721  while ((0 < cL.X) && !IS_WORD_SEP(ptrL->Char.UnicodeChar)
1722  && !IS_WORD_SEP((ptrL-1)->Char.UnicodeChar))
1723  {
1724  --cL.X;
1725  --ptrL;
1726  }
1727  while ((cR.X < TextBuffer->ScreenBufferSize.X - 1) &&
1728  !IS_WORD_SEP(ptrR->Char.UnicodeChar) &&
1729  !IS_WORD_SEP((ptrR+1)->Char.UnicodeChar))
1730  {
1731  ++cR.X;
1732  ++ptrR;
1733  }
1734 
1735  /*
1736  * Update the selection started with the single
1737  * left-click that preceded this double-click.
1738  */
1740  UpdateSelection(GuiData, &cL, &cR);
1741 
1742  /* Ignore the next mouse move signal */
1743  GuiData->IgnoreNextMouseSignal = TRUE;
1744 #undef IS_WORD_SEP
1745  }
1746 
1747  break;
1748  }
1749 
1750  case WM_RBUTTONDOWN:
1751  case WM_RBUTTONDBLCLK:
1752  {
1753  if (!(GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
1754  {
1755  Paste(GuiData);
1756  }
1757  else
1758  {
1759  Copy(GuiData);
1760  }
1761 
1762  /* Ignore the next mouse move signal */
1763  GuiData->IgnoreNextMouseSignal = TRUE;
1764  break;
1765  }
1766 
1767  case WM_MOUSEMOVE:
1768  {
1769  if (!(GET_KEYSTATE_WPARAM(wParam) & MK_LBUTTON)) break;
1770  if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1771 
1772  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1773  UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1774  break;
1775  }
1776 
1777  default:
1778  DoDefault = TRUE; // FALSE;
1779  break;
1780  }
1781  }
1783  {
1784  INPUT_RECORD er;
1785  WORD wKeyState = GET_KEYSTATE_WPARAM(wParam);
1786  DWORD dwButtonState = 0;
1787  DWORD dwControlKeyState = 0;
1788  DWORD dwEventFlags = 0;
1789 
1790  switch (msg)
1791  {
1792  case WM_LBUTTONDOWN:
1793  SetCapture(GuiData->hWindow);
1794  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1795  dwEventFlags = 0;
1796  break;
1797 
1798  case WM_MBUTTONDOWN:
1799  SetCapture(GuiData->hWindow);
1800  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1801  dwEventFlags = 0;
1802  break;
1803 
1804  case WM_RBUTTONDOWN:
1805  SetCapture(GuiData->hWindow);
1806  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1807  dwEventFlags = 0;
1808  break;
1809 
1810  case WM_XBUTTONDOWN:
1811  {
1812  /* Get which X-button was pressed */
1813  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1814 
1815  /* Check for X-button validity */
1816  if (wButton & ~(XBUTTON1 | XBUTTON2))
1817  {
1818  DPRINT1("X-button 0x%04x invalid\n", wButton);
1819  DoDefault = TRUE;
1820  break;
1821  }
1822 
1823  SetCapture(GuiData->hWindow);
1824  dwButtonState = (wButton == XBUTTON1 ? FROM_LEFT_3RD_BUTTON_PRESSED
1826  dwEventFlags = 0;
1827  break;
1828  }
1829 
1830  case WM_LBUTTONUP:
1831  ReleaseCapture();
1832  dwButtonState = 0;
1833  dwEventFlags = 0;
1834  break;
1835 
1836  case WM_MBUTTONUP:
1837  ReleaseCapture();
1838  dwButtonState = 0;
1839  dwEventFlags = 0;
1840  break;
1841 
1842  case WM_RBUTTONUP:
1843  ReleaseCapture();
1844  dwButtonState = 0;
1845  dwEventFlags = 0;
1846  break;
1847 
1848  case WM_XBUTTONUP:
1849  {
1850  /* Get which X-button was released */
1851  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1852 
1853  /* Check for X-button validity */
1854  if (wButton & ~(XBUTTON1 | XBUTTON2))
1855  {
1856  DPRINT1("X-button 0x%04x invalid\n", wButton);
1857  /* Ok, just release the button anyway... */
1858  }
1859 
1860  ReleaseCapture();
1861  dwButtonState = 0;
1862  dwEventFlags = 0;
1863  break;
1864  }
1865 
1866  case WM_LBUTTONDBLCLK:
1867  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1868  dwEventFlags = DOUBLE_CLICK;
1869  break;
1870 
1871  case WM_MBUTTONDBLCLK:
1872  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1873  dwEventFlags = DOUBLE_CLICK;
1874  break;
1875 
1876  case WM_RBUTTONDBLCLK:
1877  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1878  dwEventFlags = DOUBLE_CLICK;
1879  break;
1880 
1881  case WM_XBUTTONDBLCLK:
1882  {
1883  /* Get which X-button was double-clicked */
1884  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1885 
1886  /* Check for X-button validity */
1887  if (wButton & ~(XBUTTON1 | XBUTTON2))
1888  {
1889  DPRINT1("X-button 0x%04x invalid\n", wButton);
1890  DoDefault = TRUE;
1891  break;
1892  }
1893 
1894  dwButtonState = (wButton == XBUTTON1 ? FROM_LEFT_3RD_BUTTON_PRESSED
1896  dwEventFlags = DOUBLE_CLICK;
1897  break;
1898  }
1899 
1900  case WM_MOUSEMOVE:
1901  dwButtonState = 0;
1902  dwEventFlags = MOUSE_MOVED;
1903  break;
1904 
1905  case WM_MOUSEWHEEL:
1906  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1907  dwEventFlags = MOUSE_WHEELED;
1908  break;
1909 
1910  case WM_MOUSEHWHEEL:
1911  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1912  dwEventFlags = MOUSE_HWHEELED;
1913  break;
1914 
1915  default:
1916  DoDefault = TRUE;
1917  break;
1918  }
1919 
1920  /*
1921  * HACK FOR CORE-8394 (Part 1):
1922  *
1923  * It appears that depending on which VM ReactOS runs, the next mouse
1924  * signal coming after a button-down action can be a mouse-move (e.g.
1925  * on VBox, whereas on QEMU it is not the case). However it is NOT a
1926  * rule, so that we cannot use the IgnoreNextMouseSignal flag to just
1927  * "ignore" the next mouse event, thinking it would always be a mouse-
1928  * move signal.
1929  *
1930  * To work around this problem (that should really be fixed in Win32k),
1931  * we use a second flag to ignore this possible next mouse move signal.
1932  */
1933  switch (msg)
1934  {
1935  case WM_LBUTTONDOWN:
1936  case WM_MBUTTONDOWN:
1937  case WM_RBUTTONDOWN:
1938  case WM_XBUTTONDOWN:
1939  GuiData->HackCORE8394IgnoreNextMove = TRUE;
1940  default:
1941  break;
1942  }
1943 
1944  if (!DoDefault)
1945  {
1946  if (wKeyState & MK_LBUTTON)
1947  dwButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
1948  if (wKeyState & MK_MBUTTON)
1949  dwButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
1950  if (wKeyState & MK_RBUTTON)
1951  dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
1952  if (wKeyState & MK_XBUTTON1)
1953  dwButtonState |= FROM_LEFT_3RD_BUTTON_PRESSED;
1954  if (wKeyState & MK_XBUTTON2)
1955  dwButtonState |= FROM_LEFT_4TH_BUTTON_PRESSED;
1956 
1958  dwControlKeyState |= RIGHT_ALT_PRESSED;
1960  dwControlKeyState |= LEFT_ALT_PRESSED;
1962  dwControlKeyState |= RIGHT_CTRL_PRESSED;
1964  dwControlKeyState |= LEFT_CTRL_PRESSED;
1966  dwControlKeyState |= SHIFT_PRESSED;
1968  dwControlKeyState |= NUMLOCK_ON;
1970  dwControlKeyState |= SCROLLLOCK_ON;
1972  dwControlKeyState |= CAPSLOCK_ON;
1973  /* See WM_CHAR MSDN documentation for instance */
1974  if (HIWORD(lParam) & KF_EXTENDED)
1975  dwControlKeyState |= ENHANCED_KEY;
1976 
1977  /* Send a mouse event */
1978  er.EventType = MOUSE_EVENT;
1980  er.Event.MouseEvent.dwButtonState = dwButtonState;
1981  er.Event.MouseEvent.dwControlKeyState = dwControlKeyState;
1982  er.Event.MouseEvent.dwEventFlags = dwEventFlags;
1983 
1985  }
1986  }
1987  else
1988  {
1989  DoDefault = TRUE;
1990  }
1991 
1992  LeaveCriticalSection(&Console->Lock);
1993 
1994 Quit:
1995  if (!DoDefault)
1996  return 0;
1997 
1998  if (msg == WM_MOUSEWHEEL || msg == WM_MOUSEHWHEEL)
1999  {
2000  INT nBar;
2001  WORD sbCode;
2002  // WORD wKeyState = GET_KEYSTATE_WPARAM(wParam);
2003  SHORT wDelta = GET_WHEEL_DELTA_WPARAM(wParam);
2004 
2005  if (msg == WM_MOUSEWHEEL)
2006  nBar = SB_VERT;
2007  else // if (msg == WM_MOUSEHWHEEL)
2008  nBar = SB_HORZ;
2009 
2010  // NOTE: We currently do not support zooming...
2011  // if (wKeyState & MK_CONTROL)
2012 
2013  // FIXME: For some reason our win32k does not set the key states
2014  // when sending WM_MOUSEWHEEL or WM_MOUSEHWHEEL ...
2015  // if (wKeyState & MK_SHIFT)
2017  sbCode = (wDelta >= 0 ? SB_PAGEUP : SB_PAGEDOWN);
2018  else
2019  sbCode = (wDelta >= 0 ? SB_LINEUP : SB_LINEDOWN);
2020 
2021  OnScroll(GuiData, nBar, sbCode);
2022  }
2023 
2024  return DefWindowProcW(GuiData->hWindow, msg, wParam, lParam);
2025 }
#define WM_MBUTTONUP
Definition: winuser.h:1770
COORD dwSelectionCursor
Definition: conwnd.h:93
union _CHAR_INFO::@3234 Char
#define FROM_LEFT_1ST_BUTTON_PRESSED
Definition: wincon.h:159
#define SCROLLLOCK_ON
Definition: wincon.h:143
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
DWORD dwEventFlags
Definition: wincon.h:257
#define WM_LBUTTONDOWN
Definition: winuser.h:1763
static VOID Paste(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:2052
#define MK_LBUTTON
Definition: winuser.h:2347
static COORD PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
Definition: conwnd.c:1574
#define RIGHTMOST_BUTTON_PRESSED
Definition: wincon.h:160
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
#define VK_RMENU
Definition: winuser.h:2267
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define MK_MBUTTON
Definition: winuser.h:2351
WCHAR UnicodeChar
Definition: wincon.h:184
#define SB_HORZ
Definition: winuser.h:552
#define FROM_LEFT_2ND_BUTTON_PRESSED
Definition: wincon.h:161
#define IS_WORD_SEP(c)
#define CONSOLE_NO_SELECTION
Definition: wincon.h:102
BOOL IgnoreNextMouseSignal
Definition: conwnd.h:72
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
#define SHIFT_PRESSED
Definition: wincon.h:141
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:920
#define CONSOLE_MOUSE_DOWN
Definition: wincon.h:106
DWORD dwButtonState
Definition: wincon.h:255
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:105
#define MOUSE_MOVED
Definition: wincon.h:168
#define FALSE
Definition: types.h:117
BOOL HackCORE8394IgnoreNextMove
Definition: conwnd.h:74
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DOUBLE_CLICK
Definition: wincon.h:169
short SHORT
Definition: pedump.c:59
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#define VK_SHIFT
Definition: winuser.h:2182
COORD dwMousePosition
Definition: wincon.h:254
#define GetConsoleInputBufferMode(Console)
Definition: conio.h:320
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:104
Definition: bufpool.h:45
static VOID OnScroll(PGUI_CONSOLE_DATA GuiData, INT nBar, WORD sbCode)
Definition: conwnd.c:1466
#define MK_RBUTTON
Definition: winuser.h:2348
#define WM_RBUTTONDOWN
Definition: winuser.h:1766
SHORT WINAPI GetKeyState(_In_ int)
#define LEFT_ALT_PRESSED
Definition: wincon.h:138
#define KF_EXTENDED
Definition: winuser.h:2426
ULONG X
Definition: bl.h:1339
#define FROM_LEFT_3RD_BUTTON_PRESSED
Definition: wincon.h:162
#define KEY_PRESSED
Definition: conwnd.h:26
#define ENHANCED_KEY
Definition: wincon.h:145
#define MOUSE_EVENT
Definition: wincon.h:129
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_RBUTTONUP
Definition: winuser.h:1767
#define ENABLE_MOUSE_INPUT
Definition: wincon.h:82
#define LEFT_CTRL_PRESSED
Definition: wincon.h:140
#define VK_RCONTROL
Definition: winuser.h:2265
#define VK_LMENU
Definition: winuser.h:2266
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1765
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1771
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:103
Definition: bl.h:1337
#define GetType(This)
Definition: conio.h:54
static VOID Copy(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:2029
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define VK_SCROLL
Definition: winuser.h:2260
#define VK_NUMLOCK
Definition: winuser.h:2259
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
#define WM_LBUTTONUP
Definition: winuser.h:1764
DWORD dwControlKeyState
Definition: wincon.h:256
#define WM_MBUTTONDOWN
Definition: winuser.h:1769
#define VK_CAPITAL
Definition: winuser.h:2186
#define SB_LINEDOWN
Definition: winuser.h:565
#define WM_MOUSEMOVE
Definition: winuser.h:1762
#define NULL
Definition: types.h:112
#define SB_LINEUP
Definition: winuser.h:564
CConsole Console
WORD EventType
Definition: wincon.h:273
#define DPRINT1
Definition: precomp.h:8
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
MOUSE_EVENT_RECORD MouseEvent
Definition: wincon.h:276
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1768
#define HIWORD(l)
Definition: typedefs.h:247
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
#define MOUSE_WHEELED
Definition: wincon.h:170
#define FROM_LEFT_4TH_BUTTON_PRESSED
Definition: wincon.h:163
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:139
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define VK_LCONTROL
Definition: winuser.h:2264
union _INPUT_RECORD::@3236 Event
ULONG Y
Definition: bl.h:1340
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
#define MOUSE_HWHEELED
Definition: wincon.h:172
LPARAM lParam
Definition: combotst.c:139
#define NUMLOCK_ON
Definition: wincon.h:142
#define RIGHT_ALT_PRESSED
Definition: wincon.h:137
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:201
#define CAPSLOCK_ON
Definition: wincon.h:144
#define KEY_TOGGLED
Definition: conwnd.h:25

Referenced by ConWndProc().

◆ OnMove()

static VOID OnMove ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 2170 of file conwnd.c.

2171 {
2172  RECT rcWnd;
2173 
2174  // TODO: Simplify the code.
2175  // See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
2176 
2177  /* Retrieve our real position */
2178  GetWindowRect(GuiData->hWindow, &rcWnd);
2179  GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
2180  GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
2181 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by ConWndProc().

◆ OnNcCreate()

static BOOL OnNcCreate ( HWND  hWnd,
LPCREATESTRUCTW  Create 
)
static

Definition at line 630 of file conwnd.c.

631 {
632  PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
634 
635  if (GuiData == NULL)
636  {
637  DPRINT1("GuiConsoleNcCreate: No GUI data\n");
638  return FALSE;
639  }
640 
641  Console = GuiData->Console;
642 
643  GuiData->hWindow = hWnd;
644  GuiData->hSysMenu = GetSystemMenu(hWnd, FALSE);
645 
646  /* Initialize the fonts */
647  if (!InitFonts(GuiData,
648  GuiData->GuiInfo.FaceName,
649  GuiData->GuiInfo.FontWeight,
650  GuiData->GuiInfo.FontFamily,
651  GuiData->GuiInfo.FontSize,
652  0, FALSE))
653  {
654  /* Reset only the output code page if we don't have a suitable
655  * font for it, possibly falling back to "United States (OEM)". */
656  UINT AltCodePage = GetOEMCP();
657 
658  if (AltCodePage == Console->OutputCodePage)
659  AltCodePage = CP_USA;
660 
661  DPRINT1("Could not initialize font '%S' for code page %d - Resetting CP to %d\n",
662  GuiData->GuiInfo.FaceName, Console->OutputCodePage, AltCodePage);
663 
664  CON_SET_OUTPUT_CP(Console, AltCodePage);
665 
666  /* We will use a fallback font if we cannot find
667  * anything for this replacement code page. */
668  if (!InitFonts(GuiData,
669  GuiData->GuiInfo.FaceName,
670  GuiData->GuiInfo.FontWeight,
671  GuiData->GuiInfo.FontFamily,
672  GuiData->GuiInfo.FontSize,
673  0, TRUE))
674  {
675  DPRINT1("Failed to initialize font '%S' for code page %d\n",
676  GuiData->GuiInfo.FaceName, Console->OutputCodePage);
677 
678  DPRINT1("GuiConsoleNcCreate: InitFonts failed\n");
679  GuiData->hWindow = NULL;
680  NtSetEvent(GuiData->hGuiInitEvent, NULL);
681  return FALSE;
682  }
683  }
684 
685  /* Initialize the terminal framebuffer */
686  GuiData->hMemDC = CreateCompatibleDC(NULL);
687  GuiData->hBitmap = NULL;
688  GuiData->hSysPalette = NULL; /* Original system palette */
689 
690  /* Update the icons of the window */
691  if (GuiData->hIcon != ghDefaultIcon)
692  {
693  DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_BIG , (LPARAM)GuiData->hIcon );
694  DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
695  }
696 
697  // FIXME: Keep these instructions here ? ///////////////////////////////////
698  Console->ActiveBuffer->CursorBlinkOn = TRUE;
699  Console->ActiveBuffer->ForceCursorOff = FALSE;
701 
702  SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
703 
704  if (GuiData->IsWindowVisible)
705  {
707  }
708 
709  // FIXME: HACK: Potential HACK for CORE-8129; see revision 63595.
710  //CreateSysMenu(GuiData->hWindow);
711 
712  DPRINT("OnNcCreate - setting start event\n");
713  NtSetEvent(GuiData->hGuiInitEvent, NULL);
714 
715  /* We accept dropped files */
716  DragAcceptFiles(GuiData->hWindow, TRUE);
717 
718  return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
719 }
HANDLE hGuiInitEvent
Definition: conwnd.h:44
#define TRUE
Definition: types.h:120
_In_ BOOLEAN Create
Definition: pstypes.h:527
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
HWND hWnd
Definition: settings.c:17
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:522
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define WM_NCCREATE
Definition: winuser.h:1670
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CON_SET_OUTPUT_CP(Console, CodePage)
Definition: conio.h:323
#define ICON_SMALL
Definition: tnclass.cpp:48
HICON ghDefaultIcon
Definition: conwnd.c:73
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL InitFonts(_Inout_ PGUI_CONSOLE_DATA GuiData, _In_reads_or_z_(LF_FACESIZE) PCWSTR FaceName, _In_ ULONG FontWeight, _In_ ULONG FontFamily, _In_ COORD FontSize, _In_opt_ UINT CodePage, _In_ BOOL UseDefaultFallback)
Definition: conwnd.c:521
HICON hIconSm
Definition: conwnd.h:67
#define GWLP_USERDATA
Definition: treelist.c:63
#define CONGUI_UPDATE_TIMER
Definition: conwnd.c:36
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
LONG_PTR LPARAM
Definition: windef.h:208
HMENU hSysMenu
Definition: conwnd.h:76
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CP_USA
Definition: font.h:19
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define CONGUI_UPDATE_TIME
Definition: conwnd.c:35
CConsole Console
#define DPRINT1
Definition: precomp.h:8
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
HPALETTE hSysPalette
Definition: conwnd.h:64
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
#define SetWindowLongPtrW
Definition: winuser.h:5326
HBITMAP hBitmap
Definition: conwnd.h:63
#define DPRINT
Definition: sndvol32.h:71
#define ICON_BIG
Definition: tnclass.cpp:51
UINT WINAPI GetOEMCP(VOID)
Definition: nls.c:2233

Referenced by ConWndProc().

◆ OnNcDestroy()

static LRESULT OnNcDestroy ( HWND  hWnd)
static

Definition at line 1440 of file conwnd.c.

1441 {
1443 
1444  /* Free the GuiData registration */
1446 
1447  /* Reset the system menu back to default and destroy the previous menu */
1449 
1450  if (GuiData)
1451  {
1452  if (GuiData->IsWindowVisible)
1454 
1455  /* Free the terminal framebuffer */
1456  if (GuiData->hMemDC ) DeleteDC(GuiData->hMemDC);
1457  if (GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
1458  // if (GuiData->hSysPalette) DeleteObject(GuiData->hSysPalette);
1459  DeleteFonts(GuiData);
1460  }
1461 
1462  return DefWindowProcW(hWnd, WM_NCDESTROY, 0, 0);
1463 }
static PGUI_CONSOLE_DATA GuiGetGuiData(HWND hWnd)
Definition: conwnd.c:420
#define TRUE
Definition: types.h:120
VOID DeleteFonts(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:481
HWND hWnd
Definition: settings.c:17
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GWLP_USERDATA
Definition: treelist.c:63
#define CONGUI_UPDATE_TIMER
Definition: conwnd.c:36
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
#define WM_NCDESTROY
Definition: winuser.h:1671
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
uint32_t DWORD_PTR
Definition: typedefs.h:65
BOOL WINAPI DeleteDC(_In_ HDC)
#define NULL
Definition: types.h:112
#define SetWindowLongPtrW
Definition: winuser.h:5326
HBITMAP hBitmap
Definition: conwnd.h:63

Referenced by ConWndProc().

◆ OnPaint()

static VOID OnPaint ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1043 of file conwnd.c.

1044 {
1045  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
1046  PAINTSTRUCT ps;
1047  RECT rcPaint;
1048 
1049  /* Do nothing if the window is hidden */
1050  if (!GuiData->IsWindowVisible) return;
1051 
1052  BeginPaint(GuiData->hWindow, &ps);
1053  if (ps.hdc != NULL &&
1054  ps.rcPaint.left < ps.rcPaint.right &&
1055  ps.rcPaint.top < ps.rcPaint.bottom)
1056  {
1057  EnterCriticalSection(&GuiData->Lock);
1058 
1059  /* Compose the current screen-buffer on-memory */
1060  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
1061  {
1063  GuiData, &ps.rcPaint, &rcPaint);
1064  }
1065  else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
1066  {
1068  GuiData, &ps.rcPaint, &rcPaint);
1069  }
1070 
1071  /* Send it to screen */
1072  BitBlt(ps.hdc,
1073  ps.rcPaint.left,
1074  ps.rcPaint.top,
1075  rcPaint.right - rcPaint.left,
1076  rcPaint.bottom - rcPaint.top,
1077  GuiData->hMemDC,
1078  rcPaint.left,
1079  rcPaint.top,
1080  SRCCOPY);
1081 
1082  /* Draw the selection region if needed */
1084  {
1085  PaintSelectionRect(GuiData, &ps);
1086  }
1087 
1088  // TODO: Move cursor display here!
1089 
1090  LeaveCriticalSection(&GuiData->Lock);
1091  }
1092  EndPaint(GuiData->hWindow, &ps);
1093 
1094  return;
1095 }
LONG top
Definition: windef.h:307
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
LONG left
Definition: windef.h:306
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
LONG right
Definition: windef.h:308
static VOID PaintSelectionRect(PGUI_CONSOLE_DATA GuiData, PPAINTSTRUCT pps)
Definition: conwnd.c:900
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:104
VOID GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, PRECT rcView, PRECT rcFramebuffer)
Definition: graphics.c:124
VOID GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, PRECT rcView, PRECT rcFramebuffer)
Definition: text.c:433
CRITICAL_SECTION Lock
Definition: conwnd.h:42
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
#define GetType(This)
Definition: conio.h:54
#define NULL
Definition: types.h:112
LONG bottom
Definition: windef.h:309
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define SRCCOPY
Definition: wingdi.h:333
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49

Referenced by ConWndProc().

◆ OnPaletteChanged()

static VOID OnPaletteChanged ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1098 of file conwnd.c.

1099 {
1100  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
1101 
1102  /* Do nothing if the window is hidden */
1103  if (!GuiData->IsWindowVisible) return;
1104 
1105  // See WM_PALETTECHANGED message
1106  // if ((HWND)wParam == hWnd) break;
1107 
1108  // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
1109  if (ActiveBuffer->PaletteHandle)
1110  {
1111  DPRINT("WM_PALETTECHANGED changing palette\n");
1112 
1113  /* Specify the use of the system palette for the framebuffer */
1114  SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
1115 
1116  /* Realize the (logical) palette */
1117  RealizePalette(GuiData->hMemDC);
1118  }
1119 }
UINT WINAPI SetSystemPaletteUse(_In_ HDC, _In_ UINT)
HPALETTE PaletteHandle
Definition: conio.h:78
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
#define DPRINT
Definition: sndvol32.h:71
UINT WINAPI RealizePalette(_In_ HDC)
Definition: palette.c:138

Referenced by ConWndProc().

◆ OnScroll()

static VOID OnScroll ( PGUI_CONSOLE_DATA  GuiData,
INT  nBar,
WORD  sbCode 
)
static

Definition at line 1466 of file conwnd.c.

1467 {
1468  PCONSRV_CONSOLE Console = GuiData->Console;
1470  SCROLLINFO sInfo;
1471  INT oldPos, Maximum;
1472  PSHORT pOriginXY;
1473 
1474  ASSERT(nBar == SB_HORZ || nBar == SB_VERT);
1475 
1477 
1478  Buff = GuiData->ActiveBuffer;
1479 
1480  if (nBar == SB_HORZ)
1481  {
1482  Maximum = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
1483  pOriginXY = &Buff->ViewOrigin.X;
1484  }
1485  else // if (nBar == SB_VERT)
1486  {
1487  Maximum = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
1488  pOriginXY = &Buff->ViewOrigin.Y;
1489  }
1490 
1491  /* Set scrollbar sizes */
1492  sInfo.cbSize = sizeof(sInfo);
1494 
1495  if (!GetScrollInfo(GuiData->hWindow, nBar, &sInfo)) goto Quit;
1496 
1497  oldPos = sInfo.nPos;
1498 
1499  switch (sbCode)
1500  {
1501  case SB_LINEUP: // SB_LINELEFT:
1502  sInfo.nPos--;
1503  break;
1504 
1505  case SB_LINEDOWN: // SB_LINERIGHT:
1506  sInfo.nPos++;
1507  break;
1508 
1509  case SB_PAGEUP: // SB_PAGELEFT:
1510  sInfo.nPos -= sInfo.nPage;
1511  break;
1512 
1513  case SB_PAGEDOWN: // SB_PAGERIGHT:
1514  sInfo.nPos += sInfo.nPage;
1515  break;
1516 
1517  case SB_THUMBTRACK:
1518  sInfo.nPos = sInfo.nTrackPos;
1520  break;
1521 
1522  case SB_THUMBPOSITION:
1523  sInfo.nPos = sInfo.nTrackPos;
1525  break;
1526 
1527  case SB_TOP: // SB_LEFT:
1528  sInfo.nPos = sInfo.nMin;
1529  break;
1530 
1531  case SB_BOTTOM: // SB_RIGHT:
1532  sInfo.nPos = sInfo.nMax;
1533  break;
1534 
1535  default:
1536  break;
1537  }
1538 
1539  sInfo.nPos = min(max(sInfo.nPos, 0), Maximum);
1540 
1541  if (oldPos != sInfo.nPos)
1542  {
1543  USHORT OldX = Buff->ViewOrigin.X;
1544  USHORT OldY = Buff->ViewOrigin.Y;
1545  UINT WidthUnit, HeightUnit;
1546 
1547  /* We now modify Buff->ViewOrigin */
1548  *pOriginXY = sInfo.nPos;
1549 
1550  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
1551 
1552  ScrollWindowEx(GuiData->hWindow,
1553  (OldX - Buff->ViewOrigin.X) * WidthUnit ,
1554  (OldY - Buff->ViewOrigin.Y) * HeightUnit,
1555  NULL,
1556  NULL,
1557  NULL,
1558  NULL,
1559  SW_INVALIDATE);
1560 
1561  sInfo.fMask = SIF_POS;
1562  SetScrollInfo(GuiData->hWindow, nBar, &sInfo, TRUE);
1563 
1564  UpdateWindow(GuiData->hWindow);
1565  // InvalidateRect(GuiData->hWindow, NULL, FALSE);
1566  }
1567 
1568 Quit:
1569  LeaveCriticalSection(&Console->Lock);
1570  return;
1571 }
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define max(a, b)
Definition: svc.c:63
#define SIF_RANGE
Definition: winuser.h:1225
signed short * PSHORT
Definition: retypes.h:6
VOID ConioUnpause(PCONSRV_CONSOLE Console, UCHAR Flags)
Definition: console.c:866
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI UpdateWindow(_In_ HWND)
int32_t INT
Definition: typedefs.h:58
#define SIF_PAGE
Definition: winuser.h:1223
COORD ScreenBufferSize
Definition: conio.h:62
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#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:1339
#define ASSERT(a)
Definition: mode.c:44
#define SB_THUMBTRACK
Definition: winuser.h:573
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SW_INVALIDATE
Definition: winuser.h:2559
#define SIF_POS
Definition: winuser.h:1224
FORCEINLINE VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.h:22
#define SB_TOP
Definition: winuser.h:578
#define PAUSED_FROM_SCROLLBAR
Definition: conio_winsrv.h:110
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
#define SIF_TRACKPOS
Definition: winuser.h:1227
VOID ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags)
Definition: console.c:859
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define SB_LINEDOWN
Definition: winuser.h:565
#define NULL
Definition: types.h:112
#define SB_LINEUP
Definition: winuser.h:564
#define SB_BOTTOM
Definition: winuser.h:577
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1340
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by ConWndProc(), and OnMouse().

◆ OnSize()

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

Definition at line 2104 of file conwnd.c.

2105 {
2106  PCONSRV_CONSOLE Console = GuiData->Console;
2107 
2108  /* Do nothing if the window is hidden */
2109  if (!GuiData->IsWindowVisible || IsIconic(GuiData->hWindow)) return;
2110 
2112 
2113  if (!GuiData->WindowSizeLock &&
2115  {
2116  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
2117  DWORD windx, windy, charx, chary;
2118  UINT WidthUnit, HeightUnit;
2119 
2120  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
2121 
2122  GuiData->WindowSizeLock = TRUE;
2123 
2124  windx = LOWORD(lParam);
2125  windy = HIWORD(lParam);
2126 
2127  /* Compensate for existing scroll bars (because lParam values do not accommodate scroll bar) */
2128  if (Buff->ViewSize.X < Buff->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // Window currently has a horizontal scrollbar
2129  if (Buff->ViewSize.Y < Buff->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // Window currently has a vertical scrollbar
2130 
2131  charx = windx / (int)WidthUnit ;
2132  chary = windy / (int)HeightUnit;
2133 
2134  /* Character alignment (round size up or down) */
2135  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
2136  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
2137 
2138  /* Compensate for added scroll bars in window */
2139  if (Buff->ViewSize.X < Buff->ScreenBufferSize.X) windy -= GetSystemMetrics(SM_CYHSCROLL); // Window will have a horizontal scroll bar
2140  if (Buff->ViewSize.Y < Buff->ScreenBufferSize.Y) windx -= GetSystemMetrics(SM_CXVSCROLL); // Window will have a vertical scroll bar
2141 
2142  charx = windx / (int)WidthUnit ;
2143  chary = windy / (int)HeightUnit;
2144 
2145  /* Character alignment (round size up or down) */
2146  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
2147  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
2148 
2149  /* Resize window */
2150  if ((charx != Buff->ViewSize.X) || (chary != Buff->ViewSize.Y))
2151  {
2152  Buff->ViewSize.X = (charx <= (DWORD)Buff->ScreenBufferSize.X) ? charx : Buff->ScreenBufferSize.X;
2153  Buff->ViewSize.Y = (chary <= (DWORD)Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
2154  }
2155 
2156  ResizeConWnd(GuiData, WidthUnit, HeightUnit);
2157 
2158  /* Adjust the start of the visible area if we are attempting to show nonexistent areas */
2159  if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) < Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
2160  if ((Buff->ScreenBufferSize.Y - Buff->ViewOrigin.Y) < Buff->ViewSize.Y) Buff->ViewOrigin.Y = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
2161  InvalidateRect(GuiData->hWindow, NULL, TRUE);
2162 
2163  GuiData->WindowSizeLock = FALSE;
2164  }
2165 
2166  LeaveCriticalSection(&Console->Lock);
2167 }
#define SM_CYHSCROLL
Definition: winuser.h:956
#define SIZE_MAXIMIZED
Definition: winuser.h:2487
#define TRUE
Definition: types.h:120
#define SIZE_RESTORED
Definition: winuser.h:2485
static VOID ResizeConWnd(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
Definition: conwnd.c:428
BOOL WINAPI IsIconic(_In_ HWND)
#define DWORD
Definition: nt_native.h:44
WPARAM wParam
Definition: combotst.c:138
BOOL WindowSizeLock
Definition: conwnd.h:43
#define FALSE
Definition: types.h:117
COORD ScreenBufferSize
Definition: conio.h:62
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
ULONG X
Definition: bl.h:1339
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:2486
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
FORCEINLINE VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.h:22
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define SM_CXVSCROLL
Definition: winuser.h:955
CConsole Console
#define HIWORD(l)
Definition: typedefs.h:247
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1340
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 ConWndProc().

◆ OnTimer()

static VOID OnTimer ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1310 of file conwnd.c.

1311 {
1312  PCONSRV_CONSOLE Console = GuiData->Console;
1314 
1315  /* Do nothing if the window is hidden */
1316  if (!GuiData->IsWindowVisible) return;
1317 
1319 
1321 
1322  Buff = GuiData->ActiveBuffer;
1323 
1324  if (GetType(Buff) == TEXTMODE_BUFFER)
1325  {
1326  /* Repaint the caret */
1327  InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
1328  Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
1329 
1330  if ((GuiData->OldCursor.x != Buff->CursorPosition.X) ||
1331  (GuiData->OldCursor.y != Buff->CursorPosition.Y))
1332  {
1333  SCROLLINFO sInfo;
1334  int OldScrollX = -1, OldScrollY = -1;
1335  int NewScrollX = -1, NewScrollY = -1;
1336 
1337  sInfo.cbSize = sizeof(sInfo);
1338  sInfo.fMask = SIF_POS;
1339  // Capture the original position of the scroll bars and save them.
1340  if (GetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo)) OldScrollX = sInfo.nPos;
1341  if (GetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo)) OldScrollY = sInfo.nPos;
1342 
1343  // If we successfully got the info for the horizontal scrollbar
1344  if (OldScrollX >= 0)
1345  {
1346  if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) ||
1347  (Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X)))
1348  {
1349  // Handle the horizontal scroll bar
1350  if (Buff->CursorPosition.X >= Buff->ViewSize.X)
1351  NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1;
1352  else
1353  NewScrollX = 0;
1354  }
1355  else
1356  {
1357  NewScrollX = OldScrollX;
1358  }
1359  }
1360  // If we successfully got the info for the vertical scrollbar
1361  if (OldScrollY >= 0)
1362  {
1363  if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) ||
1364  (Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y)))
1365  {
1366  // Handle the vertical scroll bar
1367  if (Buff->CursorPosition.Y >= Buff->ViewSize.Y)
1368  NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1;
1369  else
1370  NewScrollY = 0;
1371  }
1372  else
1373  {
1374  NewScrollY = OldScrollY;
1375  }
1376  }
1377 
1378  // Adjust scroll bars and refresh the window if the cursor has moved outside the visible area
1379  // NOTE: OldScroll# and NewScroll# will both be -1 (initial value) if the info for the respective scrollbar
1380  // was not obtained successfully in the previous steps. This means their difference is 0 (no scrolling)
1381  // and their associated scrollbar is left alone.
1382  if ((OldScrollX != NewScrollX) || (OldScrollY != NewScrollY))
1383  {
1384  Buff->ViewOrigin.X = NewScrollX;
1385  Buff->ViewOrigin.Y = NewScrollY;
1386  ScrollWindowEx(GuiData->hWindow,
1387  (OldScrollX - NewScrollX) * GuiData->CharWidth,
1388  (OldScrollY - NewScrollY) * GuiData->CharHeight,
1389  NULL,
1390  NULL,
1391  NULL,
1392  NULL,
1393  SW_INVALIDATE);
1394  if (NewScrollX >= 0)
1395  {
1396  sInfo.nPos = NewScrollX;
1397  SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
1398  }
1399  if (NewScrollY >= 0)
1400  {
1401  sInfo.nPos = NewScrollY;
1402  SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
1403  }
1404  UpdateWindow(GuiData->hWindow);
1405  // InvalidateRect(GuiData->hWindow, NULL, FALSE);
1406  GuiData->OldCursor.x = Buff->CursorPosition.X;
1407  GuiData->OldCursor.y = Buff->CursorPosition.Y;
1408  }
1409  }
1410  }
1411  else /* if (GetType(Buff) == GRAPHICS_BUFFER) */
1412  {
1413  }
1414 
1415  LeaveCriticalSection(&Console->Lock);
1416 }
long y
Definition: polytest.cpp:48
BOOLEAN CursorBlinkOn
Definition: conio.h:72
long x
Definition: polytest.cpp:48
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
#define SB_HORZ
Definition: winuser.h:552
COORD CursorPosition
Definition: conio.h:71
BOOL WINAPI UpdateWindow(_In_ HWND)
if(dx==0 &&dy==0)
Definition: linetemp.h:174
UINT CharHeight
Definition: conwnd.h:87
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#define CONGUI_UPDATE_TIMER
Definition: conwnd.c:36
#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)
VOID InvalidateCell(PGUI_CONSOLE_DATA GuiData, SHORT x, SHORT y)
Definition: guiterm.c:88
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
ULONG X
Definition: bl.h:1339
POINT OldCursor
Definition: conwnd.h:54
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
#define SW_INVALIDATE
Definition: winuser.h:2559
#define SIF_POS
Definition: winuser.h:1224
#define GetType(This)
Definition: conio.h:54
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
#define NULL
Definition: types.h:112
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:1340
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by ConWndProc().

◆ PaintSelectionRect()

static VOID PaintSelectionRect ( PGUI_CONSOLE_DATA  GuiData,
PPAINTSTRUCT  pps 
)
static

Definition at line 900 of file conwnd.c.

901 {
902  HRGN rgnPaint = CreateRectRgnIndirect(&pps->rcPaint);
903  HRGN rgnSel = CreateSelectionRgn(GuiData, GuiData->LineSelection,
904  &GuiData->Selection.dwSelectionAnchor,
905  &GuiData->Selection.srSelection);
906 
907  /* Invert the selection */
908 
909  int ErrorCode = CombineRgn(rgnPaint, rgnPaint, rgnSel, RGN_AND);
910  if (ErrorCode != ERROR && ErrorCode != NULLREGION)
911  {
912  InvertRgn(pps->hdc, rgnPaint);
913  }
914 
915  DeleteObject(rgnSel);
916  DeleteObject(rgnPaint);
917 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR(name)
Definition: error_private.h:53
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
#define NULLREGION
Definition: wingdi.h:361
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
SMALL_RECT srSelection
Definition: wincon.h:210
#define RGN_AND
Definition: wingdi.h:356
BOOL LineSelection
Definition: conwnd.h:94
static HRGN CreateSelectionRgn(PGUI_CONSOLE_DATA GuiData, BOOL LineSelection, PCOORD SelectionAnchor, PSMALL_RECT SmallRect)
Definition: conwnd.c:810
BOOL WINAPI InvertRgn(_In_ HDC, _In_ HRGN)
Definition: painting.c:229

Referenced by OnPaint().

◆ Paste()

static VOID Paste ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 2052 of file conwnd.c.

2053 {
2054  if (OpenClipboard(GuiData->hWindow))
2055  {
2057 
2058  if (GetType(Buffer) == TEXTMODE_BUFFER)
2059  {
2061  }
2062  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
2063  {
2065  }
2066 
2067  CloseClipboard();
2068  }
2069 }
VOID GuiPasteToTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: text.c:339
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
Definition: bufpool.h:45
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
#define GetType(This)
Definition: conio.h:54
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
VOID GuiPasteToGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: graphics.c:111

Referenced by DECLARE_INTERFACE_(), OnCommand(), OnMouse(), and CConsole::ReadLine().

◆ PointToCoord()

static COORD PointToCoord ( PGUI_CONSOLE_DATA  GuiData,
LPARAM  lParam 
)
static

Definition at line 1574 of file conwnd.c.

1575 {
1577  COORD Coord;
1578  UINT WidthUnit, HeightUnit;
1579 
1580  GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
1581 
1582  Coord.X = Buffer->ViewOrigin.X + ((SHORT)LOWORD(lParam) / (int)WidthUnit );
1583  Coord.Y = Buffer->ViewOrigin.Y + ((SHORT)HIWORD(lParam) / (int)HeightUnit);
1584 
1585  /* Clip coordinate to ensure it's inside buffer */
1586  if (Coord.X < 0)
1587  Coord.X = 0;
1588  else if (Coord.X >= Buffer->ScreenBufferSize.X)
1589  Coord.X = Buffer->ScreenBufferSize.X - 1;
1590 
1591  if (Coord.Y < 0)
1592  Coord.Y = 0;
1593  else if (Coord.Y >= Buffer->ScreenBufferSize.Y)
1594  Coord.Y = Buffer->ScreenBufferSize.Y - 1;
1595 
1596  return Coord;
1597 }
short SHORT
Definition: pedump.c:59
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1339
Definition: bl.h:1337
FORCEINLINE VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.h:22
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:247
ULONG Y
Definition: bl.h:1340
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 OnMouse().

◆ RegisterConWndClass()

BOOLEAN RegisterConWndClass ( IN HINSTANCE  hInstance)

Definition at line 136 of file conwnd.c.

137 {
139  ATOM WndClassAtom;
140 
143  IMAGE_ICON,
146  LR_SHARED);
149  IMAGE_ICON,
152  LR_SHARED);
154 
155  WndClass.cbSize = sizeof(WNDCLASSEXW);
156  WndClass.lpszClassName = GUI_CONWND_CLASS;
157  WndClass.lpfnWndProc = ConWndProc;
158  WndClass.style = CS_DBLCLKS /* | CS_HREDRAW | CS_VREDRAW */;
159  WndClass.hInstance = hInstance;
160  WndClass.hIcon = ghDefaultIcon;
161  WndClass.hIconSm = ghDefaultIconSm;
162  WndClass.hCursor = ghDefaultCursor;
163  WndClass.hbrBackground = NULL;
164  WndClass.lpszMenuName = NULL;
165  WndClass.cbClsExtra = 0;
166  WndClass.cbWndExtra = GWLP_CONWND_ALLOC;
167 
168  WndClassAtom = RegisterClassExW(&WndClass);
169  if (WndClassAtom == 0)
170  {
171  DPRINT1("Failed to register GUI console class\n");
172  }
173  else
174  {
175  NtUserConsoleControl(GuiConsoleWndClassAtom, &WndClassAtom, sizeof(ATOM));
176  }
177 
178  return (WndClassAtom != 0);
179 }
#define LR_SHARED
Definition: winuser.h:1094
#define IMAGE_ICON
Definition: winuser.h:212
WORD ATOM
Definition: dimm.idl:113
#define GWLP_CONWND_ALLOC
Definition: conwnd.c:43
#define SM_CYSMICON
Definition: winuser.h:1007
struct _WNDCLASSEXW WNDCLASSEXW
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
HINSTANCE hInstance
Definition: charmap.c:20
HICON ghDefaultIcon
Definition: conwnd.c:73
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
NTSTATUS APIENTRY NtUserConsoleControl(IN CONSOLECONTROL ConsoleCtrl, IN PVOID ConsoleCtrlInfo, IN ULONG ConsoleCtrlInfoLength)
Definition: console.c:14
#define SM_CXICON
Definition: winuser.h:966
static LRESULT CALLBACK ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:2250
#define IDI_TERMINAL
Definition: resource.h:44
int WINAPI GetSystemMetrics(_In_ int)
#define GUI_CONWND_CLASS
Definition: conwnd.h:15
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define SM_CXSMICON
Definition: winuser.h:1006
#define SM_CYICON
Definition: winuser.h:967
HICON ghDefaultIconSm
Definition: conwnd.c:74
HCURSOR ghDefaultCursor
Definition: conwnd.c:75
#define CS_DBLCLKS
Definition: winuser.h:646
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define IDC_ARROW
Definition: winuser.h:682
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
WCHAR WndClass[]
Definition: capicon.c:23

Referenced by GuiInit().

◆ ResizeConWnd()

static VOID ResizeConWnd ( PGUI_CONSOLE_DATA  GuiData,
DWORD  WidthUnit,
DWORD  HeightUnit 
)
static

Definition at line 428 of file conwnd.c.

429 {
430  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
431  SCROLLINFO sInfo;
432 
433  DWORD Width, Height;
434 
435  Width = Buff->ViewSize.X * WidthUnit +
437  Height = Buff->ViewSize.Y * HeightUnit +
439 
440  /* Set scrollbar sizes */
441  sInfo.cbSize = sizeof(sInfo);
442  sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
443  sInfo.nMin = 0;
444  if (Buff->ScreenBufferSize.Y > Buff->ViewSize.Y)
445  {
446  sInfo.nMax = Buff->ScreenBufferSize.Y - 1;
447  sInfo.nPage = Buff->ViewSize.Y;
448  sInfo.nPos = Buff->ViewOrigin.Y;
449  SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
451  ShowScrollBar(GuiData->hWindow, SB_VERT, TRUE);
452  }
453  else
454  {
455  ShowScrollBar(GuiData->hWindow, SB_VERT, FALSE);
456  }
457 
458  if (Buff->ScreenBufferSize.X > Buff->ViewSize.X)
459  {
460  sInfo.nMax = Buff->ScreenBufferSize.X - 1;
461  sInfo.nPage = Buff->ViewSize.X;
462  sInfo.nPos = Buff->ViewOrigin.X;
463  SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
465  ShowScrollBar(GuiData->hWindow, SB_HORZ, TRUE);
466  }
467  else
468  {
469  ShowScrollBar(GuiData->hWindow, SB_HORZ, FALSE);
470  }
471 
472  /* Resize the window */
473  SetWindowPos(GuiData->hWindow, NULL, 0, 0, Width, Height,
475  // NOTE: The SWP_NOCOPYBITS flag can be replaced by a subsequent call
476  // to: InvalidateRect(GuiData->hWindow, NULL, TRUE);
477 }
#define SM_CYHSCROLL
Definition: winuser.h:956
#define SIF_RANGE
Definition: winuser.h:1225
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:124
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
#define SM_CXEDGE
Definition: winuser.h:1002
_In_ HFONT _Out_ PUINT Height
Definition: font.h:124
#define SWP_NOZORDER
Definition: winuser.h:1237
#define SM_CYFRAME
Definition: winuser.h:990
#define SM_CXFRAME
Definition: winuser.h:988
#define SIF_PAGE
Definition: winuser.h:1223
#define SWP_NOCOPYBITS
Definition: winuser.h:1233
#define FALSE
Definition: types.h:117
COORD ScreenBufferSize
Definition: conio.h:62
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#define SM_CYEDGE
Definition: winuser.h:1003
ULONG X
Definition: bl.h:1339
#define SM_CYCAPTION
Definition: winuser.h:957
#define SWP_NOACTIVATE
Definition: winuser.h:1232
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SIF_POS
Definition: winuser.h:1224
#define NULL
Definition: types.h:112
#define SM_CXVSCROLL
Definition: winuser.h:955
#define SWP_NOMOVE
Definition: winuser.h:1234
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
ULONG Y
Definition: bl.h:1340
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by ConWndProc(), and OnSize().

◆ SelectAll()

static VOID SelectAll ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 315 of file conwnd.c.

316 {
317  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
318  COORD SelectionAnchor;
319 
320  /* Clear the old selection */
322 
323  /*
324  * The selection area extends to the whole screen buffer's width.
325  */
326  SelectionAnchor.X = SelectionAnchor.Y = 0;
327  GuiData->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
328 
329  /*
330  * Determine whether the selection must extend to just some part
331  * (for text-mode screen buffers) or to all of the screen buffer's
332  * height (for graphics ones).
333  */
334  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
335  {
336  /*
337  * We select all the characters from the first line
338  * to the line where the cursor is positioned.
339  */
340  GuiData->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
341  }
342  else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
343  {
344  /*
345  * We select all the screen buffer area.
346  */
347  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
348  }
349 
350  /* Restart a new selection */
352  UpdateSelection(GuiData, &SelectionAnchor, &GuiData->dwSelectionCursor);
353 }
COORD dwSelectionCursor
Definition: conwnd.h:93
COORD CursorPosition
Definition: conio.h:71
#define CONSOLE_NO_SELECTION
Definition: wincon.h:102
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:920
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:105
COORD ScreenBufferSize
Definition: conio.h:62
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
ULONG X
Definition: bl.h:1339
Definition: bl.h:1337
#define GetType(This)
Definition: conio.h:54
ULONG Y
Definition: bl.h:1340

Referenced by OnCommand().

◆ SendMenuEvent()

static VOID SendMenuEvent ( PCONSRV_CONSOLE  Console,
UINT  CmdId 
)
static

Definition at line 274 of file conwnd.c.

275 {
276  INPUT_RECORD er;
277 
278  DPRINT("Menu item ID: %d\n", CmdId);
279 
281 
282  /* Send a menu event */
283  er.EventType = MENU_EVENT;
284  er.Event.MenuEvent.dwCommandId = CmdId;
286 
288 }
#define TRUE
Definition: types.h:120
#define MENU_EVENT
Definition: wincon.h:131
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
CConsole Console
WORD EventType
Definition: wincon.h:273
MENU_EVENT_RECORD MenuEvent
Definition: wincon.h:278
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define DPRINT
Definition: sndvol32.h:71
union _INPUT_RECORD::@3236 Event
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:201

Referenced by ConWndProc(), and OnCommand().

◆ SetConWndConsoleLeaderCID()

VOID SetConWndConsoleLeaderCID ( IN PGUI_CONSOLE_DATA  GuiData)

Definition at line 48 of file conwnd.c.

49 {
50  PCONSOLE_PROCESS_DATA ProcessData;
51 
52  ProcessData = ConSrvGetConsoleLeaderProcess(GuiData->Console);
53 
54  ASSERT(ProcessData != NULL);
55  DPRINT("ProcessData: %p, ProcessData->Process %p.\n", ProcessData, ProcessData->Process);
56 
57  if (ProcessData->Process)
58  {
59  CLIENT_ID ConsoleLeaderCID = ProcessData->Process->ClientId;
61  (LONG_PTR)(ConsoleLeaderCID.UniqueProcess));
63  (LONG_PTR)(ConsoleLeaderCID.UniqueThread));
64  }
65  else
66  {
67  SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_PID, 0);
68  SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_TID, 0);
69  }
70 }
PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console)
Definition: console.c:1363
HANDLE UniqueProcess
Definition: compat.h:684
#define GWLP_CONSOLE_LEADER_TID
Definition: conwnd.c:45
#define GWLP_CONSOLE_LEADER_PID
Definition: conwnd.c:44
CLIENT_ID ClientId
Definition: csrsrv.h:38
#define ASSERT(a)
Definition: mode.c:44
PCSR_PROCESS Process
Definition: consrv.h:43
HANDLE UniqueThread
Definition: compat.h:685
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define NULL
Definition: types.h:112
#define SetWindowLongPtrW
Definition: winuser.h:5326
#define DPRINT
Definition: sndvol32.h:71

Referenced by GuiRefreshInternalInfo().

◆ UnRegisterConWndClass()

BOOLEAN UnRegisterConWndClass ( HINSTANCE  hInstance)

Definition at line 182 of file conwnd.c.

183 {
185 }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
HINSTANCE hInstance
Definition: charmap.c:20
#define GUI_CONWND_CLASS
Definition: conwnd.h:15

◆ UpdateSelection()

static VOID UpdateSelection ( PGUI_CONSOLE_DATA  GuiData,
PCOORD SelectionAnchor  OPTIONAL,
PCOORD  coord 
)
static

Definition at line 920 of file conwnd.c.

923 {
924  PCONSRV_CONSOLE Console = GuiData->Console;
925  HRGN oldRgn = CreateSelectionRgn(GuiData, GuiData->LineSelection,
926  &GuiData->Selection.dwSelectionAnchor,
927  &GuiData->Selection.srSelection);
928 
929  /* Update the anchor if needed (use the old one if NULL) */
930  if (SelectionAnchor)
931  GuiData->Selection.dwSelectionAnchor = *SelectionAnchor;
932 
933  // TODO: Scroll buffer to bring 'coord' into view
934 
935  if (coord != NULL)
936  {
937  SMALL_RECT rc;
938  HRGN newRgn;
939 
940  /*
941  * Pressing the Control key while selecting text, allows us to enter
942  * into line-selection mode, the selection mode of *nix terminals.
943  */
944  BOOL OldLineSel = GuiData->LineSelection;
946 
947  /* Exchange left/top with right/bottom if required */
948  rc.Left = min(GuiData->Selection.dwSelectionAnchor.X, coord->X);
949  rc.Top = min(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
950  rc.Right = max(GuiData->Selection.dwSelectionAnchor.X, coord->X);
951  rc.Bottom = max(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
952 
953  newRgn = CreateSelectionRgn(GuiData, GuiData->LineSelection,
954  &GuiData->Selection.dwSelectionAnchor,
955  &rc);
956 
958  {
959  if (OldLineSel != GuiData->LineSelection ||
960  memcmp(&rc, &GuiData->Selection.srSelection, sizeof(SMALL_RECT)) != 0)
961  {
962  /* Calculate the region that needs to be updated */
963  if (oldRgn && newRgn && CombineRgn(newRgn, newRgn, oldRgn, RGN_XOR) != ERROR)
964  {
965  InvalidateRgn(GuiData->hWindow, newRgn, FALSE);
966  }
967  }
968  }
969  else
970  {
971  InvalidateRgn(GuiData->hWindow, newRgn, FALSE);
972  }
973 
974  DeleteObject(newRgn);
975 
977  GuiData->Selection.srSelection = rc;
978  GuiData->dwSelectionCursor = *coord;
979 
980  if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
981  {
982  LPWSTR SelTypeStr = NULL , WindowTitle = NULL;
983  SIZE_T SelTypeStrLength = 0, Length = 0;
984 
985  /* Clear the old selection */
987  {
988  InvalidateRgn(GuiData->hWindow, oldRgn, FALSE);
989  }
990 
991  /*
992  * When passing a zero-length buffer size, LoadString(...) returns
993