glow/ui/editor.go
Carlos Alexandro Becker c991ec475d
feat: use x/editor (#543)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2023-11-17 09:02:52 -03:00

22 lines
406 B
Go

package ui
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/x/editor"
)
type editorFinishedMsg struct{ err error }
func openEditor(path string) tea.Cmd {
cb := func(err error) tea.Msg {
return editorFinishedMsg{err}
}
editor, err := editor.Cmd("Glow", path)
if err != nil {
return func() tea.Msg {
return errMsg{err}
}
}
return tea.ExecProcess(editor, cb)
}