lrstanley / bubblezone

helper utility for BubbleTea, allowing easy mouse event tracking
https://pkg.go.dev/github.com/lrstanley/bubblezone
MIT License
521 stars 15 forks source link

bug: Handle zones in non WithAltScreen #11

Open Chillance opened 1 year ago

Chillance commented 1 year ago

🌧 Describe the problem

AltScreen enables a fresh screen and everything starts from the top. But, if I don't use this AltScreen, it seems the zones y position will be calculated wrong. I tested with not having a AltScreen and I noticed my styles triggered when I was at the top with the mouse, although the output was at the bottom. So, it seemed to work, but it essentially triggered like the text was at the top.

I'm not sure how or if this could be solved but it would be nice if this worked somehow. Able to set some offset or even calculate it properly somehow?

⛅ Expected behavior

zones to work in non AltScreen.

🔄 Minimal reproduction

No response

💠 Version: bubblezone

b3469cc5a65953ac7af1d38bf6ba5391eba93751

🖥 Version: Operating system

linux/ubuntu

⚙ Additional context

No response

🤝 Requirements

lrstanley commented 1 year ago

From my initial testing, it looks as though mouse coordinates still return as if it was a full screen, however non-alt-screen programs scan start at any height from the top of the screen. Looking at the events that bubbletea produces, I don't see a way of being able to calculate the difference to be able to tell how far offset from the top of the screen it may be (it may not be something bubbletea can even determine).

May reach out to folks on the bubbletea team to see if there is some hidden magic we can do to determine such an offset.

I suspect that if there is a way, maybe it's something like the cursor reports it's position, and on initial start, bubbletea places that cursor in the first block, waits for it to report it's position, then begins drawing regular content. However, I am also unsure if adjusting the output height during runtime has any impacts on the reported height either.