From 53abadbce7223b379a077e2ed6b863ff3e6cbaaa Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 26 Jul 2022 15:11:45 -0700 Subject: [PATCH] feat: use bubblezone for better mouse support --- go.mod | 3 ++- go.sum | 9 ++++----- server/session.go | 2 ++ ui/common/common.go | 2 ++ ui/ui.go | 4 +++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 01e41a039390be81fce59442798c6df03a9e1724..0b84d26e1cdf6596d1e7061b8322470d47353f18 100755 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/chroma v0.10.0 github.com/caarlos0/env/v6 v6.9.1 github.com/charmbracelet/bubbles v0.11.0 - github.com/charmbracelet/bubbletea v0.21.0 + github.com/charmbracelet/bubbletea v0.22.0 github.com/charmbracelet/glamour v0.5.1-0.20220727183416-a99aac852791 github.com/charmbracelet/lipgloss v0.5.0 github.com/charmbracelet/wish v0.5.0 @@ -27,6 +27,7 @@ require ( github.com/gobwas/glob v0.2.3 github.com/gogs/git-module v1.6.1 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da + github.com/lrstanley/bubblezone v0.0.0-20220716194435-3cb8c52f6a8f github.com/muesli/mango-cobra v1.2.0 github.com/muesli/roff v0.1.0 github.com/spf13/cobra v1.5.0 diff --git a/go.sum b/go.sum index 895546613e726d6ee7e24de875ba2ddaddfcd75b..7f16699365bfcda0afa0e8616eb40d18346c99ad 100644 --- a/go.sum +++ b/go.sum @@ -29,10 +29,9 @@ github.com/caarlos0/sshmarshal v0.1.0/go.mod h1:7Pd/0mmq9x/JCzKauogNjSQEhivBclCQ github.com/charmbracelet/bubbles v0.11.0 h1:fBLyY0PvJnd56Vlu5L84JJH6f4axhgIJ9P3NET78f0Q= github.com/charmbracelet/bubbles v0.11.0/go.mod h1:bbeTiXwPww4M031aGi8UK2HT9RDWoiNibae+1yCMtcc= github.com/charmbracelet/bubbletea v0.20.0/go.mod h1:zpkze1Rioo4rJELjRyGlm9T2YNou1Fm4LIJQSa5QMEM= -github.com/charmbracelet/bubbletea v0.21.0 h1:f3y+kanzgev5PA916qxmDybSHU3N804uOnKnhRPXTcI= github.com/charmbracelet/bubbletea v0.21.0/go.mod h1:GgmJMec61d08zXsOhqRC/AiOx4K4pmz+VIcRIm1FKr4= -github.com/charmbracelet/glamour v0.5.0 h1:wu15ykPdB7X6chxugG/NNfDUbyyrCLV9XBalj5wdu3g= -github.com/charmbracelet/glamour v0.5.0/go.mod h1:9ZRtG19AUIzcTm7FGLGbq3D5WKQ5UyZBbQsMQN0XIqc= +github.com/charmbracelet/bubbletea v0.22.0 h1:E1BTNSE3iIrq0G0X6TjGAmrQ32cGCbFDPcIuImikrUc= +github.com/charmbracelet/bubbletea v0.22.0/go.mod h1:aoVIwlNlr5wbCB26KhxfrqAn0bMp4YpJcoOelbxApjs= github.com/charmbracelet/glamour v0.5.1-0.20220727183416-a99aac852791 h1:FVfu61RRIkiQCsS0KSjLkZOMf0XF5RxQqXJraTDGp/M= github.com/charmbracelet/glamour v0.5.1-0.20220727183416-a99aac852791/go.mod h1:HXz79SMFnF9arKxqeoHWxmo1BhplAH7wehlRhKQIL94= github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao= @@ -102,6 +101,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/lrstanley/bubblezone v0.0.0-20220716194435-3cb8c52f6a8f h1:FjWlbnOxKSZpFlNhsx6xFy/OnkdYTAYTuoulojPdZ9o= +github.com/lrstanley/bubblezone v0.0.0-20220716194435-3cb8c52f6a8f/go.mod h1:CxaUrg7Y6DmnquTpb1Rgxib+u+NcRxrDi8m/mR1poTM= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= @@ -117,8 +118,6 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4 github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75 h1:Pijfgr7ZuvX7QIQiEwLdRVr3RoMG+i0SbBO1Qu+7yVk= github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75/go.mod h1:76rfSfYPWj01Z85hUf/ituArm797mNKcvINh1OlsZKo= -github.com/microcosm-cc/bluemonday v1.0.17 h1:Z1a//hgsQ4yjC+8zEkV8IWySkXnsxmdSY642CTFQb5Y= -github.com/microcosm-cc/bluemonday v1.0.17/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM= github.com/microcosm-cc/bluemonday v1.0.19 h1:OI7hoF5FY4pFz2VA//RN8TfM0YJ2dJcl4P4APrCWy6c= github.com/microcosm-cc/bluemonday v1.0.19/go.mod h1:QNzV2UbLK2/53oIIwTOyLUSABMkjZ4tqiyC1g/DyqxE= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= diff --git a/server/session.go b/server/session.go index de6f2d4c3d33a0fb2feb01181c8b5d6d04a3dc12..96aeba4a919ecf6afa290219cb4efdd74b2da904 100644 --- a/server/session.go +++ b/server/session.go @@ -12,6 +12,7 @@ import ( "github.com/charmbracelet/soft-serve/ui/styles" bm "github.com/charmbracelet/wish/bubbletea" "github.com/gliderlabs/ssh" + zone "github.com/lrstanley/bubblezone" ) // SessionHandler is the soft-serve bubbletea ssh session handler. @@ -38,6 +39,7 @@ func SessionHandler(ac *appCfg.Config) bm.ProgramHandler { KeyMap: keymap.DefaultKeyMap(), Width: pty.Window.Width, Height: pty.Window.Height, + Zone: zone.New(), } m := ui.New( ac, diff --git a/ui/common/common.go b/ui/common/common.go index f18d0298b00422d343f382682c031b15301e02c0..8a5cb451a92824ba6289b438c0b03919bfbeba0a 100644 --- a/ui/common/common.go +++ b/ui/common/common.go @@ -4,6 +4,7 @@ import ( "github.com/aymanbagabas/go-osc52" "github.com/charmbracelet/soft-serve/ui/keymap" "github.com/charmbracelet/soft-serve/ui/styles" + zone "github.com/lrstanley/bubblezone" ) // Common is a struct all components should embed. @@ -13,6 +14,7 @@ type Common struct { KeyMap *keymap.KeyMap Width int Height int + Zone *zone.Manager } // SetSize sets the width and height of the common struct. diff --git a/ui/ui.go b/ui/ui.go index c87c69adec4cbe3c5429a1309da094e29b122907..2e0db8c8009d6d2048e76d2585216df9d6dcdc55 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -267,7 +267,9 @@ func (ui *UI) View() string { if ui.showFooter { view = lipgloss.JoinVertical(lipgloss.Left, view, ui.footer.View()) } - return ui.common.Styles.App.Render(view) + return ui.common.Zone.Scan( + ui.common.Styles.App.Render(view), + ) } func (ui *UI) setRepoCmd(rn string) tea.Cmd {