summaryrefslogtreecommitdiff
path: root/runtime/menu.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-07-17 15:20:30 +0200
committerBram Moolenaar <Bram@vim.org>2010-07-17 15:20:30 +0200
commitc5604bc1656354af7404270e27441f2e8f70d785 (patch)
tree229eed4ddaadee9ffb0594ee104e2a3bd6c83038 /runtime/menu.vim
parentf91787cb9adc47cadea5d17b08d075a15a2e00f4 (diff)
downloadvim-git-c5604bc1656354af7404270e27441f2e8f70d785.tar.gz
Better implementation of creating the Color Scheme menu. (Juergen Kraemer)
Diffstat (limited to 'runtime/menu.vim')
-rw-r--r--runtime/menu.vim28
1 files changed, 12 insertions, 16 deletions
diff --git a/runtime/menu.vim b/runtime/menu.vim
index a9eb81879..2cbd55c4e 100644
--- a/runtime/menu.vim
+++ b/runtime/menu.vim
@@ -337,27 +337,23 @@ fun! s:FileFormat()
endif
endfun
+
" Setup the Edit.Color Scheme submenu
+
+" get NL separated string with file names
let s:n = globpath(&runtimepath, "colors/*.vim")
+
+" split at NL, Ignore case for VMS and windows, sort on name
+let s:names = sort(map(split(s:n, "\n"), 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 1)
+
+" define all the submenu entries
let s:idx = 100
-while strlen(s:n) > 0
- let s:i = stridx(s:n, "\n")
- if s:i < 0
- let s:name = s:n
- let s:n = ""
- else
- let s:name = strpart(s:n, 0, s:i)
- let s:n = strpart(s:n, s:i + 1, 19999)
- endif
- " Ignore case for VMS and windows
- let s:name = substitute(s:name, '\c.*[/\\:\]]\([^/\\:]*\)\.vim', '\1', '')
+for s:name in s:names
exe "an 20.450." . s:idx . ' &Edit.C&olor\ Scheme.' . s:name . " :colors " . s:name . "<CR>"
- unlet s:name
- unlet s:i
let s:idx = s:idx + 10
-endwhile
-unlet s:n
-unlet s:idx
+endfor
+unlet s:name s:names s:n s:idx
+
" Setup the Edit.Keymap submenu
if has("keymap")