mirror of
https://github.com/jroimartin/gocui.git
synced 2025-04-24 13:48:51 +08:00
Refactoring of *View.writeRune
This commit is contained in:
parent
2677ad0445
commit
ad91aa2b83
19
edit.go
19
edit.go
@ -245,25 +245,24 @@ func (v *View) writeRune(x, y int, ch rune) error {
|
|||||||
v.lines = append(v.lines, s...)
|
v.lines = append(v.lines, s...)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := cell{
|
|
||||||
fgColor: v.FgColor,
|
|
||||||
bgColor: v.BgColor,
|
|
||||||
chr: ch,
|
|
||||||
}
|
|
||||||
|
|
||||||
olen := len(v.lines[y])
|
olen := len(v.lines[y])
|
||||||
|
|
||||||
|
var s []cell
|
||||||
if x >= len(v.lines[y]) {
|
if x >= len(v.lines[y]) {
|
||||||
s := make([]cell, x-len(v.lines[y])+1)
|
s = make([]cell, x-len(v.lines[y])+1)
|
||||||
v.lines[y] = append(v.lines[y], s...)
|
|
||||||
} else if !v.Overwrite {
|
} else if !v.Overwrite {
|
||||||
v.lines[y] = append(v.lines[y], c)
|
s = make([]cell, 1)
|
||||||
}
|
}
|
||||||
|
v.lines[y] = append(v.lines[y], s...)
|
||||||
|
|
||||||
if !v.Overwrite || (v.Overwrite && x >= olen-1) {
|
if !v.Overwrite || (v.Overwrite && x >= olen-1) {
|
||||||
copy(v.lines[y][x+1:], v.lines[y][x:])
|
copy(v.lines[y][x+1:], v.lines[y][x:])
|
||||||
}
|
}
|
||||||
v.lines[y][x] = c
|
v.lines[y][x] = cell{
|
||||||
|
fgColor: v.FgColor,
|
||||||
|
bgColor: v.BgColor,
|
||||||
|
chr: ch,
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user