comparison runtime/menu.vim @ 435:73f016dbb279

updated for version 7.0112
author vimboss
date Thu, 21 Jul 2005 21:08:21 +0000
parents 4a1ead01d30b
children 59b7b7e99c95
comparison
equal deleted inserted replaced
434:9595cf1d80a7 435:73f016dbb279
1 " Vim support file to define the default menus 1 " Vim support file to define the default menus
2 " You can also use this as a start for your own set of menus. 2 " You can also use this as a start for your own set of menus.
3 " 3 "
4 " Maintainer: Bram Moolenaar <Bram@vim.org> 4 " Maintainer: Bram Moolenaar <Bram@vim.org>
5 " Last Change: 2005 Jul 08 5 " Last Change: 2005 Jul 21
6 6
7 " Note that ":an" (short for ":anoremenu") is often used to make a menu work 7 " Note that ":an" (short for ":anoremenu") is often used to make a menu work
8 " in all modes and avoid side effects from mappings defined by the user. 8 " in all modes and avoid side effects from mappings defined by the user.
9 9
10 " Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise 10 " Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise
871 871
872 noremenu <script> <silent> 1.100 PopUp.Select\ &All :<C-U>call <SID>SelectAll()<CR> 872 noremenu <script> <silent> 1.100 PopUp.Select\ &All :<C-U>call <SID>SelectAll()<CR>
873 inoremenu <script> <silent> 1.100 PopUp.Select\ &All <C-O>:call <SID>SelectAll()<CR> 873 inoremenu <script> <silent> 1.100 PopUp.Select\ &All <C-O>:call <SID>SelectAll()<CR>
874 cnoremenu <script> <silent> 1.100 PopUp.Select\ &All <C-U>call <SID>SelectAll()<CR> 874 cnoremenu <script> <silent> 1.100 PopUp.Select\ &All <C-U>call <SID>SelectAll()<CR>
875 875
876 if has("spell")
877 " Spell suggestions in the popup menu. Note that this will slow down the
878 " appearance of the menu!
879 func! <SID>SpellPopup()
880 if exists("s:changeitem") && s:changeitem != ''
881 call <SID>SpellDel()
882 endif
883
884 let curcol = col('.')
885 let w = spellbadword()
886 if col('.') > curcol " don't use word after the cursor
887 let w = ''
888 call cursor(0, curcol) " put the cursor back where it was
889 endif
890 if w != ''
891 let s:suglist = spellsuggest(w, 10)
892 if len(s:suglist) <= 0
893 call cursor(0, curcol) " put the cursor back where it was
894 else
895 let s:changeitem = 'change\ "' . escape(w, ' .'). '"\ to'
896 let s:fromword = w
897 let pri = 1
898 for sug in s:suglist
899 exe 'amenu 1.5.' . pri . ' PopUp.' . s:changeitem . '.' . escape(sug, ' .')
900 \ . ' :call <SID>SpellReplace(' . pri . ')<CR>'
901 let pri += 1
902 endfor
903
904 let s:additem = 'add\ "' . escape(w, ' .') . '"\ to\ word\ list'
905 exe 'amenu 1.6 PopUp.' . s:additem . ' :spellgood ' . w . '<CR>'
906
907 let s:ignoreitem = 'ignore\ "' . escape(w, ' .') . '"'
908 exe 'amenu 1.7 PopUp.' . s:ignoreitem . ' :spellgood! ' . w . '<CR>'
909
910 amenu 1.8 PopUp.-SpellSep- :
911 endif
912 endif
913 endfunc
914
915 func! <SID>SpellReplace(n)
916 let l = getline('.')
917 call setline('.', strpart(l, 0, col('.') - 1) . s:suglist[a:n - 1]
918 \ . strpart(l, col('.') + len(s:fromword) - 1))
919 endfunc
920
921 func! <SID>SpellDel()
922 exe "aunmenu PopUp." . s:changeitem
923 exe "aunmenu PopUp." . s:additem
924 exe "aunmenu PopUp." . s:ignoreitem
925 aunmenu PopUp.-SpellSep-
926 let s:changeitem = ''
927 endfun
928
929 au! MenuPopup * call <SID>SpellPopup()
930 endif
876 931
877 " The GUI toolbar (for MS-Windows and GTK) 932 " The GUI toolbar (for MS-Windows and GTK)
878 if has("toolbar") 933 if has("toolbar")
879 an 1.10 ToolBar.Open :browse confirm e<CR> 934 an 1.10 ToolBar.Open :browse confirm e<CR>
880 an <silent> 1.20 ToolBar.Save :if expand("%") == ""<Bar>browse confirm w<Bar>else<Bar>confirm w<Bar>endif<CR> 935 an <silent> 1.20 ToolBar.Save :if expand("%") == ""<Bar>browse confirm w<Bar>else<Bar>confirm w<Bar>endif<CR>