-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle.go
40 lines (32 loc) · 913 Bytes
/
style.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
package zedit
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/widget"
)
type Style struct {
Bold, Italic, Monospace bool
FGColor, BGColor color.Color
}
var EmptyStyle = Style{}
func (s Style) ToTextGridStyle() widget.TextGridStyle {
return &widget.CustomTextGridStyle{TextStyle: fyne.TextStyle{Bold: s.Bold, Italic: s.Italic, Monospace: s.Monospace},
FGColor: s.FGColor, BGColor: s.BGColor}
}
type Cell struct {
Rune rune
Style Style
}
func (c Cell) ToTextGridCell() widget.TextGridCell {
return widget.TextGridCell{Rune: c.Rune, Style: c.Style.ToTextGridStyle()}
}
func NewCellFromTextGridCell(cell widget.TextGridCell) Cell {
if cell.Style == nil {
return Cell{Rune: cell.Rune, Style: Style{}}
}
return Cell{
Rune: cell.Rune,
Style: Style{Bold: false, Italic: false, Monospace: true,
FGColor: cell.Style.TextColor(), BGColor: cell.Style.BackgroundColor()},
}
}