Re: [Haskell-cafe] Trapping getChar before echo
It might be worth looking at something like a curses library. On Mon, Feb 1, 2010 at 4:45 PM, Mark Spezzano wrote: > I've tried this example and it just lets me type in anything in CAPITALS, > which is nice, but Delete key doesn't delete and the arrow keys unfortunately > let me manoeuvre the cursor all over the screen. Also the biggest problem is > that Enter doesn't terminate the input session. > > Isn't there a simple way to do something like this? > > Surely Haskell must have a standard getLine function that support CAPITALS > and backspacing and no arrow keys. Arrows keys with history would be nice. > > Mark > > > On 31/01/2010, at 11:27 PM, Andrew Coppin wrote: > >> Michael Hartl wrote: >>> 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 >>> >> >> Last time I tried something like this [on Windows], it didn't seem to work. >> I wanted to trap arrow keys and so forth, but they seem to be being used for >> input history. (I.e., pressing the up-arrow produces previously-entered >> lines of text, and none of this appears to be reaching the Haskell program >> itself.) Has this changed since I tried it last year? >> >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trapping getChar before echo
I've tried this example and it just lets me type in anything in CAPITALS, which is nice, but Delete key doesn't delete and the arrow keys unfortunately let me manoeuvre the cursor all over the screen. Also the biggest problem is that Enter doesn't terminate the input session. Isn't there a simple way to do something like this? Surely Haskell must have a standard getLine function that support CAPITALS and backspacing and no arrow keys. Arrows keys with history would be nice. Mark On 31/01/2010, at 11:27 PM, Andrew Coppin wrote: > Michael Hartl wrote: >> 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 >> > > Last time I tried something like this [on Windows], it didn't seem to work. I > wanted to trap arrow keys and so forth, but they seem to be being used for > input history. (I.e., pressing the up-arrow produces previously-entered lines > of text, and none of this appears to be reaching the Haskell program itself.) > Has this changed since I tried it last year? > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trapping getChar before echo
Michael Hartl wrote: 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 Last time I tried something like this [on Windows], it didn't seem to work. I wanted to trap arrow keys and so forth, but they seem to be being used for input history. (I.e., pressing the up-arrow produces previously-entered lines of text, and none of this appears to be reaching the Haskell program itself.) Has this changed since I tried it last year? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trapping getChar before echo
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 > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trapping getChar before echo
Hi Mark, http://haskell.org/hoogle/?hoogle=set+echo Thanks, Neil On Sun, Jan 31, 2010 at 8:47 AM, Mark Spezzano wrote: > 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 > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Trapping getChar before echo
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 Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe