|
|
@@ -2,6 +2,7 @@
|
|
|
package cell
|
|
|
|
|
|
import (
|
|
|
+ "github.com/gdamore/tcell"
|
|
|
"p78git.ddns.net/svi/libtui/alias"
|
|
|
"p78git.ddns.net/svi/libtui/pos"
|
|
|
"p78git.ddns.net/svi/libtui/types"
|
|
|
@@ -9,9 +10,18 @@ import (
|
|
|
|
|
|
// Cell -- ячейка для отрисовки на экране
|
|
|
type Cell struct {
|
|
|
- pos types.IPos
|
|
|
- lit alias.Lit
|
|
|
- style alias.Style
|
|
|
+ pos types.IPos
|
|
|
+ lit alias.Lit
|
|
|
+ style alias.Style
|
|
|
+ bgColor alias.Color
|
|
|
+ fgColor alias.Color
|
|
|
+ isBold bool
|
|
|
+ isBlink bool
|
|
|
+ isReverse bool
|
|
|
+ isUnderline bool
|
|
|
+ isDim bool
|
|
|
+ isItalic bool
|
|
|
+ isNormal bool
|
|
|
}
|
|
|
|
|
|
// NewCell -- возвращает новую знакоместо экрана
|
|
|
@@ -47,7 +57,46 @@ func (sf *Cell) Style() alias.Style {
|
|
|
return sf.style
|
|
|
}
|
|
|
|
|
|
+// BgColorSet -- устанавливает фон ячейки
|
|
|
+func (sf *Cell) BgColorSet(bgColor alias.Color) {
|
|
|
+ sf.bgColor = bgColor
|
|
|
+ st := tcell.Style(sf.style)
|
|
|
+ st = st.Background(tcell.Color(bgColor))
|
|
|
+ sf.style = alias.Style(st)
|
|
|
+}
|
|
|
+
|
|
|
+// BgColor -- возвращает цвет фона ячейки
|
|
|
+func (sf *Cell) BgColor() alias.Color {
|
|
|
+ return sf.bgColor
|
|
|
+}
|
|
|
+
|
|
|
// SetStyle -- устанавливает стиль ячейки
|
|
|
-func (sf *Cell) SetStyle(style alias.Style) {
|
|
|
- sf.style = style
|
|
|
+func (sf *Cell) SetStyle(st alias.Style) {
|
|
|
+ fg, bg, attr := tcell.Style(st).Decompose()
|
|
|
+ sf.bgColor = alias.Color(bg)
|
|
|
+ sf.fgColor = alias.Color(fg)
|
|
|
+ sf.isBold = attr&tcell.AttrBold != 0
|
|
|
+ sf.isBlink = attr&tcell.AttrBlink != 0
|
|
|
+ sf.isReverse = attr&tcell.AttrReverse != 0
|
|
|
+ sf.isUnderline = attr&tcell.AttrUnderline != 0
|
|
|
+ sf.isDim = attr&tcell.AttrDim != 0
|
|
|
+ sf.isItalic = attr&tcell.AttrItalic != 0
|
|
|
+ sf.isNormal = false
|
|
|
+ if !(sf.isBlink || sf.isBold || sf.isReverse || sf.isUnderline || sf.isDim || sf.isItalic) {
|
|
|
+ sf.isNormal = true
|
|
|
+ }
|
|
|
+ sf.style = st
|
|
|
+}
|
|
|
+
|
|
|
+// FgColor -- возвращает цвет литеры
|
|
|
+func (sf *Cell) FgColor() alias.Color {
|
|
|
+ return sf.fgColor
|
|
|
+}
|
|
|
+
|
|
|
+// FgColorSet -- устанавливает новый цвет литеры
|
|
|
+func (sf *Cell) FgColorSet(fgColor alias.Color) {
|
|
|
+ sf.fgColor = fgColor
|
|
|
+ st := tcell.Style(sf.style)
|
|
|
+ st = st.Foreground(tcell.Color(fgColor))
|
|
|
+ sf.style = alias.Style(st)
|
|
|
}
|