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
;
23 extern BOOL UiDrawTime
;
24 extern BOOL UiMinimal
;
27 * printf() - prints formatted text to stdout
28 * originally from GRUB
30 int printf(const char *format
, ... )
34 char c
, *ptr
, str
[16];
36 while ((c
= *(format
++)))
44 switch (c
= *(format
++))
46 case 'd': case 'u': case 'x':
48 *_itoa(va_arg(ap
, unsigned long), str
, 16) = 0;
50 *_itoa(va_arg(ap
, unsigned long), str
, 10) = 0;
56 MachConsPutChar(*(ptr
++));
60 case 'c': MachConsPutChar((va_arg(ap
,int))&0xff); break;
63 ptr
= va_arg(ap
,char *);
65 while ((c
= *(ptr
++)))
74 printf("\nprintf() invalid format specifier - %%%c\n", c
);
85 BOOL
TuiInitialize(VOID
)
87 MachVideoClearScreen(ATTR(COLOR_WHITE
, COLOR_BLACK
));
88 MachVideoHideShowTextCursor(FALSE
);
90 TextVideoBuffer
= VideoAllocateOffScreenBuffer();
91 if (TextVideoBuffer
== NULL
)
99 VOID
TuiUnInitialize(VOID
)
101 if (UiUseSpecialEffects
)
107 MachVideoSetDisplayMode(NULL
, FALSE
);
110 //VideoClearScreen();
111 MachVideoHideShowTextCursor(TRUE
);
114 VOID
TuiDrawBackdrop(VOID
)
119 // Fill in a black background
129 // Update the screen buffer
131 VideoCopyOffScreenBufferToVRAM();
136 // Fill in the background (excluding title box & status bar)
139 TUI_TITLE_BOX_CHAR_HEIGHT
,
143 ATTR(UiBackdropFgColor
, UiBackdropBgColor
));
146 // Draw the title box
151 TUI_TITLE_BOX_CHAR_HEIGHT
- 1,
156 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
163 GetFreeLoaderVersionString(),
164 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
172 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
176 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
181 TuiDrawText(UiScreenWidth
- 16, 3, /*"F1 for Help"*/"F8 for Options", ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
186 TuiDrawText( (UiScreenWidth
/ 2) - (strlen(UiTitleBoxTitleText
) / 2),
189 ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
194 TuiDrawStatusText("Welcome to FreeLoader!");
197 // Update the date & time
201 VideoCopyOffScreenBufferToVRAM();
206 * This function assumes coordinates are zero-based
208 VOID
TuiFillArea(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
, CHAR FillChar
, UCHAR Attr
/* Color Attributes */)
210 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
213 // Clip the area to the screen
214 if ((Left
>= UiScreenWidth
) || (Top
>= UiScreenHeight
))
218 if (Right
>= UiScreenWidth
)
220 Right
= UiScreenWidth
- 1;
222 if (Bottom
>= UiScreenHeight
)
224 Bottom
= UiScreenHeight
- 1;
227 // Loop through each line and fill it in
228 for (i
=Top
; i
<=Bottom
; i
++)
230 // Loop through each character (column) in the line and fill it in
231 for (j
=Left
; j
<=Right
; j
++)
233 ScreenMemory
[((i
*2)*UiScreenWidth
)+(j
*2)] = (UCHAR
)FillChar
;
234 ScreenMemory
[((i
*2)*UiScreenWidth
)+(j
*2)+1] = Attr
;
241 * This function assumes coordinates are zero-based
243 VOID
TuiDrawShadow(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
)
245 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
248 // Shade the bottom of the area
249 if (Bottom
< (UiScreenHeight
- 1))
251 if (UiScreenHeight
< 34)
260 for (; Idx
<=Right
; Idx
++)
262 ScreenMemory
[(((Bottom
+1)*2)*UiScreenWidth
)+(Idx
*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
266 // Shade the right of the area
267 if (Right
< (UiScreenWidth
- 1))
269 for (Idx
=Top
+1; Idx
<=Bottom
; Idx
++)
271 ScreenMemory
[((Idx
*2)*UiScreenWidth
)+((Right
+1)*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
274 if (UiScreenHeight
< 34)
276 if ((Right
+ 1) < (UiScreenWidth
- 1))
278 for (Idx
=Top
+1; Idx
<=Bottom
; Idx
++)
280 ScreenMemory
[((Idx
*2)*UiScreenWidth
)+((Right
+2)*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
285 // Shade the bottom right corner
286 if ((Right
< (UiScreenWidth
- 1)) && (Bottom
< (UiScreenHeight
- 1)))
288 ScreenMemory
[(((Bottom
+1)*2)*UiScreenWidth
)+((Right
+1)*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
290 if (UiScreenHeight
< 34)
292 if (((Right
+ 1) < (UiScreenWidth
- 1)) && (Bottom
< (UiScreenHeight
- 1)))
294 ScreenMemory
[(((Bottom
+1)*2)*UiScreenWidth
)+((Right
+2)*2)+1] = ATTR(COLOR_GRAY
, COLOR_BLACK
);
301 * This function assumes coordinates are zero-based
303 VOID
TuiDrawBox(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
, UCHAR VertStyle
, UCHAR HorzStyle
, BOOL Fill
, BOOL Shadow
, UCHAR Attr
)
305 UCHAR ULCorner
, URCorner
, LLCorner
, LRCorner
;
307 // Calculate the corner values
308 if (HorzStyle
== HORZ
)
310 if (VertStyle
== VERT
)
317 else // VertStyle == D_VERT
325 else // HorzStyle == D_HORZ
327 if (VertStyle
== VERT
)
334 else // VertStyle == D_VERT
343 // Fill in box background
346 TuiFillArea(Left
, Top
, Right
, Bottom
, ' ', Attr
);
350 TuiFillArea(Left
, Top
, Left
, Top
, ULCorner
, Attr
);
351 TuiFillArea(Right
, Top
, Right
, Top
, URCorner
, Attr
);
352 TuiFillArea(Left
, Bottom
, Left
, Bottom
, LLCorner
, Attr
);
353 TuiFillArea(Right
, Bottom
, Right
, Bottom
, LRCorner
, Attr
);
356 TuiFillArea(Left
, Top
+1, Left
, Bottom
-1, VertStyle
, Attr
);
358 TuiFillArea(Left
+1, Top
, Right
-1, Top
, HorzStyle
, Attr
);
359 // Fill in right line
360 TuiFillArea(Right
, Top
+1, Right
, Bottom
-1, VertStyle
, Attr
);
361 // Fill in bottom line
362 TuiFillArea(Left
+1, Bottom
, Right
-1, Bottom
, HorzStyle
, Attr
);
367 TuiDrawShadow(Left
, Top
, Right
, Bottom
);
373 * This function assumes coordinates are zero-based
375 VOID
TuiDrawText(ULONG X
, ULONG Y
, PCSTR Text
, UCHAR Attr
)
377 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
381 for (i
=X
, j
=0; Text
[j
] && i
<UiScreenWidth
; i
++,j
++)
383 ScreenMemory
[((Y
*2)*UiScreenWidth
)+(i
*2)] = (UCHAR
)Text
[j
];
384 ScreenMemory
[((Y
*2)*UiScreenWidth
)+(i
*2)+1] = Attr
;
388 VOID
TuiDrawCenteredText(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
, PCSTR TextString
, UCHAR Attr
)
393 ULONG LineBreakCount
;
402 TextLength
= strlen(TextString
);
404 // Count the new lines and the box width
408 for (Index
=0; Index
<TextLength
; Index
++)
410 if (TextString
[Index
] == '\n')
417 if ((Index
- LastIndex
) > BoxWidth
)
419 BoxWidth
= (Index
- LastIndex
);
424 BoxHeight
= LineBreakCount
+ 1;
426 RealLeft
= (((Right
- Left
) - BoxWidth
) / 2) + Left
;
427 RealTop
= (((Bottom
- Top
) - BoxHeight
) / 2) + Top
;
430 for (Index
=0; Index
<TextLength
; Index
++)
432 if (TextString
[Index
] == '\n')
439 X
= RealLeft
+ LastIndex
;
442 Temp
[0] = TextString
[Index
];
444 TuiDrawText(X
, Y
, Temp
, Attr
);
449 VOID
TuiDrawStatusText(PCSTR StatusText
)
454 // Minimal UI doesn't have a status bar
456 if (UiMinimal
) return;
458 TuiDrawText(0, UiScreenHeight
-1, " ", ATTR(UiStatusBarFgColor
, UiStatusBarBgColor
));
459 TuiDrawText(1, UiScreenHeight
-1, StatusText
, ATTR(UiStatusBarFgColor
, UiStatusBarBgColor
));
461 for (i
=strlen(StatusText
)+1; i
<UiScreenWidth
; i
++)
463 TuiDrawText(i
, UiScreenHeight
-1, " ", ATTR(UiStatusBarFgColor
, UiStatusBarBgColor
));
466 VideoCopyOffScreenBufferToVRAM();
469 VOID
TuiUpdateDateTime(VOID
)
471 ULONG Year
, Month
, Day
;
472 ULONG Hour
, Minute
, Second
;
478 /* Don't draw the time if this has been disabled */
479 if (!UiDrawTime
) return;
481 MachRTCGetCurrentDateTime(&Year
, &Month
, &Day
, &Hour
, &Minute
, &Second
);
482 if (Year
< 1 || 9999 < Year
|| Month
< 1 || 12 < Month
|| Day
< 1 ||
483 31 < Day
|| 23 < Hour
|| 59 < Minute
|| 59 < Second
)
485 /* This happens on QEmu sometimes. We just skip updating */
488 // Get the month name
489 strcpy(DateString
, UiMonthNames
[Month
- 1]);
491 _itoa(Day
, TempString
, 10);
492 // Get the day postfix
493 if (1 == Day
|| 21 == Day
|| 31 == Day
)
495 strcat(TempString
, "st");
497 else if (2 == Day
|| 22 == Day
)
499 strcat(TempString
, "nd");
501 else if (3 == Day
|| 23 == Day
)
503 strcat(TempString
, "rd");
507 strcat(TempString
, "th");
510 // Add the day to the date
511 strcat(DateString
, TempString
);
512 strcat(DateString
, " ");
514 // Get the year and add it to the date
515 _itoa(Year
, TempString
, 10);
516 strcat(DateString
, TempString
);
519 TuiDrawText(UiScreenWidth
-strlen(DateString
)-2, 1, DateString
, ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
521 // Get the hour and change from 24-hour mode to 12-hour
531 _itoa(Hour
, TempString
, 10);
532 strcpy(TimeString
, " ");
533 strcat(TimeString
, TempString
);
534 strcat(TimeString
, ":");
535 _itoa(Minute
, TempString
, 10);
538 strcat(TimeString
, "0");
540 strcat(TimeString
, TempString
);
541 strcat(TimeString
, ":");
542 _itoa(Second
, TempString
, 10);
545 strcat(TimeString
, "0");
547 strcat(TimeString
, TempString
);
550 strcat(TimeString
, " PM");
554 strcat(TimeString
, " AM");
558 TuiDrawText(UiScreenWidth
-strlen(TimeString
)-2, 2, TimeString
, ATTR(UiTitleBoxFgColor
, UiTitleBoxBgColor
));
561 VOID
TuiSaveScreen(PUCHAR Buffer
)
563 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
566 for (i
=0; i
< (UiScreenWidth
* UiScreenHeight
* 2); i
++)
568 Buffer
[i
] = ScreenMemory
[i
];
572 VOID
TuiRestoreScreen(PUCHAR Buffer
)
574 PUCHAR ScreenMemory
= (PUCHAR
)TextVideoBuffer
;
577 for (i
=0; i
< (UiScreenWidth
* UiScreenHeight
* 2); i
++)
579 ScreenMemory
[i
] = Buffer
[i
];
583 VOID
TuiMessageBox(PCSTR MessageText
)
587 // Save the screen contents
588 ScreenBuffer
= MmAllocateMemory(UiScreenWidth
* UiScreenHeight
* 2);
589 TuiSaveScreen(ScreenBuffer
);
591 // Display the message box
592 TuiMessageBoxCritical(MessageText
);
594 // Restore the screen contents
595 TuiRestoreScreen(ScreenBuffer
);
596 MmFreeMemory(ScreenBuffer
);
599 VOID
TuiMessageBoxCritical(PCSTR MessageText
)
602 unsigned int height
= 1;
611 for (i
=0; i
<strlen(MessageText
); i
++)
613 if (MessageText
[i
] == '\n')
618 for (i
=0,j
=0,k
=0; i
<height
; i
++)
620 while ((MessageText
[j
] != '\n') && (MessageText
[j
] != 0))
633 // Calculate box area
634 x1
= (UiScreenWidth
- (width
+2))/2;
636 y1
= ((UiScreenHeight
- height
- 2)/2) + 1;
637 y2
= y1
+ height
+ 4;
640 TuiDrawBox(x1
, y1
, x2
, y2
, D_VERT
, D_HORZ
, TRUE
, TRUE
, ATTR(UiMessageBoxFgColor
, UiMessageBoxBgColor
));
643 for (i
=0,j
=0; i
<strlen(MessageText
)+1; i
++)
645 if ((MessageText
[i
] == '\n') || (MessageText
[i
] == 0))
649 UiDrawText(x1
+2, y1
+1+curline
, temp
, ATTR(UiMessageBoxFgColor
, UiMessageBoxBgColor
));
653 temp
[j
++] = MessageText
[i
];
657 strcpy(temp
, " OK ");
658 UiDrawText(x1
+((x2
-x1
)/2)-3, y2
-2, temp
, ATTR(COLOR_BLACK
, COLOR_GRAY
));
661 UiDrawStatusText("Press ENTER to continue");
663 VideoCopyOffScreenBufferToVRAM();
669 key
= MachConsGetCh();
670 if(key
== KEY_EXTENDED
)
671 key
= MachConsGetCh();
675 else if(key
== KEY_SPACE
)
677 else if(key
== KEY_ESC
)
683 VideoCopyOffScreenBufferToVRAM();
689 VOID
TuiDrawProgressBarCenter(ULONG Position
, ULONG Range
, PCHAR ProgressText
)
691 ULONG Left
, Top
, Right
, Bottom
;
692 ULONG Width
= 50; // Allow for 50 "bars"
696 // Is this the minimal UI?
701 // Use alternate settings
705 Right
= Left
+ Width
;
706 Top
= UiScreenHeight
- Height
- 4;
707 Bottom
= Top
+ Height
+ 1;
711 Left
= (UiScreenWidth
- Width
- 4) / 2;
712 Right
= Left
+ Width
+ 3;
713 Top
= (UiScreenHeight
- Height
- 2) / 2;
717 Bottom
= Top
+ Height
+ 1;
719 TuiDrawProgressBar(Left
, Top
, Right
, Bottom
, Position
, Range
, ProgressText
);
722 VOID
TuiDrawProgressBar(ULONG Left
, ULONG Top
, ULONG Right
, ULONG Bottom
, ULONG Position
, ULONG Range
, PCHAR ProgressText
)
725 ULONG ProgressBarWidth
= (Right
- Left
) - 3;
727 // First make sure the progress bar text fits
728 UiTruncateStringEllipsis(ProgressText
, ProgressBarWidth
- 4);
730 if (Position
> Range
)
736 // Minimal UI has no box, and only generic loading text
741 TuiDrawBox(Left
, Top
, Right
, Bottom
, VERT
, HORZ
, TRUE
, TRUE
, ATTR(UiMenuFgColor
, UiMenuBgColor
));
744 // Draw the "Loading..." text
746 TuiDrawCenteredText(Left
+ 2, Top
+ 2, Right
- 2, Top
+ 2, ProgressText
, ATTR(UiTextColor
, UiMenuBgColor
));
751 // Draw the "Loading..." text
753 TuiDrawCenteredText(Left
+ 2, Top
+ 1, Right
- 2, Top
+ 1, "ReactOS is loading files...", ATTR(7, 0));
756 // Draw the percent complete
757 for (i
=0; i
<(Position
*ProgressBarWidth
)/Range
; i
++)
759 TuiDrawText(Left
+2+i
, Top
+2, "\xDB", ATTR(UiTextColor
, UiMenuBgColor
));
762 // Draw the shadow for non-minimal UI
765 for (; i
<ProgressBarWidth
; i
++)
767 TuiDrawText(Left
+2+i
, Top
+2, "\xB2", ATTR(UiTextColor
, UiMenuBgColor
));
772 VideoCopyOffScreenBufferToVRAM();
775 UCHAR
TuiTextToColor(PCSTR ColorText
)
777 if (_stricmp(ColorText
, "Black") == 0)
779 else if (_stricmp(ColorText
, "Blue") == 0)
781 else if (_stricmp(ColorText
, "Green") == 0)
783 else if (_stricmp(ColorText
, "Cyan") == 0)
785 else if (_stricmp(ColorText
, "Red") == 0)
787 else if (_stricmp(ColorText
, "Magenta") == 0)
788 return COLOR_MAGENTA
;
789 else if (_stricmp(ColorText
, "Brown") == 0)
791 else if (_stricmp(ColorText
, "Gray") == 0)
793 else if (_stricmp(ColorText
, "DarkGray") == 0)
794 return COLOR_DARKGRAY
;
795 else if (_stricmp(ColorText
, "LightBlue") == 0)
796 return COLOR_LIGHTBLUE
;
797 else if (_stricmp(ColorText
, "LightGreen") == 0)
798 return COLOR_LIGHTGREEN
;
799 else if (_stricmp(ColorText
, "LightCyan") == 0)
800 return COLOR_LIGHTCYAN
;
801 else if (_stricmp(ColorText
, "LightRed") == 0)
802 return COLOR_LIGHTRED
;
803 else if (_stricmp(ColorText
, "LightMagenta") == 0)
804 return COLOR_LIGHTMAGENTA
;
805 else if (_stricmp(ColorText
, "Yellow") == 0)
807 else if (_stricmp(ColorText
, "White") == 0)
813 UCHAR
TuiTextToFillStyle(PCSTR FillStyleText
)
815 if (_stricmp(FillStyleText
, "Light") == 0)
819 else if (_stricmp(FillStyleText
, "Medium") == 0)
823 else if (_stricmp(FillStyleText
, "Dark") == 0)
831 VOID
TuiFadeInBackdrop(VOID
)
833 PPALETTE_ENTRY TuiFadePalette
= NULL
;
835 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed())
837 TuiFadePalette
= (PPALETTE_ENTRY
)MmAllocateMemory(sizeof(PALETTE_ENTRY
) * 64);
839 if (TuiFadePalette
!= NULL
)
841 VideoSavePaletteState(TuiFadePalette
, 64);
842 VideoSetAllColorsToBlack(64);
846 // Draw the backdrop and title box
849 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed() && TuiFadePalette
!= NULL
)
851 VideoFadeIn(TuiFadePalette
, 64);
852 MmFreeMemory(TuiFadePalette
);
856 VOID
TuiFadeOut(VOID
)
858 PPALETTE_ENTRY TuiFadePalette
= NULL
;
860 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed())
862 TuiFadePalette
= (PPALETTE_ENTRY
)MmAllocateMemory(sizeof(PALETTE_ENTRY
) * 64);
864 if (TuiFadePalette
!= NULL
)
866 VideoSavePaletteState(TuiFadePalette
, 64);
870 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed() && TuiFadePalette
!= NULL
)
875 MachVideoSetDisplayMode(NULL
, FALSE
);
877 if (UiUseSpecialEffects
&& ! MachVideoIsPaletteFixed() && TuiFadePalette
!= NULL
)
879 VideoRestorePaletteState(TuiFadePalette
, 64);
880 MmFreeMemory(TuiFadePalette
);
885 BOOL
TuiEditBox(PCSTR MessageText
, PCHAR EditTextBuffer
, ULONG Length
)
888 unsigned int height
= 1;
896 ULONG EditBoxStartX
, EditBoxEndX
;
898 unsigned int EditBoxTextCount
;
899 int EditBoxTextDisplayIndex
;
903 // Save the screen contents
904 ScreenBuffer
= MmAllocateMemory(UiScreenWidth
* UiScreenHeight
* 2);
905 TuiSaveScreen(ScreenBuffer
);
908 for (i
=0; i
<strlen(MessageText
); i
++)
910 if (MessageText
[i
] == '\n')
915 for (i
=0,j
=0,k
=0; i
<height
; i
++)
917 while ((MessageText
[j
] != '\n') && (MessageText
[j
] != 0))
930 // Calculate box area
931 x1
= (UiScreenWidth
- (width
+2))/2;
933 y1
= ((UiScreenHeight
- height
- 2)/2) + 1;
934 y2
= y1
+ height
+ 4;
937 TuiDrawBox(x1
, y1
, x2
, y2
, D_VERT
, D_HORZ
, TRUE
, TRUE
, ATTR(UiMessageBoxFgColor
, UiMessageBoxBgColor
));
940 for (i
=0,j
=0; i
<strlen(MessageText
)+1; i
++)
942 if ((MessageText
[i
] == '\n') || (MessageText
[i
] == 0))
946 UiDrawText(x1
+2, y1
+1+curline
, temp
, ATTR(UiMessageBoxFgColor
, UiMessageBoxBgColor
));
950 temp
[j
++] = MessageText
[i
];
953 EditBoxTextCount
= 0;
954 EditBoxLine
= y2
- 2;
955 EditBoxStartX
= x1
+ 3;
956 EditBoxEndX
= x2
- 3;
957 UiFillArea(EditBoxStartX
, EditBoxLine
, EditBoxEndX
, EditBoxLine
, ' ', ATTR(UiEditBoxTextColor
, UiEditBoxBgColor
));
960 EditBoxCursorX
= EditBoxStartX
;
961 MachVideoSetTextCursorPosition(EditBoxCursorX
, EditBoxLine
);
962 MachVideoHideShowTextCursor(TRUE
);
965 UiDrawStatusText("Press ENTER to continue, or ESC to cancel");
967 VideoCopyOffScreenBufferToVRAM();
973 key
= MachConsGetCh();
974 if(key
== KEY_EXTENDED
)
976 key
= MachConsGetCh();
984 else if(key
== KEY_ESC
)
989 else if (key
== KEY_BACKSPACE
) // Remove a character
991 if (EditBoxTextCount
)
994 EditTextBuffer
[EditBoxTextCount
] = 0;
1001 else // Add this key to the buffer
1003 if (EditBoxTextCount
< Length
- 1)
1005 EditTextBuffer
[EditBoxTextCount
] = key
;
1007 EditTextBuffer
[EditBoxTextCount
] = 0;
1016 // Draw the edit box background
1017 UiFillArea(EditBoxStartX
, EditBoxLine
, EditBoxEndX
, EditBoxLine
, ' ', ATTR(UiEditBoxTextColor
, UiEditBoxBgColor
));
1020 if (EditBoxTextCount
> (EditBoxEndX
- EditBoxStartX
))
1022 EditBoxTextDisplayIndex
= EditBoxTextCount
- (EditBoxEndX
- EditBoxStartX
);
1023 EditBoxCursorX
= EditBoxEndX
;
1027 EditBoxTextDisplayIndex
= 0;
1028 EditBoxCursorX
= EditBoxStartX
+ EditBoxTextCount
;
1030 UiDrawText(EditBoxStartX
, EditBoxLine
, &EditTextBuffer
[EditBoxTextDisplayIndex
], ATTR(UiEditBoxTextColor
, UiEditBoxBgColor
));
1033 MachVideoSetTextCursorPosition(EditBoxCursorX
, EditBoxLine
);
1035 TuiUpdateDateTime();
1037 VideoCopyOffScreenBufferToVRAM();
1040 // Hide the cursor again
1041 MachVideoHideShowTextCursor(FALSE
);
1043 // Restore the screen contents
1044 TuiRestoreScreen(ScreenBuffer
);
1045 MmFreeMemory(ScreenBuffer
);