Highlight numbers
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2021-04-07 12:02:08 -04:00
parent 554012eb52
commit c3b2900f42
4 changed files with 20 additions and 8 deletions

View File

@ -106,9 +106,8 @@ func (r *Row) toString() string {
func (r *Row) CursorXToRenderX(cursorX int) (renderX int) { func (r *Row) CursorXToRenderX(cursorX int) (renderX int) {
renderX = 0 renderX = 0
i := 0
for ; i < cursorX; i++ { for i := 0; i < cursorX; i++ {
if r.chars[i] == '\t' { if r.chars[i] == '\t' {
renderX += (gilo.TabSize - 1) - (renderX % gilo.TabSize) renderX += (gilo.TabSize - 1) - (renderX % gilo.TabSize)
} }

View File

@ -7,6 +7,7 @@ import (
"time" "time"
"timshome.page/gilo/internal/gilo" "timshome.page/gilo/internal/gilo"
"timshome.page/gilo/internal/terminal" "timshome.page/gilo/internal/terminal"
"unicode"
) )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -73,9 +74,20 @@ func (e *editor) drawRows(ab *gilo.Buffer) {
continue continue
} }
rowLen := e.document.GetRow(fileRow).RenderSize() - e.offset.X // rowLen := e.document.GetRow(fileRow).RenderSize() - e.offset.X
outputRow := gilo.Truncate(e.document.GetRow(fileRow).Render(e.offset), rowLen)
ab.Append(outputRow) for _, ch := range e.document.GetRow(fileRow).Render(e.offset) {
if unicode.IsDigit(ch) {
ab.Append(terminal.FGRed)
ab.AppendRune(ch)
ab.Append(terminal.DefaultFGColor)
} else {
ab.AppendRune(ch)
}
}
// outputRow := gilo.Truncate(e.document.GetRow(fileRow).Render(e.offset), rowLen)
// ab.Append(outputRow)
} }
ab.AppendLn(terminal.ClearLine) ab.AppendLn(terminal.ClearLine)

View File

@ -144,7 +144,6 @@ func (e *editor) find() {
lastMatch := -1 lastMatch := -1
direction := 1 direction := 1
query := e.prompt("Search: %s (Use ESC/Arrows/Enter)", func(query string, ch string) { query := e.prompt("Search: %s (Use ESC/Arrows/Enter)", func(query string, ch string) {
if ch == string(key.Enter) || ch == string(key.Esc) { if ch == string(key.Enter) || ch == string(key.Esc) {
lastMatch = -1 lastMatch = -1
@ -168,8 +167,8 @@ func (e *editor) find() {
for i := 0; i < e.document.RowCount(); i++ { for i := 0; i < e.document.RowCount(); i++ {
current += direction current += direction
if current == -1 { if current == -1 {
current = e.document.RowCount() - 1 current = e.document.RowCount()
} else if current > e.document.RowCount() { } else if current == e.document.RowCount() {
current = 0 current = 0
} }

View File

@ -31,6 +31,8 @@ const (
// Color sequences // Color sequences
const ( const (
DefaultFGColor = EscPrefix + "39m"
FGRed = EscPrefix + "31m"
InvertColor = EscPrefix + "7m" InvertColor = EscPrefix + "7m"
ResetColor = EscPrefix + "m" ResetColor = EscPrefix + "m"
) )