├── examples ├── subl2tm │ ├── Sublime Text │ │ ├── C++.sublime-settings │ │ ├── Enumeration.sublime-snippet │ │ ├── std-map-(map).sublime-snippet │ │ ├── std-vector-(v).sublime-snippet │ │ ├── Typedef.sublime-snippet │ │ ├── #include-(inc angle).sublime-snippet │ │ ├── #include-(inc).sublime-snippet │ │ ├── template-typename-..-(template).sublime-snippet │ │ ├── if-..-(if).sublime-snippet │ │ ├── struct.sublime-snippet │ │ ├── do...while-loop-(do).sublime-snippet │ │ ├── namespace-..-(namespace).sublime-snippet │ │ ├── printf-..-(printf).sublime-snippet │ │ ├── $1.begin()-$1.end()-(beginend).sublime-snippet │ │ ├── 030-for-int-loop-(fori).sublime-snippet │ │ ├── forv.sublime-snippet │ │ ├── fprintf.sublime-snippet │ │ ├── #ifndef-#define-#endif.sublime-snippet │ │ ├── 010-main()-(main).sublime-snippet │ │ ├── class-..-(class).sublime-snippet │ │ ├── C++.sublime-build │ │ ├── read-file-(readF).sublime-snippet │ │ ├── Completion Rules.tmPreferences │ │ ├── Symbol List - Prefix Banner Items.tmPreferences │ │ ├── Symbol List - Indent Class Methods.tmPreferences │ │ ├── Comments (C++).tmPreferences │ │ ├── Indentation Rules.tmPreferences │ │ ├── C++.tmLanguage │ │ └── C.tmLanguage │ └── build.xml └── tm2subl │ ├── TextMate │ ├── Support │ │ ├── CLib.txt.gz │ │ ├── C++Lib.txt.gz │ │ ├── bin │ │ │ ├── bootstrap.sh │ │ │ └── insert_missing_includes.rb │ │ ├── SpotlightSearch.rb │ │ ├── c_completion.rb │ │ └── c_completion2.rb │ ├── Snippets │ │ ├── Enumeration.tmSnippet │ │ ├── std::map (map).tmSnippet │ │ ├── std::vector (v).tmSnippet │ │ ├── Typedef.tmSnippet │ │ ├── #include <> (Inc).tmSnippet │ │ ├── #include "" (inc).tmSnippet │ │ ├── template (template).tmSnippet │ │ ├── if .. (if).tmSnippet │ │ ├── do...while loop (do).tmSnippet │ │ ├── Shared Pointer.tmSnippet │ │ ├── struct.tmSnippet │ │ ├── #pragma mark (mark).tmSnippet │ │ ├── #endif.tmSnippet │ │ ├── printf .. (printf).tmSnippet │ │ ├── 030 for int loop (fori).tmSnippet │ │ ├── fprintf ….tmSnippet │ │ ├── 010 main() (main).tmSnippet │ │ ├── namespace .. (namespace).tmSnippet │ │ ├── #ifndef … #define … #endif.tmSnippet │ │ ├── $1.begin(), $1.end() (beginend).tmSnippet │ │ ├── class .. (class).tmSnippet │ │ ├── read file (readF).tmSnippet │ │ └── Include header once only guard.tmSnippet │ ├── Preferences │ │ ├── Disable Spell Checking.tmPreferences │ │ ├── Symbol List: Prefix Banner Items.tmPreferences │ │ ├── Symbol List: Indent Class Methods.tmPreferences │ │ ├── Include Completion.tmPreferences │ │ ├── Indentation Rules (Comments).tmPreferences │ │ ├── Template:cast typing pairs.tmPreferences │ │ ├── Include typing pairs.tmPreferences │ │ ├── Comments (C++).tmPreferences │ │ ├── Indentation Rules.tmPreferences │ │ └── Include Completion (System).tmPreferences │ ├── Macros │ │ ├── Insert ; and Indent Line.tmMacro │ │ └── Insert Missing Includes.tmMacro │ ├── Commands │ │ ├── Toggle System:Local Include.tmCommand │ │ ├── C Library Completions.tmCommand │ │ ├── C & C++ Library Completions.tmCommand │ │ ├── Insert Call to Constructors.tmCommand │ │ ├── Compile Active File to Command Line Tool.tmCommand │ │ ├── Run.tmCommand │ │ ├── Fold:Unfold Code.tmCommand │ │ └── Quick Open.tmCommand │ ├── info.plist │ └── Syntaxes │ │ ├── C++.tmLanguage │ │ └── C.tmLanguage │ └── build.xml ├── tm2subl.xsl ├── subl2tm.xsl ├── README.md ├── tm2subl.xml └── subl2tm.xml /examples/subl2tm/Sublime Text/C++.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": ["cpp", "cc", "cxx", "c++", "h", "hpp", "hxx", "h++", "inl", "ipp"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Support/CLib.txt.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srbs/textmate-to-sublime-converter/HEAD/examples/tm2subl/TextMate/Support/CLib.txt.gz -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Support/C++Lib.txt.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/srbs/textmate-to-sublime-converter/HEAD/examples/tm2subl/TextMate/Support/C++Lib.txt.gz -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Support/bin/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | eval '"$1"' "$2" '"$3"' -o '"$3".out' 4 | 5 | if [ $? -eq 0 ]; then 6 | "$3".out; 7 | fi 8 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/Enumeration.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | Enumeration 3 | 4 | enum 5 | source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/std-map-(map).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | std::map 3 | map$0;]]> 4 | map 5 | source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/std-vector-(v).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | std::vector 3 | v$0;]]> 4 | vector 5 | source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/Typedef.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | Typedef 3 | 4 | td 5 | source.c, source.objc, source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/#include-(inc angle).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | #include <…> 3 | ]]> 4 | Inc 5 | source.c, source.objc, source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/#include-(inc).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | #include "…" 3 | 4 | inc 5 | source.c, source.objc, source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/template-typename-..-(template).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | template <typename ${1:_InputIter}> 3 | ]]> 4 | tp 5 | source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/if-..-(if).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | If Condition 3 | 7 | if 8 | source.c, source.objc, source.c++, source.objc++ 9 | 10 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/struct.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | Struct 3 | 7 | struct 8 | source.c, source.objc, source.c++, source.objc++ 9 | 10 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/do...while-loop-(do).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | Do While Loop 3 | 7 | do 8 | source.c, source.objc, source.c++, source.objc++ 9 | 10 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/namespace-..-(namespace).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | Namespace 3 | 8 | ns 9 | source.c++, source.objc++ 10 | 11 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/printf-..-(printf).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | printf … 3 | 4 | printf 5 | source.c, source.objc, source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/$1.begin()-$1.end()-(beginend).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | $1.begin(), $1.end() 3 | )?$/(?2::(?1:>:.))/}begin(), ${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end()]]> 4 | beginend 5 | source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/030-for-int-loop-(fori).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | For Loop 3 | 7 | for 8 | source.c, source.objc, source.c++, source.objc++ 9 | 10 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/forv.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | Vector For Loop 3 | ::iterator ${3:i} = $2.begin(); $3 != $2.end(); ++$3) 4 | { 5 | $0 6 | }]]> 7 | forv 8 | source.c, source.objc, source.c++, source.objc++ 9 | 10 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/fprintf.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | fprintf … 3 | 4 | fprintf 5 | source.c, source.objc, source.c++, source.objc++ 6 | 7 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/#ifndef-#define-#endif.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | #ifndef … #define … #endif 3 | 6 | def 7 | source.c, source.c++, source.objc, source.objc++ 8 | 9 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/010-main()-(main).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | main() 3 | 8 | main 9 | source.c, source.objc, source.c++, source.objc++ 10 | 11 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/class-..-(class).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | Class 3 | 11 | class 12 | source.c++, source.objc++ 13 | 14 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/C++.sublime-build: -------------------------------------------------------------------------------- 1 | { 2 | "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"], 3 | "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", 4 | "working_dir": "${file_path}", 5 | "selector": "source.c, source.c++", 6 | 7 | "variants": 8 | [ 9 | { 10 | "name": "Run", 11 | "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"] 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/read-file-(readF).sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | Read File Into Vector 3 | v; 4 | if (FILE${TM_C_POINTER: *}fp = fopen(${1:"filename"}, "r")) 5 | { 6 | char buf[1024]; 7 | while (size_t len = fread(buf, 1, sizeof(buf), fp)) 8 | v.insert(v.end(), buf, buf + len); 9 | fclose(fp); 10 | }]]> 11 | readfile 12 | source.c++, source.objc++ 13 | 14 | -------------------------------------------------------------------------------- /examples/tm2subl/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/subl2tm/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/Completion Rules.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | scope 6 | source.c, source.c++, source.objc, source.objc++ 7 | settings 8 | 9 | cancelCompletion 10 | ^\s*(\}?\s*(else|try|do)|(class|struct|enum|namespace)\s*[a-zA-Z_0-9]+*)$ 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/Enumeration.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | enum ${1:name} { $0 }; 7 | name 8 | Enumeration 9 | scope 10 | source.c++, source.objc++ 11 | tabTrigger 12 | enum 13 | uuid 14 | DD10B510-1C36-45E0-A378-527401EE55B1 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/std::map (map).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | std::map<${1:key}, ${2:value}> map$0; 7 | name 8 | std::map 9 | scope 10 | source.c++, source.objc++ 11 | tabTrigger 12 | map 13 | uuid 14 | A295A902-ACAF-11D9-987D-000D93589AF6 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/std::vector (v).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | std::vector<${1:char}> v$0; 7 | name 8 | std::vector 9 | scope 10 | source.c++, source.objc++ 11 | tabTrigger 12 | vector 13 | uuid 14 | 5E468268-ACAF-11D9-987D-000D93589AF6 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/Typedef.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | typedef ${1:int} ${2:MyCustomType}; 7 | name 8 | Typedef 9 | scope 10 | source.c, source.objc, source.c++, source.objc++ 11 | tabTrigger 12 | td 13 | uuid 14 | 08E16CAE-DBD8-4570-B778-9E0E0EFFF80C 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/#include <> (Inc).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | #include <${1:.h}> 7 | name 8 | #include <…> 9 | scope 10 | source.c, source.objc, source.c++, source.objc++ 11 | tabTrigger 12 | Inc 13 | uuid 14 | B10CBD5D-7298-11D9-813A-000D93589AF6 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/#include "" (inc).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | #include "${1:${TM_FILENAME/\..+$/.h/}}" 7 | name 8 | #include "…" 9 | scope 10 | source.c, source.objc, source.c++, source.objc++ 11 | tabTrigger 12 | inc 13 | uuid 14 | 9AB31B76-7298-11D9-813A-000D93589AF6 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Disable Spell Checking.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Spell Checking: Disable for Include Strings 7 | scope 8 | meta.preprocessor.c.include string.quoted 9 | settings 10 | 11 | spellChecking 12 | 0 13 | 14 | uuid 15 | DC32505E-226B-409A-B3C3-8FC88BF4A131 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/template (template).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | template <typename ${1:_InputIter}> 7 | name 8 | template <typename …> 9 | scope 10 | source.c++, source.objc++ 11 | tabTrigger 12 | tp 13 | uuid 14 | C5DEE118-4C9E-4F3E-97A4-0E01A250F142 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/if .. (if).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | if(${1:/* condition */}) 7 | { 8 | ${0:/* code */} 9 | } 10 | name 11 | If Condition 12 | scope 13 | source.c, source.objc, source.c++, source.objc++ 14 | tabTrigger 15 | if 16 | uuid 17 | F060AC09-C289-11D9-8CEF-000D93589AF6 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/Symbol List - Prefix Banner Items.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Symbol List: Prefix Banner Items 7 | scope 8 | meta.toc-list.banner 9 | settings 10 | 11 | symbolTransformation 12 | 13 | s/^\s+/# /; 14 | s/^=+$/-/; 15 | 16 | 17 | uuid 18 | A8E4E48A-81F3-4DB7-A7A2-88662C06E011 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/do...while loop (do).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | do { 7 | ${0:/* code */} 8 | } while(${1:/* condition */}); 9 | name 10 | Do While Loop 11 | scope 12 | source.c, source.objc, source.c++, source.objc++ 13 | tabTrigger 14 | do 15 | uuid 16 | D1F5A25E-A70F-11D9-A11A-000A95A89C98 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Symbol List: Prefix Banner Items.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Symbol List: Prefix Banner Items 7 | scope 8 | meta.toc-list.banner 9 | settings 10 | 11 | symbolTransformation 12 | 13 | s/^\s+/# /; 14 | s/^=+$/-/; 15 | 16 | 17 | uuid 18 | A8E4E48A-81F3-4DB7-A7A2-88662C06E011 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/Shared Pointer.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | typedef std::tr1::shared_ptr<${2:${1:my_type}_t}> ${3:${2/_t$/_ptr/}}; 7 | name 8 | Shared Pointer 9 | scope 10 | source.c, source.objc, source.c++, source.objc++ 11 | tabTrigger 12 | sp 13 | uuid 14 | 986C0149-7802-4385-A237-90074D9D5ACD 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/struct.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | struct ${1:${TM_FILENAME/(.+)\..+|.*/(?1:\L$1_t:name)/}} 7 | { 8 | ${0:/* data */} 9 | }; 10 | name 11 | Struct 12 | scope 13 | source.c, source.objc, source.c++, source.objc++ 14 | tabTrigger 15 | st 16 | uuid 17 | 1D14B92E-8819-11D9-8661-000D93589AF6 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/#pragma mark (mark).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | #if 0 7 | ${1:#pragma mark - 8 | }#pragma mark $2 9 | #endif 10 | 11 | $0 12 | name 13 | #pragma mark 14 | scope 15 | source.c, source.objc, source.c++, source.objc++ 16 | tabTrigger 17 | mark 18 | uuid 19 | ADD104E9-830A-4AC4-AAF4-DB6D3B0B7506 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/#endif.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | #endif 7 | 8 | keyEquivalent 9 | ~@. 10 | name 11 | #endif 12 | scope 13 | source.c, source.c++, source.objc, source.objc++, (source.c | source.c++ | source.objc | source.objc++) & comment.block.preprocessor 14 | uuid 15 | 5039DA0E-538B-48E2-A45A-E5A27787E765 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/printf .. (printf).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | printf("${1:%s}\\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} 7 | name 8 | printf … 9 | scope 10 | source.c, source.objc, source.c++, source.objc++ 11 | tabTrigger 12 | printf 13 | uuid 14 | 5A086BE2-BCF6-11D9-82A9-000D93589AF6 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/030 for int loop (fori).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | for(size_t ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) 7 | { 8 | ${0:/* code */} 9 | } 10 | name 11 | For Loop 12 | scope 13 | source.c, source.objc, source.c++, source.objc++ 14 | tabTrigger 15 | for 16 | uuid 17 | 78EF7134-0859-4475-89C3-30927865E855 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/fprintf ….tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | fprintf(${1:stderr}, "${2:%s}\\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/} 7 | name 8 | fprintf … 9 | scope 10 | source.c, source.objc, source.c++, source.objc++ 11 | tabTrigger 12 | fprintf 13 | uuid 14 | FE378349-BD63-4390-9A3B-516F7FF7F413 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/010 main() (main).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | int main (int argc, char const${TM_C_POINTER: *}argv[]) 7 | { 8 | ${0:/* code */} 9 | return 0; 10 | } 11 | name 12 | main() 13 | scope 14 | source.c, source.objc, source.c++, source.objc++ 15 | tabTrigger 16 | main 17 | uuid 18 | BC8B81AB-5F16-11D9-B9C3-000D93589AF6 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/namespace .. (namespace).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | namespace${1/.+/ /m}${1:${TM_FILENAME/^((.*?)\..*)?$/(?1:\L$2:my)/}} 7 | { 8 | $0 9 | }${1/.+/ \/* /m}$1${1/.+/ *\//m} 10 | name 11 | Namespace 12 | scope 13 | source.c++, source.objc++ 14 | tabTrigger 15 | ns 16 | uuid 17 | CEE5F928-47A2-4648-96F0-99FF5C2A7419 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/#ifndef … #define … #endif.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | #ifndef ${1/([A-Za-z0-9_]+).*/$1/} 7 | #define ${1:SYMBOL} ${2:value} 8 | #endif 9 | name 10 | #ifndef … #define … #endif 11 | scope 12 | source.c, source.c++, source.objc, source.objc++ 13 | tabTrigger 14 | def 15 | uuid 16 | 680358EA-B24B-4662-8DDA-AD42288795E4 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/$1.begin(), $1.end() (beginend).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | ${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), ${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end() 7 | name 8 | $1.begin(), $1.end() 9 | scope 10 | source.c++, source.objc++ 11 | tabTrigger 12 | beginend 13 | uuid 14 | 62D59E1C-1DF1-490E-86E9-DFF8A461AD9C 15 | 16 | 17 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/Symbol List - Indent Class Methods.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleUUID 6 | 4675A940-6227-11D9-BFB1-000D93589AF6 7 | name 8 | Symbol List: Indent Class Methods 9 | scope 10 | meta.class-struct-block.c++ entity.name.function 11 | settings 12 | 13 | symbolTransformation 14 | 15 | s/^\s*/ /; # pad 16 | 17 | uuid 18 | B2B97E23-E686-4410-991D-A92AF3A9FC95 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/class .. (class).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | class ${1:${TM_FILENAME/(.+)\..+|.*/(?1:\L$1_t:name)/}} 7 | { 8 | public: 9 | ${1/(\w+).*/$1/} (${2:arguments}); 10 | virtual ~${1/(\w+).*/$1/} (); 11 | 12 | private: 13 | ${0:/* data */} 14 | }; 15 | name 16 | Class 17 | scope 18 | source.c++, source.objc++ 19 | tabTrigger 20 | cl 21 | uuid 22 | 523B30D4-C28A-11D9-8CEF-000D93589AF6 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Symbol List: Indent Class Methods.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleUUID 6 | 4675A940-6227-11D9-BFB1-000D93589AF6 7 | name 8 | Symbol List: Indent Class Methods 9 | scope 10 | meta.class-struct-block.c++ entity.name.function 11 | settings 12 | 13 | symbolTransformation 14 | 15 | s/^\s*/ /; # pad 16 | 17 | uuid 18 | B2B97E23-E686-4410-991D-A92AF3A9FC95 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Include Completion.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Header Completion (User) 7 | scope 8 | meta.preprocessor.c.include string.quoted.double 9 | settings 10 | 11 | completionCommand 12 | find "$TM_DIRECTORY" -name "$TM_CURRENT_WORD*.h" -maxdepth 2 -exec basename "{}" \;|sort 13 | disableDefaultCompletion 14 | 1 15 | 16 | uuid 17 | 66EE7D45-6AA0-4AB9-9699-A3DF4E2B9AE7 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/read file (readF).tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | std::vector<char> v; 7 | if(FILE${TM_C_POINTER: *}fp = fopen(${1:"filename"}, "r")) 8 | { 9 | char buf[1024]; 10 | while(size_t len = fread(buf, 1, sizeof(buf), fp)) 11 | v.insert(v.end(), buf, buf + len); 12 | fclose(fp); 13 | } 14 | name 15 | Read File Into Vector 16 | scope 17 | source.c++, source.objc++ 18 | tabTrigger 19 | readfile 20 | uuid 21 | E8C3B596-9045-11D9-AB38-000D93589AF6 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Indentation Rules (Comments).tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Indentation Rules (Comments) 7 | scope 8 | comment.block 9 | settings 10 | 11 | decreaseIndentPattern 12 | (?=not)possible 13 | increaseIndentPattern 14 | (?=not)possible 15 | indentNextLinePattern 16 | (?=not)possible 17 | unIndentedLinePattern 18 | (?=not)possible 19 | 20 | uuid 21 | 56BF3367-130A-4AA1-A136-755CB3702503 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Template:cast typing pairs.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Typing Pairs: Template/Cast 7 | scope 8 | storage.type.c++.template, keyword.operator.c++.cast 9 | settings 10 | 11 | highlightPairs 12 | 13 | 14 | < 15 | > 16 | 17 | 18 | smartTypingPairs 19 | 20 | 21 | < 22 | > 23 | 24 | 25 | 26 | uuid 27 | 47DD44E6-B4F5-4C2E-BC62-C6ACEBC02A0D 28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Macros/Insert ; and Indent Line.tmMacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | commands 6 | 7 | 8 | argument 9 | ; 10 | command 11 | insertText: 12 | 13 | 14 | command 15 | indent: 16 | 17 | 18 | keyEquivalent 19 | ; 20 | name 21 | Insert ; and Indent Line 22 | scope 23 | (source.c | source.c++ | source.objc | source.objc++) - comment - string 24 | scopeType 25 | local 26 | uuid 27 | 034C3F18-097D-4B2C-8F20-C1CA3E9573E9 28 | 29 | 30 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Snippets/Include header once only guard.tmSnippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | content 6 | #ifndef ${1:`#!/usr/bin/env ruby -wKU -riconv 7 | name = ENV["TM_FILENAME"] || "untitled" 8 | name = Iconv.iconv("ASCII//TRANSLIT", "UTF-8", name).first 9 | name = name.gsub(/[^a-z0-9]+/i, "_") 10 | uuid = (rand * 2821109907455).round.to_s(36) 11 | print "#{name}_#{uuid}".tr("[a-z]", "[A-Z]") 12 | `} 13 | #define $1 14 | 15 | ${TM_SELECTED_TEXT/\Z\n//}${0:} 16 | 17 | #endif /* end of include guard: $1 */ 18 | 19 | name 20 | Header Include-Guard 21 | scope 22 | source.c, source.objc, source.c++, source.objc++ 23 | tabTrigger 24 | once 25 | uuid 26 | 74AF5E38-994C-4641-96F0-EB98A2183F60 27 | 28 | 29 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Include typing pairs.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Typing Pairs: Include Statements 7 | scope 8 | meta.preprocessor.c.include 9 | settings 10 | 11 | highlightPairs 12 | 13 | 14 | " 15 | " 16 | 17 | 18 | < 19 | > 20 | 21 | 22 | smartTypingPairs 23 | 24 | 25 | " 26 | " 27 | 28 | 29 | < 30 | > 31 | 32 | 33 | 34 | uuid 35 | 1EACF554-A30C-44B0-B97A-11E3FA995045 36 | 37 | 38 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Commands/Toggle System:Local Include.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby 9 | 10 | print case str = STDIN.read 11 | when /\A"(.*)"\z/m then "<" + $1 + ">" 12 | when /\A<(.*)>\z/m then '"' + $1 + '"' 13 | else str 14 | end 15 | 16 | fallbackInput 17 | scope 18 | input 19 | selection 20 | keyEquivalent 21 | ^" 22 | name 23 | Toggle System/Local Include 24 | output 25 | replaceSelectedText 26 | scope 27 | string.quoted.double.include.c, string.quoted.other.lt-gt.include.c 28 | uuid 29 | E8D80809-0CDE-4E57-AC2A-8C22DFF353EE 30 | 31 | 32 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/Comments (C++).tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.c, source.c++, source.objc, source.objc++ 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | // 18 | 19 | 20 | name 21 | TM_COMMENT_START_2 22 | value 23 | /* 24 | 25 | 26 | name 27 | TM_COMMENT_END_2 28 | value 29 | */ 30 | 31 | 32 | name 33 | TM_COMMENT_DISABLE_INDENT_2 34 | value 35 | yes 36 | 37 | 38 | 39 | uuid 40 | 38DBCCE5-2005-410C-B7D7-013097751AC8 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Comments (C++).tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Comments 7 | scope 8 | source.c, source.c++, source.objc, source.objc++ 9 | settings 10 | 11 | shellVariables 12 | 13 | 14 | name 15 | TM_COMMENT_START 16 | value 17 | // 18 | 19 | 20 | name 21 | TM_COMMENT_START_2 22 | value 23 | /* 24 | 25 | 26 | name 27 | TM_COMMENT_END_2 28 | value 29 | */ 30 | 31 | 32 | name 33 | TM_COMMENT_DISABLE_INDENT_2 34 | value 35 | yes 36 | 37 | 38 | 39 | uuid 40 | 38DBCCE5-2005-410C-B7D7-013097751AC8 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Commands/C Library Completions.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | 4675A940-6227-11D9-BFB1-000D93589AF6 9 | command 10 | #!/usr/bin/env ruby 11 | require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes" 12 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape" 13 | 14 | if ENV['DIALOG'] =~ /2$/ 15 | require "#{ENV['TM_BUNDLE_SUPPORT']}/c_completion2" 16 | else 17 | require "#{ENV['TM_BUNDLE_SUPPORT']}/c_completion" 18 | end 19 | 20 | res = CCompletion.new.print 21 | print res 22 | fallbackInput 23 | line 24 | input 25 | none 26 | keyEquivalent 27 | ~ 28 | name 29 | C Library Completions 30 | output 31 | insertAsSnippet 32 | scope 33 | source.c 34 | uuid 35 | 45FFA4DA-C84A-4D1F-862B-F249C24941EF 36 | 37 | 38 | -------------------------------------------------------------------------------- /tm2subl.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Commands/C & C++ Library Completions.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | 4675A940-6227-11D9-BFB1-000D93589AF6 9 | command 10 | #!/usr/bin/env ruby 11 | require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes" 12 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape" 13 | 14 | if ENV['DIALOG'] =~ /2$/ 15 | require "#{ENV['TM_BUNDLE_SUPPORT']}/c_completion2" 16 | else 17 | require "#{ENV['TM_BUNDLE_SUPPORT']}/c_completion" 18 | end 19 | 20 | res = CppCompletion.new.print 21 | print res 22 | fallbackInput 23 | line 24 | input 25 | none 26 | keyEquivalent 27 | ~ 28 | name 29 | C & C++ Library Completions 30 | output 31 | insertAsSnippet 32 | scope 33 | source.c++ 34 | uuid 35 | 093DA4F2-D97F-4309-B869-6970C090A539 36 | 37 | 38 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Macros/Insert Missing Includes.tmMacro: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | commands 6 | 7 | 8 | argument 9 | 10 | command 11 | insertText: 12 | 13 | 14 | command 15 | selectAll: 16 | 17 | 18 | argument 19 | 20 | command 21 | insert_missing_includes.rb 22 | input 23 | document 24 | output 25 | insertAsSnippet 26 | 27 | command 28 | executeCommandWithOptions: 29 | 30 | 31 | keyEquivalent 32 | ^# 33 | name 34 | Insert Missing Includes 35 | scope 36 | source.c, source.c++, source.objc, source.objc++ 37 | scopeType 38 | local 39 | uuid 40 | 0DABAE22-81C5-4ADF-8BCC-9B343A51CCB9 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Commands/Insert Call to Constructors.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby -wKU 9 | 10 | line = STDIN.read 11 | 12 | if line =~ /\((.*)\)(\s?)/ # extract parameters 13 | line, ws = $1, $2 14 | line.gsub!(/<.*?>/, '') # remove template args 15 | line.gsub!(/\(.*?\)/, '') # remove (…), e.g. ‘type const& var = type()’ 16 | line = line.split(',').map { |e| e.gsub(/.*?(\w+)(\s+=.*)?$/, '\1(\1)') }.join(', ') 17 | print ' ' if ws.empty? 18 | print ': ' + line 19 | end 20 | 21 | fallbackInput 22 | line 23 | input 24 | selection 25 | name 26 | Insert Call to Constructors 27 | output 28 | afterSelectedText 29 | scope 30 | source.c++, source.objc++ 31 | tabTrigger 32 | : 33 | uuid 34 | 1B7326BB-6A85-4ED2-A0D7-51619763D98F 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/Indentation Rules.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Indentation Rules 7 | scope 8 | source.c, source.c++, source.objc, source.objc++ 9 | settings 10 | 11 | decreaseIndentPattern 12 | (?x) 13 | ^ (.*\*/)? \s* \} .* $ 14 | | ^ \s* (public|private|protected): \s* $ 15 | | ^ \s* @(public|private|protected) \s* $ 16 | 17 | increaseIndentPattern 18 | (?x) 19 | ^ .* \{ [^}"']* $ 20 | | ^ \s* (public|private|protected): \s* $ 21 | | ^ \s* @(public|private|protected) \s* $ 22 | 23 | 24 | bracketIndentNextLinePattern 25 | (?x) 26 | ^ \s* \b(if|while|else)\b [^;]* $ 27 | | ^ \s* \b(for)\b .* $ 28 | 29 | 30 | unIndentedLinePattern 31 | ^\s*((/\*|.*\*/|//|#|template\b.*?>(?!\(.*\))|@protocol|@interface(?!.*\{)|@implementation|@end).*)?$ 32 | 33 | indentSquareBrackets 34 | 35 | 36 | 37 | uuid 38 | 02EB44C6-9203-4F4C-BFCB-7E3360B12812 39 | 40 | 41 | -------------------------------------------------------------------------------- /subl2tm.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | name 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | uuid 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Commands/Compile Active File to Command Line Tool.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby 9 | # 10 | # Compile the active file to an executable. 11 | # Executable name is prefixed with "Test". 12 | 13 | require 'English' 14 | 15 | FilePath = ENV['TM_FILEPATH'] 16 | FileDir = ENV['TM_DIRECTORY'] 17 | FileBaseName = File.basename(FilePath) 18 | FileExtension = File.extname(FilePath) 19 | FileNoExtension = FileBaseName.sub(/#{FileExtension}$/, "") 20 | 21 | Dir.chdir(ENV['TM_DIRECTORY']) 22 | 23 | # have to use g++ to bring in C++ runtime libraries 24 | cc = case FileExtension 25 | when /\.c(pp?|xx|\+\+)/,'.C','.ii' 26 | 'g++' 27 | else 28 | 'gcc' 29 | end 30 | 31 | puts %x{ "#{cc}" -g -Wmost -Os -o "Test#{FileNoExtension}" "$TM_FILEPATH"} 32 | 33 | puts "Successfully created Test#{FileNoExtension}" unless $CHILD_STATUS != 0 34 | 35 | input 36 | none 37 | name 38 | Compile Single File to Tool 39 | output 40 | showAsTooltip 41 | scope 42 | source.c, source.c++ 43 | uuid 44 | FF165AAB-1582-4DA8-B0D1-13EBD30B24FD 45 | 46 | 47 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Indentation Rules.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Indentation Rules 7 | scope 8 | source.c, source.c++, source.objc, source.objc++ 9 | settings 10 | 11 | decreaseIndentPattern 12 | (?x) 13 | ^ (.*\*/)? \s* \} ( [^}{"']* \{ | \s* while \s* \( .* )? [;\s]* (//.*|/\*.*\*/\s*)? $ 14 | | ^ \s* (public|private|protected): \s* $ 15 | | ^ \s* @(public|private|protected) \s* $ 16 | 17 | increaseIndentPattern 18 | (?x) 19 | ^ .* \{ [^}"']* $ 20 | | ^ \s* (public|private|protected): \s* $ 21 | | ^ \s* @(public|private|protected) \s* $ 22 | 23 | indentNextLinePattern 24 | (?x)^ 25 | (?! .* [;:{}] # do not indent when line ends with ;, :, {, or } 26 | \s* (//|/[*] .* [*]/ \s* $) # …account for potential trailing comment 27 | | @(public|private|protected) # do not indent after obj-c data access keywords 28 | ) 29 | .* [^\s;:{}] \s* $ # indent next if this one isn’t 30 | # terminated with ;, :, {, or } 31 | 32 | unIndentedLinePattern 33 | ^\s*((/\*|\*/|//|#|template\b.*?>(?!\(.*\))|@protocol|@optional|@interface(?!.*\{)|@implementation|@end).*)?$ 34 | 35 | uuid 36 | 02EB44C6-9203-4F4C-BFCB-7E3360B12812 37 | 38 | 39 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Support/SpotlightSearch.rb: -------------------------------------------------------------------------------- 1 | 2 | user_folder = ENV['TM_PROJECT_DIRECTORY'] 3 | 4 | (user_folder = ENV['TM_DIRECTORY']) if user_folder.nil? or user_folder.empty? or user_folder == '/' 5 | (user_folder = nil) if user_folder.nil? or user_folder.empty? or user_folder == '/' 6 | 7 | SearchFolders = [user_folder, "/System/Library/Frameworks", "/usr/include"].compact 8 | 9 | header = ARGV[0] 10 | fragment_path_to_header = header.split("/") 11 | header_component = fragment_path_to_header.pop 12 | 13 | def search( header_name ) 14 | result_paths = Array.new 15 | 16 | # find all candidates 17 | SearchFolders.each do |folder| 18 | results = %x{mdfind -onlyin "#{folder}" "kMDItemFSName == \"#{header_name}\" || kMDItemFSName == \"#{header_name}.h\"" } 19 | results.each_line {|line| result_paths << line} 20 | end 21 | 22 | return result_paths 23 | end 24 | 25 | result_paths = search(header_component) 26 | 27 | # verify the prefix path, if one is specified, 28 | # e.g. header == sys/errno.h, need to verify that "sys" is the parent directory 29 | if result_paths.size > 0 and fragment_path_to_header.size > 0 30 | fragment_path_to_header.reverse! 31 | 32 | # there's probably a simpler way to do this 33 | filtered_result_paths = result_paths.reject do |path| 34 | reject_me = false 35 | result_path_components = path.split("/") 36 | result_path_components.pop 37 | 38 | fragment_path_to_header.each {|frag| reject_me = true if result_path_components.pop != frag } 39 | reject_me 40 | end 41 | 42 | # don't filter the result paths if it means an empty array, on the theory 43 | # that finding something is better than finding nothing (and might be what 44 | # the user wanted anyway) 45 | result_paths = filtered_result_paths if filtered_result_paths.size > 0 46 | end 47 | 48 | puts result_paths.compact.join("\n") 49 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Commands/Run.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | autoScrollOutput 6 | 7 | beforeRunningCommand 8 | nop 9 | command 10 | #!/usr/bin/env ruby 11 | 12 | require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor" 13 | require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document" 14 | 15 | mode = ENV["TM_SCOPE"].slice(/.*?\bsource\.((?:obj)?c(\+\+)?)/, 1) 16 | 17 | 18 | case mode 19 | when "c" 20 | g = "GCC" 21 | env = "C" 22 | ext = "c" 23 | lang = "c" 24 | when "c++" 25 | g = "GXX" 26 | env = "CXX" 27 | ext = "cc" 28 | lang = "c++" 29 | when "objc" 30 | g = "GCC" 31 | env = "OBJC" 32 | ext = "m" 33 | lang = "objective-c" 34 | when "objc++" 35 | g = "GXX" 36 | env = "OBJCXX" 37 | ext = "mm" 38 | lang = "objective-c++" 39 | end 40 | 41 | TextMate.save_current_document(ext) 42 | TextMate::Executor.make_project_master_current_document 43 | 44 | flags = ENV["TM_#{env}_FLAGS"] || "-Wall -include stdio.h #{"-include iostream" unless mode[/c\+\+$/].nil?} #{"-framework Cocoa" unless mode[/^obj/].nil?}" 45 | args = [ENV["TM_#{g}"] || g.downcase.gsub("x", "+"), flags + " -x #{lang}", ENV["TM_FILEPATH"]] 46 | 47 | TextMate::Executor.run(args, :version_args => ["--version"], :version_regex => /\A([^\n]*) \(GCC\).*/m) 48 | 49 | input 50 | document 51 | keyEquivalent 52 | @r 53 | name 54 | Run 55 | output 56 | showAsHTML 57 | scope 58 | source.c, source.c++, source.objc, source.objc++ 59 | uuid 60 | E823A373-FFD6-42F1-998F-7571A3553847 61 | 62 | 63 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Support/bin/insert_missing_includes.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'set' 4 | require "zlib" 5 | 6 | def find_include_lines(io) 7 | res = [] 8 | in_synopsis = false 9 | io.each_line do |line| 10 | if in_synopsis then 11 | case line 12 | when /^\.In (\S+)$/: res << $1 13 | when /^\.\w+ #include <(\S+)>$/: res << $1 14 | when /^\.Sh /: break 15 | end 16 | elsif line =~ /^\.Sh SYNOPSIS/ 17 | in_synopsis = true 18 | end 19 | end 20 | res 21 | end 22 | 23 | MARK = [0xFFFC].pack("U").freeze 24 | def esc (txt); txt.gsub(/[$`\\]/, '\\\\\0'); end 25 | parts = STDIN.read.split(MARK) 26 | src = parts.join 27 | 28 | # find all function calls 29 | src.gsub!(/(if|while|for|switch|sizeof|sizeofA)\s*\(/, '') 30 | functions = src.scan(/(?:(?!->).(?!@|\.).|^\s*)\b([a-z]+)(?=\()/).flatten.to_set 31 | 32 | # collect paths to all man files involved 33 | paths = functions.collect do |func| 34 | %x{ man 2>/dev/null -WS2:3 #{func} }.scan(/.+/) 35 | end.flatten.sort.uniq 36 | 37 | # harvest includes from man files 38 | includes = Set.new 39 | paths.each do |path| 40 | if path =~ /\.gz$/ 41 | Zlib::GzipReader.open(path) { |io| includes.merge(find_include_lines(io)) } 42 | else 43 | File.open(path) { |io| includes.merge(find_include_lines(io)) } 44 | end 45 | end 46 | 47 | # figure out what we already included 48 | included = src.scan(/^\s*#\s*(?:include|import)\s+<(\S+)>/).flatten.to_set 49 | 50 | new_includes = (includes - included).collect do |inc| 51 | "#include <#{inc}>\n" 52 | end.join 53 | 54 | parts[0].sub!(/\A (?: 55 | ^ \s* (?: 56 | \/\/ .* # line comments 57 | | \/\* (?m:.*?) \*\/ # comment blocks 58 | | \# \s* (?:include|import) \s+ <.* # system includes 59 | | # blank lines 60 | ) \s* $ \n )*/x, '\0' + new_includes) 61 | 62 | print parts.collect { |part| esc part }.join('${0}') 63 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Preferences/Include Completion (System).tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Header Completion (System) 7 | scope 8 | meta.preprocessor.c.include string.quoted.other.lt-gt.include 9 | settings 10 | 11 | completionCommand 12 | #!/usr/bin/env ruby -wKU 13 | 14 | USR_HEAD = Regexp.escape "#include \"...\" search starts here:\n" 15 | SYS_HEAD = Regexp.escape "#include <...> search starts here:\n" 16 | FOOTER = Regexp.escape "End of search list." 17 | 18 | COMPILER = { 19 | "source.c" => "gcc 2>&1 >/dev/null -E -v -x c /dev/null", 20 | "source.c++" => "g++ 2>&1 >/dev/null -E -v -x c++ /dev/null", 21 | "source.objc" => "gcc 2>&1 >/dev/null -E -v -x objective-c /dev/null", 22 | "source.objc++" => "g++ 2>&1 >/dev/null -E -v -x objective-c++ /dev/null", 23 | } 24 | 25 | def compiler_search_path(domain = :system) 26 | scope = "source.c" 27 | scope = $& if ENV["TM_SCOPE"] =~ /source.(obj)?c(\+\+)?/ 28 | 29 | res = IO.popen(COMPILER[scope]) { |io| io.read } 30 | if res =~ /#{USR_HEAD}(.*)#{SYS_HEAD}(.*)#{FOOTER}/m 31 | case domain 32 | when :system then $2 33 | when :user then $1 + " .\n" 34 | when :all then $1 + " .\n" + $2 35 | end.scan(/ (\S*)(?: \(framework directory\)$)?/).flatten 36 | else 37 | abort "Failed to parse compiler output.\nCommand: " + COMPILER[scope] 38 | end 39 | end 40 | 41 | def user_search_path(domain = :system) 42 | usr = ENV["TM_USR_HEADER_PATH"].to_s 43 | sys = ENV["TM_SYS_HEADER_PATH"].to_s 44 | 45 | res = case domain 46 | when :system then sys 47 | when :user then usr 48 | when :all then "#{usr}:#{sys}" 49 | end.split(":") 50 | res.delete("") 51 | 52 | res.empty? ? nil : res 53 | end 54 | 55 | def expand_dirs(entries) 56 | entries.map do |entry| 57 | if entry =~ /(.*)\.framework$/ 58 | if File.exists? "#$1.framework/Headers/#$1.h" 59 | "#$1/#$1.h" 60 | elsif File.exists? "#$1.framework/Headers" 61 | Dir["#$1.framework/Headers/[A-Za-z]*.h"].sort.map do |e| 62 | e.sub(/\.framework\/Headers\//, "/") 63 | end 64 | else 65 | [ ] 66 | end 67 | elsif File.directory? entry 68 | Dir[entry + "/[A-Za-z]*.h"].sort 69 | else 70 | entry 71 | end 72 | end 73 | end 74 | 75 | partial_word = ENV["TM_CURRENT_WORD"] 76 | 77 | dirs = user_search_path(:system) || compiler_search_path(:system) 78 | res = [ ] 79 | dirs.each do |dir| 80 | Dir.chdir(dir) { res << expand_dirs(Dir[partial_word + "*"].sort) } 81 | end 82 | puts res.flatten.join("\n") 83 | disableDefaultCompletion 84 | 1 85 | 86 | uuid 87 | 9136716A-CE06-4801-ABC9-3D64300869F8 88 | 89 | 90 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Support/c_completion.rb: -------------------------------------------------------------------------------- 1 | class CCompletion 2 | def file_names 3 | ["CLib.txt.gz"] 4 | end 5 | 6 | def candidates_or_exit(methodSearch="") 7 | candidates = [] 8 | file_names.each do |name| 9 | zGrepped = %x{ zgrep ^#{e_sh methodSearch } #{e_sh ENV['TM_BUNDLE_SUPPORT']}/#{name} } 10 | candidates += zGrepped.split("\n") 11 | end 12 | TextMate.exit_show_tool_tip "No completion available" if candidates.empty? 13 | return candidates 14 | end 15 | 16 | def prettify(candidate) 17 | ca = candidate.split("\t") 18 | ca[0]+ca[1] 19 | end 20 | 21 | def snippet_generator(cand, s) 22 | c = cand.split"\t" 23 | i = 0 24 | middle = c[1][1..-2].split(",").collect do |arg| 25 | "${"+(i+=1).to_s+":"+ arg.strip + "}" 26 | end.join(", ") 27 | c[0][s..-1]+"("+middle+")$0" 28 | end 29 | 30 | def pop_up(candidates, searchTerm) 31 | start = searchTerm.size 32 | prettyCandidates = candidates.map { |candidate| [prettify(candidate), candidate] }.sort 33 | if prettyCandidates.size > 1 34 | require "enumerator" 35 | pruneList = [] 36 | 37 | prettyCandidates.each_cons(2) do |a| 38 | pruneList << (a[0][0] != a[1][0]) # check if prettified versions are the same 39 | end 40 | pruneList << true 41 | ind = -1 42 | prettyCandidates = prettyCandidates.select do |a| #remove duplicates 43 | pruneList[ind+=1] 44 | end 45 | end 46 | 47 | if prettyCandidates.size > 1 48 | #index = start 49 | #test = false 50 | #while !test 51 | # candidates.each_cons(2) do |a,b| 52 | # break if test = (a[index].chr != b[index].chr || a[index].chr == "\t") 53 | # end 54 | # break if test 55 | # searchTerm << candidates[0][index].chr 56 | # index +=1 57 | #end 58 | require "#{ENV['TM_SUPPORT_PATH']}/lib/osx/plist" 59 | pl = {'menuItems' => prettyCandidates.map { |pretty, full | { 'title' => pretty, 'cand' => full} }} 60 | io = open('|"$DIALOG" -u', "r+") 61 | io << pl.to_plist 62 | io.close_write 63 | res = OSX::PropertyList.load(io.read) 64 | if res.has_key? 'selectedMenuItem' 65 | snippet_generator( res['selectedMenuItem']['cand'], start ) 66 | else 67 | "" 68 | end 69 | else 70 | snippet_generator( candidates[0], start ) 71 | end 72 | end 73 | 74 | def print 75 | line = ENV['TM_CURRENT_LINE'] 76 | if ENV['TM_INPUT_START_LINE_INDEX'] 77 | caret_placement =ENV['TM_INPUT_START_LINE_INDEX'].to_i -1 78 | else 79 | caret_placement =ENV['TM_LINE_INDEX'].to_i - 1 80 | end 81 | 82 | backContext = line[1+caret_placement..-1].match /^[a-zA-Z0-9_]/ 83 | 84 | if backContext 85 | TextMate.exit_discard 86 | end 87 | 88 | 89 | alpha_and_caret = /[a-zA-Z_][_a-zA-Z0-9]*\(?$/ 90 | if k = line[0..caret_placement].match(alpha_and_caret) 91 | candidates = candidates_or_exit(k[0]) 92 | res = pop_up(candidates, k[0]) 93 | else 94 | res = "" 95 | end 96 | end 97 | end 98 | 99 | class CppCompletion < CCompletion 100 | def file_names 101 | super << "C++Lib.txt.gz" 102 | end 103 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Description 2 | ----------- 3 | 4 | It is an XSL Transformation file to switch between TextMate & Sublime Text snippets. 5 | 6 | Also included is an ant script that will convert entire bundles/packages between the two systems. 7 | 8 | 9 | Known issues and feature requests 10 | --------------------------------- 11 | 12 | Please go [here](https://github.com/srbs/textmate-to-sublime-converter/issues) to view current issues & feature requests, or to file a new one. 13 | 14 | 15 | Prerequisites 16 | ------------- 17 | 18 | 1. To use only the XSL Transformation files (*.xsl), 19 | * tm2subl: 20 | * Any XSLT processor will work. [Mac & Linux][xsltproc] come with a command built in, 21 | while [Windows][xsltproc-win] needs a download. 22 | 23 | More information on this command, see [xmlsoft][xmlsoft] 24 | or [installing instructions][install-xslt]. 25 | * subl2tm: 26 | * When converting to TextMate, I have the transformer create a UUID for TextMate to use, 27 | this requires a more advanced XSLT implementation than is given above. 28 | 29 | [Apache xalan][xalan] works without any 30 | xsl file edits. (This is what is used inside of Ant.) 31 | 32 | [Saxon][saxon] should work with one edit of the file: 33 | 34 | `xmlns:uuid="java.util.UUID"` 35 | on line 2 becomes: 36 | `xmlns:uuid="java:java.util.UUID"` 37 | 38 | To use [xsltproc](#tm2subl) above, remove lines 26-31 & `xmlns:uuid="java.util.UUID"` on line 2. 39 | 40 | 41 | 42 | 2. To use the Ant XML scripts (*.xml) 43 | * [Java 1.4][java] or above 44 | * [Ant 1.8][ant] or above 45 | 46 | Note: the requirements in 1 are not required for 2 and visa versa. 47 | 48 | 49 | How to Get 50 | ---------- 51 | 52 | git clone https://github.com/srbs/textmate-to-sublime-converter 53 | 54 | 55 | Usage 56 | ----- 57 | 58 | ... 59 | 60 | 61 | License 62 | ------- 63 | 64 | Copyright (c) 2012-2015 David "srbs" Forrest 65 | 66 | This software is provided 'as-is', without any express or implied 67 | warranty. In no event will the authors be held liable for any damages 68 | arising from the use of this software. 69 | 70 | Permission is granted to anyone to use this software for any purpose, 71 | including commercial applications, and to alter it and redistribute it 72 | freely, subject to the following restrictions: 73 | 74 | 1. The origin of this software must not be misrepresented; you must not 75 | claim that you wrote the original software. If you use this software 76 | in a product, an acknowledgment in the product documentation would be 77 | appreciated but is not required. 78 | 79 | 2. Altered source versions must be plainly marked as such, and must not be 80 | misrepresented as being the original software. 81 | 82 | 3. This notice may not be removed or altered from any source 83 | distribution. 84 | 85 | 86 | [xalan]: http://xml.apache.org/xalan-j/getstarted.html "Apache Xalan" 87 | [saxon]: http://saxon.sourceforge.net/ "Saxon" 88 | [xsltproc]: http://xmlsoft.org/xslt/xsltproc.html "XSLT proc" 89 | [xsltproc-win]: http://www.zlatkovic.com/libxml.en.html "XSLT for Windows" 90 | 91 | [xmlsoft]: http://xmlsoft.org/ "LibXML2" 92 | [install-xslt]: http://www.sagehill.net/docbookxsl/InstallingAProcessor.html "Installing xsltproc" 93 | 94 | [ant]: http://ant.apache.org/ "Apache Ant" 95 | [java]: http://www.oracle.com/technetwork/java/javase/downloads/index.html "Java" 96 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Commands/Fold:Unfold Code.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | bundleUUID 8 | 4675A940-6227-11D9-BFB1-000D93589AF6 9 | command 10 | #!/usr/bin/env ruby 11 | line = STDIN.read 12 | $tab = (ENV['TM_SOFT_TABS'] == "NO" ? "\t" : " "*ENV['TM_TAB_SIZE'].to_i ) 13 | def join_code s 14 | # transform // comments to /* */ comments while leaving strings intact 15 | s.gsub!(/((['"])(?:\\.|.)*?\2)|\/\*.*?\*\/|\/\/([^\n\r]*)/m) do |line| 16 | if $3 17 | '/*' + $3.gsub(/\*\//, '') + '*/' 18 | else 19 | line 20 | end 21 | end 22 | print s.split("\n").map {|line| line.strip}.join(" ") 23 | end 24 | 25 | def print_line(line, indent, for_ticker) 26 | s = "" 27 | s = "\n" if for_ticker == 0 28 | s + $tab*indent + line # the space should be replaced with soft or hard tab 29 | end 30 | 31 | def split_code s 32 | res = [] 33 | indent = 0 34 | for_ticker = 1 35 | # this regexp should not have a capture depth deeper than 1 36 | # yes that does rule out backrefs :( 37 | s.split(/([\{\}\;]|"(?:\\.|.)*?"|'(?:\\.|.)*?'|\/\*.*?\*\/|\/\/[^\n\r]*)/).map do |l| 38 | l = l.strip 39 | case l 40 | when /^for\s*\(/ 41 | res << print_line(l, indent, for_ticker) 42 | for_ticker = 5 43 | when "{" 44 | s = print_line(l, indent, for_ticker) 45 | for_ticker -= 1 unless for_ticker == 0 46 | indent += 1 47 | s += print_line("", indent, for_ticker) 48 | res << s 49 | when "}" 50 | indent -= 1 51 | res << print_line(l, indent, for_ticker) 52 | res << print_line("", indent, for_ticker) 53 | when ";" 54 | res << l 55 | if for_ticker == 0 56 | res << print_line("", indent, for_ticker) 57 | else 58 | res << " " 59 | end 60 | when /^\s*$/ 61 | for_ticker += 1 # if empty string maintain the status-quo 62 | else 63 | res << l 64 | end 65 | for_ticker -= 1 unless for_ticker == 0 66 | end 67 | 68 | require "enumerator" 69 | out = [] 70 | res.each_cons(2) do |a,b| 71 | # remove empty lines inserted when ; is followed by { or } 72 | out << a unless a.match(/^\n\s*$/) && b.match(/^\n\s*(\}|\{)\s*$/) 73 | end 74 | print out.join 75 | end 76 | 77 | if line.count("\n") > 1 78 | join_code(line) 79 | else 80 | split_code(line) 81 | end 82 | 83 | #k = "- (id)showSomeWindow 84 | # { 85 | # for(int i =0;i<a;i++) 86 | # { 87 | # \" boras /* */ //\" 88 | # // hello /* */ 89 | # if(a) 90 | # [ window makeKeyAndOrderFront:self]; 91 | # } 92 | # }" 93 | #join_code(k) 94 | #l = "- (id)showSomeWindow { for(int i =0;i<a;i++) { \" boras /* */ //\" /* hello /* */ if(a) [ window makeKeyAndOrderFront:self]; } }" 95 | #split_code(l) 96 | fallbackInput 97 | scope 98 | input 99 | selection 100 | keyEquivalent 101 | ^{ 102 | name 103 | Fold/Unfold Code 104 | output 105 | replaceSelectedText 106 | scope 107 | meta.block.c 108 | uuid 109 | 3D221F96-F4CC-432D-9A04-F9F4DF3E0F55 110 | 111 | 112 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Commands/Quick Open.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby -wKU 9 | 10 | require ENV['TM_SUPPORT_PATH'] + '/lib/textmate.rb' 11 | require ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb' 12 | 13 | USR_HEAD = Regexp.escape "#include \"...\" search starts here:\n" 14 | SYS_HEAD = Regexp.escape "#include <...> search starts here:\n" 15 | FOOTER = Regexp.escape 'End of search list.' 16 | 17 | COMPILER = { 18 | 'source.c' => 'gcc 2>&1 >/dev/null -E -v -x c /dev/null', 19 | 'source.c++' => 'g++ 2>&1 >/dev/null -E -v -x c++ /dev/null', 20 | 'source.objc' => 'gcc 2>&1 >/dev/null -E -v -x objective-c /dev/null', 21 | 'source.objc++' => 'g++ 2>&1 >/dev/null -E -v -x objective-c++ /dev/null', 22 | } 23 | 24 | def compiler_search_path(domain = :system) 25 | scope = 'source.c' 26 | scope = $& if ENV['TM_SCOPE'] =~ /source.(obj)?c(\+\+)?/ 27 | 28 | res = IO.popen(COMPILER[scope]) { |io| io.read } 29 | if res =~ /#{USR_HEAD}(.*)#{SYS_HEAD}(.*)#{FOOTER}/m 30 | case domain 31 | when :system then $2 32 | when :user then $1 + " .\n" 33 | when :all then $1 + " .\n" + $2 34 | end.scan(/ (\S*)(?: \(framework directory\)$)?/).flatten 35 | else 36 | abort "Failed to parse compiler output.\nCommand: " + COMPILER[scope] 37 | end 38 | end 39 | 40 | def user_search_path(domain = :system) 41 | usr = ENV['TM_USR_HEADER_PATH'].to_s 42 | sys = ENV['TM_SYS_HEADER_PATH'].to_s 43 | 44 | res = case domain 45 | when :system then sys 46 | when :user then usr 47 | when :all then "#{usr}:#{sys}" 48 | end.split(':') 49 | res.delete('') 50 | 51 | res.empty? ? nil : res 52 | end 53 | 54 | def header 55 | if ENV.has_key? 'TM_SELECTED_TEXT' 56 | [:all, ENV['TM_SELECTED_TEXT']] 57 | elsif ENV['TM_CURRENT_LINE'] =~ /#\s*(?:include|import)\s*([<"])(.*?)[">]/; 58 | [$1 == '<' ? :system : :user, $2] 59 | else 60 | defaultText = %x{ __CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 /usr/bin/pbpaste -pboard find } 61 | header = TextMate::UI.request_string :title => "Quick Open", :default => defaultText, :prompt => "Which header file do you wish to open?" 62 | [:all, header] 63 | end 64 | end 65 | 66 | def find_in_dirs(file, dirs) 67 | framework = file.sub(/(.*)\/(.*\.h)/, '\1.framework/Headers/\2') 68 | base = ENV['TM_DIRECTORY'] || Dir.getwd 69 | dirs.each do |dir| 70 | dir = "#{base}/#{dir}" unless dir[0..0] == "/" 71 | return "#{dir}/#{file}" if File.exists? "#{dir}/#{file}" 72 | return "#{dir}/#{framework}" if File.exists? "#{dir}/#{framework}" 73 | end 74 | nil 75 | end 76 | 77 | def find_recursively(header) 78 | hdr_match = /\b#{Regexp.escape(header.sub(/(\.h)?$/, '.h'))}$/i 79 | matches = Dir["/System/Library/Frameworks/*.framework/{Frameworks/*.framework/,}Headers/*.h"].find_all { |e| e =~ hdr_match } 80 | 81 | if matches.size > 1 82 | menu = matches.map do |e| 83 | header_name = $& if e =~ /[^\/]+$/ 84 | framework_suffix = e.scan(/\/([^\/]+?).framework/).flatten.join(' → ') 85 | { 'path' => e, 'title' => "#{header_name} — #{framework_suffix}" } 86 | end 87 | if res = TextMate::UI.menu(menu) 88 | res['path'] 89 | else 90 | nil 91 | end 92 | else 93 | matches.first 94 | end 95 | end 96 | 97 | domain, file = header() 98 | exit if file.nil? 99 | 100 | dirs = user_search_path(domain) || compiler_search_path(domain) 101 | if path = find_in_dirs(file, dirs) 102 | TextMate.go_to :file => path 103 | elsif domain == :all && path = find_recursively(file) 104 | TextMate.go_to :file => path 105 | else 106 | abort "Unable to find ‘#{file}’.\n\nLocations searched:\n" + dirs.map { |dir| " #{dir}" }.join("\n") 107 | end 108 | 109 | input 110 | none 111 | keyEquivalent 112 | @D 113 | name 114 | Quick Open 115 | output 116 | showAsTooltip 117 | scope 118 | source.c, source.objc, source.c++, source.objc++ 119 | uuid 120 | FF0E22D6-7D78-11D9-B4DE-000A95A89C98 121 | 122 | 123 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Support/c_completion2.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes" 3 | require "#{ENV['TM_SUPPORT_PATH']}/lib/escape" 4 | require "zlib" 5 | require "set" 6 | require "#{ENV['TM_SUPPORT_PATH']}/lib/ui" 7 | 8 | 9 | class ExternalSnippetizer 10 | 11 | def initialize(options = {}) 12 | @star = options[:star] || false 13 | @arg_name = options[:arg_name] || false 14 | @tm_C_pointer = options[:tm_C_pointer] || " *" 15 | end 16 | 17 | def snippet_generator(cand, start) 18 | 19 | cand = cand.strip 20 | oldstuff = cand[0..-1].split("\t") 21 | stuff = cand[start..-1].split("\t") 22 | stuffSize = stuff[0].size 23 | if oldstuff[0].count(":") == 1 24 | out = "${0:#{stuff[6]}}" 25 | elsif oldstuff[0].count(":") > 1 26 | 27 | name_array = stuff[0].split(":") 28 | out = "${1:#{stuff[-name_array.size - 1]}} " 29 | unless name_array.empty? 30 | begin 31 | stuff[-(name_array.size)..-1].each_with_index do |arg,i| 32 | out << name_array[i] + ":${#{i+2}:#{arg}} " 33 | end 34 | rescue NoMethodError 35 | out = "$0" 36 | end 37 | end 38 | else 39 | out = "$0" 40 | end 41 | return out.chomp.strip 42 | end 43 | 44 | def construct_arg_name(arg) 45 | a = arg.match(/(NS|AB|CI|CD)?(Mutable)?(([AEIOQUYi])?[A-Za-z_0-9]+)/) 46 | unless a.nil? 47 | (a[4].nil? ? "a": "an") + a[3].sub!(/\b\w/) { $&.upcase } 48 | else 49 | "" 50 | end 51 | end 52 | 53 | def type_declaration_snippet_generator(dict) 54 | 55 | arg_name = @arg_name && dict['noArg'] 56 | star = @star && dict['pure'] 57 | pointer = @tm_C_pointer 58 | pointer = " *" unless pointer 59 | 60 | if arg_name 61 | name = "${2:#{construct_arg_name dict['match']}}" 62 | if star 63 | name = ("${1:#{pointer}#{name}}") 64 | else 65 | name = " " + name 66 | end 67 | 68 | else 69 | name = pointer.rstrip if star 70 | end 71 | # name = name[0..-2].rstrip unless arg_name 72 | name + "$0" 73 | end 74 | 75 | def cfunction_snippet_generator(c) 76 | c = c.split"\t" 77 | i = 0 78 | "("+c[1][1..-2].split(",").collect do |arg| 79 | "${"+(i+=1).to_s+":"+ arg.strip + "}" 80 | end.join(", ")+")$0" 81 | end 82 | 83 | def run(res) 84 | if res['type'] == "methods" 85 | r = snippet_generator(res['cand'], res['match'].size) 86 | elsif res['type'] == "functions" 87 | r = cfunction_snippet_generator(res['cand']) 88 | elsif res['pure'] && res['noArg'] 89 | r = type_declaration_snippet_generator res 90 | else 91 | r = "$0" 92 | end 93 | return r 94 | end 95 | end 96 | 97 | class CCompletion 98 | def file_names 99 | ["CLib.txt.gz"] 100 | end 101 | 102 | def candidates_or_exit(methodSearch="") 103 | candidates = [] 104 | file_names.each do |name| 105 | zGrepped = %x{ zgrep ^#{e_sh methodSearch } #{e_sh ENV['TM_BUNDLE_SUPPORT']}/#{name} } 106 | candidates += zGrepped.split("\n") 107 | end 108 | TextMate.exit_show_tool_tip "No completion available" if candidates.empty? 109 | return candidates 110 | end 111 | 112 | def prettify(candidate) 113 | ca = candidate.split("\t") 114 | ca[0]+ca[1] 115 | end 116 | 117 | def snippet_generator(cand, s) 118 | c = cand.split"\t" 119 | i = 0 120 | middle = c[1][1..-2].split(",").collect do |arg| 121 | "${"+(i+=1).to_s+":"+ arg.strip + "}" 122 | end.join(", ") 123 | c[0][s..-1]+"("+middle+")$0" 124 | end 125 | 126 | def pop_up(candidates, searchTerm) 127 | start = searchTerm.size 128 | prettyCandidates = candidates.map { |candidate| [prettify(candidate), candidate] }.sort 129 | if prettyCandidates.size > 1 130 | require "enumerator" 131 | pruneList = [] 132 | 133 | prettyCandidates.each_cons(2) do |a| 134 | pruneList << (a[0][0] != a[1][0]) # check if prettified versions are the same 135 | end 136 | pruneList << true 137 | ind = -1 138 | prettyCandidates = prettyCandidates.select do |a| #remove duplicates 139 | pruneList[ind+=1] 140 | end 141 | end 142 | 143 | if prettyCandidates.size > 1 144 | #index = start 145 | #test = false 146 | #while !test 147 | # candidates.each_cons(2) do |a,b| 148 | # break if test = (a[index].chr != b[index].chr || a[index].chr == "\t") 149 | # end 150 | # break if test 151 | # searchTerm << candidates[0][index].chr 152 | # index +=1 153 | #end 154 | 155 | pl = prettyCandidates.map do |pretty, full | 156 | { 'display' => pretty, 157 | 'cand' => full, 158 | 'type' => "functions", 159 | 'match'=> full.split("\t")[0] 160 | } 161 | end 162 | 163 | flags = {} 164 | flags[:extra_chars]= '_' 165 | flags[:initial_filter]= searchTerm 166 | #TextMate.exit_show_tool_tip pl.inspect 167 | begin 168 | TextMate::UI.complete(pl, flags) do |hash| 169 | #{}"kalle kula" 170 | #hash.inspect 171 | es = ExternalSnippetizer.new 172 | 173 | es.run(hash) 174 | #hash.inspect 175 | end 176 | rescue NoMethodError 177 | TextMate.exit_show_tool_tip "you have Dialog2 installed but not the ui.rb in review" 178 | end 179 | TextMate.exit_discard # create_new_document 180 | else 181 | snippet_generator( candidates[0], start ) 182 | end 183 | end 184 | 185 | def print 186 | line = ENV['TM_CURRENT_LINE'] 187 | if ENV['TM_INPUT_START_LINE_INDEX'] 188 | caret_placement =ENV['TM_INPUT_START_LINE_INDEX'].to_i -1 189 | else 190 | caret_placement =ENV['TM_LINE_INDEX'].to_i - 1 191 | end 192 | 193 | backContext = line[1+caret_placement..-1].match /^[a-zA-Z0-9_]/ 194 | 195 | if backContext 196 | TextMate.exit_discard 197 | end 198 | 199 | 200 | alpha_and_caret = /[a-zA-Z_][_a-zA-Z0-9]*\(?$/ 201 | if k = line[0..caret_placement].match(alpha_and_caret) 202 | candidates = candidates_or_exit(k[0]) 203 | res = pop_up(candidates, k[0]) 204 | else 205 | res = "" 206 | end 207 | end 208 | end 209 | 210 | class CppCompletion < CCompletion 211 | def file_names 212 | super << "C++Lib.txt.gz" 213 | end 214 | end -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | contactEmailRot13 6 | gz-ohaqyrf@znpebzngrf.pbz 7 | contactName 8 | Allan Odgaard 9 | deleted 10 | 11 | A468007A-1960-4E1A-9F09-81EBFE04429C 12 | 13 | description 14 | Support for the venerable <a href="http://en.wikipedia.org/wiki/C_%28programming_language%29">C programming language</a> and for the leaner C++. The bundle has completion (using ⌥⎋) for the standard C functions and, in C++, STL algorithms. 15 | mainMenu 16 | 17 | excludedItems 18 | 19 | 5039DA0E-538B-48E2-A45A-E5A27787E765 20 | ADD104E9-830A-4AC4-AAF4-DB6D3B0B7506 21 | E8D80809-0CDE-4E57-AC2A-8C22DFF353EE 22 | 034C3F18-097D-4B2C-8F20-C1CA3E9573E9 23 | 093DA4F2-D97F-4309-B869-6970C090A539 24 | 25 | items 26 | 27 | E823A373-FFD6-42F1-998F-7571A3553847 28 | FF165AAB-1582-4DA8-B0D1-13EBD30B24FD 29 | ------------------------------------ 30 | FF0E22D6-7D78-11D9-B4DE-000A95A89C98 31 | 0DABAE22-81C5-4ADF-8BCC-9B343A51CCB9 32 | 1B7326BB-6A85-4ED2-A0D7-51619763D98F 33 | 45FFA4DA-C84A-4D1F-862B-F249C24941EF 34 | ------------------------------------ 35 | 318EB8ED-24B7-4BDA-840F-0BD4DE8635C1 36 | 95FCF3A0-0EF9-4BAD-9C20-78AA542CE9A4 37 | ------------------------------------ 38 | B10CBD5D-7298-11D9-813A-000D93589AF6 39 | 9AB31B76-7298-11D9-813A-000D93589AF6 40 | 680358EA-B24B-4662-8DDA-AD42288795E4 41 | ------------------------------------ 42 | A295A902-ACAF-11D9-987D-000D93589AF6 43 | 5E468268-ACAF-11D9-987D-000D93589AF6 44 | ------------------------------------ 45 | 5A086BE2-BCF6-11D9-82A9-000D93589AF6 46 | FE378349-BD63-4390-9A3B-516F7FF7F413 47 | 3D221F96-F4CC-432D-9A04-F9F4DF3E0F55 48 | 49 | submenus 50 | 51 | 318EB8ED-24B7-4BDA-840F-0BD4DE8635C1 52 | 53 | items 54 | 55 | F060AC09-C289-11D9-8CEF-000D93589AF6 56 | D1F5A25E-A70F-11D9-A11A-000A95A89C98 57 | 78EF7134-0859-4475-89C3-30927865E855 58 | ------------------------------------ 59 | 523B30D4-C28A-11D9-8CEF-000D93589AF6 60 | 1D14B92E-8819-11D9-8661-000D93589AF6 61 | CEE5F928-47A2-4648-96F0-99FF5C2A7419 62 | DD10B510-1C36-45E0-A378-527401EE55B1 63 | 08E16CAE-DBD8-4570-B778-9E0E0EFFF80C 64 | ------------------------------------ 65 | C5DEE118-4C9E-4F3E-97A4-0E01A250F142 66 | 67 | name 68 | Declarations 69 | 70 | 95FCF3A0-0EF9-4BAD-9C20-78AA542CE9A4 71 | 72 | items 73 | 74 | 74AF5E38-994C-4641-96F0-EB98A2183F60 75 | E8C3B596-9045-11D9-AB38-000D93589AF6 76 | BC8B81AB-5F16-11D9-B9C3-000D93589AF6 77 | 62D59E1C-1DF1-490E-86E9-DFF8A461AD9C 78 | 986C0149-7802-4385-A237-90074D9D5ACD 79 | 80 | name 81 | Idioms 82 | 83 | 84 | 85 | name 86 | C 87 | ordering 88 | 89 | FF0E22D6-7D78-11D9-B4DE-000A95A89C98 90 | FF165AAB-1582-4DA8-B0D1-13EBD30B24FD 91 | E8D80809-0CDE-4E57-AC2A-8C22DFF353EE 92 | 0DABAE22-81C5-4ADF-8BCC-9B343A51CCB9 93 | 034C3F18-097D-4B2C-8F20-C1CA3E9573E9 94 | 74AF5E38-994C-4641-96F0-EB98A2183F60 95 | E8C3B596-9045-11D9-AB38-000D93589AF6 96 | B10CBD5D-7298-11D9-813A-000D93589AF6 97 | 9AB31B76-7298-11D9-813A-000D93589AF6 98 | 680358EA-B24B-4662-8DDA-AD42288795E4 99 | ADD104E9-830A-4AC4-AAF4-DB6D3B0B7506 100 | BC8B81AB-5F16-11D9-B9C3-000D93589AF6 101 | D1F5A25E-A70F-11D9-A11A-000A95A89C98 102 | 78EF7134-0859-4475-89C3-30927865E855 103 | F060AC09-C289-11D9-8CEF-000D93589AF6 104 | 1D14B92E-8819-11D9-8661-000D93589AF6 105 | 523B30D4-C28A-11D9-8CEF-000D93589AF6 106 | CEE5F928-47A2-4648-96F0-99FF5C2A7419 107 | DD10B510-1C36-45E0-A378-527401EE55B1 108 | 08E16CAE-DBD8-4570-B778-9E0E0EFFF80C 109 | A295A902-ACAF-11D9-987D-000D93589AF6 110 | 5E468268-ACAF-11D9-987D-000D93589AF6 111 | 5A086BE2-BCF6-11D9-82A9-000D93589AF6 112 | FE378349-BD63-4390-9A3B-516F7FF7F413 113 | 62D59E1C-1DF1-490E-86E9-DFF8A461AD9C 114 | C5DEE118-4C9E-4F3E-97A4-0E01A250F142 115 | 5039DA0E-538B-48E2-A45A-E5A27787E765 116 | 25066DC2-6B1D-11D9-9D5B-000D93589AF6 117 | 26251B18-6B1D-11D9-AFDB-000D93589AF6 118 | 38DBCCE5-2005-410C-B7D7-013097751AC8 119 | 9136716A-CE06-4801-ABC9-3D64300869F8 120 | 66EE7D45-6AA0-4AB9-9699-A3DF4E2B9AE7 121 | 02EB44C6-9203-4F4C-BFCB-7E3360B12812 122 | DC32505E-226B-409A-B3C3-8FC88BF4A131 123 | 1EACF554-A30C-44B0-B97A-11E3FA995045 124 | 47DD44E6-B4F5-4C2E-BC62-C6ACEBC02A0D 125 | 45FFA4DA-C84A-4D1F-862B-F249C24941EF 126 | 093DA4F2-D97F-4309-B869-6970C090A539 127 | 3D221F96-F4CC-432D-9A04-F9F4DF3E0F55 128 | 1B7326BB-6A85-4ED2-A0D7-51619763D98F 129 | E823A373-FFD6-42F1-998F-7571A3553847 130 | B2B97E23-E686-4410-991D-A92AF3A9FC95 131 | A8E4E48A-81F3-4DB7-A7A2-88662C06E011 132 | 133 | source 134 | 135 | method 136 | git 137 | url 138 | git://github.com/textmate/c.tmbundle 139 | 140 | uuid 141 | 4675A940-6227-11D9-BFB1-000D93589AF6 142 | 143 | 144 | -------------------------------------------------------------------------------- /tm2subl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 174 | 175 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /subl2tm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 164 | 165 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 200 | 201 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/C++.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | comment 6 | I don't think anyone uses .hp. .cp tends to be paired with .h. (I could be wrong. :) -- chris 7 | fileTypes 8 | 9 | cpp 10 | cc 11 | cp 12 | cxx 13 | c++ 14 | C 15 | h 16 | hh 17 | hpp 18 | hxx 19 | h++ 20 | inl 21 | ipp 22 | 23 | firstLineMatch 24 | -\*- C\+\+ -\*- 25 | foldingStartMarker 26 | (?x) 27 | /\*\*(?!\*) 28 | |^(?![^{]*?//|[^{]*?/\*(?!.*?\*/.*?\{)).*?\{\s*($|//|/\*(?!.*?\*/.*\S)) 29 | 30 | foldingStopMarker 31 | (?<!\*)\*\*/|^\s*\} 32 | keyEquivalent 33 | ^~C 34 | name 35 | C++ 36 | patterns 37 | 38 | 39 | include 40 | #special_block 41 | 42 | 43 | include 44 | source.c 45 | 46 | 47 | match 48 | \b(friend|explicit|virtual)\b 49 | name 50 | storage.modifier.c++ 51 | 52 | 53 | match 54 | \b(private:|protected:|public:) 55 | name 56 | storage.modifier.c++ 57 | 58 | 59 | match 60 | \b(catch|operator|try|throw|using)\b 61 | name 62 | keyword.control.c++ 63 | 64 | 65 | match 66 | \bdelete\b(\s*\[\])?|\bnew\b(?!]) 67 | name 68 | keyword.control.c++ 69 | 70 | 71 | comment 72 | common C++ instance var naming idiom -- fMemberName 73 | match 74 | \b(f|m)[A-Z]\w*\b 75 | name 76 | variable.other.readwrite.member.c++ 77 | 78 | 79 | match 80 | \b(this)\b 81 | name 82 | variable.language.c++ 83 | 84 | 85 | match 86 | \btemplate\b\s* 87 | name 88 | storage.type.template.c++ 89 | 90 | 91 | match 92 | \b(const_cast|dynamic_cast|reinterpret_cast|static_cast)\b\s* 93 | name 94 | keyword.operator.cast.c++ 95 | 96 | 97 | match 98 | \b(and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq)\b 99 | name 100 | keyword.operator.c++ 101 | 102 | 103 | match 104 | \b(class|wchar_t)\b 105 | name 106 | storage.type.c++ 107 | 108 | 109 | match 110 | \b(export|mutable|typename)\b 111 | name 112 | storage.modifier.c++ 113 | 114 | 115 | begin 116 | (?x) 117 | (?: ^ # begin-of-line 118 | | (?: (?<!else|new|=) ) # or word + space before name 119 | ) 120 | ((?:[A-Za-z_][A-Za-z0-9_]*::)*+~[A-Za-z_][A-Za-z0-9_]*) # actual name 121 | \s*(\() # start bracket or end-of-line 122 | 123 | beginCaptures 124 | 125 | 1 126 | 127 | name 128 | entity.name.function.c++ 129 | 130 | 2 131 | 132 | name 133 | punctuation.definition.parameters.c 134 | 135 | 136 | end 137 | \) 138 | endCaptures 139 | 140 | 0 141 | 142 | name 143 | punctuation.definition.parameters.c 144 | 145 | 146 | name 147 | meta.function.destructor.c++ 148 | patterns 149 | 150 | 151 | include 152 | $base 153 | 154 | 155 | 156 | 157 | begin 158 | (?x) 159 | (?: ^ # begin-of-line 160 | | (?: (?<!else|new|=) ) # or word + space before name 161 | ) 162 | ((?:[A-Za-z_][A-Za-z0-9_]*::)*+~[A-Za-z_][A-Za-z0-9_]*) # actual name 163 | \s*(\() # terminating semi-colon 164 | 165 | beginCaptures 166 | 167 | 1 168 | 169 | name 170 | entity.name.function.c++ 171 | 172 | 2 173 | 174 | name 175 | punctuation.definition.parameters.c 176 | 177 | 178 | end 179 | \) 180 | endCaptures 181 | 182 | 0 183 | 184 | name 185 | punctuation.definition.parameters.c 186 | 187 | 188 | name 189 | meta.function.destructor.prototype.c++ 190 | patterns 191 | 192 | 193 | include 194 | $base 195 | 196 | 197 | 198 | 199 | repository 200 | 201 | angle_brackets 202 | 203 | begin 204 | < 205 | end 206 | > 207 | name 208 | meta.angle-brackets.c++ 209 | patterns 210 | 211 | 212 | include 213 | #angle_brackets 214 | 215 | 216 | include 217 | $base 218 | 219 | 220 | 221 | block 222 | 223 | begin 224 | \{ 225 | end 226 | \} 227 | name 228 | meta.block.c++ 229 | patterns 230 | 231 | 232 | captures 233 | 234 | 1 235 | 236 | name 237 | support.function.any-method.c 238 | 239 | 2 240 | 241 | name 242 | punctuation.definition.parameters.c 243 | 244 | 245 | match 246 | (?x) 247 | ( 248 | (?!while|for|do|if|else|switch|catch|enumerate|return|r?iterate)(?: \b[A-Za-z_][A-Za-z0-9_]*+\b | :: )*+ # actual name 249 | ) 250 | \s*(\() 251 | name 252 | meta.function-call.c 253 | 254 | 255 | include 256 | $base 257 | 258 | 259 | 260 | constructor 261 | 262 | patterns 263 | 264 | 265 | begin 266 | (?x) 267 | (?: ^\s*) # begin-of-line 268 | ((?!while|for|do|if|else|switch|catch|enumerate|r?iterate)[A-Za-z_][A-Za-z0-9_:]*) # actual name 269 | \s*(\() # start bracket or end-of-line 270 | 271 | beginCaptures 272 | 273 | 1 274 | 275 | name 276 | entity.name.function.c++ 277 | 278 | 2 279 | 280 | name 281 | punctuation.definition.parameters.c 282 | 283 | 284 | end 285 | \) 286 | endCaptures 287 | 288 | 0 289 | 290 | name 291 | punctuation.definition.parameters.c 292 | 293 | 294 | name 295 | meta.function.constructor.c++ 296 | patterns 297 | 298 | 299 | include 300 | $base 301 | 302 | 303 | 304 | 305 | begin 306 | (?x) 307 | (:) # begin-of-line 308 | ((?=\s*[A-Za-z_][A-Za-z0-9_:]* # actual name 309 | \s*(\())) # start bracket or end-of-line 310 | 311 | beginCaptures 312 | 313 | 1 314 | 315 | name 316 | punctuation.definition.parameters.c 317 | 318 | 319 | end 320 | (?=\{) 321 | name 322 | meta.function.constructor.initializer-list.c++ 323 | patterns 324 | 325 | 326 | include 327 | $base 328 | 329 | 330 | 331 | 332 | 333 | special_block 334 | 335 | patterns 336 | 337 | 338 | begin 339 | \b(namespace)\s+([A-Za-z_][_A-Za-z0-9:]*\b)?+(?!\s*?(;|=|,)) 340 | end 341 | (?<=\}) 342 | name 343 | meta.namespace-block.c++ 344 | patterns 345 | 346 | 347 | begin 348 | \{ 349 | end 350 | \} 351 | patterns 352 | 353 | 354 | include 355 | #special_block 356 | 357 | 358 | include 359 | #constructor 360 | 361 | 362 | include 363 | $base 364 | 365 | 366 | 367 | 368 | 369 | 370 | begin 371 | \b(class|struct)\s+([_A-Za-z][_A-Za-z0-9]*\b) 372 | beginCaptures 373 | 374 | 1 375 | 376 | name 377 | storage.type.c++ 378 | 379 | 2 380 | 381 | name 382 | entity.name.type.c++ 383 | 384 | 385 | end 386 | (?<=\})|(?=(;|,|\(|\)|>|\[|\])) 387 | name 388 | meta.class-struct-block.c++ 389 | patterns 390 | 391 | 392 | include 393 | #angle_brackets 394 | 395 | 396 | begin 397 | (\{) 398 | beginCaptures 399 | 400 | 1 401 | 402 | name 403 | punctuation.definition.scope.c++ 404 | 405 | 406 | end 407 | (\})(\s*\n)? 408 | endCaptures 409 | 410 | 1 411 | 412 | name 413 | punctuation.definition.invalid.c++ 414 | 415 | 2 416 | 417 | name 418 | invalid.illegal.you-forgot-semicolon.c++ 419 | 420 | 421 | patterns 422 | 423 | 424 | include 425 | #special_block 426 | 427 | 428 | include 429 | #constructor 430 | 431 | 432 | include 433 | $base 434 | 435 | 436 | 437 | 438 | include 439 | $base 440 | 441 | 442 | 443 | 444 | begin 445 | \b(extern)(?=\s*") 446 | beginCaptures 447 | 448 | 1 449 | 450 | name 451 | storage.modifier.c++ 452 | 453 | 454 | end 455 | (?<=\})|(?=\w) 456 | name 457 | meta.extern-block.c++ 458 | patterns 459 | 460 | 461 | begin 462 | \{ 463 | end 464 | \} 465 | patterns 466 | 467 | 468 | include 469 | #special_block 470 | 471 | 472 | include 473 | $base 474 | 475 | 476 | 477 | 478 | include 479 | $base 480 | 481 | 482 | 483 | 484 | 485 | 486 | scopeName 487 | source.c++ 488 | uuid 489 | 26251B18-6B1D-11D9-AFDB-000D93589AF6 490 | 491 | 492 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Syntaxes/C++.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | comment 6 | I don't think anyone uses .hp. .cp tends to be paired with .h. (I could be wrong. :) -- chris 7 | fileTypes 8 | 9 | cc 10 | cpp 11 | cp 12 | cxx 13 | c++ 14 | C 15 | h 16 | hh 17 | hpp 18 | h++ 19 | 20 | firstLineMatch 21 | -\*- C\+\+ -\*- 22 | foldingStartMarker 23 | (?x) 24 | /\*\*(?!\*) 25 | |^(?![^{]*?//|[^{]*?/\*(?!.*?\*/.*?\{)).*?\{\s*($|//|/\*(?!.*?\*/.*\S)) 26 | 27 | foldingStopMarker 28 | (?<!\*)\*\*/|^\s*\} 29 | keyEquivalent 30 | ^~C 31 | name 32 | C++ 33 | patterns 34 | 35 | 36 | include 37 | #special_block 38 | 39 | 40 | include 41 | source.c 42 | 43 | 44 | match 45 | \b(friend|explicit|virtual)\b 46 | name 47 | storage.modifier.c++ 48 | 49 | 50 | match 51 | \b(private:|protected:|public:) 52 | name 53 | storage.modifier.c++ 54 | 55 | 56 | match 57 | \b(catch|operator|try|throw|using)\b 58 | name 59 | keyword.control.c++ 60 | 61 | 62 | match 63 | \bdelete\b(\s*\[\])?|\bnew\b(?!]) 64 | name 65 | keyword.control.c++ 66 | 67 | 68 | comment 69 | common C++ instance var naming idiom -- fMemberName 70 | match 71 | \b(f|m)[A-Z]\w*\b 72 | name 73 | variable.other.readwrite.member.c++ 74 | 75 | 76 | match 77 | \b(this)\b 78 | name 79 | variable.language.c++ 80 | 81 | 82 | match 83 | \btemplate\b\s* 84 | name 85 | storage.type.template.c++ 86 | 87 | 88 | match 89 | \b(const_cast|dynamic_cast|reinterpret_cast|static_cast)\b\s* 90 | name 91 | keyword.operator.cast.c++ 92 | 93 | 94 | match 95 | \b(and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq)\b 96 | name 97 | keyword.operator.c++ 98 | 99 | 100 | match 101 | \b(class|wchar_t)\b 102 | name 103 | storage.type.c++ 104 | 105 | 106 | match 107 | \b(export|mutable|typename)\b 108 | name 109 | storage.modifier.c++ 110 | 111 | 112 | begin 113 | (?x) 114 | (?: ^ # begin-of-line 115 | | (?: (?<!else|new|=) ) # or word + space before name 116 | ) 117 | ((?:[A-Za-z_][A-Za-z0-9_]*::)*+~[A-Za-z_][A-Za-z0-9_]*) # actual name 118 | \s*(\() # start bracket or end-of-line 119 | 120 | beginCaptures 121 | 122 | 1 123 | 124 | name 125 | entity.name.function.c++ 126 | 127 | 2 128 | 129 | name 130 | punctuation.definition.parameters.c 131 | 132 | 133 | end 134 | \) 135 | endCaptures 136 | 137 | 0 138 | 139 | name 140 | punctuation.definition.parameters.c 141 | 142 | 143 | name 144 | meta.function.destructor.c++ 145 | patterns 146 | 147 | 148 | include 149 | $base 150 | 151 | 152 | 153 | 154 | begin 155 | (?x) 156 | (?: ^ # begin-of-line 157 | | (?: (?<!else|new|=) ) # or word + space before name 158 | ) 159 | ((?:[A-Za-z_][A-Za-z0-9_]*::)*+~[A-Za-z_][A-Za-z0-9_]*) # actual name 160 | \s*(\() # terminating semi-colon 161 | 162 | beginCaptures 163 | 164 | 1 165 | 166 | name 167 | entity.name.function.c++ 168 | 169 | 2 170 | 171 | name 172 | punctuation.definition.parameters.c 173 | 174 | 175 | end 176 | \) 177 | endCaptures 178 | 179 | 0 180 | 181 | name 182 | punctuation.definition.parameters.c 183 | 184 | 185 | name 186 | meta.function.destructor.prototype.c++ 187 | patterns 188 | 189 | 190 | include 191 | $base 192 | 193 | 194 | 195 | 196 | repository 197 | 198 | angle_brackets 199 | 200 | begin 201 | < 202 | end 203 | > 204 | name 205 | meta.angle-brackets.c++ 206 | patterns 207 | 208 | 209 | include 210 | #angle_brackets 211 | 212 | 213 | include 214 | $base 215 | 216 | 217 | 218 | block 219 | 220 | begin 221 | \{ 222 | end 223 | \} 224 | name 225 | meta.block.c++ 226 | patterns 227 | 228 | 229 | captures 230 | 231 | 1 232 | 233 | name 234 | support.function.any-method.c 235 | 236 | 2 237 | 238 | name 239 | punctuation.definition.parameters.c 240 | 241 | 242 | match 243 | (?x) 244 | ( 245 | (?!while|for|do|if|else|switch|catch|enumerate|return|r?iterate)(?: \b[A-Za-z_][A-Za-z0-9_]*+\b | :: )*+ # actual name 246 | ) 247 | \s*(\() 248 | name 249 | meta.function-call.c 250 | 251 | 252 | include 253 | $base 254 | 255 | 256 | 257 | constructor 258 | 259 | patterns 260 | 261 | 262 | begin 263 | (?x) 264 | (?: ^\s*) # begin-of-line 265 | ((?!while|for|do|if|else|switch|catch|enumerate|r?iterate)[A-Za-z_][A-Za-z0-9_:]*) # actual name 266 | \s*(\() # start bracket or end-of-line 267 | 268 | beginCaptures 269 | 270 | 1 271 | 272 | name 273 | entity.name.function.c++ 274 | 275 | 2 276 | 277 | name 278 | punctuation.definition.parameters.c 279 | 280 | 281 | end 282 | \) 283 | endCaptures 284 | 285 | 0 286 | 287 | name 288 | punctuation.definition.parameters.c 289 | 290 | 291 | name 292 | meta.function.constructor.c++ 293 | patterns 294 | 295 | 296 | include 297 | $base 298 | 299 | 300 | 301 | 302 | begin 303 | (?x) 304 | (:) # begin-of-line 305 | ((?=\s*[A-Za-z_][A-Za-z0-9_:]* # actual name 306 | \s*(\())) # start bracket or end-of-line 307 | 308 | beginCaptures 309 | 310 | 1 311 | 312 | name 313 | punctuation.definition.parameters.c 314 | 315 | 316 | end 317 | (?=\{) 318 | name 319 | meta.function.constructor.initializer-list.c++ 320 | patterns 321 | 322 | 323 | include 324 | $base 325 | 326 | 327 | 328 | 329 | 330 | special_block 331 | 332 | patterns 333 | 334 | 335 | begin 336 | \b(namespace)\b\s*([_A-Za-z][_A-Za-z0-9]*\b)?+ 337 | beginCaptures 338 | 339 | 1 340 | 341 | name 342 | storage.type.c++ 343 | 344 | 2 345 | 346 | name 347 | entity.name.type.c++ 348 | 349 | 350 | end 351 | (?<=\})|(?=(;|,|\(|\)|>|\[|\]|=)) 352 | name 353 | meta.namespace-block.c++ 354 | patterns 355 | 356 | 357 | begin 358 | (\{) 359 | beginCaptures 360 | 361 | 1 362 | 363 | name 364 | punctuation.definition.scope.c++ 365 | 366 | 367 | end 368 | (\}) 369 | endCaptures 370 | 371 | 1 372 | 373 | name 374 | punctuation.definition.scope.c++ 375 | 376 | 377 | patterns 378 | 379 | 380 | include 381 | #special_block 382 | 383 | 384 | include 385 | #constructor 386 | 387 | 388 | include 389 | $base 390 | 391 | 392 | 393 | 394 | include 395 | $base 396 | 397 | 398 | 399 | 400 | begin 401 | \b(class|struct)\b\s*([_A-Za-z][_A-Za-z0-9]*\b)?+ 402 | beginCaptures 403 | 404 | 1 405 | 406 | name 407 | storage.type.c++ 408 | 409 | 2 410 | 411 | name 412 | entity.name.type.c++ 413 | 414 | 415 | end 416 | (?<=\})|(?=(;|\(|\)|>|\[|\]|=)) 417 | name 418 | meta.class-struct-block.c++ 419 | patterns 420 | 421 | 422 | include 423 | #angle_brackets 424 | 425 | 426 | begin 427 | (\{) 428 | beginCaptures 429 | 430 | 1 431 | 432 | name 433 | punctuation.definition.scope.c++ 434 | 435 | 436 | end 437 | (\})(\s*\n)? 438 | endCaptures 439 | 440 | 1 441 | 442 | name 443 | punctuation.definition.invalid.c++ 444 | 445 | 2 446 | 447 | name 448 | invalid.illegal.you-forgot-semicolon.c++ 449 | 450 | 451 | patterns 452 | 453 | 454 | include 455 | #special_block 456 | 457 | 458 | include 459 | #constructor 460 | 461 | 462 | include 463 | $base 464 | 465 | 466 | 467 | 468 | include 469 | $base 470 | 471 | 472 | 473 | 474 | begin 475 | \b(extern)(?=\s*") 476 | beginCaptures 477 | 478 | 1 479 | 480 | name 481 | storage.modifier.c++ 482 | 483 | 484 | end 485 | (?<=\})|(?=\w) 486 | name 487 | meta.extern-block.c++ 488 | patterns 489 | 490 | 491 | begin 492 | \{ 493 | end 494 | \} 495 | patterns 496 | 497 | 498 | include 499 | #special_block 500 | 501 | 502 | include 503 | $base 504 | 505 | 506 | 507 | 508 | include 509 | $base 510 | 511 | 512 | 513 | 514 | 515 | 516 | scopeName 517 | source.c++ 518 | uuid 519 | 26251B18-6B1D-11D9-AFDB-000D93589AF6 520 | 521 | 522 | -------------------------------------------------------------------------------- /examples/subl2tm/Sublime Text/C.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | fileTypes 6 | 7 | c 8 | h 9 | 10 | firstLineMatch 11 | -[*]-( Mode:)? C -[*]- 12 | foldingStartMarker 13 | (?x) 14 | /\*\*(?!\*) 15 | |^(?![^{]*?//|[^{]*?/\*(?!.*?\*/.*?\{)).*?\{\s*($|//|/\*(?!.*?\*/.*\S)) 16 | 17 | foldingStopMarker 18 | (?<!\*)\*\*/|^\s*\} 19 | keyEquivalent 20 | ^~C 21 | name 22 | C 23 | patterns 24 | 25 | 26 | include 27 | #preprocessor-rule-enabled 28 | 29 | 30 | include 31 | #preprocessor-rule-disabled 32 | 33 | 34 | include 35 | #preprocessor-rule-other 36 | 37 | 38 | include 39 | #comments 40 | 41 | 42 | match 43 | \b(break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while)\b 44 | name 45 | keyword.control.c 46 | 47 | 48 | match 49 | \b(asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void)\b 50 | name 51 | storage.type.c 52 | 53 | 54 | match 55 | \b(const|extern|register|restrict|static|volatile|inline)\b 56 | name 57 | storage.modifier.c 58 | 59 | 60 | comment 61 | common C constant naming idiom -- kConstantVariable 62 | match 63 | \bk[A-Z]\w*\b 64 | name 65 | constant.other.variable.mac-classic.c 66 | 67 | 68 | match 69 | \bg[A-Z]\w*\b 70 | name 71 | variable.other.readwrite.global.mac-classic.c 72 | 73 | 74 | match 75 | \bs[A-Z]\w*\b 76 | name 77 | variable.other.readwrite.static.mac-classic.c 78 | 79 | 80 | match 81 | \b(NULL|true|false|TRUE|FALSE)\b 82 | name 83 | constant.language.c 84 | 85 | 86 | include 87 | #sizeof 88 | 89 | 90 | match 91 | \b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b 92 | name 93 | constant.numeric.c 94 | 95 | 96 | begin 97 | " 98 | beginCaptures 99 | 100 | 0 101 | 102 | name 103 | punctuation.definition.string.begin.c 104 | 105 | 106 | end 107 | " 108 | endCaptures 109 | 110 | 0 111 | 112 | name 113 | punctuation.definition.string.end.c 114 | 115 | 116 | name 117 | string.quoted.double.c 118 | patterns 119 | 120 | 121 | include 122 | #string_escaped_char 123 | 124 | 125 | include 126 | #string_placeholder 127 | 128 | 129 | 130 | 131 | begin 132 | ' 133 | beginCaptures 134 | 135 | 0 136 | 137 | name 138 | punctuation.definition.string.begin.c 139 | 140 | 141 | end 142 | ' 143 | endCaptures 144 | 145 | 0 146 | 147 | name 148 | punctuation.definition.string.end.c 149 | 150 | 151 | name 152 | string.quoted.single.c 153 | patterns 154 | 155 | 156 | include 157 | #string_escaped_char 158 | 159 | 160 | 161 | 162 | begin 163 | (?x) 164 | ^\s*\#\s*(define)\s+ # define 165 | ((?<id>[a-zA-Z_][a-zA-Z0-9_]*)) # macro name 166 | (?: # and optionally: 167 | (\() # an open parenthesis 168 | ( 169 | \s* \g<id> \s* # first argument 170 | ((,) \s* \g<id> \s*)* # additional arguments 171 | (?:\.\.\.)? # varargs ellipsis? 172 | ) 173 | (\)) # a close parenthesis 174 | )? 175 | 176 | beginCaptures 177 | 178 | 1 179 | 180 | name 181 | keyword.control.import.define.c 182 | 183 | 2 184 | 185 | name 186 | entity.name.function.preprocessor.c 187 | 188 | 4 189 | 190 | name 191 | punctuation.definition.parameters.c 192 | 193 | 5 194 | 195 | name 196 | variable.parameter.preprocessor.c 197 | 198 | 7 199 | 200 | name 201 | punctuation.separator.parameters.c 202 | 203 | 8 204 | 205 | name 206 | punctuation.definition.parameters.c 207 | 208 | 209 | end 210 | (?=(?://|/\*))|$ 211 | name 212 | meta.preprocessor.macro.c 213 | patterns 214 | 215 | 216 | match 217 | (?>\\\s*\n) 218 | name 219 | punctuation.separator.continuation.c 220 | 221 | 222 | include 223 | $base 224 | 225 | 226 | 227 | 228 | begin 229 | ^\s*#\s*(error|warning)\b 230 | captures 231 | 232 | 1 233 | 234 | name 235 | keyword.control.import.error.c 236 | 237 | 238 | end 239 | $ 240 | name 241 | meta.preprocessor.diagnostic.c 242 | patterns 243 | 244 | 245 | match 246 | (?>\\\s*\n) 247 | name 248 | punctuation.separator.continuation.c 249 | 250 | 251 | 252 | 253 | begin 254 | ^\s*#\s*(include|import)\b\s+ 255 | captures 256 | 257 | 1 258 | 259 | name 260 | keyword.control.import.include.c 261 | 262 | 263 | end 264 | (?=(?://|/\*))|$ 265 | name 266 | meta.preprocessor.c.include 267 | patterns 268 | 269 | 270 | match 271 | (?>\\\s*\n) 272 | name 273 | punctuation.separator.continuation.c 274 | 275 | 276 | begin 277 | " 278 | beginCaptures 279 | 280 | 0 281 | 282 | name 283 | punctuation.definition.string.begin.c 284 | 285 | 286 | end 287 | " 288 | endCaptures 289 | 290 | 0 291 | 292 | name 293 | punctuation.definition.string.end.c 294 | 295 | 296 | name 297 | string.quoted.double.include.c 298 | 299 | 300 | begin 301 | < 302 | beginCaptures 303 | 304 | 0 305 | 306 | name 307 | punctuation.definition.string.begin.c 308 | 309 | 310 | end 311 | > 312 | endCaptures 313 | 314 | 0 315 | 316 | name 317 | punctuation.definition.string.end.c 318 | 319 | 320 | name 321 | string.quoted.other.lt-gt.include.c 322 | 323 | 324 | 325 | 326 | include 327 | #pragma-mark 328 | 329 | 330 | begin 331 | ^\s*#\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef)\b 332 | captures 333 | 334 | 1 335 | 336 | name 337 | keyword.control.import.c 338 | 339 | 340 | end 341 | (?=(?://|/\*))|$ 342 | name 343 | meta.preprocessor.c 344 | patterns 345 | 346 | 347 | match 348 | (?>\\\s*\n) 349 | name 350 | punctuation.separator.continuation.c 351 | 352 | 353 | 354 | 355 | match 356 | \b(u_char|u_short|u_int|u_long|ushort|uint|u_quad_t|quad_t|qaddr_t|caddr_t|daddr_t|dev_t|fixpt_t|blkcnt_t|blksize_t|gid_t|in_addr_t|in_port_t|ino_t|key_t|mode_t|nlink_t|id_t|pid_t|off_t|segsz_t|swblk_t|uid_t|id_t|clock_t|size_t|ssize_t|time_t|useconds_t|suseconds_t)\b 357 | name 358 | support.type.sys-types.c 359 | 360 | 361 | match 362 | \b(pthread_attr_t|pthread_cond_t|pthread_condattr_t|pthread_mutex_t|pthread_mutexattr_t|pthread_once_t|pthread_rwlock_t|pthread_rwlockattr_t|pthread_t|pthread_key_t)\b 363 | name 364 | support.type.pthread.c 365 | 366 | 367 | match 368 | \b(int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|int_least8_t|int_least16_t|int_least32_t|int_least64_t|uint_least8_t|uint_least16_t|uint_least32_t|uint_least64_t|int_fast8_t|int_fast16_t|int_fast32_t|int_fast64_t|uint_fast8_t|uint_fast16_t|uint_fast32_t|uint_fast64_t|intptr_t|uintptr_t|intmax_t|intmax_t|uintmax_t|uintmax_t)\b 369 | name 370 | support.type.stdint.c 371 | 372 | 373 | match 374 | \b(noErr|kNilOptions|kInvalidID|kVariableLengthArray)\b 375 | name 376 | support.constant.mac-classic.c 377 | 378 | 379 | match 380 | \b(AbsoluteTime|Boolean|Byte|ByteCount|ByteOffset|BytePtr|CompTimeValue|ConstLogicalAddress|ConstStrFileNameParam|ConstStringPtr|Duration|Fixed|FixedPtr|Float32|Float32Point|Float64|Float80|Float96|FourCharCode|Fract|FractPtr|Handle|ItemCount|LogicalAddress|OptionBits|OSErr|OSStatus|OSType|OSTypePtr|PhysicalAddress|ProcessSerialNumber|ProcessSerialNumberPtr|ProcHandle|Ptr|ResType|ResTypePtr|ShortFixed|ShortFixedPtr|SignedByte|SInt16|SInt32|SInt64|SInt8|Size|StrFileName|StringHandle|StringPtr|TimeBase|TimeRecord|TimeScale|TimeValue|TimeValue64|UInt16|UInt32|UInt64|UInt8|UniChar|UniCharCount|UniCharCountPtr|UniCharPtr|UnicodeScalarValue|UniversalProcHandle|UniversalProcPtr|UnsignedFixed|UnsignedFixedPtr|UnsignedWide|UTF16Char|UTF32Char|UTF8Char)\b 381 | name 382 | support.type.mac-classic.c 383 | 384 | 385 | include 386 | #block 387 | 388 | 389 | begin 390 | (?x) 391 | (?: ^ # begin-of-line 392 | | 393 | (?: (?= \s ) (?<!else|new|return) (?<=\w) # or word + space before name 394 | | (?= \s*[A-Za-z_] ) (?<!&&) (?<=[*&>]) # or type modifier before name 395 | ) 396 | ) 397 | (\s*) (?!(while|for|do|if|else|switch|catch|enumerate|return|r?iterate)\s*\() 398 | ( 399 | (?: [A-Za-z_][A-Za-z0-9_]*+ | :: )++ | # actual name 400 | (?: (?<=operator) (?: [-*&<>=+!]+ | \(\) | \[\] ) ) # if it is a C++ operator 401 | ) 402 | \s*(?=\() 403 | beginCaptures 404 | 405 | 1 406 | 407 | name 408 | punctuation.whitespace.function.leading.c 409 | 410 | 3 411 | 412 | name 413 | entity.name.function.c 414 | 415 | 4 416 | 417 | name 418 | punctuation.definition.parameters.c 419 | 420 | 421 | end 422 | (?<=\})|(?=#)|(;) 423 | name 424 | meta.function.c 425 | patterns 426 | 427 | 428 | include 429 | #comments 430 | 431 | 432 | include 433 | #parens 434 | 435 | 436 | match 437 | \bconst\b 438 | name 439 | storage.modifier.c 440 | 441 | 442 | include 443 | #block 444 | 445 | 446 | 447 | 448 | repository 449 | 450 | access 451 | 452 | match 453 | \.[a-zA-Z_][a-zA-Z_0-9]*\b(?!\s*\() 454 | name 455 | variable.other.dot-access.c 456 | 457 | block 458 | 459 | begin 460 | \{ 461 | end 462 | \} 463 | name 464 | meta.block.c 465 | patterns 466 | 467 | 468 | include 469 | #block_innards 470 | 471 | 472 | 473 | block_innards 474 | 475 | patterns 476 | 477 | 478 | include 479 | #preprocessor-rule-enabled-block 480 | 481 | 482 | include 483 | #preprocessor-rule-disabled-block 484 | 485 | 486 | include 487 | #preprocessor-rule-other-block 488 | 489 | 490 | include 491 | #sizeof 492 | 493 | 494 | include 495 | #access 496 | 497 | 498 | captures 499 | 500 | 1 501 | 502 | name 503 | punctuation.whitespace.support.function.leading.c 504 | 505 | 2 506 | 507 | name 508 | support.function.C99.c 509 | 510 | 511 | match 512 | (\s*)\b(hypot(f|l)?|s(scanf|ystem|nprintf|ca(nf|lb(n(f|l)?|ln(f|l)?))|i(n(h(f|l)?|f|l)?|gn(al|bit))|tr(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(jmp|vbuf|locale|buf)|qrt(f|l)?|w(scanf|printf)|rand)|n(e(arbyint(f|l)?|xt(toward(f|l)?|after(f|l)?))|an(f|l)?)|c(s(in(h(f|l)?|f|l)?|qrt(f|l)?)|cos(h(f)?|f|l)?|imag(f|l)?|t(ime|an(h(f|l)?|f|l)?)|o(s(h(f|l)?|f|l)?|nj(f|l)?|pysign(f|l)?)|p(ow(f|l)?|roj(f|l)?)|e(il(f|l)?|xp(f|l)?)|l(o(ck|g(f|l)?)|earerr)|a(sin(h(f|l)?|f|l)?|cos(h(f|l)?|f|l)?|tan(h(f|l)?|f|l)?|lloc|rg(f|l)?|bs(f|l)?)|real(f|l)?|brt(f|l)?)|t(ime|o(upper|lower)|an(h(f|l)?|f|l)?|runc(f|l)?|gamma(f|l)?|mp(nam|file))|i(s(space|n(ormal|an)|cntrl|inf|digit|u(nordered|pper)|p(unct|rint)|finite|w(space|c(ntrl|type)|digit|upper|p(unct|rint)|lower|al(num|pha)|graph|xdigit|blank)|l(ower|ess(equal|greater)?)|al(num|pha)|gr(eater(equal)?|aph)|xdigit|blank)|logb(f|l)?|max(div|abs))|di(v|fftime)|_Exit|unget(c|wc)|p(ow(f|l)?|ut(s|c(har)?|wc(har)?)|error|rintf)|e(rf(c(f|l)?|f|l)?|x(it|p(2(f|l)?|f|l|m1(f|l)?)?))|v(s(scanf|nprintf|canf|printf|w(scanf|printf))|printf|f(scanf|printf|w(scanf|printf))|w(scanf|printf)|a_(start|copy|end|arg))|qsort|f(s(canf|e(tpos|ek))|close|tell|open|dim(f|l)?|p(classify|ut(s|c|w(s|c))|rintf)|e(holdexcept|set(e(nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(aiseexcept|ror)|get(e(nv|xceptflag)|round))|flush|w(scanf|ide|printf|rite)|loor(f|l)?|abs(f|l)?|get(s|c|pos|w(s|c))|re(open|e|ad|xp(f|l)?)|m(in(f|l)?|od(f|l)?|a(f|l|x(f|l)?)?))|l(d(iv|exp(f|l)?)|o(ngjmp|cal(time|econv)|g(1(p(f|l)?|0(f|l)?)|2(f|l)?|f|l|b(f|l)?)?)|abs|l(div|abs|r(int(f|l)?|ound(f|l)?))|r(int(f|l)?|ound(f|l)?)|gamma(f|l)?)|w(scanf|c(s(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?|mbs)|pbrk|ftime|len|r(chr|tombs)|xfrm)|to(b|mb)|rtomb)|printf|mem(set|c(hr|py|mp)|move))|a(s(sert|ctime|in(h(f|l)?|f|l)?)|cos(h(f|l)?|f|l)?|t(o(i|f|l(l)?)|exit|an(h(f|l)?|2(f|l)?|f|l)?)|b(s|ort))|g(et(s|c(har)?|env|wc(har)?)|mtime)|r(int(f|l)?|ound(f|l)?|e(name|alloc|wind|m(ove|quo(f|l)?|ainder(f|l)?))|a(nd|ise))|b(search|towc)|m(odf(f|l)?|em(set|c(hr|py|mp)|move)|ktime|alloc|b(s(init|towcs|rtowcs)|towc|len|r(towc|len))))\b 513 | 514 | 515 | captures 516 | 517 | 1 518 | 519 | name 520 | punctuation.whitespace.function-call.leading.c 521 | 522 | 2 523 | 524 | name 525 | support.function.any-method.c 526 | 527 | 3 528 | 529 | name 530 | punctuation.definition.parameters.c 531 | 532 | 533 | match 534 | (?x) (?: (?= \s ) (?:(?<=else|new|return) | (?<!\w)) (\s+))? 535 | (\b 536 | (?!(while|for|do|if|else|switch|catch|enumerate|return|r?iterate)\s*\()(?:(?!NS)[A-Za-z_][A-Za-z0-9_]*+\b | :: )++ # actual name 537 | ) 538 | \s*(\() 539 | name 540 | meta.function-call.c 541 | 542 | 543 | captures 544 | 545 | 1 546 | 547 | name 548 | variable.other.c 549 | 550 | 2 551 | 552 | name 553 | punctuation.definition.parameters.c 554 | 555 | 556 | match 557 | (?x) 558 | (?x) 559 | (?: 560 | (?: (?= \s ) (?<!else|new|return) (?<=\w)\s+ # or word + space before name 561 | ) 562 | ) 563 | ( 564 | (?: [A-Za-z_][A-Za-z0-9_]*+ | :: )++ | # actual name 565 | (?: (?<=operator) (?: [-*&<>=+!]+ | \(\) | \[\] ) )? # if it is a C++ operator 566 | ) 567 | \s*(\() 568 | name 569 | meta.initialization.c 570 | 571 | 572 | include 573 | #block 574 | 575 | 576 | include 577 | $base 578 | 579 | 580 | 581 | comments 582 | 583 | patterns 584 | 585 | 586 | captures 587 | 588 | 1 589 | 590 | name 591 | meta.toc-list.banner.block.c 592 | 593 | 594 | match 595 | ^/\* =(\s*.*?)\s*= \*/$\n? 596 | name 597 | comment.block.c 598 | 599 | 600 | begin 601 | /\* 602 | captures 603 | 604 | 0 605 | 606 | name 607 | punctuation.definition.comment.c 608 | 609 | 610 | end 611 | \*/ 612 | name 613 | comment.block.c 614 | 615 | 616 | match 617 | \*/.*\n 618 | name 619 | invalid.illegal.stray-comment-end.c 620 | 621 | 622 | captures 623 | 624 | 1 625 | 626 | name 627 | meta.toc-list.banner.line.c 628 | 629 | 630 | match 631 | ^// =(\s*.*?)\s*=\s*$\n? 632 | name 633 | comment.line.banner.c++ 634 | 635 | 636 | begin 637 | // 638 | beginCaptures 639 | 640 | 0 641 | 642 | name 643 | punctuation.definition.comment.c 644 | 645 | 646 | end 647 | $\n? 648 | name 649 | comment.line.double-slash.c++ 650 | patterns 651 | 652 | 653 | match 654 | (?>\\\s*\n) 655 | name 656 | punctuation.separator.continuation.c++ 657 | 658 | 659 | 660 | 661 | 662 | disabled 663 | 664 | begin 665 | ^\s*#\s*if(n?def)?\b.*$ 666 | comment 667 | eat nested preprocessor if(def)s 668 | end 669 | ^\s*#\s*endif\b.*$ 670 | patterns 671 | 672 | 673 | include 674 | #disabled 675 | 676 | 677 | include 678 | #pragma-mark 679 | 680 | 681 | 682 | parens 683 | 684 | begin 685 | \( 686 | end 687 | \) 688 | name 689 | meta.parens.c 690 | patterns 691 | 692 | 693 | include 694 | $base 695 | 696 | 697 | 698 | pragma-mark 699 | 700 | captures 701 | 702 | 1 703 | 704 | name 705 | meta.preprocessor.c 706 | 707 | 2 708 | 709 | name 710 | keyword.control.import.pragma.c 711 | 712 | 3 713 | 714 | name 715 | meta.toc-list.pragma-mark.c 716 | 717 | 718 | match 719 | ^\s*(#\s*(pragma\s+mark)\s+(.*)) 720 | name 721 | meta.section 722 | 723 | preprocessor-rule-disabled 724 | 725 | begin 726 | ^\s*(#(if)\s+(0)\b).* 727 | captures 728 | 729 | 1 730 | 731 | name 732 | meta.preprocessor.c 733 | 734 | 2 735 | 736 | name 737 | keyword.control.import.if.c 738 | 739 | 3 740 | 741 | name 742 | constant.numeric.preprocessor.c 743 | 744 | 745 | end 746 | ^\s*(#\s*(endif)\b) 747 | patterns 748 | 749 | 750 | begin 751 | ^\s*(#\s*(else)\b) 752 | captures 753 | 754 | 1 755 | 756 | name 757 | meta.preprocessor.c 758 | 759 | 2 760 | 761 | name 762 | keyword.control.import.else.c 763 | 764 | 765 | end 766 | (?=^\s*#\s*endif\b.*$) 767 | patterns 768 | 769 | 770 | include 771 | $base 772 | 773 | 774 | 775 | 776 | begin 777 | 778 | end 779 | (?=^\s*#\s*(else|endif)\b.*$) 780 | name 781 | comment.block.preprocessor.if-branch 782 | patterns 783 | 784 | 785 | include 786 | #disabled 787 | 788 | 789 | include 790 | #pragma-mark 791 | 792 | 793 | 794 | 795 | 796 | preprocessor-rule-disabled-block 797 | 798 | begin 799 | ^\s*(#(if)\s+(0)\b).* 800 | captures 801 | 802 | 1 803 | 804 | name 805 | meta.preprocessor.c 806 | 807 | 2 808 | 809 | name 810 | keyword.control.import.if.c 811 | 812 | 3 813 | 814 | name 815 | constant.numeric.preprocessor.c 816 | 817 | 818 | end 819 | ^\s*(#\s*(endif)\b) 820 | patterns 821 | 822 | 823 | begin 824 | ^\s*(#\s*(else)\b) 825 | captures 826 | 827 | 1 828 | 829 | name 830 | meta.preprocessor.c 831 | 832 | 2 833 | 834 | name 835 | keyword.control.import.else.c 836 | 837 | 838 | end 839 | (?=^\s*#\s*endif\b.*$) 840 | patterns 841 | 842 | 843 | include 844 | #block_innards 845 | 846 | 847 | 848 | 849 | begin 850 | 851 | end 852 | (?=^\s*#\s*(else|endif)\b.*$) 853 | name 854 | comment.block.preprocessor.if-branch.in-block 855 | patterns 856 | 857 | 858 | include 859 | #disabled 860 | 861 | 862 | include 863 | #pragma-mark 864 | 865 | 866 | 867 | 868 | 869 | preprocessor-rule-enabled 870 | 871 | begin 872 | ^\s*(#(if)\s+(0*1)\b) 873 | captures 874 | 875 | 1 876 | 877 | name 878 | meta.preprocessor.c 879 | 880 | 2 881 | 882 | name 883 | keyword.control.import.if.c 884 | 885 | 3 886 | 887 | name 888 | constant.numeric.preprocessor.c 889 | 890 | 891 | end 892 | ^\s*(#\s*(endif)\b) 893 | patterns 894 | 895 | 896 | begin 897 | ^\s*(#\s*(else)\b).* 898 | captures 899 | 900 | 1 901 | 902 | name 903 | meta.preprocessor.c 904 | 905 | 2 906 | 907 | name 908 | keyword.control.import.else.c 909 | 910 | 911 | contentName 912 | comment.block.preprocessor.else-branch 913 | end 914 | (?=^\s*#\s*endif\b.*$) 915 | patterns 916 | 917 | 918 | include 919 | #disabled 920 | 921 | 922 | include 923 | #pragma-mark 924 | 925 | 926 | 927 | 928 | begin 929 | 930 | end 931 | (?=^\s*#\s*(else|endif)\b.*$) 932 | patterns 933 | 934 | 935 | include 936 | $base 937 | 938 | 939 | 940 | 941 | 942 | preprocessor-rule-enabled-block 943 | 944 | begin 945 | ^\s*(#(if)\s+(0*1)\b) 946 | captures 947 | 948 | 1 949 | 950 | name 951 | meta.preprocessor.c 952 | 953 | 2 954 | 955 | name 956 | keyword.control.import.if.c 957 | 958 | 3 959 | 960 | name 961 | constant.numeric.preprocessor.c 962 | 963 | 964 | end 965 | ^\s*(#\s*(endif)\b) 966 | patterns 967 | 968 | 969 | begin 970 | ^\s*(#\s*(else)\b).* 971 | captures 972 | 973 | 1 974 | 975 | name 976 | meta.preprocessor.c 977 | 978 | 2 979 | 980 | name 981 | keyword.control.import.else.c 982 | 983 | 984 | contentName 985 | comment.block.preprocessor.else-branch.in-block 986 | end 987 | (?=^\s*#\s*endif\b.*$) 988 | patterns 989 | 990 | 991 | include 992 | #disabled 993 | 994 | 995 | include 996 | #pragma-mark 997 | 998 | 999 | 1000 | 1001 | begin 1002 | 1003 | end 1004 | (?=^\s*#\s*(else|endif)\b.*$) 1005 | patterns 1006 | 1007 | 1008 | include 1009 | #block_innards 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | preprocessor-rule-other 1016 | 1017 | begin 1018 | ^\s*(#\s*(if(n?def)?)\b.*?(?:(?=(?://|/\*))|$)) 1019 | captures 1020 | 1021 | 1 1022 | 1023 | name 1024 | meta.preprocessor.c 1025 | 1026 | 2 1027 | 1028 | name 1029 | keyword.control.import.c 1030 | 1031 | 1032 | end 1033 | ^\s*(#\s*(endif)\b).*$ 1034 | patterns 1035 | 1036 | 1037 | include 1038 | $base 1039 | 1040 | 1041 | 1042 | preprocessor-rule-other-block 1043 | 1044 | begin 1045 | ^\s*(#\s*(if(n?def)?)\b.*?(?:(?=(?://|/\*))|$)) 1046 | captures 1047 | 1048 | 1 1049 | 1050 | name 1051 | meta.preprocessor.c 1052 | 1053 | 2 1054 | 1055 | name 1056 | keyword.control.import.c 1057 | 1058 | 1059 | end 1060 | ^\s*(#\s*(endif)\b).*$ 1061 | patterns 1062 | 1063 | 1064 | include 1065 | #block_innards 1066 | 1067 | 1068 | 1069 | sizeof 1070 | 1071 | match 1072 | \b(sizeof)\b 1073 | name 1074 | keyword.operator.sizeof.c 1075 | 1076 | string_escaped_char 1077 | 1078 | patterns 1079 | 1080 | 1081 | match 1082 | \\(\\|[abefnprtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-fA-F0-9]{,2}|u[a-fA-F0-9]{,4}|U[a-fA-F0-9]{,8}) 1083 | name 1084 | constant.character.escape.c 1085 | 1086 | 1087 | match 1088 | \\. 1089 | name 1090 | invalid.illegal.unknown-escape.c 1091 | 1092 | 1093 | 1094 | string_placeholder 1095 | 1096 | patterns 1097 | 1098 | 1099 | match 1100 | (?x)% 1101 | (\d+\$)? # field (argument #) 1102 | [#0\- +']* # flags 1103 | [,;:_]? # separator character (AltiVec) 1104 | ((-?\d+)|\*(-?\d+\$)?)? # minimum field width 1105 | (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision 1106 | (hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier 1107 | [diouxXDOUeEfFgGaACcSspn%] # conversion type 1108 | 1109 | name 1110 | constant.other.placeholder.c 1111 | 1112 | 1113 | match 1114 | % 1115 | name 1116 | invalid.illegal.placeholder.c 1117 | 1118 | 1119 | 1120 | 1121 | scopeName 1122 | source.c 1123 | uuid 1124 | 25066DC2-6B1D-11D9-9D5B-000D93589AF6 1125 | 1126 | 1127 | -------------------------------------------------------------------------------- /examples/tm2subl/TextMate/Syntaxes/C.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | fileTypes 6 | 7 | c 8 | h 9 | 10 | firstLineMatch 11 | -[*]-( Mode:)? C -[*]- 12 | foldingStartMarker 13 | (?x) 14 | /\*\*(?!\*) 15 | |^(?![^{]*?//|[^{]*?/\*(?!.*?\*/.*?\{)).*?\{\s*($|//|/\*(?!.*?\*/.*\S)) 16 | 17 | foldingStopMarker 18 | (?<!\*)\*\*/|^\s*\} 19 | keyEquivalent 20 | ^~C 21 | name 22 | C 23 | patterns 24 | 25 | 26 | include 27 | #preprocessor-rule-enabled 28 | 29 | 30 | include 31 | #preprocessor-rule-disabled 32 | 33 | 34 | include 35 | #preprocessor-rule-other 36 | 37 | 38 | include 39 | #comments 40 | 41 | 42 | match 43 | \b(break|case|continue|default|do|else|for|goto|if|_Pragma|return|switch|while)\b 44 | name 45 | keyword.control.c 46 | 47 | 48 | match 49 | \b(asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void)\b 50 | name 51 | storage.type.c 52 | 53 | 54 | match 55 | \b(const|extern|register|restrict|static|volatile|inline)\b 56 | name 57 | storage.modifier.c 58 | 59 | 60 | comment 61 | common C constant naming idiom -- kConstantVariable 62 | match 63 | \bk[A-Z]\w*\b 64 | name 65 | constant.other.variable.mac-classic.c 66 | 67 | 68 | match 69 | \bg[A-Z]\w*\b 70 | name 71 | variable.other.readwrite.global.mac-classic.c 72 | 73 | 74 | match 75 | \bs[A-Z]\w*\b 76 | name 77 | variable.other.readwrite.static.mac-classic.c 78 | 79 | 80 | match 81 | \b(NULL|true|false|TRUE|FALSE)\b 82 | name 83 | constant.language.c 84 | 85 | 86 | include 87 | #sizeof 88 | 89 | 90 | match 91 | \b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b 92 | name 93 | constant.numeric.c 94 | 95 | 96 | begin 97 | " 98 | beginCaptures 99 | 100 | 0 101 | 102 | name 103 | punctuation.definition.string.begin.c 104 | 105 | 106 | end 107 | " 108 | endCaptures 109 | 110 | 0 111 | 112 | name 113 | punctuation.definition.string.end.c 114 | 115 | 116 | name 117 | string.quoted.double.c 118 | patterns 119 | 120 | 121 | include 122 | #string_escaped_char 123 | 124 | 125 | include 126 | #string_placeholder 127 | 128 | 129 | 130 | 131 | begin 132 | ' 133 | beginCaptures 134 | 135 | 0 136 | 137 | name 138 | punctuation.definition.string.begin.c 139 | 140 | 141 | end 142 | ' 143 | endCaptures 144 | 145 | 0 146 | 147 | name 148 | punctuation.definition.string.end.c 149 | 150 | 151 | name 152 | string.quoted.single.c 153 | patterns 154 | 155 | 156 | include 157 | #string_escaped_char 158 | 159 | 160 | 161 | 162 | begin 163 | (?x) 164 | ^\s*\#\s*(define)\s+ # define 165 | ((?<id>[a-zA-Z_][a-zA-Z0-9_]*)) # macro name 166 | (?: # and optionally: 167 | (\() # an open parenthesis 168 | ( 169 | \s* \g<id> \s* # first argument 170 | ((,) \s* \g<id> \s*)* # additional arguments 171 | (?:\.\.\.)? # varargs ellipsis? 172 | ) 173 | (\)) # a close parenthesis 174 | )? 175 | 176 | beginCaptures 177 | 178 | 1 179 | 180 | name 181 | keyword.control.import.define.c 182 | 183 | 2 184 | 185 | name 186 | entity.name.function.preprocessor.c 187 | 188 | 4 189 | 190 | name 191 | punctuation.definition.parameters.c 192 | 193 | 5 194 | 195 | name 196 | variable.parameter.preprocessor.c 197 | 198 | 7 199 | 200 | name 201 | punctuation.separator.parameters.c 202 | 203 | 8 204 | 205 | name 206 | punctuation.definition.parameters.c 207 | 208 | 209 | end 210 | (?=(?://|/\*))|$ 211 | name 212 | meta.preprocessor.macro.c 213 | patterns 214 | 215 | 216 | match 217 | (?>\\\s*\n) 218 | name 219 | punctuation.separator.continuation.c 220 | 221 | 222 | include 223 | $base 224 | 225 | 226 | 227 | 228 | begin 229 | ^\s*#\s*(error|warning)\b 230 | captures 231 | 232 | 1 233 | 234 | name 235 | keyword.control.import.error.c 236 | 237 | 238 | end 239 | $ 240 | name 241 | meta.preprocessor.diagnostic.c 242 | patterns 243 | 244 | 245 | match 246 | (?>\\\s*\n) 247 | name 248 | punctuation.separator.continuation.c 249 | 250 | 251 | 252 | 253 | begin 254 | ^\s*#\s*(include|import)\b\s+ 255 | captures 256 | 257 | 1 258 | 259 | name 260 | keyword.control.import.include.c 261 | 262 | 263 | end 264 | (?=(?://|/\*))|$ 265 | name 266 | meta.preprocessor.c.include 267 | patterns 268 | 269 | 270 | match 271 | (?>\\\s*\n) 272 | name 273 | punctuation.separator.continuation.c 274 | 275 | 276 | begin 277 | " 278 | beginCaptures 279 | 280 | 0 281 | 282 | name 283 | punctuation.definition.string.begin.c 284 | 285 | 286 | end 287 | " 288 | endCaptures 289 | 290 | 0 291 | 292 | name 293 | punctuation.definition.string.end.c 294 | 295 | 296 | name 297 | string.quoted.double.include.c 298 | 299 | 300 | begin 301 | < 302 | beginCaptures 303 | 304 | 0 305 | 306 | name 307 | punctuation.definition.string.begin.c 308 | 309 | 310 | end 311 | > 312 | endCaptures 313 | 314 | 0 315 | 316 | name 317 | punctuation.definition.string.end.c 318 | 319 | 320 | name 321 | string.quoted.other.lt-gt.include.c 322 | 323 | 324 | 325 | 326 | include 327 | #pragma-mark 328 | 329 | 330 | begin 331 | ^\s*#\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef)\b 332 | captures 333 | 334 | 1 335 | 336 | name 337 | keyword.control.import.c 338 | 339 | 340 | end 341 | (?=(?://|/\*))|$ 342 | name 343 | meta.preprocessor.c 344 | patterns 345 | 346 | 347 | match 348 | (?>\\\s*\n) 349 | name 350 | punctuation.separator.continuation.c 351 | 352 | 353 | 354 | 355 | match 356 | \b(u_char|u_short|u_int|u_long|ushort|uint|u_quad_t|quad_t|qaddr_t|caddr_t|daddr_t|dev_t|fixpt_t|blkcnt_t|blksize_t|gid_t|in_addr_t|in_port_t|ino_t|key_t|mode_t|nlink_t|id_t|pid_t|off_t|segsz_t|swblk_t|uid_t|id_t|clock_t|size_t|ssize_t|time_t|useconds_t|suseconds_t)\b 357 | name 358 | support.type.sys-types.c 359 | 360 | 361 | match 362 | \b(pthread_attr_t|pthread_cond_t|pthread_condattr_t|pthread_mutex_t|pthread_mutexattr_t|pthread_once_t|pthread_rwlock_t|pthread_rwlockattr_t|pthread_t|pthread_key_t)\b 363 | name 364 | support.type.pthread.c 365 | 366 | 367 | match 368 | \b(int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|int_least8_t|int_least16_t|int_least32_t|int_least64_t|uint_least8_t|uint_least16_t|uint_least32_t|uint_least64_t|int_fast8_t|int_fast16_t|int_fast32_t|int_fast64_t|uint_fast8_t|uint_fast16_t|uint_fast32_t|uint_fast64_t|intptr_t|uintptr_t|intmax_t|intmax_t|uintmax_t|uintmax_t)\b 369 | name 370 | support.type.stdint.c 371 | 372 | 373 | match 374 | \b(noErr|kNilOptions|kInvalidID|kVariableLengthArray)\b 375 | name 376 | support.constant.mac-classic.c 377 | 378 | 379 | match 380 | \b(AbsoluteTime|Boolean|Byte|ByteCount|ByteOffset|BytePtr|CompTimeValue|ConstLogicalAddress|ConstStrFileNameParam|ConstStringPtr|Duration|Fixed|FixedPtr|Float32|Float32Point|Float64|Float80|Float96|FourCharCode|Fract|FractPtr|Handle|ItemCount|LogicalAddress|OptionBits|OSErr|OSStatus|OSType|OSTypePtr|PhysicalAddress|ProcessSerialNumber|ProcessSerialNumberPtr|ProcHandle|Ptr|ResType|ResTypePtr|ShortFixed|ShortFixedPtr|SignedByte|SInt16|SInt32|SInt64|SInt8|Size|StrFileName|StringHandle|StringPtr|TimeBase|TimeRecord|TimeScale|TimeValue|TimeValue64|UInt16|UInt32|UInt64|UInt8|UniChar|UniCharCount|UniCharCountPtr|UniCharPtr|UnicodeScalarValue|UniversalProcHandle|UniversalProcPtr|UnsignedFixed|UnsignedFixedPtr|UnsignedWide|UTF16Char|UTF32Char|UTF8Char)\b 381 | name 382 | support.type.mac-classic.c 383 | 384 | 385 | include 386 | #block 387 | 388 | 389 | begin 390 | (?x) 391 | (?: ^ # begin-of-line 392 | | 393 | (?: (?= \s ) (?<!else|new|return) (?<=\w) # or word + space before name 394 | | (?= \s*[A-Za-z_] ) (?<!&&) (?<=[*&>]) # or type modifier before name 395 | ) 396 | ) 397 | (\s*) (?!(while|for|do|if|else|switch|catch|enumerate|return|r?iterate)\s*\() 398 | ( 399 | (?: [A-Za-z_][A-Za-z0-9_]*+ | :: )++ | # actual name 400 | (?: (?<=operator) (?: [-*&<>=+!]+ | \(\) | \[\] ) ) # if it is a C++ operator 401 | ) 402 | \s*(?=\() 403 | beginCaptures 404 | 405 | 1 406 | 407 | name 408 | punctuation.whitespace.function.leading.c 409 | 410 | 3 411 | 412 | name 413 | entity.name.function.c 414 | 415 | 4 416 | 417 | name 418 | punctuation.definition.parameters.c 419 | 420 | 421 | end 422 | (?<=\})|(?=#)|(;) 423 | name 424 | meta.function.c 425 | patterns 426 | 427 | 428 | include 429 | #comments 430 | 431 | 432 | include 433 | #parens 434 | 435 | 436 | match 437 | \bconst\b 438 | name 439 | storage.modifier.c 440 | 441 | 442 | include 443 | #block 444 | 445 | 446 | 447 | 448 | repository 449 | 450 | access 451 | 452 | match 453 | \.[a-zA-Z_][a-zA-Z_0-9]*\b(?!\s*\() 454 | name 455 | variable.other.dot-access.c 456 | 457 | block 458 | 459 | begin 460 | \{ 461 | end 462 | \} 463 | name 464 | meta.block.c 465 | patterns 466 | 467 | 468 | include 469 | #block_innards 470 | 471 | 472 | 473 | block_innards 474 | 475 | patterns 476 | 477 | 478 | include 479 | #preprocessor-rule-enabled-block 480 | 481 | 482 | include 483 | #preprocessor-rule-disabled-block 484 | 485 | 486 | include 487 | #preprocessor-rule-other-block 488 | 489 | 490 | include 491 | #sizeof 492 | 493 | 494 | include 495 | #access 496 | 497 | 498 | include 499 | #libc 500 | 501 | 502 | include 503 | #c_function_call 504 | 505 | 506 | captures 507 | 508 | 1 509 | 510 | name 511 | variable.other.c 512 | 513 | 2 514 | 515 | name 516 | punctuation.definition.parameters.c 517 | 518 | 519 | match 520 | (?x) 521 | (?x) 522 | (?: 523 | (?: (?= \s ) (?<!else|new|return) (?<=\w)\s+ # or word + space before name 524 | ) 525 | ) 526 | ( 527 | (?: [A-Za-z_][A-Za-z0-9_]*+ | :: )++ | # actual name 528 | (?: (?<=operator) (?: [-*&<>=+!]+ | \(\) | \[\] ) )? # if it is a C++ operator 529 | ) 530 | \s*(\() 531 | name 532 | meta.initialization.c 533 | 534 | 535 | include 536 | #block 537 | 538 | 539 | include 540 | $base 541 | 542 | 543 | 544 | c_function_call 545 | 546 | captures 547 | 548 | 1 549 | 550 | name 551 | punctuation.whitespace.function-call.leading.c 552 | 553 | 2 554 | 555 | name 556 | support.function.any-method.c 557 | 558 | 3 559 | 560 | name 561 | punctuation.definition.parameters.c 562 | 563 | 564 | match 565 | (?x) (?: (?= \s ) (?:(?<=else|new|return) | (?<!\w)) (\s+))? 566 | (\b 567 | (?!(while|for|do|if|else|switch|catch|enumerate|return|r?iterate)\s*\()(?:(?!NS)[A-Za-z_][A-Za-z0-9_]*+\b | :: )++ # actual name 568 | ) 569 | \s*(\() 570 | name 571 | meta.function-call.c 572 | 573 | comments 574 | 575 | patterns 576 | 577 | 578 | captures 579 | 580 | 1 581 | 582 | name 583 | meta.toc-list.banner.block.c 584 | 585 | 586 | match 587 | ^/\* =(\s*.*?)\s*= \*/$\n? 588 | name 589 | comment.block.c 590 | 591 | 592 | begin 593 | /\* 594 | captures 595 | 596 | 0 597 | 598 | name 599 | punctuation.definition.comment.c 600 | 601 | 602 | end 603 | \*/ 604 | name 605 | comment.block.c 606 | 607 | 608 | match 609 | \*/.*\n 610 | name 611 | invalid.illegal.stray-comment-end.c 612 | 613 | 614 | captures 615 | 616 | 1 617 | 618 | name 619 | meta.toc-list.banner.line.c 620 | 621 | 622 | match 623 | ^// =(\s*.*?)\s*=\s*$\n? 624 | name 625 | comment.line.banner.c++ 626 | 627 | 628 | begin 629 | // 630 | beginCaptures 631 | 632 | 0 633 | 634 | name 635 | punctuation.definition.comment.c 636 | 637 | 638 | end 639 | $\n? 640 | name 641 | comment.line.double-slash.c++ 642 | patterns 643 | 644 | 645 | match 646 | (?>\\\s*\n) 647 | name 648 | punctuation.separator.continuation.c++ 649 | 650 | 651 | 652 | 653 | 654 | disabled 655 | 656 | begin 657 | ^\s*#\s*if(n?def)?\b.*$ 658 | comment 659 | eat nested preprocessor if(def)s 660 | end 661 | ^\s*#\s*endif\b.*$ 662 | patterns 663 | 664 | 665 | include 666 | #disabled 667 | 668 | 669 | include 670 | #pragma-mark 671 | 672 | 673 | 674 | libc 675 | 676 | captures 677 | 678 | 1 679 | 680 | name 681 | punctuation.whitespace.support.function.leading.c 682 | 683 | 2 684 | 685 | name 686 | support.function.C99.c 687 | 688 | 689 | match 690 | (\s*)\b(hypot(f|l)?|s(scanf|ystem|nprintf|ca(nf|lb(n(f|l)?|ln(f|l)?))|i(n(h(f|l)?|f|l)?|gn(al|bit))|tr(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(jmp|vbuf|locale|buf)|qrt(f|l)?|w(scanf|printf)|rand)|n(e(arbyint(f|l)?|xt(toward(f|l)?|after(f|l)?))|an(f|l)?)|c(s(in(h(f|l)?|f|l)?|qrt(f|l)?)|cos(h(f)?|f|l)?|imag(f|l)?|t(ime|an(h(f|l)?|f|l)?)|o(s(h(f|l)?|f|l)?|nj(f|l)?|pysign(f|l)?)|p(ow(f|l)?|roj(f|l)?)|e(il(f|l)?|xp(f|l)?)|l(o(ck|g(f|l)?)|earerr)|a(sin(h(f|l)?|f|l)?|cos(h(f|l)?|f|l)?|tan(h(f|l)?|f|l)?|lloc|rg(f|l)?|bs(f|l)?)|real(f|l)?|brt(f|l)?)|t(ime|o(upper|lower)|an(h(f|l)?|f|l)?|runc(f|l)?|gamma(f|l)?|mp(nam|file))|i(s(space|n(ormal|an)|cntrl|inf|digit|u(nordered|pper)|p(unct|rint)|finite|w(space|c(ntrl|type)|digit|upper|p(unct|rint)|lower|al(num|pha)|graph|xdigit|blank)|l(ower|ess(equal|greater)?)|al(num|pha)|gr(eater(equal)?|aph)|xdigit|blank)|logb(f|l)?|max(div|abs))|di(v|fftime)|_Exit|unget(c|wc)|p(ow(f|l)?|ut(s|c(har)?|wc(har)?)|error|rintf)|e(rf(c(f|l)?|f|l)?|x(it|p(2(f|l)?|f|l|m1(f|l)?)?))|v(s(scanf|nprintf|canf|printf|w(scanf|printf))|printf|f(scanf|printf|w(scanf|printf))|w(scanf|printf)|a_(start|copy|end|arg))|qsort|f(s(canf|e(tpos|ek))|close|tell|open|dim(f|l)?|p(classify|ut(s|c|w(s|c))|rintf)|e(holdexcept|set(e(nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(aiseexcept|ror)|get(e(nv|xceptflag)|round))|flush|w(scanf|ide|printf|rite)|loor(f|l)?|abs(f|l)?|get(s|c|pos|w(s|c))|re(open|e|ad|xp(f|l)?)|m(in(f|l)?|od(f|l)?|a(f|l|x(f|l)?)?))|l(d(iv|exp(f|l)?)|o(ngjmp|cal(time|econv)|g(1(p(f|l)?|0(f|l)?)|2(f|l)?|f|l|b(f|l)?)?)|abs|l(div|abs|r(int(f|l)?|ound(f|l)?))|r(int(f|l)?|ound(f|l)?)|gamma(f|l)?)|w(scanf|c(s(s(tr|pn)|nc(py|at|mp)|c(spn|hr|oll|py|at|mp)|to(imax|d|u(l(l)?|max)|k|f|l(d|l)?|mbs)|pbrk|ftime|len|r(chr|tombs)|xfrm)|to(b|mb)|rtomb)|printf|mem(set|c(hr|py|mp)|move))|a(s(sert|ctime|in(h(f|l)?|f|l)?)|cos(h(f|l)?|f|l)?|t(o(i|f|l(l)?)|exit|an(h(f|l)?|2(f|l)?|f|l)?)|b(s|ort))|g(et(s|c(har)?|env|wc(har)?)|mtime)|r(int(f|l)?|ound(f|l)?|e(name|alloc|wind|m(ove|quo(f|l)?|ainder(f|l)?))|a(nd|ise))|b(search|towc)|m(odf(f|l)?|em(set|c(hr|py|mp)|move)|ktime|alloc|b(s(init|towcs|rtowcs)|towc|len|r(towc|len))))\b 691 | 692 | parens 693 | 694 | begin 695 | \( 696 | end 697 | \) 698 | name 699 | meta.parens.c 700 | patterns 701 | 702 | 703 | include 704 | $base 705 | 706 | 707 | 708 | pragma-mark 709 | 710 | captures 711 | 712 | 1 713 | 714 | name 715 | meta.preprocessor.c 716 | 717 | 2 718 | 719 | name 720 | keyword.control.import.pragma.c 721 | 722 | 3 723 | 724 | name 725 | meta.toc-list.pragma-mark.c 726 | 727 | 728 | match 729 | ^\s*(#\s*(pragma\s+mark)\s+(.*)) 730 | name 731 | meta.section 732 | 733 | preprocessor-rule-disabled 734 | 735 | begin 736 | ^\s*(#(if)\s+(0)\b).* 737 | captures 738 | 739 | 1 740 | 741 | name 742 | meta.preprocessor.c 743 | 744 | 2 745 | 746 | name 747 | keyword.control.import.if.c 748 | 749 | 3 750 | 751 | name 752 | constant.numeric.preprocessor.c 753 | 754 | 755 | end 756 | ^\s*(#\s*(endif)\b) 757 | patterns 758 | 759 | 760 | begin 761 | ^\s*(#\s*(else)\b) 762 | captures 763 | 764 | 1 765 | 766 | name 767 | meta.preprocessor.c 768 | 769 | 2 770 | 771 | name 772 | keyword.control.import.else.c 773 | 774 | 775 | end 776 | (?=^\s*#\s*endif\b.*$) 777 | patterns 778 | 779 | 780 | include 781 | $base 782 | 783 | 784 | 785 | 786 | begin 787 | 788 | end 789 | (?=^\s*#\s*(else|endif)\b.*$) 790 | name 791 | comment.block.preprocessor.if-branch 792 | patterns 793 | 794 | 795 | include 796 | #disabled 797 | 798 | 799 | include 800 | #pragma-mark 801 | 802 | 803 | 804 | 805 | 806 | preprocessor-rule-disabled-block 807 | 808 | begin 809 | ^\s*(#(if)\s+(0)\b).* 810 | captures 811 | 812 | 1 813 | 814 | name 815 | meta.preprocessor.c 816 | 817 | 2 818 | 819 | name 820 | keyword.control.import.if.c 821 | 822 | 3 823 | 824 | name 825 | constant.numeric.preprocessor.c 826 | 827 | 828 | end 829 | ^\s*(#\s*(endif)\b) 830 | patterns 831 | 832 | 833 | begin 834 | ^\s*(#\s*(else)\b) 835 | captures 836 | 837 | 1 838 | 839 | name 840 | meta.preprocessor.c 841 | 842 | 2 843 | 844 | name 845 | keyword.control.import.else.c 846 | 847 | 848 | end 849 | (?=^\s*#\s*endif\b.*$) 850 | patterns 851 | 852 | 853 | include 854 | #block_innards 855 | 856 | 857 | 858 | 859 | begin 860 | 861 | end 862 | (?=^\s*#\s*(else|endif)\b.*$) 863 | name 864 | comment.block.preprocessor.if-branch.in-block 865 | patterns 866 | 867 | 868 | include 869 | #disabled 870 | 871 | 872 | include 873 | #pragma-mark 874 | 875 | 876 | 877 | 878 | 879 | preprocessor-rule-enabled 880 | 881 | begin 882 | ^\s*(#(if)\s+(0*1)\b) 883 | captures 884 | 885 | 1 886 | 887 | name 888 | meta.preprocessor.c 889 | 890 | 2 891 | 892 | name 893 | keyword.control.import.if.c 894 | 895 | 3 896 | 897 | name 898 | constant.numeric.preprocessor.c 899 | 900 | 901 | end 902 | ^\s*(#\s*(endif)\b) 903 | patterns 904 | 905 | 906 | begin 907 | ^\s*(#\s*(else)\b).* 908 | captures 909 | 910 | 1 911 | 912 | name 913 | meta.preprocessor.c 914 | 915 | 2 916 | 917 | name 918 | keyword.control.import.else.c 919 | 920 | 921 | contentName 922 | comment.block.preprocessor.else-branch 923 | end 924 | (?=^\s*#\s*endif\b.*$) 925 | patterns 926 | 927 | 928 | include 929 | #disabled 930 | 931 | 932 | include 933 | #pragma-mark 934 | 935 | 936 | 937 | 938 | begin 939 | 940 | end 941 | (?=^\s*#\s*(else|endif)\b.*$) 942 | patterns 943 | 944 | 945 | include 946 | $base 947 | 948 | 949 | 950 | 951 | 952 | preprocessor-rule-enabled-block 953 | 954 | begin 955 | ^\s*(#(if)\s+(0*1)\b) 956 | captures 957 | 958 | 1 959 | 960 | name 961 | meta.preprocessor.c 962 | 963 | 2 964 | 965 | name 966 | keyword.control.import.if.c 967 | 968 | 3 969 | 970 | name 971 | constant.numeric.preprocessor.c 972 | 973 | 974 | end 975 | ^\s*(#\s*(endif)\b) 976 | patterns 977 | 978 | 979 | begin 980 | ^\s*(#\s*(else)\b).* 981 | captures 982 | 983 | 1 984 | 985 | name 986 | meta.preprocessor.c 987 | 988 | 2 989 | 990 | name 991 | keyword.control.import.else.c 992 | 993 | 994 | contentName 995 | comment.block.preprocessor.else-branch.in-block 996 | end 997 | (?=^\s*#\s*endif\b.*$) 998 | patterns 999 | 1000 | 1001 | include 1002 | #disabled 1003 | 1004 | 1005 | include 1006 | #pragma-mark 1007 | 1008 | 1009 | 1010 | 1011 | begin 1012 | 1013 | end 1014 | (?=^\s*#\s*(else|endif)\b.*$) 1015 | patterns 1016 | 1017 | 1018 | include 1019 | #block_innards 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | preprocessor-rule-other 1026 | 1027 | begin 1028 | ^\s*(#\s*(if(n?def)?)\b.*?(?:(?=(?://|/\*))|$)) 1029 | captures 1030 | 1031 | 1 1032 | 1033 | name 1034 | meta.preprocessor.c 1035 | 1036 | 2 1037 | 1038 | name 1039 | keyword.control.import.c 1040 | 1041 | 1042 | end 1043 | ^\s*(#\s*(endif)\b).*$ 1044 | patterns 1045 | 1046 | 1047 | include 1048 | $base 1049 | 1050 | 1051 | 1052 | preprocessor-rule-other-block 1053 | 1054 | begin 1055 | ^\s*(#\s*(if(n?def)?)\b.*?(?:(?=(?://|/\*))|$)) 1056 | captures 1057 | 1058 | 1 1059 | 1060 | name 1061 | meta.preprocessor.c 1062 | 1063 | 2 1064 | 1065 | name 1066 | keyword.control.import.c 1067 | 1068 | 1069 | end 1070 | ^\s*(#\s*(endif)\b).*$ 1071 | patterns 1072 | 1073 | 1074 | include 1075 | #block_innards 1076 | 1077 | 1078 | 1079 | sizeof 1080 | 1081 | match 1082 | \b(sizeof)\b 1083 | name 1084 | keyword.operator.sizeof.c 1085 | 1086 | string_escaped_char 1087 | 1088 | patterns 1089 | 1090 | 1091 | match 1092 | \\(\\|[abefnprtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-fA-F0-9]{,2}|u[a-fA-F0-9]{,4}|U[a-fA-F0-9]{,8}) 1093 | name 1094 | constant.character.escape.c 1095 | 1096 | 1097 | match 1098 | \\. 1099 | name 1100 | invalid.illegal.unknown-escape.c 1101 | 1102 | 1103 | 1104 | string_placeholder 1105 | 1106 | patterns 1107 | 1108 | 1109 | match 1110 | (?x)% 1111 | (\d+\$)? # field (argument #) 1112 | [#0\- +']* # flags 1113 | [,;:_]? # separator character (AltiVec) 1114 | ((-?\d+)|\*(-?\d+\$)?)? # minimum field width 1115 | (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision 1116 | (hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier 1117 | [diouxXDOUeEfFgGaACcSspn%] # conversion type 1118 | 1119 | name 1120 | constant.other.placeholder.c 1121 | 1122 | 1123 | match 1124 | % 1125 | name 1126 | invalid.illegal.placeholder.c 1127 | 1128 | 1129 | 1130 | 1131 | scopeName 1132 | source.c 1133 | uuid 1134 | 25066DC2-6B1D-11D9-9D5B-000D93589AF6 1135 | 1136 | 1137 | --------------------------------------------------------------------------------