12 |14 | */ 15 | component output="false" displayname="import" { 16 | this.tagxml = ""; 17 | this.newtags = []; 18 | this.newtagtemplate = { 19 | name = "", 20 | endtagrequired = true, 21 | completions = [], 22 | attributes = {} 23 | }; 24 | this.newattributetemplate = { 25 | name = "", 26 | completions = [] 27 | }; 28 | 29 | public function init(filename) { 30 | var filecontent = FileRead( filename ); 31 | this.tagxml = XmlParse( filecontent ).dictionary.tags; 32 | return this; 33 | } 34 | 35 | public function convert() { 36 | var i = 0; 37 | var j = 0; 38 | var k = 0; 39 | var newtag = {}; 40 | var newattribute = {}; 41 | var currenttag = ""; 42 | var paramname = ""; 43 | for ( i = 1; i <= ArrayLen( this.tagxml.Tag ); i++ ) { 44 | currenttag = this.tagxml.Tag[i]; 45 | newtag = Duplicate( this.newtagtemplate ); 46 | if ( StructKeyExists( currenttag.XmlAttributes, "endtagrequired" ) EQ false ) { 47 | newtag.endtagrequired = "false"; 48 | } 49 | newtag.name = currenttag.XmlAttributes.Name; 50 | if ( StructKeyExists( currenttag, "parameter" ) ) { 51 | for ( j = 1; j <= ArrayLen( currenttag.parameter ); j++ ) { 52 | paramname = currenttag.parameter[j].XmlAttributes.name; 53 | newtag.completions.add( paramname ); 54 | newattribute = Duplicate( this.newattributetemplate ); 55 | newattribute.name = currenttag.parameter[j].XmlAttributes.name; 56 | if ( StructKeyExists( currenttag.parameter[j].XmlAttributes, "type" ) && ( currenttag.parameter[j].XmlAttributes.type == "Boolean" || 57 | ( StructKeyExists( currenttag.parameter[j], "values" ) && StructKeyExists( currenttag.parameter[j].values, "value" ) ) ) ) { 58 | 59 | switch ( currenttag.parameter[j].XmlAttributes.type ) { 60 | case "Boolean": 61 | newattribute.completions.add( "true" ); 62 | newattribute.completions.add( "false" ); 63 | break; 64 | case "String": 65 | if ( StructKeyExists( currenttag.parameter[j],"values" ) && StructKeyExists( currenttag.parameter[j].values,"value") ) { 66 | for ( k = 1; k <= ArrayLen( currenttag.parameter[j].values.value ); k++ ) { 67 | newattribute.completions.add( Replace( currenttag.parameter[j].values.value[k].xmlattributes.option, '"', '', "all" ) ); 68 | } 69 | } 70 | break; 71 | } 72 | 73 | } 74 | newtag.attributes[newattribute.name] = newattribute; 75 | /* 76 | if ( StructKeyExists( currenttag.parameter[j].XmlAttributes, "required" ) && currenttag.parameter[j].XmlAttributes.required EQ "true" ) { 77 | 78 | } 79 | */ 80 | } 81 | } 82 | this.newtags.add( newtag ); 83 | } 84 | return this.newtags; 85 | } 86 | 87 | public function outputpython( includeValuesInMainList = true ) { 88 | var pythonoutput = ""; 89 | var tagIterator = this.newtags.iterator(); 90 | var compIterator = ""; 91 | var tag = ""; 92 | var comp = ""; 93 | var attrCompIterator = ""; 94 | var attrComp = ""; 95 | var crlf = chr( 13 ) & chr( 10 ); 96 | var attrIterator = ""; 97 | var attr = ""; 98 | 99 | while( tagIterator.hasNext() ) { 100 | tag = tagIterator.next(); 101 | pythonoutput &= "self.completions['" & tag.name & "'] = {" & crlf; 102 | compIter = tag.completions.iterator(); 103 | pythonoutput &= " 'completions': [" & crlf; 104 | while ( compIter.hasNext() ) { 105 | comp = compIter.next(); 106 | pythonoutput &= ' ("' & comp & '\t@' & comp & '", "' & comp & '=\"$1\"$0")'; 107 | if ( arguments.includeValuesInMainList && StructKeyExists( tag.attributes, comp ) ) { 108 | attrCompIterator = tag.attributes[comp].completions.iterator(); 109 | while ( attrCompIterator.hasNext() ) { 110 | attrcomp = attrCompIterator.next(); 111 | pythonoutput &= "," & crlf; 112 | pythonoutput &= ' ("' & comp & '=\"' & attrcomp & '\"\t' & comp & '", "' & comp & '=\"${1:' & attrcomp & '}\"$0")'; 113 | } 114 | } 115 | if ( compIter.hasNext() ) { 116 | pythonoutput &= ","; 117 | } 118 | pythonoutput &= crlf; 119 | } 120 | pythonoutput &= " ]," & crlf; 121 | attrIterator = StructKeyArray(tag.attributes).iterator(); 122 | pythonoutput &= " 'attributes': ["; 123 | while ( attrIterator.hasNext() ) { 124 | attr = attrIterator.next(); 125 | pythonoutput &= crlf & ' "' & attr & '"'; 126 | if ( attrIterator.hasNext() ) { 127 | pythonoutput &= ","; 128 | } 129 | } 130 | pythonoutput &= crlf & " ]" & crlf; 131 | pythonoutput &= "}" & crlf; 132 | } 133 | return pythonoutput; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /ondotcompletions.py: -------------------------------------------------------------------------------- 1 | import sublime, sublime_plugin 2 | 3 | completions = [] 4 | dotcompletions = {} 5 | dotcompletions["CGI"] = [ 6 | ("AUTH_PASSWORD", "AUTH_PASSWORD"), 7 | ("AUTH_TYPE", "AUTH_TYPE"), 8 | ("AUTH_USER", "AUTH_USER"), 9 | ("CERT_COOKIE", "CERT_COOKIE"), 10 | ("CERT_FLAGS", "CERT_FLAGS"), 11 | ("CERT_ISSUER", "CERT_ISSUER"), 12 | ("CERT_KEYSIZE", "CERT_KEYSIZE"), 13 | ("CERT_SECRETKEYSIZE", "CERT_SECRETKEYSIZE"), 14 | ("CERT_SERIALNUMBER", "CERT_SERIALNUMBER"), 15 | ("CERT_SERVER_ISSUER", "CERT_SERVER_ISSUER"), 16 | ("CERT_SERVER_SUBJECT", "CERT_SERVER_SUBJECT"), 17 | ("CERT_SUBJECT", "CERT_SUBJECT"), 18 | ("CF_TEMPLATE_PATH", "CF_TEMPLATE_PATH"), 19 | ("CONTENT_LENGTH", "CONTENT_LENGTH"), 20 | ("CONTENT_TYPE", "CONTENT_TYPE"), 21 | ("GATEWAY_INTERFACE", "GATEWAY_INTERFACE"), 22 | ("HTTP_ACCEPT", "HTTP_ACCEPT"), 23 | ("HTTP_ACCEPT_ENCODING", "HTTP_ACCEPT_ENCODING"), 24 | ("HTTP_ACCEPT_LANGUAGE", "HTTP_ACCEPT_LANGUAGE"), 25 | ("HTTP_CONNECTION", "HTTP_CONNECTION"), 26 | ("HTTP_COOKIE", "HTTP_COOKIE"), 27 | ("HTTP_HOST", "HTTP_HOST"), 28 | ("HTTP_USER_AGENT", "HTTP_USER_AGENT"), 29 | ("HTTP_REFERER", "HTTP_REFERER"), 30 | ("HTTPS", "HTTPS"), 31 | ("HTTPS_KEYSIZE", "HTTPS_KEYSIZE"), 32 | ("HTTPS_SECRETKEYSIZE", "HTTPS_SECRETKEYSIZE"), 33 | ("HTTPS_SERVER_ISSUER", "HTTPS_SERVER_ISSUER"), 34 | ("HTTPS_SERVER_SUBJECT", "HTTPS_SERVER_SUBJECT"), 35 | ("PATH_INFO", "PATH_INFO"), 36 | ("PATH_TRANSLATED", "PATH_TRANSLATED"), 37 | ("QUERY_STRING", "QUERY_STRING"), 38 | ("REMOTE_ADDR", "REMOTE_ADDR"), 39 | ("REMOTE_HOST", "REMOTE_HOST"), 40 | ("REMOTE_USER", "REMOTE_USER"), 41 | ("REQUEST_METHOD", "REQUEST_METHOD"), 42 | ("SCRIPT_NAME", "SCRIPT_NAME"), 43 | ("SERVER_NAME", "SERVER_NAME"), 44 | ("SERVER_PORT", "SERVER_PORT"), 45 | ("SERVER_PORT_SECURE", "SERVER_PORT_SECURE"), 46 | ("SERVER_PROTOCOL", "SERVER_PROTOCOL"), 47 | ("SERVER_SOFTWARE", "SERVER_SOFTWARE"), 48 | ("WEB_SERVER_API", "WEB_SERVER_API"), 49 | ("CONTEXT_PATH", "CONTEXT_PATH"), 50 | ("LOCAL_ADDR", "LOCAL_ADDR"), 51 | ("LOCAL_HOST", "LOCAL_HOST") 52 | ] 53 | 54 | class DotCompletionsCommand(sublime_plugin.TextCommand): 55 | def run(self, edit): 56 | 57 | sel = self.view.sel()[0] 58 | 59 | # insert the actual . character 60 | for region in self.view.sel(): 61 | self.view.insert(edit, region.end(), ".") 62 | 63 | if self.view.settings().get("auto_complete") == False: 64 | return 65 | 66 | word = self.view.word(sel.begin() - 1) 67 | if self.view.substr(word) == "CGI": 68 | completions.extend(dotcompletions["CGI"]) 69 | t = self.view.settings().get("auto_complete_delay") 70 | sublime.set_timeout(lambda: 71 | self.view.run_command("auto_complete", { 72 | 'disable_auto_insert': True, 73 | 'next_completion_if_showing': False, 74 | 'api_completions_only': True}), t) 75 | 76 | class OnDotCompletions(sublime_plugin.EventListener): 77 | def on_query_completions(self, view, prefix, locations): 78 | _completions = [] 79 | _completions.extend(completions) 80 | 81 | del completions[:] 82 | return _completions 83 | 84 | 85 | -------------------------------------------------------------------------------- /package-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://github.com/SublimeText/ColdFusion", 3 | "version": "2012.06.24.21.10.45", 4 | "description": "ColdFusion package for Sublime Text 2", 5 | "author": "@atomi" 6 | } 7 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # ColdFusion Package for Sublime Text 2 | 3 | ### This package is no longer maintained. 4 | 5 | Please use jcberquist's excellent package: https://github.com/jcberquist/sublimetext-cfml 6 | 7 | ### Sublime Text 3 8 | The development branch contains a rewrite of the ColdFusion plugin. 9 | The only installation method is via Git. 10 | ``` 11 | cd Packages/ 12 | git clone https://github.com/SublimeText/ColdFusion.git 13 | cd ColdFusion 14 | git checkout development 15 | ``` 16 | * CFLIB Command is not currently working. 17 | * Tag Operator Completions is not yet implemented 18 | * CFScript component method completions is not yet implemented 19 | * Only CF10 Dictionary is imported. 20 | 21 | ### What's New 22 | * Added Tag Operator completions for cfscript (10/21/12) 23 | * Added CFScript component method completions (6/28/12) 24 | * Added "auto_close_cfml", "auto_indent_on_close" settings (6/25/12) 25 | * Added Tag Attribute completions (6/24/12) 26 | * Added Command ```ColdFusion: Insert CFlib UDF``` (6/2/12) 27 | 28 | ### Features 29 | 30 | * ColdFusion cfml, and script-based CFCs syntax highlighting. (see tmLanguage files) 31 | * Auto inserts closing hash # (see Default (platform).sublime-keymap) 32 | * Provides completions that match just after typing an opening angle bracket (see cfml_completions.py) 33 | * Auto Complete ColdFusion Tags and Attributes (opt. cf7, cf8, cf9 & cf10) 34 | * ColdFusion specific key bindings (see Default (platform).sublime-keymap) 35 | 36 | ## Installation 37 | 38 | The recommended method of installation is via Package Control. 39 | 40 | ### Package Control 41 | 42 | * Follow instructions on https://packagecontrol.io/installation 43 | * Install using Package Control: Install > ColdFusion package 44 | 45 | ### Using Git 46 | 47 | Go to your Sublime Text 2 `Packages` directory and clone the repository using the command below: 48 | 49 | git clone https://github.com/SublimeText/ColdFusion 50 | 51 | ### Download Manually 52 | 53 | * Download the files using the GitHub .zip download option 54 | * Unzip the files and rename the folder to `ColdFusion` 55 | * Copy the folder to your Sublime Text 2 `Packages` directory 56 | 57 | - - - 58 | 59 | ## Key bindings 60 | 61 | Some packages will override key bindings. If you have problems with a specific key shortcut, 62 | you can add it to your User - Key Bindings file ```Preferences > Key Bindings - User``` 63 | 64 | You can also use ```sublime.log_commands(True)``` in the console (```ctrl+~```) to output key presses and their corresponding command to the console pane. 65 | 66 |#importer.outputpython()# 13 |
69 | ⇧+# #SELECTION#
70 | |
71 |
72 | Ctrl+⇧+O <cfoutput>SELECTION</cfoutput>
73 | |
74 |
77 | Ctrl+⇧+# <cfoutput>#SELECTION#</cfoutput>
78 | |
79 |
80 | Ctrl+Alt+A <cfabort />
81 | |
82 |
85 | Ctrl+Alt+D <cfdump var="#SELECTION#">
86 | |
87 |
88 | Alt+⇧+R <cfscript>SELECTION</cfscript>
89 | |
90 |
93 | Ctrl+⇧+/ block comment (cfml/cfscript)
94 | |
95 |
96 | Ctrl+Alt+⇧+/ javadoc comment
97 | |
98 |
101 | Alt+↩ terminates statement (cfscript)
102 | |
103 |
104 | Ctrl+⇧+= <cfset SELECTION />
105 | |
106 |