Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: saulpw/visidata
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: deada132793f06581df9c293ee0747f70000772a
Choose a base ref
..
head repository: saulpw/visidata
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0bed7a44c2137d0c8a078eff5306c572439bb4b3
Choose a head ref
Showing with 37 additions and 28 deletions.
  1. +20 −12 visidata/cliptext.py
  2. +2 −1 visidata/features/join.py
  3. +5 −5 visidata/form.py
  4. +1 −1 visidata/menu.py
  5. +5 −6 visidata/sheets.py
  6. +4 −3 visidata/sidebar.py
32 changes: 20 additions & 12 deletions visidata/cliptext.py
Original file line number Diff line number Diff line change
@@ -117,24 +117,31 @@ def iterchars(x):
def _clipstr(s, dispw, trunch='', oddspacech='', combch='', modch=''):
'''Return clipped string and width in terminal display characters.
Note: width may differ from len(s) if East Asian chars are 'fullwidth'.'''
if not s:
return '', 0

if dispw == 1:
return s[0], 1

w = 0
ret = ''

trunchlen = dispwidth(trunch)
for c in s:
newc, chlen = _dispch(c, oddspacech=oddspacech, combch=combch, modch=modch)
if newc:
ret += newc
w += chlen
else:
ret += c
w += dispwidth(c)

if dispw and w > dispw-trunchlen+1:
ret = ret[:-2] + trunch # replace final char with ellipsis
w += trunchlen
if not newc:
newc = c
chlen = dispwidth(c)

if dispw and w+chlen > dispw-trunchlen:
if trunchlen and dispw > trunchlen:
ret = ret[:-1] + trunch # replace final char with ellipsis
w += trunchlen
break

w += chlen
ret += newc

return ret, w


@@ -190,6 +197,9 @@ def clipdraw_chunks(scr, y, x, chunks, attr, w=None, clear=True, rtl=False, lite
clipped = ''
link = ''

if w and clear and not rtl:
scr.addstr(y, x, disp_column_fill*w, cattr.attr) # clear whole area before displaying

try:
for colorname, chunk in chunks:
if colorname.startswith('onclick'):
@@ -225,8 +235,6 @@ def clipdraw_chunks(scr, y, x, chunks, attr, w=None, clear=True, rtl=False, lite
# scr.addstr(y, x-dispw-1, disp_column_fill*dispw, attr)
scr.addstr(y, x-dispw-1, clipped, cattr.attr)
else:
if clear:
scr.addstr(y, x, disp_column_fill*chunkw, cattr.attr) # clear whole area before displaying
scr.addstr(y, x, clipped, cattr.attr)

if link:
3 changes: 2 additions & 1 deletion visidata/features/join.py
Original file line number Diff line number Diff line change
@@ -148,8 +148,9 @@ def isDiff(self, row, value):
col = list(self.cols.values())[0]
return col and value != col.getValue(row[col.sheet])


#### slicing and dicing
# rowdef: [sheet1_row, sheet2_row, ...]
# rowdef: {sheet1:sheet1_row, sheet2:sheet2_row, ...}
# if a sheet does not have this key, sheet#_row is None
class JoinSheet(Sheet):
'Column-wise join/merge. `jointype` constructor arg should be one of jointypes.'
10 changes: 5 additions & 5 deletions visidata/form.py
Original file line number Diff line number Diff line change
@@ -56,13 +56,13 @@ def run(self, scr):
self.scrForm = vd.scrFull.derwin(min(h-1, maxh+2), min(w-1, maxw+1), y, x)
self.scrForm.keypad(1)
curinput = inputs[0] if inputs else None
while True:
vd.draw_all()
vd.draw_all()

self.scrForm.erase()
self.scrForm.border()
self.draw(self.scrForm)
self.scrForm.erase()
self.scrForm.border()
self.draw(self.scrForm)

while True:
k = vd.getkeystroke(self.scrForm, self)
if k in ['^C', '^Q', '^[', 'q']:
return {}
2 changes: 1 addition & 1 deletion visidata/menu.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
vd.menuRunning = False

def menudraw(*args):
return clipdraw(*args, truncator=' ')
return clipdraw(*args, truncator='')


def Menu(title, *args):
11 changes: 5 additions & 6 deletions visidata/sheets.py
Original file line number Diff line number Diff line change
@@ -620,18 +620,17 @@ def drawColHeader(self, scr, y, h, vcolidx):

hdrs = col.name.split('\n')
for i in range(h):
name = ' ' # save room at front for LeftMore or sorted arrow
name = ''
if colwidth > 2:
name = ' ' # save room at front for LeftMore or sorted arrow

if h-i-1 < len(hdrs):
name += hdrs[::-1][h-i-1]

if len(name) > colwidth-1:
name = name[:colwidth-len(self.options.disp_truncator)] + self.options.disp_truncator

if i == h-1:
hdrcattr = update_attr(hdrcattr, colors.color_bottom_hdr, 5)

clipdraw(scr, y+i, x, name, hdrcattr.attr, colwidth)
clipdraw(scr, y+i, x, name, hdrcattr.attr, w=colwidth)
vd.onMouse(scr, x, y+i, colwidth, 1, BUTTON3_RELEASED='rename-col')

if C and x+colwidth+len(C) < self.windowWidth and y+i < self.windowWidth:
@@ -787,7 +786,7 @@ def drawRow(self, scr, row, rowidx, ybase, rowcattr: ColorAttr, maxheight,
notewidth = 1 if note else 0
if note:
notecattr = update_attr(cattr, colors.get_color(cellval.notecolor), 10)
clipdraw(scr, ybase, x+colwidth-notewidth, note, notecattr.attr)
scr.addstr(ybase, x+colwidth-notewidth, note, notecattr.attr)

if voffset >= 0:
if len(lines)-voffset > height:
7 changes: 4 additions & 3 deletions visidata/sidebar.py
Original file line number Diff line number Diff line change
@@ -72,11 +72,12 @@ def drawSidebarText(sheet, scr, text:str, title:str='', overflowmsg:str='', bott
bottommsg = overflowmsg
break

x += clipdraw(sidebarscr, i+1, 2, line, cattr, w=w-2)
x += clipdraw(sidebarscr, i+1, 2, line, cattr, w=w-3)
i += 1

x = w-len(title)-6
clipdraw(sidebarscr, 0, x, f"|[:black on yellow] {title} [:]|", cattr)
titlew = dispwidth(title)
x = w-titlew-6
clipdraw(sidebarscr, 0, x, f"|[:black on yellow] {title} [:]|", cattr, w=titlew+4)
if bottommsg:
clipdraw(sidebarscr, h-1, winw-dispwidth(bottommsg)-4, '|'+bottommsg+'|[:]', cattr)