search

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Hits    int
	Lines   []int
	Pattern string
	// contains filtered or unexported fields
}

Result describes the results of a search

func NewSearch

func NewSearch(text [][]rune, pattern string) (*Result, error)

NewSearch searches in a multiline string for lines that match the given pattern, it returns: * the number of hits (lines) * the line index

func (*Result) InitialLine

func (result *Result) InitialLine(lineNumber int) (int, error)

InitialLine sets the position for iterating the search results on the first line that is either has the same value or is the closest from 0 to the given line number. So, for a result that found that lines (1, 3, 5) were a hit: * InitialLine(-1) will set the internal iteration index at 0 (the default starting index) * InitialLine(3) will set the internal iteration index at 1. * InitialLine(4) will set the internal iteration index at 1. * InitialLine(10) will set the internal iteration index at 2.

func (*Result) NextLine

func (result *Result) NextLine() (int, error)

NextLine returns the previous line while iterating the search results. So, for a result that found that lines (1, 3, 5) were a hit: *NextLine() should give 1 *NextLine() should give 3 *NextLine() should give 5 *NextLine() should give 5

func (*Result) PreviousLine

func (result *Result) PreviousLine() (int, error)

PreviousLine returns the previous line while iterating the search results. So, for a result that found that lines (1, 3, 5) were a hit: * NextLine() should give 1 * NextLine() should give 3 * PreviousLine() should give 1 * PreviousLine() should give 1

func (*Result) String

func (result *Result) String() string

Jump to

Keyboard shortcuts

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