codemirror 3.18 with enabled the fullscreen addon

This commit is contained in:
Paolo
2013-09-26 21:52:53 +02:00
parent 633acffd28
commit ddf1998d49
166 changed files with 3820 additions and 2321 deletions
@@ -1,21 +0,0 @@
The MIT License
Copyright (c) 2010 Timothy Farrell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+70 -18
View File
@@ -1,18 +1,31 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Python mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="python.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
</head>
<body>
<h1>CodeMirror: Python mode</h1>
<title>CodeMirror: Python mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="python.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">Python</a>
</ul>
</div>
<article>
<h2>Python mode</h2>
<div><textarea id="code" name="code">
# Literals
1234
@@ -102,6 +115,34 @@ class ExampleClass(ParentClass):
self.mixin = mixin
</textarea></div>
<h2>Cython mode</h2>
<div><textarea id="code-cython" name="code-cython">
import numpy as np
cimport cython
from libc.math cimport sqrt
@cython.boundscheck(False)
@cython.wraparound(False)
def pairwise_cython(double[:, ::1] X):
cdef int M = X.shape[0]
cdef int N = X.shape[1]
cdef double tmp, d
cdef double[:, ::1] D = np.empty((M, M), dtype=np.float64)
for i in range(M):
for j in range(M):
d = 0.0
for k in range(N):
tmp = X[i, k] - X[j, k]
d += tmp * tmp
D[i, j] = sqrt(d)
return np.asarray(D)
</textarea></div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: {name: "python",
@@ -111,9 +152,19 @@ class ExampleClass(ParentClass):
indentUnit: 4,
tabMode: "shift",
matchBrackets: true
});
CodeMirror.fromTextArea(document.getElementById("code-cython"), {
mode: {name: "text/x-cython",
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 4,
tabMode: "shift",
matchBrackets: true
});
</script>
<h2>Configuration Options:</h2>
<h2>Configuration Options for Python mode:</h2>
<ul>
<li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
<li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
@@ -127,9 +178,10 @@ class ExampleClass(ParentClass):
<li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
<li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(&gt;&gt;=)|(&lt;&lt;=)|(\\*\\*=))</pre></li>
<li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre></li>
<li>extra_keywords - list of string - List of extra words ton consider as keywords</li>
<li>extra_builtins - list of string - List of extra words ton consider as builtins</li>
</ul>
<p><strong>MIME types defined:</strong> <code>text/x-python</code>.</p>
</body>
</html>
<p><strong>MIME types defined:</strong> <code>text/x-python</code> and <code>text/x-cython</code>.</p>
</article>
+33 -6
View File
@@ -36,6 +36,12 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
var py3 = {'builtins': ['ascii', 'bytes', 'exec', 'print'],
'keywords': ['nonlocal', 'False', 'True', 'None']};
if(parserConf.extra_keywords != undefined){
commonkeywords = commonkeywords.concat(parserConf.extra_keywords);
}
if(parserConf.extra_builtins != undefined){
commonBuiltins = commonBuiltins.concat(parserConf.extra_builtins);
}
if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {
commonkeywords = commonkeywords.concat(py3.keywords);
commonBuiltins = commonBuiltins.concat(py3.builtins);
@@ -145,6 +151,9 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
}
if (stream.match(identifiers)) {
if (state.lastToken == 'def' || state.lastToken == 'class') {
return 'def';
}
return 'variable';
}
@@ -252,7 +261,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
// Handle '.' connected identifiers
if (current === '.') {
style = stream.match(identifiers, false) ? null : ERRORCLASS;
if (style === null && state.lastToken === 'meta') {
if (style === null && state.lastStyle === 'meta') {
// Apply 'meta' style to '.' connected identifiers when
// appropriate.
style = 'meta';
@@ -266,7 +275,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
}
if ((style === 'variable' || style === 'builtin')
&& state.lastToken === 'meta') {
&& state.lastStyle === 'meta') {
style = 'meta';
}
@@ -307,6 +316,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
return {
tokenize: tokenBase,
scopes: [{offset:basecolumn || 0, type:'py'}],
lastStyle: null,
lastToken: null,
lambda: false,
dedent: 0
@@ -316,12 +326,16 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
token: function(stream, state) {
var style = tokenLexer(stream, state);
state.lastToken = style;
state.lastStyle = style;
if (stream.eol() && stream.lambda) {
state.lambda = false;
var current = stream.current();
if (current && style) {
state.lastToken = current;
}
if (stream.eol() && state.lambda) {
state.lambda = false;
}
return style;
},
@@ -333,9 +347,22 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
return state.scopes[0].offset;
},
lineComment: "#"
lineComment: "#",
fold: "indent"
};
return external;
});
CodeMirror.defineMIME("text/x-python", "python");
(function() {
"use strict";
var words = function(str){return str.split(' ');};
CodeMirror.defineMIME("text/x-cython", {
name: "python",
extra_keywords: words("by cdef cimport cpdef ctypedef enum except"+
"extern gil include nogil property public"+
"readonly struct union DEF IF ELIF ELSE")
});
})();