This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Has reworked DOM for better scrolling of big docs However, this includes changes to how scrolling is handled (So need to work with new DOM instead)
- Loading branch information
Showing
20 changed files
with
933 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright (C) 2012 by Marijn Haverbeke <marijnh@gmail.com> | ||
|
||
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. | ||
|
||
Please note that some subdirectories of the CodeMirror distribution | ||
include their own LICENSE files, and are released under different | ||
licences. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# CodeMirror 2 | ||
|
||
CodeMirror is a JavaScript component that provides a code editor in | ||
the browser. When a mode is available for the language you are coding | ||
in, it will color your code, and optionally help with indentation. | ||
|
||
The project page is http://codemirror.net | ||
The manual is at http://codemirror.net/doc/manual.html |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
.CodeMirror { | ||
line-height: 1em; | ||
font-family: monospace; | ||
|
||
/* Necessary so the scrollbar can be absolutely positioned within the wrapper on Lion. */ | ||
position: relative; | ||
/* This prevents unwanted scrollbars from showing up on the body and wrapper in IE. */ | ||
overflow: hidden; | ||
} | ||
|
||
.CodeMirror-scroll { | ||
overflow-x: auto; | ||
overflow-y: hidden; | ||
height: 300px; | ||
/* This is needed to prevent an IE[67] bug where the scrolled content | ||
is visible outside of the scrolling box. */ | ||
position: relative; | ||
outline: none; | ||
} | ||
|
||
/* Vertical scrollbar */ | ||
.CodeMirror-scrollbar { | ||
float: right; | ||
overflow-x: hidden; | ||
overflow-y: scroll; | ||
|
||
/* This corrects for the 1px gap introduced to the left of the scrollbar | ||
by the rule for .CodeMirror-scrollbar-inner. */ | ||
margin-left: -1px; | ||
} | ||
.CodeMirror-scrollbar-inner { | ||
/* This needs to have a nonzero width in order for the scrollbar to appear | ||
in Firefox and IE9. */ | ||
width: 1px; | ||
} | ||
.CodeMirror-scrollbar.cm-sb-overlap { | ||
/* Ensure that the scrollbar appears in Lion, and that it overlaps the content | ||
rather than sitting to the right of it. */ | ||
position: absolute; | ||
z-index: 1; | ||
float: none; | ||
right: 0; | ||
min-width: 12px; | ||
} | ||
.CodeMirror-scrollbar.cm-sb-nonoverlap { | ||
min-width: 12px; | ||
} | ||
.CodeMirror-scrollbar.cm-sb-ie7 { | ||
min-width: 18px; | ||
} | ||
|
||
.CodeMirror-gutter { | ||
position: absolute; left: 0; top: 0; | ||
z-index: 10; | ||
background-color: #f7f7f7; | ||
border-right: 1px solid #eee; | ||
min-width: 2em; | ||
height: 100%; | ||
} | ||
.CodeMirror-gutter-text { | ||
color: #aaa; | ||
text-align: right; | ||
padding: .4em .2em .4em .4em; | ||
white-space: pre !important; | ||
} | ||
.CodeMirror-lines { | ||
padding: .4em; | ||
white-space: pre; | ||
cursor: text; | ||
} | ||
.CodeMirror-lines * { | ||
/* Necessary for throw-scrolling to decelerate properly on Safari. */ | ||
pointer-events: none; | ||
} | ||
|
||
.CodeMirror pre { | ||
-moz-border-radius: 0; | ||
-webkit-border-radius: 0; | ||
-o-border-radius: 0; | ||
border-radius: 0; | ||
border-width: 0; margin: 0; padding: 0; background: transparent; | ||
font-family: inherit; | ||
font-size: inherit; | ||
padding: 0; margin: 0; | ||
white-space: pre; | ||
word-wrap: normal; | ||
line-height: inherit; | ||
color: inherit; | ||
} | ||
|
||
.CodeMirror-wrap pre { | ||
word-wrap: break-word; | ||
white-space: pre-wrap; | ||
word-break: normal; | ||
} | ||
.CodeMirror-wrap .CodeMirror-scroll { | ||
overflow-x: hidden; | ||
} | ||
|
||
.CodeMirror textarea { | ||
outline: none !important; | ||
} | ||
|
||
.CodeMirror pre.CodeMirror-cursor { | ||
z-index: 10; | ||
position: absolute; | ||
visibility: hidden; | ||
border-left: 1px solid black; | ||
border-right: none; | ||
width: 0; | ||
} | ||
.cm-keymap-fat-cursor pre.CodeMirror-cursor { | ||
width: auto; | ||
border: 0; | ||
background: transparent; | ||
background: rgba(0, 200, 0, .4); | ||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800); | ||
} | ||
/* Kludge to turn off filter in ie9+, which also accepts rgba */ | ||
.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) { | ||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); | ||
} | ||
.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {} | ||
.CodeMirror-focused pre.CodeMirror-cursor { | ||
visibility: visible; | ||
} | ||
|
||
div.CodeMirror-selected { background: #d9d9d9; } | ||
.CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; } | ||
|
||
.CodeMirror-searching { | ||
background: #ffa; | ||
background: rgba(255, 255, 0, .4); | ||
} | ||
|
||
/* Default theme */ | ||
|
||
.cm-s-default span.cm-keyword {color: #708;} | ||
.cm-s-default span.cm-atom {color: #219;} | ||
.cm-s-default span.cm-number {color: #164;} | ||
.cm-s-default span.cm-def {color: #00f;} | ||
.cm-s-default span.cm-variable {color: black;} | ||
.cm-s-default span.cm-variable-2 {color: #05a;} | ||
.cm-s-default span.cm-variable-3 {color: #085;} | ||
.cm-s-default span.cm-property {color: black;} | ||
.cm-s-default span.cm-operator {color: black;} | ||
.cm-s-default span.cm-comment {color: #a50;} | ||
.cm-s-default span.cm-string {color: #a11;} | ||
.cm-s-default span.cm-string-2 {color: #f50;} | ||
.cm-s-default span.cm-meta {color: #555;} | ||
.cm-s-default span.cm-error {color: #f00;} | ||
.cm-s-default span.cm-qualifier {color: #555;} | ||
.cm-s-default span.cm-builtin {color: #30a;} | ||
.cm-s-default span.cm-bracket {color: #cc7;} | ||
.cm-s-default span.cm-tag {color: #170;} | ||
.cm-s-default span.cm-attribute {color: #00c;} | ||
.cm-s-default span.cm-header {color: blue;} | ||
.cm-s-default span.cm-quote {color: #090;} | ||
.cm-s-default span.cm-hr {color: #999;} | ||
.cm-s-default span.cm-link {color: #00c;} | ||
|
||
span.cm-header, span.cm-strong {font-weight: bold;} | ||
span.cm-em {font-style: italic;} | ||
span.cm-emstrong {font-style: italic; font-weight: bold;} | ||
span.cm-link {text-decoration: underline;} | ||
|
||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} | ||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
// the tagRangeFinder function is | ||
// Copyright (C) 2011 by Daniel Glazman <daniel@glazman.org> | ||
// released under the MIT license (../../LICENSE) like the rest of CodeMirror | ||
CodeMirror.tagRangeFinder = function(cm, line, hideEnd) { | ||
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; | ||
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; | ||
var xmlNAMERegExp = new RegExp("^[" + nameStartChar + "][" + nameChar + "]*"); | ||
|
||
var lineText = cm.getLine(line); | ||
var found = false; | ||
var tag = null; | ||
var pos = 0; | ||
while (!found) { | ||
pos = lineText.indexOf("<", pos); | ||
if (-1 == pos) // no tag on line | ||
return; | ||
if (pos + 1 < lineText.length && lineText[pos + 1] == "/") { // closing tag | ||
pos++; | ||
continue; | ||
} | ||
// ok we weem to have a start tag | ||
if (!lineText.substr(pos + 1).match(xmlNAMERegExp)) { // not a tag name... | ||
pos++; | ||
continue; | ||
} | ||
var gtPos = lineText.indexOf(">", pos + 1); | ||
if (-1 == gtPos) { // end of start tag not in line | ||
var l = line + 1; | ||
var foundGt = false; | ||
var lastLine = cm.lineCount(); | ||
while (l < lastLine && !foundGt) { | ||
var lt = cm.getLine(l); | ||
var gt = lt.indexOf(">"); | ||
if (-1 != gt) { // found a > | ||
foundGt = true; | ||
var slash = lt.lastIndexOf("/", gt); | ||
if (-1 != slash && slash < gt) { | ||
var str = lineText.substr(slash, gt - slash + 1); | ||
if (!str.match( /\/\s*\>/ )) { // yep, that's the end of empty tag | ||
if (hideEnd === true) l++; | ||
return l; | ||
} | ||
} | ||
} | ||
l++; | ||
} | ||
found = true; | ||
} | ||
else { | ||
var slashPos = lineText.lastIndexOf("/", gtPos); | ||
if (-1 == slashPos) { // cannot be empty tag | ||
found = true; | ||
// don't continue | ||
} | ||
else { // empty tag? | ||
// check if really empty tag | ||
var str = lineText.substr(slashPos, gtPos - slashPos + 1); | ||
if (!str.match( /\/\s*\>/ )) { // finally not empty | ||
found = true; | ||
// don't continue | ||
} | ||
} | ||
} | ||
if (found) { | ||
var subLine = lineText.substr(pos + 1); | ||
tag = subLine.match(xmlNAMERegExp); | ||
if (tag) { | ||
// we have an element name, wooohooo ! | ||
tag = tag[0]; | ||
// do we have the close tag on same line ??? | ||
if (-1 != lineText.indexOf("</" + tag + ">", pos)) // yep | ||
{ | ||
found = false; | ||
} | ||
// we don't, so we have a candidate... | ||
} | ||
else | ||
found = false; | ||
} | ||
if (!found) | ||
pos++; | ||
} | ||
|
||
if (found) { | ||
var startTag = "(\\<\\/" + tag + "\\>)|(\\<" + tag + "\\>)|(\\<" + tag + "\\s)|(\\<" + tag + "$)"; | ||
var startTagRegExp = new RegExp(startTag, "g"); | ||
var endTag = "</" + tag + ">"; | ||
var depth = 1; | ||
var l = line + 1; | ||
var lastLine = cm.lineCount(); | ||
while (l < lastLine) { | ||
lineText = cm.getLine(l); | ||
var match = lineText.match(startTagRegExp); | ||
if (match) { | ||
for (var i = 0; i < match.length; i++) { | ||
if (match[i] == endTag) | ||
depth--; | ||
else | ||
depth++; | ||
if (!depth) { | ||
if (hideEnd === true) l++; | ||
return l; | ||
} | ||
} | ||
} | ||
l++; | ||
} | ||
return; | ||
} | ||
}; | ||
|
||
CodeMirror.braceRangeFinder = function(cm, line, hideEnd) { | ||
var lineText = cm.getLine(line), at = lineText.length, startChar, tokenType; | ||
for (;;) { | ||
var found = lineText.lastIndexOf("{", at); | ||
if (found < 0) break; | ||
tokenType = cm.getTokenAt({line: line, ch: found}).className; | ||
if (!/^(comment|string)/.test(tokenType)) { startChar = found; break; } | ||
at = found - 1; | ||
} | ||
if (startChar == null || lineText.lastIndexOf("}") > startChar) return; | ||
var count = 1, lastLine = cm.lineCount(), end; | ||
outer: for (var i = line + 1; i < lastLine; ++i) { | ||
var text = cm.getLine(i), pos = 0; | ||
for (;;) { | ||
var nextOpen = text.indexOf("{", pos), nextClose = text.indexOf("}", pos); | ||
if (nextOpen < 0) nextOpen = text.length; | ||
if (nextClose < 0) nextClose = text.length; | ||
pos = Math.min(nextOpen, nextClose); | ||
if (pos == text.length) break; | ||
if (cm.getTokenAt({line: i, ch: pos + 1}).className == tokenType) { | ||
if (pos == nextOpen) ++count; | ||
else if (!--count) { end = i; break outer; } | ||
} | ||
++pos; | ||
} | ||
} | ||
if (end == null || end == line + 1) return; | ||
if (hideEnd === true) end++; | ||
return end; | ||
}; | ||
|
||
CodeMirror.indentRangeFinder = function(cm, line) { | ||
var tabSize = cm.getOption("tabSize"); | ||
var myIndent = cm.getLineHandle(line).indentation(tabSize), last; | ||
for (var i = line + 1, end = cm.lineCount(); i < end; ++i) { | ||
var handle = cm.getLineHandle(i); | ||
if (!/^\s*$/.test(handle.text)) { | ||
if (handle.indentation(tabSize) <= myIndent) break; | ||
last = i; | ||
} | ||
} | ||
if (!last) return null; | ||
return last + 1; | ||
}; | ||
|
||
CodeMirror.newFoldFunction = function(rangeFinder, markText, hideEnd) { | ||
var folded = []; | ||
if (markText == null) markText = '<div style="position: absolute; left: 2px; color:#600">▼</div>%N%'; | ||
|
||
function isFolded(cm, n) { | ||
for (var i = 0; i < folded.length; ++i) { | ||
var start = cm.lineInfo(folded[i].start); | ||
if (!start) folded.splice(i--, 1); | ||
else if (start.line == n) return {pos: i, region: folded[i]}; | ||
} | ||
} | ||
|
||
function expand(cm, region) { | ||
cm.clearMarker(region.start); | ||
for (var i = 0; i < region.hidden.length; ++i) | ||
cm.showLine(region.hidden[i]); | ||
} | ||
|
||
return function(cm, line) { | ||
cm.operation(function() { | ||
var known = isFolded(cm, line); | ||
if (known) { | ||
folded.splice(known.pos, 1); | ||
expand(cm, known.region); | ||
} else { | ||
var end = rangeFinder(cm, line, hideEnd); | ||
if (end == null) return; | ||
var hidden = []; | ||
for (var i = line + 1; i < end; ++i) { | ||
var handle = cm.hideLine(i); | ||
if (handle) hidden.push(handle); | ||
} | ||
var first = cm.setMarker(line, markText); | ||
var region = {start: first, hidden: hidden}; | ||
cm.onDeleteLine(first, function() { expand(cm, region); }); | ||
folded.push(region); | ||
} | ||
}); | ||
}; | ||
}; |
Oops, something went wrong.