diff options
author | Jose Antonio Marquez Russo | 2012-02-29 15:41:12 -0800 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-02-29 15:41:12 -0800 |
commit | 13aca03d4e0d11729d691db0b7f0d2f2a6899cf6 (patch) | |
tree | dbd17232983247a38bb6b2cea480242bdf3f2422 /imports/codemirror/mode/python/python.js | |
parent | b09956e4a9a35c5588cc7cd1f01efb617cbe0884 (diff) | |
parent | 8fee7d6bdb55ba18f396c3523081b18499fa1e30 (diff) | |
download | ninja-13aca03d4e0d11729d691db0b7f0d2f2a6899cf6.tar.gz |
Merge pull request #24 from ananyasen/FileIO
undo/redo per document , codemirror 2.22 update
Diffstat (limited to 'imports/codemirror/mode/python/python.js')
-rw-r--r--[-rwxr-xr-x] | imports/codemirror/mode/python/python.js | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/imports/codemirror/mode/python/python.js b/imports/codemirror/mode/python/python.js index 382052ba..cfe8a774 100755..100644 --- a/imports/codemirror/mode/python/python.js +++ b/imports/codemirror/mode/python/python.js | |||
@@ -18,28 +18,35 @@ CodeMirror.defineMode("python", function(conf, parserConf) { | |||
18 | 'for', 'from', 'global', 'if', 'import', | 18 | 'for', 'from', 'global', 'if', 'import', |
19 | 'lambda', 'pass', 'raise', 'return', | 19 | 'lambda', 'pass', 'raise', 'return', |
20 | 'try', 'while', 'with', 'yield']; | 20 | 'try', 'while', 'with', 'yield']; |
21 | var commontypes = ['bool', 'classmethod', 'complex', 'dict', 'enumerate', | 21 | var commonBuiltins = ['abs', 'all', 'any', 'bin', 'bool', 'bytearray', 'callable', 'chr', |
22 | 'float', 'frozenset', 'int', 'list', 'object', | 22 | 'classmethod', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', |
23 | 'property', 'reversed', 'set', 'slice', 'staticmethod', | 23 | 'enumerate', 'eval', 'filter', 'float', 'format', 'frozenset', |
24 | 'str', 'super', 'tuple', 'type']; | 24 | 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', |
25 | var py2 = {'types': ['basestring', 'buffer', 'file', 'long', 'unicode', | 25 | 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', |
26 | 'xrange'], | 26 | 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', |
27 | 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range', | ||
28 | 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', | ||
29 | 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', | ||
30 | 'type', 'vars', 'zip', '__import__', 'NotImplemented', | ||
31 | 'Ellipsis', '__debug__']; | ||
32 | var py2 = {'builtins': ['apply', 'basestring', 'buffer', 'cmp', 'coerce', 'execfile', | ||
33 | 'file', 'intern', 'long', 'raw_input', 'reduce', 'reload', | ||
34 | 'unichr', 'unicode', 'xrange', 'False', 'True', 'None'], | ||
27 | 'keywords': ['exec', 'print']}; | 35 | 'keywords': ['exec', 'print']}; |
28 | var py3 = {'types': ['bytearray', 'bytes', 'filter', 'map', 'memoryview', | 36 | var py3 = {'builtins': ['ascii', 'bytes', 'exec', 'print'], |
29 | 'open', 'range', 'zip'], | 37 | 'keywords': ['nonlocal', 'False', 'True', 'None']}; |
30 | 'keywords': ['nonlocal']}; | ||
31 | 38 | ||
32 | if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) { | 39 | if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) { |
33 | commonkeywords = commonkeywords.concat(py3.keywords); | 40 | commonkeywords = commonkeywords.concat(py3.keywords); |
34 | commontypes = commontypes.concat(py3.types); | 41 | commonBuiltins = commonBuiltins.concat(py3.builtins); |
35 | var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i"); | 42 | var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i"); |
36 | } else { | 43 | } else { |
37 | commonkeywords = commonkeywords.concat(py2.keywords); | 44 | commonkeywords = commonkeywords.concat(py2.keywords); |
38 | commontypes = commontypes.concat(py2.types); | 45 | commonBuiltins = commonBuiltins.concat(py2.builtins); |
39 | var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); | 46 | var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i"); |
40 | } | 47 | } |
41 | var keywords = wordRegexp(commonkeywords); | 48 | var keywords = wordRegexp(commonkeywords); |
42 | var types = wordRegexp(commontypes); | 49 | var builtins = wordRegexp(commonBuiltins); |
43 | 50 | ||
44 | var indentInfo = null; | 51 | var indentInfo = null; |
45 | 52 | ||
@@ -129,14 +136,14 @@ CodeMirror.defineMode("python", function(conf, parserConf) { | |||
129 | return null; | 136 | return null; |
130 | } | 137 | } |
131 | 138 | ||
132 | if (stream.match(types)) { | ||
133 | return 'builtin'; | ||
134 | } | ||
135 | |||
136 | if (stream.match(keywords)) { | 139 | if (stream.match(keywords)) { |
137 | return 'keyword'; | 140 | return 'keyword'; |
138 | } | 141 | } |
139 | 142 | ||
143 | if (stream.match(builtins)) { | ||
144 | return 'builtin'; | ||
145 | } | ||
146 | |||
140 | if (stream.match(identifiers)) { | 147 | if (stream.match(identifiers)) { |
141 | return 'variable'; | 148 | return 'variable'; |
142 | } | 149 | } |
@@ -244,7 +251,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) { | |||
244 | if (current === '.') { | 251 | if (current === '.') { |
245 | style = state.tokenize(stream, state); | 252 | style = state.tokenize(stream, state); |
246 | current = stream.current(); | 253 | current = stream.current(); |
247 | if (style === 'variable') { | 254 | if (style === 'variable' || style === 'builtin') { |
248 | return 'variable'; | 255 | return 'variable'; |
249 | } else { | 256 | } else { |
250 | return ERRORCLASS; | 257 | return ERRORCLASS; |