initial public release
This commit is contained in:
@@ -34,17 +34,31 @@ printStatus str =
|
||||
out = show evald
|
||||
in if isErr evald || length out == 0
|
||||
then return ()
|
||||
else let str = " \x1b[33m=> " ++ out ++ "\x1b[0m"
|
||||
else let str = " \x1b[33m=> " ++ trunc out ++ "\x1b[0m"
|
||||
in putStr (str ++ repeat '\b' (length str - 9))
|
||||
where repeat str 0 = ""
|
||||
repeat str n = (str:repeat str (n-1))
|
||||
trunc s = if length s > 20 then take 20 s ++ "..." else s
|
||||
|
||||
|
||||
cleanPrompt :: IO ()
|
||||
cleanPrompt = putStr "\x1b[2K\r"
|
||||
|
||||
|
||||
-- TODO: Stub
|
||||
readSpecialKey :: IO ()
|
||||
readSpecialKey = do
|
||||
c <- getChar
|
||||
c2 <- getChar
|
||||
return ()
|
||||
|
||||
|
||||
readline :: IO (Maybe String)
|
||||
readline = do
|
||||
putStr promptStr
|
||||
read' ""
|
||||
readline = read' ""
|
||||
where read' acc = do
|
||||
cleanPrompt
|
||||
putStr promptStr
|
||||
putStr acc
|
||||
printStatus acc
|
||||
c <- getChar
|
||||
case c of
|
||||
@@ -57,6 +71,9 @@ readline = do
|
||||
read' (init acc)
|
||||
else do
|
||||
read' acc
|
||||
'\x1b' -> do
|
||||
readSpecialKey
|
||||
read' acc
|
||||
c ->
|
||||
if isPrint c
|
||||
then do
|
||||
|
Reference in New Issue
Block a user