/* Repeats last command of the specified type. Returns 0 on success if no * message should be saved in the status bar, > 0 to save message on successful * execution and < 0 in case of error with error message. */ static int repeat_command(FileView *view, CmdInputType type) { int backward = 0; switch(type) { case CIT_BSEARCH_PATTERN: backward = 1; /* Fall through. */ case CIT_FSEARCH_PATTERN: return find_npattern(view, cfg_get_last_search_pattern(), backward, 1); case CIT_VBSEARCH_PATTERN: backward = 1; /* Fall through. */ case CIT_VFSEARCH_PATTERN: return find_vpattern(view, cfg_get_last_search_pattern(), backward, 1); case CIT_VWBSEARCH_PATTERN: backward = 1; /* Fall through. */ case CIT_VWFSEARCH_PATTERN: return find_vwpattern(NULL, backward); case CIT_COMMAND: return execute_command(view, NULL, 0); case CIT_FILTER_PATTERN: local_filter_apply(view, ""); return 0; default: assert(0 && "Command repetition request of unexpected type."); return 0; } }
void print_search_next_msg(const FileView *view, int backward) { const int match_number = get_current_entry(view)->search_match; const char search_type = backward ? '?' : '/'; status_bar_messagef("(%d of %d) %c%s", match_number, view->matches, search_type, cfg_get_last_search_pattern()); }
void print_search_msg(const FileView *view, int backward) { if(view->matches == 0) { print_search_fail_msg(view, backward); } else { status_bar_messagef("%d of %d matching file%s for: %s", get_current_entry(view)->search_match, view->matches, (view->matches == 1) ? "" : "s", cfg_get_last_search_pattern()); } }
void print_search_fail_msg(const FileView *view, int backward) { const char *const regexp = cfg_get_last_search_pattern(); int cflags; regex_t re; int err; if(regexp[0] == '\0') { status_bar_message(""); return; } cflags = get_regexp_cflags(regexp); err = regcomp(&re, regexp, cflags); if(err != 0) { status_bar_errorf("Regexp (%s) error: %s", regexp, get_regexp_error(err, &re)); regfree(&re); return; } regfree(&re); if(cfg.wrap_scan) { status_bar_errorf("No matching files for: %s", regexp); } else if(backward) { status_bar_errorf("Search hit TOP without match for: %s", regexp); } else { status_bar_errorf("Search hit BOTTOM without match for: %s", regexp); } }
void print_search_next_msg(const FileView *view, int backward) { status_bar_messagef("(%d of %d) %c%s", view->dir_entry[view->list_pos].search_match, view->matches, backward ? '?' : '/', cfg_get_last_search_pattern()); }