ReactOS  0.4.15-dev-2701-g34593d9
conwnd.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Console Server DLL
4  * FILE: win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
5  * PURPOSE: GUI Console Window Class
6  * PROGRAMMERS: Gé van Geldorp
7  * Johannes Anderwald
8  * Jeffrey Morlan
9  * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
10  * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
11  */
12 
13 /* INCLUDES *******************************************************************/
14 
15 #include <consrv.h>
16 #include <intrin.h>
17 #include <windowsx.h>
18 #include <shellapi.h>
19 
20 #define NDEBUG
21 #include <debug.h>
22 
23 #include "concfg/font.h"
24 #include "guiterm.h"
25 #include "resource.h"
26 
27 /* GLOBALS ********************************************************************/
28 
29 // #define PM_CREATE_CONSOLE (WM_APP + 1)
30 // #define PM_DESTROY_CONSOLE (WM_APP + 2)
31 
32 // See guiterm.c
33 #define CONGUI_MIN_WIDTH 10
34 #define CONGUI_MIN_HEIGHT 10
35 #define CONGUI_UPDATE_TIME 0
36 #define CONGUI_UPDATE_TIMER 1
37 
38 #define CURSOR_BLINK_TIME 500
39 
40 
41 /**************************************************************\
42 \** Define the Console Leader Process for the console window **/
43 #define GWLP_CONWND_ALLOC (2 * sizeof(LONG_PTR))
44 #define GWLP_CONSOLE_LEADER_PID 0
45 #define GWLP_CONSOLE_LEADER_TID 4
46 
47 VOID
49 {
50  PCONSOLE_PROCESS_DATA ProcessData;
51 
52  ProcessData = ConSrvGetConsoleLeaderProcess(GuiData->Console);
53 
54  ASSERT(ProcessData != NULL);
55  DPRINT("ProcessData: %p, ProcessData->Process %p.\n", ProcessData, ProcessData->Process);
56 
57  if (ProcessData->Process)
58  {
59  CLIENT_ID ConsoleLeaderCID = ProcessData->Process->ClientId;
61  (LONG_PTR)(ConsoleLeaderCID.UniqueProcess));
63  (LONG_PTR)(ConsoleLeaderCID.UniqueThread));
64  }
65  else
66  {
67  SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_PID, 0);
68  SetWindowLongPtrW(GuiData->hWindow, GWLP_CONSOLE_LEADER_TID, 0);
69  }
70 }
71 /**************************************************************/
72 
76 
77 typedef struct _GUICONSOLE_MENUITEM
78 {
83 
85 {
92 
93  { 0, NULL, 0 } /* End of list */
94 };
95 
97 {
101 
102  { 0, NULL, 0 } /* End of list */
103 };
104 
105 /*
106  * Default 16-color palette for foreground and background
107  * (corresponding flags in comments).
108  */
109 const COLORREF s_Colors[16] =
110 {
111  RGB(0, 0, 0), // (Black)
112  RGB(0, 0, 128), // BLUE
113  RGB(0, 128, 0), // GREEN
114  RGB(0, 128, 128), // BLUE | GREEN
115  RGB(128, 0, 0), // RED
116  RGB(128, 0, 128), // BLUE | RED
117  RGB(128, 128, 0), // GREEN | RED
118  RGB(192, 192, 192), // BLUE | GREEN | RED
119 
120  RGB(128, 128, 128), // (Grey) INTENSITY
121  RGB(0, 0, 255), // BLUE | INTENSITY
122  RGB(0, 255, 0), // GREEN | INTENSITY
123  RGB(0, 255, 255), // BLUE | GREEN | INTENSITY
124  RGB(255, 0, 0), // RED | INTENSITY
125  RGB(255, 0, 255), // BLUE | RED | INTENSITY
126  RGB(255, 255, 0), // GREEN | RED | INTENSITY
127  RGB(255, 255, 255) // BLUE | GREEN | RED | INTENSITY
128 };
129 
130 /* FUNCTIONS ******************************************************************/
131 
132 static LRESULT CALLBACK
134 
135 BOOLEAN
137 {
139  ATOM WndClassAtom;
140 
143  IMAGE_ICON,
146  LR_SHARED);
149  IMAGE_ICON,
152  LR_SHARED);
154 
155  WndClass.cbSize = sizeof(WNDCLASSEXW);
156  WndClass.lpszClassName = GUI_CONWND_CLASS;
157  WndClass.lpfnWndProc = ConWndProc;
158  WndClass.style = CS_DBLCLKS /* | CS_HREDRAW | CS_VREDRAW */;
159  WndClass.hInstance = hInstance;
160  WndClass.hIcon = ghDefaultIcon;
161  WndClass.hIconSm = ghDefaultIconSm;
162  WndClass.hCursor = ghDefaultCursor;
163  WndClass.hbrBackground = NULL;
164  WndClass.lpszMenuName = NULL;
165  WndClass.cbClsExtra = 0;
166  WndClass.cbWndExtra = GWLP_CONWND_ALLOC;
167 
168  WndClassAtom = RegisterClassExW(&WndClass);
169  if (WndClassAtom == 0)
170  {
171  DPRINT1("Failed to register GUI console class\n");
172  }
173  else
174  {
175  NtUserConsoleControl(GuiConsoleWndClassAtom, &WndClassAtom, sizeof(ATOM));
176  }
177 
178  return (WndClassAtom != 0);
179 }
180 
181 BOOLEAN
183 {
185 }
186 
187 static VOID
189  const GUICONSOLE_MENUITEM *Items)
190 {
191  UINT i = 0;
192  WCHAR szMenuString[255];
193  HMENU hSubMenu;
194 
195  do
196  {
197  if (Items[i].uID != (UINT)-1)
198  {
200  Items[i].uID,
201  szMenuString,
202  ARRAYSIZE(szMenuString)) > 0)
203  {
204  if (Items[i].SubMenu != NULL)
205  {
206  hSubMenu = CreatePopupMenu();
207  if (hSubMenu != NULL)
208  {
209  AppendMenuItems(hSubMenu, Items[i].SubMenu);
210 
211  if (!AppendMenuW(hMenu,
213  (UINT_PTR)hSubMenu,
214  szMenuString))
215  {
216  DestroyMenu(hSubMenu);
217  }
218  }
219  }
220  else
221  {
222  AppendMenuW(hMenu,
223  MF_STRING,
224  Items[i].wCmdID,
225  szMenuString);
226  }
227  }
228  }
229  else
230  {
231  AppendMenuW(hMenu,
232  MF_SEPARATOR,
233  0,
234  NULL);
235  }
236  i++;
237  } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].wCmdID == 0));
238 }
239 
240 //static
241 VOID
243 {
244  MENUITEMINFOW mii;
245  HMENU hMenu;
246  PWCHAR ptrTab;
247  WCHAR szMenuStringBack[255];
248 
249  hMenu = GetSystemMenu(hWnd, FALSE);
250  if (hMenu == NULL)
251  return;
252 
253  mii.cbSize = sizeof(mii);
254  mii.fMask = MIIM_STRING;
255  mii.dwTypeData = szMenuStringBack;
256  mii.cch = ARRAYSIZE(szMenuStringBack);
257 
258  GetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
259 
260  ptrTab = wcschr(szMenuStringBack, L'\t');
261  if (ptrTab)
262  {
263  *ptrTab = L'\0';
264  mii.cch = (UINT)wcslen(szMenuStringBack);
265 
266  SetMenuItemInfoW(hMenu, SC_CLOSE, FALSE, &mii);
267  }
268 
270  DrawMenuBar(hWnd);
271 }
272 
273 static VOID
275 {
276  INPUT_RECORD er;
277 
278  DPRINT("Menu item ID: %d\n", CmdId);
279 
281 
282  /* Send a menu event */
283  er.EventType = MENU_EVENT;
284  er.Event.MenuEvent.dwCommandId = CmdId;
286 
288 }
289 
290 static VOID
291 Copy(PGUI_CONSOLE_DATA GuiData);
292 static VOID
293 Paste(PGUI_CONSOLE_DATA GuiData);
294 static VOID
296  PCOORD SelectionAnchor OPTIONAL,
297  PCOORD coord);
298 
299 static VOID
301 {
302  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
303 
304  /* Clear the old selection */
306 
307  /* Restart a new selection */
308  GuiData->dwSelectionCursor = ActiveBuffer->ViewOrigin;
309  UpdateSelection(GuiData,
310  &GuiData->dwSelectionCursor,
311  &GuiData->dwSelectionCursor);
312 }
313 
314 static VOID
316 {
317  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
318  COORD SelectionAnchor;
319 
320  /* Clear the old selection */
322 
323  /*
324  * The selection area extends to the whole screen buffer's width.
325  */
326  SelectionAnchor.X = SelectionAnchor.Y = 0;
327  GuiData->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
328 
329  /*
330  * Determine whether the selection must extend to just some part
331  * (for text-mode screen buffers) or to all of the screen buffer's
332  * height (for graphics ones).
333  */
334  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
335  {
336  /*
337  * We select all the characters from the first line
338  * to the line where the cursor is positioned.
339  */
340  GuiData->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
341  }
342  else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
343  {
344  /*
345  * We select all the screen buffer area.
346  */
347  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
348  }
349 
350  /* Restart a new selection */
352  UpdateSelection(GuiData, &SelectionAnchor, &GuiData->dwSelectionCursor);
353 }
354 
355 static LRESULT
357 {
358  LRESULT Ret = TRUE;
359  PCONSRV_CONSOLE Console = GuiData->Console;
360 
361  /*
362  * In case the selected menu item belongs to the user-reserved menu id range,
363  * send to him a menu event and return directly. The user must handle those
364  * reserved menu commands...
365  */
366  if (GuiData->CmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->CmdIdHigh)
367  {
369  goto Quit;
370  }
371 
372  /* ... otherwise, perform actions. */
373  switch (wParam)
374  {
375  case ID_SYSTEM_EDIT_MARK:
376  Mark(GuiData);
377  break;
378 
379  case ID_SYSTEM_EDIT_COPY:
380  Copy(GuiData);
381  break;
382 
384  Paste(GuiData);
385  break;
386 
388  SelectAll(GuiData);
389  break;
390 
392  DPRINT1("Scrolling is not handled yet\n");
393  break;
394 
395  case ID_SYSTEM_EDIT_FIND:
396  DPRINT1("Finding is not handled yet\n");
397  break;
398 
399  case ID_SYSTEM_DEFAULTS:
401  break;
402 
405  break;
406 
407  default:
408  Ret = FALSE;
409  break;
410  }
411 
412 Quit:
413  if (!Ret)
414  Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam);
415 
416  return Ret;
417 }
418 
419 static PGUI_CONSOLE_DATA
421 {
422  /* This function ensures that the console pointer is not NULL */
424  return ( ((GuiData == NULL) || (GuiData->hWindow == hWnd && GuiData->Console != NULL)) ? GuiData : NULL );
425 }
426 
427 static VOID
428 ResizeConWnd(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
429 {
430  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
431  SCROLLINFO sInfo;
432 
433  DWORD Width, Height;
434 
435  Width = Buff->ViewSize.X * WidthUnit +
437  Height = Buff->ViewSize.Y * HeightUnit +
439 
440  /* Set scrollbar sizes */
441  sInfo.cbSize = sizeof(sInfo);
442  sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
443  sInfo.nMin = 0;
444  if (Buff->ScreenBufferSize.Y > Buff->ViewSize.Y)
445  {
446  sInfo.nMax = Buff->ScreenBufferSize.Y - 1;
447  sInfo.nPage = Buff->ViewSize.Y;
448  sInfo.nPos = Buff->ViewOrigin.Y;
449  SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
450  Width += GetSystemMetrics(SM_CXVSCROLL);
451  ShowScrollBar(GuiData->hWindow, SB_VERT, TRUE);
452  }
453  else
454  {
455  ShowScrollBar(GuiData->hWindow, SB_VERT, FALSE);
456  }
457 
458  if (Buff->ScreenBufferSize.X > Buff->ViewSize.X)
459  {
460  sInfo.nMax = Buff->ScreenBufferSize.X - 1;
461  sInfo.nPage = Buff->ViewSize.X;
462  sInfo.nPos = Buff->ViewOrigin.X;
463  SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
464  Height += GetSystemMetrics(SM_CYHSCROLL);
465  ShowScrollBar(GuiData->hWindow, SB_HORZ, TRUE);
466  }
467  else
468  {
469  ShowScrollBar(GuiData->hWindow, SB_HORZ, FALSE);
470  }
471 
472  /* Resize the window */
473  SetWindowPos(GuiData->hWindow, NULL, 0, 0, Width, Height,
475  // NOTE: The SWP_NOCOPYBITS flag can be replaced by a subsequent call
476  // to: InvalidateRect(GuiData->hWindow, NULL, TRUE);
477 }
478 
479 
480 VOID
482 {
483  ULONG i;
484  for (i = 0; i < ARRAYSIZE(GuiData->Font); ++i)
485  {
486  if (GuiData->Font[i] != NULL) DeleteObject(GuiData->Font[i]);
487  GuiData->Font[i] = NULL;
488  }
489 }
490 
491 static HFONT
493  // COORD FontSize,
494  ULONG FontWeight,
495  // BOOLEAN bItalic,
496  BOOLEAN bUnderline,
497  BOOLEAN bStrikeOut)
498 {
499  LOGFONTW lf;
500 
501  /* Initialize the LOGFONT structure */
502  RtlZeroMemory(&lf, sizeof(lf));
503 
504  /* Retrieve the details of the current font */
505  if (GetObjectW(OrgFont, sizeof(lf), &lf) == 0)
506  return NULL;
507 
508  /* Change the font attributes */
509  // lf.lfHeight = FontSize.Y;
510  // lf.lfWidth = FontSize.X;
511  lf.lfWeight = FontWeight;
512  // lf.lfItalic = bItalic;
513  lf.lfUnderline = bUnderline;
514  lf.lfStrikeOut = bStrikeOut;
515 
516  /* Build a new font */
517  return CreateFontIndirectW(&lf);
518 }
519 
520 BOOL
522  LPWSTR FaceName, // Points to a WCHAR array of LF_FACESIZE elements.
524  COORD FontSize,
525  ULONG FontWeight)
526 {
527  HDC hDC;
528  HFONT hFont;
529 
530  /*
531  * Initialize a new NORMAL font and get its character cell size.
532  */
533  /* NOTE: FontSize is always in cell height/width units (pixels) */
534  hFont = CreateConsoleFontEx((LONG)(ULONG)FontSize.Y,
535  (LONG)(ULONG)FontSize.X,
536  FaceName,
537  FontFamily,
538  FontWeight,
539  GuiData->Console->OutputCodePage);
540  if (hFont == NULL)
541  {
542  DPRINT1("InitFonts: CreateConsoleFontEx failed\n");
543  return FALSE;
544  }
545 
546  hDC = GetDC(GuiData->hWindow);
547  if (!GetFontCellSize(hDC, hFont, &GuiData->CharHeight, &GuiData->CharWidth))
548  {
549  DPRINT1("InitFonts: GetFontCellSize failed\n");
550  ReleaseDC(GuiData->hWindow, hDC);
552  return FALSE;
553  }
554  ReleaseDC(GuiData->hWindow, hDC);
555 
556  /*
557  * Initialization succeeded.
558  */
559  // Delete all the old fonts first.
560  DeleteFonts(GuiData);
561  GuiData->Font[FONT_NORMAL] = hFont;
562 
563  /*
564  * Now build the other fonts (bold, underlined, mixed).
565  */
566  GuiData->Font[FONT_BOLD] =
568  FontWeight < FW_BOLD ? FW_BOLD : FontWeight,
569  FALSE,
570  FALSE);
571  GuiData->Font[FONT_UNDERLINE] =
573  FontWeight,
574  TRUE,
575  FALSE);
576  GuiData->Font[FONT_BOLD | FONT_UNDERLINE] =
578  FontWeight < FW_BOLD ? FW_BOLD : FontWeight,
579  TRUE,
580  FALSE);
581 
582  /*
583  * Save the settings.
584  */
585  if (FaceName != GuiData->GuiInfo.FaceName)
586  {
588  FaceName, LF_FACESIZE);
589  }
590  GuiData->GuiInfo.FontFamily = FontFamily;
591  GuiData->GuiInfo.FontSize = FontSize;
592  GuiData->GuiInfo.FontWeight = FontWeight;
593 
594  return TRUE;
595 }
596 
597 
598 static BOOL
600 {
601  PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
603 
604  if (GuiData == NULL)
605  {
606  DPRINT1("GuiConsoleNcCreate: No GUI data\n");
607  return FALSE;
608  }
609 
610  Console = GuiData->Console;
611 
612  GuiData->hWindow = hWnd;
613  GuiData->hSysMenu = GetSystemMenu(hWnd, FALSE);
614 
615  /* Initialize the fonts */
616  if (!InitFonts(GuiData,
617  GuiData->GuiInfo.FaceName,
618  GuiData->GuiInfo.FontFamily,
619  GuiData->GuiInfo.FontSize,
620  GuiData->GuiInfo.FontWeight))
621  {
622  DPRINT1("GuiConsoleNcCreate: InitFonts failed\n");
623  GuiData->hWindow = NULL;
624  NtSetEvent(GuiData->hGuiInitEvent, NULL);
625  return FALSE;
626  }
627 
628  /* Initialize the terminal framebuffer */
629  GuiData->hMemDC = CreateCompatibleDC(NULL);
630  GuiData->hBitmap = NULL;
631  GuiData->hSysPalette = NULL; /* Original system palette */
632 
633  /* Update the icons of the window */
634  if (GuiData->hIcon != ghDefaultIcon)
635  {
636  DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_BIG , (LPARAM)GuiData->hIcon );
637  DefWindowProcW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
638  }
639 
640  // FIXME: Keep these instructions here ? ///////////////////////////////////
641  Console->ActiveBuffer->CursorBlinkOn = TRUE;
642  Console->ActiveBuffer->ForceCursorOff = FALSE;
644 
645  SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
646 
647  if (GuiData->IsWindowVisible)
648  {
650  }
651 
652  // FIXME: HACK: Potential HACK for CORE-8129; see revision 63595.
653  //CreateSysMenu(GuiData->hWindow);
654 
655  DPRINT("OnNcCreate - setting start event\n");
656  NtSetEvent(GuiData->hGuiInitEvent, NULL);
657 
658  /* We accept dropped files */
659  DragAcceptFiles(GuiData->hWindow, TRUE);
660 
661  return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
662 }
663 
664 static VOID
666 {
667  WORD ActivationState = LOWORD(wParam);
668 
669  DPRINT("WM_ACTIVATE - ActivationState = %d\n", ActivationState);
670 
671  if ( ActivationState == WA_ACTIVE ||
672  ActivationState == WA_CLICKACTIVE )
673  {
674  if (GuiData->GuiInfo.FullScreen)
675  {
676  EnterFullScreen(GuiData);
677  // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
678  // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
679  }
680  }
681  else // if (ActivationState == WA_INACTIVE)
682  {
683  if (GuiData->GuiInfo.FullScreen)
684  {
686  LeaveFullScreen(GuiData);
687  // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
688  // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
689  }
690  }
691 
692  /*
693  * Ignore the next mouse signal when we are going to be enabled again via
694  * the mouse, in order to prevent, e.g. when we are in Edit mode, erroneous
695  * mouse actions from the user that could spoil text selection or copy/pastes.
696  */
697  if (ActivationState == WA_CLICKACTIVE)
698  GuiData->IgnoreNextMouseSignal = TRUE;
699 }
700 
701 static VOID
703 {
704  PCONSRV_CONSOLE Console = GuiData->Console;
705  INPUT_RECORD er;
706 
708 
709  /* Set console focus state */
710  Console->HasFocus = SetFocus;
711 
712  /*
713  * Set the priority of the processes of this console
714  * in accordance with the console focus state.
715  */
717 
718  /* Send a focus event */
719  er.EventType = FOCUS_EVENT;
722 
724 
725  if (SetFocus)
726  DPRINT("TODO: Create console caret\n");
727  else
728  DPRINT("TODO: Destroy console caret\n");
729 }
730 
731 VOID
733  PCOORD SelectionAnchor,
734  PSMALL_RECT SmallRect)
735 {
736  if (Begin == NULL || End == NULL) return;
737 
738  *Begin = *SelectionAnchor;
739  End->X = (SelectionAnchor->X == SmallRect->Left) ? SmallRect->Right
740  /* Case X != Left, must be == Right */ : SmallRect->Left;
741  End->Y = (SelectionAnchor->Y == SmallRect->Top ) ? SmallRect->Bottom
742  /* Case Y != Top, must be == Bottom */ : SmallRect->Top;
743 
744  /* Exchange Begin / End if Begin > End lexicographically */
745  if (Begin->Y > End->Y || (Begin->Y == End->Y && Begin->X > End->X))
746  {
747  End->X = _InterlockedExchange16(&Begin->X, End->X);
748  End->Y = _InterlockedExchange16(&Begin->Y, End->Y);
749  }
750 }
751 
752 static HRGN
754  BOOL LineSelection,
755  PCOORD SelectionAnchor,
756  PSMALL_RECT SmallRect)
757 {
758  if (!LineSelection)
759  {
760  RECT rect;
761  SmallRectToRect(GuiData, &rect, SmallRect);
762  return CreateRectRgnIndirect(&rect);
763  }
764  else
765  {
766  HRGN SelRgn;
767  COORD Begin, End;
768 
769  GetSelectionBeginEnd(&Begin, &End, SelectionAnchor, SmallRect);
770 
771  if (Begin.Y == End.Y)
772  {
773  SMALL_RECT sr;
774  RECT r ;
775 
776  sr.Left = Begin.X;
777  sr.Top = Begin.Y;
778  sr.Right = End.X;
779  sr.Bottom = End.Y;
780 
781  // Debug thingie to see whether I can put this corner case
782  // together with the previous one.
783  if (SmallRect->Left != sr.Left ||
784  SmallRect->Top != sr.Top ||
785  SmallRect->Right != sr.Right ||
786  SmallRect->Bottom != sr.Bottom)
787  {
788  DPRINT1("\n"
789  "SmallRect = (%d, %d, %d, %d)\n"
790  "sr = (%d, %d, %d, %d)\n"
791  "\n",
792  SmallRect->Left, SmallRect->Top, SmallRect->Right, SmallRect->Bottom,
793  sr.Left, sr.Top, sr.Right, sr.Bottom);
794  }
795 
796  SmallRectToRect(GuiData, &r, &sr);
797  SelRgn = CreateRectRgnIndirect(&r);
798  }
799  else
800  {
801  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
802 
803  HRGN rg1, rg2, rg3;
804  SMALL_RECT sr1, sr2, sr3;
805  RECT r1 , r2 , r3 ;
806 
807  sr1.Left = Begin.X;
808  sr1.Top = Begin.Y;
809  sr1.Right = ActiveBuffer->ScreenBufferSize.X - 1;
810  sr1.Bottom = Begin.Y;
811 
812  sr2.Left = 0;
813  sr2.Top = Begin.Y + 1;
814  sr2.Right = ActiveBuffer->ScreenBufferSize.X - 1;
815  sr2.Bottom = End.Y - 1;
816 
817  sr3.Left = 0;
818  sr3.Top = End.Y;
819  sr3.Right = End.X;
820  sr3.Bottom = End.Y;
821 
822  SmallRectToRect(GuiData, &r1, &sr1);
823  SmallRectToRect(GuiData, &r2, &sr2);
824  SmallRectToRect(GuiData, &r3, &sr3);
825 
826  rg1 = CreateRectRgnIndirect(&r1);
827  rg2 = CreateRectRgnIndirect(&r2);
828  rg3 = CreateRectRgnIndirect(&r3);
829 
830  CombineRgn(rg1, rg1, rg2, RGN_XOR);
831  CombineRgn(rg1, rg1, rg3, RGN_XOR);
832  DeleteObject(rg3);
833  DeleteObject(rg2);
834 
835  SelRgn = rg1;
836  }
837 
838  return SelRgn;
839  }
840 }
841 
842 static VOID
844 {
845  HRGN rgnPaint = CreateRectRgnIndirect(&pps->rcPaint);
846  HRGN rgnSel = CreateSelectionRgn(GuiData, GuiData->LineSelection,
847  &GuiData->Selection.dwSelectionAnchor,
848  &GuiData->Selection.srSelection);
849 
850  /* Invert the selection */
851 
852  int ErrorCode = CombineRgn(rgnPaint, rgnPaint, rgnSel, RGN_AND);
853  if (ErrorCode != ERROR && ErrorCode != NULLREGION)
854  {
855  InvertRgn(pps->hdc, rgnPaint);
856  }
857 
858  DeleteObject(rgnSel);
859  DeleteObject(rgnPaint);
860 }
861 
862 static VOID
864  PCOORD SelectionAnchor OPTIONAL,
865  PCOORD coord)
866 {
867  PCONSRV_CONSOLE Console = GuiData->Console;
868  HRGN oldRgn = CreateSelectionRgn(GuiData, GuiData->LineSelection,
869  &GuiData->Selection.dwSelectionAnchor,
870  &GuiData->Selection.srSelection);
871 
872  /* Update the anchor if needed (use the old one if NULL) */
873  if (SelectionAnchor)
874  GuiData->Selection.dwSelectionAnchor = *SelectionAnchor;
875 
876  // TODO: Scroll buffer to bring 'coord' into view
877 
878  if (coord != NULL)
879  {
880  SMALL_RECT rc;
881  HRGN newRgn;
882 
883  /*
884  * Pressing the Control key while selecting text, allows us to enter
885  * into line-selection mode, the selection mode of *nix terminals.
886  */
887  BOOL OldLineSel = GuiData->LineSelection;
889 
890  /* Exchange left/top with right/bottom if required */
891  rc.Left = min(GuiData->Selection.dwSelectionAnchor.X, coord->X);
892  rc.Top = min(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
893  rc.Right = max(GuiData->Selection.dwSelectionAnchor.X, coord->X);
894  rc.Bottom = max(GuiData->Selection.dwSelectionAnchor.Y, coord->Y);
895 
896  newRgn = CreateSelectionRgn(GuiData, GuiData->LineSelection,
897  &GuiData->Selection.dwSelectionAnchor,
898  &rc);
899 
901  {
902  if (OldLineSel != GuiData->LineSelection ||
903  memcmp(&rc, &GuiData->Selection.srSelection, sizeof(SMALL_RECT)) != 0)
904  {
905  /* Calculate the region that needs to be updated */
906  if (oldRgn && newRgn && CombineRgn(newRgn, newRgn, oldRgn, RGN_XOR) != ERROR)
907  {
908  InvalidateRgn(GuiData->hWindow, newRgn, FALSE);
909  }
910  }
911  }
912  else
913  {
914  InvalidateRgn(GuiData->hWindow, newRgn, FALSE);
915  }
916 
917  DeleteObject(newRgn);
918 
920  GuiData->Selection.srSelection = rc;
921  GuiData->dwSelectionCursor = *coord;
922 
923  if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
924  {
925  LPWSTR SelTypeStr = NULL , WindowTitle = NULL;
926  SIZE_T SelTypeStrLength = 0, Length = 0;
927 
928  /* Clear the old selection */
930  {
931  InvalidateRgn(GuiData->hWindow, oldRgn, FALSE);
932  }
933 
934  /*
935  * When passing a zero-length buffer size, LoadString(...) returns
936  * a read-only pointer buffer to the program's resource string.
937  */
938  SelTypeStrLength =
942  (LPWSTR)&SelTypeStr, 0);
943 
944  /*
945  * Prepend the selection type string to the current console title
946  * if we succeeded in retrieving a valid localized string.
947  */
948  if (SelTypeStr)
949  {
950  // 3 for " - " and 1 for NULL
951  Length = Console->Title.Length + (SelTypeStrLength + 3 + 1) * sizeof(WCHAR);
952  WindowTitle = ConsoleAllocHeap(0, Length);
953 
954  wcsncpy(WindowTitle, SelTypeStr, SelTypeStrLength);
955  WindowTitle[SelTypeStrLength] = UNICODE_NULL;
956  wcscat(WindowTitle, L" - ");
957  wcscat(WindowTitle, Console->Title.Buffer);
958 
959  SetWindowTextW(GuiData->hWindow, WindowTitle);
960  ConsoleFreeHeap(WindowTitle);
961  }
962 
965  }
966  }
967  else
968  {
969  /* Clear the selection */
971  {
972  InvalidateRgn(GuiData->hWindow, oldRgn, FALSE);
973  }
974 
977 
978  /* Restore the console title */
979  SetWindowTextW(GuiData->hWindow, Console->Title.Buffer);
980  }
981 
982  DeleteObject(oldRgn);
983 }
984 
985 static VOID
987 {
988  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
989  PAINTSTRUCT ps;
990  RECT rcPaint;
991 
992  /* Do nothing if the window is hidden */
993  if (!GuiData->IsWindowVisible) return;
994 
995  BeginPaint(GuiData->hWindow, &ps);
996  if (ps.hdc != NULL &&
997  ps.rcPaint.left < ps.rcPaint.right &&
998  ps.rcPaint.top < ps.rcPaint.bottom)
999  {
1000  EnterCriticalSection(&GuiData->Lock);
1001 
1002  /* Compose the current screen-buffer on-memory */
1003  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
1004  {
1006  GuiData, &ps.rcPaint, &rcPaint);
1007  }
1008  else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
1009  {
1011  GuiData, &ps.rcPaint, &rcPaint);
1012  }
1013 
1014  /* Send it to screen */
1015  BitBlt(ps.hdc,
1016  ps.rcPaint.left,
1017  ps.rcPaint.top,
1018  rcPaint.right - rcPaint.left,
1019  rcPaint.bottom - rcPaint.top,
1020  GuiData->hMemDC,
1021  rcPaint.left,
1022  rcPaint.top,
1023  SRCCOPY);
1024 
1025  /* Draw the selection region if needed */
1027  {
1028  PaintSelectionRect(GuiData, &ps);
1029  }
1030 
1031  // TODO: Move cursor display here!
1032 
1033  LeaveCriticalSection(&GuiData->Lock);
1034  }
1035  EndPaint(GuiData->hWindow, &ps);
1036 
1037  return;
1038 }
1039 
1040 static VOID
1042 {
1043  PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
1044 
1045  /* Do nothing if the window is hidden */
1046  if (!GuiData->IsWindowVisible) return;
1047 
1048  // See WM_PALETTECHANGED message
1049  // if ((HWND)wParam == hWnd) break;
1050 
1051  // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
1052  if (ActiveBuffer->PaletteHandle)
1053  {
1054  DPRINT("WM_PALETTECHANGED changing palette\n");
1055 
1056  /* Specify the use of the system palette for the framebuffer */
1057  SetSystemPaletteUse(GuiData->hMemDC, ActiveBuffer->PaletteUsage);
1058 
1059  /* Realize the (logical) palette */
1060  RealizePalette(GuiData->hMemDC);
1061  }
1062 }
1063 
1064 static BOOL
1065 IsSystemKey(WORD VirtualKeyCode)
1066 {
1067  switch (VirtualKeyCode)
1068  {
1069  /* From MSDN, "Virtual-Key Codes" */
1070  case VK_RETURN:
1071  case VK_SHIFT:
1072  case VK_CONTROL:
1073  case VK_MENU:
1074  case VK_PAUSE:
1075  case VK_CAPITAL:
1076  case VK_ESCAPE:
1077  case VK_LWIN:
1078  case VK_RWIN:
1079  case VK_NUMLOCK:
1080  case VK_SCROLL:
1081  return TRUE;
1082  default:
1083  return FALSE;
1084  }
1085 }
1086 
1087 static VOID
1089 {
1090  PCONSRV_CONSOLE Console = GuiData->Console;
1091  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
1092 
1094 
1095  ActiveBuffer = GuiData->ActiveBuffer;
1096 
1098  {
1099  WORD VirtualKeyCode = LOWORD(wParam);
1100 
1101  if (msg != WM_KEYDOWN) goto Quit;
1102 
1103  if (VirtualKeyCode == VK_RETURN)
1104  {
1105  /* Copy (and clear) selection if ENTER is pressed */
1106  Copy(GuiData);
1107  goto Quit;
1108  }
1109  else if ( VirtualKeyCode == VK_ESCAPE ||
1110  (VirtualKeyCode == 'C' && (GetKeyState(VK_CONTROL) & KEY_PRESSED)) )
1111  {
1112  /* Cancel selection if ESC or Ctrl-C are pressed */
1113  UpdateSelection(GuiData, NULL, NULL);
1114  goto Quit;
1115  }
1116 
1117  if ((GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0)
1118  {
1119  /* Keyboard selection mode */
1120  BOOL Interpreted = FALSE;
1121  BOOL MajPressed = !!(GetKeyState(VK_SHIFT) & KEY_PRESSED);
1122 
1123  switch (VirtualKeyCode)
1124  {
1125  case VK_LEFT:
1126  {
1127  Interpreted = TRUE;
1128  if (GuiData->dwSelectionCursor.X > 0)
1129  GuiData->dwSelectionCursor.X--;
1130 
1131  break;
1132  }
1133 
1134  case VK_RIGHT:
1135  {
1136  Interpreted = TRUE;
1137  if (GuiData->dwSelectionCursor.X < ActiveBuffer->ScreenBufferSize.X - 1)
1138  GuiData->dwSelectionCursor.X++;
1139 
1140  break;
1141  }
1142 
1143  case VK_UP:
1144  {
1145  Interpreted = TRUE;
1146  if (GuiData->dwSelectionCursor.Y > 0)
1147  GuiData->dwSelectionCursor.Y--;
1148 
1149  break;
1150  }
1151 
1152  case VK_DOWN:
1153  {
1154  Interpreted = TRUE;
1155  if (GuiData->dwSelectionCursor.Y < ActiveBuffer->ScreenBufferSize.Y - 1)
1156  GuiData->dwSelectionCursor.Y++;
1157 
1158  break;
1159  }
1160 
1161  case VK_HOME:
1162  {
1163  Interpreted = TRUE;
1164  GuiData->dwSelectionCursor.X = 0;
1165  GuiData->dwSelectionCursor.Y = 0;
1166  break;
1167  }
1168 
1169  case VK_END:
1170  {
1171  Interpreted = TRUE;
1172  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
1173  break;
1174  }
1175 
1176  case VK_PRIOR:
1177  {
1178  Interpreted = TRUE;
1179  GuiData->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y;
1180  if (GuiData->dwSelectionCursor.Y < 0)
1181  GuiData->dwSelectionCursor.Y = 0;
1182 
1183  break;
1184  }
1185 
1186  case VK_NEXT:
1187  {
1188  Interpreted = TRUE;
1189  GuiData->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y;
1190  if (GuiData->dwSelectionCursor.Y >= ActiveBuffer->ScreenBufferSize.Y)
1191  GuiData->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
1192 
1193  break;
1194  }
1195 
1196  default:
1197  break;
1198  }
1199 
1200  if (Interpreted)
1201  {
1202  UpdateSelection(GuiData,
1203  !MajPressed ? &GuiData->dwSelectionCursor : NULL,
1204  &GuiData->dwSelectionCursor);
1205  }
1206  else if (!IsSystemKey(VirtualKeyCode))
1207  {
1208  /* Emit an error beep sound */
1209  SendNotifyMessage(GuiData->hWindow, PM_CONSOLE_BEEP, 0, 0);
1210  }
1211 
1212  goto Quit;
1213  }
1214  else
1215  {
1216  /* Mouse selection mode */
1217 
1218  if (!IsSystemKey(VirtualKeyCode))
1219  {
1220  /* Clear the selection and send the key into the input buffer */
1221  UpdateSelection(GuiData, NULL, NULL);
1222  }
1223  else
1224  {
1225  goto Quit;
1226  }
1227  }
1228  }
1229 
1230  if ((GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
1231  {
1232  MSG Message;
1233 
1234  Message.hwnd = GuiData->hWindow;
1235  Message.message = msg;
1236  Message.wParam = wParam;
1237  Message.lParam = lParam;
1238 
1240  }
1241 
1242 Quit:
1243  LeaveCriticalSection(&Console->Lock);
1244 }
1245 
1246 
1247 // FIXME: Remove after fixing OnTimer
1248 VOID
1250  SHORT x, SHORT y);
1251 
1252 static VOID
1254 {
1255  PCONSRV_CONSOLE Console = GuiData->Console;
1257 
1258  /* Do nothing if the window is hidden */
1259  if (!GuiData->IsWindowVisible) return;
1260 
1262 
1264 
1265  Buff = GuiData->ActiveBuffer;
1266 
1267  if (GetType(Buff) == TEXTMODE_BUFFER)
1268  {
1269  /* Repaint the caret */
1270  InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
1271  Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
1272 
1273  if ((GuiData->OldCursor.x != Buff->CursorPosition.X) ||
1274  (GuiData->OldCursor.y != Buff->CursorPosition.Y))
1275  {
1276  SCROLLINFO sInfo;
1277  int OldScrollX = -1, OldScrollY = -1;
1278  int NewScrollX = -1, NewScrollY = -1;
1279 
1280  sInfo.cbSize = sizeof(sInfo);
1281  sInfo.fMask = SIF_POS;
1282  // Capture the original position of the scroll bars and save them.
1283  if (GetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo)) OldScrollX = sInfo.nPos;
1284  if (GetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo)) OldScrollY = sInfo.nPos;
1285 
1286  // If we successfully got the info for the horizontal scrollbar
1287  if (OldScrollX >= 0)
1288  {
1289  if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) ||
1290  (Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X)))
1291  {
1292  // Handle the horizontal scroll bar
1293  if (Buff->CursorPosition.X >= Buff->ViewSize.X)
1294  NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1;
1295  else
1296  NewScrollX = 0;
1297  }
1298  else
1299  {
1300  NewScrollX = OldScrollX;
1301  }
1302  }
1303  // If we successfully got the info for the vertical scrollbar
1304  if (OldScrollY >= 0)
1305  {
1306  if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) ||
1307  (Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y)))
1308  {
1309  // Handle the vertical scroll bar
1310  if (Buff->CursorPosition.Y >= Buff->ViewSize.Y)
1311  NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1;
1312  else
1313  NewScrollY = 0;
1314  }
1315  else
1316  {
1317  NewScrollY = OldScrollY;
1318  }
1319  }
1320 
1321  // Adjust scroll bars and refresh the window if the cursor has moved outside the visible area
1322  // NOTE: OldScroll# and NewScroll# will both be -1 (initial value) if the info for the respective scrollbar
1323  // was not obtained successfully in the previous steps. This means their difference is 0 (no scrolling)
1324  // and their associated scrollbar is left alone.
1325  if ((OldScrollX != NewScrollX) || (OldScrollY != NewScrollY))
1326  {
1327  Buff->ViewOrigin.X = NewScrollX;
1328  Buff->ViewOrigin.Y = NewScrollY;
1329  ScrollWindowEx(GuiData->hWindow,
1330  (OldScrollX - NewScrollX) * GuiData->CharWidth,
1331  (OldScrollY - NewScrollY) * GuiData->CharHeight,
1332  NULL,
1333  NULL,
1334  NULL,
1335  NULL,
1336  SW_INVALIDATE);
1337  if (NewScrollX >= 0)
1338  {
1339  sInfo.nPos = NewScrollX;
1340  SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
1341  }
1342  if (NewScrollY >= 0)
1343  {
1344  sInfo.nPos = NewScrollY;
1345  SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
1346  }
1347  UpdateWindow(GuiData->hWindow);
1348  // InvalidateRect(GuiData->hWindow, NULL, FALSE);
1349  GuiData->OldCursor.x = Buff->CursorPosition.X;
1350  GuiData->OldCursor.y = Buff->CursorPosition.Y;
1351  }
1352  }
1353  }
1354  else /* if (GetType(Buff) == GRAPHICS_BUFFER) */
1355  {
1356  }
1357 
1358  LeaveCriticalSection(&Console->Lock);
1359 }
1360 
1361 static BOOL
1363 {
1364  PCONSRV_CONSOLE Console = GuiData->Console;
1365 
1367  return TRUE;
1368 
1369  // TODO: Prompt for termination ? (Warn the user about possible apps running in this console)
1370 
1371  /*
1372  * FIXME: Windows will wait up to 5 seconds for the thread to exit.
1373  * We shouldn't wait here, though, since the console lock is entered.
1374  * A copy of the thread list probably needs to be made.
1375  */
1377 
1378  LeaveCriticalSection(&Console->Lock);
1379  return FALSE;
1380 }
1381 
1382 static LRESULT
1384 {
1386 
1387  /* Free the GuiData registration */
1389 
1390  /* Reset the system menu back to default and destroy the previous menu */
1392 
1393  if (GuiData)
1394  {
1395  if (GuiData->IsWindowVisible)
1397 
1398  /* Free the terminal framebuffer */
1399  if (GuiData->hMemDC ) DeleteDC(GuiData->hMemDC);
1400  if (GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
1401  // if (GuiData->hSysPalette) DeleteObject(GuiData->hSysPalette);
1402  DeleteFonts(GuiData);
1403  }
1404 
1405  return DefWindowProcW(hWnd, WM_NCDESTROY, 0, 0);
1406 }
1407 
1408 static VOID
1409 OnScroll(PGUI_CONSOLE_DATA GuiData, INT nBar, WORD sbCode)
1410 {
1411  PCONSRV_CONSOLE Console = GuiData->Console;
1413  SCROLLINFO sInfo;
1414  INT oldPos, Maximum;
1415  PSHORT pOriginXY;
1416 
1417  ASSERT(nBar == SB_HORZ || nBar == SB_VERT);
1418 
1420 
1421  Buff = GuiData->ActiveBuffer;
1422 
1423  if (nBar == SB_HORZ)
1424  {
1425  Maximum = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
1426  pOriginXY = &Buff->ViewOrigin.X;
1427  }
1428  else // if (nBar == SB_VERT)
1429  {
1430  Maximum = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
1431  pOriginXY = &Buff->ViewOrigin.Y;
1432  }
1433 
1434  /* Set scrollbar sizes */
1435  sInfo.cbSize = sizeof(sInfo);
1437 
1438  if (!GetScrollInfo(GuiData->hWindow, nBar, &sInfo)) goto Quit;
1439 
1440  oldPos = sInfo.nPos;
1441 
1442  switch (sbCode)
1443  {
1444  case SB_LINEUP: // SB_LINELEFT:
1445  sInfo.nPos--;
1446  break;
1447 
1448  case SB_LINEDOWN: // SB_LINERIGHT:
1449  sInfo.nPos++;
1450  break;
1451 
1452  case SB_PAGEUP: // SB_PAGELEFT:
1453  sInfo.nPos -= sInfo.nPage;
1454  break;
1455 
1456  case SB_PAGEDOWN: // SB_PAGERIGHT:
1457  sInfo.nPos += sInfo.nPage;
1458  break;
1459 
1460  case SB_THUMBTRACK:
1461  sInfo.nPos = sInfo.nTrackPos;
1463  break;
1464 
1465  case SB_THUMBPOSITION:
1466  sInfo.nPos = sInfo.nTrackPos;
1468  break;
1469 
1470  case SB_TOP: // SB_LEFT:
1471  sInfo.nPos = sInfo.nMin;
1472  break;
1473 
1474  case SB_BOTTOM: // SB_RIGHT:
1475  sInfo.nPos = sInfo.nMax;
1476  break;
1477 
1478  default:
1479  break;
1480  }
1481 
1482  sInfo.nPos = min(max(sInfo.nPos, 0), Maximum);
1483 
1484  if (oldPos != sInfo.nPos)
1485  {
1486  USHORT OldX = Buff->ViewOrigin.X;
1487  USHORT OldY = Buff->ViewOrigin.Y;
1488  UINT WidthUnit, HeightUnit;
1489 
1490  /* We now modify Buff->ViewOrigin */
1491  *pOriginXY = sInfo.nPos;
1492 
1493  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
1494 
1495  ScrollWindowEx(GuiData->hWindow,
1496  (OldX - Buff->ViewOrigin.X) * WidthUnit ,
1497  (OldY - Buff->ViewOrigin.Y) * HeightUnit,
1498  NULL,
1499  NULL,
1500  NULL,
1501  NULL,
1502  SW_INVALIDATE);
1503 
1504  sInfo.fMask = SIF_POS;
1505  SetScrollInfo(GuiData->hWindow, nBar, &sInfo, TRUE);
1506 
1507  UpdateWindow(GuiData->hWindow);
1508  // InvalidateRect(GuiData->hWindow, NULL, FALSE);
1509  }
1510 
1511 Quit:
1512  LeaveCriticalSection(&Console->Lock);
1513  return;
1514 }
1515 
1516 static COORD
1518 {
1520  COORD Coord;
1521  UINT WidthUnit, HeightUnit;
1522 
1523  GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
1524 
1525  Coord.X = Buffer->ViewOrigin.X + ((SHORT)LOWORD(lParam) / (int)WidthUnit );
1526  Coord.Y = Buffer->ViewOrigin.Y + ((SHORT)HIWORD(lParam) / (int)HeightUnit);
1527 
1528  /* Clip coordinate to ensure it's inside buffer */
1529  if (Coord.X < 0)
1530  Coord.X = 0;
1531  else if (Coord.X >= Buffer->ScreenBufferSize.X)
1532  Coord.X = Buffer->ScreenBufferSize.X - 1;
1533 
1534  if (Coord.Y < 0)
1535  Coord.Y = 0;
1536  else if (Coord.Y >= Buffer->ScreenBufferSize.Y)
1537  Coord.Y = Buffer->ScreenBufferSize.Y - 1;
1538 
1539  return Coord;
1540 }
1541 
1542 static LRESULT
1544 {
1545  BOOL DoDefault = FALSE;
1546  PCONSRV_CONSOLE Console = GuiData->Console;
1547 
1548  /*
1549  * HACK FOR CORE-8394 (Part 2):
1550  *
1551  * Check whether we should ignore the next mouse move event.
1552  * In either case we reset the HACK flag.
1553  *
1554  * See Part 1 of this hack below.
1555  */
1556  if (GuiData->HackCORE8394IgnoreNextMove && msg == WM_MOUSEMOVE)
1557  {
1558  GuiData->HackCORE8394IgnoreNextMove = FALSE;
1559  goto Quit;
1560  }
1561  GuiData->HackCORE8394IgnoreNextMove = FALSE;
1562 
1563  // FIXME: It's here that we need to check whether we have focus or not
1564  // and whether we are or not in edit mode, in order to know if we need
1565  // to deal with the mouse.
1566 
1567  if (GuiData->IgnoreNextMouseSignal)
1568  {
1569  if (msg != WM_LBUTTONDOWN &&
1570  msg != WM_MBUTTONDOWN &&
1571  msg != WM_RBUTTONDOWN &&
1572  msg != WM_XBUTTONDOWN)
1573  {
1574  /*
1575  * If this mouse signal is not a button-down action
1576  * then this is the last one being ignored.
1577  */
1578  GuiData->IgnoreNextMouseSignal = FALSE;
1579  }
1580  else
1581  {
1582  /*
1583  * This mouse signal is a button-down action.
1584  * Ignore it and perform default action.
1585  */
1586  DoDefault = TRUE;
1587  }
1588  goto Quit;
1589  }
1590 
1592  {
1593  DoDefault = TRUE;
1594  goto Quit;
1595  }
1596 
1597  if ( (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) ||
1598  (Console->QuickEdit) )
1599  {
1600  switch (msg)
1601  {
1602  case WM_LBUTTONDOWN:
1603  {
1604  /* Check for selection state */
1605  if ( (GuiData->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
1606  (GuiData->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) &&
1608  {
1609  /*
1610  * A mouse selection is currently in progress and the user
1611  * has pressed the SHIFT key and clicked somewhere, update
1612  * the selection.
1613  */
1614  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1615  UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1616  }
1617  else
1618  {
1619  /* Clear the old selection */
1621 
1622  /* Restart a new selection */
1623  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1624  SetCapture(GuiData->hWindow);
1626  UpdateSelection(GuiData,
1627  &GuiData->dwSelectionCursor,
1628  &GuiData->dwSelectionCursor);
1629  }
1630 
1631  break;
1632  }
1633 
1634  case WM_LBUTTONUP:
1635  {
1636  if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1637 
1638  // GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1639  GuiData->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
1640  // UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1641  ReleaseCapture();
1642 
1643  break;
1644  }
1645 
1646  case WM_LBUTTONDBLCLK:
1647  {
1649 
1650  if (GetType(Buffer) == TEXTMODE_BUFFER)
1651  {
1652 #define IS_WORD_SEP(c) \
1653  ((c) == L'\0' || (c) == L' ' || (c) == L'\t' || (c) == L'\r' || (c) == L'\n')
1654 
1656  COORD cL, cR;
1657  PCHAR_INFO ptrL, ptrR;
1658 
1659  /* Starting point */
1660  cL = cR = PointToCoord(GuiData, lParam);
1661  ptrL = ptrR = ConioCoordToPointer(TextBuffer, cL.X, cL.Y);
1662 
1663  /* Enlarge the selection by checking for whitespace */
1664  while ((0 < cL.X) && !IS_WORD_SEP(ptrL->Char.UnicodeChar)
1665  && !IS_WORD_SEP((ptrL-1)->Char.UnicodeChar))
1666  {
1667  --cL.X;
1668  --ptrL;
1669  }
1670  while ((cR.X < TextBuffer->ScreenBufferSize.X - 1) &&
1671  !IS_WORD_SEP(ptrR->Char.UnicodeChar) &&
1672  !IS_WORD_SEP((ptrR+1)->Char.UnicodeChar))
1673  {
1674  ++cR.X;
1675  ++ptrR;
1676  }
1677 
1678  /*
1679  * Update the selection started with the single
1680  * left-click that preceded this double-click.
1681  */
1683  UpdateSelection(GuiData, &cL, &cR);
1684 
1685  /* Ignore the next mouse move signal */
1686  GuiData->IgnoreNextMouseSignal = TRUE;
1687 #undef IS_WORD_SEP
1688  }
1689 
1690  break;
1691  }
1692 
1693  case WM_RBUTTONDOWN:
1694  case WM_RBUTTONDBLCLK:
1695  {
1696  if (!(GuiData->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
1697  {
1698  Paste(GuiData);
1699  }
1700  else
1701  {
1702  Copy(GuiData);
1703  }
1704 
1705  /* Ignore the next mouse move signal */
1706  GuiData->IgnoreNextMouseSignal = TRUE;
1707  break;
1708  }
1709 
1710  case WM_MOUSEMOVE:
1711  {
1712  if (!(GET_KEYSTATE_WPARAM(wParam) & MK_LBUTTON)) break;
1713  if (!(GuiData->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1714 
1715  GuiData->dwSelectionCursor = PointToCoord(GuiData, lParam);
1716  UpdateSelection(GuiData, NULL, &GuiData->dwSelectionCursor);
1717  break;
1718  }
1719 
1720  default:
1721  DoDefault = TRUE; // FALSE;
1722  break;
1723  }
1724  }
1726  {
1727  INPUT_RECORD er;
1728  WORD wKeyState = GET_KEYSTATE_WPARAM(wParam);
1729  DWORD dwButtonState = 0;
1730  DWORD dwControlKeyState = 0;
1731  DWORD dwEventFlags = 0;
1732 
1733  switch (msg)
1734  {
1735  case WM_LBUTTONDOWN:
1736  SetCapture(GuiData->hWindow);
1737  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1738  dwEventFlags = 0;
1739  break;
1740 
1741  case WM_MBUTTONDOWN:
1742  SetCapture(GuiData->hWindow);
1743  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1744  dwEventFlags = 0;
1745  break;
1746 
1747  case WM_RBUTTONDOWN:
1748  SetCapture(GuiData->hWindow);
1749  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1750  dwEventFlags = 0;
1751  break;
1752 
1753  case WM_XBUTTONDOWN:
1754  {
1755  /* Get which X-button was pressed */
1756  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1757 
1758  /* Check for X-button validity */
1759  if (wButton & ~(XBUTTON1 | XBUTTON2))
1760  {
1761  DPRINT1("X-button 0x%04x invalid\n", wButton);
1762  DoDefault = TRUE;
1763  break;
1764  }
1765 
1766  SetCapture(GuiData->hWindow);
1767  dwButtonState = (wButton == XBUTTON1 ? FROM_LEFT_3RD_BUTTON_PRESSED
1769  dwEventFlags = 0;
1770  break;
1771  }
1772 
1773  case WM_LBUTTONUP:
1774  ReleaseCapture();
1775  dwButtonState = 0;
1776  dwEventFlags = 0;
1777  break;
1778 
1779  case WM_MBUTTONUP:
1780  ReleaseCapture();
1781  dwButtonState = 0;
1782  dwEventFlags = 0;
1783  break;
1784 
1785  case WM_RBUTTONUP:
1786  ReleaseCapture();
1787  dwButtonState = 0;
1788  dwEventFlags = 0;
1789  break;
1790 
1791  case WM_XBUTTONUP:
1792  {
1793  /* Get which X-button was released */
1794  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1795 
1796  /* Check for X-button validity */
1797  if (wButton & ~(XBUTTON1 | XBUTTON2))
1798  {
1799  DPRINT1("X-button 0x%04x invalid\n", wButton);
1800  /* Ok, just release the button anyway... */
1801  }
1802 
1803  ReleaseCapture();
1804  dwButtonState = 0;
1805  dwEventFlags = 0;
1806  break;
1807  }
1808 
1809  case WM_LBUTTONDBLCLK:
1810  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1811  dwEventFlags = DOUBLE_CLICK;
1812  break;
1813 
1814  case WM_MBUTTONDBLCLK:
1815  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1816  dwEventFlags = DOUBLE_CLICK;
1817  break;
1818 
1819  case WM_RBUTTONDBLCLK:
1820  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1821  dwEventFlags = DOUBLE_CLICK;
1822  break;
1823 
1824  case WM_XBUTTONDBLCLK:
1825  {
1826  /* Get which X-button was double-clicked */
1827  WORD wButton = GET_XBUTTON_WPARAM(wParam);
1828 
1829  /* Check for X-button validity */
1830  if (wButton & ~(XBUTTON1 | XBUTTON2))
1831  {
1832  DPRINT1("X-button 0x%04x invalid\n", wButton);
1833  DoDefault = TRUE;
1834  break;
1835  }
1836 
1837  dwButtonState = (wButton == XBUTTON1 ? FROM_LEFT_3RD_BUTTON_PRESSED
1839  dwEventFlags = DOUBLE_CLICK;
1840  break;
1841  }
1842 
1843  case WM_MOUSEMOVE:
1844  dwButtonState = 0;
1845  dwEventFlags = MOUSE_MOVED;
1846  break;
1847 
1848  case WM_MOUSEWHEEL:
1849  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1850  dwEventFlags = MOUSE_WHEELED;
1851  break;
1852 
1853  case WM_MOUSEHWHEEL:
1854  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1855  dwEventFlags = MOUSE_HWHEELED;
1856  break;
1857 
1858  default:
1859  DoDefault = TRUE;
1860  break;
1861  }
1862 
1863  /*
1864  * HACK FOR CORE-8394 (Part 1):
1865  *
1866  * It appears that depending on which VM ReactOS runs, the next mouse
1867  * signal coming after a button-down action can be a mouse-move (e.g.
1868  * on VBox, whereas on QEMU it is not the case). However it is NOT a
1869  * rule, so that we cannot use the IgnoreNextMouseSignal flag to just
1870  * "ignore" the next mouse event, thinking it would always be a mouse-
1871  * move signal.
1872  *
1873  * To work around this problem (that should really be fixed in Win32k),
1874  * we use a second flag to ignore this possible next mouse move signal.
1875  */
1876  switch (msg)
1877  {
1878  case WM_LBUTTONDOWN:
1879  case WM_MBUTTONDOWN:
1880  case WM_RBUTTONDOWN:
1881  case WM_XBUTTONDOWN:
1882  GuiData->HackCORE8394IgnoreNextMove = TRUE;
1883  default:
1884  break;
1885  }
1886 
1887  if (!DoDefault)
1888  {
1889  if (wKeyState & MK_LBUTTON)
1890  dwButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
1891  if (wKeyState & MK_MBUTTON)
1892  dwButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
1893  if (wKeyState & MK_RBUTTON)
1894  dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
1895  if (wKeyState & MK_XBUTTON1)
1896  dwButtonState |= FROM_LEFT_3RD_BUTTON_PRESSED;
1897  if (wKeyState & MK_XBUTTON2)
1898  dwButtonState |= FROM_LEFT_4TH_BUTTON_PRESSED;
1899 
1901  dwControlKeyState |= RIGHT_ALT_PRESSED;
1903  dwControlKeyState |= LEFT_ALT_PRESSED;
1905  dwControlKeyState |= RIGHT_CTRL_PRESSED;
1907  dwControlKeyState |= LEFT_CTRL_PRESSED;
1909  dwControlKeyState |= SHIFT_PRESSED;
1911  dwControlKeyState |= NUMLOCK_ON;
1913  dwControlKeyState |= SCROLLLOCK_ON;
1915  dwControlKeyState |= CAPSLOCK_ON;
1916  /* See WM_CHAR MSDN documentation for instance */
1917  if (HIWORD(lParam) & KF_EXTENDED)
1918  dwControlKeyState |= ENHANCED_KEY;
1919 
1920  /* Send a mouse event */
1921  er.EventType = MOUSE_EVENT;
1923  er.Event.MouseEvent.dwButtonState = dwButtonState;
1924  er.Event.MouseEvent.dwControlKeyState = dwControlKeyState;
1925  er.Event.MouseEvent.dwEventFlags = dwEventFlags;
1926 
1928  }
1929  }
1930  else
1931  {
1932  DoDefault = TRUE;
1933  }
1934 
1935  LeaveCriticalSection(&Console->Lock);
1936 
1937 Quit:
1938  if (!DoDefault)
1939  return 0;
1940 
1941  if (msg == WM_MOUSEWHEEL || msg == WM_MOUSEHWHEEL)
1942  {
1943  INT nBar;
1944  WORD sbCode;
1945  // WORD wKeyState = GET_KEYSTATE_WPARAM(wParam);
1946  SHORT wDelta = GET_WHEEL_DELTA_WPARAM(wParam);
1947 
1948  if (msg == WM_MOUSEWHEEL)
1949  nBar = SB_VERT;
1950  else // if (msg == WM_MOUSEHWHEEL)
1951  nBar = SB_HORZ;
1952 
1953  // NOTE: We currently do not support zooming...
1954  // if (wKeyState & MK_CONTROL)
1955 
1956  // FIXME: For some reason our win32k does not set the key states
1957  // when sending WM_MOUSEWHEEL or WM_MOUSEHWHEEL ...
1958  // if (wKeyState & MK_SHIFT)
1960  sbCode = (wDelta >= 0 ? SB_PAGEUP : SB_PAGEDOWN);
1961  else
1962  sbCode = (wDelta >= 0 ? SB_LINEUP : SB_LINEDOWN);
1963 
1964  OnScroll(GuiData, nBar, sbCode);
1965  }
1966 
1967  return DefWindowProcW(GuiData->hWindow, msg, wParam, lParam);
1968 }
1969 
1970 
1971 static VOID
1973 {
1974  if (OpenClipboard(GuiData->hWindow))
1975  {
1977 
1978  if (GetType(Buffer) == TEXTMODE_BUFFER)
1979  {
1981  }
1982  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
1983  {
1985  }
1986 
1987  CloseClipboard();
1988  }
1989 
1990  /* Clear the selection */
1991  UpdateSelection(GuiData, NULL, NULL);
1992 }
1993 
1994 static VOID
1996 {
1997  if (OpenClipboard(GuiData->hWindow))
1998  {
2000 
2001  if (GetType(Buffer) == TEXTMODE_BUFFER)
2002  {
2004  }
2005  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
2006  {
2008  }
2009 
2010  CloseClipboard();
2011  }
2012 }
2013 
2014 static VOID
2016 {
2017  PCONSRV_CONSOLE Console = GuiData->Console;
2018  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
2019  DWORD windx, windy;
2020  UINT WidthUnit, HeightUnit;
2021 
2023 
2024  ActiveBuffer = GuiData->ActiveBuffer;
2025 
2026  GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
2027 
2028  windx = CONGUI_MIN_WIDTH * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
2030 
2031  minMaxInfo->ptMinTrackSize.x = windx;
2032  minMaxInfo->ptMinTrackSize.y = windy;
2033 
2034  windx = (ActiveBuffer->ScreenBufferSize.X) * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
2035  windy = (ActiveBuffer->ScreenBufferSize.Y) * HeightUnit + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION);
2036 
2037  if (ActiveBuffer->ViewSize.X < ActiveBuffer->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // Window currently has a horizontal scrollbar
2038  if (ActiveBuffer->ViewSize.Y < ActiveBuffer->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // Window currently has a vertical scrollbar
2039 
2040  minMaxInfo->ptMaxTrackSize.x = windx;
2041  minMaxInfo->ptMaxTrackSize.y = windy;
2042 
2043  LeaveCriticalSection(&Console->Lock);
2044 }
2045 
2046 static VOID
2048 {
2049  PCONSRV_CONSOLE Console = GuiData->Console;
2050 
2051  /* Do nothing if the window is hidden */
2052  if (!GuiData->IsWindowVisible || IsIconic(GuiData->hWindow)) return;
2053 
2055 
2056  if (!GuiData->WindowSizeLock &&
2058  {
2059  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
2060  DWORD windx, windy, charx, chary;
2061  UINT WidthUnit, HeightUnit;
2062 
2063  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
2064 
2065  GuiData->WindowSizeLock = TRUE;
2066 
2067  windx = LOWORD(lParam);
2068  windy = HIWORD(lParam);
2069 
2070  /* Compensate for existing scroll bars (because lParam values do not accommodate scroll bar) */
2071  if (Buff->ViewSize.X < Buff->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // Window currently has a horizontal scrollbar
2072  if (Buff->ViewSize.Y < Buff->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // Window currently has a vertical scrollbar
2073 
2074  charx = windx / (int)WidthUnit ;
2075  chary = windy / (int)HeightUnit;
2076 
2077  /* Character alignment (round size up or down) */
2078  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
2079  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
2080 
2081  /* Compensate for added scroll bars in window */
2082  if (Buff->ViewSize.X < Buff->ScreenBufferSize.X) windy -= GetSystemMetrics(SM_CYHSCROLL); // Window will have a horizontal scroll bar
2083  if (Buff->ViewSize.Y < Buff->ScreenBufferSize.Y) windx -= GetSystemMetrics(SM_CXVSCROLL); // Window will have a vertical scroll bar
2084 
2085  charx = windx / (int)WidthUnit ;
2086  chary = windy / (int)HeightUnit;
2087 
2088  /* Character alignment (round size up or down) */
2089  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
2090  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
2091 
2092  /* Resize window */
2093  if ((charx != Buff->ViewSize.X) || (chary != Buff->ViewSize.Y))
2094  {
2095  Buff->ViewSize.X = (charx <= (DWORD)Buff->ScreenBufferSize.X) ? charx : Buff->ScreenBufferSize.X;
2096  Buff->ViewSize.Y = (chary <= (DWORD)Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
2097  }
2098 
2099  ResizeConWnd(GuiData, WidthUnit, HeightUnit);
2100 
2101  /* Adjust the start of the visible area if we are attempting to show nonexistent areas */
2102  if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) < Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
2103  if ((Buff->ScreenBufferSize.Y - Buff->ViewOrigin.Y) < Buff->ViewSize.Y) Buff->ViewOrigin.Y = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
2104  InvalidateRect(GuiData->hWindow, NULL, TRUE);
2105 
2106  GuiData->WindowSizeLock = FALSE;
2107  }
2108 
2109  LeaveCriticalSection(&Console->Lock);
2110 }
2111 
2112 static VOID
2114 {
2115  RECT rcWnd;
2116 
2117  // TODO: Simplify the code.
2118  // See: GuiConsoleNotifyWndProc() PM_CREATE_CONSOLE.
2119 
2120  /* Retrieve our real position */
2121  GetWindowRect(GuiData->hWindow, &rcWnd);
2122  GuiData->GuiInfo.WindowOrigin.x = rcWnd.left;
2123  GuiData->GuiInfo.WindowOrigin.y = rcWnd.top;
2124 }
2125 
2126 static VOID
2128 {
2129  LPWSTR pszPath;
2130  WCHAR szPath[MAX_PATH + 2];
2131 
2132  szPath[0] = L'"';
2133 
2134  DragQueryFileW(hDrop, 0, &szPath[1], ARRAYSIZE(szPath) - 1);
2135  DragFinish(hDrop);
2136 
2137  if (wcschr(&szPath[1], L' ') != NULL)
2138  {
2140  pszPath = szPath;
2141  }
2142  else
2143  {
2144  pszPath = &szPath[1];
2145  }
2146 
2147  PasteText(Console, pszPath, wcslen(pszPath));
2148 }
2149 
2150 /*
2151 // HACK: This functionality is standard for general scrollbars. Don't add it by hand.
2152 
2153 VOID
2154 GuiConsoleHandleScrollbarMenu(VOID)
2155 {
2156  HMENU hMenu;
2157 
2158  hMenu = CreatePopupMenu();
2159  if (hMenu == NULL)
2160  {
2161  DPRINT("CreatePopupMenu failed\n");
2162  return;
2163  }
2164 
2165  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLHERE);
2166  //InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
2167  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLTOP);
2168  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLBOTTOM);
2169  //InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
2170  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLPAGE_UP);
2171  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLPAGE_DOWN);
2172  //InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
2173  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLUP);
2174  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLDOWN);
2175 }
2176 */
2177 
2178 HBITMAP
2180 {
2181  BITMAPINFO bmi;
2182  ZeroMemory(&bmi, sizeof(BITMAPINFO));
2183  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
2184  bmi.bmiHeader.biWidth = width;
2185  bmi.bmiHeader.biHeight = height;
2186  bmi.bmiHeader.biPlanes = 1;
2189  return CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
2190 }
2191 
2192 static LRESULT CALLBACK
2194 {
2195  LRESULT Result = 0;
2196  PGUI_CONSOLE_DATA GuiData = NULL;
2198 
2199  /*
2200  * - If it's the first time we create a window for the terminal,
2201  * just initialize it and return.
2202  *
2203  * - If we are destroying the window, just do it and return.
2204  */
2205  if (msg == WM_NCCREATE)
2206  {
2208  }
2209  else if (msg == WM_NCDESTROY)
2210  {
2211  return OnNcDestroy(hWnd);
2212  }
2213 
2214  /*
2215  * Now the terminal window is initialized.
2216  * Get the terminal data via the window's data.
2217  * If there is no data, just go away.
2218  */
2219  GuiData = GuiGetGuiData(hWnd);
2220  if (GuiData == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
2221 
2222  // TEMPORARY HACK until all of the functions can deal with a NULL GuiData->ActiveBuffer ...
2223  if (GuiData->ActiveBuffer == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
2224 
2225  /*
2226  * Just retrieve a pointer to the console in case somebody needs it.
2227  * It is not NULL because it was checked in GuiGetGuiData.
2228  * Each helper function which needs the console has to validate and lock it.
2229  */
2230  Console = GuiData->Console;
2231 
2232  /* We have a console, start message dispatching */
2233  switch (msg)
2234  {
2235  case WM_ACTIVATE:
2236  OnActivate(GuiData, wParam);
2237  break;
2238 
2239  case WM_CLOSE:
2240  if (OnClose(GuiData)) goto Default;
2241  break;
2242 
2243  case WM_ERASEBKGND:
2244  return TRUE;
2245 
2246  case WM_PAINT:
2247  OnPaint(GuiData);
2248  break;
2249 
2250  case WM_TIMER:
2251  OnTimer(GuiData);
2252  break;
2253 
2254  case WM_PALETTECHANGED:
2255  {
2256  DPRINT("WM_PALETTECHANGED called\n");
2257 
2258  /*
2259  * Protects against infinite loops:
2260  * "... A window that receives this message must not realize
2261  * its palette, unless it determines that wParam does not contain
2262  * its own window handle." (WM_PALETTECHANGED description - MSDN)
2263  *
2264  * This message is sent to all windows, including the one that
2265  * changed the system palette and caused this message to be sent.
2266  * The wParam of this message contains the handle of the window
2267  * that caused the system palette to change. To avoid an infinite
2268  * loop, care must be taken to check that the wParam of this message
2269  * does not match the window's handle.
2270  */
2271  if ((HWND)wParam == hWnd) break;
2272 
2273  DPRINT("WM_PALETTECHANGED ok\n");
2274  OnPaletteChanged(GuiData);
2275  DPRINT("WM_PALETTECHANGED quit\n");
2276  break;
2277  }
2278 
2279  case WM_KEYDOWN:
2280  case WM_KEYUP:
2281  case WM_CHAR:
2282  case WM_DEADCHAR:
2283  case WM_SYSKEYDOWN:
2284  case WM_SYSKEYUP:
2285  case WM_SYSCHAR:
2286  case WM_SYSDEADCHAR:
2287  {
2288  /* Detect Alt-Enter presses and switch back and forth to fullscreen mode */
2289  if (msg == WM_SYSKEYDOWN && (HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN)
2290  {
2291  /* Switch only at first Alt-Enter press, and ignore subsequent key repetitions */
2292  if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) != KF_REPEAT)
2293  GuiConsoleSwitchFullScreen(GuiData);
2294 
2295  break;
2296  }
2297  /* Detect Alt-Esc/Space/Tab presses defer to DefWindowProc */
2298  if ( (HIWORD(lParam) & KF_ALTDOWN) && (wParam == VK_ESCAPE || wParam == VK_SPACE || wParam == VK_TAB))
2299  {
2300  return DefWindowProcW(hWnd, msg, wParam, lParam);
2301  }
2302 
2303  OnKey(GuiData, msg, wParam, lParam);
2304  break;
2305  }
2306 
2307  case WM_SETCURSOR:
2308  {
2309  /* Do nothing if the window is hidden */
2310  if (!GuiData->IsWindowVisible) goto Default;
2311 
2312  /*
2313  * The message was sent because we are manually triggering a change.
2314  * Check whether the mouse is indeed present on this console window
2315  * and take appropriate decisions.
2316  */
2317  if (wParam == -1 && lParam == -1)
2318  {
2319  POINT mouseCoords;
2320  HWND hWndHit;
2321 
2322  /* Get the placement of the mouse */
2323  GetCursorPos(&mouseCoords);
2324 
2325  /* On which window is placed the mouse ? */
2326  hWndHit = WindowFromPoint(mouseCoords);
2327 
2328  /* It's our window. Perform the hit-test to be used later on. */
2329  if (hWndHit == hWnd)
2330  {
2331  wParam = (WPARAM)hWnd;
2332  lParam = DefWindowProcW(hWndHit, WM_NCHITTEST, 0,
2333  MAKELPARAM(mouseCoords.x, mouseCoords.y));
2334  }
2335  }
2336 
2337  /* Set the mouse cursor only when we are in the client area */
2338  if ((HWND)wParam == hWnd && LOWORD(lParam) == HTCLIENT)
2339  {
2340  if (GuiData->MouseCursorRefCount >= 0)
2341  {
2342  /* Show the cursor */
2343  SetCursor(GuiData->hCursor);
2344  }
2345  else
2346  {
2347  /* Hide the cursor if the reference count is negative */
2348  SetCursor(NULL);
2349  }
2350  return TRUE;
2351  }
2352  else
2353  {
2354  goto Default;
2355  }
2356  }
2357 
2358  case WM_LBUTTONDOWN:
2359  case WM_MBUTTONDOWN:
2360  case WM_RBUTTONDOWN:
2361  case WM_XBUTTONDOWN:
2362  case WM_LBUTTONUP:
2363  case WM_MBUTTONUP:
2364  case WM_RBUTTONUP:
2365  case WM_XBUTTONUP:
2366  case WM_LBUTTONDBLCLK:
2367  case WM_MBUTTONDBLCLK:
2368  case WM_RBUTTONDBLCLK:
2369  case WM_XBUTTONDBLCLK:
2370  case WM_MOUSEMOVE:
2371  case WM_MOUSEWHEEL:
2372  case WM_MOUSEHWHEEL:
2373  {
2374  Result = OnMouse(GuiData, msg, wParam, lParam);
2375  break;
2376  }
2377 
2378  case WM_HSCROLL:
2379  OnScroll(GuiData, SB_HORZ, LOWORD(wParam));
2380  break;
2381 
2382  case WM_VSCROLL:
2383  OnScroll(GuiData, SB_VERT, LOWORD(wParam));
2384  break;
2385 
2386  case WM_CONTEXTMENU:
2387  {
2388  /* Do nothing if the window is hidden */
2389  if (!GuiData->IsWindowVisible) break;
2390 
2391  if (DefWindowProcW(hWnd /*GuiData->hWindow*/, WM_NCHITTEST, 0, lParam) == HTCLIENT)
2392  {
2393  HMENU hMenu = CreatePopupMenu();
2394  if (hMenu != NULL)
2395  {
2397  TrackPopupMenuEx(hMenu,
2401  hWnd,
2402  NULL);
2403  DestroyMenu(hMenu);
2404  }
2405  break;
2406  }
2407  else
2408  {
2409  goto Default;
2410  }
2411  }
2412 
2413  case WM_INITMENU:
2414  {
2415  HMENU hMenu = (HMENU)wParam;
2416  if (hMenu != NULL)
2417  {
2418  /* Enable or disable the Close menu item */
2420  (GuiData->IsCloseButtonEnabled ? MF_ENABLED : MF_GRAYED));
2421 
2422  /* Enable or disable the Copy and Paste items */
2426  // FIXME: Following whether the active screen buffer is text-mode
2427  // or graphics-mode, search for CF_UNICODETEXT or CF_BITMAP formats.
2431  }
2432 
2434  break;
2435  }
2436 
2437  case WM_MENUSELECT:
2438  {
2439  if (HIWORD(wParam) == 0xFFFF) // Allow all the menu flags
2440  {
2442  }
2443  break;
2444  }
2445 
2446  case WM_COMMAND:
2447  case WM_SYSCOMMAND:
2448  {
2449  Result = OnCommand(GuiData, wParam, lParam);
2450  break;
2451  }
2452 
2453  case WM_DROPFILES:
2454  OnDropFiles(Console, (HDROP)wParam);
2455  break;
2456 
2457  case WM_SETFOCUS:
2458  case WM_KILLFOCUS:
2459  OnFocus(GuiData, (msg == WM_SETFOCUS));
2460  break;
2461 
2462  case WM_GETMINMAXINFO:
2463  OnGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam);
2464  break;
2465 
2466  case WM_MOVE:
2467  OnMove(GuiData);
2468  break;
2469 
2470 #if 0 // This code is here to prepare & control dynamic console SB resizing.
2471  case WM_SIZING:
2472  {
2473  PRECT dragRect = (PRECT)lParam;
2474  switch (wParam)
2475  {
2476  case WMSZ_LEFT:
2477  DPRINT1("WMSZ_LEFT\n");
2478  break;
2479  case WMSZ_RIGHT:
2480  DPRINT1("WMSZ_RIGHT\n");
2481  break;
2482  case WMSZ_TOP:
2483  DPRINT1("WMSZ_TOP\n");
2484  break;
2485  case WMSZ_TOPLEFT:
2486  DPRINT1("WMSZ_TOPLEFT\n");
2487  break;
2488  case WMSZ_TOPRIGHT:
2489  DPRINT1("WMSZ_TOPRIGHT\n");
2490  break;
2491  case WMSZ_BOTTOM:
2492  DPRINT1("WMSZ_BOTTOM\n");
2493  break;
2494  case WMSZ_BOTTOMLEFT:
2495  DPRINT1("WMSZ_BOTTOMLEFT\n");
2496  break;
2497  case WMSZ_BOTTOMRIGHT:
2498  DPRINT1("WMSZ_BOTTOMRIGHT\n");
2499  break;
2500  default:
2501  DPRINT1("wParam = %d\n", wParam);
2502  break;
2503  }
2504  DPRINT1("dragRect = {.left = %d ; .top = %d ; .right = %d ; .bottom = %d}\n",
2505  dragRect->left, dragRect->top, dragRect->right, dragRect->bottom);
2506  break;
2507  }
2508 #endif
2509 
2510  case WM_SIZE:
2511  OnSize(GuiData, wParam, lParam);
2512  break;
2513 
2514  case PM_RESIZE_TERMINAL:
2515  {
2516  PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer;
2517  HDC hDC;
2518  HBITMAP hnew, hold;
2519 
2520  DWORD Width, Height;
2521  UINT WidthUnit, HeightUnit;
2522 
2523  /* Do nothing if the window is hidden */
2524  if (!GuiData->IsWindowVisible) break;
2525 
2526  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
2527 
2528  Width = Buff->ScreenBufferSize.X * WidthUnit ;
2529  Height = Buff->ScreenBufferSize.Y * HeightUnit;
2530 
2531  /* Recreate the framebuffer */
2532  hDC = GetDC(GuiData->hWindow);
2533  hnew = CreateFrameBufferBitmap(hDC, Width, Height);
2534  ReleaseDC(GuiData->hWindow, hDC);
2535  hold = SelectObject(GuiData->hMemDC, hnew);
2536  if (GuiData->hBitmap)
2537  {
2538  if (hold == GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
2539  }
2540  GuiData->hBitmap = hnew;
2541 
2542  /* Resize the window to the user's values */
2543  GuiData->WindowSizeLock = TRUE;
2544  ResizeConWnd(GuiData, WidthUnit, HeightUnit);
2545  GuiData->WindowSizeLock = FALSE;
2546  break;
2547  }
2548 
2549  /*
2550  * Undocumented message sent by Windows' console.dll for applying console info.
2551  * See http://www.catch22.net/sites/default/source/files/setconsoleinfo.c
2552  * and http://www.scn.rain.com/~neighorn/PDF/MSBugPaper.pdf
2553  * for more information.
2554  */
2555  case WM_SETCONSOLEINFO:
2556  {
2557  GuiApplyUserSettings(GuiData, (HANDLE)wParam);
2558  break;
2559  }
2560 
2561  case PM_CONSOLE_BEEP:
2562  DPRINT1("Beep\n");
2563  Beep(800, 200);
2564  break;
2565 
2566  case PM_CONSOLE_SET_TITLE:
2567  SetWindowTextW(GuiData->hWindow, GuiData->Console->Title.Buffer);
2568  break;
2569 
2570  default: Default:
2572  break;
2573  }
2574 
2575  return Result;
2576 }
2577 
2578 /* EOF */
#define WM_MBUTTONUP
Definition: winuser.h:1765
#define ID_SYSTEM_EDIT_SCROLL
Definition: resource.h:16
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
COORD dwSelectionCursor
Definition: conwnd.h:93
POINT ptMinTrackSize
Definition: winuser.h:3605
#define FROM_LEFT_1ST_BUTTON_PRESSED
Definition: wincon.h:159
BOOLEAN UnRegisterConWndClass(HINSTANCE hInstance)
Definition: conwnd.c:182
#define SCROLLLOCK_ON
Definition: wincon.h:143
PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console)
Definition: console.c:1363
static VOID OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
Definition: conwnd.c:702
#define SB_PAGEDOWN
Definition: winuser.h:569
#define IDS_DEFAULTS
Definition: resource.h:28
#define BITSPIXEL
Definition: wingdi.h:719
#define WMSZ_BOTTOMRIGHT
Definition: winuser.h:2446
#define IN
Definition: typedefs.h:39
GLint GLint GLsizei width
Definition: gl.h:1546
static VOID OnSize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:2047
#define SB_PAGEUP
Definition: winuser.h:568
#define max(a, b)
Definition: svc.c:63
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
static HICON
Definition: imagelist.c:84
static PGUI_CONSOLE_DATA GuiGetGuiData(HWND hWnd)
Definition: conwnd.c:420
#define SM_CYHSCROLL
Definition: winuser.h:952
#define LF_FACESIZE
Definition: dimm.idl:39
#define LR_SHARED
Definition: winuser.h:1090
INT MouseCursorRefCount
Definition: conwnd.h:71
#define IMAGE_ICON
Definition: winuser.h:212
DWORD dwEventFlags
Definition: wincon.h:257
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
HANDLE hGuiInitEvent
Definition: conwnd.h:44
BOOL IsCloseButtonEnabled
Definition: conwnd.h:77
BOOL WINAPI DrawMenuBar(_In_ HWND)
static DNS_RECORDW r3
Definition: record.c:39
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define SIF_RANGE
Definition: winuser.h:1221
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
UINT WINAPI SetSystemPaletteUse(_In_ HDC, _In_ UINT)
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
long y
Definition: polytest.cpp:48
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_CHAR
Definition: winuser.h:1699
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
#define IDS_FIND
Definition: resource.h:27
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
static VOID Paste(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1995
#define CONGUI_MIN_HEIGHT
Definition: conwnd.c:34
BOOLEAN CursorBlinkOn
Definition: conio.h:72
#define RGB(r, g, b)
Definition: precomp.h:62
#define MK_LBUTTON
Definition: winuser.h:2342
long x
Definition: polytest.cpp:48
signed short * PSHORT
Definition: retypes.h:6
HDC WINAPI GetDC(_In_opt_ HWND)
VOID ConioUnpause(PCONSRV_CONSOLE Console, UCHAR Flags)
Definition: console.c:866
static COORD PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
Definition: conwnd.c:1517
#define RIGHTMOST_BUTTON_PRESSED
Definition: wincon.h:160
#define SB_VERT
Definition: winuser.h:553
WORD ATOM
Definition: dimm.idl:113
#define CTRL_CLOSE_EVENT
Definition: wincon.h:70
#define SIZE_MAXIMIZED
Definition: winuser.h:2482
#define TRUE
Definition: types.h:120
VOID DeleteFonts(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:481
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
#define VK_RMENU
Definition: winuser.h:2262
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ERROR(name)
Definition: error_private.h:53
#define WM_MOUSEWHEEL
Definition: treelist.c:96
_In_ BOOLEAN Create
Definition: pstypes.h:527
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
#define PM_CONSOLE_BEEP
Definition: conwnd.h:21
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
#define MK_MBUTTON
Definition: winuser.h:2346
#define GWLP_CONWND_ALLOC
Definition: conwnd.c:43
WCHAR UnicodeChar
Definition: wincon.h:184
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SB_HORZ
Definition: winuser.h:552
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
#define SIZE_RESTORED
Definition: winuser.h:2480
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
static HDC
Definition: imagelist.c:92
#define ID_SYSTEM_EDIT_COPY
Definition: resource.h:13
#define CALLBACK
Definition: compat.h:35
COORD CursorPosition
Definition: conio.h:71
#define MF_STRING
Definition: winuser.h:138
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
static DNS_RECORDW r1
Definition: record.c:37
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
#define FROM_LEFT_2ND_BUTTON_PRESSED
Definition: wincon.h:161
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:527
static VOID ResizeConWnd(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
Definition: conwnd.c:428
#define NULLREGION
Definition: wingdi.h:360
LONG top
Definition: windef.h:307
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static LRESULT OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:356
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define VK_LEFT
Definition: winuser.h:2199
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
static VOID OnMove(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:2113
#define ZeroMemory
Definition: winbase.h:1664
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
VOID GuiPasteToTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: text.c:339
#define WM_MOVE
Definition: winuser.h:1592
#define SM_CXEDGE
Definition: winuser.h:998
const struct _GUICONSOLE_MENUITEM * SubMenu
Definition: conwnd.c:80
VOID LeaveFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:39
#define SM_CYSMICON
Definition: winuser.h:1003
#define IS_WORD_SEP(c)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HWND WINAPI SetFocus(_In_opt_ HWND)
#define IDS_SCROLL
Definition: resource.h:26
LPWSTR dwTypeData
Definition: winuser.h:3244
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define CONSOLE_NO_SELECTION
Definition: wincon.h:102
#define WMSZ_TOP
Definition: winuser.h:2441
BOOL IgnoreNextMouseSignal
Definition: conwnd.h:72
#define IDS_EDIT
Definition: resource.h:21
#define KF_UP
Definition: winuser.h:2426
#define WM_NCHITTEST
Definition: winuser.h:1668
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
#define VK_LWIN
Definition: winuser.h:2210
#define VK_TAB
Definition: winuser.h:2174
#define VK_DOWN
Definition: winuser.h:2202
struct _WNDCLASSEXW WNDCLASSEXW
#define VK_PRIOR
Definition: winuser.h:2195
#define VK_MENU
Definition: winuser.h:2179
#define GetWindowLongPtrW
Definition: winuser.h:4804
CONSOLE_SELECTION_INFO Selection
Definition: conwnd.h:92
#define PM_RESIZE_TERMINAL
Definition: conwnd.h:20
uint16_t * PWCHAR
Definition: typedefs.h:56
#define IDS_PROPERTIES
Definition: resource.h:101
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1232
HICON HCURSOR
Definition: windef.h:299
#define SM_CYFRAME
Definition: winuser.h:986
SMALL_RECT srSelection
Definition: wincon.h:210
#define SHIFT_PRESSED
Definition: wincon.h:141
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define SM_CXFRAME
Definition: winuser.h:984
static VOID UpdateSelection(PGUI_CONSOLE_DATA GuiData, PCOORD SelectionAnchor OPTIONAL, PCOORD coord)
Definition: conwnd.c:863
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define VK_ESCAPE
Definition: winuser.h:2189
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
HANDLE UniqueProcess
Definition: compat.h:684
static VOID OnTimer(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1253
LONG right
Definition: windef.h:308
BOOL WINAPI IsIconic(_In_ HWND)
#define CONSOLE_MOUSE_DOWN
Definition: wincon.h:106
#define WM_NCCREATE
Definition: winuser.h:1665
DWORD dwButtonState
Definition: wincon.h:255
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DWORD
Definition: nt_native.h:44
VOID GetSelectionBeginEnd(PCOORD Begin, PCOORD End, PCOORD SelectionAnchor, PSMALL_RECT SmallRect)
Definition: conwnd.c:732
int32_t INT
Definition: typedefs.h:58
#define SIF_PAGE
Definition: winuser.h:1219
#define VK_RETURN
Definition: winuser.h:2176
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
#define GWLP_CONSOLE_LEADER_TID
Definition: conwnd.c:45
HFONT hFont
Definition: main.c:53
VOID GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: graphics.c:21
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define PAUSED_FROM_SELECTION
Definition: conio_winsrv.h:109
#define VK_NEXT
Definition: winuser.h:2196
#define WMSZ_TOPLEFT
Definition: winuser.h:2442
SHORT Right
Definition: wincon.h:193
SHORT Left
Definition: wincon.h:191
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define ICON_SMALL
Definition: tnclass.cpp:48
static VOID SendMenuEvent(PCONSRV_CONSOLE Console, UINT CmdId)
Definition: conwnd.c:274
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:105
GLuint coord
Definition: glext.h:9511
#define RGN_AND
Definition: wingdi.h:355
#define ID_SYSTEM_PROPERTIES
Definition: resource.h:19
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
static LRESULT OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:1543
BOOL WindowSizeLock
Definition: conwnd.h:43
UINT CharHeight
Definition: conwnd.h:87
#define MOUSE_MOVED
Definition: wincon.h:168
HPALETTE PaletteHandle
Definition: conio.h:78
#define SWP_NOCOPYBITS
Definition: winuser.h:1228
VOID SetConWndConsoleLeaderCID(IN PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:48
VOID PasteText(IN PCONSRV_CONSOLE Console, IN PWCHAR Buffer, IN SIZE_T cchSize)
Definition: text.c:238
#define FONT_NORMAL
Definition: conwnd.h:35
static VOID PaintSelectionRect(PGUI_CONSOLE_DATA GuiData, PPAINTSTRUCT pps)
Definition: conwnd.c:843
#define ID_SYSTEM_EDIT_MARK
Definition: resource.h:12
#define TPM_RIGHTBUTTON
Definition: winuser.h:2355
HINSTANCE hInstance
Definition: charmap.c:20
#define VK_HOME
Definition: winuser.h:2198
HICON ghDefaultIcon
Definition: conwnd.c:73
UNICODE_STRING Title
Definition: conio_winsrv.h:176
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HBITMAP CreateFrameBufferBitmap(HDC hDC, int width, int height)
Definition: conwnd.c:2179
#define VK_UP
Definition: winuser.h:2200
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console, IN ULONG ProcessGroupId, IN ULONG CtrlEvent)
Definition: console.c:1402
BOOL HackCORE8394IgnoreNextMove
Definition: conwnd.h:74
COORD ScreenBufferSize
Definition: conio.h:62
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DOUBLE_CLICK
Definition: wincon.h:169
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
long LONG
Definition: pedump.c:60
#define RGN_XOR
Definition: wingdi.h:359
#define WM_SETCURSOR
Definition: winuser.h:1618
VOID CreateSysMenu(HWND hWnd)
Definition: conwnd.c:242
short SHORT
Definition: pedump.c:59
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HICON hIconSm
Definition: conwnd.h:67
#define GWLP_CONSOLE_LEADER_PID
Definition: conwnd.c:44
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
NTSTATUS APIENTRY NtUserConsoleControl(IN CONSOLECONTROL ConsoleCtrl, IN PVOID ConsoleCtrlInfo, IN ULONG ConsoleCtrlInfoLength)
Definition: console.c:14
#define WM_MENUSELECT
Definition: winuser.h:1729
short _InterlockedExchange16(_Interlocked_operand_ short volatile *_Target, short _Value)
DWORD biCompression
Definition: amvideo.idl:35
#define WM_DROPFILES
Definition: winuser.h:1807
#define WM_SYSCHAR
Definition: winuser.h:1703
#define SM_CXICON
Definition: winuser.h:962
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#define GWLP_USERDATA
Definition: treelist.c:63
#define ID_SYSTEM_DEFAULTS
Definition: resource.h:18
static VOID OnActivate(PGUI_CONSOLE_DATA GuiData, WPARAM wParam)
Definition: conwnd.c:665
#define CONGUI_UPDATE_TIMER
Definition: conwnd.c:36
#define VK_SHIFT
Definition: winuser.h:2177
#define WM_SIZING
Definition: winuser.h:1789
#define CF_UNICODETEXT
Definition: constants.h:408
COORD dwMousePosition
Definition: wincon.h:254
static LRESULT CALLBACK ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:2193
unsigned char BOOLEAN
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
#define IDS_SELECTALL
Definition: resource.h:25
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define CURSOR_BLINK_TIME
Definition: conwnd.c:38
#define SB_THUMBPOSITION
Definition: winuser.h:572
_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 GetConsoleInputBufferMode(Console)
Definition: conio.h:318
#define IDI_TERMINAL
Definition: resource.h:44
#define WM_KEYDOWN
Definition: winuser.h:1697
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:104
#define MF_SEPARATOR
Definition: winuser.h:137
LONG_PTR LPARAM
Definition: windef.h:208
#define SM_CYEDGE
Definition: winuser.h:999
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
Definition: bufpool.h:45
static VOID OnScroll(PGUI_CONSOLE_DATA GuiData, INT nBar, WORD sbCode)
Definition: conwnd.c:1409
CLIENT_ID ClientId
Definition: csrsrv.h:38
VOID InvalidateCell(PGUI_CONSOLE_DATA GuiData, SHORT x, SHORT y)
Definition: guiterm.c:88
#define FOCUS_EVENT
Definition: wincon.h:132
HMENU hSysMenu
Definition: conwnd.h:76
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
#define MK_RBUTTON
Definition: winuser.h:2343
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL LineSelection
Definition: conwnd.h:94
BOOL GetFontCellSize(IN HDC hDC OPTIONAL, IN HFONT hFont, OUT PUINT Height, OUT PUINT Width)
Definition: font.c:119
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
SHORT WINAPI GetKeyState(_In_ int)
#define LEFT_ALT_PRESSED
Definition: wincon.h:138
SHORT Left
Definition: blue.h:32
#define KF_EXTENDED
Definition: winuser.h:2421
ULONG X
Definition: bl.h:1340
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
#define KF_REPEAT
Definition: winuser.h:2425
#define FROM_LEFT_3RD_BUTTON_PRESSED
Definition: wincon.h:162
VOID GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, PRECT rcView, PRECT rcFramebuffer)
Definition: graphics.c:124
#define WM_DEADCHAR
Definition: winuser.h:1700
static HRGN CreateSelectionRgn(PGUI_CONSOLE_DATA GuiData, BOOL LineSelection, PCOORD SelectionAnchor, PSMALL_RECT SmallRect)
Definition: conwnd.c:753
static VOID OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: conwnd.c:1088
VOID GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, PRECT rcView, PRECT rcFramebuffer)
Definition: text.c:433
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
static BOOL OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
Definition: conwnd.c:599
union _CHAR_INFO::@3240 Char
#define WM_KILLFOCUS
Definition: winuser.h:1596
static VOID Mark(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:300
#define SM_CYCAPTION
Definition: winuser.h:953
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
#define ID_SYSTEM_EDIT_SELECTALL
Definition: resource.h:15
#define KEY_PRESSED
Definition: conwnd.h:26
SHORT Bottom
Definition: blue.h:35
#define ASSERT(a)
Definition: mode.c:44
#define IDS_PASTE
Definition: shresdef.h:228
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ENHANCED_KEY
Definition: wincon.h:145
#define SB_THUMBTRACK
Definition: winuser.h:573
#define WM_SIZE
Definition: winuser.h:1593
#define SWP_NOACTIVATE
Definition: winuser.h:1227
DWORD COLORREF
Definition: windef.h:300
POINT OldCursor
Definition: conwnd.h:54
#define WM_TIMER
Definition: winuser.h:1724
#define MF_ENABLED
Definition: winuser.h:128
#define WMSZ_RIGHT
Definition: winuser.h:2440
#define WA_ACTIVE
Definition: winuser.h:2598
#define WM_CLOSE
Definition: winuser.h:1603
static DNS_RECORDW r2
Definition: record.c:38
#define WM_NCDESTROY
Definition: winuser.h:1666
static BOOL IsSystemKey(WORD VirtualKeyCode)
Definition: conwnd.c:1065
#define MAX_PATH
Definition: compat.h:34
#define MOUSE_EVENT
Definition: wincon.h:129
#define WM_PALETTECHANGED
Definition: winuser.h:1859
#define WM_KEYUP
Definition: winuser.h:1698
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned short WORD
Definition: ntddk_ex.h:93
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WA_CLICKACTIVE
Definition: winuser.h:2599
#define GUI_CONWND_CLASS
Definition: conwnd.h:15
CRITICAL_SECTION Lock
Definition: conwnd.h:42
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define SIZE_MINIMIZED
Definition: winuser.h:2481
SHORT Top
Definition: blue.h:33
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
PCSR_PROCESS Process
Definition: consrv.h:43
#define WM_RBUTTONUP
Definition: winuser.h:1762
static const GUICONSOLE_MENUITEM GuiConsoleMainMenuItems[]
Definition: conwnd.c:96
FOCUS_EVENT_RECORD FocusEvent
Definition: wincon.h:279
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
static VOID SelectAll(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:315
#define WM_PAINT
Definition: winuser.h:1602
HANDLE UniqueThread
Definition: compat.h:685
#define SM_CXSMICON
Definition: winuser.h:1002
CHAR Message[80]
Definition: alive.c:5
SHORT Bottom
Definition: wincon.h:194
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define ENABLE_MOUSE_INPUT
Definition: wincon.h:82
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define MF_POPUP
Definition: winuser.h:136
#define SM_CYICON
Definition: winuser.h:963
#define LEFT_CTRL_PRESSED
Definition: wincon.h:140
static const WCHAR L[]
Definition: oid.c:1250
#define VK_RCONTROL
Definition: winuser.h:2260
#define VK_LMENU
Definition: winuser.h:2261
HICON ghDefaultIconSm
Definition: conwnd.c:74
NTSTATUS NTAPI ConSrvSetConsoleProcessFocus(IN PCONSRV_CONSOLE Console, IN BOOLEAN SetForeground)
Definition: console.c:1453
VOID GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults)
Definition: guisettings.c:44
BOOL InitFonts(PGUI_CONSOLE_DATA GuiData, LPWSTR FaceName, ULONG FontFamily, COORD FontSize, ULONG FontWeight)
Definition: conwnd.c:521
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
struct _GUICONSOLE_MENUITEM GUICONSOLE_MENUITEM
VOID GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:175
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
BOOL EnterFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:21
HCURSOR ghDefaultCursor
Definition: conwnd.c:75
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1766
#define CS_DBLCLKS
Definition: winuser.h:646
#define WM_COMMAND
Definition: winuser.h:1722
static VOID OnPaint(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:986
BOOLEAN IsWindowVisible
Definition: conwnd.h:52
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:103
#define VK_RWIN
Definition: winuser.h:2211
#define WMSZ_BOTTOM
Definition: winuser.h:2444
Definition: bl.h:1338
#define MENU_EVENT
Definition: wincon.h:131
#define SW_INVALIDATE
Definition: winuser.h:2554
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
BOOLEAN RegisterConWndClass(IN HINSTANCE hInstance)
Definition: conwnd.c:136
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define SIF_POS
Definition: winuser.h:1220
static VOID OnDropFiles(PCONSRV_CONSOLE Console, HDROP hDrop)
Definition: conwnd.c:2127
#define VK_RIGHT
Definition: winuser.h:2201
SHORT Top
Definition: wincon.h:192
VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG *msg)
Definition: input.c:60
#define GetType(This)
Definition: conio.h:54
#define SC_MINIMIZE
Definition: winuser.h:2561
static VOID Copy(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1972
#define IDS_MARK_TITLE
Definition: resource.h:31
static HDC hDC
Definition: 3dtext.c:33
#define MIIM_STRING
Definition: winuser.h:722
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
FORCEINLINE VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.h:22
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define SB_TOP
Definition: winuser.h:578
#define WM_INITMENU
Definition: winuser.h:1727
#define FW_BOLD
Definition: wingdi.h:377
#define PAUSED_FROM_SCROLLBAR
Definition: conio_winsrv.h:108
#define WM_ACTIVATE
Definition: winuser.h:1594
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define VK_SCROLL
Definition: winuser.h:2255
#define VK_NUMLOCK
Definition: winuser.h:2254
BOOL WINAPI DeleteDC(_In_ HDC)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_SYSDEADCHAR
Definition: winuser.h:1704
unsigned short USHORT
Definition: pedump.c:61
BYTE lfStrikeOut
Definition: dimm.idl:66
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
LPCWSTR szPath
Definition: env.c:37
#define WM_SYSKEYUP
Definition: winuser.h:1702
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1759
static VOID OnPaletteChanged(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1041
DWORD dwControlKeyState
Definition: wincon.h:256
#define WM_MBUTTONDOWN
Definition: winuser.h:1764
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define VK_CAPITAL
Definition: winuser.h:2181
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
VOID ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags)
Definition: console.c:859
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define SB_LINEDOWN
Definition: winuser.h:565
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define NULL
Definition: types.h:112
#define WM_HSCROLL
Definition: winuser.h:1725
#define VK_SPACE
Definition: winuser.h:2194
#define SB_LINEUP
Definition: winuser.h:564
#define SB_BOTTOM
Definition: winuser.h:577
BOOL WINAPI InvertRgn(_In_ HDC, _In_ HRGN)
Definition: painting.c:229
#define SM_CXVSCROLL
Definition: winuser.h:951
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:43
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
UINT CharWidth
Definition: conwnd.h:86
HWND WINAPI WindowFromPoint(_In_ POINT)
#define CONGUI_UPDATE_TIME
Definition: conwnd.c:35
struct _GUICONSOLE_MENUITEM * PGUICONSOLE_MENUITEM
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static VOID OnGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
Definition: conwnd.c:2015
#define KF_ALTDOWN
Definition: winuser.h:2424
HCURSOR hCursor
Definition: conwnd.h:70
#define VK_CONTROL
Definition: winuser.h:2178
CConsole Console
WORD EventType
Definition: wincon.h:273
#define DPRINT1
Definition: precomp.h:8
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
union _INPUT_RECORD::@3242 Event
const COLORREF s_Colors[16]
Definition: conwnd.c:109
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
HINSTANCE ConSrvDllInstance
Definition: init.c:21
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
#define SC_CLOSE
Definition: winuser.h:2567
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
MOUSE_EVENT_RECORD MouseEvent
Definition: wincon.h:276
#define VK_PAUSE
Definition: winuser.h:2180
HPALETTE hSysPalette
Definition: conwnd.h:64
void WINAPI DragFinish(HDROP h)
Definition: shellole.c:543
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1763
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
#define ID_SYSTEM_EDIT_FIND
Definition: resource.h:17
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define HIWORD(l)
Definition: typedefs.h:247
unsigned int ULONG
Definition: retypes.h:1
LONG bottom
Definition: windef.h:309
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
HFONT Font[FONT_MAXNO]
Definition: conwnd.h:85
#define PM_CONSOLE_SET_TITLE
Definition: conwnd.h:22
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN Begin
Definition: acpixf.h:1297
#define SWP_NOMOVE
Definition: winuser.h:1229
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
static HFONT CreateDerivedFont(HFONT OrgFont, ULONG FontWeight, BOOLEAN bUnderline, BOOLEAN bStrikeOut)
Definition: conwnd.c:492
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define MOUSE_WHEELED
Definition: wincon.h:170
#define FROM_LEFT_4TH_BUTTON_PRESSED
Definition: wincon.h:163
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:139
MENU_EVENT_RECORD MenuEvent
Definition: wincon.h:278
#define SetWindowLongPtrW
Definition: winuser.h:5321
struct tagRECT * PRECT
static HBITMAP
Definition: button.c:44
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static const GUICONSOLE_MENUITEM GuiConsoleEditMenuItems[]
Definition: conwnd.c:84
POINT ptMaxTrackSize
Definition: winuser.h:3606
LONG lfWeight
Definition: dimm.idl:63
HBITMAP hBitmap
Definition: conwnd.h:63
#define WM_ERASEBKGND
Definition: winuser.h:1607
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HTCLIENT
Definition: winuser.h:2450
#define CONGUI_MIN_WIDTH
Definition: conwnd.c:33
#define DPRINT
Definition: sndvol32.h:71
WCHAR * LPWSTR
Definition: xmlstorage.h:184
SHORT Right
Definition: blue.h:34
LONG_PTR LRESULT
Definition: windef.h:209
#define VK_LCONTROL
Definition: winuser.h:2259
#define DIB_RGB_COLORS
Definition: wingdi.h:366
VOID GuiPasteToGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: graphics.c:111
VOID GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData)
Definition: text.c:306
BYTE lfUnderline
Definition: dimm.idl:65
ULONG Y
Definition: bl.h:1341
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:627
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:1723
#define IDS_MARK
Definition: resource.h:22
#define MOUSE_HWHEELED
Definition: wincon.h:172
VOID GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData, HANDLE hClientSection)
Definition: guisettings.c:258
#define BI_RGB
Definition: precomp.h:47
LPARAM lParam
Definition: combotst.c:139
#define WM_GETMINMAXINFO
Definition: winuser.h:1622
#define LOWORD(l)
Definition: pedump.c:82
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define VK_END
Definition: winuser.h:2197
UINT WINAPI RealizePalette(_In_ HDC)
Definition: palette.c:138
#define SRCCOPY
Definition: wingdi.h:332
#define NUMLOCK_ON
Definition: wincon.h:142
static VOID AppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: conwnd.c:188
#define SendNotifyMessage
Definition: winuser.h:5821
#define RIGHT_ALT_PRESSED
Definition: wincon.h:137
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:201
#define WMSZ_LEFT
Definition: winuser.h:2439
#define WMSZ_TOPRIGHT
Definition: winuser.h:2443
#define WMSZ_BOTTOMLEFT
Definition: winuser.h:2445
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
WCHAR WndClass[]
Definition: capicon.c:23
#define CAPSLOCK_ON
Definition: wincon.h:144
#define IDS_COPY
Definition: resource.h:121
#define ICON_BIG
Definition: tnclass.cpp:51
static LRESULT OnNcDestroy(HWND hWnd)
Definition: conwnd.c:1383
#define WM_VSCROLL
Definition: winuser.h:1726
#define WM_SETCONSOLEINFO
Definition: settings.h:21
static BOOL OnClose(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:1362
FORCEINLINE VOID SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
Definition: guiterm.h:43
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define IDS_SELECT_TITLE
Definition: resource.h:32
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
#define KEY_TOGGLED
Definition: conwnd.h:25