diff --git a/visidata/canvas.py b/visidata/canvas.py index 426395354..a04732a56 100644 --- a/visidata/canvas.py +++ b/visidata/canvas.py @@ -785,7 +785,7 @@ def deleteSourceRows(self, rows): Canvas.bindkey('BUTTON3_TRIPLE_CLICKED', 'move-canvas') Canvas.addCommand('ScrollUp', 'zoomin-mouse', 'cm=canvasMouse; incrZoom(1.0/options.disp_zoom_incr) if cm else fail("cannot zoom in on unplotted canvas"); fixPoint(plotterMouse, cm)', 'zoom in with scroll wheel') -Canvas.addCommand('ScrollDown', 'zoomout-mouse', 'cm=canvasMouse; incrZoom(options.disp_zoom_incr) if cm else fail("cannot zoom in on unplotted canvas"); fixPoint(plotterMouse, cm)', 'zoom out with scroll wheel') +Canvas.addCommand('ScrollDown', 'zoomout-mouse', 'cm=canvasMouse; incrZoom(options.disp_zoom_incr) if cm else fail("cannot zoom out on unplotted canvas"); fixPoint(plotterMouse, cm)', 'zoom out with scroll wheel') Canvas.addCommand('s', 'select-cursor', 'source.select(list(rowsWithin(plotterCursorBox)))', 'select rows on source sheet contained within canvas cursor') Canvas.addCommand('t', 'stoggle-cursor', 'source.toggle(list(rowsWithin(plotterCursorBox)))', 'toggle selection of rows on source sheet contained within canvas cursor') diff --git a/visidata/graph.py b/visidata/graph.py index 6d33c8752..3546814f7 100644 --- a/visidata/graph.py +++ b/visidata/graph.py @@ -17,6 +17,12 @@ class InvertedCanvas(Canvas): def render_async(self): self.plot_elements(invert_y=True) + def fixPoint(self, plotterPoint, canvasPoint): + 'adjust visibleBox.xymin so that canvasPoint is plotted at plotterPoint' + self.visibleBox.xmin = canvasPoint.x - self.canvasW(plotterPoint.x-self.plotviewBox.xmin) + self.visibleBox.ymin = canvasPoint.y - self.canvasH(self.plotviewBox.ymax-plotterPoint.y) + self.refresh() + def zoomTo(self, bbox): super().zoomTo(bbox) self.fixPoint(Point(self.plotviewBox.xmin, self.plotviewBox.ymax),