1

My question is how to make my ghci react properly on my home and end press.

I learned that ghci use haskeline to react to user input, and haskeline's behavior is partially defined in ~/.haskeline to some extent.

I have being suffering from the lack of support for end key and home key of ghci for a long time. So I tried to define my own ~/.haskeline file.

Firstly:

bind: a home
bind: b end

keyseq: "a" home
keyseq: "b" end

bind: left home
bind: right end

Both behave as when I press a then the cursor to the most left and similarly to others.

Secondly:

bind: home a
bind: end b

It shows that my ghci seems to ignore my home and end press absolutely.

So how could I send home and end key to ghci and haskline?

4

2 回答 2

2

应该默认工作。Haskeline 很可能无法识别您的键盘发送的任何内容作为homeend键。这取决于您的操作系统和终端设置。

您可能希望将您的$TERM设置调整为支持这些键的设置,之后Haskeline 应该会自动拾取它们。

否则,Haskeline trac wiki有一个方法可以让它识别未知的键序列,这应该在 POSIX 系统上工作(而不是在 Windows 上,默认情况下homeend应该已经工作)。将此适应当前情况:

$ ghc -e getLine
<press home, then return>...some noise here...
"...haskell string for home..."
$ ghc -e getLine
<press end, then return>...some other noise...
"...haskell string for end..."

将相应的行添加到~/.haskeline

keyseq: your-terminal "...haskell string for home..." home
keyseq: your-terminal "...haskell string for end..." end

变量your-terminal中的内容在哪里。$TERM

于 2015-11-16T02:27:17.243 回答
0

我目前不太了解Most likely Haskeline isn't recognizing whatever your keyboard sends as the home and end keys. This depends on your OS and terminal setup.我今天第一次了解到这一点。

但是我成功地写了一个~/.haskeline适应我的笔记本电脑(Ubuntu 14.04,ghc-7.10.2)。

keyseq: "\ESCOH" home
keyseq: "\ESCOF" end
于 2015-11-16T05:52:16.623 回答