prompt: added emacs-like shortcuts
This commit is contained in:
@@ -17,8 +17,6 @@ We support all builtin functions, but have no IO (no `print`).
|
|||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- A good readline copy (haskeline is sadly out of the question for this project)
|
|
||||||
- Add keyboard shortcuts
|
|
||||||
- Comment parsing
|
- Comment parsing
|
||||||
- Closures that can modify the parent environment (but do away with the `local` keyword).
|
- Closures that can modify the parent environment (but do away with the `local` keyword).
|
||||||
- Better arbitrary precision floats
|
- Better arbitrary precision floats
|
||||||
|
@@ -212,15 +212,23 @@ readline state = read' "" 0
|
|||||||
putStr [c]
|
putStr [c]
|
||||||
read' (take pos acc ++ [c] ++ drop pos acc) (pos+1) pstate
|
read' (take pos acc ++ [c] ++ drop pos acc) (pos+1) pstate
|
||||||
else
|
else
|
||||||
if ord c == 18 -- 18 == Ctrl+R
|
case ord c of
|
||||||
then do
|
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
|
mnacc <- reverseSearch pstate acc
|
||||||
case mnacc of
|
case mnacc of
|
||||||
Just nacc -> do
|
Just nacc -> do
|
||||||
putStr nacc
|
putStr nacc
|
||||||
return (Just nacc)
|
return (Just nacc)
|
||||||
_ -> read' acc pos pstate
|
_ -> read' acc pos pstate
|
||||||
else read' acc pos pstate
|
_ ->read' acc pos pstate
|
||||||
clamp n min max
|
clamp n min max
|
||||||
| n < min = min
|
| n < min = min
|
||||||
| n > max = max
|
| n > max = max
|
||||||
|
Reference in New Issue
Block a user