From 35919000709c00274f2fbb56db2f2924585edd05 Mon Sep 17 00:00:00 2001 From: Maxim Gonchar Date: Mon, 20 Jan 2014 16:47:13 +0400 Subject: [PATCH 1/3] More clear way of setting cursor shape --- share/functions/__fish_cursor_konsole.fish | 11 +++ share/functions/__fish_cursor_xterm.fish | 16 +++++ share/functions/fish_vi_cursor.fish | 78 +++++++--------------- 3 files changed, 52 insertions(+), 53 deletions(-) create mode 100644 share/functions/__fish_cursor_konsole.fish create mode 100644 share/functions/__fish_cursor_xterm.fish diff --git a/share/functions/__fish_cursor_konsole.fish b/share/functions/__fish_cursor_konsole.fish new file mode 100644 index 000000000..381ff9b9c --- /dev/null +++ b/share/functions/__fish_cursor_konsole.fish @@ -0,0 +1,11 @@ +function __fish_cursor_konsole -d 'Set cursor (konsole)' + set -l shape $argv[1] + switch "$shape" + case block + echo -en '\e]50;CursorShape=0\x7' + case underscore + echo -en '\e]50;CursorShape=2\x7' + case line + echo -en '\e]50;CursorShape=1\x7' + end +end diff --git a/share/functions/__fish_cursor_xterm.fish b/share/functions/__fish_cursor_xterm.fish new file mode 100644 index 000000000..1a0909e8d --- /dev/null +++ b/share/functions/__fish_cursor_xterm.fish @@ -0,0 +1,16 @@ +function __fish_cursor_xterm -d 'Set cursor (xterm)' + set -l shape $argv[1] + + switch "$shape" + case block + set shape 2 + case underscore + set shape 4 + case line + set shape 6 + end + if contains blink $argv + set shape (expr $shape - 1) + end + echo -en "\e[$shape q" +end diff --git a/share/functions/fish_vi_cursor.fish b/share/functions/fish_vi_cursor.fish index e3dae47a7..141bd2f5c 100644 --- a/share/functions/fish_vi_cursor.fish +++ b/share/functions/fish_vi_cursor.fish @@ -1,59 +1,31 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes' - set -l terminal $argv[1] - set -q terminal[1]; or set terminal auto + set -l terminal $argv[1] + set -q terminal[1]; or set terminal auto - switch "$terminal" - case auto - if set -q KONSOLE_PROFILE_NAME - set terminal konsole - else if set -q XTERM_LOCALE - set terminal xterm - else - #echo Not found - return 1 + set fcn + switch "$terminal" + case auto + if set -q KONSOLE_PROFILE_NAME + set fcn __fish_cursor_konsole + else if set -q XTERM_LOCALE + set fcn __fish_cursor_xterm + else + return 1 + end end - end - set -l command - set -l start - set -l end - set -l shape_block - set -l shape_line - set -l shape_underline - switch "$terminal" - case konsole iterm - set command echo -en - set start "\e]50;" - set end "\x7" - set shape_block 'CursorShape=0' - set shape_line 'CursorShape=1' - set shape_underline 'CursorShape=2' - case xterm - set command echo -en - set start '\e[' - set end ' q' - set shape_block '2' - set shape_underline '4' - set shape_line '6' - end - if not set -q command[1] - #echo not found - return 1 - end - set -g fish_cursor_insert $start$shape_line$end - set -g fish_cursor_default $start$shape_block$end - set -g fish_cursor_other $start$shape_block$end + set -g fish_cursor_insert line + set -g fish_cursor_default block + set -g fish_cursor_unknown block blink - echo " - function fish_vi_cursor_handle --on-variable fish_bind_mode - switch \$fish_bind_mode - case insert - $command \$fish_cursor_insert - case default - $command \$fish_cursor_default - case '*' - $command \$fish_cursor_other - end - end - " | source + echo " + function fish_cursor_vi_handle --on-variable fish_bind_mode + set -l varname fish_cursor_\$fish_bind_mode + if not set -q \$varname + set varname fish_cursor_unknown + end + #echo \$varname \$\$varname + $fcn \$\$varname + end + " | source end From 1514ab8ec5e4d7effe5639bf51b04b1e1f97b1b0 Mon Sep 17 00:00:00 2001 From: Maxim Gonchar Date: Mon, 20 Jan 2014 17:03:46 +0400 Subject: [PATCH 2/3] Retab --- share/functions/__fish_cursor_konsole.fish | 18 +++---- share/functions/__fish_cursor_xterm.fish | 26 ++++----- .../functions/fish_default_key_bindings.fish | 8 +-- share/functions/fish_vi_cursor.fish | 54 +++++++++---------- 4 files changed, 53 insertions(+), 53 deletions(-) diff --git a/share/functions/__fish_cursor_konsole.fish b/share/functions/__fish_cursor_konsole.fish index 381ff9b9c..12d23c696 100644 --- a/share/functions/__fish_cursor_konsole.fish +++ b/share/functions/__fish_cursor_konsole.fish @@ -1,11 +1,11 @@ function __fish_cursor_konsole -d 'Set cursor (konsole)' - set -l shape $argv[1] - switch "$shape" - case block - echo -en '\e]50;CursorShape=0\x7' - case underscore - echo -en '\e]50;CursorShape=2\x7' - case line - echo -en '\e]50;CursorShape=1\x7' - end + set -l shape $argv[1] + switch "$shape" + case block + echo -en '\e]50;CursorShape=0\x7' + case underscore + echo -en '\e]50;CursorShape=2\x7' + case line + echo -en '\e]50;CursorShape=1\x7' + end end diff --git a/share/functions/__fish_cursor_xterm.fish b/share/functions/__fish_cursor_xterm.fish index 1a0909e8d..8a8948b12 100644 --- a/share/functions/__fish_cursor_xterm.fish +++ b/share/functions/__fish_cursor_xterm.fish @@ -1,16 +1,16 @@ function __fish_cursor_xterm -d 'Set cursor (xterm)' - set -l shape $argv[1] + set -l shape $argv[1] - switch "$shape" - case block - set shape 2 - case underscore - set shape 4 - case line - set shape 6 - end - if contains blink $argv - set shape (expr $shape - 1) - end - echo -en "\e[$shape q" + switch "$shape" + case block + set shape 2 + case underscore + set shape 4 + case line + set shape 6 + end + if contains blink $argv + set shape (expr $shape - 1) + end + echo -en "\e[$shape q" end diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index f3ac2e75f..ffb4371f5 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -1,9 +1,9 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish" -a mode - if not set -q mode[1] - # Clear earlier bindings, if any - bind --erase --all - end + if not set -q mode[1] + # Clear earlier bindings, if any + bind --erase --all + end # This is the default binding, i.e. the one used if no other binding matches bind $argv "" self-insert diff --git a/share/functions/fish_vi_cursor.fish b/share/functions/fish_vi_cursor.fish index 141bd2f5c..c00485a95 100644 --- a/share/functions/fish_vi_cursor.fish +++ b/share/functions/fish_vi_cursor.fish @@ -1,31 +1,31 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes' - set -l terminal $argv[1] - set -q terminal[1]; or set terminal auto + set -l terminal $argv[1] + set -q terminal[1]; or set terminal auto - set fcn - switch "$terminal" - case auto - if set -q KONSOLE_PROFILE_NAME - set fcn __fish_cursor_konsole - else if set -q XTERM_LOCALE - set fcn __fish_cursor_xterm - else - return 1 - end - end - - set -g fish_cursor_insert line - set -g fish_cursor_default block - set -g fish_cursor_unknown block blink - - echo " - function fish_cursor_vi_handle --on-variable fish_bind_mode - set -l varname fish_cursor_\$fish_bind_mode - if not set -q \$varname - set varname fish_cursor_unknown - end - #echo \$varname \$\$varname - $fcn \$\$varname + set fcn + switch "$terminal" + case auto + if set -q KONSOLE_PROFILE_NAME + set fcn __fish_cursor_konsole + else if set -q XTERM_LOCALE + set fcn __fish_cursor_xterm + else + return 1 + end end - " | source + + set -g fish_cursor_insert line + set -g fish_cursor_default block + set -g fish_cursor_unknown block blink + + echo " + function fish_cursor_vi_handle --on-variable fish_bind_mode + set -l varname fish_cursor_\$fish_bind_mode + if not set -q \$varname + set varname fish_cursor_unknown + end + #echo \$varname \$\$varname + $fcn \$\$varname + end + " | source end From 71992158bf18c85f70828825c1b6cf77123f3d36 Mon Sep 17 00:00:00 2001 From: Maxim Gonchar Date: Mon, 20 Jan 2014 17:12:32 +0400 Subject: [PATCH 3/3] Retab again default_keybindings are left with tabs as it was in the beginning --- share/functions/__fish_complete_vi.fish | 8 ++-- share/functions/__fish_cursor_konsole.fish | 18 ++++---- share/functions/__fish_cursor_xterm.fish | 26 +++++------ share/functions/fish_vi_cursor.fish | 52 +++++++++++----------- 4 files changed, 52 insertions(+), 52 deletions(-) diff --git a/share/functions/__fish_complete_vi.fish b/share/functions/__fish_complete_vi.fish index f2f253dab..8a07ffd2e 100644 --- a/share/functions/__fish_complete_vi.fish +++ b/share/functions/__fish_complete_vi.fish @@ -3,8 +3,8 @@ function __fish_complete_vi -d "Compleletions for vi and its aliases" --argument-names cmd set -l is_vim if type $cmd > /dev/null - eval command $cmd --version >/dev/null ^/dev/null; and set -l is_vim vim - end + eval command $cmd --version >/dev/null ^/dev/null; and set -l is_vim vim + end # vim set -l cmds -c $cmd @@ -24,11 +24,11 @@ function __fish_complete_vi -d "Compleletions for vi and its aliases" --argument complete $cmds -s o -r --description 'Open stacked windows for each file' complete $cmds -s O -r --description 'Open side by side windows for each file' complete $cmds -s p -r --description 'Open tab pages for each file' - complete $cmds -s q -r --description 'Start in quickFix mode' + complete $cmds -s q -r --description 'Start in quickFix mode' complete $cmds -s r -r --description 'Use swap files for recovery' complete $cmds -s s -r --description 'Source and execute script file' complete $cmds -s t -r --description 'Set the cursor to tag' - complete $cmds -s T -r --description 'Terminal name' + complete $cmds -s T -r --description 'Terminal name' complete $cmds -s u -r --description 'Use alternative vimrc' complete $cmds -s U -r --description 'Use alternative vimrc in GUI mode' complete $cmds -s w -r --description 'Record all typed characters' diff --git a/share/functions/__fish_cursor_konsole.fish b/share/functions/__fish_cursor_konsole.fish index 12d23c696..acdcb0de6 100644 --- a/share/functions/__fish_cursor_konsole.fish +++ b/share/functions/__fish_cursor_konsole.fish @@ -1,11 +1,11 @@ function __fish_cursor_konsole -d 'Set cursor (konsole)' - set -l shape $argv[1] - switch "$shape" - case block - echo -en '\e]50;CursorShape=0\x7' - case underscore - echo -en '\e]50;CursorShape=2\x7' - case line - echo -en '\e]50;CursorShape=1\x7' - end + set -l shape $argv[1] + switch "$shape" + case block + echo -en '\e]50;CursorShape=0\x7' + case underscore + echo -en '\e]50;CursorShape=2\x7' + case line + echo -en '\e]50;CursorShape=1\x7' + end end diff --git a/share/functions/__fish_cursor_xterm.fish b/share/functions/__fish_cursor_xterm.fish index 8a8948b12..a82be021f 100644 --- a/share/functions/__fish_cursor_xterm.fish +++ b/share/functions/__fish_cursor_xterm.fish @@ -1,16 +1,16 @@ function __fish_cursor_xterm -d 'Set cursor (xterm)' - set -l shape $argv[1] + set -l shape $argv[1] - switch "$shape" - case block - set shape 2 - case underscore - set shape 4 - case line - set shape 6 - end - if contains blink $argv - set shape (expr $shape - 1) - end - echo -en "\e[$shape q" + switch "$shape" + case block + set shape 2 + case underscore + set shape 4 + case line + set shape 6 + end + if contains blink $argv + set shape (expr $shape - 1) + end + echo -en "\e[$shape q" end diff --git a/share/functions/fish_vi_cursor.fish b/share/functions/fish_vi_cursor.fish index c00485a95..f8d9ccd1f 100644 --- a/share/functions/fish_vi_cursor.fish +++ b/share/functions/fish_vi_cursor.fish @@ -1,31 +1,31 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes' - set -l terminal $argv[1] - set -q terminal[1]; or set terminal auto + set -l terminal $argv[1] + set -q terminal[1]; or set terminal auto - set fcn - switch "$terminal" - case auto - if set -q KONSOLE_PROFILE_NAME - set fcn __fish_cursor_konsole - else if set -q XTERM_LOCALE - set fcn __fish_cursor_xterm - else - return 1 - end - end + set fcn + switch "$terminal" + case auto + if set -q KONSOLE_PROFILE_NAME + set fcn __fish_cursor_konsole + else if set -q XTERM_LOCALE + set fcn __fish_cursor_xterm + else + return 1 + end + end - set -g fish_cursor_insert line - set -g fish_cursor_default block - set -g fish_cursor_unknown block blink + set -g fish_cursor_insert line + set -g fish_cursor_default block + set -g fish_cursor_unknown block blink - echo " - function fish_cursor_vi_handle --on-variable fish_bind_mode - set -l varname fish_cursor_\$fish_bind_mode - if not set -q \$varname - set varname fish_cursor_unknown - end - #echo \$varname \$\$varname - $fcn \$\$varname - end - " | source + echo " + function fish_cursor_vi_handle --on-variable fish_bind_mode + set -l varname fish_cursor_\$fish_bind_mode + if not set -q \$varname + set varname fish_cursor_unknown + end + #echo \$varname \$\$varname + $fcn \$\$varname + end + " | source end