olavolav / uniplot

Lightweight plotting to the terminal. 4x resolution via Unicode.
MIT License
343 stars 16 forks source link

Configurable move / zoom keys #23

Open riga opened 4 months ago

riga commented 4 months ago

After using uniplot now for a couple days, I found myself using the interactive mode quite often for some simple EDA on remote resources. However, I've been struggling a bit with the h/j/k/l key combinations for moving the bounding box ("struggling" is perhaps a too strong word here ^^), so I've been wondering if you would be up for having this configurable. If this option existed, I would change it to w/a/s/d.

The Options dataclass could be a good place for that, however, the question is whether this should be configurable per plot/histogram() call (1), or a global setting (2).

I don't believe people would need to change this behavior from plot to plot, so option 2 could make more sense here. In this case, a ClassVar on Options would already do the trick, allowing for (e.g.)

import uniplot
uniplot.Options.move_keys = "wasd"
uniplot.plot(...)

(just as an example, a proper setter is of course preferable here to change the class var)

olavolav commented 4 months ago

It's definitely a cool idea. I've just tried remapping the keys locally, and it is an interesting FPS-like experience 😄 Especially if w is mapped to zooming in, rather than shift view upwards

Let's see if more people want this

olavolav commented 4 months ago

In the meantime, feel free to play around with a possible wasd mapping on this separate branch.

olavolav commented 3 months ago

And as a question for you @riga and if anyone else wants to chime in: Would you expect w to zoom in 🔍 or to move upwards ⬆️ ?

riga commented 3 months ago

I would expect

I'd have no real preference for zooming, but perhaps e/r or f/g?