Skip to content

Commit fa6ae5d

Browse files
committed
fix: use ansi.Cmd to get the command from the parser
1 parent 7b6a87e commit fa6ae5d

8 files changed

Lines changed: 16 additions & 16 deletions

File tree

color.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func handleTerminalColor(p *ansi.Parser) (string, error) {
2222
} else {
2323
buf += "Set"
2424
}
25-
switch p.Cmd() {
25+
switch p.Command() {
2626
case 10:
2727
buf += " foreground color"
2828
case 11:
@@ -44,7 +44,7 @@ func handleResetTerminalColor(p *ansi.Parser) (string, error) {
4444
return "", errInvalid
4545
}
4646
var buf string
47-
switch p.Cmd() {
47+
switch p.Command() {
4848
case 110:
4949
buf += "Reset foreground color"
5050
case 111:

cursor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ func handleCursor(p *ansi.Parser) (string, error) {
1313
count = n
1414
}
1515

16-
cmd := p.Cmd()
17-
isPrivate := cmd.Marker() == '?'
18-
switch cmd.Command() {
16+
cmd := ansi.Cmd(p.Command())
17+
isPrivate := cmd.Prefix() == '?'
18+
switch cmd.Final() {
1919
case 'A':
2020
// CUU - Cursor Up
2121
return fmt.Sprintf("Cursor up %d", default1(count)), nil

kitty.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func handleKitty(p *ansi.Parser) (string, error) {
4646
first = n
4747
}
4848

49-
cmd := p.Cmd()
50-
switch cmd.Marker() {
49+
cmd := ansi.Cmd(p.Command())
50+
switch cmd.Prefix() {
5151
case '?':
5252
return "Request Kitty keyboard", nil
5353
case '>':

line.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func handleLine(p *ansi.Parser) (string, error) {
1313
count = n
1414
}
1515

16-
switch p.Cmd() {
16+
switch p.Command() {
1717
case 'K':
1818
switch count {
1919
case 0:

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
const (
19-
markerShift = parser.MarkerShift
19+
markerShift = parser.PrefixShift
2020
intermedShift = parser.IntermedShift
2121
)
2222

@@ -188,7 +188,7 @@ func process(w *colorprofile.Writer, in []byte) error {
188188
return
189189
}
190190

191-
handler, ok := reg[int(p.Cmd())]
191+
handler, ok := reg[p.Command()]
192192
if !ok {
193193
_, _ = fmt.Fprintln(w, t.error.Render(errUnhandled.Error()))
194194
return

mode.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ func handleMode(p *ansi.Parser) (string, error) {
1212
m = n
1313
}
1414
mode := modeDesc(m)
15-
cmd := p.Cmd()
15+
cmd := ansi.Cmd(p.Command())
1616
private := ""
17-
if cmd.Marker() == '?' {
17+
if cmd.Prefix() == '?' {
1818
private = "private "
1919
}
20-
switch cmd.Command() {
20+
switch cmd.Final() {
2121
case 'p':
2222
// DECRQM - Request Mode
2323
return fmt.Sprintf("Request %smode %q", private, mode), nil

screen.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ func handleScreen(p *ansi.Parser) (string, error) {
1313
count = n
1414
}
1515

16-
cmd := p.Cmd()
17-
switch cmd.Command() {
16+
cmd := ansi.Cmd(p.Command())
17+
switch cmd.Final() {
1818
case 'J':
1919
switch count {
2020
case 0:

title.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func handleTitle(p *ansi.Parser) (string, error) {
1414
// Invalid, ignore
1515
return "", errInvalid
1616
}
17-
switch p.Cmd() {
17+
switch p.Command() {
1818
case 0:
1919
return fmt.Sprintf("Set icon name and window title to %q", parts[1]), nil
2020
case 1:

0 commit comments

Comments
 (0)