Documentation ¶
Index ¶
- type GapBuffer
- func (b *GapBuffer[T]) Backspace()
- func (b *GapBuffer[T]) Collect() []T
- func (b *GapBuffer[T]) Count() int
- func (b *GapBuffer[T]) CursorGoto(pos int)
- func (b *GapBuffer[T]) CursorLeft()
- func (b *GapBuffer[T]) CursorRight()
- func (b *GapBuffer[T]) Delete()
- func (b *GapBuffer[T]) FindAll(val T) []int
- func (b *GapBuffer[T]) Get(pos int) T
- func (b *GapBuffer[T]) Insert(el T)
- func (b *GapBuffer[T]) InsertElements(elements []T)
- func (b *GapBuffer[T]) Iter() GapBufferIterator[T]
- func (b *GapBuffer[T]) Len() int
- func (b *GapBuffer[T]) TotalLen() int
- type GapBufferIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GapBuffer ¶
type GapBuffer[T ~int | ~rune] struct { Buffer []T // NOTE: In the future I might want this to be a pointer. I avoided this for now as it looked ugly GapStart int // Index of the first character *in* the gap GapEnd int // Index of the first character *after* the gap }
Gap Buffer implementation. See: https://routley.io/posts/gap-buffer
func NewGapBuffer ¶
NewGapBuffer creates a new gapbuffer and populates it with content
func (*GapBuffer[T]) Backspace ¶
func (b *GapBuffer[T]) Backspace()
Backspace deletes the character before the current position
func (*GapBuffer[T]) Collect ¶
func (b *GapBuffer[T]) Collect() []T
Collect returns a slice of the content of the gap buffer, without gap
func (*GapBuffer[T]) CursorGoto ¶
CursorGoto moves the cursor to the given position
func (*GapBuffer[T]) CursorLeft ¶
func (b *GapBuffer[T]) CursorLeft()
CursorRight moves the cursor left one character.
func (*GapBuffer[T]) CursorRight ¶
func (b *GapBuffer[T]) CursorRight()
CursorRight moves the cursor right one character.
func (*GapBuffer[T]) Delete ¶
func (b *GapBuffer[T]) Delete()
Delete deletes the character at the current cursor position.
func (*GapBuffer[T]) FindAll ¶
FindAll returns a slice with the indices of all found items inside the gap buffer
func (*GapBuffer[T]) Insert ¶
func (b *GapBuffer[T]) Insert(el T)
Insert inserts a single element at the current cursor position.
func (*GapBuffer[T]) InsertElements ¶
func (b *GapBuffer[T]) InsertElements(elements []T)
InsertElements inserts a slice of T at the current cursor position.
func (*GapBuffer[T]) Iter ¶
func (b *GapBuffer[T]) Iter() GapBufferIterator[T]
type GapBufferIterator ¶
func (*GapBufferIterator[T]) HasNext ¶
func (gi *GapBufferIterator[T]) HasNext() bool
func (*GapBufferIterator[T]) Next ¶
func (gi *GapBufferIterator[T]) Next() (int, T)