-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstate.go
48 lines (41 loc) · 1.56 KB
/
state.go
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
package vterm
//#include "vterm.h"
//#include "go_colors.h"
import "C"
// DefaultColors returns the default foreground/background colors.
func (vt *VTerm) DefaultColors() (fg, bg *Color) {
fg = &Color{}
bg = &Color{}
C.vterm_state_get_default_colors(vt.state, (*C.VTermColor)(fg), (*C.VTermColor)(bg))
return
}
// SetDefaultColors sets the default foreground/background colors.
func (vt *VTerm) SetDefaultColors(fg, bg *Color) {
C.vterm_state_set_default_colors(vt.state, (*C.VTermColor)(fg), (*C.VTermColor)(bg))
}
// PaletteColor gets the palette color of the given index.
func (vt *VTerm) PaletteColor(index int) (col *Color) {
col = &Color{}
C.vterm_state_get_palette_color(vt.state, C.int(index), (*C.VTermColor)(col))
return
}
// SetPaletteColor sets the palette color for the given index.
func (vt *VTerm) SetPaletteColor(index int, col *Color) {
C.vterm_state_set_palette_color(vt.state, C.int(index), (*C.VTermColor)(col))
}
// ConvertRGB converts the Color instance to RGB format (if it is not) using
// VTermState's internal palette, and then returns the RGB values.
func (vt *VTerm) ConvertRGB(c *Color) (r, g, b uint8) {
C.vterm_state_convert_color_to_rgb(vt.state, (*C.VTermColor)(c))
var rc, gc, bc C.uint8_t
C.goGetColorRGB((*C.VTermColor)(c), &rc, &gc, &bc)
return uint8(rc), uint8(gc), uint8(bc)
}
// SetBoldHighbright sets whether to use a brighter foreground on text set to bold.
func (vt *VTerm) SetBoldHighbright(enabled bool) {
if enabled {
C.vterm_state_set_bold_highbright(vt.state, 1)
} else {
C.vterm_state_set_bold_highbright(vt.state, 0)
}
}