Fix colors implementation

This commit is contained in:
Arun Prakash Jana 2017-08-25 02:29:39 +05:30
parent 3453369841
commit c9d15b4c98
No known key found for this signature in database
GPG Key ID: A75979F35C080412
3 changed files with 19 additions and 28 deletions

View File

@ -393,7 +393,7 @@ PROMPT KEYS:
buku (? for help) g 4 9-6 << 5 3-2
37. List bookmarks with **colored output**:
$ buku --colors gKlxe -p
$ buku --colors oKlxm -p
38. More **help**:
$ buku -h

10
buku.1
View File

@ -388,18 +388,18 @@ Y;bold reverse video
.TE
.TP
.TP
The default colors string is \fIgKlxe\fR, which stands for
The default colors string is \fIoKlxm\fR, which stands for
.IP - 2
cyan index
bright cyan index
.PD 0 \" Change paragraph spacing to 0 in the list
.IP - 2
bold bright green title
.IP - 2
yellow url
bright yellow url
.IP - 2
comments/notes/desc - normal
.IP - 2
blue tag
bright blue tag
.PD 1 \" Restore paragraph spacing
.TP
Note that
@ -769,7 +769,7 @@ List bookmarks with \fBcolored output\fR:
.PP
.EX
.IP
.B $ buku --colors gKlxe -p
.B $ buku --colors oKlxm -p
.EE
.PP

35
buku.py
View File

@ -49,14 +49,13 @@ SKIP_MIMES = {'.pdf', '.txt'}
colorize = True # Allow color output by default
# Default colour to print records
ID_srch = '\x1b[96m%d. \x1b[0m'
ID_str = ID_srch + '\x1b[1;92m%s\x1b[0;2m [%s]\x1b[0m\n'
ID_dbidx = '\x1b[96m%d. \x1b[0m'
ID_DB_str = ID_dbidx + '\x1b[1;92m%s\x1b[0m'
ID = '\x1b[96m%d. \x1b[0m'
ID_str = ID + '\x1b[1;92m%s\x1b[0;2m [%s]\x1b[0m\n'
ID_DB_str = ID + '\x1b[1;92m%s\x1b[0m'
MUTE_str = '%s \x1b[2m(L)\x1b[0m\n'
URL_str = '%s \x1b[91m>\x1b[93m %s\x1b[0m\n'
DESC_str = '%s \x1b[91m+\x1b[0m %s\n'
TAG_str = '%s \x1b[91m#\x1b[34m %s\n'
DESC_str = '%s \x1b[91m+\x1b[0m %s\x1b[0m\n'
TAG_str = '%s \x1b[91m#\x1b[94m %s\x1b[0m\n'
# colormap for color output from "googler" project
COLORMAP = {k: '\x1b[%sm' % v for k, v in {
@ -68,7 +67,7 @@ COLORMAP = {k: '\x1b[%sm' % v for k, v in {
'E': '34;1', 'F': '35;1', 'G': '36;1', 'H': '37;1',
'I': '90;1', 'J': '91;1', 'K': '92;1', 'L': '93;1',
'M': '94;1', 'N': '95;1', 'O': '96;1', 'P': '97;1',
'x': '0', 'X': '1', 'y': '7', 'Y': '7;1',
'x': '0', 'X': '1', 'y': '7', 'Y': '7;1', 'z': '2',
}.items()}
# Disguise as Firefox on Ubuntu
@ -3306,21 +3305,13 @@ POSITIONAL ARGUMENTS:
# Set colors
if args.colorstr:
ID_srch = '%d.'
ID_str = '%s [%s]\n'
ID_dbidx = '%d.'
ID_DB_str = '%s'
MUTE_str = '%s (L)\n'
URL_str = '%s > %s\n'
DESC_str = '%s + %s\n'
TAG_str = '%s # %s\n'
ID_srch = setcolors(args.colorstr)[0] + ID_srch
ID_str = ID_srch + COLORMAP['x'] + setcolors(args.colorstr)[1] + ID_str
ID_DB_str = ID_dbidx + COLORMAP['x'] + setcolors(args.colorstr)[1] + ID_DB_str
MUTE_str = setcolors(args.colorstr)[3] + MUTE_str
URL_str = setcolors(args.colorstr)[2] + URL_str
DESC_str = setcolors(args.colorstr)[3] + DESC_str
TAG_str = setcolors(args.colorstr)[4] + TAG_str
ID = setcolors(args.colorstr)[0] + '%d. ' + COLORMAP['x']
ID_DB_dim = COLORMAP['z'] + '[%s]\n' + COLORMAP['x']
ID_str = ID + setcolors(args.colorstr)[1] + '%s ' + COLORMAP['x'] + ID_DB_dim
ID_DB_str = ID + setcolors(args.colorstr)[1] + '%s' + COLORMAP['x']
URL_str = COLORMAP['j'] + '%s > ' + setcolors(args.colorstr)[2] + '%s\n' + COLORMAP['x']
DESC_str = COLORMAP['j'] + '%s + ' + setcolors(args.colorstr)[3] + '%s\n' + COLORMAP['x']
TAG_str = COLORMAP['j'] + '%s # ' + setcolors(args.colorstr)[4] + '%s\n' + COLORMAP['x']
# Set up debugging
if args.debug: