getContents, getLine, etc.
Bernd Holzmüller <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.hugs.user |
|---|---|
| Organization | ICS AG |
| Message-ID | <[email protected]> |
I recently wrote a getLine version that treats backspace correctly (you
might wish to choose a better name, though :-):
-- getLine' correctly treats backspaces (erasing the deleted characters
in output)
getLine' = liftM reverse $ getLine'' ""
where getLine'' read = do
c <- getChar
if c=='\n' then return read else do
if c=='\b'
then do putStr " \b"
if null read then getLine'' "" else getLine'' (tail read)
else getLine'' (c:read)
Regards,
--
Bernd Holzmüller
______________________________________________________
INFORMATIK CONSULTING SYSTEMS AG
SonnenbergstraÃe 13 70184 Stuttgart
Telefon: +49 (0711) 21037-37 Fax: -75
mailto:[email protected] http://www.ics-ag.de