Readline (was Re: state of ghc6 on sparc)

Mike Thomas
Mon, 23 Jun 2003 10:28:08 +1000

Hi Malcolm.

I tried this on both a Cygwin (environment variable TERM=cygwin) and a
Windows XP console with GHC 6.0.

Under Cygwin, these problems occurred:

1. ^K and ^L both appear as themselves, rather than causing deletion:

prompt> abc^Kefg

2. When editing an item in the history buffer, if I delete a one or more
characters and then move to the end of the line with the cursor, it "runs
off the end" with the same number of characters  added at the end. Those
characters are taken from the characters at what was previously the end of
the line eg:

prompt> hello

  delete 'l'

prompt> helo

  move to end of line:

prompt> heloo

(This does not happen with a new item, only with history items.)

This happens with a normal Windows XP command prompt too (that is, without
any Haskell program running) so I suspect that it is an overprinting of the
Windows terminal handling on your test program's terminal handling.

The interesting result of that is that successive invocations of the same
executable retain the command line history of previous runs.

I would expect substantially different results running under a Win98 command
line as console line editing is not provided on those older versions of the

Under the Windows XP command line prompt:

1. The stty system call is redundant:

'stty' is not recognized as an internal or external command,
operable program or batch file.

Checking that the preprocessor symbol "i386_unknown_mingw32_TARGET" is not
defined fixed that.

2. - See points 1 and 2 of the Cygwin problems above and the conclusions
drawn there.


Mike Thomas.

| -----Original Message-----
| From:
| []On Behalf Of Malcolm
| Wallace
| Sent: Friday, June 20, 2003 2:39 AM
| To:
| Cc:
| Subject: Readline (was Re: state of ghc6 on sparc)
| Alastair Reid <> writes:
| > It would be nice to have those bindings but just having backspace and
| > left-right cursors work would already be a huge improvement
| over nothing.
| OK, here is my contribution.  The attached module SimpleLineEditor
| is API-compatible with readline, and is a slight elaboration of
| the line editor currently distributed as part of hmake interactive.
| It does the basic stuff like backspace and left and right arrows.
| Today's addition was a simple history mechanism using (uggh!) an IORef.
| Because of the way I chose to implement a separation of
| keystroke-recognition from interpretation of the associated editing
| command, it should be reasonably straightforward to extend/change
| the keystrokes for different terminal types.  It should also be
| fairly easy to add more editing commands (e.g. there are commands
| for word-movement, and begin/end of line, but no key-binding and no
| interpretation yet either.)
| Perhaps we should add something like this to the hierarchical libs,
| in the readline package?  Then we can have some basic line-editing
| functionality available in a portable fashion, independent of whether
| any particular machine has the real readline library installed.
| Regards,
|     Malcolm