From 976682d2d2868a0feccd7f8a6789e433d5e350d5 Mon Sep 17 00:00:00 2001 From: bloeys Date: Sat, 24 Sep 2022 07:15:16 +0400 Subject: [PATCH] Don't show text in the cmd entry area --- glyph_grid.go | 16 +++++++++++++--- main.go | 10 ++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/glyph_grid.go b/glyph_grid.go index 2e2483e..9a0c275 100755 --- a/glyph_grid.go +++ b/glyph_grid.go @@ -38,7 +38,19 @@ func (gg *GlyphGrid) Write(rs []rune, fgColor *gglm.Vec4, bgColor *gglm.Vec4) { } } -func (gg *GlyphGrid) Clear() { +func (gg *GlyphGrid) ClearRow(rowIndex uint) { + + if rowIndex >= gg.SizeY { + panic(fmt.Sprintf("passed row index of %d is larger or equal than grid Y size of %d\n", rowIndex, gg.SizeY)) + } + + row := gg.Tiles[rowIndex] + for x := 0; x < len(row); x++ { + row[x].Glyph = utf8.RuneError + } +} + +func (gg *GlyphGrid) ClearAll() { for y := 0; y < len(gg.Tiles); y++ { row := gg.Tiles[y] @@ -46,8 +58,6 @@ func (gg *GlyphGrid) Clear() { row[x].Glyph = utf8.RuneError } } - - gg.SetCursor(0, 0) } func (gg *GlyphGrid) SetCursor(x, y uint) { diff --git a/main.go b/main.go index ed5a510..463a915 100755 --- a/main.go +++ b/main.go @@ -324,13 +324,18 @@ func (nt *nterm) MainUpdate() { nt.SepLinePos.SetY(2 * nt.GlyphRend.Atlas.LineHeight) // Draw textBuf - nt.glyphGrid.Clear() + nt.glyphGrid.ClearAll() + nt.glyphGrid.SetCursor(0, 0) + gw, gh := nt.GridSize() v1, v2 := nt.textBuf.ViewsFromToRelIndex(uint64(nt.scrollPosRel), uint64(nt.scrollPosRel)+uint64(gw*gh)) - nt.lastCmdCharPos.Data = gglm.NewVec3(0, float32(nt.GlyphRend.ScreenHeight)-nt.GlyphRend.Atlas.LineHeight, 0).Data + nt.DrawTextAnsiCodesOnGlyphGrid(v1) nt.DrawTextAnsiCodesOnGlyphGrid(v2) + nt.glyphGrid.ClearRow(nt.glyphGrid.SizeY - 1) + nt.glyphGrid.ClearRow(nt.glyphGrid.SizeY - 2) + nt.glyphGrid.ClearRow(nt.glyphGrid.SizeY - 3) for y := 0; y < len(nt.glyphGrid.Tiles); y++ { @@ -419,6 +424,7 @@ func (nt *nterm) ReadInputs() { func (nt *nterm) DrawTextAnsiCodesOnGlyphGrid(bs []byte) { + // @TODO: We should remember color state even if the ansi codes are out of view currFgColor := nt.Settings.DefaultFgColor currBgColor := nt.Settings.DefaultBgColor