diff --git a/visidata/ddwplay.py b/visidata/ddwplay.py index e123f4c4b..169f0d82a 100644 --- a/visidata/ddwplay.py +++ b/visidata/ddwplay.py @@ -1,7 +1,7 @@ from collections import defaultdict import json import time -from visidata import colors, vd +from visidata import colors, vd, clipdraw __all__ = ['Animation', 'AnimationMgr'] @@ -68,7 +68,7 @@ def load_from(self, fp): def draw(self, scr, *, t=0, x=0, y=0, loop=False, **kwargs): for r, dx, dy, _ in self.iterdeep(self.frames[''].rows): - scr.addstr(y+dy, x+dx, r.text, colors[r.color].attr) + clipdraw(scr, y+dy, x+dx, r.text, colors[r.color]) if not self.total_ms: return None @@ -78,7 +78,7 @@ def draw(self, scr, *, t=0, x=0, y=0, loop=False, **kwargs): ms -= int(f.duration_ms or 0) if ms < 0: for r, dx, dy, _ in self.iterdeep(f.rows): - scr.addstr(y+dy, x+dx, r.text, colors[r.color].attr) + clipdraw(scr, y+dy, x+dx, r.text, colors[r.color]) return -ms/1000 diff --git a/visidata/help.py b/visidata/help.py index c820dc040..d0dafc9e7 100644 --- a/visidata/help.py +++ b/visidata/help.py @@ -83,32 +83,37 @@ def __init__(self, name): def draw(self, scr, x=None, y=None): if not scr: return - if not vd.options.disp_help: - if self.scr: - self.scr.erase() - self.scr.refresh() - self.scr = None - return +# if vd.options.disp_help <= 0: +# if self.scr: +# self.scr.erase() +# self.scr.refresh() +# self.scr = None +# return if y is None: y=0 # show at top of screen by default if x is None: x=0 + hneeded = self.amgr.maxHeight+3 + wneeded = self.amgr.maxWidth+4 + scrh, scrw = scr.getmaxyx() if not self.scr or scr is not self.parentscr: # (re)allocate help pane scr if y >= 0: - if y+self.amgr.maxHeight+3 < scr.getmaxyx()[0]: + if y+hneeded < scrh: yhelp = y+1 else: - yhelp = y-self.amgr.maxHeight-3 + hneeded = max(0, min(hneeded, y-1)) + yhelp = y-hneeded else: # y<0 - yhelp = scr.getmaxyx()[0]-self.amgr.maxHeight-4 + yhelp = max(0, scrh-hneeded-1) if x >= 0: - if x+self.amgr.maxWidth+4 < scr.getmaxyx()[1]: + if x+wneeded < scrw: xhelp = x+1 else: - xhelp = x-self.amgr.maxWidth-4 + wneeded = max(0, min(wneeded, x-1)) + xhelp = x-wneeded else: # x<0 - xhelp = scr.getmaxyx()[1]-self.amgr.maxWidth-5 + xhelp = max(0, scrh-wneeded-1) - self.scr = vd.subwindow(scr, xhelp, yhelp, self.amgr.maxWidth+4, self.amgr.maxHeight+3) + self.scr = vd.subwindow(scr, xhelp, yhelp, wneeded, hneeded) self.parentscr = scr self.scr.erase() diff --git a/visidata/statusbar.py b/visidata/statusbar.py index 2e697bce9..d624b9241 100644 --- a/visidata/statusbar.py +++ b/visidata/statusbar.py @@ -235,7 +235,8 @@ def drawRightStatus(vd, scr, vs): cattr = update_attr(cattr, colors.color_top_status, 0) cattr = update_attr(cattr, colors.color_active_status if vs is vd.activeSheet else colors.color_inactive_status, 0) rstat = vd.rightStatus(vs) - statuslen = clipdraw(scr, vs.windowHeight-1, rightx-dispwidth(rstat)-1, rstat, cattr, w=vs.windowWidth-1) + x = max(2, rightx-dispwidth(rstat)-1) + statuslen = clipdraw(scr, vs.windowHeight-1, x, rstat, cattr, w=vs.windowWidth-1) except Exception as e: vd.exceptionCaught(e) finally: