keymap.vi_test.sh (30153B)
1 #!/bin/bash 2 3 ## @var[out] str ind mark 4 function ble/keymap:vi_test/decompose-state { 5 local spec=$1 6 ind=${spec%%:*} str=${spec#*:} 7 if ((${#ind}==1)) && [[ $ind == [!a-zA-Z0-9] ]]; then 8 ind=${str%%"$ind"*} ind=${#ind} str=${str::ind}${str:ind+1} 9 mark= 10 elif ((${#ind}==2)) && [[ ${ind::1} == [!a-zA-Z0-9] && ${ind:1:1} == [!a-zA-Z0-9] ]]; then 11 local ind1=${ind::1} ind2=${ind:1:1} text 12 text=${str//"$ind2"} text=${text%%"$ind1"*} ind=${#text} 13 text=${str//"$ind1"} text=${text%%"$ind2"*} mark=${#text} 14 str=${str//["$ind"]*} 15 fi 16 } 17 18 function ble/keymap:vi_test/start-section { 19 section=$1 nsuccess=0 ntest=0 20 } 21 22 function ble/keymap:vi_test/check { 23 local id=$1 initial=$2 kspecs=$3 final=$4 24 local str ind mark 25 ble/keymap:vi_test/decompose-state "$initial"; local i=$ind in=$str ima=$mark 26 ble/keymap:vi_test/decompose-state "$final"; local f=$ind fin=$str fma=$mark 27 28 local nl=$'\n' nl_rep=$'\e[7m^J\e[m' 29 ble-edit/content/reset "$in" edit 30 _ble_edit_ind=$i 31 [[ $ima ]] && _ble_edit_mark=$ima 32 local ret 33 ble-decode-kbd "$kspecs" 34 local ble_decode=${_ble_keymap_vi_test_ble_decode:-ble-decode-key} 35 "$ble_decode" $ret &>/dev/null 36 37 # check results 38 [[ $_ble_edit_ind == "$f" && $_ble_edit_str == "$fin" && ( ! $fma || $_ble_edit_mark == "$fma" ) ]]; local ext=$? 39 if ((ext==0)); then 40 ((ntest++,nsuccess++)) 41 else 42 ((ntest++)) 43 local esc_in=${in//$nl/"$nl_rep"} 44 local esc_fin=${fin//$nl/"$nl_rep"} 45 local esc_str=${_ble_edit_str//$nl/"$nl_rep"} 46 ble/util/print "test($section/$id): keys = ($kspecs)" 47 ble/util/print " initial = \"$i:$esc_in\"" 48 ble/util/print " expected = \"$f:$esc_fin\"" 49 ble/util/print " result = \"$_ble_edit_ind:$esc_str\"" 50 fi >&2 51 52 # restore states 53 case $_ble_decode_keymap in 54 (vi_[ixo]map) 55 ble-decode-key "$((_ble_decode_Ctrl|99))" &>/dev/null ;; 56 esac 57 58 return "$ext" 59 } 60 61 function ble/keymap:vi_test/show-summary { 62 local title=$section 63 if ((nsuccess==ntest)); then 64 local tip=$'\e[32mpassed\e[m' 65 else 66 local tip=$'\e[31mfailed\e[m' 67 fi 68 ble/util/print "# $title test: result $((nsuccess))/$((ntest)) $tip" 69 } 70 71 #------------------------------------------------------------------------------ 72 # tests 73 74 function ble/widget/vi-command:check-vi-mode/space { 75 ble/keymap:vi_test/start-section '<space>' 76 77 local str=$' 1234\n567890ab\n' 78 ble/keymap:vi_test/check 1 "4:$str" '4 SP' "9:$str" 79 ble/keymap:vi_test/check 2 "4:$str" 'd 4 SP' $'3: \n567890ab\n' 80 81 ble/keymap:vi_test/show-summary 82 } 83 84 function ble/widget/vi-command:check-vi-mode/cw { 85 ble/keymap:vi_test/start-section 'cw' 86 87 # provided by cmplstofB 88 ble/keymap:vi_test/check A1 '@:cp ./foo.txt @ /tmp/' 'c w' '@:cp ./foo.txt @/tmp/' 89 ble/keymap:vi_test/check A2 '@:cp ./foo.tx@t /tmp/' 'c w' '@:cp ./foo.tx@ /tmp/' 90 ble/keymap:vi_test/check A3 '@:cp ./fo@o.txt /tmp/' 'c w' '@:cp ./fo@.txt /tmp/' 91 ble/keymap:vi_test/check A4 '@:cp ./foo.t@xt /tmp/' 'c w' '@:cp ./foo.t@ /tmp/' 92 ble/keymap:vi_test/check A5 '@:cp ./fo@o.txt /tmp/' 'c W' '@:cp ./fo@ /tmp/' 93 94 ble/keymap:vi_test/check B1a '@:123@ 456 789' 'c w' '@:123@456 789' 95 ble/keymap:vi_test/check B1b '@:123@ 456 789' '1 c w' '@:123@456 789' 96 ble/keymap:vi_test/check B1c '@:123@ 456 789' '2 c w' '@:123@789' 97 ble/keymap:vi_test/check B2a '@:12@3 456 789' 'c w' '@:12@ 456 789' 98 ble/keymap:vi_test/check B2b '@:12@3 456 789' '1 c w' '@:12@ 456 789' 99 ble/keymap:vi_test/check B2c '@:12@3 456 789' '2 c w' '@:12@ 789' 100 ble/keymap:vi_test/check B3a '@:@123 456 789' 'c w' '@:@ 456 789' 101 ble/keymap:vi_test/check B3b '@:@123 456 789' '1 c w' '@:@ 456 789' 102 ble/keymap:vi_test/check B3c '@:@123 456 789' '2 c w' '@:@ 789' 103 ble/keymap:vi_test/check B4a '@:ab@c///漢字' 'c w' '@:ab@///漢字' 104 ble/keymap:vi_test/check B4b '@:ab@c///漢字' '1 c w' '@:ab@///漢字' 105 ble/keymap:vi_test/check B4c '@:ab@c///漢字' '2 c w' '@:ab@漢字' 106 ble/keymap:vi_test/check B5a '@:@abc///漢字' 'c w' '@:@///漢字' 107 ble/keymap:vi_test/check B5b '@:@abc///漢字' '1 c w' '@:@///漢字' 108 ble/keymap:vi_test/check B5c '@:@abc///漢字' '2 c w' '@:@漢字' 109 110 # with empty lines 111 ble/keymap:vi_test/check C1 $'@:123 456 @ \n\n789' 'c w' $'@:123 456 @\n\n789' 112 ble/keymap:vi_test/check C2 $'@:123 456 \n@\n789' 'c w' $'@:123 456 \n@\n789' 113 ble/keymap:vi_test/check C3 $'@:123 45@6 \n\n789' 'c w' $'@:123 45@ \n\n789' 114 ble/keymap:vi_test/check C4 $'@:123 456@ \n\n789\nabc' '2 c w' $'@:123 456@\n789\nabc' 115 ble/keymap:vi_test/check C5 $'@:123 45@6 \n\n789\nabc' '2 c w' $'@:123 45@\nabc' 116 ble/keymap:vi_test/check C6 $'@:123 4@56 \n\n789\nabc' '2 c w' $'@:123 4@\nabc' 117 ble/keymap:vi_test/check C7 $'@:123 456@ \n\n\n789\nabc' '2 c w' $'@:123 456@\n\n789\nabc' 118 ble/keymap:vi_test/check C8 $'@:123 45@6 \n\n\n789\nabc' '2 c w' $'@:123 45@\nabc' 119 ble/keymap:vi_test/check C9 $'@:123 4@56 \n\n\n789\nabc' '2 c w' $'@:123 4@\nabc' 120 ble/keymap:vi_test/check C9 $'@:123 456 \n\n@' '2 c w' $'@:123 456 \n\n@' 121 122 ble/keymap:vi_test/show-summary 123 } 124 125 function ble/widget/vi-command:check-vi-mode/search { 126 ble/keymap:vi_test/start-section '/ ? n N' 127 ble/keymap:vi_test/check A1a '@:ech@o abc abc abc' '/ a b c RET' '@:echo @abc abc abc' 128 ble/keymap:vi_test/check A1b '@:ech@o abc abc abc' '/ a b c RET n' '@:echo abc @abc abc' 129 ble/keymap:vi_test/check A1c '@:ech@o abc abc abc' '/ a b c RET 2 n' '@:echo abc abc @abc' 130 ble/keymap:vi_test/check A1d '@:ech@o abc abc abc' '/ a b c RET 2 n N' '@:echo abc @abc abc' 131 ble/keymap:vi_test/check A2a '@:echo@ abc abc abc' '/ a b c RET' '@:echo @abc abc abc' 132 ble/keymap:vi_test/check A2b '@:echo @abc abc abc' '/ a b c RET' '@:echo abc @abc abc' 133 ble/keymap:vi_test/check A2c '@:echo a@bc abc abc' '/ a b c RET' '@:echo abc @abc abc' 134 ble/keymap:vi_test/check A3a '@:echo abc@ abc abc' '? a b c RET' '@:echo @abc abc abc' 135 ble/keymap:vi_test/check A3b '@:echo abc @abc abc' '? a b c RET' '@:echo @abc abc abc' 136 ble/keymap:vi_test/check A3c '@:echo abc a@bc abc' '? a b c RET' '@:echo abc @abc abc' 137 ble/keymap:vi_test/show-summary 138 } 139 140 function ble/widget/vi-command:check-vi-mode/increment { 141 ble/keymap:vi_test/start-section '<C-a>, <C-x>' 142 143 ble/keymap:vi_test/check A1a '@:@123' 'C-a' '@:12@4' 144 ble/keymap:vi_test/check A1b '@:@123' 'C-x' '@:12@2' 145 ble/keymap:vi_test/check A1c '@:@-123' 'C-a' '@:-12@2' 146 ble/keymap:vi_test/check A1d '@:@-123' 'C-x' '@:-12@4' 147 148 ble/keymap:vi_test/check A2a '@:@ -123 0' 'C-a' '@: -12@2 0' 149 ble/keymap:vi_test/check A2b '@: @-123 0' 'C-a' '@: -12@2 0' 150 ble/keymap:vi_test/check A2c '@: -@123 0' 'C-a' '@: -12@2 0' 151 ble/keymap:vi_test/check A2d '@: -1@23 0' 'C-a' '@: -12@2 0' 152 ble/keymap:vi_test/check A2e '@: -12@3 0' 'C-a' '@: -12@2 0' 153 ble/keymap:vi_test/check A2f '@: -123@ 0' 'C-a' '@: -123 @1' 154 155 ble/keymap:vi_test/check A3a '@:@000' 'C-a' '@:00@1' 156 ble/keymap:vi_test/check A3b '@:@000' '1 0 C-a' '@:01@0' 157 ble/keymap:vi_test/check A3c '@:@000' '1 0 0 C-a' '@:10@0' 158 ble/keymap:vi_test/check A3d '@:@000' 'C-x' '@:-00@1' 159 ble/keymap:vi_test/check A3e '@:@000' '1 0 C-x' '@:-01@0' 160 ble/keymap:vi_test/check A3f '@:@000' '1 0 0 C-x' '@:-10@0' 161 ble/keymap:vi_test/check A3g '@:@099' '1 0 0 C-x' '@:-00@1' 162 ble/keymap:vi_test/check A3h '@:@099' '9 9 C-x' '@:00@0' 163 164 ble/keymap:vi_test/check A4a '@:-@0' 'C-a' '@:@1' 165 166 ble/keymap:vi_test/show-summary 167 } 168 169 function ble/widget/vi-command:check-vi-mode/macro { 170 # enable ble-decode/keylog for automatic ble-decode-key 171 local _ble_decode_keylog_depth=0 172 local _ble_keymap_vi_test_ble_decode=ble-decode-char 173 local ble_decode_char_sync=1 174 ble/keymap:vi_test/start-section 'qx..q' 175 ble/keymap:vi_test/check A1 '@:@123' 'q a A SP h e l l o @ESC q @ a' '@:123 hello hell@o' 176 ble/keymap:vi_test/show-summary 177 } 178 179 function ble/widget/vi-command:check-vi-mode/surround { 180 ble/keymap:vi_test/start-section 'surround' 181 182 # ys の時は末端の空白を除く 183 ble/keymap:vi_test/check A1a '@:abcd @fghi jklm nopq' 'y s e a' '@:abcd @<fghi> jklm nopq' 184 ble/keymap:vi_test/check A1b '@:abcd @fghi jklm nopq' 'y s w a' '@:abcd @<fghi> jklm nopq' 185 ble/keymap:vi_test/check A1c '@:abcd @fghi jklm nopq' 'y s a w a' '@:abcd @<fghi> jklm nopq' 186 ble/keymap:vi_test/check A1d '@:abcd @ jklm nopq' 'y s 3 l a' '@:abcd @<> jklm nopq' 187 188 # vS の時は末端の空白は除かない 189 ble/keymap:vi_test/check A2a '@:abcd @fghi jklm nopq' 'v 3 l S a' '@:abcd @<fghi> jklm nopq' 190 ble/keymap:vi_test/check A2b '@:abcd @fghi jklm nopq' 'v 4 l S a' '@:abcd @<fghi >jklm nopq' 191 ble/keymap:vi_test/check A2c '@:abcd @fghi jklm nopq' 'h v 5 l S a' '@:abcd@< fghi >jklm nopq' 192 193 ble/keymap:vi_test/show-summary 194 } 195 function ble/widget/vi-command:check-vi-mode/xmap_txtobj_quote { 196 ble/keymap:vi_test/start-section 'xmap text object i" a"' 197 198 # A. xmap txtobj i"/a"、開始点と終了点が同じとき 199 200 # A1. 様々な位置で実行した時 201 ble/keymap:vi_test/check A1a '@:ab@cd " fghi " jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' 202 ble/keymap:vi_test/check A1b '@:abcd @" fghi " jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' 203 ble/keymap:vi_test/check A1c '@:abcd " fghi@ " jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' 204 ble/keymap:vi_test/check A1d '@:abcd " fghi @" jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd " fghi "@< jklm >" nopq " rstu " vwxyz' 205 # A2. 引数が指定された時、a" が指定された時 206 ble/keymap:vi_test/check A2a '@:ab@cd " fghi " jklm " nopq " rstu " vwxyz' 'v 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' 207 ble/keymap:vi_test/check A2b '@:ab@cd " fghi " jklm " nopq " rstu " vwxyz' 'v a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' 208 ble/keymap:vi_test/check A2c '@:ab@cd " fghi " jklm " nopq " rstu " vwxyz' 'v 2 a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' 209 # A3. "" の中が空の時 210 ble/keymap:vi_test/check A3a '@:ab@cd "" jklm " nopq " rstu " vwxyz' 'v i " S a' '@:abcd @<""> jklm " nopq " rstu " vwxyz' 211 ble/keymap:vi_test/check A3b '@:ab@cd "" jklm " nopq " rstu " vwxyz' 'v 2 i " S a' '@:abcd @<""> jklm " nopq " rstu " vwxyz' 212 213 # B. xmap txtobj i"/a"、mark より現在位置の方が後のとき 214 # B1. i" 215 ble/keymap:vi_test/check B1a '@:abcd@ " fghi " jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd@< " fghi " jklm >" nopq " rstu " vwxyz' 216 ble/keymap:vi_test/check B1b '@:abcd " fghi " jklm " nopq@ " rstu " vwxyz' 'v l i " S a' '@:abcd " fghi " jklm " nopq@< " rstu >" vwxyz' 217 ble/keymap:vi_test/check B1c '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' 218 ble/keymap:vi_test/check B1d '@:abcd " fgh@i " jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' 219 ble/keymap:vi_test/check B1e '@:abcd " fghi " @jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd " fghi " jklm "@< nopq >" rstu " vwxyz' 220 ble/keymap:vi_test/check B1f '@:abcd " fghi "@ jklm " nopq " rstu " vwxyz' 'v l i " S a' '@:abcd " fghi "@< jklm " nopq >" rstu " vwxyz' 221 # B2. 2i" 222 ble/keymap:vi_test/check B2a '@:abcd@ " fghi " jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd@< " fghi " jklm "> nopq " rstu " vwxyz' 223 ble/keymap:vi_test/check B2b '@:abcd " fghi " jklm " nopq@ " rstu " vwxyz' 'v l 2 i " S a' '@:abcd " fghi " jklm " nopq@< " rstu "> vwxyz' 224 ble/keymap:vi_test/check B2c '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' 225 ble/keymap:vi_test/check B2d '@:abcd " fgh@i " jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' 226 ble/keymap:vi_test/check B2e '@:abcd " fghi " @jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd " fghi " jklm @<" nopq "> rstu " vwxyz' 227 ble/keymap:vi_test/check B2f '@:abcd " fghi "@ jklm " nopq " rstu " vwxyz' 'v l 2 i " S a' '@:abcd " fghi "@< jklm " nopq "> rstu " vwxyz' 228 # B3. a" 229 ble/keymap:vi_test/check B3a '@:abcd@ " fghi " jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd@< " fghi " jklm " >nopq " rstu " vwxyz' 230 ble/keymap:vi_test/check B3b '@:abcd " fghi " jklm " nopq@ " rstu " vwxyz' 'v l a " S a' '@:abcd " fghi " jklm " nopq@< " rstu " >vwxyz' 231 ble/keymap:vi_test/check B3c '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' 232 ble/keymap:vi_test/check B3d '@:abcd " fgh@i " jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' 233 ble/keymap:vi_test/check B3e '@:abcd " fghi " @jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd " fghi " jklm @<" nopq " >rstu " vwxyz' 234 ble/keymap:vi_test/check B3f '@:abcd " fghi "@ jklm " nopq " rstu " vwxyz' 'v l a " S a' '@:abcd " fghi "@< jklm " nopq " >rstu " vwxyz' 235 236 # C. xmap txtobj i"/a"、mark より現在位置の方が前のとき 237 ble/keymap:vi_test/check C1a '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v h i " S a' '@:ab@<cd> " fghi " jklm " nopq " rstu " vwxyz' 238 ble/keymap:vi_test/check C1b '@:abcd " @fghi " jklm " nopq " rstu " vwxyz' 'v h i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' 239 ble/keymap:vi_test/check C1c '@:abcd " fghi@ " jklm " nopq " rstu " vwxyz' 'v h i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' 240 ble/keymap:vi_test/check C1d '@:abcd " fghi @" jklm " nopq " rstu " vwxyz' 'v h i " S a' '@:abcd "@< fghi "> jklm " nopq " rstu " vwxyz' 241 ble/keymap:vi_test/check C1e '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v h i " S a' '@:abcd "@< fghi >" jklm " nopq " rstu " vwxyz' 242 ble/keymap:vi_test/check C1f '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v 5 h i " S a' '@:abcd "@< fghi " jklm> " nopq " rstu " vwxyz' 243 244 ble/keymap:vi_test/check C2a '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:ab@<cd> " fghi " jklm " nopq " rstu " vwxyz' 245 ble/keymap:vi_test/check C2b '@:abcd " @fghi " jklm " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' 246 ble/keymap:vi_test/check C2c '@:abcd " fghi@ " jklm " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:abcd @<" fghi >" jklm " nopq " rstu " vwxyz' 247 ble/keymap:vi_test/check C2d '@:abcd " fghi @" jklm " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' 248 ble/keymap:vi_test/check C2e '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v h 2 i " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' 249 ble/keymap:vi_test/check C2f '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v 5 h 2 i " S a' '@:abcd @<" fghi " jklm> " nopq " rstu " vwxyz' 250 251 ble/keymap:vi_test/check C3a '@:abc@d " fghi " jklm " nopq " rstu " vwxyz' 'v h a " S a' '@:ab@<cd> " fghi " jklm " nopq " rstu " vwxyz' 252 ble/keymap:vi_test/check C3b '@:abcd " @fghi " jklm " nopq " rstu " vwxyz' 'v h a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' 253 ble/keymap:vi_test/check C3c '@:abcd " fghi@ " jklm " nopq " rstu " vwxyz' 'v h a " S a' '@:abcd @<" fghi >" jklm " nopq " rstu " vwxyz' 254 ble/keymap:vi_test/check C3d '@:abcd " fghi @" jklm " nopq " rstu " vwxyz' 'v h a " S a' '@:abcd @<" fghi "> jklm " nopq " rstu " vwxyz' 255 ble/keymap:vi_test/check C3e '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v h a " S a' '@:abcd @<" fghi " >jklm " nopq " rstu " vwxyz' 256 ble/keymap:vi_test/check C3f '@:abcd " fghi " jkl@m " nopq " rstu " vwxyz' 'v 5 h a " S a' '@:abcd @<" fghi " jklm> " nopq " rstu " vwxyz' 257 258 ble/keymap:vi_test/show-summary 259 } 260 261 function ble/widget/vi-command:check-vi-mode/txtobj_word { 262 ble/keymap:vi_test/start-section 'txtobj word omap' 263 264 # A. omap iw/aw 265 ble/keymap:vi_test/check A1/iw '@:echo he@llo world "hello" "world"' 'd i w' '@:echo @ world "hello" "world"' 266 ble/keymap:vi_test/check A1/aw '@:echo he@llo world "hello" "world"' 'd a w' '@:echo @world "hello" "world"' 267 ble/keymap:vi_test/check A2/iw '@:echo hello@ world "hello" "world"' 'd i w' '@:echo hello@world "hello" "world"' 268 ble/keymap:vi_test/check A2/aw '@:echo hello@ world "hello" "world"' 'd a w' '@:echo hello@ "hello" "world"' 269 ble/keymap:vi_test/check A3/iw '@:echo hello world "he@llo" "world"' 'd i w' '@:echo hello world "@" "world"' 270 ble/keymap:vi_test/check A3/aw '@:echo hello world "he@llo" "world"' 'd a w' '@:echo hello world "@" "world"' 271 ble/keymap:vi_test/check A4/iw '@:echo hello world @"hello" "world"' 'd i w' '@:echo hello world @hello" "world"' 272 ble/keymap:vi_test/check A4/aw '@:echo hello world @"hello" "world"' 'd a w' '@:echo hello world@hello" "world"' 273 ble/keymap:vi_test/check A5/iw '@:echo hello world "hello@" "world"' 'd i w' '@:echo hello world "hello@ "world"' 274 ble/keymap:vi_test/check A5/aw '@:echo hello world "hello@" "world"' 'd a w' '@:echo hello world "hello@"world"' 275 ble/keymap:vi_test/check A1/2iw '@:echo he@llo world "hello" "world"' 'd 2 i w' '@:echo @world "hello" "world"' 276 ble/keymap:vi_test/check A1/2aw '@:echo he@llo world "hello" "world"' 'd 2 a w' '@:echo @"hello" "world"' 277 ble/keymap:vi_test/check A2/2iw '@:echo hello@ world "hello" "world"' 'd 2 i w' '@:echo hello@ "hello" "world"' 278 ble/keymap:vi_test/check A2/2aw '@:echo hello@ world "hello" "world"' 'd 2 a w' '@:echo hello@hello" "world"' 279 ble/keymap:vi_test/check A3/2iw '@:echo hello world "he@llo" "world"' 'd 2 i w' '@:echo hello world "@ "world"' 280 ble/keymap:vi_test/check A3/2aw '@:echo hello world "he@llo" "world"' 'd 2 a w' '@:echo hello world "@"world"' 281 ble/keymap:vi_test/check A4/2iw '@:echo hello world @"hello" "world"' 'd 2 i w' '@:echo hello world @" "world"' 282 ble/keymap:vi_test/check A4/2aw '@:echo hello world @"hello" "world"' 'd 2 a w' '@:echo hello world@" "world"' 283 ble/keymap:vi_test/check A5/2iw '@:echo hello world "hello@" "world"' 'd 2 i w' '@:echo hello world "hello@"world"' 284 ble/keymap:vi_test/check A5/2aw '@:echo hello world "hello@" "world"' 'd 2 a w' '@:echo hello world "hello@world"' 285 286 ble/keymap:vi_test/check A6/iw $'@:echo@ \n hello world' 'd i w' $'@:ech@o\n hello world' 287 ble/keymap:vi_test/check A6/aw $'@:echo@ \n hello world' 'd a w' $'@:echo@ world' 288 289 ble/keymap:vi_test/check A7.2/iw $'@:echo\n@\nhello\n\nworld\nZ' 'd i w' $'@:echo\n@\nhello\n\nworld\nZ' 290 ble/keymap:vi_test/check A7.2/aw $'@:echo\n@\nhello\n\nworld\nZ' 'd a w' $'@:echo\n@\nworld\nZ' 291 ble/keymap:vi_test/check A7.2/2iw $'@:echo\n@\nhello\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\nworld\nZ' 292 ble/keymap:vi_test/check A7.2/2aw $'@:echo\n@\nhello\n\nworld\nZ' 'd 2 a w' $'@:echo\n@Z' 293 294 ble/keymap:vi_test/check A7.1/1diw $'@:echo\n@\nhello\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\nworld\nZ' 295 ble/keymap:vi_test/check A7.1/2diw $'@:echo\n@\nhello\nworld\nZ' 'd 2 i w' $'@:echo\n@world\nZ' 296 ble/keymap:vi_test/check A7.1/3diw $'@:echo\n@\nhello\nworld\nZ' 'd 3 i w' $'@:echo\n@Z' 297 ble/keymap:vi_test/check A7.2/1diw $'@:echo\n@\nhello\n\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\n\nworld\nZ' 298 ble/keymap:vi_test/check A7.2/2diw $'@:echo\n@\nhello\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\nworld\nZ' 299 ble/keymap:vi_test/check A7.2/3diw $'@:echo\n@\nhello\n\nworld\nZ' 'd 3 i w' $'@:echo\n@world\nZ' 300 ble/keymap:vi_test/check A7.2/4diw $'@:echo\n@\nhello\n\nworld\nZ' 'd 4 i w' $'@:echo\n@Z' 301 ble/keymap:vi_test/check A7.3/1diw $'@:echo\n@\nhello\n\n\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\n\n\nworld\nZ' 302 ble/keymap:vi_test/check A7.3/2diw $'@:echo\n@\nhello\n\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\n\nworld\nZ' 303 ble/keymap:vi_test/check A7.3/3diw $'@:echo\n@\nhello\n\n\nworld\nZ' 'd 3 i w' $'@:echo\n@\nworld\nZ' 304 ble/keymap:vi_test/check A7.3/4diw $'@:echo\n@\nhello\n\n\nworld\nZ' 'd 4 i w' $'@:echo\n@Z' 305 ble/keymap:vi_test/check A7.4/1diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\n\n\n\nworld\nZ' 306 ble/keymap:vi_test/check A7.4/2diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\n\n\nworld\nZ' 307 ble/keymap:vi_test/check A7.4/3diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 3 i w' $'@:echo\n@\n\nworld\nZ' 308 ble/keymap:vi_test/check A7.4/4diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 4 i w' $'@:echo\n@world\nZ' 309 ble/keymap:vi_test/check A7.4/5diw $'@:echo\n@\nhello\n\n\n\nworld\nZ' 'd 5 i w' $'@:echo\n@Z' 310 ble/keymap:vi_test/check A7.5/1diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 1 i w' $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 311 ble/keymap:vi_test/check A7.5/2diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 2 i w' $'@:echo\n@\n\n\n\nworld\nZ' 312 ble/keymap:vi_test/check A7.5/3diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 3 i w' $'@:echo\n@\n\n\nworld\nZ' 313 ble/keymap:vi_test/check A7.5/4diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 4 i w' $'@:echo\n@\nworld\nZ' 314 ble/keymap:vi_test/check A7.5/5diw $'@:echo\n@\nhello\n\n\n\n\nworld\nZ' 'd 5 i w' $'@:echo\n@Z' 315 316 local A7_a=$'@:echo\n@\nhello\n\n\n\n\n\n\n\n\n\nworld\nZ' 317 318 ble/keymap:vi_test/check A7.a/1ciw "$A7_a" 'c 1 i w' $'@:echo\n@\nhello\n\n\n\n\n\n\n\n\n\nworld\nZ' 319 ble/keymap:vi_test/check A7.a/2ciw "$A7_a" 'c 2 i w' $'@:echo\n@\n\n\n\n\n\n\n\n\n\nworld\nZ' 320 ble/keymap:vi_test/check A7.a/3ciw "$A7_a" 'c 3 i w' $'@:echo\n@\n\n\n\n\n\n\n\n\nworld\nZ' 321 ble/keymap:vi_test/check A7.a/4ciw "$A7_a" 'c 4 i w' $'@:echo\n@\n\n\n\n\n\n\nworld\nZ' 322 ble/keymap:vi_test/check A7.a/5ciw "$A7_a" 'c 5 i w' $'@:echo\n@\n\n\n\n\nworld\nZ' 323 ble/keymap:vi_test/check A7.a/6ciw "$A7_a" 'c 6 i w' $'@:echo\n@\n\n\nworld\nZ' 324 ble/keymap:vi_test/check A7.a/7ciw "$A7_a" 'c 7 i w' $'@:echo\n@\nworld\nZ' 325 ble/keymap:vi_test/check A7.a/8ciw "$A7_a" 'c 8 i w' $'@:echo\n@\nZ' 326 327 ble/keymap:vi_test/check A7.a/1diw "$A7_a" 'd 1 i w' $'@:echo\n@\nhello\n\n\n\n\n\n\n\n\n\nworld\nZ' 328 ble/keymap:vi_test/check A7.a/2diw "$A7_a" 'd 2 i w' $'@:echo\n@\n\n\n\n\n\n\n\n\nworld\nZ' 329 ble/keymap:vi_test/check A7.a/3diw "$A7_a" 'd 3 i w' $'@:echo\n@\n\n\n\n\n\n\n\nworld\nZ' 330 ble/keymap:vi_test/check A7.a/4diw "$A7_a" 'd 4 i w' $'@:echo\n@\n\n\n\n\n\nworld\nZ' 331 ble/keymap:vi_test/check A7.a/5diw "$A7_a" 'd 5 i w' $'@:echo\n@\n\n\n\nworld\nZ' 332 ble/keymap:vi_test/check A7.a/6diw "$A7_a" 'd 6 i w' $'@:echo\n@\n\nworld\nZ' 333 ble/keymap:vi_test/check A7.a/7diw "$A7_a" 'd 7 i w' $'@:echo\n@world\nZ' 334 ble/keymap:vi_test/check A7.a/8diw "$A7_a" 'd 8 i w' $'@:echo\n@Z' 335 336 ble/keymap:vi_test/check A7.a/1caw "$A7_a" 'c 1 a w' $'@:echo\n@\n\n\n\n\n\n\n\n\n\nworld\nZ' 337 ble/keymap:vi_test/check A7.a/2caw "$A7_a" 'c 2 a w' $'@:echo\n@\n\n\n\n\n\n\n\nworld\nZ' 338 ble/keymap:vi_test/check A7.a/3caw "$A7_a" 'c 3 a w' $'@:echo\n@\n\n\n\n\n\nworld\nZ' 339 ble/keymap:vi_test/check A7.a/4caw "$A7_a" 'c 4 a w' $'@:echo\n@\n\n\n\nworld\nZ' 340 ble/keymap:vi_test/check A7.a/5caw "$A7_a" 'c 5 a w' $'@:echo\n@\n\nworld\nZ' 341 ble/keymap:vi_test/check A7.a/6caw "$A7_a" 'c 6 a w' $'@:echo\n@\nZ' 342 343 ble/keymap:vi_test/check A7.a/1daw "$A7_a" 'd 1 a w' $'@:echo\n@\n\n\n\n\n\n\n\n\nworld\nZ' 344 ble/keymap:vi_test/check A7.a/2daw "$A7_a" 'd 2 a w' $'@:echo\n@\n\n\n\n\n\n\nworld\nZ' 345 ble/keymap:vi_test/check A7.a/3daw "$A7_a" 'd 3 a w' $'@:echo\n@\n\n\n\n\nworld\nZ' 346 ble/keymap:vi_test/check A7.a/4daw "$A7_a" 'd 4 a w' $'@:echo\n@\n\n\nworld\nZ' 347 ble/keymap:vi_test/check A7.a/5daw "$A7_a" 'd 5 a w' $'@:echo\n@\nworld\nZ' 348 ble/keymap:vi_test/check A7.a/6daw "$A7_a" 'd 6 a w' $'@:echo\n@Z' 349 350 ble/keymap:vi_test/check A8.0/2aw $'@:echo\n@\nhello\n\nworld\n' 'd 2 a w' $'@:@echo' 351 ble/keymap:vi_test/check A8.2/2aw $'@: echo\n@\nhello\n\nworld\n' 'd 2 a w' $'@: @echo' 352 ble/keymap:vi_test/check A9.1/ciw $'@:@ \necho' 'c i w' $'@:@\necho' 353 ble/keymap:vi_test/check A9.2/ciw $'@:@\n echo' 'c i w' $'@:@\n echo' 354 355 ble/keymap:vi_test/show-summary 356 357 ble/keymap:vi_test/start-section 'txtobj word xmap' 358 359 # B. xmap iw/aw (mark == ind の時) 360 ble/keymap:vi_test/check B1/viw.1 '@:echo he@llo world "hello" "world"' 'v i w S a' '@:echo @<hello> world "hello" "world"' 361 ble/keymap:vi_test/check B1/vaw.1 '@:echo he@llo world "hello" "world"' 'v a w S a' '@:echo @<hello >world "hello" "world"' 362 ble/keymap:vi_test/check B2/viw.2 '@:echo hello@ world "hello" "world"' 'v i w S a' '@:echo hello@< >world "hello" "world"' 363 ble/keymap:vi_test/check B2/vaw.2 '@:echo hello@ world "hello" "world"' 'v a w S a' '@:echo hello@< world> "hello" "world"' 364 ble/keymap:vi_test/check B3/viw.3 '@:echo hello world "he@llo" "world"' 'v i w S a' '@:echo hello world "@<hello>" "world"' 365 ble/keymap:vi_test/check B3/vaw.3 '@:echo hello world "he@llo" "world"' 'v a w S a' '@:echo hello world "@<hello>" "world"' 366 ble/keymap:vi_test/check B4/viw.4 '@:echo hello world @"hello" "world"' 'v i w S a' '@:echo hello world @<">hello" "world"' 367 ble/keymap:vi_test/check B4/vaw.4 '@:echo hello world @"hello" "world"' 'v a w S a' '@:echo hello world@< ">hello" "world"' 368 ble/keymap:vi_test/check B5/viw.5 '@:echo hello world "hello@" "world"' 'v i w S a' '@:echo hello world "hello@<"> "world"' 369 ble/keymap:vi_test/check B5/vaw.5 '@:echo hello world "hello@" "world"' 'v a w S a' '@:echo hello world "hello@<" >"world"' 370 ble/keymap:vi_test/check B1/v2iw.1 '@:echo he@llo world "hello" "world"' 'v 2 i w S a' '@:echo @<hello >world "hello" "world"' 371 ble/keymap:vi_test/check B1/v2aw.1 '@:echo he@llo world "hello" "world"' 'v 2 a w S a' '@:echo @<hello world >"hello" "world"' 372 ble/keymap:vi_test/check B2/v2iw.2 '@:echo hello@ world "hello" "world"' 'v 2 i w S a' '@:echo hello@< world> "hello" "world"' 373 ble/keymap:vi_test/check B2/v2aw.2 '@:echo hello@ world "hello" "world"' 'v 2 a w S a' '@:echo hello@< world ">hello" "world"' 374 ble/keymap:vi_test/check B3/v2iw.3 '@:echo hello world "he@llo" "world"' 'v 2 i w S a' '@:echo hello world "@<hello"> "world"' 375 ble/keymap:vi_test/check B3/v2aw.3 '@:echo hello world "he@llo" "world"' 'v 2 a w S a' '@:echo hello world "@<hello" >"world"' 376 ble/keymap:vi_test/check B4/v2iw.4 '@:echo hello world @"hello" "world"' 'v 2 i w S a' '@:echo hello world @<"hello>" "world"' 377 ble/keymap:vi_test/check B4/v2aw.4 '@:echo hello world @"hello" "world"' 'v 2 a w S a' '@:echo hello world@< "hello>" "world"' 378 ble/keymap:vi_test/check B5/v2iw.5 '@:echo hello world "hello@" "world"' 'v 2 i w S a' '@:echo hello world "hello@<" >"world"' 379 ble/keymap:vi_test/check B5/v2aw.5 '@:echo hello world "hello@" "world"' 'v 2 a w S a' '@:echo hello world "hello@<" ">world"' 380 381 # B. xmap iw/aw (ind < mark の時) 382 ble/keymap:vi_test/check B2/v1hiw '@:echo hello wo@rld' 'v 1 h i w S a' '@:echo hello @<wor>ld' 383 ble/keymap:vi_test/check B2/v2hiw '@:echo hello wo@rld' 'v 2 h i w S a' '@:echo hello@< wor>ld' 384 ble/keymap:vi_test/check B2/v3hiw '@:echo hello wo@rld' 'v 3 h i w S a' '@:echo hello@< wor>ld' 385 ble/keymap:vi_test/check B2/v4hiw '@:echo hello wo@rld' 'v 4 h i w S a' '@:echo @<hello wor>ld' 386 ble/keymap:vi_test/check B2/v1haw '@:echo hello wo@rld' 'v 1 h a w S a' '@:echo hello@< wor>ld' 387 ble/keymap:vi_test/check B2/v2haw '@:echo hello wo@rld' 'v 2 h a w S a' '@:echo @<hello wor>ld' 388 ble/keymap:vi_test/check B2/v3haw '@:echo hello wo@rld' 'v 3 h a w S a' '@:echo @<hello wor>ld' 389 ble/keymap:vi_test/check B2/v4haw '@:echo hello wo@rld' 'v 4 h a w S a' '@:echo@< hello wor>ld' 390 ble/keymap:vi_test/check B1/v1haw '@:echo he@llo' 'v 1 h a w S a' '@:echo@< hel>lo' 391 ble/keymap:vi_test/check B1/v2haw '@:echo he@llo' 'v 2 h a w S a' '@:@<echo hel>lo' 392 ble/keymap:vi_test/check B1/v3haw '@:echo he@llo' 'v 3 h a w S a' '@:e@<cho hel>lo' 393 ble/keymap:vi_test/check B1/v4haw '@:echo he@llo' 'v 4 h a w S a' '@:e@<cho hel>lo' 394 ble/keymap:vi_test/check Bn/viw $'@:@echo hello\necho world' 'v $ o $ i w c' $'@:echo hell@echo world' 395 ble/keymap:vi_test/check Bn/viw $'@:@echo hello \necho world' 'v $ o $ i w c' $'@:echo hello@\necho world' 396 397 ble/keymap:vi_test/show-summary 398 } 399 400 function ble/widget/vi-command:check-vi-mode/op.2018-02-22 { 401 ble/keymap:vi_test/start-section 'op.2018-02-22' 402 403 # 行指向のコピー&貼り付け #D0674 404 ble/keymap:vi_test/check A0 $'@:12@345\n67890\n' 'y y p' $'@:12345\n@12345\n67890\n' 405 406 # Y 及び yy ではカーソル位置は変化しない。 #D0673 407 ble/keymap:vi_test/check B1 $'@:12@345\n67890\n' 'Y' $'@:12@345\n67890\n' 408 ble/keymap:vi_test/check B2 $'@:12@345\n67890\n' 'y y' $'@:12@345\n67890\n' 409 410 # blockwise operator d の書き直し #D0673 411 ble/keymap:vi_test/check C $'@:\n12@34567\n1あ2345\n12い345\n123う45\n1234え5\n' 'C-v 4 j l d' $'@:\n12@567\n1 345\n12345\n12 45\n12え5\n' 412 413 ble/keymap:vi_test/show-summary 414 } 415 416 #------------------------------------------------------------------------------ 417 418 function ble/widget/vi-command:check-vi-mode { 419 # save 420 local original_str=$_ble_edit_str 421 local original_ind=$_ble_edit_ind 422 local original_mark=$_ble_edit_mark 423 local original_mark_active=$_ble_edit_mark_active 424 _ble_edit_line_disabled=1 ble/widget/.insert-newline # #D1800 pair=leave-command-layout 425 ble/util/buffer.flush >&2 426 427 local section ntest nsuccess 428 429 #---------------------------------------------------------------------------- 430 431 ble/widget/vi-command:check-vi-mode/space 432 ble/widget/vi-command:check-vi-mode/cw 433 ble/widget/vi-command:check-vi-mode/search 434 ble/widget/vi-command:check-vi-mode/increment 435 ble/widget/vi-command:check-vi-mode/macro 436 ble/widget/vi-command:check-vi-mode/surround 437 ble/widget/vi-command:check-vi-mode/xmap_txtobj_quote 438 ble/widget/vi-command:check-vi-mode/op.2018-02-22 439 ble/widget/vi-command:check-vi-mode/txtobj_word 440 441 #---------------------------------------------------------------------------- 442 443 # restore 444 ble-edit/content/reset "$original_str" edit 445 _ble_edit_ind=$original_ind 446 _ble_edit_mark=$original_mark 447 _ble_edit_mark_active=$original_mark_active 448 ble/edit/leave-command-layout # #D1800 pair=.insert-newline 449 return 0 450 } 451 452 function ble/widget/vi_imap/check-vi-mode { 453 ble/widget/vi_imap/normal-mode 454 ble/widget/vi-command:check-vi-mode 455 return 0 456 } 457 458 ble-bind -m vi_imap -f 'C-\ C-\' vi_imap/check-vi-mode 459 ble-bind -m vi_nmap -f 'C-\ C-\' vi-command:check-vi-mode