ReactOS 0.4.15-dev-7093-g01a8288
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 (VOID)
 
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)
 
VOID TuiSaveScreen (PUCHAR Buffer)
 
VOID TuiRestoreScreen (PUCHAR Buffer)
 
VOID TuiMessageBox (PCSTR MessageText)
 
VOID TuiMessageBoxCritical (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 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 BOOLEAN ShowBootOptions, 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 155 of file tui.h.

◆ D_LR

#define D_LR   0xBC

Definition at line 156 of file tui.h.

◆ D_UL

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

Definition at line 153 of file tui.h.

◆ D_UR

#define D_UR   0xBB

Definition at line 154 of file tui.h.

◆ HD_LL

#define HD_LL   0xD4

Definition at line 160 of file tui.h.

◆ HD_LR

#define HD_LR   0xBE

Definition at line 161 of file tui.h.

◆ HD_UL

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

Definition at line 158 of file tui.h.

◆ HD_UR

#define HD_UR   0xB8

Definition at line 159 of file tui.h.

◆ LL

#define LL   0xC0

Definition at line 150 of file tui.h.

◆ LR

#define LR   0xD9

Definition at line 151 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 148 of file tui.h.

◆ UR

#define UR   0xBF

Definition at line 149 of file tui.h.

◆ VD_LL

#define VD_LL   0xD3

Definition at line 165 of file tui.h.

◆ VD_LR

#define VD_LR   0xBD

Definition at line 166 of file tui.h.

◆ VD_UL

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

Definition at line 163 of file tui.h.

◆ VD_UR

#define VD_UR   0xB7

Definition at line 164 of file tui.h.

Function Documentation

◆ TuiDisplayMenu()

BOOLEAN TuiDisplayMenu ( IN PCSTR  MenuHeader,
IN PCSTR MenuFooter  OPTIONAL,
IN BOOLEAN  ShowBootOptions,
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.

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

◆ TuiDrawBackdrop()

VOID TuiDrawBackdrop ( VOID  )

Definition at line 264 of file tui.c.

265{
266 /* Fill in the background (excluding title box & status bar) */
267 TuiFillArea(0,
269 UiScreenWidth - 1,
270 UiScreenHeight - 2,
273
274 /* Draw the title box */
275 TuiDrawBox(0,
276 0,
277 UiScreenWidth - 1,
279 D_VERT,
280 D_HORZ,
281 TRUE,
282 FALSE,
284
285 /* Draw version text */
286 TuiDrawText(2,
287 1,
290
291 /* Draw copyright */
292 TuiDrawText(2,
293 2,
294 BY_AUTHOR,
296 TuiDrawText(2,
297 3,
300
301 /* Draw help text */
303 /*"F1 for Help"*/ "F8 for Options",
305
306 /* Draw title text */
308 2,
311
312 /* Update the date & time */
315}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
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:496
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: tui.c:321
VOID TuiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: tui.c:70
VOID TuiUpdateDateTime(VOID)
Definition: tui.c:541
const PCSTR FrLdrVersionString
Definition: freeldr.c:32
#define TUI_TITLE_BOX_CHAR_HEIGHT
Definition: tui.h:33
ULONG UiScreenWidth
Definition: ui.c:54
#define D_HORZ
Definition: ui.h:344
UCHAR UiTitleBoxBgColor
Definition: ui.c:31
#define D_VERT
Definition: ui.h:346
#define ATTR(cFore, cBack)
Definition: ui.h:314
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
ULONG UiScreenHeight
Definition: ui.c:55
#define BY_AUTHOR
Definition: ver.h:26
#define AUTHOR_EMAIL
Definition: ver.h:25

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 496 of file tui.c.

506{
507 /* Fill in the box background */
508 if (Fill)
509 TuiFillArea(Left, Top, Right, Bottom, ' ', Attr);
510
511 /* Fill in the top horizontal line */
512 TuiDrawBoxTopLine(Left, Top, Right, VertStyle, HorzStyle, Attr);
513
514 /* Fill in the vertical left and right lines */
515 TuiFillArea(Left, Top+1, Left, Bottom-1, VertStyle, Attr);
516 TuiFillArea(Right, Top+1, Right, Bottom-1, VertStyle, Attr);
517
518 /* Fill in the bottom horizontal line */
519 TuiDrawBoxBottomLine(Left, Bottom, Right, VertStyle, HorzStyle, Attr);
520
521 /* Draw the shadow */
522 if (Shadow)
523 TuiDrawShadow(Left, Top, Right, Bottom);
524}
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:351
VOID TuiDrawBoxBottomLine(_In_ ULONG Left, _In_ ULONG Bottom, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
Definition: tui.c:452
VOID TuiDrawBoxTopLine(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
Definition: tui.c:408
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:107

Referenced by TuiDrawBackdrop(), TuiDrawProgressBar(), TuiEditBox(), and TuiMessageBoxCritical().

◆ TuiDrawBoxBottomLine()

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

Definition at line 452 of file tui.c.

459{
460 UCHAR LLCorner, LRCorner;
461
462 /* Calculate the corner values */
463 if (HorzStyle == HORZ)
464 {
465 if (VertStyle == VERT)
466 {
467 LLCorner = LL;
468 LRCorner = LR;
469 }
470 else // VertStyle == D_VERT
471 {
472 LLCorner = VD_LL;
473 LRCorner = VD_LR;
474 }
475 }
476 else // HorzStyle == D_HORZ
477 {
478 if (VertStyle == VERT)
479 {
480 LLCorner = HD_LL;
481 LRCorner = HD_LR;
482 }
483 else // VertStyle == D_VERT
484 {
485 LLCorner = D_LL;
486 LRCorner = D_LR;
487 }
488 }
489
490 TuiFillArea(Left, Bottom, Left, Bottom, LLCorner, Attr);
491 TuiFillArea(Left+1, Bottom, Right-1, Bottom, HorzStyle, Attr);
492 TuiFillArea(Right, Bottom, Right, Bottom, LRCorner, Attr);
493}
#define LR
Definition: tui.h:151
#define D_LR
Definition: tui.h:156
#define VD_LL
Definition: tui.h:165
#define HD_LL
Definition: tui.h:160
#define LL
Definition: tui.h:150
#define D_LL
Definition: tui.h:155
#define VD_LR
Definition: tui.h:166
#define HD_LR
Definition: tui.h:161
#define VERT
Definition: ui.h:345
#define HORZ
Definition: ui.h:343
unsigned char UCHAR
Definition: xmlstorage.h:181

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 408 of file tui.c.

415{
416 UCHAR ULCorner, URCorner;
417
418 /* Calculate the corner values */
419 if (HorzStyle == HORZ)
420 {
421 if (VertStyle == VERT)
422 {
423 ULCorner = UL;
424 URCorner = UR;
425 }
426 else // VertStyle == D_VERT
427 {
428 ULCorner = VD_UL;
429 URCorner = VD_UR;
430 }
431 }
432 else // HorzStyle == D_HORZ
433 {
434 if (VertStyle == VERT)
435 {
436 ULCorner = HD_UL;
437 URCorner = HD_UR;
438 }
439 else // VertStyle == D_VERT
440 {
441 ULCorner = D_UL;
442 URCorner = D_UR;
443 }
444 }
445
446 TuiFillArea(Left, Top, Left, Top, ULCorner, Attr);
447 TuiFillArea(Left+1, Top, Right-1, Top, HorzStyle, Attr);
448 TuiFillArea(Right, Top, Right, Top, URCorner, Attr);
449}
#define VD_UL
Definition: tui.h:163
#define UR
Definition: tui.h:149
#define D_UL
Definition: tui.h:153
#define UL
Definition: tui.h:148
#define HD_UR
Definition: tui.h:159
#define D_UR
Definition: tui.h:154
#define HD_UL
Definition: tui.h:158
#define VD_UR
Definition: tui.h:164

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 110 of file tui.c.

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

Referenced by MiniTuiSetProgressBarText(), and TuiSetProgressBarText().

◆ TuiDrawMenu()

VOID TuiDrawMenu ( _In_ PUI_MENU_INFO  MenuInfo)

Definition at line 191 of file tuimenu.c.

193{
194 ULONG i;
195
196 // FIXME: Theme-specific
197 /* Draw the backdrop */
199
200 /* Draw the menu box */
202
203 /* Draw each line of the menu */
204 for (i = 0; i < MenuInfo->MenuItemCount; ++i)
205 {
207 }
208
209 // FIXME: Theme-specific
210 /* Update the status bar */
211 UiVtbl.DrawStatusText("Use \x18 and \x19 to select, then press ENTER.");
212
213 /* Display the boot options if needed */
214 if (MenuInfo->ShowBootOptions)
215 {
217 }
218
220}
VOID DisplayBootTimeOptions(VOID)
Definition: options.c:181
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
menu info structure
Definition: window.h:276
VOID(* DrawStatusText)(PCSTR StatusText)
Definition: ui.h:257
VOID TuiDrawMenuItem(_In_ PUI_MENU_INFO MenuInfo, _In_ ULONG MenuItemNumber)
Definition: tuimenu.c:366
VOID TuiDrawMenuBox(_In_ PUI_MENU_INFO MenuInfo)
Definition: tuimenu.c:342
VOID UiDrawBackdrop(VOID)
Definition: ui.c:233

◆ TuiDrawMenuBox()

VOID TuiDrawMenuBox ( _In_ PUI_MENU_INFO  MenuInfo)

Definition at line 342 of file tuimenu.c.

344{
345 // FIXME: Theme-specific
346 /* Draw the menu box if requested */
347 if (UiMenuBox)
348 {
349 UiDrawBox(MenuInfo->Left,
350 MenuInfo->Top,
351 MenuInfo->Right,
352 MenuInfo->Bottom,
353 D_VERT,
354 D_HORZ,
355 FALSE, // Filled
356 TRUE, // Shadow
358 }
359
360 /* Update the date & time */
363}
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 366 of file tuimenu.c.

369{
370 ULONG SpaceLeft;
371 ULONG SpaceRight;
372 UCHAR Attribute;
373 CHAR MenuLineText[80];
374
375 /* If this is a separator */
376 if (MenuInfo->MenuItemList[MenuItemNumber] == NULL)
377 {
378 // FIXME: Theme-specific
379 /* Draw its left box corner */
380 if (UiMenuBox)
381 {
382 UiDrawText(MenuInfo->Left,
383 MenuInfo->Top + 1 + MenuItemNumber,
384 "\xC7",
386 }
387
388 /* Make it a separator line and use menu colors */
389 RtlZeroMemory(MenuLineText, sizeof(MenuLineText));
390 RtlFillMemory(MenuLineText,
391 min(sizeof(MenuLineText), (MenuInfo->Right - MenuInfo->Left - 1)),
392 0xC4);
393
394 /* Draw the item */
395 UiDrawText(MenuInfo->Left + 1,
396 MenuInfo->Top + 1 + MenuItemNumber,
397 MenuLineText,
399
400 // FIXME: Theme-specific
401 /* Draw its right box corner */
402 if (UiMenuBox)
403 {
404 UiDrawText(MenuInfo->Right,
405 MenuInfo->Top + 1 + MenuItemNumber,
406 "\xB6",
408 }
409
410 /* We are done */
411 return;
412 }
413
414 /* This is not a separator */
415 ASSERT(MenuInfo->MenuItemList[MenuItemNumber]);
416
417 /* Check if using centered menu */
418 if (UiCenterMenu)
419 {
420 /*
421 * We will want the string centered so calculate
422 * how many spaces will be to the left and right.
423 */
424 ULONG SpaceTotal =
425 (MenuInfo->Right - MenuInfo->Left - 2) -
426 (ULONG)strlen(MenuInfo->MenuItemList[MenuItemNumber]);
427 SpaceLeft = (SpaceTotal / 2) + 1;
428 SpaceRight = (SpaceTotal - SpaceLeft) + 1;
429 }
430 else
431 {
432 /* Simply left-align it */
433 SpaceLeft = 4;
434 SpaceRight = 0;
435 }
436
437 /* Format the item text string */
438 RtlStringCbPrintfA(MenuLineText, sizeof(MenuLineText),
439 "%*s%s%*s",
440 SpaceLeft, "", // Left padding
441 MenuInfo->MenuItemList[MenuItemNumber],
442 SpaceRight, ""); // Right padding
443
444 if (MenuItemNumber == MenuInfo->SelectedMenuItem)
445 {
446 /* If this is the selected item, use the selected colors */
448 }
449 else
450 {
451 /* Normal item colors */
452 Attribute = ATTR(UiTextColor, UiMenuBgColor);
453 }
454
455 /* Draw the item */
456 UiDrawText(MenuInfo->Left + 1,
457 MenuInfo->Top + 1 + MenuItemNumber,
458 MenuLineText,
459 Attribute);
460}
#define NULL
Definition: types.h:112
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#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 RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
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

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

◆ TuiDrawShadow()

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

Definition at line 351 of file tui.c.

352{
353 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
354 ULONG Idx;
355
356 /* Shade the bottom of the area */
357 if (Bottom < (UiScreenHeight - 1))
358 {
359 if (UiScreenHeight < 34)
360 Idx = Left + 2;
361 else
362 Idx = Left + 1;
363
364 for (; Idx <= Right; ++Idx)
365 {
366 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+(Idx*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
367 }
368 }
369
370 /* Shade the right of the area */
371 if (Right < (UiScreenWidth - 1))
372 {
373 for (Idx=Top+1; Idx<=Bottom; Idx++)
374 {
375 ScreenMemory[((Idx*2)*UiScreenWidth)+((Right+1)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
376 }
377 }
378 if (UiScreenHeight < 34)
379 {
380 if ((Right + 1) < (UiScreenWidth - 1))
381 {
382 for (Idx=Top+1; Idx<=Bottom; Idx++)
383 {
384 ScreenMemory[((Idx*2)*UiScreenWidth)+((Right+2)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
385 }
386 }
387 }
388
389 /* Shade the bottom right corner */
390 if ((Right < (UiScreenWidth - 1)) && (Bottom < (UiScreenHeight - 1)))
391 {
392 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+((Right+1)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
393 }
394 if (UiScreenHeight < 34)
395 {
396 if (((Right + 1) < (UiScreenWidth - 1)) && (Bottom < (UiScreenHeight - 1)))
397 {
398 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+((Right+2)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
399 }
400 }
401}
PVOID TextVideoBuffer
Definition: tui.c:22
unsigned char * PUCHAR
Definition: typedefs.h:53
#define COLOR_GRAY
Definition: ui.h:326
#define COLOR_BLACK
Definition: ui.h:319

Referenced by TuiDrawBox().

◆ TuiDrawStatusText()

VOID TuiDrawStatusText ( PCSTR  StatusText)

Definition at line 526 of file tui.c.

527{
528 SIZE_T i;
529
532
533 for (i=strlen(StatusText)+1; i<UiScreenWidth; i++)
534 {
536 }
537
539}
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 70 of file tui.c.

75{
76 TuiDrawText2(X, Y, 0 /*(ULONG)strlen(Text)*/, Text, Attr);
77}
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:87
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 87 of file tui.c.

93{
94 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
95 ULONG i, j;
96
97 /* Don't display anything if we are out of the screen */
98 if ((X >= UiScreenWidth) || (Y >= UiScreenHeight))
99 return;
100
101 /* Draw the text, not exceeding the width */
102 for (i = X, j = 0; Text[j] && i < UiScreenWidth && (MaxNumChars > 0 ? j < MaxNumChars : TRUE); i++, j++)
103 {
104 ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)] = (UCHAR)Text[j];
105 ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)+1] = Attr;
106 }
107}
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 971 of file tui.c.

972{
973 INT width = 8;
974 ULONG height = 1;
975 INT curline = 0;
976 INT k;
977 size_t i , j;
978 INT x1, x2, y1, y2;
979 CHAR temp[260];
980 CHAR key;
981 BOOLEAN Extended;
982 INT EditBoxLine;
983 ULONG EditBoxStartX, EditBoxEndX;
984 INT EditBoxCursorX;
985 ULONG EditBoxTextLength, EditBoxTextPosition;
986 INT EditBoxTextDisplayIndex;
987 BOOLEAN ReturnCode;
989
990 // Save the screen contents
994
995 // Find the height
996 for (i=0; i<strlen(MessageText); i++)
997 {
998 if (MessageText[i] == '\n')
999 height++;
1000 }
1001
1002 // Find the width
1003 for (i=0,j=0,k=0; i<height; i++)
1004 {
1005 while ((MessageText[j] != '\n') && (MessageText[j] != 0))
1006 {
1007 j++;
1008 k++;
1009 }
1010
1011 if (k > width)
1012 width = k;
1013
1014 k = 0;
1015 j++;
1016 }
1017
1018 // Calculate box area
1019 x1 = (UiScreenWidth - (width+2))/2;
1020 x2 = x1 + width + 3;
1021 y1 = ((UiScreenHeight - height - 2)/2) + 1;
1022 y2 = y1 + height + 4;
1023
1024 // Draw the box
1026
1027 // Draw the text
1028 for (i=0,j=0; i<strlen(MessageText)+1; i++)
1029 {
1030 if ((MessageText[i] == '\n') || (MessageText[i] == 0))
1031 {
1032 temp[j] = 0;
1033 j = 0;
1035 curline++;
1036 }
1037 else
1038 temp[j++] = MessageText[i];
1039 }
1040
1041 EditBoxTextLength = (ULONG)strlen(EditTextBuffer);
1042 EditBoxTextLength = min(EditBoxTextLength, Length - 1);
1043 EditBoxTextPosition = 0;
1044 EditBoxLine = y2 - 2;
1045 EditBoxStartX = x1 + 3;
1046 EditBoxEndX = x2 - 3;
1047
1048 // Draw the edit box background and the text
1049 UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1050 UiDrawText2(EditBoxStartX, EditBoxLine, EditBoxEndX - EditBoxStartX + 1, EditTextBuffer, ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1051
1052 // Show the cursor
1053 EditBoxCursorX = EditBoxStartX;
1054 MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
1056
1057 // Draw status text
1058 UiDrawStatusText("Press ENTER to continue, or ESC to cancel");
1059
1061
1062 //
1063 // Enter the text. Please keep in mind that the default input mode
1064 // of the edit boxes is in insertion mode, that is, you can insert
1065 // text without erasing the existing one.
1066 //
1067 for (;;)
1068 {
1069 if (MachConsKbHit())
1070 {
1071 Extended = FALSE;
1072 key = MachConsGetCh();
1073 if (key == KEY_EXTENDED)
1074 {
1075 Extended = TRUE;
1076 key = MachConsGetCh();
1077 }
1078
1079 if (key == KEY_ENTER)
1080 {
1081 ReturnCode = TRUE;
1082 break;
1083 }
1084 else if (key == KEY_ESC)
1085 {
1086 ReturnCode = FALSE;
1087 break;
1088 }
1089 else if (key == KEY_BACKSPACE) // Remove a character
1090 {
1091 if ( (EditBoxTextLength > 0) && (EditBoxTextPosition > 0) &&
1092 (EditBoxTextPosition <= EditBoxTextLength) )
1093 {
1094 EditBoxTextPosition--;
1095 memmove(EditTextBuffer + EditBoxTextPosition,
1096 EditTextBuffer + EditBoxTextPosition + 1,
1097 EditBoxTextLength - EditBoxTextPosition);
1098 EditBoxTextLength--;
1099 EditTextBuffer[EditBoxTextLength] = 0;
1100 }
1101 else
1102 {
1103 MachBeep();
1104 }
1105 }
1106 else if (Extended && key == KEY_DELETE) // Remove a character
1107 {
1108 if ( (EditBoxTextLength > 0) &&
1109 (EditBoxTextPosition < EditBoxTextLength) )
1110 {
1111 memmove(EditTextBuffer + EditBoxTextPosition,
1112 EditTextBuffer + EditBoxTextPosition + 1,
1113 EditBoxTextLength - EditBoxTextPosition);
1114 EditBoxTextLength--;
1115 EditTextBuffer[EditBoxTextLength] = 0;
1116 }
1117 else
1118 {
1119 MachBeep();
1120 }
1121 }
1122 else if (Extended && key == KEY_HOME) // Go to the start of the buffer
1123 {
1124 EditBoxTextPosition = 0;
1125 }
1126 else if (Extended && key == KEY_END) // Go to the end of the buffer
1127 {
1128 EditBoxTextPosition = EditBoxTextLength;
1129 }
1130 else if (Extended && key == KEY_RIGHT) // Go right
1131 {
1132 if (EditBoxTextPosition < EditBoxTextLength)
1133 EditBoxTextPosition++;
1134 else
1135 MachBeep();
1136 }
1137 else if (Extended && key == KEY_LEFT) // Go left
1138 {
1139 if (EditBoxTextPosition > 0)
1140 EditBoxTextPosition--;
1141 else
1142 MachBeep();
1143 }
1144 else if (!Extended) // Add this key to the buffer
1145 {
1146 if ( (EditBoxTextLength < Length - 1) &&
1147 (EditBoxTextPosition < Length - 1) )
1148 {
1149 memmove(EditTextBuffer + EditBoxTextPosition + 1,
1150 EditTextBuffer + EditBoxTextPosition,
1151 EditBoxTextLength - EditBoxTextPosition);
1152 EditTextBuffer[EditBoxTextPosition] = key;
1153 EditBoxTextPosition++;
1154 EditBoxTextLength++;
1155 EditTextBuffer[EditBoxTextLength] = 0;
1156 }
1157 else
1158 {
1159 MachBeep();
1160 }
1161 }
1162 else
1163 {
1164 MachBeep();
1165 }
1166 }
1167
1168 // Draw the edit box background
1169 UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1170
1171 // Fill the text in
1172 if (EditBoxTextPosition > (EditBoxEndX - EditBoxStartX))
1173 {
1174 EditBoxTextDisplayIndex = EditBoxTextPosition - (EditBoxEndX - EditBoxStartX);
1175 EditBoxCursorX = EditBoxEndX;
1176 }
1177 else
1178 {
1179 EditBoxTextDisplayIndex = 0;
1180 EditBoxCursorX = EditBoxStartX + EditBoxTextPosition;
1181 }
1182 UiDrawText2(EditBoxStartX, EditBoxLine, EditBoxEndX - EditBoxStartX + 1, &EditTextBuffer[EditBoxTextDisplayIndex], ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1183
1184 // Move the cursor
1185 MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
1186
1188
1190
1191 MachHwIdle();
1192 }
1193
1194 // Hide the cursor again
1196
1197 // Restore the screen contents
1200
1201 return ReturnCode;
1202}
unsigned char BOOLEAN
#define MachBeep()
Definition: machine.h:118
#define MachVideoSetTextCursorPosition(X, Y)
Definition: machine.h:102
#define MachVideoHideShowTextCursor(Show)
Definition: machine.h:104
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
VOID TuiRestoreScreen(PUCHAR Buffer)
Definition: tui.c:620
#define TAG_TUI_SCREENBUFFER
Definition: tui.c:190
VOID TuiSaveScreen(PUCHAR Buffer)
Definition: tui.c:609
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#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
int k
Definition: mpi.c:3369
HANDLE ScreenBuffer
Definition: notevil.c:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: copy.c:22
int32_t INT
Definition: typedefs.h:58
UCHAR UiMessageBoxFgColor
Definition: ui.c:32
UCHAR UiMessageBoxBgColor
Definition: ui.c:33
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
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711

◆ TuiFadeInBackdrop()

VOID TuiFadeInBackdrop ( VOID  )

Definition at line 915 of file tui.c.

916{
917 PPALETTE_ENTRY TuiFadePalette = NULL;
918
920 {
921 TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
923
924 if (TuiFadePalette != NULL)
925 {
926 VideoSavePaletteState(TuiFadePalette, 64);
928 }
929 }
930
931 // Draw the backdrop and title box
933
934 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
935 {
936 VideoFadeIn(TuiFadePalette, 64);
937 FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE);
938 }
939}
#define MachVideoIsPaletteFixed()
Definition: machine.h:110
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
#define TAG_TUI_PALETTE
Definition: tui.c:191
VOID TuiDrawBackdrop(VOID)
Definition: tui.c:264
Definition: video.h:12
BOOLEAN UiUseSpecialEffects
Definition: ui.c:45

◆ TuiFadeOut()

VOID TuiFadeOut ( VOID  )

Definition at line 941 of file tui.c.

942{
943 PPALETTE_ENTRY TuiFadePalette = NULL;
944
946 {
947 TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
949
950 if (TuiFadePalette != NULL)
951 {
952 VideoSavePaletteState(TuiFadePalette, 64);
953 }
954 }
955
956 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
957 {
958 VideoFadeOut(64);
959 }
960
962
963 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
964 {
965 VideoRestorePaletteState(TuiFadePalette, 64);
966 FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE);
967 }
968
969}
#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 321 of file tui.c.

322{
323 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
324 ULONG i, j;
325
326 /* Clip the area to the screen */
327 if ((Left >= UiScreenWidth) || (Top >= UiScreenHeight))
328 {
329 return;
330 }
331 if (Right >= UiScreenWidth)
332 Right = UiScreenWidth - 1;
333 if (Bottom >= UiScreenHeight)
335
336 /* Loop through each line and column and fill it in */
337 for (i = Top; i <= Bottom; ++i)
338 {
339 for (j = Left; j <= Right; ++j)
340 {
341 ScreenMemory[((i*2)*UiScreenWidth)+(j*2)] = (UCHAR)FillChar;
342 ScreenMemory[((i*2)*UiScreenWidth)+(j*2)+1] = Attr;
343 }
344 }
345}

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

◆ TuiInitialize()

BOOLEAN TuiInitialize ( VOID  )

Definition at line 195 of file tui.c.

196{
200
202 if (TextVideoBuffer == NULL)
203 {
204 return FALSE;
205 }
206
207 /* Load default settings with "Full" TUI Theme */
208
225
227 UiMenuBox = TRUE;
230
231 // TODO: Have a boolean to show/hide title box?
233 "Boot Menu");
234
236 "[Time Remaining: %d]");
237
238 return TRUE;
239}
#define MachVideoClearScreen(Attr)
Definition: machine.h:92
PVOID VideoAllocateOffScreenBuffer(VOID)
Definition: video.c:16
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
#define COLOR_BLUE
Definition: ui.h:320
#define COLOR_YELLOW
Definition: ui.h:334
#define MEDIUM_FILL
Definition: ui.h:308
#define COLOR_CYAN
Definition: ui.h:322
CHAR UiTimeText[260]
Definition: ui.c:48
#define COLOR_WHITE
Definition: ui.h:335
BOOLEAN UiShowTime
Definition: ui.c:42
#define COLOR_RED
Definition: ui.h:323

Referenced by MiniTuiInitialize().

◆ TuiMessageBox()

VOID TuiMessageBox ( PCSTR  MessageText)

Definition at line 631 of file tui.c.

632{
634
635 // Save the screen contents
639
640 // Display the message box
641 TuiMessageBoxCritical(MessageText);
642
643 // Restore the screen contents
646}
VOID TuiMessageBoxCritical(PCSTR MessageText)
Definition: tui.c:648

◆ TuiMessageBoxCritical()

VOID TuiMessageBoxCritical ( PCSTR  MessageText)

Definition at line 648 of file tui.c.

649{
650 int width = 8;
651 unsigned int height = 1;
652 int curline = 0;
653 int k;
654 size_t i , j;
655 int x1, x2, y1, y2;
656 char temp[260];
657 char key;
658
659 // Find the height
660 for (i=0; i<strlen(MessageText); i++)
661 {
662 if (MessageText[i] == '\n')
663 height++;
664 }
665
666 // Find the width
667 for (i=0,j=0,k=0; i<height; i++)
668 {
669 while ((MessageText[j] != '\n') && (MessageText[j] != 0))
670 {
671 j++;
672 k++;
673 }
674
675 if (k > width)
676 width = k;
677
678 k = 0;
679 j++;
680 }
681
682 // Calculate box area
683 x1 = (UiScreenWidth - (width+2))/2;
684 x2 = x1 + width + 3;
685 y1 = ((UiScreenHeight - height - 2)/2) + 1;
686 y2 = y1 + height + 4;
687
688 // Draw the box
690
691 // Draw the text
692 for (i=0,j=0; i<strlen(MessageText)+1; i++)
693 {
694 if ((MessageText[i] == '\n') || (MessageText[i] == 0))
695 {
696 temp[j] = 0;
697 j = 0;
699 curline++;
700 }
701 else
702 temp[j++] = MessageText[i];
703 }
704
705 // Draw OK button
706 strcpy(temp, " OK ");
708
709 // Draw status text
710 UiDrawStatusText("Press ENTER to continue");
711
713
714 for (;;)
715 {
716 if (MachConsKbHit())
717 {
718 key = MachConsGetCh();
719 if (key == KEY_EXTENDED)
720 key = MachConsGetCh();
721
722 if ((key == KEY_ENTER) || (key == KEY_SPACE) || (key == KEY_ESC))
723 break;
724 }
725
727
729
730 MachHwIdle();
731 }
732}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define KEY_SPACE
Definition: keycodes.h:42

Referenced by TuiMessageBox().

◆ TuiPrintf()

INT TuiPrintf ( _In_ PCSTR  Format,
  ... 
)

Definition at line 31 of file tui.c.

33{
34 INT i;
35 INT Length;
36 va_list ap;
37 CHAR Buffer[512];
38
40 Length = _vsnprintf(Buffer, sizeof(Buffer), Format, ap);
41 va_end(ap);
42
43 if (Length == -1)
44 Length = (INT)sizeof(Buffer);
45
46 for (i = 0; i < Length; i++)
47 {
49 }
50
51 return Length;
52}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define MachConsPutChar(Ch)
Definition: machine.h:86
Definition: bufpool.h:45
#define INT
Definition: polytest.cpp:20
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
#define _vsnprintf
Definition: xmlstorage.h:202

Referenced by MachInit().

◆ TuiRestoreScreen()

VOID TuiRestoreScreen ( PUCHAR  Buffer)

Definition at line 620 of file tui.c.

621{
622 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
623 ULONG i;
624
625 for (i=0; i < (UiScreenWidth * UiScreenHeight * 2); i++)
626 {
627 ScreenMemory[i] = Buffer[i];
628 }
629}

Referenced by TuiEditBox(), and TuiMessageBox().

◆ TuiSaveScreen()

VOID TuiSaveScreen ( PUCHAR  Buffer)

Definition at line 609 of file tui.c.

610{
611 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
612 ULONG i;
613
614 for (i=0; i < (UiScreenWidth * UiScreenHeight * 2); i++)
615 {
616 Buffer[i] = ScreenMemory[i];
617 }
618}

Referenced by TuiEditBox(), and TuiMessageBox().

◆ TuiTextToColor()

UCHAR TuiTextToColor ( PCSTR  ColorText)

Definition at line 852 of file tui.c.

853{
854 static const struct
855 {
856 PCSTR ColorName;
857 UCHAR ColorValue;
858 } Colors[] =
859 {
860 {"Black" , COLOR_BLACK },
861 {"Blue" , COLOR_BLUE },
862 {"Green" , COLOR_GREEN },
863 {"Cyan" , COLOR_CYAN },
864 {"Red" , COLOR_RED },
865 {"Magenta", COLOR_MAGENTA},
866 {"Brown" , COLOR_BROWN },
867 {"Gray" , COLOR_GRAY },
868 {"DarkGray" , COLOR_DARKGRAY },
869 {"LightBlue" , COLOR_LIGHTBLUE },
870 {"LightGreen" , COLOR_LIGHTGREEN },
871 {"LightCyan" , COLOR_LIGHTCYAN },
872 {"LightRed" , COLOR_LIGHTRED },
873 {"LightMagenta", COLOR_LIGHTMAGENTA},
874 {"Yellow" , COLOR_YELLOW },
875 {"White" , COLOR_WHITE },
876 };
877 ULONG i;
878
879 if (_stricmp(ColorText, "Default") == 0)
881
882 for (i = 0; i < RTL_NUMBER_OF(Colors); ++i)
883 {
884 if (_stricmp(ColorText, Colors[i].ColorName) == 0)
885 return Colors[i].ColorValue;
886 }
887
888 return COLOR_BLACK;
889}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
Colors
Definition: ansiprsr.h:4
UCHAR MachDefaultTextColor
Definition: pcvideo.c:111
#define _stricmp
Definition: cat.c:22
const char * PCSTR
Definition: typedefs.h:52
#define COLOR_LIGHTBLUE
Definition: ui.h:329
#define COLOR_LIGHTMAGENTA
Definition: ui.h:333
#define COLOR_DARKGRAY
Definition: ui.h:328
#define COLOR_LIGHTRED
Definition: ui.h:332
#define COLOR_LIGHTCYAN
Definition: ui.h:331
#define COLOR_MAGENTA
Definition: ui.h:324
#define COLOR_BROWN
Definition: ui.h:325
#define COLOR_LIGHTGREEN
Definition: ui.h:330
#define COLOR_GREEN
Definition: ui.h:321

Referenced by MiniTuiInitialize().

◆ TuiTextToFillStyle()

UCHAR TuiTextToFillStyle ( PCSTR  FillStyleText)

Definition at line 891 of file tui.c.

892{
893 static const struct
894 {
895 PCSTR FillStyleName;
896 UCHAR FillStyleValue;
897 } FillStyles[] =
898 {
899 {"None" , ' '},
900 {"Light" , LIGHT_FILL },
901 {"Medium", MEDIUM_FILL},
902 {"Dark" , DARK_FILL },
903 };
904 ULONG i;
905
906 for (i = 0; i < RTL_NUMBER_OF(FillStyles); ++i)
907 {
908 if (_stricmp(FillStyleText, FillStyles[i].FillStyleName) == 0)
909 return FillStyles[i].FillStyleValue;
910 }
911
912 return LIGHT_FILL;
913}
#define LIGHT_FILL
Definition: ui.h:307
#define DARK_FILL
Definition: ui.h:309

◆ TuiTruncateStringEllipsis()

VOID TuiTruncateStringEllipsis ( _Inout_z_ PSTR  StringText,
_In_ ULONG  MaxChars 
)

Definition at line 55 of file tui.c.

58{
59 /* If it's too large, just add some ellipsis past the maximum */
60 if (strlen(StringText) > MaxChars)
61 strcpy(&StringText[MaxChars - 3], "...");
62}

Referenced by MiniTuiSetProgressBarText(), and TuiSetProgressBarText().

◆ TuiUnInitialize()

VOID TuiUnInitialize ( VOID  )

Definition at line 241 of file tui.c.

242{
243 /* Do nothing if already uninitialized */
244 if (!TextVideoBuffer)
245 return;
246
248 {
249 TuiFadeOut();
250 }
251 else
252 {
254 }
255
258
262}
VOID VideoFreeOffScreenBuffer(VOID)
Definition: video.c:29
VOID TuiFadeOut(VOID)
Definition: tui.c:941

◆ TuiUpdateDateTime()

VOID TuiUpdateDateTime ( VOID  )

Definition at line 541 of file tui.c.

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

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

Variable Documentation

◆ TuiVtbl

const UIVTBL TuiVtbl
extern

Definition at line 1204 of file tui.c.

Referenced by UiInitialize().