Documentation
¶
Overview ¶
Package editor provides UI components for code viewing and editing in the TUI. This file contains the diff viewer with line-by-line coloring. Uses the shared diff package for parsing and common functionality.
Package editor provides UI components for code viewing and editing in the TUI. This file contains the main Editor component for displaying code with syntax highlighting.
Package editor provides UI components for code viewing and editing in the TUI. This file contains syntax highlighting functionality using chroma.
Package editor provides UI components for code viewing and editing in the TUI. This file contains the TextArea component for text input with theme support.
Index ¶
- Variables
- func GetSupportedLanguages() []string
- func Highlight(code string, language string) string
- func HighlightWithFilename(code string, language string, filename string) string
- func ParseUnifiedDiff(diffContent string) []diff.DiffHunk
- type DiffViewer
- func (dv *DiffViewer) Focused() bool
- func (dv *DiffViewer) Init() tea.Cmd
- func (dv *DiffViewer) Render(diffContent string) string
- func (dv *DiffViewer) RenderSimple(diffContent string) string
- func (dv *DiffViewer) SetDiffContent(content string) string
- func (dv *DiffViewer) SetFocused(focused bool)
- func (dv *DiffViewer) SetSize(width, height int)
- func (dv *DiffViewer) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (dv *DiffViewer) View() string
- type Editor
- func (e *Editor) Focused() bool
- func (e *Editor) GetContent() string
- func (e *Editor) Init() tea.Cmd
- func (e *Editor) Render() string
- func (e *Editor) RenderSimple() string
- func (e *Editor) SetContent(content string)
- func (e *Editor) SetFilename(filename string)
- func (e *Editor) SetFocused(focused bool)
- func (e *Editor) SetLanguage(language string)
- func (e *Editor) SetRect(rect layout.Rect)
- func (e *Editor) SetShowLineNumbers(show bool)
- func (e *Editor) SetSize(width, height int)
- func (e *Editor) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (e *Editor) View() string
- type TextArea
- func (t *TextArea) Focused() bool
- func (t *TextArea) GetKeyBindings() []key.Binding
- func (t *TextArea) Init() tea.Cmd
- func (t *TextArea) Reset()
- func (t *TextArea) SetFocused(focused bool)
- func (t *TextArea) SetRect(rect layout.Rect)
- func (t *TextArea) SetSize(width, height int)
- func (t *TextArea) SetValue(value string)
- func (t *TextArea) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (t *TextArea) Value() string
- func (t *TextArea) View() string
- type TextAreaKeyMaps
Constants ¶
This section is empty.
Variables ¶
var DefaultTextAreaKeyMaps = TextAreaKeyMaps{ Send: key.NewBinding( key.WithKeys("enter", "ctrl+s"), key.WithHelp("enter", "submit"), ), OpenExternalEditor: key.NewBinding( key.WithKeys("ctrl+e"), key.WithHelp("ctrl+e", "open editor"), ), }
DefaultTextAreaKeyMaps returns the default key bindings for text area.
Functions ¶
func GetSupportedLanguages ¶
func GetSupportedLanguages() []string
GetSupportedLanguages returns a list of supported language identifiers.
func Highlight ¶
Highlight highlights the given code with syntax highlighting using chroma. It takes the code content and an optional language identifier. If language is empty, it will attempt to detect the language from the filename.
func HighlightWithFilename ¶
HighlightWithFilename highlights the given code with syntax highlighting. It uses the filename to detect the language if language is not specified.
func ParseUnifiedDiff ¶
ParseUnifiedDiff parses a unified diff string into structured DiffHunks. This is a wrapper that delegates to the shared diff package.
Types ¶
type DiffViewer ¶
DiffViewer is a wrapper around the shared diff.Viewer for the editor component. It provides tea.Model interface compatibility.
func NewDiffViewer ¶
func NewDiffViewer() *DiffViewer
NewDiffViewer creates a new diff viewer component.
func (*DiffViewer) Focused ¶
func (dv *DiffViewer) Focused() bool
Focused returns whether the diff viewer is focused.
func (*DiffViewer) Render ¶
func (dv *DiffViewer) Render(diffContent string) string
Render renders the diff viewer and returns the formatted string.
func (*DiffViewer) RenderSimple ¶
func (dv *DiffViewer) RenderSimple(diffContent string) string
RenderSimple renders a diff without borders, useful for inline display.
func (*DiffViewer) SetDiffContent ¶
func (dv *DiffViewer) SetDiffContent(content string) string
SetDiffContent sets the diff content to display.
func (*DiffViewer) SetFocused ¶
func (dv *DiffViewer) SetFocused(focused bool)
SetFocused sets the focused state of the diff viewer.
func (*DiffViewer) SetSize ¶
func (dv *DiffViewer) SetSize(width, height int)
SetSize sets the dimensions of the diff viewer.
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor is a component for viewing code with syntax highlighting.
func EditorFromFile ¶
EditorFromFile creates an editor component from file content.
func EditorWithLanguage ¶
EditorWithLanguage creates an editor component with explicit language.
func NewEditorWithContent ¶
NewEditorWithContent creates a new editor component with the given content.
func (*Editor) GetContent ¶
GetContent returns the content of the editor.
func (*Editor) RenderSimple ¶
RenderSimple renders the editor without borders.
func (*Editor) SetContent ¶
SetContent sets the content of the editor.
func (*Editor) SetFilename ¶
SetFilename sets the filename for language detection.
func (*Editor) SetFocused ¶
SetFocused sets the focused state of the editor.
func (*Editor) SetLanguage ¶
SetLanguage sets the language for syntax highlighting.
func (*Editor) SetShowLineNumbers ¶
SetShowLineNumbers sets whether to show line numbers.
type TextArea ¶
type TextArea struct {
// contains filtered or unexported fields
}
TextArea is a component for text input with theme support.
func NewTextAreaWithDimensions ¶
NewTextAreaWithDimensions creates a new text area with given dimensions.
func TextAreaWithContent ¶
TextAreaWithContent creates a text area with initial content.
func (*TextArea) GetKeyBindings ¶
GetKeyBindings returns the key bindings for this component.
func (*TextArea) SetFocused ¶
SetFocused sets the focused state.