ReactOS 0.4.17-dev-848-g516f0d5
tui.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TUI_TITLE_BOX_CHAR_HEIGHT   5
 
#define UL   0xDA /* HORZ and VERT */
 
#define UR   0xBF
 
#define LL   0xC0
 
#define LR   0xD9
 
#define D_UL   0xC9 /* D_HORZ and D_VERT */
 
#define D_UR   0xBB
 
#define D_LL   0xC8
 
#define D_LR   0xBC
 
#define HD_UL   0xD5 /* D_HORZ and VERT */
 
#define HD_UR   0xB8
 
#define HD_LL   0xD4
 
#define HD_LR   0xBE
 
#define VD_UL   0xD6 /* HORZ and D_VERT */
 
#define VD_UR   0xB7
 
#define VD_LL   0xD3
 
#define VD_LR   0xBD
 

Functions

INT TuiPrintf (_In_ PCSTR Format,...)
 
VOID TuiTruncateStringEllipsis (_Inout_z_ PSTR StringText, _In_ ULONG MaxChars)
 
BOOLEAN TuiInitialize (VOID)
 
VOID TuiUnInitialize (VOID)
 
VOID TuiDrawBackdrop (ULONG DrawHeight)
 
VOID TuiFillArea (ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
 
VOID TuiDrawShadow (ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
 
VOID TuiDrawBox (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ BOOLEAN Fill, _In_ BOOLEAN Shadow, _In_ UCHAR Attr)
 
VOID TuiDrawBoxTopLine (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
 
VOID TuiDrawBoxBottomLine (_In_ ULONG Left, _In_ ULONG Bottom, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
 
VOID TuiDrawText (_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
 
VOID TuiDrawText2 (_In_ ULONG X, _In_ ULONG Y, _In_opt_ ULONG MaxNumChars, _In_reads_or_z_(MaxNumChars) PCSTR Text, _In_ UCHAR Attr)
 
VOID TuiDrawCenteredText (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR TextString, _In_ UCHAR Attr)
 
VOID TuiDrawStatusText (PCSTR StatusText)
 
VOID TuiUpdateDateTime (VOID)
 
_Ret_maybenull_ __drv_allocatesMem (Mem) PUCHAR TuiSaveScreen(VOID)
 
VOID TuiRestoreScreen (_In_opt_ __drv_freesMem(Mem) PUCHAR Buffer)
 
VOID TuiMessageBox (_In_ PCSTR MessageText)
 
VOID TuiMessageBoxCritical (_In_ PCSTR MessageText)
 
BOOLEAN TuiEditBox (PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
 
UCHAR TuiTextToColor (PCSTR ColorText)
 
UCHAR TuiTextToFillStyle (PCSTR FillStyleText)
 
VOID TuiFadeInBackdrop (VOID)
 
VOID TuiFadeOut (VOID)
 
VOID TuiDisplayThermalScreen (VOID)
 
VOID TuiDrawMenu (_In_ PUI_MENU_INFO MenuInfo)
 
VOID TuiDrawMenuBox (_In_ PUI_MENU_INFO MenuInfo)
 
VOID TuiDrawMenuItem (_In_ PUI_MENU_INFO MenuInfo, _In_ ULONG MenuItemNumber)
 
BOOLEAN TuiDisplayMenu (IN PCSTR MenuHeader, IN PCSTR MenuFooter OPTIONAL, IN PCSTR MenuItemList[], IN ULONG MenuItemCount, IN ULONG DefaultMenuItem, IN LONG MenuTimeOut, OUT PULONG SelectedMenuItem, IN BOOLEAN CanEscape, IN UiMenuKeyPressFilterCallback KeyPressFilter OPTIONAL, IN PVOID Context OPTIONAL)
 

Variables

const UIVTBL TuiVtbl
 

Macro Definition Documentation

◆ D_LL

#define D_LL   0xC8

Definition at line 172 of file tui.h.

◆ D_LR

#define D_LR   0xBC

Definition at line 173 of file tui.h.

◆ D_UL

#define D_UL   0xC9 /* D_HORZ and D_VERT */

Definition at line 170 of file tui.h.

◆ D_UR

#define D_UR   0xBB

Definition at line 171 of file tui.h.

◆ HD_LL

#define HD_LL   0xD4

Definition at line 177 of file tui.h.

◆ HD_LR

#define HD_LR   0xBE

Definition at line 178 of file tui.h.

◆ HD_UL

#define HD_UL   0xD5 /* D_HORZ and VERT */

Definition at line 175 of file tui.h.

◆ HD_UR

#define HD_UR   0xB8

Definition at line 176 of file tui.h.

◆ LL

#define LL   0xC0

Definition at line 167 of file tui.h.

◆ LR

#define LR   0xD9

Definition at line 168 of file tui.h.

◆ TUI_TITLE_BOX_CHAR_HEIGHT

#define TUI_TITLE_BOX_CHAR_HEIGHT   5

Definition at line 33 of file tui.h.

◆ UL

#define UL   0xDA /* HORZ and VERT */

Definition at line 165 of file tui.h.

◆ UR

#define UR   0xBF

Definition at line 166 of file tui.h.

◆ VD_LL

#define VD_LL   0xD3

Definition at line 182 of file tui.h.

◆ VD_LR

#define VD_LR   0xBD

Definition at line 183 of file tui.h.

◆ VD_UL

#define VD_UL   0xD6 /* HORZ and D_VERT */

Definition at line 180 of file tui.h.

◆ VD_UR

#define VD_UR   0xB7

Definition at line 181 of file tui.h.

Function Documentation

◆ __drv_allocatesMem()

_Ret_maybenull_ __drv_allocatesMem ( Mem  )

Definition at line 55 of file gui.c.

58{
59 return NULL;
60}
#define NULL
Definition: types.h:112

◆ TuiDisplayMenu()

BOOLEAN TuiDisplayMenu ( IN PCSTR  MenuHeader,
IN PCSTR MenuFooter  OPTIONAL,
IN PCSTR  MenuItemList[],
IN ULONG  MenuItemCount,
IN ULONG  DefaultMenuItem,
IN LONG  MenuTimeOut,
OUT PULONG  SelectedMenuItem,
IN BOOLEAN  CanEscape,
IN UiMenuKeyPressFilterCallback KeyPressFilter  OPTIONAL,
IN PVOID Context  OPTIONAL 
)

Definition at line 30 of file tuimenu.c.

41{
42 UI_MENU_INFO MenuInformation;
43 ULONG LastClockSecond;
44 ULONG CurrentClockSecond;
45 ULONG KeyPress;
46
47 /*
48 * Before taking any default action if there is no timeout,
49 * check whether the supplied key filter callback function
50 * may handle a specific user keypress. If it does, the
51 * timeout is cancelled.
52 */
53 if (!MenuTimeOut && KeyPressFilter && MachConsKbHit())
54 {
55 /* Get the key (get the extended key if needed) */
56 KeyPress = MachConsGetCh();
57 if (KeyPress == KEY_EXTENDED)
58 KeyPress = MachConsGetCh();
59
60 /*
61 * Call the supplied key filter callback function to see
62 * if it is going to handle this keypress.
63 */
64 if (KeyPressFilter(KeyPress, DefaultMenuItem, Context))
65 {
66 /* It processed the key character, cancel the timeout */
67 MenuTimeOut = -1;
68 }
69 }
70
71 /* Check if there is no timeout */
72 if (!MenuTimeOut)
73 {
74 /* Return the default selected item */
75 if (SelectedMenuItem) *SelectedMenuItem = DefaultMenuItem;
76 return TRUE;
77 }
78
79 /* Setup the MENU_INFO structure */
80 MenuInformation.MenuHeader = MenuHeader;
81 MenuInformation.MenuFooter = MenuFooter;
82 MenuInformation.MenuItemList = MenuItemList;
83 MenuInformation.MenuItemCount = MenuItemCount;
84 MenuInformation.MenuTimeRemaining = MenuTimeOut;
85 MenuInformation.SelectedMenuItem = DefaultMenuItem;
86 MenuInformation.Context = Context;
87
88 /* Calculate the size of the menu box */
89 TuiCalcMenuBoxSize(&MenuInformation);
90
91 /* Draw the menu */
92 UiVtbl.DrawMenu(&MenuInformation);
93
94 /* Get the current second of time */
95 LastClockSecond = ArcGetTime()->Second;
96
97 /* Process keys */
98 while (TRUE)
99 {
100 /* Process key presses */
101 KeyPress = TuiProcessMenuKeyboardEvent(&MenuInformation, KeyPressFilter);
102
103 /* Check for ENTER or ESC */
104 if (KeyPress == KEY_ENTER) break;
105 if (CanEscape && KeyPress == KEY_ESC) return FALSE;
106
107 /* Get the updated time, and check if more than a second has elapsed */
108 CurrentClockSecond = ArcGetTime()->Second;
109 if (CurrentClockSecond != LastClockSecond)
110 {
111 /* Update the time information */
112 LastClockSecond = CurrentClockSecond;
113
114 // FIXME: Theme-specific
115 /* Update the date & time */
117
118 /* If there is a countdown, update it */
119 if (MenuInformation.MenuTimeRemaining > 0)
120 {
121 MenuInformation.MenuTimeRemaining--;
122 TuiDrawMenuTimeout(&MenuInformation);
123 }
124 else if (MenuInformation.MenuTimeRemaining == 0)
125 {
126 /* A timeout occurred, exit this loop and return selection */
128 break;
129 }
131 }
132
133 MachHwIdle();
134 }
135
136 /* Return the selected item */
137 if (SelectedMenuItem) *SelectedMenuItem = MenuInformation.SelectedMenuItem;
138 return TRUE;
139}
TIMEINFO * ArcGetTime(VOID)
Definition: arcemul.c:27
#define MachHwIdle()
Definition: machine.h:130
#define MachConsKbHit()
Definition: machine.h:88
#define MachConsGetCh()
Definition: machine.h:90
VOID VideoCopyOffScreenBufferToVRAM(VOID)
Definition: video.c:38
UIVTBL UiVtbl
Definition: ui.c:64
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KEY_EXTENDED
Definition: keycodes.h:38
#define KEY_ESC
Definition: keycodes.h:49
#define KEY_ENTER
Definition: keycodes.h:39
_In_ PVOID Context
Definition: storport.h:2269
USHORT Second
Definition: fw.h:16
VOID(* DrawMenu)(PUI_MENU_INFO MenuInfo)
Definition: ui.h:303
PCSTR MenuHeader
Definition: ui.h:212
LONG MenuTimeRemaining
Definition: ui.h:217
ULONG SelectedMenuItem
Definition: ui.h:218
PCSTR MenuFooter
Definition: ui.h:213
ULONG MenuItemCount
Definition: ui.h:216
PCSTR * MenuItemList
Definition: ui.h:215
PVOID Context
Definition: ui.h:219
VOID TuiUpdateDateTime(VOID)
Definition: tui.c:547
static ULONG TuiProcessMenuKeyboardEvent(_In_ PUI_MENU_INFO MenuInfo, _In_ UiMenuKeyPressFilterCallback KeyPressFilter)
Definition: tuimenu.c:464
static VOID TuiCalcMenuBoxSize(_In_ PUI_MENU_INFO MenuInfo)
Definition: tuimenu.c:142
static VOID TuiDrawMenuTimeout(_In_ PUI_MENU_INFO MenuInfo)
Definition: tuimenu.c:224
uint32_t ULONG
Definition: typedefs.h:59

◆ TuiDisplayThermalScreen()

VOID TuiDisplayThermalScreen ( VOID  )

Definition at line 1038 of file tui.c.

1039{
1040 CHAR Key;
1041
1044
1045 TuiPrintf("\nOn previous session, ReactOS has shutdown due to a thermal condition\n"
1046 "that would have otherwise caused fatal damage to the system.\n\n"
1047 "It's extremely advised to check that your system has proper cooling\n"
1048 "and that nothing blocks the airflow of your system (dust, debris, etc).\n\n"
1049 "Replace the thermal paste if necessary. Avoid skin contact with the hot\n"
1050 "system at all costs (if it's a laptop).\n\n"
1051 "Press ENTER to continue.");
1052
1053 /* Keep displaying the RSOH screen until the user presses the ENTER key */
1054 for (;;)
1055 {
1056 if (MachConsKbHit())
1057 {
1058 Key = MachConsGetCh();
1059 if (Key == KEY_EXTENDED)
1060 {
1061 Key = MachConsGetCh();
1062 }
1063
1064 if (Key == KEY_ENTER)
1065 {
1066 break;
1067 }
1068 }
1069 }
1070}
#define MachVideoClearScreen(Attr)
Definition: machine.h:92
#define MachVideoHideShowTextCursor(Show)
Definition: machine.h:102
#define ATTR(cFore, cBack)
Definition: ui.h:323
#define COLOR_WHITE
Definition: ui.h:344
#define COLOR_RED
Definition: ui.h:332
INT TuiPrintf(_In_ PCSTR Format,...)
Definition: tui.c:39
char CHAR
Definition: pedump.c:57

Referenced by RunLoader().

◆ TuiDrawBackdrop()

VOID TuiDrawBackdrop ( ULONG  DrawHeight)

Definition at line 272 of file tui.c.

273{
274 /* Fill in the background (excluding title box & status bar) */
275 TuiFillArea(0,
277 UiScreenWidth - 1,
278 DrawHeight - 2,
281
282 /* Draw the title box */
283 TuiDrawBox(0,
284 0,
285 UiScreenWidth - 1,
287 D_VERT,
288 D_HORZ,
289 TRUE,
290 FALSE,
292
293 /* Draw version text */
294 TuiDrawText(2,
295 1,
296 VERSION,
298
299 /* Draw copyright */
300 TuiDrawText(2,
301 2,
302 BY_AUTHOR,
304 TuiDrawText(2,
305 3,
308
309 /* Draw help text */
311 /*"F1 for Help"*/ "F8 for Options",
313
314 /* Draw title text */
316 2,
319
320 /* Update the date & time */
323}
#define VERSION
Definition: rdesktop.h:45
ULONG UiScreenWidth
Definition: ui.c:54
#define D_HORZ
Definition: ui.h:353
UCHAR UiTitleBoxBgColor
Definition: ui.c:31
#define D_VERT
Definition: ui.h:355
CHAR UiTitleBoxTitleText[260]
Definition: ui.c:47
UCHAR UiTitleBoxFgColor
Definition: ui.c:30
UCHAR UiBackdropFgColor
Definition: ui.c:27
UCHAR UiBackdropFillStyle
Definition: ui.c:29
UCHAR UiBackdropBgColor
Definition: ui.c:28
VOID TuiDrawBox(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ BOOLEAN Fill, _In_ BOOLEAN Shadow, _In_ UCHAR Attr)
Definition: tui.c:502
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: tui.c:329
VOID TuiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: tui.c:78
VOID TuiUpdateDateTime(VOID)
Definition: tui.c:547
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
#define TUI_TITLE_BOX_CHAR_HEIGHT
Definition: tui.h:33
#define BY_AUTHOR
Definition: ver.h:28
#define AUTHOR_EMAIL
Definition: ver.h:27

Referenced by TuiFadeInBackdrop().

◆ TuiDrawBox()

VOID TuiDrawBox ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Right,
_In_ ULONG  Bottom,
_In_ UCHAR  VertStyle,
_In_ UCHAR  HorzStyle,
_In_ BOOLEAN  Fill,
_In_ BOOLEAN  Shadow,
_In_ UCHAR  Attr 
)

Definition at line 502 of file tui.c.

512{
513 /* Fill in the box background */
514 if (Fill)
515 TuiFillArea(Left, Top, Right, Bottom, ' ', Attr);
516
517 /* Fill in the top horizontal line */
518 TuiDrawBoxTopLine(Left, Top, Right, VertStyle, HorzStyle, Attr);
519
520 /* Fill in the vertical left and right lines */
521 TuiFillArea(Left, Top+1, Left, Bottom-1, VertStyle, Attr);
522 TuiFillArea(Right, Top+1, Right, Bottom-1, VertStyle, Attr);
523
524 /* Fill in the bottom horizontal line */
525 TuiDrawBoxBottomLine(Left, Bottom, Right, VertStyle, HorzStyle, Attr);
526
527 /* Draw the shadow */
528 if (Shadow)
529 TuiDrawShadow(Left, Top, Right, Bottom);
530}
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53
VOID TuiDrawShadow(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom)
Definition: tui.c:359
VOID TuiDrawBoxBottomLine(_In_ ULONG Left, _In_ ULONG Bottom, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
Definition: tui.c:458
VOID TuiDrawBoxTopLine(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
Definition: tui.c:414
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:286

Referenced by TuiDrawBackdrop(), TuiDrawMsgBoxCommon(), and TuiDrawProgressBar().

◆ TuiDrawBoxBottomLine()

VOID TuiDrawBoxBottomLine ( _In_ ULONG  Left,
_In_ ULONG  Bottom,
_In_ ULONG  Right,
_In_ UCHAR  VertStyle,
_In_ UCHAR  HorzStyle,
_In_ UCHAR  Attr 
)

Definition at line 458 of file tui.c.

465{
466 UCHAR LLCorner, LRCorner;
467
468 /* Calculate the corner values */
469 if (HorzStyle == HORZ)
470 {
471 if (VertStyle == VERT)
472 {
473 LLCorner = LL;
474 LRCorner = LR;
475 }
476 else // VertStyle == D_VERT
477 {
478 LLCorner = VD_LL;
479 LRCorner = VD_LR;
480 }
481 }
482 else // HorzStyle == D_HORZ
483 {
484 if (VertStyle == VERT)
485 {
486 LLCorner = HD_LL;
487 LRCorner = HD_LR;
488 }
489 else // VertStyle == D_VERT
490 {
491 LLCorner = D_LL;
492 LRCorner = D_LR;
493 }
494 }
495
496 TuiFillArea(Left, Bottom, Left, Bottom, LLCorner, Attr);
497 TuiFillArea(Left+1, Bottom, Right-1, Bottom, HorzStyle, Attr);
498 TuiFillArea(Right, Bottom, Right, Bottom, LRCorner, Attr);
499}
#define VERT
Definition: ui.h:354
#define HORZ
Definition: ui.h:352
#define LR
Definition: tui.h:168
#define D_LR
Definition: tui.h:173
#define VD_LL
Definition: tui.h:182
#define HD_LL
Definition: tui.h:177
#define LL
Definition: tui.h:167
#define D_LL
Definition: tui.h:172
#define VD_LR
Definition: tui.h:183
#define HD_LR
Definition: tui.h:178
unsigned char UCHAR
Definition: typedefs.h:53

Referenced by TuiDrawBox(), and TuiDrawMenuTimeout().

◆ TuiDrawBoxTopLine()

VOID TuiDrawBoxTopLine ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Right,
_In_ UCHAR  VertStyle,
_In_ UCHAR  HorzStyle,
_In_ UCHAR  Attr 
)

Definition at line 414 of file tui.c.

421{
422 UCHAR ULCorner, URCorner;
423
424 /* Calculate the corner values */
425 if (HorzStyle == HORZ)
426 {
427 if (VertStyle == VERT)
428 {
429 ULCorner = UL;
430 URCorner = UR;
431 }
432 else // VertStyle == D_VERT
433 {
434 ULCorner = VD_UL;
435 URCorner = VD_UR;
436 }
437 }
438 else // HorzStyle == D_HORZ
439 {
440 if (VertStyle == VERT)
441 {
442 ULCorner = HD_UL;
443 URCorner = HD_UR;
444 }
445 else // VertStyle == D_VERT
446 {
447 ULCorner = D_UL;
448 URCorner = D_UR;
449 }
450 }
451
452 TuiFillArea(Left, Top, Left, Top, ULCorner, Attr);
453 TuiFillArea(Left+1, Top, Right-1, Top, HorzStyle, Attr);
454 TuiFillArea(Right, Top, Right, Top, URCorner, Attr);
455}
#define VD_UL
Definition: tui.h:180
#define UR
Definition: tui.h:166
#define D_UL
Definition: tui.h:170
#define UL
Definition: tui.h:165
#define HD_UR
Definition: tui.h:176
#define D_UR
Definition: tui.h:171
#define HD_UL
Definition: tui.h:175
#define VD_UR
Definition: tui.h:181

Referenced by TuiDrawBox().

◆ TuiDrawCenteredText()

VOID TuiDrawCenteredText ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Right,
_In_ ULONG  Bottom,
_In_ PCSTR  TextString,
_In_ UCHAR  Attr 
)

Definition at line 118 of file tui.c.

125{
126 SIZE_T TextLength;
127 SIZE_T Index, LastIndex;
128 ULONG LineBreakCount;
129 ULONG BoxWidth, BoxHeight;
130 ULONG RealLeft, RealTop;
131 ULONG X, Y;
132 CHAR Temp[2];
133
134 /* Query text length */
135 TextLength = strlen(TextString);
136
137 /* Count the new lines and the box width */
138 LineBreakCount = 0;
139 BoxWidth = 0;
140 LastIndex = 0;
141 for (Index = 0; Index < TextLength; Index++)
142 {
143 /* Scan for new lines */
144 if (TextString[Index] == '\n')
145 {
146 /* Remember the new line */
147 LastIndex = Index;
148 LineBreakCount++;
149 }
150 else
151 {
152 /* Check for new larger box width */
153 if ((Index - LastIndex) > BoxWidth)
154 {
155 /* Update it */
156 BoxWidth = (ULONG)(Index - LastIndex);
157 }
158 }
159 }
160
161 /* Base the box height on the number of lines */
162 BoxHeight = LineBreakCount + 1;
163
164 /*
165 * Create the centered coordinates.
166 * Here, the Left/Top/Right/Bottom rectangle is a hint, around
167 * which we center the "real" text rectangle RealLeft/RealTop.
168 */
169 RealLeft = (Left + Right - BoxWidth + 1) / 2;
170 RealTop = (Top + Bottom - BoxHeight + 1) / 2;
171
172 /* Now go for a second scan */
173 LastIndex = 0;
174 for (Index = 0; Index < TextLength; Index++)
175 {
176 /* Look for new lines again */
177 if (TextString[Index] == '\n')
178 {
179 /* Update where the text should start */
180 RealTop++;
181 LastIndex = 0;
182 }
183 else
184 {
185 /* We've got a line of text to print, do it */
186 X = (ULONG)(RealLeft + LastIndex);
187 Y = RealTop;
188 LastIndex++;
189 Temp[0] = TextString[Index];
190 Temp[1] = 0;
191 TuiDrawText(X, Y, Temp, Attr);
192 }
193 }
194}
#define Y(I)
#define X(b, s)
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by MiniTuiSetProgressBarText(), and TuiSetProgressBarText().

◆ TuiDrawMenu()

VOID TuiDrawMenu ( _In_ PUI_MENU_INFO  MenuInfo)

Definition at line 198 of file tuimenu.c.

200{
201 ULONG i;
202
203 // FIXME: Theme-specific
204 /* Draw the backdrop */
206
207 /* Draw the menu box */
208 TuiDrawMenuBox(MenuInfo);
209
210 /* Draw each line of the menu */
211 for (i = 0; i < MenuInfo->MenuItemCount; ++i)
212 {
213 TuiDrawMenuItem(MenuInfo, i);
214 }
215
216 // FIXME: Theme-specific
217 /* Update the status bar */
218 UiVtbl.DrawStatusText("Use \x18 and \x19 to select, then press ENTER.");
219
221}
VOID UiDrawBackdrop(ULONG DrawHeight)
Definition: ui.c:233
ULONG UiGetScreenHeight(VOID)
Definition: ui.c:655
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
VOID(* DrawStatusText)(PCSTR StatusText)
Definition: ui.h:264
VOID TuiDrawMenuItem(_In_ PUI_MENU_INFO MenuInfo, _In_ ULONG MenuItemNumber)
Definition: tuimenu.c:367
VOID TuiDrawMenuBox(_In_ PUI_MENU_INFO MenuInfo)
Definition: tuimenu.c:343

◆ TuiDrawMenuBox()

VOID TuiDrawMenuBox ( _In_ PUI_MENU_INFO  MenuInfo)

Definition at line 343 of file tuimenu.c.

345{
346 // FIXME: Theme-specific
347 /* Draw the menu box if requested */
348 if (UiMenuBox)
349 {
350 UiDrawBox(MenuInfo->Left,
351 MenuInfo->Top,
352 MenuInfo->Right,
353 MenuInfo->Bottom,
354 D_VERT,
355 D_HORZ,
356 FALSE, // Filled
357 TRUE, // Shadow
359 }
360
361 /* Update the date & time */
363 TuiDrawMenuTimeout(MenuInfo);
364}
UCHAR UiMenuBgColor
Definition: ui.c:35
BOOLEAN UiMenuBox
Definition: ui.c:43
VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
Definition: ui.c:248
UCHAR UiMenuFgColor
Definition: ui.c:34

Referenced by MiniTuiDrawMenu(), and TuiDrawMenu().

◆ TuiDrawMenuItem()

VOID TuiDrawMenuItem ( _In_ PUI_MENU_INFO  MenuInfo,
_In_ ULONG  MenuItemNumber 
)

Definition at line 367 of file tuimenu.c.

370{
371 ULONG SpaceLeft;
372 ULONG SpaceRight;
373 UCHAR Attribute;
374 CHAR MenuLineText[80];
375
376 /* If this is a separator */
377 if (MenuInfo->MenuItemList[MenuItemNumber] == NULL)
378 {
379 // FIXME: Theme-specific
380 /* Draw its left box corner */
381 if (UiMenuBox)
382 {
383 UiDrawText(MenuInfo->Left,
384 MenuInfo->Top + 1 + MenuItemNumber,
385 "\xC7",
387 }
388
389 /* Make it a separator line and use menu colors */
390 RtlZeroMemory(MenuLineText, sizeof(MenuLineText));
391 RtlFillMemory(MenuLineText,
392 min(sizeof(MenuLineText), (MenuInfo->Right - MenuInfo->Left - 1)),
393 0xC4);
394
395 /* Draw the item */
396 UiDrawText(MenuInfo->Left + 1,
397 MenuInfo->Top + 1 + MenuItemNumber,
398 MenuLineText,
400
401 // FIXME: Theme-specific
402 /* Draw its right box corner */
403 if (UiMenuBox)
404 {
405 UiDrawText(MenuInfo->Right,
406 MenuInfo->Top + 1 + MenuItemNumber,
407 "\xB6",
409 }
410
411 /* We are done */
412 return;
413 }
414
415 /* This is not a separator */
416 ASSERT(MenuInfo->MenuItemList[MenuItemNumber]);
417
418 /* Check if using centered menu */
419 if (UiCenterMenu)
420 {
421 /*
422 * We will want the string centered so calculate
423 * how many spaces will be to the left and right.
424 */
425 ULONG SpaceTotal =
426 (MenuInfo->Right - MenuInfo->Left - 2) -
427 (ULONG)strlen(MenuInfo->MenuItemList[MenuItemNumber]);
428 SpaceLeft = (SpaceTotal / 2) + 1;
429 SpaceRight = (SpaceTotal - SpaceLeft) + 1;
430 }
431 else
432 {
433 /* Simply left-align it */
434 SpaceLeft = 4;
435 SpaceRight = 0;
436 }
437
438 /* Format the item text string */
439 RtlStringCbPrintfA(MenuLineText, sizeof(MenuLineText),
440 "%*s%s%*s",
441 SpaceLeft, "", // Left padding
442 MenuInfo->MenuItemList[MenuItemNumber],
443 SpaceRight, ""); // Right padding
444
445 if (MenuItemNumber == MenuInfo->SelectedMenuItem)
446 {
447 /* If this is the selected item, use the selected colors */
449 }
450 else
451 {
452 /* Normal item colors */
453 Attribute = ATTR(UiTextColor, UiMenuBgColor);
454 }
455
456 /* Draw the item */
457 UiDrawText(MenuInfo->Left + 1,
458 MenuInfo->Top + 1 + MenuItemNumber,
459 MenuLineText,
460 Attribute);
461}
VOID UiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: ui.c:254
BOOLEAN UiCenterMenu
Definition: ui.c:44
UCHAR UiTextColor
Definition: ui.c:36
UCHAR UiSelectedTextColor
Definition: ui.c:37
UCHAR UiSelectedTextBgColor
Definition: ui.c:38
#define ASSERT(a)
Definition: mode.c:44
#define min(a, b)
Definition: monoChain.cc:55
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by MiniTuiDrawMenu(), TuiDrawMenu(), and TuiProcessMenuKeyboardEvent().

◆ TuiDrawShadow()

VOID TuiDrawShadow ( ULONG  Left,
ULONG  Top,
ULONG  Right,
ULONG  Bottom 
)

Definition at line 359 of file tui.c.

360{
361 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
362 ULONG i;
363 BOOLEAN RightShadow = (Right < (UiScreenWidth - 1));
364 BOOLEAN DoubleRightShadow = ((Right + 1) < (UiScreenWidth - 1));
365 BOOLEAN BottomShadow = (Bottom < (UiScreenHeight - 1));
367
368 /* Cap the right and bottom borders */
369 Right = min(Right, UiScreenWidth - 1);
371
372 /* Shade the bottom of the area */
373 if (BottomShadow)
374 {
375 i = Left + (DoubleWidth ? 2 : 1);
376 for (; i <= Right; ++i)
377 {
378 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+(i*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
379 }
380 }
381
382 /* Shade the right of the area */
383 if (RightShadow)
384 {
385 for (i = Top + 1; i <= Bottom; ++i)
386 {
387 ScreenMemory[((i*2)*UiScreenWidth)+((Right+1)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
388 }
389 }
390 if (DoubleWidth && DoubleRightShadow)
391 {
392 for (i = Top + 1; i <= Bottom; ++i)
393 {
394 ScreenMemory[((i*2)*UiScreenWidth)+((Right+2)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
395 }
396 }
397
398 /* Shade the bottom right corner */
399 if (RightShadow && BottomShadow)
400 {
401 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+((Right+1)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
402 }
403 if (DoubleWidth && DoubleRightShadow && BottomShadow)
404 {
405 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+((Right+2)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
406 }
407}
unsigned char BOOLEAN
Definition: actypes.h:127
#define COLOR_GRAY
Definition: ui.h:335
ULONG UiScreenHeight
Definition: ui.c:55
#define COLOR_BLACK
Definition: ui.h:328
PVOID TextVideoBuffer
Definition: tui.c:30
static BOOLEAN DoubleWidth
Definition: video.c:58
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by TuiDrawBox().

◆ TuiDrawStatusText()

VOID TuiDrawStatusText ( PCSTR  StatusText)

Definition at line 532 of file tui.c.

533{
534 SIZE_T i;
535
538
539 for (i=strlen(StatusText)+1; i<UiScreenWidth; i++)
540 {
542 }
543
545}
UCHAR UiStatusBarBgColor
Definition: ui.c:26
UCHAR UiStatusBarFgColor
Definition: ui.c:25

◆ TuiDrawText()

VOID TuiDrawText ( _In_ ULONG  X,
_In_ ULONG  Y,
_In_ PCSTR  Text,
_In_ UCHAR  Attr 
)

Definition at line 78 of file tui.c.

83{
84 TuiDrawText2(X, Y, 0 /*(ULONG)strlen(Text)*/, Text, Attr);
85}
VOID TuiDrawText2(_In_ ULONG X, _In_ ULONG Y, _In_opt_ ULONG MaxNumChars, _In_reads_or_z_(MaxNumChars) PCSTR Text, _In_ UCHAR Attr)
Definition: tui.c:95
char * Text
Definition: combotst.c:136

Referenced by TuiDrawBackdrop(), TuiDrawCenteredText(), TuiDrawStatusText(), and TuiUpdateDateTime().

◆ TuiDrawText2()

VOID TuiDrawText2 ( _In_ ULONG  X,
_In_ ULONG  Y,
_In_opt_ ULONG  MaxNumChars,
_In_reads_or_z_(MaxNumChars) PCSTR  Text,
_In_ UCHAR  Attr 
)

Definition at line 95 of file tui.c.

101{
102 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
103 ULONG i, j;
104
105 /* Don't display anything if we are out of the screen */
106 if ((X >= UiScreenWidth) || (Y >= UiScreenHeight))
107 return;
108
109 /* Draw the text, not exceeding the width */
110 for (i = X, j = 0; Text[j] && i < UiScreenWidth && (MaxNumChars > 0 ? j < MaxNumChars : TRUE); i++, j++)
111 {
112 ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)] = (UCHAR)Text[j];
113 ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)+1] = Attr;
114 }
115}
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 GLint GLint j
Definition: glfuncs.h:250

Referenced by TuiDrawText().

◆ TuiEditBox()

BOOLEAN TuiEditBox ( PCSTR  MessageText,
PCHAR  EditTextBuffer,
ULONG  Length 
)

Definition at line 1072 of file tui.c.

1073{
1074 CHAR key;
1075 BOOLEAN Extended;
1076 INT EditBoxLine;
1077 ULONG EditBoxStartX, EditBoxEndX;
1078 INT EditBoxCursorX;
1079 ULONG EditBoxTextLength, EditBoxTextPosition;
1080 INT EditBoxTextDisplayIndex;
1081 BOOLEAN ReturnCode;
1082 SMALL_RECT BoxRect;
1084
1085 /* Save the screen contents */
1086 ScreenBuffer = TuiSaveScreen();
1087
1088 /* Draw the common parts of the message box */
1089 TuiDrawMsgBoxCommon(MessageText, &BoxRect);
1090
1091 EditBoxTextLength = (ULONG)strlen(EditTextBuffer);
1092 EditBoxTextLength = min(EditBoxTextLength, Length - 1);
1093 EditBoxTextPosition = 0;
1094 EditBoxLine = BoxRect.Bottom - 2;
1095 EditBoxStartX = BoxRect.Left + 3;
1096 EditBoxEndX = BoxRect.Right - 3;
1097
1098 // Draw the edit box background and the text
1099 UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1100 UiDrawText2(EditBoxStartX, EditBoxLine, EditBoxEndX - EditBoxStartX + 1, EditTextBuffer, ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1101
1102 // Show the cursor
1103 EditBoxCursorX = EditBoxStartX;
1104 MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
1106
1107 // Draw status text
1108 UiDrawStatusText("Press ENTER to continue, or ESC to cancel");
1109
1111
1112 //
1113 // Enter the text. Please keep in mind that the default input mode
1114 // of the edit boxes is in insertion mode, that is, you can insert
1115 // text without erasing the existing one.
1116 //
1117 for (;;)
1118 {
1119 if (MachConsKbHit())
1120 {
1121 Extended = FALSE;
1122 key = MachConsGetCh();
1123 if (key == KEY_EXTENDED)
1124 {
1125 Extended = TRUE;
1126 key = MachConsGetCh();
1127 }
1128
1129 if (key == KEY_ENTER)
1130 {
1131 ReturnCode = TRUE;
1132 break;
1133 }
1134 else if (key == KEY_ESC)
1135 {
1136 ReturnCode = FALSE;
1137 break;
1138 }
1139 else if (key == KEY_BACKSPACE) // Remove a character
1140 {
1141 if ( (EditBoxTextLength > 0) && (EditBoxTextPosition > 0) &&
1142 (EditBoxTextPosition <= EditBoxTextLength) )
1143 {
1144 EditBoxTextPosition--;
1145 memmove(EditTextBuffer + EditBoxTextPosition,
1146 EditTextBuffer + EditBoxTextPosition + 1,
1147 EditBoxTextLength - EditBoxTextPosition);
1148 EditBoxTextLength--;
1149 EditTextBuffer[EditBoxTextLength] = 0;
1150 }
1151 else
1152 {
1153 MachBeep();
1154 }
1155 }
1156 else if (Extended && key == KEY_DELETE) // Remove a character
1157 {
1158 if ( (EditBoxTextLength > 0) &&
1159 (EditBoxTextPosition < EditBoxTextLength) )
1160 {
1161 memmove(EditTextBuffer + EditBoxTextPosition,
1162 EditTextBuffer + EditBoxTextPosition + 1,
1163 EditBoxTextLength - EditBoxTextPosition);
1164 EditBoxTextLength--;
1165 EditTextBuffer[EditBoxTextLength] = 0;
1166 }
1167 else
1168 {
1169 MachBeep();
1170 }
1171 }
1172 else if (Extended && key == KEY_HOME) // Go to the start of the buffer
1173 {
1174 EditBoxTextPosition = 0;
1175 }
1176 else if (Extended && key == KEY_END) // Go to the end of the buffer
1177 {
1178 EditBoxTextPosition = EditBoxTextLength;
1179 }
1180 else if (Extended && key == KEY_RIGHT) // Go right
1181 {
1182 if (EditBoxTextPosition < EditBoxTextLength)
1183 EditBoxTextPosition++;
1184 else
1185 MachBeep();
1186 }
1187 else if (Extended && key == KEY_LEFT) // Go left
1188 {
1189 if (EditBoxTextPosition > 0)
1190 EditBoxTextPosition--;
1191 else
1192 MachBeep();
1193 }
1194 else if (!Extended) // Add this key to the buffer
1195 {
1196 if ( (EditBoxTextLength < Length - 1) &&
1197 (EditBoxTextPosition < Length - 1) )
1198 {
1199 memmove(EditTextBuffer + EditBoxTextPosition + 1,
1200 EditTextBuffer + EditBoxTextPosition,
1201 EditBoxTextLength - EditBoxTextPosition);
1202 EditTextBuffer[EditBoxTextPosition] = key;
1203 EditBoxTextPosition++;
1204 EditBoxTextLength++;
1205 EditTextBuffer[EditBoxTextLength] = 0;
1206 }
1207 else
1208 {
1209 MachBeep();
1210 }
1211 }
1212 else
1213 {
1214 MachBeep();
1215 }
1216 }
1217
1218 // Draw the edit box background
1219 UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1220
1221 // Fill the text in
1222 if (EditBoxTextPosition > (EditBoxEndX - EditBoxStartX))
1223 {
1224 EditBoxTextDisplayIndex = EditBoxTextPosition - (EditBoxEndX - EditBoxStartX);
1225 EditBoxCursorX = EditBoxEndX;
1226 }
1227 else
1228 {
1229 EditBoxTextDisplayIndex = 0;
1230 EditBoxCursorX = EditBoxStartX + EditBoxTextPosition;
1231 }
1232 UiDrawText2(EditBoxStartX, EditBoxLine, EditBoxEndX - EditBoxStartX + 1, &EditTextBuffer[EditBoxTextDisplayIndex], ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1233
1234 // Move the cursor
1235 MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
1236
1238
1240
1241 MachHwIdle();
1242 }
1243
1244 // Hide the cursor again
1246
1247 /* Restore the screen contents */
1249
1250 return ReturnCode;
1251}
#define MachBeep()
Definition: machine.h:116
#define MachVideoSetTextCursorPosition(X, Y)
Definition: machine.h:100
UCHAR UiEditBoxTextColor
Definition: ui.c:39
VOID UiDrawText2(_In_ ULONG X, _In_ ULONG Y, _In_opt_ ULONG MaxNumChars, _In_reads_or_z_(MaxNumChars) PCSTR Text, _In_ UCHAR Attr)
Definition: ui.c:264
VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.c:238
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:286
UCHAR UiEditBoxBgColor
Definition: ui.c:40
VOID TuiRestoreScreen(_In_opt_ __drv_freesMem(Mem) PUCHAR Buffer)
Definition: tui.c:640
static VOID TuiDrawMsgBoxCommon(_In_ PCSTR MessageText, _Out_ PSMALL_RECT MsgBoxRect)
Definition: tui.c:662
#define KEY_RIGHT
Definition: keycodes.h:48
#define KEY_DELETE
Definition: keycodes.h:41
#define KEY_BACKSPACE
Definition: keycodes.h:40
#define KEY_END
Definition: keycodes.h:64
#define KEY_LEFT
Definition: keycodes.h:47
#define KEY_HOME
Definition: keycodes.h:44
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
HANDLE ScreenBuffer
Definition: notevil.c:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
SHORT Right
Definition: tui.c:26
SHORT Left
Definition: tui.c:24
SHORT Bottom
Definition: tui.c:27
Definition: copy.c:22
int32_t INT
Definition: typedefs.h:58

◆ TuiFadeInBackdrop()

VOID TuiFadeInBackdrop ( VOID  )

Definition at line 982 of file tui.c.

983{
984 PPALETTE_ENTRY TuiFadePalette = NULL;
985
987 {
988 TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
990
991 if (TuiFadePalette != NULL)
992 {
993 VideoSavePaletteState(TuiFadePalette, 64);
995 }
996 }
997
998 // Draw the backdrop and title box
1000
1001 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
1002 {
1003 VideoFadeIn(TuiFadePalette, 64);
1004 FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE);
1005 }
1006}
#define MachVideoIsPaletteFixed()
Definition: machine.h:108
VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: heap.c:553
PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: heap.c:545
VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:79
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
Definition: video.c:67
struct _PALETTE_ENTRY * PPALETTE_ENTRY
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:44
BOOLEAN UiUseSpecialEffects
Definition: ui.c:45
VOID TuiDrawBackdrop(ULONG DrawHeight)
Definition: tui.c:272
#define TAG_TUI_PALETTE
Definition: tui.c:199
Definition: video.h:12

◆ TuiFadeOut()

VOID TuiFadeOut ( VOID  )

Definition at line 1008 of file tui.c.

1009{
1010 PPALETTE_ENTRY TuiFadePalette = NULL;
1011
1013 {
1014 TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
1016
1017 if (TuiFadePalette != NULL)
1018 {
1019 VideoSavePaletteState(TuiFadePalette, 64);
1020 }
1021 }
1022
1023 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
1024 {
1025 VideoFadeOut(64);
1026 }
1027
1029
1030 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
1031 {
1032 VideoRestorePaletteState(TuiFadePalette, 64);
1033 FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE);
1034 }
1035
1036}
#define MachVideoSetDisplayMode(Mode, Init)
Definition: machine.h:94
VOID VideoFadeOut(ULONG ColorCount)
Definition: video.c:138
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:54

Referenced by TuiUnInitialize().

◆ TuiFillArea()

VOID TuiFillArea ( ULONG  Left,
ULONG  Top,
ULONG  Right,
ULONG  Bottom,
CHAR  FillChar,
UCHAR  Attr 
)

Definition at line 329 of file tui.c.

330{
331 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
332 ULONG i, j;
333
334 /* Clip the area to the screen */
335 if ((Left >= UiScreenWidth) || (Top >= UiScreenHeight))
336 {
337 return;
338 }
339 if (Right >= UiScreenWidth)
340 Right = UiScreenWidth - 1;
341 if (Bottom >= UiScreenHeight)
343
344 /* Loop through each line and column and fill it in */
345 for (i = Top; i <= Bottom; ++i)
346 {
347 for (j = Left; j <= Right; ++j)
348 {
349 ScreenMemory[((i*2)*UiScreenWidth)+(j*2)] = (UCHAR)FillChar;
350 ScreenMemory[((i*2)*UiScreenWidth)+(j*2)+1] = Attr;
351 }
352 }
353}

Referenced by MiniTuiDrawBackdrop(), MiniTuiSetProgressBarText(), MiniTuiTickProgressBar(), TuiDrawBackdrop(), TuiDrawBox(), TuiDrawBoxBottomLine(), TuiDrawBoxTopLine(), TuiDrawMenuTimeout(), TuiSetProgressBarText(), and TuiTickProgressBar().

◆ TuiInitialize()

BOOLEAN TuiInitialize ( VOID  )

Definition at line 203 of file tui.c.

204{
208
210 if (TextVideoBuffer == NULL)
211 {
212 return FALSE;
213 }
214
215 /* Load default settings with "Full" TUI Theme */
216
233
235 UiMenuBox = TRUE;
238
239 // TODO: Have a boolean to show/hide title box?
241 "Boot Menu");
242
244 "[Time Remaining: %d]");
245
246 return TRUE;
247}
PVOID VideoAllocateOffScreenBuffer(VOID)
Definition: video.c:16
UCHAR UiMessageBoxFgColor
Definition: ui.c:32
UCHAR UiMessageBoxBgColor
Definition: ui.c:33
#define COLOR_BLUE
Definition: ui.h:329
#define COLOR_YELLOW
Definition: ui.h:343
#define MEDIUM_FILL
Definition: ui.h:317
#define COLOR_CYAN
Definition: ui.h:331
CHAR UiTimeText[260]
Definition: ui.c:48
BOOLEAN UiShowTime
Definition: ui.c:42
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156

Referenced by MiniTuiInitialize().

◆ TuiMessageBox()

VOID TuiMessageBox ( _In_ PCSTR  MessageText)

Definition at line 745 of file tui.c.

747{
749
750 /* Save the screen contents */
751 ScreenBuffer = TuiSaveScreen();
752
753 /* Display the message box */
754 TuiMessageBoxCritical(MessageText);
755
756 /* Restore the screen contents */
758}
VOID TuiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: tui.c:761

◆ TuiMessageBoxCritical()

VOID TuiMessageBoxCritical ( _In_ PCSTR  MessageText)

Definition at line 761 of file tui.c.

763{
764 SMALL_RECT BoxRect;
765 CHAR key;
766
767 /* Draw the common parts of the message box */
768 TuiDrawMsgBoxCommon(MessageText, &BoxRect);
769
770 /* Draw centered OK button */
771 UiDrawText((BoxRect.Left + BoxRect.Right) / 2 - 3,
772 BoxRect.Bottom - 2,
773 " OK ",
775
776 /* Draw status text */
777 UiDrawStatusText("Press ENTER to continue");
778
780
781 for (;;)
782 {
783 if (MachConsKbHit())
784 {
785 key = MachConsGetCh();
786 if (key == KEY_EXTENDED)
787 key = MachConsGetCh();
788
789 if ((key == KEY_ENTER) || (key == KEY_SPACE) || (key == KEY_ESC))
790 break;
791 }
792
794
796
797 MachHwIdle();
798 }
799}
#define KEY_SPACE
Definition: keycodes.h:42

Referenced by TuiMessageBox().

◆ TuiPrintf()

INT TuiPrintf ( _In_ PCSTR  Format,
  ... 
)

Definition at line 39 of file tui.c.

41{
42 INT i;
43 INT Length;
44 va_list ap;
45 CHAR Buffer[512];
46
48 Length = _vsnprintf(Buffer, sizeof(Buffer), Format, ap);
49 va_end(ap);
50
51 if (Length == -1)
52 Length = (INT)sizeof(Buffer);
53
54 for (i = 0; i < Length; i++)
55 {
57 }
58
59 return Length;
60}
#define MachConsPutChar(Ch)
Definition: machine.h:86
Definition: bufpool.h:45
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
#define _vsnprintf
Definition: _vsnprintf.c:28
#define INT
Definition: polytest.cpp:20
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by LoadAndBootWindowsCommon(), MachInit(), and TuiDisplayThermalScreen().

◆ TuiRestoreScreen()

VOID TuiRestoreScreen ( _In_opt_ __drv_freesMem(Mem) PUCHAR  Buffer)

Definition at line 640 of file tui.c.

642{
643 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
644 ULONG i;
645
646 if (!Buffer)
647 return;
648
649 /* Loop through each cell and copy it */
650 for (i=0; i < (UiScreenWidth * UiScreenHeight * 2); i++)
651 {
652 ScreenMemory[i] = Buffer[i];
653 }
654
655 /* Free the buffer */
657
659}
#define TAG_TUI_SCREENBUFFER
Definition: tui.c:198

Referenced by TuiEditBox(), and TuiMessageBox().

◆ TuiTextToColor()

UCHAR TuiTextToColor ( PCSTR  ColorText)

Definition at line 919 of file tui.c.

920{
921 static const struct
922 {
923 PCSTR ColorName;
924 UCHAR ColorValue;
925 } Colors[] =
926 {
927 {"Black" , COLOR_BLACK },
928 {"Blue" , COLOR_BLUE },
929 {"Green" , COLOR_GREEN },
930 {"Cyan" , COLOR_CYAN },
931 {"Red" , COLOR_RED },
932 {"Magenta", COLOR_MAGENTA},
933 {"Brown" , COLOR_BROWN },
934 {"Gray" , COLOR_GRAY },
935 {"DarkGray" , COLOR_DARKGRAY },
936 {"LightBlue" , COLOR_LIGHTBLUE },
937 {"LightGreen" , COLOR_LIGHTGREEN },
938 {"LightCyan" , COLOR_LIGHTCYAN },
939 {"LightRed" , COLOR_LIGHTRED },
940 {"LightMagenta", COLOR_LIGHTMAGENTA},
941 {"Yellow" , COLOR_YELLOW },
942 {"White" , COLOR_WHITE },
943 };
944 ULONG i;
945
946 if (_stricmp(ColorText, "Default") == 0)
948
949 for (i = 0; i < RTL_NUMBER_OF(Colors); ++i)
950 {
951 if (_stricmp(ColorText, Colors[i].ColorName) == 0)
952 return Colors[i].ColorValue;
953 }
954
955 return COLOR_BLACK;
956}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
Colors
Definition: ansiprsr.h:4
#define COLOR_LIGHTBLUE
Definition: ui.h:338
#define COLOR_LIGHTMAGENTA
Definition: ui.h:342
#define COLOR_DARKGRAY
Definition: ui.h:337
#define COLOR_LIGHTRED
Definition: ui.h:341
#define COLOR_LIGHTCYAN
Definition: ui.h:340
#define COLOR_MAGENTA
Definition: ui.h:333
#define COLOR_BROWN
Definition: ui.h:334
#define COLOR_LIGHTGREEN
Definition: ui.h:339
#define COLOR_GREEN
Definition: ui.h:330
UCHAR MachDefaultTextColor
Definition: pcvideo.c:114
#define _stricmp
Definition: cat.c:22
const char * PCSTR
Definition: typedefs.h:52

Referenced by MiniTuiInitialize().

◆ TuiTextToFillStyle()

UCHAR TuiTextToFillStyle ( PCSTR  FillStyleText)

Definition at line 958 of file tui.c.

959{
960 static const struct
961 {
962 PCSTR FillStyleName;
963 UCHAR FillStyleValue;
964 } FillStyles[] =
965 {
966 {"None" , ' '},
967 {"Light" , LIGHT_FILL },
968 {"Medium", MEDIUM_FILL},
969 {"Dark" , DARK_FILL },
970 };
971 ULONG i;
972
973 for (i = 0; i < RTL_NUMBER_OF(FillStyles); ++i)
974 {
975 if (_stricmp(FillStyleText, FillStyles[i].FillStyleName) == 0)
976 return FillStyles[i].FillStyleValue;
977 }
978
979 return LIGHT_FILL;
980}
#define LIGHT_FILL
Definition: ui.h:316
#define DARK_FILL
Definition: ui.h:318

◆ TuiTruncateStringEllipsis()

VOID TuiTruncateStringEllipsis ( _Inout_z_ PSTR  StringText,
_In_ ULONG  MaxChars 
)

Definition at line 63 of file tui.c.

66{
67 /* If it's too large, just add some ellipsis past the maximum */
68 if (strlen(StringText) > MaxChars)
69 strcpy(&StringText[MaxChars - 3], "...");
70}
strcpy
Definition: string.h:131

Referenced by MiniTuiSetProgressBarText(), and TuiSetProgressBarText().

◆ TuiUnInitialize()

VOID TuiUnInitialize ( VOID  )

Definition at line 249 of file tui.c.

250{
251 /* Do nothing if already uninitialized */
252 if (!TextVideoBuffer)
253 return;
254
256 {
257 TuiFadeOut();
258 }
259 else
260 {
262 }
263
266
270}
VOID VideoFreeOffScreenBuffer(VOID)
Definition: video.c:29
VOID TuiFadeOut(VOID)
Definition: tui.c:1008

◆ TuiUpdateDateTime()

VOID TuiUpdateDateTime ( VOID  )

Definition at line 547 of file tui.c.

548{
549 TIMEINFO* TimeInfo;
550 PCSTR DayPostfix;
551 BOOLEAN PMHour = FALSE;
552 CHAR Buffer[40];
553
554 /* Don't draw the time if this has been disabled */
555 if (!UiShowTime) return;
556
557 TimeInfo = ArcGetTime();
558 if (TimeInfo->Year < 1 || 9999 < TimeInfo->Year ||
559 TimeInfo->Month < 1 || 12 < TimeInfo->Month ||
560 TimeInfo->Day < 1 || 31 < TimeInfo->Day ||
561 23 < TimeInfo->Hour ||
562 59 < TimeInfo->Minute ||
563 59 < TimeInfo->Second)
564 {
565 /* This happens on QEmu sometimes. We just skip updating. */
566 return;
567 }
568
569 /* Get the day postfix */
570 if (1 == TimeInfo->Day || 21 == TimeInfo->Day || 31 == TimeInfo->Day)
571 DayPostfix = "st";
572 else if (2 == TimeInfo->Day || 22 == TimeInfo->Day)
573 DayPostfix = "nd";
574 else if (3 == TimeInfo->Day || 23 == TimeInfo->Day)
575 DayPostfix = "rd";
576 else
577 DayPostfix = "th";
578
579 /* Build the date string in format: "MMMM dx yyyy" */
581 "%s %d%s %d",
582 UiMonthNames[TimeInfo->Month - 1],
583 TimeInfo->Day,
584 DayPostfix,
585 TimeInfo->Year);
586
587 /* Draw the date */
590
591 /* Get the hour and change from 24-hour mode to 12-hour */
592 if (TimeInfo->Hour > 12)
593 {
594 TimeInfo->Hour -= 12;
595 PMHour = TRUE;
596 }
597 if (TimeInfo->Hour == 0)
598 {
599 TimeInfo->Hour = 12;
600 }
601
602 /* Build the time string in format: "h:mm:ss tt" */
604 " %d:%02d:%02d %s",
605 TimeInfo->Hour,
606 TimeInfo->Minute,
607 TimeInfo->Second,
608 PMHour ? "PM" : "AM");
609
610 /* Draw the time */
613}
const PCSTR UiMonthNames[12]
Definition: ui.c:50
Definition: fw.h:10
USHORT Month
Definition: fw.h:12
USHORT Day
Definition: fw.h:13
USHORT Minute
Definition: fw.h:15
USHORT Hour
Definition: fw.h:14
USHORT Year
Definition: fw.h:11

Referenced by MiniTuiTickProgressBar(), TuiDisplayMenu(), TuiDrawBackdrop(), TuiDrawMenuBox(), TuiEditBox(), TuiMessageBoxCritical(), and TuiTickProgressBar().

Variable Documentation

◆ TuiVtbl

const UIVTBL TuiVtbl
extern

Definition at line 1253 of file tui.c.

Referenced by UiInitialize().