Finish double line box drawing chars
This commit is contained in:
parent
79f529c732
commit
792aa694be
@ -156,22 +156,36 @@ def triangle(buf, width, height, left=True):
|
|||||||
buf[x + offset] = 255 if upper <= y <= lower else 0
|
buf[x + offset] = 255 if upper <= y <= lower else 0
|
||||||
|
|
||||||
|
|
||||||
def half_dhline(buf, width, height, level=1, which='left'):
|
def half_dhline(buf, width, height, level=1, which='left', only=None):
|
||||||
x1, x2 = (0, width // 2) if which == 'left' else (width // 2, width)
|
x1, x2 = (0, width // 2) if which == 'left' else (width // 2, width)
|
||||||
gap = thickness(level + 1, horizontal=False)
|
gap = thickness(level + 1, horizontal=False)
|
||||||
|
if only != 'bottom':
|
||||||
draw_hline(buf, width, x1, x2, height // 2 - gap, level)
|
draw_hline(buf, width, x1, x2, height // 2 - gap, level)
|
||||||
|
if only != 'top':
|
||||||
draw_hline(buf, width, x1, x2, height // 2 + gap, level)
|
draw_hline(buf, width, x1, x2, height // 2 + gap, level)
|
||||||
return height // 2 - gap, height // 2 + gap
|
return height // 2 - gap, height // 2 + gap
|
||||||
|
|
||||||
|
|
||||||
def half_dvline(buf, width, height, level=1, which='top'):
|
def half_dvline(buf, width, height, level=1, which='top', only=None):
|
||||||
y1, y2 = (0, height // 2) if which == 'top' else (height // 2, height)
|
y1, y2 = (0, height // 2) if which == 'top' else (height // 2, height)
|
||||||
gap = thickness(level + 1, horizontal=True)
|
gap = thickness(level + 1, horizontal=True)
|
||||||
|
if only != 'right':
|
||||||
draw_vline(buf, width, y1, y2, width // 2 - gap, level)
|
draw_vline(buf, width, y1, y2, width // 2 - gap, level)
|
||||||
|
if only != 'left':
|
||||||
draw_vline(buf, width, y1, y2, width // 2 + gap, level)
|
draw_vline(buf, width, y1, y2, width // 2 + gap, level)
|
||||||
return width // 2 - gap, width // 2 + gap
|
return width // 2 - gap, width // 2 + gap
|
||||||
|
|
||||||
|
|
||||||
|
def dvline(*s, only=None, level=1):
|
||||||
|
half_dvline(*s, only=only, level=level)
|
||||||
|
return half_dvline(*s, only=only, which='bottom', level=level)
|
||||||
|
|
||||||
|
|
||||||
|
def dhline(*s, only=None, level=1):
|
||||||
|
half_dhline(*s, only=only, level=level)
|
||||||
|
return half_dhline(*s, only=only, which='bottom', level=level)
|
||||||
|
|
||||||
|
|
||||||
def dvcorner(*s, level=1, which='╒'):
|
def dvcorner(*s, level=1, which='╒'):
|
||||||
hw = 'right' if which in '╒╘' else 'left'
|
hw = 'right' if which in '╒╘' else 'left'
|
||||||
half_dhline(*s, which=hw)
|
half_dhline(*s, which=hw)
|
||||||
@ -222,17 +236,27 @@ def dcorner(buf, width, height, level=1, which='╔'):
|
|||||||
|
|
||||||
def dpip(*a, level=1, which='╟'):
|
def dpip(*a, level=1, which='╟'):
|
||||||
if which in '╟╢':
|
if which in '╟╢':
|
||||||
left, right = half_dvline(*a)
|
left, right = dvline(*a)
|
||||||
half_dvline(*a, which='bottom')
|
|
||||||
x1, x2 = (0, left) if which == '╢' else (right, a[1])
|
x1, x2 = (0, left) if which == '╢' else (right, a[1])
|
||||||
draw_hline(a[0], a[1], x1, x2, a[2] // 2, level)
|
draw_hline(a[0], a[1], x1, x2, a[2] // 2, level)
|
||||||
else:
|
else:
|
||||||
top, bottom = half_dhline(*a)
|
top, bottom = dhline(*a)
|
||||||
half_dhline(*a, which='right')
|
|
||||||
y1, y2 = (0, top) if which == '╧' else (bottom, a[2])
|
y1, y2 = (0, top) if which == '╧' else (bottom, a[2])
|
||||||
draw_vline(a[0], a[1], y1, y2, a[1] // 2, level)
|
draw_vline(a[0], a[1], y1, y2, a[1] // 2, level)
|
||||||
|
|
||||||
|
|
||||||
|
def inner_corner(buf, width, height, which='tl', level=1):
|
||||||
|
hgap = thickness(level + 1, horizontal=True)
|
||||||
|
vgap = thickness(level + 1, horizontal=False)
|
||||||
|
vthick = thickness(level, horizontal=True) // 2
|
||||||
|
x1, x2 = (0, width // 2 - hgap + vthick + 1) if 'l' in which else (width // 2 + hgap - vthick, width)
|
||||||
|
yd = -1 if 't' in which else 1
|
||||||
|
draw_hline(buf, width, x1, x2, height // 2 + (yd * vgap), level)
|
||||||
|
y1, y2 = (0, height // 2 - vgap) if 't' in which else (height // 2 + vgap, height)
|
||||||
|
xd = -1 if 'l' in which else 1
|
||||||
|
draw_vline(buf, width, y1, y2, width // 2 + (xd * hgap), level)
|
||||||
|
|
||||||
|
|
||||||
box_chars = {
|
box_chars = {
|
||||||
'─': [hline],
|
'─': [hline],
|
||||||
'━': [p(hline, level=3)],
|
'━': [p(hline, level=3)],
|
||||||
@ -264,14 +288,19 @@ box_chars = {
|
|||||||
'╿': [p(half_vline, level=3), p(half_vline, which='bottom')],
|
'╿': [p(half_vline, level=3), p(half_vline, which='bottom')],
|
||||||
'': [triangle],
|
'': [triangle],
|
||||||
'': [p(triangle, left=False)],
|
'': [p(triangle, left=False)],
|
||||||
'═': [half_dhline, p(half_dhline, which='right')],
|
'═': [dhline],
|
||||||
'║': [half_dvline, p(half_dvline, which='bottom')],
|
'║': [dvline],
|
||||||
'╞': [vline, p(half_dhline, which='right')],
|
'╞': [vline, p(half_dhline, which='right')],
|
||||||
'╡': [vline, half_dhline],
|
'╡': [vline, half_dhline],
|
||||||
'╥': [hline, p(half_dvline, which='bottom')],
|
'╥': [hline, p(half_dvline, which='bottom')],
|
||||||
'╨': [hline, half_dvline],
|
'╨': [hline, half_dvline],
|
||||||
'╪': [vline, half_dhline, p(half_dhline, which='right')],
|
'╪': [vline, half_dhline, p(half_dhline, which='right')],
|
||||||
'╫': [hline, half_dvline, p(half_dvline, which='bottom')],
|
'╫': [hline, half_dvline, p(half_dvline, which='bottom')],
|
||||||
|
'╬': [p(inner_corner, which=x) for x in 'tl tr bl br'.split()],
|
||||||
|
'╠': [p(inner_corner, which='tr'), p(inner_corner, which='br'), p(dvline, only='left')],
|
||||||
|
'╣': [p(inner_corner, which='tl'), p(inner_corner, which='bl'), p(dvline, only='right')],
|
||||||
|
'╦': [p(inner_corner, which='bl'), p(inner_corner, which='br'), p(dhline, only='top')],
|
||||||
|
'╩': [p(inner_corner, which='tl'), p(inner_corner, which='tr'), p(dhline, only='bottom')],
|
||||||
}
|
}
|
||||||
|
|
||||||
t, f = 1, 3
|
t, f = 1, 3
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user