aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/lib
diff options
context:
space:
mode:
authorPushkar Joshi2012-02-24 12:08:49 -0800
committerPushkar Joshi2012-02-24 12:08:49 -0800
commit03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch)
treec51112223ceb9121cd595a60335eb2795215590f /imports/codemirror/lib
parentfcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff)
parent053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff)
downloadninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz
Merge branch 'pentool' into brushtool
Conflicts: imports/codemirror/mode/scheme/scheme.js js/tools/BrushTool.js
Diffstat (limited to 'imports/codemirror/lib')
-rwxr-xr-ximports/codemirror/lib/codemirror.css104
-rwxr-xr-ximports/codemirror/lib/codemirror.js2761
-rwxr-xr-ximports/codemirror/lib/util/dialog.css23
-rwxr-xr-ximports/codemirror/lib/util/dialog.js63
-rwxr-xr-ximports/codemirror/lib/util/foldcode.js66
-rwxr-xr-ximports/codemirror/lib/util/formatting.js291
-rwxr-xr-ximports/codemirror/lib/util/javascript-hint.js83
-rwxr-xr-ximports/codemirror/lib/util/overlay.js51
-rwxr-xr-ximports/codemirror/lib/util/runmode.js27
-rwxr-xr-ximports/codemirror/lib/util/search.js114
-rwxr-xr-ximports/codemirror/lib/util/searchcursor.js117
-rwxr-xr-ximports/codemirror/lib/util/simple-hint.css16
-rwxr-xr-ximports/codemirror/lib/util/simple-hint.js66
13 files changed, 3782 insertions, 0 deletions
</
diff --git a/imports/codemirror/lib/codemirror.css b/imports/codemirror/lib/codemirror.css
new file mode 100755
index 00000000..11614251
--- /dev/null
+++ b/imports/codemirror/lib/codemirror.css
@@ -0,0 +1,104 @@
1.CodeMirror {
2 line-height: 1em;
3 font-family: monospace;
4}
5
6.CodeMirror-scroll {
7 overflow: auto;
8 height: 300px;
9 /* This is needed to prevent an IE[67] bug where the scrolled content
10 is visible outside of the scrolling box. */
11 position: relative;
12}
13
14.CodeMirror-gutter {
15 position: absolute; left: 0; top: 0;
16 z-index: 10;
17 background-color: #f7f7f7;
18 border-right: 1px solid #eee;
19 min-width: 2em;
20 height: 100%;
21}
22.CodeMirror-gutter-text {
23 color: #aaa;
24 text-align: right;
25 padding: .4em .2em .4em .4em;
26 white-space: pre !important;
27}
28.CodeMirror-lines {
29 padding: .4em;
30}
31
32.CodeMirror pre {
33 -moz-border-radius: 0;
34 -webkit-border-radius: 0;
35 -o-border-radius: 0;
36 border-radius: 0;
37 border-width: 0; margin: 0; padding: 0; background: transparent;
38 font-family: inherit;
39 font-size: inherit;
40 padding: 0; margin: 0;
41 white-space: pre;
42 word-wrap: normal;
43}
44
45.CodeMirror-wrap pre {
46 word-wrap: break-word;
47 white-space: pre-wrap;
48}
49.CodeMirror-wrap .CodeMirror-scroll {
50 overflow-x: hidden;
51}
52
53.CodeMirror textarea {
54 outline: none !important;
55}
56
57.CodeMirror pre.CodeMirror-cursor {
58 z-index: 10;
59 position: absolute;
60 visibility: hidden;
61 border-left: 1px solid black;
62}
63.CodeMirror-focused pre.CodeMirror-cursor {
64 visibility: visible;
65}
66
67span.CodeMirror-selected { background: #d9d9d9; }
68.CodeMirror-focused span.CodeMirror-selected { background: #d2dcf8; }
69
70.CodeMirror-searching {background: #ffa;}
71
72/* Default theme */
73
74.cm-s-default span.cm-keyword {color: #708;}
75.cm-s-default span.cm-atom {color: #219;}
76.cm-s-default span.cm-number {color: #164;}
77.cm-s-default span.cm-def {color: #00f;}
78.cm-s-default span.cm-variable {color: black;}
79.cm-s-default span.cm-variable-2 {color: #05a;}
80.cm-s-default span.cm-variable-3 {color: #085;}
81.cm-s-default span.cm-property {color: black;}
82.cm-s-default span.cm-operator {color: black;}
83.cm-s-default span.cm-comment {color: #a50;}
84.cm-s-default span.cm-string {color: #a11;}
85.cm-s-default span.cm-string-2 {color: #f50;}
86.cm-s-default span.cm-meta {color: #555;}
87.cm-s-default span.cm-error {color: #f00;}
88.cm-s-default span.cm-qualifier {color: #555;}
89.cm-s-default span.cm-builtin {color: #30a;}
90.cm-s-default span.cm-bracket {color: #cc7;}
91.cm-s-default span.cm-tag {color: #170;}
92.cm-s-default span.cm-attribute {color: #00c;}
93.cm-s-default span.cm-header {color: #a0a;}
94.cm-s-default span.cm-quote {color: #090;}
95.cm-s-default span.cm-hr {color: #999;}
96.cm-s-default span.cm-link {color: #00c;}
97
98span.cm-header, span.cm-strong {font-weight: bold;}
99span.cm-em {font-style: italic;}
100span.cm-emstrong {font-style: italic; font-weight: bold;}
101span.cm-link {text-decoration: underline;}
102
103div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
104div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
diff --git a/imports/codemirror/lib/codemirror.js b/imports/codemirror/lib/codemirror.js
new file mode 100755
index 00000000..79eb457d
--- /dev/null
+++ b/imports/codemirror/lib/codemirror.js
@@ -0,0 +1,2761 @@
1// CodeMirror version 2.2
2//
3// All functions that need access to the editor's state live inside
4// the CodeMirror function. Below that, at the bottom of the file,
5// some utilities are defined.
6
7// CodeMirror is the only global var we claim
8var CodeMirror = (function() {
9 // This is the function that produces an editor instance. It's
10 // closure is used to store the editor state.
11 function CodeMirror(place, givenOptions) {
12 // Determine effective options based on given values and defaults.
13 var options = {}, defaults = CodeMirror.defaults;
14 for (var opt in defaults)
15 if (defaults.hasOwnProperty(opt))
16 options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
17
18 var targetDocument = options["document"];
19 // The element in which the editor lives.
20 var wrapper = targetDocument.createElement("div");
21 wrapper.className = "CodeMirror" + (options.lineWrapping ? " CodeMirror-wrap" : "");
22 // This mess creates the base DOM structure for the editor.
23 wrapper.innerHTML =
24 '<div style="overflow: hidden; position: relative; width: 3px; height: 0px;">' + // Wraps and hides input textarea
25 '<textarea style="position: absolute; padding: 0; width: 1px;" wrap="off" ' +
26 'autocorrect="off" autocapitalize="off"></textarea></div>' +
27 '<div class="CodeMirror-scroll" tabindex="-1">' +
28 '<div style="position: relative">' + // Set to the height of the text, causes scrolling
29 '<div style="position: relative">' + // Moved around its parent to cover visible view
30 '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
31 // Provides positioning relative to (visible) text origin
32 '<div class="CodeMirror-lines"><div style="position: relative">' +
33 '<div style="position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden"></div>' +
34 '<pre class="CodeMirror-cursor">&#160;</pre>' + // Absolutely positioned blinky cursor
35 '<div></div>' + // This DIV contains the actual code
36 '</div></div></div></div></div>';
37 if (place.appendChild) place.appendChild(wrapper); else place(wrapper);
38 // I've never seen more elegant code in my life.
39 var inputDiv = wrapper.firstChild, input = inputDiv.firstChild,
40 scroller = wrapper.lastChild, code = scroller.firstChild,
41 mover = code.firstChild, gutter = mover.firstChild, gutterText = gutter.firstChild,
42 lineSpace = gutter.nextSibling.firstChild, measure = lineSpace.firstChild,
43 cursor = measure.nextSibling, lineDiv = cursor.nextSibling;
44 themeChanged();
45 // Needed to hide big blue blinking cursor on Mobile Safari
46 if (/AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent)) input.style.width = "0px";
47 if (!webkit) lineSpace.draggable = true;
48 if (options.tabindex != null) input.tabIndex = options.tabindex;
49 if (!options.gutter && !options.lineNumbers) gutter.style.display = "none";
50
51 // Check for problem with IE innerHTML not working when we have a
52 // P (or similar) parent node.
53 try { stringWidth("x"); }
54 catch (e) {
55 if (e.message.match(/runtime/i))
56 e = new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)");
57 throw e;
58 }
59
60 // Delayed object wrap timeouts, making sure only one is active. blinker holds an interval.
61 var poll = new Delayed(), highlight = new Delayed(), blinker;
62
63 // mode holds a mode API object. doc is the tree of Line objects,
64 // work an array of lines that should be parsed, and history the
65 // undo history (instance of History constructor).
66 var mode, doc = new BranchChunk([new LeafChunk([new Line("")])]), work, focused;
67 loadMode();
68 // The selection. These are always maintained to point at valid
69 // positions. Inverted is used to remember that the user is
70 // selecting bottom-to-top.
71 var sel = {from: {line: 0, ch: 0}, to: {line: 0, ch: 0}, inverted: false};
72 // Selection-related flags. shiftSelecting obviously tracks
73 // whether the user is holding shift.
74 var shiftSelecting, lastClick, lastDoubleClick, draggingText, overwrite = false;
75 // Variables used by startOperation/endOperation to track what
76 // happened during the operation.
77 var updateInput, userSelChange, changes, textChanged, selectionChanged, leaveInputAlone,
78 gutterDirty, callbacks;
79 // Current visible range (may be bigger than the view window).
80 var displayOffset = 0, showingFrom = 0, showingTo = 0, lastSizeC = 0;
81 // bracketHighlighted is used to remember that a backet has been
82 // marked.
83 var bracketHighlighted;
84 // Tracks the maximum line length so that the horizontal scrollbar
85 // can be kept static when scrolling.
86 var maxLine = "", maxWidth, tabText = computeTabText();
87
88 // Initialize the content.
89 operation(function(){setValue(options.value || ""); updateInput = false;})();
90 var history = new History();
91
92 // Register our event handlers.
93 connect(scroller, "mousedown", operation(onMouseDown));
94 connect(scroller, "dblclick", operation(onDoubleClick));
95 connect(lineSpace, "dragstart", onDragStart);