
Hi Travis & Mateusz, Thanks for your advice! However I just found out that I didn't need to implement this functionality by hand since Haskeline http://hackage.haskell.org/package/haskeline-0.6.2.2/docs/System-Console-Has... does exactly what I need... Cheers, Emma On Sunday, September 28, 2014 5:01:30 PM UTC+8, Mateusz Kowalczyk wrote:
On 2014年09月28日 16:42, PENG, BO YA wrote:
I'm trying to implement the arrow key functionality for a systemf REPL to recall previously entered lines. I think I should save the previous
in a list and then traverse through the list when an arrow key is
On 09/28/2014 09:43 AM, Travis Cardwell wrote: lines pressed,
but I'm no sure how to detect an arrow key and implement this functionality. Can anyone give a brief description about the implementation or point me to some other resources? Thanks!
Perhaps readline would work for you?
http://hackage.haskell.org/package/readline
Cheers,
Travis _______________________________________________ Haskell-Cafe mailing list Haskel...@haskell.org javascript: http://www.haskell.org/mailman/listinfo/haskell-cafe
For keeping track itself, you can use something like a pointed list[1] pretty easily which frees you from having to keep track of indexes, looping around, going back and forth &c. I use it for quick-and-dirty selection in a menu in the game I'm writing. Once you have a way to get key presses, it becomes trivial (+ some lenses for clarity):
whenM (keyPress KeyUp) $ screenState . maps %= C.previous whenM (keyPress KeyDown) $ screenState . maps %= C.next
where ‘maps’ is my PointedList and C is Data.List.Pointed.Circular.
[1]: http://hackage.haskell.org/package/pointedlist
-- Mateusz K. _______________________________________________ Haskell-Cafe mailing list Haskel...@haskell.org javascript: http://www.haskell.org/mailman/listinfo/haskell-cafe