edittest

package
v0.0.0-...-2842cdc Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: ISC Imports: 2 Imported by: 0

Documentation

Overview

Package edittest contains utility functions for testing edits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseState

func ParseState(str string) (string, map[rune][2]int64)

ParseState parses an editor state description.

An editor state description describes the contents of the buffer and the editor's marks. Runes that are not between { and } represent the buffer contents. Each rune between { and } represent the beginning (first occurrence) or end (second occurrence) of a mark region with the name of the rune.

As a special case, the empty string, "", is equal to "{..}".

For example:

"{mm}abc{.}xyz{.n}123{n}αβξ"

Is a buffer with the contents:

"abcxyz123αβξ"

The mark m is the empty string at the beginning of the buffer. The mark . contains the text "xyz". The mark n contains the text "123".

func StateEquals

func StateEquals(text string, marks map[rune][2]int64, descr string) bool

StateEquals returns whether the state (text plus marks) equals the described state.

func StateString

func StateString(text string, marks map[rune][2]int64) string

StateString returns the state string description of the text and marks. The returned string is in the format of ParseState. The returned string is normalized so that multiple marks within { and } are lexicographically ordered.

Types

type RuneSlice

type RuneSlice []rune

func (RuneSlice) Len

func (rs RuneSlice) Len() int

func (RuneSlice) Less

func (rs RuneSlice) Less(i, j int) bool

func (RuneSlice) Swap

func (rs RuneSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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