Merge pull request #62 from liamg/fix-overwrite-bug

Add support for CSI ICH (@)
This commit is contained in:
Liam Galvin 2018-11-24 21:57:45 +00:00 committed by GitHub
commit b31c5d5ea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -482,6 +482,16 @@ func (buffer *Buffer) insertLine() {
}
}
func (buffer *Buffer) InsertBlankCharacters(count int) {
index := int(buffer.RawLine())
for i := 0; i < count; i++ {
cells := buffer.lines[index].cells
c := Cell{}
buffer.lines[index].cells = append(cells[:buffer.cursorX], append([]Cell{c}, cells[buffer.cursorX:]...)...)
}
}
func (buffer *Buffer) InsertLines(count int) {
if buffer.HasScrollableRegion() && !buffer.InScrollableRegion() {

View File

@ -46,6 +46,7 @@ var csiSequences = []csiMapping{
{id: 'S', handler: csiScrollUpHandler, description: "Scroll up Ps lines (default = 1) (SU), VT420, ECMA-48"},
{id: 'T', handler: csiScrollDownHandler, description: "Scroll down Ps lines (default = 1) (SD), VT420"},
{id: 'X', handler: csiEraseCharactersHandler, description: "Erase Ps Character(s) (default = 1) (ECH"},
{id: '@', handler: csiInsertBlankCharactersHandler, description: "Insert Ps (Blank) Character(s) (default = 1) (ICH)"},
}
func csiHandler(pty chan rune, terminal *Terminal) error {
@ -259,6 +260,24 @@ func csiScrollUpHandler(params []string, intermediate string, terminal *Terminal
return nil
}
func csiInsertBlankCharactersHandler(params []string, intermediate string, terminal *Terminal) error {
count := 1
if len(params) > 1 {
return fmt.Errorf("Not supported")
}
if len(params) == 1 {
var err error
count, err = strconv.Atoi(params[0])
if err != nil || count < 1 {
count = 1
}
}
terminal.ActiveBuffer().InsertBlankCharacters(count)
return nil
}
func csiInsertLinesHandler(params []string, intermediate string, terminal *Terminal) error {
count := 1
if len(params) > 1 {