from imminent, tasks
where imminent.taskid = tasks.id
order by tasks.description" in
- if rows <> [] then printf "Today:\n";
+ if rows <> [] then heading "Today";
List.iter (
fun (id, desc) ->
- printf " %s #%ld%s\n" desc id (tags_of_task dbh id)
+ printf " %s %s%s\n"
+ (string_of_task_desc desc) (string_of_taskid id)
+ (tags_of_task dbh id)
) rows;
let rows = PGSQL(dbh) "select todo.taskid, todo.deadline, todo.estimate,
from todo, tasks
where todo.taskid = tasks.id
order by todo.deadline" in
- if rows <> [] then printf "To-do list:\n";
+ if rows <> [] then heading "To-do list";
List.iter (
fun (id, deadline, estimate, desc) ->
let deadline =
match estimate with
| None -> ""
| Some period -> string_of_estimate period ^ " " in
- printf " %s %s%s #%ld%s\n"
- deadline estimate desc id (tags_of_task dbh id)
+ printf " %s %s%s %s%s\n"
+ deadline estimate (string_of_task_desc desc)
+ (string_of_taskid id) (tags_of_task dbh id)
) rows;
let rows = PGSQL(dbh) "
and not exists (select 1 from ideas where taskid = tasks.id)
and not exists (select 1 from retired where taskid = tasks.id)
order by tasks.description" in
- if rows <> [] then printf "Unsorted (use 'todo move' to move these):\n";
+ if rows <> [] then heading "Unsorted (use 'todo move' to move these)";
List.iter (
fun (id, desc) ->
- printf " %s #%ld%s\n" desc id (tags_of_task dbh id)
+ printf " %s %s%s\n"
+ (string_of_task_desc desc) (string_of_taskid id)
+ (tags_of_task dbh id)
) rows;
let rows = PGSQL(dbh) "select ideas.taskid, tasks.description
from ideas, tasks
where ideas.taskid = tasks.id
order by tasks.description" in
- if rows <> [] then printf "Ideas:\n";
+ if rows <> [] then heading "Ideas";
List.iter (
fun (id, desc) ->
- printf " %s #%ld%s\n" desc id (tags_of_task dbh id)
+ printf " %s %s%s\n"
+ (string_of_task_desc desc) (string_of_taskid id)
+ (tags_of_task dbh id)
) rows
); (* unretired *)
from retired, tasks
where retired.taskid = tasks.id
order by tasks.description" in
- if rows <> [] then printf "Retired:\n";
+ if rows <> [] then heading "Retired";
List.iter (
fun (id, desc) ->
- printf " %s #%ld%s\n" desc id (tags_of_task dbh id)
+ printf " %s %s%s\n"
+ (string_of_task_desc desc) (string_of_taskid id)
+ (tags_of_task dbh id)
) rows
)
where tags_tasks.tagid = tags.id
and tags_tasks.taskid = tasks.id
order by tags.name, tasks.id" in
- if rows <> [] then printf "Tags used:\n";
+ if rows <> [] then heading "Tags used";
let prev = ref None in
List.iter (
fun (name, colour, taskid) ->
| Some _ -> ()
);
prev := Some cur;
- printf " #%ld" taskid
+ printf " %s" (string_of_taskid taskid)
) rows;
if !prev <> None then printf "\n";
from tags
where not exists (select 1 from tags_tasks where tagid = tags.id)
order by tags.name" in
- if rows <> [] then printf "Tags not used (delete with 'todo tag-del'):\n";
+ if rows <> [] then heading "Tags not used (delete with 'todo tag-del')";
List.iter (
fun (name, colour) ->
printf " %s\n" (string_of_tag name colour)
else if days = 1 then append "1 day";
let str = Buffer.contents buf in
if str <> "" then str else "-"
+
+let heading fs =
+ let display str =
+ printf "\x1b[%d;%dm%s:\x1b[0m\n" 0 35 str
+ in
+ ksprintf display fs
+
+let string_of_taskid id =
+ sprintf "\x1b[%d;%dm#%ld\x1b[0m" 1 34 id
+
+let string_of_task_desc desc =
+ sprintf "\x1b[1m%s\x1b[0m" desc