mirror of https://github.com/jroimartin/gocui.git
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...)
|
||||
}
|
||||
|
||||
c := cell{
|
||||
fgColor: v.FgColor,
|
||||
bgColor: v.BgColor,
|
||||
chr: ch,
|
||||
}
|
||||
|
||||
olen := len(v.lines[y])
|
||||
|
||||
var s []cell
|
||||
if x >= len(v.lines[y]) {
|
||||
s := make([]cell, x-len(v.lines[y])+1)
|
||||
v.lines[y] = append(v.lines[y], s...)
|
||||
s = make([]cell, x-len(v.lines[y])+1)
|
||||
} 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) {
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue