" This plugin helps you complete things like: " variableName.abc " variableName->abc " typeName::abc " from the members of the struct/class/union that starts with abc. " If you just type abc will the script complete it with the names that " starts with abc and ignore any current scope. " " The default key mapping to complete the code are: " Alt+l in insert mode will try to find the possible completions and display " them in a popup menu. Also normal completions to the names in " cppcomplete.tags. " Alt+j in insert mode will show the popup menu with the last results. " Selecting one of the items will paste the text. " F8/F9 will work in a similar way as Ctrl+N, Ctrl+P in unextended vim so the " script can be used without the popup menu. " F5 in insert mode will lookup the class and display it in a preview window " The key mapping are only tested under Windows and linux and they will not " work on all platforms. Changing the mappings is easy. " " The plugin is depending on that exuberant ctags has generated a tags file " called cppcomplete.tags with the same options as in the following example: " ctags -n -f cppcomplete.tags --fields=+ai --C++-types=+p * " The script has a command called GenerateTags that executes the above ctags " command. The tag file cppcomplete.tags is local to the script so you can " use other tag files without affecting cppcomplete. " Java users do not need the --C++-types flag. " " For C/C++ can the script generate the cppcomplete.tags from the included " files for you. This is based on vims checkpath function. The path must be " set correct, see the vim documentation. " " This script do not requires grep anymore but it is supported. If the option " is set to build an internal list with derived classes and the first " completion takes a very long time may grep speed things up. " For Windows does the DJGPP port of grep works. " You only need grep.exe from the grep'version'b.zip file. " A good place for grep.exe could be the compilers bin directory. " The zip file is in the v2gnu directory, it can be downloaded from here: " http://www.delorie.com/djgpp/getting.html " " It is possible to define a set of lines from cppcomplete.tags with regular " expressions. I call the set for a block. The functions for this: " BuildBlockFromRegexp the command to build the block, see below. " NextInBlock jump to the line described in the block, can be called by Shift+F8 " PrevInBlock same as the above but in the other direction, use Shift+F9 " EchoBlock shows the block itself " BuildMenuFromBlock builds a menu in GUI mode from the block " The jumps are done with an internal function so the tag stack will not be " affected. " " Some simple examples there > is the prompt: " >class:l " Gives a block with all members that has a scope of a class beginning with l " >^a.*\ts\t " all structures beginning with an a " >^\(a\|b\|c) " Everything that starts with a,b or c " The full vim history mechanism can be used. " " The script has a number of variables that can be set from the menu in the " GUI or wildmenu versions. They are at the top of the script file with descriptions if " you want to change them more permanent. " " For Java do you probably want to generate a cppcomplete.tags file from the " sources of the Java SDK. The use is like with C/C++ but you will get a " better result if you change some of the configuration variables. " The default access is treated as if it was public. " " If you are new to vim and have not heard about ctags, regexp, grep are they " all described in the online documentation. Just type :help followed by the word you " want more information about. They are excellent tools that can be used for " many things. " BUGS/Features " This plugin does not really understand any C/C++ code, it is not a real parser. " It works surprisingly well but can of course give a surprising result. :) " The current scope is unknown. " Multidimensional arrays should not have a space between ][, e.g. " xyz[1][2].abc should be OK but not xyz[1] [2].abc " The script does not accept functions, e.g. xyc()->abc will not be completed or rather " it will be completed but from all names beginning with abc. " (GTK) If the mouse leaves and then reenters the popup menu is the text cursor affected. " (GTK) The popup is displayed at the mouse position and not the text cursor position. " For internal use is register c used. " Requires exuberant ctags. " The only tested platforms for the popup menu are GTK (linux) and Windows. " + probably a lot of other issues " " Anyway, I have done some testing with MFC, DX9 framework (not COM), Java SDK, STL with " good results. " Here is the configuration variables. " " The following two options only applies to Windows. " This is the only tested grep program under windows and the only one that " works with command.com. If grep is used depends on s:useBuffer and " s:neverUseGrep. let s:useDJGPP=has("win32") || has("win16") || has("dos16") || has("dos32") " This is the only way to get a popup menu under Windows so it should always " be set if you are running under Windows. let s:useWinMenu=has("gui_running") && has("gui_win32") " The rest is platform independent. " Use an internal buffer instead of grep? " This should be the fastest option but in some cases is it much faster to use " grep. See s:neverUseGrep below. let s:useBuffer=1 " Using an internal buffer probably makes the searches faster but building a " variable line by line is very expensive in a vim script. The reason is that " you do not have real variables like in C/C++ but more like names for values. " If s:useInternalList is not set will this variable not matter. let s:neverUseGrep= has("win32") || has("win16") || has("dos16") || has("dos32") " The script can make a list with the classes that is derived from another " classes. This may be faster than looking in cppcomplete.tags but the " problem is that the list can take a very long time to build. " If s:useBuffer is not true is an internal list always used. let s:useInternalList=0 " Search for typedefs? let s:searchTDefs=1 " search for macros? " this is not well supported let s:searchMacros=0 " How many lines can the menu have? " Not used under Windows. let s:maxNMenuLines=35 " Search cppcomplete.tags for class members? " It is _really_ recommended that this is on or the script will not know of " classes that is members in other classes. let s:searchClassMembers=1 " This is similar to the above but check if xxx in xxx.abc is a class type. let s:searchClassTags=1 " Search cppcomplete.tags for global variables? " If they are declared in the current file should the script find them but I turned " it on anyway. let s:searchGlobalVars=1 " ctags sometimes miss to set the access so the check is disabled by default. " If you are using Java should I turn on this check because ctags does not " miss the access for Java in the same way as for C++. let s:accessCheck=0 " I like the preview window but the default is not to display it. let s:showPreview=0 " The default language is C/C++, the other option is Java. let s:currLanguage="C/C++" " The max size of the popup menu. Perhaps is 50 more than that is useful. " If you set this to some big value may it take a long time before the " script has finished. let s:tooBig=50 " The max number of items that the popup menu will be built from if you " are not using an internal buffer on linux. " This is to prevent very long lists being built internally since this could " be very slow. The best value depends on how many identical identifiers it is " in cppcomplete.tags. " If you are running gvim will you get a warning if the limit is reached. let s:maxGrepHits=9999 " Setting this option on means that the ancestor can be anything. " This is a good idea since the script does not know the current scope and " ctags also (sometimes) treats namespaces as class scopes. let s:relaxedParents=1 " How the grep program is invoked. The GNU grep has an --mmap option " for faster memory mapping. This can be set from the menu. let s:grepPrg="grep" " Should the access information be displayed on the popup? let s:showAccess=0 " Should :: show the whole scope with items from the ancestors? " This does not seems to be the case in MSVC and that is probably a sensible " way to handle it concerning the main use in class implementation. " The default is anyway the more correct show everything alternative. let s:colonNoInherit=0 " Extra help. let s:nannyMode=1 " Complete all identifiers from cppcomplete.tags? " Pretty much the same is already in vim but I prefer the popup instead of " single stepping with Ctrl-N or Ctrl-P. let s:completeOrdinary=1 " Max recursive depth search for typedefs. This is mostly to prevent the " script to enter an endless loop for some special cases. let s:maxDepth=3 " A new option to give console users with wildmenu access to the menus. let s:useWildMenu=&wildmenu " Mappings " Take them as suggestions only. imap :PreviewClassa if has("gui_running") if (s:useWinMenu) imap :popup PopUpa imap :BuildMenua else imap :BuildMenua imap a endif endif imap :InsNextHita imap :InsPrevHita map :PrevInBlock map :NextInBlock " From this line should you be more careful if you change anything. " " Commands command! -nargs=0 AppendFromCheckpath call s:AppendFromCheckpath() command! -nargs=0 GenerateFromCheckpath call s:GenerateFromCheckpath() command! -nargs=0 GenerateTags call s:GenerateTags() command! -nargs=0 PreviewClass call s:PreCl() if has("gui_running") || s:useWildMenu command! -nargs=0 BuildMenu call s:BuildMenu() command! -nargs=0 DoMenu call s:DoMenu() command! -nargs=0 RestorePopup call s:SetStandardPopup() command! -nargs=0 RefreshMenu call s:RefreshMenu() command! -nargs=0 ClearFromTags call s:ClearFromTags() command! -nargs=0 InsertToTags call s:InsertToTags() command! -nargs=0 ToggleTDefs call s:ToggleTDefs() command! -nargs=0 ToggleMacros call s:ToggleMacros() command! -nargs=0 BrowseNFiles call s:BrowseNFiles() command! -nargs=0 GenerateAndAppend call s:GenerateAndAppend() command! -nargs=1 PreviewEntry call s:PreviewEntry() command! -nargs=0 ToggleAccess call s:ToggleAccess() command! -nargs=0 ToggleGD call s:ToggleGD() command! -nargs=0 TogglePreview call s:TogglePreview() command! -nargs=0 SetLanguage call s:SetLanguage() command! -nargs=0 ToggleRelaxed call s:ToggleRelaxed() command! -nargs=0 ToggleGlobalVars call s:ToggleGlobalVars() command! -nargs=0 ToggleClassMembers call s:ToggleClassMembers() command! -nargs=0 ToggleClassTags call s:ToggleClassTags() command! -nargs=0 ToggleFastGrep call s:ToggleFastGrep() command! -nargs=0 ToggleShowAccess call s:ToggleShowAccess() command! -nargs=0 ToggleInheritance call s:ToggleInheritance() command! -nargs=0 ToggleNanny call s:ToggleNanny() command! -nargs=0 ShowCurrentSettings call s:ShowCurrentSettings() command! -nargs=0 SetMaxHits call s:SetMaxHits() command! -nargs=0 BuildMenuFromBlock call s:BuildMenuFromBlock() endif command! -nargs=0 InsPrevHit call s:InsPrevHit() command! -nargs=0 InsNextHit call s:InsNextHit() command! -nargs=0 BuildBlockFromRegexp call s:BuildBlockFromRegexp() command! -nargs=0 NextInBlock call s:NextInBlock() command! -nargs=0 PrevInBlock call s:PrevInBlock() command! -nargs=0 EchoBlock call s:EchoBlock() command! -nargs=1 JumpToLineInBlock call s:JumpToLineInBlock() " some variables for internal use let s:listAge=0 let s:bufAge=0 let s:lastHit=0 let s:hitList="" let s:regexBlock="" let s:nannyAsked="\n" if s:useBuffer let s:cutBack='\@>' let s:groupS='\%(' else let s:cutBack='' let s:groupS='\(' endif if has("win32") || has("win16") || has("dos16") || has("dos32") let s:ctagsTemp=tempname() let s:grepTemp=tempname() endif " build the gui menu if has("gui_running") || s:useWildMenu set mousemodel=popup silent! aunmenu &cppcomplete silent! tunmenu &cppcomplete amenu &cppcomplete.&GenerateTags.&Rebuild\ from\ current\ directory:GenerateTags :GenerateTags tmenu &cppcomplete.&GenerateTags.&Rebuild\ from\ current\ directory Generate a new cppcomplete.tags file from the files in the current dorectory amenu &cppcomplete.&GenerateTags.&Append\ from\ current\ directory:GenerateAndAppend :GenerateAndAppend tmenu &cppcomplete.&GenerateTags.&Append\ from\ current\ directory Append instead of creating a totally new one. amenu &cppcomplete.&GenerateTags.&Browse\ file\ to\ append:BrowseNFiles :BrowseNFiles tmenu &cppcomplete.&GenerateTags.&Browse\ file\ to\ append Append a file using the file browser. amenu &cppcomplete.&GenerateTags.A&uto\ Generate\ a\ new\ one:GenerateFromCheckpath :GenerateFromCheckpath tmenu &cppcomplete.&GenerateTags.A&uto\ Generate\ a\ new\ one Auto generate a new cppcomplete.tags file for C/C++. amenu &cppcomplete.&GenerateTags.Aut&o\ Generate\ and\ append:AppendFromCheckpath :AppendFromCheckpath tmenu &cppcomplete.&GenerateTags.Aut&o\ Generate\ and\ append Auto generate and append. amenu &cppcomplete.&Use\ generated\ tag\ file\ in\ tags.&No:ClearFromTags :ClearFromTags tmenu &cppcomplete.&Use\ generated\ tag\ file\ in\ tags.&No Do not use cppcomplete.tags as an ordinary tag file amenu &cppcomplete.&Use\ generated\ tag\ file\ in\ tags.&Yes:InsertToTags :InsertToTags tmenu &cppcomplete.&Use\ generated\ tag\ file\ in\ tags.&Yes Use cppcomplete.tags as an ordinary tag file amenu &cppcomplete.-SEP1- amenu &cppcomplete.&Toggle\ search\ options.&Typedefs:ToggleTDefs :ToggleTDefs tmenu &cppcomplete.&Toggle\ search\ options.&Typedefs Toggle search for typedefs amenu &cppcomplete.&Toggle\ search\ options.&Macros:ToggleMacros :ToggleMacros tmenu &cppcomplete.&Toggle\ search\ options.&Macros Toggle search for macros amenu &cppcomplete.&Toggle\ search\ options.&Access\ check:ToggleAccess :ToggleAccess tmenu &cppcomplete.&Toggle\ search\ options.&Access\ check Should only items with the proper access be displayed? amenu &cppcomplete.&Toggle\ search\ options.&Relaxed\ ancestor\ check:ToggleRelaxed :ToggleRelaxed tmenu &cppcomplete.&Toggle\ search\ options.&Relaxed\ ancestor\ check Allow inner classes that may be wrong but hard to check? amenu &cppcomplete.&Toggle\ search\ options.Global\ &variables:ToggleGlobalVars :ToggleGlobalVars tmenu &cppcomplete.&Toggle\ search\ options.Global\ &variables Search cppcomplete.tags for global variables? amenu &cppcomplete.&Toggle\ search\ options.&Classes\ as\ class\ members:ToggleClassMembers :ToggleClassMembers tmenu &cppcomplete.&Toggle\ search\ options.&Classes\ as\ class\ members Complete classes that is members of other classes? amenu &cppcomplete.&Toggle\ search\ options.Inner\ class\ &names\ in\ tags:ToggleClassTags :ToggleClassTags tmenu &cppcomplete.&Toggle\ search\ options.Inner\ class\ &names\ in\ tags Search cppcomplete.tags for classes that is defined in other classes scope? amenu &cppcomplete.Toggle\ &misc\ options.&Show\ access:ToggleShowAccess :ToggleShowAccess tmenu &cppcomplete.Toggle\ &misc\ options.&Show\ access Should the popup menu also display access information? amenu &cppcomplete.Toggle\ &misc\ options.&Inheritance\ for\ :::ToggleInheritance :ToggleInheritance tmenu &cppcomplete.Toggle\ &misc\ options.&Inheritance\ for\ :: Should :: also show inherited items? amenu &cppcomplete.Toggle\ &misc\ options.&Nanny\ mode:ToggleNanny :ToggleNanny tmenu &cppcomplete.Toggle\ &misc\ options.&Nanny\ mode Try to give some extra help. amenu &cppcomplete.Toggle\ &misc\ options.&Fast\ grep:ToggleFastGrep :ToggleFastGrep tmenu &cppcomplete.Toggle\ &misc\ options.&Fast\ grep --mmap option for GNU grep amenu &cppcomplete.Toggle\ &misc\ options.&Preview:TogglePreview :TogglePreview tmenu &cppcomplete.Toggle\ &misc\ options.&Preview Open a preview window after completion? amenu &cppcomplete.-SEP2- amenu &cppcomplete.&Preview\ menu.Scan\ for\ new\ &items:RefreshMenu :RefreshMenu tmenu &cppcomplete.&Preview\ menu.Scan\ for\ new\ &items Scan cppcomplete.tags for classes, structures and unions amenu &cppcomplete.&Preview\ menu.&Classes.*****\ \ \ Nothing\ yet\ \ \ ***** amenu &cppcomplete.&Preview\ menu.&Structures.*****\ \ \ Nothing\ yet\ \ \ ****** amenu &cppcomplete.&Preview\ menu.&Unions.*****\ \ \ Nothing\ yet\ \ \ ***** amenu &cppcomplete.&Block\ menu.&Build\ Menu\ From\ Block:BuildMenuFromBlock :BuildMenuFromBlock tmenu &cppcomplete.&Block\ menu.&Build\ Menu\ From\ Block Build a menu from the items in the current block. amenu &cppcomplete.-SEP3- amenu &cppcomplete.S&et\ C/C++\ or\ Java:SetLanguage :SetLanguage tmenu &cppcomplete.S&et\ C/C++\ or\ Java Set the current language used. amenu &cppcomplete.Set\ max\ number\ of\ &hits\ displayed:SetMaxHits :SetMaxHits tmenu &cppcomplete.Set\ max\ number\ of\ &hits\ displayed How many items should the popup menu have? amenu &cppcomplete.&Show\ current\ settingsShowCurrentSettings :ShowCurrentSettings tmenu &cppcomplete.&Show\ current\ settings List the current settings. amenu &cppcomplete.-SEP4- amenu &cppcomplete.&RestorePopUp:RestorePopup :RestorePopup tmenu &cppcomplete.&RestorePopUp Restores the popup menu. endif function! s:PreCl() if &previewwindow call confirm("You are not supposed to do this then you\nalready are in the Preview window.","&OK",1,"Error") return endif if ! s:CheckForTagFile() return endif let oldParents=s:relaxedParents call s:GetPieces() let s:relaxedParents=oldParents if (s:gotCType) call s:PreviewEntry(s:clType) endif endfunction function! s:PreviewEntry(entry) if &previewwindow call confirm("You are not supposed to do this then you\nalready are in the Preview window.","&OK",1,"Error") return endif if ! s:CheckForTagFile() return endif if (a:entry!="") let tagsSav=&tags let &tags="cppcomplete.tags" execute "ptag " . a:entry silent! wincmd P if &previewwindow normal! zt silent! wincmd p endif let &tags=tagsSav endif endfunction function! s:TogglePreview() let s:showPreview=!s:showPreview endfunction function! s:ToggleAccess() let s:accessCheck=!s:accessCheck if s:accessCheck let cText="Access check enabled" else let cText="Access check disabled" endif call confirm(cText, "&OK",1,"Info") endfunction function! s:ToggleTDefs() let s:searchTDefs=!s:searchTDefs if (s:searchTDefs) let cText="Typedefs is now included in the search" else let cText="Further searches will not look for typedefs" endif call confirm(cText,"&OK",1,"Info") endfunction function! s:ToggleMacros() let s:searchMacros=!s:searchMacros if (s:searchMacros) let cText="Macros is now included in the search" else let cText="Further searches will not look for macros" endif call confirm(cText,"&OK",1,"Info") endfunction function! s:ToggleRelaxed() let s:relaxedParents=! s:relaxedParents if s:relaxedParents let cText="Ancestor check is now set to relaxed" else let cText="Strict ancestor check is now enabled" endif call confirm(cText, "&OK",1,"Info") endfunction function! s:ToggleClassMembers() let s:searchClassMembers=! s:searchClassMembers if s:searchClassMembers let cText="Search for classes as class members is enabled" elseif confirm("This is not recommended if your classes\contains other classes as members","&Do it anyway\n&Cancel",2,"Warning")==1 let cText="No search for classes as class members" else let s:searchClassMembers=1 return endif call confirm(cText, "&OK",1, "Info") endfunction function! s:ToggleClassTags() let s:searchClassTags=! s:searchClassTags if s:searchClassTags let cText="Search for class names is enabled" else let cText="No search for class names" endif call confirm(cText, "&OK",1, "Info") endfunction function! s:ToggleFastGrep() if (s:grepPrg=="grep") let s:grepPrg="grep --mmap" let cText="Fast GNU grep enabled" else let s:grepPrg="grep" let cText="Standard grep is now used" end call confirm(cText, "&OK",1, "Info") endfunction function! s:ToggleInheritance() let s:colonNoInherit=! s:colonNoInherit if s:colonNoInherit let cText=":: will not show items from the ancestors" else let cText=":: will show the whole scope with items from the ancestors" endif call confirm(cText, "&OK",1, "Info") endfunction function! s:ToggleNanny() let s:nannyMode=! s:nannyMode if s:nannyMode let cText="Nanny mode enabled" else let cText="Nanny mode disabled" endif call confirm(cText,"&OK",1,"Info") endfunction function! s:ToggleShowAccess() let s:showAccess=! s:showAccess if s:showAccess let cText="Access information will be displayed if available on the popup menu" else let cText="No access information will be displayed" endif call confirm(cText, "&OK",1, "Info") endfunction function! s:ToggleGlobalVars() let s:searchGlobalVars=! s:searchGlobalVars if s:searchGlobalVars let cText="Search for global variables is enabled" else let cText="No search for global variables" endif call confirm(cText, "&OK",1, "Info") endfunction function! s:InsertToTags() if (match(&tags, "cppcomplete.tags,",0)>=0) call confirm("cppcomplete.tags is already in tags","&OK",1,"Info") else let &tags="cppcomplete.tags," . &tags endif endfunction function! s:ClearFromTags() if (match(&tags,"cppcomplete.tags")<0) call confirm("tags did not include cppcomplete.tags","&OK",1,"Info") else let &tags=substitute(&tags,"cppcomplete.tags.","","g") endif endfunction function! s:SetGrepArg(argtxt) silent! call delete(s:grepTemp) split silent! execute "edit! " s:grepTemp let @c=a:argtxt normal! "cp silent! w silent! bwipeout endfunction function! s:RefreshMenu() if ! s:CheckForTagFile() return endif let spaceAfter="[^!\t]\\+\t" let res=confirm("If you have a big cppcomplete.tags file may strange things happen", "&All\n&Just items in the current directory\n&Cancel",2,"Warning") if res==1 let fileSelect=spaceAfter elseif res==3 return else let fileSelect="[^\\/\t]\\+\t" endif silent! aunmenu cppcomplete.Preview.Classes silent! aunmenu cppcomplete.Preview.Structures silent! aunmenu cppcomplete.Preview.Unions let cf=0 let sf=0 let uf=0 if s:useBuffer && s:neverUseGrep split let items="" call s:CheckHiddenLoaded() let x=line(".") execute ":call search('^" . spaceAfter . fileSelect . spaceAfter . "\\%(c\\|s\\|u\\)','W')" while line(".")!=x let x=line(".") normal! "cyy$ let items=items . @c execute ":call search('^" . spaceAfter . fileSelect . spaceAfter . "\\%(c\\|s\\|u\\)','W')" endwhile quit elseif s:useDJGPP call s:SetGrepArg("'^" . spaceAfter . fileSelect . spaceAfter . s:groupS . "c\\|s\\|u\\)' cppcomplete.tags") silent! let items=system(s:grepPrg . " @" . s:grepTemp) else let items=system(s:grepPrg . " '^" . spaceAfter . fileSelect . spaceAfter . s:groupS . "c\\|s\\|u\\)' cppcomplete.tags") endif let nextM=0 let nclines=0 let nslines=0 let nulines=0 let cMore="" let sMore="" let uMore="" while match(items,"\t",nextM)>0 let oldM=nextM let @c=strpart(items,nextM,match(items,"\t",nextM)-nextM) let nextM=matchend(items,"\n",nextM) if nextM<0 let nextM=strlen(items) endif let mc=match(items,"^[^\t]*\t[^\t]*\t[^\t]*\tc",oldM) let ms=match(items,"^[^\t]*\t[^\t]*\t[^\t]*\ts.*",oldM) if (mc>=0) && (mc" let nclines=nclines+1 if (! s:useWinMenu) if (nclines%s:maxNMenuLines)==0 let cMore=cMore . "More." endif endif elseif (ms>=0) && (ms" let nslines=nslines+1 if (! s:useWinMenu) if (nslines%s:maxNMenuLines)==0 let sMore=sMore . "More." endif endif else let uf=1 execute "amenu .400 &cppcomplete.&Preview.&Unions." . uMore . @c . " :PreviewEntry " . @c ."" let nulines=nulines+1 if (! s:useWinMenu) if (nulines%s:maxNMenuLines)==0 let uMore=uMore . "More." endif endif endif endwhile if cf==0 amenu &cppcomplete.&Preview.&Classes.*****\ \ \ no\ classes\ found\ \ \ ***** endif if sf==0 amenu &cppcomplete.&Preview.&Structures.*****\ \ \ no\ structures\ found\ \ \ ***** endif if uf==0 amenu &cppcomplete.&Preview.&Unions.*****\ \ \ no\ unions\ found\ \ \ ***** endif endfunction function! s:BuildMenuFromBlock() let hittedList="\n" if s:regexBlock=="" call confirm("No block to build the menu from.\nYou must first create the block with the\n:BuildBlockFromRegexp command.","&OK",1,"Error") return endif silent! aunmenu cppcomplete.Block\ menu.menu\ built\ from\ regexp let spaceAfter="[^!\t]\\+\t" let nLines=0 let skippedLines=0 let nextM=0 let grouped=confirm("Which type of menu","&Grouped by visibility\n&Not grouped",1,"Question") if grouped!=1 if grouped!=2 return else let grouped=0 endif endif let bMore="" let uMore="" let uLines=0 while match(s:regexBlock, "\t", nextM)>0 let oldM=nextM let nLines=nLines+1 let @c=strpart(s:regexBlock, nextM, match(s:regexBlock,"\t",nextM)-nextM) let nextM=matchend(s:regexBlock,"\n",nextM) if nextM<0 let nextM=strlen(s:regexBlock) endif if grouped let gStart=matchend(s:regexBlock,"^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t" . s:groupS . "class\\|struct\\|union\\|\\matchend(s:regexBlock,"\n",oldM) let gStart=-1 endif if gStart<0 let uLines=uLines+1 if !s:useWinMenu if (uLines % s:maxNMenuLines)==0 let uMore=uMore . "More." endif endif let group="uncategorized." . uMore else let gEnd=match(s:regexBlock,"[\n\t]",gStart) let group=strpart(s:regexBlock, gStart, gEnd-gStart) . "." endif else let group="" if !s:useWinMenu if ((nLines-skippedLines) % s:maxNMenuLines)==0 let bMore=bMore . "More." endif endif endif if match(hittedList, "\n" . group . @c . "\n")<0 let hittedList=hittedList . group . @c . "\n" execute "amenu &cppcomplete.&Block\\ menu.menu\\ built\\ from\\ regexp." . bMore . group . @c . " :JumpToLineInBlock " . nLines . "" else let skippedLines=skippedLines+1 endif endwhile if nLines==0 call confirm("Could not build the menu", "&OK",1,"Error") elseif skippedLines==0 call confirm("A menu with " . nLines . " items has been built.\nIt is placed in the Block menu", "&OK", 1, "Info") else call confirm("From the original " . nLines . " items was " . skippedLines . "\n skipped because of name clashes.\nThe resulting menu can be reached from the Block menu.", "&OK", 1, "Info") endif endfunction function! s:SetStandardPopup() aunmenu PopUp " The popup menu an 1.10 PopUp.&Undo u an 1.15 PopUp.-SEP1- vnoremenu 1.20 PopUp.Cu&t "+x vnoremenu 1.30 PopUp.&Copy "+y cnoremenu 1.30 PopUp.&Copy nnoremenu 1.40 PopUp.&Paste "+gP cnoremenu 1.40 PopUp.&Paste + if has("virtualedit") vnoremenu