Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ui-menu.h File Reference

Generic menu interaction functions. More...

#include "ui-output.h"

Go to the source code of this file.

Data Structures

struct  menu_action
 Primitive menu item with bound action. More...
struct  menu_iter
 Underlying function set for displaying lists in a certain kind of way. More...
struct  menu_skin
struct  menu


#define MN_ACT_GRAYED   0x0001 /* Allows selection but no action */
 Flags for menu_actions.
#define MN_ACT_HIDDEN   0x0002 /* Row is hidden, but may be selected via tag */


typedef enum _menu_row_style_t menu_row_style_t
 Type wrapper for various row styles.
typedef enum _menu_row_validity_t menu_row_validity_t
 Type wrapper for row validity.


enum  { CURS_UNKNOWN = 0, CURS_KNOWN = 1 }
 Type wrapper for various row styles. More...
enum  _menu_row_validity_t { MN_ROW_INVALID = 0, MN_ROW_VALID = 1, MN_ROW_HIDDEN = 2 }
 Type wrapper for row validity. More...
enum  menu_iter_id { MN_ITER_ACTIONS = 1, MN_ITER_STRINGS = 2 }
 Types of predefined skins available. More...
enum  skin_id { MN_SKIN_SCROLL = 1, MN_SKIN_COLUMNS = 2 }
 Identifiers for the kind of layout to use. More...
enum  {
  MN_REL_TAGS = 0x01, MN_NO_TAGS = 0x02, MN_PVT_TAGS = 0x04, MN_CASELESS_TAGS = 0x08,
  MN_DBL_TAP = 0x10, MN_NO_ACTION = 0x20
 Flags for menu appearance & behaviour. More...


struct menumenu_new (skin_id, const menu_iter *iter)
 Allocate and return a new, initialised, menu.
struct menumenu_new_action (menu_action *acts, size_t n)
void menu_init (struct menu *menu, skin_id skin, const menu_iter *iter)
 Initialise a menu, using the skin and iter functions specified.
const menu_itermenu_find_iter (menu_iter_id iter_id)
 Given a predefined menu kind, return its iter functions.
void menu_setpriv (struct menu *menu, int count, void *data)
 Set menu private data and the number of menu items.
voidmenu_priv (struct menu *menu)
 Return menu private data, set with menu_setpriv().
void menu_set_filter (struct menu *menu, const int object_list[], int n)
void menu_release_filter (struct menu *menu)
 Remove any filters set on a menu by menu_set_filer().
bool menu_layout (struct menu *menu, const region *loc)
 Ready a menu for display in the region specified.
void menu_refresh (struct menu *menu, bool reset_screen)
 Display a menu.
ui_event menu_select (struct menu *menu, int notify, bool popup)
 Run a menu.
void menu_ensure_cursor_valid (struct menu *m)
 Set the menu cursor to the next valid row.
bool menu_handle_mouse (struct menu *menu, const ui_event *in, ui_event *out)
bool menu_handle_keypress (struct menu *menu, const ui_event *in, ui_event *out)
 Handle navigation keypresses.
void menu_set_cursor_x_offset (struct menu *m, int offset)
 Allow adjustment of the cursor's default x offset.
struct menumenu_dynamic_new (void)
void menu_dynamic_add (struct menu *m, const char *text, int value)
void menu_dynamic_add_valid (struct menu *m, const char *text, int value, menu_row_validity_t valid)
void menu_dynamic_add_label (struct menu *m, const char *text, const char label, int value, char *label_list)
void menu_dynamic_add_label_valid (struct menu *m, const char *text, const char label, int value, char *label_list, menu_row_validity_t valid)
size_t menu_dynamic_longest_entry (struct menu *m)
void menu_dynamic_calc_location (struct menu *m, int mx, int my)
int menu_dynamic_select (struct menu *m)
void menu_dynamic_free (struct menu *m)


const byte curs_attrs [2][2]
const char lower_case []
const char upper_case []
const char all_letters []

Detailed Description

Generic menu interaction functions.

Copyright (c) 2007 Pete Mack Copyright (c) 2010 Andi Sidwell

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Macro Definition Documentation

#define MN_ACT_GRAYED   0x0001 /* Allows selection but no action */

Flags for menu_actions.

Referenced by menu_action_display(), menu_action_handle(), and textui_browse_knowledge().

#define MN_ACT_HIDDEN   0x0002 /* Row is hidden, but may be selected via tag */

Referenced by menu_action_valid().

Typedef Documentation

Type wrapper for various row styles.

Type wrapper for row validity.

Enumeration Type Documentation

anonymous enum
anonymous enum

Flags for menu appearance & behaviour.


Type wrapper for various row styles.


Type wrapper for row validity.


Types of predefined skins available.

enum skin_id

Identifiers for the kind of layout to use.


Ordinary scrollable single-column list.


Multicolumn view.

Function Documentation

void menu_dynamic_add ( struct menu m,
const char *  text,
int  value 
void menu_dynamic_add_label ( struct menu m,
const char *  text,
const char  label,
int  value,
char *  label_list 
void menu_dynamic_add_label_valid ( struct menu m,
const char *  text,
const char  label,
int  value,
char *  label_list,
menu_row_validity_t  valid 
void menu_dynamic_add_valid ( struct menu m,
const char *  text,
int  value,
menu_row_validity_t  valid 
void menu_dynamic_calc_location ( struct menu m,
int  mx,
int  my 
void menu_dynamic_free ( struct menu m)
size_t menu_dynamic_longest_entry ( struct menu m)
struct menu* menu_dynamic_new ( void  )
int menu_dynamic_select ( struct menu m)
void menu_ensure_cursor_valid ( struct menu m)

Set the menu cursor to the next valid row.

References menu::count, menu::cursor, menu::filter_count, menu::filter_list, is_valid_row(), and row.

Referenced by menu_release_filter(), menu_set_filter(), and menu_setpriv().

const menu_iter* menu_find_iter ( menu_iter_id  id)

Given a predefined menu kind, return its iter functions.

References menu_iter_actions, menu_iter_strings, MN_ITER_ACTIONS, and MN_ITER_STRINGS.

Referenced by display_knowledge(), menu_new_action(), and textui_knowledge_init().

bool menu_handle_keypress ( struct menu menu,
const ui_event in,
ui_event out 

Handle navigation keypresses.

Returns TRUE if they key was intelligible as navigation, regardless of whether any action was taken.

References menu::active, keypress::code, menu::count, menu::cursor, ddy, ESCAPE, EVT_ESCAPE, EVT_MOVE, EVT_SELECT, FALSE, menu::filter_count, menu::filter_list, menu::flags, get_cursor_key(), is_valid_row(), KC_ENTER, ui_event::key, MN_DBL_TAP, region::page_rows, menu_skin::process_dir, menu::skin, target_dir(), menu::top, TRUE, and ui_event::type.

Referenced by display_knowledge(), and menu_select().

bool menu_handle_mouse ( struct menu menu,
const ui_event in,
ui_event out 
void menu_init ( struct menu menu,
skin_id  skin,
const menu_iter iter 
bool menu_layout ( struct menu menu,
const region loc 
struct menu* menu_new ( skin_id  ,
const menu_iter iter 
struct menu* menu_new_action ( menu_action acts,
size_t  n 
void* menu_priv ( struct menu menu)
void menu_refresh ( struct menu menu,
bool  reset_screen 
void menu_release_filter ( struct menu menu)

Remove any filters set on a menu by menu_set_filer().

References menu::filter_count, menu::filter_list, and menu_ensure_cursor_valid().

ui_event menu_select ( struct menu menu,
int  notify,
bool  popup 

Run a menu.

'notify' is a bitwise OR of ui_event_type events that you want to menu_select to return to you if they're not handled inside the menu loop. e.g. if you want to handle key events without specifying a menu_iter->handle function, you can set notify to EVT_KBRD, and any non-navigation keyboard events will stop the menu loop and return them to you.

Some events are returned by default, and else are EVT_ESCAPE and EVT_SELECT.

Event types that can be returned: EVT_ESCAPE: no selection; go back (by default) EVT_SELECT: menu->cursor is the selected menu item (by default) EVT_MOVE: the cursor has moved EVT_KBRD: unhandled keyboard events EVT_MOUSE: unhandled mouse events EVT_RESIZE: resize events

XXX remove 'notify'

If popup is TRUE, the screen background is saved before starting the menu, and restored before each redraw. This allows variably-sized information at the bottom of the menu.

References menu::active, menu::cmd_keys, keypress::code, EVENT_EMPTY, EVT_ESCAPE, EVT_KBRD, EVT_MOUSE, EVT_RESIZE, EVT_SELECT, FALSE, menu::flags, inkey_ex(), ui_event::key, menu_calc_size(), menu_handle_action(), menu_handle_keypress(), menu_handle_mouse(), menu_refresh(), MN_NO_ACTION, region::page_rows, menu_iter::resize, menu::row_funcs, screen_load(), screen_save(), TRUE, ui_event::type, and region::width.

Referenced by cmd_menu(), death_screen(), do_cmd_colors(), do_cmd_keymaps(), do_cmd_options(), do_cmd_options_item(), do_cmd_spoilers(), do_cmd_visuals(), ego_menu(), menu_dynamic_select(), menu_question(), option_toggle_menu(), quality_action(), quality_menu(), spell_menu_browse(), spell_menu_select(), store_get_stock(), sval_menu(), textui_action_menu_choose(), textui_browse_knowledge(), textui_enter_store(), textui_store_knowledge(), wiz_create_item(), wiz_create_item_action(), and wiz_gf_demo().

void menu_set_cursor_x_offset ( struct menu m,
int  offset 

Allow adjustment of the cursor's default x offset.

References menu::cursor_x_offset.

Referenced by sval_menu().

void menu_set_filter ( struct menu menu,
const int  object_list[],
int  n 
void menu_setpriv ( struct menu menu,
int  count,
void data 

Variable Documentation

const char all_letters[]
const byte curs_attrs[2][2]
const char lower_case[]
const char upper_case[]