class Curses::Menu
Public Class Methods
Source
static VALUE menu_initialize(VALUE obj, VALUE items) { struct menudata *menup; ITEM **menu_items; int i; ID id_new; Check_Type(items, T_ARRAY); curses_init_screen(Qnil); TypedData_Get_Struct(obj, struct menudata, &menudata_type, menup); if (menup->menu) { rb_raise(rb_eRuntimeError, "already initialized menu"); } menup->items = rb_ary_new(); menu_items = ALLOC_N(ITEM *, RARRAY_LEN(items) + 1); CONST_ID(id_new, "new"); for (i = 0; i < RARRAY_LEN(items); i++) { VALUE item = RARRAY_AREF(items, i); struct itemdata *itemp; if (RB_TYPE_P(item, T_ARRAY)) { item = rb_apply(cItem, id_new, item); } GetITEM(item, itemp); menu_items[i] = itemp->item; rb_ary_push(menup->items, item); } menu_items[RARRAY_LEN(items)] = NULL; menup->menu = new_menu(menu_items); if (menup->menu == NULL) { check_curses_error(errno); } return obj; }
Construct a new Curses::Menu
.
Public Instance Methods
Source
static VALUE menu_get_back(VALUE obj) { struct menudata *menup; GetMENU(obj, menup); return CHTYPE2NUM(menu_back(menup->menu)); }
Get the background attribute of menu.
Source
static VALUE menu_set_back(VALUE obj, VALUE attr) { struct menudata *menup; GetMENU(obj, menup); CHTYPE2NUM(set_menu_back(menup->menu, NUM2CHTYPE(attr))); return attr; }
Get the background attribute of menu.
Source
# File lib/curses.rb, line 76 def back_pattern driver(Curses::REQ_BACK_PATTERN) end
Source
# File lib/curses.rb, line 72 def clear_pattern driver(Curses::REQ_CLEAR_PATTERN) end
Source
static VALUE menu_get_current_item(VALUE obj) { struct menudata *menup; ITEM *item; GetMENU(obj, menup); item = current_item(menup->menu); if (item == NULL) { return Qnil; } return item_new(item); }
Returns the current item.
Source
static VALUE menu_set_current_item(VALUE obj, VALUE item) { struct menudata *menup; struct itemdata *itemp; GetMENU(obj, menup); GetITEM(item, itemp); set_current_item(menup->menu, itemp->item); return item; }
Sets the current item.
Source
static VALUE menu_driver_m(VALUE obj, VALUE command) { struct menudata *menup; int error; GetMENU(obj, menup); error = menu_driver(menup->menu, NUM2INT(command)); check_curses_error(error); return obj; }
Perform the command on the menu.
Source
# File lib/curses.rb, line 52 def first_item driver(Curses::REQ_FIRST_ITEM) end
Source
static VALUE menu_get_fore(VALUE obj) { struct menudata *menup; GetMENU(obj, menup); return CHTYPE2NUM(menu_fore(menup->menu)); }
Sets the foreground attribute of menu. This is the highlight used for selected menu items.
Source
static VALUE menu_set_fore(VALUE obj, VALUE attr) { struct menudata *menup; GetMENU(obj, menup); set_menu_fore(menup->menu, NUM2CHTYPE(attr)); return attr; }
Sets the foreground attribute of menu. This is the highlight used for selected menu items.
Source
static VALUE menu_format_m(VALUE obj) { struct menudata *menup; int rows, cols; GetMENU(obj, menup); menu_format(menup->menu, &rows, &cols); return rb_assoc_new(INT2NUM(rows), INT2NUM(cols)); }
Get the maximum size of the menu.
Source
static VALUE menu_item_count(VALUE obj) { struct menudata *menup; GetMENU(obj, menup); return INT2NUM(item_count(menup->menu)); }
Returns the count of items in the menu.
Source
static VALUE menu_get_items(VALUE obj) { struct menudata *menup; ITEM **items; int count, i; VALUE ary; GetMENU(obj, menup); items = menu_items(menup->menu); if (items == NULL) { return Qnil; } count = item_count(menup->menu); ary = rb_ary_new(); for (i = 0; i < count; i++) { rb_ary_push(ary, item_new(items[i])); } return ary; }
Returns the items of the menu.
Source
static VALUE menu_set_items(VALUE obj, VALUE items) { struct menudata *menup; ITEM **old_items, **new_items; int i, error; Check_Type(items, T_ARRAY); GetMENU(obj, menup); old_items = menu_items(menup->menu); new_items = ALLOC_N(ITEM*, RARRAY_LEN(items) + 1); for (i = 0; i < RARRAY_LEN(items); i++) { struct itemdata *itemp; GetITEM(RARRAY_AREF(items, i), itemp); new_items[i] = itemp->item; } new_items[RARRAY_LEN(items)] = NULL; error = set_menu_items(menup->menu, new_items); if (error != E_OK) { xfree(new_items); check_curses_error(error); return items; } xfree(old_items); menup->items = rb_ary_dup(items); return items; }
Returns the items of the menu.
Source
static VALUE menu_get_mark(VALUE obj) { struct menudata *menup; const char *mark; GetMENU(obj, menup); mark = menu_mark(menup->menu); return rb_external_str_new_with_enc(mark, strlen(mark), terminal_encoding); }
Get the Menu’s mark string
Source
static VALUE menu_set_mark(VALUE obj, VALUE mark) { struct menudata *menup; GetMENU(obj, menup); set_menu_mark(menup->menu, StringValueCStr(mark)); return obj; }
Set the mark string to distinguish the selected items
Source
# File lib/curses.rb, line 80 def next_match driver(Curses::REQ_NEXT_MATCH) end
Source
static VALUE menu_opts_m(VALUE obj) { struct menudata *menup; GetMENU(obj, menup); return INT2NUM(menu_opts(menup->menu)); }
Get the current option bits of the menu.
Source
static VALUE menu_opts_off_m(VALUE obj, VALUE opts) { struct menudata *menup; int error; GetMENU(obj, menup); error = menu_opts_off(menup->menu, NUM2INT(opts)); check_curses_error(error); return obj; }
Turn off the option bits of the menu.
Source
static VALUE menu_opts_on_m(VALUE obj, VALUE opts) { struct menudata *menup; int error; GetMENU(obj, menup); error = menu_opts_on(menup->menu, NUM2INT(opts)); check_curses_error(error); return obj; }
Turn on the option bits of the menu.
Source
static VALUE menu_post(VALUE obj) { struct menudata *menup; int error; GetMENU(obj, menup); error = post_menu(menup->menu); check_curses_error(error); return obj; }
Post the menu.
Source
# File lib/curses.rb, line 84 def prev_match driver(Curses::REQ_PREV_MATCH) end
Source
# File lib/curses.rb, line 24 def right_item driver(Curses::REQ_RIGHT_ITEM) end
Source
static VALUE menu_scale(VALUE obj) { struct menudata *menup; int error, rows, columns; GetMENU(obj, menup); error = scale_menu(menup->menu, &rows, &columns); check_curses_error(error); return rb_assoc_new(INT2NUM(rows), INT2NUM(columns)); }
Return the minimum rows and columns required for the subwindow of the menu.
Source
# File lib/curses.rb, line 40 def scroll_down_line driver(Curses::REQ_SCR_DLINE) end
Source
# File lib/curses.rb, line 48 def scroll_down_page driver(Curses::REQ_SCR_DPAGE) end
Source
# File lib/curses.rb, line 36 def scroll_up_line driver(Curses::REQ_SCR_ULINE) end
Source
# File lib/curses.rb, line 44 def scroll_up_page driver(Curses::REQ_SCR_UPAGE) end
Source
static VALUE menu_set_format(VALUE obj, VALUE rows, VALUE cols) { struct menudata *menup; int error; GetMENU(obj, menup); error = set_menu_format(menup->menu, NUM2INT(rows), NUM2INT(cols)); check_curses_error(error); return obj; }
Set the maximum size of the menu.
Source
static VALUE menu_set_opts(VALUE obj, VALUE opts) { struct menudata *menup; int error; GetMENU(obj, menup); error = set_menu_opts(menup->menu, NUM2INT(opts)); check_curses_error(error); return obj; }
Set the option bits of the menu.
Source
static VALUE menu_set_sub(VALUE obj, VALUE win) { struct menudata *menup; struct windata *winp; GetMENU(obj, menup); GetWINDOW(win, winp); set_menu_sub(menup->menu, winp->window); return win; }
Set the subwindow of the menu.
Source
static VALUE menu_set_win(VALUE obj, VALUE win) { struct menudata *menup; struct windata *winp; GetMENU(obj, menup); GetWINDOW(win, winp); set_menu_win(menup->menu, winp->window); return win; }
Set the window of the menu.
Source
# File lib/curses.rb, line 68 def toggle_item driver(Curses::REQ_TOGGLE_ITEM) end
Source
static VALUE menu_unpost(VALUE obj) { struct menudata *menup; int error; GetMENU(obj, menup); error = unpost_menu(menup->menu); check_curses_error(error); return obj; }
Unpost the menu.