bump gocui

This commit is contained in:
Ryooooooga 2022-11-14 22:23:14 +09:00
parent a6ebc5869e
commit cf048e4807
No known key found for this signature in database
GPG key ID: 07CF200DFCC20C25
8 changed files with 74 additions and 33 deletions

View file

@ -39,6 +39,8 @@ const (
stateEscape
stateCSI
stateParams
stateOSC
stateOSCEscape
bold fontEffect = 1
faint fontEffect = 2
@ -124,11 +126,16 @@ func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) {
}
return false, nil
case stateEscape:
if ch == '[' {
switch ch {
case '[':
ei.state = stateCSI
return true, nil
case ']':
ei.state = stateOSC
return true, nil
default:
return false, errNotCSI
}
return false, errNotCSI
case stateCSI:
switch {
case ch >= '0' && ch <= '9':
@ -189,6 +196,16 @@ func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) {
default:
return false, errCSIParseError
}
case stateOSC:
switch ch {
case 0x1b:
ei.state = stateOSCEscape
return true, nil
}
return true, nil
case stateOSCEscape:
ei.state = stateNone
return true, nil
}
return false, nil
}

View file

@ -950,33 +950,44 @@ func (v *View) draw() error {
start = len(v.viewLines) - 1
}
y := 0
emptyCell := cell{chr: ' ', fgColor: ColorDefault, bgColor: ColorDefault}
var prevFgColor Attribute
for _, vline := range v.viewLines[start:] {
for y, vline := range v.viewLines[start:] {
if y >= maxY {
break
}
// x tracks the current x position in the view, and cellIdx tracks the
// index of the cell. If we print a double-sized rune, we increment cellIdx
// by one but x by two.
x := -v.ox
j := 0
cellIdx := 0
var c cell
for {
if x < 0 {
if j < len(vline.line) {
x += runewidth.RuneWidth(vline.line[j].chr)
}
j++
continue
}
if x >= maxX {
break
}
if j > len(vline.line)-1 {
if x < 0 {
if cellIdx < len(vline.line) {
x += runewidth.RuneWidth(vline.line[cellIdx].chr)
cellIdx++
continue
} else {
// no more characters to write so we're only going to be printing empty cells
// past this point
x = 0
}
}
// if we're out of cells to write, we'll just print empty cells.
if cellIdx > len(vline.line)-1 {
c = emptyCell
c.fgColor = prevFgColor
} else {
c = vline.line[j]
c = vline.line[cellIdx]
// capturing previous foreground colour so that if we're using the reverse
// attribute we honour the final character's colour and don't awkwardly switch
// to a new background colour for the remainder of the line
@ -1006,9 +1017,8 @@ func (v *View) draw() error {
// Not sure why the previous code was here but it caused problems
// when typing wide characters in an editor
x += runewidth.RuneWidth(c.chr)
j++
cellIdx++
}
y++
}
return nil
}