diff options
-rwxr-xr-x | telem.lua | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -279,11 +279,13 @@ function do_type() -- Show prompt and read one char io.write("[f]irst, [n]ext, [p]rev, [l]last, [r]eply, [d]one > ") c = getchar() - io.write("\n") + if c ~= "\n" then io.write("\n") end -- Dispatch to sub-command - if type_dispatch[c] == nil then + if c == "\n" then + -- pass + elseif type_dispatch[c] == nil then print("Invalid command!") - else + elseif c ~= "\n" then type_dispatch[c]() end until c == "d" @@ -357,11 +359,13 @@ repeat -- Show prompt and read 1 char from keyboard io.write("["..current_board.."] COMMAND :> ") c = getchar() - io.write("\n") + if c ~= "\n" then io.write("\n") end -- Use char as index into dispatch table - if dispatch[c] == nil then + if c == "\n" then + -- pass + elseif dispatch[c] == nil then print("Unrecognised command, hit `h` for help.") - else + else dispatch[c]() end until c == "q" |