Adding missing DL CIS handler

This commit is contained in:
Liam Galvin 2018-11-15 11:33:35 +00:00
parent 7b181ac241
commit 1371ace95c
4 changed files with 63 additions and 1 deletions

15
Makefile Normal file
View File

@ -0,0 +1,15 @@
BINARY := aminal
VERSION ?= vlatest
.PHONY: build
build: test
mkdir -p release
go build -o release/$(BINARY)-$(VERSION)
.PHONY: test
test:
go test -v ./...
.PHONY: install
install: build
install -m 0755 release/$(BINARY)-$(VERSION) /usr/local/bin/aminal

View File

@ -442,6 +442,11 @@ func (buffer *Buffer) ViewHeight() uint16 {
return buffer.viewHeight
}
func (buffer *Buffer) deleteLine() {
index := int(buffer.RawLine())
buffer.lines = buffer.lines[:index+copy(buffer.lines[index:], buffer.lines[index+1:])]
}
func (buffer *Buffer) insertLine() {
defer buffer.emitDisplayChange()
@ -492,6 +497,21 @@ func (buffer *Buffer) InsertLines(count int) {
}
func (buffer *Buffer) DeleteLines(count int) {
if buffer.HasScrollableRegion() && !buffer.InScrollableRegion() {
// should have no effect outside of scrollable region
return
}
buffer.cursorX = 0
for i := 0; i < count; i++ {
buffer.deleteLine()
}
}
func (buffer *Buffer) Index() {
// This sequence causes the active position to move downward one line without changing the column position.

View File

@ -41,6 +41,7 @@ var csiSequences = []csiMapping{
{id: 'J', handler: csiEraseInDisplayHandler, description: "Erase in Display (ED), VT100"},
{id: 'K', handler: csiEraseInLineHandler, description: "Erase in Line (EL), VT100"},
{id: 'L', handler: csiInsertLinesHandler, description: "Insert Ps Line(s) (default = 1) (IL)"},
{id: 'M', handler: csiDeleteLinesHandler, description: "Delete Ps Line(s) (default = 1) (DL)"},
{id: 'P', handler: csiDeleteHandler, description: " Delete Ps Character(s) (default = 1) (DCH)"},
{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"},
@ -276,6 +277,24 @@ func csiInsertLinesHandler(params []string, intermediate string, terminal *Termi
return nil
}
func csiDeleteLinesHandler(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().DeleteLines(count)
return nil
}
func csiScrollDownHandler(params []string, intermediate string, terminal *Terminal) error {
distance := 1
if len(params) > 1 {

View File

@ -3,6 +3,7 @@ package terminal
import (
"fmt"
"strconv"
"strings"
"github.com/liamg/aminal/buffer"
"github.com/liamg/aminal/config"
@ -15,7 +16,10 @@ func sgrSequenceHandler(params []string, intermediate string, terminal *Terminal
}
for i := range params {
switch params[i] {
p := strings.Replace(strings.Replace(params[i], "[", "", -1), "]", "", -1)
switch p {
case "00", "0":
attr := terminal.ActiveBuffer().CursorAttr()
*attr = buffer.CellAttributes{
@ -38,6 +42,8 @@ func sgrSequenceHandler(params []string, intermediate string, terminal *Terminal
terminal.ActiveBuffer().CursorAttr().Bold = false
case "22":
terminal.ActiveBuffer().CursorAttr().Dim = false
case "23":
// not italic
case "24":
terminal.ActiveBuffer().CursorAttr().Underline = false
case "25":
@ -46,6 +52,8 @@ func sgrSequenceHandler(params []string, intermediate string, terminal *Terminal
terminal.ActiveBuffer().CursorAttr().Reverse = false
case "28":
terminal.ActiveBuffer().CursorAttr().Hidden = false
case "29":
// not strikethrough
case "39":
terminal.ActiveBuffer().CursorAttr().FgColour = terminal.config.ColourScheme.Foreground
case "30":