diff --git a/README.md b/README.md index 86b0eb8..c0ef8a8 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ We support all builtin functions, but have no IO (no `print`). ## TODO -- A good readline copy (haskeline is sadly out of the question for this project) - - Add keyboard shortcuts - Comment parsing - Closures that can modify the parent environment (but do away with the `local` keyword). - Better arbitrary precision floats diff --git a/src/BC/Prompt.hs b/src/BC/Prompt.hs index 4647012..5e43303 100644 --- a/src/BC/Prompt.hs +++ b/src/BC/Prompt.hs @@ -212,15 +212,23 @@ readline state = read' "" 0 putStr [c] read' (take pos acc ++ [c] ++ drop pos acc) (pos+1) pstate else - if ord c == 18 -- 18 == Ctrl+R - then do + case ord c of + 1 -> -- == cursor to beginning + read' acc 0 pstate + 2 -> -- == cursor left + read' acc (if pos > 0 then pos-1 else pos) pstate + 5 -> -- == cursor to end + read' acc (length acc) pstate + 6 -> -- == cursor right + read' acc (if pos < length acc then pos+1 else pos) pstate + 18 -> do -- == Ctrl+R mnacc <- reverseSearch pstate acc case mnacc of Just nacc -> do putStr nacc return (Just nacc) _ -> read' acc pos pstate - else read' acc pos pstate + _ ->read' acc pos pstate clamp n min max | n < min = min | n > max = max