model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

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 is array of line strings. Buffer API's require and returns unit of codepoint positions.

func (*Buffer) AppendString

func (buf *Buffer) AppendString(row int, s string) (Position, error)

AppendString is appending string into tail.

func (*Buffer) GetLineAt

func (buf *Buffer) GetLineAt(row int) *Line

GetLineAt returns specified line.

func (*Buffer) GetLineCount

func (buf *Buffer) GetLineCount() int

GetLineCount returns count of lines.

func (*Buffer) Init

func (buf *Buffer) Init()

Init is initialize Buffer.

func (*Buffer) InsertLine

func (buf *Buffer) InsertLine(row int, column int) *Line

InsertLine is break line at specified position.

func (*Buffer) InsertString

func (buf *Buffer) InsertString(row int, column int, s string) (Position, error)

InsertString is insert string into specified position.

func (*Buffer) PrependString

func (buf *Buffer) PrependString(row int, s string) (Position, error)

PrependString is insert string into specified line ahead.

func (*Buffer) RemoveLine

func (buf *Buffer) RemoveLine(row int)

RemoveLine is remove specified line.

func (*Buffer) RemoveString

func (buf *Buffer) RemoveString(row int, column int, length int)

RemoveString is remove string specified range.

type Document

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

Document is wrapper of Buffer. track a current cursor position.

func (*Document) FindNext

func (doc *Document) FindNext(searchStr string) bool

FindNext is searches for the specified string forward from the current cursor position and moves the cursor to the beginning of the found string. Returns true if found, false otherwise.

func (*Document) FindPrev

func (doc *Document) FindPrev(searchStr string) bool

FindPrev is searches for the specified string backward from the current cursor position and moves the cursor to the beginning of the found string. Returns true if found, false otherwise.

func (*Document) GetBuffer

func (doc *Document) GetBuffer() *Buffer

GetBuffer returns Buffer.

func (*Document) GetCursorColumn

func (doc *Document) GetCursorColumn() int

GetCursorColumn returns column of cursor.

func (*Document) GetCursorRow

func (doc *Document) GetCursorRow() int

GetCursorRow returns row of cursor.

func (*Document) Init

func (doc *Document) Init()

Init is initialize Buffer.

func (*Document) InsertLine

func (doc *Document) InsertLine()

InsertLine is break line at current cursor position.

func (*Document) InsertString

func (doc *Document) InsertString(s string)

InsertString is insert string at current cursor position.

func (*Document) MoveDown

func (doc *Document) MoveDown()

MoveDown is move cursor to down.

func (*Document) MoveLeft

func (doc *Document) MoveLeft()

MoveLeft is move cursor to left.

func (*Document) MoveReset

func (doc *Document) MoveReset()

MoveReset is cursor position reset to zero.

func (*Document) MoveRight

func (doc *Document) MoveRight()

MoveRight is move cursor to right.

func (*Document) MoveUp

func (doc *Document) MoveUp()

MoveUp is move cursor to up.

func (*Document) RemoveChar

func (doc *Document) RemoveChar()

RemoveChar is remove character at current cursor position.

func (*Document) Replace

func (doc *Document) Replace(deleteCount int, replaceStr string) bool

Replace deletes the specified number of characters from the current cursor position and inserts the replacement string at that position. After replacement, the cursor is moved to the end of the inserted text. Returns true if the operation was successful, false otherwise.

type Line

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

Line is parts of buffer.

func (*Line) AppendString

func (l *Line) AppendString(s string)

AppendString is appending string into tail.

func (*Line) GetContent

func (l *Line) GetContent() string

GetContent is returns string of content.

func (*Line) InsertString

func (l *Line) InsertString(column int, s string)

InsertString is insert string into specified column.

func (*Line) PrependString

func (l *Line) PrependString(s string)

PrependString is insert string into line ahead.

func (*Line) Remove

func (l *Line) Remove(offset int, length int)

Remove is remove string specified range.

type Position

type Position struct {
	Row    int
	Column int
}

Position is representation of coordinate in two dimensional plane.

Jump to

Keyboard shortcuts

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