Coding style.
Removed the Code widget which was almost the same as the Text widget.
This commit is contained in:
parent
6eb64745b9
commit
1a12f6e369
13 changed files with 46 additions and 94 deletions
42
fill3.py
42
fill3.py
|
|
@ -341,48 +341,6 @@ class Table:
|
|||
for y, row in enumerate(appearances)])
|
||||
|
||||
|
||||
def _parse_rgb(hex_rgb):
|
||||
if hex_rgb.startswith("#"):
|
||||
hex_rgb = hex_rgb[1:]
|
||||
return tuple(eval("0x"+hex_rgb[index:index+2]) for index in [0, 2, 4])
|
||||
|
||||
|
||||
def _char_style_for_token_type(token_type, pygment_style):
|
||||
token_style = pygment_style.style_for_token(token_type)
|
||||
fg_color = (None if token_style["color"] is None
|
||||
else _parse_rgb(token_style["color"]))
|
||||
bg_color = (None if token_style["bgcolor"] is None
|
||||
else _parse_rgb(token_style["bgcolor"]))
|
||||
return termstr.CharStyle(fg_color, bg_color, token_style["bold"],
|
||||
token_style["italic"], token_style["underline"])
|
||||
|
||||
|
||||
def _pygments_to_termstr(tokens, pygment_style):
|
||||
return termstr.TermStr("").join(
|
||||
termstr.TermStr(text, _char_style_for_token_type(
|
||||
token_type, pygment_style))
|
||||
for token_type, text in tokens)
|
||||
|
||||
|
||||
class Code:
|
||||
|
||||
def __init__(self, tokens, style):
|
||||
code = _pygments_to_termstr(tokens, style).split("\n")
|
||||
max_width = max(len(line) for line in code)
|
||||
height = len(code)
|
||||
# bg_color = _parse_rgb(style.background_color)
|
||||
# bg_style = termstr.CharStyle(1, bg_color)
|
||||
# pad_char = termstr.TermStr(" ", bg_style)
|
||||
pad_char = " "
|
||||
self.code = appearance_resize(code, (max_width, height), pad_char)
|
||||
|
||||
def appearance_min(self):
|
||||
return self.code
|
||||
|
||||
def appearance(self, dimensions):
|
||||
return appearance_resize(self.appearance_min(), dimensions)
|
||||
|
||||
|
||||
class Border:
|
||||
|
||||
THIN = ["─", "─", "│", "│", "┌", "└", "┘", "┐"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue