Documentation ¶
Overview ¶
Package codeview provides a bubbletea component for displaying code. It adds line numbers and makes sure the code fits on the screen. It does not support wrapping long lines; instead, it trims them.
Index ¶
- Variables
- type KeyMap
- type Model
- func (m *Model) FullHelp() [][]key.Binding
- func (m *Model) Height() int
- func (m *Model) SetContent(lines []string)
- func (m *Model) SetFilteredLines(filteredLines []int)
- func (m *Model) SetHeight(height int)
- func (m *Model) SetShowFullHelp(showFullHelp bool)
- func (m *Model) SetShowHelp(showHelp bool)
- func (m *Model) SetTitle(title string)
- func (m *Model) SetWidth(width int)
- func (m *Model) ShortHelp() []key.Binding
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m *Model) View() string
- func (m *Model) Width() int
Constants ¶
This section is empty.
Variables ¶
var DefaultKeyMap = KeyMap{ Up: key.NewBinding( key.WithKeys("up", "k"), key.WithHelp("↑/k", "up"), ), Down: key.NewBinding( key.WithKeys("down", "j"), key.WithHelp("↓/j", "down"), ), Home: key.NewBinding( key.WithKeys("home", "g"), key.WithHelp("g/home", "top"), ), End: key.NewBinding( key.WithKeys("end", "G"), key.WithHelp("G/end", "bottom"), ), Back: key.NewBinding( key.WithKeys("esc"), key.WithHelp("esc", "back"), ), Quit: key.NewBinding( key.WithKeys("q", "ctrl+c"), key.WithHelp("q", "quit"), ), HalfScreenDown: key.NewBinding( key.WithKeys("d"), key.WithHelp("d", "half screen down"), ), HalfScreenUp: key.NewBinding( key.WithKeys("u"), key.WithHelp("u", "half screen down"), ), }
DefaultKeyMap is the default KeyMap used by codeview package.
Functions ¶
This section is empty.
Types ¶
type KeyMap ¶
type KeyMap struct { Up key.Binding Down key.Binding Home key.Binding End key.Binding Back key.Binding Quit key.Binding HalfScreenDown key.Binding HalfScreenUp key.Binding }
KeyMap includes codeview key mappings.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the codeview model. Use New to create a new instance.
func (*Model) SetContent ¶
SetContent sets the content of the codeview.
func (*Model) SetFilteredLines ¶ added in v0.5.0
SetFilteredLines sets the lines that should be displayed, while all other lines are hidden. If not set, everything is displayed.
func (*Model) SetShowFullHelp ¶
SetShowFullHelp allows to view extended help section, if visible.
func (*Model) SetShowHelp ¶
SetShowHelp allows to hide or show the help section.