void file_menu::display_current_files() { std::vector<std::string> to_show; if (!is_root(current_dir_)) { to_show.push_back(path_up); } std::vector<std::string>::iterator it; for (it = dirs_in_current_dir_.begin(); it != dirs_in_current_dir_.end(); ++it) { // Add an image to show that these are directories. std::stringstream ss; ss << font::IMAGE << dir_picture << COLUMN_SEPARATOR << *it; to_show.push_back(ss.str()); } for (it = files_in_current_dir_.begin(); it != files_in_current_dir_.end(); ++it) { const std::string display_string = COLUMN_SEPARATOR + *it; to_show.push_back(display_string); } const int menu_font_size = font::SIZE_NORMAL; // Known from menu.cpp. for (it = to_show.begin(); it != to_show.end(); ++it) { // Make sure that all lines fit. // Guess the width of the scrollbar to be 30 since it is not accessible from here. // -25 to compensate for the picture column. while(static_cast<unsigned int>( font::line_width(*it, menu_font_size)) > width() - 30 - 25) { (*it).resize((*it).size() - 1); } } set_items(to_show); }
void help_menu::display_visible_items() { std::vector<std::string> menu_items; for(std::vector<visible_item>::const_iterator items_it = visible_items_.begin(), end = visible_items_.end(); items_it != end; ++items_it) { std::string to_show = items_it->visible_string; if (selected_item_ == *items_it) to_show = std::string("*") + to_show; menu_items.push_back(to_show); } set_items(menu_items, false, true); }
TITANIUM_PROPERTY_SETTER(ListSection, items) { if (!argument.IsObject()) { return false; } const auto items = static_cast<JSObject>(argument); if (!items.IsArray()) { return false; } set_items(js_to_ListDataItem_array(items)); return true; }
void create() { ::create(); set_properties( (["light" : 2, "night light" : 1, ]) ); set_short( "a snowy tundra" ); set_long( desc_long() ); set_exits(([ "south" : ROOMS"tundra/95", "east" : ROOMS"tundra/100",])); set_items( ([ ]) ); set_smell("default", "The dry arctic wind carries little scent."); set_listen("default", "The sound of animals and humanoids fighting can be heard throughout the tundra."); set_items(desc_items()); }
void create() { ::create(); set_properties( (["light" : 2, "night light" : 1, ]) ); set_short("a mountain pass"); set_long( desc_long() ); //set_exits(([ "north" : ROOMS"mountainpath/2", //"south" : ROOMS"tundra/92", //])); set_items( ([ ]) ); set_smell("default", "The dry arctic wind carries little scent."); set_listen("default", "The sound of animals and humanoids fighting can be heard throughout the mountain pass."); set_items(desc_items()); }
static Validator* set_items_generic(Validator *v, ArrayItems *items) { return set_items(&array_validator_new()->base, items); }
int main(int ac, char **av) { int c; int ch; int i; int count_items; char **items; int shortcut[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0}; int shortcut_len = sizeof shortcut / sizeof(int); int l_num; int mode = 0; if (ac == 1) usage(); init_locale(); f_result = stderr; l.f_out = stdout; i = get_options(ac, av); items = av + i; count_items = ac - i; if (count_items == 0) return (1); if (nb_items_per_page <= 0 || nb_items_per_page >= shortcut_len) return 1; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt); terminit(); l.prefix = shortcut; l.upstr = upstr; l.dcstr = dcstr; l.bottom_msg[0] = '\0'; l.bottom_msg_col_s = 0; l.y = 0; l.cursor_y = 0; l.item_top_page = 0; set_items_per_page(&l, nb_items_per_page); set_items(&l, items, count_items); signal(SIGWINCH, sigwinch); ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsz); l.col_width = winsz.ws_col; calibre_width(&l); draw_items(&l); fflush(l.f_out); while ((c = getchar()) != 'q') { if (c == -1) { if (errno == EINTR) continue; exit(1); } switch (c) { case '/': tcsetattr( STDIN_FILENO, TCSANOW, &oldt); search(); l.cur_page = 0; l.cursor_y = 0; draw_items(&l); tcsetattr( STDIN_FILENO, TCSANOW, &newt); break; case 'n' /*|| ' ' || 'j' */: page_seek(&l, RELATIVE, 1); break; case 'p' /*|| 'k'*/: page_seek(&l, RELATIVE, -1); break; case 'j': cursor_seek(&l, 1, 1); break; case 'k': cursor_seek(&l, 1, -1); break; case ' ': select_item(&l, l.cursor_y); cursor_seek(&l, RELATIVE, 1); break; case '\n': enter_selected_items(); cleanup_exit(0); break; default: if ((l_num = has_c(c, shortcut)) >= 0) { enter_result(l_num + l.item_top_page); cleanup_exit(0); } break; } fflush(l.f_out); } cleanup_exit(0); return 0; }
void help_text_area::show_topic(const topic &t) { shown_topic_ = &t; set_items(); set_dirty(true); }
void help_text_area::set_inner_location(SDL_Rect const &rect) { bg_register(rect); if (shown_topic_) set_items(); }