Skip to content

Commit 172f387

Browse files
committed
Refactor command execution
1 parent 6320514 commit 172f387

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/module/repl.wren

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ class Repl {
6666
// TODO: Handle ESC 0 sequences.
6767
}
6868
} else if (byte == Chars.carriageReturn) {
69-
var next = executeInput()
70-
if (next == Chars.ctrlD) return true
71-
if (next != null) handleChar(next)
69+
return executeInput()
7270
} else if (byte == Chars.delete) {
7371
deleteLeft()
7472
} else if (byte >= Chars.space && byte <= Chars.tilde) {
@@ -215,13 +213,13 @@ class Repl {
215213
}
216214
}
217215

218-
executeCommand(command, arguments) {
216+
executeCommand(command, argument) {
219217
if (command == Command.clear) {
220-
return Chars.ctrlL
218+
return this.handleChar(Chars.ctrlL)
221219
}
222220

223221
if (command == Command.exit) {
224-
return Chars.ctrlD
222+
return true
225223
}
226224

227225
if (command == Command.help) {

src/module/repl.wren.inc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ static const char* replModuleSource =
6868
" // TODO: Handle ESC 0 sequences.\n"
6969
" }\n"
7070
" } else if (byte == Chars.carriageReturn) {\n"
71-
" var next = executeInput()\n"
72-
" if (next == Chars.ctrlD) return true\n"
73-
" if (next != null) handleChar(next)\n"
71+
" return executeInput()\n"
7472
" } else if (byte == Chars.delete) {\n"
7573
" deleteLeft()\n"
7674
" } else if (byte >= Chars.space && byte <= Chars.tilde) {\n"
@@ -217,13 +215,13 @@ static const char* replModuleSource =
217215
" }\n"
218216
" }\n"
219217
"\n"
220-
" executeCommand(command, arguments) {\n"
218+
" executeCommand(command, argument) {\n"
221219
" if (command == Command.clear) {\n"
222-
" return Chars.ctrlL\n"
220+
" return this.handleChar(Chars.ctrlL)\n"
223221
" }\n"
224222
"\n"
225223
" if (command == Command.exit) {\n"
226-
" return Chars.ctrlD\n"
224+
" return true\n"
227225
" }\n"
228226
"\n"
229227
" if (command == Command.help) {\n"

0 commit comments

Comments
 (0)