diff --git a/cmd/micro/cellview.go b/cmd/micro/cellview.go index 83562124..9c3dcf87 100644 --- a/cmd/micro/cellview.go +++ b/cmd/micro/cellview.go @@ -33,7 +33,10 @@ type Char struct { visualLoc Loc realLoc Loc char rune - style tcell.Style + // The actual character that is drawn + // This is only different from char if it's for example hidden character + drawChar rune + style tcell.Style } type CellView struct { @@ -100,13 +103,13 @@ func (c *CellView) Draw(buf *Buffer, top, height, left, width int) { char := line[colN] if char == '\t' { - c.lines[viewLine][viewCol] = &Char{Loc{viewCol, viewLine}, Loc{colN, lineN}, indentchar, curStyle} + c.lines[viewLine][viewCol] = &Char{Loc{viewCol, viewLine}, Loc{colN, lineN}, char, indentchar, curStyle} viewCol += tabsize - viewCol%tabsize } else if runewidth.RuneWidth(char) > 1 { - c.lines[viewLine][viewCol] = &Char{Loc{viewCol, viewLine}, Loc{colN, lineN}, char, curStyle} + c.lines[viewLine][viewCol] = &Char{Loc{viewCol, viewLine}, Loc{colN, lineN}, char, char, curStyle} viewCol += runewidth.RuneWidth(char) } else { - c.lines[viewLine][viewCol] = &Char{Loc{viewCol, viewLine}, Loc{colN, lineN}, char, curStyle} + c.lines[viewLine][viewCol] = &Char{Loc{viewCol, viewLine}, Loc{colN, lineN}, char, char, curStyle} viewCol++ } colN++ diff --git a/cmd/micro/view2.go b/cmd/micro/view2.go index 3d1cb7a8..ab122180 100644 --- a/cmd/micro/view2.go +++ b/cmd/micro/view2.go @@ -3,6 +3,7 @@ package main import "strconv" func (v *View) DisplayView() { + tabsize := int(v.Buf.Settings["tabsize"].(float64)) if v.Type == vtLog { // Log views should always follow the cursor... v.Relocate() @@ -70,6 +71,8 @@ func (v *View) DisplayView() { screenX++ } + lineStr := v.Buf.Line(realLineN) + // If there are gutter messages we need to display the '>>' symbol here if hasGutterMessages { // msgOnLine stores whether or not there is a gutter message on this line in particular @@ -156,23 +159,21 @@ func (v *View) DisplayView() { } var lastChar *Char - for i, char := range line { + for _, char := range line { if char != nil { if tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == char.realLoc.Y && v.Cursor.X == char.realLoc.X { screen.ShowCursor(xOffset+char.visualLoc.X, char.visualLoc.Y) } - screen.SetContent(xOffset+char.visualLoc.X, char.visualLoc.Y, char.char, nil, char.style) - if i == len(line)-1 { - lastChar = char - } + screen.SetContent(xOffset+char.visualLoc.X, char.visualLoc.Y, char.drawChar, nil, char.style) + lastChar = char } } if lastChar != nil { if tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() && v.Cursor.Y == lastChar.realLoc.Y && v.Cursor.X == lastChar.realLoc.X+1 { - screen.ShowCursor(xOffset+lastChar.visualLoc.X+1, lastChar.visualLoc.Y) + screen.ShowCursor(xOffset+StringWidth(string(lineStr), tabsize), lastChar.visualLoc.Y) } } else if len(line) == 0 { if tabs[curTab].CurView == v.Num && !v.Cursor.HasSelection() &&