/* FUNCTIONS *****************************************************************/
BOOLEAN
-TuiDisplayMenu(PCSTR MenuHeader,
- PCSTR MenuFooter,
- BOOLEAN ShowBootOptions,
- PCSTR MenuItemList[],
- ULONG MenuItemCount,
- ULONG DefaultMenuItem,
- LONG MenuTimeOut,
- ULONG* SelectedMenuItem,
- BOOLEAN CanEscape,
- UiMenuKeyPressFilterCallback KeyPressFilter)
+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)
{
UI_MENU_INFO MenuInformation;
ULONG LastClockSecond;
if (!MenuTimeOut && KeyPressFilter && MachConsKbHit())
{
//
- // Get the key
+ // Get the key (get the extended key if needed)
//
KeyPress = MachConsGetCh();
-
- //
- // Is it extended? Then get the extended key
- //
- if (!KeyPress) KeyPress = MachConsGetCh();
+ if (KeyPress == KEY_EXTENDED)
+ KeyPress = MachConsGetCh();
//
// Call the supplied key filter callback function to see
// if it is going to handle this keypress.
//
- if (KeyPressFilter(KeyPress))
+ if (KeyPressFilter(KeyPress, DefaultMenuItem, Context))
{
//
// It processed the key character, cancel the timeout
MenuInformation.MenuItemCount = MenuItemCount;
MenuInformation.MenuTimeRemaining = MenuTimeOut;
MenuInformation.SelectedMenuItem = DefaultMenuItem;
+ MenuInformation.Context = Context;
//
// Calculate the size of the menu box
//
// Process key presses
//
- KeyPress = TuiProcessMenuKeyboardEvent(&MenuInformation,
- KeyPressFilter);
+ KeyPress = TuiProcessMenuKeyboardEvent(&MenuInformation, KeyPressFilter);
//
// Check for ENTER or ESC
}
VOID
-NTAPI
TuiCalcMenuBoxSize(PUI_MENU_INFO MenuInfo)
{
ULONG i;
}
VOID
-NTAPI
TuiDrawMenuBox(PUI_MENU_INFO MenuInfo)
{
CHAR MenuLineText[80], TempString[80];
}
VOID
-NTAPI
TuiDrawMenuItem(PUI_MENU_INFO MenuInfo,
ULONG MenuItemNumber)
{
}
ULONG
-NTAPI
TuiProcessMenuKeyboardEvent(PUI_MENU_INFO MenuInfo,
UiMenuKeyPressFilterCallback KeyPressFilter)
{
//
// Check for a keypress
//
- if (MachConsKbHit())
+ if (!MachConsKbHit())
+ return 0; // None, bail out
+
+ //
+ // Check if the timeout is not already complete
+ //
+ if (MenuInfo->MenuTimeRemaining != -1)
{
//
- // Check if the timeout is not already complete
+ // Cancel it and remove it
//
- if (MenuInfo->MenuTimeRemaining != -1)
- {
- //
- // Cancel it and remove it
- //
- MenuInfo->MenuTimeRemaining = -1;
- TuiDrawMenuBox(MenuInfo); // FIXME: Remove for minimal UI too
- }
+ MenuInfo->MenuTimeRemaining = -1;
+ TuiDrawMenuBox(MenuInfo); // FIXME: Remove for minimal UI too
+ }
- //
- // Get the key
- //
+ //
+ // Get the key (get the extended key if needed)
+ //
+ KeyEvent = MachConsGetCh();
+ if (KeyEvent == KEY_EXTENDED)
KeyEvent = MachConsGetCh();
+ //
+ // Call the supplied key filter callback function to see
+ // if it is going to handle this keypress.
+ //
+ if (KeyPressFilter &&
+ KeyPressFilter(KeyEvent, MenuInfo->SelectedMenuItem, MenuInfo->Context))
+ {
//
- // Is it extended? Then get the extended key
+ // It processed the key character, so redraw and exit
//
- if (!KeyEvent) KeyEvent = MachConsGetCh();
+ UiVtbl.DrawMenu(MenuInfo);
+ return 0;
+ }
+ //
+ // Process the key
+ //
+ if ((KeyEvent == KEY_UP ) || (KeyEvent == KEY_DOWN) ||
+ (KeyEvent == KEY_HOME) || (KeyEvent == KEY_END ))
+ {
//
- // Call the supplied key filter callback function to see
- // if it is going to handle this keypress.
+ // Get the current selected item and count
//
- if ((KeyPressFilter) && (KeyPressFilter(KeyEvent)))
- {
- //
- // It processed the key character, so redraw and exit
- //
- UiVtbl.DrawMenu(MenuInfo);
- return 0;
- }
+ Selected = MenuInfo->SelectedMenuItem;
+ Count = MenuInfo->MenuItemCount - 1;
//
- // Process the key
+ // Check the key and change the selected menu item
//
- if ((KeyEvent == KEY_UP ) || (KeyEvent == KEY_DOWN) ||
- (KeyEvent == KEY_HOME) || (KeyEvent == KEY_END ))
+ if ((KeyEvent == KEY_UP) && (Selected > 0))
{
//
- // Get the current selected item and count
+ // Deselect previous item and go up
//
- Selected = MenuInfo->SelectedMenuItem;
- Count = MenuInfo->MenuItemCount - 1;
+ MenuInfo->SelectedMenuItem--;
+ TuiDrawMenuItem(MenuInfo, Selected);
+ Selected--;
- //
- // Check the key and change the selected menu item
- //
- if ((KeyEvent == KEY_UP) && (Selected > 0))
+ // Skip past any separators
+ if ((Selected > 0) &&
+ (MenuInfo->MenuItemList[Selected] == NULL))
{
- //
- // Deselect previous item and go up
- //
MenuInfo->SelectedMenuItem--;
- TuiDrawMenuItem(MenuInfo, Selected);
- Selected--;
-
- // Skip past any separators
- if ((Selected > 0) &&
- (MenuInfo->MenuItemList[Selected] == NULL))
- {
- MenuInfo->SelectedMenuItem--;
- }
- }
- else if ( ((KeyEvent == KEY_UP) && (Selected == 0)) ||
- (KeyEvent == KEY_END) )
- {
- //
- // Go to the end
- //
- MenuInfo->SelectedMenuItem = Count;
- TuiDrawMenuItem(MenuInfo, Selected);
}
- else if ((KeyEvent == KEY_DOWN) && (Selected < Count))
+ }
+ else if ( ((KeyEvent == KEY_UP) && (Selected == 0)) ||
+ (KeyEvent == KEY_END) )
+ {
+ //
+ // Go to the end
+ //
+ MenuInfo->SelectedMenuItem = Count;
+ TuiDrawMenuItem(MenuInfo, Selected);
+ }
+ else if ((KeyEvent == KEY_DOWN) && (Selected < Count))
+ {
+ //
+ // Deselect previous item and go down
+ //
+ MenuInfo->SelectedMenuItem++;
+ TuiDrawMenuItem(MenuInfo, Selected);
+ Selected++;
+
+ // Skip past any separators
+ if ((Selected < Count) &&
+ (MenuInfo->MenuItemList[Selected] == NULL))
{
- //
- // Deselect previous item and go down
- //
MenuInfo->SelectedMenuItem++;
- TuiDrawMenuItem(MenuInfo, Selected);
- Selected++;
-
- // Skip past any separators
- if ((Selected < Count) &&
- (MenuInfo->MenuItemList[Selected] == NULL))
- {
- MenuInfo->SelectedMenuItem++;
- }
- }
- else if ( ((KeyEvent == KEY_DOWN) && (Selected == Count)) ||
- (KeyEvent == KEY_HOME) )
- {
- //
- // Go to the beginning
- //
- MenuInfo->SelectedMenuItem = 0;
- TuiDrawMenuItem(MenuInfo, Selected);
}
-
+ }
+ else if ( ((KeyEvent == KEY_DOWN) && (Selected == Count)) ||
+ (KeyEvent == KEY_HOME) )
+ {
//
- // Select new item and update video buffer
+ // Go to the beginning
//
- TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem);
- VideoCopyOffScreenBufferToVRAM();
+ MenuInfo->SelectedMenuItem = 0;
+ TuiDrawMenuItem(MenuInfo, Selected);
}
+
+ //
+ // Select new item and update video buffer
+ //
+ TuiDrawMenuItem(MenuInfo, MenuInfo->SelectedMenuItem);
+ VideoCopyOffScreenBufferToVRAM();
}
//