
Hi, I'm writing a program for my final project at uni and I've come across the following annoying bug in my program. Basically, I have an interactive text prompt and I wish to be able to write commands into the prompt. I am currently using the function 'getLine', which as it's name suggests reads a line of text from the prompt. Unfortunately, when the delete key is used while writing to the prompt, the output differs (so typing "loaf" then 'delete' and then "d" does not seem to produce the same output as typing "load"). Also, the left and right arrow keys don't work, as they do in any normal text prompt. Any suggestins as to an alternative method to read the input??? (I'm by no means a Haskell expert btw, so I may have to be spoon fed!) thanks for your help, Rich.

If you're using GHC, take a look at module Readline in the util package (http://www.haskell.org/ghc/docs/latest/set/readline.html). I don't know which other Haskell systems support this module. Dean Herington On Mon, 25 Feb 2002, Rich wrote:
Hi,
I'm writing a program for my final project at uni and I've come across the following annoying bug in my program. Basically, I have an interactive text prompt and I wish to be able to write commands into the prompt. I am currently using the function 'getLine', which as it's name suggests reads a line of text from the prompt. Unfortunately, when the delete key is used while writing to the prompt, the output differs (so typing "loaf" then 'delete' and then "d" does not seem to produce the same output as typing "load"). Also, the left and right arrow keys don't work, as they do in any normal text prompt.
Any suggestins as to an alternative method to read the input??? (I'm by no means a Haskell expert btw, so I may have to be spoon fed!)
thanks for your help, Rich.

On Mon, 25 Feb 2002, Dean Herington wrote:
If you're using GHC, take a look at module Readline in the util package (http://www.haskell.org/ghc/docs/latest/set/readline.html). I don't know which other Haskell systems support this module.
The annoying thing is the way that terminals generally act on the ASCII codes so it looks like the delete is working. Readline library sounds like the much the best option; however if it doesn't work it is possible to write a function which postprocesses the returned string and acts on the ASCII codes for backspace, arrow movement, etc, although it's a bit complex as you've got to get easy deletion of points both immediately before and after the point you are considering in the string. ___cheers,_dave_________________________________________________________ www.cs.bris.ac.uk/~tweed/|`...heat generated by its microprocessors will email:tweed@cs.bris.ac.uk|slope upward exponentially, reaching the power work tel:(0117) 954-5250 |density of a nuclear reactor before 2010'-Intel
participants (3)
-
D. Tweed
-
Dean Herington
-
Rich