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

Go to the source code of this file.

Classes

struct  _SMALL_RECT
 

Macros

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

Typedefs

typedef struct _SMALL_RECT SMALL_RECT
 
typedef struct _SMALL_RECTPSMALL_RECT
 

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)
 
_Ret_maybenull_ __drv_allocatesMem (Mem)
 
VOID TuiRestoreScreen (_In_opt_ __drv_freesMem(Mem) PUCHAR Buffer)
 
static VOID TuiDrawMsgBoxCommon (_In_ PCSTR MessageText, _Out_ PSMALL_RECT MsgBoxRect)
 
VOID TuiMessageBox (_In_ PCSTR MessageText)
 
VOID TuiMessageBoxCritical (_In_ 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 199 of file tui.c.

◆ TAG_TUI_SCREENBUFFER

#define TAG_TUI_SCREENBUFFER   'SiuT'

Definition at line 198 of file tui.c.

Typedef Documentation

◆ PSMALL_RECT

◆ SMALL_RECT

Function Documentation

◆ __drv_allocatesMem()

_Ret_maybenull_ __drv_allocatesMem ( Mem  )

Definition at line 618 of file tui.c.

621{
623 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
624 ULONG i;
625
626 /* Allocate the buffer */
629 if (!Buffer)
630 return NULL;
631
632 /* Loop through each cell and copy it */
633 for (i=0; i < (UiScreenWidth * UiScreenHeight * 2); i++)
634 {
635 Buffer[i] = ScreenMemory[i];
636 }
637
638 return Buffer;
639}
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
ULONG UiScreenWidth
Definition: ui.c:54
ULONG UiScreenHeight
Definition: ui.c:55
#define TAG_TUI_SCREENBUFFER
Definition: tui.c:198
PVOID TextVideoBuffer
Definition: tui.c:30
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
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
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59

◆ TuiDrawBackdrop()

VOID TuiDrawBackdrop ( VOID  )

Definition at line 272 of file tui.c.

273{
274 /* Fill in the background (excluding title box & status bar) */
275 TuiFillArea(0,
277 UiScreenWidth - 1,
278 UiScreenHeight - 2,
281
282 /* Draw the title box */
283 TuiDrawBox(0,
284 0,
285 UiScreenWidth - 1,
287 D_VERT,
288 D_HORZ,
289 TRUE,
290 FALSE,
292
293 /* Draw version text */
294 TuiDrawText(2,
295 1,
298
299 /* Draw copyright */
300 TuiDrawText(2,
301 2,
302 BY_AUTHOR,
304 TuiDrawText(2,
305 3,
308
309 /* Draw help text */
311 /*"F1 for Help"*/ "F8 for Options",
313
314 /* Draw title text */
316 2,
319
320 /* Update the date & time */
323}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
VOID VideoCopyOffScreenBufferToVRAM(VOID)
Definition: video.c:38
#define D_HORZ
Definition: ui.h:347
UCHAR UiTitleBoxBgColor
Definition: ui.c:31
#define D_VERT
Definition: ui.h:349
#define ATTR(cFore, cBack)
Definition: ui.h:317
CHAR UiTitleBoxTitleText[260]
Definition: ui.c:47
UCHAR UiTitleBoxFgColor
Definition: ui.c:30
UCHAR UiBackdropFgColor
Definition: ui.c:27
UCHAR UiBackdropFillStyle
Definition: ui.c:29
UCHAR UiBackdropBgColor
Definition: ui.c:28
VOID TuiDrawBox(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ BOOLEAN Fill, _In_ BOOLEAN Shadow, _In_ UCHAR Attr)
Definition: tui.c:504
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: tui.c:329
VOID TuiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: tui.c:78
VOID TuiUpdateDateTime(VOID)
Definition: tui.c:549
#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
#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 504 of file tui.c.

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

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

◆ TuiDrawBoxBottomLine()

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

Definition at line 460 of file tui.c.

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

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

Referenced by TuiDrawBox().

◆ TuiDrawCenteredText()

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

Definition at line 118 of file tui.c.

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

Referenced by MiniTuiSetProgressBarText(), and TuiSetProgressBarText().

◆ TuiDrawMsgBoxCommon()

static VOID TuiDrawMsgBoxCommon ( _In_ PCSTR  MessageText,
_Out_ PSMALL_RECT  MsgBoxRect 
)
static

Definition at line 664 of file tui.c.

667{
668 INT width = 8;
669 ULONG height = 1;
670 INT curline = 0;
671 INT k;
672 size_t i, j;
673 INT x1, x2, y1, y2;
674 CHAR temp[260];
675
676 /* Find the height */
677 for (i = 0; i < strlen(MessageText); i++)
678 {
679 if (MessageText[i] == '\n')
680 height++;
681 }
682
683 /* Find the width */
684 for (i = j = k = 0; i < height; i++)
685 {
686 while ((MessageText[j] != '\n') && (MessageText[j] != ANSI_NULL))
687 {
688 j++;
689 k++;
690 }
691
692 if (k > width)
693 width = k;
694
695 k = 0;
696 j++;
697 }
698
699 /* Calculate box area */
700 x1 = (UiScreenWidth - (width+2))/2;
701 x2 = x1 + width + 3;
702 y1 = ((UiScreenHeight - height - 2)/2) + 1;
703 y2 = y1 + height + 4;
704
705 MsgBoxRect->Left = x1; MsgBoxRect->Right = x2;
706 MsgBoxRect->Top = y1; MsgBoxRect->Bottom = y2;
707
708
709 /* Draw the box */
712
713 /* Draw the text */
714 for (i = j = 0; i < strlen(MessageText) + 1; i++)
715 {
716 if ((MessageText[i] == '\n') || (MessageText[i] == ANSI_NULL))
717 {
718 temp[j] = 0;
719 j = 0;
720 UiDrawText(x1 + 2, y1 + 1 + curline, temp,
722 curline++;
723 }
724 else
725 {
726 temp[j++] = MessageText[i];
727 }
728 }
729}
UCHAR UiMessageBoxFgColor
Definition: ui.c:32
UCHAR UiMessageBoxBgColor
Definition: ui.c:33
VOID UiDrawText(_In_ ULONG X, _In_ ULONG Y, _In_ PCSTR Text, _In_ UCHAR Attr)
Definition: ui.c:254
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
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
int k
Definition: mpi.c:3369
#define ANSI_NULL
static calc_node_t temp
Definition: rpn_ieee.c:38
int32_t INT
Definition: typedefs.h:58
_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

Referenced by TuiEditBox(), and TuiMessageBoxCritical().

◆ TuiDrawProgressBar()

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

Definition at line 885 of file tui.c.

891{
892 /* Draw the box */
893 TuiDrawBox(Left, Top, Right, Bottom,
894 VERT, HORZ, TRUE, TRUE,
896
897 /* Exclude the box margins */
898 Left += 2;
899 Right -= 2;
900 Top += 1;
901 Bottom -= 1;
902
903 UiInitProgressBar(Left, Top, Right, Bottom, ProgressText);
904}
UCHAR UiMenuBgColor
Definition: ui.c:35
UCHAR UiMenuFgColor
Definition: ui.c:34
VOID UiInitProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: ui.c:389

Referenced by TuiDrawProgressBarCenter().

◆ TuiDrawProgressBarCenter()

static VOID TuiDrawProgressBarCenter ( _In_ PCSTR  ProgressText)
static

Definition at line 861 of file tui.c.

863{
864 ULONG Left, Top, Right, Bottom, Width, Height;
865
866 /* Build the coordinates and sizes */
867 Height = 2;
868 Width = 50; // Allow for 50 "bars"
869 Left = (UiScreenWidth - Width) / 2;
870 Top = (UiScreenHeight - Height + 4) / 2;
871 Right = Left + Width - 1;
872 Bottom = Top + Height - 1;
873
874 /* Inflate to include the box margins */
875 Left -= 2;
876 Right += 2;
877 Top -= 1;
878 Bottom += 1;
879
880 /* Draw the progress bar */
881 TuiDrawProgressBar(Left, Top, Right, Bottom, ProgressText);
882}
static VOID TuiDrawProgressBar(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR ProgressText)
Definition: tui.c:885
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88

◆ TuiDrawShadow()

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

Definition at line 359 of file tui.c.

360{
361 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
362 ULONG Idx;
363
364 /* Shade the bottom of the area */
365 if (Bottom < (UiScreenHeight - 1))
366 {
367 if (UiScreenHeight < 34)
368 Idx = Left + 2;
369 else
370 Idx = Left + 1;
371
372 for (; Idx <= Right; ++Idx)
373 {
374 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+(Idx*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
375 }
376 }
377
378 /* Shade the right of the area */
379 if (Right < (UiScreenWidth - 1))
380 {
381 for (Idx=Top+1; Idx<=Bottom; Idx++)
382 {
383 ScreenMemory[((Idx*2)*UiScreenWidth)+((Right+1)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
384 }
385 }
386 if (UiScreenHeight < 34)
387 {
388 if ((Right + 1) < (UiScreenWidth - 1))
389 {
390 for (Idx=Top+1; Idx<=Bottom; Idx++)
391 {
392 ScreenMemory[((Idx*2)*UiScreenWidth)+((Right+2)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
393 }
394 }
395 }
396
397 /* Shade the bottom right corner */
398 if ((Right < (UiScreenWidth - 1)) && (Bottom < (UiScreenHeight - 1)))
399 {
400 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+((Right+1)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
401 }
402 if (UiScreenHeight < 34)
403 {
404 if (((Right + 1) < (UiScreenWidth - 1)) && (Bottom < (UiScreenHeight - 1)))
405 {
406 ScreenMemory[(((Bottom+1)*2)*UiScreenWidth)+((Right+2)*2)+1] = ATTR(COLOR_GRAY, COLOR_BLACK);
407 }
408 }
409}
#define COLOR_GRAY
Definition: ui.h:329
#define COLOR_BLACK
Definition: ui.h:322

Referenced by TuiDrawBox().

◆ TuiDrawStatusText()

VOID TuiDrawStatusText ( PCSTR  StatusText)

Definition at line 534 of file tui.c.

535{
536 SIZE_T i;
537
540
541 for (i=strlen(StatusText)+1; i<UiScreenWidth; i++)
542 {
544 }
545
547}
UCHAR UiStatusBarBgColor
Definition: ui.c:26
UCHAR UiStatusBarFgColor
Definition: ui.c:25

◆ TuiDrawText()

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

Definition at line 78 of file tui.c.

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

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

◆ TuiDrawText2()

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

Definition at line 95 of file tui.c.

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

Referenced by TuiDrawText().

◆ TuiEditBox()

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

Definition at line 1025 of file tui.c.

1026{
1027 CHAR key;
1028 BOOLEAN Extended;
1029 INT EditBoxLine;
1030 ULONG EditBoxStartX, EditBoxEndX;
1031 INT EditBoxCursorX;
1032 ULONG EditBoxTextLength, EditBoxTextPosition;
1033 INT EditBoxTextDisplayIndex;
1034 BOOLEAN ReturnCode;
1035 SMALL_RECT BoxRect;
1037
1038 /* Save the screen contents */
1039 ScreenBuffer = TuiSaveScreen();
1040
1041 /* Draw the common parts of the message box */
1042 TuiDrawMsgBoxCommon(MessageText, &BoxRect);
1043
1044 EditBoxTextLength = (ULONG)strlen(EditTextBuffer);
1045 EditBoxTextLength = min(EditBoxTextLength, Length - 1);
1046 EditBoxTextPosition = 0;
1047 EditBoxLine = BoxRect.Bottom - 2;
1048 EditBoxStartX = BoxRect.Left + 3;
1049 EditBoxEndX = BoxRect.Right - 3;
1050
1051 // Draw the edit box background and the text
1052 UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1053 UiDrawText2(EditBoxStartX, EditBoxLine, EditBoxEndX - EditBoxStartX + 1, EditTextBuffer, ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1054
1055 // Show the cursor
1056 EditBoxCursorX = EditBoxStartX;
1057 MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
1059
1060 // Draw status text
1061 UiDrawStatusText("Press ENTER to continue, or ESC to cancel");
1062
1064
1065 //
1066 // Enter the text. Please keep in mind that the default input mode
1067 // of the edit boxes is in insertion mode, that is, you can insert
1068 // text without erasing the existing one.
1069 //
1070 for (;;)
1071 {
1072 if (MachConsKbHit())
1073 {
1074 Extended = FALSE;
1075 key = MachConsGetCh();
1076 if (key == KEY_EXTENDED)
1077 {
1078 Extended = TRUE;
1079 key = MachConsGetCh();
1080 }
1081
1082 if (key == KEY_ENTER)
1083 {
1084 ReturnCode = TRUE;
1085 break;
1086 }
1087 else if (key == KEY_ESC)
1088 {
1089 ReturnCode = FALSE;
1090 break;
1091 }
1092 else if (key == KEY_BACKSPACE) // Remove a character
1093 {
1094 if ( (EditBoxTextLength > 0) && (EditBoxTextPosition > 0) &&
1095 (EditBoxTextPosition <= EditBoxTextLength) )
1096 {
1097 EditBoxTextPosition--;
1098 memmove(EditTextBuffer + EditBoxTextPosition,
1099 EditTextBuffer + EditBoxTextPosition + 1,
1100 EditBoxTextLength - EditBoxTextPosition);
1101 EditBoxTextLength--;
1102 EditTextBuffer[EditBoxTextLength] = 0;
1103 }
1104 else
1105 {
1106 MachBeep();
1107 }
1108 }
1109 else if (Extended && key == KEY_DELETE) // Remove a character
1110 {
1111 if ( (EditBoxTextLength > 0) &&
1112 (EditBoxTextPosition < EditBoxTextLength) )
1113 {
1114 memmove(EditTextBuffer + EditBoxTextPosition,
1115 EditTextBuffer + EditBoxTextPosition + 1,
1116 EditBoxTextLength - EditBoxTextPosition);
1117 EditBoxTextLength--;
1118 EditTextBuffer[EditBoxTextLength] = 0;
1119 }
1120 else
1121 {
1122 MachBeep();
1123 }
1124 }
1125 else if (Extended && key == KEY_HOME) // Go to the start of the buffer
1126 {
1127 EditBoxTextPosition = 0;
1128 }
1129 else if (Extended && key == KEY_END) // Go to the end of the buffer
1130 {
1131 EditBoxTextPosition = EditBoxTextLength;
1132 }
1133 else if (Extended && key == KEY_RIGHT) // Go right
1134 {
1135 if (EditBoxTextPosition < EditBoxTextLength)
1136 EditBoxTextPosition++;
1137 else
1138 MachBeep();
1139 }
1140 else if (Extended && key == KEY_LEFT) // Go left
1141 {
1142 if (EditBoxTextPosition > 0)
1143 EditBoxTextPosition--;
1144 else
1145 MachBeep();
1146 }
1147 else if (!Extended) // Add this key to the buffer
1148 {
1149 if ( (EditBoxTextLength < Length - 1) &&
1150 (EditBoxTextPosition < Length - 1) )
1151 {
1152 memmove(EditTextBuffer + EditBoxTextPosition + 1,
1153 EditTextBuffer + EditBoxTextPosition,
1154 EditBoxTextLength - EditBoxTextPosition);
1155 EditTextBuffer[EditBoxTextPosition] = key;
1156 EditBoxTextPosition++;
1157 EditBoxTextLength++;
1158 EditTextBuffer[EditBoxTextLength] = 0;
1159 }
1160 else
1161 {
1162 MachBeep();
1163 }
1164 }
1165 else
1166 {
1167 MachBeep();
1168 }
1169 }
1170
1171 // Draw the edit box background
1172 UiFillArea(EditBoxStartX, EditBoxLine, EditBoxEndX, EditBoxLine, ' ', ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1173
1174 // Fill the text in
1175 if (EditBoxTextPosition > (EditBoxEndX - EditBoxStartX))
1176 {
1177 EditBoxTextDisplayIndex = EditBoxTextPosition - (EditBoxEndX - EditBoxStartX);
1178 EditBoxCursorX = EditBoxEndX;
1179 }
1180 else
1181 {
1182 EditBoxTextDisplayIndex = 0;
1183 EditBoxCursorX = EditBoxStartX + EditBoxTextPosition;
1184 }
1185 UiDrawText2(EditBoxStartX, EditBoxLine, EditBoxEndX - EditBoxStartX + 1, &EditTextBuffer[EditBoxTextDisplayIndex], ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
1186
1187 // Move the cursor
1188 MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
1189
1191
1193
1194 MachHwIdle();
1195 }
1196
1197 // Hide the cursor again
1199
1200 /* Restore the screen contents */
1202
1203 return ReturnCode;
1204}
unsigned char BOOLEAN
#define MachHwIdle()
Definition: machine.h:139
#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
UCHAR UiEditBoxTextColor
Definition: ui.c:39
VOID UiDrawText2(_In_ ULONG X, _In_ ULONG Y, _In_opt_ ULONG MaxNumChars, _In_reads_or_z_(MaxNumChars) PCSTR Text, _In_ UCHAR Attr)
Definition: ui.c:264
VOID UiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: ui.c:238
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:286
UCHAR UiEditBoxBgColor
Definition: ui.c:40
VOID TuiRestoreScreen(_In_opt_ __drv_freesMem(Mem) PUCHAR Buffer)
Definition: tui.c:642
static VOID TuiDrawMsgBoxCommon(_In_ PCSTR MessageText, _Out_ PSMALL_RECT MsgBoxRect)
Definition: tui.c:664
#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
HANDLE ScreenBuffer
Definition: notevil.c:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
SHORT Right
Definition: tui.c:26
SHORT Left
Definition: tui.c:24
SHORT Bottom
Definition: tui.c:27
Definition: copy.c:22

◆ TuiFadeInBackdrop()

VOID TuiFadeInBackdrop ( VOID  )

Definition at line 969 of file tui.c.

970{
971 PPALETTE_ENTRY TuiFadePalette = NULL;
972
974 {
975 TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
977
978 if (TuiFadePalette != NULL)
979 {
980 VideoSavePaletteState(TuiFadePalette, 64);
982 }
983 }
984
985 // Draw the backdrop and title box
987
988 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
989 {
990 VideoFadeIn(TuiFadePalette, 64);
991 FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE);
992 }
993}
#define MachVideoIsPaletteFixed()
Definition: machine.h:110
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:79
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
Definition: video.c:67
struct _PALETTE_ENTRY * PPALETTE_ENTRY
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:44
BOOLEAN UiUseSpecialEffects
Definition: ui.c:45
#define TAG_TUI_PALETTE
Definition: tui.c:199
VOID TuiDrawBackdrop(VOID)
Definition: tui.c:272
Definition: video.h:12

◆ TuiFadeOut()

VOID TuiFadeOut ( VOID  )

Definition at line 995 of file tui.c.

996{
997 PPALETTE_ENTRY TuiFadePalette = NULL;
998
1000 {
1001 TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
1003
1004 if (TuiFadePalette != NULL)
1005 {
1006 VideoSavePaletteState(TuiFadePalette, 64);
1007 }
1008 }
1009
1010 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
1011 {
1012 VideoFadeOut(64);
1013 }
1014
1016
1017 if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
1018 {
1019 VideoRestorePaletteState(TuiFadePalette, 64);
1020 FrLdrTempFree(TuiFadePalette, TAG_TUI_PALETTE);
1021 }
1022
1023}
#define MachVideoSetDisplayMode(Mode, Init)
Definition: machine.h:94
VOID VideoFadeOut(ULONG ColorCount)
Definition: video.c:138
VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount)
Definition: video.c:54

Referenced by TuiUnInitialize().

◆ TuiFillArea()

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

Definition at line 329 of file tui.c.

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

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

◆ TuiInitialize()

BOOLEAN TuiInitialize ( VOID  )

Definition at line 203 of file tui.c.

204{
208
210 if (TextVideoBuffer == NULL)
211 {
212 return FALSE;
213 }
214
215 /* Load default settings with "Full" TUI Theme */
216
233
235 UiMenuBox = TRUE;
238
239 // TODO: Have a boolean to show/hide title box?
241 "Boot Menu");
242
244 "[Time Remaining: %d]");
245
246 return TRUE;
247}
#define MachVideoClearScreen(Attr)
Definition: machine.h:92
PVOID VideoAllocateOffScreenBuffer(VOID)
Definition: video.c:16
#define COLOR_BLUE
Definition: ui.h:323
BOOLEAN UiCenterMenu
Definition: ui.c:44
#define COLOR_YELLOW
Definition: ui.h:337
UCHAR UiTextColor
Definition: ui.c:36
#define MEDIUM_FILL
Definition: ui.h:311
#define COLOR_CYAN
Definition: ui.h:325
CHAR UiTimeText[260]
Definition: ui.c:48
#define COLOR_WHITE
Definition: ui.h:338
BOOLEAN UiShowTime
Definition: ui.c:42
BOOLEAN UiMenuBox
Definition: ui.c:43
UCHAR UiSelectedTextColor
Definition: ui.c:37
UCHAR UiSelectedTextBgColor
Definition: ui.c:38
#define COLOR_RED
Definition: ui.h:326
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156

Referenced by MiniTuiInitialize().

◆ TuiMessageBox()

VOID TuiMessageBox ( _In_ PCSTR  MessageText)

Definition at line 732 of file tui.c.

734{
736
737 /* Save the screen contents */
738 ScreenBuffer = TuiSaveScreen();
739
740 /* Display the message box */
741 TuiMessageBoxCritical(MessageText);
742
743 /* Restore the screen contents */
745}
VOID TuiMessageBoxCritical(_In_ PCSTR MessageText)
Definition: tui.c:748

◆ TuiMessageBoxCritical()

VOID TuiMessageBoxCritical ( _In_ PCSTR  MessageText)

Definition at line 748 of file tui.c.

750{
751 SMALL_RECT BoxRect;
752 CHAR key;
753
754 /* Draw the common parts of the message box */
755 TuiDrawMsgBoxCommon(MessageText, &BoxRect);
756
757 /* Draw centered OK button */
758 UiDrawText((BoxRect.Left + BoxRect.Right) / 2 - 3,
759 BoxRect.Bottom - 2,
760 " OK ",
762
763 /* Draw status text */
764 UiDrawStatusText("Press ENTER to continue");
765
767
768 for (;;)
769 {
770 if (MachConsKbHit())
771 {
772 key = MachConsGetCh();
773 if (key == KEY_EXTENDED)
774 key = MachConsGetCh();
775
776 if ((key == KEY_ENTER) || (key == KEY_SPACE) || (key == KEY_ESC))
777 break;
778 }
779
781
783
784 MachHwIdle();
785 }
786}
#define KEY_SPACE
Definition: keycodes.h:42

Referenced by TuiMessageBox().

◆ TuiPrintf()

INT TuiPrintf ( _In_ PCSTR  Format,
  ... 
)

Definition at line 39 of file tui.c.

41{
42 INT i;
43 INT Length;
44 va_list ap;
45 CHAR Buffer[512];
46
48 Length = _vsnprintf(Buffer, sizeof(Buffer), Format, ap);
49 va_end(ap);
50
51 if (Length == -1)
52 Length = (INT)sizeof(Buffer);
53
54 for (i = 0; i < Length; i++)
55 {
57 }
58
59 return Length;
60}
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
#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 ( _In_opt_ __drv_freesMem(Mem) PUCHAR  Buffer)

Definition at line 642 of file tui.c.

644{
645 PUCHAR ScreenMemory = (PUCHAR)TextVideoBuffer;
646 ULONG i;
647
648 if (!Buffer)
649 return;
650
651 /* Loop through each cell and copy it */
652 for (i=0; i < (UiScreenWidth * UiScreenHeight * 2); i++)
653 {
654 ScreenMemory[i] = Buffer[i];
655 }
656
657 /* Free the buffer */
659
661}

Referenced by TuiEditBox(), and TuiMessageBox().

◆ TuiSetProgressBarText()

static VOID TuiSetProgressBarText ( _In_ PCSTR  ProgressText)
static

Definition at line 789 of file tui.c.

791{
792 ULONG ProgressBarWidth;
793 CHAR ProgressString[256];
794
795 /* Make sure the progress bar is enabled */
797
798 /* Calculate the width of the bar proper */
799 ProgressBarWidth = UiProgressBar.Right - UiProgressBar.Left + 1;
800
801 /* First make sure the progress bar text fits */
802 RtlStringCbCopyA(ProgressString, sizeof(ProgressString), ProgressText);
803 TuiTruncateStringEllipsis(ProgressString, ProgressBarWidth);
804
805 /* Clear the text area */
809
810 /* Draw the "Loading..." text */
813 ProgressString, ATTR(UiTextColor, UiMenuBgColor));
814}
UI_PROGRESS_BAR UiProgressBar
Definition: ui.c:62
VOID TuiDrawCenteredText(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ PCSTR TextString, _In_ UCHAR Attr)
Definition: tui.c:118
VOID TuiTruncateStringEllipsis(_Inout_z_ PSTR StringText, _In_ ULONG MaxChars)
Definition: tui.c:63
#define ASSERT(a)
Definition: mode.c:44
ULONG Top
Definition: ui.h:132
ULONG Bottom
Definition: ui.h:134
BOOLEAN Show
Definition: ui.h:136
ULONG Left
Definition: ui.h:131
ULONG Right
Definition: ui.h:133

◆ TuiTextToColor()

UCHAR TuiTextToColor ( PCSTR  ColorText)

Definition at line 906 of file tui.c.

907{
908 static const struct
909 {
910 PCSTR ColorName;
911 UCHAR ColorValue;
912 } Colors[] =
913 {
914 {"Black" , COLOR_BLACK },
915 {"Blue" , COLOR_BLUE },
916 {"Green" , COLOR_GREEN },
917 {"Cyan" , COLOR_CYAN },
918 {"Red" , COLOR_RED },
919 {"Magenta", COLOR_MAGENTA},
920 {"Brown" , COLOR_BROWN },
921 {"Gray" , COLOR_GRAY },
922 {"DarkGray" , COLOR_DARKGRAY },
923 {"LightBlue" , COLOR_LIGHTBLUE },
924 {"LightGreen" , COLOR_LIGHTGREEN },
925 {"LightCyan" , COLOR_LIGHTCYAN },
926 {"LightRed" , COLOR_LIGHTRED },
927 {"LightMagenta", COLOR_LIGHTMAGENTA},
928 {"Yellow" , COLOR_YELLOW },
929 {"White" , COLOR_WHITE },
930 };
931 ULONG i;
932
933 if (_stricmp(ColorText, "Default") == 0)
935
936 for (i = 0; i < RTL_NUMBER_OF(Colors); ++i)
937 {
938 if (_stricmp(ColorText, Colors[i].ColorName) == 0)
939 return Colors[i].ColorValue;
940 }
941
942 return COLOR_BLACK;
943}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
Colors
Definition: ansiprsr.h:4
#define COLOR_LIGHTBLUE
Definition: ui.h:332
#define COLOR_LIGHTMAGENTA
Definition: ui.h:336
#define COLOR_DARKGRAY
Definition: ui.h:331
#define COLOR_LIGHTRED
Definition: ui.h:335
#define COLOR_LIGHTCYAN
Definition: ui.h:334
#define COLOR_MAGENTA
Definition: ui.h:327
#define COLOR_BROWN
Definition: ui.h:328
#define COLOR_LIGHTGREEN
Definition: ui.h:333
#define COLOR_GREEN
Definition: ui.h:324
UCHAR MachDefaultTextColor
Definition: pcvideo.c:111
#define _stricmp
Definition: cat.c:22
const char * PCSTR
Definition: typedefs.h:52

Referenced by MiniTuiInitialize().

◆ TuiTextToFillStyle()

UCHAR TuiTextToFillStyle ( PCSTR  FillStyleText)

Definition at line 945 of file tui.c.

946{
947 static const struct
948 {
949 PCSTR FillStyleName;
950 UCHAR FillStyleValue;
951 } FillStyles[] =
952 {
953 {"None" , ' '},
954 {"Light" , LIGHT_FILL },
955 {"Medium", MEDIUM_FILL},
956 {"Dark" , DARK_FILL },
957 };
958 ULONG i;
959
960 for (i = 0; i < RTL_NUMBER_OF(FillStyles); ++i)
961 {
962 if (_stricmp(FillStyleText, FillStyles[i].FillStyleName) == 0)
963 return FillStyles[i].FillStyleValue;
964 }
965
966 return LIGHT_FILL;
967}
#define LIGHT_FILL
Definition: ui.h:310
#define DARK_FILL
Definition: ui.h:312

◆ TuiTickProgressBar()

static VOID TuiTickProgressBar ( _In_ ULONG  SubPercentTimes100)
static

Definition at line 817 of file tui.c.

819{
820 ULONG ProgressBarWidth;
821 ULONG FillCount;
822
823 /* Make sure the progress bar is enabled */
825
826 ASSERT(SubPercentTimes100 <= (100 * 100));
827
828 /* Calculate the width of the bar proper */
829 ProgressBarWidth = UiProgressBar.Right - UiProgressBar.Left + 1;
830
831 /* Compute fill count */
832 // FillCount = (ProgressBarWidth * Position) / Range;
833 FillCount = ProgressBarWidth * SubPercentTimes100 / (100 * 100);
834
835 /* Fill the progress bar */
836 /* Draw the percent complete -- Use the fill character */
837 if (FillCount > 0)
838 {
840 UiProgressBar.Left + FillCount - 1, UiProgressBar.Bottom,
841 '\xDB', ATTR(UiTextColor, UiMenuBgColor));
842 }
843 /* Fill the remaining with shadow blanks */
846 '\xB2', ATTR(UiTextColor, UiMenuBgColor));
847
850}

◆ TuiTruncateStringEllipsis()

VOID TuiTruncateStringEllipsis ( _Inout_z_ PSTR  StringText,
_In_ ULONG  MaxChars 
)

Definition at line 63 of file tui.c.

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

Referenced by MiniTuiSetProgressBarText(), and TuiSetProgressBarText().

◆ TuiUnInitialize()

VOID TuiUnInitialize ( VOID  )

Definition at line 249 of file tui.c.

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

◆ TuiUpdateDateTime()

VOID TuiUpdateDateTime ( VOID  )

Definition at line 549 of file tui.c.

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

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

◆ TuiVtbl

const UIVTBL TuiVtbl
Initial value:
=
{
}
UCHAR TuiTextToColor(PCSTR ColorText)
Definition: tui.c:906
VOID TuiUnInitialize(VOID)
Definition: tui.c:249
static VOID TuiSetProgressBarText(_In_ PCSTR ProgressText)
Definition: tui.c:789
UCHAR TuiTextToFillStyle(PCSTR FillStyleText)
Definition: tui.c:945
VOID TuiDrawStatusText(PCSTR StatusText)
Definition: tui.c:534
static VOID TuiTickProgressBar(_In_ ULONG SubPercentTimes100)
Definition: tui.c:817
VOID TuiFadeInBackdrop(VOID)
Definition: tui.c:969
static VOID TuiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: tui.c:861
BOOLEAN TuiInitialize(VOID)
Definition: tui.c:203
BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
Definition: tui.c:1025
VOID TuiMessageBox(_In_ PCSTR MessageText)
Definition: tui.c:732
VOID TuiDrawMenu(_In_ PUI_MENU_INFO MenuInfo)
Definition: tuimenu.c:191
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 1206 of file tui.c.

Referenced by UiInitialize().