2022-07-15 02:53:13 +00:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
2023-11-17 12:02:52 +00:00
|
|
|
"github.com/charmbracelet/x/editor"
|
2022-07-15 02:53:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type editorFinishedMsg struct{ err error }
|
|
|
|
|
2024-07-09 19:38:32 +00:00
|
|
|
func openEditor(path string, lineno int) tea.Cmd {
|
2022-07-15 02:53:13 +00:00
|
|
|
cb := func(err error) tea.Msg {
|
|
|
|
return editorFinishedMsg{err}
|
|
|
|
}
|
2024-07-09 19:38:32 +00:00
|
|
|
cmd, err := editor.Cmd("Glow", path, editor.OpenAtLine(uint(lineno)))
|
2023-08-28 12:05:12 +00:00
|
|
|
if err != nil {
|
2024-07-03 15:11:29 +00:00
|
|
|
return func() tea.Msg { return cb(err) }
|
2023-08-28 12:05:12 +00:00
|
|
|
}
|
2024-07-03 15:11:29 +00:00
|
|
|
return tea.ExecProcess(cmd, cb)
|
2022-07-15 02:53:13 +00:00
|
|
|
}
|