Skip to content
Snippets Groups Projects
Commit 3eb3ac1f authored by sof's avatar sof
Browse files

[project @ 1999-02-06 17:12:03 by sof]

H98ified
parent 69add38d
No related merge requests found
...@@ -36,8 +36,6 @@ import Foreign ...@@ -36,8 +36,6 @@ import Foreign
import System import System
--#include <readline/readline.h>
type KeyCode = Int type KeyCode = Int
type RlCallbackFunction = type RlCallbackFunction =
...@@ -64,7 +62,7 @@ readline prompt = do ...@@ -64,7 +62,7 @@ readline prompt = do
prompt (length prompt) prompt (length prompt)
litstr <- _casm_GC_ ``%r = readline (rl_prompt_hack);'' litstr <- _casm_GC_ ``%r = readline (rl_prompt_hack);''
if (litstr == ``NULL'') if (litstr == ``NULL'')
then fail (userError "Readline has read EOF") then ioError (userError "Readline has read EOF")
else do else do
str <- unpackCStringIO litstr str <- unpackCStringIO litstr
_ccall_ free litstr _ccall_ free litstr
...@@ -80,7 +78,7 @@ rlBindKey :: KeyCode -- Key to Bind to ...@@ -80,7 +78,7 @@ rlBindKey :: KeyCode -- Key to Bind to
-> IO () -> IO ()
rlBindKey key cback = rlBindKey key cback =
if (0 > key) || (key > 255) then if (0 > key) || (key > 255) then
fail (userError "Invalid ASCII Key Code, must be in range 0.255") ioError (userError "Invalid ASCII Key Code, must be in range 0.255")
else do else do
addCbackEntry (key,cback) addCbackEntry (key,cback)
_casm_ `` rl_bind_key((KeyCode)%0,&genericRlCback); '' key _casm_ `` rl_bind_key((KeyCode)%0,&genericRlCback); '' key
...@@ -100,7 +98,7 @@ rlAddDefun :: String -> -- Function Name ...@@ -100,7 +98,7 @@ rlAddDefun :: String -> -- Function Name
IO () IO ()
rlAddDefun name cback key = rlAddDefun name cback key =
if (0 > key) || (key > 255) then if (0 > key) || (key > 255) then
fail (userError "Invalid ASCII Key Code, must be in range 0..255") ioError (userError "Invalid ASCII Key Code, must be in range 0..255")
else do else do
addCbackEntry (key, cback) addCbackEntry (key, cback)
_casm_ ``rl_add_defun (%0, &genericRlCback, (KeyCode)%1);'' name key _casm_ ``rl_add_defun (%0, &genericRlCback, (KeyCode)%1);'' name key
...@@ -231,8 +229,8 @@ rlSetMark :: Int -> IO () ...@@ -231,8 +229,8 @@ rlSetMark :: Int -> IO ()
rlSetMark mark = _casm_ ``rl_mark = %0;'' mark rlSetMark mark = _casm_ ``rl_mark = %0;'' mark
rlSetDone :: Bool -> IO () rlSetDone :: Bool -> IO ()
rlSetDone True = _casm_ ``rl_done = %0;'' 1 rlSetDone True = _casm_ ``rl_done = %0;'' (1::Int)
rlSetDone False = _casm_ ``rl_done = %0;'' 0 rlSetDone False = _casm_ ``rl_done = %0;'' (0::Int)
rlPendingInput :: KeyCode -> IO () rlPendingInput :: KeyCode -> IO ()
rlPendingInput key = primIOToIO (_casm_ ``rl_pending_input = %0;'' key) rlPendingInput key = primIOToIO (_casm_ ``rl_pending_input = %0;'' key)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment