Debian Codegraph @

position.go

raw symbols SCIP
1 package ssh_config
2
3 import "fmt"
4
5 // Position of a document element within a SSH document.
6 //
7 // Line and Col are both 1-indexed positions for the element's line number and
8 // column number, respectively. Values of zero or less will cause Invalid(),
9 // to return true.
10 type Position struct {
11 Line int // line within the document
12 Col int // column within the line
13 }
14
15 // String representation of the position.
16 // Displays 1-indexed line and column numbers.
17 func (p Position) String() string {
18 return fmt.Sprintf("(%d, %d)", p.Line, p.Col)
19 }
20
21 // Invalid returns whether or not the position is valid (i.e. with negative or
22 // null values)
23 func (p Position) Invalid() bool {
24 return p.Line <= 0 || p.Col <= 0
25 }