3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 PVOID TextVideoBuffer
= NULL
;
25 * printf() - prints formatted text to stdout
26 * originally from GRUB
28 int TuiPrintf(const char *format
, ... )
32 char c
, *ptr
, str
[16];
34 while ((c
= *(format
++)))
42 switch (c
= *(format
++))
44 case 'd': case 'u': case 'x':
46 _itoa(va_arg(ap
, unsigned long), str
, 16);
48 _itoa(va_arg(ap
, unsigned long), str
, 10);
54 MachConsPutChar(*(ptr
++));
58 case 'c': MachConsPutChar((va_arg(ap
,int))&0xff); break;
61 ptr
= va_arg(ap
,char *);
63 while ((c
= *(ptr
++)))
72 printf("\nprintf() invalid format specifier - %%%c\n", c
);
83 BOOLEAN
TuiInitialize(VOID
)
85 MachVideoClearScreen(ATTR(COLOR_WHITE
, COLOR_BLACK
));
86 MachVideoHideShowTextCursor(FALSE
);
88 TextVideoBuffer
= VideoAllocateOffScreenBuffer();
89 if (TextVideoBuffer
== NULL
)
97 VOID
TuiUnInitialize(VOID
)
99 if (UiUseSpecialEffects
)
105 MachVideoSetDisplayMode(NULL
, FALSE
);
108 //VideoClearScreen();
109 MachVideoHideShowTextCursor(TRUE
);
112 VOID
TuiDrawBackdrop(VOID
)
115 // Fill in the background (excluding title box & status bar)
118 TUI_TITLE_BOX_CHAR_HEIGHT
,
122 ATTR(UiBackdropFgColor
, UiBackdropBgColor
));
125 // Draw the title box
130 TUI_TITLE_BOX_CHAR_HEIGHT
- 1,
135 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
142 GetFreeLoaderVersionString(),
143 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
151 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
155 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
160 TuiDrawText(UiScreenWidth
- 16, 3, /*"F1 for Help"*/"F8 for Options", ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
165 TuiDrawText( (UiScreenWidth
/ 2) - (strlen(UiTitleBoxTitleText
) / 2),
168 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
173 TuiDrawStatusText("Welcome to FreeLoader!");
176 // Update the date & time
180 VideoCopyOffScreenBufferToVRAM();
185 * This function assumes coordinates are zero-based
187 VOID
TuiFillArea(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
, CHAR FillChar
, UCHAR Attr
/* Color Attributes */)
189 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
192 // Clip the area to the screen
193 if ((Left
>= UiScreenWidth
) || (Top
>= UiScreenHeight
))
197 if (Right
>= UiScreenWidth
)
199 Right
= UiScreenWidth
- 1;
201 if (Bottom
>= UiScreenHeight
)
203 Bottom
= UiScreenHeight
- 1;
206 // Loop through each line and fill it in
207 for (i
=Top
; i
<=Bottom
; i
++)
209 // Loop through each character (column) in the line and fill it in
210 for (j
=Left
; j
<=Right
; j
++)
212 ScreenMemory
[((i
*2)*UiScreenWidth
)+(j
*2)] = (UCHAR
)FillChar
;
213 ScreenMemory
[((i
*2)*UiScreenWidth
)+(j
*2)+1] = Attr
;
220 * This function assumes coordinates are zero-based
222 VOID
TuiDrawShadow(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
)
224 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
227 // Shade the bottom of the area
228 if (Bottom
< (UiScreenHeight
- 1))
230 if (UiScreenHeight
< 34)
239 for (; Idx
<=Right
; Idx
++)
241 ScreenMemory
[(((Bottom
+1)*2)*UiScreenWidth
)+(Idx
*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
245 // Shade the right of the area
246 if (Right
< (UiScreenWidth
- 1))
248 for (Idx
=Top
+1; Idx
<=Bottom
; Idx
++)
250 ScreenMemory
[((Idx
*2)*UiScreenWidth
)+((Right
+1)*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
253 if (UiScreenHeight
< 34)
255 if ((Right
+ 1) < (UiScreenWidth
- 1))
257 for (Idx
=Top
+1; Idx
<=Bottom
; Idx
++)
259 ScreenMemory
[((Idx
*2)*UiScreenWidth
)+((Right
+2)*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
264 // Shade the bottom right corner
265 if ((Right
< (UiScreenWidth
- 1)) && (Bottom
< (UiScreenHeight
- 1)))
267 ScreenMemory
[(((Bottom
+1)*2)*UiScreenWidth
)+((Right
+1)*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
269 if (UiScreenHeight
< 34)
271 if (((Right
+ 1) < (UiScreenWidth
- 1)) && (Bottom
< (UiScreenHeight
- 1)))
273 ScreenMemory
[(((Bottom
+1)*2)*UiScreenWidth
)+((Right
+2)*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
280 * This function assumes coordinates are zero-based
282 VOID
TuiDrawBox(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
, UCHAR VertStyle
, UCHAR HorzStyle
, BOOLEAN Fill
, BOOLEAN Shadow
, UCHAR Attr
)
284 UCHAR ULCorner
, URCorner
, LLCorner
, LRCorner
;
286 // Calculate the corner values
287 if (HorzStyle
== HORZ
)
289 if (VertStyle
== VERT
)
296 else // VertStyle == D_VERT
304 else // HorzStyle == D_HORZ
306 if (VertStyle
== VERT
)
313 else // VertStyle == D_VERT
322 // Fill in box background
325 TuiFillArea(Left
, Top
, Right
, Bottom
, ' ', Attr
);
329 TuiFillArea(Left
, Top
, Left
, Top
, ULCorner
, Attr
);
330 TuiFillArea(Right
, Top
, Right
, Top
, URCorner
, Attr
);
331 TuiFillArea(Left
, Bottom
, Left
, Bottom
, LLCorner
, Attr
);
332 TuiFillArea(Right
, Bottom
, Right
, Bottom
, LRCorner
, Attr
);
335 TuiFillArea(Left
, Top
+1, Left
, Bottom
-1, VertStyle
, Attr
);
337 TuiFillArea(Left
+1, Top
, Right
-1, Top
, HorzStyle
, Attr
);
338 // Fill in right line
339 TuiFillArea(Right
, Top
+1, Right
, Bottom
-1, VertStyle
, Attr
);
340 // Fill in bottom line
341 TuiFillArea(Left
+1, Bottom
, Right
-1, Bottom
, HorzStyle
, Attr
);
346 TuiDrawShadow(Left
, Top
, Right
, Bottom
);
352 * This function assumes coordinates are zero-based
354 VOID
TuiDrawText(ULONG X
, ULONG Y
, PCSTR Text
, UCHAR Attr
)
356 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
360 for (i
=X
, j
=0; Text
[j
] && i
<UiScreenWidth
; i
++,j
++)
362 ScreenMemory
[((Y
*2)*UiScreenWidth
)+(i
*2)] = (UCHAR
)Text
[j
];
363 ScreenMemory
[((Y
*2)*UiScreenWidth
)+(i
*2)+1] = Attr
;
367 VOID
TuiDrawCenteredText(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
, PCSTR TextString
, UCHAR Attr
)
372 ULONG LineBreakCount
;
381 TextLength
= strlen(TextString
);
383 // Count the new lines and the box width
387 for (Index
=0; Index
<TextLength
; Index
++)
389 if (TextString
[Index
] == '\n')
396 if ((Index
- LastIndex
) > BoxWidth
)
398 BoxWidth
= (Index
- LastIndex
);
403 BoxHeight
= LineBreakCount
+ 1;
405 RealLeft
= (((Right
- Left
) - BoxWidth
) / 2) + Left
;
406 RealTop
= (((Bottom
- Top
) - BoxHeight
) / 2) + Top
;
409 for (Index
=0; Index
<TextLength
; Index
++)
411 if (TextString
[Index
] == '\n')
418 X
= RealLeft
+ LastIndex
;
421 Temp
[0] = TextString
[Index
];
423 TuiDrawText(X
, Y
, Temp
, Attr
);
428 VOID
TuiDrawStatusText(PCSTR StatusText
)
432 TuiDrawText(0, UiScreenHeight
-1, " ", ATTR(UiStatusBarFgColor
, UiStatusBarBgColor
));
433 TuiDrawText(1, UiScreenHeight
-1, StatusText
, ATTR(UiStatusBarFgColor
, UiStatusBarBgColor
));
435 for (i
=strlen(StatusText
)+1; i
<UiScreenWidth
; i
++)
437 TuiDrawText(i
, UiScreenHeight
-1, " ", ATTR(UiStatusBarFgColor
, UiStatusBarBgColor
));
440 VideoCopyOffScreenBufferToVRAM();
443 VOID
TuiUpdateDateTime(VOID
)
449 BOOLEAN PMHour
= FALSE
;
451 /* Don't draw the time if this has been disabled */
452 if (!UiDrawTime
) return;
454 TimeInfo
= ArcGetTime();
455 if (TimeInfo
->Year
< 1 || 9999 < TimeInfo
->Year
||
456 TimeInfo
->Month
< 1 || 12 < TimeInfo
->Month
||
457 TimeInfo
->Day
< 1 || 31 < TimeInfo
->Day
||
458 23 < TimeInfo
->Hour
||
459 59 < TimeInfo
->Minute
||
460 59 < TimeInfo
->Second
)
462 /* This happens on QEmu sometimes. We just skip updating */
465 // Get the month name
466 strcpy(DateString
, UiMonthNames
[TimeInfo
->Month
- 1]);
468 _itoa(TimeInfo
->Day
, TempString
, 10);
469 // Get the day postfix
470 if (1 == TimeInfo
->Day
|| 21 == TimeInfo
->Day
|| 31 == TimeInfo
->Day
)
472 strcat(TempString
, "st");
474 else if (2 == TimeInfo
->Day
|| 22 == TimeInfo
->Day
)
476 strcat(TempString
, "nd");
478 else if (3 == TimeInfo
->Day
|| 23 == TimeInfo
->Day
)
480 strcat(TempString
, "rd");
484 strcat(TempString
, "th");
487 // Add the day to the date
488 strcat(DateString
, TempString
);
489 strcat(DateString
, " ");
491 // Get the year and add it to the date
492 _itoa(TimeInfo
->Year
, TempString
, 10);
493 strcat(DateString
, TempString
);
496 TuiDrawText(UiScreenWidth
-strlen(DateString
)-2, 1, DateString
, ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
498 // Get the hour and change from 24-hour mode to 12-hour
499 if (TimeInfo
->Hour
> 12)
501 TimeInfo
->Hour
-= 12;
504 if (TimeInfo
->Hour
== 0)
508 _itoa(TimeInfo
->Hour
, TempString
, 10);
509 strcpy(TimeString
, " ");
510 strcat(TimeString
, TempString
);
511 strcat(TimeString
, ":");
512 _itoa(TimeInfo
->Minute
, TempString
, 10);
513 if (TimeInfo
->Minute
< 10)
515 strcat(TimeString
, "0");
517 strcat(TimeString
, TempString
);
518 strcat(TimeString
, ":");
519 _itoa(TimeInfo
->Second
, TempString
, 10);
520 if (TimeInfo
->Second
< 10)
522 strcat(TimeString
, "0");
524 strcat(TimeString
, TempString
);
527 strcat(TimeString
, " PM");
531 strcat(TimeString
, " AM");
535 TuiDrawText(UiScreenWidth
-strlen(TimeString
)-2, 2, TimeString
, ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
538 VOID
TuiSaveScreen(PUCHAR Buffer
)
540 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
543 for (i
=0; i
< (UiScreenWidth
* UiScreenHeight
* 2); i
++)
545 Buffer
[i
] = ScreenMemory
[i
];
549 VOID
TuiRestoreScreen(PUCHAR Buffer
)
551 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
554 for (i
=0; i
< (UiScreenWidth
* UiScreenHeight
* 2); i
++)
556 ScreenMemory
[i
] = Buffer
[i
];
560 VOID
TuiMessageBox(PCSTR MessageText
)
564 // Save the screen contents
565 ScreenBuffer
= MmHeapAlloc(UiScreenWidth
* UiScreenHeight
* 2);
566 TuiSaveScreen(ScreenBuffer
);
568 // Display the message box
569 TuiMessageBoxCritical(MessageText
);
571 // Restore the screen contents
572 TuiRestoreScreen(ScreenBuffer
);
573 MmHeapFree(ScreenBuffer
);
576 VOID
TuiMessageBoxCritical(PCSTR MessageText
)
579 unsigned int height
= 1;
588 for (i
=0; i
<strlen(MessageText
); i
++)
590 if (MessageText
[i
] == '\n')
595 for (i
=0,j
=0,k
=0; i
<height
; i
++)
597 while ((MessageText
[j
] != '\n') && (MessageText
[j
] != 0))
610 // Calculate box area
611 x1
= (UiScreenWidth
- (width
+2))/2;
613 y1
= ((UiScreenHeight
- height
- 2)/2) + 1;
614 y2
= y1
+ height
+ 4;
617 TuiDrawBox(x1
, y1
, x2
, y2
, D_VERT
, D_HORZ
, TRUE
, TRUE
, ATTR(UiMessageBoxFgColor
, UiMessageBoxBgColor
));
620 for (i
=0,j
=0; i
<strlen(MessageText
)+1; i
++)
622 if ((MessageText
[i
] == '\n') || (MessageText
[i
] == 0))
626 UiDrawText(x1
+2, y1
+1+curline
, temp
, ATTR(UiMessageBoxFgColor
, UiMessageBoxBgColor
));
630 temp
[j
++] = MessageText
[i
];
634 strcpy(temp
, " OK ");
635 UiDrawText(x1
+((x2
-x1
)/2)-3, y2
-2, temp
, ATTR(COLOR_BLACK
, COLOR_GRAY
));
638 UiDrawStatusText("Press ENTER to continue");
640 VideoCopyOffScreenBufferToVRAM();
646 key
= MachConsGetCh();
647 if(key
== KEY_EXTENDED
)
648 key
= MachConsGetCh();
652 else if(key
== KEY_SPACE
)
654 else if(key
== KEY_ESC
)
660 VideoCopyOffScreenBufferToVRAM();
666 VOID
TuiDrawProgressBarCenter(ULONG Position
, ULONG Range
, PCHAR ProgressText
)
668 ULONG Left
, Top
, Right
, Bottom
;
669 ULONG Width
= 50; // Allow for 50 "bars"
672 Left
= (UiScreenWidth
- Width
- 4) / 2;
673 Right
= Left
+ Width
+ 3;
674 Top
= (UiScreenHeight
- Height
- 2) / 2;
676 Bottom
= Top
+ Height
+ 1;
678 TuiDrawProgressBar(Left
, Top
, Right
, Bottom
, Position
, Range
, ProgressText
);
681 VOID
TuiDrawProgressBar(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
, ULONG Position
, ULONG Range
, PCHAR ProgressText
)
684 ULONG ProgressBarWidth
= (Right
- Left
) - 3;
686 // First make sure the progress bar text fits
687 UiTruncateStringEllipsis(ProgressText
, ProgressBarWidth
- 4);
689 if (Position
> Range
)
695 TuiDrawBox(Left
, Top
, Right
, Bottom
, VERT
, HORZ
, TRUE
, TRUE
, ATTR(UiMenuFgColor
, UiMenuBgColor
));
698 // Draw the "Loading..." text
700 TuiDrawCenteredText(Left
+ 2, Top
+ 2, Right
- 2, Top
+ 2, ProgressText
, ATTR(UiTextColor
, UiMenuBgColor
));
702 // Draw the percent complete
703 for (i
=0; i
<(Position
*ProgressBarWidth
)/Range
; i
++)
705 TuiDrawText(Left
+2+i
, Top
+2, "\xDB", ATTR(UiTextColor
, UiMenuBgColor
));
709 for (; i
<ProgressBarWidth
; i
++)
711 TuiDrawText(Left
+2+i
, Top
+2, "\xB2", ATTR(UiTextColor
, UiMenuBgColor
));
715 VideoCopyOffScreenBufferToVRAM();
718 UCHAR
TuiTextToColor(PCSTR ColorText
)
720 if (_stricmp(ColorText
, "Black") == 0)
722 else if (_stricmp(ColorText
, "Blue") == 0)
724 else if (_stricmp(ColorText
, "Green") == 0)
726 else if (_stricmp(ColorText
, "Cyan") == 0)
728 else if (_stricmp(ColorText
, "Red") == 0)
730 else if (_stricmp(ColorText
, "Magenta") == 0)
731 return COLOR_MAGENTA
;
732 else if (_stricmp(ColorText
, "Brown") == 0)
734 else if (_stricmp(ColorText
, "Gray") == 0)
736 else if (_stricmp(ColorText
, "DarkGray") == 0)
737 return COLOR_DARKGRAY
;
738 else if (_stricmp(ColorText
, "LightBlue") == 0)
739 return COLOR_LIGHTBLUE
;
740 else if (_stricmp(ColorText
, "LightGreen") == 0)
741 return COLOR_LIGHTGREEN
;
742 else if (_stricmp(ColorText
, "LightCyan") == 0)
743 return COLOR_LIGHTCYAN
;
744 else if (_stricmp(ColorText
, "LightRed") == 0)
745 return COLOR_LIGHTRED
;
746 else if (_stricmp(ColorText
, "LightMagenta") == 0)
747 return COLOR_LIGHTMAGENTA
;
748 else if (_stricmp(ColorText
, "Yellow") == 0)
750 else if (_stricmp(ColorText
, "White") == 0)
756 UCHAR
TuiTextToFillStyle(PCSTR FillStyleText
)
758 if (_stricmp(FillStyleText
, "Light") == 0)
762 else if (_stricmp(FillStyleText
, "Medium") == 0)
766 else if (_stricmp(FillStyleText
, "Dark") == 0)
774 VOID
TuiFadeInBackdrop(VOID
)
776 PPALETTE_ENTRY TuiFadePalette
= NULL
;
778 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed())
780 TuiFadePalette
= (PPALETTE_ENTRY
)MmHeapAlloc(sizeof(PALETTE_ENTRY
) * 64);
782 if (TuiFadePalette
!= NULL
)
784 VideoSavePaletteState(TuiFadePalette
, 64);
785 VideoSetAllColorsToBlack(64);
789 // Draw the backdrop and title box
792 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed() && TuiFadePalette
!= NULL
)
794 VideoFadeIn(TuiFadePalette
, 64);
795 MmHeapFree(TuiFadePalette
);
799 VOID
TuiFadeOut(VOID
)
801 PPALETTE_ENTRY TuiFadePalette
= NULL
;
803 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed())
805 TuiFadePalette
= (PPALETTE_ENTRY
)MmHeapAlloc(sizeof(PALETTE_ENTRY
) * 64);
807 if (TuiFadePalette
!= NULL
)
809 VideoSavePaletteState(TuiFadePalette
, 64);
813 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed() && TuiFadePalette
!= NULL
)
818 MachVideoSetDisplayMode(NULL
, FALSE
);
820 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed() && TuiFadePalette
!= NULL
)
822 VideoRestorePaletteState(TuiFadePalette
, 64);
823 MmHeapFree(TuiFadePalette
);
828 BOOLEAN
TuiEditBox(PCSTR MessageText
, PCHAR EditTextBuffer
, ULONG Length
)
831 unsigned int height
= 1;
839 ULONG EditBoxStartX
, EditBoxEndX
;
841 unsigned int EditBoxTextCount
;
842 int EditBoxTextDisplayIndex
;
846 // Save the screen contents
847 ScreenBuffer
= MmHeapAlloc(UiScreenWidth
* UiScreenHeight
* 2);
848 TuiSaveScreen(ScreenBuffer
);
851 for (i
=0; i
<strlen(MessageText
); i
++)
853 if (MessageText
[i
] == '\n')
858 for (i
=0,j
=0,k
=0; i
<height
; i
++)
860 while ((MessageText
[j
] != '\n') && (MessageText
[j
] != 0))
873 // Calculate box area
874 x1
= (UiScreenWidth
- (width
+2))/2;
876 y1
= ((UiScreenHeight
- height
- 2)/2) + 1;
877 y2
= y1
+ height
+ 4;
880 TuiDrawBox(x1
, y1
, x2
, y2
, D_VERT
, D_HORZ
, TRUE
, TRUE
, ATTR(UiMessageBoxFgColor
, UiMessageBoxBgColor
));
883 for (i
=0,j
=0; i
<strlen(MessageText
)+1; i
++)
885 if ((MessageText
[i
] == '\n') || (MessageText
[i
] == 0))
889 UiDrawText(x1
+2, y1
+1+curline
, temp
, ATTR(UiMessageBoxFgColor
, UiMessageBoxBgColor
));
893 temp
[j
++] = MessageText
[i
];
896 EditBoxTextCount
= 0;
897 EditBoxLine
= y2
- 2;
898 EditBoxStartX
= x1
+ 3;
899 EditBoxEndX
= x2
- 3;
900 UiFillArea(EditBoxStartX
, EditBoxLine
, EditBoxEndX
, EditBoxLine
, ' ', ATTR(UiEditBoxTextColor
, UiEditBoxBgColor
));
903 EditBoxCursorX
= EditBoxStartX
;
904 MachVideoSetTextCursorPosition(EditBoxCursorX
, EditBoxLine
);
905 MachVideoHideShowTextCursor(TRUE
);
908 UiDrawStatusText("Press ENTER to continue, or ESC to cancel");
910 VideoCopyOffScreenBufferToVRAM();
916 key
= MachConsGetCh();
917 if(key
== KEY_EXTENDED
)
919 key
= MachConsGetCh();
927 else if(key
== KEY_ESC
)
932 else if (key
== KEY_BACKSPACE
) // Remove a character
934 if (EditBoxTextCount
)
937 EditTextBuffer
[EditBoxTextCount
] = 0;
944 else // Add this key to the buffer
946 if (EditBoxTextCount
< Length
- 1)
948 EditTextBuffer
[EditBoxTextCount
] = key
;
950 EditTextBuffer
[EditBoxTextCount
] = 0;
959 // Draw the edit box background
960 UiFillArea(EditBoxStartX
, EditBoxLine
, EditBoxEndX
, EditBoxLine
, ' ', ATTR(UiEditBoxTextColor
, UiEditBoxBgColor
));
963 if (EditBoxTextCount
> (EditBoxEndX
- EditBoxStartX
))
965 EditBoxTextDisplayIndex
= EditBoxTextCount
- (EditBoxEndX
- EditBoxStartX
);
966 EditBoxCursorX
= EditBoxEndX
;
970 EditBoxTextDisplayIndex
= 0;
971 EditBoxCursorX
= EditBoxStartX
+ EditBoxTextCount
;
973 UiDrawText(EditBoxStartX
, EditBoxLine
, &EditTextBuffer
[EditBoxTextDisplayIndex
], ATTR(UiEditBoxTextColor
, UiEditBoxBgColor
));
976 MachVideoSetTextCursorPosition(EditBoxCursorX
, EditBoxLine
);
980 VideoCopyOffScreenBufferToVRAM();
983 // Hide the cursor again
984 MachVideoHideShowTextCursor(FALSE
);
986 // Restore the screen contents
987 TuiRestoreScreen(ScreenBuffer
);
988 MmHeapFree(ScreenBuffer
);
993 const UIVTBL TuiVtbl
=
1002 TuiDrawCenteredText
,
1006 TuiMessageBoxCritical
,
1007 TuiDrawProgressBarCenter
,