Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(record): set PAGEX to PAGE_X for proper capitalization #570

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ var CommandFuncs = map[parser.CommandType]CommandFunc{
token.UP: ExecuteKey(input.ArrowUp),
token.TAB: ExecuteKey(input.Tab),
token.ESCAPE: ExecuteKey(input.Escape),
token.PAGEUP: ExecuteKey(input.PageUp),
token.PAGEDOWN: ExecuteKey(input.PageDown),
token.PAGE_UP: ExecuteKey(input.PageUp),
token.PAGE_DOWN: ExecuteKey(input.PageDown),
token.HIDE: ExecuteHide,
token.REQUIRE: ExecuteRequire,
token.SHOW: ExecuteShow,
Expand Down
12 changes: 6 additions & 6 deletions lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ func TestLexTapeFile(t *testing.T) {
{token.AT, "@"},
{token.NUMBER, "1"},
{token.NUMBER, "3"},
{token.PAGEDOWN, "PageDown"},
{token.PAGEDOWN, "PageDown"},
{token.PAGE_DOWN, "PageDown"},
{token.PAGE_DOWN, "PageDown"},
{token.NUMBER, "2"},
{token.PAGEDOWN, "PageDown"},
{token.PAGE_DOWN, "PageDown"},
{token.AT, "@"},
{token.NUMBER, "1"},
{token.NUMBER, "3"},
Expand Down Expand Up @@ -268,10 +268,10 @@ func TestLexTapeFile(t *testing.T) {
{token.AT, "@"},
{token.NUMBER, "1"},
{token.NUMBER, "3"},
{token.PAGEUP, "PageUp"},
{token.PAGEUP, "PageUp"},
{token.PAGE_UP, "PageUp"},
{token.PAGE_UP, "PageUp"},
{token.NUMBER, "2"},
{token.PAGEUP, "PageUp"},
{token.PAGE_UP, "PageUp"},
{token.AT, "@"},
{token.NUMBER, "1"},
{token.NUMBER, "3"},
Expand Down
8 changes: 4 additions & 4 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var CommandTypes = []CommandType{ //nolint: deadcode
token.ESCAPE,
token.ILLEGAL,
token.LEFT,
token.PAGEUP,
token.PAGEDOWN,
token.PAGE_UP,
token.PAGE_DOWN,
token.RIGHT,
token.SET,
token.OUTPUT,
Expand Down Expand Up @@ -144,8 +144,8 @@ func (p *Parser) parseCommand() Command {
token.LEFT,
token.RIGHT,
token.UP,
token.PAGEUP,
token.PAGEDOWN:
token.PAGE_UP,
token.PAGE_DOWN:
return p.parseKeypress(p.cur.Type)
case token.SET:
return p.parseSet()
Expand Down
12 changes: 6 additions & 6 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ func TestParseTapeFile(t *testing.T) {
{Type: token.DOWN, Options: "", Args: "1"},
{Type: token.DOWN, Options: "", Args: "2"},
{Type: token.DOWN, Options: "1s", Args: "3"},
{Type: token.PAGEDOWN, Options: "", Args: "1"},
{Type: token.PAGEDOWN, Options: "", Args: "2"},
{Type: token.PAGEDOWN, Options: "1s", Args: "3"},
{Type: token.PAGE_DOWN, Options: "", Args: "1"},
{Type: token.PAGE_DOWN, Options: "", Args: "2"},
{Type: token.PAGE_DOWN, Options: "1s", Args: "3"},
{Type: token.ENTER, Options: "", Args: "1"},
{Type: token.ENTER, Options: "", Args: "2"},
{Type: token.ENTER, Options: "1s", Args: "3"},
Expand All @@ -181,9 +181,9 @@ func TestParseTapeFile(t *testing.T) {
{Type: token.UP, Options: "", Args: "1"},
{Type: token.UP, Options: "", Args: "2"},
{Type: token.UP, Options: "1s", Args: "3"},
{Type: token.PAGEUP, Options: "", Args: "1"},
{Type: token.PAGEUP, Options: "", Args: "2"},
{Type: token.PAGEUP, Options: "1s", Args: "3"},
{Type: token.PAGE_UP, Options: "", Args: "1"},
{Type: token.PAGE_UP, Options: "", Args: "2"},
{Type: token.PAGE_UP, Options: "1s", Args: "3"},
{Type: token.DOWN, Options: "", Args: "1"},
{Type: token.DOWN, Options: "", Args: "2"},
{Type: token.DOWN, Options: "1s", Args: "3"},
Expand Down
4 changes: 2 additions & 2 deletions record.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var EscapeSequences = map[string]string{
"\x1b[2~": token.INSERT,
"\x1b[3~": token.DELETE,
"\x1b[4~": token.END,
"\x1b[5~": token.PAGEUP,
"\x1b[6~": token.PAGEDOWN,
"\x1b[5~": token.PAGE_UP,
"\x1b[6~": token.PAGE_DOWN,
"\x01": token.CTRL + "+A",
"\x02": token.CTRL + "+B",
"\x03": token.CTRL + "+C",
Expand Down
48 changes: 40 additions & 8 deletions record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import (
)

func TestInputToTape(t *testing.T) {
input := `echo "Hello,.
tests := []struct {
name string
input string
want string
}{
{
name: "ctrl key combinations",
input: `echo "Hello,.
BACKSPACE
LEFT
LEFT
Expand All @@ -31,9 +38,8 @@ SLEEP
ALT+.
SLEEP
exit
`

want := `Type 'echo "Hello,.'
`,
want: `Type 'echo "Hello,.'
Backspace
Left 2
Right 2
Expand All @@ -51,10 +57,36 @@ Ctrl+E
Sleep 1s
Alt+.
Sleep 500ms
`
got := inputToTape(input)
if want != got {
t.Fatalf("want:\n%s\ngot:\n%s\n", want, got)
`,
},
{
name: "PageUp, PageDown #559",
input: `echo "Hello,.
PAGE_UP
PAGE_UP
PAGE_UP
PAGE_UP
PAGE_UP
PAGE_UP
PAGE_UP
PAGE_UP
PAGE_DOWN
PAGE_DOWN
PAGE_DOWN
PAGE_DOWN
exit
`,
want: `Type 'echo "Hello,.'
PageUp 8
PageDown 4
`,
},
}
for _, tc := range tests {
got := inputToTape(tc.input)
if tc.want != got {
t.Fatalf("want:\n%s\ngot:\n%s\n", tc.want, got)
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const (
ESCAPE = "ESCAPE"
HOME = "HOME"
INSERT = "INSERT"
PAGEDOWN = "PAGEDOWN"
PAGEUP = "PAGEUP"
PAGE_DOWN = "PAGE_DOWN" //nolint:revive
PAGE_UP = "PAGE_UP" //nolint:revive
SLEEP = "SLEEP"
SPACE = "SPACE"
TAB = "TAB"
Expand Down Expand Up @@ -119,8 +119,8 @@ var Keywords = map[string]Type{
"Left": LEFT,
"Right": RIGHT,
"Up": UP,
"PageUp": PAGEUP,
"PageDown": PAGEDOWN,
"PageUp": PAGE_UP, //nolint:revive
"PageDown": PAGE_DOWN, //nolint:revive
"Tab": TAB,
"Escape": ESCAPE,
"End": END,
Expand Down Expand Up @@ -176,7 +176,7 @@ func IsSetting(t Type) bool {
func IsCommand(t Type) bool {
switch t {
case TYPE, SLEEP,
UP, DOWN, RIGHT, LEFT, PAGEUP, PAGEDOWN,
UP, DOWN, RIGHT, LEFT, PAGE_UP, PAGE_DOWN,
ENTER, BACKSPACE, DELETE, TAB,
ESCAPE, HOME, INSERT, END, CTRL, SOURCE, SCREENSHOT, COPY, PASTE, WAIT:
return true
Expand Down
Loading