impl printing tree of a task

This commit is contained in:
Spaghettificated 2024-07-08 15:41:06 +02:00
parent 3cc96ed39b
commit 44ae363f58

30
todo.pl
View File

@ -6,7 +6,11 @@
all_tasks(L):- findall(X, task(X, _), L).
all_tasks(L, STATE):- findall(X, task(X, STATE), L).
print_task(X):-
task(X,ISDONE),
write(ISDONE),
write(': '),
write(X).
print_task_list([],_).
print_task_list([H|T],N) :-
M is N+1,
@ -14,10 +18,8 @@ print_task_list([H|T],N) :-
asserta(idx(N, H)),
write(N),
write(". "),
task(H,ISDONE),
write(ISDONE),
write(': '),
write(H),nl,
print_task(H),
nl,
print_task_list(T, M).
list_all :- all_tasks(L), print_task_list(L,1).
@ -86,6 +88,24 @@ check(X) :-
write("no such task as "),
write(X).
indent(0).
indent(N):-
write(" "),
M is N-1,
indent(M).
tree_branch([],_).
tree_branch([X|T],N):-
indent(N),
print_task(X),
nl,
findall(Y, requires(Y,X), L),
M is N+1,
tree_branch(L,M),
tree_branch(T,N).
tree(X):- task(X,_), tree_branch([X],0).
tree(X):- idx(X,Y), tree(Y).
uncheck(X) :- idx(X, Task), uncheck(Task).
uncheck(X):-
task(X, done),