Skip to content

Commit

Permalink
Fix refresh of text grid, add access to Text
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Feb 23, 2020
1 parent b8f9772 commit fa8b05c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions widget/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func (t *textHandler) SetText(text string) {
}
}

func (t *textHandler) Text() string {
return string(t.buffer)
}

// updateRowBounds updates the row bounds used to render properly the text widget.
// updateRowBounds should be invoked every time t.buffer changes.
func (t *textHandler) updateRowBounds() {
Expand Down
6 changes: 6 additions & 0 deletions widget/textgrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (t *textGridRender) setCellRune(str rune, pos int) {

if str == textAreaSpaceSymbol || str == textAreaTabSymbol || str == textAreaNewLineSymbol {
text.Color = theme.PlaceHolderColor()
} else {
text.Color = theme.TextColor()
}
}

Expand Down Expand Up @@ -146,6 +148,10 @@ func (t *textGridRender) refreshGrid() {

line++
}
for ; x < len(t.objects); x++ {
t.setCellRune(' ', x)
}
canvas.Refresh(t.text)
}

func (t *textGridRender) lineCountWidth() int {
Expand Down

0 comments on commit fa8b05c

Please sign in to comment.