aboutsummaryrefslogtreecommitdiff
path: root/js/code-editor/codemirror-ninja
diff options
context:
space:
mode:
Diffstat (limited to 'js/code-editor/codemirror-ninja')
-rw-r--r--js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js78
-rw-r--r--js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css45
-rw-r--r--js/code-editor/codemirror-ninja/theme/rubyblue-ninja.css22
3 files changed, 145 insertions, 0 deletions
diff --git a/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
new file mode 100644
index 00000000..866e1a8b
--- /dev/null
+++ b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
@@ -0,0 +1,78 @@
1(function() {
2 CodeMirror.simpleHint = function(editor, getHints) {
3 // We want a single cursor position.
4 if (editor.somethingSelected()) return;
5
6 // Ninja override: don't show code hinting if the token is empty
7 var tempToken = editor.getTokenAt(editor.getCursor());
8 if(tempToken && ((tempToken.string === "") || !(/[\S]/gi.test(tempToken.string)))) return;//check that token has only spaces
9
10
11 var result = getHints(editor);
12 if (!result || !result.list.length) return;
13 var completions = result.list;
14 function insert(str) {
15 editor.replaceRange(str, result.from, result.to);
16 }
17 // Ninja override: don't autocomplete to reduce user's typing errors
18// if (completions.length == 1) {insert(completions[0]); return true;}
19
20 // Build the select widget
21 var complete = document.createElement("div");
22 complete.className = "CodeMirror-completions";
23 var sel = complete.appendChild(document.createElement("select"));
24 // Opera doesn't move the selection when pressing up/down in a
25 // multi-select, but it does properly support the size property on
26 // single-selects, so no multi-select is necessary.
27 if (!window.opera) sel.multiple = true;
28 for (var i = 0; i < completions.length; ++i) {
29 var opt = sel.appendChild(document.createElement("option"));
30 opt.appendChild(document.createTextNode(completions[i]));
31 }
32 sel.firstChild.selected = true;
33 sel.size = Math.min(10, completions.length);
34 var pos = editor.cursorCoords();
35 complete.style.left = pos.x + "px";
36 complete.style.top = pos.yBot + "px";
37 document.body.appendChild(complete);
38 // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
39 var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
40 if(winW - pos.x < sel.clientWidth)
41 complete.style.left = (pos.x - sel.clientWidth) + "px";
42 // Hack to hide the scrollbar.
43 if (completions.length <= 10)
44 complete.style.width = (sel.clientWidth - 1) + "px";
45
46 var done = false;
47 function close() {
48 if (done) return;
49 done = true;
50 complete.parentNode.removeChild(complete);
51 }
52 function pick() {
53 insert(completions[sel.selectedIndex]);
54 close();
55 setTimeout(function(){editor.focus();}, 50);
56 }
57 CodeMirror.connect(sel, "blur", close);
58 CodeMirror.connect(sel, "keydown", function(event) {
59 var code = event.keyCode;
60 // Enter
61 if (code == 13) {CodeMirror.e_stop(event); pick();}
62 // Escape
63 else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
64 else if (code != 38 && code != 40) {
65 close(); editor.focus();
66 // Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
67 editor.triggerOnKeyDown(event);
68 setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50);
69 }
70 });
71 CodeMirror.connect(sel, "dblclick", pick);
72
73 sel.focus();
74 // Opera sometimes ignores focusing a freshly created node
75 if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
76 return true;
77 };
78})();
diff --git a/js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css b/js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
new file mode 100644
index 00000000..fa7e8e07
--- /dev/null
+++ b/js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
@@ -0,0 +1,45 @@
1/*
2http://lesscss.org/ dark theme
3Ported to CodeMirror by Peter Kroon
4*/
5.CodeMirror{
6 line-height: 15px;
7}
8.cm-s-lesser-dark {
9 font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', 'Monaco', Courier, monospace !important;
10 /*font-size:12px;*/
11}
12
13.cm-s-lesser-dark { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; }
14.cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/
15.cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
16.cm-s-lesser-dark .CodeMirror-lines { margin-left:3px; margin-right:3px; }/*editable code holder*/
17
18div.CodeMirror span.CodeMirror-matchingbracket { color: #7EFC7E; }/*65FC65*/
19
20.cm-s-lesser-dark .CodeMirror-gutter { background: #262626; border-right:1px solid #aaa; padding-right:3px; min-width:2.5em; }
21.cm-s-lesser-dark .CodeMirror-gutter-text { color: #777; }
22
23.cm-s-lesser-dark span.cm-keyword { color: #599eff; }
24.cm-s-lesser-dark span.cm-atom { color: #C2B470; }
25.cm-s-lesser-dark span.cm-number { color: #B35E4D; }
26.cm-s-lesser-dark span.cm-def {color: color: white;}
27.cm-s-lesser-dark span.cm-variable { color:#D9BF8C; }
28.cm-s-lesser-dark span.cm-variable-2 { color: #669199; }
29.cm-s-lesser-dark span.cm-variable-3 { color: white; }
30.cm-s-lesser-dark span.cm-property {color: #92A75C;}
31.cm-s-lesser-dark span.cm-operator {color: #92A75C;}
32.cm-s-lesser-dark span.cm-comment { color: #666; }
33.cm-s-lesser-dark span.cm-string { color: #BCD279; }
34.cm-s-lesser-dark span.cm-string-2 {color: #f50;}
35.cm-s-lesser-dark span.cm-meta { color: #738C73; }
36.cm-s-lesser-dark span.cm-error { color: #9d1e15; }
37.cm-s-lesser-dark span.cm-qualifier {color: #555;}
38.cm-s-lesser-dark span.cm-builtin { color: #ff9e59; }
39.cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; }
40.cm-s-lesser-dark span.cm-tag { color: #669199; }
41.cm-s-lesser-dark span.cm-attribute {color: #00c;}
42.cm-s-lesser-dark span.cm-header {color: #a0a;}
43.cm-s-lesser-dark span.cm-quote {color: #090;}
44.cm-s-lesser-dark span.cm-hr {color: #999;}
45.cm-s-lesser-dark span.cm-link {color: #00c;}
diff --git a/js/code-editor/codemirror-ninja/theme/rubyblue-ninja.css b/js/code-editor/codemirror-ninja/theme/rubyblue-ninja.css
new file mode 100644
index 00000000..b09e4e3e
--- /dev/null
+++ b/js/code-editor/codemirror-ninja/theme/rubyblue-ninja.css
@@ -0,0 +1,22 @@
1.cm-s-rubyblue {
2 font:Trebuchet, Verdana, sans-serif; } /* - customized editor font - */
3
4.cm-s-rubyblue { background: #112435; color: white; }
5.cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; }
6.cm-s-rubyblue .CodeMirror-gutter { background: #1F4661; border-right: 7px solid #3E7087; min-width:2.5em; }
7.cm-s-rubyblue .CodeMirror-gutter-text { color: white; }
8.cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
9
10.cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
11.cm-s-rubyblue span.cm-atom { color: #F4C20B; }
12.cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; }
13.cm-s-rubyblue span.cm-keyword { color: #F0F; }
14.cm-s-rubyblue span.cm-string { color: #F08047; }
15.cm-s-rubyblue span.cm-meta { color: #F0F; }
16.cm-s-rubyblue span.cm-variable-2, .cm-s-rubyblue span.cm-tag { color: #7BD827; }
17.cm-s-rubyblue span.cm-variable-3, .cm-s-rubyblue span.cm-def { color: white; }
18.cm-s-rubyblue span.cm-error { color: #AF2018; }
19.cm-s-rubyblue span.cm-bracket { color: #F0F; }
20.cm-s-rubyblue span.cm-link { color: #F4C20B; }
21.cm-s-rubyblue span.CodeMirror-matchingbracket { color:#F0F !important; }
22.cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }