Complete Chapter 7 Step 176
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
This commit is contained in:
parent
74b59ed4fa
commit
5ff459b6ad
@ -8,6 +8,7 @@ import (
|
|||||||
"timshome.page/gilo/editor/highlight"
|
"timshome.page/gilo/editor/highlight"
|
||||||
"timshome.page/gilo/internal/gilo"
|
"timshome.page/gilo/internal/gilo"
|
||||||
"timshome.page/gilo/terminal"
|
"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) {
|
func (e *Editor) drawRows(ab *gilo.Buffer) {
|
||||||
for y := 0; y < e.screen.Rows; y++ {
|
for y := 0; y < e.screen.Rows; y++ {
|
||||||
fileRow := y + e.offset.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
|
// this by runes so that multibyte-characters (like emoji) can
|
||||||
// all be displayed
|
// all be displayed
|
||||||
for i, ch := range row.RenderRune(e.offset) {
|
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 {
|
if currentColor != terminal.DefaultFGColor {
|
||||||
ab.Append(terminal.DefaultFGColor)
|
ab.Append(terminal.DefaultFGColor)
|
||||||
currentColor = terminal.DefaultFGColor
|
currentColor = terminal.DefaultFGColor
|
||||||
@ -189,6 +203,7 @@ func (e *Editor) drawStatusBar(ab *gilo.Buffer) {
|
|||||||
ab.Append(terminal.ResetColor)
|
ab.Append(terminal.ResetColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// drawMessageBar is the equivalent of editorDrawMessageBar in kilo
|
||||||
func (e *Editor) drawMessageBar(ab *gilo.Buffer) {
|
func (e *Editor) drawMessageBar(ab *gilo.Buffer) {
|
||||||
ab.Append("\r\n")
|
ab.Append("\r\n")
|
||||||
ab.Append(terminal.ClearLine)
|
ab.Append(terminal.ClearLine)
|
||||||
|
Loading…
Reference in New Issue
Block a user