2016-10-24 00:44:56 +00:00
|
|
|
package tui
|
|
|
|
|
|
|
|
import (
|
2017-01-11 14:01:56 +00:00
|
|
|
"fmt"
|
2017-01-10 17:12:32 +00:00
|
|
|
"os"
|
2017-01-09 17:16:12 +00:00
|
|
|
"strconv"
|
2016-10-24 00:44:56 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Types of user action
|
|
|
|
const (
|
|
|
|
Rune = iota
|
|
|
|
|
|
|
|
CtrlA
|
|
|
|
CtrlB
|
|
|
|
CtrlC
|
|
|
|
CtrlD
|
|
|
|
CtrlE
|
|
|
|
CtrlF
|
|
|
|
CtrlG
|
|
|
|
CtrlH
|
|
|
|
Tab
|
|
|
|
CtrlJ
|
|
|
|
CtrlK
|
|
|
|
CtrlL
|
|
|
|
CtrlM
|
|
|
|
CtrlN
|
|
|
|
CtrlO
|
|
|
|
CtrlP
|
|
|
|
CtrlQ
|
|
|
|
CtrlR
|
|
|
|
CtrlS
|
|
|
|
CtrlT
|
|
|
|
CtrlU
|
|
|
|
CtrlV
|
|
|
|
CtrlW
|
|
|
|
CtrlX
|
|
|
|
CtrlY
|
|
|
|
CtrlZ
|
|
|
|
ESC
|
2017-01-27 17:54:47 +00:00
|
|
|
CtrlSpace
|
2016-10-24 00:44:56 +00:00
|
|
|
|
2019-11-14 13:39:25 +00:00
|
|
|
// https://apple.stackexchange.com/questions/24261/how-do-i-send-c-that-is-control-slash-to-the-terminal
|
|
|
|
CtrlBackSlash
|
|
|
|
CtrlRightBracket
|
|
|
|
CtrlCaret
|
|
|
|
CtrlSlash
|
|
|
|
|
2016-10-24 00:44:56 +00:00
|
|
|
Invalid
|
2016-11-22 16:58:46 +00:00
|
|
|
Resize
|
2016-10-24 00:44:56 +00:00
|
|
|
Mouse
|
|
|
|
DoubleClick
|
2017-11-30 17:11:20 +00:00
|
|
|
LeftClick
|
|
|
|
RightClick
|
2016-10-24 00:44:56 +00:00
|
|
|
|
|
|
|
BTab
|
|
|
|
BSpace
|
|
|
|
|
|
|
|
Del
|
|
|
|
PgUp
|
|
|
|
PgDn
|
|
|
|
|
|
|
|
Up
|
|
|
|
Down
|
|
|
|
Left
|
|
|
|
Right
|
|
|
|
Home
|
|
|
|
End
|
|
|
|
|
2018-02-15 10:56:11 +00:00
|
|
|
SUp
|
|
|
|
SDown
|
2016-10-24 00:44:56 +00:00
|
|
|
SLeft
|
|
|
|
SRight
|
|
|
|
|
|
|
|
F1
|
|
|
|
F2
|
|
|
|
F3
|
|
|
|
F4
|
|
|
|
F5
|
|
|
|
F6
|
|
|
|
F7
|
|
|
|
F8
|
|
|
|
F9
|
|
|
|
F10
|
2016-11-19 13:40:28 +00:00
|
|
|
F11
|
|
|
|
F12
|
2016-10-24 00:44:56 +00:00
|
|
|
|
2017-05-22 08:07:05 +00:00
|
|
|
Change
|
|
|
|
|
2016-10-24 00:44:56 +00:00
|
|
|
AltSpace
|
|
|
|
AltSlash
|
|
|
|
AltBS
|
2016-11-19 13:40:28 +00:00
|
|
|
|
2018-04-12 08:39:28 +00:00
|
|
|
AltUp
|
|
|
|
AltDown
|
|
|
|
AltLeft
|
|
|
|
AltRight
|
|
|
|
|
2016-11-19 13:40:28 +00:00
|
|
|
Alt0
|
|
|
|
)
|
|
|
|
|
|
|
|
const ( // Reset iota
|
|
|
|
AltA = Alt0 + 'a' - '0' + iota
|
2016-10-24 00:44:56 +00:00
|
|
|
AltB
|
|
|
|
AltC
|
|
|
|
AltD
|
|
|
|
AltE
|
|
|
|
AltF
|
2017-04-27 17:36:36 +00:00
|
|
|
AltZ = AltA + 'z' - 'a'
|
|
|
|
CtrlAltA = AltZ + 1
|
|
|
|
CtrlAltM = CtrlAltA + 'm' - 'a'
|
2016-10-24 00:44:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
doubleClickDuration = 500 * time.Millisecond
|
|
|
|
)
|
|
|
|
|
2016-11-25 15:36:38 +00:00
|
|
|
type Color int32
|
|
|
|
|
|
|
|
func (c Color) is24() bool {
|
|
|
|
return c > 0 && (c&(1<<24)) > 0
|
|
|
|
}
|
2016-10-24 00:44:56 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
colUndefined Color = -2
|
Improvements to code quality and readability (#1737)
* Remove 1 unused field and 3 unused functions
unused elements fount by running
golangci-lint run --disable-all --enable unused
src/result.go:19:2: field `index` is unused (unused)
index int32
^
src/tui/light.go:716:23: func `(*LightWindow).stderr` is unused (unused)
func (w *LightWindow) stderr(str string) {
^
src/terminal.go:1015:6: func `numLinesMax` is unused (unused)
func numLinesMax(str string, max int) int {
^
src/tui/tui.go:167:20: func `ColorPair.is24` is unused (unused)
func (p ColorPair) is24() bool {
^
* Address warnings from "gosimple" linter
src/options.go:389:83: S1003: should use strings.Contains(str, ",,,") instead (gosimple)
if str == "," || strings.HasPrefix(str, ",,") || strings.HasSuffix(str, ",,") || strings.Index(str, ",,,") >= 0 {
^
src/options.go:630:18: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
executeRegexp = regexp.MustCompile(
^
src/terminal.go:29:16: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
placeholder = regexp.MustCompile("\\\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\\+?f?nf?})")
^
src/terminal_test.go:92:10: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
regex = regexp.MustCompile("\\w+")
^
* Address warnings from "staticcheck" linter
src/algo/algo.go:374:2: SA4006: this value of `offset32` is never used (staticcheck)
offset32, T := alloc32(offset32, slab, N)
^
src/algo/algo.go:456:2: SA4006: this value of `offset16` is never used (staticcheck)
offset16, C := alloc16(offset16, slab, width*M)
^
src/tui/tui.go:119:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
colUndefined Color = -2
^
2019-11-05 00:46:51 +00:00
|
|
|
colDefault Color = -1
|
2016-10-24 00:44:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
colBlack Color = iota
|
|
|
|
colRed
|
|
|
|
colGreen
|
|
|
|
colYellow
|
|
|
|
colBlue
|
|
|
|
colMagenta
|
|
|
|
colCyan
|
|
|
|
colWhite
|
|
|
|
)
|
|
|
|
|
2017-01-11 13:13:40 +00:00
|
|
|
type FillReturn int
|
|
|
|
|
|
|
|
const (
|
|
|
|
FillContinue FillReturn = iota
|
|
|
|
FillNextLine
|
|
|
|
FillSuspend
|
|
|
|
)
|
|
|
|
|
2017-01-07 16:30:31 +00:00
|
|
|
type ColorPair struct {
|
|
|
|
fg Color
|
|
|
|
bg Color
|
2017-09-09 04:50:07 +00:00
|
|
|
id int
|
2017-01-07 16:30:31 +00:00
|
|
|
}
|
|
|
|
|
2017-01-09 17:16:12 +00:00
|
|
|
func HexToColor(rrggbb string) Color {
|
|
|
|
r, _ := strconv.ParseInt(rrggbb[1:3], 16, 0)
|
|
|
|
g, _ := strconv.ParseInt(rrggbb[3:5], 16, 0)
|
|
|
|
b, _ := strconv.ParseInt(rrggbb[5:7], 16, 0)
|
|
|
|
return Color((1 << 24) + (r << 16) + (g << 8) + b)
|
|
|
|
}
|
|
|
|
|
2017-01-07 16:30:31 +00:00
|
|
|
func NewColorPair(fg Color, bg Color) ColorPair {
|
|
|
|
return ColorPair{fg, bg, -1}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p ColorPair) Fg() Color {
|
|
|
|
return p.fg
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p ColorPair) Bg() Color {
|
|
|
|
return p.bg
|
|
|
|
}
|
|
|
|
|
2016-10-24 00:44:56 +00:00
|
|
|
type ColorTheme struct {
|
|
|
|
Fg Color
|
|
|
|
Bg Color
|
|
|
|
DarkBg Color
|
2019-03-17 06:37:23 +00:00
|
|
|
Gutter Color
|
2016-10-24 00:44:56 +00:00
|
|
|
Prompt Color
|
|
|
|
Match Color
|
|
|
|
Current Color
|
|
|
|
CurrentMatch Color
|
|
|
|
Spinner Color
|
|
|
|
Info Color
|
|
|
|
Cursor Color
|
|
|
|
Selected Color
|
|
|
|
Header Color
|
|
|
|
Border Color
|
|
|
|
}
|
|
|
|
|
|
|
|
type Event struct {
|
|
|
|
Type int
|
|
|
|
Char rune
|
|
|
|
MouseEvent *MouseEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
type MouseEvent struct {
|
|
|
|
Y int
|
|
|
|
X int
|
|
|
|
S int
|
2017-11-30 17:11:20 +00:00
|
|
|
Left bool
|
2016-10-24 00:44:56 +00:00
|
|
|
Down bool
|
|
|
|
Double bool
|
|
|
|
Mod bool
|
|
|
|
}
|
|
|
|
|
2019-03-28 17:11:03 +00:00
|
|
|
type BorderShape int
|
2017-02-04 12:51:22 +00:00
|
|
|
|
|
|
|
const (
|
2019-03-28 17:11:03 +00:00
|
|
|
BorderNone BorderShape = iota
|
2017-02-04 12:51:22 +00:00
|
|
|
BorderAround
|
|
|
|
BorderHorizontal
|
|
|
|
)
|
|
|
|
|
2019-03-28 17:11:03 +00:00
|
|
|
type BorderStyle struct {
|
|
|
|
shape BorderShape
|
|
|
|
horizontal rune
|
|
|
|
vertical rune
|
|
|
|
topLeft rune
|
|
|
|
topRight rune
|
|
|
|
bottomLeft rune
|
|
|
|
bottomRight rune
|
|
|
|
}
|
|
|
|
|
2019-11-15 09:27:08 +00:00
|
|
|
type BorderCharacter int
|
|
|
|
|
2019-03-28 17:11:03 +00:00
|
|
|
func MakeBorderStyle(shape BorderShape, unicode bool) BorderStyle {
|
|
|
|
if unicode {
|
|
|
|
return BorderStyle{
|
|
|
|
shape: shape,
|
|
|
|
horizontal: '─',
|
|
|
|
vertical: '│',
|
|
|
|
topLeft: '┌',
|
|
|
|
topRight: '┐',
|
|
|
|
bottomLeft: '└',
|
|
|
|
bottomRight: '┘',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return BorderStyle{
|
|
|
|
shape: shape,
|
|
|
|
horizontal: '-',
|
|
|
|
vertical: '|',
|
|
|
|
topLeft: '+',
|
|
|
|
topRight: '+',
|
|
|
|
bottomLeft: '+',
|
|
|
|
bottomRight: '+',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 09:27:08 +00:00
|
|
|
func MakeTransparentBorder() BorderStyle {
|
|
|
|
return BorderStyle{
|
|
|
|
shape: BorderAround,
|
|
|
|
horizontal: ' ',
|
|
|
|
vertical: ' ',
|
|
|
|
topLeft: ' ',
|
|
|
|
topRight: ' ',
|
|
|
|
bottomLeft: ' ',
|
|
|
|
bottomRight: ' '}
|
|
|
|
}
|
|
|
|
|
2017-01-07 16:30:31 +00:00
|
|
|
type Renderer interface {
|
|
|
|
Init()
|
2017-04-28 13:58:08 +00:00
|
|
|
Pause(clear bool)
|
|
|
|
Resume(clear bool)
|
2017-01-07 16:30:31 +00:00
|
|
|
Clear()
|
|
|
|
RefreshWindows(windows []Window)
|
|
|
|
Refresh()
|
|
|
|
Close()
|
|
|
|
|
|
|
|
GetChar() Event
|
|
|
|
|
|
|
|
MaxX() int
|
|
|
|
MaxY() int
|
|
|
|
DoesAutoWrap() bool
|
|
|
|
|
2017-02-04 12:51:22 +00:00
|
|
|
NewWindow(top int, left int, width int, height int, borderStyle BorderStyle) Window
|
2017-01-07 16:30:31 +00:00
|
|
|
}
|
2016-10-24 00:44:56 +00:00
|
|
|
|
2017-01-07 16:30:31 +00:00
|
|
|
type Window interface {
|
|
|
|
Top() int
|
|
|
|
Left() int
|
|
|
|
Width() int
|
|
|
|
Height() int
|
|
|
|
|
|
|
|
Refresh()
|
|
|
|
FinishFill()
|
|
|
|
Close()
|
|
|
|
|
|
|
|
X() int
|
2017-07-19 13:46:16 +00:00
|
|
|
Y() int
|
2017-01-07 16:30:31 +00:00
|
|
|
Enclose(y int, x int) bool
|
|
|
|
|
|
|
|
Move(y int, x int)
|
|
|
|
MoveAndClear(y int, x int)
|
|
|
|
Print(text string)
|
|
|
|
CPrint(color ColorPair, attr Attr, text string)
|
2017-01-11 13:13:40 +00:00
|
|
|
Fill(text string) FillReturn
|
|
|
|
CFill(fg Color, bg Color, attr Attr, text string) FillReturn
|
2017-01-07 16:30:31 +00:00
|
|
|
Erase()
|
|
|
|
}
|
|
|
|
|
|
|
|
type FullscreenRenderer struct {
|
|
|
|
theme *ColorTheme
|
|
|
|
mouse bool
|
|
|
|
forceBlack bool
|
|
|
|
prevDownTime time.Time
|
|
|
|
clickY []int
|
2016-10-24 00:44:56 +00:00
|
|
|
}
|
|
|
|
|
2017-01-07 16:30:31 +00:00
|
|
|
func NewFullscreenRenderer(theme *ColorTheme, forceBlack bool, mouse bool) Renderer {
|
|
|
|
r := &FullscreenRenderer{
|
|
|
|
theme: theme,
|
|
|
|
mouse: mouse,
|
|
|
|
forceBlack: forceBlack,
|
|
|
|
prevDownTime: time.Unix(0, 0),
|
|
|
|
clickY: []int{}}
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
Default16 *ColorTheme
|
|
|
|
Dark256 *ColorTheme
|
|
|
|
Light256 *ColorTheme
|
|
|
|
|
2019-03-17 06:37:23 +00:00
|
|
|
ColPrompt ColorPair
|
|
|
|
ColNormal ColorPair
|
|
|
|
ColMatch ColorPair
|
|
|
|
ColCursor ColorPair
|
|
|
|
ColSelected ColorPair
|
|
|
|
ColCurrent ColorPair
|
|
|
|
ColCurrentMatch ColorPair
|
|
|
|
ColCurrentCursor ColorPair
|
|
|
|
ColCurrentSelected ColorPair
|
|
|
|
ColSpinner ColorPair
|
|
|
|
ColInfo ColorPair
|
|
|
|
ColHeader ColorPair
|
|
|
|
ColBorder ColorPair
|
2017-01-07 16:30:31 +00:00
|
|
|
)
|
|
|
|
|
2016-10-24 00:44:56 +00:00
|
|
|
func EmptyTheme() *ColorTheme {
|
|
|
|
return &ColorTheme{
|
|
|
|
Fg: colUndefined,
|
|
|
|
Bg: colUndefined,
|
|
|
|
DarkBg: colUndefined,
|
2019-03-17 06:37:23 +00:00
|
|
|
Gutter: colUndefined,
|
2016-10-24 00:44:56 +00:00
|
|
|
Prompt: colUndefined,
|
|
|
|
Match: colUndefined,
|
|
|
|
Current: colUndefined,
|
|
|
|
CurrentMatch: colUndefined,
|
|
|
|
Spinner: colUndefined,
|
|
|
|
Info: colUndefined,
|
|
|
|
Cursor: colUndefined,
|
|
|
|
Selected: colUndefined,
|
|
|
|
Header: colUndefined,
|
|
|
|
Border: colUndefined}
|
|
|
|
}
|
|
|
|
|
2017-01-11 14:01:56 +00:00
|
|
|
func errorExit(message string) {
|
|
|
|
fmt.Fprintln(os.Stderr, message)
|
2017-01-10 17:12:32 +00:00
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
|
2016-10-24 00:44:56 +00:00
|
|
|
func init() {
|
|
|
|
Default16 = &ColorTheme{
|
|
|
|
Fg: colDefault,
|
|
|
|
Bg: colDefault,
|
|
|
|
DarkBg: colBlack,
|
2019-12-12 13:53:28 +00:00
|
|
|
Gutter: colUndefined,
|
2016-10-24 00:44:56 +00:00
|
|
|
Prompt: colBlue,
|
|
|
|
Match: colGreen,
|
|
|
|
Current: colYellow,
|
|
|
|
CurrentMatch: colGreen,
|
|
|
|
Spinner: colGreen,
|
|
|
|
Info: colWhite,
|
|
|
|
Cursor: colRed,
|
|
|
|
Selected: colMagenta,
|
|
|
|
Header: colCyan,
|
|
|
|
Border: colBlack}
|
|
|
|
Dark256 = &ColorTheme{
|
|
|
|
Fg: colDefault,
|
|
|
|
Bg: colDefault,
|
|
|
|
DarkBg: 236,
|
2019-03-17 06:37:23 +00:00
|
|
|
Gutter: colUndefined,
|
2016-10-24 00:44:56 +00:00
|
|
|
Prompt: 110,
|
|
|
|
Match: 108,
|
|
|
|
Current: 254,
|
|
|
|
CurrentMatch: 151,
|
|
|
|
Spinner: 148,
|
|
|
|
Info: 144,
|
|
|
|
Cursor: 161,
|
|
|
|
Selected: 168,
|
|
|
|
Header: 109,
|
|
|
|
Border: 59}
|
|
|
|
Light256 = &ColorTheme{
|
|
|
|
Fg: colDefault,
|
|
|
|
Bg: colDefault,
|
|
|
|
DarkBg: 251,
|
2019-03-17 06:37:23 +00:00
|
|
|
Gutter: colUndefined,
|
2016-10-24 00:44:56 +00:00
|
|
|
Prompt: 25,
|
|
|
|
Match: 66,
|
|
|
|
Current: 237,
|
|
|
|
CurrentMatch: 23,
|
|
|
|
Spinner: 65,
|
|
|
|
Info: 101,
|
|
|
|
Cursor: 161,
|
|
|
|
Selected: 168,
|
|
|
|
Header: 31,
|
|
|
|
Border: 145}
|
|
|
|
}
|
|
|
|
|
2017-01-07 16:30:31 +00:00
|
|
|
func initTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool) {
|
|
|
|
if theme == nil {
|
|
|
|
initPalette(theme)
|
2016-10-24 00:44:56 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-01-07 16:30:31 +00:00
|
|
|
if forceBlack {
|
2016-10-24 00:44:56 +00:00
|
|
|
theme.Bg = colBlack
|
|
|
|
}
|
|
|
|
|
|
|
|
o := func(a Color, b Color) Color {
|
|
|
|
if b == colUndefined {
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
theme.Fg = o(baseTheme.Fg, theme.Fg)
|
|
|
|
theme.Bg = o(baseTheme.Bg, theme.Bg)
|
|
|
|
theme.DarkBg = o(baseTheme.DarkBg, theme.DarkBg)
|
2019-03-17 06:37:23 +00:00
|
|
|
theme.Gutter = o(theme.DarkBg, o(baseTheme.Gutter, theme.Gutter))
|
2016-10-24 00:44:56 +00:00
|
|
|
theme.Prompt = o(baseTheme.Prompt, theme.Prompt)
|
|
|
|
theme.Match = o(baseTheme.Match, theme.Match)
|
|
|
|
theme.Current = o(baseTheme.Current, theme.Current)
|
|
|
|
theme.CurrentMatch = o(baseTheme.CurrentMatch, theme.CurrentMatch)
|
|
|
|
theme.Spinner = o(baseTheme.Spinner, theme.Spinner)
|
|
|
|
theme.Info = o(baseTheme.Info, theme.Info)
|
|
|
|
theme.Cursor = o(baseTheme.Cursor, theme.Cursor)
|
|
|
|
theme.Selected = o(baseTheme.Selected, theme.Selected)
|
|
|
|
theme.Header = o(baseTheme.Header, theme.Header)
|
|
|
|
theme.Border = o(baseTheme.Border, theme.Border)
|
2017-01-07 16:30:31 +00:00
|
|
|
|
|
|
|
initPalette(theme)
|
|
|
|
}
|
|
|
|
|
|
|
|
func initPalette(theme *ColorTheme) {
|
2017-09-09 04:50:07 +00:00
|
|
|
idx := 0
|
|
|
|
pair := func(fg, bg Color) ColorPair {
|
|
|
|
idx++
|
|
|
|
return ColorPair{fg, bg, idx}
|
|
|
|
}
|
2017-01-07 16:30:31 +00:00
|
|
|
if theme != nil {
|
2017-09-09 04:50:07 +00:00
|
|
|
ColPrompt = pair(theme.Prompt, theme.Bg)
|
2019-03-17 06:37:23 +00:00
|
|
|
ColNormal = pair(theme.Fg, theme.Bg)
|
2017-09-09 04:50:07 +00:00
|
|
|
ColMatch = pair(theme.Match, theme.Bg)
|
2019-03-17 06:37:23 +00:00
|
|
|
ColCursor = pair(theme.Cursor, theme.Gutter)
|
|
|
|
ColSelected = pair(theme.Selected, theme.Gutter)
|
2017-09-09 04:50:07 +00:00
|
|
|
ColCurrent = pair(theme.Current, theme.DarkBg)
|
|
|
|
ColCurrentMatch = pair(theme.CurrentMatch, theme.DarkBg)
|
2019-03-17 06:37:23 +00:00
|
|
|
ColCurrentCursor = pair(theme.Cursor, theme.DarkBg)
|
|
|
|
ColCurrentSelected = pair(theme.Selected, theme.DarkBg)
|
2017-09-09 04:50:07 +00:00
|
|
|
ColSpinner = pair(theme.Spinner, theme.Bg)
|
|
|
|
ColInfo = pair(theme.Info, theme.Bg)
|
|
|
|
ColHeader = pair(theme.Header, theme.Bg)
|
|
|
|
ColBorder = pair(theme.Border, theme.Bg)
|
2017-01-07 16:30:31 +00:00
|
|
|
} else {
|
2017-09-09 04:50:07 +00:00
|
|
|
ColPrompt = pair(colDefault, colDefault)
|
2019-03-17 06:37:23 +00:00
|
|
|
ColNormal = pair(colDefault, colDefault)
|
2017-09-09 04:50:07 +00:00
|
|
|
ColMatch = pair(colDefault, colDefault)
|
2019-03-17 06:37:23 +00:00
|
|
|
ColCursor = pair(colDefault, colDefault)
|
|
|
|
ColSelected = pair(colDefault, colDefault)
|
2017-09-09 04:50:07 +00:00
|
|
|
ColCurrent = pair(colDefault, colDefault)
|
|
|
|
ColCurrentMatch = pair(colDefault, colDefault)
|
2019-03-17 06:37:23 +00:00
|
|
|
ColCurrentCursor = pair(colDefault, colDefault)
|
|
|
|
ColCurrentSelected = pair(colDefault, colDefault)
|
2017-09-09 04:50:07 +00:00
|
|
|
ColSpinner = pair(colDefault, colDefault)
|
|
|
|
ColInfo = pair(colDefault, colDefault)
|
|
|
|
ColHeader = pair(colDefault, colDefault)
|
|
|
|
ColBorder = pair(colDefault, colDefault)
|
2017-01-07 16:30:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func attrFor(color ColorPair, attr Attr) Attr {
|
|
|
|
switch color {
|
|
|
|
case ColCurrent:
|
|
|
|
return attr | Reverse
|
|
|
|
case ColMatch:
|
|
|
|
return attr | Underline
|
|
|
|
case ColCurrentMatch:
|
|
|
|
return attr | Underline | Reverse
|
|
|
|
}
|
|
|
|
return attr
|
2016-10-24 00:44:56 +00:00
|
|
|
}
|