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 style to t listing #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
9 changes: 9 additions & 0 deletions colorcodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
11 changes: 8 additions & 3 deletions t.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os, re, sys, hashlib
from operator import itemgetter
from optparse import OptionParser, OptionGroup

from colorcodes import Bcolors as bcolors

class InvalidTaskfile(Exception):
"""Raised when the path to a task file already exists as a directory."""
Expand Down Expand Up @@ -227,10 +227,15 @@ def print_list(self, kind='tasks', verbose=False, quiet=False, grep=''):
tasks[task_id]['prefix'] = prefix

plen = max(map(lambda t: len(t[label]), tasks.values())) if tasks else 0

def color_print(p, task):
"""Add effective color style to tasks list"""
print(bcolors.UNDERLINE+bcolors.WARNING + p + bcolors.ENDC, bcolors.OKBLUE+task+bcolors.ENDC)

for _, task in sorted(tasks.items()):
if grep.lower() in task['text'].lower():
p = '%s - ' % task[label].ljust(plen) if not quiet else ''
print(p + task['text'])
p = '<%s> - ' % task[label].ljust(plen) if not quiet else ''
color_print(p, task['text'])

def write(self, delete_if_empty=False):
"""Flush the finished and unfinished tasks to the files on disk."""
Expand Down