Help us shape the future of Go! Take the 2026 Go Developer Survey

editor

package
v0.244.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloseViewerMsg

type CloseViewerMsg struct {
	Path string
}

CloseViewerMsg is emitted when the viewer should be closed.

type EditableKeyMap

type EditableKeyMap struct {
	Up        key.Binding
	Down      key.Binding
	Left      key.Binding
	Right     key.Binding
	LineStart key.Binding
	LineEnd   key.Binding
	PageUp    key.Binding
	PageDown  key.Binding
	FileStart key.Binding
	FileEnd   key.Binding
	Save      key.Binding
	// Selection (shift variants)
	SelectUp        key.Binding
	SelectDown      key.Binding
	SelectLeft      key.Binding
	SelectRight     key.Binding
	SelectLineStart key.Binding
	SelectLineEnd   key.Binding
	SelectAll       key.Binding
	// Clipboard
	Copy           key.Binding
	Paste          key.Binding
	PasteClipboard key.Binding
	// Multicursor (Micro-style)
	AddCursorUp   key.Binding
	AddCursorDown key.Binding
	// Exit edit mode
	ExitEditMode key.Binding
	// Toggle word wrap
	ToggleWordWrap key.Binding
}

EditableKeyMap defines keybindings for the editable file editor.

func DefaultEditableKeyMap

func DefaultEditableKeyMap() EditableKeyMap

DefaultEditableKeyMap returns the default keybindings for the editable component.

type ExitEditModeMsg added in v0.5.0

type ExitEditModeMsg struct {
	Path string
}

ExitEditModeMsg is emitted when the user presses Esc in edit mode to return to view mode.

type FileEditDirtyMsg

type FileEditDirtyMsg struct {
	Path  string
	Dirty bool
}

FileEditDirtyMsg is emitted when the editable file's dirty state changes.

type FileEditSavedMsg

type FileEditSavedMsg struct {
	Path string
}

FileEditSavedMsg is emitted after a file is successfully saved.

type FileEditableComponent

type FileEditableComponent interface {
	tea.Model
	layout.Sizeable
	layout.Bindings
	OpenFile(path string) tea.Cmd
	FilePath() string
	IsDirty() bool
}

FileEditableComponent is the editable file editor used by the editor area.

func NewFileEditor

func NewFileEditor() FileEditableComponent

NewFileEditor creates a new editable file component.

type FileViewerComponent

type FileViewerComponent interface {
	tea.Model
	layout.Sizeable
	layout.Bindings
	OpenFile(path string) tea.Cmd
	FilePath() string
}

FileViewerComponent is the read-only file viewer used by the editor area.

func NewFileViewer

func NewFileViewer() FileViewerComponent

NewFileViewer creates a new read-only file viewer component.

type Highlighter

type Highlighter struct {
	// contains filtered or unexported fields
}

Highlighter provides reusable chroma-based syntax highlighting for TUI code views.

func New

func New(theme tuitheme.Theme) *Highlighter

New creates a highlighter using the provided Pando theme.

func (*Highlighter) Highlight

func (h *Highlighter) Highlight(source, fileName string) (string, error)

Highlight applies syntax highlighting to a full source buffer.

func (*Highlighter) HighlightLine

func (h *Highlighter) HighlightLine(line, fileName string) string

HighlightLine applies syntax highlighting to a single line. If highlighting fails, the original line is returned unchanged.

func (*Highlighter) HighlightLines

func (h *Highlighter) HighlightLines(source, fileName string) []string

HighlightLines returns the highlighted source split into per-line strings. If highlighting fails, the original unhighlighted lines are returned.

func (*Highlighter) HighlightSnippet

func (h *Highlighter) HighlightSnippet(source, language string) (string, error)

HighlightSnippet applies syntax highlighting to a code block using the declared language when available, falling back to automatic detection.

type OpenEditableFileMsg

type OpenEditableFileMsg struct {
	Path string
}

OpenEditableFileMsg requests that a file be opened in editable mode.

type Tab

type Tab struct {
	Path       string
	Name       string
	Dirty      bool
	Icon       string
	IsEditable bool // true when the tab should be opened in editable mode
}

Tab represents a file opened in the editor area.

type TabBar

type TabBar struct {
	// contains filtered or unexported fields
}

TabBar keeps track of open files and renders the compact one-line tab strip.

func NewTabBar

func NewTabBar() *TabBar

NewTabBar creates a new tab bar with default keybindings.

func (*TabBar) ActivePath

func (t *TabBar) ActivePath() string

ActivePath returns the active tab path or an empty string when none is selected.

func (*TabBar) ActiveTab

func (t *TabBar) ActiveTab() *Tab

ActiveTab returns the active tab, if any.

func (*TabBar) BindingKeys

func (t *TabBar) BindingKeys() []key.Binding

BindingKeys returns the keybindings handled by the tab bar.

func (*TabBar) CloseActiveTab

func (t *TabBar) CloseActiveTab()

CloseActiveTab closes the currently focused tab.

func (*TabBar) CloseTab

func (t *TabBar) CloseTab(index int)

CloseTab closes the tab at index and keeps the active selection in range.

func (*TabBar) Count

func (t *TabBar) Count() int

Count returns the number of open tabs.

func (*TabBar) IsActiveEditable

func (t *TabBar) IsActiveEditable() bool

IsActiveEditable returns true when the active tab is in editable mode.

func (*TabBar) NextTab

func (t *TabBar) NextTab()

NextTab focuses the next tab, wrapping around.

func (*TabBar) OpenEditableTab

func (t *TabBar) OpenEditableTab(path string) int

OpenEditableTab opens a new editable tab or focuses an existing one, returning its index.

func (*TabBar) OpenTab

func (t *TabBar) OpenTab(path string) int

OpenTab opens a new tab or focuses an existing one, returning its index.

func (*TabBar) PrevTab

func (t *TabBar) PrevTab()

PrevTab focuses the previous tab, wrapping around.

func (*TabBar) SetActiveEditable added in v0.5.0

func (t *TabBar) SetActiveEditable(editable bool)

SetActiveEditable switches the active tab between editable and view-only mode.

func (*TabBar) SetDirty

func (t *TabBar) SetDirty(path string, dirty bool)

SetDirty updates the dirty state for the tab identified by path.

func (*TabBar) SetSize

func (t *TabBar) SetSize(width int)

SetSize stores the available width so the bar can apply overflow rules.

func (*TabBar) Update

func (t *TabBar) Update(msg tea.Msg) (*TabBar, tea.Cmd)

Update applies tab-specific keybindings.

func (*TabBar) View

func (t *TabBar) View() string

View renders the one-line tab bar.

type TabKeyMap

type TabKeyMap struct {
	Close key.Binding
	Next  key.Binding
	Prev  key.Binding
}

TabKeyMap defines the keybindings handled by the tab bar.

type ViewerKeyMap

type ViewerKeyMap struct {
	Down           key.Binding
	Up             key.Binding
	HalfPageDown   key.Binding
	HalfPageUp     key.Binding
	Top            key.Binding
	Bottom         key.Binding
	Search         key.Binding
	SearchNext     key.Binding
	SearchPrev     key.Binding
	CancelSearch   key.Binding
	Close          key.Binding
	ToggleWordWrap key.Binding
}

ViewerKeyMap defines the keybindings for the file viewer component.

func DefaultViewerKeyMap

func DefaultViewerKeyMap() ViewerKeyMap

DefaultViewerKeyMap returns the default keybindings for the file viewer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL