void key_command(const char *arg) /* {{{ */ { /* accept and attemt to execute a command string */ char *cmdstr; if (arg==NULL) { /* prepare prompt */ statusbar_message(-1, ":"); set_curses_mode(NCURSES_MODE_STRING); /* get input */ statusbar_getstr(&cmdstr, ":"); wipe_statusbar(); /* reset */ set_curses_mode(NCURSES_MODE_STD); } else cmdstr = strdup(arg); /* run input command */ if (cmdstr[0]!=0) handle_command(cmdstr); free(cmdstr); } /* }}} */
void key_tasklist_filter(const char* arg) { /* {{{ */ /* handle a keyboard direction to add a new filter * arg - string to filter by (pass NULL to prompt user) * see the manual page for how filter strings are parsed */ check_free(active_filter); if (arg == NULL) { statusbar_getstr(&active_filter, "filter by: "); wipe_statusbar(); } else { active_filter = strdup(arg); } /* force reload of task list */ statusbar_message(cfg.statusbar_timeout, "filter applied"); reload = true; } /* }}} */
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; } /* }}} */
void key_tasklist_modify(const char* arg) { /* {{{ */ /* handle a keyboard direction to modify a task * arg - the modifications to apply (pass NULL to prompt user) * this will be appended to `task UUID modify ` */ char* argstr; if (arg == NULL) { statusbar_getstr(&argstr, "modify: "); wipe_statusbar(); } else { argstr = strdup(arg); } task_modify(argstr); free(argstr); statusbar_message(cfg.statusbar_timeout, "task modified"); redraw = true; } /* }}} */
void key_tasklist_sort(const char* arg) { /* {{{ */ /* handle a keyboard direction to sort * arg - the mode to sort by (pass NULL to prompt user) * see the manual page for how sort strings are parsed */ char* uuid = NULL; /* store selected task */ struct task* cur = get_task_by_position(selline); if (cur != NULL) { uuid = strdup(cur->uuid); } tnc_fprintf(logfp, LOG_DEBUG_VERBOSE, "sort: initial task uuid=%s", uuid); check_free(cfg.sortmode); if (arg == NULL) { /* store sort string */ cfg.sortmode = calloc(cols, sizeof(char)); statusbar_getstr(&(cfg.sortmode), "sort by: "); sb_timeout = time(NULL) + 3; } else { cfg.sortmode = strdup(arg); } /* run sort */ sort_wrapper(head); /* follow original task */ if (cfg.follow_task) { set_position_by_uuid(uuid); tasklist_check_curs_pos(); } check_free(uuid); /* force redraw */ redraw = true; } /* }}} */