position

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: Unlicense Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Increment

type Increment = Position

Increment is an incrementer of positions

type Position

type Position struct {
	Offset int
	Line   int
	Column int
}

Position represents the position of a character in a file.

func New

func New(line, column, offset int) Position

New returns a position with the given line, column and offset.

func (Position) Between

func (p Position) Between(p1, p2 Position) bool

func (Position) Blank

func (p1 Position) Blank(p2 Position) string

Blank returns a string corresponding to the space between p1 and p2.

func (Position) Cmp

func (p1 Position) Cmp(p2 Position) int

Cmp compares 2 positions. It returns : - -1 if p1 before p2 - 1 if p1 after p2 - 0 otherwise

func (Position) Diff

func (p1 Position) Diff(p2 Position) Increment

Diff returns p1 - p2

func (Position) Eq

func (p1 Position) Eq(p2 Position) bool

func (Position) Ge

func (p1 Position) Ge(p2 Position) bool

func (Position) Gt

func (p1 Position) Gt(p2 Position) bool

func (Position) Increment

func (p Position) Increment(inc Increment) Position

Increment returns a new position with line, column and offset incremented by the given increment.

func (Position) IncrementPosition

func (p Position) IncrementPosition(incLine, incColumn, incOffset int) Position

IncrementPosition returns a new position with line, column and offset incremented by the given increments.

func (Position) IsValid

func (p Position) IsValid() bool

IsValid returns true if the position is valid. To be valid, a position should have lines > 0 and columns/offset ≥ 0.

func (Position) Le

func (p1 Position) Le(p2 Position) bool

func (Position) Lt

func (p1 Position) Lt(p2 Position) bool

func (Position) Ne

func (p1 Position) Ne(p2 Position) bool

func (Position) Next

func (p Position) Next(r rune) Position

Next retuns the position next to the given character.

func (Position) NextString

func (p Position) NextString(s string) Position

NextString returns the cursor position next to the given string.

func (Position) Prev

func (p Position) Prev(r rune) Position

Prev returns the position before the given character.

func (Position) String

func (p Position) String() string

String returns a string representation of the position on the form L{line},C{column}

Jump to

Keyboard shortcuts

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