From f92909542825596c1112538f823ba25330cbe4b4 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Mon, 10 Feb 2014 15:21:05 +0900 Subject: [PATCH] Update vital-over: improve highlight --- .../vital/_easymotion/Over/Commandline.vim | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/autoload/vital/_easymotion/Over/Commandline.vim b/autoload/vital/_easymotion/Over/Commandline.vim index f612752..76bac6e 100644 --- a/autoload/vital/_easymotion/Over/Commandline.vim +++ b/autoload/vital/_easymotion/Over/Commandline.vim @@ -87,10 +87,19 @@ let s:base = { \ "highlights" : { \ "prompt" : "NONE", \ "cursor" : "OverCommandLineDefaultCursor", -\ "cursor_insert" : "OverCommandLineDefaultCursorInsert" +\ "cursor_on" : "OverCommandLineDefaultCursorOn", +\ "cursor_insert" : "OverCommandLineDefaultOnCursor", \ }, \} +if exists("s:Signals") + let s:base.variables.modules = s:Signals.make() + function! s:base.variables.modules.get_slot(val) + return a:val.slot.module + endfunction +endif + + function! s:base.getline() return self.line.str() @@ -245,10 +254,11 @@ endfunction function! s:base.hl_cursor_on() - if exists("self.variables.old_hi_cursor") - execute "highlight Cursor " . self.variables.old_hi_cursor - unlet self.variables.old_hi_cursor + if exists("self.variables.old_guicursor") + let &guicursor = self.variables.old_guicursor + unlet self.variables.old_guicursor endif + if exists("self.variables.old_t_ve") let &t_ve = self.variables.old_t_ve unlet self.variables.old_t_ve @@ -257,30 +267,14 @@ endfunction function! s:base.hl_cursor_off() - if exists("self.variables.old_hi_cursor") - return self.variables.old_hi_cursor - endif - let self.variables.old_hi_cursor = "cterm=reverse" - if hlexists("Cursor") - let save_verbose = &verbose - let &verbose = 0 - try - redir => cursor - silent highlight Cursor - redir END - finally - let &verbose = save_verbose - endtry - let hl = substitute(matchstr(cursor, 'xxx \zs.*'), '[ \t\n]\+\|cleared', ' ', 'g') - if !empty(substitute(hl, '\s', '', 'g')) - let self.variables.old_hi_cursor = hl - endif - highlight Cursor NONE + if exists("self.variables.old_t_ve") + return endif + + let self.variables.old_guicursor = &guicursor + set guicursor=a:block-NONE let self.variables.old_t_ve = &t_ve set t_ve= - - return self.variables.old_hi_cursor endfunction @@ -307,12 +301,15 @@ function! s:base._init() let self.variables.input = "" let self.variables.exit = 0 let self.variables.exit_code = 1 - let hl_cursor = self.hl_cursor_off() + call self.hl_cursor_off() if !hlexists("OverCommandLineDefaultCursor") - execute "highlight OverCommandLineDefaultCursor " . hl_cursor + highlight link OverCommandLineDefaultCursor Cursor + endif + if !hlexists("OverCommandLineDefaultCursorOn") + highlight link OverCommandLineDefaultCursorOn OverCommandLineDefaultCursor endif if !hlexists("OverCommandLineDefaultCursorInsert") - execute "highlight OverCommandLineDefaultCursorInsert " . hl_cursor . " term=underline gui=underline" + highlight OverCommandLineDefaultCursorInsert cterm=underline term=underline gui=underline endif endfunction @@ -379,7 +376,7 @@ function! s:_echo_cmdline(cmdline) execute "echohl" a:cmdline.highlights.cursor echon ' ' else - execute "echohl" a:cmdline.highlights.cursor_insert + execute "echohl" a:cmdline.highlights.cursor_on echon a:cmdline.line.pos_word() endif echohl NONE