Added the 2 missing files. This is probably consequences of codemirror
update.
This commit is contained in:
99
applications/admin/static/codemirror/addon/hint/python-hint.js
vendored
Normal file
99
applications/admin/static/codemirror/addon/hint/python-hint.js
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||
}
|
||||
|
||||
function arrayContains(arr, item) {
|
||||
if (!Array.prototype.indexOf) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return arr.indexOf(item) != -1;
|
||||
}
|
||||
|
||||
function scriptHint(editor, _keywords, getToken) {
|
||||
// Find the token at the cursor
|
||||
var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token;
|
||||
// If it's not a 'word-style' token, ignore the token.
|
||||
|
||||
if (!/^[\w$_]*$/.test(token.string)) {
|
||||
token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||
className: token.string == ":" ? "python-type" : null};
|
||||
}
|
||||
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
|
||||
var completionList = getCompletions(token, context);
|
||||
completionList = completionList.sort();
|
||||
|
||||
return {list: completionList,
|
||||
from: CodeMirror.Pos(cur.line, token.start),
|
||||
to: CodeMirror.Pos(cur.line, token.end)};
|
||||
}
|
||||
|
||||
function pythonHint(editor) {
|
||||
return scriptHint(editor, pythonKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
|
||||
}
|
||||
CodeMirror.registerHelper("hint", "python", pythonHint);
|
||||
|
||||
var pythonKeywords = "and del from not while as elif global or with assert else if pass yield"
|
||||
+ "break except import print class exec in raise continue finally is return def for lambda try";
|
||||
var pythonKeywordsL = pythonKeywords.split(" ");
|
||||
var pythonKeywordsU = pythonKeywords.toUpperCase().split(" ");
|
||||
|
||||
var pythonBuiltins = "abs divmod input open staticmethod all enumerate int ord str "
|
||||
+ "any eval isinstance pow sum basestring execfile issubclass print super"
|
||||
+ "bin file iter property tuple bool filter len range type"
|
||||
+ "bytearray float list raw_input unichr callable format locals reduce unicode"
|
||||
+ "chr frozenset long reload vars classmethod getattr map repr xrange"
|
||||
+ "cmp globals max reversed zip compile hasattr memoryview round __import__"
|
||||
+ "complex hash min set apply delattr help next setattr buffer"
|
||||
+ "dict hex object slice coerce dir id oct sorted intern ";
|
||||
var pythonBuiltinsL = pythonBuiltins.split(" ").join("() ").split(" ");
|
||||
var pythonBuiltinsU = pythonBuiltins.toUpperCase().split(" ").join("() ").split(" ");
|
||||
|
||||
function getCompletions(token, context) {
|
||||
var found = [], start = token.string;
|
||||
function maybeAdd(str) {
|
||||
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
|
||||
}
|
||||
|
||||
function gatherCompletions(_obj) {
|
||||
forEach(pythonBuiltinsL, maybeAdd);
|
||||
forEach(pythonBuiltinsU, maybeAdd);
|
||||
forEach(pythonKeywordsL, maybeAdd);
|
||||
forEach(pythonKeywordsU, maybeAdd);
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// If this is a property, see if it belongs to some object we can
|
||||
// find in the current environment.
|
||||
var obj = context.pop(), base;
|
||||
|
||||
if (obj.type == "variable")
|
||||
base = obj.string;
|
||||
else if(obj.type == "variable-3")
|
||||
base = ":" + obj.string;
|
||||
|
||||
while (base != null && context.length)
|
||||
base = base[context.pop().string];
|
||||
if (base != null) gatherCompletions(base);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
});
|
||||
36
applications/admin/static/codemirror/theme/web2py.css
vendored
Normal file
36
applications/admin/static/codemirror/theme/web2py.css
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
.cm-s-web2py span.cm-meta {color: #FF1717;}
|
||||
.cm-s-web2py span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
|
||||
.cm-s-web2py span.cm-atom {color: #219;}
|
||||
.cm-s-web2py span.cm-number {color: #164;}
|
||||
.cm-s-web2py span.cm-def {color: #00f;}
|
||||
.cm-s-web2py span.cm-variable {color: black;}
|
||||
.cm-s-web2py span.cm-variable-2 {color: #0000C0;}
|
||||
.cm-s-web2py span.cm-variable-3 {color: #0000C0;}
|
||||
.cm-s-web2py span.cm-property {color: black;}
|
||||
.cm-s-web2py span.cm-operator {color: black;}
|
||||
.cm-s-web2py span.cm-comment {color: #3F7F5F;}
|
||||
.cm-s-web2py span.cm-string {color: #2A00FF;}
|
||||
.cm-s-web2py span.cm-string-2 {color: #f50;}
|
||||
.cm-s-web2py span.cm-error {color: #f00;}
|
||||
.cm-s-web2py span.cm-qualifier {color: #555;}
|
||||
.cm-s-web2py span.cm-builtin {color: #30a;}
|
||||
.cm-s-web2py span.cm-bracket {color: #cc7;}
|
||||
.cm-s-web2py span.cm-tag {color: #170;}
|
||||
.cm-s-web2py span.cm-attribute {color: #00c;}
|
||||
.cm-s-web2py span.cm-link {color: #219;}
|
||||
|
||||
.cm-s-web2py .CodeMirror-matchingbracket {
|
||||
border:1px solid grey;
|
||||
color:black !important;;
|
||||
}
|
||||
|
||||
/* Editor styling */
|
||||
|
||||
.cm-s-web2py {
|
||||
line-height: 1.40em;
|
||||
font-family: Monaco, Menlo,"Andale Mono","lucida console","Courier New",monospace !important;
|
||||
background: white;
|
||||
}
|
||||
|
||||
|
||||
.CodeMirror-activeline-background {background: #e8f2ff !important;}
|
||||
Reference in New Issue
Block a user