mirror of https://github.com/rivo/tview.git
Excluding control characters from output (creates unwanted artefacts). Fixes #130
This commit is contained in:
parent
398a6c2f77
commit
0ebcb1ed99
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
@ -815,7 +816,7 @@ func (t *TextView) Draw(screen tcell.Screen) {
|
||||||
|
|
||||||
// Draw the character.
|
// Draw the character.
|
||||||
var comb []rune
|
var comb []rune
|
||||||
if len(runeSequence) > 1 {
|
if len(runeSequence) > 1 && !unicode.IsControl(runeSequence[1]) {
|
||||||
// Allocate space for the combining characters only when necessary.
|
// Allocate space for the combining characters only when necessary.
|
||||||
comb = make([]rune, len(runeSequence)-1)
|
comb = make([]rune, len(runeSequence)-1)
|
||||||
copy(comb, runeSequence[1:])
|
copy(comb, runeSequence[1:])
|
||||||
|
|
3
util.go
3
util.go
|
@ -419,7 +419,7 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
|
||||||
_, background, _ := finalStyle.Decompose()
|
_, background, _ := finalStyle.Decompose()
|
||||||
finalStyle = overlayStyle(background, style, foregroundColor, backgroundColor, attributes)
|
finalStyle = overlayStyle(background, style, foregroundColor, backgroundColor, attributes)
|
||||||
var comb []rune
|
var comb []rune
|
||||||
if len(runeSequence) > 1 {
|
if len(runeSequence) > 1 && !unicode.IsControl(runeSequence[1]) {
|
||||||
// Allocate space for the combining characters only when necessary.
|
// Allocate space for the combining characters only when necessary.
|
||||||
comb = make([]rune, len(runeSequence)-1)
|
comb = make([]rune, len(runeSequence)-1)
|
||||||
copy(comb, runeSequence[1:])
|
copy(comb, runeSequence[1:])
|
||||||
|
@ -475,7 +475,6 @@ func printWithStyle(screen tcell.Screen, text string, x, y, maxWidth, align int,
|
||||||
}
|
}
|
||||||
runeSequence = append(runeSequence, ch)
|
runeSequence = append(runeSequence, ch)
|
||||||
runeSeqWidth += chWidth
|
runeSeqWidth += chWidth
|
||||||
|
|
||||||
}
|
}
|
||||||
if drawnWidth+runeSeqWidth <= maxWidth {
|
if drawnWidth+runeSeqWidth <= maxWidth {
|
||||||
flush()
|
flush()
|
||||||
|
|
Loading…
Reference in New Issue