ReactOS  0.4.13-dev-464-g6b95727
guiterm.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_new/frontends/gui/guiterm.c
5  * PURPOSE: GUI Terminal Front-End
6  * PROGRAMMERS: Gé van Geldorp
7  * Johannes Anderwald
8  * Jeffrey Morlan
9  * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
10  */
11 
12 /* INCLUDES *******************************************************************/
13 
14 #define COBJMACROS
15 #define NONAMELESSUNION
16 
17 #include "consrv.h"
18 #include "include/conio.h"
19 #include "include/console.h"
20 #include "include/settings.h"
21 #include "conoutput.h"
22 #include "guiterm.h"
23 #include "guisettings.h"
24 #include "resource.h"
25 
26 #include <windowsx.h>
27 
28 #include <shlwapi.h>
29 #include <shlobj.h>
30 
31 #define NDEBUG
32 #include <debug.h>
33 
34 /* GUI Console Window Class name */
35 #define GUI_CONSOLE_WINDOW_CLASS L"ConsoleWindowClass"
36 
37 #ifndef WM_APP
38  #define WM_APP 0x8000
39 #endif
40 #define PM_CREATE_CONSOLE (WM_APP + 1)
41 #define PM_DESTROY_CONSOLE (WM_APP + 2)
42 #define PM_RESIZE_TERMINAL (WM_APP + 3)
43 #define PM_CONSOLE_BEEP (WM_APP + 4)
44 #define PM_CONSOLE_SET_TITLE (WM_APP + 5)
45 
46 
47 /* Not defined in any header file */
49 // See winsrv/usersrv/init.c line 234
50 
51 
52 /* GLOBALS ********************************************************************/
53 
54 typedef struct _GUI_INIT_INFO
55 {
60 
61 /**************************************************************\
62 \** Define the Console Leader Process for the console window **/
63 #define GWLP_CONSOLEWND_ALLOC (2 * sizeof(LONG_PTR))
64 #define GWLP_CONSOLE_LEADER_PID 0
65 #define GWLP_CONSOLE_LEADER_TID 4
66 
67 #define SetConsoleWndConsoleLeaderCID(GuiData) \
68 do { \
69  PCONSOLE_PROCESS_DATA ProcessData; \
70  CLIENT_ID ConsoleLeaderCID; \
71  ProcessData = CONTAINING_RECORD((GuiData)->Console->ProcessList.Blink, \
72  CONSOLE_PROCESS_DATA, \
73  ConsoleLink); \
74  ConsoleLeaderCID = ProcessData->Process->ClientId; \
75  SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_PID, (LONG_PTR)(ConsoleLeaderCID.UniqueProcess)); \
76  SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_TID, (LONG_PTR)(ConsoleLeaderCID.UniqueThread )); \
77 } while (0)
78 /**************************************************************/
79 
84 static HWND NotifyWnd = NULL;
85 
86 typedef struct _GUICONSOLE_MENUITEM
87 {
88  UINT uID;
89  const struct _GUICONSOLE_MENUITEM *SubMenu;
90  WORD wCmdID;
92 
94 {
101 
102  { 0, NULL, 0 } /* End of list */
103 };
104 
106 {
110 
111  { 0, NULL, 0 } /* End of list */
112 };
113 
114 /*
115  * Default 16-color palette for foreground and background
116  * (corresponding flags in comments).
117  */
118 const COLORREF s_Colors[16] =
119 {
120  RGB(0, 0, 0), // (Black)
121  RGB(0, 0, 128), // BLUE
122  RGB(0, 128, 0), // GREEN
123  RGB(0, 128, 128), // BLUE | GREEN
124  RGB(128, 0, 0), // RED
125  RGB(128, 0, 128), // BLUE | RED
126  RGB(128, 128, 0), // GREEN | RED
127  RGB(192, 192, 192), // BLUE | GREEN | RED
128 
129  RGB(128, 128, 128), // (Grey) INTENSITY
130  RGB(0, 0, 255), // BLUE | INTENSITY
131  RGB(0, 255, 0), // GREEN | INTENSITY
132  RGB(0, 255, 255), // BLUE | GREEN | INTENSITY
133  RGB(255, 0, 0), // RED | INTENSITY
134  RGB(255, 0, 255), // BLUE | RED | INTENSITY
135  RGB(255, 255, 0), // GREEN | RED | INTENSITY
136  RGB(255, 255, 255) // BLUE | GREEN | RED | INTENSITY
137 };
138 
139 /* FUNCTIONS ******************************************************************/
140 
141 static VOID
143  IN PGUI_CONSOLE_DATA GuiData,
144  OUT PUINT WidthUnit,
145  OUT PUINT HeightUnit)
146 {
147  if (Buffer == NULL || GuiData == NULL ||
148  WidthUnit == NULL || HeightUnit == NULL)
149  {
150  return;
151  }
152 
154  {
155  *WidthUnit = GuiData->CharWidth ;
156  *HeightUnit = GuiData->CharHeight;
157  }
158  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
159  {
160  *WidthUnit = 1;
161  *HeightUnit = 1;
162  }
163 }
164 
165 
166 
167 static VOID
169  const GUICONSOLE_MENUITEM *Items)
170 {
171  UINT i = 0;
172  WCHAR szMenuString[255];
173  HMENU hSubMenu;
174 
175  do
176  {
177  if (Items[i].uID != (UINT)-1)
178  {
180  Items[i].uID,
181  szMenuString,
182  sizeof(szMenuString) / sizeof(szMenuString[0])) > 0)
183  {
184  if (Items[i].SubMenu != NULL)
185  {
186  hSubMenu = CreatePopupMenu();
187  if (hSubMenu != NULL)
188  {
189  GuiConsoleAppendMenuItems(hSubMenu,
190  Items[i].SubMenu);
191 
192  if (!AppendMenuW(hMenu,
194  (UINT_PTR)hSubMenu,
195  szMenuString))
196  {
197  DestroyMenu(hSubMenu);
198  }
199  }
200  }
201  else
202  {
203  AppendMenuW(hMenu,
204  MF_STRING,
205  Items[i].wCmdID,
206  szMenuString);
207  }
208  }
209  }
210  else
211  {
212  AppendMenuW(hMenu,
213  MF_SEPARATOR,
214  0,
215  NULL);
216  }
217  i++;
218  } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].wCmdID == 0));
219 }
220 
221 static VOID
223 {
224  HMENU hMenu = GetSystemMenu(hWnd, FALSE);
225  if (hMenu != NULL)
226  {
228  DrawMenuBar(hWnd);
229  }
230 }
231 
232 static VOID
234 {
235  INPUT_RECORD er;
236 
237  er.EventType = MENU_EVENT;
238  er.Event.MenuEvent.dwCommandId = CmdId;
239 
241 }
242 
243 static VOID
245 static VOID
247 static VOID
249 static VOID WINAPI
251 static VOID
253 
254 
255 static LRESULT
257 {
258  LRESULT Ret = TRUE;
259  PCONSOLE Console = GuiData->Console;
260  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
261 
263  {
264  Ret = FALSE;
265  goto Quit;
266  }
267  ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
268 
269  /*
270  * In case the selected menu item belongs to the user-reserved menu id range,
271  * send to him a menu event and return directly. The user must handle those
272  * reserved menu commands...
273  */
274  if (GuiData->cmdIdLow <= (UINT)wParam && (UINT)wParam <= GuiData->cmdIdHigh)
275  {
277  goto Unlock_Quit;
278  }
279 
280  /* ... otherwise, perform actions. */
281  switch (wParam)
282  {
283  case ID_SYSTEM_EDIT_MARK:
284  {
285  LPWSTR WindowTitle = NULL;
286  SIZE_T Length = 0;
287 
288  Console->dwSelectionCursor.X = ActiveBuffer->ViewOrigin.X;
289  Console->dwSelectionCursor.Y = ActiveBuffer->ViewOrigin.Y;
290  Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
291  Console->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS;
292  GuiConsoleUpdateSelection(Console, &Console->Selection.dwSelectionAnchor);
293 
294  Length = Console->Title.Length + sizeof(L"Mark - ")/sizeof(WCHAR) + 1;
295  WindowTitle = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
296  wcscpy(WindowTitle, L"Mark - ");
297  wcscat(WindowTitle, Console->Title.Buffer);
298  SetWindowText(GuiData->hWindow, WindowTitle);
299  ConsoleFreeHeap(WindowTitle);
300 
301  break;
302  }
303 
304  case ID_SYSTEM_EDIT_COPY:
305  GuiConsoleCopy(GuiData);
306  break;
307 
309  GuiConsolePaste(GuiData);
310  break;
311 
313  {
314  LPWSTR WindowTitle = NULL;
315  SIZE_T Length = 0;
316 
317  Console->Selection.dwSelectionAnchor.X = 0;
318  Console->Selection.dwSelectionAnchor.Y = 0;
319  Console->dwSelectionCursor.X = ActiveBuffer->ViewSize.X - 1;
320  Console->dwSelectionCursor.Y = ActiveBuffer->ViewSize.Y - 1;
322  GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
323 
324  Length = Console->Title.Length + sizeof(L"Selection - ")/sizeof(WCHAR) + 1;
325  WindowTitle = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
326  wcscpy(WindowTitle, L"Selection - ");
327  wcscat(WindowTitle, Console->Title.Buffer);
328  SetWindowText(GuiData->hWindow, WindowTitle);
329  ConsoleFreeHeap(WindowTitle);
330 
331  break;
332  }
333 
335  DPRINT1("Scrolling is not handled yet\n");
336  break;
337 
338  case ID_SYSTEM_EDIT_FIND:
339  DPRINT1("Finding is not handled yet\n");
340  break;
341 
342  case ID_SYSTEM_DEFAULTS:
344  break;
345 
348  break;
349 
350  default:
351  Ret = FALSE;
352  break;
353  }
354 
355 Unlock_Quit:
357 Quit:
358  if (!Ret)
359  Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam);
360 
361  return Ret;
362 }
363 
364 static PGUI_CONSOLE_DATA
366 {
367  /* This function ensures that the console pointer is not NULL */
369  return ( ((GuiData == NULL) || (GuiData->hWindow == hWnd && GuiData->Console != NULL)) ? GuiData : NULL );
370 }
371 
372 VOID
374 {
375  /* Move the window if needed (not positioned by the system) */
376  if (!GuiData->GuiInfo.AutoPosition)
377  {
378  SetWindowPos(GuiData->hWindow,
379  NULL,
380  GuiData->GuiInfo.WindowOrigin.x,
381  GuiData->GuiInfo.WindowOrigin.y,
382  0,
383  0,
385  }
386 }
387 
388 static VOID
390 {
391  PCONSOLE Console = GuiData->Console;
393  SCROLLINFO sInfo;
394 
395  DWORD Width, Height;
396  UINT WidthUnit, HeightUnit;
397 
398  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
399 
400  Width = Buff->ViewSize.X * WidthUnit +
402  Height = Buff->ViewSize.Y * HeightUnit +
404 
405  /* Set scrollbar sizes */
406  sInfo.cbSize = sizeof(SCROLLINFO);
407  sInfo.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
408  sInfo.nMin = 0;
409  if (Buff->ScreenBufferSize.Y > Buff->ViewSize.Y)
410  {
411  sInfo.nMax = Buff->ScreenBufferSize.Y - 1;
412  sInfo.nPage = Buff->ViewSize.Y;
413  sInfo.nPos = Buff->ViewOrigin.Y;
414  SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
415  Width += GetSystemMetrics(SM_CXVSCROLL);
416  ShowScrollBar(GuiData->hWindow, SB_VERT, TRUE);
417  }
418  else
419  {
420  ShowScrollBar(GuiData->hWindow, SB_VERT, FALSE);
421  }
422 
423  if (Buff->ScreenBufferSize.X > Buff->ViewSize.X)
424  {
425  sInfo.nMax = Buff->ScreenBufferSize.X - 1;
426  sInfo.nPage = Buff->ViewSize.X;
427  sInfo.nPos = Buff->ViewOrigin.X;
428  SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
429  Height += GetSystemMetrics(SM_CYHSCROLL);
430  ShowScrollBar(GuiData->hWindow, SB_HORZ, TRUE);
431  }
432  else
433  {
434  ShowScrollBar(GuiData->hWindow, SB_HORZ, FALSE);
435  }
436 
437  /* Resize the window */
438  SetWindowPos(GuiData->hWindow, NULL, 0, 0, Width, Height,
440  // NOTE: The SWP_NOCOPYBITS flag can be replaced by a subsequent call
441  // to: InvalidateRect(GuiData->hWindow, NULL, TRUE);
442 }
443 
444 static VOID
446 {
447  PCONSOLE Console = GuiData->Console;
448  // DEVMODE dmScreenSettings;
449 
451 
452  /* Switch to full-screen or to windowed mode */
453  GuiData->GuiInfo.FullScreen = !GuiData->GuiInfo.FullScreen;
454  DPRINT1("GuiConsoleSwitchFullScreen - Switch to %s ...\n",
455  (GuiData->GuiInfo.FullScreen ? "full-screen" : "windowed mode"));
456 
457  // TODO: Change window appearance.
458  // See:
459  // http://stackoverflow.com/questions/2382464/win32-full-screen-and-hiding-taskbar
460  // http://stackoverflow.com/questions/3549148/fullscreen-management-with-winapi
461  // http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
462  // http://stackoverflow.com/questions/1400654/how-do-i-put-my-opengl-app-into-fullscreen-mode
463  // http://nehe.gamedev.net/tutorial/creating_an_opengl_window_win32/13001/
464 #if 0
465  if (GuiData->GuiInfo.FullScreen)
466  {
467  memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
468  dmScreenSettings.dmSize = sizeof(dmScreenSettings);
469  dmScreenSettings.dmDisplayFixedOutput = DMDFO_CENTER; // DMDFO_STRETCH // DMDFO_DEFAULT
470  dmScreenSettings.dmPelsWidth = 640; // Console->ActiveBuffer->ViewSize.X * GuiData->CharWidth;
471  dmScreenSettings.dmPelsHeight = 480; // Console->ActiveBuffer->ViewSize.Y * GuiData->CharHeight;
472  dmScreenSettings.dmBitsPerPel = 32;
473  dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
474  ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
475  }
476  else
477  {
478  }
479 #endif
480 
482 }
483 
484 static BOOL
486 {
487  PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
489  HDC Dc;
490  HFONT OldFont;
491  TEXTMETRICW Metrics;
492  SIZE CharSize;
493 
494  DPRINT("GuiConsoleHandleNcCreate\n");
495 
496  if (NULL == GuiData)
497  {
498  DPRINT1("GuiConsoleNcCreate: No GUI data\n");
499  return FALSE;
500  }
501 
502  Console = GuiData->Console;
503 
504  GuiData->hWindow = hWnd;
505 
506  GuiData->Font = CreateFontW(LOWORD(GuiData->GuiInfo.FontSize),
507  0, // HIWORD(GuiData->GuiInfo.FontSize),
508  0,
509  TA_BASELINE,
510  GuiData->GuiInfo.FontWeight,
511  FALSE,
512  FALSE,
513  FALSE,
514  OEM_CHARSET,
518  FIXED_PITCH | GuiData->GuiInfo.FontFamily /* FF_DONTCARE */,
519  GuiData->GuiInfo.FaceName);
520 
521  if (NULL == GuiData->Font)
522  {
523  DPRINT1("GuiConsoleNcCreate: CreateFont failed\n");
524  GuiData->hWindow = NULL;
525  SetEvent(GuiData->hGuiInitEvent);
526  return FALSE;
527  }
528  Dc = GetDC(GuiData->hWindow);
529  if (NULL == Dc)
530  {
531  DPRINT1("GuiConsoleNcCreate: GetDC failed\n");
532  DeleteObject(GuiData->Font);
533  GuiData->hWindow = NULL;
534  SetEvent(GuiData->hGuiInitEvent);
535  return FALSE;
536  }
537  OldFont = SelectObject(Dc, GuiData->Font);
538  if (NULL == OldFont)
539  {
540  DPRINT1("GuiConsoleNcCreate: SelectObject failed\n");
541  ReleaseDC(GuiData->hWindow, Dc);
542  DeleteObject(GuiData->Font);
543  GuiData->hWindow = NULL;
544  SetEvent(GuiData->hGuiInitEvent);
545  return FALSE;
546  }
547  if (!GetTextMetricsW(Dc, &Metrics))
548  {
549  DPRINT1("GuiConsoleNcCreate: GetTextMetrics failed\n");
550  SelectObject(Dc, OldFont);
551  ReleaseDC(GuiData->hWindow, Dc);
552  DeleteObject(GuiData->Font);
553  GuiData->hWindow = NULL;
554  SetEvent(GuiData->hGuiInitEvent);
555  return FALSE;
556  }
557  GuiData->CharWidth = Metrics.tmMaxCharWidth;
558  GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
559 
560  /* Measure real char width more precisely if possible. */
561  if (GetTextExtentPoint32W(Dc, L"R", 1, &CharSize))
562  GuiData->CharWidth = CharSize.cx;
563 
564  SelectObject(Dc, OldFont);
565 
566  ReleaseDC(GuiData->hWindow, Dc);
567 
568  // FIXME: Keep these instructions here ? ///////////////////////////////////
569  Console->ActiveBuffer->CursorBlinkOn = TRUE;
570  Console->ActiveBuffer->ForceCursorOff = FALSE;
572 
573  SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
574 
576  GuiConsoleCreateSysMenu(GuiData->hWindow);
577 
578  DPRINT("GuiConsoleHandleNcCreate - setting start event\n");
579  SetEvent(GuiData->hGuiInitEvent);
580 
581  return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
582 }
583 
584 static VOID
586 {
587  PCONSOLE Console = GuiData->Console;
589  UINT WidthUnit, HeightUnit;
590 
591  GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
592 
593  Rect->left = (SmallRect->Left - Buffer->ViewOrigin.X) * WidthUnit ;
594  Rect->top = (SmallRect->Top - Buffer->ViewOrigin.Y) * HeightUnit;
595  Rect->right = (SmallRect->Right + 1 - Buffer->ViewOrigin.X) * WidthUnit ;
596  Rect->bottom = (SmallRect->Bottom + 1 - Buffer->ViewOrigin.Y) * HeightUnit;
597 }
598 
599 static VOID
601 {
602  PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
603  RECT oldRect, newRect;
604 
605  SmallRectToRect(GuiData, &oldRect, &Console->Selection.srSelection);
606 
607  if (coord != NULL)
608  {
609  SMALL_RECT rc;
610  /* exchange left/top with right/bottom if required */
611  rc.Left = min(Console->Selection.dwSelectionAnchor.X, coord->X);
612  rc.Top = min(Console->Selection.dwSelectionAnchor.Y, coord->Y);
613  rc.Right = max(Console->Selection.dwSelectionAnchor.X, coord->X);
614  rc.Bottom = max(Console->Selection.dwSelectionAnchor.Y, coord->Y);
615 
616  SmallRectToRect(GuiData, &newRect, &rc);
617 
618  if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
619  {
620  if (memcmp(&rc, &Console->Selection.srSelection, sizeof(SMALL_RECT)) != 0)
621  {
622  HRGN rgn1, rgn2;
623 
624  /* calculate the region that needs to be updated */
625  if ((rgn1 = CreateRectRgnIndirect(&oldRect)))
626  {
627  if ((rgn2 = CreateRectRgnIndirect(&newRect)))
628  {
629  if (CombineRgn(rgn1, rgn2, rgn1, RGN_XOR) != ERROR)
630  {
631  InvalidateRgn(GuiData->hWindow, rgn1, FALSE);
632  }
633  DeleteObject(rgn2);
634  }
635  DeleteObject(rgn1);
636  }
637  }
638  }
639  else
640  {
641  InvalidateRect(GuiData->hWindow, &newRect, FALSE);
642  }
643  Console->Selection.dwFlags |= CONSOLE_SELECTION_NOT_EMPTY;
644  Console->Selection.srSelection = rc;
645  Console->dwSelectionCursor = *coord;
647  }
648  else
649  {
650  /* clear the selection */
651  if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
652  {
653  InvalidateRect(GuiData->hWindow, &oldRect, FALSE);
654  }
655  Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
657  }
658 }
659 
660 
661 VOID
663  PGUI_CONSOLE_DATA GuiData,
664  HDC hDC,
665  PRECT rc);
666 VOID
668  PGUI_CONSOLE_DATA GuiData,
669  HDC hDC,
670  PRECT rc);
671 
672 static VOID
674 {
675  BOOL Success = TRUE;
676  PCONSOLE Console = GuiData->Console;
677  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
678  HDC hDC;
679  PAINTSTRUCT ps;
680 
682  {
683  Success = FALSE;
684  goto Quit;
685  }
686  ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
687 
688  hDC = BeginPaint(GuiData->hWindow, &ps);
689  if (hDC != NULL &&
690  ps.rcPaint.left < ps.rcPaint.right &&
691  ps.rcPaint.top < ps.rcPaint.bottom)
692  {
693  EnterCriticalSection(&GuiData->Lock);
694 
695  if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
696  {
698  GuiData, hDC, &ps.rcPaint);
699  }
700  else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
701  {
703  GuiData, hDC, &ps.rcPaint);
704  }
705 
706  if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
707  {
708  RECT rc;
709  SmallRectToRect(GuiData, &rc, &Console->Selection.srSelection);
710 
711  /* invert the selection */
712  if (IntersectRect(&rc, &ps.rcPaint, &rc))
713  {
714  PatBlt(hDC,
715  rc.left,
716  rc.top,
717  rc.right - rc.left,
718  rc.bottom - rc.top,
719  DSTINVERT);
720  }
721  }
722 
723  LeaveCriticalSection(&GuiData->Lock);
724  }
725  EndPaint(GuiData->hWindow, &ps);
726 
727 Quit:
728  if (Success)
730  else
731  DefWindowProcW(GuiData->hWindow, WM_PAINT, 0, 0);
732 
733  return;
734 }
735 
736 static BOOL
737 IsSystemKey(WORD VirtualKeyCode)
738 {
739  switch (VirtualKeyCode)
740  {
741  /* From MSDN, "Virtual-Key Codes" */
742  case VK_RETURN:
743  case VK_SHIFT:
744  case VK_CONTROL:
745  case VK_MENU:
746  case VK_PAUSE:
747  case VK_CAPITAL:
748  case VK_ESCAPE:
749  case VK_LWIN:
750  case VK_RWIN:
751  case VK_NUMLOCK:
752  case VK_SCROLL:
753  return TRUE;
754  default:
755  return FALSE;
756  }
757 }
758 
759 static VOID
761 {
762  PCONSOLE Console = GuiData->Console;
763  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
764 
766 
767  ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
768 
769  if (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS)
770  {
771  WORD VirtualKeyCode = LOWORD(wParam);
772 
773  if (msg != WM_KEYDOWN) goto Quit;
774 
775  if (VirtualKeyCode == VK_RETURN)
776  {
777  /* Copy (and clear) selection if ENTER is pressed */
778  GuiConsoleCopy(GuiData);
779  goto Quit;
780  }
781  else if ( VirtualKeyCode == VK_ESCAPE ||
782  (VirtualKeyCode == 'C' && GetKeyState(VK_CONTROL) & 0x8000) )
783  {
784  /* Cancel selection if ESC or Ctrl-C are pressed */
786  SetWindowText(GuiData->hWindow, Console->Title.Buffer);
787 
788  goto Quit;
789  }
790 
791  if ((Console->Selection.dwFlags & CONSOLE_MOUSE_SELECTION) == 0)
792  {
793  /* Keyboard selection mode */
794  BOOL Interpreted = FALSE;
795  BOOL MajPressed = (GetKeyState(VK_SHIFT) & 0x8000);
796 
797  switch (VirtualKeyCode)
798  {
799  case VK_LEFT:
800  {
801  Interpreted = TRUE;
802  if (Console->dwSelectionCursor.X > 0)
803  Console->dwSelectionCursor.X--;
804 
805  break;
806  }
807 
808  case VK_RIGHT:
809  {
810  Interpreted = TRUE;
811  if (Console->dwSelectionCursor.X < ActiveBuffer->ScreenBufferSize.X - 1)
812  Console->dwSelectionCursor.X++;
813 
814  break;
815  }
816 
817  case VK_UP:
818  {
819  Interpreted = TRUE;
820  if (Console->dwSelectionCursor.Y > 0)
821  Console->dwSelectionCursor.Y--;
822 
823  break;
824  }
825 
826  case VK_DOWN:
827  {
828  Interpreted = TRUE;
829  if (Console->dwSelectionCursor.Y < ActiveBuffer->ScreenBufferSize.Y - 1)
830  Console->dwSelectionCursor.Y++;
831 
832  break;
833  }
834 
835  case VK_HOME:
836  {
837  Interpreted = TRUE;
838  Console->dwSelectionCursor.X = 0;
839  Console->dwSelectionCursor.Y = 0;
840  break;
841  }
842 
843  case VK_END:
844  {
845  Interpreted = TRUE;
846  Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
847  break;
848  }
849 
850  case VK_PRIOR:
851  {
852  Interpreted = TRUE;
853  Console->dwSelectionCursor.Y -= ActiveBuffer->ViewSize.Y;
854  if (Console->dwSelectionCursor.Y < 0)
855  Console->dwSelectionCursor.Y = 0;
856 
857  break;
858  }
859 
860  case VK_NEXT:
861  {
862  Interpreted = TRUE;
863  Console->dwSelectionCursor.Y += ActiveBuffer->ViewSize.Y;
864  if (Console->dwSelectionCursor.Y >= ActiveBuffer->ScreenBufferSize.Y)
865  Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
866 
867  break;
868  }
869 
870  default:
871  break;
872  }
873 
874  if (Interpreted)
875  {
876  if (!MajPressed)
877  Console->Selection.dwSelectionAnchor = Console->dwSelectionCursor;
878 
879  GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
880  }
881  else if (!IsSystemKey(VirtualKeyCode))
882  {
883  /* Emit an error beep sound */
884  SendNotifyMessage(GuiData->hWindow, PM_CONSOLE_BEEP, 0, 0);
885  }
886 
887  goto Quit;
888  }
889  else
890  {
891  /* Mouse selection mode */
892 
893  if (!IsSystemKey(VirtualKeyCode))
894  {
895  /* Clear the selection and send the key into the input buffer */
897  SetWindowText(GuiData->hWindow, Console->Title.Buffer);
898  }
899  else
900  {
901  goto Quit;
902  }
903  }
904  }
905 
906  if ((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) == 0)
907  {
908  MSG Message;
909 
910  Message.hwnd = GuiData->hWindow;
911  Message.message = msg;
912  Message.wParam = wParam;
913  Message.lParam = lParam;
914 
916  }
917 
918 Quit:
920 }
921 
922 static VOID
924 {
925  SMALL_RECT CellRect = { x, y, x, y };
926  GuiDrawRegion(This, &CellRect);
927 }
928 
929 static VOID
931 {
932  PCONSOLE Console = GuiData->Console;
934 
936 
938 
940 
941  if (GetType(Buff) == TEXTMODE_BUFFER)
942  {
943  GuiInvalidateCell(&Console->TermIFace, Buff->CursorPosition.X, Buff->CursorPosition.Y);
944  Buff->CursorBlinkOn = !Buff->CursorBlinkOn;
945 
946  if ((GuiData->OldCursor.x != Buff->CursorPosition.X) || (GuiData->OldCursor.y != Buff->CursorPosition.Y))
947  {
948  SCROLLINFO xScroll;
949  int OldScrollX = -1, OldScrollY = -1;
950  int NewScrollX = -1, NewScrollY = -1;
951 
952  xScroll.cbSize = sizeof(SCROLLINFO);
953  xScroll.fMask = SIF_POS;
954  // Capture the original position of the scroll bars and save them.
955  if (GetScrollInfo(GuiData->hWindow, SB_HORZ, &xScroll)) OldScrollX = xScroll.nPos;
956  if (GetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll)) OldScrollY = xScroll.nPos;
957 
958  // If we successfully got the info for the horizontal scrollbar
959  if (OldScrollX >= 0)
960  {
961  if ((Buff->CursorPosition.X < Buff->ViewOrigin.X) || (Buff->CursorPosition.X >= (Buff->ViewOrigin.X + Buff->ViewSize.X)))
962  {
963  // Handle the horizontal scroll bar
964  if (Buff->CursorPosition.X >= Buff->ViewSize.X) NewScrollX = Buff->CursorPosition.X - Buff->ViewSize.X + 1;
965  else NewScrollX = 0;
966  }
967  else
968  {
969  NewScrollX = OldScrollX;
970  }
971  }
972  // If we successfully got the info for the vertical scrollbar
973  if (OldScrollY >= 0)
974  {
975  if ((Buff->CursorPosition.Y < Buff->ViewOrigin.Y) || (Buff->CursorPosition.Y >= (Buff->ViewOrigin.Y + Buff->ViewSize.Y)))
976  {
977  // Handle the vertical scroll bar
978  if (Buff->CursorPosition.Y >= Buff->ViewSize.Y) NewScrollY = Buff->CursorPosition.Y - Buff->ViewSize.Y + 1;
979  else NewScrollY = 0;
980  }
981  else
982  {
983  NewScrollY = OldScrollY;
984  }
985  }
986 
987  // Adjust scroll bars and refresh the window if the cursor has moved outside the visible area
988  // NOTE: OldScroll# and NewScroll# will both be -1 (initial value) if the info for the respective scrollbar
989  // was not obtained successfully in the previous steps. This means their difference is 0 (no scrolling)
990  // and their associated scrollbar is left alone.
991  if ((OldScrollX != NewScrollX) || (OldScrollY != NewScrollY))
992  {
993  Buff->ViewOrigin.X = NewScrollX;
994  Buff->ViewOrigin.Y = NewScrollY;
995  ScrollWindowEx(GuiData->hWindow,
996  (OldScrollX - NewScrollX) * GuiData->CharWidth,
997  (OldScrollY - NewScrollY) * GuiData->CharHeight,
998  NULL,
999  NULL,
1000  NULL,
1001  NULL,
1002  SW_INVALIDATE);
1003  if (NewScrollX >= 0)
1004  {
1005  xScroll.nPos = NewScrollX;
1006  SetScrollInfo(GuiData->hWindow, SB_HORZ, &xScroll, TRUE);
1007  }
1008  if (NewScrollY >= 0)
1009  {
1010  xScroll.nPos = NewScrollY;
1011  SetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll, TRUE);
1012  }
1013  UpdateWindow(GuiData->hWindow);
1014  GuiData->OldCursor.x = Buff->CursorPosition.X;
1015  GuiData->OldCursor.y = Buff->CursorPosition.Y;
1016  }
1017  }
1018  }
1019  else /* if (GetType(Buff) == GRAPHICS_BUFFER) */
1020  {
1021  }
1022 
1023  LeaveCriticalSection(&Console->Lock);
1024 }
1025 
1026 static BOOL
1028 {
1029  PCONSOLE Console = GuiData->Console;
1030 
1032  return TRUE;
1033 
1034  // TODO: Prompt for termination ? (Warn the user about possible apps running in this console)
1035 
1036  /*
1037  * FIXME: Windows will wait up to 5 seconds for the thread to exit.
1038  * We shouldn't wait here, though, since the console lock is entered.
1039  * A copy of the thread list probably needs to be made.
1040  */
1042 
1043  LeaveCriticalSection(&Console->Lock);
1044  return FALSE;
1045 }
1046 
1047 static LRESULT
1049 {
1052 
1053  /* Free the GuiData registration */
1055 
1056  return DefWindowProcW(hWnd, WM_NCDESTROY, 0, 0);
1057 }
1058 
1059 static COORD
1061 {
1062  PCONSOLE Console = GuiData->Console;
1064  COORD Coord;
1065  UINT WidthUnit, HeightUnit;
1066 
1067  GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
1068 
1069  Coord.X = Buffer->ViewOrigin.X + ((SHORT)LOWORD(lParam) / (int)WidthUnit );
1070  Coord.Y = Buffer->ViewOrigin.Y + ((SHORT)HIWORD(lParam) / (int)HeightUnit);
1071 
1072  /* Clip coordinate to ensure it's inside buffer */
1073  if (Coord.X < 0)
1074  Coord.X = 0;
1075  else if (Coord.X >= Buffer->ScreenBufferSize.X)
1076  Coord.X = Buffer->ScreenBufferSize.X - 1;
1077 
1078  if (Coord.Y < 0)
1079  Coord.Y = 0;
1080  else if (Coord.Y >= Buffer->ScreenBufferSize.Y)
1081  Coord.Y = Buffer->ScreenBufferSize.Y - 1;
1082 
1083  return Coord;
1084 }
1085 
1086 static LRESULT
1088 {
1089  BOOL Err = FALSE;
1090  PCONSOLE Console = GuiData->Console;
1091 
1092  if (GuiData->IgnoreNextMouseSignal)
1093  {
1094  if (msg != WM_LBUTTONDOWN &&
1095  msg != WM_MBUTTONDOWN &&
1096  msg != WM_RBUTTONDOWN)
1097  {
1098  /*
1099  * If this mouse signal is not a button-down action,
1100  * then it is the last signal being ignored.
1101  */
1102  GuiData->IgnoreNextMouseSignal = FALSE;
1103  }
1104  else
1105  {
1106  /*
1107  * This mouse signal is a button-down action.
1108  * Ignore it and perform default action.
1109  */
1110  Err = TRUE;
1111  }
1112  goto Quit;
1113  }
1114 
1116  {
1117  Err = TRUE;
1118  goto Quit;
1119  }
1120 
1121  if ( (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) ||
1122  (Console->QuickEdit) )
1123  {
1124  switch (msg)
1125  {
1126  case WM_LBUTTONDOWN:
1127  {
1128  LPWSTR WindowTitle = NULL;
1129  SIZE_T Length = 0;
1130 
1131  Console->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam);
1132  SetCapture(GuiData->hWindow);
1134  GuiConsoleUpdateSelection(Console, &Console->Selection.dwSelectionAnchor);
1135 
1136  Length = Console->Title.Length + sizeof(L"Selection - ")/sizeof(WCHAR) + 1;
1137  WindowTitle = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
1138  wcscpy(WindowTitle, L"Selection - ");
1139  wcscat(WindowTitle, Console->Title.Buffer);
1140  SetWindowText(GuiData->hWindow, WindowTitle);
1141  ConsoleFreeHeap(WindowTitle);
1142 
1143  break;
1144  }
1145 
1146  case WM_LBUTTONUP:
1147  {
1148  COORD c;
1149 
1150  if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1151 
1152  c = PointToCoord(GuiData, lParam);
1153  Console->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
1155  ReleaseCapture();
1156 
1157  break;
1158  }
1159 
1160  case WM_LBUTTONDBLCLK:
1161  {
1162  DPRINT1("Handle left-double-click for selecting a word\n");
1163  break;
1164  }
1165 
1166  case WM_RBUTTONDOWN:
1167  case WM_RBUTTONDBLCLK:
1168  {
1169  if (!(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
1170  {
1171  GuiConsolePaste(GuiData);
1172  }
1173  else
1174  {
1175  GuiConsoleCopy(GuiData);
1176  }
1177 
1178  GuiData->IgnoreNextMouseSignal = TRUE;
1179  break;
1180  }
1181 
1182  case WM_MOUSEMOVE:
1183  {
1184  COORD c;
1185 
1186  if (!(wParam & MK_LBUTTON)) break;
1187  if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) break;
1188 
1189  c = PointToCoord(GuiData, lParam); /* TODO: Scroll buffer to bring c into view */
1191 
1192  break;
1193  }
1194 
1195  default:
1196  Err = FALSE; // TRUE;
1197  break;
1198  }
1199  }
1200  else if (Console->InputBuffer.Mode & ENABLE_MOUSE_INPUT)
1201  {
1202  INPUT_RECORD er;
1203  WORD wKeyState = GET_KEYSTATE_WPARAM(wParam);
1204  DWORD dwButtonState = 0;
1205  DWORD dwControlKeyState = 0;
1206  DWORD dwEventFlags = 0;
1207 
1208  switch (msg)
1209  {
1210  case WM_LBUTTONDOWN:
1211  SetCapture(GuiData->hWindow);
1212  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1213  dwEventFlags = 0;
1214  break;
1215 
1216  case WM_MBUTTONDOWN:
1217  SetCapture(GuiData->hWindow);
1218  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1219  dwEventFlags = 0;
1220  break;
1221 
1222  case WM_RBUTTONDOWN:
1223  SetCapture(GuiData->hWindow);
1224  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1225  dwEventFlags = 0;
1226  break;
1227 
1228  case WM_LBUTTONUP:
1229  ReleaseCapture();
1230  dwButtonState = 0;
1231  dwEventFlags = 0;
1232  break;
1233 
1234  case WM_MBUTTONUP:
1235  ReleaseCapture();
1236  dwButtonState = 0;
1237  dwEventFlags = 0;
1238  break;
1239 
1240  case WM_RBUTTONUP:
1241  ReleaseCapture();
1242  dwButtonState = 0;
1243  dwEventFlags = 0;
1244  break;
1245 
1246  case WM_LBUTTONDBLCLK:
1247  dwButtonState = FROM_LEFT_1ST_BUTTON_PRESSED;
1248  dwEventFlags = DOUBLE_CLICK;
1249  break;
1250 
1251  case WM_MBUTTONDBLCLK:
1252  dwButtonState = FROM_LEFT_2ND_BUTTON_PRESSED;
1253  dwEventFlags = DOUBLE_CLICK;
1254  break;
1255 
1256  case WM_RBUTTONDBLCLK:
1257  dwButtonState = RIGHTMOST_BUTTON_PRESSED;
1258  dwEventFlags = DOUBLE_CLICK;
1259  break;
1260 
1261  case WM_MOUSEMOVE:
1262  dwButtonState = 0;
1263  dwEventFlags = MOUSE_MOVED;
1264  break;
1265 
1266  case WM_MOUSEWHEEL:
1267  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1268  dwEventFlags = MOUSE_WHEELED;
1269  break;
1270 
1271  case WM_MOUSEHWHEEL:
1272  dwButtonState = GET_WHEEL_DELTA_WPARAM(wParam) << 16;
1273  dwEventFlags = MOUSE_HWHEELED;
1274  break;
1275 
1276  default:
1277  Err = TRUE;
1278  break;
1279  }
1280 
1281  if (!Err)
1282  {
1283  if (wKeyState & MK_LBUTTON)
1284  dwButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
1285  if (wKeyState & MK_MBUTTON)
1286  dwButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
1287  if (wKeyState & MK_RBUTTON)
1288  dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
1289 
1290  if (GetKeyState(VK_RMENU) & 0x8000)
1291  dwControlKeyState |= RIGHT_ALT_PRESSED;
1292  if (GetKeyState(VK_LMENU) & 0x8000)
1293  dwControlKeyState |= LEFT_ALT_PRESSED;
1294  if (GetKeyState(VK_RCONTROL) & 0x8000)
1295  dwControlKeyState |= RIGHT_CTRL_PRESSED;
1296  if (GetKeyState(VK_LCONTROL) & 0x8000)
1297  dwControlKeyState |= LEFT_CTRL_PRESSED;
1298  if (GetKeyState(VK_SHIFT) & 0x8000)
1299  dwControlKeyState |= SHIFT_PRESSED;
1300  if (GetKeyState(VK_NUMLOCK) & 0x0001)
1301  dwControlKeyState |= NUMLOCK_ON;
1302  if (GetKeyState(VK_SCROLL) & 0x0001)
1303  dwControlKeyState |= SCROLLLOCK_ON;
1304  if (GetKeyState(VK_CAPITAL) & 0x0001)
1305  dwControlKeyState |= CAPSLOCK_ON;
1306  /* See WM_CHAR MSDN documentation for instance */
1307  if (lParam & 0x01000000)
1308  dwControlKeyState |= ENHANCED_KEY;
1309 
1310  er.EventType = MOUSE_EVENT;
1312  er.Event.MouseEvent.dwButtonState = dwButtonState;
1313  er.Event.MouseEvent.dwControlKeyState = dwControlKeyState;
1314  er.Event.MouseEvent.dwEventFlags = dwEventFlags;
1315 
1317  }
1318  }
1319  else
1320  {
1321  Err = TRUE;
1322  }
1323 
1324  LeaveCriticalSection(&Console->Lock);
1325 
1326 Quit:
1327  if (Err)
1328  return DefWindowProcW(GuiData->hWindow, msg, wParam, lParam);
1329  else
1330  return 0;
1331 }
1332 
1335 
1336 static VOID
1338 {
1339  if (OpenClipboard(GuiData->hWindow))
1340  {
1341  PCONSOLE Console = GuiData->Console;
1343 
1344  if (GetType(Buffer) == TEXTMODE_BUFFER)
1345  {
1347  }
1348  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
1349  {
1351  }
1352 
1353  CloseClipboard();
1354 
1355  /* Clear the selection */
1357  SetWindowText(GuiData->hWindow, Console->Title.Buffer);
1358  }
1359 }
1360 
1363 
1364 static VOID
1366 {
1367  if (OpenClipboard(GuiData->hWindow))
1368  {
1369  PCONSOLE Console = GuiData->Console;
1371 
1372  if (GetType(Buffer) == TEXTMODE_BUFFER)
1373  {
1375  }
1376  else /* if (GetType(Buffer) == GRAPHICS_BUFFER) */
1377  {
1379  }
1380 
1381  CloseClipboard();
1382  }
1383 }
1384 
1385 static VOID
1387 {
1388  PCONSOLE Console = GuiData->Console;
1389  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
1390  DWORD windx, windy;
1391  UINT WidthUnit, HeightUnit;
1392 
1394 
1395  ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
1396 
1397  GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
1398 
1399  windx = CONGUI_MIN_WIDTH * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
1401 
1402  minMaxInfo->ptMinTrackSize.x = windx;
1403  minMaxInfo->ptMinTrackSize.y = windy;
1404 
1405  windx = (ActiveBuffer->ScreenBufferSize.X) * WidthUnit + 2 * (GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
1406  windy = (ActiveBuffer->ScreenBufferSize.Y) * HeightUnit + 2 * (GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) + GetSystemMetrics(SM_CYCAPTION);
1407 
1408  if (ActiveBuffer->ViewSize.X < ActiveBuffer->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // window currently has a horizontal scrollbar
1409  if (ActiveBuffer->ViewSize.Y < ActiveBuffer->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // window currently has a vertical scrollbar
1410 
1411  minMaxInfo->ptMaxTrackSize.x = windx;
1412  minMaxInfo->ptMaxTrackSize.y = windy;
1413 
1414  LeaveCriticalSection(&Console->Lock);
1415 }
1416 
1417 static VOID
1419 {
1420  PCONSOLE Console = GuiData->Console;
1421 
1423 
1424  if ((GuiData->WindowSizeLock == FALSE) &&
1426  {
1428  DWORD windx, windy, charx, chary;
1429  UINT WidthUnit, HeightUnit;
1430 
1431  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
1432 
1433  GuiData->WindowSizeLock = TRUE;
1434 
1435  windx = LOWORD(lParam);
1436  windy = HIWORD(lParam);
1437 
1438  // Compensate for existing scroll bars (because lParam values do not accommodate scroll bar)
1439  if (Buff->ViewSize.X < Buff->ScreenBufferSize.X) windy += GetSystemMetrics(SM_CYHSCROLL); // window currently has a horizontal scrollbar
1440  if (Buff->ViewSize.Y < Buff->ScreenBufferSize.Y) windx += GetSystemMetrics(SM_CXVSCROLL); // window currently has a vertical scrollbar
1441 
1442  charx = windx / (int)WidthUnit ;
1443  chary = windy / (int)HeightUnit;
1444 
1445  // Character alignment (round size up or down)
1446  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
1447  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
1448 
1449  // Compensate for added scroll bars in new window
1450  if (charx < Buff->ScreenBufferSize.X) windy -= GetSystemMetrics(SM_CYHSCROLL); // new window will have a horizontal scroll bar
1451  if (chary < Buff->ScreenBufferSize.Y) windx -= GetSystemMetrics(SM_CXVSCROLL); // new window will have a vertical scroll bar
1452 
1453  charx = windx / (int)WidthUnit ;
1454  chary = windy / (int)HeightUnit;
1455 
1456  // Character alignment (round size up or down)
1457  if ((windx % WidthUnit ) >= (WidthUnit / 2)) ++charx;
1458  if ((windy % HeightUnit) >= (HeightUnit / 2)) ++chary;
1459 
1460  // Resize window
1461  if ((charx != Buff->ViewSize.X) || (chary != Buff->ViewSize.Y))
1462  {
1463  Buff->ViewSize.X = (charx <= Buff->ScreenBufferSize.X) ? charx : Buff->ScreenBufferSize.X;
1464  Buff->ViewSize.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary : Buff->ScreenBufferSize.Y;
1465  }
1466 
1467  GuiConsoleResizeWindow(GuiData);
1468 
1469  // Adjust the start of the visible area if we are attempting to show nonexistent areas
1470  if ((Buff->ScreenBufferSize.X - Buff->ViewOrigin.X) < Buff->ViewSize.X) Buff->ViewOrigin.X = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
1471  if ((Buff->ScreenBufferSize.Y - Buff->ViewOrigin.Y) < Buff->ViewSize.Y) Buff->ViewOrigin.Y = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
1472  InvalidateRect(GuiData->hWindow, NULL, TRUE);
1473 
1474  GuiData->WindowSizeLock = FALSE;
1475  }
1476 
1477  LeaveCriticalSection(&Console->Lock);
1478 }
1479 
1480 /*
1481 // HACK: This functionality is standard for general scrollbars. Don't add it by hand.
1482 
1483 VOID
1484 FASTCALL
1485 GuiConsoleHandleScrollbarMenu(VOID)
1486 {
1487  HMENU hMenu;
1488 
1489  hMenu = CreatePopupMenu();
1490  if (hMenu == NULL)
1491  {
1492  DPRINT("CreatePopupMenu failed\n");
1493  return;
1494  }
1495 
1496  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLHERE);
1497  //InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
1498  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLTOP);
1499  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLBOTTOM);
1500  //InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
1501  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLPAGE_UP);
1502  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLPAGE_DOWN);
1503  //InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
1504  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLUP);
1505  //InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL, IDS_SCROLLDOWN);
1506 }
1507 */
1508 
1509 static LRESULT
1511 {
1512  PCONSOLE Console = GuiData->Console;
1514  SCROLLINFO sInfo;
1515  int fnBar;
1516  int old_pos, Maximum;
1517  PSHORT pShowXY;
1518 
1520 
1522 
1523  if (uMsg == WM_HSCROLL)
1524  {
1525  fnBar = SB_HORZ;
1526  Maximum = Buff->ScreenBufferSize.X - Buff->ViewSize.X;
1527  pShowXY = &Buff->ViewOrigin.X;
1528  }
1529  else
1530  {
1531  fnBar = SB_VERT;
1532  Maximum = Buff->ScreenBufferSize.Y - Buff->ViewSize.Y;
1533  pShowXY = &Buff->ViewOrigin.Y;
1534  }
1535 
1536  /* set scrollbar sizes */
1537  sInfo.cbSize = sizeof(SCROLLINFO);
1539 
1540  if (!GetScrollInfo(GuiData->hWindow, fnBar, &sInfo)) goto Quit;
1541 
1542  old_pos = sInfo.nPos;
1543 
1544  switch (LOWORD(wParam))
1545  {
1546  case SB_LINELEFT:
1547  sInfo.nPos -= 1;
1548  break;
1549 
1550  case SB_LINERIGHT:
1551  sInfo.nPos += 1;
1552  break;
1553 
1554  case SB_PAGELEFT:
1555  sInfo.nPos -= sInfo.nPage;
1556  break;
1557 
1558  case SB_PAGERIGHT:
1559  sInfo.nPos += sInfo.nPage;
1560  break;
1561 
1562  case SB_THUMBTRACK:
1563  sInfo.nPos = sInfo.nTrackPos;
1565  break;
1566 
1567  case SB_THUMBPOSITION:
1569  break;
1570 
1571  case SB_TOP:
1572  sInfo.nPos = sInfo.nMin;
1573  break;
1574 
1575  case SB_BOTTOM:
1576  sInfo.nPos = sInfo.nMax;
1577  break;
1578 
1579  default:
1580  break;
1581  }
1582 
1583  sInfo.nPos = max(sInfo.nPos, 0);
1584  sInfo.nPos = min(sInfo.nPos, Maximum);
1585 
1586  if (old_pos != sInfo.nPos)
1587  {
1588  USHORT OldX = Buff->ViewOrigin.X;
1589  USHORT OldY = Buff->ViewOrigin.Y;
1590  UINT WidthUnit, HeightUnit;
1591 
1592  *pShowXY = sInfo.nPos;
1593 
1594  GetScreenBufferSizeUnits(Buff, GuiData, &WidthUnit, &HeightUnit);
1595 
1596  ScrollWindowEx(GuiData->hWindow,
1597  (OldX - Buff->ViewOrigin.X) * WidthUnit ,
1598  (OldY - Buff->ViewOrigin.Y) * HeightUnit,
1599  NULL,
1600  NULL,
1601  NULL,
1602  NULL,
1603  SW_INVALIDATE);
1604 
1605  sInfo.fMask = SIF_POS;
1606  SetScrollInfo(GuiData->hWindow, fnBar, &sInfo, TRUE);
1607 
1608  UpdateWindow(GuiData->hWindow);
1609  }
1610 
1611 Quit:
1612  LeaveCriticalSection(&Console->Lock);
1613  return 0;
1614 }
1615 
1616 static LRESULT CALLBACK
1618 {
1619  LRESULT Result = 0;
1620  PGUI_CONSOLE_DATA GuiData = NULL;
1621  PCONSOLE Console = NULL;
1622 
1623  /*
1624  * - If it's the first time we create a window for the terminal,
1625  * just initialize it and return.
1626  *
1627  * - If we are destroying the window, just do it and return.
1628  */
1629  if (msg == WM_NCCREATE)
1630  {
1632  }
1633  else if (msg == WM_NCDESTROY)
1634  {
1636  }
1637 
1638  /*
1639  * Now the terminal window is initialized.
1640  * Get the terminal data via the window's data.
1641  * If there is no data, just go away.
1642  */
1643  GuiData = GuiGetGuiData(hWnd);
1644  if (GuiData == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
1645 
1646  /*
1647  * Just retrieve a pointer to the console in case somebody needs it.
1648  * It is not NULL because it was checked in GuiGetGuiData.
1649  * Each helper function which needs the console has to validate and lock it.
1650  */
1651  Console = GuiData->Console;
1652 
1653  /* We have a console, start message dispatching */
1654  switch (msg)
1655  {
1656  case WM_ACTIVATE:
1657  {
1659  break;
1660  }
1661 
1662  case WM_CLOSE:
1663  if (GuiConsoleHandleClose(GuiData)) goto Default;
1664  break;
1665 
1666  case WM_PAINT:
1667  GuiConsoleHandlePaint(GuiData);
1668  break;
1669 
1670  case WM_KEYDOWN:
1671  case WM_KEYUP:
1672  case WM_CHAR:
1673  case WM_DEADCHAR:
1674  case WM_SYSKEYDOWN:
1675  case WM_SYSKEYUP:
1676  case WM_SYSCHAR:
1677  case WM_SYSDEADCHAR:
1678  {
1679  /* Detect Alt-Enter presses and switch back and forth to fullscreen mode */
1680  if (msg == WM_SYSKEYDOWN && (HIWORD(lParam) & KF_ALTDOWN) && wParam == VK_RETURN)
1681  {
1682  /* Switch only at first Alt-Enter press, and ignore subsequent key repetitions */
1684  break;
1685  }
1686 
1687  GuiConsoleHandleKey(GuiData, msg, wParam, lParam);
1688  break;
1689  }
1690 
1691  case WM_TIMER:
1692  GuiConsoleHandleTimer(GuiData);
1693  break;
1694 
1695  case WM_SETCURSOR:
1696  {
1697  /*
1698  * The message was sent because we are manually triggering a change.
1699  * Check whether the mouse is indeed present on this console window
1700  * and take appropriate decisions.
1701  */
1702  if (wParam == -1 && lParam == -1)
1703  {
1704  POINT mouseCoords;
1705  HWND hWndHit;
1706 
1707  /* Get the placement of the mouse */
1708  GetCursorPos(&mouseCoords);
1709 
1710  /* On which window is placed the mouse ? */
1711  hWndHit = WindowFromPoint(mouseCoords);
1712 
1713  /* It's our window. Perform the hit-test to be used later on. */
1714  if (hWndHit == hWnd)
1715  {
1716  wParam = (WPARAM)hWnd;
1717  lParam = DefWindowProcW(hWndHit, WM_NCHITTEST, 0,
1718  MAKELPARAM(mouseCoords.x, mouseCoords.y));
1719  }
1720  }
1721 
1722  /* Set the mouse cursor only when we are in the client area */
1723  if ((HWND)wParam == hWnd && LOWORD(lParam) == HTCLIENT)
1724  {
1725  if (GuiData->MouseCursorRefCount >= 0)
1726  {
1727  /* Show the cursor */
1728  SetCursor(GuiData->hCursor);
1729  }
1730  else
1731  {
1732  /* Hide the cursor if the reference count is negative */
1733  SetCursor(NULL);
1734  }
1735  return TRUE;
1736  }
1737  else
1738  {
1739  goto Default;
1740  }
1741  }
1742 
1743  case WM_LBUTTONDOWN:
1744  case WM_MBUTTONDOWN:
1745  case WM_RBUTTONDOWN:
1746  case WM_LBUTTONUP:
1747  case WM_MBUTTONUP:
1748  case WM_RBUTTONUP:
1749  case WM_LBUTTONDBLCLK:
1750  case WM_MBUTTONDBLCLK:
1751  case WM_RBUTTONDBLCLK:
1752  case WM_MOUSEMOVE:
1753  case WM_MOUSEWHEEL:
1754  case WM_MOUSEHWHEEL:
1755  {
1757  break;
1758  }
1759 
1760  case WM_HSCROLL:
1761  case WM_VSCROLL:
1762  {
1763  Result = GuiConsoleHandleScroll(GuiData, msg, wParam);
1764  break;
1765  }
1766 
1767  case WM_NCRBUTTONDOWN:
1768  {
1769  DPRINT1("WM_NCRBUTTONDOWN\n");
1770  /*
1771  * HACK: !! Because, when we deal with WM_RBUTTON* and we do not
1772  * call after that DefWindowProc, on ReactOS, right-clicks on the
1773  * (non-client) application title-bar does not display the system
1774  * menu and does not trigger a WM_NCRBUTTONUP message too.
1775  * See: http://git.reactos.org/?p=reactos.git;a=blob;f=reactos/win32ss/user/user32/windows/defwnd.c;hb=HEAD#l1103
1776  * and line 1135 too.
1777  */
1779  {
1780  /* Call DefWindowProcW with the WM_CONTEXTMENU message */
1781  msg = WM_CONTEXTMENU;
1782  }
1783  goto Default;
1784  }
1785  // case WM_NCRBUTTONUP:
1786  // DPRINT1("WM_NCRBUTTONUP\n");
1787  // goto Default;
1788 
1789  case WM_CONTEXTMENU:
1790  {
1791  if (DefWindowProcW(hWnd /*GuiData->hWindow*/, WM_NCHITTEST, 0, lParam) == HTCLIENT)
1792  {
1793  HMENU hMenu = CreatePopupMenu();
1794  if (hMenu != NULL)
1795  {
1797  TrackPopupMenuEx(hMenu,
1801  hWnd,
1802  NULL);
1803  DestroyMenu(hMenu);
1804  }
1805  break;
1806  }
1807  else
1808  {
1809  goto Default;
1810  }
1811  }
1812 
1813  case WM_INITMENU:
1814  {
1815  HMENU hMenu = (HMENU)wParam;
1816  if (hMenu != NULL)
1817  {
1818  /* Enable or disable the Close menu item */
1820  (GuiData->IsCloseButtonEnabled ? MF_ENABLED : MF_GRAYED));
1821 
1822  /* Enable or disable the Copy and Paste items */
1824  ((Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
1825  (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY) ? MF_ENABLED : MF_GRAYED));
1827  (!(Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS) &&
1829  }
1830 
1832  {
1834  LeaveCriticalSection(&Console->Lock);
1835  }
1836  break;
1837  }
1838 
1839  case WM_MENUSELECT:
1840  {
1841  if (HIWORD(wParam) == 0xFFFF) // Allow all the menu flags
1842  {
1844  {
1846  LeaveCriticalSection(&Console->Lock);
1847  }
1848  }
1849  break;
1850  }
1851 
1852  case WM_COMMAND:
1853  case WM_SYSCOMMAND:
1854  {
1856  break;
1857  }
1858 
1859  case WM_SETFOCUS:
1860  case WM_KILLFOCUS:
1861  {
1863  {
1864  INPUT_RECORD er;
1865  er.EventType = FOCUS_EVENT;
1868 
1869  if (msg == WM_SETFOCUS)
1870  DPRINT1("TODO: Create console caret\n");
1871  else // if (msg == WM_KILLFOCUS)
1872  DPRINT1("TODO: Destroy console caret\n");
1873 
1874  LeaveCriticalSection(&Console->Lock);
1875  }
1876  break;
1877  }
1878 
1879  case WM_GETMINMAXINFO:
1881  break;
1882 
1883  case WM_SIZE:
1884  GuiConsoleResize(GuiData, wParam, lParam);
1885  break;
1886 
1887  case PM_RESIZE_TERMINAL:
1888  {
1889  /* Resize the window to the user's values */
1890  GuiData->WindowSizeLock = TRUE;
1891  GuiConsoleResizeWindow(GuiData);
1892  GuiData->WindowSizeLock = FALSE;
1893  break;
1894  }
1895 
1896  case PM_APPLY_CONSOLE_INFO:
1897  {
1899  {
1901  LeaveCriticalSection(&Console->Lock);
1902  }
1903  break;
1904  }
1905 
1906  case PM_CONSOLE_BEEP:
1907  DPRINT1("Beep !!\n");
1908  Beep(800, 200);
1909  break;
1910 
1911  // case PM_CONSOLE_SET_TITLE:
1912  // SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer);
1913  // break;
1914 
1915  default: Default:
1917  break;
1918  }
1919 
1920  return Result;
1921 }
1922 
1923 
1924 
1925 /******************************************************************************
1926  * GUI Terminal Initialization *
1927  ******************************************************************************/
1928 
1929 static LRESULT CALLBACK
1931 {
1932  HWND NewWindow;
1933  LONG WindowCount;
1934  MSG Msg;
1935 
1936  switch (msg)
1937  {
1938  case WM_CREATE:
1939  {
1941  return 0;
1942  }
1943 
1944  case PM_CREATE_CONSOLE:
1945  {
1947  PCONSOLE Console = GuiData->Console;
1948 
1949  NewWindow = CreateWindowExW(WS_EX_CLIENTEDGE,
1951  Console->Title.Buffer,
1953  CW_USEDEFAULT,
1954  CW_USEDEFAULT,
1955  CW_USEDEFAULT,
1956  CW_USEDEFAULT,
1957  NULL,
1958  NULL,
1960  (PVOID)GuiData);
1961  if (NULL != NewWindow)
1962  {
1964  WindowCount++;
1966 
1967  DPRINT("Set icons via PM_CREATE_CONSOLE\n");
1968  if (GuiData->hIcon == NULL)
1969  {
1970  DPRINT("Not really /o\\...\n");
1971  GuiData->hIcon = ghDefaultIcon;
1972  GuiData->hIconSm = ghDefaultIconSm;
1973  }
1974  else if (GuiData->hIcon != ghDefaultIcon)
1975  {
1976  DPRINT("Yes \\o/\n");
1977  SendMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG, (LPARAM)GuiData->hIcon);
1978  SendMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
1979  }
1980 
1981  /* Move and resize the window to the user's values */
1982  /* CAN WE DEADLOCK ?? */
1983  GuiConsoleMoveWindow(GuiData);
1984  GuiData->WindowSizeLock = TRUE;
1985  GuiConsoleResizeWindow(GuiData);
1986  GuiData->WindowSizeLock = FALSE;
1987 
1988  // ShowWindow(NewWindow, (int)wParam);
1989  ShowWindowAsync(NewWindow, (int)wParam);
1990  DPRINT("Window showed\n");
1991  }
1992 
1993  return (LRESULT)NewWindow;
1994  }
1995 
1996  case PM_DESTROY_CONSOLE:
1997  {
1999 
2000  /*
2001  * Window creation is done using a PostMessage(), so it's possible
2002  * that the window that we want to destroy doesn't exist yet.
2003  * So first empty the message queue.
2004  */
2005  /*
2006  while (PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE))
2007  {
2008  TranslateMessage(&Msg);
2009  DispatchMessageW(&Msg);
2010  }*/
2011  while (PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE)) ;
2012 
2013  if (GuiData->hWindow != NULL) /* && DestroyWindow(GuiData->hWindow) */
2014  {
2015  DestroyWindow(GuiData->hWindow);
2016 
2018  WindowCount--;
2020  if (0 == WindowCount)
2021  {
2022  NotifyWnd = NULL;
2024  DPRINT("CONSRV: Going to quit the Gui Thread!!\n");
2025  PostQuitMessage(0);
2026  }
2027  }
2028 
2029  return 0;
2030  }
2031 
2032  default:
2033  return DefWindowProcW(hWnd, msg, wParam, lParam);
2034  }
2035 }
2036 
2037 static DWORD WINAPI
2039 {
2040  MSG msg;
2041  PHANDLE GraphicsStartupEvent = (PHANDLE)Data;
2042 
2043  /*
2044  * This thread dispatches all the console notifications to the notify window.
2045  * It is common for all the console windows.
2046  */
2047 
2049 
2050  NotifyWnd = CreateWindowW(L"ConSrvCreateNotify",
2051  L"",
2053  CW_USEDEFAULT,
2054  CW_USEDEFAULT,
2055  CW_USEDEFAULT,
2056  CW_USEDEFAULT,
2057  NULL,
2058  NULL,
2060  NULL);
2061  if (NULL == NotifyWnd)
2062  {
2064  SetEvent(*GraphicsStartupEvent);
2065  return 1;
2066  }
2067 
2068  SetEvent(*GraphicsStartupEvent);
2069 
2070  while (GetMessageW(&msg, NULL, 0, 0))
2071  {
2074  }
2075 
2076  DPRINT("CONSRV: Quit the Gui Thread!!\n");
2078 
2079  return 1;
2080 }
2081 
2082 static BOOL
2084 {
2085  WNDCLASSEXW wc;
2086  ATOM ConsoleClassAtom;
2087 
2088  /* Exit if we were already initialized */
2089  // if (ConsInitialized) return TRUE;
2090 
2091  /*
2092  * Initialize and register the different window classes, if needed.
2093  */
2094  if (!ConsInitialized)
2095  {
2096  /* Initialize the notification window class */
2097  wc.cbSize = sizeof(WNDCLASSEXW);
2098  wc.lpszClassName = L"ConSrvCreateNotify";
2100  wc.style = 0;
2102  wc.hIcon = NULL;
2103  wc.hIconSm = NULL;
2104  wc.hCursor = NULL;
2105  wc.hbrBackground = NULL;
2106  wc.lpszMenuName = NULL;
2107  wc.cbClsExtra = 0;
2108  wc.cbWndExtra = 0;
2109  if (RegisterClassExW(&wc) == 0)
2110  {
2111  DPRINT1("Failed to register GUI notify wndproc\n");
2112  return FALSE;
2113  }
2114 
2115  /* Initialize the console window class */
2118  IMAGE_ICON,
2121  LR_SHARED);
2124  IMAGE_ICON,
2127  LR_SHARED);
2129  wc.cbSize = sizeof(WNDCLASSEXW);
2132  wc.style = CS_DBLCLKS /* | CS_HREDRAW | CS_VREDRAW */;
2134  wc.hIcon = ghDefaultIcon;
2135  wc.hIconSm = ghDefaultIconSm;
2136  wc.hCursor = ghDefaultCursor;
2137  wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); // The color of a terminal when it is switch off.
2138  wc.lpszMenuName = NULL;
2139  wc.cbClsExtra = 0;
2141 
2142  ConsoleClassAtom = RegisterClassExW(&wc);
2143  if (ConsoleClassAtom == 0)
2144  {
2145  DPRINT1("Failed to register GUI console wndproc\n");
2146  return FALSE;
2147  }
2148  else
2149  {
2150  NtUserConsoleControl(GuiConsoleWndClassAtom, &ConsoleClassAtom, sizeof(ATOM));
2151  }
2152 
2154  }
2155 
2156  /*
2157  * Set-up the notification window
2158  */
2159  if (NULL == NotifyWnd)
2160  {
2161  HANDLE ThreadHandle;
2162  HANDLE GraphicsStartupEvent;
2163 
2164  GraphicsStartupEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
2165  if (NULL == GraphicsStartupEvent) return FALSE;
2166 
2167  ThreadHandle = CreateThread(NULL,
2168  0,
2170  (PVOID)&GraphicsStartupEvent,
2171  0,
2172  NULL);
2173  if (NULL == ThreadHandle)
2174  {
2175  CloseHandle(GraphicsStartupEvent);
2176  DPRINT1("CONSRV: Failed to create graphics console thread. Expect problems\n");
2177  return FALSE;
2178  }
2180  CloseHandle(ThreadHandle);
2181 
2182  WaitForSingleObject(GraphicsStartupEvent, INFINITE);
2183  CloseHandle(GraphicsStartupEvent);
2184 
2185  if (NULL == NotifyWnd)
2186  {
2187  DPRINT1("CONSRV: Failed to create notification window.\n");
2188  return FALSE;
2189  }
2190  }
2191 
2192  // ConsInitialized = TRUE;
2193 
2194  return TRUE;
2195 }
2196 
2197 
2198 
2199 /******************************************************************************
2200  * GUI Console Driver *
2201  ******************************************************************************/
2202 
2203 static VOID WINAPI
2205 
2209 {
2210  PGUI_INIT_INFO GuiInitInfo;
2212  PCONSOLE_START_INFO ConsoleStartInfo;
2213 
2214  PGUI_CONSOLE_DATA GuiData;
2215  GUI_CONSOLE_INFO TermInfo;
2216 
2217  SIZE_T Length = 0;
2218  LPWSTR IconPath = NULL;
2219  INT IconIndex = 0;
2220 
2221  if (This == NULL || Console == NULL || This->OldData == NULL)
2222  return STATUS_INVALID_PARAMETER;
2223 
2224  ASSERT(This->Console == Console);
2225 
2226  GuiInitInfo = This->OldData;
2227 
2228  if (GuiInitInfo->ConsoleInfo == NULL || GuiInitInfo->ConsoleStartInfo == NULL)
2229  return STATUS_INVALID_PARAMETER;
2230 
2231  ConsoleInfo = GuiInitInfo->ConsoleInfo;
2232  ConsoleStartInfo = GuiInitInfo->ConsoleStartInfo;
2233 
2234  IconPath = ConsoleStartInfo->IconPath;
2235  IconIndex = ConsoleStartInfo->IconIndex;
2236 
2237 
2238  /* Terminal data allocation */
2240  if (!GuiData)
2241  {
2242  DPRINT1("CONSRV: Failed to create GUI_CONSOLE_DATA\n");
2243  return STATUS_UNSUCCESSFUL;
2244  }
2245  /* HACK */ Console->TermIFace.Data = (PVOID)GuiData; /* HACK */
2246  GuiData->Console = Console;
2247  GuiData->hWindow = NULL;
2248 
2249  /* The console can be resized */
2250  Console->FixedSize = FALSE;
2251 
2252  InitializeCriticalSection(&GuiData->Lock);
2253 
2254 
2255  /*
2256  * Load terminal settings
2257  */
2258 
2259  /* 1. Load the default settings */
2260  GuiConsoleGetDefaultSettings(&TermInfo, GuiInitInfo->ProcessId);
2261 
2262  /* 3. Load the remaining console settings via the registry. */
2263  if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
2264  {
2265  /* Load the terminal infos from the registry. */
2266  GuiConsoleReadUserSettings(&TermInfo,
2267  ConsoleInfo->ConsoleTitle,
2268  GuiInitInfo->ProcessId);
2269 
2270  /*
2271  * Now, update them with the properties the user might gave to us
2272  * via the STARTUPINFO structure before calling CreateProcess
2273  * (and which was transmitted via the ConsoleStartInfo structure).
2274  * We therefore overwrite the values read in the registry.
2275  */
2276  if (ConsoleStartInfo->dwStartupFlags & STARTF_USESHOWWINDOW)
2277  {
2278  TermInfo.ShowWindow = ConsoleStartInfo->ShowWindow;
2279  }
2280  if (ConsoleStartInfo->dwStartupFlags & STARTF_USEPOSITION)
2281  {
2282  TermInfo.AutoPosition = FALSE;
2283  TermInfo.WindowOrigin = ConsoleStartInfo->ConsoleWindowOrigin;
2284  }
2285  if (ConsoleStartInfo->dwStartupFlags & STARTF_RUNFULLSCREEN)
2286  {
2287  TermInfo.FullScreen = TRUE;
2288  }
2289  }
2290 
2291 
2292  /*
2293  * Set up GUI data
2294  */
2295 
2296  Length = min(wcslen(TermInfo.FaceName) + 1, LF_FACESIZE); // wcsnlen
2297  wcsncpy(GuiData->GuiInfo.FaceName, TermInfo.FaceName, LF_FACESIZE);
2298  GuiData->GuiInfo.FaceName[Length] = L'\0';
2299  GuiData->GuiInfo.FontFamily = TermInfo.FontFamily;
2300  GuiData->GuiInfo.FontSize = TermInfo.FontSize;
2301  GuiData->GuiInfo.FontWeight = TermInfo.FontWeight;
2302  GuiData->GuiInfo.UseRasterFonts = TermInfo.UseRasterFonts;
2303  GuiData->GuiInfo.FullScreen = TermInfo.FullScreen;
2304  GuiData->GuiInfo.ShowWindow = TermInfo.ShowWindow;
2305  GuiData->GuiInfo.AutoPosition = TermInfo.AutoPosition;
2306  GuiData->GuiInfo.WindowOrigin = TermInfo.WindowOrigin;
2307 
2308  /* Initialize the icon handles to their default values */
2309  GuiData->hIcon = ghDefaultIcon;
2310  GuiData->hIconSm = ghDefaultIconSm;
2311 
2312  /* Get the associated icon, if any */
2313  if (IconPath == NULL || IconPath[0] == L'\0')
2314  {
2315  IconPath = ConsoleStartInfo->AppPath;
2316  IconIndex = 0;
2317  }
2318  DPRINT("IconPath = %S ; IconIndex = %lu\n", (IconPath ? IconPath : L"n/a"), IconIndex);
2319  if (IconPath && IconPath[0] != L'\0')
2320  {
2321  HICON hIcon = NULL, hIconSm = NULL;
2323  IconIndex,
2324  &hIcon,
2325  &hIconSm,
2326  1);
2327  DPRINT("hIcon = 0x%p ; hIconSm = 0x%p\n", hIcon, hIconSm);
2328  if (hIcon != NULL)
2329  {
2330  DPRINT("Effectively set the icons\n");
2331  GuiData->hIcon = hIcon;
2332  GuiData->hIconSm = hIconSm;
2333  }
2334  }
2335 
2336  /* Mouse is shown by default with its default cursor shape */
2337  GuiData->hCursor = ghDefaultCursor;
2338  GuiData->MouseCursorRefCount = 0;
2339 
2340  /* A priori don't ignore mouse signals */
2341  GuiData->IgnoreNextMouseSignal = FALSE;
2342 
2343  /* Close button and the corresponding system menu item are enabled by default */
2344  GuiData->IsCloseButtonEnabled = TRUE;
2345 
2346  /* There is no user-reserved menu id range by default */
2347  GuiData->cmdIdLow = GuiData->cmdIdHigh = 0;
2348 
2349  /*
2350  * We need to wait until the GUI has been fully initialized
2351  * to retrieve custom settings i.e. WindowSize etc...
2352  * Ideally we could use SendNotifyMessage for this but its not
2353  * yet implemented.
2354  */
2355  GuiData->hGuiInitEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
2356 
2357  DPRINT("GUI - Checkpoint\n");
2358 
2359  /* Create the terminal window */
2361 
2362  /* Wait until initialization has finished */
2363  WaitForSingleObject(GuiData->hGuiInitEvent, INFINITE);
2364  DPRINT("OK we created the console window\n");
2365  CloseHandle(GuiData->hGuiInitEvent);
2366  GuiData->hGuiInitEvent = NULL;
2367 
2368  /* Check whether we really succeeded in initializing the terminal window */
2369  if (GuiData->hWindow == NULL)
2370  {
2371  DPRINT("GuiInitConsole - We failed at creating a new terminal window\n");
2373  return STATUS_UNSUCCESSFUL;
2374  }
2375 
2376  /* Finally, finish to initialize the frontend structure */
2377  This->Data = GuiData;
2378  if (This->OldData) ConsoleFreeHeap(This->OldData);
2379  This->OldData = NULL;
2380 
2381  return STATUS_SUCCESS;
2382 }
2383 
2384 static VOID WINAPI
2386 {
2387  PGUI_CONSOLE_DATA GuiData = This->Data;
2388 
2390 
2391  DPRINT("Destroying icons !! - GuiData->hIcon = 0x%p ; ghDefaultIcon = 0x%p ; GuiData->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n",
2392  GuiData->hIcon, ghDefaultIcon, GuiData->hIconSm, ghDefaultIconSm);
2393  if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon)
2394  {
2395  DPRINT("Destroy hIcon\n");
2396  DestroyIcon(GuiData->hIcon);
2397  }
2398  if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm)
2399  {
2400  DPRINT("Destroy hIconSm\n");
2401  DestroyIcon(GuiData->hIconSm);
2402  }
2403 
2404  This->Data = NULL;
2405  DeleteCriticalSection(&GuiData->Lock);
2406  ConsoleFreeHeap(GuiData);
2407 
2408  DPRINT("Quit GuiDeinitFrontEnd\n");
2409 }
2410 
2411 static VOID WINAPI
2413  SMALL_RECT* Region)
2414 {
2415  PGUI_CONSOLE_DATA GuiData = This->Data;
2416  RECT RegionRect;
2417 
2418  SmallRectToRect(GuiData, &RegionRect, Region);
2419  /* Do not erase the background: it speeds up redrawing and reduce flickering */
2420  InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
2421 }
2422 
2423 static VOID WINAPI
2425  SMALL_RECT* Region,
2426  SHORT CursorStartX,
2427  SHORT CursorStartY,
2428  UINT ScrolledLines,
2429  PWCHAR Buffer,
2430  UINT Length)
2431 {
2432  PGUI_CONSOLE_DATA GuiData = This->Data;
2434  SHORT CursorEndX, CursorEndY;
2435  RECT ScrollRect;
2436 
2437  if (NULL == GuiData || NULL == GuiData->hWindow) return;
2438 
2439  Buff = ConDrvGetActiveScreenBuffer(GuiData->Console);
2440  if (GetType(Buff) != TEXTMODE_BUFFER) return;
2441 
2442  if (0 != ScrolledLines)
2443  {
2444  ScrollRect.left = 0;
2445  ScrollRect.top = 0;
2446  ScrollRect.right = Buff->ViewSize.X * GuiData->CharWidth;
2447  ScrollRect.bottom = Region->Top * GuiData->CharHeight;
2448 
2449  ScrollWindowEx(GuiData->hWindow,
2450  0,
2451  -(int)(ScrolledLines * GuiData->CharHeight),
2452  &ScrollRect,
2453  NULL,
2454  NULL,
2455  NULL,
2456  SW_INVALIDATE);
2457  }
2458 
2460 
2461  if (CursorStartX < Region->Left || Region->Right < CursorStartX
2462  || CursorStartY < Region->Top || Region->Bottom < CursorStartY)
2463  {
2464  GuiInvalidateCell(This, CursorStartX, CursorStartY);
2465  }
2466 
2467  CursorEndX = Buff->CursorPosition.X;
2468  CursorEndY = Buff->CursorPosition.Y;
2469  if ((CursorEndX < Region->Left || Region->Right < CursorEndX
2470  || CursorEndY < Region->Top || Region->Bottom < CursorEndY)
2471  && (CursorEndX != CursorStartX || CursorEndY != CursorStartY))
2472  {
2473  GuiInvalidateCell(This, CursorEndX, CursorEndY);
2474  }
2475 
2476  // Set up the update timer (very short interval) - this is a "hack" for getting the OS to
2477  // repaint the window without having it just freeze up and stay on the screen permanently.
2478  Buff->CursorBlinkOn = TRUE;
2480 }
2481 
2482 static BOOL WINAPI
2485 {
2486  PGUI_CONSOLE_DATA GuiData = This->Data;
2487 
2488  if (ConDrvGetActiveScreenBuffer(GuiData->Console) == Buff)
2489  {
2491  }
2492 
2493  return TRUE;
2494 }
2495 
2496 static BOOL WINAPI
2499  SHORT OldCursorX,
2500  SHORT OldCursorY)
2501 {
2502  PGUI_CONSOLE_DATA GuiData = This->Data;
2503 
2504  if (ConDrvGetActiveScreenBuffer(GuiData->Console) == Buff)
2505  {
2506  /* Redraw char at old position (remove cursor) */
2507  GuiInvalidateCell(This, OldCursorX, OldCursorY);
2508  /* Redraw char at new position (show cursor) */
2510  }
2511 
2512  return TRUE;
2513 }
2514 
2515 static VOID WINAPI
2517 {
2518  PGUI_CONSOLE_DATA GuiData = This->Data;
2519 
2520  /* Resize the window to the user's values */
2521  // GuiData->WindowSizeLock = TRUE;
2522  // GuiConsoleResizeWindow(GuiData);
2523  // GuiData->WindowSizeLock = FALSE;
2524  // NOTE: This code ^^ causes deadlocks...
2525 
2526  PostMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
2527 }
2528 
2529 static BOOL WINAPI
2531  MSG* msg,
2532  BYTE KeyStateMenu,
2533  DWORD ShiftState,
2534  UINT VirtualKeyCode,
2535  BOOL Down)
2536 {
2537  if ((ShiftState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED) || KeyStateMenu & 0x80) &&
2538  (VirtualKeyCode == VK_ESCAPE || VirtualKeyCode == VK_TAB || VirtualKeyCode == VK_SPACE))
2539  {
2540  DefWindowProcW(msg->hwnd, msg->message, msg->wParam, msg->lParam);
2541  return TRUE;
2542  }
2543 
2544  return FALSE;
2545 }
2546 
2547 static BOOL WINAPI
2549  HCURSOR hCursor);
2550 
2551 static VOID WINAPI
2553 {
2554  PGUI_CONSOLE_DATA GuiData = This->Data;
2555 
2556  /* Update the console leader information held by the window */
2558 
2559  /*
2560  * HACK:
2561  * We reset the cursor here so that, when a console app quits, we reset
2562  * the cursor to the default one. It's quite a hack since it doesn't proceed
2563  * per - console process... This must be fixed.
2564  *
2565  * See GuiInitConsole(...) for more information.
2566  */
2567 
2568  /* Mouse is shown by default with its default cursor shape */
2569  GuiData->MouseCursorRefCount = 0; // Reinitialize the reference counter
2571 }
2572 
2573 static VOID WINAPI
2575 {
2576  PGUI_CONSOLE_DATA GuiData = This->Data;
2577  // PostMessageW(GuiData->hWindow, PM_CONSOLE_SET_TITLE, 0, 0);
2578  SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer);
2579 }
2580 
2581 static BOOL WINAPI
2583  HICON hWindowIcon)
2584 {
2585  PGUI_CONSOLE_DATA GuiData = This->Data;
2586  HICON hIcon, hIconSm;
2587 
2588  if (hWindowIcon == NULL)
2589  {
2590  hIcon = ghDefaultIcon;
2592  }
2593  else
2594  {
2595  hIcon = CopyIcon(hWindowIcon);
2596  hIconSm = CopyIcon(hWindowIcon);
2597  }
2598 
2599  if (hIcon == NULL)
2600  {
2601  return FALSE;
2602  }
2603 
2604  if (hIcon != GuiData->hIcon)
2605  {
2606  if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon)
2607  {
2608  DestroyIcon(GuiData->hIcon);
2609  }
2610  if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm)
2611  {
2612  DestroyIcon(GuiData->hIconSm);
2613  }
2614 
2615  GuiData->hIcon = hIcon;
2616  GuiData->hIconSm = hIconSm;
2617 
2618  DPRINT("Set icons in GuiChangeIcon\n");
2619  PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG, (LPARAM)GuiData->hIcon);
2620  PostMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)GuiData->hIconSm);
2621  }
2622 
2623  return TRUE;
2624 }
2625 
2626 static HWND WINAPI
2628 {
2629  PGUI_CONSOLE_DATA GuiData = This->Data;
2630  return GuiData->hWindow;
2631 }
2632 
2633 static VOID WINAPI
2635  PCOORD pSize)
2636 {
2637  PGUI_CONSOLE_DATA GuiData = This->Data;
2638  PCONSOLE_SCREEN_BUFFER ActiveBuffer;
2639  RECT WorkArea;
2640  LONG width, height;
2641  UINT WidthUnit, HeightUnit;
2642 
2643  if (!pSize) return;
2644 
2645  if (!SystemParametersInfoW(SPI_GETWORKAREA, 0, &WorkArea, 0))
2646  {
2647  DPRINT1("SystemParametersInfoW failed - What to do ??\n");
2648  return;
2649  }
2650 
2651  ActiveBuffer = ConDrvGetActiveScreenBuffer(GuiData->Console);
2652  if (ActiveBuffer)
2653  {
2654  GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
2655  }
2656  else
2657  {
2658  /* Default: text mode */
2659  WidthUnit = GuiData->CharWidth ;
2660  HeightUnit = GuiData->CharHeight;
2661  }
2662 
2663  width = WorkArea.right;
2664  height = WorkArea.bottom;
2665 
2668 
2669  if (width < 0) width = 0;
2670  if (height < 0) height = 0;
2671 
2672  pSize->X = (SHORT)(width / (int)WidthUnit ) /* HACK */ + 2;
2673  pSize->Y = (SHORT)(height / (int)HeightUnit) /* HACK */ + 1;
2674 }
2675 
2676 static ULONG WINAPI
2678 {
2679  PGUI_CONSOLE_DATA GuiData = This->Data;
2680  ULONG DisplayMode = 0;
2681 
2682  if (GuiData->GuiInfo.FullScreen)
2683  DisplayMode |= CONSOLE_FULLSCREEN_HARDWARE; // CONSOLE_FULLSCREEN
2684  else
2686 
2687  return DisplayMode;
2688 }
2689 
2690 static BOOL WINAPI
2692  ULONG NewMode)
2693 {
2694  PGUI_CONSOLE_DATA GuiData = This->Data;
2695 
2697  return FALSE;
2698 
2699  GuiData->GuiInfo.FullScreen = (NewMode & CONSOLE_FULLSCREEN_MODE);
2700  // TODO: Change the display mode
2701  return TRUE;
2702 }
2703 
2704 static INT WINAPI
2706  BOOL Show)
2707 {
2708  PGUI_CONSOLE_DATA GuiData = This->Data;
2709 
2710  /* Set the reference count */
2711  if (Show) ++GuiData->MouseCursorRefCount;
2712  else --GuiData->MouseCursorRefCount;
2713 
2714  /* Effectively show (or hide) the cursor (use special values for (w|l)Param) */
2715  PostMessageW(GuiData->hWindow, WM_SETCURSOR, -1, -1);
2716 
2717  return GuiData->MouseCursorRefCount;
2718 }
2719 
2720 static BOOL WINAPI
2722  HCURSOR hCursor)
2723 {
2724  PGUI_CONSOLE_DATA GuiData = This->Data;
2725 
2726  /*
2727  * Set the cursor's handle. If the given handle is NULL,
2728  * then restore the default cursor.
2729  */
2730  GuiData->hCursor = (hCursor ? hCursor : ghDefaultCursor);
2731 
2732  /* Effectively modify the shape of the cursor (use special values for (w|l)Param) */
2733  PostMessageW(GuiData->hWindow, WM_SETCURSOR, -1, -1);
2734 
2735  return TRUE;
2736 }
2737 
2738 static HMENU WINAPI
2740  UINT cmdIdLow,
2741  UINT cmdIdHigh)
2742 {
2743  PGUI_CONSOLE_DATA GuiData = This->Data;
2744 
2745  GuiData->cmdIdLow = cmdIdLow ;
2746  GuiData->cmdIdHigh = cmdIdHigh;
2747 
2748  return GetSystemMenu(GuiData->hWindow, FALSE);
2749 }
2750 
2751 static BOOL WINAPI
2753  BOOL Enable)
2754 {
2755  /*
2756  * NOTE: See http://www.mail-archive.com/harbour@harbour-project.org/msg27509.html
2757  * or http://harbour-devel.1590103.n2.nabble.com/Question-about-hb-gt-win-CtrlHandler-usage-td4670862i20.html
2758  * for more information.
2759  */
2760 
2761  PGUI_CONSOLE_DATA GuiData = This->Data;
2762  HMENU hSysMenu = GetSystemMenu(GuiData->hWindow, FALSE);
2763 
2764  if (hSysMenu == NULL) return FALSE;
2765 
2766  GuiData->IsCloseButtonEnabled = Enable;
2768 
2769  return TRUE;
2770 }
2771 
2773 {
2776  GuiDrawRegion,
2784  GuiChangeIcon,
2793 };
2794 
2795 
2796 static BOOL
2799 {
2800 #define PATH_SEPARATOR L'\\'
2801 
2802  BOOL RetVal = FALSE;
2803  HRESULT hRes = S_OK;
2804  LPWSTR LinkName = NULL;
2805  SIZE_T Length = 0;
2806 
2807  if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
2808  return FALSE;
2809 
2810  ConsoleStartInfo->IconPath[0] = L'\0';
2811  ConsoleStartInfo->IconIndex = 0;
2812 
2813  /* 1- Find the last path separator if any */
2814  LinkName = wcsrchr(ConsoleStartInfo->ConsoleTitle, PATH_SEPARATOR);
2815  if (LinkName == NULL)
2816  {
2817  LinkName = ConsoleStartInfo->ConsoleTitle;
2818  }
2819  else
2820  {
2821  /* Skip the path separator */
2822  ++LinkName;
2823  }
2824 
2825  /* 2- Check for the link extension. The name ".lnk" is considered invalid. */
2826  Length = wcslen(LinkName);
2827  if ( (Length <= 4) || (wcsicmp(LinkName + (Length - 4), L".lnk") != 0) )
2828  return FALSE;
2829 
2830  /* 3- It may be a link. Try to retrieve some properties */
2831  hRes = CoInitialize(NULL);
2832  if (SUCCEEDED(hRes))
2833  {
2834  /* Get a pointer to the IShellLink interface */
2835  IShellLinkW* pshl = NULL;
2836  hRes = CoCreateInstance(&CLSID_ShellLink,
2837  NULL,
2838  CLSCTX_INPROC_SERVER,
2839  &IID_IShellLinkW,
2840  (LPVOID*)&pshl);
2841  if (SUCCEEDED(hRes))
2842  {
2843  /* Get a pointer to the IPersistFile interface */
2844  IPersistFile* ppf = NULL;
2845  hRes = IPersistFile_QueryInterface(pshl, &IID_IPersistFile, (LPVOID*)&ppf);
2846  if (SUCCEEDED(hRes))
2847  {
2848  /* Load the shortcut */
2849  hRes = IPersistFile_Load(ppf, ConsoleStartInfo->ConsoleTitle, STGM_READ);
2850  if (SUCCEEDED(hRes))
2851  {
2852  /*
2853  * Finally we can get the properties !
2854  * Update the old ones if needed.
2855  */
2856  INT ShowCmd = 0;
2857  // WORD HotKey = 0;
2858 
2859  /* Reset the name of the console with the name of the shortcut */
2860  Length = min(/*Length*/ Length - 4, // 4 == len(".lnk")
2861  sizeof(ConsoleInfo->ConsoleTitle) / sizeof(ConsoleInfo->ConsoleTitle[0]) - 1);
2862  wcsncpy(ConsoleInfo->ConsoleTitle, LinkName, Length);
2863  ConsoleInfo->ConsoleTitle[Length] = L'\0';
2864 
2865  /* Get the window showing command */
2866  hRes = IShellLinkW_GetShowCmd(pshl, &ShowCmd);
2867  if (SUCCEEDED(hRes)) ConsoleStartInfo->ShowWindow = (WORD)ShowCmd;
2868 
2869  /* Get the hotkey */
2870  // hRes = pshl->GetHotkey(&ShowCmd);
2871  // if (SUCCEEDED(hRes)) ConsoleStartInfo->HotKey = HotKey;
2872 
2873  /* Get the icon location, if any */
2874 
2875  hRes = IShellLinkW_GetIconLocation(pshl,
2876  ConsoleStartInfo->IconPath,
2877  sizeof(ConsoleStartInfo->IconPath)/sizeof(ConsoleStartInfo->IconPath[0]) - 1, // == MAX_PATH
2878  &ConsoleStartInfo->IconIndex);
2879  if (!SUCCEEDED(hRes))
2880  {
2881  ConsoleStartInfo->IconPath[0] = L'\0';
2882  ConsoleStartInfo->IconIndex = 0;
2883  }
2884 
2885  // FIXME: Since we still don't load console properties from the shortcut,
2886  // return false. When this will be done, we will return true instead.
2887  RetVal = FALSE;
2888  }
2889  IPersistFile_Release(ppf);
2890  }
2891  IShellLinkW_Release(pshl);
2892  }
2893  }
2894  CoUninitialize();
2895 
2896  return RetVal;
2897 }
2898 
2902  IN OUT PVOID ExtraConsoleInfo,
2903  IN ULONG ProcessId)
2904 {
2905  PCONSOLE_START_INFO ConsoleStartInfo = ExtraConsoleInfo;
2906  PGUI_INIT_INFO GuiInitInfo;
2907 
2908  if (FrontEnd == NULL || ConsoleInfo == NULL || ConsoleStartInfo == NULL)
2909  return STATUS_INVALID_PARAMETER;
2910 
2911  /* Initialize GUI terminal emulator common functionalities */
2912  if (!GuiInit()) return STATUS_UNSUCCESSFUL;
2913 
2914  /*
2915  * Load per-application terminal settings.
2916  *
2917  * Check whether the process creating the console was launched via
2918  * a shell-link. ConsoleInfo->ConsoleTitle may be updated with the
2919  * name of the shortcut, and ConsoleStartInfo->Icon[Path|Index] too.
2920  */
2921  if (ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME)
2922  {
2923  if (!LoadShellLinkConsoleInfo(ConsoleStartInfo, ConsoleInfo))
2924  {
2925  ConsoleStartInfo->dwStartupFlags &= ~STARTF_TITLEISLINKNAME;
2926  }
2927  }
2928 
2929  /*
2930  * Initialize a private initialization info structure for later use.
2931  * It must be freed by a call to GuiUnloadFrontEnd or GuiInitFrontEnd.
2932  */
2933  GuiInitInfo = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(GUI_INIT_INFO));
2934  if (GuiInitInfo == NULL) return STATUS_NO_MEMORY;
2935 
2936  // HACK: We suppose that the pointers will be valid in GuiInitFrontEnd...
2937  GuiInitInfo->ConsoleInfo = ConsoleInfo;
2938  GuiInitInfo->ConsoleStartInfo = ConsoleStartInfo;
2939  GuiInitInfo->ProcessId = ProcessId;
2940 
2941  /* Finally, initialize the frontend structure */
2942  FrontEnd->Vtbl = &GuiVtbl;
2943  FrontEnd->Data = NULL;
2944  FrontEnd->OldData = GuiInitInfo;
2945 
2946  return STATUS_SUCCESS;
2947 }
2948 
2951 {
2952  if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
2953 
2954  if (FrontEnd->Data) GuiDeinitFrontEnd(FrontEnd);
2955  if (FrontEnd->OldData) ConsoleFreeHeap(FrontEnd->OldData);
2956 
2957  return STATUS_SUCCESS;
2958 }
2959 
2960 /* EOF */
#define WM_MBUTTONUP
Definition: winuser.h:1759
HGDIOBJ WINAPI GetStockObject(_In_ int)
#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)
VOID GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData, HANDLE hClientSection)
Definition: guisettings.c:258
VOID GuiCopyFromGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer)
Definition: graphics.c:23
HICON ghDefaultIcon
Definition: conwnd.c:62
POINT ptMinTrackSize
Definition: winuser.h:3572
#define FROM_LEFT_1ST_BUTTON_PRESSED
Definition: wincon.h:144
#define SCROLLLOCK_ON
Definition: wincon.h:137
#define IDS_DEFAULTS
Definition: resource.h:28
#define IN
Definition: typedefs.h:38
GLint GLint GLsizei width
Definition: gl.h:1546
#define STARTF_RUNFULLSCREEN
Definition: winbase.h:477
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define max(a, b)
Definition: svc.c:63
BOOL WINAPI TranslateMessage(_In_ const MSG *)
NTSTATUS NTAPI ConDrvConsoleProcessCtrlEvent(IN PCONSOLE Console, IN ULONG ProcessGroupId, IN ULONG Event)
Definition: console.c:1069
static HICON
Definition: imagelist.c:84
#define CONSOLE_WINDOWED_MODE
Definition: wincon.h:34
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
HFONT WINAPI CreateFontW(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR)
#define CloseHandle
Definition: compat.h:398
#define LF_FACESIZE
Definition: dimm.idl:39
VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:250
#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:245
HANDLE hGuiInitEvent
Definition: conwnd.h:44
BOOL IsCloseButtonEnabled
Definition: conwnd.h:77
BOOL WINAPI DrawMenuBar(_In_ HWND)
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
#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
static PGUI_CONSOLE_DATA GuiGetGuiData(HWND hWnd)
Definition: guiterm.c:365
long y
Definition: polytest.cpp:48
int cbWndExtra
Definition: winuser.h:3173
PCONSOLE_SCREEN_BUFFER ConDrvGetActiveScreenBuffer(IN PCONSOLE Console)
Definition: conoutput.c:194
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_CHAR
Definition: winuser.h:1693
static BOOL WINAPI GuiSetDisplayMode(IN OUT PFRONTEND This, ULONG NewMode)
Definition: guiterm.c:2691
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
static LRESULT GuiConsoleHandleMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:1087
static BOOL WINAPI GuiSetMenuClose(IN OUT PFRONTEND This, BOOL Enable)
Definition: guiterm.c:2752
#define IDS_FIND
Definition: resource.h:27
#define CONGUI_MIN_HEIGHT
Definition: conwnd.c:34
BOOLEAN CursorBlinkOn
Definition: conio.h:99
static VOID WINAPI GuiChangeTitle(IN OUT PFRONTEND This)
Definition: guiterm.c:2574
#define MK_LBUTTON
Definition: winuser.h:2321
long x
Definition: polytest.cpp:48
signed short * PSHORT
Definition: retypes.h:6
static COORD PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
Definition: guiterm.c:1060
HDC WINAPI GetDC(_In_opt_ HWND)
static VOID GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:389
#define RIGHTMOST_BUTTON_PRESSED
Definition: wincon.h:145
WORD ATOM
Definition: dimm.idl:113
#define SB_VERT
Definition: winuser.h:553
#define CTRL_CLOSE_EVENT
Definition: wincon.h:67
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define CONSOLE_FULLSCREEN_HARDWARE
Definition: wincon.h:30
#define SIZE_MAXIMIZED
Definition: winuser.h:2461
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define VK_RMENU
Definition: winuser.h:2241
static VOID GuiConsoleAppendMenuItems(HMENU hMenu, const GUICONSOLE_MENUITEM *Items)
Definition: guiterm.c:168
#define ERROR(name)
Definition: error_private.h:53
#define WM_MOUSEWHEEL
Definition: treelist.c:96
_In_ BOOLEAN Create
Definition: pstypes.h:511
struct _GUI_CONSOLE_DATA * PGUI_CONSOLE_DATA
#define MK_MBUTTON
Definition: winuser.h:2325
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:3915
#define CDS_FULLSCREEN
Definition: winuser.h:183
#define SIZE_RESTORED
Definition: winuser.h:2459
#define PM_DESTROY_CONSOLE
Definition: guiterm.c:41
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
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:27
COORD CursorPosition
Definition: conio.h:98
#define MF_STRING
Definition: winuser.h:138
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
#define FROM_LEFT_2ND_BUTTON_PRESSED
Definition: wincon.h:146
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
LONG top
Definition: windef.h:292
static VOID WINAPI GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This, PCOORD pSize)
Definition: guiterm.c:2634
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static BOOL WINAPI GuiProcessKeyCallback(IN OUT PFRONTEND This, MSG *msg, BYTE KeyStateMenu, DWORD ShiftState, UINT VirtualKeyCode, BOOL Down)
Definition: guiterm.c:2530
#define VK_LEFT
Definition: winuser.h:2178
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define STARTF_USEPOSITION
Definition: winbase.h:474
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define SM_CXEDGE
Definition: winuser.h:998
#define GWL_USERDATA
Definition: winuser.h:855
#define SM_CYSMICON
Definition: winuser.h:1003
HICON hIcon
Definition: winuser.h:3175
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define WM_NCRBUTTONDOWN
Definition: winuser.h:1677
static BOOL WINAPI GuiSetScreenInfo(IN OUT PFRONTEND This, PCONSOLE_SCREEN_BUFFER Buff, SHORT OldCursorX, SHORT OldCursorY)
Definition: guiterm.c:2497
#define IDS_SCROLL
Definition: resource.h:26
VOID GuiPasteToTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer)
Definition: text.c:117
#define CONSOLE_NO_SELECTION
Definition: wincon.h:96
static UINT WindowCount
Definition: multiwin.c:4
BOOL IgnoreNextMouseSignal
Definition: conwnd.h:72
#define IDS_EDIT
Definition: resource.h:21
#define KF_UP
Definition: winuser.h:2405
#define WM_NCHITTEST
Definition: winuser.h:1668
const struct _GUICONSOLE_MENUITEM * SubMenu
Definition: conwnd.c:69
UINT_PTR WPARAM
Definition: windef.h:207
static VOID GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:445
#define VK_LWIN
Definition: winuser.h:2189
#define VK_TAB
Definition: winuser.h:2153
HICON ghDefaultIconSm
Definition: conwnd.c:63
#define VK_DOWN
Definition: winuser.h:2181
struct _WNDCLASSEXW WNDCLASSEXW
#define VK_PRIOR
Definition: winuser.h:2174
#define VK_MENU
Definition: winuser.h:2158
#define GetWindowLongPtrW
Definition: winuser.h:4698
static VOID WINAPI GuiDeinitFrontEnd(IN OUT PFRONTEND This)
Definition: guiterm.c:2385
uint16_t * PWCHAR
Definition: typedefs.h:54
#define IDS_PROPERTIES
Definition: resource.h:101
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
HICON HCURSOR
Definition: windef.h:284
#define SM_CYFRAME
Definition: winuser.h:986
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define SHIFT_PRESSED
Definition: wincon.h:135
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define SM_CXFRAME
Definition: winuser.h:984
#define VK_ESCAPE
Definition: winuser.h:2168
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
LONG right
Definition: windef.h:293
#define CONSOLE_MOUSE_DOWN
Definition: wincon.h:100
#define WM_NCCREATE
Definition: winuser.h:1665
BOOL WINAPI DestroyWindow(_In_ HWND)
static BOOL GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
Definition: guiterm.c:485
DWORD dwButtonState
Definition: wincon.h:243
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4185
int32_t INT
Definition: typedefs.h:56
#define SIF_PAGE
Definition: winuser.h:1219
#define VK_RETURN
Definition: winuser.h:2155
WPARAM wParam
Definition: combotst.c:138
struct _GUI_INIT_INFO GUI_INIT_INFO
VOID GuiPasteToGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer)
Definition: graphics.c:35
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define PAUSED_FROM_SELECTION
Definition: conio_winsrv.h:128
#define VK_NEXT
Definition: winuser.h:2175
SHORT Right
Definition: wincon.h:178
SHORT Left
Definition: wincon.h:176
struct @1571 Msg[]
static HMENU WINAPI GuiMenuControl(IN OUT PFRONTEND This, UINT cmdIdLow, UINT cmdIdHigh)
Definition: guiterm.c:2739
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define ICON_SMALL
Definition: tnclass.cpp:48
#define DM_PELSWIDTH
Definition: wingdi.h:1251
static VOID GuiConsolePaste(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1365
#define CONSOLE_MOUSE_SELECTION
Definition: wincon.h:99
GLuint coord
Definition: glext.h:9511
#define ID_SYSTEM_PROPERTIES
Definition: resource.h:19
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WindowSizeLock
Definition: conwnd.h:43
UINT CharHeight
Definition: conwnd.h:87
#define MOUSE_MOVED
Definition: wincon.h:153
static const GUICONSOLE_MENUITEM GuiConsoleEditMenuItems[]
Definition: guiterm.c:93
#define SWP_NOCOPYBITS
Definition: winuser.h:1228
#define ID_SYSTEM_EDIT_MARK
Definition: resource.h:12
#define TPM_RIGHTBUTTON
Definition: winuser.h:2334
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_HOME
Definition: winuser.h:2177
#define PM_APPLY_CONSOLE_INFO
Definition: guisettings.h:17
static VOID WINAPI GuiDrawRegion(IN OUT PFRONTEND This, SMALL_RECT *Region)
Definition: guiterm.c:2412
LPCWSTR lpszMenuName
Definition: winuser.h:3178
BOOL WINAPI ShowWindowAsync(_In_ HWND, _In_ int)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define VK_UP
Definition: winuser.h:2179
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
int Check()
Definition: movefile.cpp:196
COORD ScreenBufferSize
Definition: conio.h:87
static LRESULT GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
Definition: guiterm.c:1510
static VOID GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:1418
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DOUBLE_CLICK
Definition: wincon.h:154
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define PATH_SEPARATOR
long LONG
Definition: pedump.c:60
#define RGN_XOR
Definition: wingdi.h:359
#define FIXED_PITCH
Definition: wingdi.h:443
#define WM_SETCURSOR
Definition: winuser.h:1618
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
short SHORT
Definition: pedump.c:59
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define TA_BASELINE
Definition: wingdi.h:927
#define THREAD_PRIORITY_HIGHEST
Definition: winbase.h:274
HICON hIconSm
Definition: conwnd.h:67
#define CONGUI_UPDATE_TIMER
Definition: guiterm.c:25
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
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:1723
#define WM_SYSCHAR
Definition: winuser.h:1697
#define SM_CXICON
Definition: winuser.h:962
static const GUICONSOLE_MENUITEM GuiConsoleMainMenuItems[]
Definition: guiterm.c:105
#define CW_USEDEFAULT
Definition: winuser.h:225
#define GWLP_USERDATA
Definition: treelist.c:63
#define ID_SYSTEM_DEFAULTS
Definition: resource.h:18
VOID GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer)
Definition: text.c:26
#define VK_SHIFT
Definition: winuser.h:2156
static BOOL GuiConsoleHandleClose(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1027
#define CF_UNICODETEXT
Definition: constants.h:408
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
COORD dwMousePosition
Definition: wincon.h:242
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:111
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
#define IDS_SELECTALL
Definition: resource.h:25
#define CURSOR_BLINK_TIME
Definition: conwnd.c:38
#define NONANTIALIASED_QUALITY
Definition: wingdi.h:438
#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 IDI_TERMINAL
Definition: resource.h:44
#define WM_KEYDOWN
Definition: winuser.h:1691
#define CONSOLE_SELECTION_NOT_EMPTY
Definition: wincon.h:98
#define MF_SEPARATOR
Definition: winuser.h:137
LONG_PTR LPARAM
Definition: windef.h:208
#define SM_CYEDGE
Definition: winuser.h:999
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
int cbClsExtra
Definition: winuser.h:3172
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
UINT WINAPI WINAPI PrivateExtractIconExW(LPCWSTR, int, HICON *, HICON *, UINT)
Definition: exticon.c:690
static DWORD WINAPI GuiConsoleGuiThread(PVOID Data)
Definition: guiterm.c:2038
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define FOCUS_EVENT
Definition: wincon.h:126
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
#define MK_RBUTTON
Definition: winuser.h:2322
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
LPCWSTR lpszClassName
Definition: winuser.h:3179
ULONG ProcessId
Definition: guiterm.c:58
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:661
HFONT Font[FONT_MAXNO]
Definition: conwnd.h:85
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
SHORT WINAPI GetKeyState(_In_ int)
#define LEFT_ALT_PRESSED
Definition: wincon.h:132
#define DSTINVERT
Definition: wingdi.h:326
SHORT Left
Definition: blue.h:25
#define BLACK_BRUSH
Definition: wingdi.h:895
ULONG X
Definition: bl.h:1340
#define STGM_READ
Definition: objbase.h:916
struct tagSCROLLINFO SCROLLINFO
#define ID_SYSTEM_EDIT_PASTE
Definition: resource.h:14
#define KF_REPEAT
Definition: winuser.h:2404
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
static BOOL GuiInit(VOID)
Definition: guiterm.c:2083
#define WM_DEADCHAR
Definition: winuser.h:1694
static INT WINAPI GuiShowMouseCursor(IN OUT PFRONTEND This, BOOL Show)
Definition: guiterm.c:2705
static BOOL LoadShellLinkConsoleInfo(IN OUT PCONSOLE_START_INFO ConsoleStartInfo, IN OUT PCONSOLE_INFO ConsoleInfo)
Definition: guiterm.c:2797
union _INPUT_RECORD::@3149 Event
static VOID GuiInvalidateCell(IN OUT PFRONTEND This, SHORT x, SHORT y)
Definition: guiterm.c:923
static VOID WINAPI GuiResizeTerminal(IN OUT PFRONTEND This)
Definition: guiterm.c:2516
#define WM_KILLFOCUS
Definition: winuser.h:1596
#define DMDFO_CENTER
Definition: wingdi.h:1206
#define SM_CYCAPTION
Definition: winuser.h:953
#define ID_SYSTEM_EDIT_SELECTALL
Definition: resource.h:15
SHORT Bottom
Definition: blue.h:28
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define IDS_PASTE
Definition: shresdef.h:214
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ENHANCED_KEY
Definition: wincon.h:139
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define SB_THUMBTRACK
Definition: winuser.h:573
#define WM_SIZE
Definition: winuser.h:1593
HBRUSH hbrBackground
Definition: winuser.h:3177
LONG HRESULT
Definition: typedefs.h:77
UINT cbSize
Definition: winuser.h:3169
#define SWP_NOACTIVATE
Definition: winuser.h:1227
DWORD COLORREF
Definition: windef.h:285
#define PM_CREATE_CONSOLE
Definition: guiterm.c:40
POINT OldCursor
Definition: conwnd.h:54
#define WM_TIMER
Definition: winuser.h:1718
struct _GUI_INIT_INFO * PGUI_INIT_INFO
struct _GUICONSOLE_MENUITEM * PGUICONSOLE_MENUITEM
#define MF_ENABLED
Definition: winuser.h:128
#define WM_CLOSE
Definition: winuser.h:1603
#define WM_NCDESTROY
Definition: winuser.h:1666
#define RGB(r, g, b)
Definition: wingdi.h:2918
#define MOUSE_EVENT
Definition: wincon.h:123
VOID GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults)
Definition: guisettings.c:44
#define WINAPI
Definition: msvc.h:8
const GLubyte * c
Definition: glext.h:8905
#define WM_KEYUP
Definition: winuser.h:1692
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned short WORD
Definition: ntddk_ex.h:93
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
int WINAPI GetSystemMetrics(_In_ int)
static VOID WINAPI GuiRefreshInternalInfo(IN OUT PFRONTEND This)
Definition: guiterm.c:2552
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WA_CLICKACTIVE
Definition: winuser.h:2578
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:2460
VOID GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, HDC hDC, PRECT rc)
Definition: text.c:186
SHORT Top
Definition: blue.h:26
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define WM_RBUTTONUP
Definition: winuser.h:1756
#define SetConsoleWndConsoleLeaderCID(GuiData)
Definition: guiterm.c:67
FOCUS_EVENT_RECORD FocusEvent
Definition: wincon.h:267
#define WS_HSCROLL
Definition: pedump.c:628
HINSTANCE hInstance
Definition: winuser.h:3174
#define GUI_CONSOLE_WINDOW_CLASS
Definition: guiterm.c:35
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
#define WM_PAINT
Definition: winuser.h:1602
#define PM_CONSOLE_BEEP
Definition: guiterm.c:43
#define SM_CXSMICON
Definition: winuser.h:1002
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CHAR Message[80]
Definition: alive.c:5
static const WCHAR IconIndex[]
Definition: install.c:51
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:116
#define CONGUI_UPDATE_TIME
Definition: guiterm.c:24
SHORT Bottom
Definition: wincon.h:179
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
static VOID GuiConsoleCreateSysMenu(HWND hWnd)
Definition: guiterm.c:222
#define ENABLE_MOUSE_INPUT
Definition: wincon.h:79
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define MF_POPUP
Definition: winuser.h:136
#define SM_CYICON
Definition: winuser.h:963
#define OEM_CHARSET
Definition: wingdi.h:399
#define LEFT_CTRL_PRESSED
Definition: wincon.h:134
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
VOID GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer, PGUI_CONSOLE_DATA GuiData, HDC hDC, PRECT rc)
Definition: graphics.c:47
static const WCHAR L[]
Definition: oid.c:1250
static VOID GuiSendMenuEvent(PCONSOLE Console, UINT CmdId)
Definition: guiterm.c:233
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define VK_RCONTROL
Definition: winuser.h:2239
#define VK_LMENU
Definition: winuser.h:2240
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
static BOOL IsSystemKey(WORD VirtualKeyCode)
Definition: guiterm.c:737
#define SB_PAGELEFT
Definition: winuser.h:570
unsigned char BYTE
Definition: mem.h:68
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1754
static BOOL ConsInitialized
Definition: guiterm.c:80
static VOID GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:930
HCURSOR hCursor
Definition: winuser.h:3176
static VOID GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:673
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1760
#define CS_DBLCLKS
Definition: winuser.h:646
#define WM_COMMAND
Definition: winuser.h:1716
UINT style
Definition: winuser.h:3170
static VOID GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:760
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define CONSOLE_SELECTION_IN_PROGRESS
Definition: wincon.h:97
#define VK_RWIN
Definition: winuser.h:2190
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
Definition: bl.h:1338
#define SB_LINERIGHT
Definition: winuser.h:567
static VOID GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
Definition: guiterm.c:600
#define MENU_EVENT
Definition: wincon.h:125
#define wcsicmp
Definition: string.h:1152
#define SW_INVALIDATE
Definition: winuser.h:2533
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
WNDPROC lpfnWndProc
Definition: winuser.h:3171
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define SIF_POS
Definition: winuser.h:1220
#define CONSOLE_WINDOWED
Definition: wincon.h:28
struct _GUICONSOLE_MENUITEM GUICONSOLE_MENUITEM
#define VK_RIGHT
Definition: winuser.h:2180
SHORT Top
Definition: wincon.h:177
VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG *msg)
Definition: input.c:57
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define SWP_NOSIZE
Definition: winuser.h:1230
#define HTCAPTION
Definition: winuser.h:2430
static HWND WINAPI GuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
Definition: guiterm.c:2627
static HDC hDC
Definition: 3dtext.c:33
ULONG_PTR SIZE_T
Definition: typedefs.h:78
HICON WINAPI CopyIcon(_In_ HICON)
Definition: cursoricon.c:1980
#define S_OK
Definition: intsafe.h:59
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define SB_TOP
Definition: winuser.h:578
NTSTATUS NTAPI GuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd)
Definition: guiterm.c:1307
#define WM_INITMENU
Definition: winuser.h:1721
#define PAUSED_FROM_SCROLLBAR
Definition: conio_winsrv.h:127
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WM_ACTIVATE
Definition: winuser.h:1594
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define VK_SCROLL
Definition: winuser.h:2234
#define VK_NUMLOCK
Definition: winuser.h:2233
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_SYSDEADCHAR
Definition: winuser.h:1698
#define PM_RESIZE_TERMINAL
Definition: guiterm.c:42
unsigned short USHORT
Definition: pedump.c:61
#define DM_PELSHEIGHT
Definition: wingdi.h:1252
HICON hIcon
Definition: msconfig.c:44
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
NTSTATUS NTAPI GuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
Definition: guiterm.c:1177
static VOID SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
Definition: guiterm.c:585
#define WM_SYSKEYUP
Definition: winuser.h:1696
HCURSOR ghDefaultCursor
Definition: conwnd.c:64
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1753
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
DWORD dwControlKeyState
Definition: wincon.h:244
#define WM_MBUTTONDOWN
Definition: winuser.h:1758
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
VOID GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:61
#define VK_CAPITAL
Definition: winuser.h:2160
#define SB_PAGERIGHT
Definition: winuser.h:571
static LRESULT CALLBACK GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:1930
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SetWindowText
Definition: winuser.h:5723
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define WM_HSCROLL
Definition: winuser.h:1719
#define VK_SPACE
Definition: winuser.h:2173
#define SB_BOTTOM
Definition: winuser.h:577
#define WS_VSCROLL
Definition: pedump.c:627
#define CONSOLE_FULLSCREEN_MODE
Definition: wincon.h:33
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
#define SM_CXVSCROLL
Definition: winuser.h:951
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
UINT CharWidth
Definition: conwnd.h:86
HWND WINAPI WindowFromPoint(_In_ POINT)
#define KF_ALTDOWN
Definition: winuser.h:2403
static VOID WINAPI GuiWriteStream(IN OUT PFRONTEND This, SMALL_RECT *Region, SHORT CursorStartX, SHORT CursorStartY, UINT ScrolledLines, PWCHAR Buffer, UINT Length)
Definition: guiterm.c:2424
HCURSOR hCursor
Definition: conwnd.h:70
NTSTATUS NTAPI GuiInitFrontEnd(IN OUT PFRONTEND This, IN PCONSOLE Console)
Definition: guiterm.c:2207
static const WCHAR IconPath[]
Definition: install.c:50
#define VK_CONTROL
Definition: winuser.h:2157
CConsole Console
WORD EventType
Definition: wincon.h:261
#define DPRINT1
Definition: precomp.h:8
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
HICON hIconSm
Definition: winuser.h:3180
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
VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:243
static FRONTEND_VTBL GuiVtbl
Definition: guiterm.c:2772
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
#define SC_CLOSE
Definition: winuser.h:2546
const GUID IID_IPersistFile
static VOID GetScreenBufferSizeUnits(IN PCONSOLE_SCREEN_BUFFER Buffer, IN PGUI_CONSOLE_DATA GuiData, OUT PUINT WidthUnit, OUT PUINT HeightUnit)
Definition: guiterm.c:142
MOUSE_EVENT_RECORD MouseEvent
Definition: wincon.h:264
#define VK_PAUSE
Definition: winuser.h:2159
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define OUT
Definition: typedefs.h:39
#define WM_CREATE
Definition: winuser.h:1590
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1757
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
HICON hIconSm
Definition: msconfig.c:44
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define ID_SYSTEM_EDIT_FIND
Definition: resource.h:17
#define c
Definition: ke_i.h:80
static LRESULT GuiConsoleHandleNcDestroy(HWND hWnd)
Definition: guiterm.c:1048
BOOL WINAPI Beep(IN DWORD dwFreq, IN DWORD dwDuration)
Definition: deviceio.c:48
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
#define SB_LINELEFT
Definition: winuser.h:566
LONG bottom
Definition: windef.h:294
static BOOL WINAPI GuiSetCursorInfo(IN OUT PFRONTEND This, PCONSOLE_SCREEN_BUFFER Buff)
Definition: guiterm.c:2483
#define GWLP_CONSOLEWND_ALLOC
Definition: guiterm.c:63
#define SWP_NOMOVE
Definition: winuser.h:1229
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
#define DM_BITSPERPEL
Definition: wingdi.h:1250
static BOOL WINAPI GuiChangeIcon(IN OUT PFRONTEND This, HICON hWindowIcon)
Definition: guiterm.c:2582
#define MOUSE_WHEELED
Definition: wincon.h:155
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:133
static LRESULT GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:256
MENU_EVENT_RECORD MenuEvent
Definition: wincon.h:266
#define SetWindowLongPtrW
Definition: winuser.h:5215
static VOID GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:1337
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182
POINT ptMaxTrackSize
Definition: winuser.h:3573
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HTCLIENT
Definition: winuser.h:2429
#define CONGUI_MIN_WIDTH
Definition: conwnd.c:33
WCHAR * LPWSTR
Definition: xmlstorage.h:184
SHORT Right
Definition: blue.h:27
LONG_PTR LRESULT
Definition: windef.h:209
#define VK_LCONTROL
Definition: winuser.h:2238
static ULONG WINAPI GuiGetDisplayMode(IN OUT PFRONTEND This)
Definition: guiterm.c:2677
#define INFINITE
Definition: serial.h:102
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG Y
Definition: bl.h:1341
#define memset(x, y, z)
Definition: compat.h:39
BOOL GuiConsoleReadUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:24
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WM_SYSCOMMAND
Definition: winuser.h:1717
#define IDS_MARK
Definition: resource.h:22
static LPHIST_ENTRY Top
Definition: history.c:53
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:2176
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define NUMLOCK_ON
Definition: wincon.h:136
#define SendNotifyMessage
Definition: winuser.h:5712
PCONSOLE_INFO ConsoleInfo
Definition: guiterm.c:56
#define RIGHT_ALT_PRESSED
Definition: wincon.h:131
VOID WINAPI PrivateCsrssManualGuiCheck(LONG Check)
const COLORREF s_Colors[16]
Definition: guiterm.c:118
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:195
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
unsigned int * PUINT
Definition: ndis.h:50
static VOID GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
Definition: guiterm.c:1386
#define CAPSLOCK_ON
Definition: wincon.h:138
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define IDS_COPY
Definition: resource.h:120
#define ICON_BIG
Definition: tnclass.cpp:51
VOID GuiConsoleGetDefaultSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:38
#define WM_VSCROLL
Definition: winuser.h:1720
static HWND NotifyWnd
Definition: guiterm.c:84
static BOOL WINAPI GuiSetMouseCursor(IN OUT PFRONTEND This, HCURSOR hCursor)
Definition: guiterm.c:2721
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
PCONSOLE_START_INFO ConsoleStartInfo
Definition: guiterm.c:57
static LRESULT CALLBACK GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: guiterm.c:1617