ReactOS 0.4.15-dev-5863-g1fe3ab7
tui.c File Reference
#include <freeldr.h>
Include dependency graph for tui.c:

Go to the source code of this file.

Macros

#define TAG_TUI_SCREENBUFFER   'SiuT'
 
#define TAG_TUI_PALETTE   'PiuT'
 

Functions

INT TuiPrintf (_In_ PCSTR Format,...)
 
VOID TuiTruncateStringEllipsis (_Inout_z_ PSTR StringText, _In_ ULONG MaxChars)
 
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)
 
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 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 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 TuiDrawStatusText (PCSTR StatusText)
 
VOID TuiUpdateDateTime (VOID)
 
VOID TuiSaveScreen (PUCHAR Buffer)
 
VOID TuiRestoreScreen (PUCHAR Buffer)
 
VOID TuiMessageBox (PCSTR MessageText)
 
VOID TuiMessageBoxCritical (PCSTR MessageText)
 
static VOID TuiSetProgressBarText (_In_ PCSTR ProgressText)
 
static VOID TuiTickProgressBar (_In_ ULONG SubPercentTimes100)
 
static VOID TuiDrawProgressBar (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
 
static VOID TuiDrawProgressBarCenter (_In_ PCSTR ProgressText)
 
UCHAR TuiTextToColor (PCSTR ColorText)
 
UCHAR TuiTextToFillStyle (PCSTR FillStyleText)
 
VOID TuiFadeInBackdrop (VOID)
 
VOID TuiFadeOut (VOID)
 
BOOLEAN TuiEditBox (PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
 

Variables

PVOID TextVideoBuffer = NULL
 
UCHAR MachDefaultTextColor
 
const UIVTBL TuiVtbl
 

Macro Definition Documentation

◆ TAG_TUI_PALETTE

#define TAG_TUI_PALETTE   'PiuT'

Definition at line 202 of file tui.c.

◆ TAG_TUI_SCREENBUFFER

#define TAG_TUI_SCREENBUFFER   'SiuT'

Definition at line 201 of file tui.c.

Function Documentation

◆ TuiDrawBackdrop()

VOID TuiDrawBackdrop ( VOID  )

Definition at line 275 of file tui.c.

276{
277 /* Fill in the background (excluding title box & status bar) */
278 TuiFillArea(0,
280 UiScreenWidth - 1,
281 UiScreenHeight - 2,
284
285 /* Draw the title box */
286 TuiDrawBox(0,
287 0,
288 UiScreenWidth - 1,
290 D_VERT,
291 D_HORZ,
292 TRUE,
293 FALSE,
295
296 /* Draw version text */
297 TuiDrawText(2,
298 1,
301
302 /* Draw copyright */
303 TuiDrawText(2,
304 2,
305 BY_AUTHOR,
307 TuiDrawText(2,
308 3,
311
312 /* Draw help text */
314 /*"F1 for Help"*/ "F8 for Options",
316
317 /* Draw title text */
319 2,
322
323 /* Update the date & time */
326}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
VOID VideoCopyOffScreenBufferToVRAM(VOID)
Definition: video.c:39
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:507
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: tui.c:332
VOID TuiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: tui.c:72
VOID TuiUpdateDateTime(VOID)
Definition: tui.c:552
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
const PCSTR FrLdrVersionString
Definition: freeldr.c:32
#define TUI_TITLE_BOX_CHAR_HEIGHT
Definition: tui.h:33
uint32_t ULONG
Definition: typedefs.h:59
ULONG UiScreenWidth
Definition: ui.c:56
#define D_HORZ
Definition: ui.h:344
UCHAR UiTitleBoxBgColor
Definition: ui.c:33
#define D_VERT
Definition: ui.h:346
#define ATTR(cFore, cBack)
Definition: ui.h:314
CHAR UiTitleBoxTitleText[260]
Definition: ui.c:49
UCHAR UiTitleBoxFgColor
Definition: ui.c:32
UCHAR UiBackdropFgColor
Definition: ui.c:29
UCHAR UiBackdropFillStyle
Definition: ui.c:31
UCHAR UiBackdropBgColor
Definition: ui.c:30
ULONG UiScreenHeight
Definition: ui.c:57
#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 507 of file tui.c.

517{
518 /* Fill in the box background */
519 if (Fill)
520 TuiFillArea(Left, Top, Right, Bottom, ' ', Attr);
521
522 /* Fill in the top horizontal line */
523 TuiDrawBoxTopLine(Left, Top, Right, VertStyle, HorzStyle, Attr);
524
525 /* Fill in the vertical left and right lines */
526 TuiFillArea(Left, Top+1, Left, Bottom-1, VertStyle, Attr);
527 TuiFillArea(Right, Top+1, Right, Bottom-1, VertStyle, Attr);
528
529 /* Fill in the bottom horizontal line */
530 TuiDrawBoxBottomLine(Left, Bottom, Right, VertStyle, HorzStyle, Attr);
531
532 /* Draw the shadow */
533 if (Shadow)
534 TuiDrawShadow(Left, Top, Right, Bottom);
535}
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:362
VOID TuiDrawBoxBottomLine(_In_ ULONG Left, _In_ ULONG Bottom, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
Definition: tui.c:463
VOID TuiDrawBoxTopLine(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
Definition: tui.c:419
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:109

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

470{
471 UCHAR LLCorner, LRCorner;
472
473 /* Calculate the corner values */
474 if (HorzStyle == HORZ)
475 {
476 if (VertStyle == VERT)
477 {
478 LLCorner = LL;
479 LRCorner = LR;
480 }
481 else // VertStyle == D_VERT
482 {
483 LLCorner = VD_LL;
484 LRCorner = VD_LR;
485 }
486 }
487 else // HorzStyle == D_HORZ
488 {
489 if (VertStyle == VERT)
490 {
491 LLCorner = HD_LL;
492 LRCorner = HD_LR;
493 }
494 else // VertStyle == D_VERT
495 {
496 LLCorner = D_LL;
497 LRCorner = D_LR;
498 }
499 }
500
501 TuiFillArea(Left, Bottom, Left, Bottom, LLCorner, Attr);
502 TuiFillArea(Left+1, Bottom, Right-1, Bottom, HorzStyle, Attr);
503 TuiFillArea(Right, Bottom, Right, Bottom, LRCorner, Attr);
504}
#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 419 of file tui.c.

426{
427 UCHAR ULCorner, URCorner;
428
429 /* Calculate the corner values */
430 if (HorzStyle == HORZ)
431 {
432 if (VertStyle == VERT)
433 {
434 ULCorner = UL;
435 URCorner = UR;
436 }
437 else // VertStyle == D_VERT
438 {
439 ULCorner = VD_UL;
440 URCorner = VD_UR;
441 }
442 }
443 else // HorzStyle == D_HORZ
444 {
445 if (VertStyle == VERT)
446 {
447 ULCorner = HD_UL;
448 URCorner = HD_UR;
449 }
450 else // VertStyle == D_VERT
451 {
452 ULCorner = D_UL;
453 URCorner = D_UR;
454 }
455 }
456
457 TuiFillArea(Left, Top, Left, Top, ULCorner, Attr);
458 TuiFillArea(Left+1, Top, Right-1, Top, HorzStyle, Attr);
459 TuiFillArea(Right, Top, Right, Top, URCorner, Attr);
460}
#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 119 of file tui.c.

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

◆ TuiDrawProgressBar()

static VOID TuiDrawProgressBar ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Right,
_In_ ULONG  Bottom,
_In_ PCSTR  ProgressText 
)
static

Definition at line 844 of file tui.c.

850{
851 /* Draw the box */
852 TuiDrawBox(Left, Top, Right, Bottom,
853 VERT, HORZ, TRUE, TRUE,
855
856 /* Exclude the box margins */
857 Left += 2;
858 Right -= 2;
859 Top += 1;
860 Bottom -= 1;
861
862 UiInitProgressBar(Left, Top, Right, Bottom, ProgressText);
863}
UCHAR UiMenuBgColor
Definition: ui.c:37
UCHAR UiMenuFgColor
Definition: ui.c:36
VOID UiInitProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.c:392

Referenced by TuiDrawProgressBarCenter().

◆ TuiDrawProgressBarCenter()

static VOID TuiDrawProgressBarCenter ( _In_ PCSTR  ProgressText)
static

Definition at line 820 of file tui.c.

822{
823 ULONG Left, Top, Right, Bottom, Width, Height;
824
825 /* Build the coordinates and sizes */
826 Height = 2;
827 Width = 50; // Allow for 50 "bars"
828 Left = (UiScreenWidth - Width) / 2;
829 Top = (UiScreenHeight - Height + 4) / 2;
830 Right = Left + Width - 1;
831 Bottom = Top + Height - 1;
832
833 /* Inflate to include the box margins */
834 Left -= 2;
835 Right += 2;
836 Top -= 1;
837 Bottom += 1;
838
839 /* Draw the progress bar */
840 TuiDrawProgressBar(Left, Top, Right, Bottom, ProgressText);
841}
static VOID TuiDrawProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: tui.c:844
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:126
_In_ HFONT _Out_ PUINT Height
Definition: font.h:125

◆ TuiDrawShadow()

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

Definition at line 362 of file tui.c.

363{
364 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
365 ULONG Idx;
366
367 /* Shade the bottom of the area */
368 if (Bottom < (UiScreenHeight - 1))
369 {
370 if (UiScreenHeight < 34)
371 Idx = Left + 2;
372 else
373 Idx = Left + 1;
374
375 for (; Idx <= Right; ++Idx)
376 {
377 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+(Idx*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
378 }
379 }
380
381 /* Shade the right of the area */
382 if (Right < (UiScreenWidth - 1))
383 {
384 for (Idx=Top+1; Idx<=Bottom; Idx++)
385 {
386 ScreenMemory[((Idx*2)*UiScreenWidth)+((Right+1)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
387 }
388 }
389 if (UiScreenHeight < 34)
390 {
391 if ((Right + 1) < (UiScreenWidth - 1))
392 {
393 for (Idx=Top+1; Idx<=Bottom; Idx++)
394 {
395 ScreenMemory[((Idx*2)*UiScreenWidth)+((Right+2)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
396 }
397 }
398 }
399
400 /* Shade the bottom right corner */
401 if ((Right < (UiScreenWidth - 1)) && (Bottom < (UiScreenHeight - 1)))
402 {
403 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+((Right+1)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
404 }
405 if (UiScreenHeight < 34)
406 {
407 if (((Right + 1) < (UiScreenWidth - 1)) && (Bottom < (UiScreenHeight - 1)))
408 {
409 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+((Right+2)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
410 }
411 }
412}
PVOID TextVideoBuffer
Definition: tui.c:23
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 537 of file tui.c.

538{
539 SIZE_T i;
540
543
544 for (i=strlen(StatusText)+1; i<UiScreenWidth; i++)
545 {
547 }
548
550}
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
UCHAR UiStatusBarBgColor
Definition: ui.c:28
UCHAR UiStatusBarFgColor
Definition: ui.c:27

◆ TuiDrawText()

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

Definition at line 72 of file tui.c.

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

95{
96#ifndef _M_ARM
97 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
98#endif
99 ULONG i, j;
100
101 /* Don't display anything if we are out of the screen */
102 if ((X >= UiScreenWidth) || (Y >= UiScreenHeight))
103 return;
104
105 /* Draw the text, not exceeding the width */
106 for (i = X, j = 0; Text[j] && i < UiScreenWidth && (MaxNumChars > 0 ? j < MaxNumChars : TRUE); i++, j++)
107 {
108#ifndef _M_ARM
109 ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)] = (UCHAR)Text[j];
110 ScreenMemory[((Y*2)*UiScreenWidth)+(i*2)+1] = Attr;
111#else
112 /* Write the character */
113 MachVideoPutChar(Text[j], Attr, i, Y);
114#endif
115 }
116}
#define MachVideoPutChar(Ch, Attr, X, Y)
Definition: machine.h:106
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 984 of file tui.c.

985{
986 INT width = 8;
987 ULONG height = 1;
988 INT curline = 0;
989 INT k;
990 size_t i , j;
991 INT x1, x2, y1, y2;
992 CHAR temp[260];
993 CHAR key;
994 BOOLEAN Extended;
995 INT EditBoxLine;
996 ULONG EditBoxStartX, EditBoxEndX;
997 INT EditBoxCursorX;
998 ULONG EditBoxTextLength, EditBoxTextPosition;
999 INT EditBoxTextDisplayIndex;
1000 BOOLEAN ReturnCode;
1002
1003 // Save the screen contents
1007
1008 // Find the height
1009 for (i=0; i<strlen(MessageText); i++)
1010 {
1011 if (MessageText[i] == '\n')
1012 height++;
1013 }
1014
1015 // Find the width
1016 for (i=0,j=0,k=0; i<height; i++)
1017 {
1018 while ((MessageText[j] != '\n') && (MessageText[j] != 0))
1019 {
1020 j++;
1021 k++;
1022 }
1023
1024 if (k > width)
1025 width = k;
1026
1027 k = 0;
1028 j++;
1029 }
1030
1031 // Calculate box area
1032 x1 = (UiScreenWidth - (width+2))/2;
1033 x2 = x1 + width + 3;
1034 y1 = ((UiScreenHeight - height - 2)/2) + 1;
1035 y2 = y1 + height + 4;
1036
1037 // Draw the box
1039
1040 // Draw the text
1041 for (i=0,j=0; i<strlen(MessageText)+1; i++)
1042 {
1043 if ((MessageText[i] == '\n') || (MessageText[i] == 0))
1044 {
1045 temp[j] = 0;
1046 j = 0;
1048 curline++;
1049 }
1050 else
1051 temp[j++] = MessageText[i];
1052 }
1053
1054 EditBoxTextLength = (ULONG)strlen(EditTextBuffer);
1055 EditBoxTextLength = min(EditBoxTextLength, Length - 1);
1056 EditBoxTextPosition = 0;
1057 EditBoxLine = y2 - 2;
1058 EditBoxStartX = x1 + 3;
1059 EditBoxEndX = x2 - 3;
1060
1061 // Draw the edit box background and the text
1062 UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1063 UiDrawText2(EditBoxStartX, EditBoxLine, EditBoxEndX - EditBoxStartX + 1, EditTextBuffer, ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1064
1065 // Show the cursor
1066 EditBoxCursorX = EditBoxStartX;
1067 MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
1069
1070 // Draw status text
1071 UiDrawStatusText("Press ENTER to continue, or ESC to cancel");
1072
1074
1075 //
1076 // Enter the text. Please keep in mind that the default input mode
1077 // of the edit boxes is in insertion mode, that is, you can insert
1078 // text without erasing the existing one.
1079 //
1080 for (;;)
1081 {
1082 if (MachConsKbHit())
1083 {
1084 Extended = FALSE;
1085 key = MachConsGetCh();
1086 if (key == KEY_EXTENDED)
1087 {
1088 Extended = TRUE;
1089 key = MachConsGetCh();
1090 }
1091
1092 if (key == KEY_ENTER)
1093 {
1094 ReturnCode = TRUE;
1095 break;
1096 }
1097 else if (key == KEY_ESC)
1098 {
1099 ReturnCode = FALSE;
1100 break;
1101 }
1102 else if (key == KEY_BACKSPACE) // Remove a character
1103 {
1104 if ( (EditBoxTextLength > 0) && (EditBoxTextPosition > 0) &&
1105 (EditBoxTextPosition <= EditBoxTextLength) )
1106 {
1107 EditBoxTextPosition--;
1108 memmove(EditTextBuffer + EditBoxTextPosition,
1109 EditTextBuffer + EditBoxTextPosition + 1,
1110 EditBoxTextLength - EditBoxTextPosition);
1111 EditBoxTextLength--;
1112 EditTextBuffer[EditBoxTextLength] = 0;
1113 }
1114 else
1115 {
1116 MachBeep();
1117 }
1118 }
1119 else if (Extended && key == KEY_DELETE) // Remove a character
1120 {
1121 if ( (EditBoxTextLength > 0) &&
1122 (EditBoxTextPosition < EditBoxTextLength) )
1123 {
1124 memmove(EditTextBuffer + EditBoxTextPosition,
1125 EditTextBuffer + EditBoxTextPosition + 1,
1126 EditBoxTextLength - EditBoxTextPosition);
1127 EditBoxTextLength--;
1128 EditTextBuffer[EditBoxTextLength] = 0;
1129 }
1130 else
1131 {
1132 MachBeep();
1133 }
1134 }
1135 else if (Extended && key == KEY_HOME) // Go to the start of the buffer
1136 {
1137 EditBoxTextPosition = 0;
1138 }
1139 else if (Extended && key == KEY_END) // Go to the end of the buffer
1140 {
1141 EditBoxTextPosition = EditBoxTextLength;
1142 }
1143 else if (Extended && key == KEY_RIGHT) // Go right
1144 {
1145 if (EditBoxTextPosition < EditBoxTextLength)
1146 EditBoxTextPosition++;
1147 else
1148 MachBeep();
1149 }
1150 else if (Extended && key == KEY_LEFT) // Go left
1151 {
1152 if (EditBoxTextPosition > 0)
1153 EditBoxTextPosition--;
1154 else
1155 MachBeep();
1156 }
1157 else if (!Extended) // Add this key to the buffer
1158 {
1159 if ( (EditBoxTextLength < Length - 1) &&
1160 (EditBoxTextPosition < Length - 1) )
1161 {
1162 memmove(EditTextBuffer + EditBoxTextPosition + 1,
1163 EditTextBuffer + EditBoxTextPosition,
1164 EditBoxTextLength - EditBoxTextPosition);
1165 EditTextBuffer[EditBoxTextPosition] = key;
1166 EditBoxTextPosition++;
1167 EditBoxTextLength++;
1168 EditTextBuffer[EditBoxTextLength] = 0;
1169 }
1170 else
1171 {
1172 MachBeep();
1173 }
1174 }
1175 else
1176 {
1177 MachBeep();
1178 }
1179 }
1180
1181 // Draw the edit box background
1182 UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1183
1184 // Fill the text in
1185 if (EditBoxTextPosition > (EditBoxEndX - EditBoxStartX))
1186 {
1187 EditBoxTextDisplayIndex = EditBoxTextPosition - (EditBoxEndX - EditBoxStartX);
1188 EditBoxCursorX = EditBoxEndX;
1189 }
1190 else
1191 {
1192 EditBoxTextDisplayIndex = 0;
1193 EditBoxCursorX = EditBoxStartX + EditBoxTextPosition;
1194 }
1195 UiDrawText2(EditBoxStartX, EditBoxLine, EditBoxEndX - EditBoxStartX + 1, &EditTextBuffer[EditBoxTextDisplayIndex], ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1196
1197 // Move the cursor
1198 MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
1199
1201
1203
1204 MachHwIdle();
1205 }
1206
1207 // Hide the cursor again
1209
1210 // Restore the screen contents
1213
1214 return ReturnCode;
1215}
unsigned char BOOLEAN
#define MachHwIdle()
Definition: machine.h:137
#define MachBeep()
Definition: machine.h:118
#define MachConsKbHit()
Definition: machine.h:88
#define MachVideoSetTextCursorPosition(X, Y)
Definition: machine.h:102
#define MachConsGetCh()
Definition: machine.h:90
#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:631
#define TAG_TUI_SCREENBUFFER
Definition: tui.c:201
VOID TuiSaveScreen(PUCHAR Buffer)
Definition: tui.c:620
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_EXTENDED
Definition: keycodes.h:38
#define KEY_ESC
Definition: keycodes.h:49
#define KEY_END
Definition: keycodes.h:64
#define KEY_ENTER
Definition: keycodes.h:39
#define KEY_LEFT
Definition: keycodes.h:47
#define KEY_HOME
Definition: keycodes.h:44
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define min(a, b)
Definition: monoChain.cc:55
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:34
UCHAR UiMessageBoxBgColor
Definition: ui.c:35
UCHAR UiEditBoxTextColor
Definition: ui.c:41
VOID UiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: ui.c:260
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:270
VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.c:244
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:292
UCHAR UiEditBoxBgColor
Definition: ui.c:42
_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 928 of file tui.c.

929{
930 PPALETTE_ENTRY TuiFadePalette = NULL;
931
933 {
934 TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
936
937 if (TuiFadePalette != NULL)
938 {
939 VideoSavePaletteState(TuiFadePalette, 64);
941 }
942 }
943
944 // Draw the backdrop and title box
946
947 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
948 {
949 VideoFadeIn(TuiFadePalette, 64);
950 FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE);
951 }
952}
#define MachVideoIsPaletteFixed()
Definition: machine.h:110
VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:80
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
Definition: video.c:68
struct _PALETTE_ENTRY * PPALETTE_ENTRY
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:45
#define TAG_TUI_PALETTE
Definition: tui.c:202
VOID TuiDrawBackdrop(VOID)
Definition: tui.c:275
#define NULL
Definition: types.h:112
Definition: video.h:12
BOOLEAN UiUseSpecialEffects
Definition: ui.c:47

◆ TuiFadeOut()

VOID TuiFadeOut ( VOID  )

Definition at line 954 of file tui.c.

955{
956 PPALETTE_ENTRY TuiFadePalette = NULL;
957
959 {
960 TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
962
963 if (TuiFadePalette != NULL)
964 {
965 VideoSavePaletteState(TuiFadePalette, 64);
966 }
967 }
968
969 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
970 {
971 VideoFadeOut(64);
972 }
973
975
976 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
977 {
978 VideoRestorePaletteState(TuiFadePalette, 64);
979 FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE);
980 }
981
982}
#define MachVideoSetDisplayMode(Mode, Init)
Definition: machine.h:94
VOID VideoFadeOut(ULONG ColorCount)
Definition: video.c:139
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:55

Referenced by TuiUnInitialize().

◆ TuiFillArea()

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

Definition at line 332 of file tui.c.

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

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

◆ TuiInitialize()

BOOLEAN TuiInitialize ( VOID  )

Definition at line 206 of file tui.c.

207{
211
213 if (TextVideoBuffer == NULL)
214 {
215 return FALSE;
216 }
217
218 /* Load default settings with "Full" TUI Theme */
219
236
238 UiMenuBox = TRUE;
241
242 // TODO: Have a boolean to show/hide title box?
244 "Boot Menu");
245
247 "[Time Remaining: %d]");
248
249 return TRUE;
250}
#define MachVideoClearScreen(Attr)
Definition: machine.h:92
PVOID VideoAllocateOffScreenBuffer(VOID)
Definition: video.c:17
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
BOOLEAN UiCenterMenu
Definition: ui.c:46
#define COLOR_YELLOW
Definition: ui.h:334
UCHAR UiTextColor
Definition: ui.c:38
#define MEDIUM_FILL
Definition: ui.h:308
#define COLOR_CYAN
Definition: ui.h:322
CHAR UiTimeText[260]
Definition: ui.c:50
#define COLOR_WHITE
Definition: ui.h:335
BOOLEAN UiShowTime
Definition: ui.c:44
BOOLEAN UiMenuBox
Definition: ui.c:45
UCHAR UiSelectedTextColor
Definition: ui.c:39
UCHAR UiSelectedTextBgColor
Definition: ui.c:40
#define COLOR_RED
Definition: ui.h:323

Referenced by MiniTuiInitialize().

◆ TuiMessageBox()

VOID TuiMessageBox ( PCSTR  MessageText)

Definition at line 642 of file tui.c.

643{
645
646 // Save the screen contents
650
651 // Display the message box
652 TuiMessageBoxCritical(MessageText);
653
654 // Restore the screen contents
657}
VOID TuiMessageBoxCritical(PCSTR MessageText)
Definition: tui.c:659

◆ TuiMessageBoxCritical()

VOID TuiMessageBoxCritical ( PCSTR  MessageText)

Definition at line 659 of file tui.c.

660{
661 int width = 8;
662 unsigned int height = 1;
663 int curline = 0;
664 int k;
665 size_t i , j;
666 int x1, x2, y1, y2;
667 char temp[260];
668 char key;
669
670 // Find the height
671 for (i=0; i<strlen(MessageText); i++)
672 {
673 if (MessageText[i] == '\n')
674 height++;
675 }
676
677 // Find the width
678 for (i=0,j=0,k=0; i<height; i++)
679 {
680 while ((MessageText[j] != '\n') && (MessageText[j] != 0))
681 {
682 j++;
683 k++;
684 }
685
686 if (k > width)
687 width = k;
688
689 k = 0;
690 j++;
691 }
692
693 // Calculate box area
694 x1 = (UiScreenWidth - (width+2))/2;
695 x2 = x1 + width + 3;
696 y1 = ((UiScreenHeight - height - 2)/2) + 1;
697 y2 = y1 + height + 4;
698
699 // Draw the box
701
702 // Draw the text
703 for (i=0,j=0; i<strlen(MessageText)+1; i++)
704 {
705 if ((MessageText[i] == '\n') || (MessageText[i] == 0))
706 {
707 temp[j] = 0;
708 j = 0;
710 curline++;
711 }
712 else
713 temp[j++] = MessageText[i];
714 }
715
716 // Draw OK button
717 strcpy(temp, " OK ");
719
720 // Draw status text
721 UiDrawStatusText("Press ENTER to continue");
722
724
725 for (;;)
726 {
727 if (MachConsKbHit())
728 {
729 key = MachConsGetCh();
730 if (key == KEY_EXTENDED)
731 key = MachConsGetCh();
732
733 if ((key == KEY_ENTER) || (key == KEY_SPACE) || (key == KEY_ESC))
734 break;
735 }
736
738
740
741 MachHwIdle();
742 }
743}
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 33 of file tui.c.

35{
36 INT i;
37 INT Length;
38 va_list ap;
39 CHAR Buffer[512];
40
42 Length = _vsnprintf(Buffer, sizeof(Buffer), Format, ap);
43 va_end(ap);
44
45 if (Length == -1)
46 Length = (INT)sizeof(Buffer);
47
48 for (i = 0; i < Length; i++)
49 {
51 }
52
53 return Length;
54}
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 631 of file tui.c.

632{
633 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
634 ULONG i;
635
636 for (i=0; i < (UiScreenWidth * UiScreenHeight * 2); i++)
637 {
638 ScreenMemory[i] = Buffer[i];
639 }
640}

Referenced by TuiEditBox(), and TuiMessageBox().

◆ TuiSaveScreen()

VOID TuiSaveScreen ( 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 Buffer[i] = ScreenMemory[i];
628 }
629}

Referenced by TuiEditBox(), and TuiMessageBox().

◆ TuiSetProgressBarText()

static VOID TuiSetProgressBarText ( _In_ PCSTR  ProgressText)
static

Definition at line 746 of file tui.c.

748{
749 ULONG ProgressBarWidth;
750 CHAR ProgressString[256];
751
752 /* Make sure the progress bar is enabled */
754
755 /* Calculate the width of the bar proper */
756 ProgressBarWidth = UiProgressBar.Right - UiProgressBar.Left + 1;
757
758 /* First make sure the progress bar text fits */
759 RtlStringCbCopyA(ProgressString, sizeof(ProgressString), ProgressText);
760 TuiTruncateStringEllipsis(ProgressString, ProgressBarWidth);
761
762 /* Clear the text area */
766
767 /* Draw the "Loading..." text */
770 ProgressString, ATTR(UiTextColor, UiMenuBgColor));
771}
VOID TuiDrawCenteredText(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR TextString, _In_ UCHAR Attr)
Definition: tui.c:119
VOID TuiTruncateStringEllipsis(_Inout_z_ PSTR StringText, _In_ ULONG MaxChars)
Definition: tui.c:57
#define ASSERT(a)
Definition: mode.c:44
ULONG Top
Definition: ui.h:125
ULONG Bottom
Definition: ui.h:127
BOOLEAN Show
Definition: ui.h:129
ULONG Left
Definition: ui.h:124
ULONG Right
Definition: ui.h:126
UI_PROGRESS_BAR UiProgressBar
Definition: ui.c:66

◆ TuiTextToColor()

UCHAR TuiTextToColor ( PCSTR  ColorText)

Definition at line 865 of file tui.c.

866{
867 static const struct
868 {
869 PCSTR ColorName;
870 UCHAR ColorValue;
871 } Colors[] =
872 {
873 {"Black" , COLOR_BLACK },
874 {"Blue" , COLOR_BLUE },
875 {"Green" , COLOR_GREEN },
876 {"Cyan" , COLOR_CYAN },
877 {"Red" , COLOR_RED },
878 {"Magenta", COLOR_MAGENTA},
879 {"Brown" , COLOR_BROWN },
880 {"Gray" , COLOR_GRAY },
881 {"DarkGray" , COLOR_DARKGRAY },
882 {"LightBlue" , COLOR_LIGHTBLUE },
883 {"LightGreen" , COLOR_LIGHTGREEN },
884 {"LightCyan" , COLOR_LIGHTCYAN },
885 {"LightRed" , COLOR_LIGHTRED },
886 {"LightMagenta", COLOR_LIGHTMAGENTA},
887 {"Yellow" , COLOR_YELLOW },
888 {"White" , COLOR_WHITE },
889 };
890 ULONG i;
891
892 if (_stricmp(ColorText, "Default") == 0)
894
895 for (i = 0; i < RTL_NUMBER_OF(Colors); ++i)
896 {
897 if (_stricmp(ColorText, Colors[i].ColorName) == 0)
898 return Colors[i].ColorValue;
899 }
900
901 return COLOR_BLACK;
902}
#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 904 of file tui.c.

905{
906 static const struct
907 {
908 PCSTR FillStyleName;
909 UCHAR FillStyleValue;
910 } FillStyles[] =
911 {
912 {"None" , ' '},
913 {"Light" , LIGHT_FILL },
914 {"Medium", MEDIUM_FILL},
915 {"Dark" , DARK_FILL },
916 };
917 ULONG i;
918
919 for (i = 0; i < RTL_NUMBER_OF(FillStyles); ++i)
920 {
921 if (_stricmp(FillStyleText, FillStyles[i].FillStyleName) == 0)
922 return FillStyles[i].FillStyleValue;
923 }
924
925 return LIGHT_FILL;
926}
#define LIGHT_FILL
Definition: ui.h:307
#define DARK_FILL
Definition: ui.h:309

◆ TuiTickProgressBar()

static VOID TuiTickProgressBar ( _In_ ULONG  SubPercentTimes100)
static

Definition at line 774 of file tui.c.

776{
777 ULONG ProgressBarWidth;
778 ULONG FillCount;
779
780 /* Make sure the progress bar is enabled */
782
783 ASSERT(SubPercentTimes100 <= (100 * 100));
784
785 /* Calculate the width of the bar proper */
786 ProgressBarWidth = UiProgressBar.Right - UiProgressBar.Left + 1;
787
788 /* Compute fill count */
789 // FillCount = (ProgressBarWidth * Position) / Range;
790 FillCount = ProgressBarWidth * SubPercentTimes100 / (100 * 100);
791
792 /* Fill the progress bar */
793 /* Draw the percent complete -- Use the fill character */
794 if (FillCount > 0)
795 {
797 UiProgressBar.Left + FillCount - 1, UiProgressBar.Bottom,
798 '\xDB', ATTR(UiTextColor, UiMenuBgColor));
799 }
800 /* Fill the remaining with shadow blanks */
803 '\xB2', ATTR(UiTextColor, UiMenuBgColor));
804
805#ifndef _M_ARM
808#endif
809}

◆ TuiTruncateStringEllipsis()

VOID TuiTruncateStringEllipsis ( _Inout_z_ PSTR  StringText,
_In_ ULONG  MaxChars 
)

Definition at line 57 of file tui.c.

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

Referenced by MiniTuiSetProgressBarText(), and TuiSetProgressBarText().

◆ TuiUnInitialize()

VOID TuiUnInitialize ( VOID  )

Definition at line 252 of file tui.c.

253{
254 /* Do nothing if already uninitialized */
255 if (!TextVideoBuffer)
256 return;
257
259 {
260 TuiFadeOut();
261 }
262 else
263 {
265 }
266
269
273}
VOID VideoFreeOffScreenBuffer(VOID)
Definition: video.c:30
VOID TuiFadeOut(VOID)
Definition: tui.c:954

◆ TuiUpdateDateTime()

VOID TuiUpdateDateTime ( VOID  )

Definition at line 552 of file tui.c.

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

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

Variable Documentation

◆ MachDefaultTextColor

UCHAR MachDefaultTextColor
extern

Definition at line 111 of file pcvideo.c.

Referenced by TuiTextToColor().

◆ TextVideoBuffer

PVOID TextVideoBuffer = NULL

◆ TuiVtbl

const UIVTBL TuiVtbl
Initial value:
=
{
}
VOID TuiMessageBox(PCSTR MessageText)
Definition: tui.c:642
UCHAR TuiTextToColor(PCSTR ColorText)
Definition: tui.c:865
VOID TuiUnInitialize(VOID)
Definition: tui.c:252
static VOID TuiSetProgressBarText(_In_ PCSTR ProgressText)
Definition: tui.c:746
UCHAR TuiTextToFillStyle(PCSTR FillStyleText)
Definition: tui.c:904
VOID TuiDrawStatusText(PCSTR StatusText)
Definition: tui.c:537
static VOID TuiTickProgressBar(_In_ ULONG SubPercentTimes100)
Definition: tui.c:774
VOID TuiFadeInBackdrop(VOID)
Definition: tui.c:928
static VOID TuiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: tui.c:820
BOOLEAN TuiInitialize(VOID)
Definition: tui.c:206
BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: tui.c:984
VOID TuiDrawMenu(_In_ PUI_MENU_INFO MenuInfo)
Definition: tuimenu.c:204
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: tuimenu.c:30

Definition at line 1217 of file tui.c.

Referenced by UiInitialize().