ReactOS  0.4.13-dev-66-gc714b7f
conwnd.c File Reference
#include <consrv.h>
#include <intrin.h>
#include <windowsx.h>
#include <shellapi.h>
#include <debug.h>
#include "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 (PGUI_CONSOLE_DATA GuiData, LPWSTR FaceName, ULONG FontFamily, COORD FontSize, ULONG FontWeight)
 
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)
 

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 177 of file conwnd.c.

179 {
180  UINT i = 0;
181  WCHAR szMenuString[255];
182  HMENU hSubMenu;
183 
184  do
185  {
186  if (Items[i].uID != (UINT)-1)
187  {
189  Items[i].uID,
190  szMenuString,
191  ARRAYSIZE(szMenuString)) > 0)
192  {
193  if (Items[i].SubMenu != NULL)
194  {
195  hSubMenu = CreatePopupMenu();
196  if (hSubMenu != NULL)
197  {
198  AppendMenuItems(hSubMenu, Items[i].SubMenu);
199 
200  if (!AppendMenuW(hMenu,
202  (UINT_PTR)hSubMenu,
203  szMenuString))
204  {
205  DestroyMenu(hSubMenu);
206  }
207  }
208  }
209  else
210  {
211  AppendMenuW(hMenu,
212  MF_STRING,
213  Items[i].wCmdID,
214  szMenuString);
215  }
216  }
217  }
218  else
219  {
220  AppendMenuW(hMenu,
221  MF_SEPARATOR,
222  0,
223  NULL);
224  }
225  i++;
226  } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].wCmdID == 0));
227 }
#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)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define MF_SEPARATOR
Definition: winuser.h:137
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define MF_POPUP
Definition: winuser.h:136
BOOL WINAPI DestroyMenu(_In_ HMENU)
unsigned int UINT
Definition: ndis.h:50
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
HINSTANCE ConSrvDllInstance
Definition: init.c:21
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
static VOID AppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: conwnd.c:177

Referenced by ConWndProc(), and CreateSysMenu().

◆ ConWndProc()

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

Definition at line 2161 of file conwnd.c.

2162 {
2163  LRESULT Result = 0;
2164  PGUI_CONSOLE_DATA GuiData = NULL;
2166 
2167  /*
2168  * - If it's the first time we create a window for the terminal,
2169  * just initialize it and return.
2170  *
2171  * - If we are destroying the window, just do it and return.
2172  */
2173  if (msg == WM_NCCREATE)
2174  {
2176  }
2177  else if (msg == WM_NCDESTROY)
2178  {
2179  return OnNcDestroy(hWnd);
2180  }
2181 
2182  /*
2183  * Now the terminal window is initialized.
2184  * Get the terminal data via the window's data.
2185  * If there is no data, just go away.
2186  */
2187  GuiData = GuiGetGuiData(hWnd);
2188  if (GuiData == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
2189 
2190  // TEMPORARY HACK until all of the functions can deal with a NULL GuiData->ActiveBuffer ...
2191  if (GuiData->ActiveBuffer == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
2192 
2193  /*
2194  * Just retrieve a pointer to the console in case somebody needs it.
2195  * It is not NULL because it was checked in GuiGetGuiData.
2196  * Each helper function which needs the console has to validate and lock it.
2197  */
2198  Console = GuiData->Console;
2199 
2200  /* We have a console, start message dispatching */
2201  switch (msg)
2202  {
2203  case WM_ACTIVATE:
2204  OnActivate(GuiData, wParam);
2205  break;
2206 
2207  case WM_CLOSE:
2208  if (OnClose(GuiData)) goto Default;
2209  break;
2210 
2211  case WM_PAINT:
2212  OnPaint(GuiData);
2213  break;
2214 
2215  case WM_TIMER:
2216  OnTimer(GuiData);
2217  break;
2218 
2219  case WM_PALETTECHANGED:
2220  {
2221  DPRINT("WM_PALETTECHANGED called\n");
2222 
2223  /*
2224  * Protects against infinite loops:
2225  * "... A window that receives this message must not realize
2226  * its palette, unless it determines that wParam does not contain
2227  * its own window handle." (WM_PALETTECHANGED description - MSDN)
2228  *
2229  * This message is sent to all windows, including the one that
2230  * changed the system palette and caused this message to be sent.
2231  * The wParam of this message contains the handle of the window
2232  * that caused the system palette to change. To avoid an infinite
2233  * loop, care must be taken to check that the wParam of this message
2234  * does not match the window's handle.
2235  */
2236  if ((HWND)wParam == hWnd) break;
2237 
2238  DPRINT("WM_PALETTECHANGED ok\n");
2239  OnPaletteChanged(GuiData);
2240  DPRINT("WM_PALETTECHANGED quit\n");
2241  break;
2242  }
2243 
2244  case WM_KEYDOWN:
2245  case WM_KEYUP:
2246  case WM_CHAR:
2247  case WM_DEADCHAR:
2248  case WM_SYSKEYDOWN:
2249  case WM_SYSKEYUP:
2250  case WM_SYSCHAR:
2251  case WM_SYSDEADCHAR:
2252  {
2253  /* Detect Alt-Enter presses and switch back and forth to fullscreen mode */
2254  if (msg == WM_SYSKEYDOWN && (HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN)
2255  {
2256  /* Switch only at first Alt-Enter press, and ignore subsequent key repetitions */
2257  if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) != KF_REPEAT)
2258  GuiConsoleSwitchFullScreen(GuiData);
2259 
2260  break;
2261  }
2262  /* Detect Alt-Esc/Space/Tab presses defer to DefWindowProc */
2263  if ( (HIWORD(lParam) & KF_ALTDOWN) && (wParam == VK_ESCAPE || wParam == VK_SPACE || wParam == VK_TAB))
2264  {
2265  return DefWindowProcW(hWnd, msg, wParam, lParam);
2266  }
2267 
2268  OnKey(GuiData, msg, wParam, lParam);
2269  break;
2270  }
2271 
2272  case WM_SETCURSOR:
2273  {
2274  /* Do nothing if the window is hidden */
2275  if (!GuiData->IsWindowVisible) goto Default;
2276 
2277  /*
2278  * The message was sent because we are manually triggering a change.
2279  * Check whether the mouse is indeed present on this console window
2280  * and take appropriate decisions.
2281  */
2282  if (wParam == -1 && lParam == -1)
2283  {
2284  POINT mouseCoords;
2285  HWND hWndHit;
2286 
2287  /* Get the placement of the mouse */
2288  GetCursorPos(&mouseCoords);
2289 
2290  /* On which window is placed the mouse ? */
2291  hWndHit = WindowFromPoint(mouseCoords);
2292 
2293  /* It's our window. Perform the hit-test to be used later on. */
2294  if (hWndHit == hWnd)
2295  {
2296  wParam = (WPARAM)hWnd;
2297  lParam = DefWindowProcW(hWndHit, WM_NCHITTEST, 0,
2298  MAKELPARAM(mouseCoords.x, mouseCoords.y));
2299  }
2300  }
2301 
2302  /* Set the mouse cursor only when we are in the client area */
2303  if ((HWND)wParam == hWnd && LOWORD(lParam) == HTCLIENT)
2304  {
2305  if (GuiData->MouseCursorRefCount >= 0)
2306  {
2307  /* Show the cursor */
2308  SetCursor(GuiData->hCursor);
2309  }
2310  else
2311  {
2312  /* Hide the cursor if the reference count is negative */
2313  SetCursor(NULL);
2314  }
2315  return TRUE;
2316  }
2317  else
2318  {
2319  goto Default;
2320  }
2321  }
2322 
2323  case WM_LBUTTONDOWN:
2324  case WM_MBUTTONDOWN:
2325  case WM_RBUTTONDOWN:
2326  case WM_XBUTTONDOWN:
2327  case WM_LBUTTONUP:
2328  case WM_MBUTTONUP:
2329  case WM_RBUTTONUP:
2330  case WM_XBUTTONUP:
2331  case WM_LBUTTONDBLCLK:
2332  case WM_MBUTTONDBLCLK:
2333  case WM_RBUTTONDBLCLK:
2334  case WM_XBUTTONDBLCLK:
2335  case WM_MOUSEMOVE:
2336  case WM_MOUSEWHEEL:
2337  case WM_MOUSEHWHEEL:
2338  {
2339  Result = OnMouse(GuiData, msg, wParam, lParam);
2340  break;
2341  }
2342 
2343  case WM_HSCROLL:
2344  OnScroll(GuiData, SB_HORZ, LOWORD(wParam));
2345  break;
2346 
2347  case WM_VSCROLL:
2348  OnScroll(GuiData, SB_VERT, LOWORD(wParam));
2349  break;
2350 
2351  case WM_CONTEXTMENU:
2352  {
2353  /* Do nothing if the window is hidden */
2354  if (!GuiData->IsWindowVisible) break;
2355 
2356  if (DefWindowProcW(hWnd /*GuiData->hWindow*/, WM_NCHITTEST, 0, lParam) == HTCLIENT)
2357  {
2358  HMENU hMenu = CreatePopupMenu();
2359  if (hMenu != NULL)
2360  {
2362  TrackPopupMenuEx(hMenu,
2366  hWnd,
2367  NULL);
2368  DestroyMenu(hMenu);
2369  }
2370  break;
2371  }
2372  else
2373  {
2374  goto Default;
2375  }
2376  }
2377 
2378  case WM_INITMENU:
2379  {
2380  HMENU hMenu = (HMENU)wParam;
2381  if (hMenu != NULL)
2382  {
2383  /* Enable or disable the Close menu item */
2385  (GuiData->IsCloseButtonEnabled ? MF_ENABLED : MF_GRAYED));
2386 
2387  /* Enable or disable the Copy and Paste items */
2391  // FIXME: Following whether the active screen buffer is text-mode
2392  // or graphics-mode, search for CF_UNICODETEXT or CF_BITMAP formats.
2396  }
2397 
2399  break;
2400  }
2401 
2402  case WM_MENUSELECT:
2403  {
2404  if (HIWORD(wParam) == 0xFFFF) // Allow all the menu flags
2405  {
2407  }
2408  break;
2409  }
2410 
2411  case WM_COMMAND:
2412  case WM_SYSCOMMAND:
2413  {
2414  Result = OnCommand(GuiData, wParam, lParam);
2415  break;
2416  }
2417 
2418  case WM_DROPFILES:
2419  OnDropFiles(Console, (HDROP)wParam);
2420  break;
2421 
2422  case WM_SETFOCUS:
2423  case WM_KILLFOCUS:
2424  OnFocus(GuiData, (msg == WM_SETFOCUS));
2425  break;
2426 
2427  case WM_GETMINMAXINFO:
2428  OnGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam);
2429  break;
2430 
2431  case WM_MOVE:
2432  OnMove(GuiData);
2433  break;
2434 
2435 #if 0 // This code is here to prepare & control dynamic console SB resizing.
2436  case WM_SIZING:
2437  {
2438  PRECT dragRect = (PRECT)lParam;
2439  switch (wParam)
2440  {
2441  case WMSZ_LEFT:
2442  DPRINT1("WMSZ_LEFT\n");
2443  break;
2444  case WMSZ_RIGHT:
2445  DPRINT1("WMSZ_RIGHT\n");
2446  break;
2447  case WMSZ_TOP:
2448  DPRINT1("WMSZ_TOP\n");
2449  break;
2450  case WMSZ_TOPLEFT:
2451  DPRINT1("WMSZ_TOPLEFT\n");
2452  break;
2453  case WMSZ_TOPRIGHT:
2454  DPRINT1("WMSZ_TOPRIGHT\n");
2455  break;
2456  case WMSZ_BOTTOM:
2457  DPRINT1("WMSZ_BOTTOM\n");
2458  break;
2459  case WMSZ_BOTTOMLEFT:
2460  DPRINT1("WMSZ_BOTTOMLEFT\n");
2461  break;
2462  case WMSZ_BOTTOMRIGHT:
2463  DPRINT1("WMSZ_BOTTOMRIGHT\n");
2464  break;
2465  default:
2466  DPRINT1("wParam = %d\n", wParam);
2467  break;
2468  }
2469  DPRINT1("dragRect = {.left = %d ; .top = %d ; .right = %d ; .bottom = %d}\n",
2470  dragRect->left, dragRect->top, dragRect->right, dragRect->bottom);
2471  break;
2472  }
2473 #endif
2474 
2475  case WM_SIZE:
2476  OnSize(GuiData, wParam, lParam);
2477  break;
2478 
2479  case PM_RESIZE_TERMINAL:
2480  {
2481  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
2482  HDC hDC;
2483  HBITMAP hnew, hold;
2484 
2485  DWORD Width, Height;
2486  UINT WidthUnit, HeightUnit;
2487 
2488  /* Do nothing if the window is hidden */
2489  if (!GuiData->IsWindowVisible) break;
2490 
2491  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
2492 
2493  Width = Buff->ScreenBufferSize.X * WidthUnit ;
2494  Height = Buff->ScreenBufferSize.Y * HeightUnit;
2495 
2496  /* Recreate the framebuffer */
2497  hDC = GetDC(GuiData->hWindow);
2498  hnew = CreateCompatibleBitmap(hDC, Width, Height);
2499  ReleaseDC(GuiData->hWindow, hDC);
2500  hold = SelectObject(GuiData->hMemDC, hnew);
2501  if (GuiData->hBitmap)
2502  {
2503  if (hold == GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
2504  }
2505  GuiData->hBitmap = hnew;
2506 
2507  /* Resize the window to the user's values */
2508  GuiData->WindowSizeLock = TRUE;
2509  ResizeConWnd(GuiData, WidthUnit, HeightUnit);
2510  GuiData->WindowSizeLock = FALSE;
2511  break;
2512  }
2513 
2514  /*
2515  * Undocumented message sent by Windows' console.dll for applying console info.
2516  * See http://www.catch22.net/sites/default/source/files/setconsoleinfo.c
2517  * and http://www.scn.rain.com/~neighorn/PDF/MSBugPaper.pdf
2518  * for more information.
2519  */
2520  case WM_SETCONSOLEINFO:
2521  {
2522  GuiApplyUserSettings(GuiData, (HANDLE)wParam);
2523  break;
2524  }
2525 
2526  case PM_CONSOLE_BEEP:
2527  DPRINT1("Beep\n");
2528  Beep(800, 200);
2529  break;
2530 
2531  case PM_CONSOLE_SET_TITLE:
2532  SetWindowTextW(GuiData->hWindow, GuiData->Console->Title.Buffer);
2533  break;
2534 
2535  default: Default:
2537  break;
2538  }
2539 
2540  return Result;
2541 }
#define WM_MBUTTONUP
Definition: winuser.h:1759
VOID GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData, HANDLE hClientSection)
Definition: guisettings.c:258
static VOID OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
Definition: conwnd.c:688
#define WMSZ_BOTTOMRIGHT
Definition: winuser.h:2425
static VOID OnSize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:2029
static PGUI_CONSOLE_DATA GuiGetGuiData(HWND hWnd)
Definition: conwnd.c:407
#define TRUE
Definition: types.h:120
INT MouseCursorRefCount
Definition: conwnd.h:71
BOOL IsCloseButtonEnabled
Definition: conwnd.h:76
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:1693
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
long x
Definition: polytest.cpp:48
HDC WINAPI GetDC(_In_opt_ HWND)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define SB_VERT
Definition: winuser.h:553
#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:3915
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:415
LONG top
Definition: windef.h:292
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static LRESULT OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:343
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
static VOID OnMove(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:2095
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define WM_MOVE
Definition: winuser.h:1592
#define WMSZ_TOP
Definition: winuser.h:2420
#define KF_UP
Definition: winuser.h:2405
#define WM_NCHITTEST
Definition: winuser.h:1668
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
#define VK_TAB
Definition: winuser.h:2153
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:91
#define PM_RESIZE_TERMINAL
Definition: conwnd.h:20
LONG left
Definition: windef.h:291
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define VK_ESCAPE
Definition: winuser.h:2168
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
static VOID OnTimer(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1237
LONG right
Definition: windef.h:293
#define WM_NCCREATE
Definition: winuser.h:1665
#define VK_RETURN
Definition: winuser.h:2155
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WMSZ_TOPLEFT
Definition: winuser.h:2421
static VOID SendMenuEvent(PCONSRV_CONSOLE Console, UINT CmdId)
Definition: conwnd.c:261
static LRESULT OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:1525
BOOL WindowSizeLock
Definition: conwnd.h:43
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
COORD ScreenBufferSize
Definition: conio.h:87
#define WM_SETCURSOR
Definition: winuser.h:1618
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_MENUSELECT
Definition: winuser.h:1723
#define WM_DROPFILES
Definition: winuser.h:1801
#define WM_SYSCHAR
Definition: winuser.h:1697
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
static VOID OnActivate(PGUI_CONSOLE_DATA GuiData, WPARAM wParam)
Definition: conwnd.c:651
#define WM_SIZING
Definition: winuser.h:1783
#define CF_UNICODETEXT
Definition: constants.h:408
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define WM_KEYDOWN
Definition: winuser.h:1691
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
void DPRINT(...)
Definition: polytest.cpp:61
static VOID OnScroll(PGUI_CONSOLE_DATA GuiData, INT nBar, WORD sbCode)
Definition: conwnd.c:1391
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
ULONG X
Definition: bl.h:1340
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
#define KF_REPEAT
Definition: winuser.h:2404
#define WM_DEADCHAR
Definition: winuser.h:1694
static VOID OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:1072
static BOOL OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
Definition: conwnd.c:586
#define WM_KILLFOCUS
Definition: winuser.h:1596
#define WM_SIZE
Definition: winuser.h:1593
#define WM_TIMER
Definition: winuser.h:1718
#define MF_ENABLED
Definition: winuser.h:128
#define WMSZ_RIGHT
Definition: winuser.h:2419
#define WM_CLOSE
Definition: winuser.h:1603
#define WM_NCDESTROY
Definition: winuser.h:1666
#define WM_PALETTECHANGED
Definition: winuser.h:1838
#define WM_KEYUP
Definition: winuser.h:1692
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_RBUTTONUP
Definition: winuser.h:1756
#define WM_PAINT
Definition: winuser.h:1602
VOID GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:175
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1760
#define WM_COMMAND
Definition: winuser.h:1716
static VOID OnPaint(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:972
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
#define WMSZ_BOTTOM
Definition: winuser.h:2423
BOOL WINAPI DestroyMenu(_In_ HMENU)
static VOID OnDropFiles(PCONSRV_CONSOLE Console, HDROP hDrop)
Definition: conwnd.c:2109
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:1721
#define WM_ACTIVATE
Definition: winuser.h:1594
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_SYSDEADCHAR
Definition: winuser.h:1698
#define WM_SYSKEYUP
Definition: winuser.h:1696
#define WM_LBUTTONUP
Definition: winuser.h:1753
static VOID OnPaletteChanged(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1025
#define WM_MBUTTONDOWN
Definition: winuser.h:1758
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define WM_HSCROLL
Definition: winuser.h:1719
#define VK_SPACE
Definition: winuser.h:2173
HWND WINAPI WindowFromPoint(_In_ POINT)
static VOID OnGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
Definition: conwnd.c:1997
#define KF_ALTDOWN
Definition: winuser.h:2403
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:2546
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1757
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define HIWORD(l)
Definition: typedefs.h:246
LONG bottom
Definition: windef.h:294
#define PM_CONSOLE_SET_TITLE
Definition: conwnd.h:22
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
struct tagRECT * PRECT
static HBITMAP
Definition: button.c:44
static const GUICONSOLE_MENUITEM GuiConsoleEditMenuItems[]
Definition: conwnd.c:73
HBITMAP hBitmap
Definition: conwnd.h:63
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
#define HTCLIENT
Definition: winuser.h:2429
LONG_PTR LRESULT
Definition: windef.h:209
ULONG Y
Definition: bl.h:1341
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WM_SYSCOMMAND
Definition: winuser.h:1717
LPARAM lParam
Definition: combotst.c:139
#define WM_GETMINMAXINFO
Definition: winuser.h:1622
#define LOWORD(l)
Definition: pedump.c:82
static VOID AppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: conwnd.c:177
#define WMSZ_LEFT
Definition: winuser.h:2418
#define WMSZ_TOPRIGHT
Definition: winuser.h:2422
#define WMSZ_BOTTOMLEFT
Definition: winuser.h:2424
static LRESULT OnNcDestroy(HWND hWnd)
Definition: conwnd.c:1366
#define WM_VSCROLL
Definition: winuser.h:1720
#define WM_SETCONSOLEINFO
Definition: settings.h:21
static BOOL OnClose(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1345

Referenced by RegisterConWndClass().

◆ Copy()

static VOID Copy ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1954 of file conwnd.c.

1955 {
1956  if (OpenClipboard(GuiData->hWindow))
1957  {
1959 
1960  if (GetType(Buffer) == TEXTMODE_BUFFER)
1961  {
1963  }
1964  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
1965  {
1967  }
1968 
1969  CloseClipboard();
1970  }
1971 
1972  /* Clear the selection */
1973  UpdateSelection(GuiData, NULL, NULL);
1974 }
#define TEXTMODE_BUFFER
Definition: pccons.c:21
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:849
VOID GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: graphics.c:21
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
VOID GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: text.c:297
BOOL WINAPI OpenClipboard(_In_opt_ HWND)

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

◆ CreateDerivedFont()

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

Definition at line 479 of file conwnd.c.

485 {
486  LOGFONTW lf;
487 
488  /* Initialize the LOGFONT structure */
489  RtlZeroMemory(&lf, sizeof(lf));
490 
491  /* Retrieve the details of the current font */
492  if (GetObjectW(OrgFont, sizeof(lf), &lf) == 0)
493  return NULL;
494 
495  /* Change the font attributes */
496  // lf.lfHeight = FontSize.Y;
497  // lf.lfWidth = FontSize.X;
498  lf.lfWeight = FontWeight;
499  // lf.lfItalic = bItalic;
500  lf.lfUnderline = bUnderline;
501  lf.lfStrikeOut = bStrikeOut;
502 
503  /* Build a new font */
504  return CreateFontIndirectW(&lf);
505 }
smooth NULL
Definition: ftsmooth.c:416
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 RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
LONG lfWeight
Definition: dimm.idl:63
BYTE lfUnderline
Definition: dimm.idl:65

Referenced by InitFonts().

◆ CreateSelectionRgn()

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

Definition at line 739 of file conwnd.c.

743 {
744  if (!LineSelection)
745  {
746  RECT rect;
747  SmallRectToRect(GuiData, &rect, SmallRect);
748  return CreateRectRgnIndirect(&rect);
749  }
750  else
751  {
752  HRGN SelRgn;
753  COORD Begin, End;
754 
755  GetSelectionBeginEnd(&Begin, &End, SelectionAnchor, SmallRect);
756 
757  if (Begin.Y == End.Y)
758  {
759  SMALL_RECT sr;
760  RECT r ;
761 
762  sr.Left = Begin.X;
763  sr.Top = Begin.Y;
764  sr.Right = End.X;
765  sr.Bottom = End.Y;
766 
767  // Debug thingie to see whether I can put this corner case
768  // together with the previous one.
769  if (SmallRect->Left != sr.Left ||
770  SmallRect->Top != sr.Top ||
771  SmallRect->Right != sr.Right ||
772  SmallRect->Bottom != sr.Bottom)
773  {
774  DPRINT1("\n"
775  "SmallRect = (%d, %d, %d, %d)\n"
776  "sr = (%d, %d, %d, %d)\n"
777  "\n",
778  SmallRect->Left, SmallRect->Top, SmallRect->Right, SmallRect->Bottom,
779  sr.Left, sr.Top, sr.Right, sr.Bottom);
780  }
781 
782  SmallRectToRect(GuiData, &r, &sr);
783  SelRgn = CreateRectRgnIndirect(&r);
784  }
785  else
786  {
787  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
788 
789  HRGN rg1, rg2, rg3;
790  SMALL_RECT sr1, sr2, sr3;
791  RECT r1 , r2 , r3 ;
792 
793  sr1.Left = Begin.X;
794  sr1.Top = Begin.Y;
795  sr1.Right = ActiveBuffer->ScreenBufferSize.X - 1;
796  sr1.Bottom = Begin.Y;
797 
798  sr2.Left = 0;
799  sr2.Top = Begin.Y + 1;
800  sr2.Right = ActiveBuffer->ScreenBufferSize.X - 1;
801  sr2.Bottom = End.Y - 1;
802 
803  sr3.Left = 0;
804  sr3.Top = End.Y;
805  sr3.Right = End.X;
806  sr3.Bottom = End.Y;
807 
808  SmallRectToRect(GuiData, &r1, &sr1);
809  SmallRectToRect(GuiData, &r2, &sr2);
810  SmallRectToRect(GuiData, &r3, &sr3);
811 
812  rg1 = CreateRectRgnIndirect(&r1);
813  rg2 = CreateRectRgnIndirect(&r2);
814  rg3 = CreateRectRgnIndirect(&r3);
815 
816  CombineRgn(rg1, rg1, rg2, RGN_XOR);
817  CombineRgn(rg1, rg1, rg3, RGN_XOR);
818  DeleteObject(rg3);
819  DeleteObject(rg2);
820 
821  SelRgn = rg1;
822  }
823 
824  return SelRgn;
825  }
826 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
FORCEINLINE VOID SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
Definition: guiterm.h:43
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:718
& rect
Definition: startmenu.cpp:1413
SHORT Right
Definition: wincon.h:178
SHORT Left
Definition: wincon.h:176
COORD ScreenBufferSize
Definition: conio.h:87
#define RGN_XOR
Definition: wingdi.h:359
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:28
static DNS_RECORDW r2
Definition: record.c:38
SHORT Top
Definition: blue.h:26
SHORT Bottom
Definition: wincon.h:179
Definition: bl.h:1338
SHORT Top
Definition: wincon.h:177
#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:1275
SHORT Right
Definition: blue.h:27
ULONG Y
Definition: bl.h:1341

Referenced by PaintSelectionRect(), and UpdateSelection().

◆ CreateSysMenu()

VOID CreateSysMenu ( HWND  hWnd)

Definition at line 231 of file conwnd.c.

232 {
233  MENUITEMINFOW mii;
234  WCHAR szMenuStringBack[255];
235  WCHAR *ptrTab;
236  HMENU hMenu = GetSystemMenu(hWnd, FALSE);
237  if (hMenu != NULL)
238  {
239  mii.cbSize = sizeof(mii);
240  mii.fMask = MIIM_STRING;
241  mii.dwTypeData = szMenuStringBack;
242  mii.cch = sizeof(szMenuStringBack)/sizeof(WCHAR);
243 
244  GetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
245 
246  ptrTab = wcschr(szMenuStringBack, '\t');
247  if (ptrTab)
248  {
249  *ptrTab = '\0';
250  mii.cch = wcslen(szMenuStringBack);
251 
252  SetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
253  }
254 
256  DrawMenuBar(hWnd);
257  }
258 }
BOOL WINAPI DrawMenuBar(_In_ HWND)
HWND hWnd
Definition: settings.c:17
LPWSTR dwTypeData
Definition: winuser.h:3211
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
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:85
#define MIIM_STRING
Definition: winuser.h:722
#define SC_CLOSE
Definition: winuser.h:2546
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static VOID AppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: conwnd.c:177

Referenced by GuiConsoleInputThread().

◆ DeleteFonts()

VOID DeleteFonts ( PGUI_CONSOLE_DATA  GuiData)

Definition at line 468 of file conwnd.c.

469 {
470  ULONG i;
471  for (i = 0; i < ARRAYSIZE(GuiData->Font); ++i)
472  {
473  if (GuiData->Font[i] != NULL) DeleteObject(GuiData->Font[i]);
474  GuiData->Font[i] = NULL;
475  }
476 }
#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
smooth NULL
Definition: ftsmooth.c:416
HFONT Font[FONT_MAXNO]
Definition: conwnd.h:84
unsigned int ULONG
Definition: retypes.h:1

Referenced by InitFonts(), and OnNcDestroy().

◆ GetSelectionBeginEnd()

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

Definition at line 718 of file conwnd.c.

721 {
722  if (Begin == NULL || End == NULL) return;
723 
724  *Begin = *SelectionAnchor;
725  End->X = (SelectionAnchor->X == SmallRect->Left) ? SmallRect->Right
726  /* Case X != Left, must be == Right */ : SmallRect->Left;
727  End->Y = (SelectionAnchor->Y == SmallRect->Top ) ? SmallRect->Bottom
728  /* Case Y != Top, must be == Bottom */ : SmallRect->Top;
729 
730  /* Exchange Begin / End if Begin > End lexicographically */
731  if (Begin->Y > End->Y || (Begin->Y == End->Y && Begin->X > End->X))
732  {
733  End->X = _InterlockedExchange16(&Begin->X, End->X);
734  End->Y = _InterlockedExchange16(&Begin->Y, End->Y);
735  }
736 }
SHORT Right
Definition: wincon.h:178
SHORT Left
Definition: wincon.h:176
short _InterlockedExchange16(_Interlocked_operand_ short volatile *_Target, short _Value)
smooth NULL
Definition: ftsmooth.c:416
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: wincon.h:179
SHORT Top
Definition: wincon.h:177
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:1275
ULONG Y
Definition: bl.h:1341

Referenced by CreateSelectionRgn(), and GuiCopyFromTextModeBuffer().

◆ GuiGetGuiData()

static PGUI_CONSOLE_DATA GuiGetGuiData ( HWND  hWnd)
static

Definition at line 407 of file conwnd.c.

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

Referenced by ConWndProc(), and OnNcDestroy().

◆ InitFonts()

BOOL InitFonts ( PGUI_CONSOLE_DATA  GuiData,
LPWSTR  FaceName,
ULONG  FontFamily,
COORD  FontSize,
ULONG  FontWeight 
)

Definition at line 508 of file conwnd.c.

513 {
514  HDC hDC;
515  HFONT hFont;
516 
517  /*
518  * Initialize a new NORMAL font and get its character cell size.
519  */
520  /* NOTE: FontSize is always in cell height/width units (pixels) */
521  hFont = CreateConsoleFontEx((LONG)(ULONG)FontSize.Y,
522  (LONG)(ULONG)FontSize.X,
523  FaceName,
524  FontFamily,
525  FontWeight,
526  GuiData->Console->OutputCodePage);
527  if (hFont == NULL)
528  {
529  DPRINT1("InitFonts: CreateConsoleFontEx failed\n");
530  return FALSE;
531  }
532 
533  hDC = GetDC(GuiData->hWindow);
534  if (!GetFontCellSize(hDC, hFont, &GuiData->CharHeight, &GuiData->CharWidth))
535  {
536  DPRINT1("InitFonts: GetFontCellSize failed\n");
537  ReleaseDC(GuiData->hWindow, hDC);
539  return FALSE;
540  }
541  ReleaseDC(GuiData->hWindow, hDC);
542 
543  /*
544  * Initialization succeeded.
545  */
546  // Delete all the old fonts first.
547  DeleteFonts(GuiData);
548  GuiData->Font[FONT_NORMAL] = hFont;
549 
550  /*
551  * Now build the other fonts (bold, underlined, mixed).
552  */
553  GuiData->Font[FONT_BOLD] =
555  FontWeight < FW_BOLD ? FW_BOLD : FontWeight,
556  FALSE,
557  FALSE);
558  GuiData->Font[FONT_UNDERLINE] =
560  FontWeight,
561  TRUE,
562  FALSE);
563  GuiData->Font[FONT_BOLD | FONT_UNDERLINE] =
565  FontWeight < FW_BOLD ? FW_BOLD : FontWeight,
566  TRUE,
567  FALSE);
568 
569  /*
570  * Save the settings.
571  */
572  if (FaceName != GuiData->GuiInfo.FaceName)
573  {
575  FaceName, LF_FACESIZE);
576  }
577  GuiData->GuiInfo.FontFamily = FontFamily;
578  GuiData->GuiInfo.FontSize = FontSize;
579  GuiData->GuiInfo.FontWeight = FontWeight;
580 
581  return TRUE;
582 }
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
#define TRUE
Definition: types.h:120
#define LF_FACESIZE
Definition: dimm.idl:39
HDC WINAPI GetDC(_In_opt_ HWND)
VOID DeleteFonts(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:468
static HDC
Definition: imagelist.c:92
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HFONT hFont
Definition: main.c:53
UINT CharHeight
Definition: conwnd.h:86
#define FONT_NORMAL
Definition: conwnd.h:35
long LONG
Definition: pedump.c:60
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
HFONT Font[FONT_MAXNO]
Definition: conwnd.h:84
BOOL GetFontCellSize(IN HDC hDC OPTIONAL, IN HFONT hFont, OUT PUINT Height, OUT PUINT Width)
Definition: font.c:105
ULONG X
Definition: bl.h:1340
static HDC hDC
Definition: 3dtext.c:33
#define FW_BOLD
Definition: wingdi.h:377
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
HFONT CreateConsoleFontEx(IN LONG Height, IN LONG Width OPTIONAL, IN OUT LPWSTR FaceName, IN ULONG FontFamily, IN ULONG FontWeight, IN UINT CodePage)
Definition: font.c:38
UINT CharWidth
Definition: conwnd.h:85
#define DPRINT1
Definition: precomp.h:8
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:95
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
unsigned int ULONG
Definition: retypes.h:1
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
static HFONT CreateDerivedFont(HFONT OrgFont, ULONG FontWeight, BOOLEAN bUnderline, BOOLEAN bStrikeOut)
Definition: conwnd.c:479
ULONG Y
Definition: bl.h:1341

Referenced by GuiApplyUserSettings(), and OnNcCreate().

◆ InvalidateCell()

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

Definition at line 87 of file guiterm.c.

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

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

◆ IsSystemKey()

static BOOL IsSystemKey ( WORD  VirtualKeyCode)
static

Definition at line 1049 of file conwnd.c.

1050 {
1051  switch (VirtualKeyCode)
1052  {
1053  /* From MSDN, "Virtual-Key Codes" */
1054  case VK_RETURN:
1055  case VK_SHIFT:
1056  case VK_CONTROL:
1057  case VK_MENU:
1058  case VK_PAUSE:
1059  case VK_CAPITAL:
1060  case VK_ESCAPE:
1061  case VK_LWIN:
1062  case VK_RWIN:
1063  case VK_NUMLOCK:
1064  case VK_SCROLL:
1065  return TRUE;
1066  default:
1067  return FALSE;
1068  }
1069 }
#define TRUE
Definition: types.h:120
#define VK_LWIN
Definition: winuser.h:2189
#define VK_MENU
Definition: winuser.h:2158
#define VK_ESCAPE
Definition: winuser.h:2168
#define VK_RETURN
Definition: winuser.h:2155
#define VK_SHIFT
Definition: winuser.h:2156
#define VK_RWIN
Definition: winuser.h:2190
#define VK_SCROLL
Definition: winuser.h:2234
#define VK_NUMLOCK
Definition: winuser.h:2233
#define VK_CAPITAL
Definition: winuser.h:2160
#define VK_CONTROL
Definition: winuser.h:2157
#define VK_PAUSE
Definition: winuser.h:2159

Referenced by OnKey().

◆ Mark()

static VOID Mark ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 287 of file conwnd.c.

288 {
289  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
290 
291  /* Clear the old selection */
293 
294  /* Restart a new selection */
295  GuiData->dwSelectionCursor = ActiveBuffer->ViewOrigin;
296  UpdateSelection(GuiData,
297  &GuiData->dwSelectionCursor,
298  &GuiData->dwSelectionCursor);
299 }
COORD dwSelectionCursor
Definition: conwnd.h:92
#define CONSOLE_NO_SELECTION
Definition: wincon.h:96
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:91
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:849
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90

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

◆ OnActivate()

static VOID OnActivate ( PGUI_CONSOLE_DATA  GuiData,
WPARAM  wParam 
)
static

Definition at line 651 of file conwnd.c.

652 {
653  WORD ActivationState = LOWORD(wParam);
654 
655  DPRINT("WM_ACTIVATE - ActivationState = %d\n", ActivationState);
656 
657  if ( ActivationState == WA_ACTIVE ||
658  ActivationState == WA_CLICKACTIVE )
659  {
660  if (GuiData->GuiInfo.FullScreen)
661  {
662  EnterFullScreen(GuiData);
663  // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
664  // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
665  }
666  }
667  else // if (ActivationState == WA_INACTIVE)
668  {
669  if (GuiData->GuiInfo.FullScreen)
670  {
672  LeaveFullScreen(GuiData);
673  // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
674  // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
675  }
676  }
677 
678  /*
679  * Ignore the next mouse signal when we are going to be enabled again via
680  * the mouse, in order to prevent, e.g. when we are in Edit mode, erroneous
681  * mouse actions from the user that could spoil text selection or copy/pastes.
682  */
683  if (ActivationState == WA_CLICKACTIVE)
684  GuiData->IgnoreNextMouseSignal = TRUE;
685 }
#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
void DPRINT(...)
Definition: polytest.cpp:61
#define WA_ACTIVE
Definition: winuser.h:2577
unsigned short WORD
Definition: ntddk_ex.h:93
#define WA_CLICKACTIVE
Definition: winuser.h:2578
BOOL EnterFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:21
#define SC_MINIMIZE
Definition: winuser.h:2540
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:95
#define WM_SYSCOMMAND
Definition: winuser.h:1717
#define LOWORD(l)
Definition: pedump.c:82

Referenced by ConWndProc().

◆ OnClose()

static BOOL OnClose ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1345 of file conwnd.c.

1346 {
1347  PCONSRV_CONSOLE Console = GuiData->Console;
1348 
1350  return TRUE;
1351 
1352  // TODO: Prompt for termination ? (Warn the user about possible apps running in this console)
1353 
1354  /*
1355  * FIXME: Windows will wait up to 5 seconds for the thread to exit.
1356  * We shouldn't wait here, though, since the console lock is entered.
1357  * A copy of the thread list probably needs to be made.
1358  */
1360 
1361  LeaveCriticalSection(&Console->Lock);
1362  return FALSE;
1363 }
#define TRUE
Definition: types.h:120
#define CTRL_CLOSE_EVENT
Definition: wincon.h:67
#define PCONSRV_CONSOLE
Definition: conio.h:27
NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console, IN ULONG ProcessGroupId, IN ULONG CtrlEvent)
Definition: console.c:906
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by ConWndProc().

◆ OnCommand()

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

Definition at line 343 of file conwnd.c.

344 {
345  LRESULT Ret = TRUE;
346  PCONSRV_CONSOLE Console = GuiData->Console;
347 
348  /*
349  * In case the selected menu item belongs to the user-reserved menu id range,
350  * send to him a menu event and return directly. The user must handle those
351  * reserved menu commands...
352  */
353  if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->CmdIdHigh)
354  {
356  goto Quit;
357  }
358 
359  /* ... otherwise, perform actions. */
360  switch (wParam)
361  {
362  case ID_SYSTEM_EDIT_MARK:
363  Mark(GuiData);
364  break;
365 
366  case ID_SYSTEM_EDIT_COPY:
367  Copy(GuiData);
368  break;
369 
371  Paste(GuiData);
372  break;
373 
375  SelectAll(GuiData);
376  break;
377 
379  DPRINT1("Scrolling is not handled yet\n");
380  break;
381 
382  case ID_SYSTEM_EDIT_FIND:
383  DPRINT1("Finding is not handled yet\n");
384  break;
385 
386  case ID_SYSTEM_DEFAULTS:
388  break;
389 
392  break;
393 
394  default:
395  Ret = FALSE;
396  break;
397  }
398 
399 Quit:
400  if (!Ret)
401  Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam);
402 
403  return Ret;
404 }
#define ID_SYSTEM_EDIT_SCROLL
Definition: resource.h:16
#define TRUE
Definition: types.h:120
static VOID Paste(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1977
#define ID_SYSTEM_EDIT_COPY
Definition: resource.h:13
#define PCONSRV_CONSOLE
Definition: conio.h:27
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:261
#define ID_SYSTEM_PROPERTIES
Definition: resource.h:19
#define ID_SYSTEM_EDIT_MARK
Definition: resource.h:12
#define ID_SYSTEM_DEFAULTS
Definition: resource.h:18
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
static VOID Mark(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:287
#define ID_SYSTEM_EDIT_SELECTALL
Definition: resource.h:15
VOID GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults)
Definition: guisettings.c:43
static VOID SelectAll(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:302
static VOID Copy(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1954
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:89
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_SYSCOMMAND
Definition: winuser.h:1717
LPARAM lParam
Definition: combotst.c:139

Referenced by ConWndProc().

◆ OnDropFiles()

static VOID OnDropFiles ( PCONSRV_CONSOLE  Console,
HDROP  hDrop 
)
static

Definition at line 2109 of file conwnd.c.

2110 {
2111  LPWSTR pszPath;
2112  WCHAR szPath[MAX_PATH + 2];
2113 
2114  szPath[0] = L'"';
2115 
2116  DragQueryFileW(hDrop, 0, &szPath[1], ARRAYSIZE(szPath) - 1);
2117  DragFinish(hDrop);
2118 
2119  if (wcschr(&szPath[1], L' ') != NULL)
2120  {
2122  pszPath = szPath;
2123  }
2124  else
2125  {
2126  pszPath = &szPath[1];
2127  }
2128 
2129  PasteText(Console, pszPath, wcslen(pszPath));
2130 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
smooth NULL
Definition: ftsmooth.c:416
_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:26
VOID PasteText(IN PCONSRV_CONSOLE Console, IN PWCHAR Buffer, IN SIZE_T cchSize)
Definition: text.c:229
static const WCHAR L[]
Definition: oid.c:1250
LPCWSTR szPath
Definition: env.c:35
CConsole Console
void WINAPI DragFinish(HDROP h)
Definition: shellole.c:543
WCHAR * LPWSTR
Definition: xmlstorage.h:184
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:627
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by ConWndProc().

◆ OnFocus()

static VOID OnFocus ( PGUI_CONSOLE_DATA  GuiData,
BOOL  SetFocus 
)
static

Definition at line 688 of file conwnd.c.

689 {
690  PCONSRV_CONSOLE Console = GuiData->Console;
691  INPUT_RECORD er;
692 
694 
695  /* Set console focus state */
696  Console->HasFocus = SetFocus;
697 
698  /*
699  * Set the priority of the processes of this console
700  * in accordance with the console focus state.
701  */
703 
704  /* Send a focus event */
705  er.EventType = FOCUS_EVENT;
708 
710 
711  if (SetFocus)
712  DPRINT("TODO: Create console caret\n");
713  else
714  DPRINT("TODO: Destroy console caret\n");
715 }
#define TRUE
Definition: types.h:120
HWND WINAPI SetFocus(_In_opt_ HWND)
#define PCONSRV_CONSOLE
Definition: conio.h:27
void DPRINT(...)
Definition: polytest.cpp:61
#define FOCUS_EVENT
Definition: wincon.h:126
union _INPUT_RECORD::@3145 Event
FOCUS_EVENT_RECORD FocusEvent
Definition: wincon.h:267
NTSTATUS NTAPI ConSrvSetConsoleProcessFocus(IN PCONSRV_CONSOLE Console, IN BOOLEAN SetForeground)
Definition: console.c:957
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
CConsole Console
WORD EventType
Definition: wincon.h:261
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:195

Referenced by ConWndProc().

◆ OnGetMinMaxInfo()

static VOID OnGetMinMaxInfo ( PGUI_CONSOLE_DATA  GuiData,
PMINMAXINFO  minMaxInfo 
)
static

Definition at line 1997 of file conwnd.c.

1998 {
1999  PCONSRV_CONSOLE Console = GuiData->Console;
2000  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
2001  DWORD windx, windy;
2002  UINT WidthUnit, HeightUnit;
2003 
2005 
2006  ActiveBuffer = GuiData->ActiveBuffer;
2007 
2008  GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
2009 
2010  windx = CONGUI_MIN_WIDTH * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
2012 
2013  minMaxInfo->ptMinTrackSize.x = windx;
2014  minMaxInfo->ptMinTrackSize.y = windy;
2015 
2016  windx = (ActiveBuffer->ScreenBufferSize.X) * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
2017  windy = (ActiveBuffer->ScreenBufferSize.Y) * HeightUnit + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION);
2018 
2019  if (ActiveBuffer->ViewSize.X < ActiveBuffer->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // Window currently has a horizontal scrollbar
2020  if (ActiveBuffer->ViewSize.Y < ActiveBuffer->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // Window currently has a vertical scrollbar
2021 
2022  minMaxInfo->ptMaxTrackSize.x = windx;
2023  minMaxInfo->ptMaxTrackSize.y = windy;
2024 
2025  LeaveCriticalSection(&Console->Lock);
2026 }
POINT ptMinTrackSize
Definition: winuser.h:3572
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
#define CONGUI_MIN_HEIGHT
Definition: conwnd.c:34
long x
Definition: polytest.cpp:48
#define SM_CXEDGE
Definition: winuser.h:998
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
#define PCONSRV_CONSOLE
Definition: conio.h:27
COORD ScreenBufferSize
Definition: conio.h:87
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
#define SM_CYEDGE
Definition: winuser.h:999
ULONG X
Definition: bl.h:1340
#define SM_CYCAPTION
Definition: winuser.h:953
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
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:120
unsigned int UINT
Definition: ndis.h:50
#define SM_CXVSCROLL
Definition: winuser.h:951
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
POINT ptMaxTrackSize
Definition: winuser.h:3573
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define CONGUI_MIN_WIDTH
Definition: conwnd.c:33
ULONG Y
Definition: bl.h:1341

Referenced by ConWndProc().

◆ OnKey()

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

Definition at line 1072 of file conwnd.c.

1073 {
1074  PCONSRV_CONSOLE Console = GuiData->Console;
1075  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
1076 
1078 
1079  ActiveBuffer = GuiData->ActiveBuffer;
1080 
1082  {
1083  WORD VirtualKeyCode = LOWORD(wParam);
1084 
1085  if (msg != WM_KEYDOWN) goto Quit;
1086 
1087  if (VirtualKeyCode == VK_RETURN)
1088  {
1089  /* Copy (and clear) selection if ENTER is pressed */
1090  Copy(GuiData);
1091  goto Quit;
1092  }
1093  else if ( VirtualKeyCode == VK_ESCAPE ||
1094  (VirtualKeyCode == 'C' && (GetKeyState(VK_CONTROL) & KEY_PRESSED)) )
1095  {
1096  /* Cancel selection if ESC or Ctrl-C are pressed */
1097  UpdateSelection(GuiData, NULL, NULL);
1098  goto Quit;
1099  }
1100 
1101  if ((GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0)
1102  {
1103  /* Keyboard selection mode */
1104  BOOL Interpreted = FALSE;
1105  BOOL MajPressed = !!(GetKeyState(VK_SHIFT) & KEY_PRESSED);
1106 
1107  switch (VirtualKeyCode)
1108  {
1109  case VK_LEFT:
1110  {
1111  Interpreted = TRUE;
1112  if (GuiData->dwSelectionCursor.X > 0)
1113  GuiData->dwSelectionCursor.X--;
1114 
1115  break;
1116  }
1117 
1118  case VK_RIGHT:
1119  {
1120  Interpreted = TRUE;
1121  if (GuiData->dwSelectionCursor.X < ActiveBuffer->ScreenBufferSize.X - 1)
1122  GuiData->dwSelectionCursor.X++;
1123 
1124  break;
1125  }
1126 
1127  case VK_UP:
1128  {
1129  Interpreted = TRUE;
1130  if (GuiData->dwSelectionCursor.Y > 0)
1131  GuiData->dwSelectionCursor.Y--;
1132 
1133  break;
1134  }
1135 
1136  case VK_DOWN:
1137  {
1138  Interpreted = TRUE;
1139  if (GuiData->dwSelectionCursor.Y < ActiveBuffer->ScreenBufferSize.Y - 1)
1140  GuiData->dwSelectionCursor.Y++;
1141 
1142  break;
1143  }
1144 
1145  case VK_HOME:
1146  {
1147  Interpreted = TRUE;
1148  GuiData->dwSelectionCursor.X = 0;
1149  GuiData->dwSelectionCursor.Y = 0;
1150  break;
1151  }
1152 
1153  case VK_END:
1154  {
1155  Interpreted = TRUE;
1156  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
1157  break;
1158  }
1159 
1160  case VK_PRIOR:
1161  {
1162  Interpreted = TRUE;
1163  GuiData->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y;
1164  if (GuiData->dwSelectionCursor.Y < 0)
1165  GuiData->dwSelectionCursor.Y = 0;
1166 
1167  break;
1168  }
1169 
1170  case VK_NEXT:
1171  {
1172  Interpreted = TRUE;
1173  GuiData->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y;
1174  if (GuiData->dwSelectionCursor.Y >= ActiveBuffer->ScreenBufferSize.Y)
1175  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
1176 
1177  break;
1178  }
1179 
1180  default:
1181  break;
1182  }
1183 
1184  if (Interpreted)
1185  {
1186  UpdateSelection(GuiData,
1187  !MajPressed ? &GuiData->dwSelectionCursor : NULL,
1188  &GuiData->dwSelectionCursor);
1189  }
1190  else if (!IsSystemKey(VirtualKeyCode))
1191  {
1192  /* Emit an error beep sound */
1193  SendNotifyMessage(GuiData->hWindow, PM_CONSOLE_BEEP, 0, 0);
1194  }
1195 
1196  goto Quit;
1197  }
1198  else
1199  {
1200  /* Mouse selection mode */
1201 
1202  if (!IsSystemKey(VirtualKeyCode))
1203  {
1204  /* Clear the selection and send the key into the input buffer */
1205  UpdateSelection(GuiData, NULL, NULL);
1206  }
1207  else
1208  {
1209  goto Quit;
1210  }
1211  }
1212  }
1213 
1214  if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
1215  {
1216  MSG Message;
1217 
1218  Message.hwnd = GuiData->hWindow;
1219  Message.message = msg;
1220  Message.wParam = wParam;
1221  Message.lParam = lParam;
1222 
1224  }
1225 
1226 Quit:
1227  LeaveCriticalSection(&Console->Lock);
1228 }
COORD dwSelectionCursor
Definition: conwnd.h:92
#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:2178
#define VK_DOWN
Definition: winuser.h:2181
#define VK_PRIOR
Definition: winuser.h:2174
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:91
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:849
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define VK_ESCAPE
Definition: winuser.h:2168
#define VK_RETURN
Definition: winuser.h:2155
WPARAM wParam
Definition: combotst.c:138
#define VK_NEXT
Definition: winuser.h:2175
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:99
#define VK_HOME
Definition: winuser.h:2177
#define VK_UP
Definition: winuser.h:2179
COORD ScreenBufferSize
Definition: conio.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
#define VK_SHIFT
Definition: winuser.h:2156
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
SHORT WINAPI GetKeyState(_In_ int)
ULONG X
Definition: bl.h:1340
#define KEY_PRESSED
Definition: conwnd.h:26
static BOOL IsSystemKey(WORD VirtualKeyCode)
Definition: conwnd.c:1049
unsigned short WORD
Definition: ntddk_ex.h:93
CHAR Message[80]
Definition: alive.c:5
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
#define VK_RIGHT
Definition: winuser.h:2180
VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG *msg)
Definition: input.c:57
static VOID Copy(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1954
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
#define VK_CONTROL
Definition: winuser.h:2157
CConsole Console
#define msg(x)
Definition: auth_time.c:54
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1341
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define VK_END
Definition: winuser.h:2176
#define SendNotifyMessage
Definition: winuser.h:5712

Referenced by ConWndProc().

◆ OnMouse()

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

Definition at line 1525 of file conwnd.c.

1526 {
1527  BOOL DoDefault = FALSE;
1528  PCONSRV_CONSOLE Console = GuiData->Console;
1529 
1530  /*
1531  * HACK FOR CORE-8394 (Part 2):
1532  *
1533  * Check whether we should ignore the next mouse move event.
1534  * In either case we reset the HACK flag.
1535  *
1536  * See Part 1 of this hack below.
1537  */
1538  if (GuiData->HackCORE8394IgnoreNextMove && msg == WM_MOUSEMOVE)
1539  {
1540  GuiData->HackCORE8394IgnoreNextMove = FALSE;
1541  goto Quit;
1542  }
1543  GuiData->HackCORE8394IgnoreNextMove = FALSE;
1544 
1545  // FIXME: It's here that we need to check whether we have focus or not
1546  // and whether we are or not in edit mode, in order to know if we need
1547  // to deal with the mouse.
1548 
1549  if (GuiData->IgnoreNextMouseSignal)
1550  {
1551  if (msg != WM_LBUTTONDOWN &&
1552  msg != WM_MBUTTONDOWN &&
1553  msg != WM_RBUTTONDOWN &&
1554  msg != WM_XBUTTONDOWN)
1555  {
1556  /*
1557  * If this mouse signal is not a button-down action
1558  * then this is the last one being ignored.
1559  */
1560  GuiData->IgnoreNextMouseSignal = FALSE;
1561  }
1562  else
1563  {
1564  /*
1565  * This mouse signal is a button-down action.
1566  * Ignore it and perform default action.
1567  */
1568  DoDefault = TRUE;
1569  }
1570  goto Quit;
1571  }
1572 
1574  {
1575  DoDefault = TRUE;
1576  goto Quit;
1577  }
1578 
1579  if ( (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) ||
1580  (Console->QuickEdit) )
1581  {
1582  switch (msg)
1583  {
1584  case WM_LBUTTONDOWN:
1585  {
1586  /* Check for selection state */
1587  if ( (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
1588  (GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) &&
1590  {
1591  /*
1592  * A mouse selection is currently in progress and the user
1593  * has pressed the SHIFT key and clicked somewhere, update
1594  * the selection.
1595  */
1596  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1597  UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1598  }
1599  else
1600  {
1601  /* Clear the old selection */
1603 
1604  /* Restart a new selection */
1605  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1606  SetCapture(GuiData->hWindow);
1608  UpdateSelection(GuiData,
1609  &GuiData->dwSelectionCursor,
1610  &GuiData->dwSelectionCursor);
1611  }
1612 
1613  break;
1614  }
1615 
1616  case WM_LBUTTONUP:
1617  {
1618  if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1619 
1620  // GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1621  GuiData->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
1622  // UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1623  ReleaseCapture();
1624 
1625  break;
1626  }
1627 
1628  case WM_LBUTTONDBLCLK:
1629  {
1631 
1632  if (GetType(Buffer) == TEXTMODE_BUFFER)
1633  {
1634 #define IS_WORD_SEP(c) \
1635  ((c) == L'\0' || (c) == L' ' || (c) == L'\t' || (c) == L'\r' || (c) == L'\n')
1636 
1638  COORD cL, cR;
1639  PCHAR_INFO ptrL, ptrR;
1640 
1641  /* Starting point */
1642  cL = cR = PointToCoord(GuiData, lParam);
1643  ptrL = ptrR = ConioCoordToPointer(TextBuffer, cL.X, cL.Y);
1644 
1645  /* Enlarge the selection by checking for whitespace */
1646  while ((0 < cL.X) && !IS_WORD_SEP(ptrL->Char.UnicodeChar)
1647  && !IS_WORD_SEP((ptrL-1)->Char.UnicodeChar))
1648  {
1649  --cL.X;
1650  --ptrL;
1651  }
1652  while ((cR.X < TextBuffer->ScreenBufferSize.X - 1) &&
1653  !IS_WORD_SEP(ptrR->Char.UnicodeChar) &&
1654  !IS_WORD_SEP((ptrR+1)->Char.UnicodeChar))
1655  {
1656  ++cR.X;
1657  ++ptrR;
1658  }
1659 
1660  /*
1661  * Update the selection started with the single
1662  * left-click that preceded this double-click.
1663  */
1665  UpdateSelection(GuiData, &cL, &cR);
1666 
1667  /* Ignore the next mouse move signal */
1668  GuiData->IgnoreNextMouseSignal = TRUE;
1669 #undef IS_WORD_SEP
1670  }
1671 
1672  break;
1673  }
1674 
1675  case WM_RBUTTONDOWN:
1676  case WM_RBUTTONDBLCLK:
1677  {
1678  if (!(GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
1679  {
1680  Paste(GuiData);
1681  }
1682  else
1683  {
1684  Copy(GuiData);
1685  }
1686 
1687  /* Ignore the next mouse move signal */
1688  GuiData->IgnoreNextMouseSignal = TRUE;
1689  break;
1690  }
1691 
1692  case WM_MOUSEMOVE:
1693  {
1694  if (!(GET_KEYSTATE_WPARAM(wParam) & MK_LBUTTON)) break;
1695  if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1696 
1697  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1698  UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1699  break;
1700  }
1701 
1702  default:
1703  DoDefault = TRUE; // FALSE;
1704  break;
1705  }
1706  }
1707  else if (Console->InputBuffer.Mode & ENABLE_MOUSE_INPUT)
1708  {
1709  INPUT_RECORD er;
1710  WORD wKeyState = GET_KEYSTATE_WPARAM(wParam);
1711  DWORD dwButtonState = 0;
1712  DWORD dwControlKeyState = 0;
1713  DWORD dwEventFlags = 0;
1714 
1715  switch (msg)
1716  {
1717  case WM_LBUTTONDOWN:
1718  SetCapture(GuiData->hWindow);
1719  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1720  dwEventFlags = 0;
1721  break;
1722 
1723  case WM_MBUTTONDOWN:
1724  SetCapture(GuiData->hWindow);
1725  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1726  dwEventFlags = 0;
1727  break;
1728 
1729  case WM_RBUTTONDOWN:
1730  SetCapture(GuiData->hWindow);
1731  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1732  dwEventFlags = 0;
1733  break;
1734 
1735  case WM_XBUTTONDOWN:
1736  {
1737  /* Get which X-button was pressed */
1738  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1739 
1740  /* Check for X-button validity */
1741  if (wButton & ~(XBUTTON1 | XBUTTON2))
1742  {
1743  DPRINT1("X-button 0x%04x invalid\n", wButton);
1744  DoDefault = TRUE;
1745  break;
1746  }
1747 
1748  SetCapture(GuiData->hWindow);
1749  dwButtonState = (wButton == XBUTTON1 ? FROM_LEFT_3RD_BUTTON_PRESSED
1751  dwEventFlags = 0;
1752  break;
1753  }
1754 
1755  case WM_LBUTTONUP:
1756  ReleaseCapture();
1757  dwButtonState = 0;
1758  dwEventFlags = 0;
1759  break;
1760 
1761  case WM_MBUTTONUP:
1762  ReleaseCapture();
1763  dwButtonState = 0;
1764  dwEventFlags = 0;
1765  break;
1766 
1767  case WM_RBUTTONUP:
1768  ReleaseCapture();
1769  dwButtonState = 0;
1770  dwEventFlags = 0;
1771  break;
1772 
1773  case WM_XBUTTONUP:
1774  {
1775  /* Get which X-button was released */
1776  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1777 
1778  /* Check for X-button validity */
1779  if (wButton & ~(XBUTTON1 | XBUTTON2))
1780  {
1781  DPRINT1("X-button 0x%04x invalid\n", wButton);
1782  /* Ok, just release the button anyway... */
1783  }
1784 
1785  ReleaseCapture();
1786  dwButtonState = 0;
1787  dwEventFlags = 0;
1788  break;
1789  }
1790 
1791  case WM_LBUTTONDBLCLK:
1792  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1793  dwEventFlags = DOUBLE_CLICK;
1794  break;
1795 
1796  case WM_MBUTTONDBLCLK:
1797  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1798  dwEventFlags = DOUBLE_CLICK;
1799  break;
1800 
1801  case WM_RBUTTONDBLCLK:
1802  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1803  dwEventFlags = DOUBLE_CLICK;
1804  break;
1805 
1806  case WM_XBUTTONDBLCLK:
1807  {
1808  /* Get which X-button was double-clicked */
1809  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1810 
1811  /* Check for X-button validity */
1812  if (wButton & ~(XBUTTON1 | XBUTTON2))
1813  {
1814  DPRINT1("X-button 0x%04x invalid\n", wButton);
1815  DoDefault = TRUE;
1816  break;
1817  }
1818 
1819  dwButtonState = (wButton == XBUTTON1 ? FROM_LEFT_3RD_BUTTON_PRESSED
1821  dwEventFlags = DOUBLE_CLICK;
1822  break;
1823  }
1824 
1825  case WM_MOUSEMOVE:
1826  dwButtonState = 0;
1827  dwEventFlags = MOUSE_MOVED;
1828  break;
1829 
1830  case WM_MOUSEWHEEL:
1831  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1832  dwEventFlags = MOUSE_WHEELED;
1833  break;
1834 
1835  case WM_MOUSEHWHEEL:
1836  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1837  dwEventFlags = MOUSE_HWHEELED;
1838  break;
1839 
1840  default:
1841  DoDefault = TRUE;
1842  break;
1843  }
1844 
1845  /*
1846  * HACK FOR CORE-8394 (Part 1):
1847  *
1848  * It appears that depending on which VM ReactOS runs, the next mouse
1849  * signal coming after a button-down action can be a mouse-move (e.g.
1850  * on VBox, whereas on QEMU it is not the case). However it is NOT a
1851  * rule, so that we cannot use the IgnoreNextMouseSignal flag to just
1852  * "ignore" the next mouse event, thinking it would always be a mouse-
1853  * move signal.
1854  *
1855  * To work around this problem (that should really be fixed in Win32k),
1856  * we use a second flag to ignore this possible next mouse move signal.
1857  */
1858  switch (msg)
1859  {
1860  case WM_LBUTTONDOWN:
1861  case WM_MBUTTONDOWN:
1862  case WM_RBUTTONDOWN:
1863  case WM_XBUTTONDOWN:
1864  GuiData->HackCORE8394IgnoreNextMove = TRUE;
1865  default:
1866  break;
1867  }
1868 
1869  if (!DoDefault)
1870  {
1871  if (wKeyState & MK_LBUTTON)
1872  dwButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
1873  if (wKeyState & MK_MBUTTON)
1874  dwButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
1875  if (wKeyState & MK_RBUTTON)
1876  dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
1877  if (wKeyState & MK_XBUTTON1)
1878  dwButtonState |= FROM_LEFT_3RD_BUTTON_PRESSED;
1879  if (wKeyState & MK_XBUTTON2)
1880  dwButtonState |= FROM_LEFT_4TH_BUTTON_PRESSED;
1881 
1883  dwControlKeyState |= RIGHT_ALT_PRESSED;
1885  dwControlKeyState |= LEFT_ALT_PRESSED;
1887  dwControlKeyState |= RIGHT_CTRL_PRESSED;
1889  dwControlKeyState |= LEFT_CTRL_PRESSED;
1891  dwControlKeyState |= SHIFT_PRESSED;
1893  dwControlKeyState |= NUMLOCK_ON;
1895  dwControlKeyState |= SCROLLLOCK_ON;
1897  dwControlKeyState |= CAPSLOCK_ON;
1898  /* See WM_CHAR MSDN documentation for instance */
1899  if (lParam & 0x01000000)
1900  dwControlKeyState |= ENHANCED_KEY;
1901 
1902  /* Send a mouse event */
1903  er.EventType = MOUSE_EVENT;
1905  er.Event.MouseEvent.dwButtonState = dwButtonState;
1906  er.Event.MouseEvent.dwControlKeyState = dwControlKeyState;
1907  er.Event.MouseEvent.dwEventFlags = dwEventFlags;
1908 
1910  }
1911  }
1912  else
1913  {
1914  DoDefault = TRUE;
1915  }
1916 
1917  LeaveCriticalSection(&Console->Lock);
1918 
1919 Quit:
1920  if (!DoDefault)
1921  return 0;
1922 
1923  if (msg == WM_MOUSEWHEEL || msg == WM_MOUSEHWHEEL)
1924  {
1925  INT nBar;
1926  WORD sbCode;
1927  // WORD wKeyState = GET_KEYSTATE_WPARAM(wParam);
1928  SHORT wDelta = GET_WHEEL_DELTA_WPARAM(wParam);
1929 
1930  if (msg == WM_MOUSEWHEEL)
1931  nBar = SB_VERT;
1932  else // if (msg == WM_MOUSEHWHEEL)
1933  nBar = SB_HORZ;
1934 
1935  // NOTE: We currently do not support zooming...
1936  // if (wKeyState & MK_CONTROL)
1937 
1938  // FIXME: For some reason our win32k does not set the key states
1939  // when sending WM_MOUSEWHEEL or WM_MOUSEHWHEEL ...
1940  // if (wKeyState & MK_SHIFT)
1942  sbCode = (wDelta >= 0 ? SB_PAGEUP : SB_PAGEDOWN);
1943  else
1944  sbCode = (wDelta >= 0 ? SB_LINEUP : SB_LINEDOWN);
1945 
1946  OnScroll(GuiData, nBar, sbCode);
1947  }
1948 
1949  return DefWindowProcW(GuiData->hWindow, msg, wParam, lParam);
1950 }
#define WM_MBUTTONUP
Definition: winuser.h:1759
COORD dwSelectionCursor
Definition: conwnd.h:92
#define FROM_LEFT_1ST_BUTTON_PRESSED
Definition: wincon.h:144
#define SCROLLLOCK_ON
Definition: wincon.h:137
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define TRUE
Definition: types.h:120
DWORD dwEventFlags
Definition: wincon.h:245
union _CHAR_INFO::@3143 Char
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
static VOID Paste(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1977
#define MK_LBUTTON
Definition: winuser.h:2321
static COORD PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
Definition: conwnd.c:1499
#define RIGHTMOST_BUTTON_PRESSED
Definition: wincon.h:145
#define SB_VERT
Definition: winuser.h:553
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
#define VK_RMENU
Definition: winuser.h:2241
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define MK_MBUTTON
Definition: winuser.h:2325
WCHAR UnicodeChar
Definition: wincon.h:169
#define SB_HORZ
Definition: winuser.h:552
#define FROM_LEFT_2ND_BUTTON_PRESSED
Definition: wincon.h:146
#define IS_WORD_SEP(c)
#define CONSOLE_NO_SELECTION
Definition: wincon.h:96
BOOL IgnoreNextMouseSignal
Definition: conwnd.h:72
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:91
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define SHIFT_PRESSED
Definition: wincon.h:135
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:849
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define CONSOLE_MOUSE_DOWN
Definition: wincon.h:100
DWORD dwButtonState
Definition: wincon.h:243
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:99
#define MOUSE_MOVED
Definition: wincon.h:153
BOOL HackCORE8394IgnoreNextMove
Definition: conwnd.h:74
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DOUBLE_CLICK
Definition: wincon.h:154
short SHORT
Definition: pedump.c:59
char Char
Definition: bzip2.c:161
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
#define VK_SHIFT
Definition: winuser.h:2156
COORD dwMousePosition
Definition: wincon.h:242
smooth NULL
Definition: ftsmooth.c:416
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
Definition: bufpool.h:45
static VOID OnScroll(PGUI_CONSOLE_DATA GuiData, INT nBar, WORD sbCode)
Definition: conwnd.c:1391
union _INPUT_RECORD::@3145 Event
#define MK_RBUTTON
Definition: winuser.h:2322
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
SHORT WINAPI GetKeyState(_In_ int)
#define LEFT_ALT_PRESSED
Definition: wincon.h:132
ULONG X
Definition: bl.h:1340
#define FROM_LEFT_3RD_BUTTON_PRESSED
Definition: wincon.h:147
#define KEY_PRESSED
Definition: conwnd.h:26
#define ENHANCED_KEY
Definition: wincon.h:139
#define MOUSE_EVENT
Definition: wincon.h:123
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_RBUTTONUP
Definition: winuser.h:1756
#define ENABLE_MOUSE_INPUT
Definition: wincon.h:79
#define LEFT_CTRL_PRESSED
Definition: wincon.h:134
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
#define VK_RCONTROL
Definition: winuser.h:2239
#define VK_LMENU
Definition: winuser.h:2240
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1760
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
Definition: bl.h:1338
static VOID Copy(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1954
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define VK_SCROLL
Definition: winuser.h:2234
#define VK_NUMLOCK
Definition: winuser.h:2233
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
#define WM_LBUTTONUP
Definition: winuser.h:1753
DWORD dwControlKeyState
Definition: wincon.h:244
#define WM_MBUTTONDOWN
Definition: winuser.h:1758
#define VK_CAPITAL
Definition: winuser.h:2160
#define SB_LINEDOWN
Definition: winuser.h:565
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define SB_LINEUP
Definition: winuser.h:564
CConsole Console
WORD EventType
Definition: wincon.h:261
#define DPRINT1
Definition: precomp.h:8
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
MOUSE_EVENT_RECORD MouseEvent
Definition: wincon.h:264
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1757
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
#define MOUSE_WHEELED
Definition: wincon.h:155
#define FROM_LEFT_4TH_BUTTON_PRESSED
Definition: wincon.h:148
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:133
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define VK_LCONTROL
Definition: winuser.h:2238
ULONG Y
Definition: bl.h:1341
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
LPARAM lParam
Definition: combotst.c:139
#define NUMLOCK_ON
Definition: wincon.h:136
#define RIGHT_ALT_PRESSED
Definition: wincon.h:131
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:195
#define CAPSLOCK_ON
Definition: wincon.h:138
#define KEY_TOGGLED
Definition: conwnd.h:25

Referenced by ConWndProc().

◆ OnMove()

static VOID OnMove ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 2095 of file conwnd.c.

2096 {
2097  RECT rcWnd;
2098 
2099  // TODO: Simplify the code.
2100  // See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
2101 
2102  /* Retrieve our real position */
2103  GetWindowRect(GuiData->hWindow, &rcWnd);
2104  GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
2105  GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
2106 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:95
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by ConWndProc().

◆ OnNcCreate()

static BOOL OnNcCreate ( HWND  hWnd,
LPCREATESTRUCTW  Create 
)
static

Definition at line 586 of file conwnd.c.

587 {
588  PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
590 
591  if (GuiData == NULL)
592  {
593  DPRINT1("GuiConsoleNcCreate: No GUI data\n");
594  return FALSE;
595  }
596 
597  Console = GuiData->Console;
598 
599  GuiData->hWindow = hWnd;
600 
601  /* Initialize the fonts */
602  if (!InitFonts(GuiData,
603  GuiData->GuiInfo.FaceName,
604  GuiData->GuiInfo.FontFamily,
605  GuiData->GuiInfo.FontSize,
606  GuiData->GuiInfo.FontWeight))
607  {
608  DPRINT1("GuiConsoleNcCreate: InitFonts failed\n");
609  GuiData->hWindow = NULL;
610  NtSetEvent(GuiData->hGuiInitEvent, NULL);
611  return FALSE;
612  }
613 
614  /* Initialize the terminal framebuffer */
615  GuiData->hMemDC = CreateCompatibleDC(NULL);
616  GuiData->hBitmap = NULL;
617  GuiData->hSysPalette = NULL; /* Original system palette */
618 
619  /* Update the icons of the window */
620  if (GuiData->hIcon != ghDefaultIcon)
621  {
622  DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_BIG , (LPARAM)GuiData->hIcon );
623  DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
624  }
625 
626  // FIXME: Keep these instructions here ? ///////////////////////////////////
627  Console->ActiveBuffer->CursorBlinkOn = TRUE;
628  Console->ActiveBuffer->ForceCursorOff = FALSE;
630 
631  SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
632 
633  if (GuiData->IsWindowVisible)
634  {
636  }
637 
638  // FIXME: HACK: Potential HACK for CORE-8129; see revision 63595.
639  //CreateSysMenu(GuiData->hWindow);
640 
641  DPRINT("OnNcCreate - setting start event\n");
642  NtSetEvent(GuiData->hGuiInitEvent, NULL);
643 
644  /* We accept dropped files */
645  DragAcceptFiles(GuiData->hWindow, TRUE);
646 
647  return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
648 }
#define TRUE
Definition: types.h:120
HANDLE hGuiInitEvent
Definition: conwnd.h:44
_In_ BOOLEAN Create
Definition: pstypes.h:511
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
HWND hWnd
Definition: settings.c:17
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:527
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define WM_NCCREATE
Definition: winuser.h:1665
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ICON_SMALL
Definition: tnclass.cpp:48
HICON ghDefaultIcon
Definition: conwnd.c:62
unsigned int BOOL
Definition: ntddk_ex.h:94
HICON hIconSm
Definition: conwnd.h:67
#define GWLP_USERDATA
Definition: treelist.c:63
#define CONGUI_UPDATE_TIMER
Definition: conwnd.c:36
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:458
if(!(yy_init))
Definition: macro.lex.yy.c:714
BOOL InitFonts(PGUI_CONSOLE_DATA GuiData, LPWSTR FaceName, ULONG FontFamily, COORD FontSize, ULONG FontWeight)
Definition: conwnd.c:508
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
uint32_t DWORD_PTR
Definition: typedefs.h:63
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
#define CONGUI_UPDATE_TIME
Definition: conwnd.c:35
CConsole Console
#define DPRINT1
Definition: precomp.h:8
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:95
HPALETTE hSysPalette
Definition: conwnd.h:64
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
#define SetWindowLongPtrW
Definition: winuser.h:5215
HBITMAP hBitmap
Definition: conwnd.h:63
#define ICON_BIG
Definition: tnclass.cpp:51

Referenced by ConWndProc().

◆ OnNcDestroy()

static LRESULT OnNcDestroy ( HWND  hWnd)
static

Definition at line 1366 of file conwnd.c.

1367 {
1369 
1370  /* Free the GuiData registration */
1372 
1374 
1375  if (GuiData)
1376  {
1377  if (GuiData->IsWindowVisible)
1379 
1380  /* Free the terminal framebuffer */
1381  if (GuiData->hMemDC ) DeleteDC(GuiData->hMemDC);
1382  if (GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
1383  // if (GuiData->hSysPalette) DeleteObject(GuiData->hSysPalette);
1384  DeleteFonts(GuiData);
1385  }
1386 
1387  return DefWindowProcW(hWnd, WM_NCDESTROY, 0, 0);
1388 }
static PGUI_CONSOLE_DATA GuiGetGuiData(HWND hWnd)
Definition: conwnd.c:407
#define TRUE
Definition: types.h:120
VOID DeleteFonts(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:468
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)
smooth NULL
Definition: ftsmooth.c:416
#define WM_NCDESTROY
Definition: winuser.h:1666
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
uint32_t DWORD_PTR
Definition: typedefs.h:63
BOOL WINAPI DeleteDC(_In_ HDC)
#define SetWindowLongPtrW
Definition: winuser.h:5215
HBITMAP hBitmap
Definition: conwnd.h:63

Referenced by ConWndProc().

◆ OnPaint()

static VOID OnPaint ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 972 of file conwnd.c.

973 {
974  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
975  PAINTSTRUCT ps;
976  RECT rcPaint;
977 
978  /* Do nothing if the window is hidden */
979  if (!GuiData->IsWindowVisible) return;
980 
981  BeginPaint(GuiData->hWindow, &ps);
982  if (ps.hdc != NULL &&
983  ps.rcPaint.left < ps.rcPaint.right &&
984  ps.rcPaint.top < ps.rcPaint.bottom)
985  {
986  EnterCriticalSection(&GuiData->Lock);
987 
988  /* Compose the current screen-buffer on-memory */
989  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
990  {
992  GuiData, &ps.rcPaint, &rcPaint);
993  }
994  else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
995  {
997  GuiData, &ps.rcPaint, &rcPaint);
998  }
999 
1000  /* Send it to screen */
1001  BitBlt(ps.hdc,
1002  ps.rcPaint.left,
1003  ps.rcPaint.top,
1004  rcPaint.right - rcPaint.left,
1005  rcPaint.bottom - rcPaint.top,
1006  GuiData->hMemDC,
1007  rcPaint.left,
1008  rcPaint.top,
1009  SRCCOPY);
1010 
1011  /* Draw the selection region if needed */
1013  {
1014  PaintSelectionRect(GuiData, &ps);
1015  }
1016 
1017  LeaveCriticalSection(&GuiData->Lock);
1018  }
1019  EndPaint(GuiData->hWindow, &ps);
1020 
1021  return;
1022 }
LONG top
Definition: windef.h:292
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:91
LONG left
Definition: windef.h:291
#define TEXTMODE_BUFFER
Definition: pccons.c:21
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
LONG right
Definition: windef.h:293
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
static VOID PaintSelectionRect(PGUI_CONSOLE_DATA GuiData, PPAINTSTRUCT pps)
Definition: conwnd.c:829
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
smooth NULL
Definition: ftsmooth.c:416
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
VOID GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, PRECT rcView, PRECT rcFramebuffer)
Definition: graphics.c:124
CRITICAL_SECTION Lock
Definition: conwnd.h:42
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
VOID GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, PRECT rcView, PRECT rcFramebuffer)
Definition: text.c:355
LONG bottom
Definition: windef.h:294
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define SRCCOPY
Definition: wingdi.h:332

Referenced by ConWndProc().

◆ OnPaletteChanged()

static VOID OnPaletteChanged ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1025 of file conwnd.c.

1026 {
1027  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
1028 
1029  /* Do nothing if the window is hidden */
1030  if (!GuiData->IsWindowVisible) return;
1031 
1032  // See WM_PALETTECHANGED message
1033  // if ((HWND)wParam == hWnd) break;
1034 
1035  // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
1036  if (ActiveBuffer->PaletteHandle)
1037  {
1038  DPRINT("WM_PALETTECHANGED changing palette\n");
1039 
1040  /* Specify the use of the system palette for the framebuffer */
1041  SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
1042 
1043  /* Realize the (logical) palette */
1044  RealizePalette(GuiData->hMemDC);
1045  }
1046 }
UINT WINAPI SetSystemPaletteUse(_In_ HDC, _In_ UINT)
HPALETTE PaletteHandle
Definition: conio.h:105
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
void DPRINT(...)
Definition: polytest.cpp:61
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
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 1391 of file conwnd.c.

1392 {
1393  PCONSRV_CONSOLE Console = GuiData->Console;
1395  SCROLLINFO sInfo;
1396  INT oldPos, Maximum;
1397  PSHORT pOriginXY;
1398 
1399  ASSERT(nBar == SB_HORZ || nBar == SB_VERT);
1400 
1402 
1403  Buff = GuiData->ActiveBuffer;
1404 
1405  if (nBar == SB_HORZ)
1406  {
1407  Maximum = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
1408  pOriginXY = &Buff->ViewOrigin.X;
1409  }
1410  else // if (nBar == SB_VERT)
1411  {
1412  Maximum = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
1413  pOriginXY = &Buff->ViewOrigin.Y;
1414  }
1415 
1416  /* Set scrollbar sizes */
1417  sInfo.cbSize = sizeof(sInfo);
1419 
1420  if (!GetScrollInfo(GuiData->hWindow, nBar, &sInfo)) goto Quit;
1421 
1422  oldPos = sInfo.nPos;
1423 
1424  switch (sbCode)
1425  {
1426  case SB_LINEUP: // SB_LINELEFT:
1427  sInfo.nPos--;
1428  break;
1429 
1430  case SB_LINEDOWN: // SB_LINERIGHT:
1431  sInfo.nPos++;
1432  break;
1433 
1434  case SB_PAGEUP: // SB_PAGELEFT:
1435  sInfo.nPos -= sInfo.nPage;
1436  break;
1437 
1438  case SB_PAGEDOWN: // SB_PAGERIGHT:
1439  sInfo.nPos += sInfo.nPage;
1440  break;
1441 
1442  case SB_THUMBTRACK:
1443  sInfo.nPos = sInfo.nTrackPos;
1445  break;
1446 
1447  case SB_THUMBPOSITION:
1448  sInfo.nPos = sInfo.nTrackPos;
1450  break;
1451 
1452  case SB_TOP: // SB_LEFT:
1453  sInfo.nPos = sInfo.nMin;
1454  break;
1455 
1456  case SB_BOTTOM: // SB_RIGHT:
1457  sInfo.nPos = sInfo.nMax;
1458  break;
1459 
1460  default:
1461  break;
1462  }
1463 
1464  sInfo.nPos = min(max(sInfo.nPos, 0), Maximum);
1465 
1466  if (oldPos != sInfo.nPos)
1467  {
1468  USHORT OldX = Buff->ViewOrigin.X;
1469  USHORT OldY = Buff->ViewOrigin.Y;
1470  UINT WidthUnit, HeightUnit;
1471 
1472  /* We now modify Buff->ViewOrigin */
1473  *pOriginXY = sInfo.nPos;
1474 
1475  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
1476 
1477  ScrollWindowEx(GuiData->hWindow,
1478  (OldX - Buff->ViewOrigin.X) * WidthUnit ,
1479  (OldY - Buff->ViewOrigin.Y) * HeightUnit,
1480  NULL,
1481  NULL,
1482  NULL,
1483  NULL,
1484  SW_INVALIDATE);
1485 
1486  sInfo.fMask = SIF_POS;
1487  SetScrollInfo(GuiData->hWindow, nBar, &sInfo, TRUE);
1488 
1489  UpdateWindow(GuiData->hWindow);
1490  // InvalidateRect(GuiData->hWindow, NULL, FALSE);
1491  }
1492 
1493 Quit:
1494  LeaveCriticalSection(&Console->Lock);
1495  return;
1496 }
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:250
#define SIF_RANGE
Definition: winuser.h:1221
signed short * PSHORT
Definition: retypes.h:6
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI UpdateWindow(_In_ HWND)
#define PCONSRV_CONSOLE
Definition: conio.h:27
int32_t INT
Definition: typedefs.h:56
#define SIF_PAGE
Definition: winuser.h:1219
COORD ScreenBufferSize
Definition: conio.h:87
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
smooth NULL
Definition: ftsmooth.c:416
#define SB_THUMBPOSITION
Definition: winuser.h:572
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
ULONG X
Definition: bl.h:1340
#define SB_THUMBTRACK
Definition: winuser.h:573
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SW_INVALIDATE
Definition: winuser.h:2533
#define SIF_POS
Definition: winuser.h:1220
#define SB_TOP
Definition: winuser.h:578
FORCEINLINE VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.h:22
#define PAUSED_FROM_SCROLLBAR
Definition: conio_winsrv.h:126
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_LINEUP
Definition: winuser.h:564
#define SB_BOTTOM
Definition: winuser.h:577
CConsole Console
VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:243
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1341
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 2029 of file conwnd.c.

2030 {
2031  PCONSRV_CONSOLE Console = GuiData->Console;
2032 
2033  /* Do nothing if the window is hidden */
2034  if (!GuiData->IsWindowVisible) return;
2035 
2037 
2038  if (!GuiData->WindowSizeLock &&
2040  {
2041  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
2042  DWORD windx, windy, charx, chary;
2043  UINT WidthUnit, HeightUnit;
2044 
2045  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
2046 
2047  GuiData->WindowSizeLock = TRUE;
2048 
2049  windx = LOWORD(lParam);
2050  windy = HIWORD(lParam);
2051 
2052  /* Compensate for existing scroll bars (because lParam values do not accommodate scroll bar) */
2053  if (Buff->ViewSize.X < Buff->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // Window currently has a horizontal scrollbar
2054  if (Buff->ViewSize.Y < Buff->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // Window currently has a vertical scrollbar
2055 
2056  charx = windx / (int)WidthUnit ;
2057  chary = windy / (int)HeightUnit;
2058 
2059  /* Character alignment (round size up or down) */
2060  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
2061  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
2062 
2063  /* Compensate for added scroll bars in window */
2064  if (charx < (DWORD)Buff->ScreenBufferSize.X) windy -= GetSystemMetrics(SM_CYHSCROLL); // Window will have a horizontal scroll bar
2065  if (chary < (DWORD)Buff->ScreenBufferSize.Y) windx -= GetSystemMetrics(SM_CXVSCROLL); // Window will have a vertical scroll bar
2066 
2067  charx = windx / (int)WidthUnit ;
2068  chary = windy / (int)HeightUnit;
2069 
2070  /* Character alignment (round size up or down) */
2071  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
2072  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
2073 
2074  /* Resize window */
2075  if ((charx != Buff->ViewSize.X) || (chary != Buff->ViewSize.Y))
2076  {
2077  Buff->ViewSize.X = (charx <= (DWORD)Buff->ScreenBufferSize.X) ? charx : Buff->ScreenBufferSize.X;
2078  Buff->ViewSize.Y = (chary <= (DWORD)Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
2079  }
2080 
2081  ResizeConWnd(GuiData, WidthUnit, HeightUnit);
2082 
2083  /* Adjust the start of the visible area if we are attempting to show nonexistent areas */
2084  if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) < Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
2085  if ((Buff->ScreenBufferSize.Y - Buff->ViewOrigin.Y) < Buff->ViewSize.Y) Buff->ViewOrigin.Y = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
2086  InvalidateRect(GuiData->hWindow, NULL, TRUE);
2087 
2088  GuiData->WindowSizeLock = FALSE;
2089  }
2090 
2091  LeaveCriticalSection(&Console->Lock);
2092 }
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
#define SIZE_MAXIMIZED
Definition: winuser.h:2461
#define SIZE_RESTORED
Definition: winuser.h:2459
static VOID ResizeConWnd(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
Definition: conwnd.c:415
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define DWORD
Definition: nt_native.h:44
WPARAM wParam
Definition: combotst.c:138
BOOL WindowSizeLock
Definition: conwnd.h:43
COORD ScreenBufferSize
Definition: conio.h:87
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
smooth NULL
Definition: ftsmooth.c:416
ULONG X
Definition: bl.h:1340
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SIZE_MINIMIZED
Definition: winuser.h:2460
BOOLEAN 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:120
unsigned int UINT
Definition: ndis.h:50
#define SM_CXVSCROLL
Definition: winuser.h:951
CConsole Console
#define HIWORD(l)
Definition: typedefs.h:246
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1341
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by ConWndProc().

◆ OnTimer()

static VOID OnTimer ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1237 of file conwnd.c.

1238 {
1239  PCONSRV_CONSOLE Console = GuiData->Console;
1241 
1242  /* Do nothing if the window is hidden */
1243  if (!GuiData->IsWindowVisible) return;
1244 
1246 
1248 
1249  Buff = GuiData->ActiveBuffer;
1250 
1251  if (GetType(Buff) == TEXTMODE_BUFFER)
1252  {
1253  InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
1254  Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
1255 
1256  if ((GuiData->OldCursor.x != Buff->CursorPosition.X) ||
1257  (GuiData->OldCursor.y != Buff->CursorPosition.Y))
1258  {
1259  SCROLLINFO sInfo;
1260  int OldScrollX = -1, OldScrollY = -1;
1261  int NewScrollX = -1, NewScrollY = -1;
1262 
1263  sInfo.cbSize = sizeof(sInfo);
1264  sInfo.fMask = SIF_POS;
1265  // Capture the original position of the scroll bars and save them.
1266  if (GetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo)) OldScrollX = sInfo.nPos;
1267  if (GetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo)) OldScrollY = sInfo.nPos;
1268 
1269  // If we successfully got the info for the horizontal scrollbar
1270  if (OldScrollX >= 0)
1271  {
1272  if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) ||
1273  (Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X)))
1274  {
1275  // Handle the horizontal scroll bar
1276  if (Buff->CursorPosition.X >= Buff->ViewSize.X)
1277  NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1;
1278  else
1279  NewScrollX = 0;
1280  }
1281  else
1282  {
1283  NewScrollX = OldScrollX;
1284  }
1285  }
1286  // If we successfully got the info for the vertical scrollbar
1287  if (OldScrollY >= 0)
1288  {
1289  if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) ||
1290  (Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y)))
1291  {
1292  // Handle the vertical scroll bar
1293  if (Buff->CursorPosition.Y >= Buff->ViewSize.Y)
1294  NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1;
1295  else
1296  NewScrollY = 0;
1297  }
1298  else
1299  {
1300  NewScrollY = OldScrollY;
1301  }
1302  }
1303 
1304  // Adjust scroll bars and refresh the window if the cursor has moved outside the visible area
1305  // NOTE: OldScroll# and NewScroll# will both be -1 (initial value) if the info for the respective scrollbar
1306  // was not obtained successfully in the previous steps. This means their difference is 0 (no scrolling)
1307  // and their associated scrollbar is left alone.
1308  if ((OldScrollX != NewScrollX) || (OldScrollY != NewScrollY))
1309  {
1310  Buff->ViewOrigin.X = NewScrollX;
1311  Buff->ViewOrigin.Y = NewScrollY;
1312  ScrollWindowEx(GuiData->hWindow,
1313  (OldScrollX - NewScrollX) * GuiData->CharWidth,
1314  (OldScrollY - NewScrollY) * GuiData->CharHeight,
1315  NULL,
1316  NULL,
1317  NULL,
1318  NULL,
1319  SW_INVALIDATE);
1320  if (NewScrollX >= 0)
1321  {
1322  sInfo.nPos = NewScrollX;
1323  SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
1324  }
1325  if (NewScrollY >= 0)
1326  {
1327  sInfo.nPos = NewScrollY;
1328  SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
1329  }
1330  UpdateWindow(GuiData->hWindow);
1331  // InvalidateRect(GuiData->hWindow, NULL, FALSE);
1332  GuiData->OldCursor.x = Buff->CursorPosition.X;
1333  GuiData->OldCursor.y = Buff->CursorPosition.Y;
1334  }
1335  }
1336  }
1337  else /* if (GetType(Buff) == GRAPHICS_BUFFER) */
1338  {
1339  }
1340 
1341  LeaveCriticalSection(&Console->Lock);
1342 }
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
BOOLEAN CursorBlinkOn
Definition: conio.h:99
long x
Definition: polytest.cpp:48
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
COORD CursorPosition
Definition: conio.h:98
BOOL WINAPI UpdateWindow(_In_ HWND)
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define PCONSRV_CONSOLE
Definition: conio.h:27
UINT CharHeight
Definition: conwnd.h:86
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
#define CONGUI_UPDATE_TIMER
Definition: conwnd.c:36
smooth NULL
Definition: ftsmooth.c:416
#define CURSOR_BLINK_TIME
Definition: conwnd.c:38
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
VOID InvalidateCell(PGUI_CONSOLE_DATA GuiData, SHORT x, SHORT y)
Definition: guiterm.c:87
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
ULONG X
Definition: bl.h:1340
if(!(yy_init))
Definition: macro.lex.yy.c:714
POINT OldCursor
Definition: conwnd.h:54
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
#define SW_INVALIDATE
Definition: winuser.h:2533
#define SIF_POS
Definition: winuser.h:1220
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
UINT CharWidth
Definition: conwnd.h:85
CConsole Console
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG Y
Definition: bl.h:1341
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 829 of file conwnd.c.

830 {
831  HRGN rgnPaint = CreateRectRgnIndirect(&pps->rcPaint);
832  HRGN rgnSel = CreateSelectionRgn(GuiData, GuiData->LineSelection,
833  &GuiData->Selection.dwSelectionAnchor,
834  &GuiData->Selection.srSelection);
835 
836  /* Invert the selection */
837 
838  int ErrorCode = CombineRgn(rgnPaint, rgnPaint, rgnSel, RGN_AND);
839  if (ErrorCode != ERROR && ErrorCode != NULLREGION)
840  {
841  InvertRgn(pps->hdc, rgnPaint);
842  }
843 
844  DeleteObject(rgnSel);
845  DeleteObject(rgnPaint);
846 }
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:4418
#define ERROR(name)
Definition: error_private.h:53
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
#define NULLREGION
Definition: wingdi.h:360
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:91
SMALL_RECT srSelection
Definition: wincon.h:195
#define RGN_AND
Definition: wingdi.h:355
BOOL LineSelection
Definition: conwnd.h:93
static HRGN CreateSelectionRgn(PGUI_CONSOLE_DATA GuiData, BOOL LineSelection, PCOORD SelectionAnchor, PSMALL_RECT SmallRect)
Definition: conwnd.c:739
BOOL WINAPI InvertRgn(_In_ HDC, _In_ HRGN)
Definition: painting.c:215

Referenced by OnPaint().

◆ Paste()

static VOID Paste ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 1977 of file conwnd.c.

1978 {
1979  if (OpenClipboard(GuiData->hWindow))
1980  {
1982 
1983  if (GetType(Buffer) == TEXTMODE_BUFFER)
1984  {
1986  }
1987  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
1988  {
1990  }
1991 
1992  CloseClipboard();
1993  }
1994 }
#define TEXTMODE_BUFFER
Definition: pccons.c:21
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
Definition: bufpool.h:45
VOID GuiPasteToTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: text.c:330
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
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 1499 of file conwnd.c.

1500 {
1502  COORD Coord;
1503  UINT WidthUnit, HeightUnit;
1504 
1505  GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
1506 
1507  Coord.X = Buffer->ViewOrigin.X + ((SHORT)LOWORD(lParam) / (int)WidthUnit );
1508  Coord.Y = Buffer->ViewOrigin.Y + ((SHORT)HIWORD(lParam) / (int)HeightUnit);
1509 
1510  /* Clip coordinate to ensure it's inside buffer */
1511  if (Coord.X < 0)
1512  Coord.X = 0;
1513  else if (Coord.X >= Buffer->ScreenBufferSize.X)
1514  Coord.X = Buffer->ScreenBufferSize.X - 1;
1515 
1516  if (Coord.Y < 0)
1517  Coord.Y = 0;
1518  else if (Coord.Y >= Buffer->ScreenBufferSize.Y)
1519  Coord.Y = Buffer->ScreenBufferSize.Y - 1;
1520 
1521  return Coord;
1522 }
short SHORT
Definition: pedump.c:59
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
Definition: bl.h:1338
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:246
ULONG Y
Definition: bl.h:1341
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by OnMouse().

◆ RegisterConWndClass()

BOOLEAN RegisterConWndClass ( IN HINSTANCE  hInstance)

Definition at line 125 of file conwnd.c.

126 {
128  ATOM WndClassAtom;
129 
132  IMAGE_ICON,
135  LR_SHARED);
138  IMAGE_ICON,
141  LR_SHARED);
143 
144  WndClass.cbSize = sizeof(WNDCLASSEXW);
145  WndClass.lpszClassName = GUI_CONWND_CLASS;
146  WndClass.lpfnWndProc = ConWndProc;
147  WndClass.style = CS_DBLCLKS /* | CS_HREDRAW | CS_VREDRAW */;
148  WndClass.hInstance = hInstance;
149  WndClass.hIcon = ghDefaultIcon;
150  WndClass.hIconSm = ghDefaultIconSm;
151  WndClass.hCursor = ghDefaultCursor;
152  WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); // The color of a terminal when it is switched off.
153  WndClass.lpszMenuName = NULL;
154  WndClass.cbClsExtra = 0;
155  WndClass.cbWndExtra = GWLP_CONWND_ALLOC;
156 
157  WndClassAtom = RegisterClassExW(&WndClass);
158  if (WndClassAtom == 0)
159  {
160  DPRINT1("Failed to register GUI console class\n");
161  }
162  else
163  {
164  NtUserConsoleControl(GuiConsoleWndClassAtom, &WndClassAtom, sizeof(ATOM));
165  }
166 
167  return (WndClassAtom != 0);
168 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define LR_SHARED
Definition: winuser.h:1090
#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:1003
struct _WNDCLASSEXW WNDCLASSEXW
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
HINSTANCE hInstance
Definition: charmap.c:20
HICON ghDefaultIcon
Definition: conwnd.c:62
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:962
static LRESULT CALLBACK ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:2161
smooth NULL
Definition: ftsmooth.c:416
#define IDI_TERMINAL
Definition: resource.h:44
#define BLACK_BRUSH
Definition: wingdi.h:895
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:1002
#define SM_CYICON
Definition: winuser.h:963
HICON ghDefaultIconSm
Definition: conwnd.c:63
HCURSOR ghDefaultCursor
Definition: conwnd.c:64
#define CS_DBLCLKS
Definition: winuser.h:646
#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 415 of file conwnd.c.

416 {
417  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
418  SCROLLINFO sInfo;
419 
420  DWORD Width, Height;
421 
422  Width = Buff->ViewSize.X * WidthUnit +
424  Height = Buff->ViewSize.Y * HeightUnit +
426 
427  /* Set scrollbar sizes */
428  sInfo.cbSize = sizeof(sInfo);
429  sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
430  sInfo.nMin = 0;
431  if (Buff->ScreenBufferSize.Y > Buff->ViewSize.Y)
432  {
433  sInfo.nMax = Buff->ScreenBufferSize.Y - 1;
434  sInfo.nPage = Buff->ViewSize.Y;
435  sInfo.nPos = Buff->ViewOrigin.Y;
436  SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
437  Width += GetSystemMetrics(SM_CXVSCROLL);
438  ShowScrollBar(GuiData->hWindow, SB_VERT, TRUE);
439  }
440  else
441  {
442  ShowScrollBar(GuiData->hWindow, SB_VERT, FALSE);
443  }
444 
445  if (Buff->ScreenBufferSize.X > Buff->ViewSize.X)
446  {
447  sInfo.nMax = Buff->ScreenBufferSize.X - 1;
448  sInfo.nPage = Buff->ViewSize.X;
449  sInfo.nPos = Buff->ViewOrigin.X;
450  SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
451  Height += GetSystemMetrics(SM_CYHSCROLL);
452  ShowScrollBar(GuiData->hWindow, SB_HORZ, TRUE);
453  }
454  else
455  {
456  ShowScrollBar(GuiData->hWindow, SB_HORZ, FALSE);
457  }
458 
459  /* Resize the window */
460  SetWindowPos(GuiData->hWindow, NULL, 0, 0, Width, Height,
462  // NOTE: The SWP_NOCOPYBITS flag can be replaced by a subsequent call
463  // to: InvalidateRect(GuiData->hWindow, NULL, TRUE);
464 }
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
#define SM_CXEDGE
Definition: winuser.h:998
#define SWP_NOZORDER
Definition: winuser.h:1232
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
#define SIF_PAGE
Definition: winuser.h:1219
#define SWP_NOCOPYBITS
Definition: winuser.h:1228
COORD ScreenBufferSize
Definition: conio.h:87
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYEDGE
Definition: winuser.h:999
ULONG X
Definition: bl.h:1340
#define SM_CYCAPTION
Definition: winuser.h:953
#define SWP_NOACTIVATE
Definition: winuser.h:1227
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SIF_POS
Definition: winuser.h:1220
#define SM_CXVSCROLL
Definition: winuser.h:951
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
ULONG Y
Definition: bl.h:1341
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by ConWndProc(), and OnSize().

◆ SelectAll()

static VOID SelectAll ( PGUI_CONSOLE_DATA  GuiData)
static

Definition at line 302 of file conwnd.c.

303 {
304  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
305  COORD SelectionAnchor;
306 
307  /* Clear the old selection */
309 
310  /*
311  * The selection area extends to the whole screen buffer's width.
312  */
313  SelectionAnchor.X = SelectionAnchor.Y = 0;
314  GuiData->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
315 
316  /*
317  * Determine whether the selection must extend to just some part
318  * (for text-mode screen buffers) or to all of the screen buffer's
319  * height (for graphics ones).
320  */
321  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
322  {
323  /*
324  * We select all the characters from the first line
325  * to the line where the cursor is positioned.
326  */
327  GuiData->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
328  }
329  else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
330  {
331  /*
332  * We select all the screen buffer area.
333  */
334  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
335  }
336 
337  /* Restart a new selection */
339  UpdateSelection(GuiData, &SelectionAnchor, &GuiData->dwSelectionCursor);
340 }
COORD dwSelectionCursor
Definition: conwnd.h:92
COORD CursorPosition
Definition: conio.h:98
#define CONSOLE_NO_SELECTION
Definition: wincon.h:96
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:91
#define TEXTMODE_BUFFER
Definition: pccons.c:21
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:849
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:99
COORD ScreenBufferSize
Definition: conio.h:87
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:90
ULONG X
Definition: bl.h:1340
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1341

Referenced by OnCommand().

◆ SendMenuEvent()

static VOID SendMenuEvent ( PCONSRV_CONSOLE  Console,
UINT  CmdId 
)
static

Definition at line 261 of file conwnd.c.

262 {
263  INPUT_RECORD er;
264 
265  DPRINT("Menu item ID: %d\n", CmdId);
266 
268 
269  /* Send a menu event */
270  er.EventType = MENU_EVENT;
271  er.Event.MenuEvent.dwCommandId = CmdId;
273 
275 }
#define TRUE
Definition: types.h:120
void DPRINT(...)
Definition: polytest.cpp:61
union _INPUT_RECORD::@3145 Event
#define MENU_EVENT
Definition: wincon.h:125
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
CConsole Console
WORD EventType
Definition: wincon.h:261
MENU_EVENT_RECORD MenuEvent
Definition: wincon.h:266
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:195

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  CLIENT_ID ConsoleLeaderCID;
52 
53  ProcessData = ConSrvGetConsoleLeaderProcess(GuiData->Console);
54  ConsoleLeaderCID = ProcessData->Process->ClientId;
56  (LONG_PTR)(ConsoleLeaderCID.UniqueProcess));
58  (LONG_PTR)(ConsoleLeaderCID.UniqueThread));
59 }
PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console)
Definition: console.c:867
HANDLE UniqueProcess
Definition: compat.h:474
#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
PCSR_PROCESS Process
Definition: consrv.h:43
HANDLE UniqueThread
Definition: compat.h:475
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define SetWindowLongPtrW
Definition: winuser.h:5215

Referenced by GuiRefreshInternalInfo().

◆ UnRegisterConWndClass()

BOOLEAN UnRegisterConWndClass ( HINSTANCE  hInstance)

Definition at line 171 of file conwnd.c.

172 {
174 }
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 849 of file conwnd.c.

852 {
853  PCONSRV_CONSOLE Console = GuiData->Console;
854  HRGN oldRgn = CreateSelectionRgn(GuiData, GuiData->LineSelection,
855  &GuiData->Selection.dwSelectionAnchor,
856  &GuiData->Selection.srSelection);
857 
858  /* Update the anchor if needed (use the old one if NULL) */
859  if (SelectionAnchor)
860  GuiData->Selection.dwSelectionAnchor = *SelectionAnchor;
861 
862  // TODO: Scroll buffer to bring 'coord' into view
863 
864  if (coord != NULL)
865  {
866  SMALL_RECT rc;
867  HRGN newRgn;
868 
869  /*
870  * Pressing the Control key while selecting text, allows us to enter
871  * into line-selection mode, the selection mode of *nix terminals.
872  */
873  BOOL OldLineSel = GuiData->LineSelection;
875 
876  /* Exchange left/top with right/bottom if required */
877  rc.Left = min(GuiData->Selection.dwSelectionAnchor.X, coord->X);
878  rc.Top = min(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
879  rc.Right = max(GuiData->Selection.dwSelectionAnchor.X, coord->X);
880  rc.Bottom = max(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
881 
882  newRgn = CreateSelectionRgn(GuiData, GuiData->LineSelection,
883  &GuiData->Selection.dwSelectionAnchor,
884  &rc);
885 
887  {
888  if (OldLineSel != GuiData->LineSelection ||
889  memcmp(&rc, &GuiData->Selection.srSelection, sizeof(SMALL_RECT)) != 0)
890  {
891  /* Calculate the region that needs to be updated */
892  if (oldRgn && newRgn && CombineRgn(newRgn, newRgn, oldRgn, RGN_XOR) != ERROR)
893  {
894  InvalidateRgn(GuiData->hWindow, newRgn, FALSE);
895  }
896  }
897  }
898  else
899  {
900  InvalidateRgn(GuiData->hWindow, newRgn, FALSE);
901  }
902 
903  DeleteObject(newRgn);
904 
906  GuiData->Selection.srSelection = rc;
907  GuiData->dwSelectionCursor = *coord;
908 
909  if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
910  {
911  LPWSTR SelTypeStr = NULL , WindowTitle = NULL;
912  SIZE_T SelTypeStrLength = 0, Length = 0;
913 
914  /* Clear the old selection */
916  {
917  InvalidateRgn(GuiData->hWindow, oldRgn, FALSE);
918  }
919 
920  /*
921  * When passing a zero-length buffer size, LoadString(...) returns
922  * a read-only pointer buffer to the program's resource string.
923  */
924  SelTypeStrLength =
928  (LPWSTR)&SelTypeStr, 0);
929 
930  /*
931  * Prepend the selection type string to the current console title
932  * if we succeeded in retrieving a valid localized string.
933  */
934  if (SelTypeStr)
935  {
936  // 3 for " - " and 1 for NULL
937  Length = Console->Title.Length + (SelTypeStrLength + 3 + 1) * sizeof(WCHAR);
938  WindowTitle = ConsoleAllocHeap(0, Length);
939 
940  wcsncpy(WindowTitle, SelTypeStr, SelTypeStrLength);
941  WindowTitle[SelTypeStrLength] = UNICODE_NULL;
942  wcscat(WindowTitle, L" - ");
943  wcscat(WindowTitle, Console->Title.Buffer);
944 
945  SetWindowTextW(GuiData->hWindow, WindowTitle);
946  ConsoleFreeHeap(WindowTitle);
947  }
948 
951  }
952  }
953  else
954  {
955  /* Clear the selection */
957  {
958  InvalidateRgn(GuiData->hWindow, oldRgn, FALSE);
959  }
960 
963 
964  /* Restore the console title */
965  SetWindowTextW(GuiData->hWindow, Console->Title.Buffer);
966  }
967 
968  DeleteObject(oldRgn);
969 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
COORD dwSelectionCursor
Definition: conwnd.h:92
#define max(a, b)
Definition: svc.c:63
VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:250
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERROR(name)
Definition: error_private.h:53
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define CONSOLE_NO_SELECTION
Definition: wincon.h:96
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:91
SMALL_RECT srSelection
Definition: wincon.h:195
#define PCONSRV_CONSOLE
Definition: conio.h:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define PAUSED_FROM_SELECTION
Definition: conio_winsrv.h:127
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:99
GLuint coord
Definition: glext.h:9511
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
#define RGN_XOR
Definition: wingdi.h:359
smooth NULL
Definition: ftsmooth.c:416
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
BOOL LineSelection
Definition: conwnd.h:93
SHORT WINAPI GetKeyState(_In_ int)
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
static HRGN CreateSelectionRgn(PGUI_CONSOLE_DATA GuiData, BOOL LineSelection, PCOORD SelectionAnchor, PSMALL_RECT SmallRect)
Definition: conwnd.c:739
#define KEY_PRESSED
Definition: conwnd.h:26
SHORT Bottom
Definition: blue.h:28
__wchar_t WCHAR
Definition: xmlstorage.h:180
SHORT Top
Definition: blue.h:26
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
#define IDS_MARK_TITLE
Definition: resource.h:31
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define min(a, b)
Definition: monoChain.cc:55
#define VK_CONTROL
Definition: winuser.h:2157
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
HINSTANCE ConSrvDllInstance
Definition: init.c:21
VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:243
PCONSRV_CONSOLE Console
Definition: conwnd.h:89
WCHAR * LPWSTR
Definition: xmlstorage.h:184
SHORT Right
Definition: blue.h:27
ULONG Y
Definition: bl.h:1341
#define IDS_SELECT_TITLE
Definition: resource.h:32

Referenced by Copy(), Mark(), OnKey(), OnMouse(), and SelectAll().

Variable Documentation

◆ ghDefaultCursor

HCURSOR ghDefaultCursor = NULL

Definition at line 64 of file conwnd.c.

Referenced by GuiInit(), GuiInitFrontEnd(), GuiSetMouseCursor(), and RegisterConWndClass().

◆ ghDefaultIcon

◆ ghDefaultIconSm

◆ GuiConsoleEditMenuItems

const GUICONSOLE_MENUITEM GuiConsoleEditMenuItems[]
static
Initial value:
=
{
{ 0, NULL, 0 }
}
#define ID_SYSTEM_EDIT_SCROLL
Definition: resource.h:16
#define IDS_FIND
Definition: resource.h:27
#define ID_SYSTEM_EDIT_COPY
Definition: resource.h:13
#define IDS_SCROLL
Definition: resource.h:26
#define ID_SYSTEM_EDIT_MARK
Definition: resource.h:12
smooth NULL
Definition: ftsmooth.c:416
#define IDS_SELECTALL
Definition: resource.h:25
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
#define ID_SYSTEM_EDIT_SELECTALL
Definition: resource.h:15
#define IDS_PASTE
Definition: shresdef.h:214
#define ID_SYSTEM_EDIT_FIND
Definition: resource.h:17
#define IDS_MARK
Definition: resource.h:22