Skip to content

Commit ed7c8a9

Browse files
authored
fix(record): set PAGEX to PAGE_X for proper capitalization (#570)
* fix(record): set PAGEX to PAGE_X for proper capitalization * chore: fix lint + formatting * chore(lint): add lint ignore for snake case
1 parent 2e6003e commit ed7c8a9

File tree

7 files changed

+65
-33
lines changed

7 files changed

+65
-33
lines changed

command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ var CommandFuncs = map[parser.CommandType]CommandFunc{
6060
token.UP: ExecuteKey(input.ArrowUp),
6161
token.TAB: ExecuteKey(input.Tab),
6262
token.ESCAPE: ExecuteKey(input.Escape),
63-
token.PAGEUP: ExecuteKey(input.PageUp),
64-
token.PAGEDOWN: ExecuteKey(input.PageDown),
63+
token.PAGE_UP: ExecuteKey(input.PageUp),
64+
token.PAGE_DOWN: ExecuteKey(input.PageDown),
6565
token.HIDE: ExecuteHide,
6666
token.REQUIRE: ExecuteRequire,
6767
token.SHOW: ExecuteShow,

lexer/lexer_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ func TestLexTapeFile(t *testing.T) {
235235
{token.AT, "@"},
236236
{token.NUMBER, "1"},
237237
{token.NUMBER, "3"},
238-
{token.PAGEDOWN, "PageDown"},
239-
{token.PAGEDOWN, "PageDown"},
238+
{token.PAGE_DOWN, "PageDown"},
239+
{token.PAGE_DOWN, "PageDown"},
240240
{token.NUMBER, "2"},
241-
{token.PAGEDOWN, "PageDown"},
241+
{token.PAGE_DOWN, "PageDown"},
242242
{token.AT, "@"},
243243
{token.NUMBER, "1"},
244244
{token.NUMBER, "3"},
@@ -284,10 +284,10 @@ func TestLexTapeFile(t *testing.T) {
284284
{token.AT, "@"},
285285
{token.NUMBER, "1"},
286286
{token.NUMBER, "3"},
287-
{token.PAGEUP, "PageUp"},
288-
{token.PAGEUP, "PageUp"},
287+
{token.PAGE_UP, "PageUp"},
288+
{token.PAGE_UP, "PageUp"},
289289
{token.NUMBER, "2"},
290-
{token.PAGEUP, "PageUp"},
290+
{token.PAGE_UP, "PageUp"},
291291
{token.AT, "@"},
292292
{token.NUMBER, "1"},
293293
{token.NUMBER, "3"},

parser/parser.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ var CommandTypes = []CommandType{ //nolint: deadcode
3636
token.ESCAPE,
3737
token.ILLEGAL,
3838
token.LEFT,
39-
token.PAGEUP,
40-
token.PAGEDOWN,
39+
token.PAGE_UP,
40+
token.PAGE_DOWN,
4141
token.RIGHT,
4242
token.SET,
4343
token.OUTPUT,
@@ -144,8 +144,8 @@ func (p *Parser) parseCommand() Command {
144144
token.LEFT,
145145
token.RIGHT,
146146
token.UP,
147-
token.PAGEUP,
148-
token.PAGEDOWN:
147+
token.PAGE_UP,
148+
token.PAGE_DOWN:
149149
return p.parseKeypress(p.cur.Type)
150150
case token.SET:
151151
return p.parseSet()

parser/parser_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ func TestParseTapeFile(t *testing.T) {
160160
{Type: token.DOWN, Options: "", Args: "1"},
161161
{Type: token.DOWN, Options: "", Args: "2"},
162162
{Type: token.DOWN, Options: "1s", Args: "3"},
163-
{Type: token.PAGEDOWN, Options: "", Args: "1"},
164-
{Type: token.PAGEDOWN, Options: "", Args: "2"},
165-
{Type: token.PAGEDOWN, Options: "1s", Args: "3"},
163+
{Type: token.PAGE_DOWN, Options: "", Args: "1"},
164+
{Type: token.PAGE_DOWN, Options: "", Args: "2"},
165+
{Type: token.PAGE_DOWN, Options: "1s", Args: "3"},
166166
{Type: token.ENTER, Options: "", Args: "1"},
167167
{Type: token.ENTER, Options: "", Args: "2"},
168168
{Type: token.ENTER, Options: "1s", Args: "3"},
@@ -181,9 +181,9 @@ func TestParseTapeFile(t *testing.T) {
181181
{Type: token.UP, Options: "", Args: "1"},
182182
{Type: token.UP, Options: "", Args: "2"},
183183
{Type: token.UP, Options: "1s", Args: "3"},
184-
{Type: token.PAGEUP, Options: "", Args: "1"},
185-
{Type: token.PAGEUP, Options: "", Args: "2"},
186-
{Type: token.PAGEUP, Options: "1s", Args: "3"},
184+
{Type: token.PAGE_UP, Options: "", Args: "1"},
185+
{Type: token.PAGE_UP, Options: "", Args: "2"},
186+
{Type: token.PAGE_UP, Options: "1s", Args: "3"},
187187
{Type: token.DOWN, Options: "", Args: "1"},
188188
{Type: token.DOWN, Options: "", Args: "2"},
189189
{Type: token.DOWN, Options: "1s", Args: "3"},

record.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ var EscapeSequences = map[string]string{
3131
"\x1b[2~": token.INSERT,
3232
"\x1b[3~": token.DELETE,
3333
"\x1b[4~": token.END,
34-
"\x1b[5~": token.PAGEUP,
35-
"\x1b[6~": token.PAGEDOWN,
34+
"\x1b[5~": token.PAGE_UP,
35+
"\x1b[6~": token.PAGE_DOWN,
3636
"\x01": token.CTRL + "+A",
3737
"\x02": token.CTRL + "+B",
3838
"\x03": token.CTRL + "+C",

record_test.go

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import (
66
)
77

88
func TestInputToTape(t *testing.T) {
9-
input := `echo "Hello,.
9+
tests := []struct {
10+
name string
11+
input string
12+
want string
13+
}{
14+
{
15+
name: "ctrl key combinations",
16+
input: `echo "Hello,.
1017
BACKSPACE
1118
LEFT
1219
LEFT
@@ -31,9 +38,8 @@ SLEEP
3138
ALT+.
3239
SLEEP
3340
exit
34-
`
35-
36-
want := `Type 'echo "Hello,.'
41+
`,
42+
want: `Type 'echo "Hello,.'
3743
Backspace
3844
Left 2
3945
Right 2
@@ -51,10 +57,36 @@ Ctrl+E
5157
Sleep 1s
5258
Alt+.
5359
Sleep 500ms
54-
`
55-
got := inputToTape(input)
56-
if want != got {
57-
t.Fatalf("want:\n%s\ngot:\n%s\n", want, got)
60+
`,
61+
},
62+
{
63+
name: "PageUp, PageDown #559",
64+
input: `echo "Hello,.
65+
PAGE_UP
66+
PAGE_UP
67+
PAGE_UP
68+
PAGE_UP
69+
PAGE_UP
70+
PAGE_UP
71+
PAGE_UP
72+
PAGE_UP
73+
PAGE_DOWN
74+
PAGE_DOWN
75+
PAGE_DOWN
76+
PAGE_DOWN
77+
exit
78+
`,
79+
want: `Type 'echo "Hello,.'
80+
PageUp 8
81+
PageDown 4
82+
`,
83+
},
84+
}
85+
for _, tc := range tests {
86+
got := inputToTape(tc.input)
87+
if tc.want != got {
88+
t.Fatalf("want:\n%s\ngot:\n%s\n", tc.want, got)
89+
}
5890
}
5991
}
6092

token/token.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const (
4949
ESCAPE = "ESCAPE"
5050
HOME = "HOME"
5151
INSERT = "INSERT"
52-
PAGEDOWN = "PAGEDOWN"
53-
PAGEUP = "PAGEUP"
52+
PAGE_DOWN = "PAGE_DOWN" //nolint:revive
53+
PAGE_UP = "PAGE_UP" //nolint:revive
5454
SLEEP = "SLEEP"
5555
SPACE = "SPACE"
5656
TAB = "TAB"
@@ -125,8 +125,8 @@ var Keywords = map[string]Type{
125125
"Left": LEFT,
126126
"Right": RIGHT,
127127
"Up": UP,
128-
"PageUp": PAGEUP,
129-
"PageDown": PAGEDOWN,
128+
"PageUp": PAGE_UP, //nolint:revive
129+
"PageDown": PAGE_DOWN, //nolint:revive
130130
"Tab": TAB,
131131
"Escape": ESCAPE,
132132
"End": END,
@@ -182,7 +182,7 @@ func IsSetting(t Type) bool {
182182
func IsCommand(t Type) bool {
183183
switch t {
184184
case TYPE, SLEEP,
185-
UP, DOWN, RIGHT, LEFT, PAGEUP, PAGEDOWN,
185+
UP, DOWN, RIGHT, LEFT, PAGE_UP, PAGE_DOWN,
186186
ENTER, BACKSPACE, DELETE, TAB,
187187
ESCAPE, HOME, INSERT, END, CTRL, SOURCE, SCREENSHOT, COPY, PASTE, WAIT:
188188
return true

0 commit comments

Comments
 (0)