1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-04-25 13:48:50 +08:00

Faketerm and diff on it supports partial cells.

Don't print out partial cells (cells that don't really exist since the
previous cell contains a full-width rune).
This commit is contained in:
Jakub Sobon 2018-05-27 19:27:11 +01:00
parent 367af3f86d
commit 9786171a7a
No known key found for this signature in database
GPG Key ID: F2451A77FB05D3B7
2 changed files with 13 additions and 2 deletions

View File

@ -56,12 +56,18 @@ func Diff(want, got *Terminal) string {
var optDiffs []*optDiff
for row := 0; row < size.Y; row++ {
for col := 0; col < size.X; col++ {
p := image.Point{col, row}
partial, err := got.BackBuffer().IsPartial(p)
if err != nil {
panic(fmt.Errorf("unable to determine if point %v is a partial rune: %v", p, err))
}
gotCell := got.BackBuffer()[col][row]
wantCell := want.BackBuffer()[col][row]
r := gotCell.Rune
if r != wantCell.Rune {
r = '࿃'
} else if r == 0 {
} else if r == 0 && !partial {
r = ' '
}
b.WriteRune(r)

View File

@ -121,7 +121,12 @@ func (t *Terminal) String() string {
for row := 0; row < size.Y; row++ {
for col := 0; col < size.X; col++ {
r := t.buffer[col][row].Rune
if r == 0 {
p := image.Point{col, row}
partial, err := t.buffer.IsPartial(p)
if err != nil {
panic(fmt.Errorf("unable to determine if point %v is a partial rune: %v", p, err))
}
if r == 0 && !partial {
r = ' '
}
b.WriteRune(r)