void key_tasklist_search_next(void) { /* {{{ */ /* handle a keyboard direction to move to next search result */ if (searchstring != NULL) { find_next_search_result(head, get_task_by_position(selline)); tasklist_check_curs_pos(); redraw = true; } else { statusbar_message(cfg.statusbar_timeout, "no active search string"); } } /* }}} */
void test_search() /* {{{ */ { /* test search functionality */ char *addcmdstr, *testcmdstr, *tmp; const char *proj = "test123"; const char pri = 'H'; const char *unique = "simple"; FILE *cmdout; task *this; bool pass; asprintf(&addcmdstr, "task add pro:%s pri:%c %s", proj, pri, unique); cmdout = popen(addcmdstr, "r"); pclose(cmdout); free_tasks(head); head = get_tasks(NULL); stdout = devnull; searchstring = strdup(unique); find_next_search_result(head, head); stdout = out; this = get_task_by_position(selline); pass = strcmp(this->project, proj)==0 && this->priority==pri; test_result("search", pass); if (!pass) { puts(addcmdstr); tmp = var_value_message(find_var("search_string"), 1); puts(tmp); free(tmp); puts("selected:"); printf("uuid: %s\n", this->uuid); printf("description: %s\n", this->description); printf("project: %s\n", this->project); printf("tags: %s\n", this->tags); fflush(stdout); asprintf(&testcmdstr, "task list %s", unique); system(testcmdstr); free(testcmdstr); } cmdout = popen("task undo", "r"); pclose(cmdout); free(addcmdstr); } /* }}} */
void key_tasklist_search(const char* arg) { /* {{{ */ /* handle a keyboard direction to search * arg - the string to search for (pass NULL to prompt user) */ check_free(searchstring); if (arg == NULL) { /* store search string */ statusbar_getstr(&searchstring, "/"); wipe_statusbar(); } else { searchstring = strdup(arg); } /* go to first result */ find_next_search_result(head, get_task_by_position(selline)); tasklist_check_curs_pos(); redraw = true; } /* }}} */