mirror of https://github.com/liamg/aminal.git
more scape codes
This commit is contained in:
parent
c76ef8216f
commit
006e6d53ea
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo -n "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[0J"
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo -n "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[1J"
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo -n "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[2J"
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
@ -12,6 +14,4 @@ echo -ne "\x1b[A" # up
|
||||||
echo -ne "\x1b[D" # left
|
echo -ne "\x1b[D" # left
|
||||||
echo -ne "\x1b[A" # up
|
echo -ne "\x1b[A" # up
|
||||||
echo -ne "\x1b[D" # left
|
echo -ne "\x1b[D" # left
|
||||||
sleep 2
|
echo -ne "\x1b[K"
|
||||||
echo -ne "\x1b[J0"
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo -n "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[1K"
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
echo -n "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
|
||||||
|
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[A" # up
|
||||||
|
echo -ne "\x1b[D" # left
|
||||||
|
echo -ne "\x1b[2K"
|
|
@ -5,6 +5,17 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Wish list here: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
||||||
|
|
||||||
|
type TerminalCharSet int
|
||||||
|
|
||||||
|
const (
|
||||||
|
C0 TerminalCharSet = iota
|
||||||
|
C1
|
||||||
|
C2
|
||||||
|
C3
|
||||||
|
)
|
||||||
|
|
||||||
func (terminal *Terminal) processInput(buffer chan rune) {
|
func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/ANSI_escape_code
|
// https://en.wikipedia.org/wiki/ANSI_escape_code
|
||||||
|
@ -136,7 +147,7 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
if len(params) > 0 {
|
if len(params) > 0 {
|
||||||
var err error
|
var err error
|
||||||
distance, err = strconv.Atoi(params[0])
|
distance, err = strconv.Atoi(params[0])
|
||||||
if err != nil {
|
if err != nil || params[0] == "" {
|
||||||
distance = 1
|
distance = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,20 +160,20 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
if len(params) == 2 {
|
if len(params) == 2 {
|
||||||
var err error
|
var err error
|
||||||
if params[0] != "" {
|
if params[0] != "" {
|
||||||
x, err = strconv.Atoi(string(params[0]))
|
y, err = strconv.Atoi(string(params[0]))
|
||||||
if err != nil {
|
|
||||||
x = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if params[1] != "" {
|
|
||||||
y, err = strconv.Atoi(string(params[y]))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
y = 1
|
y = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
terminal.position.Col = x - 1
|
if params[1] != "" {
|
||||||
terminal.position.Line = y - 1
|
x, err = strconv.Atoi(string(params[1]))
|
||||||
|
if err != nil {
|
||||||
|
x = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
terminal.position.Col = x - 1
|
||||||
|
terminal.position.Line = y - 1
|
||||||
|
|
||||||
case 'J':
|
case 'J':
|
||||||
|
|
||||||
|
@ -173,6 +184,18 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
|
|
||||||
switch n {
|
switch n {
|
||||||
|
|
||||||
|
case "0", "":
|
||||||
|
line := terminal.getBufferedLine(terminal.position.Line)
|
||||||
|
if line != nil {
|
||||||
|
line.Cells = line.Cells[:terminal.position.Col]
|
||||||
|
}
|
||||||
|
_, h := terminal.GetSize()
|
||||||
|
for i := terminal.position.Line + 1; i < h; i++ {
|
||||||
|
line := terminal.getBufferedLine(i)
|
||||||
|
if line != nil {
|
||||||
|
line.Cells = []Cell{}
|
||||||
|
}
|
||||||
|
}
|
||||||
case "1":
|
case "1":
|
||||||
line := terminal.getBufferedLine(terminal.position.Line)
|
line := terminal.getBufferedLine(terminal.position.Line)
|
||||||
if line != nil {
|
if line != nil {
|
||||||
|
@ -189,19 +212,6 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "0", "":
|
|
||||||
line := terminal.getBufferedLine(terminal.position.Line)
|
|
||||||
if line != nil {
|
|
||||||
line.Cells = line.Cells[:terminal.position.Col]
|
|
||||||
}
|
|
||||||
_, h := terminal.GetSize()
|
|
||||||
for i := terminal.position.Line + 1; i < h; i++ {
|
|
||||||
line := terminal.getBufferedLine(i)
|
|
||||||
if line != nil {
|
|
||||||
line.Cells = []Cell{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "2":
|
case "2":
|
||||||
_, h := terminal.GetSize()
|
_, h := terminal.GetSize()
|
||||||
for i := 0; i < h; i++ {
|
for i := 0; i < h; i++ {
|
||||||
|
@ -210,12 +220,8 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
line.Cells = []Cell{}
|
line.Cells = []Cell{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
terminal.position.Col = 0
|
|
||||||
terminal.position.Line = 0
|
|
||||||
case "3":
|
case "3":
|
||||||
terminal.lines = []Line{}
|
terminal.lines = []Line{}
|
||||||
terminal.position.Col = 0
|
|
||||||
terminal.position.Line = 0
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
terminal.logger.Errorf("Unknown CSI ED sequence: %s", n)
|
terminal.logger.Errorf("Unknown CSI ED sequence: %s", n)
|
||||||
|
@ -228,6 +234,11 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch n {
|
switch n {
|
||||||
|
case "0", "":
|
||||||
|
line := terminal.getBufferedLine(terminal.position.Line)
|
||||||
|
if line != nil {
|
||||||
|
line.Cells = line.Cells[:terminal.position.Col]
|
||||||
|
}
|
||||||
case "1":
|
case "1":
|
||||||
line := terminal.getBufferedLine(terminal.position.Line)
|
line := terminal.getBufferedLine(terminal.position.Line)
|
||||||
if line != nil {
|
if line != nil {
|
||||||
|
@ -237,11 +248,6 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "0", "":
|
|
||||||
line := terminal.getBufferedLine(terminal.position.Line)
|
|
||||||
if line != nil {
|
|
||||||
line.Cells = line.Cells[:terminal.position.Col]
|
|
||||||
}
|
|
||||||
case "2":
|
case "2":
|
||||||
line := terminal.getBufferedLine(terminal.position.Line)
|
line := terminal.getBufferedLine(terminal.position.Line)
|
||||||
if line != nil {
|
if line != nil {
|
||||||
|
@ -355,7 +361,7 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
terminal.logger.Errorf("Unknown SGR control sequence: (ESC[%s%s%s)", param, intermediate, string(final))
|
terminal.logger.Errorf("Unknown SGR control sequence: (ESC[%s%s%s)", param, intermediate, string(final))
|
||||||
}
|
}
|
||||||
|
|
||||||
//terminal.logger.Debugf("SGR control sequence: (ESC[%s%s%s)", param, intermediate, string(final))
|
terminal.logger.Debugf("SGR control sequence: (ESC[%s%s%s)", param, intermediate, string(final))
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -371,7 +377,9 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
default:
|
default:
|
||||||
terminal.logger.Errorf("Unknown CSI control sequence: 0x%02X (ESC[%s%s%s)", final, param, intermediate, string(final))
|
terminal.logger.Errorf("Unknown CSI control sequence: 0x%02X (ESC[%s%s%s)", final, param, intermediate, string(final))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
terminal.logger.Debugf("Received CSI control sequence: 0x%02X (ESC[%s%s%s)", final, param, intermediate, string(final))
|
||||||
case 0x5d: // OSC: Operating System Command
|
case 0x5d: // OSC: Operating System Command
|
||||||
b = <-buffer
|
b = <-buffer
|
||||||
switch b {
|
switch b {
|
||||||
|
@ -381,12 +389,11 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
title := []rune{}
|
title := []rune{}
|
||||||
for {
|
for {
|
||||||
b = <-buffer
|
b = <-buffer
|
||||||
if b == 0x07 {
|
if b == 0x07 || b == 0x5c { // 0x07 -> BELL, 0x5c -> ST (\)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
title = append(title, b)
|
title = append(title, b)
|
||||||
}
|
}
|
||||||
terminal.logger.Debugf("Terminal title set to: %s", string(title))
|
|
||||||
terminal.title = string(title)
|
terminal.title = string(title)
|
||||||
} else {
|
} else {
|
||||||
terminal.logger.Errorf("Invalid OSC 0 control sequence: 0x%02X", b)
|
terminal.logger.Errorf("Invalid OSC 0 control sequence: 0x%02X", b)
|
||||||
|
@ -396,10 +403,38 @@ func (terminal *Terminal) processInput(buffer chan rune) {
|
||||||
}
|
}
|
||||||
case 'c':
|
case 'c':
|
||||||
terminal.logger.Errorf("RIS not yet supported")
|
terminal.logger.Errorf("RIS not yet supported")
|
||||||
case ')', '(':
|
case '(':
|
||||||
b = <-buffer
|
b = <-buffer
|
||||||
// todo charset changes
|
switch b {
|
||||||
//terminal.logger.Debugf("Ignoring character set control code )%s", string(b))
|
case 'A': //uk @todo handle these?
|
||||||
|
terminal.charSet = C0
|
||||||
|
case 'B': //us
|
||||||
|
terminal.charSet = C0
|
||||||
|
}
|
||||||
|
case ')':
|
||||||
|
b = <-buffer
|
||||||
|
switch b {
|
||||||
|
case 'A': //uk @todo handle these?
|
||||||
|
terminal.charSet = C1
|
||||||
|
case 'B': //us
|
||||||
|
terminal.charSet = C1
|
||||||
|
}
|
||||||
|
case '*':
|
||||||
|
b = <-buffer
|
||||||
|
switch b {
|
||||||
|
case 'A': //uk @todo handle these?
|
||||||
|
terminal.charSet = C2
|
||||||
|
case 'B': //us
|
||||||
|
terminal.charSet = C2
|
||||||
|
}
|
||||||
|
case '+':
|
||||||
|
b = <-buffer
|
||||||
|
switch b {
|
||||||
|
case 'A': //uk @todo handle these?
|
||||||
|
terminal.charSet = C3
|
||||||
|
case 'B': //us
|
||||||
|
terminal.charSet = C3
|
||||||
|
}
|
||||||
case '>':
|
case '>':
|
||||||
// numeric char selection @todo
|
// numeric char selection @todo
|
||||||
case '=':
|
case '=':
|
||||||
|
|
|
@ -24,6 +24,7 @@ type Terminal struct {
|
||||||
cellAttr CellAttributes
|
cellAttr CellAttributes
|
||||||
defaultCellAttr CellAttributes
|
defaultCellAttr CellAttributes
|
||||||
cursorVisible bool
|
cursorVisible bool
|
||||||
|
charSet TerminalCharSet
|
||||||
}
|
}
|
||||||
|
|
||||||
type Line struct {
|
type Line struct {
|
||||||
|
|
Loading…
Reference in New Issue