On 12/01/09 19:16, Andy Wokula wrote:
> Matt Wozniski schrieb:
>> On 1/12/09, Yue Wu wrote:
>>> It's too complicated, if I want to save/restore highlight for others,
>>>   it would need a big change. No other simple and generic way?
>
>> Well, using synIDattr() you should be able to get all the information
>
> which needs a {synID}, provided by
>      :h hlID()
>
> maybe (GUI only):
>
> " Usage:
> "   :let sav_hlCursor = SaveColor("Cursor")
> "   : hi Cursor ...
> "   : ...
> "   :call RestoreColor(sav_hlCursor)
>
> func! SaveColor(hlgroup)
>      let savhl = {"hlgroup": a:hlgroup}
>      let curid = hlID(a:hlgroup)
>      let curtrans = synIDtrans(curid)
>      if curid != curtrans
>       let savhl.link = curtrans
>      else
>       let savhl.fg = synIDattr(curid, "fg")
>       let savhl.bg = synIDattr(curid, "bg")
>       " ...
>      endif
>      return savhl
> endfunc
>
> func! RestoreColor(hldict)
>      let savhl = a:hldict
>      exe "hi clear" savhl.hlgroup
>      if has_key(savhl, "link")
>       exe "hi link" savhl.hlgroup synIDattr(savhl.link, "name")
>      else
>       " GUI only:
>       exe "hi" savhl.hlgroup "guifg=".savhl.fg "guibg=".savhl.bg
>      endif
> endfunc
>

P.S. Not only will it only work in the GUI, it will not restore bold, 
italic, underline, undercurl and guisp= (Mine does, and I could easily 
add the hlgroup argument).

Best regards,
Tony.
-- 
ASHes to ASHes, DOS to DOS.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to