buffer

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

internal/buffer/buffer.go

internal/buffer/slice_buffer.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer interface {
	Load(filePath string) error
	Lines() [][]byte
	Line(index int) ([]byte, error)
	LineCount() int
	// Methods now return EditInfo
	Insert(pos types.Position, text []byte) (types.EditInfo, error)
	Delete(start, end types.Position) (types.EditInfo, error)
	GetText(start, end types.Position) string
	Save(filePath string) error
	Bytes() []byte
	FilePath() string
	IsModified() bool
}

Buffer defines the interface for text buffer operations.

type PieceTable added in v0.1.3

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

PieceTable is a more efficient buffer implementation for large files

func NewPieceTable added in v0.1.3

func NewPieceTable() *PieceTable

func (*PieceTable) Bytes added in v0.1.3

func (pt *PieceTable) Bytes() []byte

func (*PieceTable) Delete added in v0.1.3

func (pt *PieceTable) Delete(start, end types.Position) (types.EditInfo, error)

func (*PieceTable) FilePath added in v0.1.3

func (pt *PieceTable) FilePath() string

func (*PieceTable) GetText added in v0.1.3

func (pt *PieceTable) GetText(start, end types.Position) string

func (*PieceTable) Insert added in v0.1.3

func (pt *PieceTable) Insert(pos types.Position, text []byte) (types.EditInfo, error)

func (*PieceTable) IsModified added in v0.1.3

func (pt *PieceTable) IsModified() bool

func (*PieceTable) Line added in v0.1.3

func (pt *PieceTable) Line(index int) ([]byte, error)

func (*PieceTable) LineCount added in v0.1.3

func (pt *PieceTable) LineCount() int

func (*PieceTable) Lines added in v0.1.3

func (pt *PieceTable) Lines() [][]byte

func (*PieceTable) Load added in v0.1.3

func (pt *PieceTable) Load(filePath string) error

Implement the Buffer interface methods...

func (*PieceTable) Save added in v0.1.3

func (pt *PieceTable) Save(filePath string) error

type SliceBuffer

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

SliceBuffer implementation (content mostly unchanged, just imports and method signatures)

func NewSliceBuffer

func NewSliceBuffer() *SliceBuffer

NewSliceBuffer creates an empty SliceBuffer.

func (*SliceBuffer) Bytes

func (sb *SliceBuffer) Bytes() []byte

Bytes implementation (no changes)

func (*SliceBuffer) Delete

func (sb *SliceBuffer) Delete(start, end types.Position) (types.EditInfo, error)

Delete removes text within a given range (start inclusive, end exclusive).

func (*SliceBuffer) FilePath

func (sb *SliceBuffer) FilePath() string

func (*SliceBuffer) GetText added in v0.1.3

func (sb *SliceBuffer) GetText(start, end types.Position) string

GetText returns the text between two positions (start inclusive, end exclusive).

func (*SliceBuffer) Insert

func (sb *SliceBuffer) Insert(pos types.Position, text []byte) (types.EditInfo, error)

Insert inserts text at a given position. Handles single/multiple lines.

func (*SliceBuffer) IsModified

func (sb *SliceBuffer) IsModified() bool

IsModified returns true if the buffer has unsaved changes.

func (*SliceBuffer) Line

func (sb *SliceBuffer) Line(index int) ([]byte, error)

Line implementation (no changes)

func (*SliceBuffer) LineCount

func (sb *SliceBuffer) LineCount() int

LineCount implementation (no changes)

func (*SliceBuffer) Lines

func (sb *SliceBuffer) Lines() [][]byte

Lines implementation (no changes)

func (*SliceBuffer) Load

func (sb *SliceBuffer) Load(filePath string) error

Load reads a file into the buffer. Replaces existing content.

func (*SliceBuffer) Save

func (sb *SliceBuffer) Save(filePath string) error

Save writes the buffer content. Uses provided filePath if not empty, otherwise internal path. Updates internal filePath on successful save to a new location.

Jump to

Keyboard shortcuts

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