-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow coloring contexts and projects independently
Because @contexts and +projects are metadata as much as they are text, it can be nice to highlight them independently of the coloring of the line that contains them. This is tough to do correctly in a TODOTXT_FINAL_FILTER because doing it at that layer requires re-parsing the text of the line to find the appropriate PRI_$x color to reset to after coloring the word, or trying to reverse engineer where the color codes inserted by todo.sh end and the user's text begins (and vice versa). Closes #119
- Loading branch information
1 parent
745f5d5
commit 07b50a0
Showing
2 changed files
with
129 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/bin/bash | ||
# | ||
|
||
test_description='highlighting projects and contexts | ||
This test checks the highlighting (with colors) of projects and contexts. | ||
' | ||
. ./test-lib.sh | ||
|
||
# Prioritized tasks with projects and contexts | ||
cat > todo.txt <<EOF | ||
(A) prioritized @con01 context | ||
(B) prioritized +prj02 project | ||
(C) prioritized context at EOL @con03 | ||
(D) prioritized project at EOL +prj04 | ||
+prj05 non-prioritized project at BOL | ||
@con06 non-prioritized context at BOL | ||
multiple @con_ @texts and +pro_ +jects | ||
non-contexts: seti@home @ @* @(foo) | ||
non-projects: lost+found + +! +(bar) | ||
EOF | ||
|
||
# config file specifying COLOR_PROJECT and COLOR_CONTEXT | ||
# | ||
TEST_TODO_LABEL_COLORS=todo-colors.cfg | ||
cat todo.cfg > "$TEST_TODO_LABEL_COLORS" | ||
|
||
echo "export COLOR_CONTEXT='\\\\033[1m'" >>"$TEST_TODO_LABEL_COLORS" | ||
echo "export COLOR_PROJECT='\\\\033[2m'" >>"$TEST_TODO_LABEL_COLORS" | ||
|
||
test_todo_session 'highlighting for contexts and projects' <<'EOF' | ||
>>> todo.sh -d "$TEST_TODO_LABEL_COLORS" ls | ||
[1;33m1 (A) prioritized [1m@con01[0m[1;33m context[0m | ||
[0;32m2 (B) prioritized [2m+prj02[0m[0;32m project[0m | ||
[1;34m3 (C) prioritized context at EOL [1m@con03[0m[1;34m[0m | ||
[1;37m4 (D) prioritized project at EOL [2m+prj04[0m[1;37m[0m | ||
5 [2m+prj05[0m non-prioritized project at BOL | ||
6 [1m@con06[0m non-prioritized context at BOL | ||
7 multiple [1m@con_[0m [1m@texts[0m and [2m+pro_[0m [2m+jects[0m | ||
8 non-contexts: seti@home @ @* @(foo) | ||
9 non-projects: lost+found + +! +(bar) | ||
-- | ||
TODO: 9 of 9 tasks shown | ||
EOF | ||
|
||
test_todo_session 'suppressing highlighting for contexts and projects' <<'EOF' | ||
>>> todo.sh -p -d "$TEST_TODO_LABEL_COLORS" ls | ||
1 (A) prioritized @con01 context | ||
2 (B) prioritized +prj02 project | ||
3 (C) prioritized context at EOL @con03 | ||
4 (D) prioritized project at EOL +prj04 | ||
5 +prj05 non-prioritized project at BOL | ||
6 @con06 non-prioritized context at BOL | ||
7 multiple @con_ @texts and +pro_ +jects | ||
8 non-contexts: seti@home @ @* @(foo) | ||
9 non-projects: lost+found + +! +(bar) | ||
-- | ||
TODO: 9 of 9 tasks shown | ||
EOF | ||
|
||
test_todo_session 'suppressing display of contexts' <<'EOF' | ||
>>> todo.sh -@ -d "$TEST_TODO_LABEL_COLORS" ls | ||
[1;33m1 (A) prioritized context[0m | ||
[0;32m2 (B) prioritized [2m+prj02[0m[0;32m project[0m | ||
[1;34m3 (C) prioritized context at EOL[0m | ||
[1;37m4 (D) prioritized project at EOL [2m+prj04[0m[1;37m[0m | ||
5 [2m+prj05[0m non-prioritized project at BOL | ||
6 non-prioritized context at BOL | ||
7 multiple and [2m+pro_[0m [2m+jects[0m | ||
8 non-contexts: seti@home @ | ||
9 non-projects: lost+found + +! +(bar) | ||
-- | ||
TODO: 9 of 9 tasks shown | ||
EOF | ||
|
||
test_todo_session 'suppressing display of projects' <<'EOF' | ||
>>> todo.sh -+ -d "$TEST_TODO_LABEL_COLORS" ls | ||
[1;33m1 (A) prioritized [1m@con01[0m[1;33m context[0m | ||
[0;32m2 (B) prioritized project[0m | ||
[1;34m3 (C) prioritized context at EOL [1m@con03[0m[1;34m[0m | ||
[1;37m4 (D) prioritized project at EOL[0m | ||
5 non-prioritized project at BOL | ||
6 [1m@con06[0m non-prioritized context at BOL | ||
7 multiple [1m@con_[0m [1m@texts[0m and | ||
8 non-contexts: seti@home @ @* @(foo) | ||
9 non-projects: lost+found + | ||
-- | ||
TODO: 9 of 9 tasks shown | ||
EOF | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters