utfstrings

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const EOS = int32(-1)

EOS is returned when cursor reaches the end of the string.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	Selection

	String string
}

Cursor provides functions to navigate a Unicode string.

func (*Cursor) Backup

func (cur *Cursor) Backup()

Backup steps back one rune. Can only be called once per call of next.

func (Cursor) Build

func (cur Cursor) Build(move MoveFunc) string

Build will build a string from the cursor. move will be called before every rune and move can advance the cursor one or more times to ignore runes. Build will always start from the beginning of the string. This will not modify the original cursor since it has value receiver.

func (*Cursor) Next

func (cur *Cursor) Next() rune

Next returns the next rune in the string.

func (*Cursor) Peek

func (cur *Cursor) Peek() rune

Peek returns but does not consume the next rune in the string.

type MoveFunc

type MoveFunc func(cur *Cursor)

MoveFunc is called by Build. MoveFunc can advance the cursor one or more times. Once this function returns Build will start from the current position and consume one rune and call MoveFunc again.

type Selection

type Selection struct {
	Start int
	Pos   int
	// contains filtered or unexported fields
}

Selection represents the current selection in the cursor.

Jump to

Keyboard shortcuts

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