Skip to content

Commit 07b4c8a

Browse files
authored
Merge pull request #7 from gitdev-bash/Add-Repeat
Add repeat & other fix
2 parents a2842c1 + a579053 commit 07b4c8a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

piduck.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from importlib import import_module
44
from time import sleep
55

6+
last_line = ""
67
key_layout = "us"
78
default_delay = 10
89
string_delay = 1
@@ -38,16 +39,20 @@ def string(string):
3839
def pharse(line, known, deltrue):
3940
global default_delay
4041
global string_delay
41-
if line != " ":
42-
command = line.split()
43-
else:
42+
if line == "":
43+
return
44+
elif line == " ":
4445
command = [" "]
46+
else:
47+
command = line.split()
4548
if command[0] == "DELAY":
4649
sleep(int(command[1]) / 100)
4750
return
4851
elif command[0] == "REM":
4952
return
5053
elif command[0] == "REPEAT":
54+
for i in range(int(command[1])):
55+
pharse(last_line.strip(), [[], []], False)
5156
return # todo
5257
elif command[0] == "DEFAULTCHARDELAY":
5358
string_delay = int(command[1])
@@ -63,14 +68,14 @@ def pharse(line, known, deltrue):
6368
return
6469
elif command[0] in keymap.commap:
6570
known[0].append(keymap.commap[command[0]])
66-
if len(command) > 0:
71+
if len(command) > 1:
6772
pharse(" ".join(command[1:]), known, True)
6873
else:
6974
out(known)
7075
return
7176
elif command[0] in keymap.c1map:
7277
known[1].append(keymap.c1map[command[0]])
73-
if len(command) > 0:
78+
if len(command) > 1:
7479
pharse(" ".join(command[1:]), known, True)
7580
else:
7681
out(known)
@@ -102,20 +107,23 @@ def out(ccl):
102107

103108

104109
def main():
110+
global last_line
105111
if piargs.input is not None:
106112
file1 = open(piargs.input, "r")
107113
while True:
108114
line = file1.readline()
109115
if not line:
110116
break
111117
pharse(line.strip(), [[], []], False)
118+
last_line = line
112119
file1.close()
113120
else:
114121
while True:
115122
line = input()
116123
if not line:
117124
break
118125
pharse(line.strip(), [[], []], False)
126+
last_line = line
119127

120128

121129
main()

0 commit comments

Comments
 (0)