mirror of
https://github.com/charmbracelet/glow
synced 2024-12-14 06:02:27 +00:00
597e56bad4
closes #547
19 lines
435 B
Go
19 lines
435 B
Go
package ui
|
|
|
|
import (
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
"github.com/charmbracelet/x/editor"
|
|
)
|
|
|
|
type editorFinishedMsg struct{ err error }
|
|
|
|
func openEditor(path string, lineno int) tea.Cmd {
|
|
cb := func(err error) tea.Msg {
|
|
return editorFinishedMsg{err}
|
|
}
|
|
cmd, err := editor.Cmd("Glow", path, editor.OpenAtLine(uint(lineno)))
|
|
if err != nil {
|
|
return func() tea.Msg { return cb(err) }
|
|
}
|
|
return tea.ExecProcess(cmd, cb)
|
|
}
|