[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] Trapping getChar before echo

Subject: Re: [Haskell-cafe] Trapping getChar before echo
From: Michael Hartl
Date: Sun, 31 Jan 2010 11:12:43 +0100
import System.IO
import Data.Char

main = do
  hSetEcho stdin False
  hSetBuffering stdin NoBuffering
  hSetBuffering stdout NoBuffering
  scanLine
      where scanLine = do 
              c <- hGetChar stdin
              putChar . toUpper $ c
              scanLine


Am Sonntag, den 31.01.2010, 19:17 +1030 schrieb Mark Spezzano:
> Hi,
> 
> Is there any way of trapping keystrokes in Haskell, modifying them, and then 
> echoing?
> 
> Basically I want to give the user a prompt  like:
> >
> 
> and then have whatever they type appear in UPPERCASE regardless of whether 
> caps lock was on or not.
> 
> By default Haskell seems to echo characters in whatever case they were typed. 
> I want to sneak in a toUpper in before the Chars get echoed.
> 
> Thanks
> 
> Mark Spezzano
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>