ReactOS 0.4.15-dev-7906-g1b85a5f
tuimenu.c File Reference
#include <freeldr.h>
Include dependency graph for tuimenu.c:

Go to the source code of this file.

Functions

static VOID TuiCalcMenuBoxSize (_In_ PUI_MENU_INFO MenuInfo)
 
static ULONG TuiProcessMenuKeyboardEvent (_In_ PUI_MENU_INFO MenuInfo, _In_ UiMenuKeyPressFilterCallback KeyPressFilter)
 
static VOID TuiDrawMenuTimeout (_In_ PUI_MENU_INFO MenuInfo)
 
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)
 
VOID TuiDrawMenu (_In_ PUI_MENU_INFO MenuInfo)
 
VOID TuiDrawMenuBox (_In_ PUI_MENU_INFO MenuInfo)
 
VOID TuiDrawMenuItem (_In_ PUI_MENU_INFO MenuInfo, _In_ ULONG MenuItemNumber)
 

Function Documentation

◆ TuiCalcMenuBoxSize()

static VOID TuiCalcMenuBoxSize ( _In_ PUI_MENU_INFO  MenuInfo)
static

Definition at line 144 of file tuimenu.c.

146{
147 ULONG i;
148 ULONG Width = 0;
151
152 /* Height is the menu item count plus 2 (top border & bottom border) */
153 Height = MenuInfo->MenuItemCount + 2;
154 Height -= 1; // Height is zero-based
155
156 /* Loop every item */
157 for (i = 0; i < MenuInfo->MenuItemCount; ++i)
158 {
159 /* Get the string length and make it become the new width if necessary */
160 if (MenuInfo->MenuItemList[i])
161 {
162 Length = (ULONG)strlen(MenuInfo->MenuItemList[i]);
163 if (Length > Width) Width = Length;
164 }
165 }
166
167 /* Allow room for left & right borders, plus 8 spaces on each side */
168 Width += 18;
169
170 /* Check if we're drawing a centered menu */
171 if (UiCenterMenu)
172 {
173 /* Calculate the menu box area for a centered menu */
174 MenuInfo->Left = (UiScreenWidth - Width) / 2;
177 }
178 else
179 {
180 /* Put the menu in the default left-corner position */
181 MenuInfo->Left = -1;
182 MenuInfo->Top = 4;
183 }
184
185 /* The other margins are the same */
186 MenuInfo->Right = MenuInfo->Left + Width;
187 MenuInfo->Bottom = MenuInfo->Top + Height;
188}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
ULONG UiScreenWidth
Definition: ui.c:54
BOOLEAN UiCenterMenu
Definition: ui.c:44
ULONG UiScreenHeight
Definition: ui.c:55
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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
menu info structure
Definition: window.h:276
#define TUI_TITLE_BOX_CHAR_HEIGHT
Definition: tui.h:33
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88

Referenced by TuiDisplayMenu().

◆ TuiDisplayMenu()

BOOLEAN TuiDisplayMenu ( IN PCSTR  MenuHeader,
IN PCSTR MenuFooter  OPTIONAL,
IN BOOLEAN  ShowBootOptions,
IN PCSTR  MenuItemList[],
IN ULONG  MenuItemCount,
IN ULONG  DefaultMenuItem,
IN LONG  MenuTimeOut,
OUT PULONG  SelectedMenuItem,
IN BOOLEAN  CanEscape,
IN UiMenuKeyPressFilterCallback KeyPressFilter  OPTIONAL,
IN PVOID Context  OPTIONAL 
)

Definition at line 30 of file tuimenu.c.

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

◆ TuiDrawMenu()

VOID TuiDrawMenu ( _In_ PUI_MENU_INFO  MenuInfo)

Definition at line 191 of file tuimenu.c.

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

◆ TuiDrawMenuBox()

VOID TuiDrawMenuBox ( _In_ PUI_MENU_INFO  MenuInfo)

Definition at line 342 of file tuimenu.c.

344{
345 // FIXME: Theme-specific
346 /* Draw the menu box if requested */
347 if (UiMenuBox)
348 {
349 UiDrawBox(MenuInfo->Left,
350 MenuInfo->Top,
351 MenuInfo->Right,
352 MenuInfo->Bottom,
353 D_VERT,
354 D_HORZ,
355 FALSE, // Filled
356 TRUE, // Shadow
358 }
359
360 /* Update the date & time */
363}
#define D_HORZ
Definition: ui.h:347
#define D_VERT
Definition: ui.h:349
UCHAR UiMenuBgColor
Definition: ui.c:35
#define ATTR(cFore, cBack)
Definition: ui.h:317
BOOLEAN UiMenuBox
Definition: ui.c:43
VOID UiDrawBox(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOLEAN Fill, BOOLEAN Shadow, UCHAR Attr)
Definition: ui.c:248
UCHAR UiMenuFgColor
Definition: ui.c:34

Referenced by MiniTuiDrawMenu(), and TuiDrawMenu().

◆ TuiDrawMenuItem()

VOID TuiDrawMenuItem ( _In_ PUI_MENU_INFO  MenuInfo,
_In_ ULONG  MenuItemNumber 
)

Definition at line 366 of file tuimenu.c.

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

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

◆ TuiDrawMenuTimeout()

static VOID TuiDrawMenuTimeout ( _In_ PUI_MENU_INFO  MenuInfo)
static

How to pad/fill:

Center Box What to do: 0 0 or 1 Pad on the right with blanks. 1 0 Pad on the left with blanks. 1 1 Pad on the left with blanks + box bottom border.

Definition at line 223 of file tuimenu.c.

225{
227 CHAR MenuLineText[80];
228
229 /* If there is a timeout, draw the time remaining */
230 if (MenuInfo->MenuTimeRemaining >= 0)
231 {
232 /* Find whether the time text string is escaped
233 * with %d for specific countdown insertion. */
235 while ((ptr = strchr(ptr, '%')) && (ptr[1] != 'd'))
236 {
237 /* Ignore any following character (including a following
238 * '%' that would be escaped), thus skip two characters.
239 * If this is the last character, ignore it and stop. */
240 if (*++ptr)
241 ++ptr;
242 }
243 ASSERT(!ptr || (ptr[0] == '%' && ptr[1] == 'd'));
244
245 if (ptr)
246 {
247 /* Copy the time text string up to the '%d' insertion point and
248 * skip it, add the remaining time and the rest of the string. */
249 RtlStringCbPrintfA(MenuLineText, sizeof(MenuLineText),
250 "%.*s%d%s",
252 MenuInfo->MenuTimeRemaining,
253 ptr + 2);
254 }
255 else
256 {
257 /* Copy the time text string, append a separating blank,
258 * and add the remaining time. */
259 RtlStringCbPrintfA(MenuLineText, sizeof(MenuLineText),
260 "%s %d",
262 MenuInfo->MenuTimeRemaining);
263 }
264
265 Length = (ULONG)strlen(MenuLineText);
266 }
267 else
268 {
269 /* Erase the timeout with blanks */
270 Length = 0;
271 }
272
282 if (UiCenterMenu)
283 {
284 /* In boxed menu mode, pad on the left with blanks and box border,
285 * otherwise, pad over all the box length until its right edge. */
286 TuiFillArea(0,
287 MenuInfo->Bottom,
289 ? MenuInfo->Left - 1 /* Left side of the box bottom */
290 : MenuInfo->Right, /* Left side + all box length */
291 MenuInfo->Bottom,
294
295 if (UiMenuBox)
296 {
297 /* Fill with box bottom border */
299 MenuInfo->Bottom,
300 MenuInfo->Right,
301 D_VERT,
302 D_HORZ,
304
305 /* In centered boxed menu mode, the timeout string
306 * does not go past the right border, in principle... */
307 }
308
309 if (Length > 0)
310 {
311 /* Display the timeout at the bottom-right part of the menu */
312 UiDrawText(MenuInfo->Right - Length - 1,
313 MenuInfo->Bottom,
314 MenuLineText,
316 }
317 }
318 else
319 {
320 if (Length > 0)
321 {
322 /* Display the timeout under the menu directly */
323 UiDrawText(0,
324 MenuInfo->Bottom + 4,
325 MenuLineText,
327 }
328
329 /* Pad on the right with blanks, to erase
330 * characters when the string length decreases. */
332 MenuInfo->Bottom + 4,
333 Length ? (Length + 1) : (UiScreenWidth - 1),
334 MenuInfo->Bottom + 4,
337 );
338 }
339}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
CHAR UiTimeText[260]
Definition: ui.c:48
UCHAR UiBackdropFgColor
Definition: ui.c:27
UCHAR UiBackdropFillStyle
Definition: ui.c:29
UCHAR UiBackdropBgColor
Definition: ui.c:28
static PVOID ptr
Definition: dispmode.c:27
VOID TuiFillArea(ULONG Left, ULONG Top, ULONG Right, ULONG Bottom, CHAR FillChar, UCHAR Attr)
Definition: tui.c:329
VOID TuiDrawBoxBottomLine(_In_ ULONG Left, _In_ ULONG Bottom, _In_ ULONG Right, _In_ UCHAR VertStyle, _In_ UCHAR HorzStyle, _In_ UCHAR Attr)
Definition: tui.c:460
char * PCHAR
Definition: typedefs.h:51

Referenced by TuiDisplayMenu(), TuiDrawMenuBox(), and TuiProcessMenuKeyboardEvent().

◆ TuiProcessMenuKeyboardEvent()

static ULONG TuiProcessMenuKeyboardEvent ( _In_ PUI_MENU_INFO  MenuInfo,
_In_ UiMenuKeyPressFilterCallback  KeyPressFilter 
)
static

Definition at line 463 of file tuimenu.c.

466{
467 ULONG KeyEvent = 0;
468 ULONG Selected, Count;
469
470 /* Check for a keypress */
471 if (!MachConsKbHit())
472 return 0; // None, bail out
473
474 /* Check if the timeout is not already complete */
475 if (MenuInfo->MenuTimeRemaining != -1)
476 {
477 /* Cancel it and remove it */
478 MenuInfo->MenuTimeRemaining = -1;
480 }
481
482 /* Get the key (get the extended key if needed) */
483 KeyEvent = MachConsGetCh();
484 if (KeyEvent == KEY_EXTENDED)
485 KeyEvent = MachConsGetCh();
486
487 /*
488 * Call the supplied key filter callback function to see
489 * if it is going to handle this keypress.
490 */
491 if (KeyPressFilter &&
492 KeyPressFilter(KeyEvent, MenuInfo->SelectedMenuItem, MenuInfo->Context))
493 {
494 /* It processed the key character, so redraw and exit */
496 return 0;
497 }
498
499 /* Process the key */
500 if ((KeyEvent == KEY_UP ) || (KeyEvent == KEY_DOWN) ||
501 (KeyEvent == KEY_HOME) || (KeyEvent == KEY_END ))
502 {
503 /* Get the current selected item and count */
504 Selected = MenuInfo->SelectedMenuItem;
505 Count = MenuInfo->MenuItemCount - 1;
506
507 /* Check the key and change the selected menu item */
508 if ((KeyEvent == KEY_UP) && (Selected > 0))
509 {
510 /* Deselect previous item and go up */
511 MenuInfo->SelectedMenuItem--;
512 TuiDrawMenuItem(MenuInfo, Selected);
513 Selected--;
514
515 /* Skip past any separators */
516 if ((Selected > 0) &&
517 (MenuInfo->MenuItemList[Selected] == NULL))
518 {
519 MenuInfo->SelectedMenuItem--;
520 }
521 }
522 else if ( ((KeyEvent == KEY_UP) && (Selected == 0)) ||
523 (KeyEvent == KEY_END) )
524 {
525 /* Go to the end */
526 MenuInfo->SelectedMenuItem = Count;
527 TuiDrawMenuItem(MenuInfo, Selected);
528 }
529 else if ((KeyEvent == KEY_DOWN) && (Selected < Count))
530 {
531 /* Deselect previous item and go down */
532 MenuInfo->SelectedMenuItem++;
533 TuiDrawMenuItem(MenuInfo, Selected);
534 Selected++;
535
536 /* Skip past any separators */
537 if ((Selected < Count) &&
538 (MenuInfo->MenuItemList[Selected] == NULL))
539 {
540 MenuInfo->SelectedMenuItem++;
541 }
542 }
543 else if ( ((KeyEvent == KEY_DOWN) && (Selected == Count)) ||
544 (KeyEvent == KEY_HOME) )
545 {
546 /* Go to the beginning */
547 MenuInfo->SelectedMenuItem = 0;
548 TuiDrawMenuItem(MenuInfo, Selected);
549 }
550
551 /* Select new item and update video buffer */
552 TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem);
554 }
555
556 /* Return the pressed key */
557 return KeyEvent;
558}
#define KEY_DOWN
Definition: keycodes.h:46
#define KEY_END
Definition: keycodes.h:64
#define KEY_HOME
Definition: keycodes.h:44
#define KEY_UP
Definition: keycodes.h:45
int Count
Definition: noreturn.cpp:7

Referenced by TuiDisplayMenu().