Min-width, style & mouse support

Signed-off-by: Hadi <[email protected]>
This commit is contained in:
Hadi
2026-08-23 18:09:45 +02:00
parent 1ba517179e
commit 658b052307
7 changed files with 194 additions and 86 deletions
+22 -3
View File
@@ -4,23 +4,33 @@ import (
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
"github.com/anotherhadi/ilovetui/app"
"github.com/anotherhadi/ilovetui/minsize"
"github.com/anotherhadi/ilovetui/modal"
"github.com/anotherhadi/ilovetui/notification"
"github.com/anotherhadi/usbguard-tui/ui"
zone "github.com/lrstanley/bubblezone/v2"
)
const (
minWidth = 40
minHeight = 15
)
type appModel struct {
core ui.Model
modals modal.Model
notif notification.Model
minsize minsize.Model
width, height int
}
func newApp() appModel {
zone.NewGlobal()
return appModel{
core: ui.New(),
modals: modal.New(),
notif: notification.New(),
core: ui.New(),
modals: modal.New(),
notif: notification.New(),
minsize: minsize.New(minWidth, minHeight),
}
}
@@ -48,9 +58,18 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (a appModel) View() tea.View {
if !a.minsize.Fits(a.width, a.height) {
return tea.View{
Content: a.minsize.View(a.width, a.height),
AltScreen: true,
WindowTitle: "USBGuard TUI",
}
}
bg := lipgloss.Place(a.width, a.height, lipgloss.Left, lipgloss.Top, a.core.View())
bg = a.modals.Render(bg)
bg = a.notif.Render(bg)
bg = zone.Scan(bg)
return tea.View{
Content: bg,
AltScreen: true,