text

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package text provides the Unicode-aware gap buffer used by Kite's text controls for editing and caret movement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer manages 1-dimensional string edits with Unicode safety using a gap buffer.

func NewBuffer

func NewBuffer(text string) *Buffer

NewBuffer creates a new Buffer with the given initial text.

func (*Buffer) Backspace

func (b *Buffer) Backspace(graphemeCount int)

Backspace removes the specified number of grapheme clusters before the gap.

func (*Buffer) ByteLen

func (b *Buffer) ByteLen() int

ByteLen returns the number of bytes in the buffer.

func (*Buffer) ByteOffset

func (b *Buffer) ByteOffset() int

ByteOffset returns the current gap (cursor) position as a byte offset.

func (*Buffer) Chunks

func (b *Buffer) Chunks() ([]rune, []rune)

Chunks returns the two parts of the buffer content around the gap.

func (*Buffer) Delete

func (b *Buffer) Delete(graphemeCount int)

Delete removes the specified number of grapheme clusters after the gap.

func (*Buffer) DeleteNext

func (b *Buffer) DeleteNext()

DeleteNext is an alias for Delete(1) for compatibility.

func (*Buffer) DeletePrevious

func (b *Buffer) DeletePrevious()

DeletePrevious is an alias for Backspace(1) for compatibility.

func (*Buffer) DeleteRange

func (b *Buffer) DeleteRange(start, end int)

DeleteRange removes the text between the start and end byte offsets.

func (*Buffer) DeleteWordNext

func (b *Buffer) DeleteWordNext()

DeleteWordNext removes the word after the gap.

func (*Buffer) DeleteWordPrevious

func (b *Buffer) DeleteWordPrevious()

DeleteWordPrevious removes the word before the gap.

func (*Buffer) Insert

func (b *Buffer) Insert(text string)

Insert adds the given text at the current gap position.

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the number of runes in the buffer.

func (*Buffer) MoveEnd

func (b *Buffer) MoveEnd()

MoveEnd moves the gap to the end of the buffer.

func (*Buffer) MoveLeft

func (b *Buffer) MoveLeft()

MoveLeft moves the gap one grapheme cluster to the left.

func (*Buffer) MoveRight

func (b *Buffer) MoveRight()

MoveRight moves the gap one grapheme cluster to the right.

func (*Buffer) MoveStart

func (b *Buffer) MoveStart()

MoveStart moves the gap to the beginning of the buffer.

func (*Buffer) MoveToEnd

func (b *Buffer) MoveToEnd()

MoveToEnd is an alias for MoveEnd for compatibility.

func (*Buffer) MoveToStart

func (b *Buffer) MoveToStart()

MoveToStart is an alias for MoveStart for compatibility.

func (*Buffer) MoveWordLeft

func (b *Buffer) MoveWordLeft()

MoveWordLeft moves the gap to the start of the previous word.

func (*Buffer) MoveWordRight

func (b *Buffer) MoveWordRight()

MoveWordRight moves the gap to the end of the next word.

func (*Buffer) Reset

func (b *Buffer) Reset(text string)

Reset replaces the entire buffer content with the given text and moves the cursor to the end.

func (*Buffer) SetByteOffset

func (b *Buffer) SetByteOffset(offset int)

SetByteOffset moves the gap to the specified byte offset.

func (*Buffer) SetOffset

func (b *Buffer) SetOffset(offset int)

SetOffset is an alias for SetByteOffset for compatibility.

func (*Buffer) Value

func (b *Buffer) Value() string

Value returns the current string value of the buffer.

func (*Buffer) Version

func (b *Buffer) Version() int64

Version returns a monotonically increasing number that increments after every text-mutating operation. Moving the cursor does not increment the version.

Jump to

Keyboard shortcuts

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