adapter_bubbletea

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 17 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompletionDebounceMsg added in v0.3.0

type CompletionDebounceMsg struct {
	TriggerChar string
	Timestamp   time.Time
}

type CompletionRequestMsg added in v0.3.0

type CompletionRequestMsg struct {
	Context editor.CompletionContext
}

type CompletionResponseMsg added in v0.3.0

type CompletionResponseMsg struct {
	Completions []editor.Completion
	Context     editor.CompletionContext
}

type CursorMode

type CursorMode int
const (
	CursorSteady CursorMode = iota
	CursorBlink
)

type DeleteFileMsg

type DeleteFileMsg struct{}

type DeleteMsg added in v0.2.0

type DeleteMsg struct {
	Content string
}

type ErrorMsg added in v0.2.0

type ErrorMsg struct {
	ID    editor.ErrorId
	Error error
}

type Model

type Model struct {
	StatusLineFunc func() string
	// contains filtered or unexported fields
}

func New

func New(width, height int) Model

func (*Model) Blur

func (m *Model) Blur()

Blur sets the editor to unfocused state.

func (m *Model) CursorBlink() tea.Cmd

CursorBlink is the main command for the blinking cursor effect (toggling visibility)

func (*Model) DisableCommandMode

func (m *Model) DisableCommandMode(disable bool)

DisableCommandMode allows disabling command mode in the editor. This will disable the command mode functionality, meaning the editor will not respond to command mode keybindings.

func (*Model) DisableInsertMode added in v0.1.16

func (m *Model) DisableInsertMode(disable bool)

DisableInsertMode allows disabling insert mode in the editor. This will disable the insert mode functionality, meaning the editor will not respond to insert mode keybindings and will prevent text modifications.

func (*Model) DisableSearchMode added in v0.2.5

func (m *Model) DisableSearchMode(disable bool)

func (*Model) DisableVimMode

func (m *Model) DisableVimMode(disable bool)

DisableVimMode allows disabling Vim mode in the editor. This will disable all Vim-specific features and revert to a simpler text editor mode. If Vim mode is disabled, the editor will not respond to Vim keybindings.

func (*Model) DisableVisualLineMode added in v0.1.16

func (m *Model) DisableVisualLineMode(disable bool)

DisableVisualLineMode allows disabling visual line mode in the editor. This will disable the visual line mode functionality, meaning the editor will not respond to visual line mode keybindings.

func (*Model) DisableVisualMode added in v0.1.16

func (m *Model) DisableVisualMode(disable bool)

DisableVisualMode allows disabling visual mode in the editor. This will disable the visual mode functionality, meaning the editor will not respond to visual mode keybindings.

func (*Model) DispatchError added in v0.2.0

func (m *Model) DispatchError(err error, duration time.Duration) tea.Cmd

DispatchError allows setting an error to be displayed in the command line for a specified duration.

func (*Model) DispatchMessage added in v0.2.0

func (m *Model) DispatchMessage(message string, duration time.Duration) tea.Cmd

DispatchMessage allows setting a message to be displayed in the command line for a specified duration.

func (*Model) Focus

func (m *Model) Focus()

Focus sets the editor to focused state.

func (*Model) GetCurrentContent

func (m *Model) GetCurrentContent() string

GetCurrentContent returns the current content of the editor buffer. This content may not be saved yet, as it reflects the current state of the editor.

func (Model) GetCursorPosition added in v0.2.8

func (m Model) GetCursorPosition() editor.Position

GetCursorPosition returns the current cursor position in the editor.

func (*Model) GetEditor

func (m *Model) GetEditor() editor.Editor

GetEditor returns the underlying editor instance

func (*Model) GetSavedContent

func (m *Model) GetSavedContent() string

GetSavedContent returns the saved content of the editor buffer This content is what was last saved to disk, and may not reflect the current state of the editor. It is useful for operations that require the last saved state, such as saving to a file.

func (*Model) HasChanges

func (m *Model) HasChanges() bool

HasChanges checks if the editor has unsaved changes

func (*Model) HideLineNumbers

func (m *Model) HideLineNumbers(hide bool)

HideLineNumbers controls whether to show line numbers in the viewport.

func (*Model) HideStatusLine

func (m *Model) HideStatusLine(hide bool)

HideStatusLine controls whether to show the status line at the bottom of the viewport. If Vim mode is disabled, this will not have any effect.

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) IsCommandMode

func (m *Model) IsCommandMode() bool

IsCommandMode returns whether the editor is in command mode.

func (*Model) IsEmpty

func (m *Model) IsEmpty() bool

IsEmpty checks if the editor buffer is empty.

func (*Model) IsFocused

func (m *Model) IsFocused() bool

IsFocused returns whether the editor is currently focused.

func (*Model) IsInsertMode

func (m *Model) IsInsertMode() bool

IsInsertMode returns whether the editor is in insert mode.

func (*Model) IsNormalMode

func (m *Model) IsNormalMode() bool

IsNormalMode returns whether the editor is in normal mode.

func (*Model) IsSearchMode added in v0.2.5

func (m *Model) IsSearchMode() bool

IsSearchMode returns whether the editor is in search mode.

func (*Model) IsVisualLineMode

func (m *Model) IsVisualLineMode() bool

IsVisualLineMode returns whether the editor is in visual line mode.

func (*Model) IsVisualMode

func (m *Model) IsVisualMode() bool

IsVisualMode returns whether the editor is in visual mode.

func (*Model) SetBytes

func (m *Model) SetBytes(content []byte)

SetBytes sets the content of the editor.

func (*Model) SetCommandMode

func (m *Model) SetCommandMode()

SetCommandMode sets the editor to command mode.

func (*Model) SetContent

func (m *Model) SetContent(content string)

SetContent sets the content of the editor from a string.

func (*Model) SetCursorMode

func (m *Model) SetCursorMode(mode CursorMode)

SetCursorMode sets the cursor mode for the editor. It can be either CursorSteady or CursorBlink.

Warning: Enabling CursorBlink may have performance implications.

func (*Model) SetCursorPosition

func (m *Model) SetCursorPosition(row, col int) error

SetCursorPosition sets the cursor position in the editor.

func (*Model) SetCursorPositionEnd

func (m *Model) SetCursorPositionEnd() error

SetCursorPositionEnd sets the cursor position to the end of the editor buffer.

func (*Model) SetExtraHighlightedContextLines added in v0.1.13

func (m *Model) SetExtraHighlightedContextLines(lines uint16)

SetExtraHighlightedContextLines sets the number of extra lines to tokenise around the visible viewport. This is crucial for Markdown where code blocks need context (the opening ```) to highlight correctly.

PERFORMANCE TRADE-OFF: - Higher values: Better syntax highlighting for large code blocks, but slower scrolling - Lower values: Faster scrolling, but code blocks may lose highlighting when scrolling

Recommended values: - Small files (<5000 lines): 100-200 (default is 100) - Large files (5000-20000 lines): 50-100 - Very large files (>20000 lines): 20-50

When scrolling, if the new range overlaps with cached range, no re-tokenisation occurs (fast). When scrolling beyond cached range, the entire new range gets re-tokenised (slow if value is high).

func (*Model) SetHighlightedWords

func (m *Model) SetHighlightedWords(words map[string]lipgloss.Style)

SetHighlightedWords allows setting highlighted words in the editor. These words will be styled with the provided lipgloss styles. This is useful for highlighting specific keywords or phrases in the text.

func (*Model) SetInsertMode

func (m *Model) SetInsertMode()

SetInsertMode sets the editor to insert mode.

func (*Model) SetLanguage added in v0.1.3

func (m *Model) SetLanguage(language string, theme string)

SetLanguage sets the programming language for syntax highlighting.

If the language is empty, syntax highlighting will be disabled.

The theme parameter allows specifying a Chroma theme for the syntax highlighter. For a full list of available themes, see: https://github.com/alecthomas/chroma/blob/master/styles

func (*Model) SetMaxHistory added in v0.1.11

func (m *Model) SetMaxHistory(max uint32)

SetMaxHistory sets the maximum number of history entries for undo/redo. This allows controlling how many undo steps are kept in memory. If set to 0, no history will be kept. The default value is 1000. If the number of history entries exceeds this limit, the oldest entries will be removed. This is useful for managing memory usage in the editor.

func (*Model) SetNormalMode

func (m *Model) SetNormalMode()

SetNormalMode sets the editor to normal mode.

func (*Model) SetPlaceholder

func (m *Model) SetPlaceholder(placeholder string)

SetPlaceholder sets the placeholder text for the editor.

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

func (*Model) SetVisualLineMode

func (m *Model) SetVisualLineMode()

SetVisualLineMode sets the editor to visual line mode.

func (*Model) SetVisualMode

func (m *Model) SetVisualMode()

SetVisualMode sets the editor to visual mode.

func (*Model) ShowRelativeLineNumbers

func (m *Model) ShowRelativeLineNumbers(show bool)

ShowLineNumbers controls whether to show relative line numbers in the viewport. If Vim mode is disabled, this will not have any effect. If line numbers are hidden, this will not have any effect.

func (*Model) ShowTildeIndicator

func (m *Model) ShowTildeIndicator(show bool)

ShowTildeIndicator controls whether to show the tilde indicator in the viewport. If line numbers are hidden, this will not have any effect.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

func (Model) View

func (m Model) View() string

func (*Model) WithAutoTrigger added in v0.3.0

func (m *Model) WithAutoTrigger(enabled bool)

WithAutoTrigger enables or disables auto-trigger completions

func (*Model) WithCompletionDebounce added in v0.3.0

func (m *Model) WithCompletionDebounce(duration time.Duration)

WithCompletionDebounce sets the debounce time for auto-trigger completions

func (*Model) WithSearchInputCursorMode added in v0.2.7

func (m *Model) WithSearchInputCursorMode(mode cursor.Mode)

WithSearchInputCursorMode allows setting the cursor mode for the search input. Default is CursorStatic.

func (*Model) WithSearchOptions added in v0.2.4

func (m *Model) WithSearchOptions(options editor.SearchOptions)

WithSearchOptions allows setting custom search options for the editor.

func (*Model) WithSyntaxHighlighter added in v0.1.3

func (m *Model) WithSyntaxHighlighter(highlighter *highlighter.Highlighter)

WithSyntaxHighlighter allows setting a custom syntax highlighter.

func (*Model) WithTheme

func (m *Model) WithTheme(theme Theme)

WithTheme allows setting a custom theme for the editor.

type PasteMsg added in v0.2.0

type PasteMsg struct {
	Content string
}

type QuitMsg

type QuitMsg struct{}

type RedoMsg added in v0.2.0

type RedoMsg struct {
	ContentBefore string
}

type RelativeNumbersChangeMsg added in v0.2.0

type RelativeNumbersChangeMsg struct {
	Enabled bool
}

type RenameMsg

type RenameMsg struct {
	FileName string
}

type SaveMsg

type SaveMsg struct {
	Path    *string
	Content string
}

type SearchResultsMsg added in v0.2.2

type SearchResultsMsg struct {
	Positions []editor.Position
}

type Theme

type Theme struct {
	NormalModeStyle        lipgloss.Style
	InsertModeStyle        lipgloss.Style
	VisualModeStyle        lipgloss.Style
	CommandModeStyle       lipgloss.Style
	SearchModeStyle        lipgloss.Style
	StatusLineStyle        lipgloss.Style
	CommandLineStyle       lipgloss.Style
	MessageStyle           lipgloss.Style
	LineNumberStyle        lipgloss.Style
	CurrentLineNumberStyle lipgloss.Style
	CurrentLineStyle       lipgloss.Style
	SelectionStyle         lipgloss.Style
	ErrorStyle             lipgloss.Style
	HighlightYankStyle     lipgloss.Style
	PlaceholderStyle       lipgloss.Style

	SearchHighlightStyle   lipgloss.Style
	SearchInputPromptStyle lipgloss.Style
	SearchInputTextStyle   lipgloss.Style
	SearchInputCursorStyle lipgloss.Style

	CompletionMenuItemStyle         lipgloss.Style
	CompletionMenuSelectedItemStyle lipgloss.Style
	CompletionMenuBorderStyle       lipgloss.Style
	CompletionMenuLabelStyle        lipgloss.Style
	CompletionMenuTypeStyle         lipgloss.Style
}

func DefaultTheme

func DefaultTheme(isDark bool) Theme

DefaultTheme creates a theme with adaptive colors based on terminal background.

type UndoMsg added in v0.2.0

type UndoMsg struct {
	ContentBefore string
}

type VisualLineInfo

type VisualLineInfo struct {
	Content         string
	LogicalRow      int
	LogicalStartCol int
	IsFirstSegment  bool
}

type YankMsg added in v0.2.0

type YankMsg struct {
	Content string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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