diff --git a/autoload/mmtemplates/core.vim b/autoload/mmtemplates/core.vim new file mode 100644 index 0000000..cacdef1 --- /dev/null +++ b/autoload/mmtemplates/core.vim @@ -0,0 +1,3568 @@ +"=============================================================================== +" +" File: mmtemplates#core.vim +" +" Description: Template engine: Core. +" +" Maps & Menus - Template Engine +" +" VIM Version: 7.0+ +" Author: Wolfgang Mehner, wolfgang-mehner@web.de +" Organization: +" Version: 0.9 +" Created: 30.08.2011 +" Revision: 04.02.2012 +" License: Copyright (c) 2012, Wolfgang Mehner +" This program is free software; you can redistribute it and/or +" modify it under the terms of the GNU General Public License as +" published by the Free Software Foundation, version 2 of the +" License. +" This program is distributed in the hope that it will be +" useful, but WITHOUT ANY WARRANTY; without even the implied +" warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +" PURPOSE. +" See the GNU General Public License version 2 for more details. +"=============================================================================== +" +"------------------------------------------------------------------------------- +" TODO , TODO (win) , TODO (FM) +" some todos can be found in the internal documentation +"------------------------------------------------------------------------------- +" +"------------------------------------------------------------------------------- +" Basic checks. {{{1 +"------------------------------------------------------------------------------- +" +" need at least 7.0 +if v:version < 700 + echohl WarningMsg + echo 'The plugin templates.vim needs Vim version >= 7.' + echohl None + finish +endif +" +" prevent duplicate loading +" need compatible +if &cp || ( exists('g:Templates_Version') && ! exists('g:Templates_DevelopmentOverwrite') ) + finish +endif +let g:Templates_Version= '0.9' " version number of this script; do not change +" +if ! exists ( 'g:Templates_MapInUseWarn' ) + let g:Templates_MapInUseWarn = 1 +endif +" +"---------------------------------------------------------------------- +" === Modul setup. === {{{1 +"---------------------------------------------------------------------- +" +let s:DebugGlobalOverwrite = 0 +let s:DebugLevel = s:DebugGlobalOverwrite +" +let s:StateStackStyleTop = -2 +let s:StateStackFile = -1 +" +let s:StateStackLength = 2 +" +let s:Flagactions = { + \ ':i' : '', + \ ':l' : ' (-> lowercase)', + \ ':u' : ' (-> uppercase)', + \ ':c' : ' (-> capitalize)', + \ ':L' : ' (-> legalize name)', + \ } +" +let s:MsgInsertionNotAvail = "insertion not available for a fold" +" +"---------------------------------------------------------------------- +" s:StandardMacros : The standard macros. {{{2 +"---------------------------------------------------------------------- +" +let s:StandardMacros = { + \ 'BASENAME' : '', + \ 'DATE' : '%x', + \ 'FILENAME' : '', + \ 'PATH' : '', + \ 'SUFFIX' : '', + \ 'TIME' : '%X', + \ 'YEAR' : '%Y', + \ } +" +"---------------------------------------------------------------------- +" s:FileReadNameSpace : The set of functions a template file can call. {{{2 +"---------------------------------------------------------------------- +" +let s:FileReadNameSpace = { + \ 'IncludeFile' : 'ss\?', + \ 'SetFormat' : 'ss', + \ 'SetMacro' : 'ss', + \ 'SetPath' : 'ss', + \ 'SetStyle' : 's', + \ + \ 'MenuShortcut' : 'ss', + \ 'SetMap' : 'ss', + \ 'SetProperty' : 'ss', + \ 'SetShortcut' : 'ss', + \ } +" +"---------------------------------------------------------------------- +" s:TypeNames : Name of types as characters. {{{2 +"---------------------------------------------------------------------- +" +let s:TypeNames = [ ' ', ' ', ' ', ' ', ' ', ' ' ] +" +let s:TypeNames[ type(0) ] = 'i' " integer +let s:TypeNames[ type("") ] = 's' " string +let s:TypeNames[ type([]) ] = 'l' " list +let s:TypeNames[ type({}) ] = 'd' " dict +"let s:TypeNames[ type(0.0) ] = 'n' " number +" TODO: why does float not work in some cases? +" not important right now. +" +"---------------------------------------------------------------------- +" === Regular Expressions. === {{{1 +"---------------------------------------------------------------------- +" +let s:RegexSettings = { + \ 'MacroName' : '[a-zA-Z_][a-zA-Z0-9_]*', + \ 'MacroList' : '\%([a-zA-Z_]\|[a-zA-Z_][a-zA-Z0-9_ \t,]*[a-zA-Z0-9_]\)', + \ 'TemplateName' : '[a-zA-Z_][a-zA-Z0-9_+\-\., ]*[a-zA-Z0-9_+\-\.,]', + \ 'TextOpt' : '[a-zA-Z_][a-zA-Z0-9_+\-: \t,]*[a-zA-Z0-9_+\-]', + \ 'Mapping' : '[a-zA-Z0-9+\-]\+', + \ + \ 'CommentStart' : '\$', + \ 'BlockDelimiter' : '==', + \ + \ 'CommentHint' : '$', + \ 'CommandHint' : '[A-Z]', + \ 'DelimHint' : '=', + \ 'MacroHint' : '|', + \ + \ 'MacroStart' : '|', + \ 'MacroEnd' : '|', + \ 'EditTagStart' : '<', + \ 'EditTagEnd' : '>', + \ 'JumpTag1Start' : '{', + \ 'JumpTag1End' : '}', + \ 'JumpTag2Start' : '<', + \ 'JumpTag2End' : '>', + \ } +" +"---------------------------------------------------------------------- +" s:UpdateFileReadRegex : Update the regular expressions. {{{2 +"---------------------------------------------------------------------- +" +function! s:UpdateFileReadRegex ( regex, settings ) + " + let quote = '\(["'']\?\)' + " + " Basics + let a:regex.MacroName = a:settings.MacroName + let a:regex.MacroNameC = '\('.a:settings.MacroName.'\)' + let a:regex.TemplateNameC = '\('.a:settings.TemplateName.'\)' + let a:regex.Mapping = a:settings.Mapping + let a:regex.AbsolutePath = '^[\~/]' " TODO: Is that right and/or complete? + " + " Syntax Categories + let a:regex.EmptyLine = '^\s*$' + let a:regex.CommentLine = '^'.a:settings.CommentStart + let a:regex.FunctionCall = '^\s*'.a:regex.MacroNameC.'\s*(\(.*\))\s*$' + let a:regex.MacroAssign = '^\s*'.a:settings.MacroStart.a:regex.MacroNameC.a:settings.MacroEnd + \ .'\s*=\s*'.quote.'\(.\{-}\)'.'\2'.'\s*$' " deprecated + " + " Blocks + let delim = a:settings.BlockDelimiter + let a:regex.Styles1Start = '^'.delim.'\s*IF\s\+|STYLE|\s\+IS\s\+'.a:regex.MacroNameC.'\s*'.delim + let a:regex.Styles1End = '^'.delim.'\s*ENDIF\s*'.delim + + let a:regex.Styles2Start = '^'.delim.'\s*USE\s\+STYLES\s*:' + \ .'\s*\('.a:settings.MacroList.'\)'.'\s*'.delim + let a:regex.Styles2End = '^'.delim.'\s*ENDSTYLES\s*'.delim + " + " Texts + let a:regex.TemplateStart = '^'.delim.'\s*\%(TEMPLATE:\)\?\s*'.a:regex.TemplateNameC.'\s*'.delim + \ .'\s*\%(\('.a:settings.TextOpt.'\)\s*'.delim.'\)\?' + let a:regex.TemplateEnd = '^'.delim.'\s*ENDTEMPLATE\s*'.delim + " + let a:regex.ListStart = '^'.delim.'\s*LIST:\s*'.a:regex.MacroNameC.'\s*'.delim + \ .'\s*\%(\('.a:settings.TextOpt.'\)\s*'.delim.'\)\?' + let a:regex.ListEnd = '^'.delim.'\s*ENDLIST\s*'.delim + " + let a:regex.HelpStart = '^'.delim.'\s*HELP:\s*'.a:regex.TemplateNameC.'\s*'.delim + \ .'\s*\%(\('.a:settings.TextOpt.'\)\s*'.delim.'\)\?' + let a:regex.HelpEnd = '^'.delim.'\s*ENDHELP\s*'.delim + " + " Special Hints + let a:regex.CommentHint = a:settings.CommentHint + let a:regex.CommandHint = a:settings.CommandHint + let a:regex.DelimHint = a:settings.DelimHint + let a:regex.MacroHint = a:settings.MacroHint + " +endfunction " ---------- end of function s:UpdateFileReadRegex ---------- +" +"---------------------------------------------------------------------- +" s:UpdateTemplateRegex : Update the regular expressions. {{{2 +"---------------------------------------------------------------------- +" +function! s:UpdateTemplateRegex ( regex, settings ) + " + let quote = '["'']' + " + " Function Arguments + let a:regex.RemoveQuote = '^\s*'.quote.'\zs.*\ze'.quote.'\s*$' + " + " Basics + let a:regex.MacroStart = a:settings.MacroStart + let a:regex.MacroEnd = a:settings.MacroEnd + let a:regex.MacroName = a:settings.MacroName + let a:regex.MacroNameC = '\('.a:settings.MacroName.'\)' + let a:regex.MacroMatch = '^'.a:settings.MacroStart.a:settings.MacroName.a:settings.MacroEnd.'$' + let a:regex.MacroSimple = a:settings.MacroStart.a:settings.MacroName.a:settings.MacroEnd + " + " Syntax Categories + let a:regex.FunctionLine = '^'.a:settings.MacroStart.'\('.a:regex.MacroNameC.'(\(.*\))\)'.a:settings.MacroEnd.'\s*\n' + let a:regex.FunctionChecked = '^'.a:regex.MacroNameC.'(\(.*\))$' + let a:regex.FunctionList = '^LIST(\(.\{-}\))$' + let a:regex.FunctionComment = a:settings.MacroStart.'\(C\|Comment\)'.'(\(.\{-}\))'.a:settings.MacroEnd + let a:regex.FunctionInsert = a:settings.MacroStart.'\(Insert\|InsertLine\)'.'(\(.\{-}\))'.a:settings.MacroEnd + let a:regex.MacroRequest = a:settings.MacroStart.'?'.a:regex.MacroNameC.'\%(:\(\a\)\)\?'.a:settings.MacroEnd + let a:regex.MacroInsert = a:settings.MacroStart.''.a:regex.MacroNameC.'\%(:\(\a\)\)\?'.a:settings.MacroEnd + let a:regex.ListItem = a:settings.MacroStart.''.a:regex.MacroNameC.':ENTRY_*'.a:settings.MacroEnd + " + let a:regex.TextBlockFunctions = '^\%(C\|Comment\|Insert\|InsertLine\)$' + " + " Jump Tags + let a:regex.JumpTagBoth = '<-\w*->\|{-\w*-}\|<+\w*+>\|{+\w*+}' + let a:regex.JumpTagType2 = '<-\w*->\|{-\w*-}' + " +endfunction " ---------- end of function s:UpdateTemplateRegex ---------- +" }}}2 +" +"---------------------------------------------------------------------- +" === Script: Auxiliary functions. === {{{1 +"---------------------------------------------------------------------- +" +"---------------------------------------------------------------------- +" s:ParameterTypes : Get the types of the arguments. {{{2 +" +" Returns a string with one character per argument, denoting the type. +" Uses the codebook 's:TypeNames'. +" +" Examples: +" - s:ParameterTypes ( 1, "string", [] ) -> "isl" +" - s:ParameterTypes ( 1, 'string', {} ) -> "isd" +" - s:ParameterTypes ( 1, 1.0 ) -> "in" +"---------------------------------------------------------------------- +" +function! s:ParameterTypes ( ... ) + return join( map( copy( a:000 ), 's:TypeNames[ type ( v:val ) ]' ), '' ) +endfunction " ---------- end of function s:ParameterTypes ---------- +" +"---------------------------------------------------------------------- +" s:FunctionCheck : Check the syntax, name and parameter types. {{{2 +" +" Throw a 'Template:Check:*' exception whenever: +" - The syntax of the call "name( params )" is wrong. +" - The function name 'name' is not a key in 'namespace'. +" - The parameter string (as produced by s:ParameterTypes) does not match +" the regular expression found in "namespace[name]". +"---------------------------------------------------------------------- +" +function! s:FunctionCheck ( name, param, namespace ) + " + " check the syntax and get the parameter string + try + exe 'let param_s = s:ParameterTypes( '.a:param.' )' + catch /^Vim(let):E\d\+:/ + throw 'Template:Check:function call "'.a:name.'('.a:param.')": '.matchstr ( v:exception, '^Vim(let):E\d\+:\zs.*' ) + endtry + " + " check the function and the parameters + if ! has_key ( a:namespace, a:name ) + throw 'Template:Check:unknown function: "'.a:name.'"' + elseif param_s !~ '^'.a:namespace[ a:name ].'$' + throw 'Template:Check:wrong parameter types: "'.a:name.'"' + endif + " +endfunction " ---------- end of function s:FunctionCheck ---------- +" +"---------------------------------------------------------------------- +" s:LiteralReplacement : Substitute without using regular expressions. {{{2 +"---------------------------------------------------------------------- +" +function! s:LiteralReplacement ( text, remove, insert, flag ) + return substitute( a:text, + \ '\V'.escape( a:remove, '\' ), + \ escape( a:insert, '\&~' ), a:flag ) +" \ '\='.string( a:insert ), a:flag ) +endfunction " ---------- end of function s:LiteralReplacement ---------- +" +"---------------------------------------------------------------------- +" s:ConcatNormalizedFilename : Concatenate and normalize a filename. {{{2 +"---------------------------------------------------------------------- +" +function! s:ConcatNormalizedFilename ( ... ) + if a:0 == 1 + let filename = ( a:1 ) + elseif a:0 == 2 + let filename = ( a:1 ).'/'.( a:2 ) + endif + return fnamemodify( filename, ':p' ) +endfunction " ---------- end of function s:ConcatNormalizedFilename ---------- +" +"---------------------------------------------------------------------- +" s:GetNormalizedPath : Split and normalize a path. {{{2 +"---------------------------------------------------------------------- +" +function! s:GetNormalizedPath ( filename ) + return fnamemodify( a:filename, ':p:h' ) +endfunction " ---------- end of function s:GetNormalizedPath ---------- +" +""---------------------------------------------------------------------- +" s:UserInput : Input after a highlighted prompt. {{{2 +" +" 3. argument : optional completion +" 4. argument : optional list, if the 3. argument is 'customlist' +" +" Throws an exception 'Template:UserInputAborted' if the obtained input is empty, +" so use it like this: +" try +" let style = s:UserInput( 'prompt', '', ... ) +" catch /Template:UserInputAborted/ +" return +" endtry +"---------------------------------------------------------------------- +" +function! s:UserInput ( prompt, text, ... ) + " + echohl Search " highlight prompt + call inputsave() " preserve typeahead + if a:0 == 0 || a:1 == '' + let retval = input( a:prompt, a:text ) + elseif a:1 == 'customlist' + let s:UserInputList = a:2 + let retval = input( a:prompt, a:text, 'customlist,mmtemplates#core#UserInputEx' ) + let s:UserInputList = [] + else + let retval = input( a:prompt, a:text, a:1 ) + endif + call inputrestore() " restore typeahead + echohl None " reset highlighting + " + if empty( retval ) + throw 'Template:UserInputAborted' + endif + " + let retval = substitute( retval, '^\s\+', "", "" ) " remove leading whitespaces + let retval = substitute( retval, '\s\+$', "", "" ) " remove trailing whitespaces + " + return retval + " +endfunction " ---------- end of function s:UserInput ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#UserInputEx : ex-command for s:UserInput. {{{3 +"---------------------------------------------------------------------- +" +function! mmtemplates#core#UserInputEx ( ArgLead, CmdLine, CursorPos ) + return filter( copy( s:UserInputList ), 'v:val =~ "\\V\\<'.escape(a:ArgLead,'\').'\\w\\*"' ) +endfunction " ---------- end of function mmtemplates#core#UserInputEx ---------- +" }}}3 +" +let s:UserInputList = [] +" +"---------------------------------------------------------------------- +" s:ErrorMsg : Print an error message. {{{2 +"---------------------------------------------------------------------- +" +function! s:ErrorMsg ( ... ) + echohl WarningMsg + for line in a:000 + echomsg line + endfor + echohl None +endfunction " ---------- end of function s:ErrorMsg ---------- +" +"---------------------------------------------------------------------- +" s:DebugMsg : Print debug information. {{{2 +"---------------------------------------------------------------------- +" +function! s:DebugMsg ( msg, ... ) + if s:DebugLevel + if a:0 == 0 || ( a:1 <= s:DebugLevel ) + echo a:msg + endif + endif +endfunction " ---------- end of function s:DebugMsg ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#NewLibrary : Create a new template library. {{{1 +"---------------------------------------------------------------------- +" +function! mmtemplates#core#NewLibrary ( ... ) + " + " ================================================== + " data + " ================================================== + " + " library + let library = { + \ 'macros' : {}, + \ 'resources' : {}, + \ 'templates' : {}, + \ + \ 'temp_list' : [], + \ + \ 'styles' : [ 'default' ], + \ 'current_style' : 'default', + \ + \ 'menu_shortcuts' : {}, + \ 'menu_existing' : {}, + \ + \ 'regex_settings' : ( copy ( s:RegexSettings ) ), + \ 'regex_file' : {}, + \ 'regex_template' : {}, + \ + \ 'library_files' : [], + \ } + " used by maps: 'map_commands' + " + call extend ( library.macros, s:StandardMacros, 'keep' ) + " + call s:UpdateFileReadRegex ( library.regex_file, library.regex_settings ) + call s:UpdateTemplateRegex ( library.regex_template, library.regex_settings ) + " + " ================================================== + " parameters + " ================================================== + " + let i = 1 + while i <= a:0 + " +" if a:[i] == 'debug' && i+1 <= a:0 && ! s:DebugGlobalOverwrite +" let s:DebugLevel = a:[i+1] +" let i += 2 +" else + if type ( a:[i] ) == type ( '' ) | call s:ErrorMsg ( 'Unknown option: "'.a:[i].'"' ) + else | call s:ErrorMsg ( 'Unknown option at position '.i.'.' ) | endif + let i += 1 +" endif + " + endwhile + " + " ================================================== + " done + " ================================================== + " + return library " return the new library + " +endfunction " ---------- end of function mmtemplates#core#NewLibrary ---------- +" +"---------------------------------------------------------------------- +" === Read Templates: Auxiliary functions. === {{{1 +"---------------------------------------------------------------------- +" +"---------------------------------------------------------------------- +" s:SetFormat : Set the format of |DATE|, ... (template function). {{{2 +"---------------------------------------------------------------------- +" +function! s:SetFormat ( name, replacement ) + " + " check for valid name + if a:name !~ 'TIME\|DATE\|YEAR' + call s:ErrorMsg ( 'Can not set the format of: '.a:name ) + return + endif + " + let s:library.macros[ a:name ] = a:replacement + " +endfunction " ---------- end of function s:SetFormat ---------- +" +"---------------------------------------------------------------------- +" s:SetMacro : Set a replacement (template function). {{{2 +"---------------------------------------------------------------------- +" +function! s:SetMacro ( name, replacement ) + " + " check for valid name + if a:name !~ s:library.regex_file.MacroName + call s:ErrorMsg ( 'Macro name must be a valid identifier: '.a:name ) + return + elseif has_key ( s:StandardMacros, a:name ) + call s:ErrorMsg ( 'The special macro "'.a:name.'" can not be replaced via SetMacro.' ) + return + endif + " + let s:library.macros[ a:name ] = a:replacement + " +endfunction " ---------- end of function s:SetMacro ---------- +" +"---------------------------------------------------------------------- +" s:SetStyle : Set the current style (template function). {{{2 +"---------------------------------------------------------------------- +" +function! s:SetStyle ( name ) + " + " check for valid name + if a:name !~ s:library.regex_file.MacroName + call s:ErrorMsg ( 'Style name must be a valid identifier: '.a:name ) + return + endif + " + let s:library.current_style = a:name + " +endfunction " ---------- end of function s:SetStyle ---------- +" +"---------------------------------------------------------------------- +" s:SetPath : Set a path-resource (template function). {{{2 +"---------------------------------------------------------------------- +" +function! s:SetPath ( name, value ) + " + " check for valid name + if a:name !~ s:library.regex_file.MacroName + call s:ErrorMsg ( 'Path name must be a valid identifier: '.a:name ) + return + endif + " + let s:library.resources[ 'path!'.a:name ] = a:value + " +endfunction " ---------- end of function s:SetPath ---------- +" +"---------------------------------------------------------------------- +" s:MenuShortcut : Set a shortcut for a sub-menu (template function). {{{2 +"---------------------------------------------------------------------- +" +function! s:MenuShortcut ( name, shortcut ) + " + " check for valid shortcut + if len ( a:shortcut ) > 1 + call s:ErrorMsg ( 'The shortcut for "'.a:name.'" must be a single character.' ) + return + endif + " + let name = substitute( a:name, '\.$', '', '' ) + " + let s:library.menu_shortcuts[ name ] = a:shortcut + " +endfunction " ---------- end of function s:MenuShortcut ---------- +" +"---------------------------------------------------------------------- +" s:SetMap : TODO (template function). {{{2 +"---------------------------------------------------------------------- +" +function! s:SetMap ( name, map ) + " + echo 'SetMap: TO BE IMPLEMENTED' + " +endfunction " ---------- end of function s:SetMap ---------- +" +"---------------------------------------------------------------------- +" s:SetProperty : TODO (template function). {{{2 +"---------------------------------------------------------------------- +" +function! s:SetProperty ( name, shortcut ) + " + echo 'SetProperty: TO BE IMPLEMENTED' + " +endfunction " ---------- end of function s:SetProperty ---------- +" +"---------------------------------------------------------------------- +" s:SetShortcut : TODO (template function). {{{2 +"---------------------------------------------------------------------- +" +function! s:SetShortcut ( name, shortcut ) + " + " check for valid shortcut + if len ( a:shortcut ) > 1 + call s:ErrorMsg ( 'The shortcut for "'.a:name.'" must be a single character.' ) + return + endif + " + echo 'SetShortcut: TO BE IMPLEMENTED' + " +endfunction " ---------- end of function s:SetShortcut ---------- +" +"---------------------------------------------------------------------- +" s:AddStyles : Add styles to the list. {{{2 +"---------------------------------------------------------------------- +" +function! s:AddStyles ( styles ) + " + " TODO: check for valid name + " add the styles to the list + for s in a:styles + if -1 == index ( s:library.styles, s ) + call add ( s:library.styles, s ) + endif + endfor + " +endfunction " ---------- end of function s:AddStyles ---------- +" +"---------------------------------------------------------------------- +" s:UseStyles : Set the styles. {{{2 +"---------------------------------------------------------------------- +" +function! s:UseStyles ( styles ) + " + " 'use_styles' empty? -> we may have new styles + " otherwise -> must be a subset, so no new styles + if empty ( s:t_runtime.use_styles ) + " add the styles to the list + call s:AddStyles ( a:styles ) + else + " are the styles a sub-set of the currently used styles? + for s in a:styles + if -1 == index ( s:t_runtime.use_styles, s ) + call s:ErrorMsg ( 'Style "'.s.'" currently not in use.' ) + return + endif + endfor + endif + " + " push the new style and use it as the current style + call add ( s:t_runtime.styles_stack, a:styles ) + let s:t_runtime.use_styles = a:styles + " +endfunction " ---------- end of function s:UseStyles ---------- +" +"---------------------------------------------------------------------- +" s:RevertStyles : Revert the styles. {{{2 +"---------------------------------------------------------------------- +" +function! s:RevertStyles ( times ) + " + " get the current top, and check whether any more styles can be removed + let state_lim = s:t_runtime.state_stack[ s:StateStackStyleTop ] + let state_top = len( s:t_runtime.styles_stack ) + " + if state_lim > ( state_top - a:times ) + call s:ErrorMsg ( 'Can not close any more style sections.' ) + return + endif + " + " remove the top + call remove ( s:t_runtime.styles_stack, -1 * a:times, -1 ) + " + " reset the current style + if state_top > a:times + let s:t_runtime.use_styles = s:t_runtime.styles_stack[ -1 ] + else + let s:t_runtime.use_styles = [] + endif + " +endfunction " ---------- end of function s:RevertStyles ---------- +" +"---------------------------------------------------------------------- +" s:AddText : Add a text. {{{1 +"---------------------------------------------------------------------- +" +function! s:AddText ( type, name, settings, lines ) + " + if a:type == 'help' + call s:AddTemplate ( 'help', a:name, a:settings, a:lines ) + elseif a:type == 'list' + call s:AddList ( 'list', a:name, a:settings, a:lines ) + elseif a:type == 'template' + call s:AddTemplate ( 't', a:name, a:settings, a:lines ) + endif + " +endfunction " ---------- end of function s:AddText ---------- +" +"---------------------------------------------------------------------- +" s:AddList : Add a list. {{{1 +"---------------------------------------------------------------------- +" +function! s:AddList ( type, name, settings, lines ) + " + " ================================================== + " checks + " ================================================== + " + " Error: empty name + if empty ( a:name ) + call s:ErrorMsg ( 'List name can not be empty.' ) + return + endif + " + " Warning: empty template + if empty ( a:lines ) + call s:ErrorMsg ( 'Warning: Empty list: "'.a:name.'"' ) + endif + " + " Warning: already existing + if s:t_runtime.overwrite_warning && has_key ( s:library.resources, 'list!'.a:name ) + call s:ErrorMsg ( 'Warning: Overwriting list "'.a:name.'"' ) + endif + " + " ================================================== + " settings + " ================================================== + " + let type = 'list' + let bare = 0 + " + for s in a:settings + " + if s == 'list' + let type = 'list' + elseif s == 'hash' || s == 'dict' || s == 'dictionary' + let type = 'dict' + elseif s == 'bare' + let bare = 1 + else + call s:ErrorMsg ( 'Warning: Unknown setting in list "'.a:name.'": "'.s.'"' ) + endif + " + endfor + " + if type == 'list' + if bare + let lines = escape( a:lines, '"' ) + let lines = substitute( lines, '^\s*', '"', '' ) + let lines = substitute( lines, '\s*\n$', '"', '' ) + let lines = substitute( lines, '\s*\n\s*', '", "', 'g' ) + exe 'let list = [ '.lines.' ]' + else + exe 'let list = [ '.substitute( a:lines, '\n', ' ', 'g' ).' ]' + end + call sort ( list ) + elseif type == 'dict' + if bare + s:ErrorMsg ( 'bare hash: to be implemented' ) + else + exe 'let list = { '.substitute( a:lines, '\n', ' ', 'g' ).' }' + end + endif + " + let s:library.resources[ 'list!'.a:name ] = list + " +endfunction " ---------- end of function s:AddList ---------- +" +"---------------------------------------------------------------------- +" s:AddTemplate : Add a template. {{{1 +"---------------------------------------------------------------------- +" +function! s:AddTemplate ( type, name, settings, lines ) + " + let name = a:name + " + " ================================================== + " checks + " ================================================== + " + " Error: empty name + if empty ( name ) + call s:ErrorMsg ( 'Template name can not be empty.' ) + return + endif + " + " Warning: empty template + if empty ( a:lines ) + call s:ErrorMsg ( 'Warning: Empty template: "'.name.'"' ) + endif + " + " ================================================== + " new template + " ================================================== + " + if ! has_key ( s:library.templates, name.'!!type' ) + " + " -------------------------------------------------- + " new template + " -------------------------------------------------- + " + let type = a:type + let placement = 'below' + let indentation = '1' + " + let entry = 1 + let sc = '' + let mp = '' + let visual = -1 != stridx ( a:lines, '' ) + " + " -------------------------------------------------- + " settings + " -------------------------------------------------- + for s in a:settings + " + if s == 'start' || s == 'above' || s == 'below' || s == 'append' || s == 'insert' + let placement = s + + " entry and hot keys: + elseif s == 'nomenu' + let entry = 0 + elseif s == 'expandmenu' + let entry = 2 + elseif s =~ '^sc\s*:' || s =~ '^shortcut\s*:' + let sc = matchstr ( s, '^\w\+\s*:\s*\zs'.s:library.regex_file.Mapping ) + elseif s =~ '^map\s*:' + let mp = matchstr ( s, '^map\s*:\s*\zs'.s:library.regex_file.Mapping ) + + " special insertion in visual mode: + elseif s == 'visual' + let visual = 1 + elseif s == 'novisual' + let visual = 0 + + " indentation + elseif s == 'indent' + let indentation = '1' + elseif s == 'noindent' + let indentation = '0' + +" " picker: +" elseif s == 'pick-file' +" let type = 'pick-file' +" elseif s == 'pick-list' +" let type = 'pick-list' + +" " lists: +" elseif s == 'single-line-list' +" let type = 'single-line-list' +" elseif s == 'multi-line-list' +" let type = 'multi-line-list' + + else + call s:ErrorMsg ( 'Warning: Unknown setting in template "'.name.'": "'.s.'"' ) + endif + " + endfor + " + " TODO: review this + if a:type == 'help' + let placement = 'help' + endif + " + " -------------------------------------------------- + " new template + " -------------------------------------------------- + let s:library.templates[ name.'!!type' ] = type.','.placement.','.indentation + let s:library.templates[ name.'!!menu' ] = entry.",".visual.",'".sc."','".mp."'" + " + call add ( s:library.temp_list, name ) + " + endif + " + " ================================================== + " text + " ================================================== + " + " the styles + if a:type == 'help' + " Warning: overwriting a style + if s:t_runtime.overwrite_warning && has_key ( s:library.templates, name.'!default' ) + call s:ErrorMsg ( 'Warning: Help is overwriting a template: "'.name.'"' ) + endif + let s:library.templates[ name.'!default' ] = a:lines + return + elseif empty ( s:t_runtime.use_styles ) + let styles = [ 'default' ] + else + let styles = s:t_runtime.use_styles + endif + " + " save the lines + for s in styles + " + " Warning: overwriting a style + if s:t_runtime.overwrite_warning && has_key ( s:library.templates, name.'!'.s ) + call s:ErrorMsg ( 'Warning: Overwriting style in template "'.name.'": "'.s.'"' ) + endif + " + let s:library.templates[ name.'!'.s ] = a:lines + " + endfor + " +endfunction " ---------- end of function s:AddTemplate ---------- +" +"---------------------------------------------------------------------- +" s:IncludeFile : Read a template file (IncludeFile). {{{1 +"---------------------------------------------------------------------- +" +function! s:IncludeFile ( templatefile, ... ) + " + let regex = s:library.regex_file + " + let read_abs = 0 + if a:0 >= 1 && a:1 == 'abs' + let read_abs = 1 + endif + " + " ================================================== + " checks + " ================================================== + " + " Expand ~, $HOME, ... and check for absolute path + let templatefile = expand( a:templatefile ) + " +" if templatefile =~ regex.AbsolutePath +" let templatefile = s:ConcatNormalizedFilename ( templatefile ) +" else +" let templatefile = s:ConcatNormalizedFilename ( s:t_runtime.state_stack[ s:StateStackFile ], templatefile ) +" endif + if read_abs + let templatefile = s:ConcatNormalizedFilename ( templatefile ) + else + let templatefile = s:ConcatNormalizedFilename ( s:t_runtime.state_stack[ s:StateStackFile ], templatefile ) + endif + " + " file does not exists or was already visited? + if !filereadable( templatefile ) + throw 'Template:Check:file "'.templatefile.'" does not exist or is not readable' + elseif has_key ( s:t_runtime.files_visited, templatefile ) + throw 'Template:Check:file "'.templatefile.'" already read' + endif + " + " ================================================== + " setup + " ================================================== + " + " add to the state stack + call add ( s:t_runtime.state_stack, len( s:t_runtime.styles_stack ) ) " length of styles_stack + call add ( s:t_runtime.state_stack, s:GetNormalizedPath ( templatefile ) ) " current path + " + " mark file as read + let s:t_runtime.files_visited[templatefile] = 1 + " + " debug: + call s:DebugMsg ( 'Reading '.templatefile.' ...', 2 ) + " + " old format? + let format = 'new' " TODO: review this + " + let state = 'command' + let t_start = 0 + let last_styles = '' + " + " ================================================== + " go trough the file + " ================================================== + " + let filelines = readfile( templatefile ) + " + for line in filelines + " + let firstchar = line[0] + " + " which state + if state == 'command' + " ================================================== + " state: command + " ================================================== + " + " empty line? + if empty ( line ) + continue + endif + " + " comment? + if firstchar == regex.CommentHint + if line =~ regex.CommentLine + continue + endif + endif + " + " macro line? --- |MACRO| = something + if firstchar == regex.MacroHint + " + let mlist = matchlist ( line, regex.MacroAssign ) + if ! empty ( mlist ) + " STYLE, includefile or general macro + if mlist[1] == 'STYLE' + call s:SetStyle ( mlist[3] ) + elseif mlist[1] == 'includefile' + try + call s:IncludeFile ( mlist[3], 'old' ) + catch /Template:Check:.*/ + let msg = v:exception[ len( 'Template:Check:') : -1 ] + call s:ErrorMsg ( 'While loading "'.templatefile.'":', msg ) + endtry + else + call s:SetMacro ( mlist[1], mlist[3] ) + endif + continue + endif + " + endif + " + " function call? --- Function( param_list ) + if firstchar =~ regex.CommandHint + " + let mlist = matchlist ( line, regex.FunctionCall ) + if ! empty ( mlist ) + let [ name, param ] = mlist[ 1 : 2 ] + " + try + " check the call + call s:FunctionCheck ( name, param, s:FileReadNameSpace ) + " try to call + exe 'call s:'.name.' ( '.param.' ) ' + catch /Template:Check:.*/ + let msg = v:exception[ len( 'Template:Check:') : -1 ] + call s:ErrorMsg ( 'While loading "'.templatefile.'":', msg ) + catch // + call s:ErrorMsg ( 'While calling "'.name.'" in "'.templatefile.'":', v:exception ) + endtry + " + continue + endif + " + endif + " + " section or text? + if firstchar == regex.DelimHint + " + " switch styles? + let mlist = matchlist ( line, regex.Styles1Start ) + if ! empty ( mlist ) + call s:UseStyles ( [ mlist[1] ] ) + let last_styles = mlist[0] + continue + endif + " + " switch styles? + if line =~ regex.Styles1End + call s:RevertStyles ( 1 ) + continue + endif + " + " switch styles? + let mlist = matchlist ( line, regex.Styles2Start ) + if ! empty ( mlist ) + call s:UseStyles ( split( mlist[1], '\s*,\s*' ) ) + let last_styles = mlist[0] + continue + endif + " + " switch styles? + if line =~ regex.Styles2End + call s:RevertStyles ( 1 ) + continue + endif + " + " start of text? + let mlist_template = matchlist ( line, regex.TemplateStart ) + let mlist_list = matchlist ( line, regex.ListStart ) + let mlist_help = matchlist ( line, regex.HelpStart ) + if ! empty ( mlist_template ) + let state = 'text' + let t_type = 'template' + let t_start = 1 + elseif ! empty ( mlist_list ) + let state = 'text' + let t_type = 'list' + let t_start = 1 + elseif ! empty ( mlist_help ) + let state = 'text' + let t_type = 'help' + let t_start = 1 + endif + " + endif + " + " empty line? + if line =~ regex.EmptyLine + continue + endif + " + elseif state == 'text' + " ================================================== + " state: text + " ================================================== + " + if firstchar == regex.CommentHint || firstchar == regex.DelimHint + "if firstchar =~ '[=\$]' + " + " comment or end of template? + if line =~ regex.CommentLine + \ || ( line =~ regex.TemplateEnd && format == 'new' ) + \ || ( line =~ regex.ListEnd && format == 'new' ) + let state = 'command' + call s:AddText ( t_type, t_name, t_settings, t_lines ) + continue + endif + " + " start of new template? + let mlist_template = matchlist ( line, regex.TemplateStart ) + let mlist_list = matchlist ( line, regex.ListStart ) + let mlist_help = matchlist ( line, regex.HelpStart ) + if ! empty ( mlist_template ) + call s:AddText ( t_type, t_name, t_settings, t_lines ) + let t_type = 'template' + let t_start = 1 + elseif ! empty ( mlist_list ) + call s:AddText ( t_type, t_name, t_settings, t_lines ) + let t_type = 'list' + let t_start = 1 + elseif ! empty ( mlist_help ) + call s:AddText ( t_type, t_name, t_settings, t_lines ) + let t_type = 'help' + let t_start = 1 + else + let t_lines .= line."\n" " read the line + continue + endif + " + else + let t_lines .= line."\n" " read the line + continue + endif + " + endif + " + " start of template? + if t_start + if t_type == 'template' + let t_name = mlist_template[1] + let t_settings = split( mlist_template[2], '\s*,\s*' ) + elseif t_type == 'list' + let t_name = mlist_list[1] + let t_settings = split( mlist_list[2], '\s*,\s*' ) + elseif t_type == 'help' + let t_name = mlist_help[1] + let t_settings = split( mlist_help[2], '\s*,\s*' ) + endif + let t_lines = '' + let t_start = 0 + continue + endif + " + call s:ErrorMsg ( 'Failed to read line: '.line ) + " + endfor + " + " ================================================== + " wrap up + " ================================================== + " + if state == 'text' + call s:AddText ( t_type, t_name, t_settings, t_lines ) + endif + " + " all style sections closed? + let state_lim = s:t_runtime.state_stack[ s:StateStackStyleTop ] + let state_top = len( s:t_runtime.styles_stack ) + if state_lim < state_top + call s:RevertStyles ( state_top - state_lim ) + call s:ErrorMsg ( 'Styles section has not been closed: '.last_styles ) + endif + " + " debug: + call s:DebugMsg ( '... '.templatefile.' done.', 2 ) + " + " restore the previous state + call remove ( s:t_runtime.state_stack, -1 * s:StateStackLength, -1 ) + " +endfunction " ---------- end of function s:IncludeFile ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#ReadTemplates : Read a template file. {{{1 +"---------------------------------------------------------------------- +" +" TODO: what to do with library.temp_list during reloading? +" +function! mmtemplates#core#ReadTemplates ( library, ... ) + " + " ================================================== + " checks + " ================================================== + " + " check the arguments + if type( a:library ) == type( '' ) + exe 'let t_lib = '.a:library + elseif type( a:library ) == type( {} ) + let t_lib = a:library + else + return s:ErrorMsg ( 'Argument "library" must be given as a dict or string.' ) + endif + " + let mode = '' + let file = '' + " + " ================================================== + " setup + " ================================================== + " + " library + let s:library = t_lib + let s:t_runtime = { + \ 'state_stack' : [], + \ 'use_styles' : [], + \ 'styles_stack' : [], + \ 'files_visited' : {}, + \ + \ 'overwrite_warning' : 0, + \ } + " + " ================================================== + " parameters + " ================================================== + " + let i = 1 + while i <= a:0 + " + if a:[i] == 'load' && i+1 <= a:0 + let mode = 'load' + let file = a:[i+1] + let i += 2 + elseif a:[i] == 'reload' && i+1 <= a:0 + let mode = 'reload' + let file = a:[i+1] + let i += 2 + elseif a:[i] == 'overwrite_warning' + let s:t_runtime.overwrite_warning = 1 + let i += 1 + elseif a:[i] == 'debug' && i+1 <= a:0 && ! s:DebugGlobalOverwrite + let s:DebugLevel = a:[i+1] + let i += 2 + else + if type ( a:[i] ) == type ( '' ) | call s:ErrorMsg ( 'Unknown option: "'.a:[i].'"' ) + else | call s:ErrorMsg ( 'Unknown option at position '.i.'.' ) | endif + let i += 1 + endif + " + endwhile + " + " ================================================== + " files + " ================================================== + " + let templatefiles = [] + " + if mode == 'load' + " + " check the type + if type( file ) != type( '' ) + return s:ErrorMsg ( 'Argument "filename" must be given as a string.' ) + endif + " + " expand ~, $HOME, ... and normalize + let file = expand ( file ) + call add ( templatefiles, s:ConcatNormalizedFilename ( file ) ) + " + " add to library + call add ( t_lib.library_files, s:ConcatNormalizedFilename ( file ) ) + " + elseif mode == 'reload' + " + if type( file ) == type( 0 ) + call add ( templatefiles, t_lib.library_files[ file ] ) + elseif type( file ) == type( '' ) + " load all or a specific file + if file == 'all' + call extend ( templatefiles, t_lib.library_files ) + else + " + " check and add the file + let file = expand ( file ) + let file = s:ConcatNormalizedFilename ( file ) + " + if ! filereadable ( file ) + return s:ErrorMsg ( 'The file "'.file.'" does not exist.' ) + elseif index ( t_lib.library_files, file ) == -1 + return s:ErrorMsg ( 'The file "'.file.'" is not part of the template library.' ) + endif + " + call add ( templatefiles, file ) + " + endif + else + return s:ErrorMsg ( 'Argument "fileid" must be given as an integer or string.' ) + endif + " + " remove old maps + if has_key ( t_lib, 'map_commands' ) + call remove ( t_lib, 'map_commands' ) + endif + " + endif + " + " ================================================== + " read the library + " ================================================== + " + " debug: + if s:DebugLevel > 0 + let time_start = reltime() + endif + " + for f in templatefiles + " + " file exists? + if !filereadable ( f ) + call s:ErrorMsg ( 'Template library "'.f.'" does not exist or is not readable.' ) + continue + endif + " + " runtime information: + " - set up the state stack: length of styles_stack + current path + " - reset the current styles + let s:t_runtime.state_stack = [ 0, s:GetNormalizedPath ( f ) ] + let s:t_runtime.use_styles = [] + let s:t_runtime.styles_stack = [] + " + " read the top-level file + call s:IncludeFile ( f, 'abs' ) + " + endfor + " + call sort ( s:library.styles ) " sort the styles + " + " debug: + if s:DebugLevel > 0 + echo 'Loading library: '.reltimestr( reltime( time_start ) ) + endif + " + " ================================================== + " wrap up + " ================================================== + " + unlet s:library " remove script variables + unlet s:t_runtime " ... + " + let s:DebugLevel = s:DebugGlobalOverwrite " reset debug + " + if mode == 'reload' + echo 'Reloaded the template library.' + endif + +endfunction " ---------- end of function mmtemplates#core#ReadTemplates ---------- +" +"---------------------------------------------------------------------- +" === Insert Templates: Auxiliary functions. === {{{1 +"---------------------------------------------------------------------- +" +"---------------------------------------------------------------------- +" s:ApplyFlag : Modify a text according to 'flag'. {{{2 +"---------------------------------------------------------------------- +" +function! s:ApplyFlag ( text, flag ) + " + if a:flag == '' || a:flag == 'i' " i : identity + return a:text + elseif a:flag == 'l' " l : lowercase + return tolower(a:text) + elseif a:flag == 'u' " u : uppercase + return toupper(a:text) + elseif a:flag == 'c' " c : capitalize + return toupper(a:text[0]).a:text[1:] + elseif a:flag == 'L' " L : legalized name + let text = substitute( a:text, '\s\+', '_', 'g' ) " multiple whitespaces + let text = substitute( text, '\W\+', '_', 'g' ) " multiple non-word characters + let text = substitute( text, '_\+', '_', 'g' ) " multiple underscores + return text + else " flag not valid + return a:text + endif + " +endfunction " ---------- end of function s:ApplyFlag ---------- +" +"---------------------------------------------------------------------- +" s:OpenFold : Open fold and go to the first or last line of this fold. {{{2 +"---------------------------------------------------------------------- +" +function! s:OpenFold ( mode ) + if foldclosed(".") < 0 + return + endif + " we are on a closed fold: + " get end position, open fold, + " jump to the last line of the previously closed fold + let foldstart = foldclosed(".") + let foldend = foldclosedend(".") + normal zv + if a:mode == 'below' + exe ":".foldend + elseif a:mode == 'start' + exe ":".foldstart + endif +endfunction " ---------- end of function s:OpenFold ---------- +" +"---------------------------------------------------------------------- +" s:ReplaceMacros : Replace all the macros in a text. {{{1 +"---------------------------------------------------------------------- +" +function! s:ReplaceMacros ( text, m_local ) + " + let text1 = '' + let text2 = a:text + " + let regex = '\(\_.\{-}\)'.s:library.regex_template.MacroInsert.'\(\_.*\)' + " + while 1 + " + let mlist = matchlist ( text2, regex ) + " + " no more macros? + if empty ( mlist ) + break + endif + " + " check for recursion + if -1 != index ( s:t_runtime.macro_stack, mlist[2] ) + let m_text = '' + call add ( s:t_runtime.macro_stack, mlist[2] ) + throw 'Template:MacroRecursion' + elseif has_key ( a:m_local, mlist[2] ) + let m_text = get ( a:m_local, mlist[2] ) + else + let m_text = get ( s:library.macros, mlist[2], '' ) + end + " + if m_text =~ s:library.regex_template.MacroSimple + " + call add ( s:t_runtime.macro_stack, mlist[2] ) + " + let m_text = s:ReplaceMacros ( m_text, a:m_local ) + " + call remove ( s:t_runtime.macro_stack, -1 ) + " + endif + " + " apply flag? + if ! empty ( mlist[3] ) + let m_text = s:ApplyFlag ( m_text, mlist[3] ) + endif + " + let text1 .= mlist[1].m_text + let text2 = mlist[4] + " + endwhile + " + return text1.text2 + " +endfunction " ---------- end of function s:ReplaceMacros ---------- +" +" "---------------------------------------------------------------------- +" " s:ReplaceMacrosOld : Replace all the macros in a text. {{{1 +" "---------------------------------------------------------------------- +" " +" function! s:ReplaceMacrosOld ( text, m_local, m_global ) +" " +" " TODO: prevent recursion of macros +" " TODO: should be rewritten, so that this works as expected: +" " |DDD| = test +" " |EEE| = |DDD| +" " Expanding |EEE:u| will result in: +" " test +" " +" let text = a:text +" " +" while 1 +" " +" let mlist = matchlist ( text, s:library.regex_template.MacroInsert ) +" " +" " no more macros? +" if empty ( mlist ) +" break +" endif +" " +" if has_key ( a:m_local, mlist[1] ) +" let m_text = get ( a:m_local, mlist[1] ) +" else +" let m_text = get ( a:m_global, mlist[1], '' ) +" end +" " +" " apply flag? +" if ! empty ( mlist[2] ) +" let m_text = s:ApplyFlag ( m_text, mlist[2] ) +" endif +" " +" " insert the replacement +" let text = s:LiteralReplacement ( text, mlist[0], m_text, 'g' ) +" " +" endwhile +" " +" return text +" " +" endfunction " ---------- end of function s:ReplaceMacrosOld ---------- +" +"---------------------------------------------------------------------- +" === Templates === {{{1 +"---------------------------------------------------------------------- +" +"---------------------------------------------------------------------- +" s:CheckHelp : Check a template (pick-file). {{{2 +"---------------------------------------------------------------------- +" +let s:NamespaceHelp = { + \ 'Word' : 's', + \ 'Pattern' : 's', 'Default' : 's', + \ 'Substitute' : 'sss', 'LiteralSub' : 'sss', + \ 'System' : 's', 'Vim' : 's', + \ } +" +function! s:CheckHelp ( cmds, text, calls ) + return [ a:cmds, a:text ] +endfunction " ---------- end of function s:CheckHelp ---------- +" +" "---------------------------------------------------------------------- +" " s:CheckPickFile : Check a template (pick-file). {{{2 +" "---------------------------------------------------------------------- +" " +" let s:NamespacePickFile = { +" \ 'Prompt' : 's', +" \ 'Path' : 's', 'GetPath' : 's', +" \ } +" " +" function! s:CheckPickFile ( cmds, text, calls ) +" return [ a:cmds, a:text ] +" endfunction " ---------- end of function s:CheckPickFile ---------- +" " +" "---------------------------------------------------------------------- +" " s:CheckPickList : Check a template (pick-list). {{{2 +" "---------------------------------------------------------------------- +" " +" let s:NamespacePickList = { +" \ 'Prompt' : 's', +" \ 'List' : '[ld]', 'GetList' : 's', +" \ } +" " +" function! s:CheckPickList ( cmds, text, calls ) +" return [ a:cmds, a:text ] +" endfunction " ---------- end of function s:CheckPickList ---------- +" +"---------------------------------------------------------------------- +" s:CheckStdTempl : Check a template (standard). {{{2 +"---------------------------------------------------------------------- +" +let s:NamespaceStdTempl = { + \ 'DefaultMacro' : 's[sl]', + \ 'PickFile' : 'ss', + \ 'PickList' : 's[sld]', + \ 'Prompt' : 'ss', + \ 'SurroundWith' : 's[sl]*', + \ } +let s:NamespaceStdTemplInsert = { + \ 'Comment' : 's\?', + \ 'Insert' : 's[sl]*', + \ 'InsertLine' : 's[sl]*', + \ } +" +function! s:CheckStdTempl ( cmds, text, calls ) + " + let regex = s:library.regex_template + let ms = regex.MacroStart + let me = regex.MacroEnd + " + let cmds = a:cmds + let text = a:text + " + let prompted = {} + " + " -------------------------------------------------- + " replacements + " -------------------------------------------------- + while 1 + " + let mlist = matchlist ( text, regex.MacroRequest ) + " + " no more macros? + if empty ( mlist ) + break + endif + " + let m_name = mlist[1] + let m_flag = mlist[2] + " + " not a special macro and not already done? + if has_key ( s:StandardMacros, m_name ) + call s:ErrorMsg ( 'The special macro "'.m_name.'" can not be replaced via |?'.m_name.'|.' ) + elseif ! has_key ( prompted, m_name ) + let cmds .= "Prompt(".string(m_name).",".string(m_flag).")\n" + let prompted[ m_name ] = 1 + endif + " + if ! empty ( m_flag ) | let m_flag = ':'.m_flag | endif + " + " insert a normal macro + let text = s:LiteralReplacement ( text, + \ mlist[0], ms.m_name.m_flag.me, 'g' ) + " + endwhile + " + " -------------------------------------------------- + " lists + " -------------------------------------------------- + let list_items = [ 'EMPTY', 'SINGLE', 'FIRST', 'LAST' ] " + 'ENTRY' + " + while 1 + " + let mlist = matchlist ( text, regex.ListItem ) + " + " no more macros? + if empty ( mlist ) + break + endif + " + let l_name = mlist[1] + " + let mlist = matchlist ( text, + \ '\([^'."\n".']*\)'.ms.l_name.':ENTRY_*'.me.'\([^'."\n".']*\)\n' ) + " + let cmds .= "LIST(".string(l_name)."," + \ .string(mlist[1]).",".string(mlist[2]).")\n" + let text = s:LiteralReplacement ( text, + \ mlist[0], ms.l_name.':LIST'.me."\n", '' ) + " + for item in list_items + " + let mlist = matchlist ( text, + \ '\([^'."\n".']*\)'.ms.l_name.':'.item.'_*'.me.'\([^'."\n".']*\)\n' ) + " + if empty ( mlist ) + let cmds .= "\n" + continue + endif + " + let cmds .= "[".string(mlist[1]).",".string(mlist[2])."]\n" + let text = s:LiteralReplacement ( text, mlist[0], '', '' ) + endfor + " + endwhile + " + " -------------------------------------------------- + " comments + " -------------------------------------------------- + while 1 + " + let mlist = matchlist ( text, regex.FunctionComment ) + " + " no more comments? + if empty ( mlist ) + break + endif + " + let [ f_name, f_param ] = mlist[ 1 : 2 ] + " + " check the call + call s:FunctionCheck ( 'Comment', f_param, s:NamespaceStdTemplInsert ) + " + exe 'let flist = ['.f_param.']' + " + if empty ( flist ) | let flag = 'eol' + else | let flag = flist[0] | endif + " + let mlist = matchlist ( text, regex.FunctionComment.'\s*\([^'."\n".']*\)' ) + " + let text = s:LiteralReplacement ( text, mlist[0], + \ ms.'InsertLine("Comments.end-of-line","|CONTENT|",'.string( mlist[3] ).')'.me, '' ) + " + endwhile + " + return [ cmds, text ] + " +endfunction " ---------- end of function s:CheckStdTempl ---------- +" +"---------------------------------------------------------------------- +" s:CheckTemplate : Check a template. {{{2 +" +" Get the command and text block. +"---------------------------------------------------------------------- +" +function! s:CheckTemplate ( template, type ) + " + let regex = s:library.regex_template + " + let cmds = '' + let text = '' + let calls = [] + " + " the known functions + if a:type == 't' + let namespace = s:NamespaceStdTempl + elseif a:type == 'pick-file' + let namespace = s:NamespacePickFile + elseif a:type == 'pick-list' + let namespace = s:NamespacePickList + elseif a:type == 'help' + let namespace = s:NamespaceHelp + endif + " + " go trough the lines + let idx = 0 + while idx < len ( a:template ) + " + let idx_n = stridx ( a:template, "\n", idx ) + let mlist = matchlist ( a:template[ idx : idx_n ], regex.FunctionLine ) + " + " no match or 'Comment' or 'Insert' function? + if empty ( mlist ) || mlist[ 2 ] =~ regex.TextBlockFunctions + break + endif + " + let [ f_name, f_param ] = mlist[ 2 : 3 ] + " + " check the call + call s:FunctionCheck ( f_name, f_param, namespace ) + " + call add ( calls, [ f_name, f_param ] ) + " + let cmds .= mlist[1]."\n" + let idx += len ( mlist[0] ) + " + endwhile + " + let text = a:template[ idx : -1 ] + " + " checks depending on the type + if a:type == 't' + return s:CheckStdTempl( cmds, text, calls ) + elseif a:type == 'pick-file' + return s:CheckPickFile( cmds, text, calls ) + elseif a:type == 'pick-list' + return s:CheckPickList( cmds, text, calls ) + elseif a:type == 'help' + return s:CheckHelp( cmds, text, calls ) + endif + " +endfunction " ---------- end of function s:CheckTemplate ---------- +" +"---------------------------------------------------------------------- +" s:GetTemplate : Get a template. {{{2 +"---------------------------------------------------------------------- +" +function! s:GetTemplate ( name, style ) + " + let name = a:name + let style = a:style + " + " check the template + if has_key ( s:library.templates, name.'!!type' ) + let info = s:library.templates[ a:name.'!!type' ] + let [ type, placement, indentation ] = split ( info, ',' ) + else + throw 'Template:Prepare:template does not exist' + endif + " + if style == '!any' + for s in s:library.styles + if has_key ( s:library.templates, name.'!'.s ) + let template = get ( s:library.templates, name.'!'.s ) + let style = s + endif + endfor + else + " check the style + if has_key ( s:library.templates, name.'!'.style ) + let template = get ( s:library.templates, name.'!'.style ) + elseif has_key ( s:library.templates, name.'!default' ) + let template = get ( s:library.templates, name.'!default' ) + let style = 'default' + elseif style == 'default' + throw 'Template:Check:template does not have the default style'. + else + throw 'Template:Check:template has neither the style "'.style.'" nor the default style' + endif + endif + " + " check the text + let head = template[ 0 : 5 ] + " + if head == "|P()|\n" " plain text + " TODO: special type for plain + let cmds = '' + let text = template[ 6 : -1 ] + elseif head == "|T()|\n" " only text (contains only macros without '?') + " TODO: special type for text + " TODO: no need to call 's:PrepareStdTempl', + " once every other special forces an entry in the command block + let cmds = '' + let text = template[ 6 : -1 ] + elseif head == "|C()|\n" " command and text block + let splt = stridx ( template, "|T()|\n" ) - 1 + let cmds = template[ 6 : splt ] + let text = template[ splt+7 : -1 ] + else + " + " do checks + let [ cmds, text ] = s:CheckTemplate ( template, type ) + " + " save the result + if empty ( cmds ) + let template = "|T()|\n".text + else + let template = "|C()|\n".cmds."|T()|\n".text + end + let s:library.templates[ a:name.'!'.style ] = template + " +" echo cmds."<" +" echo text."<" + end + " + return [ cmds, text, type, placement, indentation ] +endfunction " ---------- end of function s:GetTemplate ---------- +" +"---------------------------------------------------------------------- +" s:GetPickList : Get the list (pick-list). {{{2 +"---------------------------------------------------------------------- +" +function! s:GetPickList ( name ) + " + let regex = s:library.regex_template + " + " get the template + let [ cmds, text, type, placement, indentation ] = s:GetTemplate ( a:name, '!any' ) + " + if type == 't' + " + for line in split( cmds, "\n" ) + " the line will match and it will be a valid function + let [ f_name, f_param ] = matchlist ( line, regex.FunctionChecked )[ 1 : 2 ] + " + if f_name == 'PickList' + " + exe 'let [ _, listarg ] = [ '.f_param.' ]' + " + let entry = '' + " + if type ( listarg ) == type ( '' ) + if ! has_key ( s:library.resources, 'list!'.listarg ) + call s:ErrorMsg ( 'List "'.listarg.'" does not exist.' ) + return [] + endif + let list = s:library.resources[ 'list!'.listarg ] + else + let list = listarg + endif + " + endif + endfor + " + elseif type == 'pick-list' + " + for line in split( cmds, "\n" ) + " the line will match and it will be a valid function + let [ f_name, f_param ] = matchlist ( line, regex.FunctionChecked )[ 1 : 2 ] + " + if f_name == 'List' + exe 'let list = '.f_param + elseif f_name == 'GetList' + " + let listname = matchstr ( f_param, regex.RemoveQuote ) + if ! has_key ( s:library.resources, 'list!'.listname ) + call s:ErrorMsg ( 'List "'.listname.'" does not exist.' ) + return [] + endif + let list = s:library.resources[ 'list!'.listname ] + " + endif + endfor + " + else + call s:ErrorMsg ( 'Template "'.a:name.'" is not a list picker.' ) + return [] + endif + " + if type ( list ) == type ( [] ) + return list + else + return sort ( keys ( list ) ) + endif + " +endfunction " ---------- end of function s:GetPickList ---------- +" +"---------------------------------------------------------------------- +" s:PrepareHelp : Prepare a template (pick-file). {{{2 +"---------------------------------------------------------------------- +" +function! s:PrepareHelp ( cmds, text ) + " + let regex = s:library.regex_template + " + let pick = '' + let default = '' + let method = '' + let call = '' + " + let buf_line = getline('.') + let buf_pos = col('.') - 1 + " + " ================================================== + " command block + " ================================================== + " + for line in split( a:cmds, "\n" ) + " + " the line will match and it will be a valid function + let [ f_name, f_param ] = matchlist ( line, regex.FunctionChecked )[ 1 : 2 ] + " + if f_name == 'C' + " ignore + elseif f_name == 'Word' + exe 'let switch = '.f_param | " TODO: works differently than 'Pattern': picks up word behind the cursor, too + if switch == 'W' | let pick = expand('') + else | let pick = expand('') | endif + elseif f_name == 'Pattern' + exe 'let pattern = '.f_param + let cnt = 1 + while 1 + let m_end = matchend ( buf_line, pattern, 0, cnt ) - 1 + if m_end < 0 + let pick = '' + break + elseif m_end >= buf_pos + let m_start = match ( buf_line, pattern, 0, cnt ) + if m_start <= buf_pos | let pick = buf_line[ m_start : m_end ] + else | let pick = '' | endif + break + endif + let cnt += 1 + endwhile + elseif f_name == 'Default' + exe 'let default = '.f_param + elseif f_name == 'LiteralSub' + exe 'let [ p, r, f ] = ['.f_param.']' + let pick = s:LiteralReplacement ( pick, p, r, f ) + elseif f_name == 'Substitute' + exe 'let [ p, r, f ] = ['.f_param.']' + let pick = substitute ( pick, p, r, f ) + elseif f_name == 'System' || f_name == 'Vim' + let method = f_name + exe 'let call = '.f_param + endif + " + endfor + " + " ================================================== + " call for help + " ================================================== + " + if empty ( pick ) && empty ( default ) + \ || empty ( method ) + return '' + endif + " + let m_local = copy ( s:t_runtime.macros ) + " + if ! empty ( pick ) + let m_local.PICK = pick + let call = s:ReplaceMacros ( call, m_local ) + else + let call = s:ReplaceMacros ( default, m_local ) + endif + " + if method == 'System' + echo 'call system ( '.string ( call ).' )' | " debug + exe 'call system ( '.string ( call ).' )' + elseif method == 'Vim' + echo call | " debug + exe call + endif + " + return '' + " +endfunction " ---------- end of function s:PrepareHelp ---------- +" +" "---------------------------------------------------------------------- +" " s:PreparePickFile : Prepare a template (pick-file). {{{2 +" "---------------------------------------------------------------------- +" " +" function! s:PreparePickFile ( cmds, text ) +" " +" let regex = s:library.regex_template +" " +" let msg = 'File' +" let path = '' +" let text = a:text +" " +" " ================================================== +" " command block +" " ================================================== +" " +" for line in split( a:cmds, "\n" ) +" " +" " the line will match and it will be a valid function +" let [ f_name, f_param ] = matchlist ( line, regex.FunctionChecked )[ 1 : 2 ] +" " +" if f_name == 'C' +" " ignore +" elseif f_name == 'Prompt' +" let msg = matchstr ( f_param, regex.RemoveQuote ) +" elseif f_name == 'Path' +" let path = matchstr ( f_param, regex.RemoveQuote ) +" elseif f_name == 'GetPath' +" " +" let path = matchstr ( f_param, regex.RemoveQuote ) +" if ! has_key ( s:library.resources, 'path!'.path ) +" throw 'Template:Prepare:the resources "'.path.'" does not exist' +" endif +" let path = s:library.resources[ 'path!'.path ] +" endif +" " +" endfor +" " +" " ================================================== +" " get the path +" " ================================================== +" " +" let path = expand ( path ) +" let file = s:UserInput ( msg.' : ', path, 'file' ) +" " +" let m_local = copy ( s:t_runtime.macros ) +" " +" let m_local.PICK_COMPL = file +" let m_local.PATH_COMPL = fnamemodify ( file, ':h' ) +" " +" let file = substitute ( file, '\V\^'.path, '', '' ) +" " +" let m_local.PICK = file +" let m_local.PATH = fnamemodify ( file, ':h' ) +" let m_local.FILENAME = fnamemodify ( file, ':t' ) +" let m_local.BASENAME = fnamemodify ( file, ':t:r' ) +" let m_local.SUFFIX = fnamemodify ( file, ':e' ) +" " +" let text = s:ReplaceMacros ( text, m_local, s:library.macros ) +" " +" return text +" " +" endfunction " ---------- end of function s:PreparePickFile ---------- +" " +" "---------------------------------------------------------------------- +" " s:PreparePickList : Prepare a template (pick-list). {{{2 +" "---------------------------------------------------------------------- +" " +" function! s:PreparePickList ( cmds, text ) +" " +" let regex = s:library.regex_template +" " +" let msg = 'Choose' +" let text = a:text +" let entry = '' +" " +" " ================================================== +" " command block +" " ================================================== +" " +" for line in split( a:cmds, "\n" ) +" " +" " the line will match and it will be a valid function +" let [ f_name, f_param ] = matchlist ( line, regex.FunctionChecked )[ 1 : 2 ] +" " +" if f_name == 'C' +" " ignore +" elseif f_name == 'Prompt' +" let msg = matchstr ( f_param, regex.RemoveQuote ) +" elseif f_name == 'List' +" exe 'let list = '.f_param +" elseif f_name == 'GetList' +" " +" let listname = matchstr ( f_param, regex.RemoveQuote ) +" if ! has_key ( s:library.resources, 'list!'.listname ) +" throw 'Template:Prepare:the resources "'.listname.'" does not exist' +" endif +" let list = s:library.resources[ 'list!'.listname ] +" " +" elseif f_name == 'Pick' +" let entry = matchstr ( f_param, regex.RemoveQuote ) +" endif +" " +" endfor +" " +" " ================================================== +" " get the entry +" " ================================================== +" " +" if ! exists ( 'list' ) +" throw 'Template:Check:no list specified' +" endif +" " +" if type ( list ) == type ( [] ) +" let type = 'list' +" let input_list = list +" else +" let type = 'dict' +" let input_list = sort ( keys ( list ) ) +" endif +" " +" if empty ( entry ) +" let entry = s:UserInput ( msg.' : ', '', 'customlist', input_list ) +" endif +" " +" let m_local = copy ( s:t_runtime.macros ) +" let m_local.KEY = entry +" " +" " TODO: entry might not exist +" if type == 'dict' +" let entry = list[ entry ] +" endif +" " +" let m_local.VALUE = entry +" let m_local.PICK = entry +" " +" let text = s:ReplaceMacros ( text, m_local, s:library.macros ) +" " +" return text +" " +" endfunction " ---------- end of function s:PreparePickList ---------- +" +"---------------------------------------------------------------------- +" s:PrepareStdTempl : Prepare a template (standard). {{{2 +"---------------------------------------------------------------------- +" +function! s:PrepareStdTempl ( cmds, text ) + " + " TODO: revert must work like a stack, first set, last reverted + " TODO: revert in case of PickList and PickFile + " + let regex = s:library.regex_template + let ms = regex.MacroStart + let me = regex.MacroEnd + " + let m_local = s:t_runtime.macros + let m_global = s:library.macros + let prompted = s:t_runtime.prompted + " + let text = a:text + let surround = '' + let revert = '' + " + " + " ================================================== + " command block + " ================================================== + " + let cmds = split( a:cmds, "\n" ) + let i_cmds = 0 + let n_cmds = len( cmds ) + " + while i_cmds < n_cmds + " + " the line will match and it will be a valid function + let [ f_name, f_param ] = matchlist ( cmds[ i_cmds ], regex.FunctionChecked )[ 1 : 2 ] + " + if f_name == 'C' + " ignore + elseif f_name == 'SurroundWith' + let surround = f_param + elseif f_name == 'DefaultMacro' + " + let [ m_name, m_text ] = eval ( '[ '.f_param.' ]' ) + " + if ! has_key ( m_local, m_name ) + let revert = 'call remove ( m_local, "'.m_name.'" ) | '.revert + let m_local[ m_name ] = m_text + endif + " + elseif f_name == 'PickFile' + " + let [ p_prompt, p_path ] = eval ( '[ '.f_param.' ]' ) + " + if p_path =~ regex.MacroName + if ! has_key ( s:library.resources, 'path!'.p_path ) + throw 'Template:Prepare:the resources "'.p_path.'" does not exist' + endif + let p_path = s:library.resources[ 'path!'.p_path ] + endif + " + let p_path = expand ( p_path ) + let file = s:UserInput ( p_prompt.' : ', p_path, 'file' ) + " + let m_local.PICK_COMPL = file + let m_local.PATH_COMPL = fnamemodify ( file, ':h' ) + " + let file = substitute ( file, '\V\^'.p_path, '', '' ) + " + let m_local.PICK = file + let m_local.PATH = fnamemodify ( file, ':h' ) + let m_local.FILENAME = fnamemodify ( file, ':t' ) + let m_local.BASENAME = fnamemodify ( file, ':t:r' ) + let m_local.SUFFIX = fnamemodify ( file, ':e' ) + " + elseif f_name == 'PickEntry' + " + let [ p_which, p_entry ] = eval ( '[ '.f_param.' ]' ) + " + let l:pick_entry = p_entry + " + elseif f_name == 'PickList' + " + let [ p_prompt, p_list ] = eval ( '[ '.f_param.' ]' ) + " + if type ( p_list ) == type ( '' ) + if ! has_key ( s:library.resources, 'list!'.p_list ) + throw 'Template:Prepare:the resources "'.p_list.'" does not exist' + endif + let list = s:library.resources[ 'list!'.p_list ] + else + let list = p_list + end + " + if type ( list ) == type ( [] ) + let type = 'list' + let input_list = list + else + let type = 'dict' + let input_list = sort ( keys ( list ) ) + endif + " + if exists ( 'l:pick_entry' ) + let entry = l:pick_entry + else + let entry = s:UserInput ( p_prompt.' : ', '', 'customlist', input_list ) + endif + " + let m_local.KEY = entry + " + if type == 'dict' + if ! has_key ( list, entry ) + throw 'Template:Prepare:the entry "'.entry.'" does not exist' + endif + let entry = list[ entry ] + endif + " + let m_local.VALUE = entry + let m_local.PICK = entry + " + elseif f_name == 'Prompt' + " + let [ m_name, m_flag ] = eval ( '[ '.f_param.' ]' ) + " + " not already done and not a local macro? + if ! has_key ( prompted, m_name ) + \ && ! has_key ( m_local, m_name ) + let m_text = get ( m_global, m_name, '' ) + " + " prompt user for replacement + let flagaction = get ( s:Flagactions, m_flag, '' ) " notify flag action, if any + let m_text = s:UserInput ( m_name.flagaction.' : ', m_text ) + let m_text = s:ApplyFlag ( m_text, m_flag ) + " + " save the result + let m_global[ m_name ] = m_text + let prompted[ m_name ] = 1 + endif + else + break + endif + " + let i_cmds += 1 + endwhile + " + " -------------------------------------------------- + " lists + " -------------------------------------------------- + " + while i_cmds < n_cmds + " + let mlist = matchlist ( cmds[ i_cmds ], regex.FunctionList ) + " + if empty ( mlist ) + break + endif + "echo '--'.mlist[1].'--' + " + exe 'let [ l_name, head_def, tail_def ] = ['.mlist[1].']' + let l_text = '' + if ! has_key ( m_local, l_name ) + let l_len = 0 + elseif type ( m_local[ l_name ] ) == type ( '' ) + let l_list = [ m_local[ l_name ] ] + let l_len = 1 + else + let l_list = m_local[ l_name ] + let l_len = len ( l_list ) + endif + " + if l_len == 0 + if ! empty ( cmds[ i_cmds+1 ] ) + exe 'let [ head, tail ] = '.cmds[ i_cmds+1 ] + let l_text = head.tail."\n" + endif + elseif l_len == 1 + if ! empty ( cmds[ i_cmds+2 ] ) + exe 'let [ head, tail ] = '.cmds[ i_cmds+2 ] + let l_text = head.l_list[0].tail."\n" + elseif ! empty ( cmds[ i_cmds+3 ] ) + exe 'let [ head, tail ] = '.cmds[ i_cmds+3 ] + let l_text = head.l_list[0].tail."\n" + else + let l_text = head_def.l_list[0].tail_def."\n" + end + else " l_len >= 2 + " + if ! empty ( cmds[ i_cmds+3 ] ) + exe 'let [ head, tail ] = '.cmds[ i_cmds+3 ] + let l_text .= head.l_list[0].tail."\n" + else + let l_text .= head_def.l_list[0].tail_def."\n" + endif + " + for idx in range ( 1, l_len-2 ) + let l_text .= head_def.l_list[idx].tail_def."\n" + endfor + " + if ! empty ( cmds[ i_cmds+4 ] ) + exe 'let [ head, tail ] = '.cmds[ i_cmds+4 ] + let l_text .= head.l_list[-1].tail."\n" + else + let l_text .= head_def.l_list[-1].tail_def."\n" + endif + endif + " + let text = s:LiteralReplacement ( text, ms.l_name.':LIST'.me."\n", l_text, '' ) + " + let i_cmds += 5 + endwhile + " + " ================================================== + " text block: macros and templates + " ================================================== + " + " insert other templates + while 1 + " + let mlist = matchlist ( text, regex.FunctionInsert ) + " + " no more inserts? + if empty ( mlist ) + break + endif + " + let [ f_name, f_param ] = mlist[ 1 : 2 ] + " + " check the call + call s:FunctionCheck ( f_name, f_param, s:NamespaceStdTemplInsert ) + " + if f_name == 'InsertLine' + " get the replacement + exe 'let m_text = s:PrepareTemplate ( '.f_param.' )[0]' + let m_text = m_text[ 0 : -2 ] + " check + if m_text =~ "\n" + throw 'Template:Prepare:inserts more than a single line: "'.mlist[0].'"' + endif + elseif f_name == 'Insert' + " get the replacement + exe 'let m_text = s:PrepareTemplate ( '.f_param.' )[0]' + let m_text = m_text[ 0 : -2 ] + " prepare + let mlist = matchlist ( text, '\([^'."\n".']*\)'.regex.FunctionInsert.'\([^'."\n".']*\)' ) + let head = mlist[1] + let tail = mlist[4] + let m_text = head.substitute( m_text, "\n", tail."\n".head, 'g' ).tail + else + throw 'Template:Check:the function "'.f_name.'" does not exist' + endif + " + " insert + let text = s:LiteralReplacement ( text, mlist[0], m_text, '' ) + " + endwhile + " + " insert the replacements + let text = s:ReplaceMacros ( text, m_local ) + " + " ================================================== + " surround the template + " ================================================== + " + if ! empty ( surround ) + " get the replacement + exe 'let [ s_text, s_place ] = s:PrepareTemplate ( '.surround.', "do_surround" )' + " + if s_place == 'CONTENT' + if -1 == match( s_text, '' ) + throw 'Template:Check:surround template: missing' + endif + " + let mcontext = matchlist ( s_text, '\([^'."\n".']*\)'.''.'\([^'."\n".']*\)' ) + let head = mcontext[1] + let tail = mcontext[2] + " insert + let text = text[ 0: -2 ] " remove trailing '\n' + let text = head.substitute( text, "\n", tail."\n".head, 'g' ).tail + let text = s:LiteralReplacement ( s_text, mcontext[0], text, '' ) + elseif s_place == 'SPLIT' + if -1 == match( s_text, '' ) + throw 'Template:Check:surround template: missing' + endif + " + if match( s_text, '\s*\n' ) >= 0 + let part = split ( s_text, '\s*\s*\n', 1 ) + else + let part = split ( s_text, '', 1 ) + endif + let text = part[0].text.part[1] + endif + endif + " + exe revert + " + return text + " +endfunction " ---------- end of function s:PrepareStdTempl ---------- +" +"---------------------------------------------------------------------- +" s:PrepareTemplate : Prepare a template for insertion. {{{2 +"---------------------------------------------------------------------- +" +function! s:PrepareTemplate ( name, ... ) + " + let regex = s:library.regex_template + " + " ================================================== + " setup and checks + " ================================================== + " + " check for recursion + if -1 != index ( s:t_runtime.obj_stack, a:name ) + call add ( s:t_runtime.obj_stack, a:name ) + throw 'Template:Recursion' + endif + " + call add ( s:t_runtime.obj_stack, a:name ) + " + " current style + let style = s:library.current_style + " + " get the template + let [ cmds, text, type, placement, indentation ] = s:GetTemplate ( a:name, style ) + " + " current macros + let m_local = s:t_runtime.macros + let prompted = s:t_runtime.prompted + " + let remove_cursor = 1 + let remove_split = 1 + let use_surround = 0 + let use_split = 0 + " + let revert = '' + " + " ================================================== + " parameters + " ================================================== + " + let i = 1 + while i <= a:0 + " + if a:[i] =~ regex.MacroMatch && i+1 <= a:0 + let m_name = matchlist ( a:[i], regex.MacroNameC )[1] + if has_key ( m_local, m_name ) + let revert = 'let m_local["'.m_name.'"] = '.string( m_local[ m_name ] ).' | '.revert + else + let revert = 'call remove ( m_local, "'.m_name.'" ) | '.revert + endif + let m_local[ m_name ] = a:[i+1] + let i += 2 + elseif a:[i] == '' + let remove_cursor = 0 + let i += 1 + elseif a:[i] == '' + let remove_split = 0 + let i += 1 + elseif a:[i] == 'do_surround' + let use_surround = 1 + let i += 1 + elseif a:[i] == 'use_split' + let use_split = 1 + let remove_split = 0 + let i += 1 + elseif a:[i] == 'pick' && i+1 <= a:0 + let cmds = "PickEntry( '', ".string(a:[i+1])." )\n".cmds + let i += 2 + else + if type ( a:[i] ) == type ( '' ) | call s:ErrorMsg ( 'Unknown option: "'.a:[i].'"' ) + else | call s:ErrorMsg ( 'Unknown option at position '.i.'.' ) | endif + let i += 1 + endif + " + endwhile + " + " ================================================== + " prepare + " ================================================== + " + if type == 't' + let text = s:PrepareStdTempl( cmds, text ) + elseif type == 'pick-file' + let text = s:PreparePickFile( cmds, text ) + elseif type == 'pick-list' + let text = s:PreparePickList( cmds, text ) + elseif type == 'help' + let text = s:PrepareHelp( cmds, text ) + endif + " + if remove_cursor + let text = s:LiteralReplacement( text, '', '', 'g' ) + endif + if remove_split + let text = s:LiteralReplacement( text, '', '', 'g' ) + endif + if ! use_surround || use_split + let text = s:LiteralReplacement( text, '', '', 'g' ) + endif + " + " ================================================== + " wrap up + " ================================================== + " + exe revert + " + call remove ( s:t_runtime.obj_stack, -1 ) + " + if use_split + return [ text, 'SPLIT' ] + elseif use_surround + return [ text, 'CONTENT' ] + else + return [ text, placement, indentation ] + endif + " +endfunction " ---------- end of function s:PrepareTemplate ---------- +" +"---------------------------------------------------------------------- +" s:InsertIntoBuffer : Insert a text into the buffer. {{{1 +" (thanks to Fritz Mehner) +"---------------------------------------------------------------------- +" +function! s:InsertIntoBuffer ( text, placement, indentation, flag_visual_mode ) + " + " TODO: syntax + let regex = s:library.regex_template + " + let placement = a:placement + let indentation = a:indentation == '1' + " + if a:flag_visual_mode == 0 + " -------------------------------------------------- + " command and insert mode + " -------------------------------------------------- + " + " remove the split point + let text = substitute( a:text, '\V'.'', '', 'g' ) + " + if placement == 'below' + " + exe ':'.s:t_runtime.range[1] + call s:OpenFold('below') + let pos1 = line(".")+1 + put = text + let pos2 = line(".") + " + elseif placement == 'above' + " + exe ':'.s:t_runtime.range[0] + let pos1 = line(".") + put! = text + let pos2 = line(".") + " + elseif placement == 'start' + " + exe ':1' + call s:OpenFold('start') + let pos1 = 1 + put! = text + let pos2 = line(".") + " + elseif placement == 'append' || placement == 'insert' + " + if &foldenable && foldclosed(".") >= 0 + echohl WarningMsg | echomsg s:MsgInsertionNotAvail | echohl None + return + elseif placement == 'append' + let pos1 = line(".") + put = text + let pos2 = line(".")-1 + exe ":".pos1 + :join! + let indentation = 0 + elseif placement == 'insert' + let text = text[ 0: -2 ] " remove trailing '\n' + let currentline = getline( "." ) + let pos1 = line(".") + let pos2 = pos1 + count( split(text,'\zs'), "\n" ) + "" assign to the unnamed register " : + "let @"=text + "normal p + exe 'normal! a'.text + " reformat only multi-line inserts and previously empty lines + if pos1 == pos2 && currentline != '' + let indentation = 0 + endif + endif + " + endif + " + elseif a:flag_visual_mode == 1 + " -------------------------------------------------- + " visual mode + " -------------------------------------------------- + " + " remove the jump targets (2nd type) + let text = substitute( a:text, regex.JumpTagType2, '', 'g' ) + " + " TODO: Is the behaviour well-defined? + " Suggestion: The line might include a cursor and a split and nothing else. + if match( text, '' ) >= 0 + if match( text, '\s*\n' ) >= 0 + let part = split ( text, '\s*\s*\n', 1 ) + else + let part = split ( text, '', 1 ) + endif + let part[1] = part[1][ 0: -2 ] " remove trailing '\n' + else + let part = [ "", text[ 0: -2 ] ] " remove trailing '\n' + echomsg 'SPLIT missing in template.' + endif + " + " 'visual' and placement 'insert': + " + " part0 and part1 can consist of several lines + " + " 'visual' and placement 'below': + " + " + " + " part0 and part1 can consist of several lines + " + if placement == 'insert' + " windows: register @* does not work + " solution: recover area of the visual mode and yank, + " puts the selected area into the buffer @" + normal gvy + let pos1 = line(".") + let pos2 = pos1 + let str = escape ( @", '\' ) + let repl = escape ( part[0].@".part[1], '\&~' ) + " TODO: substitute is not the best choice, + " problematic when '\V'.@* matches before the actual position + exe ':s/\V'.str.'/'.repl.'/' + let indentation = 0 + elseif placement == 'below' + :'put = part[1] + let pos1 = line("'<") - len(split(part[0], '\n' )) + let pos2 = line("'>") + len(split(part[1], '\n' )) + endif + " + endif + " + " proper indenting + if indentation + exe ":".pos1 + exe "normal ".( pos2-pos1+1 )."==" + endif + " + return [ pos1, pos2 ] + " +endfunction " ---------- end of function s:InsertIntoBuffer ---------- +" +"---------------------------------------------------------------------- +" s:PositionCursor : Position the cursor. {{{1 +" (thanks to Fritz Mehner) +"---------------------------------------------------------------------- +" +function! s:PositionCursor ( placement, flag_visual_mode, pos1, pos2 ) + " + " TODO: syntax + " + exe ":".a:pos1 + let mtch = search( '\|{CURSOR}', 'c', a:pos2 ) + if mtch != 0 " CURSOR found: + let line = getline(mtch) + if line =~ '$\|{CURSOR}$' + call setline( mtch, substitute( line, '\|{CURSOR}', '', '' ) ) + if a:flag_visual_mode == 1 && getline(".") =~ '^\s*$' + normal J + else + startinsert! + endif + else + call setline( mtch, substitute( line, '\|{CURSOR}', '', '' ) ) + :startinsert + endif + else " no CURSOR found + if a:placement == 'below' + exe ":".a:pos2 | " to the end of the block; needed for repeated inserts + endif + endif + " +endfunction " ---------- end of function s:PositionCursor ---------- +" +"---------------------------------------------------------------------- +" s:HighlightJumpTargets : Highlight the jump targets. {{{1 +"---------------------------------------------------------------------- +" +function! s:HighlightJumpTargets ( regex ) + exe 'match Search /'.a:regex.'/' +endfunction " ---------- end of function s:HighlightJumpTargets ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#InsertTemplate : Insert a template. {{{1 +"---------------------------------------------------------------------- +" +function! mmtemplates#core#InsertTemplate ( library, t_name, ... ) range + " + " TODO: check arguments, 'library' as a string + " TODO: t_name == '!pick' + " TODO: syntax for CURSOR, SPLIT, jump tags + " + " ================================================== + " setup + " ================================================== + " + " library and runtime information + let s:library = a:library + let s:t_runtime = { + \ 'obj_stack' : [], + \ 'macro_stack' : [], + \ 'macros' : {}, + \ 'prompted' : {}, + \ + \ 'placement' : '', + \ 'range' : [ a:firstline, a:lastline ], + \ } + let regex = s:library.regex_template + " + " renew the predefined macros + let s:t_runtime.macros[ 'BASENAME' ] = expand( '%:t:r' ) + let s:t_runtime.macros[ 'FILENAME' ] = expand( '%:t' ) + let s:t_runtime.macros[ 'PATH' ] = expand( '%:p:h' ) + let s:t_runtime.macros[ 'SUFFIX' ] = expand( '%:e' ) + " + let s:t_runtime.macros[ 'DATE' ] = strftime( s:library.macros[ 'DATE' ] ) + let s:t_runtime.macros[ 'TIME' ] = strftime( s:library.macros[ 'TIME' ] ) + let s:t_runtime.macros[ 'YEAR' ] = strftime( s:library.macros[ 'YEAR' ] ) + " + " handle folds internally (and save the state) + if &foldenable + let foldmethod_save = &foldmethod + set foldmethod=manual + endif + " use internal formatting to avoid conflicts when using == below + " (and save the state) + let equalprg_save = &equalprg + set equalprg= + " + let flag_visual_mode = 0 + let options = [] + " + " ================================================== + " parameters + " ================================================== + " + let i = 1 + while i <= a:0 + " + if a:[i] == 'v' || a:[i] == 'visual' + let flag_visual_mode = 1 + let i += 1 + elseif a:[i] == 'placement' && i+1 <= a:0 + let s:t_runtime.placement = a:[i+1] + let i += 2 + elseif a:[i] == 'range' && i+2 <= a:0 + let s:t_runtime.range[0] = a:[i+1] + let s:t_runtime.range[1] = a:[i+2] + let i += 3 + elseif a:[i] =~ regex.MacroMatch && i+1 <= a:0 + let name = matchlist ( a:[i], regex.MacroNameC )[1] + let s:t_runtime.macros[ name ] = a:[i+1] + let i += 2 + elseif a:[i] == 'pick' && i+1 <= a:0 + call add ( options, 'pick' ) + call add ( options, a:[i+1] ) + let i += 2 + else + if type ( a:[i] ) == type ( '' ) | call s:ErrorMsg ( 'Unknown option: "'.a:[i].'"' ) + else | call s:ErrorMsg ( 'Unknown option at position '.i.'.' ) | endif + let i += 1 + endif + " + endwhile + " + " ================================================== + " do the job + " ================================================== + " + try + " + " prepare the template for insertion + if empty ( options ) + let [ text, placement, indentation ] = s:PrepareTemplate ( a:t_name, '', '' ) + else + let [ text, placement, indentation ] = call ( 's:PrepareTemplate', [ a:t_name, '', '' ] + options ) + endif + " + if placement == 'help' + " job already done, TODO: review this + else + " + if ! empty ( s:t_runtime.placement ) + let placement = s:t_runtime.placement + endif + " + " insert the text into the buffer + let [ pos1, pos2 ] = s:InsertIntoBuffer ( text, placement, indentation, flag_visual_mode ) + " + " position the cursor + call s:PositionCursor ( placement, flag_visual_mode, pos1, pos2 ) + " + " highlight jump targets + call s:HighlightJumpTargets ( regex.JumpTagBoth ) + endif + " + catch /Template:UserInputAborted/ + " noop + catch /Template:Check:.*/ + " + let templ = s:t_runtime.obj_stack[ -1 ] + let msg = v:exception[ len( 'Template:Check:') : -1 ] + call s:ErrorMsg ( 'Checking "'.templ.'":', msg ) + " + catch /Template:Prepare:.*/ + " + let templ = s:t_runtime.obj_stack[ -1 ] + let incld = len ( s:t_runtime.obj_stack ) == 1 ? '' : '(included by: "'.s:t_runtime.obj_stack[ -2 ].'")' + let msg = v:exception[ len( 'Template:Prepare:') : -1 ] + call s:ErrorMsg ( 'Preparing "'.templ.'":', incld, msg ) + " + catch /Template:Recursion/ + " + let templ = s:t_runtime.obj_stack[ -1 ] + let idx1 = index ( s:t_runtime.obj_stack, templ ) + let cont = idx1 == 0 ? [] : [ '...' ] + call call ( 's:ErrorMsg', [ 'Recursion detected while including the template/s:' ] + cont + + \ s:t_runtime.obj_stack[ idx1 : -1 ] ) + " + catch /Template:MacroRecursion/ + " + let macro = s:t_runtime.macro_stack[ -1 ] + let idx1 = index ( s:t_runtime.macro_stack, macro ) + let cont = idx1 == 0 ? [] : [ '...' ] + call call ( 's:ErrorMsg', [ 'Recursion detected while replacing the macro/s:' ] + cont + + \ s:t_runtime.macro_stack[ idx1 : -1 ] ) + " +" catch /Template:Insert:.*/ + catch /Template:.*/ + " + let msg = v:exception[ len( 'Template:') : -1 ] + call s:ErrorMsg ( msg ) + " + finally + " + " ================================================== + " wrap up + " ================================================== + " + " restore the state: folding and formatter program + if &foldenable + exe "set foldmethod=".foldmethod_save + normal zv + endif + let &equalprg = equalprg_save + " + " remove script variables + unlet s:library + unlet s:t_runtime + " + endtry + " +endfunction " ---------- end of function mmtemplates#core#InsertTemplate ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#CreateMaps : Create maps for a template library. {{{1 +"---------------------------------------------------------------------- +" +function! mmtemplates#core#CreateMaps ( library, localleader, ... ) + " + " check the arguments + if type( a:library ) == type( '' ) + exe 'let t_lib = '.a:library + else + call s:ErrorMsg ( 'Argument "library" must be given as a string.' ) + return + endif + " + if type( a:localleader ) != type( '' ) + call s:ErrorMsg ( 'Argument "localleader" must be given as a string.' ) + return + elseif ! empty ( a:localleader ) + let maplocalleader = a:localleader + endif + " + " the commands have been generated before + if has_key ( t_lib, 'map_commands' ) + "let TimeStart = reltime() + exe t_lib.map_commands + "echo 'Executing maps: '.reltimestr( reltime( TimeStart ) ) + return + endif + " + " options + let options = ' ' + let leader = '' + let sep = "\n" + " + let do_jump_map = 0 + let do_special_maps = 0 + " + let cmd = '' + " + " parameters + let i = 1 + while i <= a:0 + " + if a:[i] == 'do_jump_map' + let do_jump_map = 1 + let i += 1 + elseif a:[i] == 'do_special_maps' + let do_special_maps = 1 + let i += 1 + else + if type ( a:[i] ) == type ( '' ) | call s:ErrorMsg ( 'Unknown option: "'.a:[i].'"' ) + else | call s:ErrorMsg ( 'Unknown option at position '.i.'.' ) | endif + let i += 1 + endif + " + endwhile + " + "let TimeStart = reltime() + " + " go through all the templates + for t_name in t_lib.temp_list + " + exe 'let [ entry, visual, shortcut, mp ] = ['.t_lib.templates[ t_name.'!!menu' ].']' + " + " no map? + if empty ( mp ) + continue + endif + " + for mode in [ 'n', 'v', 'i' ] + " + " map already existing? + if ! empty ( maparg( leader.mp, mode ) ) + if g:Templates_MapInUseWarn != 0 + call s:ErrorMsg ( 'Mapping already in use: "'.leader.mp.'", mode "'.mode.'"' ) + endif + continue + endif + " + " visual and insert mode: insert '' + if mode == 'n' | let esc = '' + else | let esc = '' | endif + " + " visual mode: template contains a split tag, or the mode is forced + if mode == 'v' && visual == 1 | let v = ',"v"' + else | let v = '' | endif + " + " assemble the command to create the maps + let cmd .= mode.'noremap '.options.' '.leader.mp.' '.esc.':call mmtemplates#core#InsertTemplate('.a:library.',"'.t_name.'"'.v.')'.sep + endfor + " + endfor + " + " jump map + if do_jump_map + let jump_key = '' " TODO: configurable + if ! empty ( maparg( jump_key ) ) + call s:ErrorMsg ( 'Mapping already in use: "'.jump_key.'"' ) + else + let jump_regex = string ( escape ( t_lib.regex_template.JumpTagBoth, '|' ) ) + let cmd .= 'nnoremap '.options.' '.jump_key.' i=mmtemplates#core#JumpToTag('.jump_regex.')'.sep + let cmd .= 'inoremap '.options.' '.jump_key.' =mmtemplates#core#JumpToTag('.jump_regex.')'.sep + endif + endif + " + " special maps + " TODO: configuration of maps + " TODO: edit template + if do_special_maps + let special_maps = { + \ 're' : ':call mmtemplates#core#EditTemplateFiles('.a:library.',-1)', + \ 'rr' : ':call mmtemplates#core#ReadTemplates('.a:library.',"reload","all")', + \ 'rs' : ':call mmtemplates#core#ChooseStyle('.a:library.',"!pick")', + \ } + "\ 'rt' : ':call mmtemplates#core#InsertTemplate('.a:library.',"!pick")', + " + for [ mp, action ] in items ( special_maps ) + if ! empty ( maparg( leader.mp ) ) + call s:ErrorMsg ( 'Mapping already in use: "'.leader.mp.'"' ) + else + let cmd .= ' noremap '.options.' '.leader.mp.' '.action.sep + let cmd .= 'inoremap '.options.' '.leader.mp.' '.action.sep + endif + endfor + endif + " + let t_lib.map_commands = cmd + exe cmd + " + "echo 'Generating maps: '.reltimestr( reltime( TimeStart ) ) + " +endfunction " ---------- end of function mmtemplates#core#CreateMaps ---------- +" +"---------------------------------------------------------------------- +" === Create Menus: Auxiliary functions. === {{{1 +"---------------------------------------------------------------------- +" +"---------------------------------------------------------------------- +" s:CreateSubmenu : Create sub-menus, given they do not already exists. {{{2 +" +" The menu 'menu' can contain '&' and a trailing '.'. Both are ignored. +"---------------------------------------------------------------------- +function! s:CreateSubmenu ( t_lib, root_menu, global_name, menu ) + " + " go through the menu, clean up and check for new menus + let submenu = '' + for part in split( a:menu, '\.' ) + let clean = substitute( part, '&', '', 'g' ) + if ! has_key ( a:t_lib.menu_existing, submenu.clean ) + " a new menu! + let a:t_lib.menu_existing[ submenu.clean ] = 1 + " + " shortcut and menu entry + if has_key ( a:t_lib.menu_shortcuts, submenu.clean ) + let shortcut = a:t_lib.menu_shortcuts[ submenu.clean ] + if stridx ( tolower( clean ), tolower( shortcut ) ) == -1 + let assemble = submenu.clean.' (&'.shortcut.')' + else + let assemble = submenu.substitute( clean, '\c'.shortcut, '\&&', '' ) + endif + else + let assemble = submenu.part + endif + " + let assemble .= '.' + " + if -1 != stridx ( clean, '' ) + exe 'amenu '.a:root_menu.escape( assemble.clean, ' ' ).' :echo "This is a menu header."' + else + exe 'amenu '.a:root_menu.escape( assemble.clean, ' ' ).''.escape( a:global_name, ' .' ).' :echo "This is a menu header."' + endif + exe 'amenu '.a:root_menu.escape( assemble, ' ' ).'-Sep00- ' + endif + let submenu .= clean.'.' + endfor + " +endfunction " ---------- end of function s:CreateSubmenu ---------- +" +"---------------------------------------------------------------------- +" s:CreateTemplateMenus : Create menus for the templates. {{{2 +"---------------------------------------------------------------------- +" +function! s:CreateTemplateMenus ( t_lib, root_menu, global_name, t_lib_name ) + " + " go through all the templates + for t_name in a:t_lib.temp_list + " + exe 'let [ entry, visual, shortcut, mp ] = ['.a:t_lib.templates[ t_name.'!!menu' ].']' + " + " no menu entry? + if entry == 0 + continue + endif + " + " get the sub-menu and the entry + let [ t_menu, t_last ] = matchlist ( t_name, '^\(.*\.\)\?\([^\.]\+\)$' )[1:2] + " + " menu does not exist? + if ! empty ( t_menu ) && ! has_key ( a:t_lib.menu_existing, t_menu[ 0 : -2 ] ) + call s:CreateSubmenu ( a:t_lib, a:root_menu, a:global_name, t_menu[ 0 : -2 ] ) + endif + " + " shortcut and menu entry + if ! empty ( shortcut ) + if stridx ( tolower( t_last ), tolower( shortcut ) ) == -1 + let t_last .= ' (&'.shortcut.')' + else + let t_last = substitute( t_last, '\c'.shortcut, '\&&', '' ) + endif + endif + " + " assemble the entry, including the map, TODO: escape the map + let compl_entry = escape( t_menu.t_last, ' ' ) + if empty ( mp ) + let map_entry = '' + else + let map_entry = '\\'.mp + end + " + if entry == 1 + " prevents problems in insert mode + exe 'amenu '.a:root_menu.compl_entry.map_entry.' :call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'")' + if visual == 1 + exe 'vmenu '.a:root_menu.compl_entry.map_entry.' :call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v")' + endif + elseif entry == 2 + call s:CreateSubmenu ( a:t_lib, a:root_menu, a:global_name, t_menu.t_last.map_entry ) + " + for item in s:GetPickList ( t_name ) + let item_entry = compl_entry.'.'.substitute ( substitute ( escape ( item, ' .' ), '&', '\&\&', 'g' ), '\w', '\&&', '' ) + exe 'amenu '.a:root_menu.item_entry.' :call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","pick",'.string(item).')' + if visual == 1 + exe 'vmenu '.a:root_menu.item_entry.' :call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v","pick",'.string(item).')' + endif + endfor + " +" exe 'amenu '.a:root_menu.compl_entry.'.-\ choose\ -'.map_entry.' :call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'")' +" if visual == 1 +" exe 'vmenu '.a:root_menu.compl_entry.'.-\ choose\ -'.map_entry.' :call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"'.t_name.'","v")' +" endif + endif + " + endfor + " +endfunction " ---------- end of function s:CreateTemplateMenus ---------- +" +"---------------------------------------------------------------------- +" s:CreateSpecialsMenus : Create menus for a template library. {{{2 +"---------------------------------------------------------------------- +" +function! s:CreateSpecialsMenus ( t_lib, root_menu, global_name, t_lib_name, specials_menu, styles_only ) + " + " TODO: expansion of the 'styles'-menu should be configurable + " + let specials_menu = a:specials_menu + let specials_menu = substitute( specials_menu, '\.$', '', '' ) + " + " new menu? + if ! has_key ( a:t_lib.menu_existing, substitute ( specials_menu, '&', '', 'g' ) ) + call s:CreateSubmenu ( a:t_lib, a:root_menu, a:global_name, specials_menu ) + endif + " + if ! a:styles_only + " create edit, reread and choose templates + exe 'amenu '.a:root_menu.specials_menu.'.&edit\ templates' + \ .' :call mmtemplates#core#EditTemplateFiles('.a:t_lib_name.',-1)' + exe 'amenu '.a:root_menu.specials_menu.'.&reread\ templates' + \ .' :call mmtemplates#core#ReadTemplates('.a:t_lib_name.',"reload","all")' + " exe 'amenu '.a:root_menu.specials_menu.'.choose\ &template' + " \ .' :call mmtemplates#core#InsertTemplate('.a:t_lib_name.',"!pick")' + endif + " + " create a menu for all the styles + for s in a:t_lib.styles + exe 'amenu '.a:root_menu.specials_menu.'.choose\ &style.'.escape( s, ' ' ) + \ .' :call mmtemplates#core#ChooseStyle('.a:t_lib_name.','.string(s).')' + endfor + " +endfunction " ---------- end of function s:CreateSpecialsMenus ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#CreateMenus : Create menus for a template library. {{{1 +"---------------------------------------------------------------------- +" +function! mmtemplates#core#CreateMenus ( library, root_menu, ... ) + " + " TODO: correct escapes + " TODO: separate special entries + " TODO: mapleader configurable + " + " check for feature + if ! has ( 'menu' ) + return + endif + " + " check the arguments + if type( a:library ) == type( '' ) + exe 'let t_lib = '.a:library + let s:library = t_lib + else + call s:ErrorMsg ( 'Argument "library" must be given as a string.' ) + return + endif + " + if type( a:root_menu ) != type( '' ) + call s:ErrorMsg ( 'Argument "root_menu" must be given as a string.' ) + return + endif + " + " prepare + let root_menu = substitute( a:root_menu, '&', '', 'g' ) + let global_name = substitute( root_menu, '\.$', '', '' ) + let root_menu = global_name.'.' + let specials_menu = '&Run' + " + let do_reset = 0 + let do_templates = 0 + let do_specials = 0 " no specials + let existing = [] + let submenus = [] + " + " parameters + let i = 1 + while i <= a:0 + " + if a:[i] == 'global_name' && i+1 <= a:0 + let global_name = a:[i+1] + let i += 2 + elseif a:[i] == 'existing_menu' && i+1 <= a:0 + if type ( a:[i+1] ) == type ( '' ) | call add ( existing, a:[i+1] ) + else | call extend ( existing, a:[i+1] ) | endif + let i += 2 + elseif a:[i] == 'sub_menu' && i+1 <= a:0 + if type ( a:[i+1] ) == type ( '' ) | call add ( submenus, a:[i+1] ) + else | call extend ( submenus, a:[i+1] ) | endif + let i += 2 + elseif a:[i] == 'specials_menu' && i+1 <= a:0 + let specials_menu = a:[i+1] + let i += 2 + elseif a:[i] == 'do_all' + let do_reset = 1 + let do_templates = 1 + let do_specials = 1 + let i += 1 + elseif a:[i] == 'do_reset' + let do_reset = 1 + let i += 1 + elseif a:[i] == 'do_templates' + let do_templates = 1 + let i += 1 + elseif a:[i] == 'do_specials' + let do_specials = 1 + let i += 1 + elseif a:[i] == 'do_styles' + let do_specials = 2 + let i += 1 + else + if type ( a:[i] ) == type ( '' ) | call s:ErrorMsg ( 'Unknown option: "'.a:[i].'"' ) + else | call s:ErrorMsg ( 'Unknown option at position '.i.'.' ) | endif + let i += 1 + endif + " + endwhile + " + " reset + if do_reset + call filter ( t_lib.menu_existing, 0 ) + endif + " + " existing menus + for name in existing + let name = substitute( name, '&', '', 'g' ) + let name = substitute( name, '\.$', '', '' ) + let t_lib.menu_existing[ name ] = 1 + endfor + " + " sub-menus + for name in submenus + call s:CreateSubmenu ( t_lib, root_menu, global_name, name ) + endfor + " + " templates + if do_templates + call s:CreateTemplateMenus ( t_lib, root_menu, global_name, a:library ) + endif + " + " specials + if do_specials == 1 + " all specials + call s:CreateSpecialsMenus ( t_lib, root_menu, global_name, a:library, specials_menu, 0 ) + elseif do_specials == 2 + " styles only + call s:CreateSpecialsMenus ( t_lib, root_menu, global_name, a:library, specials_menu, 1 ) + endif + " + " wrap up + unlet s:library + " +endfunction " ---------- end of function mmtemplates#core#CreateMenus ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#ChooseStyle : Choose a style. {{{1 +"---------------------------------------------------------------------- +" +function! mmtemplates#core#ChooseStyle ( library, style ) + " + " check the arguments + if type( a:library ) == type( '' ) + exe 'let t_lib = '.a:library + elseif type( a:library ) == type( {} ) + let t_lib = a:library + else + call s:ErrorMsg ( 'Argument "library" must be given as a dict or string.' ) + return + endif + " + if type( a:style ) != type( '' ) + call s:ErrorMsg ( 'Argument "style" must be given as a string.' ) + return + endif + " + " pick and change the style + if a:style == '!pick' + try + let style = s:UserInput( 'Style (currently '.t_lib.current_style.') : ', '', + \ 'customlist', t_lib.styles ) + catch /Template:UserInputAborted/ + return + endtry + else + let style = a:style + endif + " + " check the new style + if style == '' + " noop + elseif -1 != index ( t_lib.styles, style ) + if t_lib.current_style != style + let t_lib.current_style = style + echo 'Changed style to "'.style.'".' + endif + else + call s:ErrorMsg ( 'Style was not changed. Style "'.style.'" is not available.' ) + end + " +endfunction " ---------- end of function mmtemplates#core#ChooseStyle ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#Resource : Access to various resources. {{{1 +"---------------------------------------------------------------------- +function! mmtemplates#core#Resource ( library, mode, ... ) + " + " TODO mode 'special' for |DATE|, |TIME| and |year| + " + " check the arguments + if type( a:library ) == type( '' ) + exe 'let t_lib = '.a:library + elseif type( a:library ) == type( {} ) + let t_lib = a:library + else + return [ '', 'Argument "library" must be given as a dict or string.' ] + endif + " + if type( a:mode ) != type( '' ) + return [ '', 'Argument "mode" must be given as a string.' ] + endif + " + " some specials? + if a:mode == 'get' || a:mode == 'set' + " continue below + elseif a:mode == 'style' + return [ t_lib.current_style, '' ] + elseif a:mode == 'jumptag' + return [ t_lib.regex_template.JumpTagBoth, '' ] + else + return [ '', 'Mode "'.a:mode.'" is unknown.' ] + endif + " + " type of 'resource' + let types = { 'macro' : 's', 'path' : 's', 'list' : '[ld]' } + " + " additional arguments + if a:mode == 'get' && a:0 < 2 + return [ '', 'Mode "get" requires two additional arguments.' ] + elseif a:mode == 'set' && a:0 < 3 + return [ '', 'Mode "set" requires three additional arguments.' ] + elseif type( a:1 ) != type( '' ) + return [ '', 'Argument "resource" must be given as a string.' ] + elseif type( a:2 ) != type( '' ) + return [ '', 'Argument "key" must be given as a string.' ] + elseif ! has_key ( types, a:1 ) + return [ '', 'Resource "'.a:1.'" does not exist.' ] + endif + " + let resource = a:1 + let key = a:2 + " + " operation: 'get', 'set' or special? + if a:mode == 'get' + " + " get + if resource == 'macro' + return [ get( t_lib.macros, key ), '' ] + elseif resource == 'path' + return [ get( t_lib.resources, 'path!'.key ), '' ] + elseif resource == 'list' + return [ get( t_lib.resources, 'list!'.key ), '' ] + endif + " + elseif a:mode == 'set' + " + let value = a:3 + " + " check type and set + if s:TypeNames[ type( value ) ] !~ types[ resource ] + return [ '', 'Argument "value" has the wrong type.' ] + elseif resource == 'macro' + let t_lib.macros[ key ] = value + elseif resource == 'path' + let t_lib.resources[ 'path!'.key ] = value + elseif resource == 'list' + let t_lib.resources[ 'list!'.key ] = value + endif + " + return [ 0, '' ] + endif + " +endfunction " ---------- end of function mmtemplates#core#Resource ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#ExpandText : Expand the macros in a text. {{{1 +"---------------------------------------------------------------------- +function! mmtemplates#core#ExpandText ( library, text ) + " + " check the arguments + if type( a:library ) == type( '' ) + exe 'let t_lib = '.a:library + elseif type( a:library ) == type( {} ) + let t_lib = a:library + else + return s:ErrorMsg ( 'Argument "library" must be given as a dict or string.' ) + endif + " + if type( a:text ) != type( '' ) + return s:ErrorMsg ( 'Argument "text" must be given as a string.' ) + endif + " + " runtime environment + let s:library = t_lib + let s:t_runtime = { + \ 'macro_stack' : [], + \ } + " + " renew the predefined macros + let m_local = {} + let m_local[ 'BASENAME' ] = expand( '%:t:r' ) + let m_local[ 'FILENAME' ] = expand( '%:t' ) + let m_local[ 'PATH' ] = expand( '%:p:h' ) + let m_local[ 'SUFFIX' ] = expand( '%:e' ) + " + let m_local[ 'DATE' ] = strftime( t_lib.macros[ 'DATE' ] ) + let m_local[ 'TIME' ] = strftime( t_lib.macros[ 'TIME' ] ) + let m_local[ 'YEAR' ] = strftime( t_lib.macros[ 'YEAR' ] ) + " + let res = '' + " + try + let res = s:ReplaceMacros ( a:text, m_local ) + catch /Template:MacroRecursion/ + " + let macro = s:t_runtime.macro_stack[ -1 ] + let idx1 = index ( s:t_runtime.macro_stack, macro ) + let cont = idx1 == 0 ? [] : [ '...' ] + call call ( 's:ErrorMsg', [ 'Recursion detected while replacing the macro/s:' ] + cont + + \ s:t_runtime.macro_stack[ idx1 : -1 ] ) + " + catch /Template:.*/ + " + let msg = v:exception[ len( 'Template:') : -1 ] + call s:ErrorMsg ( msg ) + " + finally + unlet s:library + unlet s:t_runtime + endtry + " + return res + " +endfunction " ---------- end of function mmtemplates#core#ExpandText ---------- +" +"---------------------------------------------------------------------- +" mmtemplates#core#JumpToTag : Access to various resources. {{{1 +"---------------------------------------------------------------------- +function! mmtemplates#core#JumpToTag ( regex ) + " + let match = search( a:regex, 'c' ) + if match > 0 + " remove the target + call setline( match, substitute( getline('.'), a:regex, '', '' ) ) + endif + " + return '' +endfunction " ---------- end of function mmtemplates#core#JumpToTag ---------- +" +"------------------------------------------------------------------------------- +" mmtemplates#core#EditTemplateFiles : Choose and edit a template file. {{{1 +"------------------------------------------------------------------------------- +function! mmtemplates#core#EditTemplateFiles ( library, file ) + " + " check the arguments + if type( a:library ) == type( '' ) + exe 'let t_lib = '.a:library + elseif type( a:library ) == type( {} ) + let t_lib = a:library + else + return s:ErrorMsg ( 'Argument "library" must be given as a dict or string.' ) + endif + " + if type( a:file ) == type( 0 ) + let file = t_lib.library_files[ a:file ] + elseif type( a:file ) == type( '' ) + " + let file = expand ( a:file ) + let file = s:ConcatNormalizedFilename ( file ) + " + if ! filereadable ( file ) + return s:ErrorMsg ( 'The file "'.file.'" does not exist.' ) + elseif index ( t_lib.library_files, file ) == -1 + return s:ErrorMsg ( 'The file "'.file.'" is not part of the template library.' ) + endif + " + else + return s:ErrorMsg ( 'Argument "file" must be given as an integer or string.' ) + endif + " + " get the directory + let dir = fnamemodify ( file, ':h' ) + " + " TODO: method configurable + let method = 'explore' + let templatefile = '' + " + if ! filereadable ( file ) + return s:ErrorMsg ( 'The directory "'.dir.'" does not exist.' ) + elseif method == 'explore' + " open a file explorer + if ! exists ( 'g:loaded_netrwPlugin' ) | return s:ErrorMsg ( 'The plugin "netrw" is not available.' ) | endif + exe 'update! | split | Explore '.dir + elseif method == 'browse' + " open a file browser + if ! has ( 'browse' ) | return s:ErrorMsg ( 'The command "browse" is not available.' ) | endif + let templatefile = browse ( 0, 'edit a template file', dir, '' ) + " returns an empty string if "Cancel" is pressed + endif + " + " open a buffer and start editing + if ! empty ( templatefile ) + exe 'update! | split | edit '.templatefile + endif + " +endfunction " ---------- end of function mmtemplates#core#EditTemplateFiles ---------- +" +"------------------------------------------------------------------------------- +" mmtemplates#core#ChangeSyntax : Change the syntax of the templates. {{{1 +"------------------------------------------------------------------------------- + +function! mmtemplates#core#ChangeSyntax ( library, category, ... ) + " + " check the arguments + if type( a:library ) == type( '' ) + exe 'let t_lib = '.a:library + elseif type( a:library ) == type( {} ) + let t_lib = a:library + else + return s:ErrorMsg ( 'Argument "library" must be given as a dict or string.' ) + endif + " + if type( a:category ) != type( '' ) + return s:ErrorMsg ( 'Argument "category" must be given as an integer or string.' ) + endif + " + if a:category == 'comment' + " + if a:0 < 1 + return s:ErrorMsg ( 'Not enough arguments for '.a:category.'.' ) + elseif a:0 == 1 + let t_lib.regex_settings.CommentStart = a:1 + let t_lib.regex_settings.CommentHint = a:1[0] + elseif a:0 == 2 + let t_lib.regex_settings.CommentStart = a:1 + let t_lib.regex_settings.CommentHint = a:2[0] + endif + " + call s:UpdateFileReadRegex ( t_lib.regex_file, t_lib.regex_settings ) + " + else + return s:ErrorMsg ( 'Unknown category: '.a:category ) + endif + " +endfunction " ---------- end of function mmtemplates#core#ChangeSyntax ---------- +" }}}1 +" +" ===================================================================================== +" vim: foldmethod=marker diff --git a/README.csupport b/c-support/README.csupport similarity index 85% rename from README.csupport rename to c-support/README.csupport index 2f6381b..0c3dde3 100644 --- a/README.csupport +++ b/c-support/README.csupport @@ -1,4 +1,4 @@ -README for c.vim (Version 5.18) / March 03 2012 +README for c.vim (Version 6.0) / August 17 2012 * DESCRIPTION * INSTALLATION @@ -52,11 +52,11 @@ value of $HOME with ":echo $HOME" from inside Vim). '$HOME/.vim/c-support/templates/Templates' Here is the minimal personalization (my settings as an example): - |AUTHOR| = Dr. Fritz Mehner - |AUTHORREF| = fgm - |EMAIL| = mehner@fh-swf.de - |COMPANY| = FH Südwestfalen, Iserlohn - |COPYRIGHT| = Copyright (c) |YEAR|, |AUTHOR| + SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) + SetMacro( 'AUTHORREF', 'fgm' ) + SetMacro( 'EMAIL', 'mehner.fritz@fh-swf.de' ) + SetMacro( 'ORGANIZATION','FH Südwestfalen, Iserlohn' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) (Read more about the template system in the plugin documentation) @@ -70,7 +70,6 @@ value of $HOME with ":echo $HOME" from inside Vim). for your .vimrc and .gvimrc. You may want to use parts of them. The files are documented. - (2) WINDOWS ------------ @@ -102,15 +101,15 @@ the value of $HOME with ":echo $HOME" from inside Vim). '$HOME/vimfiles/c-support/templates/Templates' Here is the minimal personalization (my settings as an example): - |AUTHOR| = Dr. Fritz Mehner - |AUTHORREF| = fgm - |EMAIL| = mehner@fh-swf.de - |COMPANY| = FH Südwestfalen, Iserlohn - |COPYRIGHT| = Copyright (c) |YEAR|, |AUTHOR| + SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) + SetMacro( 'AUTHORREF', 'fgm' ) + SetMacro( 'EMAIL', 'mehner.fritz@fh-swf.de' ) + SetMacro( 'ORGANIZATION','FH Südwestfalen, Iserlohn' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) (Read more about the template system in the plugin documentation) -(2.4) Make the plugin help accessable by typing the following command on the +(2.4) Make the plugin help accessible by typing the following command on the Vim command line: :helptags $HOME\vimfiles\doc\ @@ -149,9 +148,19 @@ Any problems ? See the TROUBLESHOOTING section at the end of the help file ================================================================================ RELEASE NOTES ================================================================================ -- Hotkeys \lcs, \ucs removed. -- Bugfix: delayed template initialization missing correct style. -- Wrong cursor position when inserting some templates at the end of a line. + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + ++ The plug-in version 6.0+ is a rewriting of version 5.19. ++ + ++ The versions 6.0+ are based on a new and more powerful template system ++ + ++ (please see |template-support|for more information). ++ + ++ The template syntax has changed! ++ + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +- New template system (many thanks to Wolfgang Mehner) +- A few new hotkeys and menu item. +- A few hotkeys and menu items renamed. Please see file ./c-support/doc/ChangeLog . @@ -161,6 +170,8 @@ Any problems ? See the TROUBLESHOOTING section at the end of the help file README.csupport This file. +autoload/mmtemplates/core.vim The template system. + doc/csupport.txt The help file for the local on-line help. ftplugin/c.vim A file type plug-in. Define hotkeys, creates a @@ -187,6 +198,7 @@ c-support/wordlists/stl_index.list STL: method and type names. c-support/doc/c-hotkeys.pdf Hotkey reference card. c-support/doc/ChangeLog The change log. +rc/customization.cpp.vim Additional mappings for C++. rc/customization.ctags Additional settings I use in .ctags to enable navigation through makefiles ans qmake files with the plug-in taglist.vim. diff --git a/c-support/codesnippets/Makefile b/c-support/codesnippets/Makefile index 96bc7a0..aedf875 100644 --- a/c-support/codesnippets/Makefile +++ b/c-support/codesnippets/Makefile @@ -23,7 +23,7 @@ # Prerequisites are generated automatically; makedepend is not # needed (see documentation for GNU make Version 3.81, April 2006, # section 4.13). The utility sed is used. -#========================================== makefile template version 1.9 ====== +#========================================== makefile template version 1.10 ===== # DEBUG can be set to YES to include debugging info, or NO otherwise DEBUG := YES @@ -49,22 +49,6 @@ RELEASE_CFLAGS := -Wall -ansi -pedantic -O3 DEBUG_LDFLAGS := -g RELEASE_LDFLAGS := -ifeq (YES, ${DEBUG}) - CFLAGS := ${DEBUG_CFLAGS} - CXXFLAGS := ${DEBUG_CXXFLAGS} - LDFLAGS := ${DEBUG_LDFLAGS} -else - CFLAGS := ${RELEASE_CFLAGS} - CXXFLAGS := ${RELEASE_CXXFLAGS} - LDFLAGS := ${RELEASE_LDFLAGS} -endif - -ifeq (YES, ${PROFILE}) - CFLAGS := ${CFLAGS} -pg -O3 - CXXFLAGS := ${CXXFLAGS} -pg -O3 - LDFLAGS := ${LDFLAGS} -pg -endif - # ------------ additional system include directories ------------------------- GLOBAL_INC_DIR = @@ -99,6 +83,22 @@ EXE_CMDLINE = # The following statements usually need not to be changed #=============================================================================== +ifeq (YES, ${DEBUG}) + CFLAGS := ${DEBUG_CFLAGS} + CXXFLAGS := ${DEBUG_CXXFLAGS} + LDFLAGS := ${DEBUG_LDFLAGS} +else + CFLAGS := ${RELEASE_CFLAGS} + CXXFLAGS := ${RELEASE_CXXFLAGS} + LDFLAGS := ${RELEASE_LDFLAGS} +endif + +ifeq (YES, ${PROFILE}) + CFLAGS := ${CFLAGS} -pg -O3 + CXXFLAGS := ${CXXFLAGS} -pg -O3 + LDFLAGS := ${LDFLAGS} -pg +endif + C_SOURCES = $(filter %.c, $(SOURCES)) CPP_SOURCES = $(filter-out %.c, $(SOURCES)) ALL_INC_DIR = $(addprefix -I, $(LOCAL_INC_DIR) $(GLOBAL_INC_DIR)) @@ -188,6 +188,7 @@ tarball: @lokaldir=`pwd`; lokaldir=$${lokaldir##*/}; \ rm --force $$lokaldir.tar.gz; \ tar --exclude=$(TARBALL_EXCLUDE) \ + --exclude=$(EXECUTABLE) \ --create \ --gzip \ --verbose \ @@ -196,7 +197,7 @@ tarball: # ------------ zip ------------------------------------------------------------- zip: @lokaldir=`pwd`; lokaldir=$${lokaldir##*/}; \ - zip -r $$lokaldir.zip * -x $(ZIP_EXCLUDE) + zip -r $$lokaldir.zip * -x $(ZIP_EXCLUDE) -x ${EXECUTABLE} .PHONY: clean tarball zip diff --git a/c-support/codesnippets/Makefile.multi-target.template b/c-support/codesnippets/Makefile.multi-target.template index 75da8dd..ab5bc14 100644 --- a/c-support/codesnippets/Makefile.multi-target.template +++ b/c-support/codesnippets/Makefile.multi-target.template @@ -3,27 +3,27 @@ # File: Makefile # Description: # -# Usage: make (generate executable(s) ) -# make clean (remove objects, executables, prerequisits ) -# make tarball (generate compressed archive ) -# make zip (generate compressed archive ) +# Usage: make (generate executable(s) ) +# make clean (remove objects, executables ) +# make tarball (generate compressed archive ) +# make zip (generate compressed archive ) # # Author: Dr.-Ing. Fritz Mehner # Email: mehner@mfh-iserlohn.de -# Created: +# Created: 03.04.2012 # #=============================================================================== +TARGETS = target1 target2 CC = gcc CCP = g++ CFLAGS = -c -g -Wall LFLAGS = -g SYS_LIBS = -lm -TARBALL_EXCLUDE = "*.{o,gz,zip}" -ZIP_EXCLUDE = *.o *.gz *.zip +TARBALL_INCLUDE = *.{c,h,cc,hh} Makefile +ZIP_INCLUDE = $(TARBALL_INCLUDE) -TARGETS = target_1 target_2 #---------- targets -------------------------------------- all: $(TARGETS) @@ -35,36 +35,31 @@ all: $(TARGETS) $(CCP) $(CFLAGS) $*.cc #---------- target 1 ------------------------------------- -# C target -target_1: target_1.o +# ----- C target +target1: target1.o $(CC) $(LFLAGS) -o $@ $@.o $(SYS_LIBS) #---------- target 2 ------------------------------------- -# C++ target -target_2: target_2.o +# ----- C++ target +target2: target2.o $(CCP) $(LFLAGS) -o $@ $@.o $(SYS_LIBS) - -#---------- target 3 ------------------------------------- - - - #---------- tarball -------------------------------------- tarball: - lokaldir=`pwd`; lokaldir=$${lokaldir##*/}; \ + @lokaldir=`pwd`; lokaldir=$${lokaldir##*/};\ rm --force $$lokaldir.tar.gz; \ - tar --exclude=$(TARBALL_EXCLUDE) \ - --create \ + tar --create \ --gzip \ --verbose \ - --file $$lokaldir.tar.gz * + --file $$lokaldir.tar.gz \ + $(TARBALL_INCLUDE) #---------- zip ------------------------------------------ zip: - lokaldir=`pwd`; lokaldir=$${lokaldir##*/}; \ - zip -r $$lokaldir.zip * -x $(ZIP_EXCLUDE) + @lokaldir=`pwd`; lokaldir=$${lokaldir##*/};\ + zip -r $$lokaldir.zip $(ZIP_INCLUDE) #---------- clear up ------------------------------------- clean: - rm --force $(EXECUTABLE) $(OBJECTS) $(PREREQUISITES) + rm --force $(TARGETS) *.o diff --git a/c-support/codesnippets/Makefile.pro b/c-support/codesnippets/Makefile.pro new file mode 100644 index 0000000..f9867a2 --- /dev/null +++ b/c-support/codesnippets/Makefile.pro @@ -0,0 +1,21 @@ +#======================================================================================= +# +# Filename: Makefile.pro +# Description: qmake project file +# +# Usage: qmake +# +# Version: 1.0 +# Created: +# Revision: --- +# Author: +# Company: +# Email: +#======================================================================================= + +TEMPLATE = app +CONFIG = debug warn_on +SOURCES += +HEADERS += +TARGET = + diff --git a/c-support/doc/ChangeLog b/c-support/doc/ChangeLog new file mode 100644 index 0000000..fc47d8f --- /dev/null +++ b/c-support/doc/ChangeLog @@ -0,0 +1,497 @@ +================================================================================ + RELEASE NOTES FOR VERSION 5.19 +================================================================================ +- Resolve home for linked home directories. +- Three C++-items removed (see file 'customization.cpp.vim'). +- Bugfix: global options changed unintentionally. +- Minor improvements and bugfixes. + +================================================================================ + RELEASE NOTES FOR VERSION 5.18 +================================================================================ +- Hotkeys \lcs, \ucs removed. +- Bugfix: delayed template initialization missing correct style. +- Wrong cursor position when inserting some templates at the end of a line. + + +================================================================================ + RELEASE NOTES FOR VERSION 5.17 +================================================================================ +- Two new plugin tags: LICENSE,ORGANIZATION +- System-wide installation: minimal Template file for a user will automatically + be added. +- New menu item and hotkey: choose a makefile. +- New idiom: realloc. +- New preprocessor item: #if #endif. +- New hotkeys: \ire, \ifs, \ifp, \pif. + +================================================================================ + RELEASE NOTES FOR VERSION 5.16.1 +================================================================================ +- Bugfix: problem with a system-wide installation under Windows (thanks to Ricardo Vrech). + +================================================================================ + RELEASE NOTES FOR VERSION 5.16 +================================================================================ +- Plugin loads faster: loading the templates is delayed until the first use. +- Plugin now works with pathogen.vim. +- Menus will always be generated (for the use with :emenu). +- Bugfix: no local templates available with a system-wide installation (thanks to Iain Arnell). +- Several improvements. + +================================================================================ + RELEASE NOTES FOR VERSION 5.15 +================================================================================ +- New hotkey \cx C to C++ comments and vice versa. +- Several hotkeys allow a range, e.g. '3\cl' (see help text and c-hotkey.pdf). +- Improved prototype picking: \nf, \np picks up a function prototype, + \nm picks up a method prototype (see documentation for more). +- include-statements will now be inserted in the actual line (before: new line + below the actual line). +- Several minor improvements. + +================================================================================ + RELEASE NOTES FOR VERSION 5.14 +================================================================================ +- A makefile can be run with C-F9 +- Linking ( Run menu, \rl, \rr ) will be suppressed if buffer contains no main function. +- Bugfix: correctly deactivate unwanted compiler messages in a quickfix buffer. +- Several minor improvements + +================================================================================ + RELEASE NOTES FOR VERSION 5.13 +================================================================================ +- New hotkeys \rmc (run 'make clean') and \rme (executable to run). +- Hotkeys for make are working when in a makefile. +- Linker errors and errors during a make will be shown in a quickfix buffer. +- Bugfix: detection of a systemwide installation can fail. +- Bugfix: preprocessor directive '#if 0 #endif' not working. + +================================================================================ + RELEASE NOTES FOR VERSION 5.12 +================================================================================ +- New hotkeys \+" . +- Windows: user installation now possible. +- Bugfixe: for-idiom shows part of type definition as variable name in some cases. +- Bugfixe: wrong cursor position for some templates. +================================================================================ + RELEASE NOTES FOR VERSION 5.11 +================================================================================ +- New tag {CURSOR} to avoid indent problems in a few cases. +- Three hotkeys renamed \rg -> \rma , \ri -> \rpa , \re -> \rka (better to remember). +- 'long long' added to the for-idioms. +- Bugfixes: for-idiom shows type as variable name if no variable name was given. +- Bugfixes: for-idiom inserts standard types with 2+ words wrong. +- Bugfixes: multiline end-of-line comments have wrong position in some cases. +- Bugfixes: local installation looks like a system-wide installation in seldom cases. + +================================================================================ + RELEASE NOTES FOR VERSION 5.10 +================================================================================ +- The plugin now handles different template styles without editing and + reloading the main template file. +- The number of template styles is not limited. +- New hotkey and ex-command to switch template styles. +- Template styles can automatically be related to file extensions. +- indent(1) errors will be presented in a quickfix error window. +- Comment alignment improved. +- Minor improvements. + +================================================================================ + RELEASE NOTES FOR VERSION 5.9 +================================================================================ ++ Two additional hotkeys (+ ex commands) for preprocessor statements. ++ Compile-link-run: improved error detection. ++ Menu Run: hardcopy can print any buffer. ++ Several minor improvements and bugfixes. + +================================================================================ + RELEASE NOTES FOR VERSION 5.8 +================================================================================ ++ Hotkeys are shown in the menus. ++ File browser for code snippets and templates choosable (2 global variables). ++ Two new hotkeys: include file description (implementation, header). ++ New menu item: namespace alias ++ Bugfix: wrapper script for use of a xterm could not handle parameters containing blanks. ++ Several minor improvements. + +================================================================================ + RELEASE NOTES FOR VERSION 5.7 +================================================================================ ++ 4 new hotkeys : insert file section comments (C/C++/H), special comments, + keyword comments. ++ Adjusting end-of-line comment adjustment improved. + +================================================================================ + RELEASE NOTES FOR VERSION 5.6 +================================================================================ ++ Jump targets (templates) and mapping Ctrl-j can be switched off. ++ Yet unused jump targets will be highlighted after a file is opened. ++ Statements menu: else block (key mapping \se). ++ Handling of improved (templates). ++ Minor improvements. + +================================================================================ + RELEASE NOTES FOR VERSION 5.5 +================================================================================ ++ Additional plugin-tags (jump targets in templates): <+text+>, <-text->. ++ Additional mapping Ctrl-j : jump to these new targets. ++ Template-file: additional macro |STYLE| and IF-ENDIF-construct to easily + choose between sets of templates. ++ Additional mapping: auto-complete classical C comment (also multi-line). ++ Additional mapping: auto-complete open block starting with { . ++ Visual mode for date and time insertion (menu 'Comments'). ++ Visual mode for tags (submenu 'Comments->tags (plugin)'). ++ Bugfix: hotkey \ica not working ++ Bugfix: hotkey Shift-F2 for the alternate-plugin disappeared. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.4 +======================================================================================= ++ New hotkey \+co inserts ' cout << << endl;' ++ New menu item C++-menu: 'cout' replaces 'cout variable' and 'cout string'. ++ Hotkey \c/ removed ( \cc does the same). ++ Bugfix: after an unsuccessful compilation screen sometimes garbled. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.3 +======================================================================================= ++ Insertions work properly when folding is used. ++ Menu items Idioms->for(...) : type declaration for loop variable possible (tab completion). ++ Specification of command line arguments (Run->cmd. line arg.): filename completion active. ++ New main menu item 'show manual' (hotkey \hm): read manual for word under cursor. ++ One hotkey renamed: \h -> \hp (help plugin) + +======================================================================================= + RELEASE NOTES FOR VERSION 5.2.1 +======================================================================================= ++ Bugfix: stray characters whith three dialogs ++ Bugfix: Missing parameter in 2 internal function calls ++ Menu items 'Snippets->edit local/global templates' start an file browser (convenience). + +======================================================================================= + RELEASE NOTES FOR VERSION 5.2 +======================================================================================= ++ Superfluous control characters for mode switching (menus, hotkeys) removed. Caused beeps. ++ Template files (local/global) can be opened from the snippet menu. ++ Three new preprocessor statements. ++ v-mode for RTTI-entries. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.1 +======================================================================================= ++ Definition and implementation of classes have now different templates and menu entries. ++ Accessor methods (get/set) can be generated. ++ New templates: everything other than language keywords comes from a template + (and is user changeable). + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.5 +======================================================================================= ++ Bugfix: on a few systems doubling of path components in the run command (F9). + Skip this upgrade if you do not have this problem. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.4 +======================================================================================= ++ Format for the macros |DATE|, |TIME|, and |YEAR| can be defined by the user. ++ Help text improved. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.3 +======================================================================================= ++ Code snippets can now be used in the console mode (Vim without GUI). ++ Bugfix: Possible conflict with 'indent' removed when inserting templates. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.2 +======================================================================================= ++ Bugfix: Prototype picker did not alway delete no longer used prototypes. ++ Bugfix: Prototype picker removed template specializations from parameter lists. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0.1 +======================================================================================= ++ Bugfix: autocmd setting can influence autocmd settings of OTHER plugins. + +======================================================================================= + RELEASE NOTES FOR VERSION 5.0 +======================================================================================= ++ Completely new template system. Now every menu item is user definable. ++ Changes to allow a system-wide installation. ++ A few hotkeys added and renamed. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.6.1 +======================================================================================= ++ New global variable to control the filetype of *.h header files (default is now 'cpp'). ++ Bugfix: properly resetting 'compiler' after using make, splint, and CodeCheck. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.6 +======================================================================================= ++ New insert mode mappings (comments, statements, preprocessing, idioms, C++). ++ Some mappings renamed (easier to remember). ++ New tag (basename of a file reduced to characters allowed in names). + +======================================================================================= + RELEASE NOTES FOR VERSION 4.5 +======================================================================================= ++ New menu item and hotkey for the (re)alignement of end-of-line comments. ++ Hotkey \cn removed. Only one menu item for end-of-line comments left. ++ Changed hotkeys: \ce -> \cl and \cl -> \cs . ++ Three new tags (giving the basename of a file) for writing template files. ++ Prototype picker handles template methods. ++ Bugfix: splint works now under Windows. ++ Minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.4 +======================================================================================= ++ Plugin directories rearranged. ++ main- and for-idiom have a visual mode now. ++ Four new commands (command line) to control the comment style. ++ Comment style (C/C++) can automatically follow the filetype. ++ Bugfix: empty new file after removing the header template can't be closed. ++ Bugfix : Tools entry missing when root menu not shown from the start. ++ Minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.3 +======================================================================================= ++ CodeCheck (TM) integrated (source code analysing tool). ++ New key mappings for preprocessor statements. ++ New preprocessor menu. ++ Bugfix: indent under Windows. ++ Minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.2.1 +======================================================================================= ++ Bugfix: change needed for some menu names after patch 7.0.054 . + +======================================================================================= + RELEASE NOTES FOR VERSION 4.2 +======================================================================================= ++ Setting the starting column for trailing comments improved. ++ Small bug in block uncommenting fixed. ++ Mac OS X : circumvent a Vim bug which caused a crash when loading plugin version 4.1. ++ File syntax/c.vim removed (but see help in csupport.txt). + +======================================================================================= + RELEASE NOTES FOR VERSION 4.1 +======================================================================================= ++ A complete switch statement can be made from a list of labels. ++ Additional cases can be made from a list of labels. ++ Small bug in line end commenting fixed. ++ Some minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 4.0 +======================================================================================= + ++ Kernighan & Ritchie style for block statements can be enabled. ++ Changes to make it compatible with Vim 7. ++ Set C/C++ file type for source files which should not be preprocessed (*.i, *.ii). ++ Some minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.11 +======================================================================================= + ++ Hotkeys and an accompanying reference card added. ++ Preparation for syntax based folding. ++ Some minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.10 +======================================================================================= + ++ Remove "#if 0 ... #endif" from the inside. ++ Change C comments to C++ comments and vice versa. ++ try..catch / catch / catch(...) now can be set surround a marked area. ++ Prototype picking improved (for C++). ++ A hardcopy shows the localized date and time in the header line. ++ New help menu entry in the main menu of this plugin (shows the plugin documentation). ++ Switch between corresponding source and header files with if the plugin a.vim + is present. ++ Plugin can be used with autocompletion for (, [, and { . + +======================================================================================= + RELEASE NOTES FOR VERSION 3.9.1 +======================================================================================= + ++ Doubling of file header for new c- and h-files under Windows fixed (Thanks to + Fabricio C A Oliveira). ++ Tiny bug in the file open idioms fixed. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.9 +======================================================================================= + ++ Formatter 'indent' integrated. ++ Bugfix in the automatic header insertion. ++ Assert idiom added. ++ #if 0 ... #endif statement for blocking out code added. ++ Minor stylistic improvements in some idioms. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.8.2 +======================================================================================= + ++ Screen update problem solved: color inversion under FC4 (Thanks to Bernie Barton). ++ RTTI menu : additional v-mode. ++ Statement menu and C++ menu rearranged. ++ Include guard : name generation improved. ++ File header templates will be included for additional file extensions (cp, cxx, c++, ...). + +======================================================================================= + RELEASE NOTES FOR VERSION 3.8.1 +======================================================================================= + ++ More C++ output manipulators, manipulator insertion more intuitive. ++ Output into buffer: cursor goes to top of file. ++ Makefile template improved (code snippet). ++ Some internal improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.8 +======================================================================================= + ++ Windows support. Most features are now available under Windows. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.7.2 +======================================================================================= + ++ Run buffer through splint (A tool for statically checking C programs; see + http://www.splint.org). An error window will be opened; quickfix commands can be used. ++ Set buffer related command line arguments for splint. ++ Line end comments start in a fixed column (can be set from the menu). ++ Spaces in path names and file names are now possible. ++ Template files and snippet files are no longer kept in the list of alternate files. ++ Some minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.7.1 +======================================================================================= + ++ Bug fixed (command line arguments not passed to the executable). ++ File extension for executables can be set. ++ Minor improvements. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.7 +======================================================================================= + ++ Running a program: + (1) Run program from the gVim command line. + (2) Run program and direct the output into a window with name "C-Output". + This buffer and its content will disappear when closing the window. + The buffer is reused when still open. + (3) Run program in an xterm (adjustable). ++ Command line arguments are now buffer related (each buffer can have its own arguments). ++ Code snippets can be protected from being indented during insertion. ++ Picked up prototypes will be deleted after insertion. ++ A code snippet with the file name extension "ni" or "noindent" will not be + indented on insertion. ++ for- and calloc-/malloc-idioms improved. ++ Bug fixed (word list handling). + + +======================================================================================= + RELEASE NOTES FOR VERSION 3.6 +======================================================================================= + ++ Installation simplified. ++ for-loop-idiom asks for control variable, initial value, ... ++ malloc-idiom asks for pointer variable and size. ++ Toggling the comment style works correct again. ++ Empty error windows will be closed. ++ Prototype picker removes trailing parts of the function body if marked. ++ The dialog windows (GUI) have been replaced by more flexible command line inputs. ++ The undocumented and unnecessary hot key F12 has been removed. ++ Extension to ctags + taglist shows makefile targets and qmake targets. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.5 +======================================================================================= + ++ Aligned line end comments for consecutive lines. ++ Improved prototype picker removes comments. ++ Picked up prototypes can be shown. ++ Uncomment more than one block at once. ++ 3 new idioms. ++ Help file improved . + +======================================================================================= + RELEASE NOTES FOR VERSION 3.4 +======================================================================================= + ++ Two new global variables: C_Dictionary_File, C_MenuHeader . ++ The preprocessor statements #if... and the function idiom include marked + lines when invoked in visual mode. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.3 +======================================================================================= + ++ The C/C++ root menu can be disabled. + +======================================================================================= + RELEASE NOTES FOR VERSION 3.2 +======================================================================================= + ++ Only one C/C++ entry in the gVim root menu. ++ All hotkeys are only defined for C/C++ files (file type plugin added). ++ The following constructs are now read as templates from files: + class, class using new, + template class, template class using new, + error class ++ Install script added. ++ Customization improved. ++ Documentation improved (help file added). ++ Bug fix (template file handling) + +======================================================================================= + RELEASE NOTES FOR VERSION 3.1 +======================================================================================= + ++ When the comment style "C" is active the menu entry "Comments.code->comment" + turns a marked region in one multiline C-comment. ++ The menu entry "Comments.comment->code" turns marked multiline C-comment + back into code. ++ A marked region can be surrounded by a for-, if, if-else, while-, do-while-statement + (with indentation). ++ The menu entry "Snippets.make prototype" makes a C- or C++-prototype from + the current line or marked region and puts it in an internal buffer. ++ The menu entry "Snippets.add prototype" also makes a C- or C++-prototype from + the current line or a marked region and adds it to the internal buffer. ++ The menu entry "Snippets.put prototype" inserts all gathered prototypes + below the current line. ++ Tag substitution rewritten (Some characters in a substitution text for a tag + prevented the tag from being substituted). + +======================================================================================= + RELEASE NOTES FOR VERSION 3.0 +======================================================================================= + ++ C-style comments AND C++-style comments are supported now. ++ The menu entry 'Comments->Comment style ..' switches the styles (toggle). ++ Block comments are now read as templates or skeletons from files: + Frame Block, Function Description, Method Description, + Class Description, H+file header, C/C++-file header ++ These templates can contain tags like |FILENAME|, |AUTHOR| etc. which are replaced + after reading (KDevelop templates can be used without any change). ++ indentation: multiline inserts and code snippets will be indented after insertion. ++ Most menu entries are now also active in normal mode. ++ new menu items: + includes for the C99 header, + includes for the standard C++ header, + includes for the C++ version of the Standard C Library header, + multiline C comment + vim modeline ++ Reading the templates is done in one function which can be called in an autocmd. ++ Code cleanup: register z no longer used. Most function calls are silent now. + + diff --git a/c-support/doc/c-hotkeys.pdf b/c-support/doc/c-hotkeys.pdf new file mode 100644 index 0000000..4695e42 Binary files /dev/null and b/c-support/doc/c-hotkeys.pdf differ diff --git a/c-support/doc/c-hotkeys.tex b/c-support/doc/c-hotkeys.tex new file mode 100644 index 0000000..6289eb9 --- /dev/null +++ b/c-support/doc/c-hotkeys.tex @@ -0,0 +1,353 @@ +%%===================================================================================== +%% +%% File: c-hotkeys.tex +%% +%% Description: c-support.vim : Key mappings for Vim without GUI. +%% +%% +%% Author: Dr.-Ing. Fritz Mehner +%% Email: mehner@fh-swf.de +%% Copyright: Copyright (C) 2006-2012 Dr.-Ing. Fritz Mehner (mehner@fh-swf.de) +%% Version: 1.0 +%% Created: 10.11.2006 +%% +%% Notes: +%% +%%===================================================================================== + +\documentclass[oneside,11pt,landscape,DIV17]{scrartcl} + +\usepackage[english]{babel} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{times} +\usepackage{lastpage} +\usepackage{multicol} +\usepackage{setspace} + +\setlength\parindent{0pt} + +\newcommand{\Pluginversion}{6.0} +\newcommand{\ReleaseDate}{\today} +\newcommand{\Rep}{{\tiny{[n]}}} + +%%---------------------------------------------------------------------- +%% luximono : Type1-font +%% Makes keyword stand out by using semibold letters. +%%---------------------------------------------------------------------- +\usepackage[scaled]{luximono} + +%%---------------------------------------------------------------------- +%% fancyhdr +%%---------------------------------------------------------------------- +\usepackage{fancyhdr} +\pagestyle{fancyplain} +\fancyfoot[L]{\small \ReleaseDate} +\fancyfoot[C]{c-support.vim} +\fancyfoot[R]{\small \textbf{Page \thepage{} / \pageref{LastPage}}} +\renewcommand{\headrulewidth}{0.0pt} + +%%---------------------------------------------------------------------- +%% hyperref +%%---------------------------------------------------------------------- +\usepackage[ps2pdf]{hyperref} +\hypersetup{pdfauthor={Dr.-Ing. Fritz Mehner, FH Südwestfalen, Iserlohn, Germany}} +\hypersetup{pdfkeywords={Vim, C/C++}} +\hypersetup{pdfsubject={Vim-plugin, c-support.vim, hot keys}} +\hypersetup{pdftitle={Vim-plugin, c-support.vim, hot keys}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% START OF DOCUMENT +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{document}% + +\begin{multicols}{3} +% +%%====================================================================== +%% title +%%====================================================================== +\begin{center} +\textbf{\textsc{\small{Vim-Plugin}}}\\ +\textbf{\LARGE{c-support.vim}}\\ +\textbf{\textsc{\small{Version \Pluginversion}}}\\ +\textbf{\textsc{\Huge{Hot keys}}}\\ +Key mappings for Vim with and without GUI.\\ +Plugin: http://vim.sourceforge.net\\ +\vspace{3.0mm} +{\normalsize (i)} insert mode, {\normalsize (n)} normal mode, {\normalsize (v)} visual mode\\ +\vspace{5.0mm} +% +%%====================================================================== +%% SIDE 1 +%%====================================================================== +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{10mm}|p{60mm}|} +%% +%%---------------------------------------------------------------------- +%% show plugin help +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{H}elp}}\\ +\hline \verb'\hm' & manual for word under cursor \hfill (n,i)\\ +\hline \verb'\hp' & help (c-support) \hfill (n,i)\\ +\hline +% +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{C}omments}} \\ +\hline \Rep\verb'\cl' & end-of-line comment \hfill (n,v,i)\\ +\hline \Rep\verb'\cj' & adjust end-of-line comment \hfill (n,v,i)\\ +\hline \verb'\cs' & set end-of-line comment column \hfill (n) \\ +\hline \Rep\verb'\c*' & code $\Rightarrow$ comment \verb'/* */' \hfill (n,v) \\ +\hline \Rep\verb'\cc' & code $\Rightarrow$ comment \verb'//' \hfill (n,v,o)\\ +\hline \Rep\verb'\co' & comment $\Rightarrow$ code \hfill (n,v,o)\\ + +\hline \verb'\cfr' & frame comment \hfill (n,i)\\ +\hline \verb'\cfu' & function comment \hfill (n,i)\\ +\hline \verb'\cme' & method description \hfill (n,i)\\ +\hline \verb'\ccl' & class description \hfill (n,i)\\ +\hline \verb'\cfdi'& file description (implementation) \hfill (n,i)\\ +\hline \verb'\cfdh'& file description (header) \hfill (n,i)\\ + +\hline \verb'\ccs'& C/C++--file sections\hspace{3mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ +\hline \verb'\chs'& H--file sections\hspace{10mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ +\hline \verb'\ckc'& keyword comment\hspace{5mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ +\hline \verb'\csc'& special comment\hspace{7,5mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ +\hline \verb'\cma'& template macros\hspace{7,5mm}\footnotesize{(tab compl.)} \hfill \normalsize{(n,i)}\\ + +\hline \verb'\cd' & date \hfill (n,v,i)\\ +\hline \verb'\ct' & date \& time \hfill (n,v,i)\\ +\hline \Rep\verb'\cx' & exch. comment style: C $\leftrightarrow$ C++ \hfill (n,v,i)\\ +\hline +\end{tabular}\\ +%%~~~~~ TABULAR : end ~~~~~~~~~~ +% +%%====================================================================== +%% table, middle part +%%====================================================================== +% +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{15mm}|p{55mm}|} +%%---------------------------------------------------------------------- +%% menu statements +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{S}tatements}} \\ +\hline \verb'\sd' & \verb'do { } while' \hfill (n,v,i)\\ +\hline \verb'\sf' & \verb'for' \hfill (n,i)\\ +\hline \verb'\sfo' & \verb'for { }' \hfill (n,v,i)\\ +\hline \verb'\si' & \verb'if' \hfill (n,i)\\ +\hline \verb'\sif' & \verb'if { }' \hfill (n,v,i)\\ +\hline \verb'\sie' & \verb'if else' \hfill (n,v,i)\\ +\hline \verb'\sife'& \verb'if { } else { }' \hfill (n,v,i)\\ +\hline \verb'\se' & \verb'else { }' \hfill (n,v,i)\\ +\hline \verb'\sw' & \verb'while' \hfill (n,i)\\ +\hline \verb'\swh' & \verb'while { }' \hfill (n,v,i)\\ +\hline \verb'\ss' & \verb'switch' \hfill (n,v,i)\\ +\hline \verb'\sc' & \verb'case' \hfill (n,i)\\ +\hline \verb'\sb' & \verb'{ }' \hfill (n,v,i)\\ +\hline +%%---------------------------------------------------------------------- +%% preprocessor menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{P}reprocessor}} \\ +\hline \verb'\pih' & include Std. Lib. header \hfill (n,i)\\ +\hline \verb'\pg' & \verb$#include<...>$ (global)\hfill (n,i)\\ +\hline \verb'\pl' & \verb$#include"..."$ (local) \hfill (n,i)\\ +\hline \verb'\pd' & \verb'#define' \hfill (n,i)\\ +\hline \verb'\pu' & \verb'#undef' \hfill (n,i)\\ +\hline \verb'\pif' & \verb'#if #endif' \hfill (n,v,i)\\ +\hline \verb'\pie' & \verb'#if #else #endif' \hfill (n,v,i)\\ +\hline \verb'\pid' & \verb'#ifdef #else #endif' \hfill (n,v,i)\\ +\hline \verb'\pin' & \verb'#ifndef #else #endif' \hfill (n,v,i)\\ +\hline \verb'\pind' & \verb'#ifndef #def #endif' \hfill (n,v,i)\\ +\hline \verb'\pe' & \verb'#error ' \hfill (n,i)\\ +\hline \verb'\pli' & \verb'#line ' \hfill (n,i)\\ +\hline \verb'\pp' & \verb'#pragma' \hfill (n,i)\\ +\hline \verb'\pw' & \verb'#warning' \hfill (n,i)\\ +\hline \verb'\pi0' & \verb'#if 0 #endif' \hfill (n,v,i)\\ +\hline \verb'\pr0' & remove \verb'#if 0 #endif' \hfill (n,i)\\ +\hline +\end{tabular} \\ +%%~~~~~ TABULAR : end ~~~~~~~~~~ + +%%====================================================================== +%% table, right part +%%====================================================================== +% +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{11mm}|p{60mm}|}% +%%---------------------------------------------------------------------- +%% snippet menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{S\textbf{n}ippet}} \\ +\hline \verb'\nr' & read code snippet \hfill (n,i)\\ +\hline \verb'\nv' & view code snippet \hfill (n,v,i)\\ +\hline \verb'\nw' & write code snippet \hfill (n,v,i)\\ +\hline \verb'\ne' & edit code snippet \hfill (n,i)\\ +\hline \Rep\verb'\nf' & pick up function prototype\hfill (n,v,i)\\ + \Rep\verb'\np' & \hfill (n,v,i)\\ +\hline \Rep\verb'\nm' & pick up method prototype \hfill (n,v,i)\\ +\hline \verb'\ni' & insert prototype(s) \hfill (n,i)\\ +\hline \verb'\nc' & clear prototype(s) \hfill (n,i)\\ +\hline \verb'\ns' & show prototype(s) \hfill (n,i)\\ +% +\hline \verb'\ntl' & edit local templates \hfill (n,i)\\ +\hline \verb'\ntr' & reread the templates \hfill (n,i)\\ +\hline \verb'\njt' & insert jump tag \hfill (n,i)\\ +\hline +%%---------------------------------------------------------------------- +%% idioms menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{I}dioms}} \\ +\hline \verb'\if' & function \hfill (n,v,i)\\ +\hline \verb'\isf' & static function \hfill (n,v,i)\\ +\hline \verb'\im' & \verb'main()' \hfill (n,v,i)\\ +\hline \verb'\ie' & \verb'enum' + \verb'typedef' \hfill (n,v,i)\\ +\hline \verb'\is' & \verb'struct' + \verb'typedef' \hfill (n,v,i)\\ +\hline \verb'\iu' & \verb'union' + \verb'typedef' \hfill (n,v,i)\\ +\hline \verb'\ipr' & \verb'printf()' \hfill (n,i)\\ +\hline \verb'\isc' & \verb'scanf()' \hfill (n,i)\\ +\hline \verb'\ica' & \verb'p=calloc()' \hfill (n,i)\\ +\hline \verb'\ima' & \verb'p=malloc()' \hfill (n,i)\\ +\hline \verb'\ire' & \verb'p=realloc()' \hfill (n,i)\\ +\hline \verb'\isi' & \verb'sizeof()' \hfill (n,v,i)\\ +\hline \verb'\ias' & \verb'assert()' \hfill (n,v,i)\\ +\hline \verb'\ii' & open input file \hfill (n,v,i)\\ +\hline \verb'\io' & open output file \hfill (n,v,i)\\ +\hline \verb'\ifsc'& fscanf \hfill (n,i)\\ +\hline \verb'\ifpr'& fprintf \hfill (n,i)\\ +\hline \Rep\verb'\i0' & \verb'for( x=0; x=0; x-=1 )' \hfill (n,v,i)\\ +\hline +\end{tabular} +% +%\begin{minipage}[b]{64mm}% +%\scriptsize{% +%\vspace{1mm} +%$^1$ {system-wide installation only} +%}% +%\end{minipage} +% +% +%%====================================================================== +%% SIDE 2 +%%====================================================================== +% +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{12mm}|p{60mm}|} +%%---------------------------------------------------------------------- +%% C++ menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{C\textbf{++}}} \\ +\hline \verb'\+ih' & \verb$#include$ C++ Std. Lib. header \hfill (n,i)\\ +\hline \verb'\+ich' & \verb$#include$ C Std. Lib. header \hfill (n,i)\\ +\hline \verb'\+om' & output manipulators \hfill (n,i)\\ +\hline \verb'\+fb' & ios flagbits \hfill (n,i)\\ +\hline +\hline \verb'\+c' & class \hfill (n,i)\\ +\hline \verb'\+cn' & class (using \verb'new') \hfill (n,i)\\ +\hline \verb'\+tc' & template class \hfill (n,i)\\ +\hline \verb'\+tcn' & template class (using \verb'new') \hfill (n,i)\\ +\hline \verb'\+ec' & error class \hfill (n,i)\\ +\hline \verb'\+tf' & template function \hfill (n,i)\\ +\hline +\hline \verb'\+tr' & \verb'try' \dots \verb'catch' \hfill (n,v,i)\\ +\hline \verb'\+ca' & \verb'catch' \hfill (n,v,i)\\ +\hline \verb'\+caa' & \verb'catch(...)' \hfill (n,v,i)\\ +\hline +\hline \verb'\+ex' & \verb'extern "C" { }' \hfill (n,v,i)\\ +\hline \verb'\+oif' & open input file \hfill (n,v,i)\\ +\hline \verb'\+oof' & open output file \hfill (n,v,i)\\ +\hline \verb'\+uns' & \verb'using namespace std;' \hfill (n,v,i)\\ +\hline \verb'\+un' & \verb'using namespace xxx;' \hfill (n,v,i)\\ +\hline \verb'\+unb' & \verb'namespace xxx { }' \hfill (n,v,i)\\ +\hline \verb'\+na' & namespace alias \hfill (n,v,i)\\ +\hline \verb'\+rt' & RTTI \hfill (n,v,i)\\ + +\hline +\hline \verb'\+ic' & class implementation \hfill (n,i)\\ +\hline \verb'\+icn' & class (using \verb'new') implementation \hfill (n,i)\\ +\hline \verb'\+im' & method implementation \hfill (n,i)\\ +\hline \verb'\+ia' & accessor implementation \hfill (n,i)\\ +\hline \verb'\+itc' & template class implementation \hfill (n,i)\\ +\hline \verb'\+itcn'& template class (using \verb'new') impl. \hfill (n,i)\\ +\hline \verb'\+itm' & template method implementation \hfill (n,i)\\ +\hline \verb'\+ita' & template accessor implementation \hfill (n,i)\\ +\hline \verb'\+ioi' & operator >> \hfill (n,i)\\ +\hline \verb'\+ioo' & operator << \hfill (n,i)\\ +\hline +\end{tabular} +\vspace{100mm} +%%~~~~~ TABULAR : begin ~~~~~~~~~~ +\begin{tabular}[]{|p{12mm}|p{58mm}|} +%%---------------------------------------------------------------------- +%% run menu +%%---------------------------------------------------------------------- +\hline +\multicolumn{2}{|r|}{\textsl{\textbf{R}un}} \\ +\hline \verb'\rc' & save and compile \hfill (n,i)\\ +\hline \verb'\rl' & link \hfill (n,i)\\ +\hline \verb'\rr' & run \hfill (n,i)\\ +\hline \verb'\ra' & set comand line arguments \hfill (n,i)\\ +\hline \verb'\rm' & run \texttt{ make}$^1$ \hfill (n,i)\\ +\hline \verb'\rmc' & run \texttt{ make clean}$^1$ \hfill (n,i)\\ +\hline \verb'\rcm' & choose a makefile $^1$ \hfill (n,i)\\ +\hline \verb'\rme' & executable to run$^1$ \hfill (n,i)\\ +\hline \verb'\rma' & cmd. line arg. for \texttt{make}$^1$ \hfill (n,i)\\ +% +\hline \verb'\rp' & run \texttt{splint}$^2$ \hfill (n,i)\\ +\hline \verb'\rpa' & cmd. line arg. for \texttt{splint} \hfill (n,i)\\ +% +\hline \verb'\rcc' & run \texttt{cppcheck}$^3$ \hfill (n,i)\\ +\hline \verb'\rccs'& severity for \texttt{cppcheck} \hfill (n,i)\\ +% +\hline \verb'\rk' & run \texttt{ CodeCheck}$^4$ \hfill (n,i)\\ +\hline \verb'\rka' & cmd. line arg. for \texttt{CodeCheck} \hfill (n,i)\\ +% +\hline \verb'\ri' & run \texttt{ indent} \hfill (n,i)\\ +\hline \Rep\verb'\rh' & hardcopy buffer \hfill (n,i,v)\\ +\hline \verb'\rs' & show plugin settings \hfill (n,i)\\ +\hline \verb'\rx' & set xterm size \hfill (n,i, only Unix \& GUI)\\ +\hline \verb'\ro' & change output destination \hfill (n,i)\\ +\hline +%\end{tabular} +%\begin{spacing}{1.2} +%\begin{tabular}[]{|p{12mm}|p{58mm}|} +\hline +\multicolumn{2}{|r|}{\textbf{Additional Mappings}$^5$}\\ +\hline +\hline \textbf{typing} & \textbf{expansion}\\ +\hline \verb'/*' & \verb'/* */' \hfill (i)\\ +\hline \verb'/*' & \verb'/* '\fbox{\small{(multiline) marked text}}\verb' */' \hfill (v)\\ +\hline \verb'/*' & \verb'/*'\hfill (i)\newline\verb' * |'\newline\verb' */'\\ +\hline \verb'{' & \verb'{'\hfill (i)\newline\verb' |'\newline\verb'}' \\ +\hline \verb'{' & \verb'{'\hfill (v)\newline\verb' '\fbox{\small{(multiline) marked text}}\newline\verb'}'\\ +\hline +\end{tabular} +%\end{spacing} +%%~~~~~ TABULAR : end ~~~~~~~~~~ +%\vspace{60mm} +% +% +\begin{minipage}[b]{65mm}% +%\vspace{10mm} +% +\scriptsize{% +%\vspace{10mm} +\hrulefill\\ +$^1$ also working for filetype \textbf{make}\\ +$^2$ \textit{www.splint.org}\\ +$^3$ \textit{cppcheck.sourceforge.net}\\ +$^4$ \textbf{CodeCheck}$^{TM}$ is a product of Abraxas Software, Inc.\\ +$^5$ defined in \verb'~/ftplugin/c.vim' +}% +% +\end{minipage} +% +\end{center} +\end{multicols} +\end{document} diff --git a/c-support/rc/customization.cpp.vim b/c-support/rc/customization.cpp.vim new file mode 100644 index 0000000..3632383 --- /dev/null +++ b/c-support/rc/customization.cpp.vim @@ -0,0 +1,26 @@ +" ------------------------------------------------------------------------------ +" +" Vim filetype plugin file +" +" Language : C++ +" Plugin : c.vim +" Maintainer : Fritz Mehner +" +" ------------------------------------------------------------------------------ +" +" Only do this when not done yet for this buffer +" +if exists("b:did_CPP_ftplugin") + finish +endif +let b:did_CPP_ftplugin = 1 +" +"------------------------------------------------------------------------------- +" additional mapping : C++ I/O +"------------------------------------------------------------------------------- +" +inoremap >> >> +inoremap << << +inoremap <<" << "" +inoremap <<; << "\n"; +" diff --git a/c-support/rc/customization.gvimrc b/c-support/rc/customization.gvimrc index 31befe7..dd90cd5 100644 --- a/c-support/rc/customization.gvimrc +++ b/c-support/rc/customization.gvimrc @@ -4,7 +4,6 @@ " AUTHOR: Dr.-Ing. Fritz Mehner " VERSION: 1.0 " CREATED: 04.04.2009 -" REVISION: $Id: customization.gvimrc,v 1.3 2009/04/04 08:26:21 mehner Exp $ "=================================================================================== " "=================================================================================== diff --git a/c-support/rc/customization.vimrc b/c-support/rc/customization.vimrc index 917018a..74fe92c 100644 --- a/c-support/rc/customization.vimrc +++ b/c-support/rc/customization.vimrc @@ -3,7 +3,6 @@ " DESCRIPTION: suggestion for a personal configuration file ~/.vimrc " AUTHOR: Dr.-Ing. Fritz Mehner " CREATED: 04.04.2009 -" REVISION: $Id: customization.vimrc,v 1.6 2009/10/03 12:24:30 mehner Exp $ "=================================================================================== " "=================================================================================== diff --git a/c-support/scripts/wrapper.sh b/c-support/scripts/wrapper.sh index f78861c..45d4fe3 100644 --- a/c-support/scripts/wrapper.sh +++ b/c-support/scripts/wrapper.sh @@ -12,7 +12,6 @@ # AUTHOR: Dr.-Ing. Fritz Mehner (Mn), mehner@fh-swf.de # COMPANY: Fachhochschule Südwestfalen, Iserlohn # CREATED: 23.11.2004 18:04:01 CET -# REVISION: $Id: wrapper.sh,v 1.5 2009/06/03 17:47:06 mehner Exp $ #=============================================================================== executable="${1}" # name of the executable diff --git a/c-support/templates/Templates b/c-support/templates/Templates index 74bcd9f..aa3a965 100644 --- a/c-support/templates/Templates +++ b/c-support/templates/Templates @@ -1,30 +1,43 @@ -$ -$ ============================================================= -$ ========== USER MACROS ====================================== -$ ============================================================= -$ -|AUTHOR| = YOUR NAME -|AUTHORREF| = -|EMAIL| = -|COMPANY| = -|COPYRIGHT| = Copyright (c) |YEAR|, |AUTHOR| -|STYLE| = default -$ -$ ============================================================= -$ ========== FILE INCLUDES ==================================== -$ ============================================================= -$ -|includefile| = c.comments.template -|includefile| = c.cpp.template -|includefile| = c.idioms.template -|includefile| = c.preprocessor.template -|includefile| = c.statements.template -$ -== IF |STYLE| IS CPP == -|includefile| = cpp.comments.template -|includefile| = cpp.cpp.template -|includefile| = cpp.idioms.template -|includefile| = cpp.preprocessor.template -|includefile| = cpp.statements.template -== ENDIF == -$ +§ ========================================================== +§ User Macros +§ ========================================================== + +SetMacro( 'AUTHOR', 'YOUR NAME' ) +SetMacro( 'AUTHORREF', '' ) +SetMacro( 'COMPANY', '' ) +SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) +SetMacro( 'EMAIL', '' ) +SetMacro( 'LICENSE', 'GNU General Public License' ) +SetMacro( 'ORGANIZATION','' ) + +SetStyle( 'C' ) + +§ ========================================================== +§ File Includes and Shortcuts +§ ========================================================== + +MenuShortcut( 'Comments', 'c' ) +MenuShortcut( 'Statements', 's' ) +MenuShortcut( 'Idioms', 'i' ) +MenuShortcut( 'Preprocessor', 'p' ) +MenuShortcut( 'Snippets', 'n' ) +MenuShortcut( 'C++', 'c' ) +§ +IncludeFile( 'snippets.template' ) +§ +== USE STYLES : C == +IncludeFile( 'c.comments.template' ) +IncludeFile( 'c.cpp.template' ) +IncludeFile( 'c.idioms.template' ) +IncludeFile( 'c.preprocessor.template' ) +IncludeFile( 'c.statements.template' ) +== ENDSTYLES == +§ +== USE STYLES : CPP == +IncludeFile( 'cpp.comments.template' ) +IncludeFile( 'cpp.cpp.template' ) +IncludeFile( 'cpp.idioms.template' ) +IncludeFile( 'cpp.preprocessor.template' ) +IncludeFile( 'cpp.statements.template' ) +== ENDSTYLES == + diff --git a/c-support/templates/c.comments.template b/c-support/templates/c.comments.template index 1501628..7323937 100644 --- a/c-support/templates/c.comments.template +++ b/c-support/templates/c.comments.template @@ -1,21 +1,17 @@ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.end-of-line-comment == append == +== Comments.end-of-line-comment == append, nomenu == /* */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.frame == +== Comments.frame == map:cfr, shortcut:f == /*----------------------------------------------------------------------------- * *-----------------------------------------------------------------------------*/ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.function == +== Comments.function == map:cfu, shortcut:f == /* * === FUNCTION ====================================================================== * Name: |?FUNCTION_NAME| * Description: * ===================================================================================== */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.method == +== Comments.method == map:cme, shortcut:m == /* *-------------------------------------------------------------------------------------- * Class: |?CLASSNAME| @@ -23,16 +19,14 @@ $%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% * Description: *-------------------------------------------------------------------------------------- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.class == +== Comments.class == map:ccl, shortcut:c == /* * ===================================================================================== * Class: |?CLASSNAME| * Description: * ===================================================================================== */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-description == start == +== Comments.file description impl == map:cfdi, shortcut:c, start, noindent == /* * ===================================================================================== * @@ -50,9 +44,8 @@ $%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% * * ===================================================================================== */ -#include -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-description-header == start == + +== Comments.file description header == map:cfdh, shortcut:h, start, noindent == /* * ===================================================================================== * @@ -70,110 +63,69 @@ $%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% * * ===================================================================================== */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-header-includes == -/* ##### HEADER FILE INCLUDES ################################################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-macros == -/* ##### MACROS - LOCAL TO THIS SOURCE FILE ################################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-typedefs == -/* ##### TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-data-types == -/* ##### DATA TYPES - LOCAL TO THIS SOURCE FILE ############################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-class-defs == -/* ##### CLASS DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################## */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-local-variables == -/* ##### VARIABLES - LOCAL TO THIS SOURCE FILE ################################ */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-prototypes == -/* ##### PROTOTYPES - LOCAL TO THIS SOURCE FILE ############################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-function-defs-exported == -/* ##### FUNCTION DEFINITIONS - EXPORTED FUNCTIONS ############################ */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-function-defs-local == -/* ##### FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE ##################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-class-implementations-exported == -/* ##### CLASS IMPLEMENTATIONS - EXPORTED CLASSES ############################# */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-class-implementations-local == -/* ##### CLASS IMPLEMENTATIONS - LOCAL CLASSES ################################ */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-header-includes == -/* ##### HEADER FILE INCLUDES ################################################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-macros == -/* ##### EXPORTED MACROS ######################################################## */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-typedefs == -/* ##### EXPORTED TYPE DEFINITIONS ############################################## */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-data-types == -/* ##### EXPORTED DATA TYPES #################################################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-class-defs == -/* ##### EXPORTED CLASS DEFINITIONS ############################################# */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-variables == -/* ##### EXPORTED VARIABLES ##################################################### */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-function-declarations == -/* ##### EXPORTED FUNCTION DECLARATIONS ######################################### */ +== ENDTEMPLATE == + +== LIST: comments_c_sections == hash == + 'HEADER FILE INCLUDES' : 'HEADER FILE INCLUDES ###############################', + 'LOCAL MACROS' : 'MACROS - LOCAL TO THIS SOURCE FILE ###############', + 'LOCAL TYPE DEFINITIONS' : 'TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE #####', + 'LOCAL DATA TYPES' : 'DATA TYPES - LOCAL TO THIS SOURCE FILE ###########', + 'LOCAL VARIABLES' : 'VARIABLES - LOCAL TO THIS SOURCE FILE ############', + 'LOCAL PROTOTYPES' : 'PROTOTYPES - LOCAL TO THIS SOURCE FILE ###########', + 'EXP. FUNCTION DEFINITIONS' : 'FUNCTION DEFINITIONS - EXPORTED FUNCTIONS ########', + 'LOCAL FUNCTION DEFINITIONS' : 'FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE #', + 'LOCAL CLASS DEFINITIONS' : 'CLASS DEFINITIONS - LOCAL TO THIS SOURCE FILE ####', + 'EXP. CLASS IMPLEMENTATIONS' : 'CLASS IMPLEMENTATIONS - EXPORTED CLASSES #########', + 'LOCAL CLASS IMPLEMENTATIONS' : 'CLASS IMPLEMENTATIONS - LOCAL CLASSES ############', +== LIST: comments_h_sections == hash == + 'HEADER FILE INCLUDES' : 'HEADER FILE INCLUDES ###########', + 'EXPORTED MACROS' : 'EXPORTED MACROS ################', + 'EXPORTED TYPE DEFINITIONS' : 'EXPORTED TYPE DEFINITIONS ######', + 'EXPORTED DATA TYPES' : 'EXPORTED DATA TYPES ############', + 'EXPORTED CLASS DEFINITIONS' : 'EXPORTED CLASS DEFINITIONS #####', + 'EXPORTED VARIABLES' : 'EXPORTED VARIABLES #############', + 'EXPORTED FUNCTION DECLARATIONS' : 'EXPORTED FUNCTION DECLARATIONS #', +== LIST: comments_keywords == hash == + 'BUG' : ':BUG:|DATE| |TIME|:|AUTHORREF|:', + 'COMPILER' : ':COMPILER:|DATE| |TIME|:|AUTHORREF|:', + 'REMARK' : ':REMARK:|DATE| |TIME|:|AUTHORREF|:', + 'TODO' : ':TODO:|DATE| |TIME|:|AUTHORREF|:', + 'WARNING' : ':WARNING:|DATE| |TIME|:|AUTHORREF|:', + 'WORKAROUND' : ':WORKAROUND:|DATE| |TIME|:|AUTHORREF|:', + 'new keyword' : '::|DATE| |TIME|:|AUTHORREF|: {+COMMENT+}', +== LIST: comments_special == list == + 'EMPTY' , + 'FALL THROUGH' , + 'IMPLICIT TYPE CONVERSION' , + 'NO RETURN' , + 'NOT REACHED' , + 'TO BE IMPLEMENTED' , + 'constant type is long' , + 'constant type is unsigned' , + 'constant type is unsigned long', +== LIST: comments_macros == list == + 'AUTHOR' , + 'AUTHORREF' , + 'COMPANY' , + 'COPYRIGHT' , + 'EMAIL' , + 'ORGANIZATION', +== ENDLIST == + +== Comments.C file sections == expandmenu, append, map:ccs, shortcut:s == +|PickList( 'C file sections', 'comments_c_sections' )| +/* ##### |PICK|#################### */ +== Comments.H file sections == expandmenu, append, map:chs, shortcut:s == +|PickList( 'H file sections', 'comments_h_sections' )| +/* ##### |PICK|######################################## */ +== Comments.keyword comments == expandmenu, append, map:ckc, shortcut:k == +|PickList( 'keyword comments', 'comments_keywords' )| + /* |PICK| */ +== Comments.special comments == expandmenu, append, map:csc, shortcut:s == +|PickList( 'special comments', 'comments_special' )| + /* |PICK| */ +== Comments.macros == expandmenu, insert, map:cma, shortcut:m == +|PickList( 'macro', 'comments_macros' )| +||PICK|| +== ENDTEMPLATE == -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.keyword-bug == append == - /* :BUG:|DATE| |TIME|:|AUTHORREF|: */ -== comment.keyword-compiler == append == - /* :COMPILER:|DATE| |TIME|:|AUTHORREF|: */ -== comment.keyword-todo == append == - /* :TODO:|DATE| |TIME|:|AUTHORREF|: */ -== comment.keyword-tricky == append == - /* :TRICKY:|DATE| |TIME|:|AUTHORREF|: */ -== comment.keyword-warning == append == - /* :WARNING:|DATE| |TIME|:|AUTHORREF|: */ -== comment.keyword-workaround == append == - /* :WORKAROUND:|DATE| |TIME|:|AUTHORREF|: */ -== comment.keyword-keyword == append == - /* :|?KEYWORD:u|:|DATE| |TIME|:|AUTHORREF|: */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.special-empty == append == - /* EMPTY */ -== comment.special-fall-through == append == - /* FALL THROUGH */ -== comment.special-implicit-type-conversion == append == - /* IMPLICIT TYPE CONVERSION */ -== comment.special-no-return == append == - /* NO RETURN */ -== comment.special-not-reached == append == - /* NOT REACHED */ -== comment.special-remains-to-be-implemented == append == - /* REMAINS TO BE IMPLEMENTED */ -== comment.special-constant-type-is-long == append == - /* constant type is long */ -== comment.special-constant-type-is-unsigned == append == - /* constant type is unsigned */ -== comment.special-constant-type-is-unsigned-long == append == - /* constant type is unsigned long */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/c-support/templates/c.cpp.template b/c-support/templates/c.cpp.template index 40fb829..fa3c978 100644 --- a/c-support/templates/c.cpp.template +++ b/c-support/templates/c.cpp.template @@ -1,92 +1,157 @@ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -$ -== cpp.cin == -cin >> ; -$ -== cpp.cout == insert == -cout << << endl; -$ -== cpp.cout-operator == insert == -<< "" -$ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.output-manipulator-boolalpha == insert == -<< boolalpha -== cpp.output-manipulator-dec == insert == -<< dec -== cpp.output-manipulator-endl == insert == -<< endl -== cpp.output-manipulator-fixed == insert == -<< fixed -== cpp.output-manipulator-flush == insert == -<< flush -== cpp.output-manipulator-hex == insert == -<< hex -== cpp.output-manipulator-internal == insert == -<< internal -== cpp.output-manipulator-left == insert == -<< left -== cpp.output-manipulator-oct == insert == -<< oct -== cpp.output-manipulator-right == insert == -<< right -== cpp.output-manipulator-scientific == insert == -<< scientific -== cpp.output-manipulator-setbase == insert == -<< setbase(10) -== cpp.output-manipulator-setfill == insert == -<< setfill() -== cpp.output-manipulator-setiosflag == insert == -<< setiosflags() -== cpp.output-manipulator-setprecision == insert == -<< setprecision(6) -== cpp.output-manipulator-setw == insert == -<< setw(0) -== cpp.output-manipulator-showbase == insert == -<< showbase -== cpp.output-manipulator-showpoint == insert == -<< showpoint -== cpp.output-manipulator-showpos == insert == -<< showpos -== cpp.output-manipulator-uppercase == insert == -<< uppercase -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.method-implementation == -void -|?CLASSNAME|::|?METHODNAME| ( <+argument list+> ) -{ - return ; -} /* ----- end of method |CLASSNAME|::|?METHODNAME| ----- */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.accessor-implementation == -/* - *-------------------------------------------------------------------------------------- - * Class: |?CLASSNAME| - * Method: get_|?ATTRIBUTE| - *-------------------------------------------------------------------------------------- - */ -inline |?RETURNTYPE| -|CLASSNAME|::get_|ATTRIBUTE| ( ) const -{ - return |ATTRIBUTE|; -} /* ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- */ - -/* - *-------------------------------------------------------------------------------------- - * Class: |CLASSNAME| - * Method: set_|ATTRIBUTE| - *-------------------------------------------------------------------------------------- - */ -inline void -|CLASSNAME|::set_|ATTRIBUTE| ( |RETURNTYPE| value ) -{ - |ATTRIBUTE| = value; - return ; -} /* ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.class-definition == +== LIST: output_manipulators == hash == + 'boolalpha' : 'boolalpha' , + 'dec' : 'dec' , + 'defaultfloat' : 'defaultfloat' , + 'endl' : 'endl' , + 'ends' : 'ends' , + 'fixed' : 'fixed' , + 'flush' : 'flush' , + 'get_money' : 'get_money' , + 'get_time' : 'get_time' , + 'hexfloat' : 'hexfloat' , + 'hex' : 'hex' , + 'internal' : 'internal' , + 'left' : 'left' , + 'oct' : 'oct' , + 'put_money' : 'put_money' , + 'put_time' : 'put_time' , + 'resetiosflag' : 'resetiosflag' , + 'right' : 'right' , + 'scientific' : 'scientific' , + 'setbase' : 'setbase(10)' , + 'setfill' : 'setfill()' , + 'setiosflags' : 'setiosflags()' , + 'setprecision' : 'setprecision(6)', + 'setw' : 'setw(0)' , + 'showbase' : 'showbase' , + 'showpoint' : 'showpoint' , + 'showpos' : 'showpos' , + 'skipws' : 'skipws' , + 'unitbuf' : 'unitbuf' , + 'uppercase' : 'uppercase' , + 'ws' : 'ws' , +== ENDLIST == + +== LIST: ios_flagbits == list == + 'adjustfield', + 'basefield' , + 'boolalpha' , + 'dec' , + 'fixed' , + 'floatfield' , + 'hex' , + 'internal' , + 'left' , + 'oct' , + 'right' , + 'scientific' , + 'showbase' , + 'showpoint' , + 'showpos' , + 'skipws' , + 'unitbuf' , + 'uppercase' , +== ENDLIST == + +== LIST: include == list == + 'algorithm' , + 'array' , + 'atomic' , + 'bitset' , + 'chrono' , + 'codecvt' , + 'complex' , + 'condition_variable' , + 'deque' , + 'exception' , + 'forward_list' , + 'fstream' , + 'functional' , + 'future' , + 'initializer_list' , + 'iomanip' , + 'ios' , + 'iosfwd' , + 'iostream' , + 'istream' , + 'iterator' , + 'limits' , + 'list' , + 'locale' , + 'map' , + 'memory' , + 'mutex' , + 'new' , + 'numeric' , + 'ostream' , + 'queue' , + 'random' , + 'ratio' , + 'regex' , + 'set' , + 'sstream' , + 'stack' , + 'stdexcept' , + 'streambuf' , + 'string' , + 'strstream' , + 'system_error' , + 'thread' , + 'tuple' , + 'typeindex' , + 'typeinfo' , + 'type_traits' , + 'unordered_map', + 'unordered_set', + 'utility' , + 'valarray' , + 'vector' , +== ENDLIST == + +== LIST: c_include == list == + 'cassert' , + 'ccomplex' , + 'cctype' , + 'cerrno' , + 'cfenv' , + 'cfloat' , + 'cinttypes', + 'ciso646' , + 'climits' , + 'clocale' , + 'cmath' , + 'csetjmp' , + 'csignal' , + 'cstdalign', + 'cstdarg' , + 'cstdbool' , + 'cstddef' , + 'cstdint' , + 'cstdio' , + 'cstdlib' , + 'cstring' , + 'ctgmath' , + 'ctime' , + 'cuchar' , + 'cwchar' , + 'cwctype' , +== ENDLIST == + +== C++.include C++ std lib header == expandmenu, insert, map:+ih, shortcut:i == +|PickList( 'include', 'include' )| +#include <|PICK|> +== C++.include C std lib header == expandmenu, insert, map:+ich, shortcut:c == +|PickList( 'include C', 'c_include' )| +#include <|PICK|> +== C++.output manipulators == expandmenu, insert, map:+om, shortcut:m == +|PickList( 'output manipulators', 'output_manipulators' )| + << |PICK| +== C++.ios flagbits == expandmenu, insert, map:+fb, shortcut:i == +|PickList( 'ios flagbits', 'ios_flagbits' )| +ios::|PICK| +== ENDTEMPLATE == + +== C++.class == map:+c, shortcut:c == /* * ===================================================================================== * Class: |?CLASSNAME:c| @@ -106,28 +171,18 @@ class |CLASSNAME| /* ==================== OPERATORS ======================================= */ protected: + /* ==================== METHODS ======================================= */ + /* ==================== DATA MEMBERS ======================================= */ private: + /* ==================== METHODS ======================================= */ + /* ==================== DATA MEMBERS ======================================= */ }; /* ----- end of class |CLASSNAME| ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.class-implementation == -/* - *-------------------------------------------------------------------------------------- - * Class: |?CLASSNAME:c| - * Method: |CLASSNAME| - * Description: constructor - *-------------------------------------------------------------------------------------- - */ -|CLASSNAME|::|CLASSNAME| () -{ -} /* ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.class-using-new-definition == +== C++.class using new == map:+cn, shortcut:n == /* * ===================================================================================== * Class: |?CLASSNAME:c| @@ -151,15 +206,114 @@ class |CLASSNAME| |CLASSNAME|& operator = ( const |CLASSNAME| &other ); /* assignment operator */ protected: + /* ==================== METHODS ======================================= */ + /* ==================== DATA MEMBERS ======================================= */ private: + /* ==================== METHODS ======================================= */ + /* ==================== DATA MEMBERS ======================================= */ }; /* ----- end of class |CLASSNAME| ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.class-using-new-implementation == +== C++.template class == map:+tc, shortcut:t == +/* + * ===================================================================================== + * Class: |?CLASSNAME:c| + * Description: + * ===================================================================================== + */ +template < class T > +class |CLASSNAME| +{ + public: + /* ==================== LIFECYCLE ======================================= */ + |CLASSNAME| (); /* constructor */ + + /* ==================== ACCESSORS ======================================= */ + + /* ==================== MUTATORS ======================================= */ + + /* ==================== OPERATORS ======================================= */ + + protected: + /* ==================== METHODS ======================================= */ + + /* ==================== DATA MEMBERS ======================================= */ + + private: + /* ==================== METHODS ======================================= */ + + /* ==================== DATA MEMBERS ======================================= */ + +}; /* ---------- end of template class |CLASSNAME| ---------- */ + +== C++.template class using new == map:+tcn, shortcut:n == +/* + * ===================================================================================== + * Class: |?CLASSNAME:c| + * Description: + * ===================================================================================== + */ + +template < class T > +class |CLASSNAME| +{ + public: + // ==================== LIFECYCLE ======================================= + |CLASSNAME| (); /* constructor */ + |CLASSNAME| ( const |CLASSNAME| &other ); /* copy constructor */ + ~|CLASSNAME| (); /* destructor */ + + /* ==================== ACCESSORS ======================================= */ + + /* ==================== MUTATORS ======================================= */ + + /* ==================== OPERATORS ======================================= */ + + |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator + + protected: + /* ==================== METHODS ======================================= */ + + /* ==================== DATA MEMBERS ======================================= */ + + private: + /* ==================== METHODS ======================================= */ + + /* ==================== DATA MEMBERS ======================================= */ + +}; /* ----- end of template class |CLASSNAME| ----- */ + +== C++.error class == map:+ec, shortcut:e == +/* + * ===================================================================================== + * Class: |?CLASSNAME:c| + * Description: + * ===================================================================================== + */ +class |CLASSNAME| +{ + public: |CLASSNAME| ( string msg = "|CLASSNAME|" ):message(msg) { } + virtual ~|CLASSNAME| ( ) { } + virtual string what ( ) const throw ( ) { return message; } + protected: string message; +}; /* ----- end of class |CLASSNAME| ----- */ + +== C++.IMPLEMENTATION.class == map:+ic , shortcut:c == +/* + *-------------------------------------------------------------------------------------- + * Class: |?CLASSNAME:c| + * Method: |CLASSNAME| + * Description: constructor + *-------------------------------------------------------------------------------------- + */ +|CLASSNAME|::|CLASSNAME| () +{ +} /* ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- */ + +== C++.IMPLEMENTATION.class using new == map:+icn , shortcut:n == /* *-------------------------------------------------------------------------------------- * Class: |?CLASSNAME:c| @@ -208,43 +362,25 @@ $%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% return *this; } /* ----- end of method |CLASSNAME|::operator = (assignment operator) ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.error-class == -/* - * ===================================================================================== - * Class: |?CLASSNAME:c| - * Description: - * ===================================================================================== - */ -class |CLASSNAME| -{ - public: |CLASSNAME| ( string msg = "|CLASSNAME|" ):message(msg) { } - virtual ~|CLASSNAME| ( ) { } - virtual string what ( ) const throw ( ) { return message; } - protected: string message; -}; /* ----- end of class |CLASSNAME| ----- */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-method-implementation == -template < class T > -void |?CLASSNAME|::|?METHODNAME| ( <+argument list+> ) +== C++.IMPLEMENTATION.method == map:+im , shortcut:m == +void +|?CLASSNAME|::|?METHODNAME| ( <+argument_list+> ) { return ; -} /* ----- end of method |CLASSNAME|::|METHODNAME| ----- */ +} /* ----- end of method |CLASSNAME|::|?METHODNAME| ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-accessor-implementation == +== C++.IMPLEMENTATION.accessor == map:+ia , shortcut:a == /* *-------------------------------------------------------------------------------------- * Class: |?CLASSNAME| * Method: get_|?ATTRIBUTE| *-------------------------------------------------------------------------------------- */ -template < class T > -inline |?RETURNTYPE| |CLASSNAME|::get_|ATTRIBUTE| ( ) const +inline |?RETURNTYPE| +|CLASSNAME|::get_|ATTRIBUTE| ( ) const { return |ATTRIBUTE|; -} /* ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- */ +} /* ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- */ /* *-------------------------------------------------------------------------------------- @@ -252,44 +388,14 @@ inline |?RETURNTYPE| |CLASSNAME|::get_|ATTRIBUTE| ( ) const * Method: set_|ATTRIBUTE| *-------------------------------------------------------------------------------------- */ -template < class T > -inline void |CLASSNAME|::set_|ATTRIBUTE| ( |RETURNTYPE| value ) +inline void +|CLASSNAME|::set_|ATTRIBUTE| ( |RETURNTYPE| value ) { |ATTRIBUTE| = value; return ; -} /* ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-class-definition == -/* - * ===================================================================================== - * Class: |?CLASSNAME:c| - * Description: - * ===================================================================================== - */ -template < class T > -class |CLASSNAME| -{ - public: - /* ==================== LIFECYCLE ======================================= */ - |CLASSNAME| (); /* constructor */ - - /* ==================== ACCESSORS ======================================= */ - - /* ==================== MUTATORS ======================================= */ - - /* ==================== OPERATORS ======================================= */ - - protected: - /* ==================== DATA MEMBERS ======================================= */ - - private: - /* ==================== DATA MEMBERS ======================================= */ - -}; /* ---------- end of template class |CLASSNAME| ---------- */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-class-implementation == +} /* ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- */ + +== C++.IMPLEMENTATION.template class == map:+itc , shortcut:c == /* *-------------------------------------------------------------------------------------- * Class: |?CLASSNAME:c| @@ -303,42 +409,7 @@ template < class T > } /* ---------- end of constructor of template class |CLASSNAME| ---------- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-class-using-new-definition == -/* - * ===================================================================================== - * Class: |?CLASSNAME:c| - * Description: - * ===================================================================================== - */ - -template < class T > -class |CLASSNAME| -{ - public: - // ==================== LIFECYCLE ======================================= - |CLASSNAME| (); /* constructor */ - |CLASSNAME| ( const |CLASSNAME| &other ); /* copy constructor */ - ~|CLASSNAME| (); /* destructor */ - - /* ==================== ACCESSORS ======================================= */ - - /* ==================== MUTATORS ======================================= */ - - /* ==================== OPERATORS ======================================= */ - - |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator - - protected: - /* ==================== DATA MEMBERS ======================================= */ - - private: - /* ==================== DATA MEMBERS ======================================= */ - -}; /* ----- end of template class |CLASSNAME| ----- */ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-class-using-new-implementation == +== C++.IMPLEMENTATION.template class using new == map:+itcn , shortcut:n == /* *-------------------------------------------------------------------------------------- * Class: |?CLASSNAME:c| @@ -388,31 +459,60 @@ template < class T > return *this; } /* ---------- end of assignment operator of template class |CLASSNAME| ---------- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-function == +== C++.IMPLEMENTATION.template method == map:+itm , shortcut:m == +template < class T > +void |?CLASSNAME|::|?METHODNAME| ( <+argument_list+> ) +{ + return ; +} /* ----- end of method |CLASSNAME|::|METHODNAME| ----- */ + +== C++.IMPLEMENTATION.template accessor == map:+ita , shortcut:a == +/* + *-------------------------------------------------------------------------------------- + * Class: |?CLASSNAME| + * Method: get_|?ATTRIBUTE| + *-------------------------------------------------------------------------------------- + */ +template < class T > +inline |?RETURNTYPE| |CLASSNAME|::get_|ATTRIBUTE| ( ) const +{ + return |ATTRIBUTE|; +} /* ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- */ + +/* + *-------------------------------------------------------------------------------------- + * Class: |CLASSNAME| + * Method: set_|ATTRIBUTE| + *-------------------------------------------------------------------------------------- + */ +template < class T > +inline void |CLASSNAME|::set_|ATTRIBUTE| ( |RETURNTYPE| value ) +{ + |ATTRIBUTE| = value; + return ; +} /* ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- */ + +== C++.template function == map:+tf, shortcut:f == template -void |?TEMPALTE_FUNCTION_NAME| ( <+argument list+> ) +void |?TEMPALTE_FUNCTION_NAME| ( <+argument_list+> ) { return ; } /* ----- end of template function |?TEMPALTE_FUNCTION_NAME| ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.operator-in == +== C++.IMPLEMENTATION.operator, out == map:+ioo, shortcut:o == ostream & -operator << ( ostream & os, const |?CLASSNAME| & obj ) +operator << ( ostream &os, const |?CLASSNAME| &obj ) { os << obj. ; return os; } /* ----- end of function operator << ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.operator-out == +== C++.IMPLEMENTATION.operator, in == map:+ioi, shortcut:i == istream & -operator >> ( istream & is, |?CLASSNAME| & obj ) +operator >> ( istream &is, |?CLASSNAME| &obj ) { is >> obj. ; return is; } /* ----- end of function operator >> ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.try-catch == +== C++.try catch == map:+tr, shortcut:t == try { } catch ( const &ExceptObj ) { /* handle exception: */ @@ -420,20 +520,16 @@ catch ( const &ExceptObj ) { /* handle exception: */ catch (...) { /* handle exception: unspecified */ } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.catch == +== C++.catch == map:+ca, shortcut:c == catch ( const &ExceptObj ) { /* handle exception: */ } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.catch-points == +== C++.catch all == map:+caa, shortcut:c == catch (...) { /* handle exception: unspecified */ } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.extern == +== C++.extern C == map:+ex, shortcut:x == extern "C" { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.open-input-file == +== C++.open input file == map:+oif, shortcut:o == string ifs_file_name = ""; /* input file name */ ifstream ifs; /* create ifstream object */ @@ -442,11 +538,10 @@ if (!ifs) { cerr << "\nERROR : failed to open input file " << ifs_file_name << endl; exit (EXIT_FAILURE); } -{-continue here-} +{-continue_here-} ifs.close (); /* close ifstream */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.open-output-file == -string ofs_file_name = ""; /* input file name */ +== C++.open output file == map:+oof, shortcut:o == +string ofs_file_name = ""; /* output file name */ ofstream ofs; /* create ofstream object */ ofs.open ( ofs_file_name.c_str() ); /* open ofstream */ @@ -454,31 +549,28 @@ if (!ofs) { cerr << "\nERROR : failed to open output file " << ofs_file_name << endl; exit (EXIT_FAILURE); } -{-continue here-} +{-continue_here-} ofs.close (); /* close ofstream */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.namespace-std == +== C++.using namespace std == map:+uns, shortcut:n == using namespace std; -== cpp.namespace == +== C++.using namespace xxx == map:+un, shortcut:n == using namespace |?NAMESPACE|; -== cpp.namespace-block == +== C++.namespace block xxx == map:+unb, shortcut:b == namespace |?NAMESPACE| { } /* ----- end of namespace |NAMESPACE| ----- */ -== cpp.namespace-alias == -namespace |?NAMESPACE_ALIAS| = {-original namespace name-}; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.rtti-typeid == insert == -typeid() -$ -== cpp.rtti-static-cast == insert == -static_cast<>() -$ -== cpp.rtti-const-cast == insert == -const_cast<>() -$ -== cpp.rtti-reinterpret-cast == insert == -reinterpret_cast<>() -$ -== cpp.rtti-dynamic-cast == insert == -dynamic_cast<>() -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== C++.namespace alias == map:+na, shortcut:a == +namespace |?NAMESPACE_ALIAS| = {-original_namespace_name-}; +== ENDTEMPLATE == + +== LIST: rtti == list == + 'const_cast' , + 'dynamic_cast' , + 'reinterpret_cast', + 'static_cast' , + 'typeid' , +== ENDLIST == + +== C++.RTTI == expandmenu, insert, map:+rt, shortcut:i == +|PickList( 'RTTI', 'rtti' )| +|PICK|<>() +== ENDTEMPLATE == diff --git a/c-support/templates/c.idioms.template b/c-support/templates/c.idioms.template index 1ae6940..1c6afa6 100644 --- a/c-support/templates/c.idioms.template +++ b/c-support/templates/c.idioms.template @@ -1,5 +1,4 @@ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.function == +== Idioms.function == map:if, shortcut:f == /* * === FUNCTION ====================================================================== * Name: |?FUNCTION_NAME| @@ -7,12 +6,11 @@ $%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% * ===================================================================================== */ void -|FUNCTION_NAME| ( <+argument list+> ) +|FUNCTION_NAME| ( <+argument_list+> ) { - return <+return value+>; + return <+return_value+>; } /* ----- end of function |FUNCTION_NAME| ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.function-static == +== Idioms.function-static == map:isf, shortcut:t == /* * === FUNCTION ====================================================================== * Name: |?FUNCTION_NAME| @@ -20,12 +18,11 @@ $%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% * ===================================================================================== */ static void -|FUNCTION_NAME| ( <+argument list+> ) +|FUNCTION_NAME| ( <+argument_list+> ) { - return <+return value+>; + return <+return_value+>; } /* ----- end of static function |FUNCTION_NAME| ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.main == +== Idioms.main == map:im, shortcut:m == #include /* @@ -39,31 +36,26 @@ main ( int argc, char *argv[] ) { return EXIT_SUCCESS; } /* ---------- end of function main ---------- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.enum == +== Idioms.enum == map:ie, shortcut:e == enum |?ENUM_NAME| { }; /* ---------- end of enum |ENUM_NAME| ---------- */ typedef enum |ENUM_NAME| |ENUM_NAME:c|; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.struct == +== Idioms.struct == map:is, shortcut:s == struct |?STRUCT_NAME| { }; /* ---------- end of struct |STRUCT_NAME| ---------- */ typedef struct |STRUCT_NAME| |STRUCT_NAME:c|; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.union == +== Idioms.union == map:iu, shortcut:u == union |?UNION_NAME| { }; /* ---------- end of union |UNION_NAME| ---------- */ typedef union |UNION_NAME| |UNION_NAME:c|; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.printf == insert == -printf ( "\n" ); -== idioms.scanf == insert == +== Idioms.scanf == map:isc, shortcut:s, insert == scanf ( "", & ); -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.calloc == +== Idioms.printf == map:ipr, shortcut:p, insert == +printf ( "\n" ); +== Idioms.calloc == map:ica, shortcut:c == |?POINTER| = calloc ( (size_t)(<+COUNT+>), sizeof(<+TYPE+>) ); if ( |POINTER|==NULL ) { fprintf ( stderr, "\ndynamic memory allocation failed\n" ); @@ -73,8 +65,7 @@ if ( |POINTER|==NULL ) { free (|POINTER|); |POINTER| = NULL; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.malloc == +== Idioms.malloc == map:ima, shortcut:m == |?POINTER| = malloc ( sizeof(<+TYPE+>) ); if ( |POINTER|==NULL ) { fprintf ( stderr, "\ndynamic memory allocation failed\n" ); @@ -84,21 +75,18 @@ if ( |POINTER|==NULL ) { free (|POINTER|); |POINTER| = NULL; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.realloc == +== Idioms.realloc == map:ire, shortcut:r == |?POINTER| = realloc ( |POINTER|, sizeof(<+TYPE+>) ); if ( |POINTER|==NULL ) { fprintf ( stderr, "\ndynamic memory reallocation failed\n" ); exit (EXIT_FAILURE); } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.sizeof == insert == +== Idioms.sizeof == map:isi, shortcut:s, insert == sizeof() -== idioms.assert == insert == +== Idioms.assert == map:ias, shortcut:a, insert == assert(); -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.open-input-file == +== Idioms.open-input-file == map:ii, shortcut:i == FILE *|?FILEPOINTER|; /* input-file pointer */ char *|FILEPOINTER|_file_name = ""; /* input-file name */ @@ -108,15 +96,14 @@ if ( |FILEPOINTER| == NULL ) { |FILEPOINTER|_file_name, strerror(errno) ); exit (EXIT_FAILURE); } -{-continue here-} +{-continue_here-} if( fclose(|FILEPOINTER|) == EOF ) { /* close input file */ fprintf ( stderr, "couldn't close file '%s'; %s\n", |FILEPOINTER|_file_name, strerror(errno) ); exit (EXIT_FAILURE); } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.open-output-file == +== Idioms.open-output-file == map:io, shortcut:o == FILE *|?FILEPOINTER|; /* output-file pointer */ char *|FILEPOINTER|_file_name = ""; /* output-file name */ @@ -126,16 +113,14 @@ if ( |FILEPOINTER| == NULL ) { |FILEPOINTER|_file_name, strerror(errno) ); exit (EXIT_FAILURE); } -{-continue here-} +{-continue_here-} if( fclose(|FILEPOINTER|) == EOF ) { /* close output file */ fprintf ( stderr, "couldn't close file '%s'; %s\n", |FILEPOINTER|_file_name, strerror(errno) ); exit (EXIT_FAILURE); } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.fprintf == insert == +== Idioms.fprintf == map:ifsc, shortcut:f, insert == fprintf ( |?FILEPOINTER|, "\n", ); -== idioms.fscanf == insert == +== Idioms.fscanf == map:ifpr, shortcut:f, insert == fscanf ( |?FILEPOINTER|, "", & ); -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/c-support/templates/c.preprocessor.template b/c-support/templates/c.preprocessor.template index 27c6356..ef170bd 100644 --- a/c-support/templates/c.preprocessor.template +++ b/c-support/templates/c.preprocessor.template @@ -1,54 +1,94 @@ -$------------------------------------------------------------------------- -== preprocessor.include-global == insert == +== LIST: C_StandardLibs == list == + 'assert.h' , + 'complex.h' , + 'ctype.h' , + 'errno.h' , + 'fenv.h' , + 'float.h' , + 'inttypes.h' , + 'iso646.h' , + 'limits.h' , + 'locale.h' , + 'math.h' , + 'setjmp.h' , + 'signal.h' , + 'stdalign.h' , + 'stdarg.h' , + 'stdatomic.h' , + 'stdbool.h' , + 'stddef.h' , + 'stdint.h' , + 'stdio.h' , + 'stdlib.h' , + 'stdnoreturn.h', + 'string.h' , + 'tgmath.h' , + 'threads.h' , + 'time.h' , + 'uchar.h' , + 'wchar.h' , + 'wctype.h' , +== ENDLIST == + +== Preprocessor.include std lib header == expandmenu, append, map:pih, shortcut:s == +|PickList( 'Std. Libs', 'C_StandardLibs' )| +#include <|PICK|> +== ENDTEMPLATE == + +§------------------------------------------------------------------------- +== Preprocessor.include-global == map:pg, shortcut:g, insert == #include <> -$------------------------------------------------------------------------- -== preprocessor.include-local == insert == +§------------------------------------------------------------------------- +== Preprocessor.include-local == map:pl, shortcut:l, insert == #include "" -$------------------------------------------------------------------------- -== preprocessor.define == insert == +§------------------------------------------------------------------------- +== Preprocessor.define == map:pd, shortcut:d, insert == #define /* */ -$------------------------------------------------------------------------- -== preprocessor.undefine == insert == +§------------------------------------------------------------------------- +== Preprocessor.undefine == map:pu, shortcut:u, insert == #undef /* */ -$------------------------------------------------------------------------- -== preprocessor.if-endif == +§------------------------------------------------------------------------- +== Preprocessor.if-endif == map:pif, shortcut:i == #if |?CONDITION:u| #endif /* ----- |CONDITION| ----- */ -$------------------------------------------------------------------------- -== preprocessor.if-else-endif == +§------------------------------------------------------------------------- +== Preprocessor.if-else-endif == map:pie, shortcut:i == #if |?CONDITION:u| #else /* ----- not |CONDITION| ----- */ <+ELSE PART+> #endif /* ----- not |CONDITION| ----- */ -$------------------------------------------------------------------------- -== preprocessor.ifdef-else-endif == +§------------------------------------------------------------------------- +== Preprocessor.ifdef-else-endif == map:pid, shortcut:f == #ifdef |?CONDITION:u| #else /* ----- not |CONDITION| ----- */ <+ELSE PART+> #endif /* ----- not |CONDITION| ----- */ -$------------------------------------------------------------------------- -== preprocessor.ifndef-else-endif == +§------------------------------------------------------------------------- +== Preprocessor.ifndef-else-endif == map:pin, shortcut:n == #ifndef |?CONDITION:u| #else /* ----- not |CONDITION| ----- */ <+ELSE PART+> #endif /* ----- not |CONDITION| ----- */ -$------------------------------------------------------------------------- -== preprocessor.ifndef-def-endif == +§------------------------------------------------------------------------- +== Preprocessor.ifndef-def-endif == map:pind, shortcut:e == #ifndef |?BASENAME:L|_INC #define |BASENAME|_INC #endif /* ----- #ifndef |BASENAME|_INC ----- */ -$------------------------------------------------------------------------- -== preprocessor.error == +§------------------------------------------------------------------------- +== Preprocessor.error == map:pe, shortcut:o == #error "" /* */ -$------------------------------------------------------------------------- -== preprocessor.line == +§------------------------------------------------------------------------- +== Preprocessor.line == map:pli, shortcut:l == #line /* */ -$------------------------------------------------------------------------- -== preprocessor.pragma == +§------------------------------------------------------------------------- +== Preprocessor.pragma == map:pp, shortcut:p == #pragma /* */ -$------------------------------------------------------------------------- +§------------------------------------------------------------------------- +== Preprocessor.warning == map:pw, shortcut:w == +#warning /* */ +§------------------------------------------------------------------------- diff --git a/c-support/templates/c.statements.template b/c-support/templates/c.statements.template index 574366d..6bebd8e 100644 --- a/c-support/templates/c.statements.template +++ b/c-support/templates/c.statements.template @@ -1,48 +1,46 @@ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.do-while == +== Statements.do while == map:sd, shortcut:d == do { } while ( ); /* ----- end do-while ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.for == +== Statements.for == map:sf, shortcut:o == for ( ; ; ) -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.for-block == -for ( ; ; ) { +§ +§ The names INIT, CONDITION, INCREMENT, and 'for block' are used by the main +§ plugin plugin/c.vim . Please do not change. +§ +== Statements.for block == map:sfo, shortcut:r == +|DefaultMacro( 'CONDITION', '{+CONDITION+}' )| +|DefaultMacro( 'INCREMENT', '{+INCREMENT+}' )| +for ( |INIT|; |CONDITION|; |INCREMENT| ) { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.if == +== Statements.range-based for == map:sfr, shortcut:a == +for ( : <-EXPRESSION-> ){ +} +== Statements.if == map:si, shortcut:i == if ( ) -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.if-block == +== Statements.if block == map:sif, shortcut:f == if ( ) { -<-IF PART-> +<-IF_PART-> } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.if-else == +== Statements.if else == map:sie, shortcut:e == if ( ) else -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.if-block-else == +== Statements.if block else == map:sife, shortcut:l == if ( ) { -<-IF PART-> +<-IF_PART-> } else { -<-ELSE PART-> +<-ELSE_PART-> } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.else-block == +== Statements.else block == map:se, shortcut:e == else { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.while == +== Statements.while == map:sw, shortcut:w == while ( ) -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.while-block == +== Statements.while block == map:swh, shortcut:h == while ( ) { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.switch == +== Statements.switch == map:ss, shortcut:s == switch ( ) { case <-LABEL->: break; @@ -56,14 +54,11 @@ switch ( ) { default: break; } /* ----- end switch ----- */ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.case == +== Statements.case == map:sc, shortcut:c == case : break; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.block == +== Statements.block == map:sb, shortcut:b == { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/c-support/templates/cpp.comments.template b/c-support/templates/cpp.comments.template index 5cb19db..698f247 100644 --- a/c-support/templates/cpp.comments.template +++ b/c-support/templates/cpp.comments.template @@ -1,168 +1,119 @@ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.end-of-line-comment == append == +== Comments.end-of-line-comment == append, nomenu == // -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.frame == -//---------------------------------------------------------------------- +== Comments.frame == map:cfr, shortcut:f == +//----------------------------------------------------------------------------- // -//---------------------------------------------------------------------- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.function == +//----------------------------------------------------------------------------- +== Comments.function == map:cfu, shortcut:f == // === FUNCTION ====================================================================== // Name: |?FUNCTION_NAME| // Description: // ===================================================================================== -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.method == +== Comments.method == map:cme, shortcut:m == //-------------------------------------------------------------------------------------- // Class: |?CLASSNAME| -// Method: |?METHODNAME| +// Method: |?CLASSNAME| :: |?METHODNAME| // Description: //-------------------------------------------------------------------------------------- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.class == +== Comments.class == map:ccl, shortcut:c == // ===================================================================================== // Class: |?CLASSNAME| // Description: // ===================================================================================== -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-description == start == +== Comments.file description impl == map:cfdi, shortcut:c, start, noindent == // ===================================================================================== -// +// // Filename: |FILENAME| -// +// // Description: -// +// // Version: 1.0 // Created: |DATE| |TIME| // Revision: none -// Compiler: g++ -// +// Compiler: gcc +// // Author: |AUTHOR| (|AUTHORREF|), |EMAIL| -// Company: |ORGANIZATION| -// +// Organization: |ORGANIZATION| +// // ===================================================================================== -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-description-header == start == +== Comments.file description header == map:cfdh, shortcut:h, start, noindent == // ===================================================================================== -// +// // Filename: |FILENAME| -// +// // Description: -// +// // Version: 1.0 // Created: |DATE| |TIME| // Revision: none -// Compiler: g++ -// +// Compiler: gcc +// // Author: |AUTHOR| (|AUTHORREF|), |EMAIL| -// Company: |ORGANIZATION| -// +// Organization: |ORGANIZATION| +// // ===================================================================================== -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-header-includes == -// ##### HEADER FILE INCLUDES ################################################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-macros == -// ##### MACROS - LOCAL TO THIS SOURCE FILE ################################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-typedefs == -// ##### TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-data-types == -// ##### DATA TYPES - LOCAL TO THIS SOURCE FILE ############################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-class-defs == -// ##### CLASS DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################## - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-local-variables == -// ##### VARIABLES - LOCAL TO THIS SOURCE FILE ################################ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-prototypes == -// ##### PROTOTYPES - LOCAL TO THIS SOURCE FILE ############################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-function-defs-exported == -// ##### FUNCTION DEFINITIONS - EXPORTED FUNCTIONS ############################ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-function-defs-local == -// ##### FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE ##################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-class-implementations-exported == -// ##### CLASS IMPLEMENTATIONS - EXPORTED CLASSES ############################# - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-cpp-class-implementations-local == -// ##### CLASS IMPLEMENTATIONS - LOCAL CLASSES ################################ - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-header-includes == -// ##### HEADER FILE INCLUDES ################################################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-macros == -// ##### EXPORTED MACROS ######################################################## - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-typedefs == -// ##### EXPORTED TYPE DEFINITIONS ############################################## - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-data-types == -// ##### EXPORTED DATA TYPES #################################################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-class-defs == -// ##### EXPORTED CLASS DEFINITIONS ############################################# - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-variables == -// ##### EXPORTED VARIABLES ##################################################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.file-section-hpp-exported-function-declarations == -// ##### EXPORTED FUNCTION DECLARATIONS ######################################### - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.keyword-bug == append == - // :BUG:|DATE| |TIME|:|AUTHORREF|: -== comment.keyword-compiler == append == - // :COMPILER:|DATE| |TIME|:|AUTHORREF|: -== comment.keyword-todo == append == - // :TODO:|DATE| |TIME|:|AUTHORREF|: -== comment.keyword-tricky == append == - // :TRICKY:|DATE| |TIME|:|AUTHORREF|: -== comment.keyword-warning == append == - // :WARNING:|DATE| |TIME|:|AUTHORREF|: -== comment.keyword-workaround == append == - // :WORKAROUND:|DATE| |TIME|:|AUTHORREF|: -== comment.keyword-keyword == append == - // :|?KEYWORD:u|:|DATE| |TIME|:|AUTHORREF|: -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== comment.special-empty == append == - // EMPTY -== comment.special-fall-through == append == - // FALL THROUGH -== comment.special-implicit-type-conversion == append == - // IMPLICIT TYPE CONVERSION -== comment.special-no-return == append == - // NO RETURN -== comment.special-not-reached == append == - // NOT REACHED -== comment.special-remains-to-be-implemented == append == - // REMAINS TO BE IMPLEMENTED -== comment.special-constant-type-is-long == append == - // constant type is long -== comment.special-constant-type-is-unsigned == append == - // constant type is unsigned -== comment.special-constant-type-is-unsigned-long == append == - // constant type is unsigned long -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +== ENDTEMPLATE == + +== LIST: comments_c_sections == hash == + 'HEADER FILE INCLUDES' : 'HEADER FILE INCLUDES ###############################', + 'LOCAL MACROS' : 'MACROS - LOCAL TO THIS SOURCE FILE ###############', + 'LOCAL TYPE DEFINITIONS' : 'TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE #####', + 'LOCAL DATA TYPES' : 'DATA TYPES - LOCAL TO THIS SOURCE FILE ###########', + 'LOCAL VARIABLES' : 'VARIABLES - LOCAL TO THIS SOURCE FILE ############', + 'LOCAL PROTOTYPES' : 'PROTOTYPES - LOCAL TO THIS SOURCE FILE ###########', + 'EXP. FUNCTION DEFINITIONS' : 'FUNCTION DEFINITIONS - EXPORTED FUNCTIONS ########', + 'LOCAL FUNCTION DEFINITIONS' : 'FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE #', + 'LOCAL CLASS DEFINITIONS' : 'CLASS DEFINITIONS - LOCAL TO THIS SOURCE FILE ####', + 'EXP. CLASS IMPLEMENTATIONS' : 'CLASS IMPLEMENTATIONS - EXPORTED CLASSES #########', + 'LOCAL CLASS IMPLEMENTATIONS' : 'CLASS IMPLEMENTATIONS - LOCAL CLASSES ############', +== LIST: comments_h_sections == hash == + 'HEADER FILE INCLUDES' : 'HEADER FILE INCLUDES ###########', + 'EXPORTED MACROS' : 'EXPORTED MACROS ################', + 'EXPORTED TYPE DEFINITIONS' : 'EXPORTED TYPE DEFINITIONS ######', + 'EXPORTED DATA TYPES' : 'EXPORTED DATA TYPES ############', + 'EXPORTED CLASS DEFINITIONS' : 'EXPORTED CLASS DEFINITIONS #####', + 'EXPORTED VARIABLES' : 'EXPORTED VARIABLES #############', + 'EXPORTED FUNCTION DECLARATIONS' : 'EXPORTED FUNCTION DECLARATIONS #', +== LIST: comments_keywords == hash == + 'BUG' : ':BUG:|DATE| |TIME|:|AUTHORREF|:', + 'COMPILER' : ':COMPILER:|DATE| |TIME|:|AUTHORREF|:', + 'REMARK' : ':REMARK:|DATE| |TIME|:|AUTHORREF|:', + 'TODO' : ':TODO:|DATE| |TIME|:|AUTHORREF|:', + 'WARNING' : ':WARNING:|DATE| |TIME|:|AUTHORREF|:', + 'WORKAROUND' : ':WORKAROUND:|DATE| |TIME|:|AUTHORREF|:', + 'new keyword' : '::|DATE| |TIME|:|AUTHORREF|: {+COMMENT+}', +== LIST: comments_special == list == + 'EMPTY' , + 'FALL THROUGH' , + 'IMPLICIT TYPE CONVERSION' , + 'NO RETURN' , + 'NOT REACHED' , + 'TO BE IMPLEMENTED' , + 'constant type is long' , + 'constant type is unsigned' , + 'constant type is unsigned long', +== LIST: comments_macros == list == + 'AUTHOR' , + 'AUTHORREF' , + 'COMPANY' , + 'COPYRIGHT' , + 'EMAIL' , + 'ORGANIZATION', +== ENDLIST == + +== Comments.C file sections == expandmenu, append, map:ccs, shortcut:s == +|PickList( 'C file sections', 'comments_c_sections' )| +// ##### |PICK|#################### +== Comments.H file sections == expandmenu, append, map:chs, shortcut:s == +|PickList( 'H file sections', 'comments_h_sections' )| +// ##### |PICK|######################################## +== Comments.keyword comments == expandmenu, append, map:ckc, shortcut:k == +|PickList( 'keyword comments', 'comments_keywords' )| + // |PICK| +== Comments.special comments == expandmenu, append, map:csc, shortcut:s == +|PickList( 'special comments', 'comments_special' )| + // |PICK| +== Comments.macros == expandmenu, insert, map:cma, shortcut:m == +|PickList( 'macro', 'comments_macros' )| +||PICK|| +== ENDTEMPLATE == diff --git a/c-support/templates/cpp.cpp.template b/c-support/templates/cpp.cpp.template index ddcaada..3efe0d7 100644 --- a/c-support/templates/cpp.cpp.template +++ b/c-support/templates/cpp.cpp.template @@ -1,181 +1,336 @@ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -$ -== cpp.cin == -cin >> ; -$ -== cpp.cout == insert == -cout << << endl; -$ -== cpp.cout-operator == insert == -<< "" -$ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.output-manipulator-boolalpha == insert == -<< boolalpha -== cpp.output-manipulator-dec == insert == -<< dec -== cpp.output-manipulator-endl == insert == -<< endl -== cpp.output-manipulator-fixed == insert == -<< fixed -== cpp.output-manipulator-flush == insert == -<< flush -== cpp.output-manipulator-hex == insert == -<< hex -== cpp.output-manipulator-internal == insert == -<< internal -== cpp.output-manipulator-left == insert == -<< left -== cpp.output-manipulator-oct == insert == -<< oct -== cpp.output-manipulator-right == insert == -<< right -== cpp.output-manipulator-scientific == insert == -<< scientific -== cpp.output-manipulator-setbase == insert == -<< setbase(10) -== cpp.output-manipulator-setfill == insert == -<< setfill() -== cpp.output-manipulator-setiosflag == insert == -<< setiosflags() -== cpp.output-manipulator-setprecision == insert == -<< setprecision(6) -== cpp.output-manipulator-setw == insert == -<< setw(0) -== cpp.output-manipulator-showbase == insert == -<< showbase -== cpp.output-manipulator-showpoint == insert == -<< showpoint -== cpp.output-manipulator-showpos == insert == -<< showpos -== cpp.output-manipulator-uppercase == insert == -<< uppercase -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.method-implementation == -void -|?CLASSNAME|::|?METHODNAME| ( <+argument list+> ) +== LIST: output_manipulators == hash == + 'boolalpha' : 'boolalpha' , + 'dec' : 'dec' , + 'defaultfloat' : 'defaultfloat' , + 'endl' : 'endl' , + 'ends' : 'ends' , + 'fixed' : 'fixed' , + 'flush' : 'flush' , + 'get_money' : 'get_money' , + 'get_time' : 'get_time' , + 'hexfloat' : 'hexfloat' , + 'hex' : 'hex' , + 'internal' : 'internal' , + 'left' : 'left' , + 'oct' : 'oct' , + 'put_money' : 'put_money' , + 'put_time' : 'put_time' , + 'resetiosflag' : 'resetiosflag' , + 'right' : 'right' , + 'scientific' : 'scientific' , + 'setbase' : 'setbase(10)' , + 'setfill' : 'setfill()' , + 'setiosflags' : 'setiosflags()' , + 'setprecision' : 'setprecision(6)', + 'setw' : 'setw(0)' , + 'showbase' : 'showbase' , + 'showpoint' : 'showpoint' , + 'showpos' : 'showpos' , + 'skipws' : 'skipws' , + 'unitbuf' : 'unitbuf' , + 'uppercase' : 'uppercase' , + 'ws' : 'ws' , +== ENDLIST == + +== LIST: ios_flagbits == list == + 'adjustfield', + 'basefield' , + 'boolalpha' , + 'dec' , + 'fixed' , + 'floatfield' , + 'hex' , + 'internal' , + 'left' , + 'oct' , + 'right' , + 'scientific' , + 'showbase' , + 'showpoint' , + 'showpos' , + 'skipws' , + 'unitbuf' , + 'uppercase' , +== ENDLIST == + +== LIST: include == list == + 'algorithm' , + 'array' , + 'atomic' , + 'bitset' , + 'chrono' , + 'codecvt' , + 'complex' , + 'condition_variable' , + 'deque' , + 'exception' , + 'forward_list' , + 'fstream' , + 'functional' , + 'future' , + 'initializer_list' , + 'iomanip' , + 'ios' , + 'iosfwd' , + 'iostream' , + 'istream' , + 'iterator' , + 'limits' , + 'list' , + 'locale' , + 'map' , + 'memory' , + 'mutex' , + 'new' , + 'numeric' , + 'ostream' , + 'queue' , + 'random' , + 'ratio' , + 'regex' , + 'set' , + 'sstream' , + 'stack' , + 'stdexcept' , + 'streambuf' , + 'string' , + 'strstream' , + 'system_error' , + 'thread' , + 'tuple' , + 'typeindex' , + 'typeinfo' , + 'type_traits' , + 'unordered_map', + 'unordered_set', + 'utility' , + 'valarray' , + 'vector' , +== ENDLIST == + +== LIST: c_include == list == + 'cassert' , + 'ccomplex' , + 'cctype' , + 'cerrno' , + 'cfenv' , + 'cfloat' , + 'cinttypes', + 'ciso646' , + 'climits' , + 'clocale' , + 'cmath' , + 'csetjmp' , + 'csignal' , + 'cstdalign', + 'cstdarg' , + 'cstdbool' , + 'cstddef' , + 'cstdint' , + 'cstdio' , + 'cstdlib' , + 'cstring' , + 'ctgmath' , + 'ctime' , + 'cuchar' , + 'cwchar' , + 'cwctype' , +== ENDLIST == + +== C++.include C++ std lib header == expandmenu, insert, map:+ih, shortcut:i == +|PickList( 'include', 'include' )| +#include <|PICK|> +== C++.include C std lib header == expandmenu, insert, map:+ich, shortcut:c == +|PickList( 'include C', 'c_include' )| +#include <|PICK|> +== C++.output manipulators == expandmenu, insert, map:+om, shortcut:m == +|PickList( 'output manipulators', 'output_manipulators' )| + << |PICK| +== C++.ios flagbits == expandmenu, insert, map:+fb, shortcut:i == +|PickList( 'ios flagbits', 'ios_flagbits' )| +ios::|PICK| +== ENDTEMPLATE == + +== C++.class == map:+c, shortcut:c == +// ===================================================================================== +// Class: |?CLASSNAME:c| +// Description: +// ===================================================================================== +class |CLASSNAME| { - return ; -} // ----- end of method |CLASSNAME|::|METHODNAME| ----- + public: + // ==================== LIFECYCLE ======================================= + |CLASSNAME| (); // constructor -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.accessor-implementation == -//-------------------------------------------------------------------------------------- -// Class: |?CLASSNAME| -// Method: get_|?ATTRIBUTE| -//-------------------------------------------------------------------------------------- -inline |?RETURNTYPE| -|CLASSNAME|::get_|ATTRIBUTE| ( ) const -{ - return |ATTRIBUTE|; -} // ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- + // ==================== ACCESSORS ======================================= -//-------------------------------------------------------------------------------------- -// Class: |CLASSNAME| -// Method: set_|ATTRIBUTE| -//-------------------------------------------------------------------------------------- -inline void -|CLASSNAME|::set_|ATTRIBUTE| ( |RETURNTYPE| value ) + // ==================== MUTATORS ======================================= + + // ==================== OPERATORS ======================================= + + protected: + // ==================== METHODS ======================================= + + // ==================== DATA MEMBERS ======================================= + + private: + // ==================== METHODS ======================================= + + // ==================== DATA MEMBERS ======================================= + +}; // ----- end of class |CLASSNAME| ----- + +== C++.class using new == map:+cn, shortcut:n == +// ===================================================================================== +// Class: |?CLASSNAME:c| +// Description: +// ===================================================================================== +class |CLASSNAME| { - |ATTRIBUTE| = value; - return ; -} // ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.class-definition == + public: + // ==================== LIFECYCLE ======================================= + |CLASSNAME| (); // constructor + |CLASSNAME| ( const |CLASSNAME| &other ); // copy constructor + ~|CLASSNAME| (); // destructor + + // ==================== ACCESSORS ======================================= + + // ==================== MUTATORS ======================================= + + // ==================== OPERATORS ======================================= + + |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator + + protected: + // ==================== METHODS ======================================= + + // ==================== DATA MEMBERS ======================================= + + private: + // ==================== METHODS ======================================= + + // ==================== DATA MEMBERS ======================================= + +}; // ----- end of class |CLASSNAME| ----- + +== C++.template class == map:+tc, shortcut:t == // ===================================================================================== // Class: |?CLASSNAME:c| // Description: // ===================================================================================== + */ +template < class T > class |CLASSNAME| { public: - // ==================== LIFECYCLE ======================================= - |CLASSNAME| (); // constructor + // ==================== LIFECYCLE ======================================= + |CLASSNAME| (); // constructor - // ==================== ACCESSORS ======================================= + // ==================== ACCESSORS ======================================= - // ==================== MUTATORS ======================================= + // ==================== MUTATORS ======================================= - // ==================== OPERATORS ======================================= + // ==================== OPERATORS ======================================= protected: - // ==================== DATA MEMBERS ======================================= + // ==================== METHODS ======================================= + + // ==================== DATA MEMBERS ======================================= private: - // ==================== DATA MEMBERS ======================================= + // ==================== METHODS ======================================= -}; // ----- end of class |CLASSNAME| ----- + // ==================== DATA MEMBERS ======================================= -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.class-implementation == -//-------------------------------------------------------------------------------------- -// Class: |?CLASSNAME| -// Method: |CLASSNAME| -// Description: constructor -//-------------------------------------------------------------------------------------- -|CLASSNAME|::|CLASSNAME| () -{ -} // ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- +}; // ---------- end of template class |CLASSNAME| ---------- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.class-using-new-definition == +== C++.template class using new == map:+tcn, shortcut:n == // ===================================================================================== // Class: |?CLASSNAME:c| // Description: // ===================================================================================== + +template < class T > class |CLASSNAME| { public: // ==================== LIFECYCLE ======================================= - |CLASSNAME| (); // constructor - |CLASSNAME| ( const |CLASSNAME| &other ); // copy constructor - ~|CLASSNAME| (); // destructor + |CLASSNAME| (); // constructor + |CLASSNAME| ( const |CLASSNAME| &other ); // copy constructor + ~|CLASSNAME| (); // destructor - // ==================== ACCESSORS ======================================= + // ==================== ACCESSORS ======================================= - // ==================== MUTATORS ======================================= + // ==================== MUTATORS ======================================= - // ==================== OPERATORS ======================================= + // ==================== OPERATORS ======================================= - |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator + |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator protected: - // ==================== DATA MEMBERS ======================================= + // ==================== METHODS ======================================= + + // ==================== DATA MEMBERS ======================================= private: - // ==================== DATA MEMBERS ======================================= + // ==================== METHODS ======================================= + + // ==================== DATA MEMBERS ======================================= -}; // ----- end of class |CLASSNAME| ----- +}; // ----- end of template class |CLASSNAME| ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.class-using-new-implementation == +== C++.error class == map:+ec, shortcut:e == +// ===================================================================================== +// Class: |?CLASSNAME:c| +// Description: +// ===================================================================================== +class |CLASSNAME| +{ + public: |CLASSNAME| ( string msg = "|CLASSNAME|" ):message(msg) { } + virtual ~|CLASSNAME| ( ) { } + virtual string what ( ) const throw ( ) { return message; } + protected: string message; +}; // ----- end of class |CLASSNAME| ----- + +== C++.IMPLEMENTATION.class == map:+ic , shortcut:c == //-------------------------------------------------------------------------------------- -// Class: |?CLASSNAME| +// Class: |?CLASSNAME:c| // Method: |CLASSNAME| // Description: constructor //-------------------------------------------------------------------------------------- |CLASSNAME|::|CLASSNAME| () { -} // ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- +} // ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- + +== C++.IMPLEMENTATION.class using new == map:+icn , shortcut:n == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME:c| +// Method: |CLASSNAME| +// Description: constructor +//-------------------------------------------------------------------------------------- +|CLASSNAME|::|CLASSNAME| () +{ +} // ----- end of method |CLASSNAME|::|CLASSNAME| (constructor) ----- //-------------------------------------------------------------------------------------- // Class: |CLASSNAME| // Method: |CLASSNAME| // Description: copy constructor //-------------------------------------------------------------------------------------- + */ |CLASSNAME|::|CLASSNAME| ( const |CLASSNAME| &other ) { -} // ----- end of method |CLASSNAME|::|CLASSNAME| (copy constructor) ----- +} // ----- end of method |CLASSNAME|::|CLASSNAME| (copy constructor) ----- //-------------------------------------------------------------------------------------- // Class: |CLASSNAME| // Method: ~|CLASSNAME| // Description: destructor //-------------------------------------------------------------------------------------- + */ |CLASSNAME|::~|CLASSNAME| () { -} // ----- end of method |CLASSNAME|::~|CLASSNAME| (destructor) ----- +} // ----- end of method |CLASSNAME|::~|CLASSNAME| (destructor) ----- //-------------------------------------------------------------------------------------- // Class: |CLASSNAME| @@ -188,135 +343,59 @@ $%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if ( this != &other ) { } return *this; -} // ----- end of method |CLASSNAME|::operator = (assignment operator) ----- +} // ----- end of method |CLASSNAME|::operator = (assignment operator) ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.error-class == -// ===================================================================================== -// Class: |?CLASSNAME:c| -// Description: -// ===================================================================================== -class |CLASSNAME| -{ - public: |CLASSNAME| ( string msg = "|CLASSNAME|" ):message(msg) { } - virtual ~|CLASSNAME| ( ) { } - virtual string what ( ) const throw ( ) { return message; } - protected: string message; -}; // ---------- end of class |CLASSNAME| ---------- - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-method-implementation == -template < class T > -void |?CLASSNAME|::|?METHODNAME| ( <+argument list+> ) +== C++.IMPLEMENTATION.method == map:+im , shortcut:m == +void +|?CLASSNAME|::|?METHODNAME| ( <+argument_list+> ) { return ; -} // ----- end of method |CLASSNAME|::|METHODNAME| ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-accessor-implementation == +} // ----- end of method |CLASSNAME|::|?METHODNAME| ----- + +== C++.IMPLEMENTATION.accessor == map:+ia , shortcut:a == //-------------------------------------------------------------------------------------- // Class: |?CLASSNAME| // Method: get_|?ATTRIBUTE| //-------------------------------------------------------------------------------------- -template < class T > -inline |?RETURNTYPE| |CLASSNAME|::get_|ATTRIBUTE| ( ) const +inline |?RETURNTYPE| +|CLASSNAME|::get_|ATTRIBUTE| ( ) const { return |ATTRIBUTE|; -} // ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- +} // ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- //-------------------------------------------------------------------------------------- // Class: |CLASSNAME| // Method: set_|ATTRIBUTE| //-------------------------------------------------------------------------------------- -template < class T > -inline void |CLASSNAME|::set_|ATTRIBUTE| ( |RETURNTYPE| value ) +inline void +|CLASSNAME|::set_|ATTRIBUTE| ( |RETURNTYPE| value ) { |ATTRIBUTE| = value; return ; -} // ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- +} // ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-class-definition == -// ===================================================================================== -// Class: |?CLASSNAME:c| -// Description: -// ===================================================================================== - -template < class T > -class |CLASSNAME| -{ - public: - // ==================== LIFECYCLE ======================================= - |CLASSNAME| (); // constructor - - // ==================== ACCESSORS ======================================= - - // ==================== MUTATORS ======================================= - - // ==================== OPERATORS ======================================= - - protected: - // ==================== DATA MEMBERS ======================================= - - private: - // ==================== DATA MEMBERS ======================================= - -}; // ----- end of template class |CLASSNAME| ----- - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-class-implementation == +== C++.IMPLEMENTATION.template class == map:+itc , shortcut:c == //-------------------------------------------------------------------------------------- -// Class: |?CLASSNAME| +// Class: |?CLASSNAME:c| // Method: |CLASSNAME| -// Description: constructor +// Description: //-------------------------------------------------------------------------------------- template < class T > -|CLASSNAME| :: |CLASSNAME| () +|CLASSNAME| < T >::|CLASSNAME| () { -} // ----- end of constructor of template class |CLASSNAME| ----- +} // ---------- end of constructor of template class |CLASSNAME| ---------- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-class-using-new-definition == -// ===================================================================================== -// Class: |?CLASSNAME:c| -// Description: -// ===================================================================================== -template < class T > -class |CLASSNAME| -{ - public: - // ==================== LIFECYCLE ======================================= - |CLASSNAME| (); // constructor - |CLASSNAME| ( const |CLASSNAME| &other ); // copy constructor - ~|CLASSNAME| (); // destructor - - // ==================== ACCESSORS ======================================= - - // ==================== MUTATORS ======================================= - - // ==================== OPERATORS ======================================= - - |CLASSNAME|& operator = ( const |CLASSNAME| &other ); // assignment operator - - protected: - // ==================== DATA MEMBERS ======================================= - - private: - // ==================== DATA MEMBERS ======================================= - -}; // ----- end of template class |CLASSNAME| ----- - -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-class-using-new-implementation == +== C++.IMPLEMENTATION.template class using new == map:+itcn , shortcut:n == //-------------------------------------------------------------------------------------- -// Class: |?CLASSNAME| +// Class: |?CLASSNAME:c| // Method: |CLASSNAME| // Description: constructor //-------------------------------------------------------------------------------------- template < class T > -|CLASSNAME|::|CLASSNAME| () -{ -} // ----- end of constructor of template class |CLASSNAME| ----- +|CLASSNAME|< T >::|CLASSNAME| () +{ +} // ---------- end of constructor of template class |CLASSNAME| ---------- //-------------------------------------------------------------------------------------- // Class: |CLASSNAME| @@ -324,9 +403,9 @@ template < class T > // Description: copy constructor //-------------------------------------------------------------------------------------- template < class T > -|CLASSNAME|::|CLASSNAME| ( const |CLASSNAME| &other ) -{ -} // ----- end of copy constructor of template class |CLASSNAME| ----- +|CLASSNAME|< T >::|CLASSNAME| ( const |CLASSNAME| &other ) +{ +} // ---------- end of copy constructor of template class |CLASSNAME| ---------- //-------------------------------------------------------------------------------------- // Class: |CLASSNAME| @@ -334,9 +413,9 @@ template < class T > // Description: destructor //-------------------------------------------------------------------------------------- template < class T > -|CLASSNAME|::~|CLASSNAME| () +|CLASSNAME|< T >::~|CLASSNAME| () { -} // ----- end of destructor of template class |CLASSNAME| ----- +} // ---------- end of destructor of template class |CLASSNAME| ---------- //-------------------------------------------------------------------------------------- // Class: |CLASSNAME| @@ -344,104 +423,119 @@ template < class T > // Description: assignment operator //-------------------------------------------------------------------------------------- template < class T > -|CLASSNAME|& |CLASSNAME|::operator = ( const |CLASSNAME| &other ) +|CLASSNAME|< T >& |CLASSNAME|< T >::operator = ( const |CLASSNAME| &other ) { - if ( this != &other ) { - } return *this; -} // ----- end of assignment operator of template class |CLASSNAME| ----- +} // ---------- end of assignment operator of template class |CLASSNAME| ---------- + +== C++.IMPLEMENTATION.template method == map:+itm , shortcut:m == +template < class T > +void |?CLASSNAME|::|?METHODNAME| ( <+argument_list+> ) +{ + return ; +} // ----- end of method |CLASSNAME|::|METHODNAME| ----- + +== C++.IMPLEMENTATION.template accessor == map:+ita , shortcut:a == +//-------------------------------------------------------------------------------------- +// Class: |?CLASSNAME| +// Method: get_|?ATTRIBUTE| +//-------------------------------------------------------------------------------------- +template < class T > +inline |?RETURNTYPE| |CLASSNAME|::get_|ATTRIBUTE| ( ) const +{ + return |ATTRIBUTE|; +} // ----- end of method |CLASSNAME|::get_|ATTRIBUTE| ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.template-function == +//-------------------------------------------------------------------------------------- +// Class: |CLASSNAME| +// Method: set_|ATTRIBUTE| +//-------------------------------------------------------------------------------------- +template < class T > +inline void |CLASSNAME|::set_|ATTRIBUTE| ( |RETURNTYPE| value ) +{ + |ATTRIBUTE| = value; + return ; +} // ----- end of method |CLASSNAME|::set_|ATTRIBUTE| ----- + +== C++.template function == map:+tf, shortcut:f == template -void |?TEMPALTE_FUNCTION_NAME| ( <+argument list+> ) +void |?TEMPALTE_FUNCTION_NAME| ( <+argument_list+> ) { return ; -} // ----- end of template function |?TEMPALTE_FUNCTION_NAME| ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.operator-in == +} // ----- end of template function |?TEMPALTE_FUNCTION_NAME| ----- +== C++.IMPLEMENTATION.operator, out == map:+ioo, shortcut:o == ostream & -operator << ( ostream & os, const |?CLASSNAME| & obj ) +operator << ( ostream &os, const |?CLASSNAME| &obj ) { os << obj. ; return os; -} // ----- end of function operator << ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.operator-out == +} // ----- end of function operator << ----- +== C++.IMPLEMENTATION.operator, in == map:+ioi, shortcut:i == istream & -operator >> ( istream & is, |?CLASSNAME| & obj ) +operator >> ( istream &is, |?CLASSNAME| &obj ) { is >> obj. ; return is; -} // ----- end of function operator >> ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.try-catch == +} // ----- end of function operator >> ----- +== C++.try catch == map:+tr, shortcut:t == try { } -catch ( const &ExceptObj ) { // handle exception: +catch ( const &ExceptObj ) { // handle exception: } -catch (...) { // handle exception: unspecified +catch (...) { // handle exception: unspecified } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.catch == -catch ( const &ExceptObj ) { // handle exception: +== C++.catch == map:+ca, shortcut:c == +catch ( const &ExceptObj ) { // handle exception: } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.catch-points == -catch (...) { // handle exception: unspecified +== C++.catch all == map:+caa, shortcut:c == +catch (...) { // handle exception: unspecified } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.extern == +== C++.extern C == map:+ex, shortcut:x == extern "C" { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.open-input-file == -string ifs_file_name = ""; // input file name -ifstream ifs; // create ifstream object +== C++.open input file == map:+oif, shortcut:o == +string ifs_file_name = ""; // input file name +ifstream ifs; // create ifstream object -ifs.open ( ifs_file_name.c_str() ); // open ifstream +ifs.open ( ifs_file_name.c_str() ); // open ifstream if (!ifs) { cerr << "\nERROR : failed to open input file " << ifs_file_name << endl; exit (EXIT_FAILURE); } -{-continue here-} -ifs.close (); // close ifstream -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.open-output-file == -string ofs_file_name = ""; // input file name -ofstream ofs; // create ofstream object - -ofs.open ( ofs_file_name.c_str() ); // open ofstream +{-continue_here-} +ifs.close (); // close ifstream +== C++.open output file == map:+oof, shortcut:o == +string ofs_file_name = ""; // output file name +ofstream ofs; // create ofstream object + +ofs.open ( ofs_file_name.c_str() ); // open ofstream if (!ofs) { cerr << "\nERROR : failed to open output file " << ofs_file_name << endl; exit (EXIT_FAILURE); } -{-continue here-} -ofs.close (); // close ofstream -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.namespace-std == +{-continue_here-} +ofs.close (); // close ofstream +== C++.using namespace std == map:+uns, shortcut:n == using namespace std; -== cpp.namespace == +== C++.using namespace xxx == map:+un, shortcut:n == using namespace |?NAMESPACE|; -== cpp.namespace-block == +== C++.namespace block xxx == map:+unb, shortcut:b == namespace |?NAMESPACE| { -} // ----- end of namespace |NAMESPACE| ----- -== cpp.namespace-alias == -namespace |?NAMESPACE_ALIAS| = {-original namespace name-}; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== cpp.rtti-typeid == insert == -typeid() -$ -== cpp.rtti-static-cast == insert == -static_cast<>() -$ -== cpp.rtti-const-cast == insert == -const_cast<>() -$ -== cpp.rtti-reinterpret-cast == insert == -reinterpret_cast<>() -$ -== cpp.rtti-dynamic-cast == insert == -dynamic_cast<>() -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +} // ----- end of namespace |NAMESPACE| ----- +== C++.namespace alias == map:+na, shortcut:a == +namespace |?NAMESPACE_ALIAS| = {-original_namespace_name-}; +== ENDTEMPLATE == + +== LIST: rtti == list == + 'const_cast' , + 'dynamic_cast' , + 'reinterpret_cast', + 'static_cast' , + 'typeid' , +== ENDLIST == + +== C++.RTTI == expandmenu, insert, map:+rt, shortcut:i == +|PickList( 'RTTI', 'rtti' )| +|PICK|<>() +== ENDTEMPLATE == diff --git a/c-support/templates/cpp.idioms.template b/c-support/templates/cpp.idioms.template index 911592d..f7d379a 100644 --- a/c-support/templates/cpp.idioms.template +++ b/c-support/templates/cpp.idioms.template @@ -1,45 +1,49 @@ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.function == +== Idioms.function == map:if, shortcut:f == +// === FUNCTION ====================================================================== +// Name: |?FUNCTION_NAME| +// Description: +// ===================================================================================== void -|?FUNCTION_NAME| ( <+argument list+> ) +|FUNCTION_NAME| ( <+argument_list+> ) { - return <+return value+>; -} // ----- end of function |FUNCTION_NAME| ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.function-static == + return <+return_value+>; +} // ----- end of function |FUNCTION_NAME| ----- +== Idioms.function-static == map:isf, shortcut:t == +// === FUNCTION ====================================================================== +// Name: |?FUNCTION_NAME| +// Description: +// ===================================================================================== static void -|?FUNCTION_NAME| ( <+argument list+> ) +|FUNCTION_NAME| ( <+argument_list+> ) { - return <+return value+>; -} // ----- end of static function |FUNCTION_NAME| ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.main == -#include + return <+return_value+>; +} // ----- end of static function |FUNCTION_NAME| ----- +== Idioms.main == map:im, shortcut:m == +#include +// === FUNCTION ====================================================================== +// Name: main +// Description: +// ===================================================================================== int main ( int argc, char *argv[] ) { return EXIT_SUCCESS; -} // ---------- end of function main ---------- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.enum == +} // ---------- end of function main ---------- +== Idioms.enum == map:ie, shortcut:e == enum |?ENUM_NAME| { -}; // ---------- end of enum |ENUM_NAME| ---------- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.struct == +}; // ---------- end of enum |ENUM_NAME| ---------- +== Idioms.struct == map:is, shortcut:s == struct |?STRUCT_NAME| { -}; // ---------- end of struct |STRUCT_NAME| ---------- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.union == +}; // ---------- end of struct |STRUCT_NAME| ---------- +== Idioms.union == map:iu, shortcut:u == union |?UNION_NAME| { -}; // ---------- end of union |UNION_NAME| ---------- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.printf == insert == -printf ( "\n" ); -== idioms.scanf == insert == +}; // ---------- end of union |UNION_NAME| ---------- +== Idioms.scanf == map:isc, shortcut:s, insert == scanf ( "", & ); -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.calloc == +== Idioms.printf == map:ipr, shortcut:p, insert == +printf ( "\n" ); +== Idioms.calloc == map:ica, shortcut:c == |?POINTER| = calloc ( (size_t)(<+COUNT+>), sizeof(<+TYPE+>) ); if ( |POINTER|==NULL ) { fprintf ( stderr, "\ndynamic memory allocation failed\n" ); @@ -49,8 +53,7 @@ if ( |POINTER|==NULL ) { free (|POINTER|); |POINTER| = NULL; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.malloc == +== Idioms.malloc == map:ima, shortcut:m == |?POINTER| = malloc ( sizeof(<+TYPE+>) ); if ( |POINTER|==NULL ) { fprintf ( stderr, "\ndynamic memory allocation failed\n" ); @@ -60,23 +63,20 @@ if ( |POINTER|==NULL ) { free (|POINTER|); |POINTER| = NULL; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.realloc == +== Idioms.realloc == map:ire, shortcut:r == |?POINTER| = realloc ( |POINTER|, sizeof(<+TYPE+>) ); if ( |POINTER|==NULL ) { fprintf ( stderr, "\ndynamic memory reallocation failed\n" ); exit (EXIT_FAILURE); } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.sizeof == insert == +== Idioms.sizeof == map:isi, shortcut:s, insert == sizeof() -== idioms.assert == insert == +== Idioms.assert == map:ias, shortcut:a, insert == assert(); -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.open-input-file == -FILE *|?FILEPOINTER|; // input-file pointer -char *|FILEPOINTER|_file_name = ""; // input-file name +== Idioms.open-input-file == map:ii, shortcut:i == +FILE *|?FILEPOINTER|; // input-file pointer +char *|FILEPOINTER|_file_name = ""; // input-file name |FILEPOINTER| = fopen( |FILEPOINTER|_file_name, "r" ); if ( |FILEPOINTER| == NULL ) { @@ -84,17 +84,16 @@ if ( |FILEPOINTER| == NULL ) { |FILEPOINTER|_file_name, strerror(errno) ); exit (EXIT_FAILURE); } -{-continue here-} -if( fclose(|FILEPOINTER|) == EOF ) { // close input file +{-continue_here-} +if( fclose(|FILEPOINTER|) == EOF ) { // close input file fprintf ( stderr, "couldn't close file '%s'; %s\n", |FILEPOINTER|_file_name, strerror(errno) ); exit (EXIT_FAILURE); } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.open-output-file == -FILE *|?FILEPOINTER|; // output-file pointer -char *|FILEPOINTER|_file_name = ""; // output-file name +== Idioms.open-output-file == map:io, shortcut:o == +FILE *|?FILEPOINTER|; // output-file pointer +char *|FILEPOINTER|_file_name = ""; // output-file name |FILEPOINTER| = fopen( |FILEPOINTER|_file_name, "w" ); if ( |FILEPOINTER| == NULL ) { @@ -102,16 +101,15 @@ if ( |FILEPOINTER| == NULL ) { |FILEPOINTER|_file_name, strerror(errno) ); exit (EXIT_FAILURE); } -{-continue here-} -if( fclose(|FILEPOINTER|) == EOF ) { // close output file +{-continue_here-} +if( fclose(|FILEPOINTER|) == EOF ) { // close output file fprintf ( stderr, "couldn't close file '%s'; %s\n", |FILEPOINTER|_file_name, strerror(errno) ); exit (EXIT_FAILURE); } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== idioms.fprintf == insert == +== Idioms.fprintf == map:ifsc, shortcut:f, insert == fprintf ( |?FILEPOINTER|, "\n", ); -== idioms.fscanf == insert == +== Idioms.fscanf == map:ifpr, shortcut:f, insert == fscanf ( |?FILEPOINTER|, "", & ); -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/c-support/templates/cpp.preprocessor.template b/c-support/templates/cpp.preprocessor.template index 8aba79d..82ba13f 100644 --- a/c-support/templates/cpp.preprocessor.template +++ b/c-support/templates/cpp.preprocessor.template @@ -1,54 +1,94 @@ -$------------------------------------------------------------------------- -== preprocessor.include-global == +== LIST: C_StandardLibs == list == + 'assert.h' , + 'complex.h' , + 'ctype.h' , + 'errno.h' , + 'fenv.h' , + 'float.h' , + 'inttypes.h' , + 'iso646.h' , + 'limits.h' , + 'locale.h' , + 'math.h' , + 'setjmp.h' , + 'signal.h' , + 'stdalign.h' , + 'stdarg.h' , + 'stdatomic.h' , + 'stdbool.h' , + 'stddef.h' , + 'stdint.h' , + 'stdio.h' , + 'stdlib.h' , + 'stdnoreturn.h', + 'string.h' , + 'tgmath.h' , + 'threads.h' , + 'time.h' , + 'uchar.h' , + 'wchar.h' , + 'wctype.h' , +== ENDLIST == + +== Preprocessor.include std lib header == expandmenu, append, map:pih, shortcut:s == +|PickList( 'Std. Libs', 'C_StandardLibs' )| +#include <|PICK|> +== ENDTEMPLATE == + +§------------------------------------------------------------------------- +== Preprocessor.include-global == map:pg, shortcut:g, insert == #include <> -$------------------------------------------------------------------------- -== preprocessor.include-local == +§------------------------------------------------------------------------- +== Preprocessor.include-local == map:pl, shortcut:l, insert == #include "" -$------------------------------------------------------------------------- -== preprocessor.define == -#define // -$------------------------------------------------------------------------- -== preprocessor.undefine == -#undef // -$------------------------------------------------------------------------- -== preprocessor.if-endif == +§------------------------------------------------------------------------- +== Preprocessor.define == map:pd, shortcut:d, insert == +#define // +§------------------------------------------------------------------------- +== Preprocessor.undefine == map:pu, shortcut:u, insert == +#undef // +§------------------------------------------------------------------------- +== Preprocessor.if-endif == map:pif, shortcut:i == #if |?CONDITION:u| -#endif // ----- |CONDITION| ----- -$------------------------------------------------------------------------- -== preprocessor.if-else-endif == +#endif // ----- |CONDITION| ----- +§------------------------------------------------------------------------- +== Preprocessor.if-else-endif == map:pie, shortcut:i == #if |?CONDITION:u| -#else // ----- not |CONDITION| ----- +#else // ----- not |CONDITION| ----- <+ELSE PART+> -#endif // ----- not |CONDITION| ----- -$------------------------------------------------------------------------- -== preprocessor.ifdef-else-endif == +#endif // ----- not |CONDITION| ----- +§------------------------------------------------------------------------- +== Preprocessor.ifdef-else-endif == map:pid, shortcut:f == #ifdef |?CONDITION:u| -#else // ----- not |CONDITION| ----- +#else // ----- not |CONDITION| ----- <+ELSE PART+> -#endif // ----- not |CONDITION| ----- -$------------------------------------------------------------------------- -== preprocessor.ifndef-else-endif == +#endif // ----- not |CONDITION| ----- +§------------------------------------------------------------------------- +== Preprocessor.ifndef-else-endif == map:pin, shortcut:n == #ifndef |?CONDITION:u| -#else // ----- not |CONDITION| ----- +#else // ----- not |CONDITION| ----- <+ELSE PART+> -#endif // ----- not |CONDITION| ----- -$------------------------------------------------------------------------- -== preprocessor.ifndef-def-endif == +#endif // ----- not |CONDITION| ----- +§------------------------------------------------------------------------- +== Preprocessor.ifndef-def-endif == map:pind, shortcut:e == #ifndef |?BASENAME:L|_INC #define |BASENAME|_INC -#endif // ----- #ifndef |BASENAME|_INC ----- -$------------------------------------------------------------------------- -== preprocessor.error == -#error "" // -$------------------------------------------------------------------------- -== preprocessor.line == -#line // -$------------------------------------------------------------------------- -== preprocessor.pragma == -#pragma // -$------------------------------------------------------------------------- +#endif // ----- #ifndef |BASENAME|_INC ----- +§------------------------------------------------------------------------- +== Preprocessor.error == map:pe, shortcut:o == +#error "" // +§------------------------------------------------------------------------- +== Preprocessor.line == map:pli, shortcut:l == +#line // +§------------------------------------------------------------------------- +== Preprocessor.pragma == map:pp, shortcut:p == +#pragma // +§------------------------------------------------------------------------- +== Preprocessor.warning == map:pw, shortcut:w == +#warning /* */ +§------------------------------------------------------------------------- diff --git a/c-support/templates/cpp.statements.template b/c-support/templates/cpp.statements.template index c2fdecb..04a79ac 100644 --- a/c-support/templates/cpp.statements.template +++ b/c-support/templates/cpp.statements.template @@ -1,72 +1,65 @@ -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.do-while == +== Statements.do while == map:sd, shortcut:d == do { -} while ( ); // ----- end do-while ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.for == +} while ( ); // ----- end do-while ----- +== Statements.for == map:sf, shortcut:o == for ( ; ; ) -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.for-block == -for ( ; ; ) { +§ +§ The names INIT, CONDITION, INCREMENT, and 'for block' are used by the main +§ plugin plugin/c.vim . Please do not change. +§ +== Statements.for block == map:sfo, shortcut:r == +|DefaultMacro( 'CONDITION', '{+CONDITION+}' )| +|DefaultMacro( 'INCREMENT', '{+INCREMENT+}' )| +for ( |INIT|; |CONDITION|; |INCREMENT| ) { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.if == +== Statements.range-based for == map:sfr, shortcut:a == +for ( : <-EXPRESSION-> ){ +} +== Statements.if == map:si, shortcut:i == if ( ) -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.if-block == +== Statements.if block == map:sif, shortcut:f == if ( ) { -<-IF PART-> +<-IF_PART-> } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.if-else == +== Statements.if else == map:sie, shortcut:e == if ( ) else -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.if-block-else == +== Statements.if block else == map:sife, shortcut:l == if ( ) { -<-IF PART-> +<-IF_PART-> } else { -<+ELSE PART+> +<-ELSE_PART-> } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.else-block == +== Statements.else block == map:se, shortcut:e == else { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.while == +== Statements.while == map:sw, shortcut:w == while ( ) -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.while-block == +== Statements.while block == map:swh, shortcut:h == while ( ) { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.switch == +== Statements.switch == map:ss, shortcut:s == switch ( ) { - case 1: + case <-LABEL->: break; - case 2: - break; - - case 3: + case <-LABEL->: break; - case 4: + case <-LABEL->: break; default: break; -} // ----- end switch ----- -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.case == +} // ----- end switch ----- +== Statements.case == map:sc, shortcut:c == case : break; -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -== statements.block == +== Statements.block == map:sb, shortcut:b == { } -$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + diff --git a/c-support/templates/snippets.template b/c-support/templates/snippets.template new file mode 100644 index 0000000..74cfa8b --- /dev/null +++ b/c-support/templates/snippets.template @@ -0,0 +1,11 @@ +== LIST: snippets_jumptags == hash == + 'less-plus' : '<++>', + 'less-minus' : '<-->', + 'brace-plus' : '{++}', + 'brace-minus' : '{--}', +== ENDLIST == + +== Snippets.jump tags == expandmenu, insert, map:njt, shortcut:m == +|PickList( 'jumptags', 'snippets_jumptags' )| +|PICK| +== ENDTEMPLATE == diff --git a/c-support/wordlists/c-c++-keywords.list b/c-support/wordlists/c-c++-keywords.list index 4bcd27a..84cd2bc 100644 --- a/c-support/wordlists/c-c++-keywords.list +++ b/c-support/wordlists/c-c++-keywords.list @@ -1,111 +1,119 @@ -adjustfield -basefield -boolalpha -floatfield -internal -scientific +boolalpha +defaultfloat +endl +ends +fixed +flush +get_money +get_time +hexfloat +internal +left +put_money +put_time +resetiosflag +right +scientific setbase +setfill setiosflags setprecision -showbase -showpoint -showpos +setw +showbase +showpoint +showpos +skipws +unitbuf uppercase +alignas +alignof +and_eq auto +bitand +bitor +bool break case -char -const -continue -default -double -else -enum -extern -float -goto -inline -long -register -restrict -return -short -signed -sizeof -static -struct -switch -typedef -union -unsigned -void -volatile -while -_Bool -_Complex -_Imaginary -EXIT_FAILURE -EXIT_SUCCESS -size_t - -alignas -alignof -bool catch +char char16_t char32_t class -constexpr +compl +const const_cast +constexpr +continue decltype +default delete +do +double dynamic_cast +else +enum explicit export +extern false +float friend +goto +if +inline +long mutable namespace -new -neexcept -nullptr +noexcept +not_eq +nullptr operator +or +or_eq private protected public +register reinterpret_cast +return +short +signed +sizeof +static static_assert static_cast +struct +switch template this thread_local throw true +typedef typeid typename +union +unsigned using virtual +void +volatile wchar_t - -and_eq -bitand -bitor -compl -not_eq -or_eq -xor_eq +while +xor_eq define -defined elif endif error ifdef ifndef include +line pragma undef +warning exception bad_alloc diff --git a/doc/csupport.txt b/doc/csupport.txt index d99d7d5..646f011 100644 --- a/doc/csupport.txt +++ b/doc/csupport.txt @@ -1,7 +1,7 @@ -*csupport.txt* C/C++ Support January 06 2012 +*csupport.txt* C/C++ Support August 20 2012 C/C++ Support *c-support* *csupport* - Plugin version 5.18 + Plugin version 6.0 for Vim version 7.0 and above Fritz Mehner @@ -11,6 +11,15 @@ code snippets, templates, and comments. Syntax checking, compiling, running a program, running a code checker or a reformatter can be done with a keystroke. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++ The plug-in version 6.0+ is a rewriting of version 5.19+. ++ +++ The versions 5.0+ are based on a new and more powerful template system ++ +++ (please see |template-support|for more information). ++ +++ The template syntax has changed! ++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1. Usage |csupport-usage-gvim| 1.1 Menu 'Comments' |csupport-comm| 1.1.1 Append aligned comments |csupport-comm-aligned| @@ -20,7 +29,7 @@ keystroke. 1.1.5 Frame comments, file header, ... |csupport-comm-frame| 1.1.6 File section comments .. |csupport-comm-sections| 1.1.7 Keyword comment, special comment |csupport-comm-keyword| - 1.1.8 Tags (plugin) |csupport-comm-tags| + 1.1.8 Macros |csupport-comm-macros| 1.1.9 Date and date+time |csupport-comm-date| 1.1.10 C to C++ comments and vice versa |csupport-comm-c-cpp| 1.2 Menu 'Statements' |csupport-stat| @@ -30,7 +39,6 @@ keystroke. 1.3.1 Normal mode, insert mode. |csupport-prep-normal-mode| 1.3.2 Visual mode. |csupport-prep-visual-mode| 1.3.3 Block out code with #if 0 .. #endif |csupport-prep-if0| - 1.3.4 Ex-commands |csupport-prep-ex| 1.4 Menu 'Idioms' |csupport-idioms| 1.4.1 Item 'function' |csupport-idioms-function| 1.4.2 for-loop control |csupport-idioms-for-loop| @@ -43,8 +51,7 @@ keystroke. 1.6 Menu 'C++' |csupport-c++| 1.6.1 Normal mode, insert mode. |csupport-c++-normal-mode| 1.6.2 Visual mode. |csupport-c++-visual-mode| - 1.6.3 Method implementation |csupport-c++-method-impl| - 1.6.4 Ex commands |csupport-c++-ex| + 1.6.3 Implementation |csupport-c++-impl| 1.7 Menu 'Run' |csupport-run| 1.7.1 Minimal make functionality |csupport-run-buffer| 1.7.2 Command line arguments |csupport-run-cmdline-args| @@ -54,12 +61,13 @@ keystroke. 1.7.6 Run make clean |csupport-run-make-clean| 1.7.7 Command line arguments for make |csupport-run-make-args| 1.7.8 Splint |csupport-run-splint| - 1.7.9 CodeCheck |csupport-run-codecheck| - 1.7.10 Indent |csupport-run-indent| - 1.7.11 Hardcopy |csupport-run-hardcopy| - 1.7.12 Rebuild templates |csupport-run-templates| - 1.7.13 Xterm size |csupport-run-xterm| - 1.7.14 Output redirection |csupport-run-output| + 1.7.9 Cppcheck |csupport-run-cppcheck| + 1.7.10 CodeCheck |csupport-run-codecheck| + 1.7.11 Indent |csupport-run-indent| + 1.7.12 Hardcopy |csupport-run-hardcopy| + 1.7.13 Rebuild templates |csupport-run-templates| + 1.7.14 Xterm size |csupport-run-xterm| + 1.7.15 Output redirection |csupport-run-output| 1.8 Help |csupport-help| 2. Usage without GUI |csupport-usage-vim| @@ -73,12 +81,9 @@ keystroke. 5.2 Macros |csupport-templates-macros| 5.2.1 User defined formats for date and time |csupport-templates-date| 5.3 Templates |csupport-templates-names| - 5.3.1 Template names |csupport-templates-names| - 5.3.2 Template definition |csupport-templates-definition| - 5.3.3 Template expansion |csupport-templates-expansion| - 5.3.4 The macros <+text+> etc. |csupport-templates-jump| - 5.3.5 Command Ctrl-j |csupport-Ctrl-j| - 5.4 Switching between template sets |csupport-templates-sets| + 5.3.1 Template definition |csupport-templates-definition| + 5.3.2 The jump tags <+text+> etc. |csupport-templates-jumptags| + 5.3.3 Command Ctrl-j |csupport-Ctrl-j| 5.5 Binding a style to a file extension |csupport-templates-bind| 6. C/C++ Dictionaries |csupport-dictionary| 7. Extend ctags |csupport-ctags| @@ -116,102 +121,101 @@ In NORMAL MODE, the menu item 'end-of-line comment' will append a comment to the current line. In VISUAL MODE, this item will append aligned comments to all marked lines. Marking the first 4 lines - +> print_double_array ( double array[], int n, int columns, char* arrayname ) - -and choosing 'end-of-line com. /**/' will yield. - +< +and choosing 'end-of-line comment' will yield +> print_double_array ( double array[], /* */ int n, /* */ int columns, /* */ char* arrayname /* */ - ) /* */ - + ) +< If one or more lines go beyond the starting column (s.below), the comments will start at the second column after the longest line. The cursor will then be positioned inside the first comment. The default starting column is 49 ( = (multiple of 2,4, or 8) + 1 ). This can be changed by setting a global variable in the file ~/.vimrc , e.g. : - +> let g:C_LineEndCommColDefault = 45 - -The starting column can also be set by the menu item -'Comments->set end-of-line com. col'. Just position the cursor in an -arbitrary column (column number is shown in the Vim status line) and choose -this menu item. This setting is buffer related. - +< +The starting column can also be set by the menu item 'Comments->set +end-of-line com. col'. Just position the cursor in an arbitrary column +(column number is shown in the Vim status line) and choose this menu item. +This setting is buffer related. If the cursor was at the end of a line you will be asked for a column number -because this position is most likely not the desired starting column. -Your choice will be confirmed. +because this position is most likely not the desired starting column. Your +choice will be confirmed. ------------------------------------------------------------------------------ 1.1.2 ADJUST END-OF-LINE COMMENTS *csupport-comm-realign* After some changes end-of-line comments may be no longer aligned: - +> print_double_array ( double array[], /* */ long int n, /* */ unsigned int columns, /* */ char* a_name /* */ - ) /* */ - + ) +< Realignment can be achieved with the menu item 'adjust end-of-line com.' In normal mode the comment (if any) in the current line will be aligned to the end-of-line comment column (see above) if possible. In visual mode the comments in the marked block will be aligned: - +> print_double_array ( double array[], /* */ long int n, /* */ unsigned int columns, /* */ char* a_name /* */ - ) /* */ - + ) +< The realignment will not be done for comments with nothing else than leading whitespaces. These comments are usually captions: - +> max = other.max; /* the maximum value */ len = other.len; /* the length */ /* ===== the next section ===== */ pos = (x+y+z)/3.0; /* the next position */ - +< After the alignment we have: - +> max = other.max; /* the maximum value */ len = other.len; /* the length */ /* ===== the next section ===== */ pos = (x+y+z)/3.0; /* the next position */ - +< ------------------------------------------------------------------------------ 1.1.3 CODE TO COMMENT *csupport-code-to-comm* The marked block - -xxxxxxxx -xxxxxxxx -xxxxxxxx - +> + xxxxxxxx + xxxxxxxx + xxxxxxxx +< will be changed by the menu item 'code->comment /**/' into the multiline comment (all (partially) marked lines): - -/* xxxxxxxx - * xxxxxxxx - * xxxxxxxx - */ - +> + /* xxxxxxxx + * xxxxxxxx + * xxxxxxxx + */ +< The marked block will be changed by the menu item 'code->comment //' into the multiline comment - -//xxxxxxxx -//xxxxxxxx -//xxxxxxxx - +> + //xxxxxxxx + //xxxxxxxx + //xxxxxxxx +< The menu items works also for a single line. A single line needs not to be marked. @@ -222,7 +226,7 @@ marked. If one (or more) complete comment (i.e. all lines belonging to the comment) is marked the item 'comment->code' will uncomment it. If the following lines are marked - +> * printf ("\n"); */ @@ -234,9 +238,9 @@ are marked /* * printf ("\n"); */ - +< uncommenting will yield - +> * printf ("\n"); */ @@ -247,7 +251,7 @@ uncommenting will yield printf ("\n"); - +< The first 2 lines are only a part of a C-comment and remain unchanged. A C-comment can start with /* , /** or /*! . @@ -261,22 +265,22 @@ needs not to be marked. Frame comments, file header comments and function, methods, class descriptions are read as templates from the appropriate files (see |csupport-templates|). -There are two file description templates (menu items 'file description (impl.)' -and 'file description (header)', see also |csupport-templates|): +There are two file description templates (menu items 'file description impl' +and 'file description header', see also |csupport-templates|): - comment.file-description : files *.c *.cc *.cp *.cxx *.cpp *.CPP *.c++ + implementation : files *.c *.cc *.cp *.cxx *.cpp *.CPP *.c++ *.C *.i *.ii - comment.file-description-header : everything else with filetype 'c' or 'cpp' + header : everything else with filetype 'c' or 'cpp' The appropriate template will also be included into a new file. The plugin decides on the basis of the file extension. The default is shown above. You can change the list by setting a global variable in '~/.vimrc': - - au BufRead,BufNewFile *.XYZ set filetype=c +> + autocmd BufRead,BufNewFile *.XYZ set filetype=c let g:C_SourceCodeExtensions = 'XYZ c cc cp cxx cpp CPP c++ C i ii' - +< A new file named 'test.XYZ' will now be considered a C implementation file. ------------------------------------------------------------------------------ @@ -285,66 +289,49 @@ A new file named 'test.XYZ' will now be considered a C implementation file. File section comments can be uses to separate typical C- and H-file sections with comments of similar appearance, e.g. - -/* ##### HEADER FILE INCLUDES ################################################### */ - -/* ##### MACROS - LOCAL TO THIS SOURCE FILE ################################### */ - -/* ##### TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################### */ - +> + /* ##### HEADER FILE INCLUDES ################################################### */ + + /* ##### MACROS - LOCAL TO THIS SOURCE FILE ################################### */ + + /* ##### TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE ######################### */ +< These section comments can also be inserted using the hotkey \ccs for C/C++ -files, or \chs for H-files. These hotkeys will start the command -'CFileSection' or 'HFileSection' on the command line: - - :CFileSection - :HFileSection - -Now type a to start the selection menu to choose from. +files, or \chs for H-files. ------------------------------------------------------------------------------ 1.1.7 KEYWORD COMMENT, SPECIAL COMMENT *csupport-comm-keyword* Keword comments are end-of-line comments: - +> /* :::: */ - +y Keywords are - BUG COMPILER TODO TRICKY WARNING WORKAROUND user-defined-keyword + BUG COMPILER REMARK TODO TRICKY WARNING WORKAROUND user-defined-keyword These are preliminary comments to document places where work will be resumed shortly. They are usually not meant for the final documentation. These comments are easily found by searching for the keyword. -The keyword comments can also be inserted using the hotkey \ckc . This hotkey -starts the command 'KeywordComment' on the command line: - - :KeywordComment - -Now type a to start the selection menu to choose from. +The keyword comments can also be inserted using the hotkey \ckc . Special comments are occasionally used to mark special features of a code construct (e.g. a fall through cases in a switch statement, an empty loop): - +> /* EMPTY */ /* NOT REACHED */ /* REMAINS TO BE IMPLEMENTED */ .... - -The special comments can also be inserted using the hotkey \csc . This hotkey -starts the command 'SpecialComment' on the command line: - - :SpecialComment - -Now type a to start the selection menu to choose from. +< +The special comments can also be inserted using the hotkey \csc . ------------------------------------------------------------------------------ -1.1.8 TAGS (PLUGIN) *csupport-comm-tags* +1.1.8 MACROS (PLUGIN) *csupport-comm-macros* -The submenu 'tags (plugin)' let you insert the predefined macros from the -template system (see|csupport-templates-macros|). In visual mode the marked -string will be replaced by the macro. +The submenu 'macros' let you insert the predefined macros from the template +system (see|csupport-templates-macros|). ------------------------------------------------------------------------------ @@ -372,25 +359,24 @@ changes the current line and the next 2 lines. 1.2.1 NORMAL MODE, INSERT MODE. *csupport-stat-normal-mode* -An empty statement will be inserted and properly indented. The item 'if{}' +An empty statement will be inserted and properly indented. The item 'if block' will insert an if-statement: - -if ( ) -{ -} - - +> + if ( ) { + <-IF_PART-> + } +< 1.2.2 VISUAL MODE. *csupport-stat-visual-mode* STATEMENTS WITH BLOCKS AND CASE LABEL. -------------------------------------- The highlighted area - -xxxxx -xxxxx - +> + xxxxx + xxxxx +< can be surrounded by one of the following statements: - +> +----------------------------+-----------------------------+ | if ( ) | if ( ) | | { | { | @@ -431,14 +417,14 @@ can be surrounded by one of the following statements: | break; | | } | +----------------------------+-----------------------------+ - +< The whole statement will be indented after insertion. STATEMENTS WITHOUT BLOCKS. -------------------------- One of the following statements can be inserted: - +> +-------------------------------+--------------------------+ | if ( ) | for ( ; ; ) | +-------------------------------+--------------------------+ @@ -448,7 +434,7 @@ One of the following statements can be inserted: | case : | | | break; | | +-------------------------------+--------------------------+ - +< ------------------------------------------------------------------------------ 1.3 MENU 'Preprocessor' *csupport-prep* @@ -463,12 +449,12 @@ The preprocessor statements will be inserted and properly indented. STATEMENTS WITH BLOCKS ---------------------- The highlighted area - -xxxxx -xxxxx - +> + xxxxx + xxxxx +< can be surrounded by one of the following statements: - +> +----------------------------+-----------------------------+ | #if CONDITION | | xxxxx | @@ -501,18 +487,18 @@ can be surrounded by one of the following statements: | | | #endif /* ----- #if 0 : If0Label_1 ----- */ | +----------------------------------------------------------+ - +< The macro name for an include guard (e.g. INC_TEST above) will be derived as a suggestion from the file name. 1.3.3 BLOCK OUT CODE WITH #if 0 ... #endif *csupport-prep-if0* The menu item #if 0 #endif inserts the lines - +> #if 0 /* ----- #if 0 : If0Label_1 ----- */ #endif /* ----- #if 0 : If0Label_1 ----- */ - +< In visual mode the marked block of lines will be surrounded by these lines. This is usually done to temporarily block out some code. The label names like @@ -531,22 +517,6 @@ The menu item 'remove #if #endif' removes such a construct if the cursor is in the middle of such a section or on one of the two enclosing lines. Nested constructs will be untouched. -1.3.4 EX-COMMANDS *csupport-prep-ex* - -There are 4 additional Ex command which can be used to insert include -statements: - - Ex command hotkey includes - ------------------------------------------------------------------------- - :IncludeStdLibrary \ps C standard library - :IncludeC99Library \pc C99 library - :IncludeCppLibrary \+ps C++ standard library - :IncludeCppCLibrary \+pc C standard library ( #include ) - -Type :Inc and choose one of the commands. Now type an additional space -and a to show the whole list list or type a space and a few leading -characters to reduce this list. - ------------------------------------------------------------------------------ 1.4 MENU 'Idioms' *csupport-idioms* ------------------------------------------------------------------------------ @@ -556,16 +526,17 @@ characters to reduce this list. NORMAL MODE, INSERT MODE: The name of the function is asked for and the following lines (for function name "f") will be inserted: - - void - f ( ) - { - return ; - } /* ---------- end of function f ---------- */ - +> + void + f ( <+argument_list+> ) + { + return <+return_value+>; + } /* ----- end of function f ----- */ + void +< VISUAL MODE: -Main or [static] function: the highlighted lines will go inside the new -function or main. +Main or function: the highlighted lines will go inside the new function or +main. for-loops: the highlighted lines will be set in braces. 1.4.2 for-loop control *csupport-idioms-for-loop* @@ -578,7 +549,7 @@ start an input dialog asking for at least the name of the loop variable. The other parameters are optional. The type is restricted to the following integral data types: - +> char int long @@ -597,7 +568,7 @@ optional. The type is restricted to the following integral data types: unsigned long long int unsigned short unsigned short int - +< One of these types can be specified by typing it completely or by typing zero or more characters of its name and completing them to the full name by using the tab key (tab completion). If the start of the type name is ambiguous (e.g. @@ -623,9 +594,10 @@ Code snippets are pieces of code which are kept in separate files in a special directory (e.g. a few lines of code or a complete template for a Makefile). File names are used to identify the snippets. The snippet directory will be created during the installation ( $HOME/.vim/codesnippets-c is the default). -Snippets are managed with the 3 items +Snippets are managed with the 4 items C/C++ -> Snippets -> read code snippet + C/C++ -> Snippets -> view code snippet C/C++ -> Snippets -> write code snippet C/C++ -> Snippets -> edit code snippet @@ -642,6 +614,9 @@ The inserted lines will be indented. EDIT A SNIPPET This is a normal edit. +VIEW A SNIPPET +Show file in a read-only buffer. + INDENTATION / NO INDENTATION Code snippets are normally indented after insertion. To suppress indentation add the file extension "ni" or "noindent" to the snippet file name, e.g. @@ -653,9 +628,9 @@ Snippet browser Under a GUI a file requester will be put up. Without GUI the filename will be read from the command line. You can change this behavior by setting a global variable in your ~/.vimrc : - +> let g:C_GuiSnippetBrowser = 'commandline' - +< The default value is 'gui'. @@ -665,7 +640,7 @@ PICK UP FUNCTION PROTOTYPES (key mappings \np, \nf). To make a prototype from a function head mark the function head and choose 'Snippets -> pick up funct. prototype'. From the first six lines of - +> void print_double_array ( double array[], /* array to print */ int n, /* number of elements to print */ @@ -675,11 +650,11 @@ To make a prototype from a function head mark the function head and choose { ... } /* ---------- end of function print_double_array ---------- */ - +< the prototype - +> void print_double_array ( double array[], int n, int columns, char* arrayname ); - +< is produced and put in an internal buffer. - Leading and trailing whitespaces are removed. - All inner whitespaces are squeezed. @@ -694,27 +669,27 @@ PICK UP METHOD PROTOTYPES (key mapping \nm). For C++ methods the menu item 'Snippets -> pick up method prototype' should be used. Namespace names and class names will be removed (exception: 'std::' ). The first two lines of - +> std::string ROBOT::Robot::get_name ( void ) { return type_name; } /* ----- end of method Robot::get_name ----- */ - +< result in the prototype - +> std::string get_name ( void ); - +< The 3 lines - +> template const Stack& Stack::operator = ( const Stack &other ) - +< result in the prototype - +> const Stack& operator = ( const Stack &other ); - +< Folding may help picking up prototypes (see |csupport-folding|). @@ -731,11 +706,11 @@ The prototype buffer can be cleared with 'Snippets -> clear prototype(s)' . SHOW PROTOTYPES The list of gathered prototypes can be shown with 'Snippets -> show prototype(s)'. The number and the filename are shown, e.g. - +> (1) matrix.c # double** calloc_double_matrix ( int rows, int columns ); (2) matrix.c # void free_double_matrix ( double **m ); (3) foomain.c # void foo ( ); - +< REMARK. Generating prototypes this way is nice in a small project. You may want to use an extractor like cextract or something else. @@ -754,21 +729,27 @@ loaded from the main file. Now change whatever file you want, save it, and click on the menu item 'reread templates' to read in the file(s) and to rebuild the internal representation of the templates. -The menu item 'edit global templates' opens the main template file in a -system-wide plugin installation (see |csupport-system-wide|). This is -usually the file '$VIM./vimfiles/c-support/templates/Templates'. - Template browser ---------------- Under a GUI a file requester will be put up. Without GUI the filename will be read from the command line. You can change this behavior by setting a global variable in your ~/.vimrc : - +> let g:C_GuiTemplateBrowser = 'explorer' - +< The default value is 'gui'. 'explorer' will start the file explorer (see help|:Explore|). To use the commandline asign 'commandline'. +Template Style +-------------- +The template system supports different template styles. If there are more than +one style the menu item 'choose style' let you choose a style on the fly. + +Template Jump Tags +------------------ +You can use different jump tags in a template, e.g. {-tagname-}. The allowed +tags can be chosen from this menu.(see|csupport-templates-jumptags|) + ------------------------------------------------------------------------------ 1.6 MENU 'C++' *csupport-c++* ------------------------------------------------------------------------------ @@ -776,30 +757,30 @@ The default value is 'gui'. 'explorer' will start the file explorer 1.6.1 NORMAL MODE, INSERT MODE. *csupport-c++-normal-mode* An empty statement will be inserted and in some cases properly indented. The -item 'try .. catch' will insert the following lines: - +item 'try catch' will insert the following lines: +> try { } catch ( const &ExceptObj ) { // handle exception: } catch (...) { // handle exception: unspecified } - +< The cursor will go into the try block. 1.6.2 VISUAL MODE. *csupport-c++-visual-mode* The highlighted area can be surrounded by one of the following statements: - try - catch + try catch catch - catch(...) - namespace { } - extern "C" { } + catch all + extern C + namespace block xxx The whole statement will be indented after insertion. -1.6.3 METHOD IMPLEMENTATION *csupport-c++-method-impl* +1.6.3 IMPLEMENTATION *csupport-c++-impl* The menu item 'method implement.' asks for a method name. If this item is called the first time you will see just an scope resolution operator. If you @@ -807,11 +788,6 @@ specify the scope this is used the next time you call this item. If you use one of the menu items to generate a class (see |csupport-templates|) the scope will be extracted and used for the next method. -1.6.4 EX COMMANDS *csupport-c++-ex* - -There are 4 additional Ex command which can be used to insert include -statements. Please see |csupport-prep-ex|. - ------------------------------------------------------------------------------ 1.7 MENU 'Run' *csupport-run* ------------------------------------------------------------------------------ @@ -954,7 +930,20 @@ When vim is started this plugin will check whether splint is executable. If not, the menu item will *NOT' be visible. -1.7.9 CODECHECK *csupport-run-codecheck* +1.7.9 CPPCHECK *csupport-run-cppcheck* + +Cppcheck (http://sourceforge.net/apps/mediawiki/cppcheck/) is tool for static +C++ code analysis. Cppcheck only detects the types of bugs that the compilers +normally fail to detect. + +An error window will be opened if cppcheck has something to complain about. +Quickfix commands can now be used to jump to an error location. For easier +navigation see tip under 'SAVE AND COMPILE' |csupport-run-buffer|. +Cppcheck has many options. Predefined groups og checks can be enabled by the +menu item 'cppcheck severity'. Please see the original documentation for more +information. + +1.7.10 CODECHECK *csupport-run-codecheck* CodeCheck (TM) is a commercial code analyzing tool produced by Abraxas Software, Inc. (www.abraxas-software.com). @@ -971,20 +960,20 @@ CodeCheck has many options. For a quick try you can use the menu item CodeCheck will be run with default options (see |csupport-custom-glob-vars|). The default options can be overwritten by placing a global variable in ~/.vimrc , e.g. - +> let g:C_CodeCheckOptions = "-K13 -Rmeyers" - +< The default name for the executable is 'check'. There are other names in use on different platforms. The name can be changed by placing a global variable in ~/.vimrc , e.g. - +> let g:C_CodeCheckExeName = "chknt.exe" - +< When vim is started this plugin will check whether CodeCheck is executable. If not, the menu item will *NOT' be visible. -1.7.10 INDENT *csupport-run-indent* +1.7.11 INDENT *csupport-run-indent* The formatter 'indent' can be run over the whole buffer. Before formatting a buffer this buffer will be saved to disk and you will be asked for a @@ -994,7 +983,7 @@ Indent has many options. These are kept in the file '.indent.pro' in your home directory. See the indent manual for more information. -1.7.11 HARDCOPY *csupport-run-hardcopy* +1.7.12 HARDCOPY *csupport-run-hardcopy* Generates a PostScript file from the whole buffer or from a marked region. On a Windows system a printer dialog is displayed. @@ -1004,34 +993,34 @@ goes to the HOME directory. The output destination will be shown in a message. The print header contains date and time for the current locale. The definition used is - +> let s:C_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" - +< The current locale can be overwritten by changing the language, e.g. - +> :language C - +< or by setting a global variable in the file ~/.vimrc , e.g. : - +> let g:C_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} SEITE %N" - +< See :h printheader and :h strftime() for more details. -1.7.12 REBUILD TEMPLATES *csupport-run-templates* +1.7.13 REBUILD TEMPLATES *csupport-run-templates* After editing one or more template files a click on this item rereads the template files and rebuilds all templates. -1.7.13 XTERM SIZE *csupport-run-xterm* +1.7.14 XTERM SIZE *csupport-run-xterm* The size of the xterm used for running a program (below) can be set by this menu item. The default is 80 columns with 24 lines. This feature is not available under Windows. -1.7.14 OUTPUT REDIRECTION *csupport-run-output* +1.7.15 OUTPUT REDIRECTION *csupport-run-output* Running a program can be done in one of three ways: (1) Run the program from the gVim command line. @@ -1069,7 +1058,9 @@ Plugin help ----------- The root menu item 'help (plugin)' shows this plugin help in a help window. The help tags must have been generated with +> :helptags ~/.vim/doc +< The hotkey is \hp (for "help plugin"). Displaying a manual @@ -1122,6 +1113,7 @@ Legend: (i) insert mode, (n) normal mode, (v) visual mode \chs H-file section (tab. compl.) (n,i) \ckc keyword comment (tab. compl.) (n,i) \csc special comment (tab. compl.) (n,i) + \cma plugin macros (tab. compl.) (n,i) \cd date (n,v,i) \ct date \& time (n,v,i) [n]\cx toggle comments: C <--> C++ (n,v,i) @@ -1140,39 +1132,18 @@ Legend: (i) insert mode, (n) normal mode, (v) visual mode \swh while { } (n,v,i) \ss switch (n,v,i) \sc case (n,i) - \s{ \sb { } (n,v,i) - - -- Preprocessor ------------------------------------------------------- - - \ps choose a standard library include (n,i) - \pc choose a C99 include (n,i) - \p< #include <> (n,i) - \p" #include "" (n,i) - \pd #define (n,i) - \pu #undef (n,i) - \pif #if #endif (n,v,i) - \pie #if #else #endif (n,v,i) - \pid #ifdef #else #endif (n,v,i) - \pin #ifndef #else #endif (n,v,i) - \pind #ifndef #def #endif (n,v,i) - \pi0 #if 0 #endif (n,v,i) - \pr0 remove #if 0 #endif (n,i) - \pe #error (n,i) - \pl #line (n,i) - \pp #pragma (n,i) + \sb {} (n,v,i) -- Idioms ------------------------------------------------------------- \if function (n,v,i) - \isf static function (n,v,i) + \isf function static (n,v,i) \im main() (n,v,i) - [n]\i0 for( x=0; x=0; x-=1 ) (n,v,i) \ie enum + typedef (n,i) \is struct + typedef (n,i) \iu union + typedef (n,i) - \ip printf() (n,i) \isc scanf() (n,i) + \ipr printf() (n,i) \ica p=calloc() (n,i) \ima p=malloc() (n,i) \ire p=realloc() (n,i) @@ -1180,49 +1151,82 @@ Legend: (i) insert mode, (n) normal mode, (v) visual mode \ias assert() (n,v) \ii open input file (n,i) \io open output file (n,i) - \ifs fscanf (n,i) - \ifp fprintf (n,i) + \ifsc fscanf (n,i) + \ifpr fprintf (n,i) + [n]\i0 for( x=0; x=0; x-=1 ) (n,v,i) + + -- Preprocessor ------------------------------------------------------- + + \pih include standard library header (n,i) + \pg #include <> (global) (n,i) + \pl #include "" (local) (n,i) + \pd #define (n,i) + \pu #undef (n,i) + \pif #if #endif (n,v,i) + \pie #if #else #endif (n,v,i) + \pid #ifdef #else #endif (n,v,i) + \pin #ifndef #else #endif (n,v,i) + \pind #ifndef #def #endif (n,v,i) + \pe #error (n,i) + \pl #line (n,i) + \pp #pragma (n,i) + \pw #warning (n,i) + \pi0 #if 0 #endif (n,v,i) + \pr0 remove #if 0 #endif (n,i) -- Snippets ----------------------------------------------------------- \nr read code snippet (n,i) + \nv view code snippet (read-only) (n,i) \nw write code snippet (n,v,i) \ne edit code snippet (n,i) + [n]\nf pick up function prototype (n,v,i) [n]\np pick up function prototype (n,v,i) [n]\nm pick up method prototype (n,v,i) \ni insert prototype(s) (n,i) \nc clear prototype(s) (n,i) \ns show prototype(s) (n,i) + \ntl edit local templates (n,i) - \ntg edit global templates (n,i) - \ntr rebuild templates (n,i) + \ntr reread templates (n,i) + \njt include jump tags (n,i) -- C++ ---------------------------------------------------------------- - \+co cout << << endl; (n,i) - \+" << "" (n,i) + \+ih include C++ standard library header (n,i) + \+ich include C standard library header (n,i) + \+om output manipulators (n,i) + \+fb ios flag bits (n,i) \+c class (n,i) - \+ps #include <...> STL (n,i) - \+pc #include C (n,i) \+cn class (using new) (n,i) - \+ci class implementation (n,i) - \+cni class (using new) implementation (n,i) - \+mi method implementation (n,i) - \+ai accessor implementation (n,i) - \+tc template class (n,i) \+tcn template class (using new) (n,i) - \+tci template class implementation (n,i) - \+tcni template class (using new) impl. (n,i) - \+tmi template method implementation (n,i) - \+tai template accessor implementation (n,i) - - \+tf template function (n,i) \+ec error class (n,i) + \+tf template function (n,i) \+tr try ... catch (n,v,i) \+ca catch (n,v,i) - \+c. catch(...) (n,v,i) + \+caa catch(...) (n,v,i) + \+ex extern "C" { } (n,v,i) + \+oif open input file (n,v,i) + \+oof open output file (n,v,i) + \+uns using namespace std; (n,v,i) + \+un using namespace xxx; (n,v,i) + \+unb namespace xxx { } (n,v,i) + \+na namespace alias (n,v,i) + \+rt RTTI (n,v,i) + + \+ic class implementation (n,i) + \+icn class (using new) implementation (n,i) + \+im method implementation (n,i) + \+ia accessor implementation (n,i) + \+itc template class implementation (n,i) + \+itcn template class (using new) impl. (n,i) + \+itm template method implementation (n,i) + \+ita template accessor implementation (n,i) + \+ioi operator >> (n,i) + \+ioo operator << (n,i) -- Run ---------------------------------------------------------------- @@ -1237,24 +1241,29 @@ Legend: (i) insert mode, (n) normal mode, (v) visual mode \rma cmd. line arg. for make (n,i) \rp run splint (n,i) \rpa cmd. line arg. for splint (n,i) + \rcc run cppcheck (n,i) + \rccs severity for cppcheck (n,i) \rk run CodeCheck (TM) (n,i) \rka cmd. line arg. for CodeCheck (TM) (n,i) - \rd run indent (n,v,i) + \ri run indent (n,v,i) [n]\rh hardcopy buffer (n,v,i) \rs show plugin settings (n,i) \rx set xterm size (n, only Linux/UNIX & GUI) \ro change output destination (n,i) -The hotkeys are defined in the file type plugin c.vim (part of this csupport -plugin package) and described in the document c-hot-keys.pdf +The file perl-hot-keys.pdf contains a reference card for these key mappings. +Multi-line inserts and code snippets will be indented after insertion. + +The hotkeys are defined in the template files (part of this csupport +plugin package) and described in the document c-hotkeys.pdf Changing the default map leader '\' ----------------------------------- The map leader can be changed by the user by setting a global variable in the file .vimrc - +> let g:C_MapLeader = ',' - +< The map leader is now a comma. The 'line end comment' command is now defined as ',cl'. This setting will be used as a so called local leader and influences only files with filetype 'c' and 'cpp'. @@ -1279,17 +1288,17 @@ Shift-F2 can be used to switch between source files and header files if the plugin a.vim (http://vim.sourceforge.net/scripts/script.php?script_id=31) is present. To suppress the creation of a new header file when switching from a source file the file ~/.vimrc should contain a line - +> let g:alternateNoDefaultAlternate = 1 - +< A header file will only be opened if it already exists. The Shift-key is dead when you are working with Vim in a console terminal (non-Gui). You could add - +> noremap \a :A inoremap \a :A - +< to get a hot key for this case. ============================================================================== @@ -1307,7 +1316,6 @@ Several global variables are checked by the script to customize it: ---------------------------------------------------------------------------- g:C_GlobalTemplateFile plugin_dir.'c-support/templates/Templates' g:C_LocalTemplateFile $HOME.'/.vim/c-support/templates/Templates' - g:C_TemplateOverwrittenMsg 'yes' g:C_Ctrl_j 'on' g:C_CodeSnippets plugin_dir.'/c-support/codesnippets/' @@ -1315,7 +1323,7 @@ Several global variables are checked by the script to customize it: g:C_LoadMenus 'yes' g:C_MenuHeader 'yes' g:C_OutputGvim 'vim' - g:C_Root '&C\/C\+\+.' + g:C_RootMenu '&C\/C\+\+.' g:C_XtermDefaults '-fa courier -fs 12 -geometry 80x24' g:C_Printheader "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" g:C_MapLeader '\' @@ -1352,10 +1360,9 @@ The variable plugin_dir will automatically be set to one of the following values ---------------------------------------------------------------------------- - 1. group: g:C_GlobalTemplateFile : Sets the master template file (see|csupport-templates|) - g:C_LocalTemplateFile : Sets the local template file (see|csupport-templates|) - g:C_TemplateOverwrittenMsg : message if template is overwritten - g:C_Ctrl_j : hotkey Ctrl-j 'on'/'off' (see|csupport-Ctrl-j|) + 1. group: g:C_GlobalTemplateFile : sets the global template file (see|csupport-templates|) + g:C_LocalTemplateFile : sets the local template file (see|csupport-templates|) + g:C_Ctrl_j : hotkey Ctrl-j 'on'/'off' (see|csupport-Ctrl-j|) 2. group: g:C_CodeSnippets : The name of the code snippet directory (see |csupport-snippets|). @@ -1366,7 +1373,7 @@ The variable plugin_dir will automatically be set to one of the following values g:C_OutputGvim : when program is running output goes to the vim command line ("vim"), to a buffer ("buffer") or to an xterm ("xterm"). - g:C_Root : The name of the root menu entry of this plugin + g:C_RootMenu : The name of the root menu entry of this plugin (see |csupport-custom-root|). g:C_XtermDefaults : the xterm defaults g:C_Printheader : hardcopy: definition of the page header @@ -1401,9 +1408,9 @@ To override the default add appropriate assignments to ~/.vimrc . 4.2 THE ROOT MENU *csupport-custom-root* ------------------------------------------------------------------------------ -The variable g:C_Root, if set (in '.vimrc' or in '.gvimrc'), gives the name -of the single gVim root menu entry in which the C/C++ submenus will be put. -The default is +The variable g:C_RootMenu, if set (in '.vimrc' or in '.gvimrc'), gives the +name of the single gVim root menu entry in which the C/C++ submenus will be +put. The default is '&C\/C\+\+.' '' @@ -1412,7 +1419,7 @@ Note the terminating dot. If you want to set the plugin root menu into another menu, e.g. 'Plugin', this is done by the following line in '.vimrc' - let g:C_Root = '&Plugin.&C\/C\+\+.' + let g:C_RootMenu = '&Plugin.&C\/C\+\+.' ------------------------------------------------------------------------------ 4.3 SYSTEM-WIDE INSTALLATION *csupport-system-wide* @@ -1463,20 +1470,19 @@ Create your private template directory: Create a private template file 'Templates' (compulsory) in this directory to overwrite some macros, e.g. +> + SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) + SetMacro( 'AUTHORREF', 'fgm' ) + SetMacro( 'EMAIL', 'mehner.fritz@fh-swf.de' ) + SetMacro( 'ORGANIZATION','FH Südwestfalen, Iserlohn' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) +< +You can also have local templates which override the global ones. To see a +messages in this case set a global variable in '~/.vimrc' (Windows: '~\_vimrc'): - *|AUTHOR|* = your name - *|AUTHORREF|* = ... - *|EMAIL|* = ... - *|COMPANY|* = ... - *|COPYRIGHT|* = ... - -You can also have local templates which overwrite the global ones. To suppress -the messages in this case set a global variable in '~/.vimrc' (Windows: -'~\_vimrc') : + let g:Templates_MapInUseWarn = 0 - let g:C_TemplateOverwrittenMsg= 'no' - -The default is 'yes'. +The default is '1'. ============================================================================== 5. TEMPLATE FILES AND TAGS *csupport-templates* @@ -1486,51 +1492,86 @@ The default is 'yes'. 5.1 TEMPLATE FILES *csupport-templates-files* ------------------------------------------------------------------------------ -Nearly all menu entries insert code snippets or comments. All of these are +Nearly all menu items insert code snippets or comments. All of these are contained within template files and can be changed by the user to meet their -requirements. +requirements. The menu shortcuts (e.g. 'c' for the Comments menu) and the +menu item hotkeys (e.g. '\ct' insert date and time) are also defined in the +templates. +The template engine comes as a separate plug-in contributed by Wolfgang Mehner. +This section is a short introduction to this template system. Please see +|templatesupport.txt| for more information. -The master template file is '$HOME/.vim/c-support/templates/Templates' for a -user installation and '$VIM/vimfiles/c-support/templates/Templates' for a -system-wide installation (see|csupport-system-wide|). +The master template file is '$HOME/.vim/c-support/templates/Templates' for +a user installation and '$VIM/vimfiles/c-support/templates/Templates' for +a system-wide installation (see |csupport-system-wide|). The master template file starts with a macro section followed by templates for single menu items or better by including other template files grouping the -templates according to the menu structure of this plugin. The master file -could look like this: - - $ - $ ============================================================= - $ ========== USER MACROS ====================================== - $ ============================================================= - $ - *|AUTHOR|* = Dr. Fritz Mehner - *|AUTHORREF|* = mn - *|EMAIL|* = mehner@fh-swf.de - *|COMPANY|* = FH Südwestfalen, Iserlohn - *|COPYRIGHT|* = Copyright (c)*|YEAR|,|AUTHOR|* - $ - $ ============================================================= - $ ========== FILE INCLUDES ==================================== - $ ============================================================= - $ - *|includefile|* = c.comments.template - *|includefile|* = c.cpp.template - *|includefile|* = c.idioms.template - *|includefile|* = c.preprocessor.template - *|includefile|* = c.statements.template - -Lines starting with a dollar sign are comments. The section starting -with *|AUTHOR|* assigns values to predefined tags -(see|csupport-templates-macros|) to personalize some templates. Other -predefined tags with given default values can be used (e.g. *|YEAR|* ). - -User defined tags are possible. They have the following syntax: - - *|macroname|* = replacement - -A macroname starts with a letter (uppercase or lowercase) followed by zero or -more letters, digits or underscores. +templates according to the menu structure of this plug-in. The master file +usually looks like this (my settings as an example): +> + § ========================================================== + § User Macros + § ========================================================== + + SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) + SetMacro( 'AUTHORREF', 'fgm' ) + SetMacro( 'COMPANY', '' ) + SetMacro( 'COPYRIGHT', 'Copyright (c) |YEAR|, |AUTHOR|' ) + SetMacro( 'EMAIL', 'mehner.fritz@fh-swf.de' ) + SetMacro( 'LICENSE', 'GNU General Public License' ) + SetMacro( 'ORGANIZATION','FH Südwestfalen, Iserlohn' ) + + SetStyle( 'C' ) + + § ========================================================== + § File Includes and Shortcuts + § ========================================================== + + MenuShortcut( 'Comments', 'c' ) + MenuShortcut( 'Statements', 's' ) + MenuShortcut( 'Idioms', 'i' ) + MenuShortcut( 'Preprocessor', 'p' ) + MenuShortcut( 'Snippets', 'n' ) + MenuShortcut( 'C++', 'c' ) + § + IncludeFile( 'snippets.template' ) + § + == USE STYLES : C == + IncludeFile( 'c.comments.template' ) + IncludeFile( 'c.cpp.template' ) + IncludeFile( 'c.idioms.template' ) + IncludeFile( 'c.preprocessor.template' ) + IncludeFile( 'c.statements.template' ) + == ENDSTYLES == + § + == USE STYLES : CPP == + IncludeFile( 'cpp.comments.template' ) + IncludeFile( 'cpp.cpp.template' ) + IncludeFile( 'cpp.idioms.template' ) + IncludeFile( 'cpp.preprocessor.template' ) + IncludeFile( 'cpp.statements.template' ) + == ENDSTYLES == + +Lines starting with a section sign (§) are comments. The section starting with +> + SetMacro( 'AUTHOR', 'Dr. Fritz Mehner' ) +< +assigns values to predefined tags (macros). Arbitrary user-defined macros are +possible. The macro name must follows the rules for a C language identifier: +first character letter or underscore; case matters; digits are allowed +beginning with the second character. + +The statement +> + IncludeFile( 'c.comments.templates' ) +< +includes the templates from the file 'c.comments.templates' (in the same +directory). An absolute path would also be possible. The statement +> + MenuShortcut( 'Comments', 'c' ) +< +sets 'c' as the shortcut for the Comments menu. ------------------------------------------------------------------------------ 5.2 MACROS *csupport-templates-macros* @@ -1538,325 +1579,69 @@ more letters, digits or underscores. The following macro names are predefined. The first group is used to personalize templates. - - ---------------------------------------------------------------------------- - PREDEFINED MACROS DEFAULT VALUE - ---------------------------------------------------------------------------- -*|AUTHOR|* "" -*|AUTHORREF|* "" -*|EMAIL|* "" -*|COMPANY|* "" -*|PROJECT|* "" -*|COPYRIGHTHOLDER|* "" -*|STYLE|* "" -*|includefile|* "" - -*|BASENAME|* filename without path and suffix -*|DATE|* the preferred date representation for the current locale +> + |BASENAME| filename without path and suffix + |DATE| the preferred date representation for the current locale without the time -*|FILENAME|* filename without path -*|PATH|* path without filename -*|SUFFIX|* filename suffix -*|TIME|* the preferred time representation for the current locale + |FILENAME| filename without path + |PATH| path without filename + |SUFFIX| filename suffix + |TIME| the preferred time representation for the current locale without the date and the time zone or name or abbreviation -*|YEAR|* the year as a decimal number including the century - -The macro *|includefile|* can be used to include an additional template file. -A file will be included only once. Commenting and uncommenting include macros -is a simple way to switch between several sets of templates (see also -|csupport-run-templates|). Overwriting existing macros and templates is -possible. - + |YEAR| the year as a decimal number including the century +< ---------------------------------------------------------------------------- - PREDEFINED TAGS + PREDEFINED TAGS USED IN TEMPLATES ---------------------------------------------------------------------------- - ,{CURSOR} The cursor position after insertion of a template - <+text+>,<-text->, Jump targets in templates. Jump with Ctrl-j. - {+text+},{-text-} See |csupport-templates-jump|. + The cursor position after insertion of a template. + <+text+>,<-text-> See |csupport-templates-jumptags|. + {+text+},{-text-} - The split point when inserting in visual mode - (see|csupport-templates-definition|) + The split point when inserting in visual mode + (see|csupport-templates|) -A dependent template file can start with its own macro section. There is no +A dependent template file can start with its own command section. There is no need to have all user defined macros in the master file. -When the first template definition is found (see below) macro definitions are -no longer recognized. -Use the tag variant with curly braces if the indentation of the following line -is wrong after template insertion. + ------------------------------------------------------------------------------ -5.2.1 USER DEFINED FORMATS FOR DATE AND TIME *csupport-templates-date* +5.2.1 USER DEFINED FORMATS FOR DATE AND TIME *csupport-templates-date* ------------------------------------------------------------------------------ The format for *|DATE|* ,*|TIME|* , and*|YEAR|* can be set by the user. The defaults are - *|DATE|* '%x' - *|TIME|* '%X' - *|YEAR|* '%Y' +Example: +> + |DATE| '%x' + |TIME| '%X' + |YEAR| '%Y' +< See the manual page of the C function strftime() for the format. The accepted format depends on your system, thus this is not portable! The maximum length of the result is 80 characters. -User defined formats can be set using the following global variables in -~/.vimrc , e.g. - let g:C_FormatDate = '%D' - let g:C_FormatTime = '%H:%M' - let g:C_FormatYear = 'year %Y' +User defined formats can be set using the following function calls in the +master template file is '$HOME/.vim/c-support/templates/Templates', e.g. +> + SetFormat( 'DATE', '%D' ) + SetFormat( 'TIME', '%H:%M' ) + SetFormat( 'YEAR', 'year %Y' ) ------------------------------------------------------------------------------ 5.3 TEMPLATES *csupport-templates-names* ------------------------------------------------------------------------------ -5.3.1 Template names - +5.3.1 Template definition *csupport-templates-definition* The template behind a menu entry is identified by a given name. The first part -of the name identifies the menu, the second part identifies the item. The -modes are also hard coded (see|csupport-templates-definition|for the use of -). - - TEMPLATE NAME MODES - -------------------------------------------------------------------------- - - comment.class normal - comment.end-of-line-comment normal - comment.file-description normal - comment.file-description-header normal - comment.file-section-cpp-class-defs normal - comment.file-section-cpp-class-implementations-exported normal - comment.file-section-cpp-class-implementations-local normal - comment.file-section-cpp-data-types normal - comment.file-section-cpp-function-defs-exported normal - comment.file-section-cpp-function-defs-local normal - comment.file-section-cpp-header-includes normal - comment.file-section-cpp-local-variables normal - comment.file-section-cpp-macros normal - comment.file-section-cpp-prototypes normal - comment.file-section-cpp-typedefs normal - comment.file-section-hpp-exported-class-defs normal - comment.file-section-hpp-exported-data-types normal - comment.file-section-hpp-exported-function-declarations normal - comment.file-section-hpp-exported-typedefs normal - comment.file-section-hpp-exported-variables normal - comment.file-section-hpp-header-includes normal - comment.file-section-hpp-macros normal - comment.frame normal - comment.function normal - comment.keyword-bug normal - comment.keyword-compiler normal - comment.keyword-keyword normal - comment.keyword-todo normal - comment.keyword-tricky normal - comment.keyword-warning normal - comment.keyword-workaround normal - comment.method normal - comment.special-constant-type-is-long normal - comment.special-constant-type-is-unsigned-long normal - comment.special-constant-type-is-unsigned normal - comment.special-empty normal - comment.special-fall-through normal - comment.special-implicit-type-conversion normal - comment.special-no-return normal - comment.special-not-reached normal - comment.special-remains-to-be-implemented normal - - cpp.accessor-implementation normal - cpp.catch normal, visual - cpp.catch-points normal, visual - cpp.cin normal - cpp.class-definition normal - cpp.class-implementation normal - cpp.class-using-new-definition normal - cpp.class-using-new-implementation normal - cpp.cout-operator normal - cpp.cout normal - cpp.error-class normal - cpp.extern normal, visual - cpp.method-implementation normal - cpp.namespace-block normal, visual - cpp.namespace normal - cpp.namespace-std normal - cpp.open-input-file normal - cpp.open-output-file normal - cpp.operator-in normal - cpp.operator-out normal - cpp.output-manipulator-boolalpha normal - cpp.output-manipulator-dec normal - cpp.output-manipulator-endl normal - cpp.output-manipulator-fixed normal - cpp.output-manipulator-flush normal - cpp.output-manipulator-hex normal - cpp.output-manipulator-internal normal - cpp.output-manipulator-left normal - cpp.output-manipulator-oct normal - cpp.output-manipulator-right normal - cpp.output-manipulator-scientific normal - cpp.output-manipulator-setbase normal - cpp.output-manipulator-setfill normal - cpp.output-manipulator-setiosflag normal - cpp.output-manipulator-setprecision normal - cpp.output-manipulator-setw normal - cpp.output-manipulator-showbase normal - cpp.output-manipulator-showpoint normal - cpp.output-manipulator-showpos normal - cpp.output-manipulator-uppercase normal - cpp.rtti-const-cast normal - cpp.rtti-dynamic-cast normal - cpp.rtti-reinterpret-cast normal - cpp.rtti-static-cast normal - cpp.rtti-typeid normal - cpp.template-accessor-implementation normal - cpp.template-class-definition normal - cpp.template-class-implementation normal - cpp.template-class-using-new-definition normal - cpp.template-class-using-new-implementation normal - cpp.template-function normal - cpp.template-method-implementation normal - cpp.try-catch normal, visual - - idioms.assert normal - idioms.calloc normal - idioms.enum normal, visual - idioms.fprintf normal - idioms.fscanf normal - idioms.function normal, visual - idioms.function-static normal, visual - idioms.main normal, visual - idioms.malloc normal - idioms.open-input-file normal - idioms.open-output-file normal - idioms.printf normal - idioms.scanf normal - idioms.sizeof normal - idioms.struct normal, visual - idioms.union normal, visual - - preprocessor.define normal - preprocessor.ifdef-else-endif normal, visual - preprocessor.if-else-endif normal, visual - preprocessor.ifndef-def-endif normal, visual - preprocessor.ifndef-else-endif normal, visual - preprocessor.include-global normal - preprocessor.include-local normal - preprocessor.undefine normal - - statements.block normal, visual - statements.case normal - statements.do-while normal, visual - statements.for-block normal - statements.for normal - statements.if-block-else normal, visual - statements.if-block normal, visual - statements.if-else normal, visual - statements.if normal - statements.switch normal, visual - statements.while-block normal, visual - statements.while normal - - -5.3.2 Template definition *csupport-templates-definition* - -A template definition starts with a template head line with the following -syntax: - - == templatename == [ position == ] - -The templatename is one of the above template identifiers. The position -attribute is optional. Possible attribute values are: - - above insert the template before the current line - append append the template to the current line - below insert the template below the current line - insert insert the template at the cursor position - start insert the template before the first line of the buffer - -An example: - - == comment.function == - /* - * === FUNCTION ======================================================= - * Name: - * Description: - * ====================================================================== - */ - -The definition of a template ends at the next head line or at the end of the -file. - -Templates for the visual mode can use . The text before will -than be inserted above the marked area, the text after will be -inserted behind the marked area. An example: - - == statements.if-block-else == - if ( ) { - } else { - } - -If applied to the marked block - - xxxxxxxxxxx - xxxxxxxxxxx - -this template yields - - if ( ) { - xxxxxxxxxxx - xxxxxxxxxxx - } else { - } - -The templates with a visual mode are shown in the table under -|csupport-templates-names|. - -5.3.3 Template expansion *csupport-templates-expansion* - -There are additional ways to control the expansion of a template. - -USER INPUT ----------- -If the usage of a yet undefined user macro starts with a question mark the -user will be asked for the replacement first, e.g. with the following template - - == idioms.function == - void - *|?FUNCTION_NAME|* ( ) - { - return ; - } /* ----- end of function*|FUNCTION_NAME|* ----- */ - -The user can specify the function name which then will be applied twice. If -the macro was already in use the old value will be suggested as default. - -MACRO MANIPULATION ------------------- - -A macro expansion can be controlled by the following attributes - - :l change macro text to lowercase - :u change macro text to uppercase - :c capitalize macro text - :L legalize name +of the name identifies the menu name, the second part identifies the item. +A template definition starts with a template header with the following syntax: -The include guard template is an example for the use of ':L' : + == menu_name.template_name == options == - == preprocessor.ifndef-def-endif == - #ifndef *|?BASENAME:L|_INC* - #define *|BASENAME|_INC* - - #endif // ----- #ifndef*|BASENAME|_INC* ----- +The options are described here: |template-support-options|. -The base name of the file shall be used as part of the include guard name. -The predefined macro*|BASENAME|* is used to ask for this part because this -macro has already a defined value. That value can accepted or replaced by the -user. For the filename 'test test++test.h' the legalized base name -'TEST_TEST_TEST' will be suggested. +5.3.2 The jump tags <+text+> etc. *csupport-templates-jumptags* -Legalization means: - - replace all whitespaces by underscores - - replace all non-word characters by underscores - - replace '+' and '-' by underscore - -5.3.4 The macros <+text+> etc. *csupport-templates-jump* - -There are four macro types which can be used as jump targets in templates: +There are four jump tag types which can be used as jump targets in templates: <+text+> Can be jumped to by hitting Ctrl-j. {+text+} Same as <+text+>. Used in cases where indentation gives unwanted @@ -1865,132 +1650,27 @@ There are four macro types which can be used as jump targets in templates: <-text-> Same as the two above. Will be removed if the template is used {-text-} in visual mode. -The text inside the brackets is userdefined and can be empty. The text -can be composed from letters (uppercase and lowercase), digits, underscores -and blanks. After the insertion of an template these jump targets will be -highlighted. +The text inside the brackets is userdefined and can be empty. The text can be +composed from letters (uppercase and lowercase), digits, and underscores. +After the insertion of an template these jump targets will be highlighted. -5.3.5 Command Ctrl-j *csupport-Ctrl-j* +5.3.3 Command Ctrl-j *csupport-Ctrl-j* Use the command Ctrl-j to jump to the next target. The target will be removed and the mode will switched to insertion. Ctrl-j works in normal and in insert -mode. - -The template for a function can be written as follows: - - == idioms.function == - void - |?FUNCTION_NAME| ( <+argument list+> ) - { - return <+return value+>; - } /* ----- end of function |FUNCTION_NAME| ----- */ - -The cursor will be set behind 'void'. You can remove 'void' easily with -Ctrl-w (delete word before cursor) and insert a new type. A Ctrl-j leads you -to the argument list. The target disappears and you can type on. When the -function body is written a final Ctrl-j brings you to the return statement. - -The following example shows the usage of the type {-text-}. The idiom for the -opening of a file marks the line before the file is closed. This is also the -line where the template will be split to surround a marked area. In this case -(visual mode) the target is not needed and therefore removed (minus signs as -mnemonic). In normal and insert mode the target is meaningful and will be -therefore be present. The form <-...-> would result in a wrong indentation of -the file close statement. The brace type will be handled as a block and the -indentation will be correct. - - == cpp.open-input-file == - char *ifs_file_name = ""; /* input file name */ - ifstream ifs; /* create ifstream object */ - - ifs.open (ifs_file_name); /* open ifstream */ - if (!ifs) { - cerr << "\nERROR : failed to open input file " << ifs_file_name << endl; - exit (EXIT_FAILURE); - } - {-continue here-} - ifs.close (); /* close ifstream */ - -Extra feature of Ctrl-j ------------------------ -If none of the above described targets is left Ctrl-j can be used to jump -behind closing brackets, parenthesis, braces, or string terminators ('"`). -This feature is limited to the current line. Ctrl-j does not jump behind the -last character in a line. - - -How to switch the mapping for Ctrl-j off ----------------------------------------- -The original meaning of Ctrl-j is 'move [n] lines downward' (see |CTRL-j|). -If you are accustomed to use the deafult and don't like these jump targets you -can switch them off. Put the following line in the file .vimrc : - - let g:C_Ctrl_j = 'off' - -The default value of g:C_Ctrl_j is 'on'. You do not have to change the -template files. All jump targets will be removed before a template will be -inserted. - -============================================================================== -5.4 SWITCHING BETWEEN TEMPLATE SETS *csupport-templates-sets* -============================================================================== - -This plugin comes with two sets of templates. These are suggestions. You may -want to have additional sets for different projects or occasionally want to -use doxygen style comments. To facilitate switching use the macro*|STYLE|* -(|csupport-templates-files|) to define a unique name and the -IF-ENDIF-construct to choose a particular set of files for example: - - ... - - *|STYLE|* = C - $ - $ ============================================================= - $ ========== FILE INCLUDES ==================================== - $ ============================================================= - $ - == IF *|STYLE|* IS C == - $ - |includefile| = c.comments.template - |includefile| = c.cpp.template - |includefile| = c.idioms.template - |includefile| = c.preprocessor.template - |includefile| = c.statements.template - $ - == ENDIF == - - ... - -The syntax is as follows: - - == IF macro_name IS macro_value == - - == ENDIF == - -Includes outside an IF-ENDIF construct are associated with the default style -'default'. A style set does not have to a complete set of templates. For an -incomplete set the other templates are taken from the default style. - -IF, IS, and ENDIF are keywords. - -HINT. Use these constructs to avoid overwriting your templates when updating -csupport. Copy and rename the set of files you want to change and surround the -includes with an appropriate IF-construct: - - *|STYLE|* = MY_C - $ - ... - $ - == IF *|STYLE|* IS MY_C == - |includefile| = my_c.comments.template - |includefile| = my_c.cpp.template - |includefile| = my_c.idioms.template - |includefile| = my_c.preprocessor.template - |includefile| = my_c.statements.template - == ENDIF == - -Keep a copy of the main template file 'Templates' because this file will be -overwritten if you do not update manually. +mode. The template for an if-else-statement can be written as follows: +> + == Statements.if, else == map:sie, sc:i == + if + <-IF_PART-> + else + <+ELSE_PART+> + endif +< +The cursor will be set as shown. When the condition is specified a Ctrl-j let +you jump to the target <-IF PART-> and deletes it. When the block is written +a Ctrl-j leads you to the else-part. The target <+ELSE_PART+> disappears and +you can type on. ============================================================================== 5.5 BINDING A STYLE TO A FILE EXTENSION *csupport-templates-bind* @@ -1998,9 +1678,9 @@ overwritten if you do not update manually. You can bind the existing styles to one or more filename extensions. To do so assign a Dictionary to the global variable g:C_Styles in '~/.vimrc' : - -let g:C_Styles = { '*.c,*.h' : 'default', '*.cc,*.cpp,*.hh' : 'CPP' } - +> + let g:C_Styles = { '*.c,*.h' : 'C', '*.cc,*.cpp,*.c++,*.C,*.hh,*.h++,*.H' : 'CPP' } +< A Dictionary is created with a comma separated list of entries in curly braces. Each entry has a key and a value, separated by a colon. Each key can only appear once. The keys are themselves a comma separated list of filename @@ -2033,12 +1713,12 @@ following values: $VIM.'/vimfiles/' for Windows If you want to use an additional list MyC.list put the following lines into ~/.vimrc : - - let g:C_Dictionary_File = PLUGIN_DIR.'/c-support/wordlists/c-c++-keywords.list,'. - \ PLUGIN_DIR.'/c-support/wordlists/k+r.list,'. - \ PLUGIN_DIR.'/c-support/wordlists/stl_index.list,'. - \ PLUGIN_DIR.'/c-support/wordlists/MyC.list' - +> + let g:C_Dictionary_File = PLUGIN_DIR.'/c-support/wordlists/c-c++-keywords.list,'. + \ PLUGIN_DIR.'/c-support/wordlists/k+r.list,'. + \ PLUGIN_DIR.'/c-support/wordlists/stl_index.list,'. + \ PLUGIN_DIR.'/c-support/wordlists/MyC.list' +< When in file ~/.vimrc the name PLUGIN_DIR has to be replaced by $HOME or $VIM (see above). Whitespaces in the pathnames have to be escaped with a backslash. @@ -2097,13 +1777,13 @@ If you frequently change the plugin templates and you are using the taglist plugin (section above) you may want to use this plugin for navigation. This is achieved in two steps. First add a new language definition to the file $HOME/.ctags : - +> --langdef=template --langmap=template:.template,TEMPLATE --regex-template=/^==\s+([^=]+)\s+==\s*(\s+==\s+([^=]+)\s+==)?/\1/t,template/ - +< Now add the following lines to the file $HOME/.vimrc : - +> let tlist_template_settings = 'template;t:template' "--------------------------------------------------------------- " plugin templates : set filetype for *.template @@ -2112,7 +1792,7 @@ Now add the following lines to the file $HOME/.vimrc : autocmd BufNewFile,BufRead Templates set filetype=template autocmd BufNewFile,BufRead *.template set filetype=template endif " has("autocmd") - +< The assignment defines the heading for the template section in the taglist window. The autocmds set the file type 'template' for the main template file 'Templates' and the includefiles '*.template' (if any). @@ -2139,11 +1819,11 @@ Visual mode ----------- A range of lines containing closed folds can be surrounded by constructs which have a visual mode, e.g. a for-loop: - +> for ( ; ; ) { +--- 4 lines: {------------------------------------------------------------ } - +< See |folding| for more information on folding. ============================================================================== @@ -2166,6 +1846,16 @@ Open a block (modes: i,v): } In visual mode the content of the new block will be indented. +The file customization.cpp.vim provides additional insert mode mappings to +facilitate writting cin and cout statements, e.g. +> + '<<' -> ' << |' + '<<"' -> ' << "|" ' + '<<;' -> ' << "|\n";' + '>>' -> ' >> |' +< +Copy this file to ~/.vim/ftplugin and rename it to 'cpp.vim'. + ============================================================================== 10. WINDOWS PARTICULARITIES *csupport-windows* ============================================================================== @@ -2223,18 +1913,6 @@ directory): * How can I see what was loaded? - Use ':scriptnames' from the Vim command line. -* No main menu item. - - Loading of plugin files must be enabled. If not use - :filetype plugin on - This is the minimal content of the file '$HOME/.vimrc'. Create one if there - is none, or better use customization.vimrc. - -* Most key mappings do not work. - - They are defined in a filetype plugin in '$HOME/.vim/ftplugin/'. Use - ':filetype' to check if filetype plugins are enabled. If not, add the line - filetype plugin on - to the file '~/.vimrc'. - * Some hotkeys do not work. - The hotkeys might be in use by your graphical desktop environment. Under KDE Ctrl-F9 is the hotkey which let you switch to the 9. desktop. The key diff --git a/doc/templatesupport.txt b/doc/templatesupport.txt new file mode 100644 index 0000000..197233a --- /dev/null +++ b/doc/templatesupport.txt @@ -0,0 +1,1054 @@ +*templatesupport.txt* MM Template Support July 18 2012 + +MM Template Support *template-support* + + Plugin version 0.9 + for Vim version 7.0 and above + Wolfgang Mehner + + + --- The Maps & Menus Template Support ... --- + +-- ... for Vim Users -- + +This plug-in aims at providing extendible template libraries. A template +library can assist in speeding up the writing of code, while at the same time +ensuring a consistent style. The templates are written in an easy markup +language, which enables the user to customize templates without much hassle. + +Menus and maps to access the templates are created automatically. While maps +might or might not be the preferred way of inserting templates (as well as +using Vim in general), the menus always provided an overview of the templates +and the associated maps. This makes it quite easy to use the templates and +learn their maps at the same time. + +-- ... for Plug-Ins -- + +The template support is controlled by an API and thus can be integrated in +another plug-in. A template library is essentially an object, several of which +can exist in parallel. This makes it relatively easy to write a plug-in for +the programming language of your choice. + +Here is a list of high profile plug-ins which use the template support: +- Bash-Support (www.vim.org/scripts/script.php?script_id=365) +- C-Support (www.vim.org/scripts/script.php?script_id=213) +- Perl-Support (www.vim.org/scripts/script.php?script_id=556) + +============================================================================== +0. TABLE OF CONTENTS *template-support-contents* +============================================================================== + + 1. Introduction |template-introduction| + + 8. Backwards Compatibility |template-support-backwards| + 9. API |template-support-api| + 9.1 Basic Usage |template-support-api-basic| + 9.2 Creating Maps and Menus |template-support-api-maps| + 9.3 Access |template-support-api-access| + + A. Syntax |template-support-syntax| + A.1 Command Section |template-support-syntax-cmd| + A.2 Templates |template-support-syntax-templ| + A.3 Lists |template-support-syntax-list| + B Commands |template-support-commands| + B.1 Command Section |template-support-cmd-cmd-sct| + B.2 Templates |template-support-cmd-templates| + C Options |template-support-options| + C.1 Templates |template-support-opt-templ| + C.2 List |template-support-opt-list| + +============================================================================== +1. INTRODUCTION *template-introduction* +============================================================================== + + *Todo introduction + +============================================================================== +8. BACKWARDS COMPATIBILITY *template-support-backwards* +============================================================================== + +The following behavior is not compatible with the old template systems of +various plugins. This list does not include new features which are now +supported. + +c-support: +doxygen-support: +perl-support: + - No automatic uppercase for *|BASENAME|* . + - The format for *|DATE|* , *|TIME|* and *|YEAR|* is now configured via the + template library. Plug-ins may provide other ways to do the configuration. + +perl-support: + - The template head can not have the format > + == templatename == [ position == ] [ indentation == ] +< anymore, since the last part would be ignored. Use the list of template + options instead: > + == templatename == [ position, indentation == ] +< Both 'position' and 'indentation' are optional, of course. + +============================================================================== +9. API *template-support-api* +============================================================================== + +This chapter is only relevant if you want to use the template system with your +own plugin! + +The API enables other plugins to use the template system. + +Each template library is stored in a dictionary (|Dictionary|). + - This dictionary must be a global variable, because it it used for purposes + such as callback functions for menu entries and maps. + - Do not change the entries of the dictionary directly, since the internal + structure may change. The API provides access to the stored information. + +------------------------------------------------------------------------------ +9.1 BASIC USAGE *template-support-api-basic* +------------------------------------------------------------------------------ + +These functions provide the basic functionality to load template libraries and +insert templates into a buffer. A further function expands macros in a text. + +------------------------------------------------------------------------------ + *mmtemplates#core#NewLibrary()* +To create a new template library call: + + library = mmtemplates#core#NewLibrary () ~ + +No parameters. +Returns: + library - The template library. (dict) + +Example: > + + let g:My_C_Templates = mmtemplates#core#NewLibrary () +< +Creates a new library and stores it in the variable 'g:My_C_Templates'. + +------------------------------------------------------------------------------ + *mmtemplates#core#ReadTemplates()* +Templates are loaded using the function: + + mmtemplates#core#ReadTemplates ( library, ... ) ~ + +Parameters: + library - The template library. (string or dict) +Options: + "load", file - Load templates from 'file'. (string) + "reload", what - Reload templates according to 'what', see below. + (string or integer) + "overwrite_warning" - Print a warning each time a template is overwritten. + "debug", level - View debug information with the given level of detail. + (integer, default: show no debug information) +No returns. + +The library can either be given directly, or as the name of the global +variable containing the library. + +When loading a new file, it must be given with a path and filename. > + mmtemplates#core#ReadTemplates ( library, "load", "path/file.templates" ) +< +The entire library can be reloaded by calling: > + mmtemplates#core#ReadTemplates ( library, "reload", "all" ) +A file can be reloaded, but only if it has been loaded before: > + mmtemplates#core#ReadTemplates ( library, "reload", "path/file.templates" ) +The i'th file which has been loaded can be reloaded via: > + mmtemplates#core#ReadTemplates ( library, "reload", i ) +< +With the switch "overwrite_warning", a warning is displayed whenever a +template is encountered which already has a text for the current style. + +Example 1: Load a file. +> + call mmtemplates#core#ReadTemplates ( g:My_C_Templates, + \ "load", "$HOME/.vim/c-support/templates/lib.templates", + \ "debug", 1, "overwrite_warning" ) +< +Load the templates in the given file and print very little debug information. +Print a warning whenever a template is overwritten. + +Example 2.1: Load several files. +> + call mmtemplates#core#ReadTemplates ( g:My_C_Templates, + \ "load", "/usr/share/vim/.../global.templates" ) + + call mmtemplates#core#ReadTemplates ( g:My_C_Templates, + \ "load", "$HOME/.vim/.../local.templates" ) +< +Load the templates in the two files. + +Example 2.2: Reload specific templates. +> + call mmtemplates#core#ReadTemplates ( g:My_C_Templates, "reload", -1 ) +< +Reload the last template which has been loaded. +(".../local.templates" from above) + +Example 2.3: Reload templates by name. +> + call mmtemplates#core#ReadTemplates ( g:My_C_Templates, + \ "reload", "$HOME/.vim/.../local.templates" ) +< +------------------------------------------------------------------------------ + *mmtemplates#core#InsertTemplate()* +To insert templates into the current buffer use: + + mmtemplates#core#InsertTemplate ( library, name, ... ) ~ + +Parameters: + library - The template library. (string or dict) + name - The name of the template or "!pick". (string) +Options: + "v" - > "visual" + "visual" - Visual mode, use the tag. +No returns. + +The library can either be given directly, or as the name of the global +variable containing the library. +It the template 'name' does not exist, an error message is displayed. + +If 'name' is "!pick", the user is presented with a list of all template, and +can choose one to be included. (currently not implemented!) + +Examples: +> + call mmtemplates#core#InsertTemplate ( g:My_C_Templates, + \ "Statement.If", "v" ) +< +Include "Statement.If", surround the selected lines. +> + call mmtemplates#core#InsertTemplate ( g:My_C_Templates, "!pick" ) +< +The user is prompted for a template, which is then included. + +------------------------------------------------------------------------------ + *mmtemplates#core#ExpandText()* +To perform macro expansion in a text use: + + rtext = mmtemplates#core#ExpandText ( library, text ) ~ + +Parameters: + library - The template library. (string or dict) + text - A text. (string) +Returns: + rtext - The text after the macro expansion (string). + +The library can either be given directly, or as the name of the global +variable containing the library. +The expansion is done using all the settings in the library, as well as the +global macro replacements such as *|AUTHOR|* . + +Examples: +> + let text = mmtemplates#core#ExpandText ( g:My_C_Templates, "|DATE| |TIME|" ) +< +Returns "29.2.2000 12:00", depending on the format set in the library. +This can be used for special menu entries such as: +> + exe 'amenu Comments.Special.Date\ Time ' + \ .':exe "normal! a".mmtemplates#core#ExpandText ( ' + \ .'g:My_C_Templates, "\|DATE\| \|TIME\|" )' +< +------------------------------------------------------------------------------ + *mmtemplates#core#EditTemplateFiles()* +The jump to the next tag is performed by: + + mmtemplates#core#EditTemplateFiles ( library, file ) ~ + +Parameters: + library - The template library. (string or dict) + file - A file. (string or integer) +No returns. + +The library can either be given directly, or as the name of the global +variable containing the library. + +The argument 'file' can be given as a filename, in which case it must have +been loaded before via |mmtemplates#core#ReadTemplates()|. +'file' can also be an integer i, which refers to the i'th file that has been +loaded. + +A file browser is then opened for the directory containing the file. + *Todo configuration of the file browser + +Example: +> + " load the last template file: + call mmtemplates#core#ReadTemplates ( g:My_C_Templates, + \ "load", "$HOME/.vim/.../templates/local.templates" ) + + " ... + + " edit the library + call mmtemplates#core#EditTemplateFiles ( g:My_C_Templates, -1 ) +< +Opens a file browser in the directory "$HOME/.vim/.../templates/". + +------------------------------------------------------------------------------ + *mmtemplates#core#JumpToTag()* +The jump to the next tag is performed by: + + e = mmtemplates#core#JumpToTag ( regex ) ~ + +Parameters: + regex - The regex to jump to. (string) +Returns: + e - An empty string. + +Jumps to the next occurrence of 'regex' and removes it from the buffer. Then +the function returns an empty string. +The regular expression can be obtained from the template library via the +function |mmtemplates#core#Resource()|. + +Example: + +This function is best used in maps such as this: +> + let regex = mmtemplates#core#Resource ( g:My_C_Templates, "jumptag" ) + + " ... + + nnoremap i=mmtemplates#core#JumpToTag ( regex ) + inoremap =mmtemplates#core#JumpToTag ( regex ) +< +This maps can be created automatically using |mmtemplates#core#CreateMaps()|. + +------------------------------------------------------------------------------ +9.2 CREATING MENUS AND MAPS *template-support-api-maps* +------------------------------------------------------------------------------ + +The automated generation of maps and menus is carried out by these functions. + +------------------------------------------------------------------------------ + *mmtemplates#core#CreateMaps()* +The automatic creation of maps is carried out by the function: + + mmtemplates#core#CreateMaps ( library, localleader, ... ) ~ + +Parameters: + library - The name of the variable containing the library. (string) + localleader - The local mapleader. (string) +Options: + "do_jump_map" - Create a map for |mmtemplates#core#JumpToTag()|. + "do_special_maps" - Create maps for the special operations. +No returns. + +If 'localleader' is an empty string, the standard mapleader is used. +Otherwise > + let maplocalleader = localleader +is executed before the maps are created. (see |mapleader|) + +The maps for the jump and the special operations (choose a template/style, +reread/edit the library) are not created unless the corresponding options are +given. + +This function creates maps which are local to the buffer, so it must be called +in the appropriate filetype-plugin, or by an autocommand. +An error message is displayed whenever a mapping already exists. The existing +mapping is not overwritten. + +Example: +> + call mmtemplates#core#CreateMaps ( "g:My_C_Templates", "", "do_jump_map" ) +< +Creates maps using the standard mapleader. A map to jump to the next tag is +also created. + +Technical Details: + - The library must be given as the name of the global variable, since this + name is required to create the maps. + - The function creates maps of the following types: + noremap, inoremap, vnoremap + +------------------------------------------------------------------------------ + *mmtemplates#core#CreateMenus()* +The automatic creation of menus is carried out by the function: + + mmtemplates#core#CreateMenus ( library, rootmenu, ... ) ~ + +Parameters: + library - The name of the variable containing the library. (string) + rootmenu - The name of the root menu. (string) +Options: + "global_name", name - The name used in the menu headers. + (string, default: the value of 'rootmenu') + "existing_menu", names - The menus which already exist. + (string or list of strings) + "sub_menu", names - Additional sub-menus which should be created. + (string or list of strings) + "specials_menu", name - The name of the menu containing the special + operations. (string, default: "Run") + "do_all" - Action: Reset and create all menus. + "do_reset" - Action: Reset. + "do_templates" - Action: Create menus for all the templates. + "do_specials" - Action: Create a menu with the special entries. + "do_styles" - Action: Create a menu for selecting the style. +No returns. + +"do_all", "do_templates", "do_specials" and "do_styles" starts the automatic +creation of menu entries. Sub-menus are created automatically as needed. +The special operations are: choose a template/style, reread/edit the library. +The corresponding menu entries are put in the sub-menus given by the option +"specials_menu". + +Each sub-menu looks like this, starting with a header: +> + + --- ------------- + + + ... ... +< +The global name (option "global_name") helps to keep track of tear-off menus. +"sub_menu" can be used to create additional menus, which have the same header. + +The library keeps track of all created sub-menus, to be able to add the +headers correctly. "existing_menu" adds menus to this list. +"do_reset" resets this list and allows for the menus to be created once more. +"do_all" also reset the list before it carries out further operations. + +The "&" and the trailing points in 'rootmenu' and "existing_menus" are +ignored. "sub_menus" and "specials_menu" also ignore trailing points, but use +the "&" to create shortcuts. However, if a shortcut for the menu has been set +in the library, that one is preferred. + + +Example 1: Basic usage. + +Suppose your plugin creates the following menus: +> + C-Support + >-+ Comments + | >-- code->comment + | >-- comment->code + | >-+ Special + | | >--- ... + >-+ Run + | >-- run + | >-- ... +< +Then the call has to look like this: +> + call mmtemplates#core#CreateMenus ( "g:My_C_Templates", "&C-Support", + \ "do_all", "existing_menu", [ "&Comments","Comments.&Special.","&Run." ] ) +< +To create headers for each sub-menu, similar to those the template support +creates, use code like this: +> + let root_menu = "&C-Support" + let global_name = "C/C++" + exe 'amenu '.root_menu.'.'.root_menu.' ' + exe 'amenu '.root_menu.'.-Sep0- ' + exe 'amenu '.root_menu.'.&Run.Run'.global_name.' ' + exe 'amenu '.root_menu.'.Run.-Sep00- ' +< + +Example 2: Advanced usage. + +You can use this facility to create all the menu headers. +It also gives you more control over the order of the menu entries. + +First, reset the list of created menus: > + call mmtemplates#core#CreateMenus ( "g:My_C_Templates", "C-Support", + \ "do_reset" ) +Then create a sub-menu (shortcut "c"): > + call mmtemplates#core#CreateMenus ( "g:My_C_Templates", "C-Support", + \ "sub_menu", "&Comments" ) + " entries: comment/uncomment/... : + ... +Create entries for the templates: > + call mmtemplates#core#CreateMenus ( "g:My_C_Templates", "C-Support", + \ "do_templates" ) +Create a run menu (shortcut "r"): > + call mmtemplates#core#CreateMenus ( "g:My_C_Templates", "C-Support", + \ "sub_menu", "&Run" ) + " entries: compile/run/test/... : + ... +Create the special entries at the end of the run menu: > + call mmtemplates#core#CreateMenus ( "g:My_C_Templates", "C-Support", + \ "do_specials", "specials_menu", "Run." ) +> + +Technical Details: + - The library must be given as the name of the global variable, since this + name is required to create the menues. + - The function creates menus of the following types: + amenu, vmenu (where appropriate) + +------------------------------------------------------------------------------ +9.3 ACCESS *template-support-api-access* +------------------------------------------------------------------------------ + +The following functions are used to query and change the resources of a +template library. For example, they are used to change the style or to change +the format of the date and time. + +------------------------------------------------------------------------------ + *mmtemplates#core#ChooseStyle()* +The style is changed using the function: + + mmtemplates#core#ChooseStyle ( library, style ) ~ + +Parameters: + library - The template library. (string or dict) + style - The name of the style or "!pick". (string) +No returns. + +The library can either be given directly, or as the name of the global +variable containing the library. +If 'style' is "!pick", the user is presented with a list of all styles, and +can choose one. +It the style 'style' does not exist, an error message is displayed and the +style remains unchanged. + +Example: +> + call mmtemplates#core#ChooseStyle ( g:My_C_Templates, "!pick" ) +< +The user is prompted for a new style. + +------------------------------------------------------------------------------ + *mmtemplates#core#Resource()* +Access to a number of resources is provided by: + + [ rval, msg ] = mmtemplates#core#Resource ( library, mode, ... ) ~ + + [ rval, msg ] ~ + = mmtemplates#core#Resource ( library, "get", resource, key ) ~ + [ rval, msg ] ~ + = mmtemplates#core#Resource ( library, "set", resource, key, val ) ~ + +Parameters: + library - The template library. (string or dict) + mode - The operation which should be executed. (string) +Options: + ... - Depending on 'mode'. +Returns: + rval - Content and type depending on 'mode'. + msg - In case of success: An empty string. (string) + In case of failure: An error message. (string) + +The library can either be given directly, or as the name of the global +variable containing the library. + +The following modes are supported: + - "jumptag" : Return the regex used to find jump tags. + - "style" : Return the name of the current style. + - "get" : Return the resource with the given key or 0. + - "set" : Change the resource with the given key to val. + ('rval' is undefined) + +The mode "get" supports the following resources: + - "macro", "m": A macro as set by SetMacro( "m", ... ) + - "path", "p": A path as set by SetPath( "p", ... ) + - "list", "l": The list as generated by == List: l == ... == +It returns the integer 0, if the resource 'key' does not exist. +The mode "set" can be used to overwrite these resources. +The resource "list" is returned as a reference, use it responsibly. + +Setting the special macros "DATE", "TIME", and "YEAR" changes the format of +the date and time. they use the same format as the function |strftime()|. +Setting "basename", "FILENAME", "PATH" and "SUFFIX" has no effect. + + +Example 1: + +The format of the macro *|TIME|* can be changed by calling: +> + call mmtemplates#core#Resource ( g:My_C_Templates, "set", "macro", + \ "TIME", "%H:%M" ) +< + +Example 2: + +Suppose you have a template like this: +> + == Include.project include == insert, pick-file == + |Prompt( "project include directory" )| + |GetPath( "project_include" )| + #include "|PICK|" + == ENDTEMPLATE == +< +Whenever you switch to a new project, you can execute: +> + call mmtemplates#core#Resource ( g:My_C_Templates, "set", "path", + \ "project_include", project_include_dir ) +< +The next time you insert the template "Include.project include", the file +browser will already be set to the project include directory. + + +Example 3: + +Get the current style: +> + let current_style = mmtemplates#core#Resource ( g:My_C_Templates, "style" ) +< +============================================================================== +A. SYNTAX *template-support-syntax* +============================================================================== + +The standards for the idioms are as follows, but may be changed via the API: + +Idiom Changeable? Standard + +CommentStart yes $ +BlockDelimiter no == + +MacroName no a-z, A-Z, 0-9 and _ + starting with a letter or underscore +StyleName no same as MacroName +ResourceName no same as MacroName +CommandName no same as MacroName +TemplateName no a-z, A-Z, 0-9 and _ + - . , + starting with a letter or underscore, + not ending with a whitespace +OptionName no same as MacroName +Mapping no a-z, A-Z, 0-9 and _ + - + +The rules in the next sections use the following notation: + +- Syntax category: StartsWithCapitalLetters +- Keyword: ALLCAPS +- Various items: -something- +- Square brackets [ ] mark an optional part of the rule. +- All other characters are as printed. +- Whitespaces are ignored, except where marks the start of the line. + Whitespaces can not appear there. + +------------------------------------------------------------------------------ +A.1 COMMAND SECTION *template-support-syntax-cmd* +------------------------------------------------------------------------------ + +MacroAssignment: + -text- + ' -text- ' + " -text- " + +Note: Trailing whitespaces are ignored, even with the first rule. + + +Statement (one of): + -empty line- + CommentStart -anything- + CommandName ( ParameterList ) + *|MacroName|* = MacroAssignment + StyleBlock1 + StyleBlock2 + Template + List + HelpTemplate + + +StyleBlock1 (sequence): + == IF *|STYLE|* IS MacroName == + StatementList + == ENDIF == + + +StyleBlock2 (sequence): + == USE STYLES : MacroNameList == + StatementList + == ENDSTYLES == + + +Template (sequence): + == [ TEMPLATE : ] TemplateName == [ OptionList == ] + -several lines- + == ENDTEMPLATE == + +Note: The " TEMPLATE : " in the first line is optional, as opposed to the +structure of the next two rules. + + +List (sequence): + == LIST : MacroName == [ OptionList == ] + -several lines- + == ENDLIST == + + +HelpTemplate (sequence): + == HELP : TemplateName == [ OptionList == ] + -several lines- + == ENDHELP == + + +MacroNameList (one of): + MacroName + MacroName , MacroNameList + + +OptionList (one of): + -empty- + Option + Option , OptionList + + +Option (one of): + OptionName + OptionName : MacroName + OptionName : Mapping + +------------------------------------------------------------------------------ +A.2 TEMPLATES *template-support-syntax-templ* +------------------------------------------------------------------------------ + + *Todo syntax templates + +------------------------------------------------------------------------------ +A.3 LISTS *template-support-syntax-list* +------------------------------------------------------------------------------ + +Lists can either be lists or dictionaries. (Corresponding to the types Vim +uses: |List| and |Dictionary|.) + +Lists are a comma separated list of strings: +> + == LIST: Options == list == + "tabstop", "shiftwidth", + "wrap", "nowrap", + "filetype" + == ENDLIST == +< +Bare lists do not require quotes, each line is interpreted as an entry. +Leading and trailing whitespaces are ignored: +> + == LIST: Options == list, bare == + tabstop + shiftwidth + wrap + nowrap + filetype + == ENDLIST == +< +Dictionaries associate a key with a value. Key and value are separated by a +colon, different entries by a comma. +> + == LIST: FileEndings == dict == + "C" : ".c" , + "C++" : ".cc" , + "Perl" : ".pl" , + "Shell" : ".sh" , + "Vimscript" : ".vim" , + == ENDLIST == +< +============================================================================== +B COMMANDS *template-support-commands* +============================================================================== + +This sections list the commands supported by the template system. + +------------------------------------------------------------------------------ +B.1 COMMAND SECTION *template-support-cmd-cmd-sct* +------------------------------------------------------------------------------ + +The following commands can be used outside of templates, in the so-called +command section. + +------------------------------------------------------------------------------ + *template-support-IncludeFile()* +Include the file 'filename': + + IncludeFile ( filename ) ~ + +'filename' can contain a path which can be absolute or relative. Relative +paths are interpreted in relation to the directory of the file containing the +command. + +------------------------------------------------------------------------------ + *template-support-SetFormat()* +Set the format of 'item' to 'format': + + SetFormat ( item, format ) ~ + +This changes the way the macros "TIME", "DATE" and "YEAR" are replaced. It +sets the format of the date and time. They use the same format as the function +|strftime()|. + +Example: > + SetMacro ( "TIME", "%H:%M" ) +The macro *|TIME|* will now be replaced by something like 10:24. + +------------------------------------------------------------------------------ + *template-support-SetMacro()* +Set the macro 'name' to 'text': + + SetMacro ( name, text ) ~ + +This is used to set replacements for macros. + +Setting the macros "TIME", "DATE", "YEAR", "BASENAME", "FILENAME" , "PATH" and +"SUFFIX" is not allowed. They are set to the appropriate values for insertion +of a template. + +Example: > + SetMacro ( "AUTHOR", "My cat." ) + +------------------------------------------------------------------------------ + *template-support-SetPath()* +Set the resource 'name' to the given path. + + SetPath ( name, path ) ~ + +Subsequently the path can be used in templates. + +------------------------------------------------------------------------------ + *template-support-SetStyle()* +Set the active style to 'name': + + SetStyle ( name ) ~ + +This style will be used after the library has been loaded. + +------------------------------------------------------------------------------ + *template-support-MenuShortcut()* +Set the shortcut for the submenu 'menu' to 'shortcut': + + MenuShortcut ( menu, shortcut ) ~ + +The shortcut is set for the menu named by the last component of 'menu', which +can consist of several parts, separated by points. Trailing points are +ignored. + +Example: > + MenuShortcut ( "Comments.Frames.", "r" ) +Sets the shortcut for the submenu "Frames", not "Comments". + +------------------------------------------------------------------------------ +B.2 TEMPLATES *template-support-cmd-templates* +------------------------------------------------------------------------------ + +Templates themselves support various commands, either in the command block at +the beginning of the template, or in the text itself. + +------------------------------------------------------------------------------ + *template-support-PickFile()* +Open a prompt and let the user select a file: + + |PickFile ( prompt, path )| ~ + +Displays 'prompt' and lets the user select a file. The file browser starts out +in the directory named by 'path'. If 'path' matches an identifier, the path +resource by this name severs as the path. Otherwise the string path is used as +the path directly. + +After the user selected a file, several replacements for macros are created, +which can be inserted in the template: +- *|PICK_COMPL|* : the complete path and name of the selected file +- *|PATH_COMPL|* : the complete path of the selected file +- *|PICK|* : the selected path and file relative to the directory given + in 'path' +- *|PATH|* : the path in *|PICK|* +- *|FILENAME|* : the name of the file +- *|BASENAME|* : the name of the file without the suffix +- *|SUFFIX|* : the suffix of the file + +Example: > + + SetPath ( "global", "/usr/include/" ) + + == global include == below == + |PickFile( "select a file: ", "global" )| + #include <|PICK|> + == local include == below == + |PickFile( "select a file: ", "global/" )| + #include "|PICK|" + == ENDTEMPLATE == +< +The path in the first template is the resource "global", which in turn is +"/usr/include/". The path in the second template will be "global/", since the +string does not match an identifier. + +If the user inserts the template "global include", he will be asked to select +a file, starting in the directory "/usr/include/". If we selects the file: > + /usr/include/QtGui/QPushButton +the macro *|PICK|* will be set to "QtGui/QPushButton", and *|PATH|* to +"QtGui". + +------------------------------------------------------------------------------ + *template-support-PickList()* +Open a prompt and let the user select an entry from a list: + + |PickList ( prompt, list )| ~ + +Displays 'prompt' and lets the user select an entry from a list. If 'list' is +a string and matches an identifier, the list resource by this name is used. +If 'list' is a list or a dictionary, it is used directly. + +In case of lists, the user has to choose an entry from the list. In case of +dictionaries, the user has to choose one of the keys. + +After the user selected an entry, several replacements for macros are created, +which can be inserted in the template: +- *|VALUE|* : the selected entry from the list or dictionary +- *|KEY|* : the selected key (dictionaries only) +- *|PICK|* : same as *|VALUE|* + +Example: +> + == LIST: headers == list == + "stdlib", + "stdio", + "string", + == LIST: functions == hash == + "strcpy" : "{+DEST+}, {+SRC+}", + "strncpy" : "{+DEST+}, {+SRC+}, {+N+}", + "strcmp" : "{+STR1+}, {+STR2+}", + "strncmp" : "{+STR1+}, {+STR2+}, {+N+}", + "strlen" : "{+STR+}", + == ENDLIST == + + == header include == below == + |PickList( "header file: ", "headers" )| + #include <|PICK|.h> + == function call == insert == + |PickList( "function: ", "functions" )| + |KEY| ( |VALUE| ) + == ENDTEMPLATE == +< +The first template is straight ahead. The user selects a header from the list, +then the preprocessor directive is inserted. + +The second template uses a dictionary. The user has to pick an entry from the +list of function names. The template is inserted using both the selected key +and value. Each value is a list of jump tags, named for the arguments of the +corresponding function. + +------------------------------------------------------------------------------ + *template-support-Prompt()* +Prompt the for a replacement of the macro: + + |Prompt ( macro, flag )| ~ + +The user is prompted for a replacement of 'macro'. After the user has entered +a text, the flag is applied. The replacement is saved to be reused later. + +Flags: +- "" : no change to the text +- "l" : change text to lowercase +- "u" : change text to uppercase +- "c" : capitalize text +- "L" : legalize name + +Example: +> + == chapter, alt1 == below == + ============================================================================ + |?NUMBER| |?NAME:u| + ============================================================================ + + + + == chapter, alt2 == below == + |Prompt( 'NAME', '' )| + |Prompt( 'NUMBER', '' )| + ============================================================================ + |NUMBER| |NAME:u| + ============================================================================ + + + + == chapter, toc == below == + |NUMBER| |NAME:c| + == ENDTEMPLATE == +< +This inserts captions for chapters as used in this document. With the first +alternative, the user is first prompted for a replacement of *|NUMBER|* , +because of the order both macros appear in the text. The name is saved in +uppercase. +Using the second alternative, the user is prompted for the name first. The +name is saved as entered and only inserted in uppercase. Now it can be +inserted into the table of contents as entered by the user. + +============================================================================== +C OPTIONS *template-support-options* +============================================================================== + +The following sections list the options for templates and lists. + +------------------------------------------------------------------------------ +C.1 TEMPLATES *template-support-opt-templ* +------------------------------------------------------------------------------ + +The template options appear in the head of the template: + == == == ~ + +It is not required to specify any options. The defaults are given below. +Help templates use the same options as normal templates. + +------------------------------------------------------------------------------ + *template-support-start* *template-support-append* + *template-support-above* *template-support-insert* + *template-support-below* +Placement: + + start - The text is placed above the first line. + above - The text is placed above the first line. + below - The text is placed below the first line (default). + append - The text is appended to the current line. + insert - The text is inserted at the cursor position. + +Note: "below" and "insert" support split tag in visual mode. + +------------------------------------------------------------------------------ + *template-support-visual* *template-support-indent* + *template-support-novisual* *template-support-noindent* +Insertion: + + visual - Use the split tag in visual mode (default?). + novisual - No special behavior in visual mode (default?). + + indent - The inserted text is indented (default). + noindent - No automatic indentation. + +Note: "visual" is the default for templates containing the split tag, +"novisual" for templates without the split tag. + +------------------------------------------------------------------------------ + *template-support-sc* *template-support-nomenu* + *template-support-shortcut* *template-support-expandmenu* + *template-support-map* +Menus and Maps: + + nomenu - No menu entry is created. + expandmenu - A submenu is created for this template with entries matching + those of a given list. + sc: - A shortcut is created for the menu entry of this template. + shortcut: - Long version of sc:. + map: - A map is created for this template. + +Note: The default is for a menu entry to be created. +Note: A shortcut can only be one character long. A map can be several +characters long. It is always preceded by the local mapleader. + +------------------------------------------------------------------------------ +C.2 LISTS *template-support-opt-list* +------------------------------------------------------------------------------ + +The list options appear in the head of the list: + == List: OutputModifiers == == ~ + +It is not required to specify any options. The defaults are given below. + +------------------------------------------------------------------------------ + *template-support-list* *template-support-dict* + *template-support-hash* *template-support-dictionary* +Type: + + list - The object is given as a list. (default) + hash - The object is a hash, or dictionary. + dict - Same as hash. + dictionary - Same as hash. + +For a description see |template-support-syntax-list|. + +------------------------------------------------------------------------------ + *template-support-bare* +Interpretation: + + bare - The list is interpreted as a bare list. Each line is considered to be + a new entry. + +Note: Bare list are not the default. + +============================================================================== +vim:tw=78:noet:ts=2:ft=help:norl: diff --git a/ftplugin/c.vim b/ftplugin/c.vim index 16344da..f53cb25 100644 --- a/ftplugin/c.vim +++ b/ftplugin/c.vim @@ -5,7 +5,6 @@ " Language : C / C++ " Plugin : c.vim " Maintainer : Fritz Mehner -" Revision : $Id: c.vim,v 1.71 2011/12/27 21:04:33 mehner Exp $ " " ------------------------------------------------------------------------------ " @@ -16,451 +15,8 @@ if exists("b:did_C_ftplugin") endif let b:did_C_ftplugin = 1 " -" ---------- system installation or local installation ---------- -" -let s:installation = 'local' -if match( expand(""), escape( $VIM, ' \' ) ) == 0 - let s:installation = 'system' -endif -" -" ---------- Do we have a mapleader other than '\' ? ------------ -" -if exists("g:C_MapLeader") - let maplocalleader = g:C_MapLeader -endif -" -" ---------- C/C++ dictionary ----------------------------------- -" This will enable keyword completion for C and C++ -" using Vim's dictionary feature |i_CTRL-X_CTRL-K|. -" Set the new dictionaries in front of the existing ones -" -if exists("g:C_Dictionary_File") - let save=&dictionary - silent! exe 'setlocal dictionary='.g:C_Dictionary_File - silent! exe 'setlocal dictionary+='.save -endif -" -" ---------- F-key mappings ------------------------------------ -" -" Alt-F9 write buffer and compile -" F9 compile and link -" Ctrl-F9 run executable -" Shift-F9 command line arguments -" - map :call C_Compile():call C_HlMessage() -imap :call C_Compile():call C_HlMessage() -" - map :call C_Link():call C_HlMessage() -imap :call C_Link():call C_HlMessage() -" - map :call C_Run() -imap :call C_Run() -" - map :call C_Arguments() -imap :call C_Arguments() -" -" ---------- alternate file plugin (a.vim) ---------------------- -" -if exists("loaded_alternateFile") - map :A -imap :A -endif -" -command! -nargs=1 -complete=customlist,C_CFileSectionList CFileSection call C_CFileSectionListInsert () -command! -nargs=1 -complete=customlist,C_HFileSectionList HFileSection call C_HFileSectionListInsert () -command! -nargs=1 -complete=customlist,C_KeywordCommentList KeywordComment call C_KeywordCommentListInsert () -command! -nargs=1 -complete=customlist,C_SpecialCommentList SpecialComment call C_SpecialCommentListInsert () -command! -nargs=1 -complete=customlist,C_StdLibraryIncludesList IncludeStdLibrary call C_StdLibraryIncludesInsert () -command! -nargs=1 -complete=customlist,C_C99LibraryIncludesList IncludeC99Library call C_C99LibraryIncludesInsert () -command! -nargs=1 -complete=customlist,C_CppLibraryIncludesList IncludeCppLibrary call C_CppLibraryIncludesInsert () -command! -nargs=1 -complete=customlist,C_CppCLibraryIncludesList IncludeCppCLibrary call C_CppCLibraryIncludesInsert() -command! -nargs=1 -complete=customlist,C_StyleList CStyle call C_Style () - -" ---------- KEY MAPPINGS : MENU ENTRIES ------------------------------------- -" ---------- comments menu ------------------------------------------------ -" - noremap cl :call C_EndOfLineComment() -inoremap cl :call C_EndOfLineComment() -vnoremap cl :call C_EndOfLineComment() -" -nnoremap cj :call C_AdjustLineEndComm() -vnoremap cj :call C_AdjustLineEndComm() -inoremap cj :call C_AdjustLineEndComm()a -" - noremap cs :call C_GetLineEndCommCol() - - noremap c* :call C_CodeToCommentC():nohlsearchj -vnoremap c* :call C_CodeToCommentC():nohlsearchj - - noremap cc :call C_CodeToCommentCpp():nohlsearchj -vnoremap cc :call C_CodeToCommentCpp():nohlsearchj - noremap co :call C_CommentToCode():nohlsearch -vnoremap co :call C_CommentToCode():nohlsearch - - noremap cfr :call C_InsertTemplate("comment.frame") - noremap cfu :call C_InsertTemplate("comment.function") - noremap cme :call C_InsertTemplate("comment.method") - noremap ccl :call C_InsertTemplate("comment.class") - noremap cfdi :call C_InsertTemplate("comment.file-description") - noremap cfdh :call C_InsertTemplate("comment.file-description-header") - -inoremap cfr :call C_InsertTemplate("comment.frame") -inoremap cfu :call C_InsertTemplate("comment.function") -inoremap cme :call C_InsertTemplate("comment.method") -inoremap ccl :call C_InsertTemplate("comment.class") -inoremap cfdi :call C_InsertTemplate("comment.file-description") -inoremap cfdh :call C_InsertTemplate("comment.file-description-header") - - noremap cd :call C_InsertDateAndTime('d') -inoremap cd :call C_InsertDateAndTime('d')a -vnoremap cd s:call C_InsertDateAndTime('d')a - noremap ct :call C_InsertDateAndTime('dt') -inoremap ct :call C_InsertDateAndTime('dt')a -vnoremap ct s:call C_InsertDateAndTime('dt')a -" - noremap cx :call C_CommentToggle( ) -inoremap cx :call C_CommentToggle( ) -vnoremap cx :call C_CommentToggle( ) -" -" call the above defined commands: -" - noremap ccs :CFileSection - noremap chs :HFileSection - noremap ckc :KeywordComment - noremap csc :SpecialComment -" -inoremap ccs :CFileSection -inoremap chs :HFileSection -inoremap ckc :KeywordComment -inoremap csc :SpecialComment -" -" ---------- statements menu ------------------------------------------------ -" - noremap sd :call C_InsertTemplate("statements.do-while") -vnoremap sd :call C_InsertTemplate("statements.do-while", "v") -inoremap sd :call C_InsertTemplate("statements.do-while") - - noremap sf :call C_InsertTemplate("statements.for") -inoremap sf :call C_InsertTemplate("statements.for") - - noremap sfo :call C_InsertTemplate("statements.for-block") -vnoremap sfo :call C_InsertTemplate("statements.for-block", "v") -inoremap sfo :call C_InsertTemplate("statements.for-block") - - noremap si :call C_InsertTemplate("statements.if") -inoremap si :call C_InsertTemplate("statements.if") - - noremap sif :call C_InsertTemplate("statements.if-block") -vnoremap sif :call C_InsertTemplate("statements.if-block", "v") -inoremap sif :call C_InsertTemplate("statements.if-block") - - noremap sie :call C_InsertTemplate("statements.if-else") -vnoremap sie :call C_InsertTemplate("statements.if-else", "v") -inoremap sie :call C_InsertTemplate("statements.if-else") - - noremap sife :call C_InsertTemplate("statements.if-block-else") -vnoremap sife :call C_InsertTemplate("statements.if-block-else", "v") -inoremap sife :call C_InsertTemplate("statements.if-block-else") - - noremap se :call C_InsertTemplate("statements.else-block") -vnoremap se :call C_InsertTemplate("statements.else-block", "v") -inoremap se :call C_InsertTemplate("statements.else-block") - - noremap sw :call C_InsertTemplate("statements.while") -inoremap sw :call C_InsertTemplate("statements.while") - - noremap swh :call C_InsertTemplate("statements.while-block") -vnoremap swh :call C_InsertTemplate("statements.while-block", "v") -inoremap swh :call C_InsertTemplate("statements.while-block") - - noremap ss :call C_InsertTemplate("statements.switch") -vnoremap ss :call C_InsertTemplate("statements.switch", "v") -inoremap ss :call C_InsertTemplate("statements.switch") - - noremap sc :call C_InsertTemplate("statements.case") -inoremap sc :call C_InsertTemplate("statements.case") - - noremap s{ :call C_InsertTemplate("statements.block") -vnoremap s{ :call C_InsertTemplate("statements.block", "v") -inoremap s{ :call C_InsertTemplate("statements.block") - - noremap sb :call C_InsertTemplate("statements.block") -vnoremap sb :call C_InsertTemplate("statements.block", "v") -inoremap sb :call C_InsertTemplate("statements.block") -" -" ---------- preprocessor menu ---------------------------------------------- -" - noremap ps :IncludeStdLibrary -inoremap ps :IncludeStdLibrary - noremap pc :IncludeC99Library -inoremap pc :IncludeC99Library - noremap +ps :IncludeCppLibrary -inoremap +ps :IncludeCppLibrary - noremap +pc :IncludeCppCLibrary -inoremap +pc :IncludeCppC9Library -" - noremap p< :call C_InsertTemplate("preprocessor.include-global") - noremap p" :call C_InsertTemplate("preprocessor.include-local") - noremap pd :call C_InsertTemplate("preprocessor.define") - noremap pu :call C_InsertTemplate("preprocessor.undefine") -" -inoremap p< :call C_InsertTemplate("preprocessor.include-global") -inoremap p" :call C_InsertTemplate("preprocessor.include-local") -inoremap pd :call C_InsertTemplate("preprocessor.define") -inoremap pu :call C_InsertTemplate("preprocessor.undefine") - - noremap pif :call C_InsertTemplate("preprocessor.if-endif") - noremap pie :call C_InsertTemplate("preprocessor.if-else-endif") - noremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif") - noremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif") - noremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif") - -vnoremap pif :call C_InsertTemplate("preprocessor.if-endif", "v") -vnoremap pie :call C_InsertTemplate("preprocessor.if-else-endif", "v") -vnoremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif", "v") -vnoremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif", "v") -vnoremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif", "v") - -inoremap pif :call C_InsertTemplate("preprocessor.if-endif") -inoremap pie :call C_InsertTemplate("preprocessor.if-else-endif") -inoremap pid :call C_InsertTemplate("preprocessor.ifdef-else-endif") -inoremap pin :call C_InsertTemplate("preprocessor.ifndef-else-endif") -inoremap pind :call C_InsertTemplate("preprocessor.ifndef-def-endif") - - noremap pi0 :call C_PPIf0("a")2ji -inoremap pi0 :call C_PPIf0("a")2ji -vnoremap pi0 :call C_PPIf0("v") - - noremap pr0 :call C_PPIf0Remove() -inoremap pr0 :call C_PPIf0Remove() -" - noremap pe :call C_InsertTemplate("preprocessor.error") - noremap pl :call C_InsertTemplate("preprocessor.line") - noremap pp :call C_InsertTemplate("preprocessor.pragma") -" -inoremap pe :call C_InsertTemplate("preprocessor.error") -inoremap pl :call C_InsertTemplate("preprocessor.line") -inoremap pp :call C_InsertTemplate("preprocessor.pragma") -" -" ---------- idioms menu ---------------------------------------------------- -" - noremap if :call C_InsertTemplate("idioms.function") -vnoremap if :call C_InsertTemplate("idioms.function", "v") -inoremap if :call C_InsertTemplate("idioms.function") - noremap isf :call C_InsertTemplate("idioms.function-static") -vnoremap isf :call C_InsertTemplate("idioms.function-static", "v") -inoremap isf :call C_InsertTemplate("idioms.function-static") - noremap im :call C_InsertTemplate("idioms.main") -vnoremap im :call C_InsertTemplate("idioms.main", "v") -inoremap im :call C_InsertTemplate("idioms.main") -" - noremap i0 :call C_CodeFor("up" ) -vnoremap i0 :call C_CodeFor("up" ) -inoremap i0 :call C_CodeFor("up" )i - noremap in :call C_CodeFor("down") -vnoremap in :call C_CodeFor("down") -inoremap in :call C_CodeFor("down")i -" - noremap ie :call C_InsertTemplate("idioms.enum") -vnoremap ie :call C_InsertTemplate("idioms.enum" , "v") -inoremap ie :call C_InsertTemplate("idioms.enum") - noremap is :call C_InsertTemplate("idioms.struct") -vnoremap is :call C_InsertTemplate("idioms.struct", "v") -inoremap is :call C_InsertTemplate("idioms.struct") - noremap iu :call C_InsertTemplate("idioms.union") -vnoremap iu :call C_InsertTemplate("idioms.union" , "v") -inoremap iu :call C_InsertTemplate("idioms.union") -" - noremap ip :call C_InsertTemplate("idioms.printf") -inoremap ip :call C_InsertTemplate("idioms.printf") - noremap isc :call C_InsertTemplate("idioms.scanf") -inoremap isc :call C_InsertTemplate("idioms.scanf") -" - noremap ica :call C_InsertTemplate("idioms.calloc") -inoremap ica :call C_InsertTemplate("idioms.calloc") - noremap ima :call C_InsertTemplate("idioms.malloc") -inoremap ima :call C_InsertTemplate("idioms.malloc") - noremap ire :call C_InsertTemplate("idioms.realloc") -inoremap ire :call C_InsertTemplate("idioms.realloc") -" - noremap isi :call C_InsertTemplate("idioms.sizeof") -inoremap isi :call C_InsertTemplate("idioms.sizeof") -vnoremap isi :call C_InsertTemplate("idioms.sizeof", "v") - - noremap ias :call C_InsertTemplate("idioms.assert") -vnoremap ias :call C_InsertTemplate("idioms.assert", "v") -inoremap ias :call C_InsertTemplate("idioms.assert") -" - noremap ii :call C_InsertTemplate("idioms.open-input-file") -inoremap ii :call C_InsertTemplate("idioms.open-input-file") -vnoremap ii :call C_InsertTemplate("idioms.open-input-file", "v") - noremap io :call C_InsertTemplate("idioms.open-output-file") -inoremap io :call C_InsertTemplate("idioms.open-output-file") -vnoremap io :call C_InsertTemplate("idioms.open-output-file", "v") -" - noremap ifs :call C_InsertTemplate("idioms.fscanf") -inoremap ifs :call C_InsertTemplate("idioms.fscanf") - noremap ifp :call C_InsertTemplate("idioms.fprintf") -inoremap ifp :call C_InsertTemplate("idioms.fprintf") -" -" ---------- snippet menu : snippets ----------------------------------------- -" - noremap nr :call C_CodeSnippet("r") - noremap nw :call C_CodeSnippet("w") -vnoremap nw :call C_CodeSnippet("wv") - noremap ne :call C_CodeSnippet("e") -" -inoremap nr :call C_CodeSnippet("r") -inoremap nw :call C_CodeSnippet("w") -inoremap ne :call C_CodeSnippet("e") -" -" ---------- snippet menu : prototypes --------------------------------------- -" - noremap np :call C_ProtoPick("function") -vnoremap np :call C_ProtoPick("function") -inoremap np :call C_ProtoPick("function") -" - noremap nf :call C_ProtoPick("function") -vnoremap nf :call C_ProtoPick("function") -inoremap nf :call C_ProtoPick("function") -" - noremap nm :call C_ProtoPick("method") -vnoremap nm :call C_ProtoPick("method") -inoremap nm :call C_ProtoPick("method") -" - noremap ni :call C_ProtoInsert() -inoremap ni :call C_ProtoInsert() -" - noremap nc :call C_ProtoClear() -inoremap nc :call C_ProtoClear() -" - noremap ns :call C_ProtoShow() -inoremap ns :call C_ProtoShow() -" -" ---------- snippet menu : templates ---------------------------------------- -" - noremap ntl :call C_BrowseTemplateFiles("Local") -inoremap ntl :call C_BrowseTemplateFiles("Local") - if s:installation == 'system' - noremap ntg :call C_BrowseTemplateFiles("Global") - inoremap ntg :call C_BrowseTemplateFiles("Global") - endif - noremap ntr :call C_RereadTemplates() - noremap nts :CStyle -inoremap ntr :call C_RereadTemplates() -inoremap nts :CStyle -" -" ---------- C++ menu ---------------------------------------------------- -" - noremap +" :call C_InsertTemplate("cpp.cout-operator") -inoremap +" :call C_InsertTemplate("cpp.cout-operator") - noremap +co :call C_InsertTemplate("cpp.cout") -inoremap +co :call C_InsertTemplate("cpp.cout") -" - noremap +c :call C_InsertTemplate("cpp.class-definition") -inoremap +c :call C_InsertTemplate("cpp.class-definition") - noremap +cn :call C_InsertTemplate("cpp.class-using-new-definition") -inoremap +cn :call C_InsertTemplate("cpp.class-using-new-definition") - - noremap +ci :call C_InsertTemplate("cpp.class-implementation") -inoremap +ci :call C_InsertTemplate("cpp.class-implementation") - noremap +cni :call C_InsertTemplate("cpp.class-using-new-implementation") -inoremap +cni :call C_InsertTemplate("cpp.class-using-new-implementation") - - noremap +mi :call C_InsertTemplate("cpp.method-implementation") -inoremap +mi :call C_InsertTemplate("cpp.method-implementation") - noremap +ai :call C_InsertTemplate("cpp.accessor-implementation") -inoremap +ai :call C_InsertTemplate("cpp.accessor-implementation") - - noremap +tc :call C_InsertTemplate("cpp.template-class-definition") -inoremap +tc :call C_InsertTemplate("cpp.template-class-definition") - noremap +tcn :call C_InsertTemplate("cpp.template-class-using-new-definition") -inoremap +tcn :call C_InsertTemplate("cpp.template-class-using-new-definition") - - noremap +tci :call C_InsertTemplate("cpp.template-class-implementation") -inoremap +tci :call C_InsertTemplate("cpp.template-class-implementation") - noremap +tcni :call C_InsertTemplate("cpp.template-class-using-new-implementation") -inoremap +tcni :call C_InsertTemplate("cpp.template-class-using-new-implementation") - - noremap +tmi :call C_InsertTemplate("cpp.template-method-implementation") -inoremap +tmi :call C_InsertTemplate("cpp.template-method-implementation") - noremap +tai :call C_InsertTemplate("cpp.template-accessor-implementation") -inoremap +tai :call C_InsertTemplate("cpp.template-accessor-implementation") - - noremap +tf :call C_InsertTemplate("cpp.template-function") -inoremap +tf :call C_InsertTemplate("cpp.template-function") - - noremap +ec :call C_InsertTemplate("cpp.error-class") -inoremap +ec :call C_InsertTemplate("cpp.error-class") - - noremap +tr :call C_InsertTemplate("cpp.try-catch") -vnoremap +tr :call C_InsertTemplate("cpp.try-catch", "v") -inoremap +tr :call C_InsertTemplate("cpp.try-catch") - - noremap +ca :call C_InsertTemplate("cpp.catch") -vnoremap +ca :call C_InsertTemplate("cpp.catch", "v") -inoremap +ca :call C_InsertTemplate("cpp.catch") - - noremap +c. :call C_InsertTemplate("cpp.catch-points") -vnoremap +c. :call C_InsertTemplate("cpp.catch-points", "v") -inoremap +c. :call C_InsertTemplate("cpp.catch-points") -" -" ---------- run menu -------------------------------------------------------- -" - map rc :call C_Compile():call C_HlMessage() - map rl :call C_Link():call C_HlMessage() - map rr :call C_Run() - map ra :call C_Arguments() - map rm :call C_Make() - map rcm :call C_ChooseMakefile() - map rmc :call C_MakeClean() - map rme :call C_MakeExeToRun() - map rma :call C_MakeArguments() - map rp :call C_SplintCheck():call C_HlMessage() - map rpa :call C_SplintArguments() - map rd :call C_Indent() - map rh :call C_Hardcopy() - map rs :call C_Settings() -" -vmap rh :call C_Hardcopy() -" -imap rc :call C_Compile():call C_HlMessage() -imap rl :call C_Link():call C_HlMessage() -imap rr :call C_Run() -imap ra :call C_Arguments() -imap rm :call C_Make() -imap rmc :call C_MakeClean() -imap rme :call C_MakeExeToRun() -imap rma :call C_MakeArguments() -imap rp :call C_SplintCheck():call C_HlMessage() -imap rpa :call C_SplintArguments() -imap rd :call C_Indent() -imap rh :call C_Hardcopy() -imap rs :call C_Settings() - if has("unix") - map rx :call C_XtermSize() - imap rx :call C_XtermSize() - endif - map ro :call C_Toggle_Gvim_Xterm() -imap ro :call C_Toggle_Gvim_Xterm() -" -" Abraxas CodeCheck (R) -" -if executable("check") - map rk :call C_CodeCheck():call C_HlMessage() - map rka :call C_CodeCheckArguments() - imap rk :call C_CodeCheck():call C_HlMessage() - imap rka :call C_CodeCheckArguments() -endif -" ---------- plugin help ----------------------------------------------------- -" - map hp :call C_HelpCsupport() -imap hp :call C_HelpCsupport() - map hm :call C_Help("m") -imap hm :call C_Help("m") -" "------------------------------------------------------------------------------- -" additional mapping : complete a classical C comment: '/*' => '/* | */' +" ADDITIONAL MAPPING : complete a classical C comment: '/*' => '/* | */' "------------------------------------------------------------------------------- inoremap /* /**/ vnoremap /* s/**/p @@ -479,9 +35,3 @@ inoremap /* /*/kA inoremap { {}O vnoremap { S{}Pk=iB " -" -if !exists("g:C_Ctrl_j") || ( exists("g:C_Ctrl_j") && g:C_Ctrl_j != 'off' ) - nmap i=C_JumpCtrlJ() - imap =C_JumpCtrlJ() -endif -" diff --git a/ftplugin/make.vim b/ftplugin/make.vim index 9c35243..40598e0 100644 --- a/ftplugin/make.vim +++ b/ftplugin/make.vim @@ -5,7 +5,6 @@ " Language : make " Plugin : c.vim " Maintainer : Fritz Mehner -" Revision : $Id: make.vim,v 1.4 2011/12/27 21:04:33 mehner Exp $ " " ------------------------------------------------------------------------------ " diff --git a/plugin/c.vim b/plugin/c.vim index 1f57206..d442cfc 100644 --- a/plugin/c.vim +++ b/plugin/c.vim @@ -13,11 +13,11 @@ " (see the files README.csupport and csupport.txt). " " Author: Dr.-Ing. Fritz Mehner, FH Südwestfalen, 58644 Iserlohn, Germany -" Email: mehner@fh-swf.de +" Email: mehner.fritz@fh-swf.de " " Version: see variable g:C_Version below " Created: 04.11.2000 -" License: Copyright (c) 2000-2011, Fritz Mehner +" License: Copyright (c) 2000-2012, Fritz Mehner " This program is free software; you can redistribute it and/or " modify it under the terms of the GNU General Public License as " published by the Free Software Foundation, version 2 of the @@ -27,7 +27,6 @@ " warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR " PURPOSE. " See the GNU General Public License version 2 for more details. -" Revision: $Id: c.vim,v 1.162 2012/02/25 15:15:30 mehner Exp $ " "------------------------------------------------------------------------------ " @@ -41,7 +40,7 @@ endif if exists("g:C_Version") || &cp finish endif -let g:C_Version= "5.17" " version number of this script; do not change +let g:C_Version= "6.0" " version number of this script; do not change " "################################################################################# " @@ -54,7 +53,7 @@ let g:C_Version= "5.17" " version number of this script; do not change let s:MSWIN = has("win16") || has("win32") || has("win64") || has("win95") let s:UNIX = has("unix") || has("macunix") || has("win32unix") " -let s:installation = '*undefined*' +let g:C_Installation = '*undefined*' let s:plugin_dir = '' " let s:C_GlobalTemplateFile = '' @@ -71,14 +70,14 @@ if s:MSWIN \ substitute( expand("$HOME"), '\', '/', 'g' ) ) == 0 " " USER INSTALLATION ASSUMED - let s:installation = 'local' + let g:C_Installation = 'local' let s:plugin_dir = substitute( expand(':p:h:h'), '\', '/', 'g' ) let s:C_LocalTemplateFile = s:plugin_dir.'/c-support/templates/Templates' let s:C_LocalTemplateDir = fnamemodify( s:C_LocalTemplateFile, ":p:h" ).'/' else " " SYSTEM WIDE INSTALLATION - let s:installation = 'system' + let g:C_Installation = 'system' let s:plugin_dir = $VIM.'/vimfiles' let s:C_GlobalTemplateDir = s:plugin_dir.'/c-support/templates' let s:C_GlobalTemplateFile = s:C_GlobalTemplateDir.'/Templates' @@ -91,15 +90,15 @@ if s:MSWIN else " ========== Linux/Unix ====================================================== " - if match( expand(""), expand("$HOME") ) == 0 + if match( expand(""), resolve( expand("$HOME") ) ) == 0 " USER INSTALLATION ASSUMED - let s:installation = 'local' + let g:C_Installation = 'local' let s:plugin_dir = expand(':p:h:h') let s:C_LocalTemplateFile = s:plugin_dir.'/c-support/templates/Templates' let s:C_LocalTemplateDir = fnamemodify( s:C_LocalTemplateFile, ":p:h" ).'/' else " SYSTEM WIDE INSTALLATION - let s:installation = 'system' + let g:C_Installation = 'system' let s:plugin_dir = $VIM.'/vimfiles' let s:C_GlobalTemplateDir = s:plugin_dir.'/c-support/templates' let s:C_GlobalTemplateFile = s:C_GlobalTemplateDir.'/Templates' @@ -141,32 +140,38 @@ else endif let s:C_VimCompilerName = 'gcc' " the compiler name used by :compiler " +let s:C_CFlags = '-Wall -g -O0 -c' " C compiler flags: compile, don't optimize +let s:C_LFlags = '-Wall -g -O0' " C compiler flags: link , don't optimize +let s:C_Libs = '-lm' " C libraries to use +" +let s:C_CplusCFlags = '-Wall -g -O0 -c' " C++ compiler flags: compile, don't optimize +let s:C_CplusLFlags = '-Wall -g -O0' " C++ compiler flags: link , don't optimize +let s:C_CplusLibs = '-lm' " C++ libraries to use +" let s:C_CExtension = 'c' " C file extension; everything else is C++ -let s:C_CFlags = '-Wall -g -O0 -c' " compiler flags: compile, don't optimize let s:C_CodeCheckExeName = 'check' let s:C_CodeCheckOptions = '-K13' -let s:C_LFlags = '-Wall -g -O0' " compiler flags: link , don't optimize -let s:C_Libs = '-lm' " libraries to use let s:C_LineEndCommColDefault = 49 let s:C_LoadMenus = 'yes' -let s:C_CreateMenusDelayed = 'no' +let s:C_CreateMenusDelayed = 'no' let s:C_MenuHeader = 'yes' let s:C_OutputGvim = 'vim' let s:C_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N" -let s:C_Root = '&C\/C\+\+.' " the name of the root menu of this plugin +let s:C_RootMenu = '&C\/C\+\+.' " the name of the root menu of this plugin let s:C_TypeOfH = 'cpp' let s:C_Wrapper = s:plugin_dir.'/c-support/scripts/wrapper.sh' let s:C_XtermDefaults = '-fa courier -fs 12 -geometry 80x24' let s:C_GuiSnippetBrowser = 'gui' " gui / commandline let s:C_GuiTemplateBrowser = 'gui' " gui / explorer / commandline " -let s:C_TemplateOverriddenMsg = 'no' let s:C_Ctrl_j = 'on' " let s:C_FormatDate = '%x' let s:C_FormatTime = '%X' let s:C_FormatYear = '%Y' let s:C_SourceCodeExtensions = 'c cc cp cxx cpp CPP c++ C i ii' +let g:C_MapLeader = '\' +let s:C_CppcheckSeverity = 'all' " "------------------------------------------------------------------------------ " @@ -181,6 +186,11 @@ endfunction " ---------- end of function C_CheckGlobal ---------- call C_CheckGlobal('C_CCompiler ') call C_CheckGlobal('C_CExtension ') call C_CheckGlobal('C_CFlags ') +call C_CheckGlobal('C_LFlags ') +call C_CheckGlobal('C_Libs ') +call C_CheckGlobal('C_CplusCFlags ') +call C_CheckGlobal('C_CplusLFlags ') +call C_CheckGlobal('C_CplusLibs ') call C_CheckGlobal('C_CodeCheckExeName ') call C_CheckGlobal('C_CodeCheckOptions ') call C_CheckGlobal('C_CodeSnippets ') @@ -195,8 +205,6 @@ call C_CheckGlobal('C_GlobalTemplateFile ') call C_CheckGlobal('C_GuiSnippetBrowser ') call C_CheckGlobal('C_GuiTemplateBrowser ') call C_CheckGlobal('C_IndentErrorLog ') -call C_CheckGlobal('C_LFlags ') -call C_CheckGlobal('C_Libs ') call C_CheckGlobal('C_LineEndCommColDefault') call C_CheckGlobal('C_LoadMenus ') call C_CheckGlobal('C_LocalTemplateFile ') @@ -205,9 +213,8 @@ call C_CheckGlobal('C_MenuHeader ') call C_CheckGlobal('C_ObjExtension ') call C_CheckGlobal('C_OutputGvim ') call C_CheckGlobal('C_Printheader ') -call C_CheckGlobal('C_Root ') +call C_CheckGlobal('C_RootMenu ') call C_CheckGlobal('C_SourceCodeExtensions ') -call C_CheckGlobal('C_TemplateOverriddenMsg') call C_CheckGlobal('C_TypeOfH ') call C_CheckGlobal('C_VimCompilerName ') call C_CheckGlobal('C_XtermDefaults ') @@ -236,61 +243,21 @@ let s:C_HlMessage = "" let s:C_If0_Counter = 0 let s:C_If0_Txt = "If0Label_" " -let s:C_SplintIsExecutable = 0 -if executable( "splint" ) - let s:C_SplintIsExecutable = 1 -endif -" -let s:C_CodeCheckIsExecutable = 0 -if executable( s:C_CodeCheckExeName ) - let s:C_CodeCheckIsExecutable = 1 -endif +let s:C_SplintIsExecutable = executable( "splint" ) +let s:C_CppcheckIsExecutable = executable( "cppcheck" ) +let s:C_CodeCheckIsExecutable = executable( s:C_CodeCheckExeName ) +let s:C_IndentIsExecutable = executable( "indent" ) " "------------------------------------------------------------------------------ " Control variables (not user configurable) "------------------------------------------------------------------------------ -let s:Attribute = { 'below':'', 'above':'', 'start':'', 'append':'', 'insert':'' } -let s:C_Attribute = {} -let s:C_ExpansionLimit = 10 -let s:C_FileVisited = [] -" -let s:C_MacroNameRegex = '\([a-zA-Z][a-zA-Z0-9_]*\)' -let s:C_MacroLineRegex = '^\s*|'.s:C_MacroNameRegex.'|\s*=\s*\(.*\)' -let s:C_MacroCommentRegex = '^\$' -let s:C_ExpansionRegex = '|?'.s:C_MacroNameRegex.'\(:\a\)\?|' -let s:C_NonExpansionRegex = '|'.s:C_MacroNameRegex.'\(:\a\)\?|' -" -let s:C_TemplateNameDelimiter = '-+_,\. ' -let s:C_TemplateLineRegex = '^==\s*\([a-zA-Z][0-9a-zA-Z'.s:C_TemplateNameDelimiter -let s:C_TemplateLineRegex .= ']\+\)\s*==\s*\([a-z]\+\s*==\)\?' -let s:C_TemplateIf = '^==\s*IF\s\+|STYLE|\s\+IS\s\+'.s:C_MacroNameRegex.'\s*==' -let s:C_TemplateEndif = '^==\s*ENDIF\s*==' -" -let s:C_Com1 = '/*' " C-style : comment start -let s:C_Com2 = '*/' " C-style : comment end -" -let s:C_ExpansionCounter = {} -let s:C_TJT = '[ 0-9a-zA-Z_]*' -let s:C_TemplateJumpTarget1 = '<+'.s:C_TJT.'+>\|{+'.s:C_TJT.'+}' -let s:C_TemplateJumpTarget2 = '<-'.s:C_TJT.'->\|{-'.s:C_TJT.'-}' -let s:C_Macro = {'|AUTHOR|' : 'first name surname', - \ '|AUTHORREF|' : '', - \ '|COMPANY|' : '', - \ '|COPYRIGHTHOLDER|': '', - \ '|EMAIL|' : '', - \ '|LICENSE|' : 'GNU General Public License', - \ '|ORGANIZATION|' : '', - \ '|PROJECT|' : '', - \ '|STYLE|' : '' - \ } -let s:C_MacroFlag = { ':l' : 'lowercase' , - \ ':u' : 'uppercase' , - \ ':c' : 'capitalize' , - \ ':L' : 'legalize name' , - \ } -let s:C_ActualStyle = 'default' -let s:C_ActualStyleLast = s:C_ActualStyle -let s:C_Template = { 'default' : {} } +" +let s:C_Com1 = '/*' " C-style : comment start +let s:C_Com2 = '*/' " C-style : comment end +" +let s:C_TJT = '[ 0-9a-zA-Z_]*' +let s:C_TemplateJumpTarget1 = '<+'.s:C_TJT.'+>\|{+'.s:C_TJT.'+}' +let s:C_TemplateJumpTarget2 = '<-'.s:C_TJT.'->\|{-'.s:C_TJT.'-}' let s:C_TemplatesLoaded = 'no' let s:C_ForTypes = [ @@ -314,83 +281,52 @@ let s:C_ForTypes = [ \ 'unsigned short int' , \ ] -let s:C_ForTypes_Check_Order = [ - \ 'char' , - \ 'int' , - \ 'long long int' , - \ 'long long' , - \ 'long int' , - \ 'long' , - \ 'short int' , - \ 'short' , - \ 'size_t' , - \ 'unsigned short int' , - \ 'unsigned short' , - \ 'unsigned long long int', - \ 'unsigned long long' , - \ 'unsigned long int' , - \ 'unsigned long' , - \ 'unsigned int' , - \ 'unsigned char' , - \ 'unsigned' , - \ ] - let s:MsgInsNotAvail = "insertion not available for a fold" -let s:MenuRun = s:C_Root.'&Run' +let s:MenuRun = s:C_RootMenu.'&Run' -"------------------------------------------------------------------------------ +let s:output1 = 'VIM->buffer->xterm' +let s:output2 = 'BUFFER->xterm->vim' +let s:output3 = 'XTERM->vim->buffer' +let s:C_saved_global_option = {} let s:C_SourceCodeExtensionsList = split( s:C_SourceCodeExtensions, '\s\+' ) - -"------------------------------------------------------------------------------ +" +let s:CppcheckSeverity = [ "all", "error", "warning", "style", "performance", "portability", "information" ] +" +"=== FUNCTION ================================================================ +" NAME: C_MenuTitle {{{1 +" DESCRIPTION: display warning +" PARAMETERS: - +" RETURNS: +"=============================================================================== +function! C_MenuTitle () + echohl WarningMsg | echo "This is a menu header." | echohl None +endfunction " ---------- end of function C_MenuTitle ---------- "------------------------------------------------------------------------------ " C : C_InitMenus {{{1 " Initialization of C support menus "------------------------------------------------------------------------------ " -function! C_InitMenus () -" -" the menu names -" - let MenuComments = s:C_Root.'&Comments' - let MenuStatements = s:C_Root.'&Statements' - let MenuIdioms = s:C_Root.'&Idioms' - let MenuPreprocessor = s:C_Root.'&Preprocessor' - let MenuSnippets = s:C_Root.'S&nippets' - let MenuCpp = s:C_Root.'C&++' - " - "=============================================================================================== - "----- Menu : C main menu entry ------------------------------------------- {{{2 - "=============================================================================================== +function! s:C_InitMenus () " - if s:C_MenuHeader == 'yes' - exe "amenu ".s:C_Root.'C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".s:C_Root.'-Sep00- ' - exe "amenu ".MenuComments.'.&CommentsC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuComments.'.-Sep00- ' - exe "amenu ".MenuStatements.'.&StatementsC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuStatements.'.-Sep00- ' - exe "amenu ".MenuIdioms.'.&IdiomsC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuIdioms.'.-Sep00- ' - exe "amenu ".MenuPreprocessor.'.&PreprocessorC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuPreprocessor.'.-Sep00- ' - exe "amenu ".MenuPreprocessor.'.#include\ &Std\.Lib\.\\ps.Std\.Lib\.C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuPreprocessor.'.#include\ &Std\.Lib\.\\ps.-Sep0- ' - exe "amenu ".MenuPreprocessor.'.#include\ C&99\\pc.C99C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuPreprocessor.'.#include\ C&99\\pc.-Sep0- ' - exe "amenu ".MenuSnippets.'.S&nippetsC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuSnippets.'.-Sep00- ' - exe "amenu ".MenuCpp.'.C&\+\+C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuCpp.'.-Sep00- ' - exe "amenu ".s:MenuRun.'.&RunC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".s:MenuRun.'.-Sep00- ' + if ! has ( 'menu' ) + return endif " + " Preparation + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'do_reset' ) + " + exe 'amenu '.s:C_RootMenu.'C\/C\+\+ ' + exe 'amenu '.s:C_RootMenu.'-Sep00- ' +" "=============================================================================================== "----- Menu : C-Comments -------------------------------------------------- {{{2 "=============================================================================================== " + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'sub_menu', '&Comments' ) + let MenuComments = s:C_RootMenu.'&Comments' + " exe "amenu ".MenuComments.'.end-of-&line\ comment\\cl :call C_EndOfLineComment( )' exe "vmenu ".MenuComments.'.end-of-&line\ comment\\cl :call C_EndOfLineComment( )' @@ -408,631 +344,172 @@ function! C_InitMenus () exe "vmenu ".MenuComments.'.c&omment\ ->\ code\\co :call C_CommentToCode():nohlsearch' exe "amenu ".MenuComments.'.-SEP0- :' - exe "amenu ".MenuComments.'.&frame\ comment\\cfr :call C_InsertTemplate("comment.frame")' - exe "amenu ".MenuComments.'.f&unction\ description\\cfu :call C_InsertTemplate("comment.function")' - exe "amenu ".MenuComments.'.-SEP1- :' - exe "amenu ".MenuComments.'.&method\ description\\cme :call C_InsertTemplate("comment.method")' - exe "amenu ".MenuComments.'.cl&ass\ description\\ccl :call C_InsertTemplate("comment.class")' - exe "amenu ".MenuComments.'.-SEP2- :' - exe "amenu ".MenuComments.'.file\ description\ \(impl\.\)\\cfdi :call C_InsertTemplate("comment.file-description")' - exe "amenu ".MenuComments.'.file\ description\ \(header\)\\cfdh :call C_InsertTemplate("comment.file-description-header")' - exe "amenu ".MenuComments.'.-SEP3- :' - " - "----- Submenu : C-Comments : file sections ------------------------------------------------------------- - " - if s:C_MenuHeader == 'yes' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.file\ sectionsC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.-Sep0- ' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.H-file\ sectionsC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.-Sep0- ' - exe "amenu ".MenuComments.'.-SEP4- :' - exe "amenu ".MenuComments.'.&keyword\ comm\.\\ckc.keyw\.+comm\.C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuComments.'.&keyword\ comm\.\\ckc.-Sep0- ' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.special\ comm\.C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.-Sep0- ' - exe "amenu ".MenuComments.'.ta&gs\ (plugin).tags\ (plugin)C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuComments.'.ta&gs\ (plugin).-Sep0- ' - endif - " - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.&Header\ File\ Includes :call C_InsertTemplate("comment.file-section-cpp-header-includes")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.Local\ &Macros :call C_InsertTemplate("comment.file-section-cpp-macros")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.Local\ &Type\ Def\. :call C_InsertTemplate("comment.file-section-cpp-typedefs")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.Local\ &Data\ Types :call C_InsertTemplate("comment.file-section-cpp-data-types")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.Local\ &Variables :call C_InsertTemplate("comment.file-section-cpp-local-variables")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.Local\ &Prototypes :call C_InsertTemplate("comment.file-section-cpp-prototypes")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.&Exp\.\ Function\ Def\. :call C_InsertTemplate("comment.file-section-cpp-function-defs-exported")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.&Local\ Function\ Def\. :call C_InsertTemplate("comment.file-section-cpp-function-defs-local")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.-SEP6- :' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.Local\ &Class\ Def\. :call C_InsertTemplate("comment.file-section-cpp-class-defs")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.E&xp\.\ Class\ Impl\. :call C_InsertTemplate("comment.file-section-cpp-class-implementations-exported")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.L&ocal\ Class\ Impl\. :call C_InsertTemplate("comment.file-section-cpp-class-implementations-local")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.-SEP7- :' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.&All\ sections,\ C :call C_Comment_C_SectionAll("c")' - exe "amenu ".MenuComments.'.&C\/C\+\+-file\ sections\\ccs.All\ §ions,\ C++ :call C_Comment_C_SectionAll("cpp")' - " - "----- Submenu : H-Comments : file sections ------------------------------------------------------------- - " - "' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.&Header\ File\ Includes :call C_InsertTemplate("comment.file-section-hpp-header-includes")' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.Exported\ &Macros :call C_InsertTemplate("comment.file-section-hpp-macros")' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.Exported\ &Type\ Def\. :call C_InsertTemplate("comment.file-section-hpp-exported-typedefs")' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.Exported\ &Data\ Types :call C_InsertTemplate("comment.file-section-hpp-exported-data-types")' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.Exported\ &Variables :call C_InsertTemplate("comment.file-section-hpp-exported-variables")' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.Exported\ &Funct\.\ Decl\. :call C_InsertTemplate("comment.file-section-hpp-exported-function-declarations")' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.-SEP4- :' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.E&xported\ Class\ Def\. :call C_InsertTemplate("comment.file-section-hpp-exported-class-defs")' - - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.-SEP5- :' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.&All\ sections,\ C :call C_Comment_H_SectionAll("c")' - exe "amenu ".MenuComments.'.&H-file\ sections\\chs.All\ §ions,\ C++ :call C_Comment_H_SectionAll("cpp")' - " - exe "amenu ".MenuComments.'.-SEP8- :' - " - "----- Submenu : C-Comments : keyword comments ---------------------------------------------------------- - " -" - exe "amenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&BUG\: $:call C_InsertTemplate("comment.keyword-bug")' - exe "amenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&COMPILER\: $:call C_InsertTemplate("comment.keyword-compiler")' - exe "amenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&TODO\: $:call C_InsertTemplate("comment.keyword-todo")' - exe "amenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&WARNING\: $:call C_InsertTemplate("comment.keyword-warning")' - exe "amenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:W&ORKAROUND\: $:call C_InsertTemplate("comment.keyword-workaround")' - exe "amenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&new\ keyword\: $:call C_InsertTemplate("comment.keyword-keyword")' -" - exe "imenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&BUG\: $:call C_InsertTemplate("comment.keyword-bug")' - exe "imenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&COMPILER\: $:call C_InsertTemplate("comment.keyword-compiler")' - exe "imenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&TODO\: $:call C_InsertTemplate("comment.keyword-todo")' - exe "imenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&WARNING\: $:call C_InsertTemplate("comment.keyword-warning")' - exe "imenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:W&ORKAROUND\: $:call C_InsertTemplate("comment.keyword-workaround")' - exe "imenu ".MenuComments.'.&keyword\ comm\.\\ckc.\:&new\ keyword\: $:call C_InsertTemplate("comment.keyword-keyword")' - " - "----- Submenu : C-Comments : special comments ---------------------------------------------------------- - " - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.&EMPTY $:call C_InsertTemplate("comment.special-empty")' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.&FALL\ THROUGH $:call C_InsertTemplate("comment.special-fall-through") ' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.&IMPL\.\ TYPE\ CONV $:call C_InsertTemplate("comment.special-implicit-type-conversion") ' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.&NO\ RETURN $:call C_InsertTemplate("comment.special-no-return") ' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.NOT\ &REACHED $:call C_InsertTemplate("comment.special-not-reached") ' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.&TO\ BE\ IMPL\. $:call C_InsertTemplate("comment.special-remains-to-be-implemented")' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.-SEP81- :' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.constant\ type\ is\ &long\ (L) $:call C_InsertTemplate("comment.special-constant-type-is-long")' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.constant\ type\ is\ &unsigned\ (U) $:call C_InsertTemplate("comment.special-constant-type-is-unsigned")' - exe "amenu ".MenuComments.'.&special\ comm\.\\csc.constant\ type\ is\ unsigned\ l&ong\ (UL) $:call C_InsertTemplate("comment.special-constant-type-is-unsigned-long")' - " - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.&EMPTY $:call C_InsertTemplate("comment.special-empty")' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.&FALL\ THROUGH $:call C_InsertTemplate("comment.special-fall-through") ' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.&IMPL\.\ TYPE\ CONV $:call C_InsertTemplate("comment.special-implicit-type-conversion") ' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.&NO\ RETURN $:call C_InsertTemplate("comment.special-no-return") ' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.NOT\ &REACHED $:call C_InsertTemplate("comment.special-not-reached") ' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.&TO\ BE\ IMPL\. $:call C_InsertTemplate("comment.special-remains-to-be-implemented")' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.-SEP81- :' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.constant\ type\ is\ &long\ (L) $:call C_InsertTemplate("comment.special-constant-type-is-long")' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.constant\ type\ is\ &unsigned\ (U) $:call C_InsertTemplate("comment.special-constant-type-is-unsigned")' - exe "imenu ".MenuComments.'.&special\ comm\.\\csc.constant\ type\ is\ unsigned\ l&ong\ (UL) $:call C_InsertTemplate("comment.special-constant-type-is-unsigned-long")' - " - "----- Submenu : C-Comments : Tags ---------------------------------------------------------- - " - " - exe "anoremenu ".MenuComments.'.ta&gs\ (plugin).&AUTHOR :call C_InsertMacroValue("AUTHOR")' - exe "anoremenu ".MenuComments.'.ta&gs\ (plugin).&AUTHORREF :call C_InsertMacroValue("AUTHORREF")' - exe "anoremenu ".MenuComments.'.ta&gs\ (plugin).&COMPANY :call C_InsertMacroValue("COMPANY")' - exe "anoremenu ".MenuComments.'.ta&gs\ (plugin).©RIGHTHOLDER :call C_InsertMacroValue("COPYRIGHTHOLDER")' - exe "anoremenu ".MenuComments.'.ta&gs\ (plugin).&EMAIL :call C_InsertMacroValue("EMAIL")' - exe "anoremenu ".MenuComments.'.ta&gs\ (plugin).&LICENSE :call C_InsertMacroValue("LICENSE")' - exe "anoremenu ".MenuComments.'.ta&gs\ (plugin).&ORGANIZATION :call C_InsertMacroValue("ORGANIZATION")' - exe "anoremenu ".MenuComments.'.ta&gs\ (plugin).&PROJECT :call C_InsertMacroValue("PROJECT")' - " - exe "inoremenu ".MenuComments.'.ta&gs\ (plugin).&AUTHOR :call C_InsertMacroValue("AUTHOR")a' - exe "inoremenu ".MenuComments.'.ta&gs\ (plugin).&AUTHORREF :call C_InsertMacroValue("AUTHORREF")a' - exe "inoremenu ".MenuComments.'.ta&gs\ (plugin).&COMPANY :call C_InsertMacroValue("COMPANY")a' - exe "inoremenu ".MenuComments.'.ta&gs\ (plugin).©RIGHTHOLDER :call C_InsertMacroValue("COPYRIGHTHOLDER")a' - exe "inoremenu ".MenuComments.'.ta&gs\ (plugin).&EMAIL :call C_InsertMacroValue("EMAIL")a' - exe "inoremenu ".MenuComments.'.ta&gs\ (plugin).&LICENSE :call C_InsertMacroValue("LICENSE")a' - exe "inoremenu ".MenuComments.'.ta&gs\ (plugin).&ORGANIZATION :call C_InsertMacroValue("ORGANIZATION")a' - exe "inoremenu ".MenuComments.'.ta&gs\ (plugin).&PROJECT :call C_InsertMacroValue("PROJECT")a' - " - exe "vnoremenu ".MenuComments.'.ta&gs\ (plugin).&AUTHOR s:call C_InsertMacroValue("AUTHOR")a' - exe "vnoremenu ".MenuComments.'.ta&gs\ (plugin).&AUTHORREF s:call C_InsertMacroValue("AUTHORREF")a' - exe "vnoremenu ".MenuComments.'.ta&gs\ (plugin).&COMPANY s:call C_InsertMacroValue("COMPANY")a' - exe "vnoremenu ".MenuComments.'.ta&gs\ (plugin).©RIGHTHOLDER s:call C_InsertMacroValue("COPYRIGHTHOLDER")a' - exe "vnoremenu ".MenuComments.'.ta&gs\ (plugin).&EMAIL s:call C_InsertMacroValue("EMAIL")a' - exe "vnoremenu ".MenuComments.'.ta&gs\ (plugin).&LICENSE s:call C_InsertMacroValue("LICENSE")a' - exe "vnoremenu ".MenuComments.'.ta&gs\ (plugin).&ORGANIZATION s:call C_InsertMacroValue("ORGANIZATION")a' - exe "vnoremenu ".MenuComments.'.ta&gs\ (plugin).&PROJECT s:call C_InsertMacroValue("PROJECT")a' - " - exe " menu ".MenuComments.'.&date\\cd :call C_InsertDateAndTime("d")' - exe "imenu ".MenuComments.'.&date\\cd :call C_InsertDateAndTime("d")a' - exe "vmenu ".MenuComments.'.&date\\cd s:call C_InsertDateAndTime("d")a' - exe " menu ".MenuComments.'.date\ &time\\ct :call C_InsertDateAndTime("dt")' - exe "imenu ".MenuComments.'.date\ &time\\ct :call C_InsertDateAndTime("dt")a' - exe "vmenu ".MenuComments.'.date\ &time\\ct s:call C_InsertDateAndTime("dt")a' - - exe "amenu ".MenuComments.'.-SEP12- :' - exe "amenu ".MenuComments.'.\/*\ &xxx\ *\/\ \ <->\ \ \/\/\ xxx\\cx :call C_CommentToggle()' - exe "vmenu ".MenuComments.'.\/*\ &xxx\ *\/\ \ <->\ \ \/\/\ xxx\\cx :call C_CommentToggle()' - " - "=============================================================================================== - "----- Menu : C-Statements------------------------------------------------- {{{2 - "=============================================================================================== - " - exe "amenu ".MenuStatements.'.&do\ \{\ \}\ while\\sd :call C_InsertTemplate("statements.do-while")' - exe "vmenu ".MenuStatements.'.&do\ \{\ \}\ while\\sd :call C_InsertTemplate("statements.do-while", "v")' - exe "imenu ".MenuStatements.'.&do\ \{\ \}\ while\\sd :call C_InsertTemplate("statements.do-while")' - " - exe "amenu ".MenuStatements.'.f&or\\sf :call C_InsertTemplate("statements.for")' - exe "imenu ".MenuStatements.'.f&or\\sf :call C_InsertTemplate("statements.for")' - " - exe "amenu ".MenuStatements.'.fo&r\ \{\ \}\\sfo :call C_InsertTemplate("statements.for-block")' - exe "vmenu ".MenuStatements.'.fo&r\ \{\ \}\\sfo :call C_InsertTemplate("statements.for-block", "v")' - exe "imenu ".MenuStatements.'.fo&r\ \{\ \}\\sfo :call C_InsertTemplate("statements.for-block")' - " - exe "amenu ".MenuStatements.'.&if\\si :call C_InsertTemplate("statements.if")' - exe "imenu ".MenuStatements.'.&if\\si :call C_InsertTemplate("statements.if")' - " - exe "amenu ".MenuStatements.'.i&f\ \{\ \}\\sif :call C_InsertTemplate("statements.if-block")' - exe "vmenu ".MenuStatements.'.i&f\ \{\ \}\\sif :call C_InsertTemplate("statements.if-block", "v")' - exe "imenu ".MenuStatements.'.i&f\ \{\ \}\\sif :call C_InsertTemplate("statements.if-block")' - - exe "amenu ".MenuStatements.'.if\ &else\\sie :call C_InsertTemplate("statements.if-else")' - exe "vmenu ".MenuStatements.'.if\ &else\\sie :call C_InsertTemplate("statements.if-else", "v")' - exe "imenu ".MenuStatements.'.if\ &else\\sie :call C_InsertTemplate("statements.if-else")' - " - exe "amenu ".MenuStatements.'.if\ \{\ \}\ e&lse\ \{\ \}\\sife :call C_InsertTemplate("statements.if-block-else")' - exe "vmenu ".MenuStatements.'.if\ \{\ \}\ e&lse\ \{\ \}\\sife :call C_InsertTemplate("statements.if-block-else", "v")' - exe "imenu ".MenuStatements.'.if\ \{\ \}\ e&lse\ \{\ \}\\sife :call C_InsertTemplate("statements.if-block-else")' - " - exe "amenu ".MenuStatements.'.&else\ \{\ \}\\se :call C_InsertTemplate("statements.else-block")' - exe "vmenu ".MenuStatements.'.&else\ \{\ \}\\se :call C_InsertTemplate("statements.else-block", "v")' - exe "imenu ".MenuStatements.'.&else\ \{\ \}\\se :call C_InsertTemplate("statements.else-block")' - " - exe "amenu ".MenuStatements.'.&while\\sw :call C_InsertTemplate("statements.while")' - exe "imenu ".MenuStatements.'.&while\\sw :call C_InsertTemplate("statements.while")' - " - exe "amenu ".MenuStatements.'.w&hile\ \{\ \}\\swh :call C_InsertTemplate("statements.while-block")' - exe "vmenu ".MenuStatements.'.w&hile\ \{\ \}\\swh :call C_InsertTemplate("statements.while-block", "v")' - exe "imenu ".MenuStatements.'.w&hile\ \{\ \}\\swh :call C_InsertTemplate("statements.while-block")' - " - exe "amenu ".MenuStatements.'.&switch\ \{\ \}\\ss :call C_InsertTemplate("statements.switch")' - exe "vmenu ".MenuStatements.'.&switch\ \{\ \}\\ss :call C_InsertTemplate("statements.switch", "v")' - exe "imenu ".MenuStatements.'.&switch\ \{\ \}\\ss :call C_InsertTemplate("statements.switch")' - " - exe "amenu ".MenuStatements.'.&case\ \.\.\.\ break\\sc :call C_InsertTemplate("statements.case")' - exe "imenu ".MenuStatements.'.&case\ \.\.\.\ break\\sc :call C_InsertTemplate("statements.case")' - " - " - exe "amenu ".MenuStatements.'.&\{\ \}\\sb :call C_InsertTemplate("statements.block")' - exe "vmenu ".MenuStatements.'.&\{\ \}\\sb :call C_InsertTemplate("statements.block", "v")' - exe "imenu ".MenuStatements.'.&\{\ \}\\sb :call C_InsertTemplate("statements.block")' - " " - "=============================================================================================== - "----- Menu : C-Idioms ---------------------------------------------------- {{{2 - "=============================================================================================== - " - exe "amenu ".MenuIdioms.'.&function\\if :call C_InsertTemplate("idioms.function")' - exe "vmenu ".MenuIdioms.'.&function\\if :call C_InsertTemplate("idioms.function", "v")' - exe "imenu ".MenuIdioms.'.&function\\if :call C_InsertTemplate("idioms.function")' - exe "amenu ".MenuIdioms.'.s&tatic\ function\\isf :call C_InsertTemplate("idioms.function-static")' - exe "vmenu ".MenuIdioms.'.s&tatic\ function\\isf :call C_InsertTemplate("idioms.function-static", "v")' - exe "imenu ".MenuIdioms.'.s&tatic\ function\\isf :call C_InsertTemplate("idioms.function-static")' - exe "amenu ".MenuIdioms.'.&main\\im :call C_InsertTemplate("idioms.main")' - exe "vmenu ".MenuIdioms.'.&main\\im :call C_InsertTemplate("idioms.main", "v")' - exe "imenu ".MenuIdioms.'.&main\\im :call C_InsertTemplate("idioms.main")' - - exe "amenu ".MenuIdioms.'.-SEP1- :' - exe "amenu ".MenuIdioms.'.for(x=&0;\ x\\i0 :call C_CodeFor("up" )' - exe "vmenu ".MenuIdioms.'.for(x=&0;\ x\\i0 :call C_CodeFor("up" )' - exe "imenu ".MenuIdioms.'.for(x=&0;\ x\\i0 :call C_CodeFor("up" )i' - exe "amenu ".MenuIdioms.'.for(x=&n-1;\ x>=0;\ x\-=1)\\in :call C_CodeFor("down")' - exe "vmenu ".MenuIdioms.'.for(x=&n-1;\ x>=0;\ x\-=1)\\in :call C_CodeFor("down")' - exe "imenu ".MenuIdioms.'.for(x=&n-1;\ x>=0;\ x\-=1)\\in :call C_CodeFor("down")i' - - exe "amenu ".MenuIdioms.'.-SEP2- :' - exe "amenu ".MenuIdioms.'.&enum\\ie :call C_InsertTemplate("idioms.enum")' - exe "vmenu ".MenuIdioms.'.&enum\\ie :call C_InsertTemplate("idioms.enum" , "v")' - exe "imenu ".MenuIdioms.'.&enum\\ie :call C_InsertTemplate("idioms.enum" )' - exe "amenu ".MenuIdioms.'.&struct\\is :call C_InsertTemplate("idioms.struct")' - exe "vmenu ".MenuIdioms.'.&struct\\is :call C_InsertTemplate("idioms.struct", "v")' - exe "imenu ".MenuIdioms.'.&struct\\is :call C_InsertTemplate("idioms.struct")' - exe "amenu ".MenuIdioms.'.&union\\iu :call C_InsertTemplate("idioms.union")' - exe "vmenu ".MenuIdioms.'.&union\\iu :call C_InsertTemplate("idioms.union" , "v")' - exe "imenu ".MenuIdioms.'.&union\\iu :call C_InsertTemplate("idioms.union" )' - exe "amenu ".MenuIdioms.'.-SEP3- :' - " - exe "amenu ".MenuIdioms.'.&scanf\\isc :call C_InsertTemplate("idioms.scanf")' - exe "imenu ".MenuIdioms.'.&scanf\\isc :call C_InsertTemplate("idioms.scanf")' - exe "amenu ".MenuIdioms.'.&printf\\ip :call C_InsertTemplate("idioms.printf")' - exe "imenu ".MenuIdioms.'.&printf\\ip :call C_InsertTemplate("idioms.printf")' - " - exe "amenu ".MenuIdioms.'.-SEP4- :' - exe "amenu ".MenuIdioms.'.p=&calloc\(n,sizeof(type)\)\\ica :call C_InsertTemplate("idioms.calloc")' - exe "imenu ".MenuIdioms.'.p=&calloc\(n,sizeof(type)\)\\ica :call C_InsertTemplate("idioms.calloc")' - exe "amenu ".MenuIdioms.'.p=&malloc\(sizeof(type)\)\\ima :call C_InsertTemplate("idioms.malloc")' - exe "imenu ".MenuIdioms.'.p=&malloc\(sizeof(type)\)\\ima :call C_InsertTemplate("idioms.malloc")' - exe "amenu ".MenuIdioms.'.p=&realloc\(p,sizeof(type)\)\\ire :call C_InsertTemplate("idioms.realloc")' - exe "imenu ".MenuIdioms.'.p=&realloc\(p,sizeof(type)\)\\ire :call C_InsertTemplate("idioms.realloc")' - " - exe "anoremenu ".MenuIdioms.'.&sizeof(\ \)\\isi :call C_InsertTemplate("idioms.sizeof")' - exe "inoremenu ".MenuIdioms.'.&sizeof(\ \)\\isi :call C_InsertTemplate("idioms.sizeof")' - exe "vnoremenu ".MenuIdioms.'.&sizeof(\ \)\\isi :call C_InsertTemplate("idioms.sizeof", "v")' - " - exe "anoremenu ".MenuIdioms.'.&assert(\ \)\\ias :call C_InsertTemplate("idioms.assert")' - exe "inoremenu ".MenuIdioms.'.&assert(\ \)\\ias :call C_InsertTemplate("idioms.assert")' - exe "vnoremenu ".MenuIdioms.'.&assert(\ \)\\ias :call C_InsertTemplate("idioms.assert", "v")' - - exe "amenu ".MenuIdioms.'.-SEP5- :' - exe "amenu ".MenuIdioms.'.open\ &input\ file\\ii :call C_InsertTemplate("idioms.open-input-file")' - exe "imenu ".MenuIdioms.'.open\ &input\ file\\ii :call C_InsertTemplate("idioms.open-input-file")' - exe "vmenu ".MenuIdioms.'.open\ &input\ file\\ii :call C_InsertTemplate("idioms.open-input-file", "v")' - exe "amenu ".MenuIdioms.'.open\ &output\ file\\io :call C_InsertTemplate("idioms.open-output-file")' - exe "imenu ".MenuIdioms.'.open\ &output\ file\\io :call C_InsertTemplate("idioms.open-output-file")' - exe "vmenu ".MenuIdioms.'.open\ &output\ file\\io :call C_InsertTemplate("idioms.open-output-file", "v")' - " - exe "amenu ".MenuIdioms.'.fscanf\\ifs :call C_InsertTemplate("idioms.fscanf")' - exe "imenu ".MenuIdioms.'.fscanf\\ifs :call C_InsertTemplate("idioms.fscanf")' - exe "amenu ".MenuIdioms.'.fprintf\\ifp :call C_InsertTemplate("idioms.fprintf")' - exe "imenu ".MenuIdioms.'.fprintf\\ifp :call C_InsertTemplate("idioms.fprintf")' + "=============================================================================================== + "----- Menu : Statements (title) {{{2 + "=============================================================================================== + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'sub_menu', '&Statements' ) " - "=============================================================================================== - "----- Menu : C-Preprocessor ---------------------------------------------- {{{2 - "=============================================================================================== + "=============================================================================================== + "----- Menu : Idioms (title) {{{2 + "=============================================================================================== + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'sub_menu', '&Idioms' ) " - "----- Submenu : C-Idioms: standard library ------------------------------------------------------- - "' - call C_CIncludeMenus ( MenuPreprocessor.'.#include\ &Std\.Lib\.\\ps', s:C_StandardLibs ) - " - call C_CIncludeMenus ( MenuPreprocessor.'.#include\ C&99\\pc', s:C_C99Libs ) - " - exe "amenu ".MenuPreprocessor.'.-SEP2- :' - exe "anoremenu ".MenuPreprocessor.'.#include\ &\<\.\.\.\>\\p< :call C_InsertTemplate("preprocessor.include-global")' - exe "inoremenu ".MenuPreprocessor.'.#include\ &\<\.\.\.\>\\p< :call C_InsertTemplate("preprocessor.include-global")' - exe "anoremenu ".MenuPreprocessor.'.#include\ &\"\.\.\.\"\\p" :call C_InsertTemplate("preprocessor.include-local")' - exe "inoremenu ".MenuPreprocessor.'.#include\ &\"\.\.\.\"\\p" :call C_InsertTemplate("preprocessor.include-local")' - exe "amenu ".MenuPreprocessor.'.#&define\\pd :call C_InsertTemplate("preprocessor.define")' - exe "imenu ".MenuPreprocessor.'.#&define\\pd :call C_InsertTemplate("preprocessor.define")' - exe "amenu ".MenuPreprocessor.'.&#undef\\pu :call C_InsertTemplate("preprocessor.undefine")' - exe "imenu ".MenuPreprocessor.'.&#undef\\pu :call C_InsertTemplate("preprocessor.undefine")' - " - exe "amenu ".MenuPreprocessor.'.#&if\ #endif\\pif :call C_InsertTemplate("preprocessor.if-endif")' - exe "imenu ".MenuPreprocessor.'.#&if\ #endif\\pif :call C_InsertTemplate("preprocessor.if-endif")' - exe "vmenu ".MenuPreprocessor.'.#&if\ #endif\\pif :call C_InsertTemplate("preprocessor.if-endif", "v")' - exe "amenu ".MenuPreprocessor.'.#&if\ #else\ #endif\\pie :call C_InsertTemplate("preprocessor.if-else-endif")' - exe "imenu ".MenuPreprocessor.'.#&if\ #else\ #endif\\pie :call C_InsertTemplate("preprocessor.if-else-endif")' - exe "vmenu ".MenuPreprocessor.'.#&if\ #else\ #endif\\pie :call C_InsertTemplate("preprocessor.if-else-endif", "v")' - exe "amenu ".MenuPreprocessor.'.#i&fdef\ #else\ #endif\\pid :call C_InsertTemplate("preprocessor.ifdef-else-endif")' - exe "imenu ".MenuPreprocessor.'.#i&fdef\ #else\ #endif\\pid :call C_InsertTemplate("preprocessor.ifdef-else-endif")' - exe "vmenu ".MenuPreprocessor.'.#i&fdef\ #else\ #endif\\pid :call C_InsertTemplate("preprocessor.ifdef-else-endif", "v")' - exe "amenu ".MenuPreprocessor.'.#if&ndef\ #else\ #endif\\pin :call C_InsertTemplate("preprocessor.ifndef-else-endif")' - exe "imenu ".MenuPreprocessor.'.#if&ndef\ #else\ #endif\\pin :call C_InsertTemplate("preprocessor.ifndef-else-endif")' - exe "vmenu ".MenuPreprocessor.'.#if&ndef\ #else\ #endif\\pin :call C_InsertTemplate("preprocessor.ifndef-else-endif", "v")' - exe "amenu ".MenuPreprocessor.'.#ifnd&ef\ #def\ #endif\\pind :call C_InsertTemplate("preprocessor.ifndef-def-endif")' - exe "imenu ".MenuPreprocessor.'.#ifnd&ef\ #def\ #endif\\pind :call C_InsertTemplate("preprocessor.ifndef-def-endif")' - exe "vmenu ".MenuPreprocessor.'.#ifnd&ef\ #def\ #endif\\pind :call C_InsertTemplate("preprocessor.ifndef-def-endif", "v")' - - exe "amenu ".MenuPreprocessor.'.#if\ &0\ #endif\\pi0 :call C_PPIf0("a")2ji' - exe "imenu ".MenuPreprocessor.'.#if\ &0\ #endif\\pi0 :call C_PPIf0("a")2ji' - exe "vmenu ".MenuPreprocessor.'.#if\ &0\ #endif\\pi0 :call C_PPIf0("v")' - " - exe "amenu ".MenuPreprocessor.'.&remove\ #if\ 0\ #endif\\pr0 :call C_PPIf0Remove()' - exe "imenu ".MenuPreprocessor.'.&remove\ #if\ 0\ #endif\\pr0 :call C_PPIf0Remove()' - " - exe "amenu ".MenuPreprocessor.'.#err&or\\pe :call C_InsertTemplate("preprocessor.error")' - exe "imenu ".MenuPreprocessor.'.#err&or\\pe :call C_InsertTemplate("preprocessor.error")' - exe "amenu ".MenuPreprocessor.'.#&line\\pl :call C_InsertTemplate("preprocessor.line")' - exe "imenu ".MenuPreprocessor.'.#&line\\pl :call C_InsertTemplate("preprocessor.line")' - exe "amenu ".MenuPreprocessor.'.#&pragma\\pp :call C_InsertTemplate("preprocessor.pragma")' - exe "imenu ".MenuPreprocessor.'.#&pragma\\pp :call C_InsertTemplate("preprocessor.pragma")' + "=============================================================================================== + "----- Menu : Preprocessor (title) {{{2 + "=============================================================================================== + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'sub_menu', '&Preprocessor' ) " "=============================================================================================== "----- Menu : Snippets ---------------------------------------------------- {{{2 "=============================================================================================== " + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'sub_menu', 'S&nippets' ) + let ahead = 'anoremenu '.s:C_RootMenu.'S&nippets.' + let vhead = 'vnoremenu '.s:C_RootMenu.'S&nippets.' + let ihead = 'inoremenu '.s:C_RootMenu.'S&nippets.' + " if !empty(s:C_CodeSnippets) - exe "amenu ".MenuSnippets.'.&read\ code\ snippet\\nr :call C_CodeSnippet("r")' - exe "imenu ".MenuSnippets.'.&read\ code\ snippet\\nr :call C_CodeSnippet("r")' - exe "amenu ".MenuSnippets.'.&write\ code\ snippet\\nw :call C_CodeSnippet("w")' - exe "vmenu ".MenuSnippets.'.&write\ code\ snippet\\nw :call C_CodeSnippet("wv")' - exe "imenu ".MenuSnippets.'.&write\ code\ snippet\\nw :call C_CodeSnippet("w")' - exe "amenu ".MenuSnippets.'.&edit\ code\ snippet\\ne :call C_CodeSnippet("e")' - exe "imenu ".MenuSnippets.'.&edit\ code\ snippet\\ne :call C_CodeSnippet("e")' - exe " menu ".MenuSnippets.'.-SEP1- :' - endif - exe " menu ".MenuSnippets.'.&pick\ up\ func\.\ prototype\\nf,\ \\np :call C_ProtoPick("function")' - exe "vmenu ".MenuSnippets.'.&pick\ up\ func\.\ prototype\\nf,\ \\np :call C_ProtoPick("function")' - exe "imenu ".MenuSnippets.'.&pick\ up\ func\.\ prototype\\nf,\ \\np :call C_ProtoPick("function")' - exe " menu ".MenuSnippets.'.&pick\ up\ method\ prototype\\nm :call C_ProtoPick("method")' - exe "vmenu ".MenuSnippets.'.&pick\ up\ method\ prototype\\nm :call C_ProtoPick("method")' - exe "imenu ".MenuSnippets.'.&pick\ up\ method\ prototype\\nm :call C_ProtoPick("method")' - exe " menu ".MenuSnippets.'.&insert\ prototype(s)\\ni :call C_ProtoInsert()' - exe "imenu ".MenuSnippets.'.&insert\ prototype(s)\\ni :call C_ProtoInsert()' - exe " menu ".MenuSnippets.'.&clear\ prototype(s)\\nc :call C_ProtoClear()' - exe "imenu ".MenuSnippets.'.&clear\ prototype(s)\\nc :call C_ProtoClear()' - exe " menu ".MenuSnippets.'.&show\ prototype(s)\\ns :call C_ProtoShow()' - exe "imenu ".MenuSnippets.'.&show\ prototype(s)\\ns :call C_ProtoShow()' - - exe " menu ".MenuSnippets.'.-SEP2- :' - exe "amenu ".MenuSnippets.'.edit\ &local\ templates\\ntl :call C_BrowseTemplateFiles("Local")' - exe "imenu ".MenuSnippets.'.edit\ &local\ templates\\ntl :call C_BrowseTemplateFiles("Local")' - if s:installation == 'system' - exe "amenu ".MenuSnippets.'.edit\ &global\ templates\\ntg :call C_BrowseTemplateFiles("Global")' - exe "imenu ".MenuSnippets.'.edit\ &global\ templates\\ntg :call C_BrowseTemplateFiles("Global")' - endif - exe "amenu ".MenuSnippets.'.reread\ &templates\\ntr :call C_RereadTemplates("yes")' - exe "imenu ".MenuSnippets.'.reread\ &templates\\ntr :call C_RereadTemplates("yes")' - exe "amenu ".MenuSnippets.'.switch\ template\ st&yle\\nts :CStyle' - exe "imenu ".MenuSnippets.'.switch\ template\ st&yle\\nts :CStyle' - " - "=============================================================================================== - "----- Menu : C++ --------------------------------------------------------- {{{2 - "=============================================================================================== + exe ahead.'&read\ code\ snippet\\nr :call C_CodeSnippet("r")' + exe ihead.'&read\ code\ snippet\\nr :call C_CodeSnippet("r")' + exe ahead.'&view\ code\ snippet\\nv :call C_CodeSnippet("view")' + exe ihead.'&view\ code\ snippet\\nv :call C_CodeSnippet("view")' + exe ahead.'&write\ code\ snippet\\nw :call C_CodeSnippet("w")' + exe vhead.'&write\ code\ snippet\\nw :call C_CodeSnippet("wv")' + exe ihead.'&write\ code\ snippet\\nw :call C_CodeSnippet("w")' + exe ahead.'&edit\ code\ snippet\\ne :call C_CodeSnippet("e")' + exe ihead.'&edit\ code\ snippet\\ne :call C_CodeSnippet("e")' + exe ahead.'-SEP1- :' + endif + exe ahead.'&pick\ up\ func\.\ prototype\\nf,\ \\np :call C_ProtoPick("function")' + exe vhead.'&pick\ up\ func\.\ prototype\\nf,\ \\np :call C_ProtoPick("function")' + exe ihead.'&pick\ up\ func\.\ prototype\\nf,\ \\np :call C_ProtoPick("function")' + exe ahead.'&pick\ up\ method\ prototype\\nm :call C_ProtoPick("method")' + exe vhead.'&pick\ up\ method\ prototype\\nm :call C_ProtoPick("method")' + exe ihead.'&pick\ up\ method\ prototype\\nm :call C_ProtoPick("method")' + exe ahead.'&insert\ prototype(s)\\ni :call C_ProtoInsert()' + exe ihead.'&insert\ prototype(s)\\ni :call C_ProtoInsert()' + exe ahead.'&clear\ prototype(s)\\nc :call C_ProtoClear()' + exe ihead.'&clear\ prototype(s)\\nc :call C_ProtoClear()' + exe ahead.'&show\ prototype(s)\\ns :call C_ProtoShow()' + exe ihead.'&show\ prototype(s)\\ns :call C_ProtoShow()' + + exe ahead.'-SEP2- :' + " + exe ahead.'edit\ &local\ templates\\ntl :call mmtemplates#core#EditTemplateFiles(g:C_Templates,-1)' + exe ihead.'edit\ &local\ templates\\ntl :call mmtemplates#core#EditTemplateFiles(g:C_Templates,-1)' + if g:C_Installation == 'system' + exe ahead.'edit\ &local\ templates\\ntg :call mmtemplates#core#EditTemplateFiles(g:C_Templates,1)' + exe ihead.'edit\ &local\ templates\\ntg :call mmtemplates#core#EditTemplateFiles(g:C_Templates,1)' + endif + " + exe ahead.'reread\ &templates\\ntr :call mmtemplates#core#ReadTemplates(g:C_Templates,"reload","all")' + exe ihead.'reread\ &templates\\ntr :call mmtemplates#core#ReadTemplates(g:C_Templates,"reload","all")' " - exe "anoremenu ".MenuCpp.'.c&in :call C_InsertTemplate("cpp.cin")' - exe "inoremenu ".MenuCpp.'.c&in :call C_InsertTemplate("cpp.cin")' - exe "anoremenu ".MenuCpp.'.c&out\\+co :call C_InsertTemplate("cpp.cout")' - exe "inoremenu ".MenuCpp.'.c&out\\+co :call C_InsertTemplate("cpp.cout")' - exe "anoremenu ".MenuCpp.'.<<\ &\"\"\\+" :call C_InsertTemplate("cpp.cout-operator")' - exe "inoremenu ".MenuCpp.'.<<\ &\"\"\\+" :call C_InsertTemplate("cpp.cout-operator")' - " - "----- Submenu : C++ : output manipulators ------------------------------------------------------- - " - if s:C_MenuHeader == 'yes' - exe "amenu ".MenuCpp.'.&output\ manipulators.output\ manip\.C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuCpp.'.&output\ manipulators.-Sep0- ' - exe "amenu ".MenuCpp.'.ios\ flag&bits.ios\ flagsC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuCpp.'.ios\ flag&bits.-Sep0- ' - exe "amenu ".MenuCpp.'.&#include\ \\+ps.alg\.\.vecC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuCpp.'.&#include\ \\+ps.-Sep0- ' - exe "amenu ".MenuCpp.'.&#include\ \\+pc.cXC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuCpp.'.&#include\ \\+pc.-Sep0- ' - endif - " - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &boolalpha :call C_InsertTemplate("cpp.output-manipulator-boolalpha")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &dec :call C_InsertTemplate("cpp.output-manipulator-dec")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &endl :call C_InsertTemplate("cpp.output-manipulator-endl")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &fixed :call C_InsertTemplate("cpp.output-manipulator-fixed")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ fl&ush :call C_InsertTemplate("cpp.output-manipulator-flush")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &hex :call C_InsertTemplate("cpp.output-manipulator-hex")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &internal :call C_InsertTemplate("cpp.output-manipulator-internal")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &left :call C_InsertTemplate("cpp.output-manipulator-left")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &oct :call C_InsertTemplate("cpp.output-manipulator-oct")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &right :call C_InsertTemplate("cpp.output-manipulator-right")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ s&cientific :call C_InsertTemplate("cpp.output-manipulator-scientific")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &setbase\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setbase")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ se&tfill\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setfill")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ setiosfla&g\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setiosflags")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ set&precision\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setprecision")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ set&w\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setw")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ showb&ase :call C_InsertTemplate("cpp.output-manipulator-showbase")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ showpoi&nt :call C_InsertTemplate("cpp.output-manipulator-showpoint")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ showpos\ \(&1\) :call C_InsertTemplate("cpp.output-manipulator-showpos")' - exe "anoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ uppercase\ \(&2\) :call C_InsertTemplate("cpp.output-manipulator-uppercase")' - " - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &boolalpha :call C_InsertTemplate("cpp.output-manipulator-boolalpha")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &dec :call C_InsertTemplate("cpp.output-manipulator-dec")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &endl :call C_InsertTemplate("cpp.output-manipulator-endl")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &fixed :call C_InsertTemplate("cpp.output-manipulator-fixed")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ fl&ush :call C_InsertTemplate("cpp.output-manipulator-flush")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &hex :call C_InsertTemplate("cpp.output-manipulator-hex")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &internal :call C_InsertTemplate("cpp.output-manipulator-internal")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &left :call C_InsertTemplate("cpp.output-manipulator-left")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &oct :call C_InsertTemplate("cpp.output-manipulator-oct")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &right :call C_InsertTemplate("cpp.output-manipulator-right")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ s&cientific :call C_InsertTemplate("cpp.output-manipulator-scientific")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ &setbase\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setbase")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ se&tfill\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setfill")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ setiosfla&g\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setiosflags")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ set&precision\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setprecision")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ set&w\(\ \) :call C_InsertTemplate("cpp.output-manipulator-setw")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ showb&ase :call C_InsertTemplate("cpp.output-manipulator-showbase")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ showpoi&nt :call C_InsertTemplate("cpp.output-manipulator-showpoint")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ showpos\ \(&1\) :call C_InsertTemplate("cpp.output-manipulator-showpos")' - exe "inoremenu ".MenuCpp.'.&output\ manipulators.\<\<\ uppercase\ \(&2\) :call C_InsertTemplate("cpp.output-manipulator-uppercase")' - " - "----- Submenu : C++ : ios flag bits ------------------------------------------------------------- - " - " - call C_CIosFlagMenus ( MenuCpp.'.ios\ flag&bits', s:Cpp_IosFlagBits ) - " - "----- Submenu : C++ library (algorithm - locale) ---------------------------------------------- - " - call C_CIncludeMenus ( MenuCpp.'.&#include\ \\+ps', s:Cpp_StandardLibs ) - " - "----- Submenu : C library (cassert - ctime) ------------------------------------------------- - " - call C_CIncludeMenus ( MenuCpp.'.&#include\ \\+pc', s:Cpp_CStandardLibs ) - " - "----- End Submenu : C library (cassert - ctime) --------------------------------------------- - " - exe "amenu ".MenuCpp.'.-SEP2- :' - - exe "amenu ".MenuCpp.'.&class\\+c :call C_InsertTemplate("cpp.class-definition")' - exe "imenu ".MenuCpp.'.&class\\+c :call C_InsertTemplate("cpp.class-definition")' - exe "amenu ".MenuCpp.'.class\ (w\.\ &new)\\+cn :call C_InsertTemplate("cpp.class-using-new-definition")' - exe "imenu ".MenuCpp.'.class\ (w\.\ &new)\\+cn :call C_InsertTemplate("cpp.class-using-new-definition")' - exe "amenu ".MenuCpp.'.&templ\.\ class\\+tc :call C_InsertTemplate("cpp.template-class-definition")' - exe "imenu ".MenuCpp.'.&templ\.\ class\\+tc :call C_InsertTemplate("cpp.template-class-definition")' - exe "amenu ".MenuCpp.'.templ\.\ class\ (w\.\ ne&w)\\+tcn :call C_InsertTemplate("cpp.template-class-using-new-definition")' - exe "imenu ".MenuCpp.'.templ\.\ class\ (w\.\ ne&w)\\+tcn :call C_InsertTemplate("cpp.template-class-using-new-definition")' - - " - "----- Submenu : C++ : IMPLEMENTATION ------------------------------------------------------- - " - if s:C_MenuHeader == 'yes' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.IMPLEMENT\.C\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.-Sep0- ' - endif - " - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.&class\\+ci :call C_InsertTemplate("cpp.class-implementation")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.&class\\+ci :call C_InsertTemplate("cpp.class-implementation")' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.class\ (w\.\ &new)\\+cni :call C_InsertTemplate("cpp.class-using-new-implementation")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.class\ (w\.\ &new)\\+cni :call C_InsertTemplate("cpp.class-using-new-implementation")' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.&method\\+mi :call C_InsertTemplate("cpp.method-implementation")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.&method\\+mi :call C_InsertTemplate("cpp.method-implementation")' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.&accessor\\+ai :call C_InsertTemplate("cpp.accessor-implementation")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.&accessor\\+ai :call C_InsertTemplate("cpp.accessor-implementation")' - " - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.-SEP21- :' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.&templ\.\ class\\+tci :call C_InsertTemplate("cpp.template-class-implementation")' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.&templ\.\ class\\+tci :call C_InsertTemplate("cpp.template-class-implementation")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.templ\.\ class\ (w\.\ ne&w)\\+tcni :call C_InsertTemplate("cpp.template-class-using-new-implementation")' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.templ\.\ class\ (w\.\ ne&w)\\+tcni :call C_InsertTemplate("cpp.template-class-using-new-implementation")' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.templ\.\ mðod\\+tmi :call C_InsertTemplate("cpp.template-method-implementation")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.templ\.\ mðod\\+tmi :call C_InsertTemplate("cpp.template-method-implementation")' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.templ\.\ a&ccessor\\+tai :call C_InsertTemplate("cpp.template-accessor-implementation")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.templ\.\ a&ccessor\\+tai :call C_InsertTemplate("cpp.template-accessor-implementation")' - " - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.-SEP22- :' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.operator\ &<< :call C_InsertTemplate("cpp.operator-in")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.operator\ &<< :call C_InsertTemplate("cpp.operator-in")' - exe "amenu ".MenuCpp.'.IM&PLEMENTATION.operator\ &>> :call C_InsertTemplate("cpp.operator-out")' - exe "imenu ".MenuCpp.'.IM&PLEMENTATION.operator\ &>> :call C_InsertTemplate("cpp.operator-out")' - " - "----- End Submenu : C++ : IMPLEMENTATION ------------------------------------------------------- - " - exe "amenu ".MenuCpp.'.-SEP31- :' - exe "amenu ".MenuCpp.'.templ\.\ &function\\+tf :call C_InsertTemplate("cpp.template-function")' - exe "imenu ".MenuCpp.'.templ\.\ &function\\+tf :call C_InsertTemplate("cpp.template-function")' - exe "amenu ".MenuCpp.'.&error\ class\\+ec :call C_InsertTemplate("cpp.error-class")' - exe "imenu ".MenuCpp.'.&error\ class\\+ec :call C_InsertTemplate("cpp.error-class")' - - exe "amenu ".MenuCpp.'.-SEP5- :' - exe "amenu ".MenuCpp.'.tr&y\ \.\.\ catch\\+tr :call C_InsertTemplate("cpp.try-catch")' - exe "imenu ".MenuCpp.'.tr&y\ \.\.\ catch\\+tr :call C_InsertTemplate("cpp.try-catch")' - exe "vmenu ".MenuCpp.'.tr&y\ \.\.\ catch\\+tr :call C_InsertTemplate("cpp.try-catch", "v")' - exe "amenu ".MenuCpp.'.catc&h\\+ca :call C_InsertTemplate("cpp.catch")' - exe "imenu ".MenuCpp.'.catc&h\\+ca :call C_InsertTemplate("cpp.catch")' - exe "vmenu ".MenuCpp.'.catc&h\\+ca :call C_InsertTemplate("cpp.catch", "v")' - - exe "amenu ".MenuCpp.'.catch\(&\.\.\.\)\\+c\. :call C_InsertTemplate("cpp.catch-points")' - exe "imenu ".MenuCpp.'.catch\(&\.\.\.\)\\+c\. :call C_InsertTemplate("cpp.catch-points")' - exe "vmenu ".MenuCpp.'.catch\(&\.\.\.\)\\+c\. :call C_InsertTemplate("cpp.catch-points", "v")' - - exe "amenu ".MenuCpp.'.-SEP6- :' - exe "amenu ".MenuCpp.'.open\ input\ file\ \ \(&4\) :call C_InsertTemplate("cpp.open-input-file")' - exe "imenu ".MenuCpp.'.open\ input\ file\ \ \(&4\) :call C_InsertTemplate("cpp.open-input-file")' - exe "vmenu ".MenuCpp.'.open\ input\ file\ \ \(&4\) :call C_InsertTemplate("cpp.open-input-file", "v")' - exe "amenu ".MenuCpp.'.open\ output\ file\ \(&5\) :call C_InsertTemplate("cpp.open-output-file")' - exe "imenu ".MenuCpp.'.open\ output\ file\ \(&5\) :call C_InsertTemplate("cpp.open-output-file")' - exe "vmenu ".MenuCpp.'.open\ output\ file\ \(&5\) :call C_InsertTemplate("cpp.open-output-file", "v")' - exe "amenu ".MenuCpp.'.-SEP7- :' - - exe "amenu ".MenuCpp.'.&using\ namespace\ std; :call C_InsertTemplate("cpp.namespace-std")' - exe "imenu ".MenuCpp.'.&using\ namespace\ std; :call C_InsertTemplate("cpp.namespace-std")' - exe "amenu ".MenuCpp.'.u&sing\ namespace\ ???; :call C_InsertTemplate("cpp.namespace")' - exe "imenu ".MenuCpp.'.u&sing\ namespace\ ???; :call C_InsertTemplate("cpp.namespace")' - - exe "amenu ".MenuCpp.'.names&pace\ ???\ \{\ \} :call C_InsertTemplate("cpp.namespace-block")' - exe "imenu ".MenuCpp.'.names&pace\ ???\ \{\ \} :call C_InsertTemplate("cpp.namespace-block")' - exe "vmenu ".MenuCpp.'.names&pace\ ???\ \{\ \} :call C_InsertTemplate("cpp.namespace-block", "v")' - exe "amenu ".MenuCpp.'.namespace\ &alias\ =\ ??? :call C_InsertTemplate("cpp.namespace-alias")' - exe "imenu ".MenuCpp.'.namespace\ &alias\ =\ ??? :call C_InsertTemplate("cpp.namespace-alias")' - - exe "amenu ".MenuCpp.'.-SEP8- :' + if !empty(s:C_CodeSnippets) + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'do_styles', + \ 'specials_menu', 'Snippets' ) + endif " - "----- Submenu : RTTI ---------------------------------------------------------------------------- + "=============================================================================================== + "----- Menu : Run {{{2 + "=============================================================================================== " - if s:C_MenuHeader == 'yes' - exe "amenu ".MenuCpp.'.&RTTI.RTTIC\/C\+\+ :call C_MenuTitle()' - exe "amenu ".MenuCpp.'.&RTTI.-Sep0- ' - endif - " - exe "anoremenu ".MenuCpp.'.&RTTI.&typeid :call C_InsertTemplate("cpp.rtti-typeid")' - exe "anoremenu ".MenuCpp.'.&RTTI.&static_cast :call C_InsertTemplate("cpp.rtti-static-cast")' - exe "anoremenu ".MenuCpp.'.&RTTI.&const_cast :call C_InsertTemplate("cpp.rtti-const-cast")' - exe "anoremenu ".MenuCpp.'.&RTTI.&reinterpret_cast :call C_InsertTemplate("cpp.rtti-reinterpret-cast")' - exe "anoremenu ".MenuCpp.'.&RTTI.&dynamic_cast :call C_InsertTemplate("cpp.rtti-dynamic-cast")' - " - exe "inoremenu ".MenuCpp.'.&RTTI.&typeid :call C_InsertTemplate("cpp.rtti-typeid")' - exe "inoremenu ".MenuCpp.'.&RTTI.&static_cast :call C_InsertTemplate("cpp.rtti-static-cast")' - exe "inoremenu ".MenuCpp.'.&RTTI.&const_cast :call C_InsertTemplate("cpp.rtti-const-cast")' - exe "inoremenu ".MenuCpp.'.&RTTI.&reinterpret_cast :call C_InsertTemplate("cpp.rtti-reinterpret-cast")' - exe "inoremenu ".MenuCpp.'.&RTTI.&dynamic_cast :call C_InsertTemplate("cpp.rtti-dynamic-cast")' - " - exe "vnoremenu ".MenuCpp.'.&RTTI.&typeid :call C_InsertTemplate("cpp.rtti-typeid", "v")' - exe "vnoremenu ".MenuCpp.'.&RTTI.&static_cast :call C_InsertTemplate("cpp.rtti-static-cast", "v")' - exe "vnoremenu ".MenuCpp.'.&RTTI.&const_cast :call C_InsertTemplate("cpp.rtti-const-cast", "v")' - exe "vnoremenu ".MenuCpp.'.&RTTI.&reinterpret_cast :call C_InsertTemplate("cpp.rtti-reinterpret-cast", "v")' - exe "vnoremenu ".MenuCpp.'.&RTTI.&dynamic_cast :call C_InsertTemplate("cpp.rtti-dynamic-cast", "v")' - " - "----- End Submenu : RTTI ------------------------------------------------------------------------ - " - exe "amenu ".MenuCpp.'.e&xtern\ \"C\"\ \{\ \} :call C_InsertTemplate("cpp.extern")' - exe "imenu ".MenuCpp.'.e&xtern\ \"C\"\ \{\ \} :call C_InsertTemplate("cpp.extern")' - exe "vmenu ".MenuCpp.'.e&xtern\ \"C\"\ \{\ \} :call C_InsertTemplate("cpp.extern", "v")' + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'sub_menu', 'C&++' ) " "=============================================================================================== "----- Menu : run ----- -------------------------------------------------- {{{2 "=============================================================================================== - " - exe "amenu ".s:MenuRun.'.save\ and\ &compile\\rc\ \ \ :call C_Compile():call C_HlMessage()' - exe "imenu ".s:MenuRun.'.save\ and\ &compile\\rc\ \ \ :call C_Compile():call C_HlMessage()' - exe "amenu ".s:MenuRun.'.&link\\rl\ \ \ \ \ :call C_Link():call C_HlMessage()' - exe "imenu ".s:MenuRun.'.&link\\rl\ \ \ \ \ :call C_Link():call C_HlMessage()' - exe "amenu ".s:MenuRun.'.&run\\rr\ \ \ :call C_Run()' - exe "imenu ".s:MenuRun.'.&run\\rr\ \ \ :call C_Run()' - exe "amenu ".s:MenuRun.'.cmd\.\ line\ &arg\.\\ra\ \ \ :call C_Arguments()' - exe "imenu ".s:MenuRun.'.cmd\.\ line\ &arg\.\\ra\ \ \ :call C_Arguments()' - " - exe "amenu ".s:MenuRun.'.-SEP0- :' - exe "amenu ".s:MenuRun.'.&make\\rm :call C_Make()' - exe "imenu ".s:MenuRun.'.&make\\rm :call C_Make()' - exe "amenu ".s:MenuRun.'.&choose\ makefile\\rcm :call C_ChooseMakefile()' - exe "imenu ".s:MenuRun.'.&choose\ makefile\\rcm :call C_ChooseMakefile()' - exe "amenu ".s:MenuRun.'.executable\ to\ run\\rme :call C_MakeExeToRun()' - exe "imenu ".s:MenuRun.'.executable\ to\ run\\rme :call C_MakeExeToRun()' - exe "amenu ".s:MenuRun.'.&make\ clean\\rmc :call C_MakeClean()' - exe "imenu ".s:MenuRun.'.&make\ clean\\rmc :call C_MakeClean()' - exe "amenu ".s:MenuRun.'.cmd\.\ line\ ar&g\.\ for\ make\\rma :call C_MakeArguments()' - exe "imenu ".s:MenuRun.'.cmd\.\ line\ ar&g\.\ for\ make\\rma :call C_MakeArguments()' - " - exe "amenu ".s:MenuRun.'.-SEP1- :' + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'sub_menu', '&Run' ) + " + let ahead = 'anoremenu '.s:MenuRun.'.' + let vhead = 'vnoremenu '.s:MenuRun.'.' + let ihead = 'inoremenu '.s:MenuRun.'.' + " + exe ahead.'save\ and\ &compile\\rc\ \ \ :call C_Compile():call C_HlMessage()' + exe ihead.'save\ and\ &compile\\rc\ \ \ :call C_Compile():call C_HlMessage()' + exe ahead.'&link\\rl\ \ \ \ \ :call C_Link():call C_HlMessage()' + exe ihead.'&link\\rl\ \ \ \ \ :call C_Link():call C_HlMessage()' + exe ahead.'&run\\rr\ \ \ :call C_Run()' + exe ihead.'&run\\rr\ \ \ :call C_Run()' + exe ahead.'cmd\.\ line\ &arg\.\\ra\ \ \ :call C_Arguments()' + exe ihead.'cmd\.\ line\ &arg\.\\ra\ \ \ :call C_Arguments()' + " + exe ahead.'-SEP0- :' + exe ahead.'&make\\rm :call C_Make()' + exe ihead.'&make\\rm :call C_Make()' + exe ahead.'&choose\ makefile\\rcm :call C_ChooseMakefile()' + exe ihead.'&choose\ makefile\\rcm :call C_ChooseMakefile()' + exe ahead.'executable\ to\ run\\rme :call C_ExeToRun()' + exe ihead.'executable\ to\ run\\rme :call C_ExeToRun()' + exe ahead.'&make\ clean\\rmc :call C_MakeClean()' + exe ihead.'&make\ clean\\rmc :call C_MakeClean()' + exe ahead.'cmd\.\ line\ ar&g\.\ for\ make\\rma :call C_MakeArguments()' + exe ihead.'cmd\.\ line\ ar&g\.\ for\ make\\rma :call C_MakeArguments()' + " + exe ahead.'-SEP1- :' " if s:C_SplintIsExecutable==1 - exe "amenu ".s:MenuRun.'.s&plint\\rp :call C_SplintCheck():call C_HlMessage()' - exe "imenu ".s:MenuRun.'.s&plint\\rp :call C_SplintCheck():call C_HlMessage()' - exe "amenu ".s:MenuRun.'.cmd\.\ line\ arg\.\ for\ spl&int\\rpa :call C_SplintArguments()' - exe "imenu ".s:MenuRun.'.cmd\.\ line\ arg\.\ for\ spl&int\\rpa :call C_SplintArguments()' - exe "amenu ".s:MenuRun.'.-SEP2- :' + exe ahead.'s&plint\\rp :call C_SplintCheck():call C_HlMessage()' + exe ihead.'s&plint\\rp :call C_SplintCheck():call C_HlMessage()' + exe ahead.'cmd\.\ line\ arg\.\ for\ spl&int\\rpa :call C_SplintArguments()' + exe ihead.'cmd\.\ line\ arg\.\ for\ spl&int\\rpa :call C_SplintArguments()' + exe ahead.'-SEP2- :' + endif + " + if s:C_CppcheckIsExecutable==1 + exe ahead.'cppcheck\\rcc :call C_CppcheckCheck():call C_HlMessage()' + exe ihead.'cppcheck\\rcc :call C_CppcheckCheck():call C_HlMessage()' + " + if s:C_MenuHeader == 'yes' + exe ahead.'cppcheck\ severity\\rccs.cppcheck\ severity :call C_MenuTitle()' + exe ahead.'cppcheck\ severity\\rccs.-Sep5- :' + endif + + for level in s:CppcheckSeverity + exe ahead.'cppcheck\ severity\\rccs.&'.level.' :call C_GetCppcheckSeverity("'.level.'")' + endfor endif " if s:C_CodeCheckIsExecutable==1 - exe "amenu ".s:MenuRun.'.CodeChec&k\\rk :call C_CodeCheck():call C_HlMessage()' - exe "imenu ".s:MenuRun.'.CodeChec&k\\rk :call C_CodeCheck():call C_HlMessage()' - exe "amenu ".s:MenuRun.'.cmd\.\ line\ arg\.\ for\ Cod&eCheck\\rka :call C_CodeCheckArguments()' - exe "imenu ".s:MenuRun.'.cmd\.\ line\ arg\.\ for\ Cod&eCheck\\rka :call C_CodeCheckArguments()' - exe "amenu ".s:MenuRun.'.-SEP3- :' + exe ahead.'CodeChec&k\\rk :call C_CodeCheck():call C_HlMessage()' + exe ihead.'CodeChec&k\\rk :call C_CodeCheck():call C_HlMessage()' + exe ahead.'cmd\.\ line\ arg\.\ for\ Cod&eCheck\\rka :call C_CodeCheckArguments()' + exe ihead.'cmd\.\ line\ arg\.\ for\ Cod&eCheck\\rka :call C_CodeCheckArguments()' + exe ahead.'-SEP3- :' endif " - exe "amenu ".s:MenuRun.'.in&dent\\rd :call C_Indent()' - exe "imenu ".s:MenuRun.'.in&dent\\rd :call C_Indent()' + exe ahead.'in&dent\\ri :call C_Indent()' + exe ihead.'in&dent\\ri :call C_Indent()' if s:MSWIN - exe "amenu ".s:MenuRun.'.&hardcopy\ to\ printer\\rh :call C_Hardcopy()' - exe "imenu ".s:MenuRun.'.&hardcopy\ to\ printer\\rh :call C_Hardcopy()' - exe "vmenu ".s:MenuRun.'.&hardcopy\ to\ printer\\rh :call C_Hardcopy()' + exe ahead.'&hardcopy\ to\ printer\\rh :call C_Hardcopy()' + exe ihead.'&hardcopy\ to\ printer\\rh :call C_Hardcopy()' + exe vhead.'&hardcopy\ to\ printer\\rh :call C_Hardcopy()' else - exe "amenu ".s:MenuRun.'.&hardcopy\ to\ FILENAME\.ps\\rh :call C_Hardcopy()' - exe "imenu ".s:MenuRun.'.&hardcopy\ to\ FILENAME\.ps\\rh :call C_Hardcopy()' - exe "vmenu ".s:MenuRun.'.&hardcopy\ to\ FILENAME\.ps\\rh :call C_Hardcopy()' + exe ahead.'&hardcopy\ to\ FILENAME\.ps\\rh :call C_Hardcopy()' + exe ihead.'&hardcopy\ to\ FILENAME\.ps\\rh :call C_Hardcopy()' + exe vhead.'&hardcopy\ to\ FILENAME\.ps\\rh :call C_Hardcopy()' endif - exe "imenu ".s:MenuRun.'.-SEP4- :' + exe ihead.'-SEP4- :' - exe "amenu ".s:MenuRun.'.&settings\\rs :call C_Settings()' - exe "imenu ".s:MenuRun.'.&settings\\rs :call C_Settings()' - exe "imenu ".s:MenuRun.'.-SEP5- :' + exe ahead.'&settings\\rs :call C_Settings()' + exe ihead.'&settings\\rs :call C_Settings()' + exe ihead.'-SEP5- :' if !s:MSWIN - exe "amenu ".s:MenuRun.'.&xterm\ size\\rx :call C_XtermSize()' - exe "imenu ".s:MenuRun.'.&xterm\ size\\rx :call C_XtermSize()' + exe ahead.'&xterm\ size\\rx :call C_XtermSize()' + exe ihead.'&xterm\ size\\rx :call C_XtermSize()' endif if s:C_OutputGvim == "vim" - exe "amenu ".s:MenuRun.'.&output:\ VIM->buffer->xterm\\ro :call C_Toggle_Gvim_Xterm()' - exe "imenu ".s:MenuRun.'.&output:\ VIM->buffer->xterm\\ro :call C_Toggle_Gvim_Xterm()' + exe ahead.'&output:\ '.s:output1.'\\ro :call C_Toggle_Gvim_Xterm()' + exe ihead.'&output:\ '.s:output1.'\\ro :call C_Toggle_Gvim_Xterm()' else if s:C_OutputGvim == "buffer" - exe "amenu ".s:MenuRun.'.&output:\ BUFFER->xterm->vim\\ro :call C_Toggle_Gvim_Xterm()' - exe "imenu ".s:MenuRun.'.&output:\ BUFFER->xterm->vim\\ro :call C_Toggle_Gvim_Xterm()' + exe ahead.'&output:\ '.s:output2.'\\ro :call C_Toggle_Gvim_Xterm()' + exe ihead.'&output:\ '.s:output2.'\\ro :call C_Toggle_Gvim_Xterm()' else - exe "amenu ".s:MenuRun.'.&output:\ XTERM->vim->buffer\\ro :call C_Toggle_Gvim_Xterm()' - exe "imenu ".s:MenuRun.'.&output:\ XTERM->vim->buffer\\ro :call C_Toggle_Gvim_Xterm()' + exe ahead.'&output:\ '.s:output3.'\\ro :call C_Toggle_Gvim_Xterm()' + exe ihead.'&output:\ '.s:output3.'\\ro :call C_Toggle_Gvim_Xterm()' endif endif " @@ -1040,85 +517,89 @@ function! C_InitMenus () "----- Menu : help ------------------------------------------------------- {{{2 "=============================================================================================== " - exe " menu ".s:C_Root.'&help\ (C-Support)\\hp :call C_HelpCsupport()' - exe "imenu ".s:C_Root.'&help\ (C-Support)\\hp :call C_HelpCsupport()' - exe " menu ".s:C_Root.'show\ &manual\\hm :call C_Help("m")' - exe "imenu ".s:C_Root.'show\ &manual\\hm :call C_Help("m")' + exe " menu ".s:C_RootMenu.'&help\ (C-Support)\\hp :call C_HelpCsupport()' + exe "imenu ".s:C_RootMenu.'&help\ (C-Support)\\hp :call C_HelpCsupport()' + exe " menu ".s:C_RootMenu.'show\ &manual\\hm :call C_Help("m")' + exe "imenu ".s:C_RootMenu.'show\ &manual\\hm :call C_Help("m")' + " + "=============================================================================================== + "----- Menu : GENERATE MENU ITEMS FROM THE TEMPLATES {{{2 + "=============================================================================================== + call mmtemplates#core#CreateMenus ( 'g:C_Templates', s:C_RootMenu, 'do_templates' ) + "=============================================================================================== + "=============================================================================================== + " + "=============================================================================================== + "----- Menu : C-Comments -------------------------------------------------- {{{2 + "=============================================================================================== + " + exe "amenu ".MenuComments.'.-SEP8- :' + exe " menu ".MenuComments.'.&date\\cd :call C_InsertDateAndTime("d")' + exe "imenu ".MenuComments.'.&date\\cd :call C_InsertDateAndTime("d")a' + exe "vmenu ".MenuComments.'.&date\\cd s:call C_InsertDateAndTime("d")a' + exe " menu ".MenuComments.'.date\ &time\\ct :call C_InsertDateAndTime("dt")' + exe "imenu ".MenuComments.'.date\ &time\\ct :call C_InsertDateAndTime("dt")a' + exe "vmenu ".MenuComments.'.date\ &time\\ct s:call C_InsertDateAndTime("dt")a' -endfunction " ---------- end of function C_InitMenus ---------- -" -function! C_MenuTitle () - echohl WarningMsg | echo "This is a menu title." | echohl None -endfunction " ---------- end of function C_MenuTitle ---------- + exe "amenu ".MenuComments.'.-SEP12- :' + exe "amenu ".MenuComments.'.\/*\ &xxx\ *\/\ \ <->\ \ \/\/\ xxx\\cx :call C_CommentToggle()' + exe "vmenu ".MenuComments.'.\/*\ &xxx\ *\/\ \ <->\ \ \/\/\ xxx\\cx :call C_CommentToggle()' + " + "=============================================================================================== + "----- Menu : C-Idioms ---------------------------------------------------- {{{2 + "=============================================================================================== + " + let MenuIdioms = s:C_RootMenu.'&Idioms.' + " + exe "amenu ".MenuIdioms.'-SEP1- :' + exe "amenu ".MenuIdioms.'for(x=&0;\ x\\i0 :call C_CodeFor("up" )' + exe "vmenu ".MenuIdioms.'for(x=&0;\ x\\i0 :call C_CodeFor("up","v")' + exe "imenu ".MenuIdioms.'for(x=&0;\ x\\i0 :call C_CodeFor("up" )' + exe "amenu ".MenuIdioms.'for(x=&n-1;\ x>=0;\ x\-=1)\\in :call C_CodeFor("down" )' + exe "vmenu ".MenuIdioms.'for(x=&n-1;\ x>=0;\ x\-=1)\\in :call C_CodeFor("down","v")' + exe "imenu ".MenuIdioms.'for(x=&n-1;\ x>=0;\ x\-=1)\\in :call C_CodeFor("down" )' + " + "=============================================================================================== + "----- Menu : C-Preprocessor ---------------------------------------------- {{{2 + "=============================================================================================== + " + let MenuPreprocessor = s:C_RootMenu.'&Preprocessor.' + " + exe "amenu ".MenuPreprocessor.'-SEP2- :' + exe "amenu ".MenuPreprocessor.'#if\ &0\ #endif\\pi0 :call C_PPIf0("a")2ji' + exe "imenu ".MenuPreprocessor.'#if\ &0\ #endif\\pi0 :call C_PPIf0("a")2ji' + exe "vmenu ".MenuPreprocessor.'#if\ &0\ #endif\\pi0 :call C_PPIf0("v")' + " + exe "amenu ".MenuPreprocessor.'&remove\ #if\ 0\ #endif\\pr0 :call C_PPIf0Remove()' + exe "imenu ".MenuPreprocessor.'&remove\ #if\ 0\ #endif\\pr0 :call C_PPIf0Remove()' + " +endfunction " ---------- end of function s:C_InitMenus ---------- " "=============================================================================================== "----- Menu Functions -------------------------------------------------------------------------- "=============================================================================================== " -let s:C_StandardLibs = [ - \ '&assert\.h' , '&ctype\.h' , '&errno\.h' , - \ '&float\.h' , '&limits\.h' , 'l&ocale\.h' , - \ '&math\.h' , 'set&jmp\.h' , 's&ignal\.h' , - \ 'stdar&g\.h' , 'st&ddef\.h' , '&stdio\.h' , - \ 'stdli&b\.h' , 'st&ring\.h' , '&time\.h' , - \ ] -" -let s:C_C99Libs = [ - \ '&complex\.h', '&fenv\.h', '&inttypes\.h', - \ 'is&o646\.h', '&stdbool\.h', 's&tdint\.h', - \ 'tg&math\.h', '&wchar\.h', 'wct&ype\.h', - \ ] -" -let s:Cpp_StandardLibs = [ - \ '&algorithm', '&bitset', '&complex', '&deque', - \ '&exception', '&fstream', 'f&unctional', 'iomani&p', - \ '&ios', 'iosf&wd', 'io&stream', 'istrea&m', - \ 'iterato&r', '&limits', 'lis&t', 'l&ocale', - \ '&map', 'memor&y', '&new', 'numeri&c', - \ '&ostream', '&queue', '&set', 'sst&ream', - \ 'st&ack', 'stde&xcept', 'stream&buf', 'str&ing', - \ '&typeinfo', '&utility', '&valarray', 'v&ector', - \ ] -" -let s:Cpp_CStandardLibs = [ - \ 'c&assert', 'c&ctype', 'c&errno', 'c&float', - \ 'c&limits', 'cl&ocale', 'c&math', 'cset&jmp', - \ 'cs&ignal', 'cstdar&g', 'cst&ddef', 'c&stdio', - \ 'cstdli&b', 'cst&ring', 'c&time', - \ ] - -let s:Cpp_IosFlagBits = [ - \ 'ios::&adjustfield', 'ios::bas&efield', 'ios::&boolalpha', - \ 'ios::&dec', 'ios::&fixed', 'ios::floa&tfield', - \ 'ios::&hex', 'ios::&internal', 'ios::&left', - \ 'ios::&oct', 'ios::&right', 'ios::s&cientific', - \ 'ios::sho&wbase', 'ios::showpoint\ \(&1\)', 'ios::show&pos', - \ 'ios::&skipws', 'ios::u&nitbuf', 'ios::&uppercase', - \ ] - -"------------------------------------------------------------------------------ -" C_CIncludeMenus: generate the C/C++-standard library menu entries {{{1 -"------------------------------------------------------------------------------ -function! C_CIncludeMenus ( menupath, liblist ) - for item in a:liblist - let replacement = substitute( item, '[&\\]*', '','g' ) - exe "anoremenu ".a:menupath.'.'.item.' i#include<'.replacement.'>' - exe "inoremenu ".a:menupath.'.'.item.' #include<'.replacement.'>' - endfor - return -endfunction " ---------- end of function C_CIncludeMenus ---------- - "------------------------------------------------------------------------------ -" C_CIosFlagMenus: generate the C++ ios flags menu entries {{{1 +" C_SaveGlobalOption {{{1 +" param 1 : option name +" param 2 : characters to be escaped (optional) "------------------------------------------------------------------------------ -function! C_CIosFlagMenus ( menupath, flaglist ) - for item in a:flaglist - let replacement = substitute( item, '[^[:alpha:]:]', '','g' ) - exe " noremenu ".a:menupath.'.'.item.' i'.replacement - exe "inoremenu ".a:menupath.'.'.item.' '.replacement - endfor - return -endfunction " ---------- end of function C_CIosFlagMenus ---------- +function! s:C_SaveGlobalOption ( option, ... ) + exe 'let escaped =&'.a:option + if a:0 == 0 + let escaped = escape( escaped, ' |"\' ) + else + let escaped = escape( escaped, ' |"\'.a:1 ) + endif + let s:C_saved_global_option[a:option] = escaped +endfunction " ---------- end of function C_SaveGlobalOption ---------- +" +"------------------------------------------------------------------------------ +" C_RestoreGlobalOption {{{1 +"------------------------------------------------------------------------------ +function! s:C_RestoreGlobalOption ( option ) + exe ':set '.a:option.'='.s:C_saved_global_option[a:option] +endfunction " ---------- end of function C_RestoreGlobalOption ---------- " "------------------------------------------------------------------------------ " C_Input: Input after a highlighted prompt {{{1 @@ -1254,50 +735,13 @@ function! C_EndOfLineComment ( ) range let diff = b:C_LineEndCommentColumn -1 -linelength endif exe "normal ".diff."A " - call C_InsertTemplate('comment.end-of-line-comment') + call mmtemplates#core#InsertTemplate(g:C_Templates, 'Comments.end-of-line-comment') if line > a:firstline normal k endif endfor endfunction " ---------- end of function C_EndOfLineComment ---------- " -"------------------------------------------------------------------------------ -" C_Comment_C_SectionAll: Section Comments {{{1 -"------------------------------------------------------------------------------ -function! C_Comment_C_SectionAll ( type ) - - call C_InsertTemplate("comment.file-section-cpp-header-includes") - call C_InsertTemplate("comment.file-section-cpp-macros") - call C_InsertTemplate("comment.file-section-cpp-typedefs") - call C_InsertTemplate("comment.file-section-cpp-data-types") - if a:type=="cpp" - call C_InsertTemplate("comment.file-section-cpp-class-defs") - endif - call C_InsertTemplate("comment.file-section-cpp-local-variables") - call C_InsertTemplate("comment.file-section-cpp-prototypes") - call C_InsertTemplate("comment.file-section-cpp-function-defs-exported") - call C_InsertTemplate("comment.file-section-cpp-function-defs-local") - if a:type=="cpp" - call C_InsertTemplate("comment.file-section-cpp-class-implementations-exported") - call C_InsertTemplate("comment.file-section-cpp-class-implementations-local") - endif - -endfunction " ---------- end of function C_Comment_C_SectionAll ---------- -" -function! C_Comment_H_SectionAll ( type ) - - call C_InsertTemplate("comment.file-section-hpp-header-includes") - call C_InsertTemplate("comment.file-section-hpp-macros") - call C_InsertTemplate("comment.file-section-hpp-exported-typedefs") - call C_InsertTemplate("comment.file-section-hpp-exported-data-types") - if a:type=="cpp" - call C_InsertTemplate("comment.file-section-hpp-exported-class-defs") - endif - call C_InsertTemplate("comment.file-section-hpp-exported-variables") - call C_InsertTemplate("comment.file-section-hpp-exported-function-declarations") - -endfunction " ---------- end of function C_Comment_H_SectionAll ---------- -" "---------------------------------------------------------------------- " C_CodeToCommentC : Code -> Comment {{{1 "---------------------------------------------------------------------- @@ -1485,19 +929,6 @@ function! C_PPIf0Remove () silent exe ':'.frstline.','.frstline.'d' endfunction " ---------- end of function C_PPIf0Remove ---------- -" -"------------------------------------------------------------------------------- -" C_LegalizeName : replace non-word characters by underscores -" - multiple whitespaces -" - multiple non-word characters -" - multiple underscores -"------------------------------------------------------------------------------- -function! C_LegalizeName ( name ) - let identifier = substitute( a:name, '\s\+', '_', 'g' ) - let identifier = substitute( identifier, '\W\+', '_', 'g' ) - let identifier = substitute( identifier, '_\+', '_', 'g' ) - return identifier -endfunction " ---------- end of function C_LegalizeName ---------- "------------------------------------------------------------------------------ " C_CodeSnippet : read / edit code snippet {{{1 @@ -1541,6 +972,19 @@ function! C_CodeSnippet(mode) :execute "update! | split | edit ".l:snippetfile endif endif + " + " update current buffer / split window / view snippet file + " + if a:mode == "view" + if has("gui_running") && s:C_GuiSnippetBrowser == 'gui' + let l:snippetfile=browse(0,"view a code snippet",s:C_CodeSnippets,"") + else + let l:snippetfile=input("view snippet ", s:C_CodeSnippets, "file" ) + endif + if !empty(l:snippetfile) + :execute "update! | split | view ".l:snippetfile + endif + endif " " write whole buffer into snippet file " @@ -1592,7 +1036,7 @@ endfunction " ---------- end of function C_ForTypeComplete ---------- "------------------------------------------------------------------------------ " C_CodeFor : for (idiom) {{{1 "------------------------------------------------------------------------------ -function! C_CodeFor( direction ) range +function! C_CodeFor( direction, ... ) range " let updown = ( a:direction == 'up' ? 'INCR.' : 'DECR.' ) let string = C_Input( '[TYPE (expand)] VARIABLE [START [END ['.updown.']]] : ', '', @@ -1604,7 +1048,7 @@ function! C_CodeFor( direction ) range let string = substitute( string, '\s\+', ' ', 'g' ) let nextindex = -1 let loopvar_type = '' - for item in s:C_ForTypes_Check_Order + for item in sort( copy( s:C_ForTypes ) ) let nextindex = matchend( string, '^'.item ) if nextindex > 0 let loopvar_type = item @@ -1646,7 +1090,9 @@ function! C_CodeFor( direction ) range if empty(startval) let startval = '0' endif - let zz= 'for ( '.loopvar_type.loopvar.' = '.startval.'; '.loopvar.' < '.endval.'; '.loopvar.' += '.incval." )" + let txt_init = loopvar_type.loopvar.' = '.startval + let txt_cond = loopvar.' < '.endval + let txt_incr = loopvar.' += '.incval else if empty(endval) let endval = '0' @@ -1654,45 +1100,21 @@ function! C_CodeFor( direction ) range if empty(startval) let startval = 'n-1' endif - let zz= 'for ( '.loopvar_type.loopvar.' = '.startval.'; '.loopvar.' >= '.endval.'; '.loopvar.' -= '.incval." )" - endif - " - " use internal formatting to avoid conficts when using == below - let equalprg_save = &equalprg - set equalprg= - - " ----- normal mode ---------------- - if a:firstline == a:lastline - let zz = zz." {\n}" - put =zz - normal k - normal 2== + let txt_init = loopvar_type.loopvar.' = '.startval + let txt_cond = loopvar.' >= '.endval + let txt_incr = loopvar.' -= '.incval endif - " ----- visual mode ---------------- - if a:firstline < a:lastline - let zz = zz.' {' - let zz2= '}' - exe ":".a:lastline."put =zz2" - exe ":".a:firstline."put! =zz" - :exe 'normal ='.(a:lastline-a:firstline+2).'+' - endif - " - " restore formatter programm - let &equalprg = equalprg_save " - " position the cursor - " - normal ^ - if missing == 1 - let match = search( '\<'.incval.'\>', 'W', line(".") ) + if a:0 == 0 + call mmtemplates#core#InsertTemplate ( g:C_Templates, 'Statements.for block', + \ '|INIT|', txt_init, '|CONDITION|', txt_cond, '|INCREMENT|', txt_incr, + \ 'range', a:firstline, a:lastline ) + elseif a:0 == 1 && a:1 == 'v' + call mmtemplates#core#InsertTemplate ( g:C_Templates, 'Statements.for block', + \ '|INIT|', txt_init, '|CONDITION|', txt_cond, '|INCREMENT|', txt_incr, + \ 'range', a:firstline, a:lastline, 'v' ) else - if missing == 2 - let match = search( '\<'.endval.'\>', 'W', line(".") ) - else - if missing == 3 - let match = search( '\<'.startval.'\>', 'W', line(".") ) - endif - endif + echohl WarningMsg | echomsg "for loop construction : unknown argument ".a:1 | echohl None endif " endfunction " ---------- end of function C_CodeFor ---------- @@ -1882,6 +1304,7 @@ function! C_Compile () let SouEsc = '"'.SouEsc.'"' let ObjEsc = '"'.ObjEsc.'"' endif + let compilerflags = '' " update : write source file if necessary exe ":update" @@ -1889,11 +1312,13 @@ function! C_Compile () " compilation if object does not exist or object exists and is older then the source if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou))) " &makeprg can be a string containing blanks - let makeprg_saved = '"'.&makeprg.'"' + call s:C_SaveGlobalOption('makeprg') if expand("%:e") == s:C_CExtension exe "setlocal makeprg=".s:C_CCompiler + let compilerflags = s:C_CFlags else exe "setlocal makeprg=".s:C_CplusCompiler + let compilerflags = s:C_CplusCFlags endif " " COMPILATION @@ -1901,14 +1326,14 @@ function! C_Compile () exe ":compiler ".s:C_VimCompilerName let v:statusmsg = '' let s:LastShellReturnCode = 0 - exe "make ".s:C_CFlags." ".SouEsc." -o ".ObjEsc - exe "setlocal makeprg=".makeprg_saved + exe "make ".compilerflags." ".SouEsc." -o ".ObjEsc if empty(v:statusmsg) let s:C_HlMessage = "'".Obj."' : compilation successful" endif if v:shell_error != 0 let s:LastShellReturnCode = v:shell_error endif + call s:C_RestoreGlobalOption('makeprg') " " open error window if necessary :redraw! @@ -1982,22 +1407,25 @@ function! C_Link () " object exists " source exists " object newer then source + let linkerflags = s:C_LFlags if filereadable(Obj) && (getftime(Obj) >= getftime(Sou)) - let makeprg_saved='"'.&makeprg.'"' + call s:C_SaveGlobalOption('makeprg') if expand("%:e") == s:C_CExtension exe "setlocal makeprg=".s:C_CCompiler + let linkerflags = s:C_LFlags else exe "setlocal makeprg=".s:C_CplusCompiler + let linkerflags = s:C_CplusLFlags endif exe ":compiler ".s:C_VimCompilerName let s:LastShellReturnCode = 0 let v:statusmsg = '' - silent exe "make ".s:C_LFlags." -o ".ExeEsc." ".ObjEsc." ".s:C_Libs + silent exe "make ".linkerflags." -o ".ExeEsc." ".ObjEsc." ".s:C_Libs if v:shell_error != 0 let s:LastShellReturnCode = v:shell_error endif - exe "setlocal makeprg=".makeprg_saved + call s:C_RestoreGlobalOption('makeprg') " if empty(v:statusmsg) let s:C_HlMessage = "'".Exe."' : linking successful" @@ -2041,9 +1469,9 @@ function! C_Run () "============================================================================== if s:C_OutputGvim == "vim" " - if s:C_MakeExecutableToRun !~ "^\s*$" - call C_HlMessage( "executable : '".s:C_MakeExecutableToRun."'" ) - exe '!'.Quote.s:C_MakeExecutableToRun.Quote.' '.l:arguments + if s:C_ExecutableToRun !~ "^\s*$" + call C_HlMessage( "executable : '".s:C_ExecutableToRun."'" ) + exe '!'.Quote.s:C_ExecutableToRun.Quote.' '.l:arguments else silent call C_Link() @@ -2068,7 +1496,7 @@ function! C_Run () if s:C_OutputGvim == "buffer" let l:currentbuffernr = bufnr("%") " - if s:C_MakeExecutableToRun =~ "^\s*$" + if s:C_ExecutableToRun =~ "^\s*$" call C_Link() endif if l:currentbuffer == bufname("%") @@ -2094,9 +1522,9 @@ function! C_Run () " run programm " setlocal modifiable - if s:C_MakeExecutableToRun !~ "^\s*$" - call C_HlMessage( "executable : '".s:C_MakeExecutableToRun."'" ) - exe '%!'.Quote.s:C_MakeExecutableToRun.Quote.' '.l:arguments + if s:C_ExecutableToRun !~ "^\s*$" + call C_HlMessage( "executable : '".s:C_ExecutableToRun."'" ) + exe '%!'.Quote.s:C_ExecutableToRun.Quote.' '.l:arguments setlocal nomodifiable " if winheight(winnr()) >= line("$") @@ -2126,13 +1554,13 @@ function! C_Run () "============================================================================== if s:C_OutputGvim == "xterm" " - if s:C_MakeExecutableToRun !~ "^\s*$" + if s:C_ExecutableToRun !~ "^\s*$" if s:MSWIN - exe '!'.Quote.s:C_MakeExecutableToRun.Quote.' '.l:arguments + exe '!'.Quote.s:C_ExecutableToRun.Quote.' '.l:arguments else - silent exe '!xterm -title '.s:C_MakeExecutableToRun.' '.s:C_XtermDefaults.' -e '.s:C_Wrapper.' '.s:C_MakeExecutableToRun.' '.l:arguments.' &' + silent exe '!xterm -title '.s:C_ExecutableToRun.' '.s:C_XtermDefaults.' -e '.s:C_Wrapper.' '.s:C_ExecutableToRun.' '.l:arguments.' &' :redraw! - call C_HlMessage( "executable : '".s:C_MakeExecutableToRun."'" ) + call C_HlMessage( "executable : '".s:C_ExecutableToRun."'" ) endif else @@ -2175,32 +1603,31 @@ endfunction " ---------- end of function C_Arguments ---------- " C_Toggle_Gvim_Xterm : change output destination {{{1 "---------------------------------------------------------------------- function! C_Toggle_Gvim_Xterm () - if s:C_OutputGvim == "vim" - exe "aunmenu ".s:MenuRun.'.&output:\ VIM->buffer->xterm' - exe "amenu ".s:MenuRun.'.&output:\ BUFFER->xterm->vim\\ro :call C_Toggle_Gvim_Xterm()' - exe "imenu ".s:MenuRun.'.&output:\ BUFFER->xterm->vim\\ro :call C_Toggle_Gvim_Xterm()' + exe "aunmenu ".s:MenuRun.'.&output:\ '.s:output1 + exe "amenu ".s:MenuRun.'.&output:\ '.s:output2.'\\ro :call C_Toggle_Gvim_Xterm()' + exe "imenu ".s:MenuRun.'.&output:\ '.s:output2.'\\ro :call C_Toggle_Gvim_Xterm()' let s:C_OutputGvim = "buffer" else if s:C_OutputGvim == "buffer" - exe "aunmenu ".s:MenuRun.'.&output:\ BUFFER->xterm->vim' + exe "aunmenu ".s:MenuRun.'.&output:\ '.s:output2 if (!s:MSWIN) - exe "amenu ".s:MenuRun.'.&output:\ XTERM->vim->buffer\\ro :call C_Toggle_Gvim_Xterm()' - exe "imenu ".s:MenuRun.'.&output:\ XTERM->vim->buffer\\ro :call C_Toggle_Gvim_Xterm()' + exe "amenu ".s:MenuRun.'.&output:\ '.s:output3.'\\ro :call C_Toggle_Gvim_Xterm()' + exe "imenu ".s:MenuRun.'.&output:\ '.s:output3.'\\ro :call C_Toggle_Gvim_Xterm()' else - exe "amenu ".s:MenuRun.'.&output:\ VIM->buffer->xterm\\ro :call C_Toggle_Gvim_Xterm()' - exe "imenu ".s:MenuRun.'.&output:\ VIM->buffer->xterm\\ro :call C_Toggle_Gvim_Xterm()' + exe "amenu ".s:MenuRun.'.&output:\ '.s:output1.'\\ro :call C_Toggle_Gvim_Xterm()' + exe "imenu ".s:MenuRun.'.&output:\ '.s:output1.'\\ro :call C_Toggle_Gvim_Xterm()' endif - if (!s:MSWIN) && (!empty($Display)) + if (!s:MSWIN) let s:C_OutputGvim = "xterm" else let s:C_OutputGvim = "vim" endif else " ---------- output : xterm -> gvim - exe "aunmenu ".s:MenuRun.'.&output:\ XTERM->vim->buffer' - exe "amenu ".s:MenuRun.'.&output:\ VIM->buffer->xterm\\ro :call C_Toggle_Gvim_Xterm()' - exe "imenu ".s:MenuRun.'.&output:\ VIM->buffer->xterm\\ro :call C_Toggle_Gvim_Xterm()' + exe "aunmenu ".s:MenuRun.'.&output:\ '.s:output3 + exe "amenu ".s:MenuRun.'.&output:\ '.s:output1.'\\ro :call C_Toggle_Gvim_Xterm()' + exe "imenu ".s:MenuRun.'.&output:\ '.s:output1.'\\ro :call C_Toggle_Gvim_Xterm()' let s:C_OutputGvim = "vim" endif endif @@ -2227,17 +1654,23 @@ endfunction " ---------- end of function C_XtermSize ---------- "------------------------------------------------------------------------------ " run make(1) {{{1 "------------------------------------------------------------------------------ -let s:C_MakeCmdLineArgs = '' " command line arguments for Run-make; initially empty -let s:C_MakeExecutableToRun = '' +let s:C_ExecutableToRun = '' let s:C_Makefile = '' +let s:C_MakeCmdLineArgs = '' " command line arguments for Run-make; initially empty " "------------------------------------------------------------------------------ " C_ChooseMakefile : choose a makefile {{{1 "------------------------------------------------------------------------------ function! C_ChooseMakefile () let s:C_Makefile = '' - " the path will be escaped: - let s:C_Makefile = C_Input ( "choose a Makefile: ", getcwd(), "file" ) + let mkfile = findfile( "Makefile", ".;" ) " try to find a Makefile + if mkfile == '' + let mkfile = findfile( "makefile", ".;" ) " try to find a makefile + endif + if mkfile == '' + let mkfile = getcwd() + endif + let s:C_Makefile = C_Input ( "choose a Makefile: ", mkfile, "file" ) if s:MSWIN let s:C_Makefile = substitute( s:C_Makefile, '\\ ', ' ', 'g' ) endif @@ -2272,13 +1705,13 @@ endfunction " ---------- end of function C_Make ---------- function! C_MakeClean() " run make clean if s:C_Makefile == '' - exe ":make clean" + exe ":!make clean" else exe ':lchdir '.fnamemodify( s:C_Makefile, ":p:h" ) if s:MSWIN - exe ':make -f "'.s:C_Makefile.'" clean' + exe ':!make -f "'.s:C_Makefile.'" clean' else - exe ':make -f '.s:C_Makefile.' clean' + exe ':!make -f '.s:C_Makefile.' clean' endif exe ":lchdir -" endif @@ -2292,17 +1725,17 @@ function! C_MakeArguments () endfunction " ---------- end of function C_MakeArguments ---------- "------------------------------------------------------------------------------ -" C_MakeExeToRun : choose executable to run {{{1 +" C_ExeToRun : choose executable to run {{{1 "------------------------------------------------------------------------------ -function! C_MakeExeToRun () - let s:C_MakeExecutableToRun = C_Input( 'executable to run [tab compl.]: ', '', 'file' ) - if s:C_MakeExecutableToRun !~ "^\s*$" +function! C_ExeToRun () + let s:C_ExecutableToRun = C_Input( 'executable to run [tab compl.]: ', '', 'file' ) + if s:C_ExecutableToRun !~ "^\s*$" if s:MSWIN - let s:C_MakeExecutableToRun = substitute(s:C_MakeExecutableToRun, '\\ ', ' ', 'g' ) + let s:C_ExecutableToRun = substitute(s:C_ExecutableToRun, '\\ ', ' ', 'g' ) endif - let s:C_MakeExecutableToRun = escape( getcwd().'/', s:C_FilenameEscChar ).s:C_MakeExecutableToRun + let s:C_ExecutableToRun = escape( getcwd().'/', s:C_FilenameEscChar ).s:C_ExecutableToRun endif -endfunction " ---------- end of function C_MakeExeToRun ---------- +endfunction " ---------- end of function C_ExeToRun ---------- " "------------------------------------------------------------------------------ " C_SplintArguments : splint command line arguments {{{1 @@ -2336,7 +1769,7 @@ function! C_SplintCheck () let s:C_HlMessage = "" exe ":cclose" silent exe ":update" - let makeprg_saved='"'.&makeprg.'"' + call s:C_SaveGlobalOption('makeprg') " Windows seems to need this: if s:MSWIN :compiler splint @@ -2345,7 +1778,7 @@ function! C_SplintCheck () " let l:arguments = exists("b:C_SplintCmdLineArgs") ? b:C_SplintCmdLineArgs : ' ' silent exe "make ".l:arguments." ".escape(l:currentbuffer,s:C_FilenameEscChar) - exe "setlocal makeprg=".makeprg_saved + call s:C_RestoreGlobalOption('makeprg') exe ":botright cwindow" " " message in case of success @@ -2356,6 +1789,89 @@ function! C_SplintCheck () endfunction " ---------- end of function C_SplintCheck ---------- " "------------------------------------------------------------------------------ +" C_CppcheckCheck : run cppcheck(1) {{{1 +"------------------------------------------------------------------------------ +function! C_CppcheckCheck () + if s:C_CppcheckIsExecutable==0 + let s:C_HlMessage = ' Cppcheck is not executable or not installed! ' + return + endif + let l:currentbuffer=bufname("%") + if &filetype != "c" && &filetype != "cpp" + let s:C_HlMessage = ' "'.l:currentbuffer.'" seems not to be a C/C++ file ' + return + endif + let s:C_HlMessage = "" + exe ":cclose" + silent exe ":update" + call s:C_SaveGlobalOption('makeprg') + " + call s:C_SaveGlobalOption('errorformat') + setlocal errorformat=[%f:%l]:%m + " Windows seems to need this: + if s:MSWIN + :compiler cppcheck + endif + :setlocal makeprg=cppcheck + " + silent exe "make --enable=".s:C_CppcheckSeverity.' '.escape(l:currentbuffer,s:C_FilenameEscChar) + call s:C_RestoreGlobalOption('makeprg') + exe ":botright cwindow" + " + " message in case of success + " + if l:currentbuffer == bufname("%") + let s:C_HlMessage = " Cppcheck --- no warnings for : ".l:currentbuffer + endif +endfunction " ---------- end of function C_CppcheckCheck ---------- + +"=== FUNCTION ================================================================ +" NAME: C_CppcheckSeverityList {{{1 +" DESCRIPTION: cppcheck severity : callback function for completion +" PARAMETERS: ArgLead - +" CmdLine - +" CursorPos - +" RETURNS: +"=============================================================================== +function! C_CppcheckSeverityList ( ArgLead, CmdLine, CursorPos ) + return filter( copy( s:CppcheckSeverity ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) +endfunction " ---------- end of function C_CppcheckSeverityList ---------- + +"=== FUNCTION ================================================================ +" NAME: C_GetCppcheckSeverity {{{1 +" DESCRIPTION: cppcheck severity : used in command definition +" PARAMETERS: severity - cppcheck severity +" RETURNS: +"=============================================================================== +function! C_GetCppcheckSeverity ( severity ) + let sev = a:severity + let sev = substitute( sev, '^\s\+', '', '' ) " remove leading whitespaces + let sev = substitute( sev, '\s\+$', '', '' ) " remove trailing whitespaces + " + if index( s:CppcheckSeverity, tolower(sev) ) >= 0 + let s:C_CppcheckSeverity = sev + echomsg "cppcheck severity is set to '".s:C_CppcheckSeverity."'" + else + let s:C_CppcheckSeverity = 'all' " the default + echomsg "wrong argument '".a:severity."' / severity is set to '".s:C_CppcheckSeverity."'" + endif + " +endfunction " ---------- end of function C_GetCppcheckSeverity ---------- +" +"=== FUNCTION ================================================================ +" NAME: C_CppcheckSeverityInput +" DESCRIPTION: read cppcheck severity from the command line +" PARAMETERS: - +" RETURNS: +"=============================================================================== +function! C_CppcheckSeverityInput () + let retval = input( "cppcheck severity (current = '".s:C_CppcheckSeverity."' / tab exp.): ", '', 'customlist,C_CppcheckSeverityList' ) + redraw! + call C_GetCppcheckSeverity( retval ) + return +endfunction " ---------- end of function C_CppcheckSeverityInput ---------- +" +"------------------------------------------------------------------------------ " C_CodeCheckArguments : CodeCheck command line arguments {{{1 "------------------------------------------------------------------------------ function! C_CodeCheckArguments () @@ -2387,21 +1903,22 @@ function! C_CodeCheck () let s:C_HlMessage = "" exe ":cclose" silent exe ":update" - let makeprg_saved='"'.&makeprg.'"' + call s:C_SaveGlobalOption('makeprg') exe "setlocal makeprg=".s:C_CodeCheckExeName " " match the splint error messages (quickfix commands) " ignore any lines that didn't match one of the patterns " - :setlocal errorformat=%f(%l)%m + call s:C_SaveGlobalOption('errorformat') + setlocal errorformat=%f(%l)%m " let l:arguments = exists("b:C_CodeCheckCmdLineArgs") ? b:C_CodeCheckCmdLineArgs : "" if empty( l:arguments ) let l:arguments = s:C_CodeCheckOptions endif exe ":make ".l:arguments." ".escape( l:currentbuffer, s:C_FilenameEscChar ) - exe ':setlocal errorformat=' - exe ":setlocal makeprg=".makeprg_saved + call s:C_RestoreGlobalOption('errorformat') + call s:C_RestoreGlobalOption('makeprg') exe ":botright cwindow" " " message in case of success @@ -2416,7 +1933,7 @@ endfunction " ---------- end of function C_CodeCheck ---------- "------------------------------------------------------------------------------ " function! C_Indent ( ) - if !executable("indent") + if s:C_IndentIsExecutable == 0 echomsg 'indent is not executable or not installed!' return endif @@ -2436,6 +1953,7 @@ function! C_Indent ( ) else silent exe ":%!indent 2> ".s:C_IndentErrorLog redraw! + call s:C_SaveGlobalOption('errorformat') if getfsize( s:C_IndentErrorLog ) > 0 exe ':edit! '.s:C_IndentErrorLog let errorlogbuffer = bufnr("%") @@ -2447,7 +1965,7 @@ function! C_Indent ( ) else echomsg 'File "'.l:currentbuffer.'" reformatted.' endif - setlocal errorformat= + call s:C_RestoreGlobalOption('errorformat') endif endfunction " ---------- end of function C_Indent ---------- @@ -2471,26 +1989,29 @@ endfunction " ---------- end of function C_HlMessage ---------- "------------------------------------------------------------------------------ function! C_Settings () let txt = " C/C++-Support settings\n\n" - let txt = txt.' author : "'.s:C_Macro['|AUTHOR|']."\"\n" - let txt = txt.' authorref : "'.s:C_Macro['|AUTHORREF|']."\"\n" - let txt = txt.' company : "'.s:C_Macro['|COMPANY|']."\"\n" - let txt = txt.' copyright holder : "'.s:C_Macro['|COPYRIGHTHOLDER|']."\"\n" - let txt = txt.' email : "'.s:C_Macro['|EMAIL|']."\"\n" - let txt = txt.' licence : "'.s:C_Macro['|LICENSE|']."\"\n" - let txt = txt.' organization : "'.s:C_Macro['|ORGANIZATION|']."\"\n" - let txt = txt.' project : "'.s:C_Macro['|PROJECT|']."\"\n" + let txt = txt.' author : "'.mmtemplates#core#ExpandText( g:C_Templates, '|AUTHOR|' )."\"\n" + let txt = txt.' authorref : "'.mmtemplates#core#ExpandText( g:C_Templates, '|AUTHORREF|' )."\"\n" + let txt = txt.' company : "'.mmtemplates#core#ExpandText( g:C_Templates, '|COMPANY|' )."\"\n" + let txt = txt.' copyright holder : "'.mmtemplates#core#ExpandText( g:C_Templates, '|COPYRIGHT|' )."\"\n" + let txt = txt.' email : "'.mmtemplates#core#ExpandText( g:C_Templates, '|EMAIL|' )."\"\n" + let txt = txt.' licence : "'.mmtemplates#core#ExpandText( g:C_Templates, '|LICENSE|' )."\"\n" + let txt = txt.' organization : "'.mmtemplates#core#ExpandText( g:C_Templates, '|ORGANIZATION|')."\"\n" + let txt = txt.' project : "'.mmtemplates#core#ExpandText( g:C_Templates, '|PROJECT|' )."\"\n" let txt = txt.' C / C++ compiler : '.s:C_CCompiler.' / '.s:C_CplusCompiler."\n" let txt = txt.' C file extension : "'.s:C_CExtension.'" (everything else is C++)'."\n" let txt = txt.' extension for objects : "'.s:C_ObjExtension."\"\n" let txt = txt.'extension for executables : "'.s:C_ExeExtension."\"\n" - let txt = txt.' compiler flags : "'.s:C_CFlags."\"\n" - let txt = txt.' linker flags : "'.s:C_LFlags."\"\n" - let txt = txt.' libraries : "'.s:C_Libs."\"\n" + let txt = txt.' compiler flags (C) : "'.s:C_CFlags."\"\n" + let txt = txt.' linker flags (C) : "'.s:C_LFlags."\"\n" + let txt = txt.' libraries (C) : "'.s:C_Libs."\"\n" + let txt = txt.' compiler flags (C++) : "'.s:C_CplusCFlags."\"\n" + let txt = txt.' linker flags (C++) : "'.s:C_CplusLFlags."\"\n" + let txt = txt.' libraries (C++) : "'.s:C_CplusLibs."\"\n" let txt = txt.' code snippet directory : "'.s:C_CodeSnippets."\"\n" " ----- template files ------------------------ - let txt = txt.' template style : "'.s:C_ActualStyle."\"\n" - let txt = txt.' plugin installation : "'.s:installation."\"\n" - if s:installation == 'system' + let txt = txt.' template style : "'.mmtemplates#core#Resource ( g:C_Templates, "style" )[0]."\"\n" + let txt = txt.' plugin installation : "'.g:C_Installation."\"\n" + if g:C_Installation == 'system' let txt = txt.'global template directory : '.s:C_GlobalTemplateDir."\n" if filereadable( s:C_LocalTemplateFile ) let txt = txt.' local template directory : '.s:C_LocalTemplateDir."\n" @@ -2517,6 +2038,10 @@ function! C_Settings () endif let txt = txt." splint options(s) : ".ausgabe."\n" endif + " ----- cppcheck ------------------------------ + if s:C_CppcheckIsExecutable==1 + let txt = txt." cppcheck severity : ".s:C_CppcheckSeverity."\n" + endif " ----- code check -------------------------- if s:C_CodeCheckIsExecutable==1 if exists("b:C_CodeCheckCmdLineArgs") @@ -2528,7 +2053,7 @@ function! C_Settings () endif let txt = txt."\n" let txt = txt."__________________________________________________________________________\n" - let txt = txt." C/C++-Support, Version ".g:C_Version." / Dr.-Ing. Fritz Mehner / mehner@fh-swf.de\n\n" + let txt = txt." C/C++-Support, Version ".g:C_Version." / Dr.-Ing. Fritz Mehner / mehner.fritz@fh-swf.de\n\n" echo txt endfunction " ---------- end of function C_Settings ---------- " @@ -2722,88 +2247,83 @@ function! C_CreateGuiMenus () aunmenu &Tools.Load\ C\ Support amenu 40.1000 &Tools.-SEP100- : amenu 40.1030 &Tools.Unload\ C\ Support :call C_RemoveGuiMenus() - call C_InitMenus() - let s:C_MenusVisible = 'yes' + call s:C_RereadTemplates('no') + call s:C_InitMenus() + let s:C_MenusVisible = 'yes' endif endfunction " ---------- end of function C_CreateGuiMenus ---------- -"------------------------------------------------------------------------------ -" C_ToolMenu {{{1 -"------------------------------------------------------------------------------ -function! C_ToolMenu () - amenu 40.1000 &Tools.-SEP100- : - amenu 40.1030 &Tools.Load\ C\ Support :call C_CreateGuiMenus() - imenu 40.1030 &Tools.Load\ C\ Support :call C_CreateGuiMenus() -endfunction " ---------- end of function C_ToolMenu ---------- - -"------------------------------------------------------------------------------ -" C_RemoveGuiMenus {{{1 -"------------------------------------------------------------------------------ -function! C_RemoveGuiMenus () - if s:C_MenusVisible == 'yes' - exe "aunmenu ".s:C_Root - " - aunmenu &Tools.Unload\ C\ Support - call C_ToolMenu() - " - let s:C_MenusVisible = 'no' +function! C_CheckAndRereadTemplates () + if s:C_TemplatesLoaded == 'no' + call s:C_RereadTemplates('no') + let s:C_TemplatesLoaded = 'yes' endif -endfunction " ---------- end of function C_RemoveGuiMenus ---------- +endfunction " ---------- end of function C_CheckAndRereadTemplates ---------- -"------------------------------------------------------------------------------ -" C_RereadTemplates {{{1 -" rebuild commands and the menu from the (changed) template file -"------------------------------------------------------------------------------ -function! C_RereadTemplates ( msg ) - let s:style = 'default' - let s:C_Template = { 'default' : {} } - let s:C_FileVisited = [] - let messsage = '' +"=== FUNCTION ================================================================ +" NAME: C_RereadTemplates {{{1 +" DESCRIPTION: rebuild commands and the menu from the (changed) template file +" PARAMETERS: displaymsg - yes / no +" RETURNS: +"=============================================================================== +function! s:C_RereadTemplates ( displaymsg ) + let g:C_Templates = mmtemplates#core#NewLibrary () + call mmtemplates#core#ChangeSyntax ( g:C_Templates, 'comment', '§', '§' ) + let s:C_TemplateJumpTarget = mmtemplates#core#Resource ( g:C_Templates, "jumptag" )[0] + + let messsage = '' " - if s:installation == 'system' + if g:C_Installation == 'system' "------------------------------------------------------------------------------- - " system installation + " SYSTEM INSTALLATION "------------------------------------------------------------------------------- if filereadable( s:C_GlobalTemplateFile ) - call C_ReadTemplates( s:C_GlobalTemplateFile ) + call mmtemplates#core#ReadTemplates ( g:C_Templates, 'load', s:C_GlobalTemplateFile ) else echomsg "Global template file '".s:C_GlobalTemplateFile."' not readable." return endif let messsage = "Templates read from '".s:C_GlobalTemplateFile."'" " - if filereadable( s:C_LocalTemplateFile ) - call C_ReadTemplates( s:C_LocalTemplateFile ) - let messsage = messsage." and '".s:C_LocalTemplateFile."'" - if s:C_Macro['|AUTHOR|'] == 'YOUR NAME' - echomsg "Please set your personal details in file '".s:C_LocalTemplateFile."'." + "------------------------------------------------------------------------------- + " handle local template files + "------------------------------------------------------------------------------- + if finddir( s:C_LocalTemplateDir ) == '' + " try to create a local template directory + if exists("*mkdir") + try + call mkdir( s:C_LocalTemplateDir, "p" ) + catch /.*/ + endtry endif - else - let template = [ '|AUTHOR| = YOUR NAME', - \ '|COPYRIGHT| = Copyright (c) |YEAR|, |AUTHOR|' - \ ] - if finddir( s:C_LocalTemplateDir ) == '' - " try to create a local template directory - if exists("*mkdir") - try - call mkdir( s:C_LocalTemplateDir, "p" ) - " write a default local template file - call writefile( template, s:C_LocalTemplateFile ) - catch /.*/ - endtry - endif - else - " write a default local template file + endif + + if isdirectory( s:C_LocalTemplateDir ) && !filereadable( s:C_LocalTemplateFile ) + " write a default local template file + let template = [ ] + let sample_template_file = fnamemodify( s:C_GlobalTemplateDir, ':h' ).'/rc/sample_template_file' + if filereadable( sample_template_file ) + for line in readfile( sample_template_file ) + call add( template, line ) + endfor call writefile( template, s:C_LocalTemplateFile ) endif endif " + if filereadable( s:C_LocalTemplateFile ) + call mmtemplates#core#ReadTemplates ( g:C_Templates, 'load', s:C_LocalTemplateFile ) + let messsage = messsage." and '".s:C_LocalTemplateFile."'" + if mmtemplates#core#ExpandText( g:C_Templates, '|AUTHOR|' ) == 'YOUR NAME' + echomsg "Please set your personal details in file '".s:C_LocalTemplateFile."'." + endif + endif + " else "------------------------------------------------------------------------------- - " local installation + " LOCAL INSTALLATION "------------------------------------------------------------------------------- if filereadable( s:C_LocalTemplateFile ) - call C_ReadTemplates( s:C_LocalTemplateFile ) + call mmtemplates#core#ReadTemplates ( g:C_Templates, 'load', s:C_LocalTemplateFile ) let messsage = "Templates read from '".s:C_LocalTemplateFile."'" else echomsg "Local template file '".s:C_LocalTemplateFile."' not readable." @@ -2811,183 +2331,34 @@ function! C_RereadTemplates ( msg ) endif " endif - if a:msg == 'yes' + if a:displaymsg == 'yes' echomsg messsage.'.' endif -endfunction " ---------- end of function C_RereadTemplates ---------- -" -"------------------------------------------------------------------------------ -" C_BrowseTemplateFiles {{{1 -"------------------------------------------------------------------------------ -function! C_BrowseTemplateFiles ( type ) - let templatefile = eval( 's:C_'.a:type.'TemplateFile' ) - let templatedir = eval( 's:C_'.a:type.'TemplateDir' ) - if isdirectory( templatedir ) - if has("browse") && s:C_GuiTemplateBrowser == 'gui' - let l:templatefile = browse(0,"edit a template file", templatedir, "" ) - else - let l:templatefile = '' - if s:C_GuiTemplateBrowser == 'explorer' - exe ':Explore '.templatedir - endif - if s:C_GuiTemplateBrowser == 'commandline' - let l:templatefile = input("edit a template file", templatedir, "file" ) - endif - endif - if !empty(l:templatefile) - :execute "update! | split | edit ".l:templatefile - endif - else - echomsg "Template directory '".templatedir."' does not exist." - endif -endfunction " ---------- end of function C_BrowseTemplateFiles ---------- +endfunction " ---------- end of function s:C_RereadTemplates ---------- "------------------------------------------------------------------------------ -" C_ReadTemplates {{{1 -" read the template file(s), build the macro and the template dictionary -" +" C_ToolMenu {{{1 "------------------------------------------------------------------------------ -let s:style = 'default' - -function! C_CheckAndRereadTemplates () - if s:C_TemplatesLoaded == 'no' - call C_RereadTemplates('no') - let s:C_TemplatesLoaded = 'yes' - endif -endfunction " ---------- end of function C_CheckAndRereadTemplates ---------- - -function! C_ReadTemplates ( templatefile ) - - if !filereadable( a:templatefile ) - echohl WarningMsg - echomsg "C/C++ template file '".a:templatefile."' does not exist or is not readable" - echohl None - return - endif - - let skipmacros = 0 - let s:C_FileVisited += [a:templatefile] - - "------------------------------------------------------------------------------ - " read template file, start with an empty template dictionary - "------------------------------------------------------------------------------ - - let item = '' - let skipline = 0 - for line in readfile( a:templatefile ) - " if not a comment : - if line !~ s:C_MacroCommentRegex - " - "------------------------------------------------------------------------------- - " IF |STYLE| IS ... - "------------------------------------------------------------------------------- - " - let string = matchlist( line, s:C_TemplateIf ) - if !empty(string) - if !has_key( s:C_Template, string[1] ) - " new s:style - let s:style = string[1] - let s:C_Template[s:style] = {} - continue - endif - endif - " - "------------------------------------------------------------------------------- - " ENDIF - "------------------------------------------------------------------------------- - " - let string = matchlist( line, s:C_TemplateEndif ) - if !empty(string) - let s:style = 'default' - continue - endif - " - " macros and file includes - " - let string = matchlist( line, s:C_MacroLineRegex ) - if !empty(string) && skipmacros == 0 - let key = '|'.string[1].'|' - let val = string[2] - let val = substitute( val, '\s\+$', '', '' ) - let val = substitute( val, "[\"\']$", '', '' ) - let val = substitute( val, "^[\"\']", '', '' ) - " - if key == '|includefile|' && count( s:C_FileVisited, val ) == 0 - let path = fnamemodify( a:templatefile, ":p:h" ) - call C_ReadTemplates( path.'/'.val ) " recursive call - else - let s:C_Macro[key] = escape( val, '&' ) - endif - continue " next line - endif - " - " template header - " - let name = matchstr( line, s:C_TemplateLineRegex ) - " - if !empty(name) - let part = split( name, '\s*==\s*') - let item = part[0] - if has_key( s:C_Template[s:style], item ) && s:C_TemplateOverriddenMsg == 'yes' - echomsg "existing C/C++ template '".item."' overwritten" - endif - let s:C_Template[s:style][item] = '' - let skipmacros = 1 - " - let s:C_Attribute[item] = 'below' - if has_key( s:Attribute, get( part, 1, 'NONE' ) ) - let s:C_Attribute[item] = part[1] - endif - else - if !empty(item) - let s:C_Template[s:style][item] .= line."\n" - endif - endif - endif - " - endfor " --------- read line --------- - - let s:C_ActualStyle = 'default' - if !empty( s:C_Macro['|STYLE|'] ) - let s:C_ActualStyle = s:C_Macro['|STYLE|'] - endif - let s:C_ActualStyleLast = s:C_ActualStyle - - call C_SetSmallCommentStyle() -endfunction " ---------- end of function C_ReadTemplates ---------- +function! C_ToolMenu () + amenu 40.1000 &Tools.-SEP100- : + amenu 40.1030 &Tools.Load\ C\ Support :call C_CreateGuiMenus() + imenu 40.1030 &Tools.Load\ C\ Support :call C_CreateGuiMenus() +endfunction " ---------- end of function C_ToolMenu ---------- "------------------------------------------------------------------------------ -" C_Style{{{1 -" ex-command CStyle : callback function +" C_RemoveGuiMenus {{{1 "------------------------------------------------------------------------------ -function! C_Style ( style ) - call C_CheckAndRereadTemplates() - let lstyle = substitute( a:style, '^\s\+', "", "" ) " remove leading whitespaces - let lstyle = substitute( lstyle, '\s\+$', "", "" ) " remove trailing whitespaces - if has_key( s:C_Template, lstyle ) - if len( s:C_Template[lstyle] ) == 0 - echomsg "style '".lstyle."' : no templates defined" - return - endif - let s:C_ActualStyleLast = s:C_ActualStyle - let s:C_ActualStyle = lstyle - if len( s:C_ActualStyle ) > 1 && s:C_ActualStyle != s:C_ActualStyleLast - echomsg "template style is '".lstyle."'" - endif - else - echomsg "style '".lstyle."' does not exist" +function! C_RemoveGuiMenus () + if s:C_MenusVisible == 'yes' + exe "aunmenu ".s:C_RootMenu + " + aunmenu &Tools.Unload\ C\ Support + call C_ToolMenu() + " + let s:C_MenusVisible = 'no' endif -endfunction " ---------- end of function C_Style ---------- - -"------------------------------------------------------------------------------ -" C_StyleList {{{1 -" ex-command CStyle -"------------------------------------------------------------------------------ -function! C_StyleList ( ArgLead, CmdLine, CursorPos ) - " show all types / types beginning with a:ArgLead - return filter( copy(keys( s:C_Template) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) -endfunction " ---------- end of function C_StyleList ---------- +endfunction " ---------- end of function C_RemoveGuiMenus ---------- "------------------------------------------------------------------------------ " C_OpenFold {{{1 @@ -3009,217 +2380,6 @@ function! C_OpenFold ( mode ) endif endfunction " ---------- end of function C_OpenFold ---------- -"------------------------------------------------------------------------------ -" C_InsertTemplate {{{1 -" insert a template from the template dictionary -" do macro expansion -"------------------------------------------------------------------------------ -function! C_InsertTemplate ( key, ... ) - - if s:C_TemplatesLoaded == 'no' - call C_RereadTemplates('no') - let s:C_TemplatesLoaded = 'yes' - endif - - if !has_key( s:C_Template[s:C_ActualStyle], a:key ) && - \ !has_key( s:C_Template['default'], a:key ) - echomsg "style '".a:key."' / template '".a:key - \ ."' not found. Please check your template file in '".s:C_GlobalTemplateDir."'" - return - endif - - if &foldenable - let foldmethod_save = &foldmethod - set foldmethod=manual - endif - "------------------------------------------------------------------------------ - " insert the user macros - "------------------------------------------------------------------------------ - - " use internal formatting to avoid conficts when using == below - " - let equalprg_save = &equalprg - set equalprg= - - let mode = s:C_Attribute[a:key] - - " remove and insert the complete macro - " - if a:0 == 0 - let val = C_ExpandUserMacros (a:key) - if empty(val) - return - endif - let val = C_ExpandSingleMacro( val, '', '' ) - - if mode == 'below' - call C_OpenFold('below') - let pos1 = line(".")+1 - put =val - let pos2 = line(".") - " proper indenting - exe ":".pos1 - let ins = pos2-pos1+1 - exe "normal ".ins."==" - " - elseif mode == 'above' - let pos1 = line(".") - put! =val - let pos2 = line(".") - " proper indenting - exe ":".pos1 - let ins = pos2-pos1+1 - exe "normal ".ins."==" - " - elseif mode == 'start' - normal gg - call C_OpenFold('start') - let pos1 = 1 - put! =val - let pos2 = line(".") - " proper indenting - exe ":".pos1 - let ins = pos2-pos1+1 - exe "normal ".ins."==" - " - elseif mode == 'append' - if &foldenable && foldclosed(".") >= 0 - echohl WarningMsg | echomsg s:MsgInsNotAvail | echohl None - exe "set foldmethod=".foldmethod_save - return - else - let pos1 = line(".") - put =val - let pos2 = line(".")-1 - exe ":".pos1 - :join! - endif - " - elseif mode == 'insert' - if &foldenable && foldclosed(".") >= 0 - echohl WarningMsg | echomsg s:MsgInsNotAvail | echohl None - exe "set foldmethod=".foldmethod_save - return - else - let val = substitute( val, '\n$', '', '' ) - let currentline = getline( "." ) - let pos1 = line(".") - let pos2 = pos1 + count( split(val,'\zs'), "\n" ) - " assign to the unnamed register "" : - exe 'normal! a'.val - " reformat only multiline inserts and previously empty lines - if pos2-pos1 > 0 || currentline =~ '' - exe ":".pos1 - let ins = pos2-pos1+1 - exe "normal ".ins."==" - endif - endif - " - endif - " - else - " - " ===== visual mode =============================== - " - if a:1 == 'v' - let val = C_ExpandUserMacros (a:key) - let val = C_ExpandSingleMacro( val, s:C_TemplateJumpTarget2, '' ) - if empty(val) - return - endif - - if match( val, '\s*\n' ) >= 0 - let part = split( val, '\s*\n' ) - else - let part = split( val, '' ) - endif - - if len(part) < 2 - let part = [ "" ] + part - echomsg 'SPLIT missing in template '.a:key - endif - " - " 'visual' and mode 'insert': - " - " part0 and part1 can consist of several lines - " - if mode == 'insert' - let pos1 = line(".") - let pos2 = pos1 - " windows: recover area of the visual mode and yank, puts the selected area in the buffer - normal gvy - let string = eval('@"') - let replacement = part[0].string.part[1] - " remove trailing '\n' - let replacement = substitute( replacement, '\n$', '', '' ) - exe ':s/'.string.'/'.replacement.'/' - endif - " - " 'visual' and mode 'below': - " - " - " - " part0 and part1 can consist of several lines - " - if mode == 'below' - - :'put =part[1] - - let pos1 = line("'<") - len(split(part[0], '\n' )) - let pos2 = line("'>") + len(split(part[1], '\n' )) - "" echo part[0] part[1] pos1 pos2 - " " proper indenting - exe ":".pos1 - let ins = pos2-pos1+1 - exe "normal ".ins."==" - endif - " - endif " ---------- end visual mode - endif - - " restore formatter programm - let &equalprg = equalprg_save - - "------------------------------------------------------------------------------ - " position the cursor - "------------------------------------------------------------------------------ - exe ":".pos1 - let mtch = search( '\|{CURSOR}', 'c', pos2 ) - if mtch != 0 - let line = getline(mtch) - if line =~ '$\|{CURSOR}$' - call setline( mtch, substitute( line, '\|{CURSOR}', '', '' ) ) - if a:0 != 0 && a:1 == 'v' && getline(".") =~ '^\s*$' - normal J - else - :startinsert! - endif - else - call setline( mtch, substitute( line, '\|{CURSOR}', '', '' ) ) - :startinsert - endif - else - " to the end of the block; needed for repeated inserts - if mode == 'below' - exe ":".pos2 - endif - endif - - "------------------------------------------------------------------------------ - " marked words - "------------------------------------------------------------------------------ - " define a pattern to highlight - call C_HighlightJumpTargets () - - if &foldenable - " restore folding method - exe "set foldmethod=".foldmethod_save - normal zv - endif - -endfunction " ---------- end of function C_InsertTemplate ---------- - "------------------------------------------------------------------------------ " C_HighlightJumpTargets "------------------------------------------------------------------------------ @@ -3246,143 +2406,6 @@ function! C_JumpCtrlJ () endif return '' endfunction " ---------- end of function C_JumpCtrlJ ---------- - -"------------------------------------------------------------------------------ -" C_ExpandUserMacros {{{1 -"------------------------------------------------------------------------------ -function! C_ExpandUserMacros ( key ) - - if has_key( s:C_Template[s:C_ActualStyle], a:key ) - let template = s:C_Template[s:C_ActualStyle][ a:key ] - else - let template = s:C_Template['default'][ a:key ] - endif - let s:C_ExpansionCounter = {} " reset the expansion counter - - "------------------------------------------------------------------------------ - " renew the predefined macros and expand them - " can be replaced, with e.g. |?DATE| - "------------------------------------------------------------------------------ - let s:C_Macro['|BASENAME|'] = toupper(expand("%:t:r")) - let s:C_Macro['|DATE|'] = C_DateAndTime('d') - let s:C_Macro['|FILENAME|'] = expand("%:t") - let s:C_Macro['|PATH|'] = expand("%:p:h") - let s:C_Macro['|SUFFIX|'] = expand("%:e") - let s:C_Macro['|TIME|'] = C_DateAndTime('t') - let s:C_Macro['|YEAR|'] = C_DateAndTime('y') - - "------------------------------------------------------------------------------ - " delete jump targets if mapping for C-j is off - "------------------------------------------------------------------------------ - if s:C_Ctrl_j == 'off' - let template = substitute( template, s:C_TemplateJumpTarget1.'\|'.s:C_TemplateJumpTarget2, '', 'g' ) - endif - - "------------------------------------------------------------------------------ - " look for replacements - "------------------------------------------------------------------------------ - while match( template, s:C_ExpansionRegex ) != -1 - let macro = matchstr( template, s:C_ExpansionRegex ) - let replacement = substitute( macro, '?', '', '' ) - let template = substitute( template, macro, replacement, "g" ) - - let match = matchlist( macro, s:C_ExpansionRegex ) - - if !empty( match[1] ) - let macroname = '|'.match[1].'|' - " - " notify flag action, if any - let flagaction = '' - if has_key( s:C_MacroFlag, match[2] ) - let flagaction = ' (-> '.s:C_MacroFlag[ match[2] ].')' - endif - " - " ask for a replacement - if has_key( s:C_Macro, macroname ) - let name = C_Input( match[1].flagaction.' : ', C_ApplyFlag( s:C_Macro[macroname], match[2] ) ) - else - let name = C_Input( match[1].flagaction.' : ', '' ) - endif - if empty(name) - return "" - endif - " - " keep the modified name - let s:C_Macro[macroname] = C_ApplyFlag( name, match[2] ) - endif - endwhile - - "------------------------------------------------------------------------------ - " do the actual macro expansion - " loop over the macros found in the template - "------------------------------------------------------------------------------ - while match( template, s:C_NonExpansionRegex ) != -1 - - let macro = matchstr( template, s:C_NonExpansionRegex ) - let match = matchlist( macro, s:C_NonExpansionRegex ) - - if !empty( match[1] ) - let macroname = '|'.match[1].'|' - - if has_key( s:C_Macro, macroname ) - "------------------------------------------------------------------------------- - " check for recursion - "------------------------------------------------------------------------------- - if has_key( s:C_ExpansionCounter, macroname ) - let s:C_ExpansionCounter[macroname] += 1 - else - let s:C_ExpansionCounter[macroname] = 0 - endif - if s:C_ExpansionCounter[macroname] >= s:C_ExpansionLimit - echomsg " recursion terminated for recursive macro ".macroname - return template - endif - "------------------------------------------------------------------------------- - " replace - "------------------------------------------------------------------------------- - let replacement = C_ApplyFlag( s:C_Macro[macroname], match[2] ) - let replacement = escape( replacement, '&' ) - let template = substitute( template, macro, replacement, "g" ) - else - " - " macro not yet defined - let s:C_Macro['|'.match[1].'|'] = '' - endif - endif - - endwhile - - return template -endfunction " ---------- end of function C_ExpandUserMacros ---------- - -"------------------------------------------------------------------------------ -" C_ApplyFlag {{{1 -"------------------------------------------------------------------------------ -function! C_ApplyFlag ( val, flag ) - " - " l : lowercase - if a:flag == ':l' - return tolower(a:val) - endif - " - " u : uppercase - if a:flag == ':u' - return toupper(a:val) - endif - " - " c : capitalize - if a:flag == ':c' - return toupper(a:val[0]).a:val[1:] - endif - " - " L : legalized name - if a:flag == ':L' - return C_LegalizeName(a:val) - endif - " - " flag not valid - return a:val -endfunction " ---------- end of function C_ApplyFlag ---------- " "------------------------------------------------------------------------------ " C_ExpandSingleMacro {{{1 @@ -3391,41 +2414,6 @@ function! C_ExpandSingleMacro ( val, macroname, replacement ) return substitute( a:val, escape(a:macroname, '$' ), a:replacement, "g" ) endfunction " ---------- end of function C_ExpandSingleMacro ---------- -"------------------------------------------------------------------------------ -" C_SetSmallCommentStyle {{{1 -"------------------------------------------------------------------------------ -function! C_SetSmallCommentStyle () - if has_key( s:C_Template, 'comment.end-of-line-comment' ) - if match( s:C_Template['comment.end-of-line-comment'], '^\s*/\*' ) != -1 - let s:C_Com1 = '/*' " C-style : comment start - let s:C_Com2 = '*/' " C-style : comment end - else - let s:C_Com1 = '//' " C++style : comment start - let s:C_Com2 = '' " C++style : comment end - endif - endif -endfunction " ---------- end of function C_SetSmallCommentStyle ---------- - -"------------------------------------------------------------------------------ -" C_InsertMacroValue {{{1 -"------------------------------------------------------------------------------ -function! C_InsertMacroValue ( key ) - if empty( s:C_Macro['|'.a:key.'|'] ) - echomsg 'the tag |'.a:key.'| is empty' - return - endif - " - if &foldenable && foldclosed(".") >= 0 - echohl WarningMsg | echomsg s:MsgInsNotAvail | echohl None - return - endif - if col(".") > 1 - exe 'normal! a'.s:C_Macro['|'.a:key.'|'] - else - exe 'normal! i'.s:C_Macro['|'.a:key.'|'] - endif -endfunction " ---------- end of function C_InsertMacroValue ---------- - "------------------------------------------------------------------------------ " insert date and time {{{1 "------------------------------------------------------------------------------ @@ -3465,224 +2453,230 @@ function! C_InsertTemplateWrapper () call C_CheckAndRereadTemplates() if isdirectory(expand('%:p:h')) if index( s:C_SourceCodeExtensionsList, expand('%:e') ) >= 0 - call C_InsertTemplate("comment.file-description") + call mmtemplates#core#InsertTemplate(g:C_Templates, 'Comments.file description impl') else - call C_InsertTemplate("comment.file-description-header") + call mmtemplates#core#InsertTemplate(g:C_Templates, 'Comments.file description-header') endif set modified endif endfunction " ---------- end of function C_InsertTemplateWrapper ---------- " -"------------------------------------------------------------------------------- -" Comment : C/C++ File Sections {{{1 -"------------------------------------------------------------------------------- -let s:CFileSection = { - \ "Header\ File\ Includes" : "file-section-cpp-header-includes" , - \ "Local\ Macros" : "file-section-cpp-macros" , - \ "Local\ Type\ Def\." : "file-section-cpp-typedefs" , - \ "Local\ Data\ Types" : "file-section-cpp-data-types" , - \ "Local\ Variables" : "file-section-cpp-local-variables" , - \ "Local\ Prototypes" : "file-section-cpp-prototypes" , - \ "Exp\.\ Function\ Def\." : "file-section-cpp-function-defs-exported" , - \ "Local\ Function\ Def\." : "file-section-cpp-function-defs-local" , - \ "Local\ Class\ Def\." : "file-section-cpp-class-defs" , - \ "Exp\.\ Class\ Impl\." : "file-section-cpp-class-implementations-exported", - \ "Local\ Class\ Impl\." : "file-section-cpp-class-implementations-local" , - \ "All\ sections,\ C" : "c", - \ "All\ sections,\ C++" : "cpp", - \ } - -function! C_CFileSectionList ( ArgLead, CmdLine, CursorPos ) - return filter( copy( sort(keys( s:CFileSection)) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) -endfunction " ---------- end of function C_CFileSectionList ---------- - -function! C_CFileSectionListInsert ( arg ) - if has_key( s:CFileSection, a:arg ) - if s:CFileSection[a:arg] == 'c' || s:CFileSection[a:arg] == 'cpp' - call C_Comment_C_SectionAll( 'comment.'.s:CFileSection[a:arg] ) - return - endif - call C_InsertTemplate( 'comment.'.s:CFileSection[a:arg] ) - else - echomsg "entry '".a:arg."' does not exist" - endif -endfunction " ---------- end of function C_CFileSectionListInsert ---------- -" -"------------------------------------------------------------------------------- -" Comment : H File Sections {{{1 -"------------------------------------------------------------------------------- -let s:HFileSection = { - \ "Header\ File\ Includes" : "file-section-hpp-header-includes" , - \ "Exported\ Macros" : "file-section-hpp-macros" , - \ "Exported\ Type\ Def\." : "file-section-hpp-exported-typedefs" , - \ "Exported\ Data\ Types" : "file-section-hpp-exported-data-types" , - \ "Exported\ Variables" : "file-section-hpp-exported-variables" , - \ "Exported\ Funct\.\ Decl\." : "file-section-hpp-exported-function-declarations", - \ "Exported\ Class\ Def\." : "file-section-hpp-exported-class-defs" , - \ "All\ sections,\ C" : "c" , - \ "All\ sections,\ C++" : "cpp" , - \ } - -function! C_HFileSectionList ( ArgLead, CmdLine, CursorPos ) - return filter( copy( sort(keys( s:HFileSection)) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) -endfunction " ---------- end of function C_HFileSectionList ---------- - -function! C_HFileSectionListInsert ( arg ) - if has_key( s:HFileSection, a:arg ) - if s:HFileSection[a:arg] == 'c' || s:HFileSection[a:arg] == 'cpp' - call C_Comment_C_SectionAll( 'comment.'.s:HFileSection[a:arg] ) - return - endif - call C_InsertTemplate( 'comment.'.s:HFileSection[a:arg] ) - else - echomsg "entry '".a:arg."' does not exist" - endif -endfunction " ---------- end of function C_HFileSectionListInsert ---------- -" -"------------------------------------------------------------------------------- -" Comment : Keyword Comments {{{1 -"------------------------------------------------------------------------------- -let s:KeywordComment = { - \ 'BUG' : 'keyword-bug', - \ 'COMPILER' : 'keyword-compiler', - \ 'TODO' : 'keyword-todo', - \ 'TRICKY' : 'keyword-tricky', - \ 'WARNING' : 'keyword-warning', - \ 'WORKAROUND' : 'keyword-workaround', - \ 'new\ keyword' : 'keyword-keyword', - \ } - -function! C_KeywordCommentList ( ArgLead, CmdLine, CursorPos ) - return filter( copy( sort(keys( s:KeywordComment)) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) -endfunction " ---------- end of function C_KeywordCommentList ---------- - -function! C_KeywordCommentListInsert ( arg ) - if has_key( s:KeywordComment, a:arg ) - if s:KeywordComment[a:arg] == 'c' || s:KeywordComment[a:arg] == 'cpp' - call C_Comment_C_SectionAll( 'comment.'.s:KeywordComment[a:arg] ) - return - endif - call C_InsertTemplate( 'comment.'.s:KeywordComment[a:arg] ) - else - echomsg "entry '".a:arg."' does not exist" - endif -endfunction " ---------- end of function C_KeywordCommentListInsert ---------- -" -"------------------------------------------------------------------------------- -" Comment : Special Comments {{{1 -"------------------------------------------------------------------------------- -let s:SpecialComment = { - \ 'EMPTY' : 'special-empty' , - \ 'FALL\ THROUGH' : 'special-fall-through' , - \ 'IMPL\.\ TYPE\ CONV' : 'special-implicit-type-conversion")' , - \ 'NO\ RETURN' : 'special-no-return' , - \ 'NOT\ REACHED' : 'special-not-reached' , - \ 'TO\ BE\ IMPL\.' : 'special-remains-to-be-implemented' , - \ 'constant\ type\ is\ long\ (L)' : 'special-constant-type-is-long' , - \ 'constant\ type\ is\ unsigned\ (U)' : 'special-constant-type-is-unsigned' , - \ 'constant\ type\ is\ unsigned\ long\ (UL)' : 'special-constant-type-is-unsigned-long' , - \ } - -function! C_SpecialCommentList ( ArgLead, CmdLine, CursorPos ) - return filter( copy( sort(keys( s:SpecialComment)) ), 'v:val =~ "\\<'.a:ArgLead.'\\w*"' ) -endfunction " ---------- end of function C_SpecialCommentList ---------- - -function! C_SpecialCommentListInsert ( arg ) - if has_key( s:SpecialComment, a:arg ) - if s:SpecialComment[a:arg] == 'c' || s:SpecialComment[a:arg] == 'cpp' - call C_Comment_C_SectionAll( 'comment.'.s:SpecialComment[a:arg] ) - return - endif - call C_InsertTemplate( 'comment.'.s:SpecialComment[a:arg] ) - else - echomsg "entry '".a:arg."' does not exist" - endif -endfunction " ---------- end of function C_SpecialCommentListInsert ---------- - -"------------------------------------------------------------------------------- -" Standard Library Includes -"------------------------------------------------------------------------------- -function! C_CleanDirNameList ( list ) - let result = copy( a:list ) - let index = 0 - while index < len( result ) - let result[index] = substitute( result[index], '[&\\]', '', 'g' ) - let index = index + 1 - endwhile - return result -endfunction " ---------- end of function C_CleanDirNameList ---------- - -let s:C_StandardLibsClean = C_CleanDirNameList( s:C_StandardLibs ) -let s:C_C99LibsClean = C_CleanDirNameList( s:C_C99Libs ) -let s:Cpp_StandardLibsClean = C_CleanDirNameList( s:Cpp_StandardLibs ) -let s:Cpp_CStandardLibsClean = C_CleanDirNameList( s:Cpp_CStandardLibs ) - -"------------------------------------------------------------------------------- -" callback functions used in the filetype plugin ftplugin/c.vim -" callback functions -"------------------------------------------------------------------------------- - -function! C_IncludesInsert ( arg, List ) - if index( a:List, a:arg ) >= 0 - exe 'normal a#include <'.a:arg.'>' - else - echomsg "entry '".a:arg."' does not exist" - endif -endfunction " ---------- end of function C_IncludesInsert -" -function! C_StdLibraryIncludesInsert ( arg ) - call C_IncludesInsert ( a:arg, s:C_StandardLibsClean ) -endfunction " ---------- end of function C_StdLibraryIncludesInsert - -function! C_C99LibraryIncludesInsert ( arg ) - call C_IncludesInsert ( a:arg, s:C_C99LibsClean ) -endfunction " ---------- end of function C_C99LibraryIncludesInsert - -function! C_CppLibraryIncludesInsert ( arg ) - call C_IncludesInsert ( a:arg, s:Cpp_StandardLibsClean ) -endfunction " ---------- end of function C_CppLibraryIncludesInsert +"=== FUNCTION ================================================================ +" NAME: CreateAdditionalMaps {{{1 +" DESCRIPTION: create additional maps +" PARAMETERS: - +" RETURNS: +"=============================================================================== +function! s:CreateAdditionalMaps () + " + " ---------- Do we have a mapleader other than '\' ? ------------ + if exists("g:C_MapLeader") + let maplocalleader = g:C_MapLeader + endif + " + " ---------- C/C++ dictionary ----------------------------------- + " This will enable keyword completion for C and C++ + " using Vim's dictionary feature |i_CTRL-X_CTRL-K|. + " Set the new dictionaries in front of the existing ones + " + if exists("g:C_Dictionary_File") + silent! exe 'setlocal dictionary+='.g:C_Dictionary_File + endif + " + "------------------------------------------------------------------------------- + " USER DEFINED COMMANDS + "------------------------------------------------------------------------------- + " + " ---------- F-key mappings ------------------------------------ + " + " Alt-F9 write buffer and compile + " F9 compile and link + " Ctrl-F9 run executable + " Shift-F9 command line arguments + " + map :call C_Compile():call C_HlMessage() + imap :call C_Compile():call C_HlMessage() + " + map :call C_Link():call C_HlMessage() + imap :call C_Link():call C_HlMessage() + " + map :call C_Run() + imap :call C_Run() + " + map :call C_Arguments() + imap :call C_Arguments() + " -function! C_CppCLibraryIncludesInsert ( arg ) - call C_IncludesInsert ( a:arg, s:Cpp_CStandardLibsClean ) -endfunction " ---------- end of function C_CppCLibraryIncludesInsert + " ---------- KEY MAPPINGS : MENU ENTRIES ------------------------------------- + " ---------- comments menu ------------------------------------------------ + " + noremap cl :call C_EndOfLineComment() + inoremap cl :call C_EndOfLineComment() + " + nnoremap cj :call C_AdjustLineEndComm() + vnoremap cj :call C_AdjustLineEndComm() + inoremap cj :call C_AdjustLineEndComm()a + " + noremap cs :call C_GetLineEndCommCol() -"------------------------------------------------------------------------------- -" callback functions used in the filetype plugin ftplugin/c.vim -" custom completion -"------------------------------------------------------------------------------- + noremap c* :call C_CodeToCommentC():nohlsearchj + vnoremap c* :call C_CodeToCommentC():nohlsearchj -function! C_IncludesList ( ArgLead, CmdLine, CursorPos, List ) - " show all libs - if empty(a:ArgLead) - return a:List + noremap cc :call C_CodeToCommentCpp():nohlsearchj + vnoremap cc :call C_CodeToCommentCpp():nohlsearchj + noremap co :call C_CommentToCode():nohlsearch + vnoremap co :call C_CommentToCode():nohlsearch + + noremap cd :call C_InsertDateAndTime('d') + inoremap cd :call C_InsertDateAndTime('d')a + vnoremap cd s:call C_InsertDateAndTime('d')a + noremap ct :call C_InsertDateAndTime('dt') + inoremap ct :call C_InsertDateAndTime('dt')a + vnoremap ct s:call C_InsertDateAndTime('dt')a + " + noremap cx :call C_CommentToggle( ) + inoremap cx :call C_CommentToggle( ) + vnoremap cx :call C_CommentToggle( ) + " + " ---------- statements menu ------------------------------------------------ + " + " ---------- preprocessor menu ---------------------------------------------- + " + noremap pi0 :call C_PPIf0("a")2ji + inoremap pi0 :call C_PPIf0("a")2ji + vnoremap pi0 :call C_PPIf0("v") + + noremap pr0 :call C_PPIf0Remove() + inoremap pr0 :call C_PPIf0Remove() + " + " ---------- idioms menu ---------------------------------------------------- + " + noremap i0 :call C_CodeFor("up" ) + vnoremap i0 :call C_CodeFor("up","v") + inoremap i0 :call C_CodeFor("up" ) + noremap in :call C_CodeFor("down" ) + vnoremap in :call C_CodeFor("down","v") + inoremap in :call C_CodeFor("down" ) + " + " ---------- snippet menu : snippets ----------------------------------------- + " + noremap nr :call C_CodeSnippet("r") + noremap nv :call C_CodeSnippet("view") + noremap nw :call C_CodeSnippet("w") + vnoremap nw :call C_CodeSnippet("wv") + noremap ne :call C_CodeSnippet("e") + " + inoremap nr :call C_CodeSnippet("r") + inoremap nv :call C_CodeSnippet("view") + inoremap nw :call C_CodeSnippet("w") + inoremap ne :call C_CodeSnippet("e") + " + " ---------- snippet menu : prototypes --------------------------------------- + " + noremap np :call C_ProtoPick("function") + vnoremap np :call C_ProtoPick("function") + inoremap np :call C_ProtoPick("function") + " + noremap nf :call C_ProtoPick("function") + vnoremap nf :call C_ProtoPick("function") + inoremap nf :call C_ProtoPick("function") + " + noremap nm :call C_ProtoPick("method") + vnoremap nm :call C_ProtoPick("method") + inoremap nm :call C_ProtoPick("method") + " + noremap ni :call C_ProtoInsert() + inoremap ni :call C_ProtoInsert() + " + noremap nc :call C_ProtoClear() + inoremap nc :call C_ProtoClear() + " + noremap ns :call C_ProtoShow() + inoremap ns :call C_ProtoShow() + " + " ---------- snippet menu : templates ---------------------------------------- + " + nnoremap ntl :call mmtemplates#core#EditTemplateFiles(g:C_Templates,-1) + inoremap ntl :call mmtemplates#core#EditTemplateFiles(g:C_Templates,-1) + if g:C_Installation == 'system' + nnoremap ntg :call mmtemplates#core#EditTemplateFiles(g:C_Templates,1) + inoremap ntg :call mmtemplates#core#EditTemplateFiles(g:C_Templates,1) + endif + nnoremap ntr :call mmtemplates#core#ReadTemplates(g:C_Templates,"reload","all") + inoremap ntr :call mmtemplates#core#ReadTemplates(g:C_Templates,"reload","all") + nnoremap nts :call mmtemplates#core#ChooseStyle(g:C_Templates,"!pick") + inoremap nts :call mmtemplates#core#ChooseStyle(g:C_Templates,"!pick") + " + " ---------- C++ menu ---------------------------------------------------- + " + " ---------- run menu -------------------------------------------------------- + " + map rc :call C_Compile():call C_HlMessage() + imap rc :call C_Compile():call C_HlMessage() + map rl :call C_Link():call C_HlMessage() + imap rl :call C_Link():call C_HlMessage() + map rr :call C_Run() + imap rr :call C_Run() + map ra :call C_Arguments() + imap ra :call C_Arguments() + map rm :call C_Make() + imap rm :call C_Make() + map rcm :call C_ChooseMakefile() + imap rcm :call C_ChooseMakefile() + map rmc :call C_MakeClean() + imap rmc :call C_MakeClean() + map rme :call C_ExeToRun() + imap rme :call C_ExeToRun() + map rma :call C_MakeArguments() + imap rma :call C_MakeArguments() + map rp :call C_SplintCheck():call C_HlMessage() + imap rp :call C_SplintCheck():call C_HlMessage() + map rpa :call C_SplintArguments() + imap rpa :call C_SplintArguments() + map rcc :call C_CppcheckCheck():call C_HlMessage() + imap rcc :call C_CppcheckCheck():call C_HlMessage() + map rccs :call C_CppcheckSeverityInput() + imap rccs :call C_CppcheckSeverityInput() + + map ri :call C_Indent() + imap ri :call C_Indent() + map rh :call C_Hardcopy() + imap rh :call C_Hardcopy() + vmap rh :call C_Hardcopy() + map rs :call C_Settings() + imap rs :call C_Settings() + " + if has("unix") + map rx :call C_XtermSize() + imap rx :call C_XtermSize() + endif + map ro :call C_Toggle_Gvim_Xterm() + imap ro :call C_Toggle_Gvim_Xterm() + " + " Abraxas CodeCheck (R) + " + if s:C_CodeCheckIsExecutable==1 + map rk :call C_CodeCheck():call C_HlMessage() + imap rk :call C_CodeCheck():call C_HlMessage() + map rka :call C_CodeCheckArguments() + imap rka :call C_CodeCheckArguments() endif - " show libs beginning with a:ArgLead - let expansions = [] - for item in a:List - if match( item, '\<'.a:ArgLead.'\w*' ) == 0 - call add( expansions, item ) - endif - endfor - return expansions -endfunction " ---------- end of function C_IncludesList ---------- + " ---------- plugin help ----------------------------------------------------- + " + map hp :call C_HelpCsupport() + imap hp :call C_HelpCsupport() + map hm :call C_Help("m") + imap hm :call C_Help("m") + " + if !exists("g:C_Ctrl_j") || ( exists("g:C_Ctrl_j") && g:C_Ctrl_j != 'off' ) + nmap i=C_JumpCtrlJ() + imap =C_JumpCtrlJ() + endif +endfunction " ---------- end of function s:CreateAdditionalMaps ---------- +" +" Plug-in setup: {{{1 " -function! C_StdLibraryIncludesList ( ArgLead, CmdLine, CursorPos ) - return C_IncludesList ( a:ArgLead, a:CmdLine, a:CursorPos, s:C_StandardLibsClean ) -endfunction " ---------- end of function C_StdLibraryIncludesList ---------- - -function! C_C99LibraryIncludesList ( ArgLead, CmdLine, CursorPos ) - return C_IncludesList ( a:ArgLead, a:CmdLine, a:CursorPos, s:C_C99LibsClean ) -endfunction " ---------- end of function C_C99LibraryIncludesList ---------- - -function! C_CppLibraryIncludesList ( ArgLead, CmdLine, CursorPos ) - return C_IncludesList ( a:ArgLead, a:CmdLine, a:CursorPos, s:Cpp_StandardLibsClean ) -endfunction " ---------- end of function C_CppLibraryIncludesList ---------- - -function! C_CppCLibraryIncludesList ( ArgLead, CmdLine, CursorPos ) - return C_IncludesList ( a:ArgLead, a:CmdLine, a:CursorPos, s:Cpp_CStandardLibsClean ) -endfunction " ---------- end of function C_CppCLibraryIncludesList ---------- - "------------------------------------------------------------------------------ " show / hide the c-support menus " define key mappings (gVim only) @@ -3694,6 +2688,9 @@ if s:C_LoadMenus == 'yes' && s:C_CreateMenusDelayed == 'no' call C_CreateGuiMenus() endif " +" +command! -nargs=1 -complete=customlist,C_CppcheckSeverityList CppcheckSeverity call C_GetCppcheckSeverity () +" "------------------------------------------------------------------------------ " Automated header insertion " Local settings for the quickfix window @@ -3716,13 +2713,14 @@ if has("autocmd") autocmd BufNewFile,BufRead *.i :set filetype=c autocmd BufNewFile,BufRead *.ii :set filetype=cpp " - " " DELAYED LOADING OF THE TEMPLATE DEFINITIONS " - autocmd BufNewFile,BufRead * - \ if (&filetype=='cpp' || &filetype=='c') | - \ call C_CreateMenusDelayed() | - \ endif + autocmd FileType * + \ if ( &filetype == 'cpp' || &filetype == 'c') | + \ call C_CreateMenusDelayed() | + \ call s:CreateAdditionalMaps() | + \ call mmtemplates#core#CreateMaps ( 'g:C_Templates', g:C_MapLeader ) | + \ endif "------------------------------------------------------------------------------- " style switching :Automated header insertion (suffixes from the gcc manual) @@ -3739,7 +2737,7 @@ if has("autocmd") " template styles are related to file extensions "------------------------------------------------------------------------------- for [ pattern, stl ] in items( g:C_Styles ) - exe "autocmd BufNewFile,BufRead,BufEnter ".pattern." call C_Style( '".stl."' )" + exe "autocmd BufNewFile,BufRead,BufEnter ".pattern." call mmtemplates#core#ChooseStyle ( g:C_Templates, '".stl."')" exe "autocmd BufNewFile ".pattern." call C_InsertTemplateWrapper()" endfor " @@ -3752,6 +2750,8 @@ if has("autocmd") exe 'autocmd BufRead *.'.join( s:C_SourceCodeExtensionsList, '\|*.' ) \ .' call C_HighlightJumpTargets()' " +" autocmd BufNewFile,BufRead * if &filetype =~ '^\(c\|cpp\)$' | +" \ call s:CreateAdditionalMaps() | endif endif " has("autocmd") " "===================================================================================== diff --git a/syntax/template.vim b/syntax/template.vim new file mode 100644 index 0000000..070922b --- /dev/null +++ b/syntax/template.vim @@ -0,0 +1,82 @@ +" Vim syntax file +" +if version < 600 + syntax clear +elseif exists("b:current_syntax") + "finish +endif + +" comment +syn match Comment "^\$.*$" +syn match Comment "\%(==\)\@<=[^=]*$" + +" templates, lists, ... +syn match Structure "^==\s*\%(TEMPLATE:\)\?[a-zA-Z0-9-+\.,_ ]\+==\%(.\+==\)\?" +syn match Structure "^==\s*ENDTEMPLATE\s*==" + +syn match Structure "^==\s*LIST:\s*[a-zA-Z0-9_]\+\s*==\%(.\+==\)\?" +syn match Structure "^==\s*ENDLIST\s*==" + +syn match Structure "^==\s*HELP:[a-zA-Z0-9-+\.,_ ]\+==\%(.\+==\)\?" +syn match Structure "^==\s*ENDHELP\s*==" + +" style sections +syn match Statement "^==\s*IF\s\+|STYLE|\s\+IS\s\+[a-zA-Z0-9_]\+\s*==" +syn match Statement "^==\s*ENDIF\s*==" + +syn match Statement "^==\s*USE\s\+STYLES\s*:[a-zA-Z0-9_, ]\+==" +syn match Statement "^==\s*ENDSTYLES\s*==" + +" functions: command mode +syn match Function "IncludeFile\ze\s*(" +syn match Function "SetFormat\ze\s*(" +syn match Function "SetMacro\ze\s*(" +syn match Function "SetStyle\ze\s*(" +syn match Function "SetSyntax\ze\s*(" +syn match Function "SetPath\ze\s*(" + +syn match Function "MenuShortcut\ze\s*(" +syn match Function "SetProperty\ze\s*(" +syn match Function "SetMap\ze\s*(" +syn match Function "SetShortcut\ze\s*(" + +" functions: standard template +syn match Function "|\zsDefaultMacro\ze(" +syn match Function "|\zsPrompt\ze(" +syn match Function "|\zsPickFile\ze(" +syn match Function "|\zsPickList\ze(" +syn match Function "|\zsSurroundWith\ze(" +syn match Function "|\zsInsert\ze(" +syn match Function "|\zsInsertLine\ze(" + +syn match Comment "|C(.\{-})|" +syn match Comment "|Comment(.\{-})|" + +" functions: picker +syn match Function "|\zsPath\ze(" " file +syn match Function "|\zsGetPath\ze(" " file +syn match Function "|\zsKeepPath\ze(" " file +syn match Function "|\zsRemovePath\ze(" " file +syn match Function "|\zsList\ze(" " list +syn match Function "|\zsGetList\ze(" " list + +" functions: help +syn match Function "|\zsPrompt\ze(" +syn match Function "|\zsWord\ze(" +syn match Function "|\zsPattern\ze(" +syn match Function "|\zsDefault\ze(" +syn match Function "|\zsSubstitute\ze(" +syn match Function "|\zsLiteralSub\ze(" +syn match Function "|\zsSystem\ze(" +syn match Function "|\zsVim\ze(" + +" strings, macros, tags, jump targets +syn match String "\%(''\|'.\{-}[^']'\)" +syn match String "\%(\"\"\|\".\{-}[^\\]\"\)" + +syn match Tag "|?\?[a-zA-Z][a-zA-Z0-9_:]*|" +syn match Tag "<[a-zA-Z][a-zA-Z0-9_]*>" + +syn match Search "[<{][+-]\w*[+-][}>]" + +let b:current_syntax = "template"