buffer

package
v0.0.0-...-99b4a15 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertNode

func InsertNode(src *BufferNode, n *BufferNode)

InsertNode inserts node `n` before node `src`

func ReplaceNode

func ReplaceNode(old *BufferNode, new *BufferNode)

ReplaceNode replaces node `old` with `new` in the Linked List

Types

type Buffer

type Buffer struct {
	Path string // Absolute path on disk.

	Val   *gapbuffer.GapBuffer[rune] // Actual raw text data. Gap Buffer is a nice compromise between Piece Chain and buffer.
	Lines *gapbuffer.GapBuffer[int]  // The line numbers are also stored in a Gap Buffer

	CursorRow, CursorCol int          // ???
	Cursor               cursor.Model // Cursor position inside this buffer.
	// contains filtered or unexported fields
}

Buffer represents an opened file.

func NewBuffer

func NewBuffer(path string) (*Buffer, error)

NewBuffer constructs a new buffer from a path. If that file exists, it opens it for reading, otherwise it will just open a fake file in memory

func (*Buffer) CursorLeft

func (b *Buffer) CursorLeft()

func (*Buffer) CursorRight

func (b *Buffer) CursorRight()

CursorRight moves the cursor one position to the right

func (Buffer) Name

func (b Buffer) Name() string

Name returns the title of the buffer window to display

func (*Buffer) String

func (b *Buffer) String() string

String returns the string contained in this buffer

type BufferNode

type BufferNode struct {
	Prev   *BufferNode
	Next   *BufferNode
	Buffer *Buffer
}

The bufferline is composed of a linked-list

func Node

func Node(buf *Buffer) *BufferNode

Node takes a *buffer and returns a *BufferNode

type LinkedList

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

func NewList

func NewList() LinkedList

func (*LinkedList) AddNode

func (l *LinkedList) AddNode(n *BufferNode)

func (*LinkedList) Iter

func (l *LinkedList) Iter() common.Iterator[BufferNode]

Creates an iterator over the LinkedList elements

type NodeIterator

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

NodeIterator implements the Iterator interface for LinkedList

func (*NodeIterator) HasNext

func (i *NodeIterator) HasNext() bool

HasNext tells us wether the iterator still has elements to consume

func (*NodeIterator) Next

func (i *NodeIterator) Next() *BufferNode

Next gets the next element in this iterator

Jump to

Keyboard shortcuts

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