charmbracelet / lipgloss

Style definitions for nice terminal layouts 👄
MIT License
8.03k stars 228 forks source link

Feature: Mouse Support #29

Closed unikzforce closed 3 years ago

unikzforce commented 3 years ago

This has been implemented in this repository: https://github.com/jroimartin/gocui

meowgorithm commented 3 years ago

Hi! Lip Gloss is strictly for rendering only. That said, it works wonderfully with Bubble Tea, a terminal user interface framework which features mouse support.

unikzforce commented 3 years ago

Wow, How cool is this ecosystem :) thanks man

ghost commented 3 years ago

@meowgorithm I'm struggling with how to detect mouse clicks in a bounding box of something generated by Lipgloss. I believe it's not possible in Bubbletea's current state, but I'd love to be wrong about this:

Let's say you wanted to make those fancy tabs in the Lipgloss demo respond to clicks. You'd have to calculate the bounding box of each tab, but mouse events get passed through the Update method, while all of the Lipgloss work happens in the View method. I tried some unmentionable ugly hacks that break the functional nature of the Elm architecture for storing bounding boxes in the model that are computed during the View cycle, but clearly not a sustainable way to continue. The only other thing I can imagine is abstracting the view rendering code into a function that gets recomputed on both View and optionally Update when required, that attaches additional hitbox data to each cell to compare a mouse event with some identifier (some 3D games work this way).

Any suggestions or ideas?

meowgorithm commented 3 years ago

@winduptoy Hi! I know exactly your plight, and you're correct that it's not an easy task at the moment. We're actually putting the finishing touches on updates for both Lip Gloss and Bubble Tea that will address exactly what you want to do here. I'll update this issue with progress, but expect a release soon.

(Related: https://github.com/charmbracelet/bubbletea/issues/79)