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) {
renderX = 0
i := 0
for ; i < cursorX; i++ {
for i := 0; i < cursorX; i++ {
if r.chars[i] == '\t' {
renderX += (gilo.TabSize - 1) - (renderX % gilo.TabSize)
}

View File

@ -7,6 +7,7 @@ import (
"time"
"timshome.page/gilo/internal/gilo"
"timshome.page/gilo/internal/terminal"
"unicode"
)
// ----------------------------------------------------------------------------
@ -73,9 +74,20 @@ func (e *editor) drawRows(ab *gilo.Buffer) {
continue
}
rowLen := e.document.GetRow(fileRow).RenderSize() - e.offset.X
outputRow := gilo.Truncate(e.document.GetRow(fileRow).Render(e.offset), rowLen)
ab.Append(outputRow)
// rowLen := e.document.GetRow(fileRow).RenderSize() - e.offset.X
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)

View File

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

View File

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