1
0
mirror of https://github.com/gryf/tagbar.git synced 2025-12-17 19:40:27 +01:00

Replace usearrows with iconchars

This commit is contained in:
Jan Larres
2011-12-22 18:06:48 +13:00
parent f9b50a1e95
commit 8e5ce3a3e5
4 changed files with 47 additions and 53 deletions

View File

@@ -73,17 +73,8 @@ if s:ftype_out !~# 'detection:ON'
endif
unlet s:ftype_out
if has('multi_byte') && has('unix') && &encoding == 'utf-8' &&
\ (empty(&termencoding) || &termencoding == 'utf-8')
let s:icon_closed = '▶'
let s:icon_open = '▼'
elseif has('multi_byte') && (has('win32') || has('win64')) && g:tagbar_usearrows
let s:icon_closed = '▷'
let s:icon_open = '◢'
else
let s:icon_closed = '+'
let s:icon_open = '-'
endif
let s:icon_closed = g:tagbar_iconchars[0]
let s:icon_open = g:tagbar_iconchars[1]
let s:type_init_done = 0
let s:autocommands_done = 0

View File

@@ -421,21 +421,22 @@ Example:
let g:tagbar_foldlevel = 2
<
*g:tagbar_usearrows*
g:tagbar_usearrows~
{Windows only}
Default: 0
*g:tagbar_iconchars*
g:tagbar_iconchars~
Tagbar can display nice Unicode arrows instead of +/- characters as fold icons.
However, Windows doesn't seem to be able to substitute in characters from
other fonts if the current font doesn't support them. This means that you have
to use a font that supports those arrows. Unfortunately there is no way to
detect whether specific characters are supported in the current font. So if
your font supports those arrows you have to set this option to make it work.
Since the display of the icons used to indicate open or closed folds depends
on the actual font used, different characters may be optimal for different
fonts. With this variable you can set the icons to characters of your liking.
The first character in the list specifies the icon to use for a closed fold,
and the second one for an open fold.
Example:
Examples (don't worry if some the characters aren't displayed correctly, just
choose other characters in that case):
>
let g:tagbar_usearrows = 1
let g:tagbar_iconchars = ['▶', '▼'] (default on Linux and Mac OS X)
let g:tagbar_iconchars = ['▾', '▸']
let g:tagbar_iconchars = ['▷', '◢']
let g:tagbar_iconchars = ['+', '-'] (default on Windows)
<
*g:tagbar_autoshowtag*

View File

@@ -78,8 +78,13 @@ if !exists('g:tagbar_foldlevel')
let g:tagbar_foldlevel = 99
endif
if !exists('g:tagbar_usearrows')
let g:tagbar_usearrows = 0
if !exists('g:tagbar_iconchars')
if has('multi_byte') && has('unix') && &encoding == 'utf-8' &&
\ (empty(&termencoding) || &termencoding == 'utf-8')
let g:tagbar_iconchars = ['▶', '▼']
else
let g:tagbar_iconchars = ['+', '-']
endif
endif
if !exists('g:tagbar_autoshowtag')

View File

@@ -11,35 +11,32 @@ if exists("b:current_syntax")
finish
endif
if has('multi_byte') && has('unix') && &encoding == 'utf-8' &&
\ (empty(&termencoding) || &termencoding == 'utf-8')
syntax match TagbarKind '\([▶▼] \)\@<=[^-+: ]\+[^:]\+$'
syntax match TagbarScope '\([▶▼][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@='
syntax match TagbarFoldIcon '[▶▼]\([-+# ]\)\@='
syntax match TagbarAccessPublic '\([▶▼ ]\)\@<=+\([^-+# ]\)\@='
syntax match TagbarAccessProtected '\([▶▼ ]\)\@<=#\([^-+# ]\)\@='
syntax match TagbarAccessPrivate '\([▶▼ ]\)\@<=-\([^-+# ]\)\@='
elseif has('multi_byte') && (has('win32') || has('win64')) && g:tagbar_usearrows
syntax match TagbarKind '\([▷◢] \)\@<=[^-+: ]\+[^:]\+$'
syntax match TagbarScope '\([▷◢][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@='
syntax match TagbarFoldIcon '[▷◢]\([-+# ]\)\@='
syntax match TagbarAccessPublic '\([▷◢ ]\)\@<=+\([^-+# ]\)\@='
syntax match TagbarAccessProtected '\([▷◢ ]\)\@<=#\([^-+# ]\)\@='
syntax match TagbarAccessPrivate '\([▷◢ ]\)\@<=-\([^-+# ]\)\@='
else
syntax match TagbarKind '\([-+] \)\@<=[^-+: ]\+[^:]\+$'
syntax match TagbarScope '\([-+][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@='
syntax match TagbarFoldIcon '[-+]\([-+# ]\)\@='
syntax match TagbarAccessPublic '\([-+ ]\)\@<=+\([^-+# ]\)\@='
syntax match TagbarAccessProtected '\([-+ ]\)\@<=#\([^-+# ]\)\@='
syntax match TagbarAccessPrivate '\([-+ ]\)\@<=-\([^-+# ]\)\@='
let s:ic = g:tagbar_iconchars[0]
if s:ic =~ '[]^\\-]'
let s:ic = '\' . s:ic
endif
let s:io = g:tagbar_iconchars[1]
if s:io =~ '[]^\\-]'
let s:io = '\' . s:io
endif
let s:pattern = '\([' . s:ic . s:io . '] \)\@<=[^-+: ]\+[^:]\+$'
execute "syntax match TagbarKind '" . s:pattern . "'"
let s:pattern = '\([' . s:ic . s:io . '][-+# ]\)\@<=[^*]\+\(\*\?\(([^)]\+)\)\? :\)\@='
execute "syntax match TagbarScope '" . s:pattern . "'"
let s:pattern = '[' . s:ic . s:io . ']\([-+# ]\)\@='
execute "syntax match TagbarFoldIcon '" . s:pattern . "'"
let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=+\([^-+# ]\)\@='
execute "syntax match TagbarAccessPublic '" . s:pattern . "'"
let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=#\([^-+# ]\)\@='
execute "syntax match TagbarAccessProtected '" . s:pattern . "'"
let s:pattern = '\([' . s:ic . s:io . ' ]\)\@<=-\([^-+# ]\)\@='
execute "syntax match TagbarAccessPrivate '" . s:pattern . "'"
unlet s:pattern
syntax match TagbarNestedKind '^\s\+\[[^]]\+\]$'
syntax match TagbarComment '^".*'