getContents, getLine, etc.
Bernd Holzmüller
holzmueller@ics-ag.de
Wed, 06 Aug 2003 13:46:56 +0200
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:holzmueller@ics-ag.de http://www.ics-ag.de