static void test_delc_completion(void) { char *completion; assert_int_equal(0, execute_cmd("command udf a")); reset_completion(); assert_int_equal(5, complete_cmd("delc u")); assert_int_equal(2, get_completion_count()); if(get_completion_count() == 0) return; completion = next_completion(); assert_string_equal("udf", completion); free(completion); }
static void test_skip_abbreviations(void) { char *completion; reset_completion(); assert_int_equal(0, complete_cmd("d")); assert_int_equal(3, get_completion_count()); if(get_completion_count() == 0) return; completion = next_completion(); assert_string_equal("delcommand", completion); free(completion); completion = next_completion(); assert_string_equal("delete", completion); free(completion); }
static void test_skip_complete_args(void) { char *completion; reset_completion(); assert_int_equal(17, complete_cmd("% dele fast slow ")); assert_int_equal(3, get_completion_count()); if(get_completion_count() == 0) return; completion = next_completion(); assert_string_equal("fastrun", completion); free(completion); completion = next_completion(); assert_string_equal("followlinks", completion); free(completion); }
static void test_skip_goto(void) { char *completion; reset_completion(); assert_int_equal(0, complete_cmd("")); assert_int_equal(5, get_completion_count()); if(get_completion_count() == 0) return; completion = next_completion(); assert_string_equal("comclear", completion); free(completion); completion = next_completion(); assert_string_equal("command", completion); free(completion); completion = next_completion(); assert_string_equal("delcommand", completion); free(completion); }
/** * Load list with entries from local completion index. */ static void addrcompl_load_local( void ) { guint count = 0; for (count = 0; count < get_completion_count(); count++) { gchar *address; address = get_complete_address( count ); /* g_print( "\taddress ::%s::\n", address ); */ /* Append contents to end of display queue */ addrcompl_add_queue( address ); } }
static void cmd_shift_tab(key_info_t key_info, keys_info_t *keys_info) { if(!input_stat.complete_continue) draw_wild_menu(1); input_stat.reverse_completion = 1; if(input_stat.complete_continue && get_completion_count() == 2) input_stat.complete_continue = 0; do_completion(); if(cfg.wild_menu) draw_wild_menu(0); }
static void test_dont_remove_range(void) { char *completion; reset_completion(); assert_int_equal(2, complete_cmd("% del")); assert_int_equal(3, get_completion_count()); if(get_completion_count() == 0) return; completion = next_completion(); assert_string_equal("delcommand", completion); free(completion); reset_completion(); assert_int_equal(1, complete_cmd("3del")); assert_int_equal(3, get_completion_count()); if(get_completion_count() == 0) return; completion = next_completion(); assert_string_equal("delcommand", completion); free(completion); }
/* * op == 0 - draw * op < 0 - redraw * op > 0 - reset */ static void draw_wild_menu(int op) { static int last_pos; const char ** list = get_completion_list(); int pos = get_completion_pos(); int count = get_completion_count() - 1; int i; int len = getmaxx(stdscr); if(sub_mode == MENU_CMD_SUBMODE || input_stat.complete == NULL) return; if(count < 2) return; if(op > 0) { last_pos = 0; return; } if(pos == 0 || pos == count) last_pos = 0; if(last_pos == 0 && pos == count - 1) last_pos = count; if(pos < last_pos) { int l = len; while(last_pos > 0 && l > 2) { last_pos--; l -= strlen(list[last_pos]); if(last_pos != 0) l -= 2; } if(l < 2) last_pos++; } werase(stat_win); wmove(stat_win, 0, 0); for(i = last_pos; i < count && len > 0; i++) { len -= strlen(list[i]); if(i != 0) len -= 2; if(i == last_pos && last_pos > 0) { wprintw(stat_win, "< "); } else if(i > last_pos) { if(len < 2) { wprintw(stat_win, " >"); break; } wprintw(stat_win, " "); } if(i == pos) { col_attr_t col; col = cfg.cs.color[STATUS_LINE_COLOR]; mix_colors(&col, &cfg.cs.color[MENU_COLOR]); init_pair(DCOLOR_BASE + MENU_COLOR, col.fg, col.bg); wbkgdset(stat_win, COLOR_PAIR(DCOLOR_BASE + MENU_COLOR) | col.attr); } wprint(stat_win, list[i]); if(i == pos) { wbkgdset(stat_win, COLOR_PAIR(DCOLOR_BASE + STATUS_LINE_COLOR) | cfg.cs.color[STATUS_LINE_COLOR].attr); pos = -pos; } } if(pos > 0 && pos != count) { last_pos = pos; draw_wild_menu(op); return; } if(op == 0 && len < 2 && i - 1 == pos) last_pos = i; wrefresh(stat_win); }