File: enum.go

package info (click to toggle)
golang-github-achannarasappa-term-grid 0.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 132 kB
  • sloc: makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package grid

// TextAlign is an enum used to set the text alignment within a cell
type TextAlign int

const (
	// Left align text within a cell
	Left TextAlign = iota
	// Right align text within a cell
	Right
)

func (ta TextAlign) String() string {
	return [...]string{"Left", "Right"}[ta]
}

// Overflow is an enum used to set the text overflow behavior within a cell
type Overflow int

const (
	// Hide text that extends beyond the width of a cell
	Hidden Overflow = iota
	// Wrap text onto the next line when the text width exceeds the width of the cell
	Wrap
	// Wrap text onto the next line when the text width exceeds the width of the cell
	// but only break on words
	WrapWord
)

func (to Overflow) String() string {
	return [...]string{"Hidden", "Wrap", "WrapWord"}[to]
}

// Breakpoint is an enum used to set the visibility of cells are various terminal sizes
type Breakpoint int

const (
	Small Breakpoint = iota
	Medium
	Large
	XLarge
)

func (bp Breakpoint) String() string {
	return [...]string{"Small", "Medium", "Large", "XLarge"}[bp]
}

func (bp Breakpoint) Size() int {
	return [...]int{50, 100, 200, 400}[bp]
}