1
0
Fork 0

Complete Chapter 7 Step 176
timw4mail/gilo/pipeline/head This commit looks good Details

This commit is contained in:
Timothy Warren 2023-10-05 15:29:37 -04:00
parent 74b59ed4fa
commit 5ff459b6ad
1 changed files with 16 additions and 1 deletions

View File

@ -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)