Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color for task #267

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/t1330-ls-highlighting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,26 @@ test_todo_session 'highlighting priority position' <<EOF
TODO: 3 of 3 tasks shown
EOF

# check highlighting of task ids
#
TEST_TODO_CUSTOM=todo-custom.cfg
cat todo.cfg > "$TEST_TODO_CUSTOM"
cat >> "$TEST_TODO_CUSTOM" <<'EOF'
export PRI_A=$RED
export COLOR_ID=$YELLOW
EOF
cat > todo.txt <<EOF
(A) some prioritized task
1 task containing 3 various numbers 15
simple task with id
EOF
test_todo_session 'highlighting task id' <<'EOF'
>>> todo.sh -d "$TEST_TODO_CUSTOM" ls
1 (A) some prioritized task
2 1 task containing 3 various numbers 15
3 simple task with id
--
TODO: 3 of 3 tasks shown
EOF

test_done
1 change: 1 addition & 0 deletions todo.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export REPORT_FILE="$TODO_DIR/report.txt"
#
# export COLOR_PROJECT=$RED
# export COLOR_CONTEXT=$RED
# export COLOR_ID=$RED

# === BEHAVIOR ===

Expand Down
7 changes: 6 additions & 1 deletion todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,9 @@ _format()
}
}
end_clr = (clr ? highlight("DEFAULT") : "")

id_beg = highlight("COLOR_ID")
id_end = ( id_beg ? (highlight("DEFAULT") clr) : "")

prj_beg = highlight("COLOR_PROJECT")
prj_end = (prj_beg ? (highlight("DEFAULT") clr) : "")
Expand All @@ -969,7 +972,9 @@ _format()

printf "%s", clr
for (i = 1; i <= len; ++i) {
if (words[i] ~ /^[+].*[A-Za-z0-9_]$/) {
if ((i == 1) && (words[i] ~ /^[0-9]+$/)) {
printf "%s", id_beg words[i] id_end
} else if (words[i] ~ /^[+].*[A-Za-z0-9_]$/) {
printf "%s", prj_beg words[i] prj_end
} else if (words[i] ~ /^[@].*[A-Za-z0-9_]$/) {
printf "%s", ctx_beg words[i] ctx_end
Expand Down