diff options
Diffstat (limited to 'defaultGetCommand.hs')
-rw-r--r-- | defaultGetCommand.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/defaultGetCommand.hs b/defaultGetCommand.hs new file mode 100644 index 0000000..b82f2ce --- /dev/null +++ b/defaultGetCommand.hs @@ -0,0 +1,33 @@ + + + + +defaultGetCommand :: IO Command +defaultGetCommand = do + c1 <- getChar + case c1 of + '\x1b' -> do + c2 <- getChar + case c2 of + '[' -> do + c3 <- getChar + case c3 of + 'C' -> return MoveCursorRight + 'D' -> return MoveCursorLeft + '3' -> do + c4 <- getChar + case c4 of + '~' -> return KillNextChar + _ -> return $ AlertBadInput (c1:c2:c3:c4:[]) + _ -> return $ AlertBadInput (c1:c2:c3:[]) + _ -> return $ AlertBadInput (c1:c2:[]) + _ -> + if isPrint c1 + then return $ InsertChar c1 + else + case ord c1 of + 22 -> return InsertNextCharVerbatim + 23 -> return KillLastWord + 10 -> return ExecuteInputBuffer + 127 -> return KillLastChar + _ -> return $ AlertBadInput (c1:[]) |