buffer

package
v0.0.0-...-4540273 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitTree

func InitTree(sourceCode *SourceCode, ext string) tea.Cmd

InitTree parses the source code using treesitter and generates a syntax tree for it.

Types

type Line

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

Line describes a line. Using this I can easily index lines and get their length and indentation

type Mode

type Mode int

Stores editor mode

const (
	Normal Mode = iota
	Insert
	Select
)

type Model

type Model struct {
	Path string // Absolute path on disk.

	Focused bool

	Mode Mode // Current buffer mode
	// contains filtered or unexported fields
}

Model represents an opened file.

func New

func New() Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Name

func (b Model) Name() string

Name returns the title of the buffer window to display

func (*Model) OpenFile

func (m *Model) OpenFile(path string) tea.Cmd

OpenFile opens the given file inside the buffer

func (Model) Update

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

func (Model) View

func (m Model) View() string

View renders the Buffer content to screen

func (*Model) WriteToDisk

func (b *Model) WriteToDisk() tea.Cmd

WriteToDisk saves the current buffer to disk

type SourceCode

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

SourceCode is the main container for the opened files. TODO name to something more generic, like Buffer?

func (*SourceCode) AddSelection

func (s *SourceCode) AddSelection()

func (*SourceCode) CurrentLine

func (s *SourceCode) CurrentLine() (int, Line, error)

CurrentLine returns the current line index and value

func (*SourceCode) GenerateColors

func (s *SourceCode) GenerateColors() []byte

GenerateColors generates the new Syntax Highlighting for the current tree. It is a blocking operation that should take as little as possible.

func (*SourceCode) GenerateTree

func (s *SourceCode) GenerateTree() *sitter.Node

func (*SourceCode) GetColors

func (s *SourceCode) GetColors(start, end int) []byte

func (*SourceCode) GetSelection

func (s *SourceCode) GetSelection() (start, end int)

func (*SourceCode) GetSlice

func (s *SourceCode) GetSlice(start, end int) []byte

GetSlice returns the slice between start and end

func (*SourceCode) LineWidth

func (s *SourceCode) LineWidth(l Line) int

Returns the width, in characters, of a given line

func (*SourceCode) Lines

func (s *SourceCode) Lines() map[int]Line

Returns a map of type lineIndex: {start in buffer, end in buffer}

func (*SourceCode) RegenerateLines

func (s *SourceCode) RegenerateLines()

RegenerateLines regenerates the line information

func (*SourceCode) RelalcHpos

func (s *SourceCode) RelalcHpos()

func (*SourceCode) SetCursor

func (s *SourceCode) SetCursor(pos int)

func (*SourceCode) SetSource

func (s *SourceCode) SetSource(source []byte)

SetSource loads a file and computes the appropriate LineInfo's

func (*SourceCode) StartSelection

func (s *SourceCode) StartSelection()

type TreeInitMsg

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

Contains the new cursor coordinates

type Viewport

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

Jump to

Keyboard shortcuts

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