-
Notifications
You must be signed in to change notification settings - Fork 51
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
Markers with multiple tasks #312
Comments
It should work that way. If it's not, please attach an example config, and a modified dummy install script that reproduces the issue, and I'll have a look at it. |
Here you go #!/bin/sh
set -e
set -u
TMP_DIR="$(mktemp --directory --suffix .vit)"
VIT_DIR="$TMP_DIR/vit"
TASK_DIR="$TMP_DIR/task"
TASKRC="$TMP_DIR/taskrc"
echo "
This script will create a dummy TaskWarrior database and VIT configuration.
"
read -p "Press enter to continue... " DUMMY
echo "Creating dummy task configuration..."
mkdir "$TASK_DIR"
cat > "$TASKRC" <<EOT
data.location=$TASK_DIR
EOT
export TASKRC
echo -e "report.next.columns = id,start.age,project,description,urgency\n report.next.labels = ID,Active,Project,Description,Urg" >> "$TASKRC"
echo "Creating dummy VIT configuration..."
mkdir "$VIT_DIR"
touch "$VIT_DIR/config.ini"
echo -e "[marker]\ntag.label= \ntag.frog.label = 🐸\ntag.dog.label = 🐶\ntag.house.label = 🏠" >> "$VIT_DIR/config.ini"
echo "Adding some dummy tasks..."
task add a
task add b
task +LATEST start
task add c
task +LATEST start
task +LATEST modify project:foo
task 1 mod +frog
task 2 mod +frog +dummytag
task 3 mod +frog +dog +house
echo "Complete!
Copy and paste the following two export statements into your current
shell sesison to activate the dummy installation.
export TASKRC=${TASKRC}
export VIT_DIR=${VIT_DIR}
When complete, you can simply exit the current shell session, or copy and paste
the following 'unset' commands to revert the current shell session to the
TaskWarrior/VIT defaults.
unset TASKRC
unset VIT_DIR
" |
The code that handles setting markers for tags is here: https://github.com/vit-project/vit/blob/2.x/vit/formatter/markers.py#L43-L57 The current logic is like this:
So I think you're misunderstanding the current implementation. Basically, if it has one tag, we can display a custom label, otherwise the label is more meant to signify "this task has tags". It's possible to adjust the code, but I'm not sure I want to do this. Markers are meant to be simple indications of non-displayed columns, and if you want more detail, then you add that column to the report. |
Indeed, I misunderstood the current logic. I will adapt accordingly. Thank you for the detailed explanation. |
In case you didn't know, formatters can be overridden by your own custom formatters. This means you can override the default Markers class and provide the custom formatting functionality you desire when formatting tag markers. I took a few minutes and got this working: from vit.formatter.markers import Markers as MarkersBase
class Markers(MarkersBase):
def format_tags(self, width, text_markup, tags):
if not tags:
color = self.colorizer.tag_none()
label = self.labels['tag.none.label']
return self.add_label(color, label, width, text_markup)
elif len(tags) == 1:
tag = list(tags)[0]
color = self.colorizer.tag(tag)
custom_label = 'tag.%s.label' % tag
label = self.labels['tag.label'] if not custom_label in self.labels else self.labels[custom_label]
return self.add_label(color, label, width, text_markup)
# This is the new logic, the rest is just a copy of the existing
# format_tags() method.
elif len(tags) > 1 and not self.labels['tag.label']:
labels = []
for tag in list(tags):
# Last color will be the one used.
color = self.colorizer.tag(tag)
custom_label = 'tag.%s.label' % tag
if custom_label in self.labels:
labels.append(self.labels[custom_label])
label = ''.join(labels)
return self.add_label(color, label, width, text_markup)
else:
color = self.colorizer.tag('')
label = self.labels['tag.label']
return self.add_label(color, label, width, text_markup) You would simply follow the directions at https://github.com/vit-project/vit/blob/2.x/CUSTOMIZE.md#formatters for placing that code into your VIT user directory, the file would live at Of course with this method you'd have to track any changes to the I may yet include that new logic in VIT core, why don't you play with the override version for a bit and see if it works OK? |
Awesome! Thank you very much |
In my setup (vit 2.1.0, taskwarrior 2.6.0), I would like to have different markers for different tags, for instance
I expect that a task tagged with
frog label office
would show all three emoji in the marker column. But it appears that tag-related markers only show up if this is the only tag on that task (even if I tagfrog foo
, the frog emoji will not appear).Am I missing something here? Is this intended?
The text was updated successfully, but these errors were encountered: