【问题标题】:How to write ~/.haskeline so that ghci or haskeline can behave properly on `home` and `end`如何编写 ~/.haskeline 以便 ghci 或 haskeline 可以在 `home` 和 `end` 上正常运行
【发布时间】:2016-02-16 16:03:21
【问题描述】:

我的问题是如何让我的ghci 对我的homeend 做出正确反应。

我了解到ghci 使用haskeline 对用户输入做出反应,而haskeline 的行为在某种程度上是在~/.haskeline 中定义的。

长期以来,我一直在为ghciend key 和home key 缺乏支持而苦恼。所以我尝试定义自己的~/.haskeline 文件。

首先:

bind: a home
bind: b end

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

bind: left home
bind: right end

当我按下 a 然后光标在最左边时,两者的行为都与其他类似。

其次:

bind: home a
bind: end b

这表明我的ghci 似乎完全忽略了我的homeend 按下。

那么我如何将homeend 密钥发送到ghcihaskline

【问题讨论】:

    标签: haskell keyboard read-eval-print-loop ghci haskeline


    【解决方案1】:

    应该默认工作。 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 变量中的任何内容。

    【讨论】:

      【解决方案2】:

      我目前对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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-08-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-26
        • 1970-01-01
        相关资源
        最近更新 更多