diff --git a/advanced-options.html b/advanced-options.html index 977d653..6eb745b 100644 --- a/advanced-options.html +++ b/advanced-options.html @@ -1,5 +1,6 @@ +

diff --git a/codemirror-base.js b/codemirror-base.js deleted file mode 100644 index 9a426d2..0000000 --- a/codemirror-base.js +++ /dev/null @@ -1,89 +0,0 @@ -function method(g,m){return function(){g[m].apply(g,arguments)}}var StopIteration={toString:function(){return"StopIteration"}};function forEach(g,m){if(g.next)try{for(;;)m(g.next())}catch(k){if(k!=StopIteration)throw k;}else for(var l=0;l0)throw"End of stringstream reached without emptying buffer ('"+p+"').";else throw StopIteration;return k.charAt(l++)},get:function(){var o=p;p="";if(l>0){o+=k.slice(0,l);k=k.slice(l);l=0}return o},push:function(o){k=k.slice(0, -l)+o+k.slice(l)},lookAhead:function(o,q,a,c){function f(j){return c?j.toLowerCase():j}o=f(o);var b=false,d=p,e=l;for(a&&this.nextWhileMatches(/[\s\u00a0]/);;){a=l+o.length;var h=k.length-l;if(a<=k.length){b=o==f(k.slice(l,a));l=a;break}else if(o.slice(0,h)==f(k.slice(l))){p+=k;k="";try{k=g.next()}catch(i){if(i!=StopIteration)throw i;break}l=0;o=o.slice(h)}else break}if(!(b&&q)){k=p.slice(d.length)+k;l=e;p=d}return b},lookAheadRegex:function(o,q){if(o.source.charAt(0)!="^")throw Error("Regexps passed to lookAheadRegex must start with ^"); -for(;k.indexOf("\n",l)==-1;)try{k+=g.next()}catch(a){if(a!=StopIteration)throw a;break}var c=k.slice(l).match(o);if(c&&q)l+=c[0].length;return c},more:function(){return this.peek()!==null},applies:function(o){var q=this.peek();return q!==null&&o(q)},nextWhile:function(o){for(var q;(q=this.peek())!==null&&o(q);)this.next()},matches:function(o){var q=this.peek();return q!==null&&o.test(q)},nextWhileMatches:function(o){for(var q;(q=this.peek())!==null&&o.test(q);)this.next()},equals:function(o){return o=== -this.peek()},endOfLine:function(){var o=this.peek();return o==null||o=="\n"}}};var select={}; -(function(){function g(b,d){for(;b&&b.parentNode!=d;)b=b.parentNode;return b}function m(b,d){for(;!b.previousSibling&&b.parentNode!=d;)b=b.parentNode;return g(b.previousSibling,d)}function k(b){var d=b.nextSibling;if(d){for(;d.firstChild;)d=d.firstChild;return d.nodeType==3||isBR(d)?d:k(d)}else{for(b=b.parentNode;b&&!b.nextSibling;)b=b.parentNode;return b&&k(b)}}select.ie_selection=document.selection&&document.selection.createRangeCollection;select.scrollToNode=function(b,d){if(b){for(var e=b,h=document.body, -i=document.documentElement,j=!e.nextSibling||!e.nextSibling.nextSibling||!e.nextSibling.nextSibling.nextSibling,n=0;e&&!e.offsetTop;){n++;e=e.previousSibling}if(n==0)j=false;if(!(webkit&&e&&e.offsetTop==5&&e.offsetLeft==5)){n=n*(e?e.offsetHeight:0);var t=0,u=b?b.offsetWidth:0;for(e=e;e&&e.offsetParent;){n+=e.offsetTop;isBR(e)||(t+=e.offsetLeft);e=e.offsetParent}e=h.scrollLeft||i.scrollLeft||0;h=h.scrollTop||i.scrollTop||0;var r=false,w=window.innerWidth||i.clientWidth||0;if(d||uw){e=t;r=true}}t=n-h;if(t<0||j||t>(window.innerHeight||i.clientHeight||0)-50){h=j?1E6:n;r=true}r&&window.scrollTo(e,h)}}};select.scrollToCursor=function(b){select.scrollToNode(select.selectionTopNode(b,true)||b.firstChild,true)};var l=null;select.snapshotChanged=function(){if(l)l.changed=true};select.snapshotReplaceNode=function(b,d,e,h){function i(j){if(b==j.node){l.changed=true;if(e&&j.offset>e)j.offset-=e;else{j.node=d;j.offset+=h||0}}else if(select.ie_selection&& -j.offset==0&&j.node==k(b))l.changed=true}if(l){i(l.start);i(l.end)}};select.snapshotMove=function(b,d,e,h,i){function j(n){if(b==n.node&&(!i||n.offset==0)){l.changed=true;n.node=d;n.offset=h?Math.max(0,n.offset+e):e}}if(l){j(l.start);j(l.end)}};if(select.ie_selection){var p=function(){var b=document.selection;return b&&(b.createRange||b.createTextRange)()},o=function(b){function d(u){for(var r=null;!r&&u;){r=u.nextSibling;u=u.parentNode}return e(r)}function e(u){for(;u&&u.firstChild;)u=u.firstChild; -return{node:u,offset:0}}var h=p();h.collapse(b);b=h.parentElement();if(!isAncestor(document.body,b))return null;if(!b.firstChild)return e(b);var i=h.duplicate();i.moveToElementText(b);i.collapse(true);for(var j=b.firstChild;j;j=j.nextSibling){if(j.nodeType==3){var n=j.nodeValue.length;i.move("character",n)}else{i.moveToElementText(j);i.collapse(false)}var t=h.compareEndPoints("StartToStart",i);if(t==0)return d(j);if(t!=1){if(j.nodeType!=3)return e(j);i.setEndPoint("StartToEnd",h);return{node:j,offset:n- -i.text.length}}}return d(b)};select.markSelection=function(){l=null;if(document.selection){var b=o(true),d=o(false);if(b&&d)l={start:b,end:d,changed:false}}};select.selectMarked=function(){function b(h){var i=document.body.createTextRange(),j=h.node;if(j)if(j.nodeType==3){i.moveToElementText(j.parentNode);for(h=h.offset;j.previousSibling;){j=j.previousSibling;h+=(j.innerText||"").length}i.move("character",h)}else{i.moveToElementText(j);i.collapse(true)}else{i.moveToElementText(document.body);i.collapse(false)}return i} -if(l&&l.changed){var d=b(l.start),e=b(l.end);d.setEndPoint("StartToEnd",e);d.select()}};select.offsetInNode=function(b){var d=p();if(!d)return 0;var e=d.duplicate();try{e.moveToElementText(b)}catch(h){return 0}d.setEndPoint("StartToStart",e);return d.text.length};select.selectionTopNode=function(b,d){function e(r,w){if(w.nodeType==3){for(var x=0,s=w.previousSibling;s&&s.nodeType==3;){x+=s.nodeValue.length;s=s.previousSibling}if(s){try{r.moveToElementText(s)}catch(v){return false}r.collapse(false)}else r.moveToElementText(w.parentNode); -x&&r.move("character",x)}else try{r.moveToElementText(w)}catch(y){return false}return true}var h=p();if(!h)return false;var i=h.duplicate();h.collapse(d);var j=h.parentElement();if(j&&isAncestor(b,j)){i.moveToElementText(j);if(h.compareEndPoints("StartToStart",i)==1)return g(j,b)}d=0;for(j=b.childNodes.length-1;d")};select.insertTabAtCursor=function(){q("\u00a0\u00a0\u00a0\u00a0")};select.cursorPos=function(b,d){var e=p();if(!e)return null;for(var h= -select.selectionTopNode(b,d);h&&!isBR(h);)h=h.previousSibling;var i=e.duplicate();e.collapse(d);if(h){i.moveToElementText(h);i.collapse(false)}else{try{i.moveToElementText(b)}catch(j){return null}i.collapse(true)}e.setEndPoint("StartToStart",i);return{node:h,offset:e.text.length}};select.setCursorPos=function(b,d,e){function h(j){var n=document.body.createTextRange();if(j.node){n.moveToElementText(j.node);n.collapse(false)}else{n.moveToElementText(b);n.collapse(true)}n.move("character",j.offset); -return n}var i=h(d);e&&e!=d&&i.setEndPoint("EndToEnd",h(e));i.select()};select.getBookmark=function(b){var d=select.cursorPos(b,true);b=select.cursorPos(b,false);if(d&&b)return{from:d,to:b}};select.setBookmark=function(b,d){d&&select.setCursorPos(b,d.from,d.to)}}else{var a=function(b,d){for(;b.nodeType!=3&&!isBR(b);){var e=b.childNodes[d]||b.nextSibling;for(d=0;!e&&b.parentNode;){b=b.parentNode;e=b.nextSibling}b=e;if(!e)break}return{node:b,offset:d}};select.markSelection=function(){var b=window.getSelection(); -if(!b||b.rangeCount==0)return l=null;b=b.getRangeAt(0);l={start:a(b.startContainer,b.startOffset),end:a(b.endContainer,b.endOffset),changed:false}};select.selectMarked=function(){function b(){if(e.start.node==e.end.node&&e.start.offset==e.end.offset){var i=window.getSelection();if(!i||i.rangeCount==0)return true;i=i.getRangeAt(0);i=a(i.startContainer,i.startOffset);return e.start.node!=i.node||e.start.offset!=i.offset}}function d(i,j){if(i.node)i.offset==0?h["set"+j+"Before"](i.node):h["set"+j](i.node, -i.offset);else h.setStartAfter(document.body.lastChild||document.body)}var e=l;if(e&&(e.changed||webkit&&b())){var h=document.createRange();d(e.end,"End");d(e.start,"Start");c(h)}};var c=function(b){var d=window.getSelection();if(d){d.removeAllRanges();d.addRange(b)}},f=function(){var b=window.getSelection();return!b||b.rangeCount==0?false:b.getRangeAt(0)};select.selectionTopNode=function(b,d){var e=f();if(!e)return false;var h=d?e.startContainer:e.endContainer,i=d?e.startOffset:e.endOffset;window.opera&& -!d&&e.endContainer==b&&e.endOffset==e.startOffset+1&&b.childNodes[e.startOffset]&&isBR(b.childNodes[e.startOffset])&&i--;return h.nodeType==3?i>0?g(h,b):m(h,b):h.nodeName.toUpperCase()=="HTML"?i==1?null:b.lastChild:h==b?i==0?null:h.childNodes[i-1]:i==h.childNodes.length?g(h,b):i==0?m(h,b):g(h.childNodes[i-1],b)};select.focusAfterNode=function(b,d){var e=document.createRange();e.setStartBefore(d.firstChild||d);if(b&&!b.firstChild)e.setEndAfter(b);else b?e.setEnd(b,b.childNodes.length):e.setEndBefore(d.firstChild|| -d);e.collapse(false);c(e)};select.somethingSelected=function(){var b=f();return b&&!b.collapsed};select.offsetInNode=function(b){var d=f();if(!d)return 0;d=d.cloneRange();d.setStartBefore(b);return d.toString().length};select.insertNodeAtCursor=function(b){var d=f();if(d){d.deleteContents();d.insertNode(b);webkitLastLineHack(document.body);if(window.opera&&isBR(b)&&isSpan(b.parentNode)){d=b.nextSibling;var e=b.parentNode,h=e.parentNode;h.insertBefore(b,e.nextSibling);for(e="";d&&d.nodeType==3;d=d.nextSibling){e+= -d.nodeValue;removeElement(d)}h.insertBefore(makePartSpan(e,document),b.nextSibling)}d=document.createRange();d.selectNode(b);d.collapse(false);c(d)}};select.insertNewlineAtCursor=function(){select.insertNodeAtCursor(document.createElement("BR"))};select.insertTabAtCursor=function(){select.insertNodeAtCursor(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"))};select.cursorPos=function(b,d){var e=f();if(e){for(var h=select.selectionTopNode(b,d);h&&!isBR(h);)h=h.previousSibling;e=e.cloneRange();e.collapse(d); -h?e.setStartAfter(h):e.setStartBefore(b);e=e.toString();return{node:h,offset:e.length}}};select.setCursorPos=function(b,d,e){function h(j,n,t){function u(s){s.nodeType==3?r.push(s):forEach(s.childNodes,u)}if(n==0&&j&&!j.nextSibling){i["set"+t+"After"](j);return true}if(j=j?j.nextSibling:b.firstChild){if(n==0){i["set"+t+"Before"](j);return true}for(var r=[];;){for(;j&&!r.length;){u(j);j=j.nextSibling}var w=r.shift();if(!w)return false;var x=w.nodeValue.length;if(x>=n){i["set"+t](w,n);return true}n-= -x}}}var i=document.createRange();e=e||d;h(e.node,e.offset,"End")&&h(d.node,d.offset,"Start")&&c(i)}}})();function UndoHistory(g,m,k,l){this.container=g;this.maxDepth=m;this.commitDelay=k;this.editor=l;this.parent=l.parent;this.last=this.first=g={text:"",from:null,to:null};this.firstTouched=false;this.history=[];this.redoHistory=[];this.touched=[]} -UndoHistory.prototype={scheduleCommit:function(){var g=this;this.parent.clearTimeout(this.commitTimeout);this.commitTimeout=this.parent.setTimeout(function(){g.tryCommit()},this.commitDelay)},touch:function(g){this.setTouched(g);this.scheduleCommit()},undo:function(){this.commit();if(this.history.length){var g=this.history.pop();this.redoHistory.push(this.updateTo(g,"applyChain"));this.notifyEnvironment();return this.chainNode(g)}},redo:function(){this.commit();if(this.redoHistory.length){var g=this.redoHistory.pop(); -this.addUndoLevel(this.updateTo(g,"applyChain"));this.notifyEnvironment();return this.chainNode(g)}},clear:function(){this.history=[];this.redoHistory=[]},historySize:function(){return{undo:this.history.length,redo:this.redoHistory.length}},push:function(g,m,k){for(var l=[],p=0;pthis.maxDepth&&this.history.shift()},touchedChains:function(){function g(a,c){if(a)a.historyTemp=c;else p=c}function m(a){for(var c=[],f=a?a.nextSibling:l.container.firstChild;f&&(!isBR(f)||f.hackBR);f=f.nextSibling)!f.hackBR&&f.currentText&&c.push(f.currentText);return{from:a,to:f,text:cleanText(c.join(""))}}function k(a,c){for(var f=c+"Sibling",b=a[f];b&&!isBR(b);)b=b[f];return b}var l=this,p=null,o=[];l.firstTouched&&l.touched.push(null);forEach(l.touched,function(a){if(!(a&& -(a.parentNode!=l.container||a.hackBR))){if(a)a.historyTouched=false;else l.firstTouched=false;var c=m(a),f=l.after(a);if(!f||f.text!=c.text||f.to!=c.to){o.push(c);g(a,c)}}});var q=[];l.touched=[];forEach(o,function(a){if(a.from?a.from.historyTemp:p){for(var c=[],f=a.from,b=true;;){var d=f?f.historyTemp:p;if(!d)if(b)break;else d=m(f);c.unshift(d);g(f,null);if(!f)break;b=l.after(f);f=k(f,"previous")}f=a.to;for(b=l.before(a.from);;){if(!f)break;d=f?f.historyTemp:p;if(!d)if(b)break;else d=m(f);c.push(d); -g(f,null);b=l.before(f);f=k(f,"next")}q.push(c)}});return q},shadowChain:function(g){var m=[],k=this.after(g[0].from);for(g=g[g.length-1].to;;){m.push(k);k=k.to;if(!k||k==g)break;else k=k.historyAfter||this.before(g)}return m},applyChain:function(g){var m=select.cursorPos(this.container,false),k=this,l=g[0].from,p=g[g.length-1].to;(function(b,d){for(var e=b?b.nextSibling:k.container.firstChild;e!=d;){var h=e.nextSibling;removeElement(e);e=h}})(l,p);for(var o=0;o0&&k.container.insertBefore(q.from, -p);var a=makePartSpan(fixSpaces(q.text));k.container.insertBefore(a,p);if(m&&m.node==q.from){a=0;var c=this.after(q.from);if(c&&o==g.length-1){for(var f=0;ff)a=q.text.length-c.text.length}select.setCursorPos(this.container,{node:q.from,offset:Math.max(0,m.offset+a)})}else m&&o==g.length-1&&m.node&&m.node.parentNode!=this.container&&select.setCursorPos(this.container,{node:q.from,offset:q.text.length})}this.linkChain(g);return l}};var internetExplorer=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent),webkit=/AppleWebKit/.test(navigator.userAgent),safari=/Apple Computer, Inc/.test(navigator.vendor),gecko=navigator.userAgent.match(/gecko\/(\d{8})/i);if(gecko)gecko=Number(gecko[1]);var mac=/Mac/.test(navigator.platform),brokenOpera=window.opera&&/Version\/10.[56]/.test(navigator.userAgent),slowWebkit=/AppleWebKit\/533/.test(navigator.userAgent); -function makeWhiteSpace(g){for(var m=[],k=true;g>0;g--){m.push(k||g==1?nbsp:" ");k^=true}return m.join("")}function fixSpaces(g){if(g.charAt(0)==" ")g=nbsp+g.slice(1);return g.replace(/\t/g,function(){return makeWhiteSpace(indentUnit)}).replace(/[ \u00a0]{2,}/g,function(m){return makeWhiteSpace(m.length)})}function cleanText(g){return g.replace(/\u00a0/g," ").replace(/\u200b/g,"")} -function makePartSpan(g){var m=g;if(g.nodeType==3)m=g.nodeValue;else g=document.createTextNode(m);var k=document.createElement("span");k.isPart=true;k.appendChild(g);k.currentText=m;return k}function alwaysZero(){return 0}var webkitLastLineHack=webkit?function(g){var m=g.lastChild;if(!m||!m.hackBR){m=document.createElement("br");m.hackBR=true;g.appendChild(m)}}:function(){}; -function asEditorLines(g){var m=makeWhiteSpace(indentUnit);return map(g.replace(/\t/g,m).replace(/\u00a0/g," ").replace(/\r\n?/g,"\n").split("\n"),fixSpaces)} -var Editor=function(){function g(a,c){function f(e,h){if(e.nodeType==3){if((e.nodeValue=fixSpaces(e.nodeValue.replace(/[\r\u200b]/g,"").replace(/\n/g," "))).length)d=false;b.push(e)}else if(isBR(e)&&e.childNodes.length==0){d=true;b.push(e)}else{for(var i=e.firstChild;i;i=i.nextSibling)f(i);if(!d&&q.hasOwnProperty(e.nodeName.toUpperCase())){d=true;if(!c||!h)b.push(document.createElement("br"))}}}var b=[],d=true;f(a,true);return b}function m(a){function c(e){var h=e.parentNode,i=e.nextSibling;return function(j){h.insertBefore(j, -i)}}var f=[],b=null,d=true;return{next:function(){if(!a)throw StopIteration;var e=a;a=e.nextSibling;var h;if(e.isPart&&e.childNodes.length==1&&e.firstChild.nodeType==3){h=e.firstChild.nodeValue;e.dirty=e.dirty||h!=e.currentText;e.currentText=h;h=!/[\n\t\r]/.test(e.currentText)}else h=false;if(h){f.push(e);d=false;return e.currentText}else if(isBR(e)){d&&window.opera&&e.parentNode.insertBefore(makePartSpan(""),e);f.push(e);d=true;return"\n"}else{h=!e.nextSibling;b=c(e);removeElement(e);e=g(e,h);for(h= -0;h=u&&(r=t.lastIndexOf(c,n-u))!=-1:(r=t.indexOf(c,n))!=-1)return{from:{node:j,offset:r},to:{node:j,offset:r+u}}}:function(i,j,n){var t=i?h.length-1:0,u=h[t],r=d(j),w=i?r.indexOf(u)+u.length:r.lastIndexOf(u);if(!(i?w>=n||w!=u.length:w<=n||w!=r.length-u.length))for(n=j;;){if(i&&!n)break;n=i?this.history.nodeBefore(n):this.history.nodeAfter(n);if(!i&&!n)break;r=d(n);u=h[i?--t:++t];if(t>0&&tc){b=d.nextSibling;f=e.slice(0,c)+f+e.slice(c);removeElement(d);break}c-=e.length}c=asEditorLines(f);for(f=0;f0&&this.container.insertBefore(document.createElement("BR"), -b);this.container.insertBefore(makePartSpan(c[f]),b)}this.addDirtyNode(a);this.scheduleHighlight()},selectedText:function(){var a=this.history;a.commit();var c=select.cursorPos(this.container,true),f=select.cursorPos(this.container,false);if(!c||!f)return"";if(c.node==f.node)return a.textAfter(c.node).slice(c.offset,f.offset);var b=[a.textAfter(c.node).slice(c.offset)];for(c=a.nodeAfter(c.node);c!=f.node;c=a.nodeAfter(c))b.push(a.textAfter(c));b.push(a.textAfter(f.node).slice(0,f.offset));return cleanText(b.join("\n"))}, -replaceSelection:function(a){this.history.commit();var c=select.cursorPos(this.container,true),f=select.cursorPos(this.container,false);if(c&&f){f=this.replaceRange(c,f,a);select.setCursorPos(this.container,f);webkitLastLineHack(this.container)}},cursorCoords:function(a,c){function f(j,n){var t=-(document.body.scrollTop||document.documentElement.scrollTop||0),u=-(document.body.scrollLeft||document.documentElement.scrollLeft||0)+n;forEach([j,c?null:window.frameElement],function(r){for(;r;){u+=r.offsetLeft; -t+=r.offsetTop;r=r.offsetParent}});return{x:u,y:t,yBot:t+j.offsetHeight}}function b(j,n){var t=document.createElement("SPAN");t.appendChild(document.createTextNode(j));try{return n(t)}finally{t.parentNode&&t.parentNode.removeChild(t)}}var d=select.cursorPos(this.container,a);if(!d)return null;for(var e=d.offset,h=d.node,i=this;e;){h=h?h.nextSibling:this.container.firstChild;d=nodeText(h);if(e=20101026)){this.capturingPaste=true;var a=window.frameElement.CodeMirror.textareaHack,c=this.cursorCoords(true, -true);a.style.top=c.y+"px";if(internetExplorer)if(c=select.getBookmark(this.container))this.selectionSnapshot=c;parent.focus();a.value="";a.focus();var f=this;this.parent.setTimeout(function(){f.capturingPaste=false;window.focus();f.selectionSnapshot&&window.select.setBookmark(f.container,f.selectionSnapshot);var b=a.value;if(b){f.replaceSelection(b);select.scrollToCursor(f.container)}},10)}},replaceRange:function(a,c,f){f=asEditorLines(f);f[0]=this.history.textAfter(a.node).slice(0,a.offset)+f[0]; -var b=f[f.length-1];f[f.length-1]=b+this.history.textAfter(c.node).slice(c.offset);c=this.history.nodeAfter(c.node);this.history.push(a.node,c,f);return{node:this.history.nodeBefore(c),offset:b.length}},getSearchCursor:function(a,c,f){return new p(this,a,c,f)},reindent:function(){this.container.firstChild&&this.indentRegion(null,this.container.lastChild)},reindentSelection:function(a){if(select.somethingSelected()){var c=select.selectionTopNode(this.container,true),f=select.selectionTopNode(this.container, -false);c===false||f===false||this.indentRegion(c,f,a)}else this.indentAtCursor(a)},grabKeys:function(a,c){this.frozen=a;this.keyFilter=c},ungrabKeys:function(){this.frozen="leave"},setParser:function(a,c){o.Parser=window[a];(c=c||this.options.parserConfig)&&o.Parser.configure&&o.Parser.configure(c);if(this.container.firstChild){forEach(this.container.childNodes,function(f){if(f.nodeType!=3)f.dirty=true});this.addDirtyNode(this.firstChild);this.scheduleHighlight()}},keyDown:function(a){if(this.frozen== -"leave")this.keyFilter=this.frozen=null;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode,a))){a.stop();this.frozen(a)}else{var c=a.keyCode;this.delayScanning();this.options.autoMatchParens&&this.scheduleParenHighlight();if(c==13){if(a.ctrlKey&&!a.altKey)this.reparseBuffer();else{select.insertNewlineAtCursor();c=this.options.enterMode;if(c!="flat")this.indentAtCursor(c=="keep"?"keep":undefined);select.scrollToCursor(this.container)}a.stop()}else if(c==9&&this.options.tabMode!="default"&& -!a.ctrlKey){this.handleTab(!a.shiftKey);a.stop()}else if(c==32&&a.shiftKey&&this.options.tabMode=="default"){this.handleTab(true);a.stop()}else if(c==36&&!a.shiftKey&&!a.ctrlKey)this.home()&&a.stop();else if(c==35&&!a.shiftKey&&!a.ctrlKey)this.end()&&a.stop();else if(c==33&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageUp()&&a.stop();else if(c==34&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageDown()&&a.stop();else if((c==219||c==221)&&a.ctrlKey&&!a.altKey){this.highlightParens(a.shiftKey,true);a.stop()}else if(a.metaKey&& -!a.shiftKey&&(c==37||c==39)){var f=select.selectionTopNode(this.container);if(!(f===false||!this.container.firstChild)){if(c==37)select.focusAfterNode(k(f),this.container);else{c=l(f,this.container);select.focusAfterNode(c?c.previousSibling:this.container.lastChild,this.container)}a.stop()}}else if((a.ctrlKey||a.metaKey)&&!a.altKey)if(a.shiftKey&&c==90||c==89){select.scrollToNode(this.history.redo());a.stop()}else if(c==90||safari&&c==8){select.scrollToNode(this.history.undo());a.stop()}else if(c== -83&&this.options.saveFunction){this.options.saveFunction();a.stop()}else c==86&&!mac&&this.reroutePasteEvent()}},keyPress:function(a){var c=this.options.electricChars&&o.Parser.electricChars,f=this;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode||a.code,a))||a.code==13||a.code==9&&this.options.tabMode!="default"||a.code==32&&a.shiftKey&&this.options.tabMode=="default")a.stop();else if(mac&&(a.ctrlKey||a.metaKey)&&a.character=="v")this.reroutePasteEvent();else if(c&&c.indexOf(a.character)!= --1)this.parent.setTimeout(function(){f.indentAtCursor(null)},0);else if(brokenOpera)if(a.code==8){var b=select.selectionTopNode(this.container);f=this;var d=b?b.nextSibling:this.container.firstChild;b!==false&&d&&isBR(d)&&this.parent.setTimeout(function(){select.selectionTopNode(f.container)==d&&select.focusAfterNode(d.previousSibling,f.container)},20)}else{if(a.code==46){b=select.selectionTopNode(this.container);f=this;b&&isBR(b)&&this.parent.setTimeout(function(){select.selectionTopNode(f.container)!= -b&&select.focusAfterNode(b,f.container)},20)}}else if(slowWebkit){d=(b=select.selectionTopNode(this.container))?b.nextSibling:this.container.firstChild;if(b&&d&&isBR(d)&&!isBR(b)){var e=document.createTextNode("\u200b");this.container.insertBefore(e,d);this.parent.setTimeout(function(){if(e.nodeValue=="\u200b")removeElement(e);else e.nodeValue=e.nodeValue.replace("\u200b","")},20)}}webkit&&!this.options.textWrapping&&setTimeout(function(){var h=select.selectionTopNode(f.container,true);h&&h.nodeType== -3&&h.previousSibling&&isBR(h.previousSibling)&&h.nextSibling&&isBR(h.nextSibling)&&h.parentNode.replaceChild(document.createElement("BR"),h.previousSibling)},50)},keyUp:function(a){this.cursorActivity(a.keyCode>=16&&a.keyCode<=18||a.keyCode>=33&&a.keyCode<=40)},indentLineAfter:function(a,c){function f(n){n=n?n.nextSibling:b.container.firstChild;if(!n||!hasClass(n,"whitespace"))return null;return n}var b=this,d=f(a),e=0,h=d?d.currentText.length:0,i=d?d.nextSibling:a?a.nextSibling:this.container.firstChild; -if(c=="keep"){if(a){var j=f(k(a.previousSibling));if(j)e=j.currentText.length}}else{j=a&&i&&i.currentText?i.currentText:"";if(c!=null&&this.options.tabMode=="shift")e=c?h+indentUnit:Math.max(0,h-indentUnit);else if(a)e=a.indentation(j,h,c);else if(o.Parser.firstIndentation)e=o.Parser.firstIndentation(j,h,c)}h=e-h;if(h<0)if(e==0){if(i)select.snapshotMove(d.firstChild,i.firstChild||i,0);removeElement(d);d=null}else{select.snapshotMove(d.firstChild,d.firstChild,h,true);d.currentText=makeWhiteSpace(e); -d.firstChild.nodeValue=d.currentText}else if(h>0)if(d){d.currentText=makeWhiteSpace(e);d.firstChild.nodeValue=d.currentText;select.snapshotMove(d.firstChild,d.firstChild,h,true)}else{d=makePartSpan(makeWhiteSpace(e));d.className="whitespace";a?insertAfter(d,a):this.container.insertBefore(d,this.container.firstChild);select.snapshotMove(i&&(i.firstChild||i),d.firstChild,e,false,true)}else d&&select.snapshotMove(d.firstChild,d.firstChild,e,false);h!=0&&this.addDirtyNode(a)},highlightAtCursor:function(){var a= -select.selectionTopNode(this.container,true),c=select.selectionTopNode(this.container,false);if(a===false||c===false)return false;select.markSelection();if(this.highlight(a,l(c,this.container),true,20)===false)return false;select.selectMarked();return true},handleTab:function(a){this.options.tabMode=="spaces"?select.insertTabAtCursor():this.reindentSelection(a)},home:function(){var a=select.selectionTopNode(this.container,true),c=a;if(a===false||!(!a||a.isPart||isBR(a))||!this.container.firstChild)return false; -for(;a&&!isBR(a);)a=a.previousSibling;var f=a?a.nextSibling:this.container.firstChild;f&&f!=c&&f.isPart&&hasClass(f,"whitespace")?select.focusAfterNode(f,this.container):select.focusAfterNode(a,this.container);select.scrollToCursor(this.container);return true},end:function(){var a=select.selectionTopNode(this.container,true);if(a===false)return false;a=l(a,this.container);if(!a)return false;select.focusAfterNode(a.previousSibling,this.container);select.scrollToCursor(this.container);return true}, -pageUp:function(){var a=this.cursorPosition().line,c=this.visibleLineCount();if(a===false||c===false)return false;c-=2;for(var f=0;f -0;){var a=this.dirty.pop();try{for(;a&&a.parentNode!=this.container;)a=a.parentNode;if(a&&(a.dirty||a.nodeType==3))return a}catch(c){}}return null},highlightDirty:function(a){if(!window||!window.parent||!window.select)return false;this.options.readOnly||select.markSelection();for(var c,f=a?null:(new Date).getTime()+this.options.passTime;((new Date).getTime()=j||!r&&!w&&x>1&&!f)throw StopIteration;w=r;r=false;x=0;u.next()}else{if(!isSpan(v))throw"Parser out of sync. Expected SPAN.";if(v.dirty)r=true;x++;if(!v.reduced&&v.currentText==s.value&&v.className==s.style){i&&v.dirty&&i(v,s,h);v.dirty=false;u.next()}else{r=true;var y=makePartSpan(s.value);y.className=s.style;e.insertBefore(y,v);i&&i(y,s,h);s=s.value.length;for(var A=0;s>0;){v=u.get();var z=v.currentText.length;select.snapshotReplaceNode(v.firstChild,y.firstChild,s,A); -if(z>s){v=v;v.currentText=v.currentText.substring(s);v.reduced=true;s=0}else{s-=z;A+=z;u.remove()}}}}});d(a);webkitLastLineHack(this.container);return{node:u.getNonEmpty(),dirty:r}}};return o}();addEventHandler(window,"load",function(){var g=window.frameElement.CodeMirror;g.editor=new Editor(g.options);this.parent.setTimeout(method(g,"init"),0)});function tokenizer(g,m){function k(p){return p!="\n"&&/^[\s\u00a0]*$/.test(p)}var l={state:m,take:function(p){if(typeof p=="string")p={style:p,type:p};p.content=(p.content||"")+g.get();/\n$/.test(p.content)||g.nextWhile(k);p.value=p.content+g.get();return p},next:function(){if(!g.more())throw StopIteration;var p;if(g.equals("\n")){g.next();return this.take("whitespace")}if(g.applies(k))p="whitespace";else for(;!p;)p=this.state(g,function(o){l.state=o});return this.take(p)}};return l};var CSSParser=Editor.Parser=function(){function g(k,l,p){return function(o){return!k||/^\}/.test(o)?p:l?p+indentUnit*2:p+indentUnit}}var m=function(){function k(q,a){var c=q.next();if(c=="@"){q.nextWhileMatches(/\w/);return"css-at"}else if(c=="/"&&q.equals("*")){a(l);return null}else if(c=="<"&&q.equals("!")){a(p);return null}else if(c=="=")return"css-compare";else if(q.equals("=")&&(c=="~"||c=="|")){q.next();return"css-compare"}else if(c=='"'||c=="'"){a(o(c));return null}else if(c=="#"){q.nextWhileMatches(/\w/); -return"css-hash"}else if(c=="!"){q.nextWhileMatches(/[ \t]/);q.nextWhileMatches(/\w/);return"css-important"}else if(/\d/.test(c)){q.nextWhileMatches(/[\w.%]/);return"css-unit"}else if(/[,.+>*\/]/.test(c))return"css-select-op";else if(/[;{}:\[\]]/.test(c))return"css-punctuation";else{q.nextWhileMatches(/[\w\\\-_]/);return"css-identifier"}}function l(q,a){for(var c=false;!q.endOfLine();){var f=q.next();if(c&&f=="/"){a(k);break}c=f=="*"}return"css-comment"}function p(q,a){for(var c=0;!q.endOfLine();){var f= -q.next();if(c>=2&&f==">"){a(k);break}c=f=="-"?c+1:0}return"css-comment"}function o(q){return function(a,c){for(var f=false;!a.endOfLine();){var b=a.next();if(b==q&&!f)break;f=!f&&b=="\\"}f||c(k);return"css-string"}}return function(q,a){return tokenizer(q,a||k)}}();return{make:function(k,l){l=l||0;var p=m(k),o=false,q=false,a=false,c={next:function(){var f=p.next(),b=f.style,d=f.content;if(b=="css-hash")b=f.style=q?"css-colorcode":"css-identifier";if(b=="css-identifier")if(q)f.style="css-value";else if(!o&& -!a)f.style="css-selector";if(d=="\n")f.indentation=g(o,q,l);if(d=="{"&&a=="@media")a=false;else if(d=="{")o=true;else if(d=="}")o=q=a=false;else if(d==";")q=a=false;else if(o&&b!="css-comment"&&b!="whitespace")q=true;else if(!o&&b=="css-at")a=d;return f},copy:function(){var f=o,b=q,d=p.state;return function(e){p=m(e,d);o=f;q=b;return c}}};return c},electricChars:"}"}}(); diff --git a/codemirror.css b/codemirror.css index 33a8971..6b5ff44 100644 --- a/codemirror.css +++ b/codemirror.css @@ -1,55 +1,66 @@ -html { - cursor: text; +.CodeMirror { + overflow: auto; + min-height: 200px; + line-height: 1em; + font-family: monospace; } -.editbox { - margin: .4em; - padding: 0; - font-family: Monaco, Consolas, Courier New, Courier, monospace; - font-size: 10pt; - color: black; +.CodeMirror-gutter { + position: absolute; left: 0; top: 0; + background-color: #f7f7f7; + border-right: 1px solid #eee; + min-width: 2em; + height: 100%; } - -pre.code, .editbox { - color: #666; +.CodeMirror-gutter-text { + color: #aaa; + text-align: right; + padding: .4em .2em .4em .4em; } - -.editbox p { - margin: 0; +.CodeMirror-lines { + padding: .4em; } -span.css-at { - color: #708; +.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; } -span.css-unit { - color: #281; +.CodeMirror textarea { + font-family: monospace !important; } -span.css-value { - color: #708; +.CodeMirror-cursor { + z-index: 10; + position: absolute; + visibility: hidden; + border-left: 1px solid black !important; } - -span.css-identifier { - color: black; +.CodeMirror-focused .CodeMirror-cursor { + visibility: visible; } -span.css-selector { - color: #11B; +span.CodeMirror-selected { + background: #ccc !important; + color: HighlightText !important; } - -span.css-important { - color: #00F; +.CodeMirror-focused span.CodeMirror-selected { + background: Highlight !important; } -span.css-colorcode { - color: #299; -} - -span.css-comment { - color: #A70; -} +.CodeMirror-matchingbracket {color: #0f0 !important;} +.CodeMirror-nonmatchingbracket {color: #f22 !important;} -span.css-string { - color: #A22; -} \ No newline at end of file +span.css-at {color: #708;} +span.css-unit {color: #281;} +span.css-value {color: #708;} +span.css-identifier {color: black;} +span.css-selector {color: #11B;} +span.css-important {color: #00F;} +span.css-colorcode {color: #299;} +span.css-comment {color: #A70;} +span.css-string {color: #A22;} diff --git a/codemirror.js b/codemirror.js index f693be2..1564cdc 100644 --- a/codemirror.js +++ b/codemirror.js @@ -1,23 +1 @@ -var CodeMirrorConfig=window.CodeMirrorConfig||{},CodeMirror=function(){function D(a,b){for(var c in b)a.hasOwnProperty(c)||(a[c]=b[c])}function E(a,b){for(var c=0;c";return c}function G(a){if(typeof a.parserfile=="string")a.parserfile=[a.parserfile];if(typeof a.basefiles=="string")a.basefiles=[a.basefiles];if(typeof a.stylesheet=="string")a.stylesheet=[a.stylesheet];var b=['']; -b.push('');var c=a.noScriptCaching?"?nocache="+(new Date).getTime().toString(16):"";E(a.stylesheet,function(d){b.push('')});E(a.basefiles.concat(a.parserfile),function(d){/^https?:/.test(d)||(d=a.path+d);b.push('