From c9d15b4c98fbc7bd438ca92d2b33d4ab9536dfda Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Fri, 25 Aug 2017 02:29:39 +0530 Subject: [PATCH] Fix colors implementation --- README.md | 2 +- buku.1 | 10 +++++----- buku.py | 35 +++++++++++++---------------------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 354a744..230ef58 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/buku.1 b/buku.1 index 6b409e8..b5ad3a4 100644 --- a/buku.1 +++ b/buku.1 @@ -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 diff --git a/buku.py b/buku.py index 1d14808..52580bc 100755 --- a/buku.py +++ b/buku.py @@ -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: