Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update to charm beta versions #50

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 26 additions & 33 deletions flipperui/flipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
}
)

// ErrStyle is the style of the error message
var ErrStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF0000"))

// Model represents the flipper model.
// It also implements the bubbletea.Model interface.
type Model struct {
Expand Down Expand Up @@ -76,20 +73,21 @@
height int
}
// Style is the style of the flipper screen
Style lipgloss.Style
style lipgloss.Style
// bgColor is the background color of the flipper screen
bgColor string
// fgColor is the foreground color of the flipper screen
fgColor string
// ErrStyle is the style of the error message
errStyle lipgloss.Style
}

var _ tea.Model = (*Model)(nil)

// New constructs a new flipper model.
func New(fz *recfz.FlipperZero, screenUpdate <-chan ScreenMsg, opts ...FlipperOpts) tea.Model {
func New(fz *recfz.FlipperZero, screenUpdate <-chan ScreenMsg, opts ...FlipperOpts) *Model {
m := Model{
fz: fz,
viewport: viewport.New(flipperScreenWidth, flipperScreenHeight),
lastFZEvent: time.Now().Add(-fzEventCoolDown),
screenUpdate: screenUpdate,
mu: &sync.Mutex{},
Expand All @@ -103,24 +101,26 @@
bgColor: "#FF8C00",
fgColor: "#000000",
}
m.viewport.MouseWheelEnabled = false

for _, opt := range opts {
opt(&m)
}

colorBg = lipgloss.Color(m.bgColor)
colorFg = lipgloss.Color(m.fgColor)

m.Style = lipgloss.NewStyle().Background(colorBg).Foreground(colorFg)

return &m
}

// Init is the bubbletea init function.
// the initial listenScreenUpdate command is started here.
func (m Model) Init() tea.Cmd {
return listenScreenUpdate(m.screenUpdate)
func (m Model) Init(ctx tea.Context) (tea.Model, tea.Cmd) {
colorBg = lipgloss.Color(m.bgColor)
colorFg = lipgloss.Color(m.fgColor)
m.style = ctx.NewStyle().Background(colorBg).Foreground(colorFg)
m.errStyle = ctx.NewStyle().Foreground(lipgloss.Color("#FF0000"))

m.viewport = viewport.New(ctx, flipperScreenWidth, flipperScreenHeight)
m.viewport.MouseWheelEnabled = false

return m, listenScreenUpdate(m.screenUpdate)
}

// listenScreenUpdate listens for screen updates from the flipper and returns them as tea.Cmds.
Expand All @@ -131,15 +131,15 @@
}

// Update is the bubbletea update function and handles all tea.Msgs.
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m Model) Update(ctx tea.Context, msg tea.Msg) (tea.Model, tea.Cmd) {

Check warning on line 134 in flipperui/flipper.go

View workflow job for this annotation

GitHub Actions / lint / lint

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
var cmds []tea.Cmd

switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.Type {
case tea.KeyCtrlC:
switch msg.String() {
case "ctrl+c":
return nil, tea.Quit
case tea.KeyCtrlS:
case "ctrl+s":
m.saveImage()
return m, nil
default:
Expand All @@ -149,7 +149,7 @@
}
}

case tea.MouseMsg:
case tea.MouseWheelMsg:
event := mapMouse(msg)
if event != -1 {
m.sendFlipperEvent(event, false)
Expand All @@ -158,25 +158,18 @@
case tea.WindowSizeMsg:
m.viewport.Width = min(msg.Width, flipperScreenWidth)
m.viewport.Height = min(msg.Height, flipperScreenHeight)
m.viewport.SetContent(m.Style.Render(m.content))
m.viewport.SetContent(m.style.Render(m.content))

case ScreenMsg:
m.content = msg.screen
m.currentScreen = msg.image
m.viewport.SetContent(m.Style.Render(m.content))
m.viewport.SetContent(m.style.Render(m.content))
cmds = append(cmds, listenScreenUpdate(m.screenUpdate))
}

return m, tea.Batch(cmds...)
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

// mapKey maps a tea.KeyMsg to a flipper.InputKey
func mapKey(key tea.KeyMsg) (flipper.InputKey, bool) {
switch key.String() {
Expand Down Expand Up @@ -209,8 +202,8 @@
}

// mapMouse maps a tea.MouseMsg to a flipper.InputKey
func mapMouse(event tea.MouseMsg) flipper.InputKey {
switch event.Type {
func mapMouse(event tea.MouseWheelMsg) flipper.InputKey {
switch event.Button {
case tea.MouseWheelUp:
return flipper.InputKeyUp
case tea.MouseWheelDown:
Expand All @@ -235,11 +228,11 @@
}

// View renders the flipper screen or an error message if there was an error.
func (m Model) View() string {
func (m Model) View(ctx tea.Context) string {
if m.err != nil && time.Since(m.errTime) < time.Second*4 {
return ErrStyle.Render(fmt.Sprintf("%d %s", int((time.Second*4 - time.Since(m.errTime)).Seconds()), m.err))
return m.errStyle.Render(fmt.Sprintf("%d %s", int((time.Second*4 - time.Since(m.errTime)).Seconds()), m.err))
}
return m.viewport.View()
return m.viewport.View(ctx)
}

// UpdateScreen renders the terminal screen based on the flipper screen.
Expand Down
24 changes: 15 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/jon4hz/fztea

go 1.18
go 1.21

require (
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/lipgloss v0.9.1
github.com/charmbracelet/bubbles v0.18.1-0.20240515202012-815f47433bf6
github.com/charmbracelet/bubbletea v0.26.3-0.20240521190034-5bec833f6ac3
github.com/charmbracelet/lipgloss v0.10.1-0.20240524152121-9f57d00c5c27
github.com/charmbracelet/ssh v0.0.0-20240202115812-f4ab1009799a
github.com/charmbracelet/wish v1.3.1
github.com/disintegration/imaging v1.6.2
Expand All @@ -20,31 +20,37 @@ require (
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/keygen v0.5.0 // indirect
github.com/charmbracelet/log v0.3.1 // indirect
github.com/charmbracelet/log v0.4.1-0.20240524153040-9a6ca188d8b0 // indirect
github.com/charmbracelet/x/ansi v0.1.1 // indirect
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651 // indirect
github.com/charmbracelet/x/exp/term v0.0.0-20240202113029-6ff29cf0473e // indirect
github.com/charmbracelet/x/input v0.1.0 // indirect
github.com/charmbracelet/x/term v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.1.0 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/creack/goselect v0.1.2 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/mango v0.1.0 // indirect
github.com/muesli/mango-pflag v0.1.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.4.6 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
Expand Down
31 changes: 31 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,40 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0=
github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw=
github.com/charmbracelet/bubbles v0.18.1-0.20240515202012-815f47433bf6 h1:pcJH3GbSZbCuozLoAtuMixhVr0gNgjlDfH192NyECKA=
github.com/charmbracelet/bubbles v0.18.1-0.20240515202012-815f47433bf6/go.mod h1:kMLFBc67ZNByH5u/JF2eFCev3M5B4JYeE3vvK61AmCM=
github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM=
github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg=
github.com/charmbracelet/bubbletea v0.26.3-0.20240521190034-5bec833f6ac3 h1:w0fudd3gZ0TgqEAnfOiYpuDQ5B1CMf8XdbgFtEshO2M=
github.com/charmbracelet/bubbletea v0.26.3-0.20240521190034-5bec833f6ac3/go.mod h1:XggZds/FnG8qLKTAc4DRzqooDc72f94hdsj1Qb2cWfM=
github.com/charmbracelet/keygen v0.5.0 h1:XY0fsoYiCSM9axkrU+2ziE6u6YjJulo/b9Dghnw6MZc=
github.com/charmbracelet/keygen v0.5.0/go.mod h1:DfvCgLHxZ9rJxdK0DGw3C/LkV4SgdGbnliHcObV3L+8=
github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg=
github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I=
github.com/charmbracelet/lipgloss v0.10.1-0.20240515201529-1969fb54fefe h1:2SKkDenRBzWlqbqnk7cseOretWPktJNddvQkvORQxWo=
github.com/charmbracelet/lipgloss v0.10.1-0.20240515201529-1969fb54fefe/go.mod h1:/WJOlugg8bddqSP52FFiGXWVIfXsO+/+KzOGAT7opnw=
github.com/charmbracelet/lipgloss v0.10.1-0.20240524152121-9f57d00c5c27 h1:uT/Ji1RluIWK/wQ8psfloXHxYDn9OjdohVWGSoMpr3U=
github.com/charmbracelet/lipgloss v0.10.1-0.20240524152121-9f57d00c5c27/go.mod h1:/WJOlugg8bddqSP52FFiGXWVIfXsO+/+KzOGAT7opnw=
github.com/charmbracelet/log v0.3.1 h1:TjuY4OBNbxmHWSwO3tosgqs5I3biyY8sQPny/eCMTYw=
github.com/charmbracelet/log v0.3.1/go.mod h1:OR4E1hutLsax3ZKpXbgUqPtTjQfrh1pG3zwHGWuuq8g=
github.com/charmbracelet/log v0.4.1-0.20240524153040-9a6ca188d8b0 h1:pibUnnq7U2/GJqs+AM8jD/QZ2/kb4LxRtAht8q5wJJE=
github.com/charmbracelet/log v0.4.1-0.20240524153040-9a6ca188d8b0/go.mod h1:/yggUvKQs6ok3uz53FgwqVwO/FvxyM6pFWtUj+wJ9XQ=
github.com/charmbracelet/ssh v0.0.0-20240202115812-f4ab1009799a h1:ryXQeBfu7DN77RFiKLa/VA9VRkMsinpkv4qYparR//k=
github.com/charmbracelet/ssh v0.0.0-20240202115812-f4ab1009799a/go.mod h1:GPT/bjXsVDf5TKq2P1n4zl79ZnGwt2lWr19DomWm7zw=
github.com/charmbracelet/wish v1.3.1 h1:HXrHadxu6qbZOfwjEuu2OWpGWuhpKVd26Ecpv+QEc58=
github.com/charmbracelet/wish v1.3.1/go.mod h1:4GbN5YK/Qmip0k/nT+dOuYVpdKgj3oZBnsOeEJlG9fE=
github.com/charmbracelet/x/ansi v0.1.1 h1:CGAduulr6egay/YVbGc8Hsu8deMg1xZ/bkaXTPi1JDk=
github.com/charmbracelet/x/ansi v0.1.1/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651 h1:3RXpZWGWTOeVXCTv0Dnzxdv/MhNUkBfEcbaTY0zrTQI=
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
github.com/charmbracelet/x/exp/term v0.0.0-20240202113029-6ff29cf0473e h1:45T85zTqW/gN3FK5/JFM5Jk+LJkdP2gAfJcg8xE5lBs=
github.com/charmbracelet/x/exp/term v0.0.0-20240202113029-6ff29cf0473e/go.mod h1:8NVO/XlUZbcJU5g0gVE7K1YiNnRFqYA3nZzGS/0lBRk=
github.com/charmbracelet/x/input v0.1.0 h1:TEsGSfZYQyOtp+STIjyBq6tpRaorH0qpwZUj8DavAhQ=
github.com/charmbracelet/x/input v0.1.0/go.mod h1:ZZwaBxPF7IG8gWWzPUVqHEtWhc1+HXJPNuerJGRGZ28=
github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI=
github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw=
github.com/charmbracelet/x/windows v0.1.0 h1:gTaxdvzDM5oMa/I2ZNF7wN78X/atWemG9Wph7Ika2k4=
github.com/charmbracelet/x/windows v0.1.0/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand All @@ -30,6 +48,8 @@ github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/flipperdevices/go-flipper v0.6.0 h1:e9M8anZc7wCi0BJK37MfevYefdfifslHzTV7CEtYrKI=
github.com/flipperdevices/go-flipper v0.6.0/go.mod h1:rXHKrpiUSl2H3NM4lDj4V9P8xR/xTjlfmCWS1W9XUaw=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
Expand All @@ -50,6 +70,8 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/coral v1.0.0 h1:odyqkoEg4aJAINOzvnjN4tUsdp+Zleccs7tRIAkkYzU=
Expand All @@ -71,10 +93,14 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=
github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
go.bug.st/serial v1.6.2 h1:kn9LRX3sdm+WxWKufMlIRndwGfPWsH1/9lCWXQCasq8=
go.bug.st/serial v1.6.2/go.mod h1:UABfsluHAiaNI+La2iESysd9Vetq7VRdpxvjx7CmmOE=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
Expand All @@ -85,10 +111,15 @@ golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
rootCmd.PersistentFlags().StringVar(&rootFlags.fgColor, "fg-color", "#000000", "foreground color")
rootCmd.PersistentFlags().StringVar(&rootFlags.bgColor, "bg-color", "#FF8C00", "background color")

rootCmd.AddCommand(serverCmd, versionCmd, manCmd)
//rootCmd.AddCommand(serverCmd, versionCmd, manCmd)
rootCmd.AddCommand(versionCmd, manCmd)
}

func root(cmd *coral.Command, args []string) {

Check warning on line 42 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint

unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
// parse screenshot resolution
screenshotResolution, err := parseScreenshotResolution()
if err != nil {
Expand Down Expand Up @@ -67,7 +68,7 @@
flipperui.WithBgColor(rootFlags.bgColor),
),
}
if err := tea.NewProgram(m, tea.WithMouseCellMotion()).Start(); err != nil {
if _, err := tea.NewProgram(m, tea.WithMouseCellMotion()).Run(); err != nil {
log.Fatalln(err)
}
}
Expand All @@ -85,7 +86,7 @@
DisableFlagsInUseLine: true,
Hidden: true,
Args: coral.NoArgs,
RunE: func(cmd *coral.Command, args []string) error {

Check warning on line 89 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint

unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive)
manPage, err := mcoral.NewManPage(1, rootCmd)
if err != nil {
return err
Expand All @@ -99,7 +100,7 @@
var versionCmd = &coral.Command{
Use: "version",
Short: "Print the version info",
Run: func(cmd *coral.Command, args []string) {

Check warning on line 103 in main.go

View workflow job for this annotation

GitHub Actions / lint / lint

unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive)
fmt.Printf("Version: %s\n", version.Version)
fmt.Printf("Commit: %s\n", version.Commit)
fmt.Printf("Date: %s\n", version.Date)
Expand Down
14 changes: 8 additions & 6 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ type model struct {
}

// Init is the bubbletea init function.
func (m model) Init() tea.Cmd {
return m.flipper.Init()
func (m model) Init(ctx tea.Context) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
m.flipper, cmd = m.flipper.Init(ctx)
return m, cmd
}

// Update is the bubbletea update function and handles all tea.Msgs.
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m model) Update(ctx tea.Context, msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
Expand All @@ -30,11 +32,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

var cmd tea.Cmd
m.flipper, cmd = m.flipper.Update(msg)
m.flipper, cmd = m.flipper.Update(ctx, msg)
return m, cmd
}

// View is the bubbletea view function.
func (m model) View() string {
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, m.flipper.View())
func (m model) View(ctx tea.Context) string {
return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, m.flipper.View(ctx))
}
20 changes: 2 additions & 18 deletions server.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
package main

import (
"context"
"log"
"os"
"os/signal"
"syscall"
"time"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/ssh"
"github.com/charmbracelet/wish"
bm "github.com/charmbracelet/wish/bubbletea"
lm "github.com/charmbracelet/wish/logging"
"github.com/jon4hz/fztea/flipperui"
"github.com/jon4hz/fztea/recfz"
"github.com/muesli/coral"
)

/*
var serverFlags struct {
listen string
authorizedKeys string
Expand Down Expand Up @@ -108,3 +91,4 @@ func server(cmd *coral.Command, args []string) {
log.Fatalln(err)
}
}
*/
Loading