void complete_colorschemes(const char name[]) { int i; size_t len; int schemes_len; char **schemes; len = strlen(name); schemes = list_color_schemes(&schemes_len); for(i = 0; i < schemes_len; i++) { if(schemes[i][0] != '.' || name[0] == '.') { if(strnoscmp(name, schemes[i], len) == 0) { vle_compl_add_match(schemes[i]); } } } free_string_array(schemes, schemes_len); vle_compl_finish_group(); vle_compl_add_last_match(name); }
int show_colorschemes_menu(FileView *view) { static menu_info m; init_menu_info(&m, strdup("Choose the default Color Scheme"), strdup("No color schemes found")); m.execute_handler = &execute_colorscheme_cb; m.items = list_color_schemes(&m.len); qsort(m.items, m.len, sizeof(*m.items), &sorter); /* It's safe to set m.pos to negative value, since menus.c handles this * correctly. */ #ifndef _WIN32 m.pos = string_array_pos(m.items, m.len, cfg.cs.name); #else m.pos = string_array_pos_case(m.items, m.len, cfg.cs.name); #endif return display_menu(&m, view); }