buffer

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

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 10 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)
	Save(filePath string) error
	Bytes() []byte
	FilePath() string
	IsModified() bool
}

Buffer defines the interface for text buffer operations.

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) 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