mirror of
https://github.com/charmbracelet/glow
synced 2024-11-13 23:47:06 +00:00
c991ec475d
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
22 lines
406 B
Go
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)
|
|
}
|