├── .gitignore ├── README.md ├── autoload └── vital │ └── __latest__ │ └── Over │ ├── Commandline.vim │ ├── Commandline │ ├── Base.vim │ ├── Maker.vim │ ├── Modules.vim │ └── Modules │ │ ├── All.vim │ │ ├── AsyncUpdate.vim │ │ ├── BufferComplete.vim │ │ ├── Cancel.vim │ │ ├── CursorMove.vim │ │ ├── Delete.vim │ │ ├── Digraphs.vim │ │ ├── Doautocmd.vim │ │ ├── DrawCommandline.vim │ │ ├── ExceptionExit.vim │ │ ├── ExceptionMessage.vim │ │ ├── Execute.vim │ │ ├── Exit.vim │ │ ├── HistAdd.vim │ │ ├── History.vim │ │ ├── IgnoreRegexpBackwardWord.vim │ │ ├── Incsearch.vim │ │ ├── InsertRegister.vim │ │ ├── KeyMapping.vim │ │ ├── LiteralInsert.vim │ │ ├── NoInsert.vim │ │ ├── Paste.vim │ │ ├── Redraw.vim │ │ └── Scroll.vim │ ├── Exception.vim │ ├── Input.vim │ ├── Keymapping.vim │ ├── Signals.vim │ └── String.vim ├── doc └── vital-over-commandline.jax ├── example ├── callback.vim ├── custom.vim ├── incsearch.vim ├── key_mapping.vim ├── key_mapping_dict.vim ├── module.vim └── simple.vim └── test └── Over ├── Commandline ├── Base.vim └── Modules │ ├── Digraphs.vim │ ├── Doautocmd.vim │ ├── IgnoreRegexpBackwardWord.vim │ ├── InsertRegister.vim │ └── LiteralInsert.vim ├── Keymapping.vim └── String.vim /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags-ja 2 | test_over/* 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #vital-over 2 | 3 | Vim commandline frame work 4 | 5 | 6 | ## Requirement 7 | 8 | * __[vim-jp/vital.vim](https://github.com/vim-jp/vital.vim)__ 9 | 10 | 11 | ##Example 12 | 13 | ```vim 14 | let s:cmdline = vital#of("vital").import("Over.Commandline") 15 | 16 | " コマンドラインのオブジェクトを生成 17 | let s:my = s:cmdline.make_standard(">") 18 | 19 | " コマンドラインの入力を開始 20 | call s:my.start() 21 | ``` 22 | 23 | 24 | ##License 25 | 26 | [NYSL](http://www.kmonos.net/nysl/) 27 | 28 | [NYSL English](http://www.kmonos.net/nysl/index.en.html) 29 | 30 | 31 | ##Special Thanks 32 | 33 | * [@haya14busa](https://github.com/haya14busa) 34 | 35 | 36 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_vital_loaded(V) 7 | let s:V = a:V 8 | let s:Maker = s:V.import("Over.Commandline.Maker") 9 | let s:Modules = s:V.import("Over.Commandline.Modules") 10 | endfunction 11 | 12 | 13 | function! s:_vital_depends() 14 | return [ 15 | \ "Over.Commandline.Maker", 16 | \ "Over.Commandline.Modules", 17 | \ "Over.Commandline.Modules.All", 18 | \ ] 19 | endfunction 20 | 21 | 22 | function! s:make_module(...) 23 | return call(s:Modules.make, a:000, s:Modules) 24 | endfunction 25 | 26 | 27 | function! s:get_module(...) 28 | return call(s:Modules.get, a:000, s:Modules) 29 | endfunction 30 | 31 | 32 | function! s:make_default(...) 33 | return call(s:Maker.default, a:000, s:Maker) 34 | endfunction 35 | 36 | 37 | function! s:make_standard(...) 38 | return call(s:Maker.standard, a:000, s:Maker) 39 | endfunction 40 | 41 | 42 | function! s:make_standard_search(...) 43 | return call(s:Maker.standard_search, a:000, s:Maker) 44 | endfunction 45 | 46 | 47 | function! s:make_standard_search_back(...) 48 | return call(s:Maker.standard_search_back, a:000, s:Maker) 49 | endfunction 50 | 51 | let &cpo = s:save_cpo 52 | unlet s:save_cpo 53 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Base.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_vital_loaded(V) 7 | let s:V = a:V 8 | let s:String = s:V.import("Over.String") 9 | let s:Signals = s:V.import("Over.Signals") 10 | let s:Input = s:V.import("Over.Input") 11 | let s:Keymapping = s:V.import("Over.Keymapping") 12 | let s:Module = s:V.import("Over.Commandline.Modules") 13 | let s:base.variables.modules = s:Signals.make() 14 | function! s:base.variables.modules.get_slot(val) 15 | return a:val.slot.module 16 | endfunction 17 | 18 | let s:Highlight = s:V.import("Palette.Highlight") 19 | endfunction 20 | 21 | 22 | function! s:_vital_depends() 23 | return [ 24 | \ "Over.String", 25 | \ "Over.Signals", 26 | \ "Over.Input", 27 | \ "Over.Keymapping", 28 | \ "Over.Commandline.Modules", 29 | \ "Palette.Highlight", 30 | \ ] 31 | endfunction 32 | 33 | 34 | function! s:make(...) 35 | let result = deepcopy(s:base) 36 | call result.set_prompt(get(a:, 1, ":")) 37 | call result.connect(result, "_") 38 | return result 39 | endfunction 40 | 41 | 42 | function! s:make_plain() 43 | return deepcopy(s:base) 44 | endfunction 45 | 46 | 47 | let s:base = { 48 | \ "line" : {}, 49 | \ "variables" : { 50 | \ "prompt" : "", 51 | \ "char" : "", 52 | \ "input" : "", 53 | \ "tap_key" : "", 54 | \ "exit" : 0, 55 | \ "keymapping" : {}, 56 | \ "suffix" : "", 57 | \ "is_setted" : 0, 58 | \ }, 59 | \ "highlights" : { 60 | \ "prompt" : "NONE", 61 | \ "cursor" : "VitalOverCommandLineCursor", 62 | \ "cursor_on" : "VitalOverCommandLineCursorOn", 63 | \ "cursor_insert" : "VitalOverCommandLineOnCursor", 64 | \ }, 65 | \} 66 | 67 | if exists("s:Signals") 68 | let s:base.variables.modules = s:Signals.make() 69 | function! s:base.variables.modules.get_slot(val) 70 | return a:val.slot.module 71 | endfunction 72 | endif 73 | 74 | 75 | function! s:base.getline() 76 | return self.line.str() 77 | endfunction 78 | 79 | 80 | function! s:base.setline(line) 81 | return self.line.set(a:line) 82 | endfunction 83 | 84 | 85 | function! s:base.char() 86 | return self.variables.char 87 | endfunction 88 | 89 | 90 | function! s:base.setchar(char, ...) 91 | " 1 の場合は既に設定されていても上書きする 92 | " 0 の場合は既に設定されていれば上書きしない 93 | let overwrite = get(a:, 1, 1) 94 | if overwrite || self.variables.is_setted == 0 95 | let self.variables.input = a:char 96 | let self.variables.is_setted = 1 97 | endif 98 | endfunction 99 | 100 | 101 | function! s:base.getpos() 102 | return self.line.pos() 103 | endfunction 104 | 105 | 106 | function! s:base.setpos(pos) 107 | return self.line.set_pos(a:pos) 108 | endfunction 109 | 110 | 111 | function! s:base.tap_keyinput(key) 112 | let self.variables.tap_key = a:key 113 | endfunction 114 | 115 | 116 | function! s:base.untap_keyinput(key) 117 | if self.variables.tap_key == a:key 118 | let self.variables.tap_key = "" 119 | return 1 120 | endif 121 | endfunction 122 | 123 | 124 | function! s:base.get_tap_key() 125 | return self.variables.tap_key 126 | endfunction 127 | 128 | 129 | function! s:base.is_input(key, ...) 130 | let prekey = get(a:, 1, "") 131 | return self.get_tap_key() ==# prekey 132 | \ && self.char() ==# a:key 133 | " \ && self.char() == (prekey . a:key) 134 | endfunction 135 | 136 | 137 | function! s:base.input_key() 138 | return self.variables.input_key 139 | endfunction 140 | 141 | 142 | function! s:base.set_prompt(prompt) 143 | let self.variables.prompt = a:prompt 144 | endfunction 145 | 146 | 147 | function! s:base.get_prompt() 148 | return self.variables.prompt 149 | endfunction 150 | 151 | 152 | function! s:base.set_suffix(str) 153 | let self.variables.suffix = a:str 154 | endfunction 155 | 156 | 157 | function! s:base.get_suffix() 158 | return self.variables.suffix 159 | endfunction 160 | 161 | 162 | function! s:base.insert(word, ...) 163 | if a:0 164 | call self.line.set(a:1) 165 | endif 166 | call self.line.input(a:word) 167 | endfunction 168 | 169 | function! s:base.forward() 170 | return self.line.forward() 171 | endfunction 172 | 173 | function! s:base.backward() 174 | return self.line.backward() 175 | endfunction 176 | 177 | 178 | function! s:base.backward_word(...) 179 | let pat = get(a:, 1, '\k\+\s*\|.') 180 | return matchstr(self.backward(), '\%(' . pat . '\)$') 181 | endfunction 182 | 183 | 184 | function! s:base.connect(module, ...) 185 | if type(a:module) == type("") 186 | return call(self.connect, [s:Module.make(a:module)] + a:000, self) 187 | endif 188 | if empty(a:module) 189 | return 190 | endif 191 | let name = a:0 > 0 ? a:1 : a:module.name 192 | let slot = self.variables.modules.find_first_by("get(v:val.slot, 'name', '') == " . string(name)) 193 | if empty(slot) 194 | call self.variables.modules.connect({ "name" : name, "module" : a:module }) 195 | else 196 | let slot.slot.module = a:module 197 | endif 198 | " let self.variables.modules[name] = a:module 199 | endfunction 200 | 201 | 202 | function! s:base.disconnect(name) 203 | return self.variables.modules.disconnect_by( 204 | \ "get(v:val.slot, 'name', '') == " . string(a:name) 205 | \ ) 206 | " unlet self.variables.modules[a:name] 207 | endfunction 208 | 209 | 210 | function! s:base.get_module(name) 211 | let slot = self.variables.modules.find_first_by("get(v:val.slot, 'name', '') == " . string(a:name)) 212 | return empty(slot) ? {} : slot.slot.module 213 | endfunction 214 | 215 | 216 | function! s:base.callevent(event) 217 | call self.variables.modules.sort_by("has_key(v:val.slot.module, 'priority') ? v:val.slot.module.priority('" . a:event . "') : 0") 218 | return self.variables.modules.call(a:event, [self]) 219 | " call map(filter(copy(self.variables.modules), "has_key(v:val, a:event)"), "v:val." . a:event . "(self)") 220 | endfunction 221 | 222 | 223 | function! s:base.cmap(lhs, rhs) 224 | let self.variables.keymapping[a:lhs] = a:rhs 225 | endfunction 226 | 227 | 228 | function! s:base.cnoremap(lhs, rhs) 229 | let key = s:Keymapping.as_key_config(a:rhs) 230 | let key.noremap = 1 231 | let self.variables.keymapping[a:lhs] = key 232 | endfunction 233 | 234 | 235 | function! s:base.cunmap(lhs) 236 | unlet self.variables.keymapping[a:lhs] 237 | endfunction 238 | 239 | 240 | function! s:base.keymapping() 241 | return self.__keymapping__() 242 | endfunction 243 | 244 | 245 | function! s:base.__keymapping__() 246 | return {} 247 | endfunction 248 | 249 | 250 | function! s:base.execute(...) 251 | let command = get(a:, 1, self.getline()) 252 | call self.__execute(command) 253 | endfunction 254 | 255 | 256 | function! s:base.draw() 257 | call self.callevent("on_draw_pre") 258 | call self.callevent("on_draw") 259 | endfunction 260 | 261 | 262 | function! s:base.exit(...) 263 | let self.variables.exit = 1 264 | let self.variables.exit_code = get(a:, 1, 0) 265 | endfunction 266 | 267 | 268 | function! s:base.enable_keymapping() 269 | let self.variables.enable_keymapping = 1 270 | endfunction 271 | 272 | 273 | function! s:base.disable_keymapping() 274 | let self.variables.enable_keymapping = 0 275 | endfunction 276 | 277 | 278 | function! s:base.is_enable_keymapping() 279 | return self.variables.enable_keymapping 280 | endfunction 281 | 282 | " function! s:base.cancel() 283 | " call self.exit(1) 284 | " call self.__on_cancel() 285 | " endfunction 286 | 287 | 288 | function! s:base.exit_code() 289 | return self.variables.exit_code 290 | endfunction 291 | 292 | 293 | function! s:base.hl_cursor_on() 294 | if exists("self.variables.old_guicursor") 295 | set guicursor& 296 | let &guicursor = self.variables.old_guicursor 297 | unlet self.variables.old_guicursor 298 | endif 299 | 300 | if exists("self.variables.old_t_ve") 301 | let &t_ve = self.variables.old_t_ve 302 | unlet self.variables.old_t_ve 303 | endif 304 | endfunction 305 | 306 | 307 | function! s:base.hl_cursor_off() 308 | if exists("self.variables.old_t_ve") 309 | return 310 | endif 311 | 312 | let self.variables.old_guicursor = &guicursor 313 | set guicursor=n:block-NONE 314 | let self.variables.old_t_ve = &t_ve 315 | set t_ve= 316 | endfunction 317 | 318 | 319 | function! s:base.start(...) 320 | let exit_code = call(self.__main, a:000, self) 321 | return exit_code 322 | endfunction 323 | 324 | 325 | function! s:base.__empty(...) 326 | endfunction 327 | 328 | 329 | function! s:base.get(...) 330 | let Old_execute = self.execute 331 | let self.execute = self.__empty 332 | try 333 | let exit_code = call(self.start, a:000, self) 334 | if exit_code == 0 335 | return self.getline() 336 | endif 337 | finally 338 | let self.execute = Old_execute 339 | endtry 340 | return "" 341 | endfunction 342 | 343 | 344 | function! s:base.input_key_stack() 345 | return self.variables.input_key_stack 346 | endfunction 347 | 348 | 349 | function! s:base.input_key_stack_string() 350 | return join(self.variables.input_key_stack, "") 351 | endfunction 352 | 353 | 354 | function! s:base.set_input_key_stack(stack) 355 | let self.variables.input_key_stack = a:stack 356 | return self.variables.input_key_stack 357 | endfunction 358 | 359 | 360 | function! s:base.input_key_stack_pop() 361 | return remove(self.input_key_stack(), 0) 362 | endfunction 363 | 364 | 365 | function! s:base.getchar(...) 366 | if empty(self.input_key_stack()) 367 | return call(s:Input.getchar, a:000, s:Input) 368 | endif 369 | return self.input_key_stack_pop() 370 | endfunction 371 | 372 | 373 | function! s:base.__init_variables() 374 | let self.variables.tap_key = "" 375 | let self.variables.char = "" 376 | let self.variables.input = "" 377 | let self.variables.exit = 0 378 | let self.variables.exit_code = 1 379 | let self.variables.enable_keymapping = 1 380 | let self.variables.input_key_stack = [] 381 | let self.line = deepcopy(s:String.make()) 382 | endfunction 383 | 384 | 385 | function! s:_is_valid_highlight(name) 386 | let highlight = s:Highlight.get(a:name) 387 | if empty(highlight) 388 | return 0 389 | endif 390 | 391 | if has("gui_running") 392 | \ && (has_key(highlight, "guifg") || has_key(highlight, "guibg")) 393 | return 1 394 | elseif (has_key(highlight, "ctermfg") || has_key(highlight, "ctermbg")) 395 | return 1 396 | endif 397 | return 0 398 | endfunction 399 | 400 | 401 | function! s:base.__init() 402 | call self.__init_variables() 403 | call self.hl_cursor_off() 404 | if !hlexists(self.highlights.cursor) 405 | if s:_is_valid_highlight("Cursor") 406 | execute "highlight link " . self.highlights.cursor . " Cursor" 407 | else 408 | " Workaround by CUI Vim Cursor Highlight 409 | " issues #92 410 | " https://github.com/osyo-manga/vital-over/issues/92 411 | execute "highlight " . self.highlights.cursor . " term=reverse cterm=reverse gui=reverse" 412 | endif 413 | endif 414 | if !hlexists(self.highlights.cursor_on) 415 | execute "highlight link " . self.highlights.cursor_on . " " . self.highlights.cursor 416 | endif 417 | if !hlexists(self.highlights.cursor_insert) 418 | execute "highlight " . self.highlights.cursor_insert . " cterm=underline term=underline gui=underline" 419 | endif 420 | endfunction 421 | 422 | 423 | function! s:base.__execute(command) 424 | call self.callevent("on_execute_pre") 425 | try 426 | call self.__execute__(a:command) 427 | catch 428 | echohl ErrorMsg 429 | echom matchstr(v:exception, 'Vim\((\w*)\)\?:\zs.*\ze') 430 | echohl None 431 | call self.callevent("on_execute_failed") 432 | finally 433 | call self.callevent("on_execute") 434 | endtry 435 | endfunction 436 | 437 | 438 | function! s:base.__execute__(cmd) 439 | execute a:cmd 440 | endfunction 441 | 442 | 443 | function! s:base.__input_char(char) 444 | let char = a:char 445 | let self.variables.input_key = char 446 | let self.variables.char = char 447 | call self.setchar(self.variables.char) 448 | let self.variables.is_setted = 0 449 | call self.callevent("on_char_pre") 450 | call self.insert(self.variables.input) 451 | call self.callevent("on_char") 452 | endfunction 453 | 454 | 455 | function! s:base.__input(input, ...) 456 | if a:input == "" 457 | return 458 | endif 459 | 460 | let self.variables.input_key = a:input 461 | if a:0 == 0 462 | let keymapping = self.__get_keymapping() 463 | else 464 | let keymapping = a:1 465 | endif 466 | if self.is_enable_keymapping() 467 | let key = s:Keymapping.unmapping(keymapping, a:input) 468 | else 469 | let key = a:input 470 | endif 471 | if key == "" 472 | return 473 | endif 474 | 475 | call self.set_input_key_stack(s:String.split_by_keys(key)) 476 | while !(empty(self.input_key_stack()) || self.is_exit()) 477 | call self.__input_char(self.input_key_stack_pop()) 478 | endwhile 479 | endfunction 480 | 481 | 482 | function! s:is_input_waiting(keymapping, input) 483 | let num = len(filter(copy(a:keymapping), 'stridx(v:key, a:input) == 0')) 484 | return num > 1 || (num == 1 && !has_key(a:keymapping, a:input)) 485 | endfunction 486 | 487 | 488 | function! s:base.__inputting() 489 | if !self.is_enable_keymapping() 490 | return self.__input(s:Input.getchar()) 491 | endif 492 | 493 | let input = s:Input.getchar() 494 | let old_line = self.getline() 495 | let old_pos = self.getpos() 496 | let keymapping = self.__get_keymapping() 497 | try 498 | let t = reltime() 499 | while s:is_input_waiting(keymapping, input) 500 | \ && str2nr(reltimestr(reltime(t))) * 1000 < &timeoutlen 501 | call self.setline(old_line) 502 | call self.insert(input) 503 | call self.setpos(old_pos) 504 | call self.draw() 505 | let input .= s:Input.getchar(0) 506 | endwhile 507 | finally 508 | call self.setline(old_line) 509 | call self.setpos(old_pos) 510 | endtry 511 | call self.__input(input, keymapping) 512 | endfunction 513 | 514 | 515 | function! s:base.__update() 516 | " call self.callevent("on_update") 517 | " if !getchar(1) 518 | " continue 519 | " endif 520 | " 521 | " call self.__input(s:getchar(0)) 522 | " call self.draw() 523 | 524 | call self.callevent("on_update") 525 | call self.__inputting() 526 | " call self.__input(s:Input.getchar()) 527 | if self.is_exit() 528 | return -1 529 | endif 530 | call self.draw() 531 | endfunction 532 | 533 | 534 | function! s:base.__main(...) 535 | try 536 | call self.__init() 537 | call self.callevent("on_enter") 538 | 539 | call self.__input(get(a:, 1, "")) 540 | call self.draw() 541 | while !self.is_exit() 542 | try 543 | if self.__update() 544 | break 545 | endif 546 | catch 547 | call self.callevent("on_exception") 548 | endtry 549 | endwhile 550 | catch 551 | echohl ErrorMsg | echom v:throwpoint . " " . v:exception | echohl None 552 | let self.variables.exit_code = -1 553 | finally 554 | call self.__finish() 555 | call self.callevent("on_leave") 556 | endtry 557 | return self.exit_code() 558 | endfunction 559 | 560 | 561 | function! s:base.__finish() 562 | call self.hl_cursor_on() 563 | endfunction 564 | 565 | 566 | function! s:base.__is_exit() 567 | return self.is_exit() 568 | endfunction 569 | 570 | 571 | function! s:base.is_exit() 572 | return self.variables.exit 573 | endfunction 574 | 575 | 576 | function! s:base.__get_keymapping() 577 | let result = {} 578 | " for module in values(self.variables.modules) 579 | for module in self.variables.modules.slots() 580 | if has_key(module, "keymapping") 581 | if module isnot self 582 | call extend(result, module.keymapping(self)) 583 | endif 584 | endif 585 | endfor 586 | return extend(extend(result, self.variables.keymapping), self.keymapping()) 587 | endfunction 588 | 589 | 590 | let &cpo = s:save_cpo 591 | unlet s:save_cpo 592 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Maker.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | let s:modules = [ 6 | \ "Scroll", 7 | \ "CursorMove", 8 | \ "Delete", 9 | \ "HistAdd", 10 | \ "History", 11 | \ "Cancel", 12 | \ "Execute", 13 | \ "NoInsert", 14 | \ "InsertRegister", 15 | \ "Redraw", 16 | \ "DrawCommandline", 17 | \ "ExceptionExit", 18 | \ "ExceptionMessage", 19 | \] 20 | 21 | 22 | function! s:_vital_loaded(V) 23 | let s:V = a:V 24 | let s:Cmdline = s:V.import("Over.Commandline.Base") 25 | let s:Modules = s:V.import("Over.Commandline.Modules") 26 | endfunction 27 | 28 | 29 | function! s:_vital_depends() 30 | return [ 31 | \ "Over.Commandline.Base", 32 | \ "Over.Commandline.Modules", 33 | \ ] + map(copy(s:modules), "'Over.Commandline.Modules.' . v:val") 34 | endfunction 35 | 36 | 37 | function! s:default(...) 38 | return call(s:Cmdline.make, a:000, s:Cmdline) 39 | endfunction 40 | 41 | 42 | function! s:plain() 43 | return s:Cmdline.plain() 44 | endfunction 45 | 46 | 47 | function! s:standard(...) 48 | let result = call(s:Cmdline.make, a:000, s:Cmdline) 49 | call result.connect("Execute") 50 | call result.connect("Cancel") 51 | call result.connect("Delete") 52 | call result.connect("CursorMove") 53 | call result.connect("HistAdd") 54 | call result.connect("History") 55 | call result.connect("InsertRegister") 56 | call result.connect(s:Modules.get("NoInsert").make_special_chars()) 57 | call result.connect("Redraw") 58 | call result.connect("DrawCommandline") 59 | call result.connect("ExceptionExit") 60 | call result.connect("ExceptionMessage") 61 | call result.connect(s:Modules.get("KeyMapping").make_vim_cmdline_mapping()) 62 | call result.connect("Digraphs") 63 | call result.connect("LiteralInsert") 64 | 65 | return result 66 | endfunction 67 | 68 | 69 | function! s:standard_search(...) 70 | let result = s:standard(get(a:, 1, "/")) 71 | call result.connect(s:Modules.get("Execute").make_search("/")) 72 | call result.connect(s:Modules.make("HistAdd", "/")) 73 | call result.connect(s:Modules.make("History", "/")) 74 | return result 75 | endfunction 76 | 77 | 78 | function! s:standard_search_back(...) 79 | let result = s:standard(get(a:, 1, "?")) 80 | call result.connect(s:Modules.get("Execute").make_search("?")) 81 | call result.connect(s:Modules.make("HistAdd", "/")) 82 | call result.connect(s:Modules.make("History", "/")) 83 | return result 84 | endfunction 85 | 86 | 87 | let &cpo = s:save_cpo 88 | unlet s:save_cpo 89 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_vital_loaded(V) 7 | let s:V = a:V 8 | endfunction 9 | 10 | 11 | function! s:get(name) 12 | if exists("s:" . a:name) 13 | return s:{a:name} 14 | endif 15 | let s:{a:name} = s:V.import('Over.Commandline.Modules.' . a:name) 16 | return s:{a:name} 17 | endfunction 18 | 19 | 20 | function! s:make(name, ...) 21 | let module = s:get(a:name) 22 | return call(module.make, a:000, module) 23 | endfunction 24 | 25 | 26 | let &cpo = s:save_cpo 27 | unlet s:save_cpo 28 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/All.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:modules = map(split(globpath(expand(":p:h"), "/*.vim"), "\n"), "fnamemodify(v:val, ':t:r')") 7 | 8 | 9 | function! s:_vital_depends() 10 | return map(copy(s:modules), "'Over.Commandline.Modules.' . v:val") 11 | endfunction 12 | 13 | 14 | let &cpo = s:save_cpo 15 | unlet s:save_cpo 16 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/AsyncUpdate.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | function! s:_vital_loaded(V) 6 | let s:V = a:V 7 | let s:Base = s:V.import("Over.Commandline.Base") 8 | endfunction 9 | 10 | 11 | let s:module = { 12 | \ "name" : "AsyncUpdate" 13 | \} 14 | 15 | function! s:module.on_enter(cmdline) 16 | function! a:cmdline.__update() 17 | call self.callevent("on_update") 18 | try 19 | if !getchar(1) 20 | return 21 | endif 22 | call self.__inputting() 23 | catch /^Vim:Interrupt$/ 24 | call self.__input("\") 25 | endtry 26 | 27 | call self.draw() 28 | endfunction 29 | endfunction 30 | 31 | 32 | function! s:make() 33 | return deepcopy(s:module) 34 | endfunction 35 | 36 | 37 | let &cpo = s:save_cpo 38 | unlet s:save_cpo 39 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/BufferComplete.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_uniq(list) 7 | let dict = {} 8 | for _ in a:list 9 | let dict[_] = 0 10 | endfor 11 | return keys(dict) 12 | endfunction 13 | 14 | 15 | let s:module = { 16 | \ "name" : "BufferComplete", 17 | \} 18 | 19 | 20 | function! s:_buffer_complete() 21 | return sort(s:_uniq(filter(split(join(getline(1, '$')), '\W'), '!empty(v:val)')), 1) 22 | endfunction 23 | 24 | 25 | function! s:_parse_line(line) 26 | let keyword = matchstr(a:line, '\zs\w\+\ze$') 27 | let pos = strchars(a:line) - strchars(keyword) 28 | return [pos, keyword] 29 | endfunction 30 | 31 | 32 | function! s:_as_statusline(list, count) 33 | if empty(a:list) 34 | return 35 | endif 36 | let hl_none = "%#StatusLine#" 37 | let hl_select = "%#StatusLineNC#" 38 | let tail = " > " 39 | let result = a:list[0] 40 | let pos = 0 41 | for i in range(1, len(a:list)-1) 42 | if strdisplaywidth(result . " " . a:list[i]) > &columns - len(tail) 43 | if a:count < i 44 | break 45 | else 46 | let pos = -i 47 | endif 48 | let result = a:list[i] 49 | else 50 | let result .= (" " . a:list[i]) 51 | endif 52 | if a:count == i 53 | let pos = pos + i 54 | endif 55 | endfor 56 | return join(map(split(result, " "), 'v:key == pos ? hl_select . v:val . hl_none : v:val')) 57 | endfunction 58 | 59 | 60 | function! s:module.get_complete_words() 61 | return s:_buffer_complete() 62 | endfunction 63 | 64 | 65 | function! s:module.complete(cmdline) 66 | call s:_finish() 67 | let s:old_statusline = &statusline 68 | 69 | let backward = a:cmdline.backward() 70 | let [pos, keyword] = s:_parse_line(backward) 71 | 72 | if !exists("s:complete") 73 | let s:complete = self.get_complete_words() 74 | endif 75 | let s:complete_list = filter(copy(s:complete), 'v:val =~ ''^''.keyword') 76 | if empty(s:complete_list) 77 | return -1 78 | endif 79 | 80 | if pos == 0 81 | let backward = "" 82 | else 83 | let backward = join(split(backward, '\zs')[ : pos-1 ], "") 84 | endif 85 | let s:line = backward . a:cmdline.forward() 86 | let s:pos = pos 87 | call a:cmdline.setline(s:line) 88 | 89 | let s:count = 0 90 | endfunction 91 | 92 | 93 | function! s:_finish() 94 | if exists("s:old_statusline") 95 | let &statusline = s:old_statusline 96 | unlet s:old_statusline 97 | redrawstatus 98 | endif 99 | endfunction 100 | 101 | 102 | function! s:module.on_char_pre(cmdline) 103 | if a:cmdline.is_input("(buffer-complete)") 104 | \ || a:cmdline.is_input("(buffer-complete-prev)") 105 | if self.complete(a:cmdline) == -1 106 | call s:_finish() 107 | call a:cmdline.setchar('') 108 | return 109 | endif 110 | if a:cmdline.is_input("(buffer-complete-prev)") 111 | let s:count = len(s:complete_list) - 1 112 | endif 113 | call a:cmdline.setchar('') 114 | call a:cmdline.tap_keyinput("Completion") 115 | " elseif a:cmdline.is_input("\", "Completion") 116 | elseif a:cmdline.is_input("(buffer-complete)", "Completion") 117 | \ || a:cmdline.is_input("\", "Completion") 118 | call a:cmdline.setchar('') 119 | let s:count += 1 120 | if s:count >= len(s:complete_list) 121 | let s:count = 0 122 | endif 123 | elseif a:cmdline.is_input("(buffer-complete-prev)", "Completion") 124 | \ || a:cmdline.is_input("\", "Completion") 125 | call a:cmdline.setchar('') 126 | let s:count -= 1 127 | if s:count < 0 128 | let s:count = len(s:complete_list) - 1 129 | endif 130 | else 131 | if a:cmdline.untap_keyinput("Completion") 132 | call a:cmdline.callevent("on_char_pre") 133 | endif 134 | call s:_finish() 135 | return 136 | endif 137 | call a:cmdline.setline(s:line) 138 | call a:cmdline.insert(s:complete_list[s:count], s:pos) 139 | if len(s:complete_list) > 1 140 | let &statusline = s:_as_statusline(s:complete_list, s:count) 141 | redrawstatus 142 | endif 143 | if len(s:complete_list) == 1 144 | call a:cmdline.untap_keyinput("Completion") 145 | endif 146 | endfunction 147 | 148 | 149 | function! s:module.on_draw_pre(...) 150 | " redrawstatus 151 | endfunction 152 | 153 | 154 | function! s:module.on_leave(cmdline) 155 | call s:_finish() 156 | unlet! s:complete 157 | endfunction 158 | 159 | function! s:make() 160 | return deepcopy(s:module) 161 | endfunction 162 | 163 | let &cpo = s:save_cpo 164 | unlet s:save_cpo 165 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Cancel.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | let s:module = { 6 | \ "name" : "Cancel" 7 | \} 8 | 9 | function! s:module.on_char_pre(cmdline) 10 | if a:cmdline.is_input("\") 11 | \ || a:cmdline.is_input("\") 12 | " call a:cmdline.cancel() 13 | call a:cmdline.exit(1) 14 | call a:cmdline.setchar("") 15 | endif 16 | endfunction 17 | 18 | 19 | function! s:make() 20 | return deepcopy(s:module) 21 | endfunction 22 | 23 | 24 | let &cpo = s:save_cpo 25 | unlet s:save_cpo 26 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/CursorMove.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:module = { 7 | \ "name" : "CursorMove" 8 | \} 9 | function! s:module.on_char_pre(cmdline) 10 | if a:cmdline.is_input("\") 11 | call a:cmdline.line.next() 12 | call a:cmdline.setchar('') 13 | elseif a:cmdline.is_input("\") 14 | call a:cmdline.line.prev() 15 | call a:cmdline.setchar('') 16 | elseif a:cmdline.is_input("\") 17 | \ || a:cmdline.is_input("\") 18 | call a:cmdline.setline(0) 19 | call a:cmdline.setchar('') 20 | elseif a:cmdline.is_input("\") 21 | \ || a:cmdline.is_input("\") 22 | call a:cmdline.setline(a:cmdline.line.length()) 23 | call a:cmdline.setchar('') 24 | elseif a:cmdline.is_input("\") 25 | \ || a:cmdline.is_input("\") 26 | call a:cmdline.setline(strridx(a:cmdline.backward()[:-2], ' ') + 1) 27 | call a:cmdline.setchar('') 28 | elseif a:cmdline.is_input("\") 29 | \ || a:cmdline.is_input("\") 30 | let p = stridx(a:cmdline.forward()[1:], ' ') 31 | call a:cmdline.setline(p != -1 ? a:cmdline.line.pos() + p + 2 : a:cmdline.line.length()) 32 | call a:cmdline.setchar('') 33 | endif 34 | endfunction 35 | 36 | 37 | function! s:make() 38 | return deepcopy(s:module) 39 | endfunction 40 | 41 | 42 | let &cpo = s:save_cpo 43 | unlet s:save_cpo 44 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Delete.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:module = { 7 | \ "name" : "Delete", 8 | \} 9 | function! s:module.on_char_pre(cmdline) 10 | if a:cmdline.is_input("\") 11 | \ || a:cmdline.is_input("\") 12 | if a:cmdline.line.length() == 0 13 | return a:cmdline.exit(1) 14 | else 15 | call a:cmdline.line.remove_prev() 16 | call a:cmdline.setchar('') 17 | endif 18 | elseif a:cmdline.is_input("\") 19 | call a:cmdline.line.remove_pos() 20 | call a:cmdline.setchar('') 21 | elseif a:cmdline.is_input("\") 22 | let word = a:cmdline.backward_word() 23 | let backward = a:cmdline.backward()[ : -strlen(word)-1 ] 24 | call a:cmdline.setline(backward . a:cmdline.line.pos_char() . a:cmdline.forward()) 25 | call a:cmdline.setline(strchars(backward)) 26 | call a:cmdline.setchar('') 27 | elseif a:cmdline.is_input("\") 28 | call a:cmdline.setline(a:cmdline.line.pos_char() . a:cmdline.forward()) 29 | call a:cmdline.setline(0) 30 | call a:cmdline.setchar('') 31 | endif 32 | endfunction 33 | 34 | 35 | function! s:make() 36 | return deepcopy(s:module) 37 | endfunction 38 | 39 | 40 | let &cpo = s:save_cpo 41 | unlet s:save_cpo 42 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Digraphs.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | function! s:_vital_loaded(V) 6 | let s:Input = a:V.import("Over.Input") 7 | endfunction 8 | 9 | 10 | function! s:_vital_depends() 11 | return [ 12 | \ "Over.Input", 13 | \ ] 14 | endfunction 15 | 16 | 17 | let s:module = { 18 | \ "name" : "Digraphs", 19 | \ "digraphs" : {} 20 | \} 21 | 22 | function! s:capture(cmd) 23 | let verbose_save = &verbose 24 | let &verbose = 0 25 | try 26 | redir => result 27 | execute "silent!" a:cmd 28 | redir END 29 | finally 30 | let &verbose = verbose_save 31 | endtry 32 | return result 33 | endfunction 34 | 35 | function! s:digraph() abort 36 | let x = split(substitute(s:capture(':digraph'), "\n", ' ', 'g'), 37 | \ '[[:graph:]]\{2}\s.\{1,4}\s\+\d\+\s*\zs') 38 | let digraphs = map(x, "split(v:val, ' \\+')") 39 | let r = {} 40 | for d in digraphs 41 | let r[d[0]] = len(d) is 3 && d[2] =~# '\d\+' ? nr2char(str2nr(d[2],10)) 42 | \ : len(d) is 2 && d[1] =~# '32' ? nr2char(str2nr(d[1],10)) 43 | \ : '' 44 | endfor 45 | return r 46 | endfunction 47 | 48 | 49 | function! s:module.on_leave(cmdline) 50 | " Delete cache to handle additional digraphs definition 51 | let self.digraphs = {} 52 | endfunction 53 | 54 | function! s:module.on_char_pre(cmdline) 55 | if a:cmdline.is_input("\") 56 | if empty(self.digraphs) 57 | " Get digraphs when inputting instead of on_enter because it cause 58 | " flicker in some environments #107 59 | let self.digraphs = s:digraph() 60 | endif 61 | call a:cmdline.setchar('?') 62 | let self.prefix_key = a:cmdline.input_key() 63 | let self.old_line = a:cmdline.getline() 64 | let self.old_pos = a:cmdline.getpos() 65 | return 66 | elseif exists("self.prefix_key") 67 | \ && a:cmdline.get_tap_key() == self.prefix_key 68 | call a:cmdline.setline(self.old_line) 69 | call a:cmdline.setpos(self.old_pos) 70 | let x = a:cmdline.input_key() 71 | let y = s:Input.getchar() 72 | " For CTRL-K, there is one general digraph: CTRL-K {char} will 73 | " enter {char} with the highest bit set. You can use this to enter 74 | " meta-characters. 75 | let char = x ==# "\" ? 76 | \ nr2char(char2nr(y) + 128) : get(self.digraphs, x . y, y) 77 | call a:cmdline.setchar(char) 78 | endif 79 | endfunction 80 | 81 | function! s:module.on_char(cmdline) 82 | if a:cmdline.is_input("\") 83 | call a:cmdline.tap_keyinput(self.prefix_key) 84 | call a:cmdline.disable_keymapping() 85 | call a:cmdline.setpos(a:cmdline.getpos()-1) 86 | else 87 | if exists("self.prefix_key") 88 | call a:cmdline.untap_keyinput(self.prefix_key) 89 | call a:cmdline.enable_keymapping() 90 | unlet! self.prefix_key 91 | endif 92 | endif 93 | endfunction 94 | 95 | 96 | function! s:make() 97 | return deepcopy(s:module) 98 | endfunction 99 | 100 | let &cpo = s:save_cpo 101 | unlet s:save_cpo 102 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Doautocmd.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_vital_loaded(V) 7 | let s:V = a:V 8 | let s:E = s:V.import("Over.Exception") 9 | endfunction 10 | 11 | 12 | function! s:_vital_depends() 13 | return [ 14 | \ "Over.Exception", 15 | \ ] 16 | endfunction 17 | 18 | 19 | let s:cache_command = {} 20 | function! s:doautocmd_user(prefix, command) 21 | let group = a:prefix . "-vital-over-commandline-doautocmd-dummy" 22 | if !has_key(s:cache_command, a:prefix) 23 | let s:cache_command[a:prefix] = {} 24 | endif 25 | 26 | if !has_key(s:cache_command[a:prefix], a:command) 27 | execute "autocmd " . group 28 | \ . " User " . a:command." silent! execute ''" 29 | 30 | if v:version > 703 || v:version == 703 && has("patch438") 31 | let s:cache_command[a:prefix][a:command] = "doautocmd User " . a:command 32 | else 33 | let s:cache_command[a:prefix][a:command] = "doautocmd User " . a:command 34 | endif 35 | endif 36 | 37 | execute s:cache_command[a:prefix][a:command] 38 | endfunction 39 | 40 | 41 | let s:hooks = [ 42 | \ "enter", 43 | \ "leave", 44 | \ "char", 45 | \ "char_pre", 46 | \ "draw", 47 | \ "draw_pre", 48 | \ "execute_pre", 49 | \ "execute_failed", 50 | \ "execute", 51 | \ "exception", 52 | \] 53 | 54 | let s:hooks_camel = [ 55 | \ "Enter", 56 | \ "Leave", 57 | \ "Char", 58 | \ "CharPre", 59 | \ "Draw", 60 | \ "DrawPre", 61 | \ "ExecutePre", 62 | \ "ExecuteFailed", 63 | \ "Execute", 64 | \ "Exception", 65 | \] 66 | 67 | 68 | let s:module = { 69 | \ "name" : "Doautocmd", 70 | \} 71 | 72 | 73 | for s:i in range(len(s:hooks)) 74 | execute join([ 75 | \ "function! s:module.on_" . s:hooks[s:i] . "(cmdline, ...)", 76 | \ " let s:cmdline = a:cmdline", 77 | \ " call s:doautocmd_user(self.prefix, self.prefix . " . string(s:hooks_camel[s:i]) . ")", 78 | \ "endfunction", 79 | \ ], "\n") 80 | endfor 81 | 82 | 83 | function! s:get_cmdline() 84 | if !exists("s:cmdline") 85 | execute s:E.throw_cmd("Undefined cmdline object.", "Over.Commandline.Modules.Doautocmd") 86 | endif 87 | return s:cmdline 88 | endfunction 89 | 90 | 91 | function! s:make(prefix) 92 | if has_key(s:cache_command, a:prefix) 93 | unlet! s:cache_command[a:prefix] 94 | endif 95 | execute "augroup " a:prefix . "-vital-over-commandline-doautocmd-dummy" 96 | autocmd! 97 | augroup END 98 | 99 | let module = deepcopy(s:module) 100 | let module.prefix = a:prefix 101 | return module 102 | endfunction 103 | 104 | 105 | let &cpo = s:save_cpo 106 | unlet s:save_cpo 107 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/DrawCommandline.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | let s:module = { 6 | \ "name" : "DrawCommandline" 7 | \} 8 | 9 | let s:cmdheight = {} 10 | 11 | function! s:cmdheight.save() 12 | if has_key(self, "value") 13 | return 14 | endif 15 | let self.value = &cmdheight 16 | endfunction 17 | 18 | function! s:cmdheight.restore() 19 | if has_key(self, "value") 20 | let &cmdheight = self.value 21 | unlet self.value 22 | endif 23 | endfunction 24 | 25 | 26 | function! s:cmdheight.get() 27 | return self.value 28 | endfunction 29 | 30 | 31 | function! s:suffix(left, suffix) 32 | let left_len = strdisplaywidth(a:left) 33 | let len = &columns - left_len % &columns 34 | let len = len + (&columns * (strdisplaywidth(a:suffix) > (len - 1))) - 1 35 | return repeat(" ", len - strdisplaywidth(a:suffix)) . a:suffix 36 | " return printf("%" . len . "S", a:suffix) 37 | endfunction 38 | 39 | 40 | let s:old_width = 0 41 | function! s:_redraw(cmdline) 42 | let left = a:cmdline.get_prompt() . a:cmdline.getline() . (empty(a:cmdline.line.pos_char()) ? " " : "") 43 | let width = len(left) + 1 44 | 45 | if a:cmdline.get_suffix() != "" 46 | let width += len(s:suffix(left, a:cmdline.get_suffix())) - 1 47 | endif 48 | 49 | if &columns >= width && &columns <= s:old_width && s:old_width >= width 50 | redraw 51 | normal! : 52 | elseif &columns <= width 53 | normal! : 54 | else 55 | redraw 56 | endif 57 | let s:old_width = width 58 | 59 | call s:cmdheight.save() 60 | let height = max([(width - 1) / (&columns) + 1, s:cmdheight.get()]) 61 | if height > &cmdheight || &cmdheight > height 62 | let &cmdheight = height 63 | redraw 64 | endif 65 | endfunction 66 | 67 | 68 | function! s:_as_echon(str) 69 | return "echon " . strtrans(string(a:str)) 70 | endfunction 71 | 72 | 73 | function! s:module.on_draw_pre(cmdline) 74 | if empty(a:cmdline.line.pos_char()) 75 | let cursor = "echohl " . a:cmdline.highlights.cursor . " | echon ' '" 76 | else 77 | let cursor = "echohl " . a:cmdline.highlights.cursor_on . " | " . s:_as_echon(a:cmdline.line.pos_char()) 78 | endif 79 | let suffix = "" 80 | if a:cmdline.get_suffix() != "" 81 | let suffix = s:_as_echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_char())), a:cmdline.get_suffix())) 82 | endif 83 | let self.draw_command = join([ 84 | \ "echohl " . a:cmdline.highlights.prompt, 85 | \ s:_as_echon(a:cmdline.get_prompt()), 86 | \ "echohl NONE", 87 | \ s:_as_echon(a:cmdline.backward()), 88 | \ cursor, 89 | \ "echohl NONE", 90 | \ s:_as_echon(a:cmdline.forward()), 91 | \ suffix, 92 | \ ], " | ") 93 | 94 | call s:_redraw(a:cmdline) 95 | endfunction 96 | 97 | 98 | function! s:_echon(expr) 99 | echon strtrans(a:expr) 100 | endfunction 101 | 102 | 103 | function! s:module.on_draw(cmdline) 104 | execute self.draw_command 105 | " execute "echohl" a:cmdline.highlights.prompt 106 | " call s:echon(a:cmdline.get_prompt()) 107 | " echohl NONE 108 | " call s:echon(a:cmdline.backward()) 109 | " if empty(a:cmdline.line.pos_char()) 110 | " execute "echohl" a:cmdline.highlights.cursor 111 | " call s:echon(' ') 112 | " else 113 | " execute "echohl" a:cmdline.highlights.cursor_on 114 | " call s:echon(a:cmdline.line.pos_char()) 115 | " endif 116 | " echohl NONE 117 | " call s:echon(a:cmdline.forward()) 118 | " if a:cmdline.get_suffix() != "" 119 | " call s:echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_char())), a:cmdline.get_suffix())) 120 | " endif 121 | endfunction 122 | 123 | 124 | function! s:module.on_execute_pre(...) 125 | call s:cmdheight.restore() 126 | endfunction 127 | 128 | 129 | function! s:module.on_leave(...) 130 | call s:cmdheight.restore() 131 | endfunction 132 | 133 | 134 | function! s:make() 135 | return deepcopy(s:module) 136 | endfunction 137 | 138 | 139 | let &cpo = s:save_cpo 140 | unlet s:save_cpo 141 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/ExceptionExit.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | let s:module = { 6 | \ "name" : "ExceptionExit", 7 | \} 8 | 9 | 10 | function! s:module.on_exception(cmdline) 11 | call a:cmdline.exit(-1) 12 | endfunction 13 | 14 | 15 | function! s:make(...) 16 | let result = deepcopy(s:module) 17 | let result.exit_code = get(a:, 1, 0) 18 | return result 19 | endfunction 20 | 21 | let &cpo = s:save_cpo 22 | unlet s:save_cpo 23 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/ExceptionMessage.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:vname = expand(":h:h:h:h:t") 7 | 8 | 9 | let s:module = { 10 | \ "name" : "ExceptionMessage", 11 | \} 12 | 13 | 14 | function! s:module.on_exception(cmdline) 15 | let self.exception = v:exception 16 | let self.throwpoint = v:throwpoint 17 | endfunction 18 | 19 | 20 | function! s:module.on_draw_pre(cmdline) 21 | if has_key(self, "exception") 22 | call self.message(a:cmdline) 23 | unlet self.exception 24 | endif 25 | endfunction 26 | 27 | function! s:module.message(...) 28 | echohl ErrorMsg 29 | execute self.command string(self.prefix . " : " . self.throwpoint . " " . self.exception) 30 | echohl None 31 | endfunction 32 | 33 | 34 | function! s:module.on_leave(cmdline) 35 | if has_key(self, "exception") 36 | call self.message(a:cmdline) 37 | unlet self.exception 38 | endif 39 | endfunction 40 | 41 | 42 | function! s:make(...) 43 | let result = deepcopy(s:module) 44 | let result.prefix = get(a:, 1, "vital-over(".s:vname.") Exception") 45 | let result.command = get(a:, 2, "echom") 46 | return result 47 | endfunction 48 | 49 | 50 | let &cpo = s:save_cpo 51 | unlet s:save_cpo 52 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Execute.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:silent_feedkeys(expr, name, ...) 7 | let mode = get(a:, 1, "m") 8 | let map = printf("(%s)", a:name) 9 | if mode == "n" 10 | let command = "nnoremap" 11 | else 12 | let command = "nmap" 13 | endif 14 | execute command "" map printf("%s:nunmap %s", a:expr, map) 15 | call feedkeys(printf("\(%s)", a:name)) 16 | endfunction 17 | 18 | 19 | function! s:_is_input_enter(cmdline) 20 | return a:cmdline.is_input("\") 21 | \ || a:cmdline.is_input("\") 22 | \ || a:cmdline.is_input("\") 23 | endfunction 24 | 25 | 26 | let s:module = { 27 | \ "name" : "Execute" 28 | \} 29 | 30 | function! s:module.on_char_pre(cmdline) 31 | if s:_is_input_enter(a:cmdline) 32 | call self.execute(a:cmdline) 33 | call a:cmdline.setchar("") 34 | call a:cmdline.exit(0) 35 | endif 36 | if a:cmdline.is_input("(execute-no-exit)") 37 | call self.execute(a:cmdline) 38 | call a:cmdline.setchar("") 39 | endif 40 | endfunction 41 | 42 | function! s:module.execute(cmdline) 43 | return a:cmdline.execute() 44 | endfunction 45 | 46 | 47 | function! s:make() 48 | return deepcopy(s:module) 49 | endfunction 50 | 51 | 52 | let s:search = deepcopy(s:module) 53 | let s:search.prefix = "/" 54 | 55 | 56 | function! s:search.execute(cmdline) 57 | call s:silent_feedkeys(":call histdel('/', -1)\", "remove_hist", "n") 58 | let cmd = printf("call s:silent_feedkeys(\"%s%s\\", 'search', 'n')", self.prefix, a:cmdline.getline()) 59 | execute cmd 60 | " let cmd = printf("call search('%s')", a:cmdline.getline()) 61 | " call a:cmdline.execute(cmd) 62 | " let @/ = a:cmdline.getline() 63 | " call s:silent_feedkeys(":let &hlsearch = &hlsearch\", "hlsearch", "n") 64 | endfunction 65 | 66 | 67 | 68 | function! s:make_search(...) 69 | let result = deepcopy(s:search) 70 | let result.prefix = get(a:, 1, "/") 71 | return result 72 | endfunction 73 | 74 | 75 | let &cpo = s:save_cpo 76 | unlet s:save_cpo 77 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Exit.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | let s:module = { 6 | \ "name" : "Exit", 7 | \ "exit_code" : 0 8 | \} 9 | 10 | 11 | function! s:module.on_char_pre(cmdline) 12 | if a:cmdline.is_input("(exit)") 13 | call a:cmdline.setchar("") 14 | call a:cmdline.exit(self.exit_code) 15 | endif 16 | endfunction 17 | 18 | 19 | function! s:make() 20 | return deepcopy(s:module) 21 | endfunction 22 | 23 | 24 | let &cpo = s:save_cpo 25 | unlet s:save_cpo 26 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/HistAdd.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:module = { 7 | \ "name" : "HistAdd", 8 | \ "mode" : "cmd" 9 | \} 10 | 11 | function! s:module.on_leave(cmdline) 12 | call histadd(self.mode, a:cmdline.getline()) 13 | endfunction 14 | 15 | 16 | function! s:make(...) 17 | let module = deepcopy(s:module) 18 | let module.mode = get(a:, 1, "cmd") 19 | return module 20 | endfunction 21 | 22 | let &cpo = s:save_cpo 23 | unlet s:save_cpo 24 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/History.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | let s:module = { 6 | \ "name" : "History", 7 | \ "mode" : "cmd", 8 | \} 9 | 10 | function! s:module.histories() 11 | return map(range(1, &history), 'histget(self.mode, v:val * -1)') 12 | endfunction 13 | 14 | function! s:_should_match_cmdline(cmdline) 15 | return a:cmdline.is_input("\") 16 | \ || a:cmdline.is_input("\") 17 | endfunction 18 | 19 | function! s:_reset() 20 | let s:cmdhist = [] 21 | let s:count = 0 22 | let s:is_match_mode = 0 " /: true, /: false 23 | endfunction 24 | 25 | function! s:module.on_enter(...) 26 | call s:_reset() 27 | endfunction 28 | 29 | function! s:module.on_char_pre(cmdline) 30 | if !a:cmdline.is_input("\") && !a:cmdline.is_input("\") 31 | \ && !a:cmdline.is_input("\") && !a:cmdline.is_input("\") 32 | call s:_reset() 33 | return 34 | else 35 | if s:count == 0 && empty(s:cmdhist) 36 | \ || s:is_match_mode != s:_should_match_cmdline(a:cmdline) 37 | let cmdline = '^' . a:cmdline.getline() 38 | let s:is_match_mode = s:_should_match_cmdline(a:cmdline) 39 | let s:cmdhist = [a:cmdline.getline()] + (s:is_match_mode ? 40 | \ filter(self.histories(), 'v:val =~ cmdline') : self.histories()) 41 | endif 42 | endif 43 | call a:cmdline.setchar("") 44 | if a:cmdline.is_input("\") || a:cmdline.is_input("\") 45 | let s:count = max([s:count - 1, 0]) 46 | endif 47 | if a:cmdline.is_input("\") || a:cmdline.is_input("\") 48 | let s:count = min([s:count + 1, len(s:cmdhist)]) 49 | endif 50 | call a:cmdline.setline(get(s:cmdhist, s:count, a:cmdline.getline())) 51 | endfunction 52 | 53 | function! s:make(...) 54 | let module = deepcopy(s:module) 55 | let module.mode = get(a:, 1, "cmd") 56 | return module 57 | endfunction 58 | 59 | let &cpo = s:save_cpo 60 | unlet s:save_cpo 61 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/IgnoreRegexpBackwardWord.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | " Improved backward word detection which ignore regular expression 6 | let s:module = { 7 | \ "name" : "IgnoreRegexpBackwardWord" 8 | \} 9 | 10 | function! s:backward_word(str, ...) 11 | let pat = get(a:, 1, '\k\+\s*\|.') 12 | let flags = s:non_escaped_backslash . 13 | \ '\%(' . 'z[se]' . 14 | \ '\|' . '[iIkKfFpPsSdDxXoOwWhHaAlLuUetrbncCZmMvV]' . 15 | \ '\|' . '%[dxouUCVlcv]' . 16 | \ '\|' . "%'[a-zA-Z]" . 17 | \ '\|' . '%#=\d' . 18 | \ '\|' . 'z\=\d' . 19 | \ '\)' 20 | return matchstr(get(split(a:str, flags . '\s*\zs'), -1, ""), 21 | \ '\%(' . flags . '\s*\|' . pat . '\)$') 22 | endfunction 23 | 24 | 25 | let s:non_escaped_backslash = '\m\%(\%(^\|[^\\]\)\%(\\\\\)*\)\@<=\\' 26 | 27 | function! s:module.on_enter(cmdline) 28 | function! a:cmdline.backward_word(...) 29 | return call("s:backward_word", [self.backward()] + a:000) 30 | endfunction 31 | endfunction 32 | 33 | function! s:make() 34 | return deepcopy(s:module) 35 | endfunction 36 | 37 | 38 | let &cpo = s:save_cpo 39 | unlet s:save_cpo 40 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Incsearch.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:escape_regex(pattern) 7 | return substitute(a:pattern, '^\^', '\\_^', "") 8 | endfunction 9 | 10 | 11 | 12 | let s:module = { 13 | \ "name" : "Incsearch", 14 | \ "highlights" : { 15 | \ "incsearch" : "IncSearch" 16 | \ }, 17 | \ "pattern" : "", 18 | \ "search_flag" : "", 19 | \ "mode" : "", 20 | \} 21 | 22 | 23 | function! s:module.search_hl_off() 24 | if exists("self.search_hl_id") 25 | call matchdelete(self.search_hl_id) 26 | unlet self.search_hl_id 27 | endif 28 | endfunction 29 | 30 | 31 | function! s:module.search_hl_on(pattern) 32 | call self.search_hl_off() 33 | let self.search_hl_id = matchadd(self.highlights.incsearch, a:pattern) 34 | endfunction 35 | 36 | 37 | function! s:module.on_enter(...) 38 | let self.old_pos = getpos(".") 39 | endfunction 40 | 41 | 42 | function! s:module.on_leave(...) 43 | call setpos(".", self.old_pos) 44 | call self.search_hl_off() 45 | endfunction 46 | 47 | 48 | function! s:module.on_char(cmdline) 49 | call self.search_hl_off() 50 | let line = a:cmdline.getline() 51 | let result = get(matchlist(line, self.pattern), 1, "") 52 | if result != "" 53 | let pos = searchpos(result, self.search_flag) 54 | if pos == [0, 0] 55 | return 56 | endif 57 | call self.search_hl_on('\%' . pos[0] . 'l' . (&ignorecase ? '\c' : "") . s:escape_regex(result)) 58 | redraw 59 | endif 60 | endfunction 61 | 62 | 63 | function! s:make(...) 64 | let module = deepcopy(s:module) 65 | let module.mode = get(a:, 1, "/") 66 | let module.pattern = get(a:, 2, '^\(.\+\)') 67 | let module.search_flag = get(a:, 3, 'c') 68 | return module 69 | endfunction 70 | 71 | 72 | 73 | let &cpo = s:save_cpo 74 | unlet s:save_cpo 75 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/InsertRegister.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_vital_loaded(V) 7 | let s:V = a:V 8 | let s:String = s:V.import("Over.String") 9 | endfunction 10 | 11 | 12 | function! s:_vital_depends() 13 | return [ 14 | \ "Over.String", 15 | \ ] 16 | endfunction 17 | 18 | 19 | function! s:to_string(expr) 20 | return type(a:expr) == type("") ? a:expr : string(a:expr) 21 | endfunction 22 | 23 | 24 | function! s:input(cmdline) 25 | let CR_index = index(a:cmdline.input_key_stack(), "\") 26 | if CR_index != -1 27 | let input = a:cmdline.input_key_stack_string() 28 | let input = input[ : CR_index-1] 29 | call a:cmdline.set_input_key_stack(a:cmdline.input_key_stack()[CR_index+1 : ]) 30 | return eval(input) 31 | endif 32 | 33 | let input_text = "" 34 | if !empty(a:cmdline.input_key_stack()) 35 | let input_text = a:cmdline.input_key_stack_string() 36 | call a:cmdline.set_input_key_stack([]) 37 | endif 38 | 39 | call a:cmdline.hl_cursor_on() 40 | try 41 | redraw 42 | let input = input("=", input_text, "expression") 43 | if !empty(input) 44 | let input = s:to_string(eval(input)) 45 | endif 46 | catch 47 | return "" 48 | finally 49 | call a:cmdline.hl_cursor_off() 50 | endtry 51 | return input 52 | endfunction 53 | 54 | 55 | let s:module = { 56 | \ "name" : "InsertRegister" 57 | \} 58 | 59 | 60 | 61 | function! s:module.reset() 62 | let self.cword = expand("") 63 | let self.cWORD = expand("") 64 | let self.cfile = expand("") 65 | endfunction 66 | 67 | function! s:module.on_enter(...) 68 | call self.reset() 69 | " let self.prefix_key = "" 70 | endfunction 71 | 72 | 73 | function! s:get_cmdline_cword(backward, cword) 74 | " let backward = matchstr(a:backward, '.\{-}\zs\k\+$') 75 | let backward = a:backward 76 | if &incsearch == 0 || a:cword == "" || a:backward == "" || s:String.index(a:cword, backward) != 0 77 | return a:cword 78 | endif 79 | return a:cword[len(backward) : ] 80 | endfunction 81 | 82 | 83 | function! s:module.on_char_pre(cmdline) 84 | if a:cmdline.is_input("\") 85 | call a:cmdline.setchar('"') 86 | let self.prefix_key = a:cmdline.input_key() 87 | let self.old_line = a:cmdline.getline() 88 | let self.old_pos = a:cmdline.getpos() 89 | return 90 | elseif exists("self.prefix_key") 91 | \ && a:cmdline.get_tap_key() == self.prefix_key 92 | call a:cmdline.setline(self.old_line) 93 | call a:cmdline.setpos(self.old_pos) 94 | let char = a:cmdline.input_key() 95 | if char =~ '^[0-9a-zA-z.%#:/"\-*+]$' 96 | let register = tr(getreg(char), "\n", "\r") 97 | call a:cmdline.setchar(register) 98 | elseif char == "=" 99 | call a:cmdline.setchar(s:input(a:cmdline)) 100 | elseif char == "\" 101 | call a:cmdline.setchar(s:get_cmdline_cword(a:cmdline.backward_word(), self.cword)) 102 | elseif char == "\" 103 | call a:cmdline.setchar(self.cWORD) 104 | elseif char == "\" 105 | call a:cmdline.setchar(self.cfile) 106 | elseif char == "\" 107 | call a:cmdline.setchar('"') 108 | else 109 | call a:cmdline.setchar("") 110 | endif 111 | " elseif a:cmdline.is_input('=', self.prefix_key) 112 | " call a:cmdline.setchar(s:input(a:cmdline)) 113 | " elseif a:cmdline.is_input("\", self.prefix_key) 114 | " call a:cmdline.setchar(self.cword) 115 | " elseif a:cmdline.is_input("\", self.prefix_key) 116 | " call a:cmdline.setchar(self.cWORD) 117 | " elseif a:cmdline.is_input("\", self.prefix_key) 118 | " call a:cmdline.setchar(self.cfile) 119 | " elseif a:cmdline.is_input("\", self.prefix_key) 120 | " call a:cmdline.setchar('"') 121 | " else 122 | " call a:cmdline.setchar("") 123 | " endif 124 | endif 125 | endfunction 126 | 127 | 128 | function! s:module.on_char(cmdline) 129 | if a:cmdline.is_input("\") 130 | call a:cmdline.tap_keyinput(self.prefix_key) 131 | call a:cmdline.disable_keymapping() 132 | call a:cmdline.setpos(a:cmdline.getpos()-1) 133 | else 134 | if exists("self.prefix_key") 135 | call a:cmdline.untap_keyinput(self.prefix_key) 136 | call a:cmdline.enable_keymapping() 137 | unlet! self.prefix_key 138 | endif 139 | endif 140 | endfunction 141 | 142 | 143 | 144 | function! s:make() 145 | return deepcopy(s:module) 146 | endfunction 147 | 148 | let &cpo = s:save_cpo 149 | unlet s:save_cpo 150 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/KeyMapping.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_vital_loaded(V) 7 | let s:Keymapping = a:V.import("Palette.Keymapping") 8 | endfunction 9 | 10 | 11 | function! s:_vital_depends() 12 | return [ 13 | \ "Palette.Keymapping", 14 | \ ] 15 | endfunction 16 | 17 | 18 | let s:emacs = { 19 | \ "name" : "KeyMapping_emacs_like" 20 | \} 21 | 22 | function! s:emacs.keymapping(cmdline) 23 | return { 24 | \ "\" : { 25 | \ "key" : "\", 26 | \ "noremap" : 1, 27 | \ "lock" : 1, 28 | \ }, 29 | \ "\" : { 30 | \ "key" : "\", 31 | \ "noremap" : 1, 32 | \ "lock" : 1, 33 | \ }, 34 | \ "\" : { 35 | \ "key" : "\", 36 | \ "noremap" : 1, 37 | \ "lock" : 1, 38 | \ }, 39 | \ "\" : { 40 | \ "key" : "\", 41 | \ "noremap" : 1, 42 | \ "lock" : 1, 43 | \ }, 44 | \ "\" : { 45 | \ "key" : "\", 46 | \ "noremap" : 1, 47 | \ "lock" : 1, 48 | \ }, 49 | \ "\" : { 50 | \ "key" : "\", 51 | \ "noremap" : 1, 52 | \ "lock" : 1, 53 | \ }, 54 | \ "\" : { 55 | \ "key" : "\", 56 | \ "noremap" : 1, 57 | \ "lock" : 1, 58 | \ }, 59 | \ "\" : { 60 | \ "key" : "\", 61 | \ "noremap" : 1, 62 | \ "lock" : 1, 63 | \ }, 64 | \ "\" : { 65 | \ "key" : "\", 66 | \ "noremap" : 1, 67 | \ "lock" : 1, 68 | \ }, 69 | \ "\" : { 70 | \ "key" : "\", 71 | \ "noremap" : 1, 72 | \ "lock" : 1, 73 | \ }, 74 | \ } 75 | endfunction 76 | 77 | 78 | function! s:make_emacs() 79 | return deepcopy(s:emacs) 80 | endfunction 81 | 82 | 83 | let s:vim_cmdline_mapping = { 84 | \ "name" : "KeyMapping_vim_cmdline_mapping", 85 | \ "_cmaps" : {} 86 | \} 87 | 88 | function! s:_convert_sid(rhs, sid) abort 89 | return substitute(a:rhs, '', '' . a:sid . '_', 'g') 90 | endfunction 91 | 92 | function! s:_auto_cmap() 93 | let cmaps = {} 94 | let cmap_info = s:Keymapping.rhs_key_list("c", 0, 1) 95 | " vital-over currently doesn't support mappings 96 | for c in filter(cmap_info, "v:val['buffer'] ==# 0") 97 | let cmaps[s:Keymapping.escape_special_key(c['lhs'])] = { 98 | \ 'noremap' : c['noremap'], 99 | \ 'key' : s:Keymapping.escape_special_key(s:_convert_sid(c['rhs'], c['sid'])), 100 | \ 'expr' : s:Keymapping.escape_special_key(c['expr']), 101 | \ } 102 | endfor 103 | return cmaps 104 | endfunction 105 | 106 | 107 | function! s:vim_cmdline_mapping.on_enter(cmdline) 108 | let self._cmaps = s:_auto_cmap() 109 | if exists("*execute") 110 | let self._old_cmap = execute("cmap") 111 | endif 112 | endfunction 113 | 114 | 115 | function! s:vim_cmdline_mapping.on_update(cmdline) 116 | if !exists("*execute") 117 | return 118 | endif 119 | 120 | let cmap_ = execute("cmap") 121 | if self._old_cmap != cmap_ 122 | let self._cmaps = s:_auto_cmap() 123 | let self._old_cmap = cmap_ 124 | endif 125 | endfunction 126 | 127 | 128 | function! s:vim_cmdline_mapping.keymapping(cmdline) 129 | return self._cmaps 130 | endfunction 131 | 132 | 133 | function! s:make_vim_cmdline_mapping() 134 | return deepcopy(s:vim_cmdline_mapping) 135 | endfunction 136 | 137 | 138 | 139 | let &cpo = s:save_cpo 140 | unlet s:save_cpo 141 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/LiteralInsert.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:module = { 7 | \ "name" : "LiteralInsert", 8 | \} 9 | 10 | function! s:module.on_char_pre(cmdline) 11 | if a:cmdline.is_input("\") 12 | \ || a:cmdline.is_input("\") 13 | let old_line = a:cmdline.getline() 14 | let old_pos = a:cmdline.getpos() 15 | call a:cmdline.insert('^') 16 | call a:cmdline.setpos(old_pos) 17 | call a:cmdline.draw() 18 | let char = a:cmdline.getchar() 19 | call a:cmdline.setline(old_line) 20 | call a:cmdline.setpos(old_pos) 21 | call a:cmdline.setchar(char) 22 | endif 23 | endfunction 24 | 25 | function! s:make() 26 | return deepcopy(s:module) 27 | endfunction 28 | 29 | let &cpo = s:save_cpo 30 | unlet s:save_cpo 31 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/NoInsert.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | let s:module = { 6 | \ "name" : "NoInsert", 7 | \ "chars" : [] 8 | \} 9 | 10 | 11 | function! s:module.is_no_insert(char) 12 | return index(self.chars, a:char) >= 0 13 | endfunction 14 | 15 | 16 | function! s:module.on_char_pre(cmdline) 17 | if self.is_no_insert(a:cmdline.char()) 18 | call a:cmdline.setchar("", 0) 19 | endif 20 | endfunction 21 | 22 | 23 | function! s:make(chars) 24 | let module = deepcopy(s:module) 25 | let module.chars = type(a:chars) == type([]) ? a:chars : [a:chars] 26 | return module 27 | endfunction 28 | 29 | 30 | function! s:make_special_chars() 31 | let module = s:make([]) 32 | function! module.is_no_insert(char) 33 | return char2nr(a:char) == 128 || char2nr(a:char) < 27 34 | endfunction 35 | return module 36 | endfunction 37 | 38 | 39 | let &cpo = s:save_cpo 40 | unlet s:save_cpo 41 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Paste.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:module = { 7 | \ "name" : "Paste" 8 | \} 9 | 10 | function! s:module.on_char_pre(cmdline) 11 | if a:cmdline.is_input("(paste)") 12 | let register = v:register == "" ? '"' : v:register 13 | call a:cmdline.insert(tr(getreg("*"), "\n", "\r")) 14 | call a:cmdline.setchar('') 15 | endif 16 | endfunction 17 | 18 | 19 | function! s:make() 20 | return deepcopy(s:module) 21 | endfunction 22 | 23 | 24 | let &cpo = s:save_cpo 25 | unlet s:save_cpo 26 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Redraw.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:module = { 7 | \ "name" : "Redraw", 8 | \} 9 | 10 | function! s:module.on_execute_pre(cmdline) 11 | call self.redraw(a:cmdline) 12 | endfunction 13 | 14 | function! s:module.on_enter(...) 15 | let self.is_execute = 0 16 | endfunction 17 | 18 | function! s:module.on_execute(...) 19 | let self.is_execute = 1 20 | endfunction 21 | 22 | function! s:module.on_execute_failed(...) 23 | let self.is_execute = 0 24 | endfunction 25 | 26 | function! s:module.on_leave(cmdline) 27 | if self.is_execute == 0 && a:cmdline.exit_code() != -1 28 | call self.redraw(a:cmdline) 29 | endif 30 | endfunction 31 | 32 | 33 | " function! s:module.on_draw_pre(cmdline) 34 | " call self.redraw(a:cmdline) 35 | " endfunction 36 | 37 | 38 | function! s:module.redraw(cmdline) 39 | redraw 40 | " Workaround for the :set cedit= 41 | " https://github.com/osyo-manga/vital-over/issues/52 42 | " https://github.com/Lokaltog/vim-easymotion/issues/177#issuecomment-53663431 43 | if &cedit != "" 44 | \ ||(v:version > 704 || v:version == 704 && has("patch441")) 45 | normal! : 46 | else 47 | execute "normal! :\" 48 | endif 49 | endfunction 50 | 51 | function! s:make() 52 | return deepcopy(s:module) 53 | endfunction 54 | 55 | 56 | let &cpo = s:save_cpo 57 | unlet s:save_cpo 58 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Commandline/Modules/Scroll.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:module = { 7 | \ "name" : "Scroll" 8 | \} 9 | function! s:module.on_char_pre(cmdline) 10 | if a:cmdline.is_input("(scroll-y)") 11 | execute "normal! \" 12 | call a:cmdline.setchar('') 13 | elseif a:cmdline.is_input("(scroll-u)") 14 | execute "normal! \" 15 | call a:cmdline.setchar('') 16 | elseif a:cmdline.is_input("(scroll-f)") 17 | execute "normal! \" 18 | call a:cmdline.setchar('') 19 | elseif a:cmdline.is_input("(scroll-e)") 20 | execute "normal! \" 21 | call a:cmdline.setchar('') 22 | elseif a:cmdline.is_input("(scroll-d)") 23 | execute "normal! \" 24 | call a:cmdline.setchar('') 25 | elseif a:cmdline.is_input("(scroll-b)") 26 | execute "normal! \" 27 | call a:cmdline.setchar('') 28 | endif 29 | endfunction 30 | 31 | 32 | function! s:make() 33 | return deepcopy(s:module) 34 | endfunction 35 | 36 | let &cpo = s:save_cpo 37 | unlet s:save_cpo 38 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Exception.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | let s:vname = expand(":h:h:t") 7 | let s:prefix = printf("vital-over(%s) Exception", s:vname) 8 | 9 | function! s:set_prefix(prefix) 10 | let s:prefix = a:prefix 11 | endfunction 12 | 13 | function! s:throw_cmd(exp, where) 14 | return 'throw ' . string(s:prefix . " : " . a:exp . " in " . a:where) 15 | endfunction 16 | 17 | 18 | function! s:throw(exp, where) 19 | execute s:throw_cmd(a:exp, a:where) 20 | endfunction 21 | 22 | 23 | function! s:error(text, where) 24 | echohl ErrorMsg 25 | echom s:prefix . " : " . a:text . " in " . a:where 26 | echohl None 27 | endfunction 28 | 29 | 30 | let &cpo = s:save_cpo 31 | unlet s:save_cpo 32 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Input.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:getchar(...) 7 | let mode = get(a:, 1, 0) 8 | while 1 9 | " Workaround for https://github.com/osyo-manga/vital-over/issues/53 10 | try 11 | let char = call("getchar", a:000) 12 | catch /^Vim:Interrupt$/ 13 | let char = 3 " 14 | endtry 15 | " Workaround for the mappings 16 | if string(char) !=# "\x80\xfd`" 17 | return mode == 1 ? !!char 18 | \ : type(char) == type(0) ? nr2char(char) : char 19 | endif 20 | endwhile 21 | endfunction 22 | 23 | 24 | let &cpo = s:save_cpo 25 | unlet s:save_cpo 26 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Keymapping.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | 7 | function! s:_vital_loaded(V) 8 | let s:V = a:V 9 | let s:String = s:V.import("Over.String") 10 | endfunction 11 | 12 | 13 | function! s:_vital_depends() 14 | return [ 15 | \ "Over.String", 16 | \ ] 17 | endfunction 18 | 19 | 20 | function! s:as_key_config(config) 21 | let base = { 22 | \ "noremap" : 0, 23 | \ "lock" : 0, 24 | \ "expr" : 0, 25 | \ } 26 | return type(a:config) == type({}) ? extend(base, a:config) 27 | \ : extend(base, { 28 | \ "key" : a:config, 29 | \ }) 30 | endfunction 31 | 32 | 33 | function! s:match_key(keymapping, key) 34 | let keys = sort(keys(a:keymapping)) 35 | return get(filter(keys, 'stridx(a:key, v:val) == 0'), -1, '') 36 | endfunction 37 | 38 | 39 | function! s:_safe_eval(expr, ...) 40 | call extend(l:, get(a:, 1, {})) 41 | let result = get(a:, 2, "") 42 | try 43 | let result = eval(a:expr) 44 | catch 45 | echohl ErrorMsg | echom v:exception | echohl None 46 | endtry 47 | return result 48 | endfunction 49 | 50 | 51 | function! s:_get_key(conf) 52 | " call extend(l:, a:conf) 53 | let self = a:conf 54 | return get(a:conf, "expr", 0) ? s:_safe_eval(a:conf.key, l:) : a:conf.key 55 | endfunction 56 | 57 | 58 | function! s:unmapping(keymapping, key, ...) 59 | let is_locking = get(a:, 1, 0) 60 | let key = s:match_key(a:keymapping, a:key) 61 | if key == "" 62 | return s:String.length(a:key) <= 1 ? a:key : s:unmapping(a:keymapping, a:key[0], is_locking) . s:unmapping(a:keymapping, a:key[1:], is_locking) 63 | endif 64 | 65 | let map_conf = s:as_key_config(a:keymapping[key]) 66 | 67 | let next_input = s:unmapping(a:keymapping, a:key[len(key) : ], is_locking) 68 | if map_conf.lock == 0 && is_locking 69 | return key . next_input 70 | elseif map_conf.lock 71 | return s:unmapping(a:keymapping, s:_get_key(map_conf), is_locking) . next_input 72 | else 73 | return s:unmapping(a:keymapping, s:_get_key(map_conf), map_conf.noremap) . next_input 74 | endif 75 | endfunction 76 | 77 | 78 | 79 | let &cpo = s:save_cpo 80 | unlet s:save_cpo 81 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/Signals.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_vital_loaded(V) 7 | let s:V = a:V 8 | let s:L = s:V.import("Data.List") 9 | endfunction 10 | 11 | 12 | function! s:_vital_depends() 13 | return ["Data.List"] 14 | endfunction 15 | 16 | 17 | let s:base = { 18 | \ "variables" : { 19 | \ "slots" : [], 20 | \ "counter" : 0, 21 | \ } 22 | \} 23 | 24 | 25 | function! s:base.connect(slot) 26 | let self.variables.counter += 1 27 | let slot = { "id" : self.variables.counter, "slot" : a:slot } 28 | call add(self.variables.slots, slot) 29 | return slot 30 | endfunction 31 | 32 | 33 | function! s:base.disconnect(slot) 34 | if empty(a:slot) 35 | return -1 36 | endif 37 | for i in range(len(self.variables.slots)) 38 | if self.variables.slots[i].id == a:slot.id 39 | unlet self.variables.slots[i] 40 | return 41 | endif 42 | endfor 43 | return -1 44 | endfunction 45 | 46 | 47 | function! s:base.disconnect_by(expr) 48 | return self.disconnect(self.find_first_by(a:expr)) 49 | endfunction 50 | 51 | 52 | function! s:call(list, func, ...) 53 | let args = get(a:, 1, []) 54 | let def = get(a:, 2, 0) 55 | return map(copy(a:list), "has_key(v:val, a:func) ? call(v:val.".a:func.", args, v:val) : def") 56 | endfunction 57 | 58 | function! s:base.call(func, ...) 59 | return call("s:call", [self.slots(), a:func] + a:000) 60 | endfunction 61 | 62 | 63 | function! s:base.find_by(expr) 64 | return filter(copy(self.variables.slots), a:expr) 65 | endfunction 66 | 67 | 68 | function! s:base.find_first_by(expr) 69 | return get(self.find_by(a:expr), 0, {}) 70 | endfunction 71 | 72 | 73 | function! s:base.sort_by(expr) 74 | let self.variables.slots = s:L.sort_by(self.variables.slots, a:expr) 75 | endfunction 76 | 77 | 78 | function! s:base.get_slot(val) 79 | return a:val.slot 80 | endfunction 81 | 82 | 83 | function! s:base.slots() 84 | return map(copy(self.variables.slots), "self.get_slot(v:val)") 85 | endfunction 86 | 87 | 88 | " function! s:base.dict() 89 | " let result = {} 90 | " for _ in self.variables.slots 91 | " let result[_.id] = _.value 92 | " endfor 93 | " return result 94 | " endfunction 95 | 96 | 97 | function! s:make() 98 | let result = deepcopy(s:base) 99 | return result 100 | endfunction 101 | 102 | 103 | let &cpo = s:save_cpo 104 | unlet s:save_cpo 105 | -------------------------------------------------------------------------------- /autoload/vital/__latest__/Over/String.vim: -------------------------------------------------------------------------------- 1 | scriptencoding utf-8 2 | let s:save_cpo = &cpo 3 | set cpo&vim 4 | 5 | 6 | function! s:_vital_loaded(V) 7 | let s:V = a:V 8 | let s:List = s:V.import("Data.List") 9 | endfunction 10 | 11 | 12 | function! s:_vital_depends() 13 | return [ 14 | \ "Data.List", 15 | \ ] 16 | endfunction 17 | 18 | 19 | function! s:_clamp(x, max, min) 20 | return min([max([a:x, a:max]), a:min]) 21 | endfunction 22 | 23 | 24 | let s:base = {} 25 | 26 | function! s:base.set(item) 27 | return type(a:item) == type("") ? self.set_str(a:item) 28 | \ : type(a:item) == type(0) ? self.set_pos(a:item) 29 | \ : self 30 | endfunction 31 | 32 | function! s:base.str() 33 | return join(self.list, "") 34 | endfunction 35 | 36 | function! s:base.set_pos(pos) 37 | let self.col = s:_clamp(a:pos, 0, self.length()) 38 | return self 39 | endfunction 40 | 41 | function! s:base.backward() 42 | return self.col > 0 ? join(self.list[ : self.col-1], '') : "" 43 | endfunction 44 | 45 | function! s:base.forward() 46 | return join(self.list[self.col+1 : ], '') 47 | endfunction 48 | 49 | function! s:base.pos_char() 50 | return get(self.list, self.col, "") 51 | endfunction 52 | 53 | function! s:base.set_str(str) 54 | let self.list = split(a:str, '\zs') 55 | let self.col = strchars(a:str, 1) 56 | return self 57 | endfunction 58 | 59 | function! s:base.pos() 60 | return self.col 61 | endfunction 62 | 63 | function! s:base.input(str) 64 | call extend(self.list, split(a:str, '\zs'), self.col) 65 | let self.col += len(split(a:str, '\zs')) 66 | return self 67 | endfunction 68 | 69 | function! s:base.length() 70 | return len(self.list) 71 | endfunction 72 | 73 | function! s:base.next() 74 | return self.set_pos(self.col + 1) 75 | endfunction 76 | 77 | function! s:base.prev() 78 | return self.set_pos(self.col - 1) 79 | endfunction 80 | 81 | function! s:base.remove(index) 82 | if a:index < 0 || self.length() <= a:index 83 | return "" 84 | endif 85 | let result = self.list[a:index] 86 | unlet self.list[a:index] 87 | if a:index < self.col 88 | call self.set(self.col - 1) 89 | endif 90 | return result 91 | endfunction 92 | 93 | function! s:base.remove_pos() 94 | return self.remove(self.col) 95 | endfunction 96 | 97 | function! s:base.remove_prev() 98 | return self.remove(self.col - 1) 99 | endfunction 100 | 101 | function! s:base.remove_next() 102 | return self.remove(self.col + 1) 103 | endfunction 104 | 105 | 106 | function! s:make(...) 107 | let default = get(a:, 1, "") 108 | let result = deepcopy(s:base) 109 | call result.set(default) 110 | return result 111 | endfunction 112 | 113 | " NOTE: old regexpengine has a bug with string which contains binary 114 | " :echo "\x80" =~ "\\%#=1\x80" | " => 0 115 | " But it matches correctly with :h /collection 116 | " :echo "\x80" =~ "\\%#=1[\x80]" | " => 1 117 | " http://lingr.com/room/vim/archives/2015/02/13#message-21261450 118 | let s:_engine = exists("+regexpengine") ? '\%#=2' : '' 119 | " \ => Û\xfdQ 120 | " \ => À\xfeX 121 | let s:_regex = exists("+regexpengine") 122 | \ ? "\\%(Û\xfdQ\\|À\xfeX\\|\x80\xfc.\\%(\x80..\\|.\\)\\|\x80..\\|.\\)\\zs" 123 | \ : "\\%(Û[\xfd]Q\\|À[\xfe]X\\|[\x80][\xfc].\\%([\x80]..\\|.\\)\\|[\x80]..\\|.\\)\\zs" 124 | function! s:_split_keystring(str, ...) 125 | return split(a:str, s:_engine . '\m\%(' . get(a:, 1, '') . s:_regex . '\)') 126 | endfunction 127 | 128 | function! s:split_by_keys(str) 129 | return s:_split_keystring(a:str, "\\%(\\\|\\)(.\\{-})\\zs\\|") 130 | endfunction 131 | 132 | function! s:index(haystack, needle, ...) 133 | let start = get(a:, 1, 0) 134 | let ignorecase = get(a:, 2, &ignorecase) 135 | if ignorecase 136 | return stridx(tolower(a:haystack), tolower(a:needle), start) 137 | else 138 | return stridx(a:haystack, a:needle, start) 139 | endif 140 | endfunction 141 | 142 | 143 | function! s:length(str) 144 | return len(s:split_by_keys(a:str)) 145 | endfunction 146 | 147 | 148 | let &cpo = s:save_cpo 149 | unlet s:save_cpo 150 | -------------------------------------------------------------------------------- /doc/vital-over-commandline.jax: -------------------------------------------------------------------------------- 1 | *vital-over-commandline.txt* 独自コマンドラインを定義するフレームワーク 2 | 3 | ============================================================================== 4 | 目次 *vital-over-commandline-contents* 5 | 6 | インターフェース |Vital.Over.Commandline-interface| 7 | 関数 |Vital.Over.Commandline-functions| 8 | コマンドライン |Vital.Over.Commandline-object| 9 | キーマッピング |Vital.Over.Commandline-keymapping| 10 | モジュール |Vital.Over.Commandline-modules| 11 | 12 | 13 | ============================================================================== 14 | インターフェース *Vital.Over.Commandline-interface* 15 | 16 | ------------------------------------------------------------------------------ 17 | 関数 *Vital.Over.Commandline-functions* 18 | 19 | make_standard({prompt}) *Vital.Over.Commandline.make_standard()* 20 | 標準のコマンドラインの挙動に準じたコマンドラインオブジェクトを生成しま 21 | す。 22 | オブジェクトの内容は |Vital.Over.Commandline.object| を参照して下さ 23 | い。 24 | *Vital.Over.Commandline.make_standard_search()* 25 | make_standard_search({prompt}) 26 | 標準の検索コマンドラインの挙動に準じたコマンドラインオブジェクトを生成 27 | します。 28 | 前方検索します。 29 | 30 | *Vital.Over.Commandline.make_standard_search_back()* 31 | make_standard_search_back({prompt}) 32 | 標準の検索コマンドラインの挙動に準じたコマンドラインオブジェクトを生成 33 | します。 34 | 後方検索します。 35 | 36 | make_default({prompt}) *Vital.Over.Commandline.make_default()* 37 | |Vital.Over.Commandline.object| のオブジェクトを生成します。 38 | NOTE: この関数で生成したオブジェクトは何も行いません。 39 | キャンセルや実行などもできないので注意して下さい。 40 | 41 | get_module({name}) *Vital.Over.Commandline.get_module()* 42 | {name} の |Vital.Over.Commandline.modules| を取得します。 43 | 導入されていないモジュールは失敗します。 44 | 45 | make_module({name}[, {args...}]) *Vital.Over.Commandline.make_module()* 46 | {name} の |Vital.Over.Commandline.modules| を生成します。 47 | 導入されていないモジュールは失敗します。 48 | 49 | ============================================================================== 50 | コマンドライン *Vital.Over.Commandline-object* 51 | 52 | |Vital.Over.Commandline-make_standard()| 等で生成したオブジェクトが保持する関 53 | 数です。 54 | また、このオブジェクトは "_" + 英数字から始まる要素を定義しないことが保証され 55 | ています。 56 | このオブジェクトに対して、ユーザ側で変数や関数を定義したい場合は "_" + 英数字 57 | からはじまる名前を使うことを推奨します。 58 | NOTE https://github.com/osyo-manga/vital-over/issues/128 59 | > 60 | let cmdline = make_standard() 61 | " オブジェクトに変数を定義する場合は 62 | " let cmdline.my_value = 10 63 | " _ から始めることを推奨 64 | let cmdline._my_value = 10 65 | 66 | < 67 | 68 | CORE *Vital.Over.Commandline.object-core* 69 | 70 | object.getline() *Vital.Over.Commandline.object-getline()* 71 | コマンドラインの文字列を返します 72 | 73 | object.setline({line}) *Vital.Over.Commandline.object-setline()* 74 | コマンドラインに {line} を設定します 75 | 76 | object.char() *Vital.Over.Commandline.object-char()* 77 | 入力された文字を返します 78 | 79 | object.setchar({char}) *Vital.Over.Commandline.object-setchar()* 80 | コマンドラインに挿入される文字{char}を設定します 81 | コマンドラインに文字を挿入したくない場合は空の文字を設定して下さい 82 | 83 | object.getpos() *Vital.Over.Commandline.object-getpos()* 84 | コマンドラインのカーソル位置を返します 85 | 86 | object.setpos({col}) *Vital.Over.Commandline.object-setpos()* 87 | コマンドラインのカーソル位置を {col} 設定します 88 | 89 | object.is_input({key}) *Vital.Over.Commandline.object-input()* 90 | {key} が入力されたかどうかを判定します。 91 | 入力されたかどうかの判定は char() と比較するのではなくて is_input() を 92 | 使用して下さい。 93 | Example: > 94 | " a が押されたら a が変える 95 | is_input("a") 96 | 97 | " が押されたら 1 が変える 98 | is_input("\") 99 | < 100 | 101 | object.forward() *Vital.Over.Commandline.object-forward()* 102 | カーソル位置より前方のコマンドラインの文字列を返します。 103 | カーソル上の文字は含みません。 104 | 105 | object.backward() *Vital.Over.Commandline.object-backward()* 106 | カーソル位置より後方のコマンドラインの文字列を返します。 107 | カーソル上の文字を含みます。 108 | 109 | object.connect({module} [, {name}]) *Vital.Over.Commandline.object-connect()* 110 | {name} という名前の {module} を追加します。 111 | {module} はモジュールの実装を記述した辞書になります。 112 | {name} は disconnect() 時に使用されます。 113 | {name} がなければ {module} の "name" キーの値が使用されます。 114 | また、{module} が文字列の場合はその名前のモジュールが追加されます。 115 | Example: > 116 | " コマンドラインのオブジェクトを生成 117 | let s:my = s:cmdline.make_plain("$ ") 118 | 119 | 120 | " 使用したいモジュールを追加 121 | " get_module() でモジュールを取得できる 122 | call s:my.connect(s:cmdline.get_module("Scroll").make()) 123 | 124 | " 直接名前をしていする事も可能 125 | " この場合は 126 | " s:cmdline.get_module("CursorMove").make() 127 | " と同等 128 | call s:my.connect("CursorMove") 129 | < 130 | 131 | 132 | object.disconnect({name}) *Vital.Over.Commandline.object-disconnect()* 133 | {name} のモジュールを削除します。 134 | 135 | object.start([{string}]) *Vital.Over.Commandline.object-start()* 136 | コマンドラインの入力を開始します。 137 | コマンドラインが正常終了した場合、入力した文字列を |:execute| で実行し 138 | ます。 139 | {string} を指定した場合,{string}が入力された状態で開始します. 140 | 141 | object.get([{string}]) *Vital.Over.Commandline.object-get()* 142 | コマンドラインの入力を開始します。 143 | |Vital.Over.Commandline.object-start()| とは違い入力されたコマンドは実 144 | 行されません。 145 | コマンドラインが正常終了した場合に入力された文字列を返します。 146 | 異常終了した場合は空の文字列を返します。 147 | {string} を指定した場合,{string}が入力された状態で開始します. 148 | 149 | 150 | object.exit([{exitcode}]) *Vital.Over.Commandline.object-exit()* 151 | コマンドラインを終了します。 152 | {exitcode} は exit_code() が返す値になります。 153 | 引数がなければ 0 が設定されます。 154 | 155 | object.exit_code() *Vital.Over.Commandline.object-exit_code()* 156 | 終了コードを返します。 157 | 0 : 正常終了 158 | 0 以外 : 異常終了(e.g. で終了した場合) 159 | 160 | object.is_exit() *Vital.Over.Commandline.object-is_exit()* 161 | いずれかのタイミングでコマンドラインが終了していた時に 1 が返ってきま 162 | す。 163 | それ以外は 0 が返ってきます。 164 | 165 | object.cmap({lhs}, {rhs}) *Vital.Over.Commandline.object-cmap()* 166 | {lhs} に {rhs} のキーを割り当てます。 167 | Example: > 168 | call s:my.cmap("\", "\") 169 | call s:my.cmap("\", "\") 170 | < 171 | NOTE: {rhs} には複数の文字も設定できるが一部特殊文字が含まれている場 172 | 合は |NFA| が組み込まれている必要がある 173 | Example: > 174 | " 1文字ならば問題ない 175 | call s:my.cmap("\", "\") 176 | call s:my.cmap("\", "\") 177 | 178 | " 複数の文字は NFA が使用できる場合のみ機能する 179 | call s:my.cmap("\", "\\") 180 | call s:my.cmap("\", "\\") 181 | < 182 | 183 | 184 | object.cnoremap({lhs}, {rhs}) *Vital.Over.Commandline.object-cnoremap()* 185 | {lhs} に {rhs} のキーを割り当てます。 186 | cmap() とは違い再マップされません。 187 | 188 | object.cunmap({lhs}) *Vital.Over.Commandline.object-cunmap()* 189 | {lhs} に割り当てられたキーマップを削除します。 190 | 191 | 192 | object.set_prompt({string}) *Vital.Over.Commandline.object-set_prompt()* 193 | プロンプトに {string} を設定します。 194 | 195 | object.get_prompt() *Vital.Over.Commandline.object-get_prompt()* 196 | 現在のプロンプトの文字列を返します。 197 | 198 | object.enable_keymapping() *Vital.Over.Commandline.object-enable_keymapping()* 199 | キーマッピングを有効にします。 200 | コマンドラインを開始した時に自動的に有効になります。 201 | 202 | object.disable_keymapping() *Vital.Over.Commandline.object-disable_keymapping()* 203 | キーマッピングを無効にします。 204 | コマンドラインの開始時にキーマッピングを無効にしたい場合は、 205 | |Vital.Over.Commandline.object-on_enter()| 206 | でこの関数を呼ぶ必要があります。 207 | 208 | *Vital.Over.Commandline.object-is_enable_keymapping()* 209 | object.is_enable_keymapping() 210 | キーマッピングが有効なら 1 を返し、無効なら 0 を返します。 211 | 212 | object.getchar() *Vital.Over.Commandline.object-getchar()* 213 | |getchar()| と同等ですが、スタックにキーが積まれていればそちらを優先 214 | して使用します。 215 | 216 | object.execute([{cmd}]) *Vital.Over.Commandline.object-execute()* 217 | {cmd} の実行を行ないます。 218 | {cmd} が渡されなかった時は現在入力されている文字列が使用されます。 219 | この関数が呼ばれた時に 220 | |Vital.Over.Commandline.object-on_execute()| 等が呼ばれます。 221 | また、この時のコマンドの実行方法は 222 | |Vital.Over.Commandline.object-__execute__()| に依存します。 223 | デフォルトでは |:execute| が呼び出されます。 224 | 225 | 226 | CALLBACK *Vital.Over.Commandline.object-callback* 227 | 228 | object.priority({event}) *Vital.Over.Commandline.object-priority()* 229 | {event} 時に処理される優先順位を返します。 230 | 返す数値が低いほうが先に処理されます。 231 | 232 | object.on_enter({self}) *Vital.Over.Commandline.object-on_enter()* 233 | コマンドラインが開始された時に呼ばれる関数です。 234 | 235 | object.on_leave({self}) *Vital.Over.Commandline.object-on_leave()* 236 | コマンドラインが終了された時に呼ばれる関数です 237 | 238 | object.on_char_pre({self}) *Vital.Over.Commandline.object-on_char_pre()* 239 | コマンドラインで文字が入力され、コマンドラインに挿入される前に呼ばれる 240 | 関数です 241 | 242 | object.on_char({self}) *Vital.Over.Commandline.object-on_char()* 243 | コマンドラインで文字が入力され、コマンドラインに挿入された後に呼ばれる 244 | 関数です。 245 | 246 | object.on_execute_pre({self}) *Vital.Over.Commandline.object-on_execute_pre()* 247 | コマンドラインでコマンドが実行される直前に呼ばれる関数です。 248 | コマンドラインが空でも呼ばれます。 249 | 250 | object.on_execute({self}) *Vital.Over.Commandline.object-on_execute()* 251 | コマンドラインでコマンドが実行された後に呼ばれる関数です。 252 | コマンドラインが空でも呼ばれます。 253 | *Vital.Over.Commandline.object-on_execute_failed()* 254 | object.on_execute_failed({self}) 255 | コマンドラインでコマンドを実行し、失敗した時に呼ばれる関数です。 256 | コマンドラインが空でも呼ばれます。 257 | *Vital.Over.Commandline.object-on_update()* 258 | object.on_update({self}) 259 | キー入力の処理を行う直前に呼ばれる関数です。 260 | 261 | 262 | OVERRIDE *Vital.Over.Commandline.object-override* 263 | ユーザ側で定義することで処理を変更するための関数です 264 | 265 | *Vital.Over.Commandline.object-__execute__()* 266 | object.__execute__({command}) 267 | 入力確定時に {command} を実行する関数です。 268 | デフォルトでは {command} を |:execute| します。 269 | 270 | *Vital.Over.Commandline.object-__keymapping__()* 271 | object.__keymapping__() 272 | キーマッピングの辞書を返します。 273 | *Vital.Over.Commandline.object-keymapping()* 274 | 以前の名前は keymapping() 275 | 276 | 277 | ============================================================================== 278 | キーマッピング *Vital.Over.Commandline-keymapping* 279 | 280 | コマンドライン上での独自のキーマッピングを cmap()/cnoremap()、もしくは辞書で定 281 | 義することができます。 282 | 283 | Example: > 284 | let s:cmdline = vital#of("vital").import("Over.Commandline") 285 | let s:my = s:cmdline.make_standard("$ ") 286 | 287 | " カーソル移動を別のキーに割り当てる 288 | call s:my.cnoremap("\", "\") 289 | call s:my.cnoremap("\", "\") 290 | call s:my.cnoremap("\", "(scroll-e)") 291 | call s:my.cnoremap("\", "(scroll-y)") 292 | 293 | " レジスタ "+" の挿入 294 | call s:my.cnoremap("\", "\+") 295 | 296 | 297 | 298 | 定義した辞書は各コマンドラインの |Vital.Over.Commandline-object-keymapping()| 299 | で返すことでそのコマンドラインに反映されます。 300 | 以下のように辞書を使用する場合はキーに {lrh} を値に {rhs} を設定します。 301 | 302 | Example: > 303 | let s:cmdline = vital#of("vital").import("Over.Commandline") 304 | let s:my = s:cmdline.make_standard("$ ") 305 | 306 | " キーマッピングを設定する 307 | function! s:my.keymapping() 308 | " 309 | " を割り当てる 310 | return { 311 | \ "\" : "\", 312 | \ "\" : "\", 313 | \ } 314 | endfunction 315 | < 316 | 317 | また、再マップされないようにする場合は次のように {rhs} に辞書を設定して下さ 318 | い。 319 | 320 | Example: > 321 | function! s:my.keymapping() 322 | " は再マップされない 323 | return { 324 | \ "\" : { 325 | \ "key" : "\", 326 | \ "noremap" : 1, 327 | \ }, 328 | \ "\" : "\", 329 | \ "\" : "\", 330 | \ } 331 | endfunction 332 | < 333 | 334 | 335 | また、キーマッピングの優先順位は次のようになります。 336 | 337 | 1.コマンドラインオブジェクトのkeymapping() 338 | 2.コマンドラインオブジェクトの cmap()/cnoremap() で追加されたキーマップ 339 | 3.各モジュールで定義されているキーマップ 340 | 341 | 上から順に優先順位が高いです。 342 | 343 | 344 | ============================================================================== 345 | モジュール *Vital.Over.Commandline-modules* 346 | 347 | |Vital.Over.Commandline-object| はモジュールを追加する事でその機能を拡張する事 348 | ができます。 349 | これは以下のように利用することができます。 350 | 351 | Example: > 352 | let s:V = vital#of("vital") 353 | let s:cmdline = s:V.import("Over.Commandline") 354 | 355 | 356 | " コマンドラインのオブジェクトを生成 357 | let s:my = s:cmdline.make_plain("$ ") 358 | 359 | 360 | " 使用したいモジュールを追加 361 | " 使用したいモジュールを追加 362 | " get_module() でモジュールを取得できる 363 | call s:my.connect(s:cmdline.get_module("Scroll").make()) 364 | 365 | " 直接名前をしていする事も可能 366 | " この場合は 367 | " s:cmdline.get_module("CursorMove").make() 368 | " と同等 369 | call s:my.connect("CursorMove") 370 | < 371 | 特に記述がない限りは make() を使用してそのモジュールを生成します。 372 | また、 から始まるキーは任意のキーに割り当てて使用します。 373 | 374 | 375 | 名前 機能~ 376 | BufferComplete 起動したバッファのワードで補完 377 | Cancel(*) コマンドラインの中断 378 | CursorMove(*) カーソル移動 379 | Delete(*) 文字の削除 380 | Execute(*) コマンドの実行 381 | HistAdd(*) |history| への追加 382 | History(*) コマンド履歴の呼び出し 383 | Incsearch |incsearch| のような挙動のエミュレート 384 | KeyMapping キーマッピングの提供 385 | NoInsert(*) 挿入しない文字の処理 386 | Paste @* の挿入 387 | Scroll 起動したウィンドウのスクロール 388 | InsertRegister(*) レジスタの内容を挿入 389 | Doautocmd |User| の呼び出し 390 | IgnoreRegexpBackwardWord カーソル前の単語の検出で正規表現を無視 391 | Digraphs |digraph| 機能 392 | 393 | (*) が付いているモジュールは Over.Commandline に付属します。 394 | それ以外のモジュールは |:Vitalize| 時に個別に指定して導入する必要があります。 395 | 396 | 397 | BufferComplete *Vital.Over.Commandline-modules-BufferComplete* 398 | 起動したバッファ上の単語で補完を行います。 399 | 400 | *Vital.Over.Commandline-modules-BufferComplete-keymapping* 401 | キー 機能~ 402 | (buffer-complete) 補完の開始 403 | 次の補完へ移動 404 | (buffer-complete-prev) 補完の開始 405 | 前の補完へ移動 406 | 補完中であれば次の補完へ移動 407 | 補完中であれば前の補完へ移動 408 | 409 | Cancel *Vital.Over.Commandline-modules-Cancel* 410 | コマンドラインの入力を中断します。 411 | このモジュールで終了した場合は終了コードが 1 になります。 412 | 413 | *Vital.Over.Commandline-modules-Cancel-keymapping* 414 | キー 機能~ 415 | , 入力を中断 416 | , 入力された文字がない場合に中断 417 | 418 | CursorMove *Vital.Over.Commandline-modules-CursorMove* 419 | カーソル移動を行います。 420 | *Vital.Over.Commandline-modules-CursorMove-keymapping* 421 | キー 機能~ 422 | カーソルを右に移動 423 | カーソルを右に移動 424 | , カーソルを行頭へ移動 425 | , カーソルを行末へ移動 426 | , カーソルを 1WORD 分左へ移動 427 | , カーソルを 1WORD 分右へ移動 428 | 429 | Delete *Vital.Over.Commandline-modules-Delete* 430 | 入力された文字の削除を行います。 431 | *Vital.Over.Commandline-modules-Delete-keymapping* 432 | キー 機能~ 433 | , カーソル位置より後ろの1文字を削除 434 | カーソル位置より後ろの単語を削除 435 | カーソル位置より後ろの文字を全て削除 436 | カーソル位置上の文字を削除 437 | 438 | Execute *Vital.Over.Commandline-modules-Execute* 439 | |Vital.Over.Commandline.object-execute()| を呼び出し、コマンドの実行を 440 | 行ないます。 441 | *Vital.Over.Commandline-modules-Execute-keymapping* 442 | キー 機能~ 443 | , , 入力されているコマンドを実行し、コマンドライン 444 | を終了する 445 | (execute-no-exit) 入力されているコマンドを実行。コマンドラインは 446 | 終了しません。 447 | 448 | Exit *Vital.Over.Commandline-modules-Exit* 449 | コマンドラインを終了します。 450 | *Vital.Over.Commandline-modules-Exit-keymapping* 451 | キー 機能~ 452 | (exit) コマンドラインを終了します。 453 | 454 | HistAdd *Vital.Over.Commandline-modules-HistAdd* 455 | 入力された文字を履歴に追加します。 456 | *Vital.Over.Commandline-modules-HistAdd-function* 457 | make({mode}) 458 | {mode} に履歴を追加します。 459 | {mode} の値は |histadd()| と同じです。 460 | 461 | History *Vital.Over.Commandline-modules-History* 462 | コマンド履歴を挿入します。 463 | *Vital.Over.Commandline-modules-History-keymapping* 464 | キー 機能~ 465 | 前の履歴を挿入 466 | 次の履歴を挿入 467 | 468 | *Vital.Over.Commandline-modules-History-function* 469 | make({mode}) 470 | {mode} の履歴を挿入します。 471 | {mode} の値は |histadd()| と同じです。 472 | 473 | KeyMapping *Vital.Over.Commandline-modules-KeyMapping* 474 | キーマッピングを提供します。 475 | *Vital.Over.Commandline-modules-KeyMapping-function* 476 | make_emacs() 477 | Emacs のようなキーマッピングを提供します。 478 | make_vim_cmdline_mapping() 479 | Vimデフォルトの |:cmap|, |:cnoremap| で定義されたマッピングを展開 480 | して適用したキーマッピングを提供します。 481 | 482 | NoInsert *Vital.Over.Commandline-modules-NoInsert* 483 | 挿入しない文字を設定します。 484 | また、挿入を行わないだけでキーの入力チェックは行われます。 485 | *Vital.Over.Commandline-modules-NoInsert-function* 486 | make_special_chars() 487 | 特殊文字を挿入しない。 488 | 489 | Scroll *Vital.Over.Commandline-modules-Scroll* 490 | 起動したバッファのウィンドウをスクロールします。 491 | *Vital.Over.Commandline-modules-Scroll-keymapping* 492 | キー 機能~ 493 | (scroll-y) |CTRL-y| と同等 494 | (scroll-u) |CTRL-u| と同等 495 | (scroll-f) |CTRL-f| と同等 496 | (scroll-e) |CTRL-e| と同等 497 | (scroll-d) |CTRL-d| と同等 498 | (scroll-b) |CTRL-b| と同等 499 | 500 | InsertRegister *Vital.Over.Commandline-modules-InsertRegister* 501 | レジスタの内容を挿入します。 502 | *Vital.Over.Commandline-modules-InsertRegister-keymapping* 503 | キー 機能~ 504 | {0-9a-z"%#:-=.} レジスタの内容を挿入 |c_CTRL-R| 505 | カーソル下のファイル名 506 | カーソル下の word 507 | カーソル下の WORD 508 | 509 | Doautocmd *Vital.Over.Commandline-modules-Doautocmd* 510 | 以下のタイミングで |autocm| |User| を呼び出します。 511 | 実際には make({prefix}) の {prefix} 文字が先頭に追加されます。 512 | *Vital.Over.Commandline-modules-Doautocmd-autocmd* 513 | 名前 発生するとき ~ 514 | Enter コマンドラインが開始された時 515 | Leave コマンドラインが終了した時 516 | CharPre 文字が入力され、コマンドラインに挿入される前 517 | Char 文字が入力され、コマンドラインに挿入された後 518 | ExecutePre コマンドが実行される直前 519 | Execute コマンドが実行された後 520 | ExecuteFailed コマンドを実行し、失敗した時 521 | 522 | *Vital.Over.Commandline-modules-Doautocmd-function* 523 | make({prefix}) 524 | {prefix} を追加した |autocm| |User| を呼び出します。 525 | Example: > 526 | let s:V= vital#of("vital") 527 | let s:cmdline = s:V.import("Over.Commandline") 528 | let s:my = s:cmdline.make_plain("$ ") 529 | 530 | call s:my.connect(s:cmdline.get_module("Doautocmd").make("MyCmdline")) 531 | 532 | augroup test 533 | autocmd! 534 | " コマンドラインの起動時にプロンプトを変更する 535 | autocmd User MyCmdlineEnter let s:my.prompt = "homu >" 536 | augroup END 537 | < 538 | 539 | Redraw *Vital.Over.Commandline-modules-Redraw* 540 | コマンドラインの再描画を行います。 541 | 542 | DrawCommandline *Vital.Over.Commandline-modules-DrawCommandline* 543 | コマンドラインへ描画します。 544 | 545 | ExceptionExit *Vital.Over.Commandline-modules-ExceptionExit* 546 | いずれかのタイミングで例外が発生した場合に中断します。 547 | 548 | ExceptionMessage *Vital.Over.Commandline-modules-ExceptionMessage* 549 | 発生した例外の内容を出力します。 550 | 551 | IgnoreRegexpBackwardWord 552 | *Vital.Over.Commandline-modules-IgnoreRegexpBackwardWord* 553 | |Vital.Over.Commandline-modules-Delete| モジュールにおける 554 | の単語の削除や, |Vital.Over.Commandline-modules-InsertRegister| 555 | における による単語の挿入時に使用する単語において正規表現を 556 | 無視するようにします。 557 | 558 | コマンドライン WORD(デフォルト) IgnoreRegexpBackwardWord~ 559 | >hi word "hi word" "word" 560 | >\vword "vword" "word" 561 | >\\vword "vword" "vword" 562 | 563 | Digraphs *Vital.Over.Commandline-modules-Digraphs* 564 | Vim の |digraphs| 機能を有効化します 565 | キー 機能~ 566 | {char1}{char2} ダイグラフの入力 (|c_CTRL-K| を参照) 567 | 568 | 569 | ============================================================================== 570 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 571 | -------------------------------------------------------------------------------- /example/callback.vim: -------------------------------------------------------------------------------- 1 | call vital#of("vital").unload() 2 | let s:cmdline = vital#of("vital").import("Over.Commandline") 3 | 4 | 5 | " コマンドラインのオブジェクトを生成 6 | let s:my = s:cmdline.make_standard("$ ") 7 | 8 | " 任意のタイミングに処理を追加する 9 | " :help Vital.Over.Commandline-object-callback 10 | 11 | " コマンドラインが開始された時に呼ばれる 12 | function! s:my.on_enter(...) 13 | " プロンプトを変更 14 | call self.set_prompt(">>> ") 15 | endfunction 16 | 17 | " キーが入力するたびに呼ばれる 18 | function! s:my.on_char_pre(...) 19 | " 小文字が入力されたら 20 | if self.char() =~ '[a-z]' 21 | " 大文字にして入力する 22 | call self.setchar(toupper(self.char())) 23 | endif 24 | endfunction 25 | 26 | " コマンドラインの開始 27 | call s:my.start() 28 | 29 | -------------------------------------------------------------------------------- /example/custom.vim: -------------------------------------------------------------------------------- 1 | let s:cmdline = vital#of("vital").import("Over.Commandline") 2 | 3 | 4 | " コマンドラインのオブジェクトを生成 5 | " このオブジェクトは何も行わないので 6 | " 自分で Modules を追加してカスタマイズしていく 7 | let s:my = s:cmdline.make_default("$ ") 8 | 9 | 10 | " 使用したいモジュールを追加する 11 | " get_module() でモジュールを取得できる 12 | " "DrawCommandline" はコマンドラインに出力を行う 13 | call s:my.connect(s:cmdline.get_module("DrawCommandline").make()) 14 | 15 | 16 | " "Execute" は で入力されたコマンドを実行する 17 | call s:my.connect(s:cmdline.get_module("Execute").make()) 18 | 19 | 20 | " 直接名前をしていする事も可能 21 | " この場合は 22 | " s:cmdline.get_module("Cancel").make() 23 | " と同等 24 | " "Cancel" は でコマンドラインを終了する 25 | call s:my.connect("Cancel") 26 | 27 | 28 | " コマンドラインの開始 29 | call s:my.start() 30 | 31 | -------------------------------------------------------------------------------- /example/incsearch.vim: -------------------------------------------------------------------------------- 1 | let s:cmdline = vital#of("vital").import("Over.Commandline") 2 | 3 | 4 | let s:search = s:cmdline.make_standard("/") 5 | 6 | " 必要なモジュールを追加 7 | call s:search.connect(s:cmdline.make_module("History", "/")) 8 | call s:search.connect(s:cmdline.make_module("HistAdd", "/")) 9 | call s:search.connect(s:cmdline.make_module("Incsearch", "/")) 10 | 11 | 12 | " 検索の実行コマンド 13 | function! s:search.execute() 14 | call feedkeys("/" . self.getline() . "\") 15 | endfunction 16 | 17 | 18 | function! Search() 19 | call s:search.start() 20 | endfunction 21 | 22 | -------------------------------------------------------------------------------- /example/key_mapping.vim: -------------------------------------------------------------------------------- 1 | let s:cmdline = vital#of("vital").import("Over.Commandline") 2 | 3 | 4 | " コマンドラインのオブジェクトを生成 5 | let s:my = s:cmdline.make_standard("$ ") 6 | 7 | 8 | " 使用したいモジュールを追加 9 | call s:my.connect("Scroll") 10 | 11 | 12 | " 生成したコマンドラインに対してキーマップを設定する 13 | call s:my.cnoremap("\", "\") 14 | call s:my.cnoremap("\", "\") 15 | call s:my.cnoremap("\", "(scroll-e)") 16 | call s:my.cnoremap("\", "(scroll-y)") 17 | 18 | 19 | " コマンドラインの開始 20 | call s:my.start() 21 | 22 | -------------------------------------------------------------------------------- /example/key_mapping_dict.vim: -------------------------------------------------------------------------------- 1 | let s:cmdline = vital#of("vital").import("Over.Commandline") 2 | 3 | 4 | " コマンドラインのオブジェクトを生成 5 | let s:my = s:cmdline.make_standard("$ ") 6 | 7 | 8 | " 使用したいモジュールを追加 9 | call s:my.connect("Scroll") 10 | 11 | 12 | " 任意のマッピングの辞書を返す 13 | " , でカーソル移動 14 | " , でスクロールする 15 | function! s:my.keymapping() 16 | return { 17 | \ "\" : "\", 18 | \ "\" : "\", 19 | \ "\" : "(scroll-e)", 20 | \ "\" : "(scroll-y)", 21 | \ } 22 | endfunction 23 | 24 | 25 | " コマンドラインの開始 26 | call s:my.start() 27 | 28 | -------------------------------------------------------------------------------- /example/module.vim: -------------------------------------------------------------------------------- 1 | let s:cmdline = vital#of("vital").import("Over.Commandline") 2 | 3 | 4 | " コマンドラインのオブジェクトを生成 5 | let s:my = s:cmdline.make_standard("$ ") 6 | 7 | 8 | " モジュールの生成 9 | let s:module = { 10 | \ "name" : "Custom", 11 | \} 12 | 13 | 14 | " キーが入力されて文字が挿入される前に呼ばれる関数 15 | function! s:module.on_char_pre(cmdline) 16 | " キー入力の判定 17 | " コマンドラインに @* を挿入 18 | if a:cmdline.is_input("\") 19 | call a:cmdline.insert(@*) 20 | 21 | " 入力された文字が挿入されないように削除 22 | call a:cmdline.setchar('') 23 | 24 | " コマンドラインを終了する 25 | elseif a:cmdline.is_input("\") 26 | call a:cmdline.exit() 27 | endif 28 | endfunction 29 | 30 | 31 | " モジュールを追加 32 | call s:my.connect(s:module) 33 | 34 | 35 | " コマンドラインの開始 36 | call s:my.start() 37 | 38 | 39 | -------------------------------------------------------------------------------- /example/simple.vim: -------------------------------------------------------------------------------- 1 | let s:cmdline = vital#of("vital").import("Over.Commandline") 2 | 3 | 4 | " コマンドラインのオブジェクトを生成 5 | " make_standard() は標準のコマンドラインの挙動に準じたコマンドラインが生成される 6 | " NOTE:全ての機能が実装されているわけではない 7 | let s:my = s:cmdline.make_standard(":") 8 | 9 | 10 | " コマンドラインの開始 11 | " でコマンドを実行したり でコマンドラインを終了する 12 | call s:my.start() 13 | 14 | -------------------------------------------------------------------------------- /test/Over/Commandline/Base.vim: -------------------------------------------------------------------------------- 1 | 2 | call vital#of("vital").unload() 3 | let s:Base = vital#of("vital").import("Over.Commandline.Base") 4 | let s:Cmdline = vital#of("vital").import("Over.Commandline") 5 | 6 | 7 | function! s:test_backward_word() 8 | let cmdline = s:Base.make() 9 | call cmdline._init_variables() 10 | 11 | call cmdline._input(" __bbb") 12 | OwlCheck cmdline.backward_word() == "__bbb" 13 | OwlCheck cmdline.backward_word('[a-z]\+') == "bbb" 14 | 15 | call cmdline._input(" bbb ") 16 | OwlCheck cmdline.backward_word() == "bbb " 17 | 18 | call cmdline._input("(") 19 | OwlCheck cmdline.backward_word() == "(" 20 | endfunction 21 | 22 | 23 | function! s:test_input_key_stack() 24 | let cmdline = s:Cmdline.make_standard() 25 | call cmdline.start("mami\homu") 26 | OwlCheck cmdline.input_key_stack() == ["h", "o", "m", "u"] 27 | OwlCheck cmdline.input_key_stack_string() == "homu" 28 | endfunction 29 | 30 | 31 | function! s:test_issues_73() 32 | let cmdline = s:Cmdline.make_standard() 33 | let cmdline.cnoremap("h", "ho\mu") 34 | echo cmdline.start("h") 35 | OwlCheck cmdline.getline() == "ho" 36 | OwlCheck cmdline.input_key_stack_string() == "mu" 37 | endfunction 38 | 39 | 40 | function! s:test_is_input_watting() 41 | let Base = s:Base 42 | let mapping = { 43 | \ "a" : "b", 44 | \ "aa" : "b", 45 | \ "abc" : "b", 46 | \ "c" : "d", 47 | \ "A" : "d", 48 | \ } 49 | 50 | OwlCheck Base.is_input_waiting(mapping, "a") 51 | OwlCheck !Base.is_input_waiting(mapping, "bc") 52 | OwlCheck !Base.is_input_waiting(mapping, "aa") 53 | OwlCheck !Base.is_input_waiting(mapping, "c") 54 | OwlCheck !Base.is_input_waiting(mapping, ".") 55 | OwlCheck !Base.is_input_waiting(mapping, '\w') 56 | OwlCheck !Base.is_input_waiting(mapping, 'A') 57 | endfunction 58 | 59 | 60 | -------------------------------------------------------------------------------- /test/Over/Commandline/Modules/Digraphs.vim: -------------------------------------------------------------------------------- 1 | 2 | call vital#of("vital").unload() 3 | let s:Digraphs = vital#of("vital").import("Over.Commandline.Modules.Digraphs") 4 | let s:digraphs = s:Digraphs.digraph() 5 | 6 | function! s:test_backward_word() 7 | let d = s:digraphs 8 | OwlCheck d['NU'] ==# "\" 9 | OwlCheck d['SH'] ==# "\" 10 | OwlCheck d['SP'] ==# " " 11 | OwlCheck d['AC'] =~# "\x9f" 12 | endfunction 13 | -------------------------------------------------------------------------------- /test/Over/Commandline/Modules/Doautocmd.vim: -------------------------------------------------------------------------------- 1 | 2 | call vital#of("vital").unload() 3 | let s:V = vital#of("vital") 4 | let s:Base = s:V.import("Over.Commandline.Base") 5 | let s:Cmdline = s:V.import("Over.Commandline") 6 | let s:Doautocmd = s:V.import("Over.Commandline.Modules.Doautocmd") 7 | 8 | function! s:func() 9 | let cmdline = s:Doautocmd.get_cmdline() 10 | if cmdline.is_input("a") 11 | call cmdline.setchar("b") 12 | endif 13 | endfunction 14 | 15 | 16 | augroup test-vital-over-commandline-modules-doautocmd 17 | autocmd! 18 | autocmd User TestVitalOverCharPre call s:func() 19 | augroup END 20 | 21 | 22 | function! s:test_getcmdline() 23 | let cmdline = s:Cmdline.make_default() 24 | call cmdline.connect("Cancel") 25 | call cmdline.connect(s:Doautocmd.make("TestVitalOver")) 26 | 27 | call cmdline.start("aa\") 28 | OwlCheck cmdline.getline() == "bb" 29 | endfunction 30 | 31 | -------------------------------------------------------------------------------- /test/Over/Commandline/Modules/IgnoreRegexpBackwardWord.vim: -------------------------------------------------------------------------------- 1 | 2 | call vital#of("vital").unload() 3 | let s:Base = vital#of("vital").import("Over.Commandline.Base") 4 | let s:IgnoreRegexpBackwardWord = vital#of("vital").import("Over.Commandline.Modules.IgnoreRegexpBackwardWord") 5 | 6 | 7 | function! s:test_backward_word() 8 | let cmdline = s:Base.make() 9 | call cmdline.connect(s:IgnoreRegexpBackwardWord.make()) 10 | call cmdline.callevent("on_enter") 11 | call cmdline._init_variables() 12 | 13 | call cmdline._input('\vword') 14 | OwlCheck cmdline.backward_word() == 'word' 15 | 16 | call cmdline._input(' \v__homu') 17 | OwlCheck cmdline.backward_word() == '__homu' 18 | OwlCheck cmdline.backward_word('[a-z]\+') == 'homu' 19 | endfunction 20 | 21 | 22 | function! s:func(...) 23 | return call(s:IgnoreRegexpBackwardWord.backward_word, a:000, s:IgnoreRegexpBackwardWord) 24 | endfunction 25 | 26 | 27 | function! s:test_free_backward_word() 28 | OwlCheck s:func('\vword') == "word" 29 | OwlCheck s:func('\vword ') == "word " 30 | OwlCheck s:func('homu\zsmami') == "mami" 31 | OwlCheck s:func('\zs\v') == '\v' 32 | OwlCheck s:func('\zs mado \v') == '\v' 33 | OwlCheck s:func('\v ') == '\v ' 34 | OwlCheck s:func('\\zs ') == 'zs ' 35 | OwlCheck s:func('\') == '\' 36 | OwlCheck s:func('\%''mmark') == 'mark' 37 | endfunction 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/Over/Commandline/Modules/InsertRegister.vim: -------------------------------------------------------------------------------- 1 | 2 | call vital#of("vital").unload() 3 | let s:Base = vital#of("vital").import("Over.Commandline.Base") 4 | let s:Cmdline = vital#of("vital").import("Over.Commandline") 5 | 6 | 7 | function! s:owl_begin() 8 | let g:owl_success_message_format = "" 9 | call vital#of("vital").unload() 10 | endfunction 11 | 12 | function! s:owl_end() 13 | let g:owl_success_message_format = "%f:%l:[Success] %e" 14 | endfunction 15 | 16 | 17 | function! s:test_get_cmdline_cword() 18 | let InsertRegister = vital#of("vital").import("Over.Commandline.Modules.InsertRegister") 19 | try 20 | let ignorecase = &ignorecase 21 | 22 | let &ignorecase = 1 23 | OwlCheck InsertRegister.get_cmdline_cword("cu", "cursor") == "rsor" 24 | OwlCheck InsertRegister.get_cmdline_cword("homu cu", "cursor") == "rsor" 25 | OwlCheck InsertRegister.get_cmdline_cword("homu cu", "CURSoR") == "RSoR" 26 | 27 | let &ignorecase = 0 28 | OwlCheck InsertRegister.get_cmdline_cword("cu", "cursor") == "rsor" 29 | OwlCheck InsertRegister.get_cmdline_cword("homu cu", "cursor") == "rsor" 30 | OwlCheck InsertRegister.get_cmdline_cword("homu cu", "CURSoR") != "RSoR" 31 | finally 32 | let &ignorecase = ignorecase 33 | endtry 34 | endfunction 35 | 36 | 37 | function! s:test_input_expr() 38 | let cmdline = s:Cmdline.make_standard() 39 | 40 | call cmdline.cnoremap("\", "\=1+2\") 41 | call cmdline.start("\homu\") 42 | OwlCheck cmdline.getline() == "3homu" 43 | 44 | " call cmdline.start("\=Homu") 45 | endfunction 46 | 47 | 48 | function! s:test_input_issues_83() 49 | let cmdline = s:Cmdline.make_standard() 50 | 51 | call cmdline.start("\=1+2\homu\") 52 | OwlCheck cmdline.getline() == "3homu" 53 | 54 | " call cmdline.start("\=Homu") 55 | endfunction 56 | 57 | -------------------------------------------------------------------------------- /test/Over/Commandline/Modules/LiteralInsert.vim: -------------------------------------------------------------------------------- 1 | 2 | call vital#of("vital").unload() 3 | let s:V = vital#of("vital") 4 | let s:Base = s:V.import("Over.Commandline.Base") 5 | let s:Cmdline = s:V.import("Over.Commandline") 6 | 7 | 8 | function! s:owl_begin() 9 | let g:owl_success_message_format = "" 10 | endfunction 11 | 12 | function! s:owl_end() 13 | let g:owl_success_message_format = "%f:%l:[Success] %e" 14 | endfunction 15 | 16 | 17 | function! s:test_remap() 18 | let cmdline = s:Cmdline.make_default() 19 | call cmdline.connect("Cancel") 20 | call cmdline.connect("LiteralInsert") 21 | 22 | call cmdline.cnoremap("\", "\\") 23 | 24 | call cmdline.start("\\") 25 | OwlCheck cmdline.getline() == "\" 26 | endfunction 27 | 28 | -------------------------------------------------------------------------------- /test/Over/Keymapping.vim: -------------------------------------------------------------------------------- 1 | 2 | call vital#of("vital").unload() 3 | let s:Keymapping = vital#of("vital").import("Over.Keymapping") 4 | 5 | 6 | function! s:test_match_key() 7 | let Keymapping = s:Keymapping 8 | 9 | let map = { 10 | \ "a" : "bc", 11 | \ "b" : "00", 12 | \ "bc" : "11", 13 | \ "def" : "bc", 14 | \ "de" : "bc", 15 | \ "\\" : "bc", 16 | \ "e" : "aa", 17 | \ "ef" : "aa", 18 | \ "efg" : "aa", 19 | \ '.*' : "aa", 20 | \ "E" : "BB", 21 | \ } 22 | 23 | " echo Keymapping.match_key(map, "b") 24 | " echo Keymapping.match_key(map, "bc") 25 | " echo Keymapping.match_key(map, "bcd") 26 | 27 | OwlCheck Keymapping.match_key(map, "") is "" 28 | OwlCheck Keymapping.match_key(map, "a") is "a" 29 | OwlCheck Keymapping.match_key(map, "ab") is "a" 30 | OwlCheck Keymapping.match_key(map, "ba") is "b" 31 | OwlCheck Keymapping.match_key(map, "bcde") is "bc" 32 | OwlCheck Keymapping.match_key(map, "b") is "b" 33 | OwlCheck Keymapping.match_key(map, "bc") is "bc" 34 | OwlCheck Keymapping.match_key(map, "d") is "" 35 | OwlCheck Keymapping.match_key(map, "de") is "de" 36 | OwlCheck Keymapping.match_key(map, "def") is "def" 37 | OwlCheck Keymapping.match_key(map, "defaa") is "def" 38 | OwlCheck Keymapping.match_key(map, "\") is "" 39 | OwlCheck Keymapping.match_key(map, "\\") is "\\" 40 | OwlCheck Keymapping.match_key(map, "e") is "e" 41 | OwlCheck Keymapping.match_key(map, "ef") is "ef" 42 | OwlCheck Keymapping.match_key(map, "efg") is "efg" 43 | OwlCheck Keymapping.match_key(map, "efga") is "efg" 44 | OwlCheck Keymapping.match_key(map, '.*') is ".*" 45 | OwlCheck Keymapping.match_key(map, 'EE') is "E" 46 | endfunction 47 | 48 | 49 | function! s:test_unmapping() 50 | let Keymapping = s:Keymapping 51 | 52 | let map = { 53 | \ "a" : "bc", 54 | \ "b" : "00", 55 | \ "bc" : "11", 56 | \ "def" : "b", 57 | \ "\\" : "\", 58 | \ "\" : "\", 59 | \ "\\" : "\", 60 | \ "gh" : "b", 61 | \ '.*' : "l", 62 | \ '\w\+' : '.*.*', 63 | \ } 64 | OwlCheck Keymapping.unmapping(map, "bc") is "11" 65 | OwlCheck Keymapping.unmapping(map, "bb") is "0000" 66 | OwlCheck Keymapping.unmapping(map, "abc") is "1111" 67 | OwlCheck Keymapping.unmapping(map, "defc") is "00c" 68 | OwlCheck Keymapping.unmapping(map, "\\") is "\" 69 | OwlCheck Keymapping.unmapping(map, "\\\") is "\\" 70 | OwlCheck Keymapping.unmapping(map, "\\") is "\\" 71 | OwlCheck Keymapping.unmapping(map, "gh") is "00" 72 | OwlCheck Keymapping.unmapping(map, '\w\+') is "ll" 73 | endfunction 74 | 75 | 76 | function! s:test_unmapping_noremap() 77 | let Keymapping = s:Keymapping 78 | 79 | let map = { 80 | \ "a" : { "key" : "bc", "noremap" : 1 }, 81 | \ "bc" : "a", 82 | \ } 83 | OwlCheck Keymapping.unmapping(map, "a") is "bc" 84 | OwlCheck Keymapping.unmapping(map, "bc") is "bc" 85 | endfunction 86 | 87 | 88 | function! s:test_unmapping_lock() 89 | let Keymapping = s:Keymapping 90 | let map = { 91 | \ "\" : { 92 | \ "key" : "\", 93 | \ "lock" : 0, 94 | \ "noremap" : 1, 95 | \ }, 96 | \ "\" : { 97 | \ "key" : "\", 98 | \ "lock" : 0, 99 | \ "noremap" : 1, 100 | \ }, 101 | \ "\" : { 102 | \ "key" : "\", 103 | \ "lock" : 1, 104 | \ "noremap" : 1, 105 | \ }, 106 | \ "\" : { 107 | \ "key" : "\", 108 | \ "lock" : 0, 109 | \ "noremap" : 1, 110 | \ }, 111 | \ "h" : { 112 | \ "key" : "ho\mu", 113 | \ "lock" : 0, 114 | \ "noremap" : 1, 115 | \ }, 116 | \ "a" : { 117 | \ "key" : "c_", 118 | \ "lock" : 1, 119 | \ "noremap" : 1, 120 | \ }, 121 | \ "b" : { 122 | \ "key" : "nacab", 123 | \ "lock" : 0, 124 | \ "noremap" : 1, 125 | \ }, 126 | \ "c" : { 127 | \ "key" : "m", 128 | \ "lock" : 0, 129 | \ "noremap" : 0, 130 | \ }, 131 | \ "_" : { 132 | \ "key" : "-", 133 | \ "lock" : 1, 134 | \ "noremap" : 1, 135 | \ }, 136 | \ "aa" : "b" 137 | \ } 138 | 139 | OwlCheck Keymapping.unmapping(map, "\") is "\" 140 | OwlCheck Keymapping.unmapping(map, "\") is "\" 141 | OwlCheck Keymapping.unmapping(map, "\") is "\" 142 | OwlCheck Keymapping.unmapping(map, "\\\\") is "\\\\" 143 | OwlCheck Keymapping.unmapping(map, "\\\\") is "\\\\" 144 | OwlCheck Keymapping.unmapping(map, "h") is "ho\mu" 145 | OwlCheck Keymapping.unmapping(map, "b") is "nc-cc-b" 146 | OwlCheck Keymapping.unmapping(map, "aa") is "nc-cc-b" 147 | endfunction 148 | 149 | 150 | function! s:test_BS_S_Tab() 151 | let Keymapping = s:Keymapping 152 | let map = { 153 | \ "\" : "a", 154 | \ "\" : "b" 155 | \ } 156 | OwlCheck Keymapping.unmapping(map, "\") is "a" 157 | OwlCheck Keymapping.unmapping(map, "\") is "b" 158 | 159 | endfunction 160 | 161 | 162 | 163 | function! s:test_expr() 164 | let Keymapping = s:Keymapping 165 | let map = { 166 | \ "a" : { 167 | \ "expr" : 1, 168 | \ "key" : "1 + 2", 169 | \ }, 170 | \ "b" : "aa", 171 | \ "3" : "h", 172 | \ } 173 | 174 | OwlCheck Keymapping.unmapping(map, "a") is "h" 175 | OwlCheck Keymapping.unmapping(map, "b") is "hh" 176 | endfunction 177 | 178 | 179 | function! s:test_expr_reference_self() 180 | let Keymapping = s:Keymapping 181 | let map = { 182 | \ "a" : { 183 | \ "expr" : 1, 184 | \ "key" : "self.value + self.value2", 185 | \ "value" : 1, 186 | \ "value2" : 2 187 | \ }, 188 | \ "b" : "aa", 189 | \ "3" : "h", 190 | \ } 191 | 192 | OwlCheck Keymapping.unmapping(map, "a") is "h" 193 | OwlCheck Keymapping.unmapping(map, "b") is "hh" 194 | endfunction 195 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /test/Over/String.vim: -------------------------------------------------------------------------------- 1 | 2 | function! s:owl_begin() 3 | let g:owl_success_message_format = "" 4 | call vital#of("vital").unload() 5 | endfunction 6 | 7 | function! s:owl_end() 8 | let g:owl_success_message_format = "%f:%l:[Success] %e" 9 | endfunction 10 | 11 | 12 | function! s:_test_split() 13 | let owl_SID = owl#filename_to_SID("vital-over/autoload/vital/__latest__/Over/String.vim") 14 | OwlCheck s:split_by_keys("abcd") == ["a", "b", "c", "d"] 15 | OwlCheck s:split_by_keys("\") == ["\"] 16 | OwlCheck s:split_by_keys("\a") == ["\", "a"] 17 | OwlCheck s:split_by_keys("\\") == ["\", "\"] 18 | OwlCheck s:split_by_keys("\\\") == ["\", "\", "\", "<", "B", "S", ">"] 19 | OwlCheck s:split_by_keys("\+") == ["\", "+"] 20 | OwlCheck s:split_by_keys("(scroll-e)") == ["(scroll-e)"] 21 | OwlCheck s:split_by_keys("\") == ["\"] 22 | OwlCheck s:split_by_keys("\\\") == ["\", "\", "\"] 23 | OwlCheck s:split_by_keys("234567") == ["2", "3", "4", "5", "6", "7"] 24 | OwlCheck s:split_by_keys("(exit)aa") == ["(exit)", "a", "a"] 25 | OwlCheck s:split_by_keys("aa\aa\") == ['a', 'a', "\", 'a', 'a', "\"] 26 | OwlCheck s:split_by_keys("aa\aa\") == ['a', 'a', "\", 'a', 'a', "\"] 27 | endfunction 28 | 29 | 30 | function! s:test_split() 31 | let old = &re 32 | try 33 | let &re = 1 34 | call s:_test_split() 35 | let &re = 2 36 | call s:_test_split() 37 | finally 38 | let &re = old 39 | endtry 40 | endfunction 41 | 42 | 43 | function! s:test_index() 44 | let String = vital#of("vital").import("Over.String") 45 | try 46 | let ignorecase = &ignorecase 47 | let &ignorecase = 1 48 | OwlCheck String.index("An Example", "Example") == 3 49 | OwlCheck String.index("An Example", "example") == 3 50 | OwlCheck String.index("An Example", "Example", 4) == -1 51 | 52 | OwlCheck String.index("An Example", "Example", 0, 0) == 3 53 | OwlCheck String.index("An Example", "example", 0, 0) == -1 54 | OwlCheck String.index("An Example", "example", 0, 1) == 3 55 | 56 | let &ignorecase = 0 57 | OwlCheck String.index("An Example", "example") == -1 58 | OwlCheck String.index("An Example", "Example", 0, 0) == 3 59 | OwlCheck String.index("An Example", "example", 0, 0) == -1 60 | OwlCheck String.index("An Example", "example", 0, 1) == 3 61 | finally 62 | let &ignorecase = ignorecase 63 | endtry 64 | endfunction 65 | 66 | 67 | --------------------------------------------------------------------------------