Skip to content

Commit

Permalink
Hotfix - implement "Support custom colours" from (jarun#174)
Browse files Browse the repository at this point in the history
# sorted import in alphabetical order
# adjusted var name's
# add color table to man page
# add --colors option to readme "Usage" section
  • Loading branch information
shv-q3 committed Aug 18, 2017
1 parent 28f9810 commit 745ff87
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ POWER TOYS:
N=1: URL, N=2: URL and tag, N=3: title,
N=4: URL, title and tag
-j, --json Json formatted output for -p and search
--colors set output colors (see man page for details)
--nc disable color output
--np do not show the prompt, run and exit
-o, --open [...] browse bookmarks by indices and ranges
Expand Down
12 changes: 6 additions & 6 deletions buku.1
Original file line number Diff line number Diff line change
Expand Up @@ -340,19 +340,19 @@ can be integrated in a GUI environment with simple tweaks. Refer to:
.br
.I https://github.com/jarun/Buku#gui-integration
.SH COLORS
\fBbuku\fR allows you to customize the color scheme via a four-letter string, reminiscent of BSD \fBLSCOLORS\fR. The six letters represent the colors of
\fBBuku\fR allows you to customize the color scheme via a four-letter string, reminiscent of BSD \fBLSCOLORS\fR. The four letters represent the colors of
.IP - 2
bookmark id and title
bookmark's id and title
.PD 0 \" Change paragraph spacing to 0 in the list
.IP - 2
URLs
bookmark's url
.IP - 2
bookmark description
bookmark's description
.IP - 2
bookmark tag
bookmark's tag
.PD 1 \" Restore paragraph spacing
.TP
respectively. The four-letter string is passed in either as the argument to the \fB--colors\fR option.
respectively. The four-letter string is passed in either as the argument to the \fB--colors\fR option, or as the value of the environment variable \fBBUKU_COLORS\fR.
.TP
We offer the following colors/styles:
.TS
Expand Down
31 changes: 16 additions & 15 deletions buku.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# along with Buku. If not, see <http://www.gnu.org/licenses/>.

import argparse
import collections
import html.parser as HTMLParser
import json
import logging
Expand All @@ -36,7 +37,6 @@
import urllib3
from urllib3.util import parse_url, make_headers
import webbrowser
import collections

__version__ = '3.2'
__author__ = 'Arun Prakash Jana <[email protected]>'
Expand Down Expand Up @@ -2673,30 +2673,30 @@ def print_single_rec(row, idx=0): # NOQA

# Start with index and title
if idx != 0:
idandtitleresult = ID_str % (idx, row[2] if row[2] else 'Untitled', row[0])
id_title_res = ID_str % (idx, row[2] if row[2] else 'Untitled', row[0])
else:
idandtitleresult = ID_DB_str % (row[0], row[2] if row[2] else 'Untitled')
id_title_res = ID_DB_str % (row[0], row[2] if row[2] else 'Untitled')
# Indicate if record is immutable
if row[5] & 1:
idandtitleresult = MUTE_str % (idandtitleresult)
id_title_res = MUTE_str % (id_title_res)
else:
idandtitleresult += '\n'
id_title_res += '\n'

# Append URL
urlresult = ''
urlresult = URL_str % (urlresult, row[1])
url_res = ''
url_res = URL_str % (url_res, row[1])

# Append description
descresult = ''
desc_res = ''
if row[4]:
descresult = DESC_str % (descresult, row[4])
desc_res = DESC_str % (desc_res, row[4])

# Append tags IF not default (delimiter)
tagresult = ''
tag_res = ''
if row[3] != DELIM:
tagresult = TAG_str % (tagresult, row[3][1:-1])
tag_res = TAG_str % (tag_res, row[3][1:-1])

print(idandtitleresult + urlresult + descresult + tagresult)
print(id_title_res + url_res + desc_res + tag_res)

def format_json(resultset, single_record=False, field_filter=0):
'''Return results in Json format
Expand Down Expand Up @@ -3083,6 +3083,7 @@ def main():
tags_in = None
desc_in = None
pipeargs = []
colorstr_env = os.getenv('BUKU_COLORS')

try:
piped_input(sys.argv, pipeargs)
Expand Down Expand Up @@ -3224,8 +3225,8 @@ def main():
N=1: URL, N=2: URL and tag, N=3: title,
N=4: URL, title and tag
-j, --json Json formatted output for -p and search
--colors set output colors (see man page for details)
--nc disable color output
--colors set output colors (see man page for details
--np do not show the prompt, run and exit
-o, --open [...] browse bookmarks by indices and ranges
open a random bookmark, if no arguments
Expand All @@ -3248,9 +3249,9 @@ def main():
addarg('-p', '--print', nargs='*', help=HIDE)
addarg('-f', '--format', type=int, default=0, choices={1, 2, 3, 4}, help=HIDE)
addarg('-j', '--json', action='store_true', help=HIDE)
addarg('--colors', dest='colorstr', type=argparser.is_colorstr,
default=colorstr_env if colorstr_env else 'GKlg', metavar='COLORS', help=HIDE)
addarg('--nc', action='store_true', help=HIDE)
addarg('--colors', dest='colorstr', type=argparser.is_colorstr, metavar='COLORS',
help=HIDE)
addarg('--np', action='store_true', help=HIDE)
addarg('-o', '--open', nargs='*', help=HIDE)
addarg('--oa', action='store_true', help=HIDE)
Expand Down

0 comments on commit 745ff87

Please sign in to comment.