ENH: Added highlighting of done (but not yet archived) tasks.

This makes done tasks more stand out (like prioritized tasks) in the task list. Default highlighting is LIGHT_GREY, which seems to be modest and go well with the assumed dark terminal background.
Reintroduced the OSX-compatible sed filter that was introduced by commit 8b7e2e6aad and superseded by the PRI_X coloring generalization.
This commit is contained in:
Ingo Karkat
2010-07-15 16:14:46 +02:00
parent 9b7f85bea1
commit f5d4249078
3 changed files with 56 additions and 4 deletions

View File

@@ -111,4 +111,41 @@ test_todo_session 'different highlighting for pri X' <<'EOF'
TODO: 8 of 8 tasks shown TODO: 8 of 8 tasks shown
EOF EOF
# check highlighting of done (but not yet archived) tasks
#
cat > todo.txt <<EOF
(A) smell the uppercase Roses +flowers @outside
remove1
notice the sunflowers
remove2
stop
EOF
test_todo_session 'highlighting of done tasks' <<EOF
>>> todo.sh -a do 2
2 x 2009-02-13 remove1
TODO: 2 marked as done.
>>> todo.sh list
1 (A) smell the uppercase Roses +flowers @outside
3 notice the sunflowers
4 remove2
5 stop
2 x 2009-02-13 remove1
--
TODO: 5 of 5 tasks shown
>>> todo.sh -a do 4
4 x 2009-02-13 remove2
TODO: 4 marked as done.
>>> todo.sh list
1 (A) smell the uppercase Roses +flowers @outside
3 notice the sunflowers
5 stop
2 x 2009-02-13 remove1
4 x 2009-02-13 remove2
--
TODO: 5 of 5 tasks shown
EOF
test_done test_done

View File

@@ -38,18 +38,26 @@ export TMP_FILE="$TODO_DIR/todo.tmp"
# export WHITE='\\033[1;37m' # export WHITE='\\033[1;37m'
# export DEFAULT='\\033[0m' # export DEFAULT='\\033[0m'
# === PRIORITY COLORS === # === COLORS ===
## Priorities can be any upper-case letter.
## A,B,C are highlighted; you can add coloring for more.
## Uncomment and edit to override these defaults. ## Uncomment and edit to override these defaults.
## Reference the constants from the color map above,
## or use $NONE to disable highlighting.
#
# Priorities can be any upper-case letter.
# A,B,C are highlighted; you can add coloring for more.
#
# export PRI_A=$YELLOW # color for A priority # export PRI_A=$YELLOW # color for A priority
# export PRI_B=$GREEN # color for B priority # export PRI_B=$GREEN # color for B priority
# export PRI_C=$LIGHT_BLUE # color for C priority # export PRI_C=$LIGHT_BLUE # color for C priority
# export PRI_D=... # define your own # export PRI_D=... # define your own
# export PRI_X=$WHITE # color unless explicitly defined # export PRI_X=$WHITE # color unless explicitly defined
# There is highlighting for tasks that have been done,
# but haven't been archived yet.
#
# export COLOR_DONE=$LIGHT_GREY
# === BEHAVIOR === # === BEHAVIOR ===
## customize list output ## customize list output

View File

@@ -470,6 +470,9 @@ export PRI_B=$GREEN # color for B priority
export PRI_C=$LIGHT_BLUE # color for C priority export PRI_C=$LIGHT_BLUE # color for C priority
export PRI_X=$WHITE # color for rest of them export PRI_X=$WHITE # color for rest of them
# Default highlight colors.
export COLOR_DONE=$LIGHT_GREY # color for done (but not yet archived) tasks
# Default sentence delimiters for todo.sh append. # Default sentence delimiters for todo.sh append.
# If the text to be appended to the task begins with one of these characters, no # If the text to be appended to the task begins with one of these characters, no
# whitespace is inserted in between. This makes appending to an enumeration # whitespace is inserted in between. This makes appending to an enumeration
@@ -531,6 +534,7 @@ if [ $TODOTXT_PLAIN = 1 ]; then
done done
PRI_X=$NONE PRI_X=$NONE
DEFAULT=$NONE DEFAULT=$NONE
COLOR_DONE=$NONE
fi fi
_addto() { _addto() {
@@ -632,6 +636,9 @@ _list() {
s/^ /0/; s/^ /0/;
''' \ ''' \
| eval ${TODOTXT_SORT_COMMAND} \ | eval ${TODOTXT_SORT_COMMAND} \
| sed '''
/^[0-9]\{'$PADDING'\} x /s|^.*|'$COLOR_DONE'&'$DEFAULT'|
''' \
| awk '''{ | awk '''{
pos = match($0, /\([A-Z]\)/) pos = match($0, /\([A-Z]\)/)
if( pos > 0 && match($0, /^[0-9]+ x /) != 1 ) { if( pos > 0 && match($0, /^[0-9]+ x /) != 1 ) {