diff --git a/editor/draw.go b/editor/draw.go index 3b867be..c9e33d4 100644 --- a/editor/draw.go +++ b/editor/draw.go @@ -8,6 +8,7 @@ import ( "timshome.page/gilo/editor/highlight" "timshome.page/gilo/internal/gilo" "timshome.page/gilo/terminal" + "unicode" ) // ---------------------------------------------------------------------------- @@ -57,6 +58,7 @@ func (e *Editor) scroll() { } } +// drawRows is the equivalent to editorDrawRows in kilo func (e *Editor) drawRows(ab *gilo.Buffer) { for y := 0; y < e.screen.Rows; y++ { fileRow := y + e.offset.Y @@ -89,7 +91,19 @@ func (e *Editor) drawFileRow(fileRow int, ab *gilo.Buffer) { // this by runes so that multibyte-characters (like emoji) can // all be displayed for i, ch := range row.RenderRune(e.offset) { - if row.Hl[i] == highlight.Normal { + if unicode.IsControl(ch) { + sym := '?' + if ch <= 26 { + sym = '@' + ch + } + + ab.Append(terminal.InvertColor) + ab.AppendRune(sym) + ab.Append(terminal.ResetColor) + if currentColor != terminal.DefaultFGColor { + ab.Append(currentColor) + } + } else if row.Hl[i] == highlight.Normal { if currentColor != terminal.DefaultFGColor { ab.Append(terminal.DefaultFGColor) currentColor = terminal.DefaultFGColor @@ -189,6 +203,7 @@ func (e *Editor) drawStatusBar(ab *gilo.Buffer) { ab.Append(terminal.ResetColor) } +// drawMessageBar is the equivalent of editorDrawMessageBar in kilo func (e *Editor) drawMessageBar(ab *gilo.Buffer) { ab.Append("\r\n") ab.Append(terminal.ClearLine)