Documentation
¶
Overview ¶
internal/buffer/buffer.go
internal/buffer/slice_buffer.go
Index ¶
- type Buffer
- type PieceTable
- func (pt *PieceTable) Bytes() []byte
- func (pt *PieceTable) Delete(start, end types.Position) (types.EditInfo, error)
- func (pt *PieceTable) FilePath() string
- func (pt *PieceTable) GetText(start, end types.Position) string
- func (pt *PieceTable) Insert(pos types.Position, text []byte) (types.EditInfo, error)
- func (pt *PieceTable) IsModified() bool
- func (pt *PieceTable) Line(index int) ([]byte, error)
- func (pt *PieceTable) LineCount() int
- func (pt *PieceTable) Lines() [][]byte
- func (pt *PieceTable) Load(filePath string) error
- func (pt *PieceTable) Save(filePath string) error
- type SliceBuffer
- func (sb *SliceBuffer) Bytes() []byte
- func (sb *SliceBuffer) Delete(start, end types.Position) (types.EditInfo, error)
- func (sb *SliceBuffer) FilePath() string
- func (sb *SliceBuffer) GetText(start, end types.Position) string
- func (sb *SliceBuffer) Insert(pos types.Position, text []byte) (types.EditInfo, error)
- func (sb *SliceBuffer) IsModified() bool
- func (sb *SliceBuffer) Line(index int) ([]byte, error)
- func (sb *SliceBuffer) LineCount() int
- func (sb *SliceBuffer) Lines() [][]byte
- func (sb *SliceBuffer) Load(filePath string) error
- func (sb *SliceBuffer) Save(filePath string) error
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) 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) IsModified ¶ added in v0.1.3
func (pt *PieceTable) IsModified() bool
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) Delete ¶
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 ¶
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.