cursor

package
v0.1.0-pre-release-v4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBufferCol

func GetBufferCol(line string, visualCol int, tabWidth int) int

GetBufferCol translates a visual column to a buffer column

func GetVisualCol

func GetVisualCol(line string, col int, tabWidth int) int

GetVisualCol translates a buffer column to a visual column

func GetVisualLineLength

func GetVisualLineLength(line string, tabWidth int) int

GetVisualLineLength computes the visual length of a line

Types

type Editor

type Editor interface {
	GetBuffer() buffer.Buffer
	ScrollOff() int
}

Editor is the interface cursor manager expects from the editor

type Manager

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

Manager handles cursor positioning and viewport management

func NewManager

func NewManager(editor Editor) *Manager

NewManager creates a new cursor manager

func (*Manager) GetBufferCol

func (m *Manager) GetBufferCol(line string, visualCol int) int

GetBufferCol translates a visual column position to a buffer column position, accounting for tab characters.

func (*Manager) GetPosition

func (m *Manager) GetPosition() types.Position

GetPosition returns the current cursor position

func (*Manager) GetViewport

func (m *Manager) GetViewport() (int, int)

GetViewport returns the current viewport top line and left column

func (*Manager) GetVisualCol

func (m *Manager) GetVisualCol(line string, col int) int

GetVisualCol translates a buffer column position to a visual column position, accounting for tab characters.

func (*Manager) Move

func (m *Manager) Move(deltaLine, deltaCol int)

Move moves the cursor by the given delta This is an alias for MoveCursor to maintain API compatibility

func (*Manager) MoveCursor

func (m *Manager) MoveCursor(deltaLine, deltaCol int)

MoveCursor moves the cursor by the given delta

func (*Manager) MoveToEndOfLine

func (m *Manager) MoveToEndOfLine()

MoveToEndOfLine moves the cursor to the end of the current line

func (*Manager) MoveToLineEnd

func (m *Manager) MoveToLineEnd()

MoveToLineEnd moves the cursor to the end of the current line This is an alias for MoveToEndOfLine to maintain API compatibility

func (*Manager) MoveToLineStart

func (m *Manager) MoveToLineStart()

MoveToLineStart moves the cursor to the start of the current line This is an alias for MoveToStartOfLine to maintain API compatibility

func (*Manager) MoveToStartOfLine

func (m *Manager) MoveToStartOfLine()

MoveToStartOfLine moves the cursor to the first non-whitespace character

func (*Manager) PageMove

func (m *Manager) PageMove(deltaPages int)

PageMove moves the cursor by the given number of pages

func (*Manager) ScrollToCursor

func (m *Manager) ScrollToCursor()

ScrollToCursor ensures the cursor is visible in the viewport

func (*Manager) SetPosition

func (m *Manager) SetPosition(pos types.Position)

SetPosition sets the cursor position

func (*Manager) SetViewSize

func (m *Manager) SetViewSize(width, height int)

SetViewSize updates the view dimensions

Jump to

Keyboard shortcuts

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