johnnovak / illwill

A curses inspired simple cross-platform console library for Nim
Do What The F*ck You Want To Public License
398 stars 27 forks source link

Is it possible to create terminal buffers someplace besides the upper left corner? #41

Open MatrixManAtYrService opened 11 months ago

MatrixManAtYrService commented 11 months ago

Hi, thanks for this project. I'm excited to use it.

Please take a look at this asciicast: https://asciinema.org/a/352660

Notice how the action happens below the prompt. I'd like to do something similar with illwill in non-fullscreen mode. But I see that newTerminalBuffer always creates buffers in the top left corner of my terminal--I only have control over their width and height.

Can it be done with illwill? What would the strategy be?

johnnovak commented 11 months ago

Hi, I'm not working on it actively, so I had to take a quick look at the code 😄 I don't think it's possible, but it could be added by extending display to receive the start coordinates. If you raise a PR with a clean solution and possibly examples, I'll merge it.

MatrixManAtYrService commented 11 months ago

Ok, I'll play around with that approach. You'll see a PR if I end up with something worth sharing. Thanks.

MatrixManAtYrService commented 11 months ago

I'll want to use it in anger for a bit longer before suggesting that anybody adopt my changes, but it was actually pretty easy to add the offsets.

Where I ran into trouble was getting the cursor position so that I could use this new ability to place the buffer below my prompt. I've posted about it here: https://forum.nim-lang.org/t/10491#69978

johnnovak commented 11 months ago

Good luck @MatrixManAtYrService 😄

You might have noticed that illwill already initialises raw mode... but maybe only in fullscreen? Can't remember.

Also, please note that whatever change you introduce, illwill must behave the same way on macOS, Windows, and Linux. So you'll need to test things on all 3 platforms if you want to get your PR merged, plus also provide test evidence as I don't have much time to spend on this.

Just wanted to set clear expectations, that's all 😄 PRs of course are still welcome 😄

MatrixManAtYrService commented 10 months ago

I added getCursorPos to std/terminal, and learned some things along the way :slightly_smiling_face: That unblocks me for this work, for which I have proved the concept to myself, but still need to bang on it a bit before it's in a shape to contribute. I'll have a PR for this... eventually.