浏览代码

Make sure the terminal is always in application mode when zle is active.

Felix Dreissig 11 年之前
父节点
当前提交
ff0cafa14d
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      lib/key-bindings.zsh

+ 13 - 0
lib/key-bindings.zsh

@@ -2,6 +2,19 @@
 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
 # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
 
 
+# Make sure that the terminal is in application mode when zle is active, since
+# only then values from $terminfo are valid
+if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
+  function zle-line-init() {
+    echoti smkx
+  }
+  function zle-line-finish() {
+    echoti rmkx
+  }
+  zle -N zle-line-init
+  zle -N zle-line-finish
+fi
+
 bindkey -e                                          # Use emacs key bindings
 bindkey -e                                          # Use emacs key bindings
 
 
 bindkey '\ew' kill-region                           # [Esc-w] - Kill from the cursor to the mark
 bindkey '\ew' kill-region                           # [Esc-w] - Kill from the cursor to the mark