Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: chrome_linux/resources/inspector/CodeMirrorTextEditor.js

Issue 42163002: Roll Linux reference build to official build 31.0.1650.34 (trunk r224845, branch r230433) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/reference_builds/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 window.CodeMirror=(function(){"use strict";var gecko=/gecko\/\d/i.test(navigator .userAgent);var ie=/MSIE \d/.test(navigator.userAgent);var ie_lt8=ie&&(document. documentMode==null||document.documentMode<8);var ie_lt9=ie&&(document.documentMo de==null||document.documentMode<9);var webkit=/WebKit\//.test(navigator.userAgen t);var qtwebkit=webkit&&/Qt\/\d+\.\d+/.test(navigator.userAgent);var chrome=/Chr ome\//.test(navigator.userAgent);var opera=/Opera\//.test(navigator.userAgent);v ar safari=/Apple Computer/.test(navigator.vendor);var khtml=/KHTML\//.test(navig ator.userAgent);var mac_geLion=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.use rAgent);var mac_geMountainLion=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.use rAgent);var phantom=/PhantomJS/.test(navigator.userAgent);var ios=/AppleWebKit/. test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent);var mobile=io s||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.use rAgent);var mac=ios||/Mac/.test(navigator.platform);var windows=/windows/i.test( navigator.platform);var opera_version=opera&&navigator.userAgent.match(/Version\ /(\d*\.\d*)/);if(opera_version)opera_version=Number(opera_version[1]);if(opera_v ersion&&opera_version>=15){opera=false;webkit=true;} 1 window.CodeMirror=(function(){"use strict";var gecko=/gecko\/\d/i.test(navigator .userAgent);var ie=/MSIE \d/.test(navigator.userAgent);var ie_lt8=ie&&(document. documentMode==null||document.documentMode<8);var ie_lt9=ie&&(document.documentMo de==null||document.documentMode<9);var webkit=/WebKit\//.test(navigator.userAgen t);var qtwebkit=webkit&&/Qt\/\d+\.\d+/.test(navigator.userAgent);var chrome=/Chr ome\//.test(navigator.userAgent);var opera=/Opera\//.test(navigator.userAgent);v ar safari=/Apple Computer/.test(navigator.vendor);var khtml=/KHTML\//.test(navig ator.userAgent);var mac_geLion=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.use rAgent);var mac_geMountainLion=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.use rAgent);var phantom=/PhantomJS/.test(navigator.userAgent);var ios=/AppleWebKit/. test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent);var mobile=io s||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.use rAgent);var mac=ios||/Mac/.test(navigator.platform);var windows=/win/i.test(navi gator.platform);var opera_version=opera&&navigator.userAgent.match(/Version\/(\d *\.\d*)/);if(opera_version)opera_version=Number(opera_version[1]);if(opera_versi on&&opera_version>=15){opera=false;webkit=true;}
2 var flipCtrlCmd=mac&&(qtwebkit||opera&&(opera_version==null||opera_version<12.11 ));var captureMiddleClick=gecko||(ie&&!ie_lt9);var sawReadOnlySpans=false,sawCol lapsedSpans=false;function CodeMirror(place,options){if(!(this instanceof CodeMi rror))return new CodeMirror(place,options);this.options=options=options||{};for( var opt in defaults)if(!options.hasOwnProperty(opt)&&defaults.hasOwnProperty(opt )) 2 var flipCtrlCmd=mac&&(qtwebkit||opera&&(opera_version==null||opera_version<12.11 ));var captureMiddleClick=gecko||(ie&&!ie_lt9);var sawReadOnlySpans=false,sawCol lapsedSpans=false;function CodeMirror(place,options){if(!(this instanceof CodeMi rror))return new CodeMirror(place,options);this.options=options=options||{};for( var opt in defaults)if(!options.hasOwnProperty(opt)&&defaults.hasOwnProperty(opt ))
3 options[opt]=defaults[opt];setGuttersForLineNumbers(options);var docStart=typeof options.value=="string"?0:options.value.first;var display=this.display=makeDisp lay(place,docStart);display.wrapper.CodeMirror=this;updateGutters(this);if(optio ns.autofocus&&!mobile)focusInput(this);this.state={keyMaps:[],overlays:[],modeGe n:0,overwrite:false,focused:false,suppressEdits:false,pasteIncoming:false,draggi ngText:false,highlight:new Delayed()};themeChanged(this);if(options.lineWrapping ) 3 options[opt]=defaults[opt];setGuttersForLineNumbers(options);var docStart=typeof options.value=="string"?0:options.value.first;var display=this.display=makeDisp lay(place,docStart);display.wrapper.CodeMirror=this;updateGutters(this);if(optio ns.autofocus&&!mobile)focusInput(this);this.state={keyMaps:[],overlays:[],modeGe n:0,overwrite:false,focused:false,suppressEdits:false,pasteIncoming:false,draggi ngText:false,highlight:new Delayed()};themeChanged(this);if(options.lineWrapping )
4 this.display.wrapper.className+=" CodeMirror-wrap";var doc=options.value;if(type of doc=="string")doc=new Doc(options.value,options.mode);operation(this,attachDo c)(this,doc);if(ie)setTimeout(bind(resetInput,this,true),20);registerEventHandle rs(this);var hasFocus;try{hasFocus=(document.activeElement==display.input);}catc h(e){} 4 this.display.wrapper.className+=" CodeMirror-wrap";var doc=options.value;if(type of doc=="string")doc=new Doc(options.value,options.mode);operation(this,attachDo c)(this,doc);if(ie)setTimeout(bind(resetInput,this,true),20);registerEventHandle rs(this);var hasFocus;try{hasFocus=(document.activeElement==display.input);}catc h(e){}
5 if(hasFocus||(options.autofocus&&!mobile))setTimeout(bind(onFocus,this),20);else onBlur(this);operation(this,function(){for(var opt in optionHandlers) 5 if(hasFocus||(options.autofocus&&!mobile))setTimeout(bind(onFocus,this),20);else onBlur(this);operation(this,function(){for(var opt in optionHandlers)
6 if(optionHandlers.propertyIsEnumerable(opt)) 6 if(optionHandlers.propertyIsEnumerable(opt))
7 optionHandlers[opt](this,options[opt],Init);for(var i=0;i<initHooks.length;++i)i nitHooks[i](this);})();} 7 optionHandlers[opt](this,options[opt],Init);for(var i=0;i<initHooks.length;++i)i nitHooks[i](this);})();}
8 function makeDisplay(place,docStart){var d={};var input=d.input=elt("textarea",n ull,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none ; font-size: 4px;");if(webkit)input.style.width="1000px";else input.setAttribute ("wrap","off");if(ios)input.style.border="1px solid black";input.setAttribute("a utocorrect","off");input.setAttribute("autocapitalize","off");input.setAttribute ("spellcheck","false");d.inputDiv=elt("div",[input],null,"overflow: hidden; posi tion: relative; width: 3px; height: 0px;");d.scrollbarH=elt("div",[elt("div",nul l,null,"height: 1px")],"CodeMirror-hscrollbar");d.scrollbarV=elt("div",[elt("div ",null,null,"width: 1px")],"CodeMirror-vscrollbar");d.scrollbarFiller=elt("div", null,"CodeMirror-scrollbar-filler");d.gutterFiller=elt("div",null,"CodeMirror-gu tter-filler");d.lineDiv=elt("div",null,"CodeMirror-code");d.selectionDiv=elt("di v",null,null,"position: relative; z-index: 1");d.cursor=elt("div","\u00a0","Code Mirror-cursor");d.otherCursor=elt("div","\u00a0","CodeMirror-cursor CodeMirror-s econdarycursor");d.measure=elt("div",null,"CodeMirror-measure");d.lineSpace=elt( "div",[d.measure,d.selectionDiv,d.lineDiv,d.cursor,d.otherCursor],null,"position : relative; outline: none");d.mover=elt("div",[elt("div",[d.lineSpace],"CodeMirr or-lines")],null,"position: relative");d.sizer=elt("div",[d.mover],"CodeMirror-s izer");d.heightForcer=elt("div",null,null,"position: absolute; height: "+scrolle rCutOff+"px; width: 1px;");d.gutters=elt("div",null,"CodeMirror-gutters");d.line Gutter=null;d.scroller=elt("div",[d.sizer,d.heightForcer,d.gutters],"CodeMirror- scroll");d.scroller.setAttribute("tabIndex","-1");d.wrapper=elt("div",[d.inputDi v,d.scrollbarH,d.scrollbarV,d.scrollbarFiller,d.gutterFiller,d.scroller],"CodeMi rror");if(ie_lt8){d.gutters.style.zIndex=-1;d.scroller.style.paddingRight=0;} 8 function makeDisplay(place,docStart){var d={};var input=d.input=elt("textarea",n ull,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none ; font-size: 4px;");if(webkit)input.style.width="1000px";else input.setAttribute ("wrap","off");if(ios)input.style.border="1px solid black";input.setAttribute("a utocorrect","off");input.setAttribute("autocapitalize","off");input.setAttribute ("spellcheck","false");d.inputDiv=elt("div",[input],null,"overflow: hidden; posi tion: relative; width: 3px; height: 0px;");d.scrollbarH=elt("div",[elt("div",nul l,null,"height: 1px")],"CodeMirror-hscrollbar");d.scrollbarV=elt("div",[elt("div ",null,null,"width: 1px")],"CodeMirror-vscrollbar");d.scrollbarFiller=elt("div", null,"CodeMirror-scrollbar-filler");d.gutterFiller=elt("div",null,"CodeMirror-gu tter-filler");d.lineDiv=elt("div",null,"CodeMirror-code");d.selectionDiv=elt("di v",null,null,"position: relative; z-index: 1");d.cursor=elt("div","\u00a0","Code Mirror-cursor");d.otherCursor=elt("div","\u00a0","CodeMirror-cursor CodeMirror-s econdarycursor");d.measure=elt("div",null,"CodeMirror-measure");d.lineSpace=elt( "div",[d.measure,d.selectionDiv,d.lineDiv,d.cursor,d.otherCursor],null,"position : relative; outline: none");d.mover=elt("div",[elt("div",[d.lineSpace],"CodeMirr or-lines")],null,"position: relative");d.sizer=elt("div",[d.mover],"CodeMirror-s izer");d.heightForcer=elt("div",null,null,"position: absolute; height: "+scrolle rCutOff+"px; width: 1px;");d.gutters=elt("div",null,"CodeMirror-gutters");d.line Gutter=null;d.scroller=elt("div",[d.sizer,d.heightForcer,d.gutters],"CodeMirror- scroll");d.scroller.setAttribute("tabIndex","-1");d.wrapper=elt("div",[d.inputDi v,d.scrollbarH,d.scrollbarV,d.scrollbarFiller,d.gutterFiller,d.scroller],"CodeMi rror");if(ie_lt8){d.gutters.style.zIndex=-1;d.scroller.style.paddingRight=0;}
9 if(place.appendChild)place.appendChild(d.wrapper);else place(d.wrapper);if(ios)i nput.style.width="0px";if(!webkit)d.scroller.draggable=true;if(khtml){d.inputDiv .style.height="1px";d.inputDiv.style.position="absolute";} 9 if(place.appendChild)place.appendChild(d.wrapper);else place(d.wrapper);if(ios)i nput.style.width="0px";if(!webkit)d.scroller.draggable=true;if(khtml){d.inputDiv .style.height="1px";d.inputDiv.style.position="absolute";}
10 else if(ie_lt8)d.scrollbarH.style.minWidth=d.scrollbarV.style.minWidth="18px";d. viewOffset=d.lastSizeC=0;d.showingFrom=d.showingTo=docStart;d.lineNumWidth=d.lin eNumInnerWidth=d.lineNumChars=null;d.prevInput="";d.alignWidgets=false;d.polling Fast=false;d.poll=new Delayed();d.cachedCharWidth=d.cachedTextHeight=null;d.meas ureLineCache=[];d.measureLineCachePos=0;d.inaccurateSelection=false;d.maxLine=nu ll;d.maxLineLength=0;d.maxLineChanged=false;d.wheelDX=d.wheelDY=d.wheelStartX=d. wheelStartY=null;return d;} 10 else if(ie_lt8)d.scrollbarH.style.minWidth=d.scrollbarV.style.minWidth="18px";d. viewOffset=d.lastSizeC=0;d.showingFrom=d.showingTo=docStart;d.lineNumWidth=d.lin eNumInnerWidth=d.lineNumChars=null;d.prevInput="";d.alignWidgets=false;d.polling Fast=false;d.poll=new Delayed();d.cachedCharWidth=d.cachedTextHeight=null;d.meas ureLineCache=[];d.measureLineCachePos=0;d.inaccurateSelection=false;d.maxLine=nu ll;d.maxLineLength=0;d.maxLineChanged=false;d.wheelDX=d.wheelDY=d.wheelStartX=d. wheelStartY=null;return d;}
11 function loadMode(cm){cm.doc.mode=CodeMirror.getMode(cm.options,cm.doc.modeOptio n);cm.doc.iter(function(line){if(line.stateAfter)line.stateAfter=null;if(line.st yles)line.styles=null;});cm.doc.frontier=cm.doc.first;startWorker(cm,100);cm.sta te.modeGen++;if(cm.curOp)regChange(cm);} 11 function loadMode(cm){cm.doc.mode=CodeMirror.getMode(cm.options,cm.doc.modeOptio n);cm.doc.iter(function(line){if(line.stateAfter)line.stateAfter=null;if(line.st yles)line.styles=null;});cm.doc.frontier=cm.doc.first;startWorker(cm,100);cm.sta te.modeGen++;if(cm.curOp)regChange(cm);}
12 function wrappingChanged(cm){if(cm.options.lineWrapping){cm.display.wrapper.clas sName+=" CodeMirror-wrap";cm.display.sizer.style.minWidth="";}else{cm.display.wr apper.className=cm.display.wrapper.className.replace(" CodeMirror-wrap","");comp uteMaxLength(cm);} 12 function wrappingChanged(cm){if(cm.options.lineWrapping){cm.display.wrapper.clas sName+=" CodeMirror-wrap";cm.display.sizer.style.minWidth="";}else{cm.display.wr apper.className=cm.display.wrapper.className.replace(" CodeMirror-wrap","");comp uteMaxLength(cm);}
13 estimateLineHeights(cm);regChange(cm);clearCaches(cm);setTimeout(function(){upda teScrollbars(cm);},100);} 13 estimateLineHeights(cm);regChange(cm);clearCaches(cm);setTimeout(function(){upda teScrollbars(cm);},100);}
14 function estimateHeight(cm){var th=textHeight(cm.display),wrapping=cm.options.li neWrapping;var perLine=wrapping&&Math.max(5,cm.display.scroller.clientWidth/char Width(cm.display)-3);return function(line){if(lineIsHidden(cm.doc,line)) 14 function estimateHeight(cm){var th=textHeight(cm.display),wrapping=cm.options.li neWrapping;var perLine=wrapping&&Math.max(5,cm.display.scroller.clientWidth/char Width(cm.display)-3);return function(line){if(lineIsHidden(cm.doc,line))
15 return 0;else if(wrapping) 15 return 0;else if(wrapping)
16 return(Math.ceil(line.text.length/perLine)||1)*th;else 16 return(Math.ceil(line.text.length/perLine)||1)*th;else
17 return th;};} 17 return th;};}
18 function estimateLineHeights(cm){var doc=cm.doc,est=estimateHeight(cm);doc.iter( function(line){var estHeight=est(line);if(estHeight!=line.height)updateLineHeigh t(line,estHeight);});} 18 function estimateLineHeights(cm){var doc=cm.doc,est=estimateHeight(cm);doc.iter( function(line){var estHeight=est(line);if(estHeight!=line.height)updateLineHeigh t(line,estHeight);});}
19 function keyMapChanged(cm){var map=keyMap[cm.options.keyMap],style=map.style;cm. display.wrapper.className=cm.display.wrapper.className.replace(/\s*cm-keymap-\S+ /g,"")+ 19 function keyMapChanged(cm){var map=keyMap[cm.options.keyMap],style=map.style;cm. display.wrapper.className=cm.display.wrapper.className.replace(/\s*cm-keymap-\S+ /g,"")+
20 (style?" cm-keymap-"+style:"");cm.state.disableInput=map.disableInput;} 20 (style?" cm-keymap-"+style:"");cm.state.disableInput=map.disableInput;}
21 function themeChanged(cm){cm.display.wrapper.className=cm.display.wrapper.classN ame.replace(/\s*cm-s-\S+/g,"")+ 21 function themeChanged(cm){cm.display.wrapper.className=cm.display.wrapper.classN ame.replace(/\s*cm-s-\S+/g,"")+
22 cm.options.theme.replace(/(^|\s)\s*/g," cm-s-");clearCaches(cm);} 22 cm.options.theme.replace(/(^|\s)\s*/g," cm-s-");clearCaches(cm);}
23 function guttersChanged(cm){updateGutters(cm);regChange(cm);setTimeout(function( ){alignHorizontally(cm);},20);} 23 function guttersChanged(cm){updateGutters(cm);regChange(cm);setTimeout(function( ){alignHorizontally(cm);},20);}
24 function updateGutters(cm){var gutters=cm.display.gutters,specs=cm.options.gutte rs;removeChildren(gutters);for(var i=0;i<specs.length;++i){var gutterClass=specs [i];var gElt=gutters.appendChild(elt("div",null,"CodeMirror-gutter "+gutterClass ));if(gutterClass=="CodeMirror-linenumbers"){cm.display.lineGutter=gElt;gElt.sty le.width=(cm.display.lineNumWidth||1)+"px";}} 24 function updateGutters(cm){var gutters=cm.display.gutters,specs=cm.options.gutte rs;removeChildren(gutters);for(var i=0;i<specs.length;++i){var gutterClass=specs [i];var gElt=gutters.appendChild(elt("div",null,"CodeMirror-gutter "+gutterClass ));if(gutterClass=="CodeMirror-linenumbers"){cm.display.lineGutter=gElt;gElt.sty le.width=(cm.display.lineNumWidth||1)+"px";}}
25 gutters.style.display=i?"":"none";} 25 gutters.style.display=i?"":"none";}
26 function lineLength(doc,line){if(line.height==0)return 0;var len=line.text.lengt h,merged,cur=line;while(merged=collapsedSpanAtStart(cur)){var found=merged.find( );cur=getLine(doc,found.from.line);len+=found.from.ch-found.to.ch;} 26 function lineLength(doc,line){if(line.height==0)return 0;var len=line.text.lengt h,merged,cur=line;while(merged=collapsedSpanAtStart(cur)){var found=merged.find( );cur=getLine(doc,found.from.line);len+=found.from.ch-found.to.ch;}
27 cur=line;while(merged=collapsedSpanAtEnd(cur)){var found=merged.find();len-=cur. text.length-found.from.ch;cur=getLine(doc,found.to.line);len+=cur.text.length-fo und.to.ch;} 27 cur=line;while(merged=collapsedSpanAtEnd(cur)){var found=merged.find();len-=cur. text.length-found.from.ch;cur=getLine(doc,found.to.line);len+=cur.text.length-fo und.to.ch;}
28 return len;} 28 return len;}
29 function computeMaxLength(cm){var d=cm.display,doc=cm.doc;d.maxLine=getLine(doc, doc.first);d.maxLineLength=lineLength(doc,d.maxLine);d.maxLineChanged=true;doc.i ter(function(line){var len=lineLength(doc,line);if(len>d.maxLineLength){d.maxLin eLength=len;d.maxLine=line;}});} 29 function computeMaxLength(cm){var d=cm.display,doc=cm.doc;d.maxLine=getLine(doc, doc.first);d.maxLineLength=lineLength(doc,d.maxLine);d.maxLineChanged=true;doc.i ter(function(line){var len=lineLength(doc,line);if(len>d.maxLineLength){d.maxLin eLength=len;d.maxLine=line;}});}
30 function setGuttersForLineNumbers(options){var found=false;for(var i=0;i<options .gutters.length;++i){if(options.gutters[i]=="CodeMirror-linenumbers"){if(options .lineNumbers)found=true;else options.gutters.splice(i--,1);}} 30 function setGuttersForLineNumbers(options){var found=indexOf(options.gutters,"Co deMirror-linenumbers");if(found==-1&&options.lineNumbers){options.gutters=option s.gutters.concat(["CodeMirror-linenumbers"]);}else if(found>-1&&!options.lineNum bers){options.gutters=options.gutters.slice(0);options.gutters.splice(i,1);}}
31 if(!found&&options.lineNumbers) 31 function updateScrollbars(cm){var d=cm.display,docHeight=cm.doc.height;var total Height=docHeight+paddingVert(d);d.sizer.style.minHeight=d.heightForcer.style.top =totalHeight+"px";d.gutters.style.height=Math.max(totalHeight,d.scroller.clientH eight-scrollerCutOff)+"px";var scrollHeight=Math.max(totalHeight,d.scroller.scro llHeight);var needsH=d.scroller.scrollWidth>(d.scroller.clientWidth+1);var needs V=scrollHeight>(d.scroller.clientHeight+1);if(needsV){d.scrollbarV.style.display ="block";d.scrollbarV.style.bottom=needsH?scrollbarWidth(d.measure)+"px":"0";d.s crollbarV.firstChild.style.height=(scrollHeight-d.scroller.clientHeight+d.scroll barV.clientHeight)+"px";}else{d.scrollbarV.style.display="";d.scrollbarV.firstCh ild.style.height="0";}
32 options.gutters.push("CodeMirror-linenumbers");} 32 if(needsH){d.scrollbarH.style.display="block";d.scrollbarH.style.right=needsV?sc rollbarWidth(d.measure)+"px":"0";d.scrollbarH.firstChild.style.width=(d.scroller .scrollWidth-d.scroller.clientWidth+d.scrollbarH.clientWidth)+"px";}else{d.scrol lbarH.style.display="";d.scrollbarH.firstChild.style.width="0";}
33 function updateScrollbars(cm){var d=cm.display,docHeight=cm.doc.height;var total Height=docHeight+paddingVert(d);d.sizer.style.minHeight=d.heightForcer.style.top =totalHeight+"px";d.gutters.style.height=Math.max(totalHeight,d.scroller.clientH eight-scrollerCutOff)+"px";var scrollHeight=Math.max(totalHeight,d.scroller.scro llHeight);var needsH=d.scroller.scrollWidth>(d.scroller.clientWidth+1);var needs V=scrollHeight>(d.scroller.clientHeight+1);if(needsV){d.scrollbarV.style.display ="block";d.scrollbarV.style.bottom=needsH?scrollbarWidth(d.measure)+"px":"0";d.s crollbarV.firstChild.style.height=(scrollHeight-d.scroller.clientHeight+d.scroll barV.clientHeight)+"px";}else d.scrollbarV.style.display="";if(needsH){d.scrollb arH.style.display="block";d.scrollbarH.style.right=needsV?scrollbarWidth(d.measu re)+"px":"0";d.scrollbarH.firstChild.style.width=(d.scroller.scrollWidth-d.scrol ler.clientWidth+d.scrollbarH.clientWidth)+"px";}else d.scrollbarH.style.display= "";if(needsH&&needsV){d.scrollbarFiller.style.display="block";d.scrollbarFiller. style.height=d.scrollbarFiller.style.width=scrollbarWidth(d.measure)+"px";}else d.scrollbarFiller.style.display="";if(needsH&&cm.options.coverGutterNextToScroll bar&&cm.options.fixedGutter){d.gutterFiller.style.display="block";d.gutterFiller .style.height=scrollbarWidth(d.measure)+"px";d.gutterFiller.style.width=d.gutter s.offsetWidth+"px";}else d.gutterFiller.style.display="";if(mac_geLion&&scrollba rWidth(d.measure)===0) 33 if(needsH&&needsV){d.scrollbarFiller.style.display="block";d.scrollbarFiller.sty le.height=d.scrollbarFiller.style.width=scrollbarWidth(d.measure)+"px";}else d.s crollbarFiller.style.display="";if(needsH&&cm.options.coverGutterNextToScrollbar &&cm.options.fixedGutter){d.gutterFiller.style.display="block";d.gutterFiller.st yle.height=scrollbarWidth(d.measure)+"px";d.gutterFiller.style.width=d.gutters.o ffsetWidth+"px";}else d.gutterFiller.style.display="";if(mac_geLion&&scrollbarWi dth(d.measure)===0)
34 d.scrollbarV.style.minWidth=d.scrollbarH.style.minHeight=mac_geMountainLion?"18p x":"12px";} 34 d.scrollbarV.style.minWidth=d.scrollbarH.style.minHeight=mac_geMountainLion?"18p x":"12px";}
35 function visibleLines(display,doc,viewPort){var top=display.scroller.scrollTop,h eight=display.wrapper.clientHeight;if(typeof viewPort=="number")top=viewPort;els e if(viewPort){top=viewPort.top;height=viewPort.bottom-viewPort.top;} 35 function visibleLines(display,doc,viewPort){var top=display.scroller.scrollTop,h eight=display.wrapper.clientHeight;if(typeof viewPort=="number")top=viewPort;els e if(viewPort){top=viewPort.top;height=viewPort.bottom-viewPort.top;}
36 top=Math.floor(top-paddingTop(display));var bottom=Math.ceil(top+height);return{ from:lineAtHeight(doc,top),to:lineAtHeight(doc,bottom)};} 36 top=Math.floor(top-paddingTop(display));var bottom=Math.ceil(top+height);return{ from:lineAtHeight(doc,top),to:lineAtHeight(doc,bottom)};}
37 function alignHorizontally(cm){var display=cm.display;if(!display.alignWidgets&& (!display.gutters.firstChild||!cm.options.fixedGutter))return;var comp=compensat eForHScroll(display)-display.scroller.scrollLeft+cm.doc.scrollLeft;var gutterW=d isplay.gutters.offsetWidth,l=comp+"px";for(var n=display.lineDiv.firstChild;n;n= n.nextSibling)if(n.alignable){for(var i=0,a=n.alignable;i<a.length;++i)a[i].styl e.left=l;} 37 function alignHorizontally(cm){var display=cm.display;if(!display.alignWidgets&& (!display.gutters.firstChild||!cm.options.fixedGutter))return;var comp=compensat eForHScroll(display)-display.scroller.scrollLeft+cm.doc.scrollLeft;var gutterW=d isplay.gutters.offsetWidth,l=comp+"px";for(var n=display.lineDiv.firstChild;n;n= n.nextSibling)if(n.alignable){for(var i=0,a=n.alignable;i<a.length;++i)a[i].styl e.left=l;}
38 if(cm.options.fixedGutter) 38 if(cm.options.fixedGutter)
39 display.gutters.style.left=(comp+gutterW)+"px";} 39 display.gutters.style.left=(comp+gutterW)+"px";}
40 function maybeUpdateLineNumberWidth(cm){if(!cm.options.lineNumbers)return false; var doc=cm.doc,last=lineNumberFor(cm.options,doc.first+doc.size-1),display=cm.di splay;if(last.length!=display.lineNumChars){var test=display.measure.appendChild (elt("div",[elt("div",last)],"CodeMirror-linenumber CodeMirror-gutter-elt"));var innerW=test.firstChild.offsetWidth,padding=test.offsetWidth-innerW;display.line Gutter.style.width="";display.lineNumInnerWidth=Math.max(innerW,display.lineGutt er.offsetWidth-padding);display.lineNumWidth=display.lineNumInnerWidth+padding;d isplay.lineNumChars=display.lineNumInnerWidth?last.length:-1;display.lineGutter. style.width=display.lineNumWidth+"px";return true;} 40 function maybeUpdateLineNumberWidth(cm){if(!cm.options.lineNumbers)return false; var doc=cm.doc,last=lineNumberFor(cm.options,doc.first+doc.size-1),display=cm.di splay;if(last.length!=display.lineNumChars){var test=display.measure.appendChild (elt("div",[elt("div",last)],"CodeMirror-linenumber CodeMirror-gutter-elt"));var innerW=test.firstChild.offsetWidth,padding=test.offsetWidth-innerW;display.line Gutter.style.width="";display.lineNumInnerWidth=Math.max(innerW,display.lineGutt er.offsetWidth-padding);display.lineNumWidth=display.lineNumInnerWidth+padding;d isplay.lineNumChars=display.lineNumInnerWidth?last.length:-1;display.lineGutter. style.width=display.lineNumWidth+"px";return true;}
41 return false;} 41 return false;}
42 function lineNumberFor(options,i){return String(options.lineNumberFormatter(i+op tions.firstLineNumber));} 42 function lineNumberFor(options,i){return String(options.lineNumberFormatter(i+op tions.firstLineNumber));}
43 function compensateForHScroll(display){return getRect(display.scroller).left-get Rect(display.sizer).left;} 43 function compensateForHScroll(display){return getRect(display.scroller).left-get Rect(display.sizer).left;}
44 function updateDisplay(cm,changes,viewPort,forced){var oldFrom=cm.display.showin gFrom,oldTo=cm.display.showingTo,updated;var visible=visibleLines(cm.display,cm. doc,viewPort);for(;;){if(!updateDisplayInner(cm,changes,visible,forced))break;fo rced=false;updated=true;updateSelection(cm);updateScrollbars(cm);if(viewPort) 44 function updateDisplay(cm,changes,viewPort,forced){var oldFrom=cm.display.showin gFrom,oldTo=cm.display.showingTo,updated;var visible=visibleLines(cm.display,cm. doc,viewPort);for(;;){var oldWidth=cm.display.scroller.clientWidth;if(!updateDis playInner(cm,changes,visible,forced))break;updated=true;changes=[];updateSelecti on(cm);updateScrollbars(cm);if(cm.options.lineWrapping&&oldWidth!=cm.display.scr oller.clientWidth){forced=true;continue;}
45 forced=false;if(viewPort)
45 viewPort=Math.min(cm.display.scroller.scrollHeight-cm.display.scroller.clientHei ght,typeof viewPort=="number"?viewPort:viewPort.top);visible=visibleLines(cm.dis play,cm.doc,viewPort);if(visible.from>=cm.display.showingFrom&&visible.to<=cm.di splay.showingTo) 46 viewPort=Math.min(cm.display.scroller.scrollHeight-cm.display.scroller.clientHei ght,typeof viewPort=="number"?viewPort:viewPort.top);visible=visibleLines(cm.dis play,cm.doc,viewPort);if(visible.from>=cm.display.showingFrom&&visible.to<=cm.di splay.showingTo)
46 break;changes=[];} 47 break;}
47 if(updated){signalLater(cm,"update",cm);if(cm.display.showingFrom!=oldFrom||cm.d isplay.showingTo!=oldTo) 48 if(updated){signalLater(cm,"update",cm);if(cm.display.showingFrom!=oldFrom||cm.d isplay.showingTo!=oldTo)
48 signalLater(cm,"viewportChange",cm,cm.display.showingFrom,cm.display.showingTo); } 49 signalLater(cm,"viewportChange",cm,cm.display.showingFrom,cm.display.showingTo); }
49 return updated;} 50 return updated;}
50 function updateDisplayInner(cm,changes,visible,forced){var display=cm.display,do c=cm.doc;if(!display.wrapper.clientWidth){display.showingFrom=display.showingTo= doc.first;display.viewOffset=0;return;} 51 function updateDisplayInner(cm,changes,visible,forced){var display=cm.display,do c=cm.doc;if(!display.wrapper.clientWidth){display.showingFrom=display.showingTo= doc.first;display.viewOffset=0;return;}
51 if(!forced&&changes.length==0&&visible.from>display.showingFrom&&visible.to<disp lay.showingTo) 52 if(!forced&&changes.length==0&&visible.from>display.showingFrom&&visible.to<disp lay.showingTo)
52 return;if(maybeUpdateLineNumberWidth(cm)) 53 return;if(maybeUpdateLineNumberWidth(cm))
53 changes=[{from:doc.first,to:doc.first+doc.size}];var gutterW=display.sizer.style .marginLeft=display.gutters.offsetWidth+"px";display.scrollbarH.style.left=cm.op tions.fixedGutter?gutterW:"0";var positionsChangedFrom=Infinity;if(cm.options.li neNumbers) 54 changes=[{from:doc.first,to:doc.first+doc.size}];var gutterW=display.sizer.style .marginLeft=display.gutters.offsetWidth+"px";display.scrollbarH.style.left=cm.op tions.fixedGutter?gutterW:"0";var positionsChangedFrom=Infinity;if(cm.options.li neNumbers)
54 for(var i=0;i<changes.length;++i) 55 for(var i=0;i<changes.length;++i)
55 if(changes[i].diff){positionsChangedFrom=changes[i].from;break;} 56 if(changes[i].diff&&changes[i].from<positionsChangedFrom){positionsChangedFrom=c hanges[i].from;}
56 var end=doc.first+doc.size;var from=Math.max(visible.from-cm.options.viewportMar gin,doc.first);var to=Math.min(end,visible.to+cm.options.viewportMargin);if(disp lay.showingFrom<from&&from-display.showingFrom<20)from=Math.max(doc.first,displa y.showingFrom);if(display.showingTo>to&&display.showingTo-to<20)to=Math.min(end, display.showingTo);if(sawCollapsedSpans){from=lineNo(visualLine(doc,getLine(doc, from)));while(to<end&&lineIsHidden(doc,getLine(doc,to)))++to;} 57 var end=doc.first+doc.size;var from=Math.max(visible.from-cm.options.viewportMar gin,doc.first);var to=Math.min(end,visible.to+cm.options.viewportMargin);if(disp lay.showingFrom<from&&from-display.showingFrom<20)from=Math.max(doc.first,displa y.showingFrom);if(display.showingTo>to&&display.showingTo-to<20)to=Math.min(end, display.showingTo);if(sawCollapsedSpans){from=lineNo(visualLine(doc,getLine(doc, from)));while(to<end&&lineIsHidden(doc,getLine(doc,to)))++to;}
57 var intact=[{from:Math.max(display.showingFrom,doc.first),to:Math.min(display.sh owingTo,end)}];if(intact[0].from>=intact[0].to)intact=[];else intact=computeInta ct(intact,changes);if(sawCollapsedSpans) 58 var intact=[{from:Math.max(display.showingFrom,doc.first),to:Math.min(display.sh owingTo,end)}];if(intact[0].from>=intact[0].to)intact=[];else intact=computeInta ct(intact,changes);if(sawCollapsedSpans)
58 for(var i=0;i<intact.length;++i){var range=intact[i],merged;while(merged=collaps edSpanAtEnd(getLine(doc,range.to-1))){var newTo=merged.find().from.line;if(newTo >range.from)range.to=newTo;else{intact.splice(i--,1);break;}}} 59 for(var i=0;i<intact.length;++i){var range=intact[i],merged;while(merged=collaps edSpanAtEnd(getLine(doc,range.to-1))){var newTo=merged.find().from.line;if(newTo >range.from)range.to=newTo;else{intact.splice(i--,1);break;}}}
59 var intactLines=0;for(var i=0;i<intact.length;++i){var range=intact[i];if(range. from<from)range.from=from;if(range.to>to)range.to=to;if(range.from>=range.to)int act.splice(i--,1);else intactLines+=range.to-range.from;} 60 var intactLines=0;for(var i=0;i<intact.length;++i){var range=intact[i];if(range. from<from)range.from=from;if(range.to>to)range.to=to;if(range.from>=range.to)int act.splice(i--,1);else intactLines+=range.to-range.from;}
60 if(!forced&&intactLines==to-from&&from==display.showingFrom&&to==display.showing To){updateViewOffset(cm);return;} 61 if(!forced&&intactLines==to-from&&from==display.showingFrom&&to==display.showing To){updateViewOffset(cm);return;}
61 intact.sort(function(a,b){return a.from-b.from;});try{var focused=document.activ eElement;}catch(e){} 62 intact.sort(function(a,b){return a.from-b.from;});try{var focused=document.activ eElement;}catch(e){}
62 if(intactLines<(to-from)*.7)display.lineDiv.style.display="none";patchDisplay(cm ,from,to,intact,positionsChangedFrom);display.lineDiv.style.display="";if(focuse d&&document.activeElement!=focused&&focused.offsetHeight)focused.focus();var dif ferent=from!=display.showingFrom||to!=display.showingTo||display.lastSizeC!=disp lay.wrapper.clientHeight;if(different){display.lastSizeC=display.wrapper.clientH eight;startWorker(cm,400);} 63 if(intactLines<(to-from)*.7)display.lineDiv.style.display="none";patchDisplay(cm ,from,to,intact,positionsChangedFrom);display.lineDiv.style.display="";if(focuse d&&document.activeElement!=focused&&focused.offsetHeight)focused.focus();var dif ferent=from!=display.showingFrom||to!=display.showingTo||display.lastSizeC!=disp lay.wrapper.clientHeight;if(different){display.lastSizeC=display.wrapper.clientH eight;startWorker(cm,400);}
63 display.showingFrom=from;display.showingTo=to;updateHeightsInViewport(cm);update ViewOffset(cm);return true;} 64 display.showingFrom=from;display.showingTo=to;updateHeightsInViewport(cm);update ViewOffset(cm);return true;}
64 function updateHeightsInViewport(cm){var display=cm.display;var prevBottom=displ ay.lineDiv.offsetTop;for(var node=display.lineDiv.firstChild,height;node;node=no de.nextSibling)if(node.lineObj){if(ie_lt8){var bot=node.offsetTop+node.offsetHei ght;height=bot-prevBottom;prevBottom=bot;}else{var box=getRect(node);height=box. bottom-box.top;} 65 function updateHeightsInViewport(cm){var display=cm.display;var prevBottom=displ ay.lineDiv.offsetTop;for(var node=display.lineDiv.firstChild,height;node;node=no de.nextSibling)if(node.lineObj){if(ie_lt8){var bot=node.offsetTop+node.offsetHei ght;height=bot-prevBottom;prevBottom=bot;}else{var box=getRect(node);height=box. bottom-box.top;}
65 var diff=node.lineObj.height-height;if(height<2)height=textHeight(display);if(di ff>.001||diff<-.001){updateLineHeight(node.lineObj,height);var widgets=node.line Obj.widgets;if(widgets)for(var i=0;i<widgets.length;++i) 66 var diff=node.lineObj.height-height;if(height<2)height=textHeight(display);if(di ff>.001||diff<-.001){updateLineHeight(node.lineObj,height);var widgets=node.line Obj.widgets;if(widgets)for(var i=0;i<widgets.length;++i)
66 widgets[i].height=widgets[i].node.offsetHeight;}}} 67 widgets[i].height=widgets[i].node.offsetHeight;}}}
67 function updateViewOffset(cm){var off=cm.display.viewOffset=heightAtLine(cm,getL ine(cm.doc,cm.display.showingFrom));cm.display.mover.style.top=off+"px";} 68 function updateViewOffset(cm){var off=cm.display.viewOffset=heightAtLine(cm,getL ine(cm.doc,cm.display.showingFrom));cm.display.mover.style.top=off+"px";}
68 function computeIntact(intact,changes){for(var i=0,l=changes.length||0;i<l;++i){ var change=changes[i],intact2=[],diff=change.diff||0;for(var j=0,l2=intact.lengt h;j<l2;++j){var range=intact[j];if(change.to<=range.from&&change.diff){intact2.p ush({from:range.from+diff,to:range.to+diff});}else if(change.to<=range.from||cha nge.from>=range.to){intact2.push(range);}else{if(change.from>range.from) 69 function computeIntact(intact,changes){for(var i=0,l=changes.length||0;i<l;++i){ var change=changes[i],intact2=[],diff=change.diff||0;for(var j=0,l2=intact.lengt h;j<l2;++j){var range=intact[j];if(change.to<=range.from&&change.diff){intact2.p ush({from:range.from+diff,to:range.to+diff});}else if(change.to<=range.from||cha nge.from>=range.to){intact2.push(range);}else{if(change.from>range.from)
69 intact2.push({from:range.from,to:change.from});if(change.to<range.to) 70 intact2.push({from:range.from,to:change.from});if(change.to<range.to)
70 intact2.push({from:change.to+diff,to:range.to+diff});}} 71 intact2.push({from:change.to+diff,to:range.to+diff});}}
71 intact=intact2;} 72 intact=intact2;}
72 return intact;} 73 return intact;}
73 function getDimensions(cm){var d=cm.display,left={},width={};for(var n=d.gutters .firstChild,i=0;n;n=n.nextSibling,++i){left[cm.options.gutters[i]]=n.offsetLeft; width[cm.options.gutters[i]]=n.offsetWidth;} 74 function getDimensions(cm){var d=cm.display,left={},width={};for(var n=d.gutters .firstChild,i=0;n;n=n.nextSibling,++i){left[cm.options.gutters[i]]=n.offsetLeft; width[cm.options.gutters[i]]=n.offsetWidth;}
74 return{fixedPos:compensateForHScroll(d),gutterTotalWidth:d.gutters.offsetWidth,g utterLeft:left,gutterWidth:width,wrapperWidth:d.wrapper.clientWidth};} 75 return{fixedPos:compensateForHScroll(d),gutterTotalWidth:d.gutters.offsetWidth,g utterLeft:left,gutterWidth:width,wrapperWidth:d.wrapper.clientWidth};}
75 function patchDisplay(cm,from,to,intact,updateNumbersFrom){var dims=getDimension s(cm);var display=cm.display,lineNumbers=cm.options.lineNumbers;if(!intact.lengt h&&(!webkit||!cm.display.currentWheelTarget)) 76 function patchDisplay(cm,from,to,intact,updateNumbersFrom){var dims=getDimension s(cm);var display=cm.display,lineNumbers=cm.options.lineNumbers;if(!intact.lengt h&&(!webkit||!cm.display.currentWheelTarget))
76 removeChildren(display.lineDiv);var container=display.lineDiv,cur=container.firs tChild;function rm(node){var next=node.nextSibling;if(webkit&&mac&&cm.display.cu rrentWheelTarget==node){node.style.display="none";node.lineObj=null;}else{node.p arentNode.removeChild(node);} 77 removeChildren(display.lineDiv);var container=display.lineDiv,cur=container.firs tChild;function rm(node){var next=node.nextSibling;if(webkit&&mac&&cm.display.cu rrentWheelTarget==node){node.style.display="none";node.lineObj=null;}else{node.p arentNode.removeChild(node);}
77 return next;} 78 return next;}
78 var nextIntact=intact.shift(),lineN=from;cm.doc.iter(from,to,function(line){if(n extIntact&&nextIntact.to==lineN)nextIntact=intact.shift();if(lineIsHidden(cm.doc ,line)){if(line.height!=0)updateLineHeight(line,0);if(line.widgets&&cur.previous Sibling)for(var i=0;i<line.widgets.length;++i){var w=line.widgets[i];if(w.showIf Hidden){var prev=cur.previousSibling;if(/pre/i.test(prev.nodeName)){var wrap=elt ("div",null,null,"position: relative");prev.parentNode.replaceChild(wrap,prev);w rap.appendChild(prev);prev=wrap;} 79 var nextIntact=intact.shift(),lineN=from;cm.doc.iter(from,to,function(line){if(n extIntact&&nextIntact.to==lineN)nextIntact=intact.shift();if(lineIsHidden(cm.doc ,line)){if(line.height!=0)updateLineHeight(line,0);if(line.widgets&&cur&&cur.pre viousSibling)for(var i=0;i<line.widgets.length;++i){var w=line.widgets[i];if(w.s howIfHidden){var prev=cur.previousSibling;if(/pre/i.test(prev.nodeName)){var wra p=elt("div",null,null,"position: relative");prev.parentNode.replaceChild(wrap,pr ev);wrap.appendChild(prev);prev=wrap;}
79 var wnode=prev.appendChild(elt("div",[w.node],"CodeMirror-linewidget"));if(!w.ha ndleMouseEvents)wnode.ignoreEvents=true;positionLineWidget(w,wnode,prev,dims);}} }else if(nextIntact&&nextIntact.from<=lineN&&nextIntact.to>lineN){while(cur.line Obj!=line)cur=rm(cur);if(lineNumbers&&updateNumbersFrom<=lineN&&cur.lineNumber) 80 var wnode=prev.appendChild(elt("div",[w.node],"CodeMirror-linewidget"));if(!w.ha ndleMouseEvents)wnode.ignoreEvents=true;positionLineWidget(w,wnode,prev,dims);}} }else if(nextIntact&&nextIntact.from<=lineN&&nextIntact.to>lineN){while(cur.line Obj!=line)cur=rm(cur);if(lineNumbers&&updateNumbersFrom<=lineN&&cur.lineNumber)
80 setTextContent(cur.lineNumber,lineNumberFor(cm.options,lineN));cur=cur.nextSibli ng;}else{if(line.widgets)for(var j=0,search=cur,reuse;search&&j<20;++j,search=se arch.nextSibling) 81 setTextContent(cur.lineNumber,lineNumberFor(cm.options,lineN));cur=cur.nextSibli ng;}else{if(line.widgets)for(var j=0,search=cur,reuse;search&&j<20;++j,search=se arch.nextSibling)
81 if(search.lineObj==line&&/div/i.test(search.nodeName)){reuse=search;break;} 82 if(search.lineObj==line&&/div/i.test(search.nodeName)){reuse=search;break;}
82 var lineNode=buildLineElement(cm,line,lineN,dims,reuse);if(lineNode!=reuse){cont ainer.insertBefore(lineNode,cur);}else{while(cur!=reuse)cur=rm(cur);cur=cur.next Sibling;} 83 var lineNode=buildLineElement(cm,line,lineN,dims,reuse);if(lineNode!=reuse){cont ainer.insertBefore(lineNode,cur);}else{while(cur!=reuse)cur=rm(cur);cur=cur.next Sibling;}
83 lineNode.lineObj=line;} 84 lineNode.lineObj=line;}
84 ++lineN;});while(cur)cur=rm(cur);} 85 ++lineN;});while(cur)cur=rm(cur);}
85 function buildLineElement(cm,line,lineNo,dims,reuse){var lineElement=lineContent (cm,line);var markers=line.gutterMarkers,display=cm.display,wrap;if(!cm.options. lineNumbers&&!markers&&!line.bgClass&&!line.wrapClass&&!line.widgets) 86 function buildLineElement(cm,line,lineNo,dims,reuse){var built=buildLineContent( cm,line),lineElement=built.pre;var markers=line.gutterMarkers,display=cm.display ,wrap;var bgClass=built.bgClass?built.bgClass+" "+(line.bgClass||""):line.bgClas s;if(!cm.options.lineNumbers&&!markers&&!bgClass&&!line.wrapClass&&!line.widgets )
86 return lineElement;if(reuse){reuse.alignable=null;var isOk=true,widgetsSeen=0,in sertBefore=null;for(var n=reuse.firstChild,next;n;n=next){next=n.nextSibling;if( !/\bCodeMirror-linewidget\b/.test(n.className)){reuse.removeChild(n);}else{for(v ar i=0;i<line.widgets.length;++i){var widget=line.widgets[i];if(widget.node==n.f irstChild){if(!widget.above&&!insertBefore)insertBefore=n;positionLineWidget(wid get,n,reuse,dims);++widgetsSeen;break;}} 87 return lineElement;if(reuse){reuse.alignable=null;var isOk=true,widgetsSeen=0,in sertBefore=null;for(var n=reuse.firstChild,next;n;n=next){next=n.nextSibling;if( !/\bCodeMirror-linewidget\b/.test(n.className)){reuse.removeChild(n);}else{for(v ar i=0;i<line.widgets.length;++i){var widget=line.widgets[i];if(widget.node==n.f irstChild){if(!widget.above&&!insertBefore)insertBefore=n;positionLineWidget(wid get,n,reuse,dims);++widgetsSeen;break;}}
87 if(i==line.widgets.length){isOk=false;break;}}} 88 if(i==line.widgets.length){isOk=false;break;}}}
88 reuse.insertBefore(lineElement,insertBefore);if(isOk&&widgetsSeen==line.widgets. length){wrap=reuse;reuse.className=line.wrapClass||"";}} 89 reuse.insertBefore(lineElement,insertBefore);if(isOk&&widgetsSeen==line.widgets. length){wrap=reuse;reuse.className=line.wrapClass||"";}}
89 if(!wrap){wrap=elt("div",null,line.wrapClass,"position: relative");wrap.appendCh ild(lineElement);} 90 if(!wrap){wrap=elt("div",null,line.wrapClass,"position: relative");wrap.appendCh ild(lineElement);}
90 if(line.bgClass) 91 if(bgClass)
91 wrap.insertBefore(elt("div",null,line.bgClass+" CodeMirror-linebackground"),wrap .firstChild);if(cm.options.lineNumbers||markers){var gutterWrap=wrap.insertBefor e(elt("div",null,null,"position: absolute; left: "+ 92 wrap.insertBefore(elt("div",null,bgClass+" CodeMirror-linebackground"),wrap.firs tChild);if(cm.options.lineNumbers||markers){var gutterWrap=wrap.insertBefore(elt ("div",null,null,"position: absolute; left: "+
92 (cm.options.fixedGutter?dims.fixedPos:-dims.gutterTotalWidth)+"px"),wrap.firstCh ild);if(cm.options.fixedGutter)(wrap.alignable||(wrap.alignable=[])).push(gutter Wrap);if(cm.options.lineNumbers&&(!markers||!markers["CodeMirror-linenumbers"])) 93 (cm.options.fixedGutter?dims.fixedPos:-dims.gutterTotalWidth)+"px"),wrap.firstCh ild);if(cm.options.fixedGutter)(wrap.alignable||(wrap.alignable=[])).push(gutter Wrap);if(cm.options.lineNumbers&&(!markers||!markers["CodeMirror-linenumbers"]))
93 wrap.lineNumber=gutterWrap.appendChild(elt("div",lineNumberFor(cm.options,lineNo ),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+dims.gutterLeft["CodeMi rror-linenumbers"]+"px; width: " 94 wrap.lineNumber=gutterWrap.appendChild(elt("div",lineNumberFor(cm.options,lineNo ),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+dims.gutterLeft["CodeMi rror-linenumbers"]+"px; width: "
94 +display.lineNumInnerWidth+"px"));if(markers) 95 +display.lineNumInnerWidth+"px"));if(markers)
95 for(var k=0;k<cm.options.gutters.length;++k){var id=cm.options.gutters[k],found= markers.hasOwnProperty(id)&&markers[id];if(found) 96 for(var k=0;k<cm.options.gutters.length;++k){var id=cm.options.gutters[k],found= markers.hasOwnProperty(id)&&markers[id];if(found)
96 gutterWrap.appendChild(elt("div",[found],"CodeMirror-gutter-elt","left: "+ 97 gutterWrap.appendChild(elt("div",[found],"CodeMirror-gutter-elt","left: "+
97 dims.gutterLeft[id]+"px; width: "+dims.gutterWidth[id]+"px"));}} 98 dims.gutterLeft[id]+"px; width: "+dims.gutterWidth[id]+"px"));}}
98 if(ie_lt8)wrap.style.zIndex=2;if(line.widgets&&wrap!=reuse)for(var i=0,ws=line.w idgets;i<ws.length;++i){var widget=ws[i],node=elt("div",[widget.node],"CodeMirro r-linewidget");if(!widget.handleMouseEvents)node.ignoreEvents=true;positionLineW idget(widget,node,wrap,dims);if(widget.above) 99 if(ie_lt8)wrap.style.zIndex=2;if(line.widgets&&wrap!=reuse)for(var i=0,ws=line.w idgets;i<ws.length;++i){var widget=ws[i],node=elt("div",[widget.node],"CodeMirro r-linewidget");if(!widget.handleMouseEvents)node.ignoreEvents=true;positionLineW idget(widget,node,wrap,dims);if(widget.above)
99 wrap.insertBefore(node,cm.options.lineNumbers&&line.height!=0?gutterWrap:lineEle ment);else 100 wrap.insertBefore(node,cm.options.lineNumbers&&line.height!=0?gutterWrap:lineEle ment);else
100 wrap.appendChild(node);signalLater(widget,"redraw");} 101 wrap.appendChild(node);signalLater(widget,"redraw");}
101 return wrap;} 102 return wrap;}
(...skipping 11 matching lines...) Expand all
113 iterateBidiSections(getOrder(lineObj),fromArg||0,toArg==null?lineLen:toArg,funct ion(from,to,dir){var leftPos=coords(from,"left"),rightPos,left,right;if(from==to ){rightPos=leftPos;left=right=leftPos.left;}else{rightPos=coords(to-1,"right");i f(dir=="rtl"){var tmp=leftPos;leftPos=rightPos;rightPos=tmp;} 114 iterateBidiSections(getOrder(lineObj),fromArg||0,toArg==null?lineLen:toArg,funct ion(from,to,dir){var leftPos=coords(from,"left"),rightPos,left,right;if(from==to ){rightPos=leftPos;left=right=leftPos.left;}else{rightPos=coords(to-1,"right");i f(dir=="rtl"){var tmp=leftPos;leftPos=rightPos;rightPos=tmp;}
114 left=leftPos.left;right=rightPos.right;} 115 left=leftPos.left;right=rightPos.right;}
115 if(fromArg==null&&from==0)left=pl;if(rightPos.top-leftPos.top>3){add(left,leftPo s.top,null,leftPos.bottom);left=pl;if(leftPos.bottom<rightPos.top)add(left,leftP os.bottom,null,rightPos.top);} 116 if(fromArg==null&&from==0)left=pl;if(rightPos.top-leftPos.top>3){add(left,leftPo s.top,null,leftPos.bottom);left=pl;if(leftPos.bottom<rightPos.top)add(left,leftP os.bottom,null,rightPos.top);}
116 if(toArg==null&&to==lineLen)right=clientWidth;if(!start||leftPos.top<start.top|| leftPos.top==start.top&&leftPos.left<start.left) 117 if(toArg==null&&to==lineLen)right=clientWidth;if(!start||leftPos.top<start.top|| leftPos.top==start.top&&leftPos.left<start.left)
117 start=leftPos;if(!end||rightPos.bottom>end.bottom||rightPos.bottom==end.bottom&& rightPos.right>end.right) 118 start=leftPos;if(!end||rightPos.bottom>end.bottom||rightPos.bottom==end.bottom&& rightPos.right>end.right)
118 end=rightPos;if(left<pl+1)left=pl;add(left,rightPos.top,right-left,rightPos.bott om);});return{start:start,end:end};} 119 end=rightPos;if(left<pl+1)left=pl;add(left,rightPos.top,right-left,rightPos.bott om);});return{start:start,end:end};}
119 if(sel.from.line==sel.to.line){drawForLine(sel.from.line,sel.from.ch,sel.to.ch); }else{var fromLine=getLine(doc,sel.from.line),toLine=getLine(doc,sel.to.line);va r singleVLine=visualLine(doc,fromLine)==visualLine(doc,toLine);var leftEnd=drawF orLine(sel.from.line,sel.from.ch,singleVLine?fromLine.text.length:null).end;var rightStart=drawForLine(sel.to.line,singleVLine?0:null,sel.to.ch).start;if(single VLine){if(leftEnd.top<rightStart.top-2){add(leftEnd.right,leftEnd.top,null,leftE nd.bottom);add(pl,rightStart.top,rightStart.left,rightStart.bottom);}else{add(le ftEnd.right,leftEnd.top,rightStart.left-leftEnd.right,leftEnd.bottom);}} 120 if(sel.from.line==sel.to.line){drawForLine(sel.from.line,sel.from.ch,sel.to.ch); }else{var fromLine=getLine(doc,sel.from.line),toLine=getLine(doc,sel.to.line);va r singleVLine=visualLine(doc,fromLine)==visualLine(doc,toLine);var leftEnd=drawF orLine(sel.from.line,sel.from.ch,singleVLine?fromLine.text.length:null).end;var rightStart=drawForLine(sel.to.line,singleVLine?0:null,sel.to.ch).start;if(single VLine){if(leftEnd.top<rightStart.top-2){add(leftEnd.right,leftEnd.top,null,leftE nd.bottom);add(pl,rightStart.top,rightStart.left,rightStart.bottom);}else{add(le ftEnd.right,leftEnd.top,rightStart.left-leftEnd.right,leftEnd.bottom);}}
120 if(leftEnd.bottom<rightStart.top) 121 if(leftEnd.bottom<rightStart.top)
121 add(pl,leftEnd.bottom,null,rightStart.top);} 122 add(pl,leftEnd.bottom,null,rightStart.top);}
122 removeChildrenAndAdd(display.selectionDiv,fragment);display.selectionDiv.style.d isplay="";} 123 removeChildrenAndAdd(display.selectionDiv,fragment);display.selectionDiv.style.d isplay="";}
123 function restartBlink(cm){if(!cm.state.focused)return;var display=cm.display;cle arInterval(display.blinker);var on=true;display.cursor.style.visibility=display. otherCursor.style.visibility="";display.blinker=setInterval(function(){display.c ursor.style.visibility=display.otherCursor.style.visibility=(on=!on)?"":"hidden" ;},cm.options.cursorBlinkRate);} 124 function restartBlink(cm){if(!cm.state.focused)return;var display=cm.display;cle arInterval(display.blinker);var on=true;display.cursor.style.visibility=display. otherCursor.style.visibility="";if(cm.options.cursorBlinkRate>0)
125 display.blinker=setInterval(function(){display.cursor.style.visibility=display.o therCursor.style.visibility=(on=!on)?"":"hidden";},cm.options.cursorBlinkRate);}
124 function startWorker(cm,time){if(cm.doc.mode.startState&&cm.doc.frontier<cm.disp lay.showingTo) 126 function startWorker(cm,time){if(cm.doc.mode.startState&&cm.doc.frontier<cm.disp lay.showingTo)
125 cm.state.highlight.set(time,bind(highlightWorker,cm));} 127 cm.state.highlight.set(time,bind(highlightWorker,cm));}
126 function highlightWorker(cm){var doc=cm.doc;if(doc.frontier<doc.first)doc.fronti er=doc.first;if(doc.frontier>=cm.display.showingTo)return;var end=+new Date+cm.o ptions.workTime;var state=copyState(doc.mode,getStateBefore(cm,doc.frontier));va r changed=[],prevChange;doc.iter(doc.frontier,Math.min(doc.first+doc.size,cm.dis play.showingTo+500),function(line){if(doc.frontier>=cm.display.showingFrom){var oldStyles=line.styles;line.styles=highlightLine(cm,line,state);var ischange=!old Styles||oldStyles.length!=line.styles.length;for(var i=0;!ischange&&i<oldStyles. length;++i)ischange=oldStyles[i]!=line.styles[i];if(ischange){if(prevChange&&pre vChange.end==doc.frontier)prevChange.end++;else changed.push(prevChange={start:d oc.frontier,end:doc.frontier+1});} 128 function highlightWorker(cm){var doc=cm.doc;if(doc.frontier<doc.first)doc.fronti er=doc.first;if(doc.frontier>=cm.display.showingTo)return;var end=+new Date+cm.o ptions.workTime;var state=copyState(doc.mode,getStateBefore(cm,doc.frontier));va r changed=[],prevChange;doc.iter(doc.frontier,Math.min(doc.first+doc.size,cm.dis play.showingTo+500),function(line){if(doc.frontier>=cm.display.showingFrom){var oldStyles=line.styles;line.styles=highlightLine(cm,line,state);var ischange=!old Styles||oldStyles.length!=line.styles.length;for(var i=0;!ischange&&i<oldStyles. length;++i)ischange=oldStyles[i]!=line.styles[i];if(ischange){if(prevChange&&pre vChange.end==doc.frontier)prevChange.end++;else changed.push(prevChange={start:d oc.frontier,end:doc.frontier+1});}
127 line.stateAfter=copyState(doc.mode,state);}else{processLine(cm,line,state);line. stateAfter=doc.frontier%5==0?copyState(doc.mode,state):null;} 129 line.stateAfter=copyState(doc.mode,state);}else{processLine(cm,line,state);line. stateAfter=doc.frontier%5==0?copyState(doc.mode,state):null;}
128 ++doc.frontier;if(+new Date>end){startWorker(cm,cm.options.workDelay);return tru e;}});if(changed.length) 130 ++doc.frontier;if(+new Date>end){startWorker(cm,cm.options.workDelay);return tru e;}});if(changed.length)
129 operation(cm,function(){for(var i=0;i<changed.length;++i) 131 operation(cm,function(){for(var i=0;i<changed.length;++i)
130 regChange(this,changed[i].start,changed[i].end);})();} 132 regChange(this,changed[i].start,changed[i].end);})();}
131 function findStartLine(cm,n,precise){var minindent,minline,doc=cm.doc;for(var se arch=n,lim=n-100;search>lim;--search){if(search<=doc.first)return doc.first;var line=getLine(doc,search-1);if(line.stateAfter&&(!precise||search<=doc.frontier)) return search;var indented=countColumn(line.text,null,cm.options.tabSize);if(min line==null||minindent>indented){minline=search-1;minindent=indented;}} 133 function findStartLine(cm,n,precise){var minindent,minline,doc=cm.doc,maxScan=cm .doc.mode.innerMode?1000:100;for(var search=n,lim=n-maxScan;search>lim;--search) {if(search<=doc.first)return doc.first;var line=getLine(doc,search-1);if(line.st ateAfter&&(!precise||search<=doc.frontier))return search;var indented=countColum n(line.text,null,cm.options.tabSize);if(minline==null||minindent>indented){minli ne=search-1;minindent=indented;}}
132 return minline;} 134 return minline;}
133 function getStateBefore(cm,n,precise){var doc=cm.doc,display=cm.display;if(!doc. mode.startState)return true;var pos=findStartLine(cm,n,precise),state=pos>doc.fi rst&&getLine(doc,pos-1).stateAfter;if(!state)state=startState(doc.mode);else sta te=copyState(doc.mode,state);doc.iter(pos,n,function(line){processLine(cm,line,s tate);var save=pos==n-1||pos%5==0||pos>=display.showingFrom&&pos<display.showing To;line.stateAfter=save?copyState(doc.mode,state):null;++pos;});return state;} 135 function getStateBefore(cm,n,precise){var doc=cm.doc,display=cm.display;if(!doc. mode.startState)return true;var pos=findStartLine(cm,n,precise),state=pos>doc.fi rst&&getLine(doc,pos-1).stateAfter;if(!state)state=startState(doc.mode);else sta te=copyState(doc.mode,state);doc.iter(pos,n,function(line){processLine(cm,line,s tate);var save=pos==n-1||pos%5==0||pos>=display.showingFrom&&pos<display.showing To;line.stateAfter=save?copyState(doc.mode,state):null;++pos;});return state;}
134 function paddingTop(display){return display.lineSpace.offsetTop;} 136 function paddingTop(display){return display.lineSpace.offsetTop;}
135 function paddingVert(display){return display.mover.offsetHeight-display.lineSpac e.offsetHeight;} 137 function paddingVert(display){return display.mover.offsetHeight-display.lineSpac e.offsetHeight;}
136 function paddingLeft(display){var e=removeChildrenAndAdd(display.measure,elt("pr e",null,null,"text-align: left")).appendChild(elt("span","x"));return e.offsetLe ft;} 138 function paddingLeft(display){var e=removeChildrenAndAdd(display.measure,elt("pr e",null,null,"text-align: left")).appendChild(elt("span","x"));return e.offsetLe ft;}
137 function measureChar(cm,line,ch,data,bias){var dir=-1;data=data||measureLine(cm, line);for(var pos=ch;;pos+=dir){var r=data.get(pos);if(r)break;if(dir<0&&pos==0) dir=1;} 139 function measureChar(cm,line,ch,data,bias){var dir=-1;data=data||measureLine(cm, line);if(data.crude){var left=data.left+ch*data.width;return{left:left,right:lef t+data.width,top:data.top,bottom:data.bottom};}
140 for(var pos=ch;;pos+=dir){var r=data[pos];if(r)break;if(dir<0&&pos==0)dir=1;}
138 bias=pos>ch?"left":pos<ch?"right":bias;if(bias=="left"&&r.leftSide)r=r.leftSide; else if(bias=="right"&&r.rightSide)r=r.rightSide;return{left:pos<ch?r.right:r.le ft,right:pos>ch?r.left:r.right,top:r.top,bottom:r.bottom};} 141 bias=pos>ch?"left":pos<ch?"right":bias;if(bias=="left"&&r.leftSide)r=r.leftSide; else if(bias=="right"&&r.rightSide)r=r.rightSide;return{left:pos<ch?r.right:r.le ft,right:pos>ch?r.left:r.right,top:r.top,bottom:r.bottom};}
139 function findCachedMeasurement(cm,line){var cache=cm.display.measureLineCache;fo r(var i=0;i<cache.length;++i){var memo=cache[i];if(memo.text==line.text&&memo.ma rkedSpans==line.markedSpans&&cm.display.scroller.clientWidth==memo.width&&memo.c lasses==line.textClass+"|"+line.bgClass+"|"+line.wrapClass) 142 function findCachedMeasurement(cm,line){var cache=cm.display.measureLineCache;fo r(var i=0;i<cache.length;++i){var memo=cache[i];if(memo.text==line.text&&memo.ma rkedSpans==line.markedSpans&&cm.display.scroller.clientWidth==memo.width&&memo.c lasses==line.textClass+"|"+line.bgClass+"|"+line.wrapClass)
140 return memo;}} 143 return memo;}}
141 function clearCachedMeasurement(cm,line){var exists=findCachedMeasurement(cm,lin e);if(exists)exists.text=exists.measure=exists.markedSpans=null;} 144 function clearCachedMeasurement(cm,line){var exists=findCachedMeasurement(cm,lin e);if(exists)exists.text=exists.measure=exists.markedSpans=null;}
142 function measureLine(cm,line){var cached=findCachedMeasurement(cm,line);if(cache d)return cached.measure;var measure=measureLineInner(cm,line,0,10);measure.get=f unction(num){if(this[num])return this[num];if(num<0||num>=line.text.length)retur n null;measureLineInner(cm,line,Math.max(num-50,0),Math.min(num+50,line.text.len gth),this);return this[num];};var cache=cm.display.measureLineCache;var memo={te xt:line.text,width:cm.display.scroller.clientWidth,markedSpans:line.markedSpans, measure:measure,classes:line.textClass+"|"+line.bgClass+"|"+line.wrapClass};if(c ache.length==16)cache[++cm.display.measureLineCachePos%16]=memo;else cache.push( memo);return measure;} 145 function measureLine(cm,line){var cached=findCachedMeasurement(cm,line);if(cache d)return cached.measure;var measure=measureLineInner(cm,line);var cache=cm.displ ay.measureLineCache;var memo={text:line.text,width:cm.display.scroller.clientWid th,markedSpans:line.markedSpans,measure:measure,classes:line.textClass+"|"+line. bgClass+"|"+line.wrapClass};if(cache.length==16)cache[++cm.display.measureLineCa chePos%16]=memo;else cache.push(memo);return measure;}
143 function measureLineInner(cm,line,from,to,oldMeasure){var display=cm.display,mea sure=emptyArray(line.text.length);var pre=lineContent(cm,line,measure,true,from, to);if(ie&&!ie_lt8&&!cm.options.lineWrapping&&pre.childNodes.length>100){var fra gment=document.createDocumentFragment();var chunk=10,n=pre.childNodes.length;for (var i=0,chunks=Math.ceil(n/chunk);i<chunks;++i){var wrap=elt("div",null,null,"d isplay: inline-block");for(var j=0;j<chunk&&n;++j){wrap.appendChild(pre.firstChi ld);--n;} 146 function measureLineInner(cm,line){if(!cm.options.lineWrapping&&line.text.length >=cm.options.crudeMeasuringFrom)
147 return crudelyMeasureLine(cm,line);var display=cm.display,measure=emptyArray(lin e.text.length);var pre=buildLineContent(cm,line,measure,true).pre;if(ie&&!ie_lt8 &&!cm.options.lineWrapping&&pre.childNodes.length>100){var fragment=document.cre ateDocumentFragment();var chunk=10,n=pre.childNodes.length;for(var i=0,chunks=Ma th.ceil(n/chunk);i<chunks;++i){var wrap=elt("div",null,null,"display: inline-blo ck");for(var j=0;j<chunk&&n;++j){wrap.appendChild(pre.firstChild);--n;}
144 fragment.appendChild(wrap);} 148 fragment.appendChild(wrap);}
145 pre.appendChild(fragment);} 149 pre.appendChild(fragment);}
146 removeChildrenAndAdd(display.measure,pre);var outer=getRect(display.lineDiv);var vranges=[],data=oldMeasure||emptyArray(line.text.length),maxBot=pre.offsetHeigh t;if(ie_lt9&&display.measure.first!=pre) 150 removeChildrenAndAdd(display.measure,pre);var outer=getRect(display.lineDiv);var vranges=[],data=emptyArray(line.text.length),maxBot=pre.offsetHeight;if(ie_lt9& &display.measure.first!=pre)
147 removeChildrenAndAdd(display.measure,pre);function measureRect(rect){var top=rec t.top-outer.top,bot=rect.bottom-outer.top;if(bot>maxBot)bot=maxBot;if(top<0)top= 0;for(var i=vranges.length-2;i>=0;i-=2){var rtop=vranges[i],rbot=vranges[i+1];if (rtop>bot||rbot<top)continue;if(rtop<=top&&rbot>=bot||top<=rtop&&bot>=rbot||Math .min(bot,rbot)-Math.max(top,rtop)>=(bot-top)>>1){vranges[i]=Math.min(top,rtop);v ranges[i+1]=Math.max(bot,rbot);break;}} 151 removeChildrenAndAdd(display.measure,pre);function measureRect(rect){var top=rec t.top-outer.top,bot=rect.bottom-outer.top;if(bot>maxBot)bot=maxBot;if(top<0)top= 0;for(var i=vranges.length-2;i>=0;i-=2){var rtop=vranges[i],rbot=vranges[i+1];if (rtop>bot||rbot<top)continue;if(rtop<=top&&rbot>=bot||top<=rtop&&bot>=rbot||Math .min(bot,rbot)-Math.max(top,rtop)>=(bot-top)>>1){vranges[i]=Math.min(top,rtop);v ranges[i+1]=Math.max(bot,rbot);break;}}
148 if(i<0){i=vranges.length;vranges.push(top,bot);} 152 if(i<0){i=vranges.length;vranges.push(top,bot);}
149 return{left:rect.left-outer.left,right:rect.right-outer.left,top:i,bottom:null}; } 153 return{left:rect.left-outer.left,right:rect.right-outer.left,top:i,bottom:null}; }
150 function finishRect(rect){rect.bottom=vranges[rect.top+1];rect.top=vranges[rect. top];} 154 function finishRect(rect){rect.bottom=vranges[rect.top+1];rect.top=vranges[rect. top];}
151 for(var i=0,cur;i<measure.length;++i)if(cur=measure[i]){var node=cur,rect=null;i f(/\bCodeMirror-widget\b/.test(cur.className)&&cur.getClientRects){if(cur.firstC hild.nodeType==1)node=cur.firstChild;var rects=node.getClientRects();if(rects.le ngth>1){rect=data[i]=measureRect(rects[0]);rect.rightSide=measureRect(rects[rect s.length-1]);}} 155 for(var i=0,cur;i<measure.length;++i)if(cur=measure[i]){var node=cur,rect=null;i f(/\bCodeMirror-widget\b/.test(cur.className)&&cur.getClientRects){if(cur.firstC hild.nodeType==1)node=cur.firstChild;var rects=node.getClientRects();if(rects.le ngth>1){rect=data[i]=measureRect(rects[0]);rect.rightSide=measureRect(rects[rect s.length-1]);}}
152 if(!rect)rect=data[i]=measureRect(getRect(node));if(cur.measureRight)rect.right= getRect(cur.measureRight).left;if(cur.leftSide)rect.leftSide=measureRect(getRect (cur.leftSide));} 156 if(!rect)rect=data[i]=measureRect(getRect(node));if(cur.measureRight)rect.right= getRect(cur.measureRight).left;if(cur.leftSide)rect.leftSide=measureRect(getRect (cur.leftSide));}
153 for(var i=0,cur;i<data.length;++i)if(measure[i]&&(cur=data[i])){finishRect(cur); if(cur.leftSide)finishRect(cur.leftSide);if(cur.rightSide)finishRect(cur.rightSi de);} 157 removeChildren(cm.display.measure);for(var i=0,cur;i<data.length;++i)if(cur=data [i]){finishRect(cur);if(cur.leftSide)finishRect(cur.leftSide);if(cur.rightSide)f inishRect(cur.rightSide);}
154 return data;} 158 return data;}
159 function crudelyMeasureLine(cm,line){var copy=new Line(line.text.slice(0,100),nu ll);if(line.textClass)copy.textClass=line.textClass;var measure=measureLineInner (cm,copy);var left=measureChar(cm,copy,0,measure,"left");var right=measureChar(c m,copy,99,measure,"right");return{crude:true,top:left.top,left:left.left,bottom: left.bottom,width:(right.right-left.left)/100};}
155 function measureLineWidth(cm,line){var hasBadSpan=false;if(line.markedSpans)for( var i=0;i<line.markedSpans;++i){var sp=line.markedSpans[i];if(sp.collapsed&&(sp. to==null||sp.to==line.text.length))hasBadSpan=true;} 160 function measureLineWidth(cm,line){var hasBadSpan=false;if(line.markedSpans)for( var i=0;i<line.markedSpans;++i){var sp=line.markedSpans[i];if(sp.collapsed&&(sp. to==null||sp.to==line.text.length))hasBadSpan=true;}
156 var cached=!hasBadSpan&&findCachedMeasurement(cm,line);if(cached)return measureC har(cm,line,line.text.length,cached.measure,"right").right;var pre=lineContent(c m,line,null,true);var end=pre.appendChild(zeroWidthElement(cm.display.measure)); removeChildrenAndAdd(cm.display.measure,pre);return getRect(end).right-getRect(c m.display.lineDiv).left;} 161 var cached=!hasBadSpan&&findCachedMeasurement(cm,line);if(cached||line.text.leng th>=cm.options.crudeMeasuringFrom)
162 return measureChar(cm,line,line.text.length,cached&&cached.measure,"right").righ t;var pre=buildLineContent(cm,line,null,true).pre;var end=pre.appendChild(zeroWi dthElement(cm.display.measure));removeChildrenAndAdd(cm.display.measure,pre);ret urn getRect(end).right-getRect(cm.display.lineDiv).left;}
157 function clearCaches(cm){cm.display.measureLineCache.length=cm.display.measureLi neCachePos=0;cm.display.cachedCharWidth=cm.display.cachedTextHeight=null;if(!cm. options.lineWrapping)cm.display.maxLineChanged=true;cm.display.lineNumChars=null ;} 163 function clearCaches(cm){cm.display.measureLineCache.length=cm.display.measureLi neCachePos=0;cm.display.cachedCharWidth=cm.display.cachedTextHeight=null;if(!cm. options.lineWrapping)cm.display.maxLineChanged=true;cm.display.lineNumChars=null ;}
158 function pageScrollX(){return window.pageXOffset||(document.documentElement||doc ument.body).scrollLeft;} 164 function pageScrollX(){return window.pageXOffset||(document.documentElement||doc ument.body).scrollLeft;}
159 function pageScrollY(){return window.pageYOffset||(document.documentElement||doc ument.body).scrollTop;} 165 function pageScrollY(){return window.pageYOffset||(document.documentElement||doc ument.body).scrollTop;}
160 function intoCoordSystem(cm,lineObj,rect,context){if(lineObj.widgets)for(var i=0 ;i<lineObj.widgets.length;++i)if(lineObj.widgets[i].above){var size=widgetHeight (lineObj.widgets[i]);rect.top+=size;rect.bottom+=size;} 166 function intoCoordSystem(cm,lineObj,rect,context){if(lineObj.widgets)for(var i=0 ;i<lineObj.widgets.length;++i)if(lineObj.widgets[i].above){var size=widgetHeight (lineObj.widgets[i]);rect.top+=size;rect.bottom+=size;}
161 if(context=="line")return rect;if(!context)context="local";var yOff=heightAtLine (cm,lineObj);if(context=="local")yOff+=paddingTop(cm.display);else yOff-=cm.disp lay.viewOffset;if(context=="page"||context=="window"){var lOff=getRect(cm.displa y.lineSpace);yOff+=lOff.top+(context=="window"?0:pageScrollY());var xOff=lOff.le ft+(context=="window"?0:pageScrollX());rect.left+=xOff;rect.right+=xOff;} 167 if(context=="line")return rect;if(!context)context="local";var yOff=heightAtLine (cm,lineObj);if(context=="local")yOff+=paddingTop(cm.display);else yOff-=cm.disp lay.viewOffset;if(context=="page"||context=="window"){var lOff=getRect(cm.displa y.lineSpace);yOff+=lOff.top+(context=="window"?0:pageScrollY());var xOff=lOff.le ft+(context=="window"?0:pageScrollX());rect.left+=xOff;rect.right+=xOff;}
162 rect.top+=yOff;rect.bottom+=yOff;return rect;} 168 rect.top+=yOff;rect.bottom+=yOff;return rect;}
163 function fromCoordSystem(cm,coords,context){if(context=="div")return coords;var left=coords.left,top=coords.top;if(context=="page"){left-=pageScrollX();top-=pag eScrollY();}else if(context=="local"||!context){var localBox=getRect(cm.display. sizer);left+=localBox.left;top+=localBox.top;} 169 function fromCoordSystem(cm,coords,context){if(context=="div")return coords;var left=coords.left,top=coords.top;if(context=="page"){left-=pageScrollX();top-=pag eScrollY();}else if(context=="local"||!context){var localBox=getRect(cm.display. sizer);left+=localBox.left;top+=localBox.top;}
164 var lineSpaceBox=getRect(cm.display.lineSpace);return{left:left-lineSpaceBox.lef t,top:top-lineSpaceBox.top};} 170 var lineSpaceBox=getRect(cm.display.lineSpace);return{left:left-lineSpaceBox.lef t,top:top-lineSpaceBox.top};}
165 function charCoords(cm,pos,context,lineObj,bias){if(!lineObj)lineObj=getLine(cm. doc,pos.line);return intoCoordSystem(cm,lineObj,measureChar(cm,lineObj,pos.ch,nu ll,bias),context);} 171 function charCoords(cm,pos,context,lineObj,bias){if(!lineObj)lineObj=getLine(cm. doc,pos.line);return intoCoordSystem(cm,lineObj,measureChar(cm,lineObj,pos.ch,nu ll,bias),context);}
166 function cursorCoords(cm,pos,context,lineObj,measurement){lineObj=lineObj||getLi ne(cm.doc,pos.line);if(!measurement)measurement=measureLine(cm,lineObj);function get(ch,right){var m=measureChar(cm,lineObj,ch,measurement,right?"right":"left") ;if(right)m.left=m.right;else m.right=m.left;return intoCoordSystem(cm,lineObj,m ,context);} 172 function cursorCoords(cm,pos,context,lineObj,measurement){lineObj=lineObj||getLi ne(cm.doc,pos.line);if(!measurement)measurement=measureLine(cm,lineObj);function get(ch,right){var m=measureChar(cm,lineObj,ch,measurement,right?"right":"left") ;if(right)m.left=m.right;else m.right=m.left;return intoCoordSystem(cm,lineObj,m ,context);}
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 cm.display.input.focus();} 225 cm.display.input.focus();}
220 function isReadOnly(cm){return cm.options.readOnly||cm.doc.cantEdit;} 226 function isReadOnly(cm){return cm.options.readOnly||cm.doc.cantEdit;}
221 function registerEventHandlers(cm){var d=cm.display;on(d.scroller,"mousedown",op eration(cm,onMouseDown));if(ie) 227 function registerEventHandlers(cm){var d=cm.display;on(d.scroller,"mousedown",op eration(cm,onMouseDown));if(ie)
222 on(d.scroller,"dblclick",operation(cm,function(e){if(signalDOMEvent(cm,e))return ;var pos=posFromMouse(cm,e);if(!pos||clickInGutter(cm,e)||eventInWidget(cm.displ ay,e))return;e_preventDefault(e);var word=findWordAt(getLine(cm.doc,pos.line).te xt,pos);extendSelection(cm.doc,word.from,word.to);}));else 228 on(d.scroller,"dblclick",operation(cm,function(e){if(signalDOMEvent(cm,e))return ;var pos=posFromMouse(cm,e);if(!pos||clickInGutter(cm,e)||eventInWidget(cm.displ ay,e))return;e_preventDefault(e);var word=findWordAt(getLine(cm.doc,pos.line).te xt,pos);extendSelection(cm.doc,word.from,word.to);}));else
223 on(d.scroller,"dblclick",function(e){signalDOMEvent(cm,e)||e_preventDefault(e);} );on(d.lineSpace,"selectstart",function(e){if(!eventInWidget(d,e))e_preventDefau lt(e);});if(!captureMiddleClick)on(d.scroller,"contextmenu",function(e){onContex tMenu(cm,e);});on(d.scroller,"scroll",function(){if(d.scroller.clientHeight){set ScrollTop(cm,d.scroller.scrollTop);setScrollLeft(cm,d.scroller.scrollLeft,true); signal(cm,"scroll",cm);}});on(d.scrollbarV,"scroll",function(){if(d.scroller.cli entHeight)setScrollTop(cm,d.scrollbarV.scrollTop);});on(d.scrollbarH,"scroll",fu nction(){if(d.scroller.clientHeight)setScrollLeft(cm,d.scrollbarH.scrollLeft);}) ;on(d.scroller,"mousewheel",function(e){onScrollWheel(cm,e);});on(d.scroller,"DO MMouseScroll",function(e){onScrollWheel(cm,e);});function reFocus(){if(cm.state. focused)setTimeout(bind(focusInput,cm),0);} 229 on(d.scroller,"dblclick",function(e){signalDOMEvent(cm,e)||e_preventDefault(e);} );on(d.lineSpace,"selectstart",function(e){if(!eventInWidget(d,e))e_preventDefau lt(e);});if(!captureMiddleClick)on(d.scroller,"contextmenu",function(e){onContex tMenu(cm,e);});on(d.scroller,"scroll",function(){if(d.scroller.clientHeight){set ScrollTop(cm,d.scroller.scrollTop);setScrollLeft(cm,d.scroller.scrollLeft,true); signal(cm,"scroll",cm);}});on(d.scrollbarV,"scroll",function(){if(d.scroller.cli entHeight)setScrollTop(cm,d.scrollbarV.scrollTop);});on(d.scrollbarH,"scroll",fu nction(){if(d.scroller.clientHeight)setScrollLeft(cm,d.scrollbarH.scrollLeft);}) ;on(d.scroller,"mousewheel",function(e){onScrollWheel(cm,e);});on(d.scroller,"DO MMouseScroll",function(e){onScrollWheel(cm,e);});function reFocus(){if(cm.state. focused)setTimeout(bind(focusInput,cm),0);}
224 on(d.scrollbarH,"mousedown",reFocus);on(d.scrollbarV,"mousedown",reFocus);on(d.w rapper,"scroll",function(){d.wrapper.scrollTop=d.wrapper.scrollLeft=0;});var res izeTimer;function onResize(){if(resizeTimer==null)resizeTimer=setTimeout(functio n(){resizeTimer=null;d.cachedCharWidth=d.cachedTextHeight=knownScrollbarWidth=nu ll;clearCaches(cm);runInOp(cm,bind(regChange,cm));},100);} 230 on(d.scrollbarH,"mousedown",reFocus);on(d.scrollbarV,"mousedown",reFocus);on(d.w rapper,"scroll",function(){d.wrapper.scrollTop=d.wrapper.scrollLeft=0;});var res izeTimer;function onResize(){if(resizeTimer==null)resizeTimer=setTimeout(functio n(){resizeTimer=null;d.cachedCharWidth=d.cachedTextHeight=knownScrollbarWidth=nu ll;clearCaches(cm);runInOp(cm,bind(regChange,cm));},100);}
225 on(window,"resize",onResize);function unregister(){for(var p=d.wrapper.parentNod e;p&&p!=document.body;p=p.parentNode){} 231 on(window,"resize",onResize);function unregister(){for(var p=d.wrapper.parentNod e;p&&p!=document.body;p=p.parentNode){}
226 if(p)setTimeout(unregister,5000);else off(window,"resize",onResize);} 232 if(p)setTimeout(unregister,5000);else off(window,"resize",onResize);}
227 setTimeout(unregister,5000);on(d.input,"keyup",operation(cm,function(e){if(signa lDOMEvent(cm,e)||cm.options.onKeyEvent&&cm.options.onKeyEvent(cm,addStop(e)))ret urn;if(e.keyCode==16)cm.doc.sel.shift=false;}));on(d.input,"input",bind(fastPoll ,cm));on(d.input,"keydown",operation(cm,onKeyDown));on(d.input,"keypress",operat ion(cm,onKeyPress));on(d.input,"focus",bind(onFocus,cm));on(d.input,"blur",bind( onBlur,cm));function drag_(e){if(signalDOMEvent(cm,e)||cm.options.onDragEvent&&c m.options.onDragEvent(cm,addStop(e)))return;e_stop(e);} 233 setTimeout(unregister,5000);on(d.input,"keyup",operation(cm,function(e){if(signa lDOMEvent(cm,e)||cm.options.onKeyEvent&&cm.options.onKeyEvent(cm,addStop(e)))ret urn;if(e.keyCode==16)cm.doc.sel.shift=false;}));on(d.input,"input",bind(fastPoll ,cm));on(d.input,"keydown",operation(cm,onKeyDown));on(d.input,"keypress",operat ion(cm,onKeyPress));on(d.input,"focus",bind(onFocus,cm));on(d.input,"blur",bind( onBlur,cm));function drag_(e){if(signalDOMEvent(cm,e)||cm.options.onDragEvent&&c m.options.onDragEvent(cm,addStop(e)))return;e_stop(e);}
228 if(cm.options.dragDrop){on(d.scroller,"dragstart",function(e){onDragStart(cm,e); });on(d.scroller,"dragenter",drag_);on(d.scroller,"dragover",drag_);on(d.scrolle r,"drop",operation(cm,onDrop));} 234 if(cm.options.dragDrop){on(d.scroller,"dragstart",function(e){onDragStart(cm,e); });on(d.scroller,"dragenter",drag_);on(d.scroller,"dragover",drag_);on(d.scrolle r,"drop",operation(cm,onDrop));}
229 on(d.scroller,"paste",function(e){if(eventInWidget(d,e))return;focusInput(cm);fa stPoll(cm);});on(d.input,"paste",function(){if(webkit&&!cm.state.fakedLastChar){ var start=d.input.selectionStart,end=d.input.selectionEnd;d.input.value+="$";d.i nput.selectionStart=start;d.input.selectionEnd=end;cm.state.fakedLastChar=true;} 235 on(d.scroller,"paste",function(e){if(eventInWidget(d,e))return;focusInput(cm);fa stPoll(cm);});on(d.input,"paste",function(){if(webkit&&!cm.state.fakedLastChar&& !(new Date-cm.state.lastMiddleDown<200)){var start=d.input.selectionStart,end=d. input.selectionEnd;d.input.value+="$";d.input.selectionStart=start;d.input.selec tionEnd=end;cm.state.fakedLastChar=true;}
230 cm.state.pasteIncoming=true;fastPoll(cm);});function prepareCopy(){if(d.inaccura teSelection){d.prevInput="";d.inaccurateSelection=false;d.input.value=cm.getSele ction();selectInput(d.input);}} 236 cm.state.pasteIncoming=true;fastPoll(cm);});function prepareCopy(){if(d.inaccura teSelection){d.prevInput="";d.inaccurateSelection=false;d.input.value=cm.getSele ction();selectInput(d.input);}}
231 on(d.input,"cut",prepareCopy);on(d.input,"copy",prepareCopy);if(khtml)on(d.sizer ,"mouseup",function(){if(document.activeElement==d.input)d.input.blur();focusInp ut(cm);});} 237 on(d.input,"cut",prepareCopy);on(d.input,"copy",prepareCopy);if(khtml)on(d.sizer ,"mouseup",function(){if(document.activeElement==d.input)d.input.blur();focusInp ut(cm);});}
232 function eventInWidget(display,e){for(var n=e_target(e);n!=display.wrapper;n=n.p arentNode){if(!n||n.ignoreEvents||n.parentNode==display.sizer&&n!=display.mover) return true;}} 238 function eventInWidget(display,e){for(var n=e_target(e);n!=display.wrapper;n=n.p arentNode){if(!n||n.ignoreEvents||n.parentNode==display.sizer&&n!=display.mover) return true;}}
233 function posFromMouse(cm,e,liberal){var display=cm.display;if(!liberal){var targ et=e_target(e);if(target==display.scrollbarH||target==display.scrollbarH.firstCh ild||target==display.scrollbarV||target==display.scrollbarV.firstChild||target== display.scrollbarFiller||target==display.gutterFiller)return null;} 239 function posFromMouse(cm,e,liberal){var display=cm.display;if(!liberal){var targ et=e_target(e);if(target==display.scrollbarH||target==display.scrollbarH.firstCh ild||target==display.scrollbarV||target==display.scrollbarV.firstChild||target== display.scrollbarFiller||target==display.gutterFiller)return null;}
234 var x,y,space=getRect(display.lineSpace);try{x=e.clientX;y=e.clientY;}catch(e){r eturn null;} 240 var x,y,space=getRect(display.lineSpace);try{x=e.clientX;y=e.clientY;}catch(e){r eturn null;}
235 return coordsChar(cm,x-space.left,y-space.top);} 241 return coordsChar(cm,x-space.left,y-space.top);}
236 var lastClick,lastDoubleClick;function onMouseDown(e){if(signalDOMEvent(this,e)) return;var cm=this,display=cm.display,doc=cm.doc,sel=doc.sel;sel.shift=e.shiftKe y;if(eventInWidget(display,e)){if(!webkit){display.scroller.draggable=false;setT imeout(function(){display.scroller.draggable=true;},100);} 242 var lastClick,lastDoubleClick;function onMouseDown(e){if(signalDOMEvent(this,e)) return;var cm=this,display=cm.display,doc=cm.doc,sel=doc.sel;sel.shift=e.shiftKe y;if(eventInWidget(display,e)){if(!webkit){display.scroller.draggable=false;setT imeout(function(){display.scroller.draggable=true;},100);}
237 return;} 243 return;}
238 if(clickInGutter(cm,e))return;var start=posFromMouse(cm,e);switch(e_button(e)){c ase 3:if(captureMiddleClick)onContextMenu.call(cm,cm,e);return;case 2:if(start)e xtendSelection(cm.doc,start);setTimeout(bind(focusInput,cm),20);e_preventDefault (e);return;} 244 if(clickInGutter(cm,e))return;var start=posFromMouse(cm,e);switch(e_button(e)){c ase 3:if(captureMiddleClick)onContextMenu.call(cm,cm,e);return;case 2:if(webkit) cm.state.lastMiddleDown=+new Date;if(start)extendSelection(cm.doc,start);setTime out(bind(focusInput,cm),20);e_preventDefault(e);return;}
239 if(!start){if(e_target(e)==display.scroller)e_preventDefault(e);return;} 245 if(!start){if(e_target(e)==display.scroller)e_preventDefault(e);return;}
240 if(!cm.state.focused)onFocus(cm);var now=+new Date,type="single";if(lastDoubleCl ick&&lastDoubleClick.time>now-400&&posEq(lastDoubleClick.pos,start)){type="tripl e";e_preventDefault(e);setTimeout(bind(focusInput,cm),20);selectLine(cm,start.li ne);}else if(lastClick&&lastClick.time>now-400&&posEq(lastClick.pos,start)){type ="double";lastDoubleClick={time:now,pos:start};e_preventDefault(e);var word=find WordAt(getLine(doc,start.line).text,start);extendSelection(cm.doc,word.from,word .to);}else{lastClick={time:now,pos:start};} 246 if(!cm.state.focused)onFocus(cm);var now=+new Date,type="single";if(lastDoubleCl ick&&lastDoubleClick.time>now-400&&posEq(lastDoubleClick.pos,start)){type="tripl e";e_preventDefault(e);setTimeout(bind(focusInput,cm),20);selectLine(cm,start.li ne);}else if(lastClick&&lastClick.time>now-400&&posEq(lastClick.pos,start)){type ="double";lastDoubleClick={time:now,pos:start};e_preventDefault(e);var word=find WordAt(getLine(doc,start.line).text,start);extendSelection(cm.doc,word.from,word .to);}else{lastClick={time:now,pos:start};}
241 var last=start;if(cm.options.dragDrop&&dragAndDrop&&!isReadOnly(cm)&&!posEq(sel. from,sel.to)&&!posLess(start,sel.from)&&!posLess(sel.to,start)&&type=="single"){ var dragEnd=operation(cm,function(e2){if(webkit)display.scroller.draggable=false ;cm.state.draggingText=false;off(document,"mouseup",dragEnd);off(display.scrolle r,"drop",dragEnd);if(Math.abs(e.clientX-e2.clientX)+Math.abs(e.clientY-e2.client Y)<10){e_preventDefault(e2);extendSelection(cm.doc,start);focusInput(cm);}});if( webkit)display.scroller.draggable=true;cm.state.draggingText=dragEnd;if(display. scroller.dragDrop)display.scroller.dragDrop();on(document,"mouseup",dragEnd);on( display.scroller,"drop",dragEnd);return;} 247 var last=start;if(cm.options.dragDrop&&dragAndDrop&&!isReadOnly(cm)&&!posEq(sel. from,sel.to)&&!posLess(start,sel.from)&&!posLess(sel.to,start)&&type=="single"){ var dragEnd=operation(cm,function(e2){if(webkit)display.scroller.draggable=false ;cm.state.draggingText=false;off(document,"mouseup",dragEnd);off(display.scrolle r,"drop",dragEnd);if(Math.abs(e.clientX-e2.clientX)+Math.abs(e.clientY-e2.client Y)<10){e_preventDefault(e2);extendSelection(cm.doc,start);focusInput(cm);}});if( webkit)display.scroller.draggable=true;cm.state.draggingText=dragEnd;if(display. scroller.dragDrop)display.scroller.dragDrop();on(document,"mouseup",dragEnd);on( display.scroller,"drop",dragEnd);return;}
242 e_preventDefault(e);if(type=="single")extendSelection(cm.doc,clipPos(doc,start)) ;var startstart=sel.from,startend=sel.to,lastPos=start;function doSelect(cur){if (posEq(lastPos,cur))return;lastPos=cur;if(type=="single"){extendSelection(cm.doc ,clipPos(doc,start),cur);return;} 248 e_preventDefault(e);if(type=="single")extendSelection(cm.doc,clipPos(doc,start)) ;var startstart=sel.from,startend=sel.to,lastPos=start;function doSelect(cur){if (posEq(lastPos,cur))return;lastPos=cur;if(type=="single"){extendSelection(cm.doc ,clipPos(doc,start),cur);return;}
243 startstart=clipPos(doc,startstart);startend=clipPos(doc,startend);if(type=="doub le"){var word=findWordAt(getLine(doc,cur.line).text,cur);if(posLess(cur,startsta rt))extendSelection(cm.doc,word.from,startend);else extendSelection(cm.doc,start start,word.to);}else if(type=="triple"){if(posLess(cur,startstart))extendSelecti on(cm.doc,startend,clipPos(doc,Pos(cur.line,0)));else extendSelection(cm.doc,sta rtstart,clipPos(doc,Pos(cur.line+1,0)));}} 249 startstart=clipPos(doc,startstart);startend=clipPos(doc,startend);if(type=="doub le"){var word=findWordAt(getLine(doc,cur.line).text,cur);if(posLess(cur,startsta rt))extendSelection(cm.doc,word.from,startend);else extendSelection(cm.doc,start start,word.to);}else if(type=="triple"){if(posLess(cur,startstart))extendSelecti on(cm.doc,startend,clipPos(doc,Pos(cur.line,0)));else extendSelection(cm.doc,sta rtstart,clipPos(doc,Pos(cur.line+1,0)));}}
244 var editorSize=getRect(display.wrapper);var counter=0;function extend(e){var cur Count=++counter;var cur=posFromMouse(cm,e,true);if(!cur)return;if(!posEq(cur,las t)){if(!cm.state.focused)onFocus(cm);last=cur;doSelect(cur);var visible=visibleL ines(display,doc);if(cur.line>=visible.to||cur.line<visible.from) 250 var editorSize=getRect(display.wrapper);var counter=0;function extend(e){var cur Count=++counter;var cur=posFromMouse(cm,e,true);if(!cur)return;if(!posEq(cur,las t)){if(!cm.state.focused)onFocus(cm);last=cur;doSelect(cur);var visible=visibleL ines(display,doc);if(cur.line>=visible.to||cur.line<visible.from)
245 setTimeout(operation(cm,function(){if(counter==curCount)extend(e);}),150);}else{ var outside=e.clientY<editorSize.top?-20:e.clientY>editorSize.bottom?20:0;if(out side)setTimeout(operation(cm,function(){if(counter!=curCount)return;display.scro ller.scrollTop+=outside;extend(e);}),50);}} 251 setTimeout(operation(cm,function(){if(counter==curCount)extend(e);}),150);}else{ var outside=e.clientY<editorSize.top?-20:e.clientY>editorSize.bottom?20:0;if(out side)setTimeout(operation(cm,function(){if(counter!=curCount)return;display.scro ller.scrollTop+=outside;extend(e);}),50);}}
246 function done(e){counter=Infinity;e_preventDefault(e);focusInput(cm);off(documen t,"mousemove",move);off(document,"mouseup",up);} 252 function done(e){counter=Infinity;e_preventDefault(e);focusInput(cm);off(documen t,"mousemove",move);off(document,"mouseup",up);}
247 var move=operation(cm,function(e){if(!ie&&!e_button(e))done(e);else extend(e);}) ;var up=operation(cm,done);on(document,"mousemove",move);on(document,"mouseup",u p);} 253 var move=operation(cm,function(e){if(!ie&&!e_button(e))done(e);else extend(e);}) ;var up=operation(cm,done);on(document,"mousemove",move);on(document,"mouseup",u p);}
248 function clickInGutter(cm,e){var display=cm.display;try{var mX=e.clientX,mY=e.cl ientY;} 254 function gutterEvent(cm,e,type,prevent,signalfn){try{var mX=e.clientX,mY=e.clien tY;}
249 catch(e){return false;} 255 catch(e){return false;}
250 if(mX>=Math.floor(getRect(display.gutters).right))return false;e_preventDefault( e);if(!hasHandler(cm,"gutterClick"))return true;var lineBox=getRect(display.line Div);if(mY>lineBox.bottom)return true;mY-=lineBox.top-display.viewOffset;for(var i=0;i<cm.options.gutters.length;++i){var g=display.gutters.childNodes[i];if(g&& getRect(g).right>=mX){var line=lineAtHeight(cm.doc,mY);var gutter=cm.options.gut ters[i];signalLater(cm,"gutterClick",cm,line,gutter,e);break;}} 256 if(mX>=Math.floor(getRect(cm.display.gutters).right))return false;if(prevent)e_p reventDefault(e);var display=cm.display;var lineBox=getRect(display.lineDiv);if( mY>lineBox.bottom||!hasHandler(cm,type))return e_defaultPrevented(e);mY-=lineBox .top-display.viewOffset;for(var i=0;i<cm.options.gutters.length;++i){var g=displ ay.gutters.childNodes[i];if(g&&getRect(g).right>=mX){var line=lineAtHeight(cm.do c,mY);var gutter=cm.options.gutters[i];signalfn(cm,type,cm,line,gutter,e);return e_defaultPrevented(e);}}}
251 return true;} 257 function contextMenuInGutter(cm,e){if(!hasHandler(cm,"gutterContextMenu"))return false;return gutterEvent(cm,e,"gutterContextMenu",false,signal);}
258 function clickInGutter(cm,e){return gutterEvent(cm,e,"gutterClick",true,signalLa ter);}
252 var lastDrop=0;function onDrop(e){var cm=this;if(signalDOMEvent(cm,e)||eventInWi dget(cm.display,e)||(cm.options.onDragEvent&&cm.options.onDragEvent(cm,addStop(e )))) 259 var lastDrop=0;function onDrop(e){var cm=this;if(signalDOMEvent(cm,e)||eventInWi dget(cm.display,e)||(cm.options.onDragEvent&&cm.options.onDragEvent(cm,addStop(e ))))
253 return;e_preventDefault(e);if(ie)lastDrop=+new Date;var pos=posFromMouse(cm,e,tr ue),files=e.dataTransfer.files;if(!pos||isReadOnly(cm))return;if(files&&files.le ngth&&window.FileReader&&window.File){var n=files.length,text=Array(n),read=0;va r loadFile=function(file,i){var reader=new FileReader;reader.onload=function(){t ext[i]=reader.result;if(++read==n){pos=clipPos(cm.doc,pos);makeChange(cm.doc,{fr om:pos,to:pos,text:splitLines(text.join("\n")),origin:"paste"},"around");}};read er.readAsText(file);};for(var i=0;i<n;++i)loadFile(files[i],i);}else{if(cm.state .draggingText&&!(posLess(pos,cm.doc.sel.from)||posLess(cm.doc.sel.to,pos))){cm.s tate.draggingText(e);setTimeout(bind(focusInput,cm),20);return;} 260 return;e_preventDefault(e);if(ie)lastDrop=+new Date;var pos=posFromMouse(cm,e,tr ue),files=e.dataTransfer.files;if(!pos||isReadOnly(cm))return;if(files&&files.le ngth&&window.FileReader&&window.File){var n=files.length,text=Array(n),read=0;va r loadFile=function(file,i){var reader=new FileReader;reader.onload=function(){t ext[i]=reader.result;if(++read==n){pos=clipPos(cm.doc,pos);makeChange(cm.doc,{fr om:pos,to:pos,text:splitLines(text.join("\n")),origin:"paste"},"around");}};read er.readAsText(file);};for(var i=0;i<n;++i)loadFile(files[i],i);}else{if(cm.state .draggingText&&!(posLess(pos,cm.doc.sel.from)||posLess(cm.doc.sel.to,pos))){cm.s tate.draggingText(e);setTimeout(bind(focusInput,cm),20);return;}
254 try{var text=e.dataTransfer.getData("Text");if(text){var curFrom=cm.doc.sel.from ,curTo=cm.doc.sel.to;setSelection(cm.doc,pos,pos);if(cm.state.draggingText)repla ceRange(cm.doc,"",curFrom,curTo,"paste");cm.replaceSelection(text,null,"paste"); focusInput(cm);onFocus(cm);}} 261 try{var text=e.dataTransfer.getData("Text");if(text){var curFrom=cm.doc.sel.from ,curTo=cm.doc.sel.to;setSelection(cm.doc,pos,pos);if(cm.state.draggingText)repla ceRange(cm.doc,"",curFrom,curTo,"paste");cm.replaceSelection(text,null,"paste"); focusInput(cm);onFocus(cm);}}
255 catch(e){}}} 262 catch(e){}}}
256 function onDragStart(cm,e){if(ie&&(!cm.state.draggingText||+new Date-lastDrop<10 0)){e_stop(e);return;} 263 function onDragStart(cm,e){if(ie&&(!cm.state.draggingText||+new Date-lastDrop<10 0)){e_stop(e);return;}
257 if(signalDOMEvent(cm,e)||eventInWidget(cm.display,e))return;var txt=cm.getSelect ion();e.dataTransfer.setData("Text",txt);if(e.dataTransfer.setDragImage&&!safari ){var img=elt("img",null,null,"position: fixed; left: 0; top: 0;");if(opera){img .width=img.height=1;cm.display.wrapper.appendChild(img);img._top=img.offsetTop;} 264 if(signalDOMEvent(cm,e)||eventInWidget(cm.display,e))return;var txt=cm.getSelect ion();e.dataTransfer.setData("Text",txt);if(e.dataTransfer.setDragImage&&!safari ){var img=elt("img",null,null,"position: fixed; left: 0; top: 0;");img.src="data :image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";if(opera ){img.width=img.height=1;cm.display.wrapper.appendChild(img);img._top=img.offset Top;}
258 e.dataTransfer.setDragImage(img,0,0);if(opera)img.parentNode.removeChild(img);}} 265 e.dataTransfer.setDragImage(img,0,0);if(opera)img.parentNode.removeChild(img);}}
259 function setScrollTop(cm,val){if(Math.abs(cm.doc.scrollTop-val)<2)return;cm.doc. scrollTop=val;if(!gecko)updateDisplay(cm,[],val);if(cm.display.scroller.scrollTo p!=val)cm.display.scroller.scrollTop=val;if(cm.display.scrollbarV.scrollTop!=val )cm.display.scrollbarV.scrollTop=val;if(gecko)updateDisplay(cm,[]);startWorker(c m,100);} 266 function setScrollTop(cm,val){if(Math.abs(cm.doc.scrollTop-val)<2)return;cm.doc. scrollTop=val;if(!gecko)updateDisplay(cm,[],val);if(cm.display.scroller.scrollTo p!=val)cm.display.scroller.scrollTop=val;if(cm.display.scrollbarV.scrollTop!=val )cm.display.scrollbarV.scrollTop=val;if(gecko)updateDisplay(cm,[]);startWorker(c m,100);}
260 function setScrollLeft(cm,val,isScroller){if(isScroller?val==cm.doc.scrollLeft:M ath.abs(cm.doc.scrollLeft-val)<2)return;val=Math.min(val,cm.display.scroller.scr ollWidth-cm.display.scroller.clientWidth);cm.doc.scrollLeft=val;alignHorizontall y(cm);if(cm.display.scroller.scrollLeft!=val)cm.display.scroller.scrollLeft=val; if(cm.display.scrollbarH.scrollLeft!=val)cm.display.scrollbarH.scrollLeft=val;} 267 function setScrollLeft(cm,val,isScroller){if(isScroller?val==cm.doc.scrollLeft:M ath.abs(cm.doc.scrollLeft-val)<2)return;val=Math.min(val,cm.display.scroller.scr ollWidth-cm.display.scroller.clientWidth);cm.doc.scrollLeft=val;alignHorizontall y(cm);if(cm.display.scroller.scrollLeft!=val)cm.display.scroller.scrollLeft=val; if(cm.display.scrollbarH.scrollLeft!=val)cm.display.scrollbarH.scrollLeft=val;}
261 var wheelSamples=0,wheelPixelsPerUnit=null;if(ie)wheelPixelsPerUnit=-.53;else if (gecko)wheelPixelsPerUnit=15;else if(chrome)wheelPixelsPerUnit=-.7;else if(safar i)wheelPixelsPerUnit=-1/3;function onScrollWheel(cm,e){var dx=e.wheelDeltaX,dy=e .wheelDeltaY;if(dx==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS)dx=e.detail;if(dy= =null&&e.detail&&e.axis==e.VERTICAL_AXIS)dy=e.detail;else if(dy==null)dy=e.wheel Delta;var display=cm.display,scroll=display.scroller;if(!(dx&&scroll.scrollWidth >scroll.clientWidth||dy&&scroll.scrollHeight>scroll.clientHeight))return;if(dy&& mac&&webkit){for(var cur=e.target;cur!=scroll;cur=cur.parentNode){if(cur.lineObj ){cm.display.currentWheelTarget=cur;break;}}} 268 var wheelSamples=0,wheelPixelsPerUnit=null;if(ie)wheelPixelsPerUnit=-.53;else if (gecko)wheelPixelsPerUnit=15;else if(chrome)wheelPixelsPerUnit=-.7;else if(safar i)wheelPixelsPerUnit=-1/3;function onScrollWheel(cm,e){var dx=e.wheelDeltaX,dy=e .wheelDeltaY;if(dx==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS)dx=e.detail;if(dy= =null&&e.detail&&e.axis==e.VERTICAL_AXIS)dy=e.detail;else if(dy==null)dy=e.wheel Delta;var display=cm.display,scroll=display.scroller;if(!(dx&&scroll.scrollWidth >scroll.clientWidth||dy&&scroll.scrollHeight>scroll.clientHeight))return;if(dy&& mac&&webkit){for(var cur=e.target;cur!=scroll;cur=cur.parentNode){if(cur.lineObj ){cm.display.currentWheelTarget=cur;break;}}}
262 if(dx&&!gecko&&!opera&&wheelPixelsPerUnit!=null){if(dy) 269 if(dx&&!gecko&&!opera&&wheelPixelsPerUnit!=null){if(dy)
263 setScrollTop(cm,Math.max(0,Math.min(scroll.scrollTop+dy*wheelPixelsPerUnit,scrol l.scrollHeight-scroll.clientHeight)));setScrollLeft(cm,Math.max(0,Math.min(scrol l.scrollLeft+dx*wheelPixelsPerUnit,scroll.scrollWidth-scroll.clientWidth)));e_pr eventDefault(e);display.wheelStartX=null;return;} 270 setScrollTop(cm,Math.max(0,Math.min(scroll.scrollTop+dy*wheelPixelsPerUnit,scrol l.scrollHeight-scroll.clientHeight)));setScrollLeft(cm,Math.max(0,Math.min(scrol l.scrollLeft+dx*wheelPixelsPerUnit,scroll.scrollWidth-scroll.clientWidth)));e_pr eventDefault(e);display.wheelStartX=null;return;}
264 if(dy&&wheelPixelsPerUnit!=null){var pixels=dy*wheelPixelsPerUnit;var top=cm.doc .scrollTop,bot=top+display.wrapper.clientHeight;if(pixels<0)top=Math.max(0,top+p ixels-50);else bot=Math.min(cm.doc.height,bot+pixels+50);updateDisplay(cm,[],{to p:top,bottom:bot});} 271 if(dy&&wheelPixelsPerUnit!=null){var pixels=dy*wheelPixelsPerUnit;var top=cm.doc .scrollTop,bot=top+display.wrapper.clientHeight;if(pixels<0)top=Math.max(0,top+p ixels-50);else bot=Math.min(cm.doc.height,bot+pixels+50);updateDisplay(cm,[],{to p:top,bottom:bot});}
265 if(wheelSamples<20){if(display.wheelStartX==null){display.wheelStartX=scroll.scr ollLeft;display.wheelStartY=scroll.scrollTop;display.wheelDX=dx;display.wheelDY= dy;setTimeout(function(){if(display.wheelStartX==null)return;var movedX=scroll.s crollLeft-display.wheelStartX;var movedY=scroll.scrollTop-display.wheelStartY;va r sample=(movedY&&display.wheelDY&&movedY/display.wheelDY)||(movedX&&display.whe elDX&&movedX/display.wheelDX);display.wheelStartX=display.wheelStartY=null;if(!s ample)return;wheelPixelsPerUnit=(wheelPixelsPerUnit*wheelSamples+sample)/(wheelS amples+1);++wheelSamples;},200);}else{display.wheelDX+=dx;display.wheelDY+=dy;}} } 272 if(wheelSamples<20){if(display.wheelStartX==null){display.wheelStartX=scroll.scr ollLeft;display.wheelStartY=scroll.scrollTop;display.wheelDX=dx;display.wheelDY= dy;setTimeout(function(){if(display.wheelStartX==null)return;var movedX=scroll.s crollLeft-display.wheelStartX;var movedY=scroll.scrollTop-display.wheelStartY;va r sample=(movedY&&display.wheelDY&&movedY/display.wheelDY)||(movedX&&display.whe elDX&&movedX/display.wheelDX);display.wheelStartX=display.wheelStartY=null;if(!s ample)return;wheelPixelsPerUnit=(wheelPixelsPerUnit*wheelSamples+sample)/(wheelS amples+1);++wheelSamples;},200);}else{display.wheelDX+=dx;display.wheelDY+=dy;}} }
266 function doHandleBinding(cm,bound,dropShift){if(typeof bound=="string"){bound=co mmands[bound];if(!bound)return false;} 273 function doHandleBinding(cm,bound,dropShift){if(typeof bound=="string"){bound=co mmands[bound];if(!bound)return false;}
267 if(cm.display.pollingFast&&readInput(cm))cm.display.pollingFast=false;var doc=cm .doc,prevShift=doc.sel.shift,done=false;try{if(isReadOnly(cm))cm.state.suppressE dits=true;if(dropShift)doc.sel.shift=false;done=bound(cm)!=Pass;}finally{doc.sel .shift=prevShift;cm.state.suppressEdits=false;} 274 if(cm.display.pollingFast&&readInput(cm))cm.display.pollingFast=false;var doc=cm .doc,prevShift=doc.sel.shift,done=false;try{if(isReadOnly(cm))cm.state.suppressE dits=true;if(dropShift)doc.sel.shift=false;done=bound(cm)!=Pass;}finally{doc.sel .shift=prevShift;cm.state.suppressEdits=false;}
268 return done;} 275 return done;}
269 function allKeyMaps(cm){var maps=cm.state.keyMaps.slice(0);if(cm.options.extraKe ys)maps.push(cm.options.extraKeys);maps.push(cm.options.keyMap);return maps;} 276 function allKeyMaps(cm){var maps=cm.state.keyMaps.slice(0);if(cm.options.extraKe ys)maps.push(cm.options.extraKeys);maps.push(cm.options.keyMap);return maps;}
270 var maybeTransition;function handleKeyBinding(cm,e){var startMap=getKeyMap(cm.op tions.keyMap),next=startMap.auto;clearTimeout(maybeTransition);if(next&&!isModif ierKey(e))maybeTransition=setTimeout(function(){if(getKeyMap(cm.options.keyMap)= =startMap){cm.options.keyMap=(next.call?next.call(null,cm):next);keyMapChanged(c m);}},50);var name=keyName(e,true),handled=false;if(!name)return false;var keyma ps=allKeyMaps(cm);if(e.shiftKey){handled=lookupKey("Shift-"+name,keymaps,functio n(b){return doHandleBinding(cm,b,true);})||lookupKey(name,keymaps,function(b){if (typeof b=="string"?/^go[A-Z]/.test(b):b.motion) 277 var maybeTransition;function handleKeyBinding(cm,e){var startMap=getKeyMap(cm.op tions.keyMap),next=startMap.auto;clearTimeout(maybeTransition);if(next&&!isModif ierKey(e))maybeTransition=setTimeout(function(){if(getKeyMap(cm.options.keyMap)= =startMap){cm.options.keyMap=(next.call?next.call(null,cm):next);keyMapChanged(c m);}},50);var name=keyName(e,true),handled=false;if(!name)return false;var keyma ps=allKeyMaps(cm);if(e.shiftKey){handled=lookupKey("Shift-"+name,keymaps,functio n(b){return doHandleBinding(cm,b,true);})||lookupKey(name,keymaps,function(b){if (typeof b=="string"?/^go[A-Z]/.test(b):b.motion)
271 return doHandleBinding(cm,b);});}else{handled=lookupKey(name,keymaps,function(b) {return doHandleBinding(cm,b);});} 278 return doHandleBinding(cm,b);});}else{handled=lookupKey(name,keymaps,function(b) {return doHandleBinding(cm,b);});}
272 if(handled){e_preventDefault(e);restartBlink(cm);if(ie_lt9){e.oldKeyCode=e.keyCo de;e.keyCode=0;} 279 if(handled){e_preventDefault(e);restartBlink(cm);if(ie_lt9){e.oldKeyCode=e.keyCo de;e.keyCode=0;}
273 signalLater(cm,"keyHandled",cm,name,e);} 280 signalLater(cm,"keyHandled",cm,name,e);}
274 return handled;} 281 return handled;}
275 function handleCharBinding(cm,e,ch){var handled=lookupKey("'"+ch+"'",allKeyMaps( cm),function(b){return doHandleBinding(cm,b,true);});if(handled){e_preventDefaul t(e);restartBlink(cm);signalLater(cm,"keyHandled",cm,"'"+ch+"'",e);} 282 function handleCharBinding(cm,e,ch){var handled=lookupKey("'"+ch+"'",allKeyMaps( cm),function(b){return doHandleBinding(cm,b,true);});if(handled){e_preventDefaul t(e);restartBlink(cm);signalLater(cm,"keyHandled",cm,"'"+ch+"'",e);}
276 return handled;} 283 return handled;}
277 var lastStoppedKey=null;function onKeyDown(e){var cm=this;if(!cm.state.focused)o nFocus(cm);if(ie&&e.keyCode==27){e.returnValue=false;} 284 var lastStoppedKey=null;function onKeyDown(e){var cm=this;if(!cm.state.focused)o nFocus(cm);if(signalDOMEvent(cm,e)||cm.options.onKeyEvent&&cm.options.onKeyEvent (cm,addStop(e)))return;if(ie&&e.keyCode==27)e.returnValue=false;var code=e.keyCo de;cm.doc.sel.shift=code==16||e.shiftKey;var handled=handleKeyBinding(cm,e);if(o pera){lastStoppedKey=handled?code:null;if(!handled&&code==88&&!hasCopyEvent&&(ma c?e.metaKey:e.ctrlKey))
278 if(signalDOMEvent(cm,e)||cm.options.onKeyEvent&&cm.options.onKeyEvent(cm,addStop (e)))return;var code=e.keyCode;cm.doc.sel.shift=code==16||e.shiftKey;var handled =handleKeyBinding(cm,e);if(opera){lastStoppedKey=handled?code:null;if(!handled&& code==88&&!hasCopyEvent&&(mac?e.metaKey:e.ctrlKey))
279 cm.replaceSelection("");}} 285 cm.replaceSelection("");}}
280 function onKeyPress(e){var cm=this;if(signalDOMEvent(cm,e)||cm.options.onKeyEven t&&cm.options.onKeyEvent(cm,addStop(e)))return;var keyCode=e.keyCode,charCode=e. charCode;if(opera&&keyCode==lastStoppedKey){lastStoppedKey=null;e_preventDefault (e);return;} 286 function onKeyPress(e){var cm=this;if(signalDOMEvent(cm,e)||cm.options.onKeyEven t&&cm.options.onKeyEvent(cm,addStop(e)))return;var keyCode=e.keyCode,charCode=e. charCode;if(opera&&keyCode==lastStoppedKey){lastStoppedKey=null;e_preventDefault (e);return;}
281 if(((opera&&(!e.which||e.which<10))||khtml)&&handleKeyBinding(cm,e))return;var c h=String.fromCharCode(charCode==null?keyCode:charCode);if(this.options.electricC hars&&this.doc.mode.electricChars&&this.options.smartIndent&&!isReadOnly(this)&& this.doc.mode.electricChars.indexOf(ch)>-1) 287 if(((opera&&(!e.which||e.which<10))||khtml)&&handleKeyBinding(cm,e))return;var c h=String.fromCharCode(charCode==null?keyCode:charCode);if(this.options.electricC hars&&this.doc.mode.electricChars&&this.options.smartIndent&&!isReadOnly(this)&& this.doc.mode.electricChars.indexOf(ch)>-1)
282 setTimeout(operation(cm,function(){indentLine(cm,cm.doc.sel.to.line,"smart");}), 75);if(handleCharBinding(cm,e,ch))return;if(ie&&!ie_lt9)cm.display.inputHasSelec tion=null;fastPoll(cm);} 288 setTimeout(operation(cm,function(){indentLine(cm,cm.doc.sel.to.line,"smart");}), 75);if(handleCharBinding(cm,e,ch))return;if(ie&&!ie_lt9)cm.display.inputHasSelec tion=null;fastPoll(cm);}
283 function onFocus(cm){if(cm.options.readOnly=="nocursor")return;if(!cm.state.focu sed){signal(cm,"focus",cm);cm.state.focused=true;if(cm.display.wrapper.className .search(/\bCodeMirror-focused\b/)==-1) 289 function onFocus(cm){if(cm.options.readOnly=="nocursor")return;if(!cm.state.focu sed){signal(cm,"focus",cm);cm.state.focused=true;if(cm.display.wrapper.className .search(/\bCodeMirror-focused\b/)==-1)
284 cm.display.wrapper.className+=" CodeMirror-focused";resetInput(cm,true);} 290 cm.display.wrapper.className+=" CodeMirror-focused";if(!cm.curOp){resetInput(cm, true);if(webkit)setTimeout(bind(resetInput,cm,true),0);}}
285 slowPoll(cm);restartBlink(cm);} 291 slowPoll(cm);restartBlink(cm);}
286 function onBlur(cm){if(cm.state.focused){signal(cm,"blur",cm);cm.state.focused=f alse;cm.display.wrapper.className=cm.display.wrapper.className.replace(" CodeMir ror-focused","");} 292 function onBlur(cm){if(cm.state.focused){signal(cm,"blur",cm);cm.state.focused=f alse;cm.display.wrapper.className=cm.display.wrapper.className.replace(" CodeMir ror-focused","");}
287 clearInterval(cm.display.blinker);setTimeout(function(){if(!cm.state.focused)cm. doc.sel.shift=false;},150);} 293 clearInterval(cm.display.blinker);setTimeout(function(){if(!cm.state.focused)cm. doc.sel.shift=false;},150);}
288 var detectingSelectAll;function onContextMenu(cm,e){if(signalDOMEvent(cm,e,"cont extmenu"))return;var display=cm.display,sel=cm.doc.sel;if(eventInWidget(display, e))return;var pos=posFromMouse(cm,e),scrollPos=display.scroller.scrollTop;if(!po s||opera)return;if(posEq(sel.from,sel.to)||posLess(pos,sel.from)||!posLess(pos,s el.to)) 294 var detectingSelectAll;function onContextMenu(cm,e){if(signalDOMEvent(cm,e,"cont extmenu"))return;var display=cm.display,sel=cm.doc.sel;if(eventInWidget(display, e)||contextMenuInGutter(cm,e))return;var pos=posFromMouse(cm,e),scrollPos=displa y.scroller.scrollTop;if(!pos||opera)return;if(posEq(sel.from,sel.to)||posLess(po s,sel.from)||!posLess(pos,sel.to))
289 operation(cm,setSelection)(cm.doc,pos,pos);var oldCSS=display.input.style.cssTex t;display.inputDiv.style.position="absolute";display.input.style.cssText="positi on: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clien tX-5)+"px; z-index: 1000; background: white; outline: none;"+"border-width: 0; o utline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(op acity=5);";focusInput(cm);resetInput(cm,true);if(posEq(sel.from,sel.to))display. input.value=display.prevInput=" ";function prepareSelectAllHack(){if(display.inp ut.selectionStart!=null){var extval=display.input.value=" "+(posEq(sel.from,sel. to)?"":display.input.value);display.prevInput=" ";display.input.selectionStart=1 ;display.input.selectionEnd=extval.length;}} 295 operation(cm,setSelection)(cm.doc,pos,pos);var oldCSS=display.input.style.cssTex t;display.inputDiv.style.position="absolute";display.input.style.cssText="positi on: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clien tX-5)+"px; z-index: 1000; background: white; outline: none;"+"border-width: 0; o utline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(op acity=5);";focusInput(cm);resetInput(cm,true);if(posEq(sel.from,sel.to))display. input.value=display.prevInput=" ";function prepareSelectAllHack(){if(display.inp ut.selectionStart!=null){var extval=display.input.value="\u200b"+(posEq(sel.from ,sel.to)?"":display.input.value);display.prevInput="\u200b";display.input.select ionStart=1;display.input.selectionEnd=extval.length;}}
290 function rehide(){display.inputDiv.style.position="relative";display.input.style .cssText=oldCSS;if(ie_lt9)display.scrollbarV.scrollTop=display.scroller.scrollTo p=scrollPos;slowPoll(cm);if(display.input.selectionStart!=null){if(!ie||ie_lt9)p repareSelectAllHack();clearTimeout(detectingSelectAll);var i=0,poll=function(){i f(display.prevInput==" "&&display.input.selectionStart==0) 296 function rehide(){display.inputDiv.style.position="relative";display.input.style .cssText=oldCSS;if(ie_lt9)display.scrollbarV.scrollTop=display.scroller.scrollTo p=scrollPos;slowPoll(cm);if(display.input.selectionStart!=null){if(!ie||ie_lt9)p repareSelectAllHack();clearTimeout(detectingSelectAll);var i=0,poll=function(){i f(display.prevInput==" "&&display.input.selectionStart==0)
291 operation(cm,commands.selectAll)(cm);else if(i++<10)detectingSelectAll=setTimeou t(poll,500);else resetInput(cm);};detectingSelectAll=setTimeout(poll,200);}} 297 operation(cm,commands.selectAll)(cm);else if(i++<10)detectingSelectAll=setTimeou t(poll,500);else resetInput(cm);};detectingSelectAll=setTimeout(poll,200);}}
292 if(ie&&!ie_lt9)prepareSelectAllHack();if(captureMiddleClick){e_stop(e);var mouse up=function(){off(window,"mouseup",mouseup);setTimeout(rehide,20);};on(window,"m ouseup",mouseup);}else{setTimeout(rehide,50);}} 298 if(ie&&!ie_lt9)prepareSelectAllHack();if(captureMiddleClick){e_stop(e);var mouse up=function(){off(window,"mouseup",mouseup);setTimeout(rehide,20);};on(window,"m ouseup",mouseup);}else{setTimeout(rehide,50);}}
293 var changeEnd=CodeMirror.changeEnd=function(change){if(!change.text)return chang e.to;return Pos(change.from.line+change.text.length-1,lst(change.text).length+(c hange.text.length==1?change.from.ch:0));};function clipPostChange(doc,change,pos ){if(!posLess(change.from,pos))return clipPos(doc,pos);var diff=(change.text.len gth-1)-(change.to.line-change.from.line);if(pos.line>change.to.line+diff){var pr eLine=pos.line-diff,lastLine=doc.first+doc.size-1;if(preLine>lastLine)return Pos (lastLine,getLine(doc,lastLine).text.length);return clipToLen(pos,getLine(doc,pr eLine).text.length);} 299 var changeEnd=CodeMirror.changeEnd=function(change){if(!change.text)return chang e.to;return Pos(change.from.line+change.text.length-1,lst(change.text).length+(c hange.text.length==1?change.from.ch:0));};function clipPostChange(doc,change,pos ){if(!posLess(change.from,pos))return clipPos(doc,pos);var diff=(change.text.len gth-1)-(change.to.line-change.from.line);if(pos.line>change.to.line+diff){var pr eLine=pos.line-diff,lastLine=doc.first+doc.size-1;if(preLine>lastLine)return Pos (lastLine,getLine(doc,lastLine).text.length);return clipToLen(pos,getLine(doc,pr eLine).text.length);}
294 if(pos.line==change.to.line+diff) 300 if(pos.line==change.to.line+diff)
295 return clipToLen(pos,lst(change.text).length+(change.text.length==1?change.from. ch:0)+ 301 return clipToLen(pos,lst(change.text).length+(change.text.length==1?change.from. ch:0)+
296 getLine(doc,change.to.line).text.length-change.to.ch);var inside=pos.line-change .from.line;return clipToLen(pos,change.text[inside].length+(inside?0:change.from .ch));} 302 getLine(doc,change.to.line).text.length-change.to.ch);var inside=pos.line-change .from.line;return clipToLen(pos,change.text[inside].length+(inside?0:change.from .ch));}
297 function computeSelAfterChange(doc,change,hint){if(hint&&typeof hint=="object") 303 function computeSelAfterChange(doc,change,hint){if(hint&&typeof hint=="object")
298 return{anchor:clipPostChange(doc,change,hint.anchor),head:clipPostChange(doc,cha nge,hint.head)};if(hint=="start")return{anchor:change.from,head:change.from};var end=changeEnd(change);if(hint=="around")return{anchor:change.from,head:end};if( hint=="end")return{anchor:end,head:end};var adjustPos=function(pos){if(posLess(p os,change.from))return pos;if(!posLess(change.to,pos))return end;var line=pos.li ne+change.text.length-(change.to.line-change.from.line)-1,ch=pos.ch;if(pos.line= =change.to.line)ch+=end.ch-change.to.ch;return Pos(line,ch);};return{anchor:adju stPos(doc.sel.anchor),head:adjustPos(doc.sel.head)};} 304 return{anchor:clipPostChange(doc,change,hint.anchor),head:clipPostChange(doc,cha nge,hint.head)};if(hint=="start")return{anchor:change.from,head:change.from};var end=changeEnd(change);if(hint=="around")return{anchor:change.from,head:end};if( hint=="end")return{anchor:end,head:end};var adjustPos=function(pos){if(posLess(p os,change.from))return pos;if(!posLess(change.to,pos))return end;var line=pos.li ne+change.text.length-(change.to.line-change.from.line)-1,ch=pos.ch;if(pos.line= =change.to.line)ch+=end.ch-change.to.ch;return Pos(line,ch);};return{anchor:adju stPos(doc.sel.anchor),head:adjustPos(doc.sel.head)};}
299 function filterChange(doc,change,update){var obj={canceled:false,from:change.fro m,to:change.to,text:change.text,origin:change.origin,cancel:function(){this.canc eled=true;}};if(update)obj.update=function(from,to,text,origin){if(from)this.fro m=clipPos(doc,from);if(to)this.to=clipPos(doc,to);if(text)this.text=text;if(orig in!==undefined)this.origin=origin;};signal(doc,"beforeChange",doc,obj);if(doc.cm )signal(doc.cm,"beforeChange",doc.cm,obj);if(obj.canceled)return null;return{fro m:obj.from,to:obj.to,text:obj.text,origin:obj.origin};} 305 function filterChange(doc,change,update){var obj={canceled:false,from:change.fro m,to:change.to,text:change.text,origin:change.origin,cancel:function(){this.canc eled=true;}};if(update)obj.update=function(from,to,text,origin){if(from)this.fro m=clipPos(doc,from);if(to)this.to=clipPos(doc,to);if(text)this.text=text;if(orig in!==undefined)this.origin=origin;};signal(doc,"beforeChange",doc,obj);if(doc.cm )signal(doc.cm,"beforeChange",doc.cm,obj);if(obj.canceled)return null;return{fro m:obj.from,to:obj.to,text:obj.text,origin:obj.origin};}
(...skipping 27 matching lines...) Expand all
327 function copyPos(x){return Pos(x.line,x.ch);} 333 function copyPos(x){return Pos(x.line,x.ch);}
328 function clipLine(doc,n){return Math.max(doc.first,Math.min(n,doc.first+doc.size -1));} 334 function clipLine(doc,n){return Math.max(doc.first,Math.min(n,doc.first+doc.size -1));}
329 function clipPos(doc,pos){if(pos.line<doc.first)return Pos(doc.first,0);var last =doc.first+doc.size-1;if(pos.line>last)return Pos(last,getLine(doc,last).text.le ngth);return clipToLen(pos,getLine(doc,pos.line).text.length);} 335 function clipPos(doc,pos){if(pos.line<doc.first)return Pos(doc.first,0);var last =doc.first+doc.size-1;if(pos.line>last)return Pos(last,getLine(doc,last).text.le ngth);return clipToLen(pos,getLine(doc,pos.line).text.length);}
330 function clipToLen(pos,linelen){var ch=pos.ch;if(ch==null||ch>linelen)return Pos (pos.line,linelen);else if(ch<0)return Pos(pos.line,0);else return pos;} 336 function clipToLen(pos,linelen){var ch=pos.ch;if(ch==null||ch>linelen)return Pos (pos.line,linelen);else if(ch<0)return Pos(pos.line,0);else return pos;}
331 function isLine(doc,l){return l>=doc.first&&l<doc.first+doc.size;} 337 function isLine(doc,l){return l>=doc.first&&l<doc.first+doc.size;}
332 function extendSelection(doc,pos,other,bias){if(doc.sel.shift||doc.sel.extend){v ar anchor=doc.sel.anchor;if(other){var posBefore=posLess(pos,anchor);if(posBefor e!=posLess(other,anchor)){anchor=pos;pos=other;}else if(posBefore!=posLess(pos,o ther)){pos=other;}} 338 function extendSelection(doc,pos,other,bias){if(doc.sel.shift||doc.sel.extend){v ar anchor=doc.sel.anchor;if(other){var posBefore=posLess(pos,anchor);if(posBefor e!=posLess(other,anchor)){anchor=pos;pos=other;}else if(posBefore!=posLess(pos,o ther)){pos=other;}}
333 setSelection(doc,anchor,pos,bias);}else{setSelection(doc,pos,other||pos,bias);} 339 setSelection(doc,anchor,pos,bias);}else{setSelection(doc,pos,other||pos,bias);}
334 if(doc.cm)doc.cm.curOp.userSelChange=true;} 340 if(doc.cm)doc.cm.curOp.userSelChange=true;}
335 function filterSelectionChange(doc,anchor,head){var obj={anchor:anchor,head:head };signal(doc,"beforeSelectionChange",doc,obj);if(doc.cm)signal(doc.cm,"beforeSel ectionChange",doc.cm,obj);obj.anchor=clipPos(doc,obj.anchor);obj.head=clipPos(do c,obj.head);return obj;} 341 function filterSelectionChange(doc,anchor,head){var obj={anchor:anchor,head:head };signal(doc,"beforeSelectionChange",doc,obj);if(doc.cm)signal(doc.cm,"beforeSel ectionChange",doc.cm,obj);obj.anchor=clipPos(doc,obj.anchor);obj.head=clipPos(do c,obj.head);return obj;}
336 function setSelection(doc,anchor,head,bias,checkAtomic){if(!checkAtomic&&hasHand ler(doc,"beforeSelectionChange")||doc.cm&&hasHandler(doc.cm,"beforeSelectionChan ge")){var filtered=filterSelectionChange(doc,anchor,head);head=filtered.head;anc hor=filtered.anchor;} 342 function setSelection(doc,anchor,head,bias,checkAtomic){if(!checkAtomic&&hasHand ler(doc,"beforeSelectionChange")||doc.cm&&hasHandler(doc.cm,"beforeSelectionChan ge")){var filtered=filterSelectionChange(doc,anchor,head);head=filtered.head;anc hor=filtered.anchor;}
337 var sel=doc.sel;sel.goalColumn=null;if(checkAtomic||!posEq(anchor,sel.anchor)) 343 var sel=doc.sel;sel.goalColumn=null;if(bias==null)bias=posLess(head,sel.head)?-1 :1;if(checkAtomic||!posEq(anchor,sel.anchor))
338 anchor=skipAtomic(doc,anchor,bias,checkAtomic!="push");if(checkAtomic||!posEq(he ad,sel.head)) 344 anchor=skipAtomic(doc,anchor,bias,checkAtomic!="push");if(checkAtomic||!posEq(he ad,sel.head))
339 head=skipAtomic(doc,head,bias,checkAtomic!="push");if(posEq(sel.anchor,anchor)&& posEq(sel.head,head))return;sel.anchor=anchor;sel.head=head;var inv=posLess(head ,anchor);sel.from=inv?head:anchor;sel.to=inv?anchor:head;if(doc.cm) 345 head=skipAtomic(doc,head,bias,checkAtomic!="push");if(posEq(sel.anchor,anchor)&& posEq(sel.head,head))return;sel.anchor=anchor;sel.head=head;var inv=posLess(head ,anchor);sel.from=inv?head:anchor;sel.to=inv?anchor:head;if(doc.cm)
340 doc.cm.curOp.updateInput=doc.cm.curOp.selectionChanged=doc.cm.curOp.cursorActivi ty=true;signalLater(doc,"cursorActivity",doc);} 346 doc.cm.curOp.updateInput=doc.cm.curOp.selectionChanged=doc.cm.curOp.cursorActivi ty=true;signalLater(doc,"cursorActivity",doc);}
341 function reCheckSelection(cm){setSelection(cm.doc,cm.doc.sel.from,cm.doc.sel.to, null,"push");} 347 function reCheckSelection(cm){setSelection(cm.doc,cm.doc.sel.from,cm.doc.sel.to, null,"push");}
342 function skipAtomic(doc,pos,bias,mayClear){var flipped=false,curPos=pos;var dir= bias||1;doc.cantEdit=false;search:for(;;){var line=getLine(doc,curPos.line);if(l ine.markedSpans){for(var i=0;i<line.markedSpans.length;++i){var sp=line.markedSp ans[i],m=sp.marker;if((sp.from==null||(m.inclusiveLeft?sp.from<=curPos.ch:sp.fro m<curPos.ch))&&(sp.to==null||(m.inclusiveRight?sp.to>=curPos.ch:sp.to>curPos.ch) )){if(mayClear){signal(m,"beforeCursorEnter");if(m.explicitlyCleared){if(!line.m arkedSpans)break;else{--i;continue;}}} 348 function skipAtomic(doc,pos,bias,mayClear){var flipped=false,curPos=pos;var dir= bias||1;doc.cantEdit=false;search:for(;;){var line=getLine(doc,curPos.line);if(l ine.markedSpans){for(var i=0;i<line.markedSpans.length;++i){var sp=line.markedSp ans[i],m=sp.marker;if((sp.from==null||(m.inclusiveLeft?sp.from<=curPos.ch:sp.fro m<curPos.ch))&&(sp.to==null||(m.inclusiveRight?sp.to>=curPos.ch:sp.to>curPos.ch) )){if(mayClear){signal(m,"beforeCursorEnter");if(m.explicitlyCleared){if(!line.m arkedSpans)break;else{--i;continue;}}}
343 if(!m.atomic)continue;var newPos=m.find()[dir<0?"from":"to"];if(posEq(newPos,cur Pos)){newPos.ch+=dir;if(newPos.ch<0){if(newPos.line>doc.first)newPos=clipPos(doc ,Pos(newPos.line-1));else newPos=null;}else if(newPos.ch>line.text.length){if(ne wPos.line<doc.first+doc.size-1)newPos=Pos(newPos.line+1,0);else newPos=null;} 349 if(!m.atomic)continue;var newPos=m.find()[dir<0?"from":"to"];if(posEq(newPos,cur Pos)){newPos.ch+=dir;if(newPos.ch<0){if(newPos.line>doc.first)newPos=clipPos(doc ,Pos(newPos.line-1));else newPos=null;}else if(newPos.ch>line.text.length){if(ne wPos.line<doc.first+doc.size-1)newPos=Pos(newPos.line+1,0);else newPos=null;}
344 if(!newPos){if(flipped){if(!mayClear)return skipAtomic(doc,pos,bias,true);doc.ca ntEdit=true;return Pos(doc.first,0);} 350 if(!newPos){if(flipped){if(!mayClear)return skipAtomic(doc,pos,bias,true);doc.ca ntEdit=true;return Pos(doc.first,0);}
345 flipped=true;newPos=pos;dir=-dir;}} 351 flipped=true;newPos=pos;dir=-dir;}}
346 curPos=newPos;continue search;}}} 352 curPos=newPos;continue search;}}}
347 return curPos;}} 353 return curPos;}}
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 for(var i=0,cur=clipPos(this.doc,from);i<amount;++i){cur=findPosH(this.doc,cur,d ir,unit,visually);if(cur.hitSide)break;} 402 for(var i=0,cur=clipPos(this.doc,from);i<amount;++i){cur=findPosH(this.doc,cur,d ir,unit,visually);if(cur.hitSide)break;}
397 return cur;},moveH:operation(null,function(dir,unit){var sel=this.doc.sel,pos;if (sel.shift||sel.extend||posEq(sel.from,sel.to)) 403 return cur;},moveH:operation(null,function(dir,unit){var sel=this.doc.sel,pos;if (sel.shift||sel.extend||posEq(sel.from,sel.to))
398 pos=findPosH(this.doc,sel.head,dir,unit,this.options.rtlMoveVisually);else 404 pos=findPosH(this.doc,sel.head,dir,unit,this.options.rtlMoveVisually);else
399 pos=dir<0?sel.from:sel.to;extendSelection(this.doc,pos,pos,dir);}),deleteH:opera tion(null,function(dir,unit){var sel=this.doc.sel;if(!posEq(sel.from,sel.to))rep laceRange(this.doc,"",sel.from,sel.to,"+delete");else replaceRange(this.doc,"",s el.from,findPosH(this.doc,sel.head,dir,unit,false),"+delete");this.curOp.userSel Change=true;}),findPosV:function(from,amount,unit,goalColumn){var dir=1,x=goalCo lumn;if(amount<0){dir=-1;amount=-amount;} 405 pos=dir<0?sel.from:sel.to;extendSelection(this.doc,pos,pos,dir);}),deleteH:opera tion(null,function(dir,unit){var sel=this.doc.sel;if(!posEq(sel.from,sel.to))rep laceRange(this.doc,"",sel.from,sel.to,"+delete");else replaceRange(this.doc,"",s el.from,findPosH(this.doc,sel.head,dir,unit,false),"+delete");this.curOp.userSel Change=true;}),findPosV:function(from,amount,unit,goalColumn){var dir=1,x=goalCo lumn;if(amount<0){dir=-1;amount=-amount;}
400 for(var i=0,cur=clipPos(this.doc,from);i<amount;++i){var coords=cursorCoords(thi s,cur,"div");if(x==null)x=coords.left;else coords.left=x;cur=findPosV(this,coord s,dir,unit);if(cur.hitSide)break;} 406 for(var i=0,cur=clipPos(this.doc,from);i<amount;++i){var coords=cursorCoords(thi s,cur,"div");if(x==null)x=coords.left;else coords.left=x;cur=findPosV(this,coord s,dir,unit);if(cur.hitSide)break;}
401 return cur;},moveV:operation(null,function(dir,unit){var sel=this.doc.sel;var po s=cursorCoords(this,sel.head,"div");if(sel.goalColumn!=null)pos.left=sel.goalCol umn;var target=findPosV(this,pos,dir,unit);if(unit=="page")addToScrollPos(this,0 ,charCoords(this,target,"div").top-pos.top);extendSelection(this.doc,target,targ et,dir);sel.goalColumn=pos.left;}),toggleOverwrite:function(value){if(value!=nul l&&value==this.state.overwrite)return;if(this.state.overwrite=!this.state.overwr ite) 407 return cur;},moveV:operation(null,function(dir,unit){var sel=this.doc.sel;var po s=cursorCoords(this,sel.head,"div");if(sel.goalColumn!=null)pos.left=sel.goalCol umn;var target=findPosV(this,pos,dir,unit);if(unit=="page")addToScrollPos(this,0 ,charCoords(this,target,"div").top-pos.top);extendSelection(this.doc,target,targ et,dir);sel.goalColumn=pos.left;}),toggleOverwrite:function(value){if(value!=nul l&&value==this.state.overwrite)return;if(this.state.overwrite=!this.state.overwr ite)
402 this.display.cursor.className+=" CodeMirror-overwrite";else 408 this.display.cursor.className+=" CodeMirror-overwrite";else
403 this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror -overwrite","");},hasFocus:function(){return this.state.focused;},scrollTo:opera tion(null,function(x,y){updateScrollPos(this,x,y);}),getScrollInfo:function(){va r scroller=this.display.scroller,co=scrollerCutOff;return{left:scroller.scrollLe ft,top:scroller.scrollTop,height:scroller.scrollHeight-co,width:scroller.scrollW idth-co,clientHeight:scroller.clientHeight-co,clientWidth:scroller.clientWidth-c o};},scrollIntoView:operation(null,function(pos,margin){if(typeof pos=="number") pos=Pos(pos,0);if(!margin)margin=0;var coords=pos;if(!pos||pos.line!=null){this. curOp.scrollToPos=pos?clipPos(this.doc,pos):this.doc.sel.head;this.curOp.scrollT oPosMargin=margin;coords=cursorCoords(this,this.curOp.scrollToPos);} 409 this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror -overwrite","");},hasFocus:function(){return this.state.focused;},scrollTo:opera tion(null,function(x,y){updateScrollPos(this,x,y);}),getScrollInfo:function(){va r scroller=this.display.scroller,co=scrollerCutOff;return{left:scroller.scrollLe ft,top:scroller.scrollTop,height:scroller.scrollHeight-co,width:scroller.scrollW idth-co,clientHeight:scroller.clientHeight-co,clientWidth:scroller.clientWidth-c o};},scrollIntoView:operation(null,function(pos,margin){if(typeof pos=="number") pos=Pos(pos,0);if(!margin)margin=0;var coords=pos;if(!pos||pos.line!=null){this. curOp.scrollToPos=pos?clipPos(this.doc,pos):this.doc.sel.head;this.curOp.scrollT oPosMargin=margin;coords=cursorCoords(this,this.curOp.scrollToPos);}
404 var sPos=calculateScrollPos(this,coords.left,coords.top-margin,coords.right,coor ds.bottom+margin);updateScrollPos(this,sPos.scrollLeft,sPos.scrollTop);}),setSiz e:operation(null,function(width,height){function interpret(val){return typeof va l=="number"||/^\d+$/.test(String(val))?val+"px":val;} 410 var sPos=calculateScrollPos(this,coords.left,coords.top-margin,coords.right,coor ds.bottom+margin);updateScrollPos(this,sPos.scrollLeft,sPos.scrollTop);}),setSiz e:operation(null,function(width,height){function interpret(val){return typeof va l=="number"||/^\d+$/.test(String(val))?val+"px":val;}
405 if(width!=null)this.display.wrapper.style.width=interpret(width);if(height!=null )this.display.wrapper.style.height=interpret(height);if(this.options.lineWrappin g) 411 if(width!=null)this.display.wrapper.style.width=interpret(width);if(height!=null )this.display.wrapper.style.height=interpret(height);if(this.options.lineWrappin g)
406 this.display.measureLineCache.length=this.display.measureLineCachePos=0;this.cur Op.forceUpdate=true;}),operation:function(f){return runInOp(this,f);},refresh:op eration(null,function(){clearCaches(this);updateScrollPos(this,this.doc.scrollLe ft,this.doc.scrollTop);regChange(this);}),swapDoc:operation(null,function(doc){v ar old=this.doc;old.cm=null;attachDoc(this,doc);clearCaches(this);resetInput(thi s,true);updateScrollPos(this,doc.scrollLeft,doc.scrollTop);return old;}),getInpu tField:function(){return this.display.input;},getWrapperElement:function(){retur n this.display.wrapper;},getScrollerElement:function(){return this.display.scrol ler;},getGutterElement:function(){return this.display.gutters;}};eventMixin(Code Mirror);var optionHandlers=CodeMirror.optionHandlers={};var defaults=CodeMirror. defaults={};function option(name,deflt,handle,notOnInit){CodeMirror.defaults[nam e]=deflt;if(handle)optionHandlers[name]=notOnInit?function(cm,val,old){if(old!=I nit)handle(cm,val,old);}:handle;} 412 this.display.measureLineCache.length=this.display.measureLineCachePos=0;this.cur Op.forceUpdate=true;}),operation:function(f){return runInOp(this,f);},refresh:op eration(null,function(){var badHeight=this.display.cachedTextHeight==null;clearC aches(this);updateScrollPos(this,this.doc.scrollLeft,this.doc.scrollTop);regChan ge(this);if(badHeight)estimateLineHeights(this);}),swapDoc:operation(null,functi on(doc){var old=this.doc;old.cm=null;attachDoc(this,doc);clearCaches(this);reset Input(this,true);updateScrollPos(this,doc.scrollLeft,doc.scrollTop);return old;} ),getInputField:function(){return this.display.input;},getWrapperElement:functio n(){return this.display.wrapper;},getScrollerElement:function(){return this.disp lay.scroller;},getGutterElement:function(){return this.display.gutters;}};eventM ixin(CodeMirror);var optionHandlers=CodeMirror.optionHandlers={};var defaults=Co deMirror.defaults={};function option(name,deflt,handle,notOnInit){CodeMirror.def aults[name]=deflt;if(handle)optionHandlers[name]=notOnInit?function(cm,val,old){ if(old!=Init)handle(cm,val,old);}:handle;}
407 var Init=CodeMirror.Init={toString:function(){return"CodeMirror.Init";}};option( "value","",function(cm,val){cm.setValue(val);},true);option("mode",null,function (cm,val){cm.doc.modeOption=val;loadMode(cm);},true);option("indentUnit",2,loadMo de,true);option("indentWithTabs",false);option("smartIndent",true);option("tabSi ze",4,function(cm){loadMode(cm);clearCaches(cm);regChange(cm);},true);option("el ectricChars",true);option("rtlMoveVisually",!windows);option("theme","default",f unction(cm){themeChanged(cm);guttersChanged(cm);},true);option("keyMap","default ",keyMapChanged);option("extraKeys",null);option("onKeyEvent",null);option("onDr agEvent",null);option("lineWrapping",false,wrappingChanged,true);option("gutters ",[],function(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm);},true );option("fixedGutter",true,function(cm,val){cm.display.gutters.style.left=val?c ompensateForHScroll(cm.display)+"px":"0";cm.refresh();},true);option("coverGutte rNextToScrollbar",false,updateScrollbars,true);option("lineNumbers",false,functi on(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm);},true);option("f irstLineNumber",1,guttersChanged,true);option("lineNumberFormatter",function(int eger){return integer;},guttersChanged,true);option("showCursorWhenSelecting",fal se,updateSelection,true);option("readOnly",false,function(cm,val){if(val=="nocur sor"){onBlur(cm);cm.display.input.blur();} 413 var Init=CodeMirror.Init={toString:function(){return"CodeMirror.Init";}};option( "value","",function(cm,val){cm.setValue(val);},true);option("mode",null,function (cm,val){cm.doc.modeOption=val;loadMode(cm);},true);option("indentUnit",2,loadMo de,true);option("indentWithTabs",false);option("smartIndent",true);option("tabSi ze",4,function(cm){loadMode(cm);clearCaches(cm);regChange(cm);},true);option("el ectricChars",true);option("rtlMoveVisually",!windows);option("theme","default",f unction(cm){themeChanged(cm);guttersChanged(cm);},true);option("keyMap","default ",keyMapChanged);option("extraKeys",null);option("onKeyEvent",null);option("onDr agEvent",null);option("lineWrapping",false,wrappingChanged,true);option("gutters ",[],function(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm);},true );option("fixedGutter",true,function(cm,val){cm.display.gutters.style.left=val?c ompensateForHScroll(cm.display)+"px":"0";cm.refresh();},true);option("coverGutte rNextToScrollbar",false,updateScrollbars,true);option("lineNumbers",false,functi on(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm);},true);option("f irstLineNumber",1,guttersChanged,true);option("lineNumberFormatter",function(int eger){return integer;},guttersChanged,true);option("showCursorWhenSelecting",fal se,updateSelection,true);option("readOnly",false,function(cm,val){if(val=="nocur sor"){onBlur(cm);cm.display.input.blur();}
408 else if(!val)resetInput(cm,true);});option("dragDrop",true);option("cursorBlinkR ate",530);option("cursorScrollMargin",0);option("cursorHeight",1);option("workTi me",100);option("workDelay",100);option("flattenSpans",true);option("pollInterva l",100);option("undoDepth",40,function(cm,val){cm.doc.history.undoDepth=val;});o ption("historyEventDelay",500);option("viewportMargin",10,function(cm){cm.refres h();},true);option("maxHighlightLength",10000,function(cm){loadMode(cm);cm.refre sh();},true);option("moveInputWithCursor",true,function(cm,val){if(!val)cm.displ ay.inputDiv.style.top=cm.display.inputDiv.style.left=0;});option("tabindex",null ,function(cm,val){cm.display.input.tabIndex=val||"";});option("autofocus",null); var modes=CodeMirror.modes={},mimeModes=CodeMirror.mimeModes={};CodeMirror.defin eMode=function(name,mode){if(!CodeMirror.defaults.mode&&name!="null")CodeMirror. defaults.mode=name;if(arguments.length>2){mode.dependencies=[];for(var i=2;i<arg uments.length;++i)mode.dependencies.push(arguments[i]);} 414 else if(!val)resetInput(cm,true);});option("dragDrop",true);option("cursorBlinkR ate",530);option("cursorScrollMargin",0);option("cursorHeight",1);option("workTi me",100);option("workDelay",100);option("flattenSpans",true);option("pollInterva l",100);option("undoDepth",40,function(cm,val){cm.doc.history.undoDepth=val;});o ption("historyEventDelay",500);option("viewportMargin",10,function(cm){cm.refres h();},true);option("maxHighlightLength",10000,function(cm){loadMode(cm);cm.refre sh();},true);option("crudeMeasuringFrom",10000);option("moveInputWithCursor",tru e,function(cm,val){if(!val)cm.display.inputDiv.style.top=cm.display.inputDiv.sty le.left=0;});option("tabindex",null,function(cm,val){cm.display.input.tabIndex=v al||"";});option("autofocus",null);var modes=CodeMirror.modes={},mimeModes=CodeM irror.mimeModes={};CodeMirror.defineMode=function(name,mode){if(!CodeMirror.defa ults.mode&&name!="null")CodeMirror.defaults.mode=name;if(arguments.length>2){mod e.dependencies=[];for(var i=2;i<arguments.length;++i)mode.dependencies.push(argu ments[i]);}
409 modes[name]=mode;};CodeMirror.defineMIME=function(mime,spec){mimeModes[mime]=spe c;};CodeMirror.resolveMode=function(spec){if(typeof spec=="string"&&mimeModes.ha sOwnProperty(spec)){spec=mimeModes[spec];}else if(spec&&typeof spec.name=="strin g"&&mimeModes.hasOwnProperty(spec.name)){var found=mimeModes[spec.name];spec=cre ateObj(found,spec);spec.name=found.name;}else if(typeof spec=="string"&&/^[\w\-] +\/[\w\-]+\+xml$/.test(spec)){return CodeMirror.resolveMode("application/xml");} 415 modes[name]=mode;};CodeMirror.defineMIME=function(mime,spec){mimeModes[mime]=spe c;};CodeMirror.resolveMode=function(spec){if(typeof spec=="string"&&mimeModes.ha sOwnProperty(spec)){spec=mimeModes[spec];}else if(spec&&typeof spec.name=="strin g"&&mimeModes.hasOwnProperty(spec.name)){var found=mimeModes[spec.name];spec=cre ateObj(found,spec);spec.name=found.name;}else if(typeof spec=="string"&&/^[\w\-] +\/[\w\-]+\+xml$/.test(spec)){return CodeMirror.resolveMode("application/xml");}
410 if(typeof spec=="string")return{name:spec};else return spec||{name:"null"};};Cod eMirror.getMode=function(options,spec){var spec=CodeMirror.resolveMode(spec);var mfactory=modes[spec.name];if(!mfactory)return CodeMirror.getMode(options,"text/ plain");var modeObj=mfactory(options,spec);if(modeExtensions.hasOwnProperty(spec .name)){var exts=modeExtensions[spec.name];for(var prop in exts){if(!exts.hasOwn Property(prop))continue;if(modeObj.hasOwnProperty(prop))modeObj["_"+prop]=modeOb j[prop];modeObj[prop]=exts[prop];}} 416 if(typeof spec=="string")return{name:spec};else return spec||{name:"null"};};Cod eMirror.getMode=function(options,spec){var spec=CodeMirror.resolveMode(spec);var mfactory=modes[spec.name];if(!mfactory)return CodeMirror.getMode(options,"text/ plain");var modeObj=mfactory(options,spec);if(modeExtensions.hasOwnProperty(spec .name)){var exts=modeExtensions[spec.name];for(var prop in exts){if(!exts.hasOwn Property(prop))continue;if(modeObj.hasOwnProperty(prop))modeObj["_"+prop]=modeOb j[prop];modeObj[prop]=exts[prop];}}
411 modeObj.name=spec.name;return modeObj;};CodeMirror.defineMode("null",function(){ return{token:function(stream){stream.skipToEnd();}};});CodeMirror.defineMIME("te xt/plain","null");var modeExtensions=CodeMirror.modeExtensions={};CodeMirror.ext endMode=function(mode,properties){var exts=modeExtensions.hasOwnProperty(mode)?m odeExtensions[mode]:(modeExtensions[mode]={});copyObj(properties,exts);};CodeMir ror.defineExtension=function(name,func){CodeMirror.prototype[name]=func;};CodeMi rror.defineDocExtension=function(name,func){Doc.prototype[name]=func;};CodeMirro r.defineOption=option;var initHooks=[];CodeMirror.defineInitHook=function(f){ini tHooks.push(f);};var helpers=CodeMirror.helpers={};CodeMirror.registerHelper=fun ction(type,name,value){if(!helpers.hasOwnProperty(type))helpers[type]=CodeMirror [type]={};helpers[type][name]=value;};CodeMirror.isWordChar=isWordChar;function copyState(mode,state){if(state===true)return state;if(mode.copyState)return mode .copyState(state);var nstate={};for(var n in state){var val=state[n];if(val inst anceof Array)val=val.concat([]);nstate[n]=val;} 417 modeObj.name=spec.name;return modeObj;};CodeMirror.defineMode("null",function(){ return{token:function(stream){stream.skipToEnd();}};});CodeMirror.defineMIME("te xt/plain","null");var modeExtensions=CodeMirror.modeExtensions={};CodeMirror.ext endMode=function(mode,properties){var exts=modeExtensions.hasOwnProperty(mode)?m odeExtensions[mode]:(modeExtensions[mode]={});copyObj(properties,exts);};CodeMir ror.defineExtension=function(name,func){CodeMirror.prototype[name]=func;};CodeMi rror.defineDocExtension=function(name,func){Doc.prototype[name]=func;};CodeMirro r.defineOption=option;var initHooks=[];CodeMirror.defineInitHook=function(f){ini tHooks.push(f);};var helpers=CodeMirror.helpers={};CodeMirror.registerHelper=fun ction(type,name,value){if(!helpers.hasOwnProperty(type))helpers[type]=CodeMirror [type]={};helpers[type][name]=value;};CodeMirror.isWordChar=isWordChar;function copyState(mode,state){if(state===true)return state;if(mode.copyState)return mode .copyState(state);var nstate={};for(var n in state){var val=state[n];if(val inst anceof Array)val=val.concat([]);nstate[n]=val;}
412 return nstate;} 418 return nstate;}
413 CodeMirror.copyState=copyState;function startState(mode,a1,a2){return mode.start State?mode.startState(a1,a2):true;} 419 CodeMirror.copyState=copyState;function startState(mode,a1,a2){return mode.start State?mode.startState(a1,a2):true;}
414 CodeMirror.startState=startState;CodeMirror.innerMode=function(mode,state){while (mode.innerMode){var info=mode.innerMode(state);if(!info||info.mode==mode)break; state=info.state;mode=info.mode;} 420 CodeMirror.startState=startState;CodeMirror.innerMode=function(mode,state){while (mode.innerMode){var info=mode.innerMode(state);if(!info||info.mode==mode)break; state=info.state;mode=info.mode;}
415 return info||{mode:mode,state:state};};var commands=CodeMirror.commands={selectA ll:function(cm){cm.setSelection(Pos(cm.firstLine(),0),Pos(cm.lastLine()));},kill Line:function(cm){var from=cm.getCursor(true),to=cm.getCursor(false),sel=!posEq( from,to);if(!sel&&cm.getLine(from.line).length==from.ch) 421 return info||{mode:mode,state:state};};var commands=CodeMirror.commands={selectA ll:function(cm){cm.setSelection(Pos(cm.firstLine(),0),Pos(cm.lastLine()));},kill Line:function(cm){var from=cm.getCursor(true),to=cm.getCursor(false),sel=!posEq( from,to);if(!sel&&cm.getLine(from.line).length==from.ch)
416 cm.replaceRange("",from,Pos(from.line+1,0),"+delete");else cm.replaceRange("",fr om,sel?to:Pos(from.line),"+delete");},deleteLine:function(cm){var l=cm.getCursor ().line;cm.replaceRange("",Pos(l,0),Pos(l),"+delete");},delLineLeft:function(cm) {var cur=cm.getCursor();cm.replaceRange("",Pos(cur.line,0),cur,"+delete");},undo :function(cm){cm.undo();},redo:function(cm){cm.redo();},goDocStart:function(cm){ cm.extendSelection(Pos(cm.firstLine(),0));},goDocEnd:function(cm){cm.extendSelec tion(Pos(cm.lastLine()));},goLineStart:function(cm){cm.extendSelection(lineStart (cm,cm.getCursor().line));},goLineStartSmart:function(cm){var cur=cm.getCursor() ,start=lineStart(cm,cur.line);var line=cm.getLineHandle(start.line);var order=ge tOrder(line);if(!order||order[0].level==0){var firstNonWS=Math.max(0,line.text.s earch(/\S/));var inWS=cur.line==start.line&&cur.ch<=firstNonWS&&cur.ch;cm.extend Selection(Pos(start.line,inWS?0:firstNonWS));}else cm.extendSelection(start);},g oLineEnd:function(cm){cm.extendSelection(lineEnd(cm,cm.getCursor().line));},goLi neRight:function(cm){var top=cm.charCoords(cm.getCursor(),"div").top+5;cm.extend Selection(cm.coordsChar({left:cm.display.lineDiv.offsetWidth+100,top:top},"div") );},goLineLeft:function(cm){var top=cm.charCoords(cm.getCursor(),"div").top+5;cm .extendSelection(cm.coordsChar({left:0,top:top},"div"));},goLineUp:function(cm){ cm.moveV(-1,"line");},goLineDown:function(cm){cm.moveV(1,"line");},goPageUp:func tion(cm){cm.moveV(-1,"page");},goPageDown:function(cm){cm.moveV(1,"page");},goCh arLeft:function(cm){cm.moveH(-1,"char");},goCharRight:function(cm){cm.moveH(1,"c har");},goColumnLeft:function(cm){cm.moveH(-1,"column");},goColumnRight:function (cm){cm.moveH(1,"column");},goWordLeft:function(cm){cm.moveH(-1,"word");},goGrou pRight:function(cm){cm.moveH(1,"group");},goGroupLeft:function(cm){cm.moveH(-1," group");},goWordRight:function(cm){cm.moveH(1,"word");},delCharBefore:function(c m){cm.deleteH(-1,"char");},delCharAfter:function(cm){cm.deleteH(1,"char");},delW ordBefore:function(cm){cm.deleteH(-1,"word");},delWordAfter:function(cm){cm.dele teH(1,"word");},delGroupBefore:function(cm){cm.deleteH(-1,"group");},delGroupAft er:function(cm){cm.deleteH(1,"group");},indentAuto:function(cm){cm.indentSelecti on("smart");},indentMore:function(cm){cm.indentSelection("add");},indentLess:fun ction(cm){cm.indentSelection("subtract");},insertTab:function(cm){cm.replaceSele ction("\t","end","+input");},defaultTab:function(cm){if(cm.somethingSelected())c m.indentSelection("add");else cm.replaceSelection("\t","end","+input");},transpo seChars:function(cm){var cur=cm.getCursor(),line=cm.getLine(cur.line);if(cur.ch> 0&&cur.ch<line.length-1) 422 cm.replaceRange("",from,Pos(from.line+1,0),"+delete");else cm.replaceRange("",fr om,sel?to:Pos(from.line),"+delete");},deleteLine:function(cm){var l=cm.getCursor ().line;cm.replaceRange("",Pos(l,0),Pos(l),"+delete");},delLineLeft:function(cm) {var cur=cm.getCursor();cm.replaceRange("",Pos(cur.line,0),cur,"+delete");},undo :function(cm){cm.undo();},redo:function(cm){cm.redo();},goDocStart:function(cm){ cm.extendSelection(Pos(cm.firstLine(),0));},goDocEnd:function(cm){cm.extendSelec tion(Pos(cm.lastLine()));},goLineStart:function(cm){cm.extendSelection(lineStart (cm,cm.getCursor().line));},goLineStartSmart:function(cm){var cur=cm.getCursor() ,start=lineStart(cm,cur.line);var line=cm.getLineHandle(start.line);var order=ge tOrder(line);if(!order||order[0].level==0){var firstNonWS=Math.max(0,line.text.s earch(/\S/));var inWS=cur.line==start.line&&cur.ch<=firstNonWS&&cur.ch;cm.extend Selection(Pos(start.line,inWS?0:firstNonWS));}else cm.extendSelection(start);},g oLineEnd:function(cm){cm.extendSelection(lineEnd(cm,cm.getCursor().line));},goLi neRight:function(cm){var top=cm.charCoords(cm.getCursor(),"div").top+5;cm.extend Selection(cm.coordsChar({left:cm.display.lineDiv.offsetWidth+100,top:top},"div") );},goLineLeft:function(cm){var top=cm.charCoords(cm.getCursor(),"div").top+5;cm .extendSelection(cm.coordsChar({left:0,top:top},"div"));},goLineUp:function(cm){ cm.moveV(-1,"line");},goLineDown:function(cm){cm.moveV(1,"line");},goPageUp:func tion(cm){cm.moveV(-1,"page");},goPageDown:function(cm){cm.moveV(1,"page");},goCh arLeft:function(cm){cm.moveH(-1,"char");},goCharRight:function(cm){cm.moveH(1,"c har");},goColumnLeft:function(cm){cm.moveH(-1,"column");},goColumnRight:function (cm){cm.moveH(1,"column");},goWordLeft:function(cm){cm.moveH(-1,"word");},goGrou pRight:function(cm){cm.moveH(1,"group");},goGroupLeft:function(cm){cm.moveH(-1," group");},goWordRight:function(cm){cm.moveH(1,"word");},delCharBefore:function(c m){cm.deleteH(-1,"char");},delCharAfter:function(cm){cm.deleteH(1,"char");},delW ordBefore:function(cm){cm.deleteH(-1,"word");},delWordAfter:function(cm){cm.dele teH(1,"word");},delGroupBefore:function(cm){cm.deleteH(-1,"group");},delGroupAft er:function(cm){cm.deleteH(1,"group");},indentAuto:function(cm){cm.indentSelecti on("smart");},indentMore:function(cm){cm.indentSelection("add");},indentLess:fun ction(cm){cm.indentSelection("subtract");},insertTab:function(cm){cm.replaceSele ction("\t","end","+input");},defaultTab:function(cm){if(cm.somethingSelected())c m.indentSelection("add");else cm.replaceSelection("\t","end","+input");},transpo seChars:function(cm){var cur=cm.getCursor(),line=cm.getLine(cur.line);if(cur.ch> 0&&cur.ch<line.length-1)
417 cm.replaceRange(line.charAt(cur.ch)+line.charAt(cur.ch-1),Pos(cur.line,cur.ch-1) ,Pos(cur.line,cur.ch+1));},newlineAndIndent:function(cm){operation(cm,function() {cm.replaceSelection("\n","end","+input");cm.indentLine(cm.getCursor().line,null ,true);})();},toggleOverwrite:function(cm){cm.toggleOverwrite();}};var keyMap=Co deMirror.keyMap={};keyMap.basic={"Left":"goCharLeft","Right":"goCharRight","Up": "goLineUp","Down":"goLineDown","End":"goLineEnd","Home":"goLineStartSmart","Page Up":"goPageUp","PageDown":"goPageDown","Delete":"delCharAfter","Backspace":"delC harBefore","Tab":"defaultTab","Shift-Tab":"indentAuto","Enter":"newlineAndIndent ","Insert":"toggleOverwrite"};keyMap.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"d eleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"go DocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ct rl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt -Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAft er","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev ","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ct rl-]":"indentMore",fallthrough:"basic"};keyMap.macDefault={"Cmd-A":"selectAll"," Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up": "goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft" ,"Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Al t-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete": "delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":" findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLe ss","Cmd-]":"indentMore","Cmd-Backspace":"delLineLeft",fallthrough:["basic","ema csy"]};keyMap["default"]=mac?keyMap.macDefault:keyMap.pcDefault;keyMap.emacsy={" Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLine Down","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E" :"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAf ter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBef ore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"};function getKeyMap(val){if(t ypeof val=="string")return keyMap[val];else return val;} 423 cm.replaceRange(line.charAt(cur.ch)+line.charAt(cur.ch-1),Pos(cur.line,cur.ch-1) ,Pos(cur.line,cur.ch+1));},newlineAndIndent:function(cm){operation(cm,function() {cm.replaceSelection("\n","end","+input");cm.indentLine(cm.getCursor().line,null ,true);})();},toggleOverwrite:function(cm){cm.toggleOverwrite();}};var keyMap=Co deMirror.keyMap={};keyMap.basic={"Left":"goCharLeft","Right":"goCharRight","Up": "goLineUp","Down":"goLineDown","End":"goLineEnd","Home":"goLineStartSmart","Page Up":"goPageUp","PageDown":"goPageDown","Delete":"delCharAfter","Backspace":"delC harBefore","Tab":"defaultTab","Shift-Tab":"indentAuto","Enter":"newlineAndIndent ","Insert":"toggleOverwrite"};keyMap.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"d eleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"go DocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ct rl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt -Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAft er","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev ","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ct rl-]":"indentMore",fallthrough:"basic"};keyMap.macDefault={"Cmd-A":"selectAll"," Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up": "goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft" ,"Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Al t-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete": "delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":" findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLe ss","Cmd-]":"indentMore","Cmd-Backspace":"delLineLeft",fallthrough:["basic","ema csy"]};keyMap["default"]=mac?keyMap.macDefault:keyMap.pcDefault;keyMap.emacsy={" Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLine Down","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E" :"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAf ter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBef ore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"};function getKeyMap(val){if(t ypeof val=="string")return keyMap[val];else return val;}
418 function lookupKey(name,maps,handle){function lookup(map){map=getKeyMap(map);var found=map[name];if(found===false)return"stop";if(found!=null&&handle(found))ret urn true;if(map.nofallthrough)return"stop";var fallthrough=map.fallthrough;if(fa llthrough==null)return false;if(Object.prototype.toString.call(fallthrough)!="[o bject Array]") 424 function lookupKey(name,maps,handle){function lookup(map){map=getKeyMap(map);var found=map[name];if(found===false)return"stop";if(found!=null&&handle(found))ret urn true;if(map.nofallthrough)return"stop";var fallthrough=map.fallthrough;if(fa llthrough==null)return false;if(Object.prototype.toString.call(fallthrough)!="[o bject Array]")
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 var LineWidget=CodeMirror.LineWidget=function(cm,node,options){if(options)for(va r opt in options)if(options.hasOwnProperty(opt)) 512 var LineWidget=CodeMirror.LineWidget=function(cm,node,options){if(options)for(va r opt in options)if(options.hasOwnProperty(opt))
507 this[opt]=options[opt];this.cm=cm;this.node=node;};eventMixin(LineWidget);functi on widgetOperation(f){return function(){var withOp=!this.cm.curOp;if(withOp)star tOperation(this.cm);try{var result=f.apply(this,arguments);} 513 this[opt]=options[opt];this.cm=cm;this.node=node;};eventMixin(LineWidget);functi on widgetOperation(f){return function(){var withOp=!this.cm.curOp;if(withOp)star tOperation(this.cm);try{var result=f.apply(this,arguments);}
508 finally{if(withOp)endOperation(this.cm);} 514 finally{if(withOp)endOperation(this.cm);}
509 return result;};} 515 return result;};}
510 LineWidget.prototype.clear=widgetOperation(function(){var ws=this.line.widgets,n o=lineNo(this.line);if(no==null||!ws)return;for(var i=0;i<ws.length;++i)if(ws[i] ==this)ws.splice(i--,1);if(!ws.length)this.line.widgets=null;var aboveVisible=he ightAtLine(this.cm,this.line)<this.cm.doc.scrollTop;updateLineHeight(this.line,M ath.max(0,this.line.height-widgetHeight(this)));if(aboveVisible)addToScrollPos(t his.cm,0,-this.height);regChange(this.cm,no,no+1);});LineWidget.prototype.change d=widgetOperation(function(){var oldH=this.height;this.height=null;var diff=widg etHeight(this)-oldH;if(!diff)return;updateLineHeight(this.line,this.line.height+ diff);var no=lineNo(this.line);regChange(this.cm,no,no+1);});function widgetHeig ht(widget){if(widget.height!=null)return widget.height;if(!widget.node.parentNod e||widget.node.parentNode.nodeType!=1) 516 LineWidget.prototype.clear=widgetOperation(function(){var ws=this.line.widgets,n o=lineNo(this.line);if(no==null||!ws)return;for(var i=0;i<ws.length;++i)if(ws[i] ==this)ws.splice(i--,1);if(!ws.length)this.line.widgets=null;var aboveVisible=he ightAtLine(this.cm,this.line)<this.cm.doc.scrollTop;updateLineHeight(this.line,M ath.max(0,this.line.height-widgetHeight(this)));if(aboveVisible)addToScrollPos(t his.cm,0,-this.height);regChange(this.cm,no,no+1);});LineWidget.prototype.change d=widgetOperation(function(){var oldH=this.height;this.height=null;var diff=widg etHeight(this)-oldH;if(!diff)return;updateLineHeight(this.line,this.line.height+ diff);var no=lineNo(this.line);regChange(this.cm,no,no+1);});function widgetHeig ht(widget){if(widget.height!=null)return widget.height;if(!widget.node.parentNod e||widget.node.parentNode.nodeType!=1)
511 removeChildrenAndAdd(widget.cm.display.measure,elt("div",[widget.node],null,"pos ition: relative"));return widget.height=widget.node.offsetHeight;} 517 removeChildrenAndAdd(widget.cm.display.measure,elt("div",[widget.node],null,"pos ition: relative"));return widget.height=widget.node.offsetHeight;}
512 function addLineWidget(cm,handle,node,options){var widget=new LineWidget(cm,node ,options);if(widget.noHScroll)cm.display.alignWidgets=true;changeLine(cm,handle, function(line){var widgets=line.widgets||(line.widgets=[]);if(widget.insertAt==n ull)widgets.push(widget);else widgets.splice(Math.min(widgets.length-1,Math.max( 0,widget.insertAt)),0,widget);widget.line=line;if(!lineIsHidden(cm.doc,line)||wi dget.showIfHidden){var aboveVisible=heightAtLine(cm,line)<cm.doc.scrollTop;updat eLineHeight(line,line.height+widgetHeight(widget));if(aboveVisible)addToScrollPo s(cm,0,widget.height);} 518 function addLineWidget(cm,handle,node,options){var widget=new LineWidget(cm,node ,options);if(widget.noHScroll)cm.display.alignWidgets=true;changeLine(cm,handle, function(line){var widgets=line.widgets||(line.widgets=[]);if(widget.insertAt==n ull)widgets.push(widget);else widgets.splice(Math.min(widgets.length-1,Math.max( 0,widget.insertAt)),0,widget);widget.line=line;if(!lineIsHidden(cm.doc,line)||wi dget.showIfHidden){var aboveVisible=heightAtLine(cm,line)<cm.doc.scrollTop;updat eLineHeight(line,line.height+widgetHeight(widget));if(aboveVisible)addToScrollPo s(cm,0,widget.height);}
513 return true;});return widget;} 519 return true;});return widget;}
514 var Line=CodeMirror.Line=function(text,markedSpans,estimateHeight){this.text=tex t;attachMarkedSpans(this,markedSpans);this.height=estimateHeight?estimateHeight( this):1;};eventMixin(Line);function updateLine(line,text,markedSpans,estimateHei ght){line.text=text;if(line.stateAfter)line.stateAfter=null;if(line.styles)line. styles=null;if(line.order!=null)line.order=null;detachMarkedSpans(line);attachMa rkedSpans(line,markedSpans);var estHeight=estimateHeight?estimateHeight(line):1; if(estHeight!=line.height)updateLineHeight(line,estHeight);} 520 var Line=CodeMirror.Line=function(text,markedSpans,estimateHeight){this.text=tex t;attachMarkedSpans(this,markedSpans);this.height=estimateHeight?estimateHeight( this):1;};eventMixin(Line);function updateLine(line,text,markedSpans,estimateHei ght){line.text=text;if(line.stateAfter)line.stateAfter=null;if(line.styles)line. styles=null;if(line.order!=null)line.order=null;detachMarkedSpans(line);attachMa rkedSpans(line,markedSpans);var estHeight=estimateHeight?estimateHeight(line):1; if(estHeight!=line.height)updateLineHeight(line,estHeight);}
515 function cleanUpLine(line){line.parent=null;detachMarkedSpans(line);} 521 function cleanUpLine(line){line.parent=null;detachMarkedSpans(line);}
516 function runMode(cm,text,mode,state,f){var flattenSpans=mode.flattenSpans;if(fla ttenSpans==null)flattenSpans=cm.options.flattenSpans;var curStart=0,curStyle=nul l;var stream=new StringStream(text,cm.options.tabSize),style;if(text==""&&mode.b lankLine)mode.blankLine(state);while(!stream.eol()){if(stream.pos>cm.options.max HighlightLength){flattenSpans=false;stream.pos=Math.min(text.length,stream.start +50000);style=null;}else{style=mode.token(stream,state);} 522 function runMode(cm,text,mode,state,f){var flattenSpans=mode.flattenSpans;if(fla ttenSpans==null)flattenSpans=cm.options.flattenSpans;var curStart=0,curStyle=nul l;var stream=new StringStream(text,cm.options.tabSize),style;if(text==""&&mode.b lankLine)mode.blankLine(state);while(!stream.eol()){if(stream.pos>cm.options.max HighlightLength){flattenSpans=false;stream.pos=text.length;style=null;}else{styl e=mode.token(stream,state);}
517 if(!flattenSpans||curStyle!=style){if(curStart<stream.start)f(stream.start,curSt yle);curStart=stream.start;curStyle=style;} 523 if(!flattenSpans||curStyle!=style){if(curStart<stream.start)f(stream.start,curSt yle);curStart=stream.start;curStyle=style;}
518 stream.start=stream.pos;} 524 stream.start=stream.pos;}
519 if(curStart<stream.pos)f(stream.pos,curStyle);} 525 while(curStart<stream.pos){var pos=Math.min(stream.pos,curStart+50000);f(pos,cur Style);curStart=pos;}}
520 function highlightLine(cm,line,state){var st=[cm.state.modeGen];runMode(cm,line. text,cm.doc.mode,state,function(end,style){st.push(end,style);});for(var o=0;o<c m.state.overlays.length;++o){var overlay=cm.state.overlays[o],i=1,at=0;runMode(c m,line.text,overlay.mode,true,function(end,style){var start=i;while(at<end){var i_end=st[i];if(i_end>end) 526 function highlightLine(cm,line,state){var st=[cm.state.modeGen];runMode(cm,line. text,cm.doc.mode,state,function(end,style){st.push(end,style);});for(var o=0;o<c m.state.overlays.length;++o){var overlay=cm.state.overlays[o],i=1,at=0;runMode(c m,line.text,overlay.mode,true,function(end,style){var start=i;while(at<end){var i_end=st[i];if(i_end>end)
521 st.splice(i,1,end,st[i+1],i_end);i+=2;at=Math.min(end,i_end);} 527 st.splice(i,1,end,st[i+1],i_end);i+=2;at=Math.min(end,i_end);}
522 if(!style)return;if(overlay.opaque){st.splice(start,i-start,end,style);i=start+2 ;}else{for(;start<i;start+=2){var cur=st[start+1];st[start+1]=cur?cur+" "+style: style;}}});} 528 if(!style)return;if(overlay.opaque){st.splice(start,i-start,end,style);i=start+2 ;}else{for(;start<i;start+=2){var cur=st[start+1];st[start+1]=cur?cur+" "+style: style;}}});}
523 return st;} 529 return st;}
524 function getLineStyles(cm,line){if(!line.styles||line.styles[0]!=cm.state.modeGe n) 530 function getLineStyles(cm,line){if(!line.styles||line.styles[0]!=cm.state.modeGe n)
525 line.styles=highlightLine(cm,line,line.stateAfter=getStateBefore(cm,lineNo(line) ));return line.styles;} 531 line.styles=highlightLine(cm,line,line.stateAfter=getStateBefore(cm,lineNo(line) ));return line.styles;}
526 function processLine(cm,line,state){var mode=cm.doc.mode;var stream=new StringSt ream(line.text,cm.options.tabSize);if(line.text==""&&mode.blankLine)mode.blankLi ne(state);while(!stream.eol()&&stream.pos<=cm.options.maxHighlightLength){mode.t oken(stream,state);stream.start=stream.pos;}} 532 function processLine(cm,line,state){var mode=cm.doc.mode;var stream=new StringSt ream(line.text,cm.options.tabSize);if(line.text==""&&mode.blankLine)mode.blankLi ne(state);while(!stream.eol()&&stream.pos<=cm.options.maxHighlightLength){mode.t oken(stream,state);stream.start=stream.pos;}}
527 var styleToClassCache={};function styleToClass(style){if(!style)return null;retu rn styleToClassCache[style]||(styleToClassCache[style]="cm-"+style.replace(/ +/g ," cm-"));} 533 var styleToClassCache={};function interpretTokenStyle(style,builder){if(!style)r eturn null;for(;;){var lineClass=style.match(/(?:^|\s)line-(background-)?(\S+)/) ;if(!lineClass)break;style=style.slice(0,lineClass.index)+style.slice(lineClass. index+lineClass[0].length);var prop=lineClass[1]?"bgClass":"textClass";if(builde r[prop]==null)
528 function lineContent(cm,realLine,measure,copyWidgets,from,to){var merged,line=re alLine,empty=true;while(merged=collapsedSpanAtStart(line)) 534 builder[prop]=lineClass[2];else if(!(new RegExp("(?:^|\s)"+lineClass[2]+"(?:$|\s )")).test(builder[prop]))
529 line=getLine(cm.doc,merged.find().from.line);var builder={pre:elt("pre"),col:0,p os:0,measure:null,measuredSomething:false,cm:cm,from:from,to:to,copyWidgets:copy Widgets};if(line.textClass)builder.pre.className=line.textClass;do{if(line.text) empty=false;builder.measure=line==realLine&&measure;builder.pos=0;builder.addTok en=builder.measure?buildTokenMeasure:buildToken;if((ie||webkit)&&cm.getOption("l ineWrapping")) 535 builder[prop]+=" "+lineClass[2];}
536 return styleToClassCache[style]||(styleToClassCache[style]="cm-"+style.replace(/ +/g," cm-"));}
537 function buildLineContent(cm,realLine,measure,copyWidgets){var merged,line=realL ine,empty=true;while(merged=collapsedSpanAtStart(line))
538 line=getLine(cm.doc,merged.find().from.line);var builder={pre:elt("pre"),col:0,p os:0,measure:null,measuredSomething:false,cm:cm,copyWidgets:copyWidgets};do{if(l ine.text)empty=false;builder.measure=line==realLine&&measure;builder.pos=0;build er.addToken=builder.measure?buildTokenMeasure:buildToken;if((ie||webkit)&&cm.get Option("lineWrapping"))
530 builder.addToken=buildTokenSplitSpaces(builder.addToken);var next=insertLineCont ent(line,builder,getLineStyles(cm,line));if(measure&&line==realLine&&!builder.me asuredSomething){measure[0]=builder.pre.appendChild(zeroWidthElement(cm.display. measure));builder.measuredSomething=true;} 539 builder.addToken=buildTokenSplitSpaces(builder.addToken);var next=insertLineCont ent(line,builder,getLineStyles(cm,line));if(measure&&line==realLine&&!builder.me asuredSomething){measure[0]=builder.pre.appendChild(zeroWidthElement(cm.display. measure));builder.measuredSomething=true;}
531 if(next)line=getLine(cm.doc,next.to.line);}while(next);if(measure&&!builder.meas uredSomething&&!measure[0]) 540 if(next)line=getLine(cm.doc,next.to.line);}while(next);if(measure&&!builder.meas uredSomething&&!measure[0])
532 measure[0]=builder.pre.appendChild(empty?elt("span","\u00a0"):zeroWidthElement(c m.display.measure));if(!builder.pre.firstChild&&!lineIsHidden(cm.doc,realLine)) 541 measure[0]=builder.pre.appendChild(empty?elt("span","\u00a0"):zeroWidthElement(c m.display.measure));if(!builder.pre.firstChild&&!lineIsHidden(cm.doc,realLine))
533 builder.pre.appendChild(document.createTextNode("\u00a0"));var order;if(measure& &ie&&(order=getOrder(line))){var l=order.length-1;if(order[l].from==order[l].to) --l;var last=order[l],prev=order[l-1];if(last.from+1==last.to&&prev&&last.level< prev.level){var span=measure[builder.pos-1];if(span)span.parentNode.insertBefore (span.measureRight=zeroWidthElement(cm.display.measure),span.nextSibling);}} 542 builder.pre.appendChild(document.createTextNode("\u00a0"));var order;if(measure& &ie&&(order=getOrder(line))){var l=order.length-1;if(order[l].from==order[l].to) --l;var last=order[l],prev=order[l-1];if(last.from+1==last.to&&prev&&last.level< prev.level){var span=measure[builder.pos-1];if(span)span.parentNode.insertBefore (span.measureRight=zeroWidthElement(cm.display.measure),span.nextSibling);}}
534 signal(cm,"renderLine",cm,realLine,builder.pre);return builder.pre;} 543 var textClass=builder.textClass?builder.textClass+" "+(realLine.textClass||""):r ealLine.textClass;if(textClass)builder.pre.className=textClass;signal(cm,"render Line",cm,realLine,builder.pre);return builder;}
535 var tokenSpecialChars=/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\uFEFF]/g;functio n buildToken(builder,text,style,startStyle,endStyle,title){if(!text)return;if(!t okenSpecialChars.test(text)){builder.col+=text.length;var content=document.creat eTextNode(text);}else{var content=document.createDocumentFragment(),pos=0;while( true){tokenSpecialChars.lastIndex=pos;var m=tokenSpecialChars.exec(text);var ski pped=m?m.index-pos:text.length-pos;if(skipped){content.appendChild(document.crea teTextNode(text.slice(pos,pos+skipped)));builder.col+=skipped;} 544 var tokenSpecialChars=/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\uFEFF]/g;functio n buildToken(builder,text,style,startStyle,endStyle,title){if(!text)return;if(!t okenSpecialChars.test(text)){builder.col+=text.length;var content=document.creat eTextNode(text);}else{var content=document.createDocumentFragment(),pos=0;while( true){tokenSpecialChars.lastIndex=pos;var m=tokenSpecialChars.exec(text);var ski pped=m?m.index-pos:text.length-pos;if(skipped){content.appendChild(document.crea teTextNode(text.slice(pos,pos+skipped)));builder.col+=skipped;}
536 if(!m)break;pos+=skipped+1;if(m[0]=="\t"){var tabSize=builder.cm.options.tabSize ,tabWidth=tabSize-builder.col%tabSize;content.appendChild(elt("span",spaceStr(ta bWidth),"cm-tab"));builder.col+=tabWidth;}else{var token=elt("span","\u2022","cm -invalidchar");token.title="\\u"+m[0].charCodeAt(0).toString(16);content.appendC hild(token);builder.col+=1;}}} 545 if(!m)break;pos+=skipped+1;if(m[0]=="\t"){var tabSize=builder.cm.options.tabSize ,tabWidth=tabSize-builder.col%tabSize;content.appendChild(elt("span",spaceStr(ta bWidth),"cm-tab"));builder.col+=tabWidth;}else{var token=elt("span","\u2022","cm -invalidchar");token.title="\\u"+m[0].charCodeAt(0).toString(16);content.appendC hild(token);builder.col+=1;}}}
537 if(style||startStyle||endStyle||builder.measure){var fullStyle=style||"";if(star tStyle)fullStyle+=startStyle;if(endStyle)fullStyle+=endStyle;var token=elt("span ",[content],fullStyle);if(title)token.title=title;return builder.pre.appendChild (token);} 546 if(style||startStyle||endStyle||builder.measure){var fullStyle=style||"";if(star tStyle)fullStyle+=startStyle;if(endStyle)fullStyle+=endStyle;var token=elt("span ",[content],fullStyle);if(title)token.title=title;return builder.pre.appendChild (token);}
538 builder.pre.appendChild(content);} 547 builder.pre.appendChild(content);}
539 function buildTokenMeasure(builder,text,style,startStyle,endStyle){if(builder.fr om||builder.to){if(builder.from>=builder.pos+text.length){buildToken(builder,tex t,style,startStyle,endStyle);builder.pos+=text.length;return;}} 548 function buildTokenMeasure(builder,text,style,startStyle,endStyle){var wrapping= builder.cm.options.lineWrapping;for(var i=0;i<text.length;++i){var ch=text.charA t(i),start=i==0;if(ch>="\ud800"&&ch<"\udbff"&&i<text.length-1){ch=text.slice(i,i +2);++i;}else if(i&&wrapping&&spanAffectsWrapping(text,i)){builder.pre.appendChi ld(elt("wbr"));}
540 var wrapping=builder.cm.options.lineWrapping;for(var i=0;i<text.length;++i){var ch=text.charAt(i),start=i==0;if(ch>="\ud800"&&ch<"\udbff"&&i<text.length-1){ch=t ext.slice(i,i+2);++i;}else if(i&&wrapping&&spanAffectsWrapping(text,i)){builder. pre.appendChild(elt("wbr"));}
541 var old=builder.measure[builder.pos];var span=builder.measure[builder.pos]=build Token(builder,ch,style,start&&startStyle,i==text.length-1&&endStyle);if(old)span .leftSide=old.leftSide||old;if(ie&&wrapping&&ch==" "&&i&&!/\s/.test(text.charAt( i-1))&&i<text.length-1&&!/\s/.test(text.charAt(i+1))) 549 var old=builder.measure[builder.pos];var span=builder.measure[builder.pos]=build Token(builder,ch,style,start&&startStyle,i==text.length-1&&endStyle);if(old)span .leftSide=old.leftSide||old;if(ie&&wrapping&&ch==" "&&i&&!/\s/.test(text.charAt( i-1))&&i<text.length-1&&!/\s/.test(text.charAt(i+1)))
542 span.style.whiteSpace="normal";builder.pos+=ch.length;} 550 span.style.whiteSpace="normal";builder.pos+=ch.length;}
543 if(text.length)builder.measuredSomething=true;} 551 if(text.length)builder.measuredSomething=true;}
544 function buildTokenSplitSpaces(inner){function split(old){var out=" ";for(var i= 0;i<old.length-2;++i)out+=i%2?" ":"\u00a0";out+=" ";return out;} 552 function buildTokenSplitSpaces(inner){function split(old){var out=" ";for(var i= 0;i<old.length-2;++i)out+=i%2?" ":"\u00a0";out+=" ";return out;}
545 return function(builder,text,style,startStyle,endStyle,title){return inner(build er,text.replace(/ {3,}/,split),style,startStyle,endStyle,title);};} 553 return function(builder,text,style,startStyle,endStyle,title){return inner(build er,text.replace(/ {3,}/,split),style,startStyle,endStyle,title);};}
546 function buildCollapsedSpan(builder,size,marker,ignoreWidget){var widget=!ignore Widget&&marker.replacedWith;if(widget){if(builder.copyWidgets)widget=widget.clon eNode(true);builder.pre.appendChild(widget);if(builder.measure){if(size){builder .measure[builder.pos]=widget;}else{var elt=builder.measure[builder.pos]=zeroWidt hElement(builder.cm.display.measure);if(marker.type!="bookmark"||marker.insertLe ft) 554 function buildCollapsedSpan(builder,size,marker,ignoreWidget){var widget=!ignore Widget&&marker.replacedWith;if(widget){if(builder.copyWidgets)widget=widget.clon eNode(true);builder.pre.appendChild(widget);if(builder.measure){if(size){builder .measure[builder.pos]=widget;}else{var elt=zeroWidthElement(builder.cm.display.m easure);if(marker.type=="bookmark"&&!marker.insertLeft)
547 builder.pre.insertBefore(elt,widget);else 555 builder.measure[builder.pos]=builder.pre.appendChild(elt);else if(builder.measur e[builder.pos])
548 builder.pre.appendChild(elt);} 556 return;else
557 builder.measure[builder.pos]=builder.pre.insertBefore(elt,widget);}
549 builder.measuredSomething=true;}} 558 builder.measuredSomething=true;}}
550 builder.pos+=size;} 559 builder.pos+=size;}
551 function insertLineContent(line,builder,styles){var spans=line.markedSpans,allTe xt=line.text,at=0;if(!spans){if(builder.to||builder.from){for(var i=1;i<styles.l ength&&(!builder.to||builder.pos<builder.to);i+=2){var text=allText.slice(at,at= styles[i]);var textLength=text.length;var resolvedStyles=styleToClass(styles[i+1 ]);if(builder.pos+textLength<=builder.from){builder.addToken(builder,text,resolv edStyles);continue;} 560 function insertLineContent(line,builder,styles){var spans=line.markedSpans,allTe xt=line.text,at=0;if(!spans){for(var i=1;i<styles.length;i+=2)
552 if(builder.pos<builder.from&&builder.pos+textLength>builder.from){var overlap=bu ilder.from-builder.pos;builder.addToken(builder,text.substring(0,overlap),resolv edStyles);text=text.substring(overlap);} 561 builder.addToken(builder,allText.slice(at,at=styles[i]),interpretTokenStyle(styl es[i+1],builder));return;}
553 builder.addToken(builder,text.substr(0,Math.min(builder.to-builder.from,text.len gth)),resolvedStyles);}}else{for(var i=1;i<styles.length;i+=2)
554 builder.addToken(builder,allText.slice(at,at=styles[i]),styleToClass(styles[i+1] ));}
555 return;}
556 var len=allText.length,pos=0,i=1,text="",style;var nextChange=0,spanStyle,spanEn dStyle,spanStartStyle,title,collapsed;for(;;){if(nextChange==pos){spanStyle=span EndStyle=spanStartStyle=title="";collapsed=null;nextChange=Infinity;var foundBoo kmarks=[];for(var j=0;j<spans.length;++j){var sp=spans[j],m=sp.marker;if(sp.from <=pos&&(sp.to==null||sp.to>pos)){if(sp.to!=null&&nextChange>sp.to){nextChange=sp .to;spanEndStyle="";} 562 var len=allText.length,pos=0,i=1,text="",style;var nextChange=0,spanStyle,spanEn dStyle,spanStartStyle,title,collapsed;for(;;){if(nextChange==pos){spanStyle=span EndStyle=spanStartStyle=title="";collapsed=null;nextChange=Infinity;var foundBoo kmarks=[];for(var j=0;j<spans.length;++j){var sp=spans[j],m=sp.marker;if(sp.from <=pos&&(sp.to==null||sp.to>pos)){if(sp.to!=null&&nextChange>sp.to){nextChange=sp .to;spanEndStyle="";}
557 if(m.className)spanStyle+=" "+m.className;if(m.startStyle&&sp.from==pos)spanStar tStyle+=" "+m.startStyle;if(m.endStyle&&sp.to==nextChange)spanEndStyle+=" "+m.en dStyle;if(m.title&&!title)title=m.title;if(m.collapsed&&(!collapsed||collapsed.m arker.size<m.size)) 563 if(m.className)spanStyle+=" "+m.className;if(m.startStyle&&sp.from==pos)spanStar tStyle+=" "+m.startStyle;if(m.endStyle&&sp.to==nextChange)spanEndStyle+=" "+m.en dStyle;if(m.title&&!title)title=m.title;if(m.collapsed&&(!collapsed||collapsed.m arker.size<m.size))
558 collapsed=sp;}else if(sp.from>pos&&nextChange>sp.from){nextChange=sp.from;} 564 collapsed=sp;}else if(sp.from>pos&&nextChange>sp.from){nextChange=sp.from;}
559 if(m.type=="bookmark"&&sp.from==pos&&m.replacedWith)foundBookmarks.push(m);} 565 if(m.type=="bookmark"&&sp.from==pos&&m.replacedWith)foundBookmarks.push(m);}
560 if(collapsed&&(collapsed.from||0)==pos){buildCollapsedSpan(builder,(collapsed.to ==null?len:collapsed.to)-pos,collapsed.marker,collapsed.from==null);if(collapsed .to==null)return collapsed.marker.find();} 566 if(collapsed&&(collapsed.from||0)==pos){buildCollapsedSpan(builder,(collapsed.to ==null?len:collapsed.to)-pos,collapsed.marker,collapsed.from==null);if(collapsed .to==null)return collapsed.marker.find();}
561 if(!collapsed&&foundBookmarks.length)for(var j=0;j<foundBookmarks.length;++j) 567 if(!collapsed&&foundBookmarks.length)for(var j=0;j<foundBookmarks.length;++j)
562 buildCollapsedSpan(builder,0,foundBookmarks[j]);} 568 buildCollapsedSpan(builder,0,foundBookmarks[j]);}
563 if(pos>=len)break;var upto=Math.min(len,nextChange);while(true){if(text){var end =pos+text.length;if(!collapsed){var tokenText=end>upto?text.slice(0,upto-pos):te xt;builder.addToken(builder,tokenText,style?style+spanStyle:spanStyle,spanStartS tyle,pos+tokenText.length==nextChange?spanEndStyle:"",title);if(builder.to&&buil der.pos>=builder.to) 569 if(pos>=len)break;var upto=Math.min(len,nextChange);while(true){if(text){var end =pos+text.length;if(!collapsed){var tokenText=end>upto?text.slice(0,upto-pos):te xt;builder.addToken(builder,tokenText,style?style+spanStyle:spanStyle,spanStartS tyle,pos+tokenText.length==nextChange?spanEndStyle:"",title);}
564 return;}
565 if(end>=upto){text=text.slice(upto-pos);pos=upto;break;} 570 if(end>=upto){text=text.slice(upto-pos);pos=upto;break;}
566 pos=end;spanStartStyle="";} 571 pos=end;spanStartStyle="";}
567 text=allText.slice(at,at=styles[i++]);style=styleToClass(styles[i++]);}}} 572 text=allText.slice(at,at=styles[i++]);style=interpretTokenStyle(styles[i++],buil der);}}}
568 function updateDoc(doc,change,markedSpans,selAfter,estimateHeight){function span sFor(n){return markedSpans?markedSpans[n]:null;} 573 function updateDoc(doc,change,markedSpans,selAfter,estimateHeight){function span sFor(n){return markedSpans?markedSpans[n]:null;}
569 function update(line,text,spans){updateLine(line,text,spans,estimateHeight);sign alLater(line,"change",line,change);} 574 function update(line,text,spans){updateLine(line,text,spans,estimateHeight);sign alLater(line,"change",line,change);}
570 var from=change.from,to=change.to,text=change.text;var firstLine=getLine(doc,fro m.line),lastLine=getLine(doc,to.line);var lastText=lst(text),lastSpans=spansFor( text.length-1),nlines=to.line-from.line;if(from.ch==0&&to.ch==0&&lastText==""){f or(var i=0,e=text.length-1,added=[];i<e;++i) 575 var from=change.from,to=change.to,text=change.text;var firstLine=getLine(doc,fro m.line),lastLine=getLine(doc,to.line);var lastText=lst(text),lastSpans=spansFor( text.length-1),nlines=to.line-from.line;if(from.ch==0&&to.ch==0&&lastText==""){f or(var i=0,e=text.length-1,added=[];i<e;++i)
571 added.push(new Line(text[i],spansFor(i),estimateHeight));update(lastLine,lastLin e.text,lastSpans);if(nlines)doc.remove(from.line,nlines);if(added.length)doc.ins ert(from.line,added);}else if(firstLine==lastLine){if(text.length==1){update(fir stLine,firstLine.text.slice(0,from.ch)+lastText+firstLine.text.slice(to.ch),last Spans);}else{for(var added=[],i=1,e=text.length-1;i<e;++i) 576 added.push(new Line(text[i],spansFor(i),estimateHeight));update(lastLine,lastLin e.text,lastSpans);if(nlines)doc.remove(from.line,nlines);if(added.length)doc.ins ert(from.line,added);}else if(firstLine==lastLine){if(text.length==1){update(fir stLine,firstLine.text.slice(0,from.ch)+lastText+firstLine.text.slice(to.ch),last Spans);}else{for(var added=[],i=1,e=text.length-1;i<e;++i)
572 added.push(new Line(text[i],spansFor(i),estimateHeight));added.push(new Line(las tText+firstLine.text.slice(to.ch),lastSpans,estimateHeight));update(firstLine,fi rstLine.text.slice(0,from.ch)+text[0],spansFor(0));doc.insert(from.line+1,added) ;}}else if(text.length==1){update(firstLine,firstLine.text.slice(0,from.ch)+text [0]+lastLine.text.slice(to.ch),spansFor(0));doc.remove(from.line+1,nlines);}else {update(firstLine,firstLine.text.slice(0,from.ch)+text[0],spansFor(0));update(la stLine,lastText+lastLine.text.slice(to.ch),lastSpans);for(var i=1,e=text.length- 1,added=[];i<e;++i) 577 added.push(new Line(text[i],spansFor(i),estimateHeight));added.push(new Line(las tText+firstLine.text.slice(to.ch),lastSpans,estimateHeight));update(firstLine,fi rstLine.text.slice(0,from.ch)+text[0],spansFor(0));doc.insert(from.line+1,added) ;}}else if(text.length==1){update(firstLine,firstLine.text.slice(0,from.ch)+text [0]+lastLine.text.slice(to.ch),spansFor(0));doc.remove(from.line+1,nlines);}else {update(firstLine,firstLine.text.slice(0,from.ch)+text[0],spansFor(0));update(la stLine,lastText+lastLine.text.slice(to.ch),lastSpans);for(var i=1,e=text.length- 1,added=[];i<e;++i)
573 added.push(new Line(text[i],spansFor(i),estimateHeight));if(nlines>1)doc.remove( from.line+1,nlines-1);doc.insert(from.line+1,added);} 578 added.push(new Line(text[i],spansFor(i),estimateHeight));if(nlines>1)doc.remove( from.line+1,nlines-1);doc.insert(from.line+1,added);}
574 signalLater(doc,"change",doc,change);setSelection(doc,selAfter.anchor,selAfter.h ead,null,true);} 579 signalLater(doc,"change",doc,change);setSelection(doc,selAfter.anchor,selAfter.h ead,null,true);}
575 function LeafChunk(lines){this.lines=lines;this.parent=null;for(var i=0,e=lines. length,height=0;i<e;++i){lines[i].parent=this;height+=lines[i].height;} 580 function LeafChunk(lines){this.lines=lines;this.parent=null;for(var i=0,e=lines. length,height=0;i<e;++i){lines[i].parent=this;height+=lines[i].height;}
576 this.height=height;} 581 this.height=height;}
577 LeafChunk.prototype={chunkSize:function(){return this.lines.length;},removeInner :function(at,n){for(var i=at,e=at+n;i<e;++i){var line=this.lines[i];this.height- =line.height;cleanUpLine(line);signalLater(line,"delete");} 582 LeafChunk.prototype={chunkSize:function(){return this.lines.length;},removeInner :function(at,n){for(var i=at,e=at+n;i<e;++i){var line=this.lines[i];this.height- =line.height;cleanUpLine(line);signalLater(line,"delete");}
578 this.lines.splice(at,n);},collapse:function(lines){lines.splice.apply(lines,[lin es.length,0].concat(this.lines));},insertInner:function(at,lines,height){this.he ight+=height;this.lines=this.lines.slice(0,at).concat(lines).concat(this.lines.s lice(at));for(var i=0,e=lines.length;i<e;++i)lines[i].parent=this;},iterN:functi on(at,n,op){for(var e=at+n;at<e;++at) 583 this.lines.splice(at,n);},collapse:function(lines){lines.splice.apply(lines,[lin es.length,0].concat(this.lines));},insertInner:function(at,lines,height){this.he ight+=height;this.lines=this.lines.slice(0,at).concat(lines).concat(this.lines.s lice(at));for(var i=0,e=lines.length;i<e;++i)lines[i].parent=this;},iterN:functi on(at,n,op){for(var e=at+n;at<e;++at)
579 if(op(this.lines[at]))return true;}};function BranchChunk(children){this.childre n=children;var size=0,height=0;for(var i=0,e=children.length;i<e;++i){var ch=chi ldren[i];size+=ch.chunkSize();height+=ch.height;ch.parent=this;} 584 if(op(this.lines[at]))return true;}};function BranchChunk(children){this.childre n=children;var size=0,height=0;for(var i=0,e=children.length;i<e;++i){var ch=chi ldren[i];size+=ch.chunkSize();height+=ch.height;ch.parent=this;}
580 this.size=size;this.height=height;this.parent=null;} 585 this.size=size;this.height=height;this.parent=null;}
581 BranchChunk.prototype={chunkSize:function(){return this.size;},removeInner:funct ion(at,n){this.size-=n;for(var i=0;i<this.children.length;++i){var child=this.ch ildren[i],sz=child.chunkSize();if(at<sz){var rm=Math.min(n,sz-at),oldHeight=chil d.height;child.removeInner(at,rm);this.height-=oldHeight-child.height;if(sz==rm) {this.children.splice(i--,1);child.parent=null;} 586 BranchChunk.prototype={chunkSize:function(){return this.size;},removeInner:funct ion(at,n){this.size-=n;for(var i=0;i<this.children.length;++i){var child=this.ch ildren[i],sz=child.chunkSize();if(at<sz){var rm=Math.min(n,sz-at),oldHeight=chil d.height;child.removeInner(at,rm);this.height-=oldHeight-child.height;if(sz==rm) {this.children.splice(i--,1);child.parent=null;}
582 if((n-=rm)==0)break;at=0;}else at-=sz;} 587 if((n-=rm)==0)break;at=0;}else at-=sz;}
583 if(this.size-n<25){var lines=[];this.collapse(lines);this.children=[new LeafChun k(lines)];this.children[0].parent=this;}},collapse:function(lines){for(var i=0,e =this.children.length;i<e;++i)this.children[i].collapse(lines);},insertInner:fun ction(at,lines,height){this.size+=lines.length;this.height+=height;for(var i=0,e =this.children.length;i<e;++i){var child=this.children[i],sz=child.chunkSize();i f(at<=sz){child.insertInner(at,lines,height);if(child.lines&&child.lines.length> 50){while(child.lines.length>50){var spilled=child.lines.splice(child.lines.leng th-25,25);var newleaf=new LeafChunk(spilled);child.height-=newleaf.height;this.c hildren.splice(i+1,0,newleaf);newleaf.parent=this;} 588 if(this.size-n<25){var lines=[];this.collapse(lines);this.children=[new LeafChun k(lines)];this.children[0].parent=this;}},collapse:function(lines){for(var i=0,e =this.children.length;i<e;++i)this.children[i].collapse(lines);},insertInner:fun ction(at,lines,height){this.size+=lines.length;this.height+=height;for(var i=0,e =this.children.length;i<e;++i){var child=this.children[i],sz=child.chunkSize();i f(at<=sz){child.insertInner(at,lines,height);if(child.lines&&child.lines.length> 50){while(child.lines.length>50){var spilled=child.lines.splice(child.lines.leng th-25,25);var newleaf=new LeafChunk(spilled);child.height-=newleaf.height;this.c hildren.splice(i+1,0,newleaf);newleaf.parent=this;}
584 this.maybeSpill();} 589 this.maybeSpill();}
585 break;} 590 break;}
586 at-=sz;}},maybeSpill:function(){if(this.children.length<=10)return;var me=this;d o{var spilled=me.children.splice(me.children.length-5,5);var sibling=new BranchC hunk(spilled);if(!me.parent){var copy=new BranchChunk(me.children);copy.parent=m e;me.children=[copy,sibling];me=copy;}else{me.size-=sibling.size;me.height-=sibl ing.height;var myIndex=indexOf(me.parent.children,me);me.parent.children.splice( myIndex+1,0,sibling);} 591 at-=sz;}},maybeSpill:function(){if(this.children.length<=10)return;var me=this;d o{var spilled=me.children.splice(me.children.length-5,5);var sibling=new BranchC hunk(spilled);if(!me.parent){var copy=new BranchChunk(me.children);copy.parent=m e;me.children=[copy,sibling];me=copy;}else{me.size-=sibling.size;me.height-=sibl ing.height;var myIndex=indexOf(me.parent.children,me);me.parent.children.splice( myIndex+1,0,sibling);}
587 sibling.parent=me.parent;}while(me.children.length>10);me.parent.maybeSpill();}, iterN:function(at,n,op){for(var i=0,e=this.children.length;i<e;++i){var child=th is.children[i],sz=child.chunkSize();if(at<sz){var used=Math.min(n,sz-at);if(chil d.iterN(at,used,op))return true;if((n-=used)==0)break;at=0;}else at-=sz;}}};var nextDocId=0;var Doc=CodeMirror.Doc=function(text,mode,firstLine){if(!(this insta nceof Doc))return new Doc(text,mode,firstLine);if(firstLine==null)firstLine=0;Br anchChunk.call(this,[new LeafChunk([new Line("",null)])]);this.first=firstLine;t his.scrollTop=this.scrollLeft=0;this.cantEdit=false;this.history=makeHistory();t his.cleanGeneration=1;this.frontier=firstLine;var start=Pos(firstLine,0);this.se l={from:start,to:start,head:start,anchor:start,shift:false,extend:false,goalColu mn:null};this.id=++nextDocId;this.modeOption=mode;if(typeof text=="string")text= splitLines(text);updateDoc(this,{from:start,to:start,text:text},null,{head:start ,anchor:start});};Doc.prototype=createObj(BranchChunk.prototype,{constructor:Doc ,iter:function(from,to,op){if(op)this.iterN(from-this.first,to-from,op);else thi s.iterN(this.first,this.first+this.size,from);},insert:function(at,lines){var he ight=0;for(var i=0,e=lines.length;i<e;++i)height+=lines[i].height;this.insertInn er(at-this.first,lines,height);},remove:function(at,n){this.removeInner(at-this. first,n);},getValue:function(lineSep){var lines=getLines(this,this.first,this.fi rst+this.size);if(lineSep===false)return lines;return lines.join(lineSep||"\n"); },setValue:function(code){var top=Pos(this.first,0),last=this.first+this.size-1; makeChange(this,{from:top,to:Pos(last,getLine(this,last).text.length),text:split Lines(code),origin:"setValue"},{head:top,anchor:top},true);},replaceRange:functi on(code,from,to,origin){from=clipPos(this,from);to=to?clipPos(this,to):from;repl aceRange(this,code,from,to,origin);},getRange:function(from,to,lineSep){var line s=getBetween(this,clipPos(this,from),clipPos(this,to));if(lineSep===false)return lines;return lines.join(lineSep||"\n");},getLine:function(line){var l=this.getL ineHandle(line);return l&&l.text;},setLine:function(line,text){if(isLine(this,li ne)) 592 sibling.parent=me.parent;}while(me.children.length>10);me.parent.maybeSpill();}, iterN:function(at,n,op){for(var i=0,e=this.children.length;i<e;++i){var child=th is.children[i],sz=child.chunkSize();if(at<sz){var used=Math.min(n,sz-at);if(chil d.iterN(at,used,op))return true;if((n-=used)==0)break;at=0;}else at-=sz;}}};var nextDocId=0;var Doc=CodeMirror.Doc=function(text,mode,firstLine){if(!(this insta nceof Doc))return new Doc(text,mode,firstLine);if(firstLine==null)firstLine=0;Br anchChunk.call(this,[new LeafChunk([new Line("",null)])]);this.first=firstLine;t his.scrollTop=this.scrollLeft=0;this.cantEdit=false;this.history=makeHistory();t his.cleanGeneration=1;this.frontier=firstLine;var start=Pos(firstLine,0);this.se l={from:start,to:start,head:start,anchor:start,shift:false,extend:false,goalColu mn:null};this.id=++nextDocId;this.modeOption=mode;if(typeof text=="string")text= splitLines(text);updateDoc(this,{from:start,to:start,text:text},null,{head:start ,anchor:start});};Doc.prototype=createObj(BranchChunk.prototype,{constructor:Doc ,iter:function(from,to,op){if(op)this.iterN(from-this.first,to-from,op);else thi s.iterN(this.first,this.first+this.size,from);},insert:function(at,lines){var he ight=0;for(var i=0,e=lines.length;i<e;++i)height+=lines[i].height;this.insertInn er(at-this.first,lines,height);},remove:function(at,n){this.removeInner(at-this. first,n);},getValue:function(lineSep){var lines=getLines(this,this.first,this.fi rst+this.size);if(lineSep===false)return lines;return lines.join(lineSep||"\n"); },setValue:function(code){var top=Pos(this.first,0),last=this.first+this.size-1; makeChange(this,{from:top,to:Pos(last,getLine(this,last).text.length),text:split Lines(code),origin:"setValue"},{head:top,anchor:top},true);},replaceRange:functi on(code,from,to,origin){from=clipPos(this,from);to=to?clipPos(this,to):from;repl aceRange(this,code,from,to,origin);},getRange:function(from,to,lineSep){var line s=getBetween(this,clipPos(this,from),clipPos(this,to));if(lineSep===false)return lines;return lines.join(lineSep||"\n");},getLine:function(line){var l=this.getL ineHandle(line);return l&&l.text;},setLine:function(line,text){if(isLine(this,li ne))
588 replaceRange(this,text,Pos(line,0),clipPos(this,Pos(line)));},removeLine:functio n(line){if(line)replaceRange(this,"",clipPos(this,Pos(line-1)),clipPos(this,Pos( line)));else replaceRange(this,"",Pos(0,0),clipPos(this,Pos(1,0)));},getLineHand le:function(line){if(isLine(this,line))return getLine(this,line);},getLineNumber :function(line){return lineNo(line);},getLineHandleVisualStart:function(line){if (typeof line=="number")line=getLine(this,line);return visualLine(this,line);},li neCount:function(){return this.size;},firstLine:function(){return this.first;},l astLine:function(){return this.first+this.size-1;},clipPos:function(pos){return clipPos(this,pos);},getCursor:function(start){var sel=this.sel,pos;if(start==nul l||start=="head")pos=sel.head;else if(start=="anchor")pos=sel.anchor;else if(sta rt=="end"||start===false)pos=sel.to;else pos=sel.from;return copyPos(pos);},some thingSelected:function(){return!posEq(this.sel.head,this.sel.anchor);},setCursor :docOperation(function(line,ch,extend){var pos=clipPos(this,typeof line=="number "?Pos(line,ch||0):line);if(extend)extendSelection(this,pos);else setSelection(th is,pos,pos);}),setSelection:docOperation(function(anchor,head){setSelection(this ,clipPos(this,anchor),clipPos(this,head||anchor));}),extendSelection:docOperatio n(function(from,to){extendSelection(this,clipPos(this,from),to&&clipPos(this,to) );}),getSelection:function(lineSep){return this.getRange(this.sel.from,this.sel. to,lineSep);},replaceSelection:function(code,collapse,origin){makeChange(this,{f rom:this.sel.from,to:this.sel.to,text:splitLines(code),origin:origin},collapse|| "around");},undo:docOperation(function(){makeChangeFromHistory(this,"undo");}),r edo:docOperation(function(){makeChangeFromHistory(this,"redo");}),setExtending:f unction(val){this.sel.extend=val;},historySize:function(){var hist=this.history; return{undo:hist.done.length,redo:hist.undone.length};},clearHistory:function(){ this.history=makeHistory(this.history.maxGeneration);},markClean:function(){this .cleanGeneration=this.changeGeneration();},changeGeneration:function(){this.hist ory.lastOp=this.history.lastOrigin=null;return this.history.generation;},isClean :function(gen){return this.history.generation==(gen||this.cleanGeneration);},get History:function(){return{done:copyHistoryArray(this.history.done),undone:copyHi storyArray(this.history.undone)};},setHistory:function(histData){var hist=this.h istory=makeHistory(this.history.maxGeneration);hist.done=histData.done.slice(0); hist.undone=histData.undone.slice(0);},markText:function(from,to,options){return markText(this,clipPos(this,from),clipPos(this,to),options,"range");},setBookmar k:function(pos,options){var realOpts={replacedWith:options&&(options.nodeType==n ull?options.widget:options),insertLeft:options&&options.insertLeft};pos=clipPos( this,pos);return markText(this,pos,pos,realOpts,"bookmark");},findMarksAt:functi on(pos){pos=clipPos(this,pos);var markers=[],spans=getLine(this,pos.line).marked Spans;if(spans)for(var i=0;i<spans.length;++i){var span=spans[i];if((span.from== null||span.from<=pos.ch)&&(span.to==null||span.to>=pos.ch)) 593 replaceRange(this,text,Pos(line,0),clipPos(this,Pos(line)));},removeLine:functio n(line){if(line)replaceRange(this,"",clipPos(this,Pos(line-1)),clipPos(this,Pos( line)));else replaceRange(this,"",Pos(0,0),clipPos(this,Pos(1,0)));},getLineHand le:function(line){if(isLine(this,line))return getLine(this,line);},getLineNumber :function(line){return lineNo(line);},getLineHandleVisualStart:function(line){if (typeof line=="number")line=getLine(this,line);return visualLine(this,line);},li neCount:function(){return this.size;},firstLine:function(){return this.first;},l astLine:function(){return this.first+this.size-1;},clipPos:function(pos){return clipPos(this,pos);},getCursor:function(start){var sel=this.sel,pos;if(start==nul l||start=="head")pos=sel.head;else if(start=="anchor")pos=sel.anchor;else if(sta rt=="end"||start===false)pos=sel.to;else pos=sel.from;return copyPos(pos);},some thingSelected:function(){return!posEq(this.sel.head,this.sel.anchor);},setCursor :docOperation(function(line,ch,extend){var pos=clipPos(this,typeof line=="number "?Pos(line,ch||0):line);if(extend)extendSelection(this,pos);else setSelection(th is,pos,pos);}),setSelection:docOperation(function(anchor,head,bias){setSelection (this,clipPos(this,anchor),clipPos(this,head||anchor),bias);}),extendSelection:d ocOperation(function(from,to,bias){extendSelection(this,clipPos(this,from),to&&c lipPos(this,to),bias);}),getSelection:function(lineSep){return this.getRange(thi s.sel.from,this.sel.to,lineSep);},replaceSelection:function(code,collapse,origin ){makeChange(this,{from:this.sel.from,to:this.sel.to,text:splitLines(code),origi n:origin},collapse||"around");},undo:docOperation(function(){makeChangeFromHisto ry(this,"undo");}),redo:docOperation(function(){makeChangeFromHistory(this,"redo ");}),setExtending:function(val){this.sel.extend=val;},historySize:function(){va r hist=this.history;return{undo:hist.done.length,redo:hist.undone.length};},clea rHistory:function(){this.history=makeHistory(this.history.maxGeneration);},markC lean:function(){this.cleanGeneration=this.changeGeneration();},changeGeneration: function(){this.history.lastOp=this.history.lastOrigin=null;return this.history. generation;},isClean:function(gen){return this.history.generation==(gen||this.cl eanGeneration);},getHistory:function(){return{done:copyHistoryArray(this.history .done),undone:copyHistoryArray(this.history.undone)};},setHistory:function(histD ata){var hist=this.history=makeHistory(this.history.maxGeneration);hist.done=his tData.done.slice(0);hist.undone=histData.undone.slice(0);},markText:function(fro m,to,options){return markText(this,clipPos(this,from),clipPos(this,to),options," range");},setBookmark:function(pos,options){var realOpts={replacedWith:options&& (options.nodeType==null?options.widget:options),insertLeft:options&&options.inse rtLeft};pos=clipPos(this,pos);return markText(this,pos,pos,realOpts,"bookmark"); },findMarksAt:function(pos){pos=clipPos(this,pos);var markers=[],spans=getLine(t his,pos.line).markedSpans;if(spans)for(var i=0;i<spans.length;++i){var span=span s[i];if((span.from==null||span.from<=pos.ch)&&(span.to==null||span.to>=pos.ch))
589 markers.push(span.marker.parent||span.marker);} 594 markers.push(span.marker.parent||span.marker);}
590 return markers;},getAllMarks:function(){var markers=[];this.iter(function(line){ var sps=line.markedSpans;if(sps)for(var i=0;i<sps.length;++i) 595 return markers;},getAllMarks:function(){var markers=[];this.iter(function(line){ var sps=line.markedSpans;if(sps)for(var i=0;i<sps.length;++i)
591 if(sps[i].from!=null)markers.push(sps[i].marker);});return markers;},posFromInde x:function(off){var ch,lineNo=this.first;this.iter(function(line){var sz=line.te xt.length+1;if(sz>off){ch=off;return true;} 596 if(sps[i].from!=null)markers.push(sps[i].marker);});return markers;},posFromInde x:function(off){var ch,lineNo=this.first;this.iter(function(line){var sz=line.te xt.length+1;if(sz>off){ch=off;return true;}
592 off-=sz;++lineNo;});return clipPos(this,Pos(lineNo,ch));},indexFromPos:function( coords){coords=clipPos(this,coords);var index=coords.ch;if(coords.line<this.firs t||coords.ch<0)return 0;this.iter(this.first,coords.line,function(line){index+=l ine.text.length+1;});return index;},copy:function(copyHistory){var doc=new Doc(g etLines(this,this.first,this.first+this.size),this.modeOption,this.first);doc.sc rollTop=this.scrollTop;doc.scrollLeft=this.scrollLeft;doc.sel={from:this.sel.fro m,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor,shift:this.sel.shift, extend:false,goalColumn:this.sel.goalColumn};if(copyHistory){doc.history.undoDep th=this.history.undoDepth;doc.setHistory(this.getHistory());} 597 off-=sz;++lineNo;});return clipPos(this,Pos(lineNo,ch));},indexFromPos:function( coords){coords=clipPos(this,coords);var index=coords.ch;if(coords.line<this.firs t||coords.ch<0)return 0;this.iter(this.first,coords.line,function(line){index+=l ine.text.length+1;});return index;},copy:function(copyHistory){var doc=new Doc(g etLines(this,this.first,this.first+this.size),this.modeOption,this.first);doc.sc rollTop=this.scrollTop;doc.scrollLeft=this.scrollLeft;doc.sel={from:this.sel.fro m,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor,shift:this.sel.shift, extend:false,goalColumn:this.sel.goalColumn};if(copyHistory){doc.history.undoDep th=this.history.undoDepth;doc.setHistory(this.getHistory());}
593 return doc;},linkedDoc:function(options){if(!options)options={};var from=this.fi rst,to=this.first+this.size;if(options.from!=null&&options.from>from)from=option s.from;if(options.to!=null&&options.to<to)to=options.to;var copy=new Doc(getLine s(this,from,to),options.mode||this.modeOption,from);if(options.sharedHist)copy.h istory=this.history;(this.linked||(this.linked=[])).push({doc:copy,sharedHist:op tions.sharedHist});copy.linked=[{doc:this,isParent:true,sharedHist:options.share dHist}];return copy;},unlinkDoc:function(other){if(other instanceof CodeMirror)o ther=other.doc;if(this.linked)for(var i=0;i<this.linked.length;++i){var link=thi s.linked[i];if(link.doc!=other)continue;this.linked.splice(i,1);other.unlinkDoc( this);break;} 598 return doc;},linkedDoc:function(options){if(!options)options={};var from=this.fi rst,to=this.first+this.size;if(options.from!=null&&options.from>from)from=option s.from;if(options.to!=null&&options.to<to)to=options.to;var copy=new Doc(getLine s(this,from,to),options.mode||this.modeOption,from);if(options.sharedHist)copy.h istory=this.history;(this.linked||(this.linked=[])).push({doc:copy,sharedHist:op tions.sharedHist});copy.linked=[{doc:this,isParent:true,sharedHist:options.share dHist}];return copy;},unlinkDoc:function(other){if(other instanceof CodeMirror)o ther=other.doc;if(this.linked)for(var i=0;i<this.linked.length;++i){var link=thi s.linked[i];if(link.doc!=other)continue;this.linked.splice(i,1);other.unlinkDoc( this);break;}
594 if(other.history==this.history){var splitIds=[other.id];linkedDocs(other,functio n(doc){splitIds.push(doc.id);},true);other.history=makeHistory();other.history.d one=copyHistoryArray(this.history.done,splitIds);other.history.undone=copyHistor yArray(this.history.undone,splitIds);}},iterLinkedDocs:function(f){linkedDocs(th is,f);},getMode:function(){return this.mode;},getEditor:function(){return this.c m;}});Doc.prototype.eachLine=Doc.prototype.iter;var dontDelegate="iter insert re move copy getEditor".split(" ");for(var prop in Doc.prototype)if(Doc.prototype.h asOwnProperty(prop)&&indexOf(dontDelegate,prop)<0) 599 if(other.history==this.history){var splitIds=[other.id];linkedDocs(other,functio n(doc){splitIds.push(doc.id);},true);other.history=makeHistory();other.history.d one=copyHistoryArray(this.history.done,splitIds);other.history.undone=copyHistor yArray(this.history.undone,splitIds);}},iterLinkedDocs:function(f){linkedDocs(th is,f);},getMode:function(){return this.mode;},getEditor:function(){return this.c m;}});Doc.prototype.eachLine=Doc.prototype.iter;var dontDelegate="iter insert re move copy getEditor".split(" ");for(var prop in Doc.prototype)if(Doc.prototype.h asOwnProperty(prop)&&indexOf(dontDelegate,prop)<0)
595 CodeMirror.prototype[prop]=(function(method){return function(){return method.app ly(this.doc,arguments);};})(Doc.prototype[prop]);eventMixin(Doc);function linked Docs(doc,f,sharedHistOnly){function propagate(doc,skip,sharedHist){if(doc.linked )for(var i=0;i<doc.linked.length;++i){var rel=doc.linked[i];if(rel.doc==skip)con tinue;var shared=sharedHist&&rel.sharedHist;if(sharedHistOnly&&!shared)continue; f(rel.doc,shared);propagate(rel.doc,doc,shared);}} 600 CodeMirror.prototype[prop]=(function(method){return function(){return method.app ly(this.doc,arguments);};})(Doc.prototype[prop]);eventMixin(Doc);function linked Docs(doc,f,sharedHistOnly){function propagate(doc,skip,sharedHist){if(doc.linked )for(var i=0;i<doc.linked.length;++i){var rel=doc.linked[i];if(rel.doc==skip)con tinue;var shared=sharedHist&&rel.sharedHist;if(sharedHistOnly&&!shared)continue; f(rel.doc,shared);propagate(rel.doc,doc,shared);}}
596 propagate(doc,null,true);} 601 propagate(doc,null,true);}
597 function attachDoc(cm,doc){if(doc.cm)throw new Error("This document is already i n use.");cm.doc=doc;doc.cm=cm;estimateLineHeights(cm);loadMode(cm);if(!cm.option s.lineWrapping)computeMaxLength(cm);cm.options.mode=doc.modeOption;regChange(cm) ;} 602 function attachDoc(cm,doc){if(doc.cm)throw new Error("This document is already i n use.");cm.doc=doc;doc.cm=cm;estimateLineHeights(cm);loadMode(cm);if(!cm.option s.lineWrapping)computeMaxLength(cm);cm.options.mode=doc.modeOption;regChange(cm) ;}
598 function getLine(chunk,n){n-=chunk.first;while(!chunk.lines){for(var i=0;;++i){v ar child=chunk.children[i],sz=child.chunkSize();if(n<sz){chunk=child;break;} 603 function getLine(chunk,n){n-=chunk.first;while(!chunk.lines){for(var i=0;;++i){v ar child=chunk.children[i],sz=child.chunkSize();if(n<sz){chunk=child;break;}
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 function isEmpty(obj){for(var n in obj)if(obj.hasOwnProperty(n)&&obj[n])return f alse;return true;} 681 function isEmpty(obj){for(var n in obj)if(obj.hasOwnProperty(n)&&obj[n])return f alse;return true;}
677 var isExtendingChar=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF \u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u0 6DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F\udc00 -\udfff]/;function elt(tag,content,className,style){var e=document.createElement (tag);if(className)e.className=className;if(style)e.style.cssText=style;if(typeo f content=="string")setTextContent(e,content);else if(content)for(var i=0;i<cont ent.length;++i)e.appendChild(content[i]);return e;} 682 var isExtendingChar=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF \u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u0 6DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F\udc00 -\udfff]/;function elt(tag,content,className,style){var e=document.createElement (tag);if(className)e.className=className;if(style)e.style.cssText=style;if(typeo f content=="string")setTextContent(e,content);else if(content)for(var i=0;i<cont ent.length;++i)e.appendChild(content[i]);return e;}
678 function removeChildren(e){for(var count=e.childNodes.length;count>0;--count) 683 function removeChildren(e){for(var count=e.childNodes.length;count>0;--count)
679 e.removeChild(e.firstChild);return e;} 684 e.removeChild(e.firstChild);return e;}
680 function removeChildrenAndAdd(parent,e){return removeChildren(parent).appendChil d(e);} 685 function removeChildrenAndAdd(parent,e){return removeChildren(parent).appendChil d(e);}
681 function setTextContent(e,str){if(ie_lt9){e.innerHTML="";e.appendChild(document. createTextNode(str));}else e.textContent=str;} 686 function setTextContent(e,str){if(ie_lt9){e.innerHTML="";e.appendChild(document. createTextNode(str));}else e.textContent=str;}
682 function getRect(node){return node.getBoundingClientRect();} 687 function getRect(node){return node.getBoundingClientRect();}
683 CodeMirror.replaceGetRect=function(f){getRect=f;};var dragAndDrop=function(){if( ie_lt9)return false;var div=elt('div');return"draggable"in div||"dragDrop"in div ;}();function spanAffectsWrapping(){return false;} 688 CodeMirror.replaceGetRect=function(f){getRect=f;};var dragAndDrop=function(){if( ie_lt9)return false;var div=elt('div');return"draggable"in div||"dragDrop"in div ;}();function spanAffectsWrapping(){return false;}
684 if(gecko) 689 if(gecko)
685 spanAffectsWrapping=function(str,i){return str.charCodeAt(i-1)==36&&str.charCode At(i)==39;};else if(safari&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent) ) 690 spanAffectsWrapping=function(str,i){return str.charCodeAt(i-1)==36&&str.charCode At(i)==39;};else if(safari&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent) )
686 spanAffectsWrapping=function(str,i){return/\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}] /.test(str.slice(i-1,i+1));};else if(webkit&&!/Chrome\/(?:29|[3-9]\d|\d\d\d)\./. test(navigator.userAgent)) 691 spanAffectsWrapping=function(str,i){return/\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}] /.test(str.slice(i-1,i+1));};else if(webkit&&/Chrome\/(?:29|[3-9]\d|\d\d\d)\./.t est(navigator.userAgent))
692 spanAffectsWrapping=function(str,i){var code=str.charCodeAt(i-1);return code>=82 08&&code<=8212;};else if(webkit)
687 spanAffectsWrapping=function(str,i){if(i>1&&str.charCodeAt(i-1)==45){if(/\w/.tes t(str.charAt(i-2))&&/[^\-?\.]/.test(str.charAt(i)))return true;if(i>2&&/[\d\.,]/ .test(str.charAt(i-2))&&/[\d\.,]/.test(str.charAt(i)))return false;} 693 spanAffectsWrapping=function(str,i){if(i>1&&str.charCodeAt(i-1)==45){if(/\w/.tes t(str.charAt(i-2))&&/[^\-?\.]/.test(str.charAt(i)))return true;if(i>2&&/[\d\.,]/ .test(str.charAt(i-2))&&/[\d\.,]/.test(str.charAt(i)))return false;}
688 return/[~!#%&*)=+}\]|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^& *(_=+{[|><]|…[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i-1,i+1));};var knownScrollb arWidth;function scrollbarWidth(measure){if(knownScrollbarWidth!=null)return kno wnScrollbarWidth;var test=elt("div",null,null,"width: 50px; height: 50px; overfl ow-x: scroll");removeChildrenAndAdd(measure,test);if(test.offsetWidth) 694 return/[~!#%&*)=+}\]|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^& *(_=+{[|><]|…[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i-1,i+1));};var knownScrollb arWidth;function scrollbarWidth(measure){if(knownScrollbarWidth!=null)return kno wnScrollbarWidth;var test=elt("div",null,null,"width: 50px; height: 50px; overfl ow-x: scroll");removeChildrenAndAdd(measure,test);if(test.offsetWidth)
689 knownScrollbarWidth=test.offsetHeight-test.clientHeight;return knownScrollbarWid th||0;} 695 knownScrollbarWidth=test.offsetHeight-test.clientHeight;return knownScrollbarWid th||0;}
690 var zwspSupported;function zeroWidthElement(measure){if(zwspSupported==null){var test=elt("span","\u200b");removeChildrenAndAdd(measure,elt("span",[test,documen t.createTextNode("x")]));if(measure.firstChild.offsetHeight!=0) 696 var zwspSupported;function zeroWidthElement(measure){if(zwspSupported==null){var test=elt("span","\u200b");removeChildrenAndAdd(measure,elt("span",[test,documen t.createTextNode("x")]));if(measure.firstChild.offsetHeight!=0)
691 zwspSupported=test.offsetWidth<=1&&test.offsetHeight>2&&!ie_lt8;} 697 zwspSupported=test.offsetWidth<=1&&test.offsetHeight>2&&!ie_lt8;}
692 if(zwspSupported)return elt("span","\u200b");else return elt("span","\u00a0",nul l,"display: inline-block; width: 1px; margin-right: -1px");} 698 if(zwspSupported)return elt("span","\u200b");else return elt("span","\u00a0",nul l,"display: inline-block; width: 1px; margin-right: -1px");}
693 var splitLines="\n\nb".split(/\n/).length!=3?function(string){var pos=0,result=[ ],l=string.length;while(pos<=l){var nl=string.indexOf("\n",pos);if(nl==-1)nl=str ing.length;var line=string.slice(pos,string.charAt(nl-1)=="\r"?nl-1:nl);var rt=l ine.indexOf("\r");if(rt!=-1){result.push(line.slice(0,rt));pos+=rt+1;}else{resul t.push(line);pos=nl+1;}} 699 var splitLines="\n\nb".split(/\n/).length!=3?function(string){var pos=0,result=[ ],l=string.length;while(pos<=l){var nl=string.indexOf("\n",pos);if(nl==-1)nl=str ing.length;var line=string.slice(pos,string.charAt(nl-1)=="\r"?nl-1:nl);var rt=l ine.indexOf("\r");if(rt!=-1){result.push(line.slice(0,rt));pos+=rt+1;}else{resul t.push(line);pos=nl+1;}}
694 return result;}:function(string){return string.split(/\r\n?|\n/);};CodeMirror.sp litLines=splitLines;var hasSelection=window.getSelection?function(te){try{return te.selectionStart!=te.selectionEnd;} 700 return result;}:function(string){return string.split(/\r\n?|\n/);};CodeMirror.sp litLines=splitLines;var hasSelection=window.getSelection?function(te){try{return te.selectionStart!=te.selectionEnd;}
695 catch(e){return false;}}:function(te){try{var range=te.ownerDocument.selection.c reateRange();} 701 catch(e){return false;}}:function(te){try{var range=te.ownerDocument.selection.c reateRange();}
696 catch(e){} 702 catch(e){}
(...skipping 26 matching lines...) Expand all
723 for(var i=0;i<len;++i){if(isNeutral.test(types[i])){for(var end=i+1;end<len&&isN eutral.test(types[end]);++end){} 729 for(var i=0;i<len;++i){if(isNeutral.test(types[i])){for(var end=i+1;end<len&&isN eutral.test(types[end]);++end){}
724 var before=(i?types[i-1]:outerType)=="L";var after=(end<len-1?types[end]:outerTy pe)=="L";var replace=before||after?"L":"R";for(var j=i;j<end;++j)types[j]=replac e;i=end-1;}} 730 var before=(i?types[i-1]:outerType)=="L";var after=(end<len-1?types[end]:outerTy pe)=="L";var replace=before||after?"L":"R";for(var j=i;j<end;++j)types[j]=replac e;i=end-1;}}
725 var order=[],m;for(var i=0;i<len;){if(countsAsLeft.test(types[i])){var start=i;f or(++i;i<len&&countsAsLeft.test(types[i]);++i){} 731 var order=[],m;for(var i=0;i<len;){if(countsAsLeft.test(types[i])){var start=i;f or(++i;i<len&&countsAsLeft.test(types[i]);++i){}
726 order.push({from:start,to:i,level:0});}else{var pos=i,at=order.length;for(++i;i< len&&types[i]!="L";++i){} 732 order.push({from:start,to:i,level:0});}else{var pos=i,at=order.length;for(++i;i< len&&types[i]!="L";++i){}
727 for(var j=pos;j<i;){if(countsAsNum.test(types[j])){if(pos<j)order.splice(at,0,{f rom:pos,to:j,level:1});var nstart=j;for(++j;j<i&&countsAsNum.test(types[j]);++j) {} 733 for(var j=pos;j<i;){if(countsAsNum.test(types[j])){if(pos<j)order.splice(at,0,{f rom:pos,to:j,level:1});var nstart=j;for(++j;j<i&&countsAsNum.test(types[j]);++j) {}
728 order.splice(at,0,{from:nstart,to:j,level:2});pos=j;}else++j;} 734 order.splice(at,0,{from:nstart,to:j,level:2});pos=j;}else++j;}
729 if(pos<i)order.splice(at,0,{from:pos,to:i,level:1});}} 735 if(pos<i)order.splice(at,0,{from:pos,to:i,level:1});}}
730 if(order[0].level==1&&(m=str.match(/^\s+/))){order[0].from=m[0].length;order.uns hift({from:0,to:m[0].length,level:0});} 736 if(order[0].level==1&&(m=str.match(/^\s+/))){order[0].from=m[0].length;order.uns hift({from:0,to:m[0].length,level:0});}
731 if(lst(order).level==1&&(m=str.match(/\s+$/))){lst(order).to-=m[0].length;order. push({from:len-m[0].length,to:len,level:0});} 737 if(lst(order).level==1&&(m=str.match(/\s+$/))){lst(order).to-=m[0].length;order. push({from:len-m[0].length,to:len,level:0});}
732 if(order[0].level!=lst(order).level) 738 if(order[0].level!=lst(order).level)
733 order.push({from:len,to:len,level:order[0].level});return order;};})();CodeMirro r.version="3.15.1";return CodeMirror;})();;CodeMirror.defineMode("css",function( config){return CodeMirror.getMode(config,"text/css");});CodeMirror.defineMode("c ss-base",function(config,parserConfig){"use strict";var indentUnit=config.indent Unit,hooks=parserConfig.hooks||{},atMediaTypes=parserConfig.atMediaTypes||{},atM ediaFeatures=parserConfig.atMediaFeatures||{},propertyKeywords=parserConfig.prop ertyKeywords||{},colorKeywords=parserConfig.colorKeywords||{},valueKeywords=pars erConfig.valueKeywords||{},allowNested=!!parserConfig.allowNested,type=null;func tion ret(style,tp){type=tp;return style;} 739 order.push({from:len,to:len,level:order[0].level});return order;};})();CodeMirro r.version="3.16.1";return CodeMirror;})();;CodeMirror.defineMode("css",function( config){return CodeMirror.getMode(config,"text/css");});CodeMirror.defineMode("c ss-base",function(config,parserConfig){"use strict";var indentUnit=config.indent Unit,hooks=parserConfig.hooks||{},atMediaTypes=parserConfig.atMediaTypes||{},atM ediaFeatures=parserConfig.atMediaFeatures||{},propertyKeywords=parserConfig.prop ertyKeywords||{},colorKeywords=parserConfig.colorKeywords||{},valueKeywords=pars erConfig.valueKeywords||{},allowNested=!!parserConfig.allowNested,type=null;func tion ret(style,tp){type=tp;return style;}
734 function tokenBase(stream,state){var ch=stream.next();if(hooks[ch]){var result=h ooks[ch](stream,state);if(result!==false)return result;} 740 function tokenBase(stream,state){var ch=stream.next();if(hooks[ch]){var result=h ooks[ch](stream,state);if(result!==false)return result;}
735 if(ch=="@"){stream.eatWhile(/[\w\\\-]/);return ret("def",stream.current());} 741 if(ch=="@"){stream.eatWhile(/[\w\\\-]/);return ret("def",stream.current());}
736 else if(ch=="=")ret(null,"compare");else if((ch=="~"||ch=="|")&&stream.eat("=")) return ret(null,"compare");else if(ch=="\""||ch=="'"){state.tokenize=tokenString (ch);return state.tokenize(stream,state);} 742 else if(ch=="=")ret(null,"compare");else if((ch=="~"||ch=="|")&&stream.eat("=")) return ret(null,"compare");else if(ch=="\""||ch=="'"){state.tokenize=tokenString (ch);return state.tokenize(stream,state);}
737 else if(ch=="#"){stream.eatWhile(/[\w\\\-]/);return ret("atom","hash");} 743 else if(ch=="#"){stream.eatWhile(/[\w\\\-]/);return ret("atom","hash");}
738 else if(ch=="!"){stream.match(/^\s*\w*/);return ret("keyword","important");} 744 else if(ch=="!"){stream.match(/^\s*\w*/);return ret("keyword","important");}
739 else if(/\d/.test(ch)){stream.eatWhile(/[\w.%]/);return ret("number","unit");} 745 else if(/\d/.test(ch)){stream.eatWhile(/[\w.%]/);return ret("number","unit");}
740 else if(ch==="-"){if(/\d/.test(stream.peek())){stream.eatWhile(/[\w.%]/);return ret("number","unit");}else if(stream.match(/^[^-]+-/)){return ret("meta","meta") ;}} 746 else if(ch==="-"){if(/\d/.test(stream.peek())){stream.eatWhile(/[\w.%]/);return ret("number","unit");}else if(stream.match(/^[^-]+-/)){return ret("meta","meta") ;}}
741 else if(/[,+>*\/]/.test(ch)){return ret(null,"select-op");} 747 else if(/[,+>*\/]/.test(ch)){return ret(null,"select-op");}
742 else if(ch=="."&&stream.match(/^-?[_a-z][_a-z0-9-]*/i)){return ret("qualifier"," qualifier");} 748 else if(ch=="."&&stream.match(/^-?[_a-z][_a-z0-9-]*/i)){return ret("qualifier"," qualifier");}
743 else if(ch==":"){return ret("operator",ch);} 749 else if(ch==":"){return ret("operator",ch);}
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 if(ch==='+'||ch==='='){return'operator';} 1109 if(ch==='+'||ch==='='){return'operator';}
1104 if(ch==='-'){stream.eat('-');stream.eatWhile(/\w/);return'attribute';} 1110 if(ch==='-'){stream.eat('-');stream.eatWhile(/\w/);return'attribute';}
1105 if(/\d/.test(ch)){stream.eatWhile(/\d/);if(!/\w/.test(stream.peek())){return'num ber';}} 1111 if(/\d/.test(ch)){stream.eatWhile(/\d/);if(!/\w/.test(stream.peek())){return'num ber';}}
1106 stream.eatWhile(/[\w-]/);var cur=stream.current();if(stream.peek()==='='&&/\w+/. test(cur))return'def';return words.hasOwnProperty(cur)?words[cur]:null;} 1112 stream.eatWhile(/[\w-]/);var cur=stream.current();if(stream.peek()==='='&&/\w+/. test(cur))return'def';return words.hasOwnProperty(cur)?words[cur]:null;}
1107 function tokenString(quote){return function(stream,state){var next,end=false,esc aped=false;while((next=stream.next())!=null){if(next===quote&&!escaped){end=true ;break;} 1113 function tokenString(quote){return function(stream,state){var next,end=false,esc aped=false;while((next=stream.next())!=null){if(next===quote&&!escaped){end=true ;break;}
1108 if(next==='$'&&!escaped&&quote!=='\''){escaped=true;stream.backUp(1);state.token s.unshift(tokenDollar);break;} 1114 if(next==='$'&&!escaped&&quote!=='\''){escaped=true;stream.backUp(1);state.token s.unshift(tokenDollar);break;}
1109 escaped=!escaped&&next==='\\';} 1115 escaped=!escaped&&next==='\\';}
1110 if(end||!escaped){state.tokens.shift();} 1116 if(end||!escaped){state.tokens.shift();}
1111 return(quote==='`'||quote===')'?'quote':'string');};};var tokenDollar=function(s tream,state){if(state.tokens.length>1)stream.eat('$');var ch=stream.next(),hungr y=/\w/;if(ch==='{')hungry=/[^}]/;if(ch==='('){state.tokens[0]=tokenString(')');r eturn tokenize(stream,state);} 1117 return(quote==='`'||quote===')'?'quote':'string');};};var tokenDollar=function(s tream,state){if(state.tokens.length>1)stream.eat('$');var ch=stream.next(),hungr y=/\w/;if(ch==='{')hungry=/[^}]/;if(ch==='('){state.tokens[0]=tokenString(')');r eturn tokenize(stream,state);}
1112 if(!/\d/.test(ch)){stream.eatWhile(hungry);stream.eat('}');} 1118 if(!/\d/.test(ch)){stream.eatWhile(hungry);stream.eat('}');}
1113 state.tokens.shift();return'def';};function tokenize(stream,state){return(state. tokens[0]||tokenBase)(stream,state);};return{startState:function(){return{tokens :[]};},token:function(stream,state){if(stream.eatSpace())return null;return toke nize(stream,state);}};});CodeMirror.defineMIME('text/x-sh','shell');;WebInspecto r.CodeMirrorTextEditor=function(url,delegate) 1119 state.tokens.shift();return'def';};function tokenize(stream,state){return(state. tokens[0]||tokenBase)(stream,state);};return{startState:function(){return{tokens :[]};},token:function(stream,state){if(stream.eatSpace())return null;return toke nize(stream,state);}};});CodeMirror.defineMIME('text/x-sh','shell');;WebInspecto r.CodeMirrorUtils={createTokenizer:function(mimeType)
1114 {WebInspector.View.call(this);this._delegate=delegate;this._url=url;this.registe rRequiredCSS("cm/codemirror.css");this.registerRequiredCSS("cm/cmdevtools.css"); this._codeMirror=window.CodeMirror(this.element,{lineNumbers:true,gutters:["Code Mirror-linenumbers"],matchBrackets:true,smartIndent:false,styleSelectedText:true ,electricChars:false,autoCloseBrackets:{explode:false}});this._codeMirror._codeM irrorTextEditor=this;CodeMirror.keyMap["devtools-common"]={"Left":"goCharLeft"," Right":"goCharRight","Up":"goLineUp","Down":"goLineDown","End":"goLineEnd","Home ":"goLineStartSmart","PageUp":"goPageUp","PageDown":"goPageDown","Delete":"delCh arAfter","Backspace":"delCharBefore","Tab":"defaultTab","Shift-Tab":"indentLess" ,"Enter":"smartNewlineAndIndent","Ctrl-Space":"autocomplete"};CodeMirror.keyMap[ "devtools-pc"]={"Ctrl-A":"selectAll","Ctrl-Z":"undoAndReveal","Shift-Ctrl-Z":"re doAndReveal","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-Up":"goDocStart","Ct rl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goGroupLeft","Ctrl-Right" :"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace ":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-/":"toggleComment",fallth rough:"devtools-common"};CodeMirror.keyMap["devtools-mac"]={"Cmd-A":"selectAll", "Cmd-Z":"undoAndReveal","Shift-Cmd-Z":"redoAndReveal","Cmd-Up":"goDocStart","Cmd -Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left" :"goLineStartSmart","Cmd-Right":"goLineEnd","Alt-Backspace":"delGroupBefore","Al t-Delete":"delGroupAfter","Cmd-/":"toggleComment",fallthrough:"devtools-common"} ;WebInspector.settings.textEditorIndent.addChangeListener(this._updateEditorInde ntation,this);this._updateEditorIndentation();WebInspector.settings.showWhitespa cesInEditor.addChangeListener(this._updateCodeMirrorMode,this);this._codeMirror. setOption("keyMap",WebInspector.isMac()?"devtools-mac":"devtools-pc");this._code Mirror.setOption("flattenSpans",false);this._codeMirror.setOption("maxHighlightL ength",1000);this._codeMirror.setOption("mode",null);this._shouldClearHistory=tr ue;this._lineSeparator="\n";this._tokenHighlighter=new WebInspector.CodeMirrorTe xtEditor.TokenHighlighter(this._codeMirror);this._blockIndentController=new WebI nspector.CodeMirrorTextEditor.BlockIndentController(this._codeMirror);this._fixW ordMovement=new WebInspector.CodeMirrorTextEditor.FixWordMovement(this._codeMirr or);this._autocompleteController=new WebInspector.CodeMirrorTextEditor.Autocompl eteController(this,this._codeMirror);this._codeMirror.on("change",this._change.b ind(this));this._codeMirror.on("beforeChange",this._beforeChange.bind(this));thi s._codeMirror.on("gutterClick",this._gutterClick.bind(this));this._codeMirror.on ("cursorActivity",this._cursorActivity.bind(this));this._codeMirror.on("scroll", this._scroll.bind(this));this._codeMirror.on("focus",this._focus.bind(this));thi s._codeMirror.on("blur",this._blur.bind(this));this.element.addEventListener("co ntextmenu",this._contextMenu.bind(this));this.element.addStyleClass("fill");this .element.style.overflow="hidden";this.element.firstChild.addStyleClass("source-c ode");this.element.firstChild.addStyleClass("fill");this._elementToWidget=new Ma p();this._nestedUpdatesCounter=0;this.element.addEventListener("focus",this._han dleElementFocus.bind(this),false);this.element.addEventListener("keydown",this._ handleKeyDown.bind(this),true);this.element.tabIndex=0;this._overrideModeWithPre fixedTokens("css-base","css-");this._overrideModeWithPrefixedTokens("javascript" ,"js-");this._overrideModeWithPrefixedTokens("xml","xml-");this._setupSelectionC olor();this._setupWhitespaceHighlight();} 1120 {var mode=CodeMirror.getMode({indentUnit:2},mimeType);var state=CodeMirror.start State(mode);function tokenize(line,callback)
1121 {var stream=new CodeMirror.StringStream(line);while(!stream.eol()){var style=mod e.token(stream,state);var value=stream.current();callback(value,style,stream.sta rt,stream.start+value.length);stream.start=stream.pos;}}
1122 return tokenize;},convertTokenType:function(tokenType)
1123 {if(tokenType.startsWith("js-variable")||tokenType.startsWith("js-property")||to kenType==="js-def")
1124 return"javascript-ident";if(tokenType==="js-string-2")
1125 return"javascript-regexp";if(tokenType==="js-number"||tokenType==="js-comment"|| tokenType==="js-string"||tokenType==="js-keyword")
1126 return"javascript-"+tokenType.substring("js-".length);return null;},overrideMode WithPrefixedTokens:function(modeName,tokenPrefix)
1127 {var oldModeName=modeName+"-old";if(CodeMirror.modes[oldModeName])
1128 return;CodeMirror.defineMode(oldModeName,CodeMirror.modes[modeName]);CodeMirror. defineMode(modeName,modeConstructor);function modeConstructor(config,parserConfi g)
1129 {var innerConfig={};for(var i in parserConfig)
1130 innerConfig[i]=parserConfig[i];innerConfig.name=oldModeName;var codeMirrorMode=C odeMirror.getMode(config,innerConfig);codeMirrorMode.name=modeName;codeMirrorMod e.token=tokenOverride.bind(this,codeMirrorMode.token);return codeMirrorMode;}
1131 function tokenOverride(superToken,stream,state)
1132 {var token=superToken(stream,state);return token?tokenPrefix+token:token;}}}
1133 WebInspector.CodeMirrorUtils.overrideModeWithPrefixedTokens("css-base","css-");W ebInspector.CodeMirrorUtils.overrideModeWithPrefixedTokens("javascript","js-");W ebInspector.CodeMirrorUtils.overrideModeWithPrefixedTokens("xml","xml-");;WebIns pector.CodeMirrorTextEditor=function(url,delegate)
1134 {WebInspector.View.call(this);this._delegate=delegate;this._url=url;this.registe rRequiredCSS("cm/codemirror.css");this.registerRequiredCSS("cm/cmdevtools.css"); this._codeMirror=window.CodeMirror(this.element,{lineNumbers:true,gutters:["Code Mirror-linenumbers"],matchBrackets:true,smartIndent:false,styleSelectedText:true ,electricChars:false,autoCloseBrackets:{explode:false}});this._codeMirror._codeM irrorTextEditor=this;CodeMirror.keyMap["devtools-common"]={"Left":"goCharLeft"," Right":"goCharRight","Up":"goLineUp","Down":"goLineDown","End":"goLineEnd","Home ":"goLineStartSmart","PageUp":"goPageUp","PageDown":"goPageDown","Delete":"delCh arAfter","Backspace":"delCharBefore","Tab":"defaultTab","Shift-Tab":"indentLess" ,"Enter":"smartNewlineAndIndent","Ctrl-Space":"autocomplete"};CodeMirror.keyMap[ "devtools-pc"]={"Ctrl-A":"selectAll","Ctrl-Z":"undoAndReveal","Shift-Ctrl-Z":"re doAndReveal","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-Up":"goDocStart","Ct rl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goGroupLeft","Ctrl-Right" :"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace ":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-/":"toggleComment",fallth rough:"devtools-common"};CodeMirror.keyMap["devtools-mac"]={"Cmd-A":"selectAll", "Cmd-Z":"undoAndReveal","Shift-Cmd-Z":"redoAndReveal","Cmd-Up":"goDocStart","Cmd -Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left" :"goLineStartSmart","Cmd-Right":"goLineEnd","Alt-Backspace":"delGroupBefore","Al t-Delete":"delGroupAfter","Cmd-/":"toggleComment",fallthrough:"devtools-common"} ;WebInspector.settings.textEditorIndent.addChangeListener(this._updateEditorInde ntation,this);this._updateEditorIndentation();WebInspector.settings.showWhitespa cesInEditor.addChangeListener(this._updateCodeMirrorMode,this);this._codeMirror. setOption("keyMap",WebInspector.isMac()?"devtools-mac":"devtools-pc");this._code Mirror.setOption("flattenSpans",false);this._codeMirror.setOption("maxHighlightL ength",1000);this._codeMirror.setOption("mode",null);this._codeMirror.setOption( "crudeMeasuringFrom",1000);this._shouldClearHistory=true;this._lineSeparator="\n ";this._tokenHighlighter=new WebInspector.CodeMirrorTextEditor.TokenHighlighter( this._codeMirror);this._blockIndentController=new WebInspector.CodeMirrorTextEdi tor.BlockIndentController(this._codeMirror);this._fixWordMovement=new WebInspect or.CodeMirrorTextEditor.FixWordMovement(this._codeMirror);this._autocompleteCont roller=new WebInspector.CodeMirrorTextEditor.AutocompleteController(this,this._c odeMirror);this._codeMirror.on("change",this._change.bind(this));this._codeMirro r.on("beforeChange",this._beforeChange.bind(this));this._codeMirror.on("gutterCl ick",this._gutterClick.bind(this));this._codeMirror.on("cursorActivity",this._cu rsorActivity.bind(this));this._codeMirror.on("scroll",this._scroll.bind(this));t his._codeMirror.on("focus",this._focus.bind(this));this._codeMirror.on("blur",th is._blur.bind(this));this.element.addEventListener("contextmenu",this._contextMe nu.bind(this),false);this.element.addStyleClass("fill");this.element.style.overf low="hidden";this.element.firstChild.addStyleClass("source-code");this.element.f irstChild.addStyleClass("fill");this._elementToWidget=new Map();this._nestedUpda tesCounter=0;this.element.addEventListener("focus",this._handleElementFocus.bind (this),false);this.element.addEventListener("keydown",this._handleKeyDown.bind(t his),true);this.element.tabIndex=0;this._setupSelectionColor();this._setupWhites paceHighlight();}
1115 WebInspector.CodeMirrorTextEditor.autocompleteCommand=function(codeMirror) 1135 WebInspector.CodeMirrorTextEditor.autocompleteCommand=function(codeMirror)
1116 {codeMirror._codeMirrorTextEditor._autocompleteController.autocomplete();} 1136 {codeMirror._codeMirrorTextEditor._autocompleteController.autocomplete();}
1117 CodeMirror.commands.autocomplete=WebInspector.CodeMirrorTextEditor.autocompleteC ommand;CodeMirror.commands.smartNewlineAndIndent=function(codeMirror) 1137 CodeMirror.commands.autocomplete=WebInspector.CodeMirrorTextEditor.autocompleteC ommand;CodeMirror.commands.smartNewlineAndIndent=function(codeMirror)
1118 {codeMirror.operation(innerSmartNewlineAndIndent.bind(this,codeMirror));function countIndent(line) 1138 {codeMirror.operation(innerSmartNewlineAndIndent.bind(this,codeMirror));function countIndent(line)
1119 {for(var i=0;i<line.length;++i){if(!WebInspector.TextUtils.isSpaceChar(line[i])) 1139 {for(var i=0;i<line.length;++i){if(!WebInspector.TextUtils.isSpaceChar(line[i]))
1120 return i;} 1140 return i;}
1121 return line.length;} 1141 return line.length;}
1122 function innerSmartNewlineAndIndent(codeMirror) 1142 function innerSmartNewlineAndIndent(codeMirror)
1123 {var cur=codeMirror.getCursor("start");var line=codeMirror.getLine(cur.line);var indent=cur.line>0?countIndent(line):0;if(cur.ch<=indent){codeMirror.replaceSele ction("\n"+line.substring(0,cur.ch),"end","+input");codeMirror.setSelection(new CodeMirror.Pos(cur.line+1,cur.ch));}else 1143 {var cur=codeMirror.getCursor("start");var line=codeMirror.getLine(cur.line);var indent=cur.line>0?countIndent(line):0;if(cur.ch<=indent){codeMirror.replaceSele ction("\n"+line.substring(0,cur.ch),"end","+input");codeMirror.setSelection(new CodeMirror.Pos(cur.line+1,cur.ch));}else
1124 codeMirror.execCommand("newlineAndIndent");}} 1144 codeMirror.execCommand("newlineAndIndent");}}
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 {return word.length&&(word[0]<'0'||word[0]>'9');},_addTextToCompletionDictionary :function(text) 1184 {return word.length&&(word[0]<'0'||word[0]>'9');},_addTextToCompletionDictionary :function(text)
1165 {var words=WebInspector.TextUtils.textToWords(text);for(var i=0;i<words.length;+ +i){if(this._shouldProcessWordForAutocompletion(words[i])) 1185 {var words=WebInspector.TextUtils.textToWords(text);for(var i=0;i<words.length;+ +i){if(this._shouldProcessWordForAutocompletion(words[i]))
1166 this._dictionary.addWord(words[i]);}},_removeTextFromCompletionDictionary:functi on(text) 1186 this._dictionary.addWord(words[i]);}},_removeTextFromCompletionDictionary:functi on(text)
1167 {var words=WebInspector.TextUtils.textToWords(text);for(var i=0;i<words.length;+ +i){if(this._shouldProcessWordForAutocompletion(words[i])) 1187 {var words=WebInspector.TextUtils.textToWords(text);for(var i=0;i<words.length;+ +i){if(this._shouldProcessWordForAutocompletion(words[i]))
1168 this._dictionary.removeWord(words[i]);}},setCompletionDictionary:function(dictio nary) 1188 this._dictionary.removeWord(words[i]);}},setCompletionDictionary:function(dictio nary)
1169 {this._dictionary=dictionary;this._addTextToCompletionDictionary(this.text());}, cursorPositionToCoordinates:function(lineNumber,column) 1189 {this._dictionary=dictionary;this._addTextToCompletionDictionary(this.text());}, cursorPositionToCoordinates:function(lineNumber,column)
1170 {if(lineNumber>=this._codeMirror.lineCount()||lineNumber<0||column<0||column>thi s._codeMirror.getLine(lineNumber).length) 1190 {if(lineNumber>=this._codeMirror.lineCount()||lineNumber<0||column<0||column>thi s._codeMirror.getLine(lineNumber).length)
1171 return null;var metrics=this._codeMirror.cursorCoords(new CodeMirror.Pos(lineNum ber,column));return{x:metrics.left,y:metrics.top,height:metrics.bottom-metrics.t op};},coordinatesToCursorPosition:function(x,y) 1191 return null;var metrics=this._codeMirror.cursorCoords(new CodeMirror.Pos(lineNum ber,column));return{x:metrics.left,y:metrics.top,height:metrics.bottom-metrics.t op};},coordinatesToCursorPosition:function(x,y)
1172 {var element=document.elementFromPoint(x,y);if(!element||!element.isSelfOrDescen dant(this._codeMirror.getWrapperElement())) 1192 {var element=document.elementFromPoint(x,y);if(!element||!element.isSelfOrDescen dant(this._codeMirror.getWrapperElement()))
1173 return null;var gutterBox=this._codeMirror.getGutterElement().boxInWindow();if(x >=gutterBox.x&&x<=gutterBox.x+gutterBox.width&&y>=gutterBox.y&&y<=gutterBox.y+gu tterBox.height) 1193 return null;var gutterBox=this._codeMirror.getGutterElement().boxInWindow();if(x >=gutterBox.x&&x<=gutterBox.x+gutterBox.width&&y>=gutterBox.y&&y<=gutterBox.y+gu tterBox.height)
1174 return null;var coords=this._codeMirror.coordsChar({left:x,top:y});return this._ toRange(coords,coords);},_convertTokenType:function(tokenType) 1194 return null;var coords=this._codeMirror.coordsChar({left:x,top:y});return this._ toRange(coords,coords);},tokenAtTextPosition:function(lineNumber,column)
1175 {if(tokenType.startsWith("js-variable")||tokenType.startsWith("js-property")||to kenType==="js-def")
1176 return"javascript-ident";if(tokenType==="js-string-2")
1177 return"javascript-regexp";if(tokenType==="js-number"||tokenType==="js-comment"|| tokenType==="js-string"||tokenType==="js-keyword")
1178 return"javascript-"+tokenType.substring("js-".length);return null;},tokenAtTextP osition:function(lineNumber,column)
1179 {if(lineNumber<0||lineNumber>=this._codeMirror.lineCount()) 1195 {if(lineNumber<0||lineNumber>=this._codeMirror.lineCount())
1180 return null;var token=this._codeMirror.getTokenAt(new CodeMirror.Pos(lineNumber, (column||0)+1));if(!token||!token.type) 1196 return null;var token=this._codeMirror.getTokenAt(new CodeMirror.Pos(lineNumber, (column||0)+1));if(!token||!token.type)
1181 return null;var convertedType=this._convertTokenType(token.type);if(!convertedTy pe) 1197 return null;var convertedType=WebInspector.CodeMirrorUtils.convertTokenType(toke n.type);if(!convertedType)
1182 return null;return{startColumn:token.start,endColumn:token.end-1,type:convertedT ype};},copyRange:function(textRange) 1198 return null;return{startColumn:token.start,endColumn:token.end-1,type:convertedT ype};},copyRange:function(textRange)
1183 {var pos=this._toPos(textRange);return this._codeMirror.getRange(pos.start,pos.e nd);},isClean:function() 1199 {var pos=this._toPos(textRange.normalize());return this._codeMirror.getRange(pos .start,pos.end);},isClean:function()
1184 {return this._codeMirror.isClean();},markClean:function() 1200 {return this._codeMirror.isClean();},markClean:function()
1185 {this._codeMirror.markClean();},_hasLongLines:function() 1201 {this._codeMirror.markClean();},_hasLongLines:function()
1186 {function lineIterator(lineHandle) 1202 {function lineIterator(lineHandle)
1187 {if(lineHandle.text.length>WebInspector.CodeMirrorTextEditor.LongLineModeLineLen gthThreshold) 1203 {if(lineHandle.text.length>WebInspector.CodeMirrorTextEditor.LongLineModeLineLen gthThreshold)
1188 hasLongLines=true;return hasLongLines;} 1204 hasLongLines=true;return hasLongLines;}
1189 var hasLongLines=false;this._codeMirror.eachLine(lineIterator);return hasLongLin es;},_whitespaceOverlayMode:function(mimeType) 1205 var hasLongLines=false;this._codeMirror.eachLine(lineIterator);return hasLongLin es;},_whitespaceOverlayMode:function(mimeType)
1190 {var modeName=CodeMirror.mimeModes[mimeType]+"+whitespaces";if(CodeMirror.modes[ modeName]) 1206 {var modeName=CodeMirror.mimeModes[mimeType]+"+whitespaces";if(CodeMirror.modes[ modeName])
1191 return modeName;function modeConstructor(config,parserConfig) 1207 return modeName;function modeConstructor(config,parserConfig)
1192 {function nextToken(stream) 1208 {function nextToken(stream)
1193 {if(stream.peek()===" "){var spaces=0;while(spaces<WebInspector.CodeMirrorTextEd itor.MaximumNumberOfWhitespacesPerSingleSpan&&stream.peek()===" "){++spaces;stre am.next();} 1209 {if(stream.peek()===" "){var spaces=0;while(spaces<WebInspector.CodeMirrorTextEd itor.MaximumNumberOfWhitespacesPerSingleSpan&&stream.peek()===" "){++spaces;stre am.next();}
1194 return"whitespace whitespace-"+spaces;} 1210 return"whitespace whitespace-"+spaces;}
1195 while(!stream.eol()&&stream.peek()!==" ") 1211 while(!stream.eol()&&stream.peek()!==" ")
1196 stream.next();return null;} 1212 stream.next();return null;}
1197 var whitespaceMode={token:nextToken};return CodeMirror.overlayMode(CodeMirror.ge tMode(config,mimeType),whitespaceMode,false);} 1213 var whitespaceMode={token:nextToken};return CodeMirror.overlayMode(CodeMirror.ge tMode(config,mimeType),whitespaceMode,false);}
1198 CodeMirror.defineMode(modeName,modeConstructor);return modeName;},_overrideModeW ithPrefixedTokens:function(modeName,tokenPrefix) 1214 CodeMirror.defineMode(modeName,modeConstructor);return modeName;},_enableLongLin esMode:function()
1199 {var oldModeName=modeName+"-old";if(CodeMirror.modes[oldModeName])
1200 return;CodeMirror.defineMode(oldModeName,CodeMirror.modes[modeName]);CodeMirror. defineMode(modeName,modeConstructor);function modeConstructor(config,parserConfi g)
1201 {var innerConfig={};for(var i in parserConfig)
1202 innerConfig[i]=parserConfig[i];innerConfig.name=oldModeName;var codeMirrorMode=C odeMirror.getMode(config,innerConfig);codeMirrorMode.name=modeName;codeMirrorMod e.token=tokenOverride.bind(this,codeMirrorMode.token);return codeMirrorMode;}
1203 function tokenOverride(superToken,stream,state)
1204 {var token=superToken(stream,state);return token?tokenPrefix+token:token;}},_ena bleLongLinesMode:function()
1205 {this._codeMirror.setOption("styleSelectedText",false);this._longLinesMode=true; },_disableLongLinesMode:function() 1215 {this._codeMirror.setOption("styleSelectedText",false);this._longLinesMode=true; },_disableLongLinesMode:function()
1206 {this._codeMirror.setOption("styleSelectedText",true);this._longLinesMode=false; },_updateCodeMirrorMode:function() 1216 {this._codeMirror.setOption("styleSelectedText",true);this._longLinesMode=false; },_updateCodeMirrorMode:function()
1207 {var showWhitespaces=WebInspector.settings.showWhitespacesInEditor.get();this._c odeMirror.setOption("mode",showWhitespaces?this._whitespaceOverlayMode(this._mim eType):this._mimeType);},setMimeType:function(mimeType) 1217 {var showWhitespaces=WebInspector.settings.showWhitespacesInEditor.get();this._c odeMirror.setOption("mode",showWhitespaces?this._whitespaceOverlayMode(this._mim eType):this._mimeType);},setMimeType:function(mimeType)
1208 {this._mimeType=mimeType;if(this._hasLongLines()) 1218 {this._mimeType=mimeType;if(this._hasLongLines())
1209 this._enableLongLinesMode();else 1219 this._enableLongLinesMode();else
1210 this._disableLongLinesMode();this._updateCodeMirrorMode();},setReadOnly:function (readOnly) 1220 this._disableLongLinesMode();this._updateCodeMirrorMode();},setReadOnly:function (readOnly)
1211 {this.element.enableStyleClass("CodeMirror-readonly",readOnly) 1221 {this.element.enableStyleClass("CodeMirror-readonly",readOnly)
1212 this._codeMirror.setOption("readOnly",readOnly);},readOnly:function() 1222 this._codeMirror.setOption("readOnly",readOnly);},readOnly:function()
1213 {return!!this._codeMirror.getOption("readOnly");},removeHighlight:function(highl ightDescriptor) 1223 {return!!this._codeMirror.getOption("readOnly");},removeHighlight:function(highl ightDescriptor)
1214 {highlightDescriptor.clear();},highlightRange:function(range,cssClass) 1224 {highlightDescriptor.clear();},highlightRange:function(range,cssClass)
(...skipping 28 matching lines...) Expand all
1243 return;this.revealLine(lineNumber);this._codeMirror.addLineClass(this._highlight edLine,null,"cm-highlight");this._clearHighlightTimeout=setTimeout(this.clearPos itionHighlight.bind(this),2000);if(!this.readOnly()) 1253 return;this.revealLine(lineNumber);this._codeMirror.addLineClass(this._highlight edLine,null,"cm-highlight");this._clearHighlightTimeout=setTimeout(this.clearPos itionHighlight.bind(this),2000);if(!this.readOnly())
1244 this._codeMirror.setSelection(new CodeMirror.Pos(lineNumber,columnNumber));},cle arPositionHighlight:function() 1254 this._codeMirror.setSelection(new CodeMirror.Pos(lineNumber,columnNumber));},cle arPositionHighlight:function()
1245 {if(this._clearHighlightTimeout) 1255 {if(this._clearHighlightTimeout)
1246 clearTimeout(this._clearHighlightTimeout);delete this._clearHighlightTimeout;if( this._highlightedLine) 1256 clearTimeout(this._clearHighlightTimeout);delete this._clearHighlightTimeout;if( this._highlightedLine)
1247 this._codeMirror.removeLineClass(this._highlightedLine,null,"cm-highlight");dele te this._highlightedLine;},elementsToRestoreScrollPositionsFor:function() 1257 this._codeMirror.removeLineClass(this._highlightedLine,null,"cm-highlight");dele te this._highlightedLine;},elementsToRestoreScrollPositionsFor:function()
1248 {return[];},inheritScrollPositions:function(textEditor) 1258 {return[];},inheritScrollPositions:function(textEditor)
1249 {},_updatePaddingBottom:function(width,height) 1259 {},_updatePaddingBottom:function(width,height)
1250 {var scrollInfo=this._codeMirror.getScrollInfo();var newPaddingBottom;var linesE lement=this.element.firstChild.querySelector(".CodeMirror-lines");var lineCount= this._codeMirror.lineCount();if(lineCount<=1) 1260 {var scrollInfo=this._codeMirror.getScrollInfo();var newPaddingBottom;var linesE lement=this.element.firstChild.querySelector(".CodeMirror-lines");var lineCount= this._codeMirror.lineCount();if(lineCount<=1)
1251 newPaddingBottom=0;else 1261 newPaddingBottom=0;else
1252 newPaddingBottom=Math.max(scrollInfo.clientHeight-this._codeMirror.getLineHandle (this._codeMirror.lastLine()).height,0);newPaddingBottom+="px";linesElement.styl e.paddingBottom=newPaddingBottom;this._codeMirror.setSize(width,height);},_resiz eEditor:function() 1262 newPaddingBottom=Math.max(scrollInfo.clientHeight-this._codeMirror.getLineHandle (this._codeMirror.lastLine()).height,0);newPaddingBottom+="px";linesElement.styl e.paddingBottom=newPaddingBottom;this._codeMirror.setSize(width,height);},_resiz eEditor:function()
1253 {var scrollInfo=this._codeMirror.getScrollInfo();var width=this.element.parentEl ement.offsetWidth;var height=this.element.parentElement.offsetHeight;this._codeM irror.setSize(width,height);this._updatePaddingBottom(width,height);this._codeMi rror.scrollTo(scrollInfo.left,scrollInfo.top);},onResize:function() 1263 {var parentElement=this.element.parentElement;if(!parentElement||!this.isShowing ())
1254 {if(WebInspector.experimentsSettings.scrollBeyondEndOfFile.isEnabled()) 1264 return;var scrollInfo=this._codeMirror.getScrollInfo();var width=parentElement.o ffsetWidth;var height=parentElement.offsetHeight;this._codeMirror.setSize(width, height);this._updatePaddingBottom(width,height);this._codeMirror.scrollTo(scroll Info.left,scrollInfo.top);},onResize:function()
1255 this._resizeEditor();else{var width=this.element.parentElement.offsetWidth;var h eight=this.element.parentElement.offsetHeight;this._codeMirror.setSize(width,hei ght);}},editRange:function(range,text) 1265 {this._resizeEditor();},editRange:function(range,text)
1256 {var pos=this._toPos(range);this._codeMirror.replaceRange(text,pos.start,pos.end );var newRange=this._toRange(pos.start,this._codeMirror.posFromIndex(this._codeM irror.indexFromPos(pos.start)+text.length));this._delegate.onTextChanged(range,n ewRange);if(WebInspector.settings.textEditorAutoDetectIndent.get()) 1266 {var pos=this._toPos(range);this._codeMirror.replaceRange(text,pos.start,pos.end );var newRange=this._toRange(pos.start,this._codeMirror.posFromIndex(this._codeM irror.indexFromPos(pos.start)+text.length));this._delegate.onTextChanged(range,n ewRange);if(WebInspector.settings.textEditorAutoDetectIndent.get())
1257 this._updateEditorIndentation();return newRange;},_wordRangeForCursorPosition:fu nction(lineNumber,column,prefixOnly) 1267 this._updateEditorIndentation();return newRange;},_wordRangeForCursorPosition:fu nction(lineNumber,column,prefixOnly)
1258 {var line=this.line(lineNumber);if(column===0||!WebInspector.TextUtils.isWordCha r(line.charAt(column-1))) 1268 {var line=this.line(lineNumber);if(column===0||!WebInspector.TextUtils.isWordCha r(line.charAt(column-1)))
1259 return null;var wordStart=column-1;while(wordStart>0&&WebInspector.TextUtils.isW ordChar(line.charAt(wordStart-1))) 1269 return null;var wordStart=column-1;while(wordStart>0&&WebInspector.TextUtils.isW ordChar(line.charAt(wordStart-1)))
1260 --wordStart;if(prefixOnly) 1270 --wordStart;if(prefixOnly)
1261 return new WebInspector.TextRange(lineNumber,wordStart,lineNumber,column);var wo rdEnd=column;while(wordEnd<line.length&&WebInspector.TextUtils.isWordChar(line.c harAt(wordEnd))) 1271 return new WebInspector.TextRange(lineNumber,wordStart,lineNumber,column);var wo rdEnd=column;while(wordEnd<line.length&&WebInspector.TextUtils.isWordChar(line.c harAt(wordEnd)))
1262 ++wordEnd;return new WebInspector.TextRange(lineNumber,wordStart,lineNumber,word End);},_beforeChange:function(codeMirror,changeObject) 1272 ++wordEnd;return new WebInspector.TextRange(lineNumber,wordStart,lineNumber,word End);},_beforeChange:function(codeMirror,changeObject)
1263 {if(!this._dictionary) 1273 {if(!this._dictionary)
1264 return;this._updatedLines=this._updatedLines||{};for(var i=changeObject.from.lin e;i<=changeObject.to.line;++i) 1274 return;this._updatedLines=this._updatedLines||{};for(var i=changeObject.from.lin e;i<=changeObject.to.line;++i)
1265 this._updatedLines[i]=this.line(i);},_change:function(codeMirror,changeObject) 1275 this._updatedLines[i]=this.line(i);},_change:function(codeMirror,changeObject)
1266 {if(WebInspector.experimentsSettings.scrollBeyondEndOfFile.isEnabled()){var hasO neLine=this._codeMirror.lineCount()===1;if(hasOneLine!==this._hasOneLine) 1276 {var hasOneLine=this._codeMirror.lineCount()===1;if(hasOneLine!==this._hasOneLin e)
1267 this._resizeEditor();this._hasOneLine=hasOneLine;} 1277 this._resizeEditor();this._hasOneLine=hasOneLine;var widgets=this._elementToWidg et.values();for(var i=0;i<widgets.length;++i)
1268 var widgets=this._elementToWidget.values();for(var i=0;i<widgets.length;++i)
1269 this._codeMirror.removeLineWidget(widgets[i]);this._elementToWidget.clear();if(t his._updatedLines){for(var lineNumber in this._updatedLines) 1278 this._codeMirror.removeLineWidget(widgets[i]);this._elementToWidget.clear();if(t his._updatedLines){for(var lineNumber in this._updatedLines)
1270 this._removeTextFromCompletionDictionary(this._updatedLines[lineNumber]);delete this._updatedLines;} 1279 this._removeTextFromCompletionDictionary(this._updatedLines[lineNumber]);delete this._updatedLines;}
1271 var linesToUpdate={};var singleCharInput=false;do{var oldRange=this._toRange(cha ngeObject.from,changeObject.to);var newRange=oldRange.clone();var linesAdded=cha ngeObject.text.length;singleCharInput=(changeObject.origin==="+input"&&changeObj ect.text.length===1&&changeObject.text[0].length===1)||(changeObject.origin==="+ delete"&&changeObject.removed.length===1&&changeObject.removed[0].length===1);if (linesAdded===0){newRange.endLine=newRange.startLine;newRange.endColumn=newRange .startColumn;}else if(linesAdded===1){newRange.endLine=newRange.startLine;newRan ge.endColumn=newRange.startColumn+changeObject.text[0].length;}else{newRange.end Line=newRange.startLine+linesAdded-1;newRange.endColumn=changeObject.text[linesA dded-1].length;} 1280 var linesToUpdate={};var singleCharInput=false;do{var oldRange=this._toRange(cha ngeObject.from,changeObject.to);var newRange=oldRange.clone();var linesAdded=cha ngeObject.text.length;singleCharInput=(changeObject.origin==="+input"&&changeObj ect.text.length===1&&changeObject.text[0].length===1)||(changeObject.origin==="+ delete"&&changeObject.removed.length===1&&changeObject.removed[0].length===1);if (linesAdded===0){newRange.endLine=newRange.startLine;newRange.endColumn=newRange .startColumn;}else if(linesAdded===1){newRange.endLine=newRange.startLine;newRan ge.endColumn=newRange.startColumn+changeObject.text[0].length;}else{newRange.end Line=newRange.startLine+linesAdded-1;newRange.endColumn=changeObject.text[linesA dded-1].length;}
1272 if(!this._muteTextChangedEvent) 1281 if(!this._muteTextChangedEvent)
1273 this._delegate.onTextChanged(oldRange,newRange);for(var i=newRange.startLine;i<= newRange.endLine;++i){linesToUpdate[i]=true;} 1282 this._delegate.onTextChanged(oldRange,newRange);for(var i=newRange.startLine;i<= newRange.endLine;++i){linesToUpdate[i]=true;}
1274 if(this._dictionary){for(var i=newRange.startLine;i<=newRange.endLine;++i) 1283 if(this._dictionary){for(var i=newRange.startLine;i<=newRange.endLine;++i)
1275 linesToUpdate[i]=this.line(i);}}while(changeObject=changeObject.next);if(this._d ictionary){for(var lineNumber in linesToUpdate) 1284 linesToUpdate[i]=this.line(i);}}while(changeObject=changeObject.next);if(this._d ictionary){for(var lineNumber in linesToUpdate)
1276 this._addTextToCompletionDictionary(linesToUpdate[lineNumber]);} 1285 this._addTextToCompletionDictionary(linesToUpdate[lineNumber]);}
1277 if(singleCharInput) 1286 if(singleCharInput)
1278 this._autocompleteController.autocomplete();},_cursorActivity:function() 1287 this._autocompleteController.autocomplete();},_cursorActivity:function()
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 return this._suggestBox.keyPressed(e);},applySuggestion:function(suggestion,isIn termediateSuggestion) 1386 return this._suggestBox.keyPressed(e);},applySuggestion:function(suggestion,isIn termediateSuggestion)
1378 {this._currentSuggestion=suggestion;},acceptSuggestion:function() 1387 {this._currentSuggestion=suggestion;},acceptSuggestion:function()
1379 {if(this._prefixRange.endColumn-this._prefixRange.startColumn!==this._currentSug gestion.length){var pos=this._textEditor._toPos(this._prefixRange);this._codeMir ror.replaceRange(this._currentSuggestion,pos.start,pos.end,"+autocomplete");}},_ onScroll:function() 1388 {if(this._prefixRange.endColumn-this._prefixRange.startColumn!==this._currentSug gestion.length){var pos=this._textEditor._toPos(this._prefixRange);this._codeMir ror.replaceRange(this._currentSuggestion,pos.start,pos.end,"+autocomplete");}},_ onScroll:function()
1380 {if(!this._suggestBox) 1389 {if(!this._suggestBox)
1381 return;var cursor=this._codeMirror.getCursor();var scrollInfo=this._codeMirror.g etScrollInfo();var topmostLineNumber=this._codeMirror.lineAtHeight(scrollInfo.to p,"local");var bottomLine=this._codeMirror.lineAtHeight(scrollInfo.top+scrollInf o.clientHeight,"local");if(cursor.line<topmostLineNumber||cursor.line>bottomLine ) 1390 return;var cursor=this._codeMirror.getCursor();var scrollInfo=this._codeMirror.g etScrollInfo();var topmostLineNumber=this._codeMirror.lineAtHeight(scrollInfo.to p,"local");var bottomLine=this._codeMirror.lineAtHeight(scrollInfo.top+scrollInf o.clientHeight,"local");if(cursor.line<topmostLineNumber||cursor.line>bottomLine )
1382 this.finishAutocomplete();else{this._anchorBox=this._anchorBoxForPosition(cursor .line,cursor.ch);this._suggestBox.setPosition(this._anchorBox);}},_onCursorActiv ity:function() 1391 this.finishAutocomplete();else{this._anchorBox=this._anchorBoxForPosition(cursor .line,cursor.ch);this._suggestBox.setPosition(this._anchorBox);}},_onCursorActiv ity:function()
1383 {if(!this._suggestBox) 1392 {if(!this._suggestBox)
1384 return;var cursor=this._codeMirror.getCursor();if(cursor.line!==this._prefixRang e.startLine||cursor.ch>this._prefixRange.endColumn||cursor.ch<this._prefixRange. startColumn) 1393 return;var cursor=this._codeMirror.getCursor();if(cursor.line!==this._prefixRang e.startLine||cursor.ch>this._prefixRange.endColumn||cursor.ch<this._prefixRange. startColumn)
1385 this.finishAutocomplete();},_anchorBoxForPosition:function(line,column) 1394 this.finishAutocomplete();},_anchorBoxForPosition:function(line,column)
1386 {var metrics=this._textEditor.cursorPositionToCoordinates(line,column);return me trics?new AnchorBox(metrics.x,metrics.y,0,metrics.height):null;},} 1395 {var metrics=this._textEditor.cursorPositionToCoordinates(line,column);return me trics?new AnchorBox(metrics.x,metrics.y,0,metrics.height):null;},}
OLDNEW
« no previous file with comments | « chrome_linux/resources/inspector/AuditsPanel.js ('k') | chrome_linux/resources/inspector/ElementsPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698