ui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UseTrueColor = true

UseTrueColor controls whether hex colors use true color (24-bit) or fall back to the nearest 256-color. Set to false for older terminals.

Functions

func ColorToANSI

func ColorToANSI(fg, bg string) string

ColorToANSI returns combined fg+bg ANSI sequence

func ColorToANSIBg

func ColorToANSIBg(color string) string

ColorToANSIBg converts a theme color string to an ANSI background escape sequence

func ColorToANSIFg

func ColorToANSIFg(color string) string

ColorToANSIFg converts a theme color string to an ANSI foreground escape sequence Supports: "0"-"255" for indexed colors, "#RGB" or "#RRGGBB" for hex colors Hex colors use true color if UseTrueColor is true, otherwise nearest 256-color

func MinimapWidth added in v0.2.0

func MinimapWidth() int

MinimapWidth returns the standard width for the minimap column.

Types

type Column added in v0.2.0

type Column struct {
	Width    int            // Fixed width in cells (0 if flexible)
	Flexible bool           // If true, this column takes remaining space
	Enabled  bool           // Whether this column is currently shown
	Renderer ColumnRenderer // The renderer for this column
}

Column represents a single column in the compositor layout.

type ColumnRenderer added in v0.2.0

type ColumnRenderer interface {
	// Render returns exactly `height` rows, each with exactly `width` visual characters.
	// ANSI codes don't count toward width - only visible characters do.
	Render(width, height int, state *RenderState) []string
}

ColumnRenderer is the interface that column renderers must implement. Each renderer produces exactly `width` visual characters per row.

type Compositor added in v0.2.0

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

Compositor joins multiple columns horizontally to produce the final viewport output.

func NewCompositor added in v0.2.0

func NewCompositor(width, height int) *Compositor

NewCompositor creates a new compositor with the given dimensions.

func (*Compositor) AddColumn added in v0.2.0

func (c *Compositor) AddColumn(col Column)

AddColumn adds a column to the compositor.

func (*Compositor) EnableColumn added in v0.2.0

func (c *Compositor) EnableColumn(index int, enabled bool)

EnableColumn enables or disables a column by index.

func (*Compositor) FlexibleColumnWidth added in v0.2.0

func (c *Compositor) FlexibleColumnWidth() int

FlexibleColumnWidth returns the calculated width of the flexible column. This is useful for external code that needs to know the text area width.

func (*Compositor) GetColumns added in v0.2.0

func (c *Compositor) GetColumns() []Column

GetColumns returns a copy of the current columns.

func (*Compositor) Height added in v0.2.0

func (c *Compositor) Height() int

Height returns the compositor height.

func (*Compositor) Render added in v0.2.0

func (c *Compositor) Render(state *RenderState) string

Render renders all enabled columns and joins them horizontally.

func (*Compositor) SetColumns added in v0.2.0

func (c *Compositor) SetColumns(cols []Column)

SetColumns replaces all columns.

func (*Compositor) SetSize added in v0.2.0

func (c *Compositor) SetSize(width, height int)

SetSize updates the compositor dimensions.

func (*Compositor) Width added in v0.2.0

func (c *Compositor) Width() int

Width returns the compositor width.

type KittyMinimapRenderer added in v0.2.0

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

KittyMinimapRenderer renders a pixel-based minimap using Kitty graphics protocol. This provides a VSCode-like minimap with syntax highlighting colors.

Kitty graphics protocol reference: https://sw.kovidgoyal.net/kitty/graphics-protocol/

Design (VSCode-style):

  • Each source character = 1 pixel wide
  • Each source line = 2 pixels tall (for readability)
  • Syntax highlighting colors preserved from the highlighter
  • Viewport indicator = dark gray semi-transparent overlay on visible region
  • Maximum 120 characters width shown (truncated, not scaled)

func NewKittyMinimapRenderer added in v0.2.0

func NewKittyMinimapRenderer(styles Styles, useKitty bool) *KittyMinimapRenderer

NewKittyMinimapRenderer creates a new Kitty graphics minimap renderer.

func (*KittyMinimapRenderer) ClearImage added in v0.2.0

func (r *KittyMinimapRenderer) ClearImage() string

ClearImage sends a Kitty graphics command to delete the minimap image. This should be called when disabling the minimap or exiting.

func (*KittyMinimapRenderer) GetKittySequence added in v0.2.0

func (r *KittyMinimapRenderer) GetKittySequence(width, height, xOffset, yOffset int, state *RenderState) string

GetKittySequence returns the Kitty graphics escape sequence to render the minimap. This should be appended to the View() output AFTER all normal rendering, with cursor positioning to place it at the minimap column location. Returns empty string if Kitty graphics is not enabled.

func (*KittyMinimapRenderer) GetMetrics added in v0.2.0

func (r *KittyMinimapRenderer) GetMetrics(viewportHeight int, state *RenderState) MinimapMetrics

GetMetrics calculates minimap metrics for mouse interaction.

func (*KittyMinimapRenderer) IsEnabled added in v0.2.0

func (r *KittyMinimapRenderer) IsEnabled() bool

IsEnabled returns whether the minimap is enabled.

func (*KittyMinimapRenderer) Render added in v0.2.0

func (r *KittyMinimapRenderer) Render(width, height int, state *RenderState) []string

Render implements ColumnRenderer. Returns blank spaces for the column area. The actual Kitty graphics is rendered separately via GetKittySequence() and appended to View() output.

func (*KittyMinimapRenderer) RowToVisualLine added in v0.2.0

func (r *KittyMinimapRenderer) RowToVisualLine(row int, metrics MinimapMetrics) int

RowToVisualLine converts a minimap row click to a visual line index.

func (*KittyMinimapRenderer) SetEnabled added in v0.2.0

func (r *KittyMinimapRenderer) SetEnabled(enabled bool)

SetEnabled enables or disables the minimap.

func (*KittyMinimapRenderer) SetLineColorFunc added in v0.2.0

func (r *KittyMinimapRenderer) SetLineColorFunc(fn func(line string) []syntax.ColorSpan)

SetLineColorFunc sets the callback for getting syntax colors for a line.

func (*KittyMinimapRenderer) SetStyles added in v0.2.0

func (r *KittyMinimapRenderer) SetStyles(styles Styles)

SetStyles updates the styles for runtime theme changes.

func (*KittyMinimapRenderer) SetUseKitty added in v0.2.0

func (r *KittyMinimapRenderer) SetUseKitty(useKitty bool)

SetUseKitty enables or disables Kitty graphics mode.

func (*KittyMinimapRenderer) Toggle added in v0.2.0

func (r *KittyMinimapRenderer) Toggle() bool

Toggle toggles the minimap on/off.

func (*KittyMinimapRenderer) UseKitty added in v0.2.0

func (r *KittyMinimapRenderer) UseKitty() bool

UseKitty returns whether Kitty graphics mode is active.

type LineNumberRenderer added in v0.2.0

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

LineNumberRenderer renders line numbers in a column. Standard width is 5 (4 digits + 1 space separator).

func NewLineNumberRenderer added in v0.2.0

func NewLineNumberRenderer(styles Styles) *LineNumberRenderer

NewLineNumberRenderer creates a new line number renderer.

func (*LineNumberRenderer) Render added in v0.2.0

func (r *LineNumberRenderer) Render(width, height int, state *RenderState) []string

Render implements ColumnRenderer. Returns line numbers for visible lines, with the cursor line highlighted.

func (*LineNumberRenderer) SetStyles added in v0.2.0

func (r *LineNumberRenderer) SetStyles(styles Styles)

SetStyles updates the styles for runtime theme changes.

type Menu struct {
	Label string
	Items []MenuItem
}

Menu represents a dropdown menu

type MenuAction int

MenuAction represents an action triggered by a menu item

const (
	ActionNone MenuAction = iota
	// File menu
	ActionNew
	ActionOpen
	ActionRecentFiles
	ActionRecentDirs
	ActionClose
	ActionSave
	ActionSaveAs
	ActionRevert
	ActionSetEncoding // Opens encoding selection dialog
	ActionExit
	// Edit menu
	ActionUndo
	ActionRedo
	ActionCut
	ActionCopy
	ActionPaste
	ActionCutLine
	ActionSelectAll
	// Search menu
	ActionFind
	ActionFindNext
	ActionReplace
	ActionGoToLine
	// Options menu
	ActionWordWrap
	ActionLineNumbers
	ActionSyntaxHighlight
	ActionScrollbar   // Toggle scrollbar
	ActionMinimap     // Toggle minimap
	ActionTheme       // Opens theme selection dialog
	ActionKeybindings // Opens keybindings dialog
	ActionSettings    // Opens settings dialog
	// Buffers menu
	ActionBuffer1
	ActionBuffer2
	ActionBuffer3
	ActionBuffer4
	ActionBuffer5
	ActionBuffer6
	ActionBuffer7
	ActionBuffer8
	ActionBuffer9
	ActionBuffer10
	ActionBuffer11
	ActionBuffer12
	ActionBuffer13
	ActionBuffer14
	ActionBuffer15
	ActionBuffer16
	ActionBuffer17
	ActionBuffer18
	ActionBuffer19
	ActionBuffer20
	// Help menu
	ActionHelp
	ActionAbout
)
type MenuBar struct {
	// contains filtered or unexported fields
}

MenuBar represents the top menu bar

func NewMenuBar

func NewMenuBar(styles Styles) *MenuBar

NewMenuBar creates a new menu bar with default menus

func (m *MenuBar) Close()

Close closes any open menu

func (m *MenuBar) DropdownHeight() int

DropdownHeight returns just the dropdown height (excluding the menu bar)

func (m *MenuBar) HandleClick(x, y int) (bool, MenuAction)

HandleClick handles a click at the given x position in the menu bar Returns true if the click was handled

func (m *MenuBar) Height() int

Height returns the total height (menu bar + dropdown if open)

func (m *MenuBar) IsOpen() bool

IsOpen returns true if a menu dropdown is open

func (m *MenuBar) NextItem()

NextItem moves to the next item in the current menu

func (m *MenuBar) NextMenu()

NextMenu moves to the next menu

func (m *MenuBar) OpenMenu(index int)

OpenMenu opens the menu at the given index

func (m *MenuBar) PrevItem()

PrevItem moves to the previous item in the current menu

func (m *MenuBar) PrevMenu()

PrevMenu moves to the previous menu

func (m *MenuBar) RenderDropdown() ([]string, int)

RenderDropdown renders the dropdown menu as separate lines for overlay Returns the lines and the horizontal offset where the dropdown starts

func (m *MenuBar) Select() MenuAction

Select returns the action of the currently selected item and closes the menu

func (m *MenuBar) SelectByHotKey(key rune) MenuAction

SelectByHotKey finds an item by hotkey in the current menu and returns its action Returns ActionNone if no match or menu is not open

func (m *MenuBar) SetBuffers(names []string, activeIdx int)

SetBuffers updates the Buffers menu with current open buffers names is a list of buffer display names, activeIdx is the currently active buffer

func (m *MenuBar) SetItemDisabled(action MenuAction, disabled bool)

SetItemDisabled sets the disabled state of a menu item by action

func (m *MenuBar) SetItemLabel(action MenuAction, label string)

SetItemLabel sets the label of a menu item by action

func (m *MenuBar) SetStyles(styles Styles)

SetStyles updates the styles for runtime theme changes

func (m *MenuBar) SetWidth(width int)

SetWidth sets the width of the menu bar

func (m *MenuBar) Toggle(index int)

Toggle toggles the menu at the given index

func (m *MenuBar) UpdateShortcuts(kb *config.KeybindingsConfig)

UpdateShortcuts updates menu item shortcuts from keybindings config. This should be called after creating the menubar to reflect user's keybindings.

func (m *MenuBar) View() string

View renders the menu bar (just the bar, not the dropdown)

type MenuItem struct {
	Label    string
	Shortcut string // Keyboard shortcut displayed (e.g., "Ctrl+S")
	HotKey   rune   // Single letter hotkey when menu is open (e.g., 'S')
	Action   MenuAction
	Disabled bool
}

MenuItem represents a single menu option

type MinimapController added in v0.2.0

type MinimapController interface {
	ColumnRenderer
	SetStyles(styles Styles)
	SetEnabled(enabled bool)
	IsEnabled() bool
	Toggle() bool
	GetMetrics(viewportHeight int, state *RenderState) MinimapMetrics
	RowToVisualLine(row int, metrics MinimapMetrics) int
	ClearImage() string                                                              // Returns escape sequence to clear graphics (Kitty only, empty for braille)
	GetKittySequence(width, height, xOffset, yOffset int, state *RenderState) string // Kitty graphics overlay
}

MinimapController is an interface for minimap renderers. Both the braille-based MinimapRenderer and KittyMinimapRenderer implement this.

type MinimapMetrics added in v0.2.0

type MinimapMetrics struct {
	TotalVisualLines    int // Total visual lines in document
	MinimapHeight       int // Height of minimap in rows (ceil(visual lines / 4))
	MinimapScrollOffset int // Current scroll offset of minimap view
	ViewportHeight      int // Height of viewport
}

MinimapMetrics holds metrics for mouse interaction with minimap.

type MinimapRenderer added in v0.2.0

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

MinimapRenderer renders a braille-based minimap of the document. Standard width is 8 (1 viewport indicator + 6 braille chars + 1 space).

=== MINIMAP SPECIFICATION (TODO: implement) ===

Vertical mapping:

  • 1 braille dot row = 1 visual line (respects word wrap)
  • Each braille character = 4 visual lines (braille has 4 dot rows)
  • Minimap height = ceil(total visual lines / 4)
  • Minimap may be shorter or taller than viewport - not scaled to fit

Horizontal mapping:

  • 1 braille dot column = 5 source characters
  • Each braille character = 10 source characters (2 dot columns × 5 chars)
  • 6 braille characters = 60 source characters max
  • Lines longer than 60 chars are truncated (not scaled)

Fill logic:

  • A dot is ON if there are >= 3 non-whitespace characters in that 5-character span (i.e., less than 2 char widths of whitespace)

Viewport indicator:

  • Option A: Current vertical bar │ on left side
  • Option B: Reverse video on braille chars within viewport range

Mouse interaction:

  • Clicking on minimap navigates viewport to that location

func NewMinimapRenderer added in v0.2.0

func NewMinimapRenderer(styles Styles) *MinimapRenderer

NewMinimapRenderer creates a new minimap renderer.

func (*MinimapRenderer) ClearImage added in v0.2.0

func (r *MinimapRenderer) ClearImage() string

ClearImage returns an empty string for braille renderer (no graphics to clear).

func (*MinimapRenderer) GetKittySequence added in v0.2.0

func (r *MinimapRenderer) GetKittySequence(width, height, xOffset, yOffset int, state *RenderState) string

GetKittySequence returns empty for braille renderer (no Kitty graphics).

func (*MinimapRenderer) GetMetrics added in v0.2.0

func (r *MinimapRenderer) GetMetrics(viewportHeight int, state *RenderState) MinimapMetrics

GetMetrics calculates minimap metrics for a given state.

func (*MinimapRenderer) IsEnabled added in v0.2.0

func (r *MinimapRenderer) IsEnabled() bool

IsEnabled returns whether the minimap is enabled.

func (*MinimapRenderer) Render added in v0.2.0

func (r *MinimapRenderer) Render(width, height int, state *RenderState) []string

Render implements ColumnRenderer. Returns braille representation of the document with viewport indicator.

func (*MinimapRenderer) RowToVisualLine added in v0.2.0

func (r *MinimapRenderer) RowToVisualLine(row int, metrics MinimapMetrics) int

RowToVisualLine converts a minimap row click to a visual line index. The row is relative to the viewport (0 = top of visible minimap area).

func (*MinimapRenderer) SetEnabled added in v0.2.0

func (r *MinimapRenderer) SetEnabled(enabled bool)

SetEnabled enables or disables the minimap.

func (*MinimapRenderer) SetStyles added in v0.2.0

func (r *MinimapRenderer) SetStyles(styles Styles)

SetStyles updates the styles for runtime theme changes.

func (*MinimapRenderer) Toggle added in v0.2.0

func (r *MinimapRenderer) Toggle() bool

Toggle toggles the minimap on/off.

type RenderState added in v0.2.0

type RenderState struct {
	// Document content
	Lines []string // All lines in the document

	// Cursor position
	CursorLine int
	CursorCol  int

	// Scroll position
	ScrollY int // First visible line (visual line for word wrap)
	ScrollX int // Horizontal scroll offset

	// Selection state (map of line index to selection range)
	Selection map[int]SelectionRange

	// Syntax highlighting (map of line index to color spans)
	LineColors map[int][]syntax.ColorSpan

	// Display options
	WordWrap bool
	TabWidth int // Display width of tabs

	// Total document metrics (used by scrollbar, minimap)
	TotalLines       int // Total buffer lines
	TotalVisualLines int // Total visual lines (with word wrap)

	// Styles for rendering
	Styles Styles
}

RenderState holds shared state passed to all column renderers. This allows columns to render consistently without direct coupling.

type Scrollbar

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

Scrollbar represents a vertical scrollbar displayed on the right side of the editor

func NewScrollbar

func NewScrollbar(styles Styles) *Scrollbar

NewScrollbar creates a new scrollbar instance

func (*Scrollbar) Height

func (s *Scrollbar) Height() int

Height returns the scrollbar height

func (*Scrollbar) IsEnabled

func (s *Scrollbar) IsEnabled() bool

IsEnabled returns whether the scrollbar is enabled

func (*Scrollbar) Render

func (s *Scrollbar) Render(viewportStart, viewportHeight, totalLines int) []string

Render renders the scrollbar as a slice of strings, one per viewport row viewportStart is the first visible line, viewportHeight is the number of visible lines, totalLines is the total number of lines in the document

func (*Scrollbar) RowToLine

func (s *Scrollbar) RowToLine(row int, totalLines, viewportHeight int) int

RowToLine converts a scrollbar row to the corresponding visual line index This is consistent with the thumb position calculation in Render

func (*Scrollbar) SetEnabled

func (s *Scrollbar) SetEnabled(enabled bool)

SetEnabled enables or disables the scrollbar

func (*Scrollbar) SetHeight

func (s *Scrollbar) SetHeight(height int)

SetHeight sets the scrollbar height

func (*Scrollbar) SetStyles

func (s *Scrollbar) SetStyles(styles Styles)

SetStyles updates the styles for runtime theme changes

func (*Scrollbar) Toggle

func (s *Scrollbar) Toggle() bool

Toggle toggles the scrollbar on/off

func (*Scrollbar) Width

func (s *Scrollbar) Width() int

Width returns the scrollbar width (1 character, or 0 if disabled)

type ScrollbarColumnAdapter added in v0.2.0

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

ScrollbarColumnAdapter wraps Scrollbar to implement ColumnRenderer.

func NewScrollbarColumnAdapter added in v0.2.0

func NewScrollbarColumnAdapter(sb *Scrollbar) *ScrollbarColumnAdapter

NewScrollbarColumnAdapter creates an adapter for the scrollbar.

func (*ScrollbarColumnAdapter) Render added in v0.2.0

func (a *ScrollbarColumnAdapter) Render(width, height int, state *RenderState) []string

Render implements ColumnRenderer interface.

type SelectionRange

type SelectionRange struct {
	Start int // Start column (inclusive)
	End   int // End column (exclusive), -1 for end of line
}

RenderLine renders a single line with optional selection highlighting

type StatusBar

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

StatusBar represents the bottom status bar

func NewStatusBar

func NewStatusBar(styles Styles) *StatusBar

NewStatusBar creates a new status bar

func (*StatusBar) ClearMessage

func (s *StatusBar) ClearMessage()

ClearMessage clears the temporary message

func (*StatusBar) SetBufferInfo

func (s *StatusBar) SetBufferInfo(index, count int)

SetBufferInfo sets the current buffer index and total buffer count

func (*StatusBar) SetCounts

func (s *StatusBar) SetCounts(words, chars int)

SetCounts sets the word and character counts

func (*StatusBar) SetEncoding

func (s *StatusBar) SetEncoding(encoding string, supported bool)

SetEncoding sets the file encoding and whether it's supported

func (*StatusBar) SetFilename

func (s *StatusBar) SetFilename(filename string)

SetFilename sets the current filename

func (*StatusBar) SetMessage

func (s *StatusBar) SetMessage(message, msgType string)

SetMessage sets a temporary message to display

func (*StatusBar) SetModified

func (s *StatusBar) SetModified(modified bool)

SetModified sets whether the buffer has been modified

func (*StatusBar) SetPosition

func (s *StatusBar) SetPosition(line, col int)

SetPosition sets the cursor position (1-indexed for display)

func (*StatusBar) SetStyles

func (s *StatusBar) SetStyles(styles Styles)

SetStyles updates the styles for runtime theme changes

func (*StatusBar) SetTotalLines

func (s *StatusBar) SetTotalLines(total int)

SetTotalLines sets the total number of lines

func (*StatusBar) SetWidth

func (s *StatusBar) SetWidth(width int)

SetWidth sets the width of the status bar

func (*StatusBar) View

func (s *StatusBar) View() string

View renders the status bar

type Styles

type Styles struct {
	// The theme these styles were generated from
	Theme config.Theme

	// Menu bar styles
	MenuBar            lipgloss.Style
	MenuItem           lipgloss.Style
	MenuItemActive     lipgloss.Style
	MenuDropdown       lipgloss.Style
	MenuOption         lipgloss.Style
	MenuOptionActive   lipgloss.Style
	MenuOptionDisabled lipgloss.Style

	// Status bar styles
	StatusBar      lipgloss.Style
	StatusModified lipgloss.Style

	// Editor styles
	Editor           lipgloss.Style
	LineNumber       lipgloss.Style
	LineNumberActive lipgloss.Style
	Selection        lipgloss.Style
	Cursor           lipgloss.Style

	// Dialog styles
	DialogBox         lipgloss.Style
	DialogTitle       lipgloss.Style
	DialogText        lipgloss.Style
	DialogButton      lipgloss.Style
	DialogButtonFocus lipgloss.Style
	DialogInput       lipgloss.Style
	DialogList        lipgloss.Style
	DialogListItem    lipgloss.Style
	DialogListActive  lipgloss.Style

	// General styles
	Subtle lipgloss.Style
	Error  lipgloss.Style
}

Styles contains all the styles used in the editor

func DefaultStyles

func DefaultStyles() Styles

DefaultStyles returns the default style configuration (DOS EDIT theme)

func NewStyles

func NewStyles(theme config.Theme) Styles

NewStyles creates a Styles configuration from a theme

type TextRenderer added in v0.2.0

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

TextRenderer renders the main text content column. This is the flexible column that displays document content with syntax highlighting, cursor, and selection.

func NewTextRenderer added in v0.2.0

func NewTextRenderer(styles Styles) *TextRenderer

NewTextRenderer creates a new text renderer.

func (*TextRenderer) Render added in v0.2.0

func (r *TextRenderer) Render(width, height int, state *RenderState) []string

Render implements ColumnRenderer. Renders document text with syntax highlighting, cursor, and selection.

func (*TextRenderer) SetStyles added in v0.2.0

func (r *TextRenderer) SetStyles(styles Styles)

SetStyles updates the styles for runtime theme changes.

type Viewport

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

Viewport handles the scrollable view of the text

func NewViewport

func NewViewport(styles Styles) *Viewport

NewViewport creates a new viewport

func (*Viewport) CountVisualLines

func (v *Viewport) CountVisualLines(lines []string) int

CountVisualLines returns the total number of visual lines when word wrap is enabled

func (*Viewport) EnsureCursorVisible

func (v *Viewport) EnsureCursorVisible(cursorLine, cursorCol int)

EnsureCursorVisible scrolls the viewport to ensure the cursor is visible

func (*Viewport) EnsureCursorVisibleWrapped

func (v *Viewport) EnsureCursorVisibleWrapped(lines []string, cursorLine, cursorCol int)

EnsureCursorVisibleWrapped scrolls the viewport to ensure cursor is visible (word-wrap aware) lines parameter is needed to calculate visual line positions

func (*Viewport) Height

func (v *Viewport) Height() int

Height returns the viewport height

func (*Viewport) LineNumberWidth

func (v *Viewport) LineNumberWidth() int

LineNumberWidth returns the width of the line number column

func (*Viewport) MoveDownVisual

func (v *Viewport) MoveDownVisual(lines []string, line, col int) (newLine, newCol int)

MoveDownVisual moves the cursor down by one visual line when word wrap is enabled. Returns the new line and column position.

func (*Viewport) MoveUpVisual

func (v *Viewport) MoveUpVisual(lines []string, line, col int) (newLine, newCol int)

MoveUpVisual moves the cursor up by one visual line when word wrap is enabled. Returns the new line and column position.

func (*Viewport) PageDown

func (v *Viewport) PageDown(totalLines int)

PageDown scrolls down by one page

func (*Viewport) PageDownWrapped

func (v *Viewport) PageDownWrapped(lines []string)

PageDownWrapped scrolls down by one page (word-wrap aware)

func (*Viewport) PageUp

func (v *Viewport) PageUp()

PageUp scrolls up by one page

func (*Viewport) PositionFromClick

func (v *Viewport) PositionFromClick(x, y int) (line, col int)

PositionFromClick converts a click position to buffer line and column

func (*Viewport) PositionFromClickWrapped

func (v *Viewport) PositionFromClickWrapped(lines []string, x, y int) (line, col int)

PositionFromClickWrapped converts a click position to buffer line and column (word-wrap aware)

func (*Viewport) Render

func (v *Viewport) Render(lines []string, cursorLine, cursorCol int, selection map[int]SelectionRange, lineColors map[int][]syntax.ColorSpan) string

Render renders the visible portion of the text lineColors is an optional map of line index to color spans for syntax highlighting

func (*Viewport) ScrollDown

func (v *Viewport) ScrollDown(totalLines int)

ScrollDown scrolls the viewport down by one line

func (*Viewport) ScrollDownWrapped

func (v *Viewport) ScrollDownWrapped(lines []string)

ScrollDownWrapped scrolls the viewport down (word-wrap aware)

func (*Viewport) ScrollUp

func (v *Viewport) ScrollUp()

ScrollUp scrolls the viewport up by one line

func (*Viewport) ScrollX

func (v *Viewport) ScrollX() int

ScrollX returns the current horizontal scroll position

func (*Viewport) ScrollY

func (v *Viewport) ScrollY() int

ScrollY returns the current vertical scroll position

func (*Viewport) ScrollbarWidth

func (v *Viewport) ScrollbarWidth() int

ScrollbarWidth returns the width reserved for the scrollbar

func (*Viewport) SetScrollX

func (v *Viewport) SetScrollX(x int)

SetScrollX sets the horizontal scroll position

func (*Viewport) SetScrollY

func (v *Viewport) SetScrollY(y int)

SetScrollY sets the vertical scroll position

func (*Viewport) SetScrollbarWidth

func (v *Viewport) SetScrollbarWidth(width int)

SetScrollbarWidth sets the width reserved for the scrollbar

func (*Viewport) SetSize

func (v *Viewport) SetSize(width, height int)

SetSize sets the viewport dimensions

func (*Viewport) SetStyles

func (v *Viewport) SetStyles(styles Styles)

SetStyles updates the styles for runtime theme changes

func (*Viewport) SetTabWidth added in v0.2.0

func (v *Viewport) SetTabWidth(width int)

SetTabWidth sets the display width for tabs

func (*Viewport) SetWordWrap

func (v *Viewport) SetWordWrap(wrap bool)

SetWordWrap enables or disables word wrap

func (*Viewport) ShowLineNum

func (v *Viewport) ShowLineNum() bool

ShowLineNum returns whether line numbers are enabled

func (*Viewport) ShowLineNumbers

func (v *Viewport) ShowLineNumbers(show bool)

ShowLineNumbers enables or disables line numbers

func (*Viewport) TabWidth added in v0.2.0

func (v *Viewport) TabWidth() int

TabWidth returns the current tab width

func (*Viewport) TextWidth

func (v *Viewport) TextWidth() int

TextWidth returns the width available for text (viewport width minus line numbers and scrollbar)

func (*Viewport) VisualLineToBufferLine

func (v *Viewport) VisualLineToBufferLine(lines []string, visualLine int) (bufferLine int, wrapOffset int)

VisualLineToBufferLine converts a visual line index to a buffer line index Returns the buffer line and the wrap offset within that line

func (*Viewport) Width

func (v *Viewport) Width() int

Width returns the viewport width

func (*Viewport) WordWrap

func (v *Viewport) WordWrap() bool

WordWrap returns whether word wrap is enabled

Jump to

Keyboard shortcuts

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