From 51f01a12d66dd05191992c17b13188f292a008bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20Bulut?= <73897211+hismailbulut@users.noreply.github.com> Date: Sun, 10 Jul 2022 18:28:57 +0300 Subject: [PATCH] Fix cursor color --- src/common/color.go | 46 ++++++++----------- src/common/common.go | 34 +++++++-------- src/common/math.go | 10 +---- src/common/rect.go | 6 +-- src/common/vector.go | 46 ++++++++++--------- src/context_menu.go | 16 ++++--- src/cursor.go | 37 +++++++++++----- src/editor.go | 2 +- src/grid.go | 7 +-- src/grid_events.go | 16 ++++--- src/grid_manager.go | 58 +++++++++++++----------- src/opengl/buffer.go | 12 ++--- src/opengl/opengl.go | 3 +- src/style.go | 102 ++++++++++++++++++++++--------------------- 14 files changed, 207 insertions(+), 188 deletions(-) diff --git a/src/common/color.go b/src/common/color.go index 4acb7ed..201f84f 100644 --- a/src/common/color.go +++ b/src/common/color.go @@ -1,40 +1,32 @@ package common -import "fmt" +import ( + "fmt" +) // Zero values for reducing allocations var ( - ZeroColorF32 = F32Color{} - ZeroColorU8 = U8Color{} + ZeroColorF32 = Color[float32]{} + ZeroColorU8 = Color[uint8]{} ) -// We can't use generics for color types - -type F32Color struct { - R, G, B, A float32 -} - -func (c F32Color) String() string { - return fmt.Sprintf("F32Color(R: %f, G: %f, B: %f, A: %f)", c.R, c.G, c.B, c.A) +type Color[T Numbers] struct { + R, G, B, A T } -type U8Color struct { - R, G, B, A uint8 +func (c Color[T]) String() string { + return fmt.Sprintf("%T(R: %v, G: %v, B: %v, A: %v)", c, c.R, c.G, c.B, c.A) } -func (c U8Color) String() string { - return fmt.Sprintf("U8Color(R: %d, G: %d, B: %d, A: %d)", c.R, c.G, c.B, c.A) -} - -func (color U8Color) Pack() uint32 { - rgb24 := uint32(color.R) - rgb24 = (rgb24 << 8) | uint32(color.G) - rgb24 = (rgb24 << 8) | uint32(color.B) - return rgb24 -} +// func (color Color[T]) Pack() uint32 { +// rgb24 := uint32(color.R) +// rgb24 = (rgb24 << 8) | uint32(color.G) +// rgb24 = (rgb24 << 8) | uint32(color.B) +// return rgb24 +// } -func ColorFromUint(color uint32) U8Color { - return U8Color{ +func ColorFromUint(color uint32) Color[uint8] { + return Color[uint8]{ R: uint8((color >> 16) & 0xff), G: uint8((color >> 8) & 0xff), B: uint8(color & 0xff), @@ -42,8 +34,8 @@ func ColorFromUint(color uint32) U8Color { } } -func (c U8Color) ToF32() F32Color { - return F32Color{ +func (c Color[T]) ToF32() Color[float32] { + return Color[float32]{ R: float32(c.R) / 255, G: float32(c.G) / 255, B: float32(c.B) / 255, diff --git a/src/common/common.go b/src/common/common.go index ccdca45..5d365c8 100644 --- a/src/common/common.go +++ b/src/common/common.go @@ -14,7 +14,7 @@ type Animation struct { // delta time and lifetime. For lifeTime parameter, 1.0 value is 1 seconds func NewAnimation(from, to Vector2[float32], lifeTime float32) Animation { if lifeTime <= 0 { - panic("animation must has non zero lifetime") + panic("animation lifetime must bigger than zero") } return Animation{ from: from, @@ -50,27 +50,27 @@ func (atomicBool *AtomicBool) Get() bool { return val != 0 } -type AtomicInt int64 - -func (atomicInt *AtomicInt) Set(value int64) { - atomic.StoreInt64((*int64)(atomicInt), value) -} - -func (atomicInt *AtomicInt) Get() int64 { - return atomic.LoadInt64((*int64)(atomicInt)) -} - -func (atomicInt *AtomicInt) Increment() { - atomicInt.Set(atomicInt.Get() + 1) -} +// type AtomicInt int64 +// +// func (atomicInt *AtomicInt) Set(value int64) { +// atomic.StoreInt64((*int64)(atomicInt), value) +// } +// +// func (atomicInt *AtomicInt) Get() int64 { +// return atomic.LoadInt64((*int64)(atomicInt)) +// } +// +// func (atomicInt *AtomicInt) Increment() { +// atomicInt.Set(atomicInt.Get() + 1) +// } // This is just for making code more readable -// Can hold up to 16 enums -type BitMask uint16 +// Can hold up to 32 enums +type BitMask uint32 func (mask BitMask) String() string { str := "" - for i := 15; i >= 0; i-- { + for i := 31; i >= 0; i-- { if mask.Has(1 << i) { str += "1" } else { diff --git a/src/common/math.go b/src/common/math.go index 142905e..e8e99aa 100644 --- a/src/common/math.go +++ b/src/common/math.go @@ -13,16 +13,8 @@ type Floats interface { float32 | float64 } -func Lerp[T Floats](a, b, f T) T { - return (a * (1.0 - f)) + (b * f) -} - -type SignedNumbers interface { - Integers | Floats -} - type Numbers interface { - SignedNumbers | UnsignedIntegers + Integers | UnsignedIntegers | Floats } func Min[T Numbers](v1, v2 T) T { diff --git a/src/common/rect.go b/src/common/rect.go index f1fa466..bd1f6b7 100644 --- a/src/common/rect.go +++ b/src/common/rect.go @@ -11,15 +11,15 @@ var ( ZeroRectangleINT = Rectangle[int]{} ) -type Rectangle[T SignedNumbers] struct { +type Rectangle[T Numbers] struct { X, Y, W, H T } func (rect Rectangle[T]) String() string { - return fmt.Sprint("Rect(X: ", rect.X, ", Y: ", rect.Y, ", W: ", rect.W, ", H: ", rect.H, ")") + return fmt.Sprintf("%T(X: %v, Y: %v, W: %v, H: %v)", rect, rect.X, rect.Y, rect.W, rect.H) } -func Rect[T SignedNumbers](X, Y, W, H T) Rectangle[T] { +func Rect[T Numbers](X, Y, W, H T) Rectangle[T] { return Rectangle[T]{X: X, Y: Y, W: W, H: H} } diff --git a/src/common/vector.go b/src/common/vector.go index 6d18fbd..19f97cb 100644 --- a/src/common/vector.go +++ b/src/common/vector.go @@ -13,12 +13,16 @@ var ( // We will use generics for vectors -type Vector2[T SignedNumbers] struct { +type Vector2[T Numbers] struct { X, Y T } +func (v Vector2[T]) String() string { + return fmt.Sprintf("%T(X: %v, Y: %v)", v, v.X, v.Y) +} + // just a shortcut -func Vec2[T SignedNumbers](X, Y T) Vector2[T] { +func Vec2[T Numbers](X, Y T) Vector2[T] { return Vector2[T]{X: X, Y: Y} } @@ -30,17 +34,6 @@ func (v Vector2[T]) Height() T { return v.Y } -var ( - Vec2Up = Vector2[float32]{X: 0, Y: -1} - Vec2Down = Vector2[float32]{X: 0, Y: 1} - Vec2Left = Vector2[float32]{X: -1, Y: 0} - Vec2Right = Vector2[float32]{X: 1, Y: 0} -) - -func (v Vector2[T]) String() string { - return fmt.Sprintf("Vec2(X: %v, Y: %v)", v.X, v.Y) -} - func (v Vector2[T]) ToVec3(Z T) Vector3[T] { return Vector3[T]{X: v.X, Y: v.Y, Z: Z} } @@ -80,17 +73,17 @@ func (v Vector2[T]) Length() float32 { return float32(math.Sqrt(float64(v.X*v.X + v.Y*v.Y))) } -func (v Vector2[T]) LengthSquare() float32 { - return float32(v.X*v.X + v.Y*v.Y) -} +// func (v Vector2[T]) LengthSquare() float32 { +// return float32(v.X*v.X + v.Y*v.Y) +// } -func (v Vector2[T]) Distance(v2 Vector2[T]) float32 { - return v2.Minus(v).Length() -} +// func (v Vector2[T]) Distance(v2 Vector2[T]) float32 { +// return v2.Minus(v).Length() +// } -func (v Vector2[T]) DistanceSquare(v2 Vector2[T]) float32 { - return v2.Minus(v).LengthSquare() -} +// func (v Vector2[T]) DistanceSquare(v2 Vector2[T]) float32 { +// return v2.Minus(v).LengthSquare() +// } func (v Vector2[T]) Normalized() Vector2[T] { return v.DivideScalar(T(v.Length())) @@ -108,11 +101,16 @@ func (v Vector2[T]) IsInRect(rect Rectangle[T]) bool { return v.X >= rect.X && v.Y >= rect.Y && v.X < rect.X+rect.W && v.Y < rect.Y+rect.H } -type Vector3[T SignedNumbers] struct { +type Vector3[T Numbers] struct { X, Y, Z T } -func Vec3[T SignedNumbers](X, Y, Z T) Vector3[T] { +func (v Vector3[T]) String() string { + return fmt.Sprintf("%T(X: %v, Y: %v, Z: %v)", v, v.X, v.Y, v.Z) +} + +// just a shortcut +func Vec3[T Numbers](X, Y, Z T) Vector3[T] { return Vector3[T]{X: X, Y: Y, Z: Z} } diff --git a/src/context_menu.go b/src/context_menu.go index 37bf8a4..0d13083 100644 --- a/src/context_menu.go +++ b/src/context_menu.go @@ -138,14 +138,20 @@ func (menu *ContextMenu) Draw() { for row := 0; row < menu.rows; row++ { for col := 0; col < menu.cols; col++ { char := menu.cells[row][col] - attrib, _ := Editor.gridManager.Attribute(0) - attrib.bold = true if menu.hlRow == row && col > 0 && col < menu.cols-1 { - menu.renderer.DrawCell(row, col, char, attrib) + // This is the highlighted cell + menu.renderer.DrawCell(row, col, char, HighlightAttribute{ + foreground: Editor.gridManager.foreground, + background: Editor.gridManager.background, + bold: true, + }) } else { // Normally we swap menu colors - attrib.foreground, attrib.background = attrib.background, attrib.foreground - menu.renderer.DrawCell(row, col, char, attrib) + menu.renderer.DrawCell(row, col, char, HighlightAttribute{ + foreground: Editor.gridManager.background, + background: Editor.gridManager.foreground, + bold: true, + }) } } } diff --git a/src/cursor.go b/src/cursor.go index b751e21..ca163fc 100644 --- a/src/cursor.go +++ b/src/cursor.go @@ -167,6 +167,24 @@ func (cursor *Cursor) modeRectangle(info ModeInfo, position, cellSize common.Vec } } +func (cursor *Cursor) AttributeColors(id int) (common.Color[uint8], common.Color[uint8]) { + // When attr_id is 0 we are using cursor foreground for default background and background for default foreground + fg := Editor.gridManager.background + bg := Editor.gridManager.foreground + if id != 0 { + attrib, ok := Editor.gridManager.attributes[id] + if ok { + if attrib.foreground.A > 0 { + fg = attrib.foreground + } + if attrib.background.A > 0 { + bg = attrib.background + } + } + } + return fg, bg +} + func (cursor *Cursor) Draw(delta float32) { if cursor.hidden || cursor.bHidden { return @@ -175,12 +193,8 @@ func (cursor *Cursor) Draw(delta float32) { defer EndBenchmark("Cursor.Draw") // Draw modeInfo := cursor.mode.Current() - cursorAttrib, found := Editor.gridManager.Attribute(modeInfo.attr_id) - // Reverse colors if attribute not found - if !found { - cursorAttrib.foreground, cursorAttrib.background = cursorAttrib.background, cursorAttrib.foreground - } - // Current grid where cursor is + cursorFg, cursorBg := cursor.AttributeColors(modeInfo.attr_id) + // Current grid where the cursor is grid := cursor.Grid() if grid != nil { pos := cursor.anim.Step(delta).ToInt() @@ -190,19 +204,18 @@ func (cursor *Cursor) Draw(delta float32) { // has a printable character and cursor shape is block if cursor.anim.IsFinished() && cell.char != 0 && blockShaped { // We need to draw cell character to the cursor foreground - cellAttrib, _ := Editor.gridManager.Attribute(cell.attribID) + cellAttrib := Editor.gridManager.Attribute(cell.attribID) // Draw undercurl to cursor if cell has if cellAttrib.undercurl { - cursor.buffer.SetIndexSp(0, cursorAttrib.foreground.ToF32()) + cursor.buffer.SetIndexSp(0, cursorFg.ToF32()) } // Draw this cell to the cursor charPos := grid.renderer.atlas.GetCharPos(cell.char, cellAttrib.bold, cellAttrib.italic, cellAttrib.underline, cellAttrib.strikethrough, grid.CellSize()) if charPos.W > grid.CellSize().Width() { charPos.W /= 2 } - normalized := grid.renderer.atlas.Normalize(charPos) - cursor.buffer.SetIndexTex1(0, normalized) - cursor.buffer.SetIndexFg(0, cursorAttrib.foreground.ToF32()) + cursor.buffer.SetIndexTex1(0, grid.renderer.atlas.Normalize(charPos)) + cursor.buffer.SetIndexFg(0, cursorFg.ToF32()) } else { // No cell drawing needed. Clear foreground. cursor.buffer.SetIndexTex1(0, common.ZeroRectangleF32) @@ -210,7 +223,7 @@ func (cursor *Cursor) Draw(delta float32) { cursor.buffer.SetIndexSp(0, common.ZeroColorF32) } // Background and position is always required - cursor.buffer.SetIndexBg(0, cursorAttrib.background.ToF32()) + cursor.buffer.SetIndexBg(0, cursorBg.ToF32()) cursor.buffer.SetIndexPos(0, rect) } } diff --git a/src/editor.go b/src/editor.go index aedd92c..8558cb8 100644 --- a/src/editor.go +++ b/src/editor.go @@ -272,7 +272,7 @@ func UpdateHandler(delta float32) { // Render calls if Editor.cDraw || Editor.cForceDraw || Editor.cRender { EndBenchmark := bench.BeginBenchmark() - Editor.window.GL().ClearScreen(Editor.gridManager.defaultBg) + Editor.window.GL().ClearScreen(Editor.gridManager.background.ToF32()) Editor.gridManager.Render() Editor.cursor.Render() Editor.contextMenu.Render() diff --git a/src/grid.go b/src/grid.go index 2ee450c..ebc57af 100644 --- a/src/grid.go +++ b/src/grid.go @@ -31,7 +31,7 @@ func (gridType GridType) String() string { } // Because of the struct packing, this order of elements is important -// Current size of the Cell is 16 bytes +// Current size of the Cell is 16 bytes in 64 bit systems type Cell struct { needsDraw bool char rune @@ -60,7 +60,7 @@ type Grid struct { // For debugging purposes. func (grid *Grid) String() string { - return fmt.Sprintf("Grid(ID: %d, Number: %d, Type: %s, Pos: %d %d, PixelPos: %v, Size: %d %d, WinID: %d, Hidden: %t)", + return fmt.Sprintf("Grid(ID: %d, Number: %d, Type: %s, Pos: %d %d, PixelPos: %v, Size: %d %d, Window: %d, Hidden: %t)", grid.id, grid.number, grid.typ, @@ -215,8 +215,9 @@ func (grid *Grid) Draw(force bool) { for col := 0; col < grid.cols; col++ { cell := grid.CellAt(row, col) if force || cell.needsDraw { - attrib, _ := Editor.gridManager.Attribute(cell.attribID) + attrib := Editor.gridManager.Attribute(cell.attribID) // Override background alpha + // TODO We must check whether it is default background or not attrib.background.A = uint8(Editor.options.transparency * 255) grid.renderer.DrawCell(row, col, cell.char, attrib) cell.needsDraw = false diff --git a/src/grid_events.go b/src/grid_events.go index 7f8860a..29468e4 100644 --- a/src/grid_events.go +++ b/src/grid_events.go @@ -190,9 +190,9 @@ func (manager *GridManager) default_colors_set(args []interface{}) { fg := v.Index(0).Elem().Convert(t_uint).Uint() bg := v.Index(1).Elem().Convert(t_uint).Uint() sp := v.Index(2).Elem().Convert(t_uint).Uint() - manager.defaultFg = common.ColorFromUint(uint32(fg)) - manager.defaultBg = common.ColorFromUint(uint32(bg)) - manager.defaultSp = common.ColorFromUint(uint32(sp)) + manager.foreground = common.ColorFromUint(uint32(fg)) + manager.background = common.ColorFromUint(uint32(bg)) + manager.special = common.ColorFromUint(uint32(sp)) // NOTE: Unlike the corresponding |ui-grid-old| events, the screen is not // always cleared after sending this event. The UI must repaint the // screen with changed background color itself. @@ -234,10 +234,16 @@ func (manager *GridManager) hl_attr_define(args []interface{}) { hl_attr.strikethrough = true case "underline": hl_attr.underline = true + case "underlineline": + // hl_attr.underlineline = true case "undercurl": hl_attr.undercurl = true + case "underdot": + // hl_attr.underdot = true + case "underdash": + // hl_attr.underdash = true case "blend": - hl_attr.blend = int(val.Convert(t_uint).Uint()) + // hl_attr.blend = int(val.Convert(t_uint).Uint()) } } manager.attributes[id] = hl_attr @@ -263,7 +269,7 @@ func (manager *GridManager) grid_line(args []interface{}) { if len(str) > 0 { char = []rune(str)[0] // If this is a space, we set it to zero - // because otherwise we draw every space + // because otherwise we try to draw every space if char == ' ' { char = 0 } diff --git a/src/grid_manager.go b/src/grid_manager.go index f7e7c52..7c2f56b 100644 --- a/src/grid_manager.go +++ b/src/grid_manager.go @@ -11,15 +11,16 @@ import ( type GridManager struct { grids map[int]*Grid - attributes map[int]HighlightAttribute - defaultFg common.U8Color - defaultBg common.U8Color - defaultSp common.U8Color sortedGrids []*Grid // These are used for creating new grids totalGridsCreated int // total number of grids created (including deleted ones) kit *fontkit.FontKit // last globally set font kit fontSize float64 // last globally set font size + // style information + attributes map[int]HighlightAttribute + foreground common.Color[uint8] // Default foreground color + background common.Color[uint8] // Default background color + special common.Color[uint8] // Default special color } func NewGridManager() *GridManager { @@ -30,28 +31,36 @@ func NewGridManager() *GridManager { return grid } -// Returns false if attribute not found -func (manager *GridManager) Attribute(id int) (HighlightAttribute, bool) { - attrib, ok := manager.attributes[id] - if !ok { +// Attribute itself reverses the color if required, so you dont have to swap them +// for rendering grids +func (manager *GridManager) Attribute(id int) (attrib HighlightAttribute) { + var ok bool + if id == 0 { // Default attribute - attrib.foreground = manager.defaultFg - attrib.background = manager.defaultBg - attrib.special = manager.defaultSp - } - if attrib.foreground.A == 0 { - attrib.foreground = manager.defaultFg - } - if attrib.background.A == 0 { - attrib.background = manager.defaultBg - } - if attrib.special.A == 0 { - attrib.special = manager.defaultSp - } - if attrib.reverse { - attrib.foreground, attrib.background = attrib.background, attrib.foreground + attrib.foreground = manager.foreground + attrib.background = manager.background + attrib.special = manager.special + } else { + attrib, ok = manager.attributes[id] + if !ok { + logger.LogF(logger.ERROR, "Attribute id %d not found!", id) + } + // Zero alpha means color is not set yet and we use default color + if attrib.foreground.A == 0 { + attrib.foreground = manager.foreground + } + if attrib.background.A == 0 { + attrib.background = manager.background + } + if attrib.special.A == 0 { + attrib.special = manager.special + } + // Reverse foreground an background colors if reverse attribute set + if attrib.reverse { + attrib.foreground, attrib.background = attrib.background, attrib.foreground + } } - return attrib, ok + return attrib } // Font related @@ -78,7 +87,6 @@ func (manager *GridManager) ResetFontSize() { for _, grid := range manager.grids { grid.SetFontSize(grid.renderer.FontSize(), Editor.window.DPI()) } - // manager.fontSize = fontSize manager.CheckDefaultGridSize() } diff --git a/src/opengl/buffer.go b/src/opengl/buffer.go index 3c29f0f..b88fbd7 100644 --- a/src/opengl/buffer.go +++ b/src/opengl/buffer.go @@ -18,11 +18,11 @@ type Vertex struct { // second texture position used for multiwidth characters tex2 common.Rectangle[float32] // layout 2 // foreground color - fg common.F32Color // layout 3 + fg common.Color[float32] // layout 3 // background color - bg common.F32Color // layout 4 + bg common.Color[float32] // layout 4 // special color - sp common.F32Color // layout 5 + sp common.Color[float32] // layout 5 } func (vertex Vertex) String() string { @@ -196,15 +196,15 @@ func (buffer *VertexBuffer) SetIndexTex2(index int, tex2 common.Rectangle[float3 buffer.data[index].tex2 = tex2 } -func (buffer *VertexBuffer) SetIndexFg(index int, fg common.F32Color) { +func (buffer *VertexBuffer) SetIndexFg(index int, fg common.Color[float32]) { buffer.data[index].fg = fg } -func (buffer *VertexBuffer) SetIndexBg(index int, bg common.F32Color) { +func (buffer *VertexBuffer) SetIndexBg(index int, bg common.Color[float32]) { buffer.data[index].bg = bg } -func (buffer *VertexBuffer) SetIndexSp(index int, sp common.F32Color) { +func (buffer *VertexBuffer) SetIndexSp(index int, sp common.Color[float32]) { buffer.data[index].sp = sp } diff --git a/src/opengl/opengl.go b/src/opengl/opengl.go index 3466f6d..3f2d76f 100644 --- a/src/opengl/opengl.go +++ b/src/opengl/opengl.go @@ -62,8 +62,7 @@ func (context *Context) SetViewport(rect common.Rectangle[int]) { }) } -func (context *Context) ClearScreen(color common.U8Color) { - c := color.ToF32() +func (context *Context) ClearScreen(c common.Color[float32]) { CheckGLError(func() { gl.ClearColor(c.R, c.G, c.B, c.A) gl.Clear(gl.COLOR_BUFFER_BIT) diff --git a/src/style.go b/src/style.go index 4260fc8..53841c6 100644 --- a/src/style.go +++ b/src/style.go @@ -34,69 +34,73 @@ func CreateUIOptions() UIOptions { func (options *UIOptions) setGuiFont(guifont string) { // Load Font - if guifont != options.guifont { - options.guifont = guifont - var size float64 = DEFAULT_FONT_SIZE - // treat underlines like whitespaces - guifont = strings.ReplaceAll(guifont, "_", " ") - // parse font options - fontOptions := strings.Split(guifont, ":") - name := fontOptions[0] - for _, opt := range fontOptions[1:] { - if len(opt) > 1 && opt[0] == 'h' { - // Font size - tsize, err := strconv.ParseFloat(opt[1:], 32) - if err == nil { - size = tsize - } + if guifont == options.guifont { + return + } + options.guifont = guifont + var size float64 = DEFAULT_FONT_SIZE + // treat underlines like whitespaces + guifont = strings.ReplaceAll(guifont, "_", " ") + // parse font options + fontOptions := strings.Split(guifont, ":") + name := fontOptions[0] + for _, opt := range fontOptions[1:] { + if len(opt) > 1 && opt[0] == 'h' { + // Font size + tsize, err := strconv.ParseFloat(opt[1:], 32) + if err == nil { + size = tsize } } - if name == "" { - // Set nil to disable font - Editor.gridManager.SetGridFontKit(1, nil) - Editor.contextMenu.SetFontKit(nil) + } + if name == "" { + // Set nil to disable font + Editor.gridManager.SetGridFontKit(1, nil) + Editor.contextMenu.SetFontKit(nil) + } else { + // Create and set font + logger.Log(logger.TRACE, "Loading font", name) + kit, err := fontkit.CreateKit(name) + if err != nil { + Editor.nvim.echoErr("Font %s not found", name) } else { - // Create and set font - logger.Log(logger.TRACE, "Loading font", name) - kit, err := fontkit.CreateKit(name) - if err != nil { - Editor.nvim.echoErr("Font %s not found", name) - } else { - // Log some info - if kit.Regular() != nil { - logger.Log(logger.TRACE, "Regular:", kit.Regular().FilePath()) - } - if kit.Bold() != nil { - logger.Log(logger.TRACE, "Bold:", kit.Bold().FilePath()) - } - if kit.Italic() != nil { - logger.Log(logger.TRACE, "Italic:", kit.Italic().FilePath()) - } - if kit.BoldItalic() != nil { - logger.Log(logger.TRACE, "BoldItalic:", kit.BoldItalic().FilePath()) - } - // Set fonts - Editor.gridManager.SetGridFontKit(1, kit) - Editor.contextMenu.SetFontKit(kit) + // Log some info + if kit.Regular() != nil { + logger.Log(logger.TRACE, "Regular:", kit.Regular().FilePath()) + } + if kit.Bold() != nil { + logger.Log(logger.TRACE, "Bold:", kit.Bold().FilePath()) + } + if kit.Italic() != nil { + logger.Log(logger.TRACE, "Italic:", kit.Italic().FilePath()) + } + if kit.BoldItalic() != nil { + logger.Log(logger.TRACE, "BoldItalic:", kit.BoldItalic().FilePath()) } + // Set fonts + Editor.gridManager.SetGridFontKit(1, kit) + Editor.contextMenu.SetFontKit(kit) } - // Always set font size to default if user not set - Editor.gridManager.SetGridFontSize(1, size) - Editor.contextMenu.SetFontSize(size) } + // Always set font size to default if user not set + Editor.gridManager.SetGridFontSize(1, size) + Editor.contextMenu.SetFontSize(size) } type HighlightAttribute struct { - foreground common.U8Color - background common.U8Color - special common.U8Color + foreground common.Color[uint8] + background common.Color[uint8] + special common.Color[uint8] reverse bool italic bool bold bool strikethrough bool underline bool - undercurl bool - blend int + // underlineline bool + undercurl bool + // underdot bool + // underdash bool + // blend int } type ModeInfo struct {