/* * Copyright (C) 2016 by Marijn Haverbeke and others * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ (function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory():typeof define==='function'&&define.amd?define(factory):(global.CodeMirror=factory());}(this,(function(){'use strict'; var userAgent=navigator.userAgent var platform=navigator.platform var gecko=/gecko\/\d/i.test(userAgent) var ie_upto10=/MSIE \d/.test(userAgent) var ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent) var ie=ie_upto10||ie_11up var ie_version=ie&&(ie_upto10?document.documentMode||6:ie_11up[1]) var webkit=/WebKit\//.test(userAgent) var qtwebkit=webkit&&/Qt\/\d+\.\d+/.test(userAgent) var chrome=/Chrome\//.test(userAgent) var presto=/Opera\//.test(userAgent) var safari=/Apple Computer/.test(navigator.vendor) var mac_geMountainLion=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent) var phantom=/PhantomJS/.test(userAgent) var ios=/AppleWebKit/.test(userAgent)&&/Mobile\/\w+/.test(userAgent) var mobile=ios||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent) var mac=ios||/Mac/.test(platform) var chromeOS=/\bCrOS\b/.test(userAgent) var windows=/win/i.test(platform) var presto_version=presto&&userAgent.match(/Version\/(\d*\.\d*)/) if(presto_version){presto_version=Number(presto_version[1])} if(presto_version&&presto_version>=15){presto=false;webkit=true} var flipCtrlCmd=mac&&(qtwebkit||presto&&(presto_version==null||presto_version<12.11)) var captureRightClick=gecko||(ie&&ie_version>=9) function classTest(cls){return new RegExp("(^|\\s)"+cls+"(?:$|\\s)\\s*")} var rmClass=function(node,cls){var current=node.className var match=classTest(cls).exec(current) if(match){var after=current.slice(match.index+match[0].length) node.className=current.slice(0,match.index)+(after?match[1]+after:"")}} function removeChildren(e){for(var count=e.childNodes.length;count>0;--count) {e.removeChild(e.firstChild)} return e} function removeChildrenAndAdd(parent,e){return removeChildren(parent).appendChild(e)} function elt(tag,content,className,style){var e=document.createElement(tag) if(className){e.className=className} if(style){e.style.cssText=style} if(typeof content=="string"){e.appendChild(document.createTextNode(content))} else if(content){for(var i=0;i=end) {return n+(end-i)} n+=nextTab-i n+=tabSize-(n%tabSize) i=nextTab+1}} function Delayed(){this.id=null} Delayed.prototype.set=function(ms,f){clearTimeout(this.id) this.id=setTimeout(f,ms)} function indexOf(array,elt){for(var i=0;i=goal) {return pos+Math.min(skipped,goal-col)} col+=nextTab-pos col+=tabSize-(col%tabSize) pos=nextTab+1 if(col>=goal){return pos}}} var spaceStrs=[""] function spaceStr(n){while(spaceStrs.length<=n) {spaceStrs.push(lst(spaceStrs)+" ")} return spaceStrs[n]} function lst(arr){return arr[arr.length-1]} function map(array,f){var out=[] for(var i=0;i"\x80"&&(ch.toUpperCase()!=ch.toLowerCase()||nonASCIISingleCaseWordChar.test(ch))} function isWordChar(ch,helper){if(!helper){return isWordCharBasic(ch)} if(helper.source.indexOf("\\w")>-1&&isWordCharBasic(ch)){return true} return helper.test(ch)} function isEmpty(obj){for(var n in obj){if(obj.hasOwnProperty(n)&&obj[n]){return false}} return true} var extendingChars=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function isExtendingChar(ch){return ch.charCodeAt(0)>=768&&extendingChars.test(ch)} function Display(place,doc,input){var d=this this.input=input d.scrollbarFiller=elt("div",null,"CodeMirror-scrollbar-filler") d.scrollbarFiller.setAttribute("cm-not-content","true") d.gutterFiller=elt("div",null,"CodeMirror-gutter-filler") d.gutterFiller.setAttribute("cm-not-content","true") d.lineDiv=elt("div",null,"CodeMirror-code") d.selectionDiv=elt("div",null,null,"position: relative; z-index: 1") d.cursorDiv=elt("div",null,"CodeMirror-cursors") d.measure=elt("div",null,"CodeMirror-measure") d.lineMeasure=elt("div",null,"CodeMirror-measure") d.lineSpace=elt("div",[d.measure,d.lineMeasure,d.selectionDiv,d.cursorDiv,d.lineDiv],null,"position: relative; outline: none") d.mover=elt("div",[elt("div",[d.lineSpace],"CodeMirror-lines")],null,"position: relative") d.sizer=elt("div",[d.mover],"CodeMirror-sizer") d.sizerWidth=null d.heightForcer=elt("div",null,null,"position: absolute; height: "+scrollerGap+"px; width: 1px;") d.gutters=elt("div",null,"CodeMirror-gutters") d.lineGutter=null d.scroller=elt("div",[d.sizer,d.heightForcer,d.gutters],"CodeMirror-scroll") d.scroller.setAttribute("tabIndex","-1") d.wrapper=elt("div",[d.scrollbarFiller,d.gutterFiller,d.scroller],"CodeMirror") if(ie&&ie_version<8){d.gutters.style.zIndex=-1;d.scroller.style.paddingRight=0} if(!webkit&&!(gecko&&mobile)){d.scroller.draggable=true} if(place){if(place.appendChild){place.appendChild(d.wrapper)} else{place(d.wrapper)}} d.viewFrom=d.viewTo=doc.first d.reportedViewFrom=d.reportedViewTo=doc.first d.view=[] d.renderedView=null d.externalMeasured=null d.viewOffset=0 d.lastWrapHeight=d.lastWrapWidth=0 d.updateLineNumbers=null d.nativeBarWidth=d.barHeight=d.barWidth=0 d.scrollbarsClipped=false d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null d.alignWidgets=false d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null d.maxLine=null d.maxLineLength=0 d.maxLineChanged=false d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null d.shift=false d.selForContextMenu=null d.activeTouch=null input.init(d)} function getLine(doc,n){n-=doc.first if(n<0||n>=doc.size){throw new Error("There is no line "+(n+doc.first)+" in the document.")} var chunk=doc while(!chunk.lines){for(var i=0;;++i){var child=chunk.children[i],sz=child.chunkSize() if(n=doc.first&&llast){return Pos(last,getLine(doc,last).text.length)} return clipToLen(pos,getLine(doc,pos.line).text.length)} 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}} function clipPosArray(doc,array){var out=[] for(var i=0;i=startCh:span.to>startCh);(nw||(nw=[])).push(new MarkedSpan(marker,span.from,endsAfter?null:span.to))}}} return nw} function markedSpansAfter(old,endCh,isInsert){var nw if(old){for(var i=0;i=endCh:span.to>endCh) if(endsAfter||span.from==endCh&&marker.type=="bookmark"&&(!isInsert||span.marker.insertLeft)){var startsBefore=span.from==null||(marker.inclusiveLeft?span.from<=endCh:span.from0&&first) {for(var i$2=0;i$20){continue} var newParts=[j,1],dfrom=cmp(p.from,m.from),dto=cmp(p.to,m.to) if(dfrom<0||!mk.inclusiveLeft&&!dfrom) {newParts.push({from:p.from,to:m.from})} if(dto>0||!mk.inclusiveRight&&!dto) {newParts.push({from:m.to,to:p.to})} parts.splice.apply(parts,newParts) j+=newParts.length-1}} return parts} function detachMarkedSpans(line){var spans=line.markedSpans if(!spans){return} for(var i=0;i=0&&toCmp<=0||fromCmp<=0&&toCmp>=0){continue} if(fromCmp<=0&&(sp.marker.inclusiveRight&&marker.inclusiveLeft?cmp(found.to,from)>=0:cmp(found.to,from)>0)||fromCmp>=0&&(sp.marker.inclusiveRight&&marker.inclusiveLeft?cmp(found.from,to)<=0:cmp(found.from,to)<0)) {return true}}}} function visualLine(line){var merged while(merged=collapsedSpanAtStart(line)) {line=merged.find(-1,true).line} return line} function visualLineContinued(line){var merged,lines while(merged=collapsedSpanAtEnd(line)){line=merged.find(1,true).line;(lines||(lines=[])).push(line)} return lines} function visualLineNo(doc,lineN){var line=getLine(doc,lineN),vis=visualLine(line) if(line==vis){return lineN} return lineNo(vis)} function visualLineEndNo(doc,lineN){if(lineN>doc.lastLine()){return lineN} var line=getLine(doc,lineN),merged if(!lineIsHidden(doc,line)){return lineN} while(merged=collapsedSpanAtEnd(line)) {line=merged.find(1,true).line} return lineNo(line)+1} function lineIsHidden(doc,line){var sps=sawCollapsedSpans&&line.markedSpans if(sps){for(var sp=(void 0),i=0;id.maxLineLength){d.maxLineLength=len d.maxLine=line}})} function iterateBidiSections(order,from,to,f){if(!order){return f(from,to,"ltr")} var found=false for(var i=0;ifrom||from==to&&part.to==from){f(Math.max(part.from,from),Math.min(part.to,to),part.level==1?"rtl":"ltr") found=true}} if(!found){f(from,to,"ltr")}} function bidiLeft(part){return part.level%2?part.to:part.from} function bidiRight(part){return part.level%2?part.from:part.to} function lineLeft(line){var order=getOrder(line);return order?bidiLeft(order[0]):0} function lineRight(line){var order=getOrder(line) if(!order){return line.text.length} return bidiRight(lst(order))} function compareBidiLevel(order,a,b){var linedir=order[0].level if(a==linedir){return true} if(b==linedir){return false} return apos){return i} if((cur.from==pos||cur.to==pos)){if(found==null){found=i}else if(compareBidiLevel(order,cur.level,order[found].level)){if(cur.from!=cur.to){bidiOther=found} return i}else{if(cur.from!=cur.to){bidiOther=i} return found}}} return found} function moveInLine(line,pos,dir,byUnit){if(!byUnit){return pos+dir} do{pos+=dir} while(pos>0&&isExtendingChar(line.text.charAt(pos))) return pos} function moveVisually(line,start,dir,byUnit){var bidi=getOrder(line) if(!bidi){return moveLogically(line,start,dir,byUnit)} var pos=getBidiPartAt(bidi,start),part=bidi[pos] var target=moveInLine(line,start,part.level%2?-dir:dir,byUnit) for(;;){if(target>part.from&&target0)==part.level%2?part.to:part.from}else{part=bidi[pos+=dir] if(!part){return null} if((dir>0)==part.level%2) {target=moveInLine(line,part.to,-1,byUnit)} else {target=moveInLine(line,part.from,1,byUnit)}}}} function moveLogically(line,start,dir,byUnit){var target=start+dir if(byUnit){while(target>0&&isExtendingChar(line.text.charAt(target))){target+=dir}} return target<0||target>line.text.length?null:target} var bidiOrdering=(function(){ var lowTypes="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN" var arabicTypes="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111" function charType(code){if(code<=0xf7){return lowTypes.charAt(code)} else if(0x590<=code&&code<=0x5f4){return"R"} else if(0x600<=code&&code<=0x6f9){return arabicTypes.charAt(code-0x600)} else if(0x6ee<=code&&code<=0x8ac){return"r"} else if(0x2000<=code&&code<=0x200b){return"w"} else if(code==0x200c){return"b"} else{return"L"}} var bidiRE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;var isNeutral=/[stwN]/,isStrong=/[LRr]/,countsAsLeft=/[Lb1n]/,countsAsNum=/[1n]/;var outerType="L" function BidiSpan(level,from,to){this.level=level this.from=from;this.to=to} return function(str){if(!bidiRE.test(str)){return false} var len=str.length,types=[] for(var i=0;i-1) {map[type]=arr.slice(0,index).concat(arr.slice(index+1))}}}} function signal(emitter,type){var handlers=getHandlers(emitter,type) if(!handlers.length){return} var args=Array.prototype.slice.call(arguments,2) for(var i=0;i0} function eventMixin(ctor){ctor.prototype.on=function(type,f){on(this,type,f)} ctor.prototype.off=function(type,f){off(this,type,f)}} function e_preventDefault(e){if(e.preventDefault){e.preventDefault()} else{e.returnValue=false}} function e_stopPropagation(e){if(e.stopPropagation){e.stopPropagation()} else{e.cancelBubble=true}} function e_defaultPrevented(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==false} function e_stop(e){e_preventDefault(e);e_stopPropagation(e)} function e_target(e){return e.target||e.srcElement} function e_button(e){var b=e.which if(b==null){if(e.button&1){b=1} else if(e.button&2){b=3} else if(e.button&4){b=2}} if(mac&&e.ctrlKey&&b==1){b=3} return b} var dragAndDrop=function(){ if(ie&&ie_version<9){return false} var div=elt('div') return"draggable"in div||"dragDrop"in div}() var zwspSupported function zeroWidthElement(measure){if(zwspSupported==null){var test=elt("span","\u200b") removeChildrenAndAdd(measure,elt("span",[test,document.createTextNode("x")])) if(measure.firstChild.offsetHeight!=0) {zwspSupported=test.offsetWidth<=1&&test.offsetHeight>2&&!(ie&&ie_version<8)}} var node=zwspSupported?elt("span","\u200b"):elt("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px") node.setAttribute("cm-text","") return node} var badBidiRects function hasBadBidiRects(measure){if(badBidiRects!=null){return badBidiRects} var txt=removeChildrenAndAdd(measure,document.createTextNode("A\u062eA")) var r0=range(txt,0,1).getBoundingClientRect() var r1=range(txt,1,2).getBoundingClientRect() removeChildren(measure) if(!r0||r0.left==r0.right){return false} return badBidiRects=(r1.right-r0.right<3)} var splitLinesAuto="\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=string.length} var line=string.slice(pos,string.charAt(nl-1)=="\r"?nl-1:nl) var rt=line.indexOf("\r") if(rt!=-1){result.push(line.slice(0,rt)) pos+=rt+1}else{result.push(line) pos=nl+1}} return result}:function(string){return string.split(/\r\n?|\n/);} var hasSelection=window.getSelection?function(te){try{return te.selectionStart!=te.selectionEnd} catch(e){return false}}:function(te){var range try{range=te.ownerDocument.selection.createRange()} catch(e){} if(!range||range.parentElement()!=te){return false} return range.compareEndPoints("StartToEnd",range)!=0} var hasCopyEvent=(function(){var e=elt("div") if("oncopy"in e){return true} e.setAttribute("oncopy","return;") return typeof e.oncopy=="function"})() var badZoomedRects=null function hasBadZoomedRects(measure){if(badZoomedRects!=null){return badZoomedRects} var node=removeChildrenAndAdd(measure,elt("span","x")) var normal=node.getBoundingClientRect() var fromRange=range(node,0,1).getBoundingClientRect() return badZoomedRects=Math.abs(normal.left-fromRange.left)>1} var modes={};var mimeModes={}; function defineMode(name,mode){if(arguments.length>2) {mode.dependencies=Array.prototype.slice.call(arguments,2)} modes[name]=mode} function defineMIME(mime,spec){mimeModes[mime]=spec} function resolveMode(spec){if(typeof spec=="string"&&mimeModes.hasOwnProperty(spec)){spec=mimeModes[spec]}else if(spec&&typeof spec.name=="string"&&mimeModes.hasOwnProperty(spec.name)){var found=mimeModes[spec.name] if(typeof found=="string"){found={name:found}} spec=createObj(found,spec) spec.name=found.name}else if(typeof spec=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(spec)){return resolveMode("application/xml")}else if(typeof spec=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(spec)){return resolveMode("application/json")} if(typeof spec=="string"){return{name:spec}} else{return spec||{name:"null"}}} function getMode(options,spec){spec=resolveMode(spec) var mfactory=modes[spec.name] if(!mfactory){return 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.hasOwnProperty(prop)){continue} if(modeObj.hasOwnProperty(prop)){modeObj["_"+prop]=modeObj[prop]} modeObj[prop]=exts[prop]}} modeObj.name=spec.name if(spec.helperType){modeObj.helperType=spec.helperType} if(spec.modeProps){for(var prop$1 in spec.modeProps) {modeObj[prop$1]=spec.modeProps[prop$1]}} return modeObj} var modeExtensions={} function extendMode(mode,properties){var exts=modeExtensions.hasOwnProperty(mode)?modeExtensions[mode]:(modeExtensions[mode]={}) copyObj(properties,exts)} 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 instanceof Array){val=val.concat([])} nstate[n]=val} return nstate} function innerMode(mode,state){var info while(mode.innerMode){info=mode.innerMode(state) if(!info||info.mode==mode){break} state=info.state mode=info.mode} return info||{mode:mode,state:state}} function startState(mode,a1,a2){return mode.startState?mode.startState(a1,a2):true} var StringStream=function(string,tabSize){this.pos=this.start=0 this.string=string this.tabSize=tabSize||8 this.lastColumnPos=this.lastColumnValue=0 this.lineStart=0} StringStream.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.posstart},eatSpace:function(){var this$1=this;var start=this.pos while(/[\s\u00a0]/.test(this.string.charAt(this.pos))){++this$1.pos} return this.pos>start},skipToEnd:function(){this.pos=this.string.length},skipTo:function(ch){var found=this.string.indexOf(ch,this.pos) if(found>-1){this.pos=found;return true}},backUp:function(n){this.pos-=n},column:function(){if(this.lastColumnPos0){return null} if(match&&consume!==false){this.pos+=match[0].length} return match}},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(n,inner){this.lineStart+=n try{return inner()} finally{this.lineStart-=n}}} function highlightLine(cm,line,state,forceToEnd){ var st=[cm.state.modeGen],lineClasses={} runMode(cm,line.text,cm.doc.mode,state,function(end,style){return st.push(end,style);},lineClasses,forceToEnd) var loop=function(o){var overlay=cm.state.overlays[o],i=1,at=0 runMode(cm,line.text,overlay.mode,true,function(end,style){var start=i while(atend) {st.splice(i,1,end,st[i+1],i_end)} i+=2 at=Math.min(end,i_end)} if(!style){return} if(overlay.opaque){st.splice(start,i-start,end,"overlay "+style) i=start+2}else{for(;startcm.options.maxHighlightLength?copyState(cm.doc.mode,state):state) line.stateAfter=state line.styles=result.styles if(result.classes){line.styleClasses=result.classes} else if(line.styleClasses){line.styleClasses=null} if(updateFrontier===cm.doc.frontier){cm.doc.frontier++}} return line.styles} 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.first&&getLine(doc,pos-1).stateAfter if(!state){state=startState(doc.mode)} else{state=copyState(doc.mode,state)} doc.iter(pos,n,function(line){processLine(cm,line.text,state) var save=pos==n-1||pos%5==0||pos>=display.viewFrom&&posstream.start){return style}} throw new Error("Mode "+mode.name+" failed to advance stream.")} function takeToken(cm,pos,precise,asArray){var getObj=function(copy){return({start:stream.start,end:stream.pos,string:stream.current(),type:style||null,state:copy?copyState(doc.mode,state):state});} var doc=cm.doc,mode=doc.mode,style pos=clipPos(doc,pos) var line=getLine(doc,pos.line),state=getStateBefore(cm,pos.line,precise) var stream=new StringStream(line.text,cm.options.tabSize),tokens if(asArray){tokens=[]} while((asArray||stream.poscm.options.maxHighlightLength){flattenSpans=false if(forceToEnd){processLine(cm,text,state,stream.pos)} stream.pos=text.length style=null}else{style=extractLineClasses(readToken(mode,stream,state,inner),lineClasses)} if(inner){var mName=inner[0].name if(mName){style="m-"+(style?mName+" "+style:mName)}} if(!flattenSpans||curStyle!=style){while(curStartlim;--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(minline==null||minindent>indented){minline=search-1 minindent=indented}} return minline} function Line(text,markedSpans,estimateHeight){this.text=text attachMarkedSpans(this,markedSpans) this.height=estimateHeight?estimateHeight(this):1} eventMixin(Line) Line.prototype.lineNo=function(){return lineNo(this)} function updateLine(line,text,markedSpans,estimateHeight){line.text=text if(line.stateAfter){line.stateAfter=null} if(line.styles){line.styles=null} if(line.order!=null){line.order=null} detachMarkedSpans(line) attachMarkedSpans(line,markedSpans) var estHeight=estimateHeight?estimateHeight(line):1 if(estHeight!=line.height){updateLineHeight(line,estHeight)}} function cleanUpLine(line){line.parent=null detachMarkedSpans(line)} var styleToClassCache={};var styleToClassCacheWithMode={};function interpretTokenStyle(style,options){if(!style||/^\s*$/.test(style)){return null} var cache=options.addModeClass?styleToClassCacheWithMode:styleToClassCache return cache[style]||(cache[style]=style.replace(/\S+/g,"cm-$&"))} function buildLineContent(cm,lineView){ var content=elt("span",null,null,webkit?"padding-right: .1px":null) var builder={pre:elt("pre",[content],"CodeMirror-line"),content:content,col:0,pos:0,cm:cm,trailingSpace:false,splitSpaces:(ie||webkit)&&cm.getOption("lineWrapping")} lineView.measure={} for(var i=0;i<=(lineView.rest?lineView.rest.length:0);i++){var line=i?lineView.rest[i-1]:lineView.line,order=(void 0) builder.pos=0 builder.addToken=buildToken if(hasBadBidiRects(cm.display.measure)&&(order=getOrder(line))) {builder.addToken=buildTokenBadBidi(builder.addToken,order)} builder.map=[] var allowFrontierUpdate=lineView!=cm.display.externalMeasured&&lineNo(line) insertLineContent(line,builder,getLineStyles(cm,line,allowFrontierUpdate)) if(line.styleClasses){if(line.styleClasses.bgClass) {builder.bgClass=joinClasses(line.styleClasses.bgClass,builder.bgClass||"")} if(line.styleClasses.textClass) {builder.textClass=joinClasses(line.styleClasses.textClass,builder.textClass||"")}} if(builder.map.length==0) {builder.map.push(0,0,builder.content.appendChild(zeroWidthElement(cm.display.measure)))} if(i==0){lineView.measure.map=builder.map lineView.measure.cache={}}else{;(lineView.measure.maps||(lineView.measure.maps=[])).push(builder.map);(lineView.measure.caches||(lineView.measure.caches=[])).push({})}} if(webkit){var last=builder.content.lastChild if(/\bcm-tab\b/.test(last.className)||(last.querySelector&&last.querySelector(".cm-tab"))) {builder.content.className="cm-tab-wrap-hack"}} signal(cm,"renderLine",cm,lineView.line,builder.pre) if(builder.pre.className) {builder.textClass=joinClasses(builder.pre.className,builder.textClass||"")} return builder} function defaultSpecialCharPlaceholder(ch){var token=elt("span","\u2022","cm-invalidchar") token.title="\\u"+ch.charCodeAt(0).toString(16) token.setAttribute("aria-label",token.title) return token} function buildToken(builder,text,style,startStyle,endStyle,title,css){if(!text){return} var displayText=builder.splitSpaces?splitSpaces(text,builder.trailingSpace):text var special=builder.cm.state.specialChars,mustWrap=false var content if(!special.test(text)){builder.col+=text.length content=document.createTextNode(displayText) builder.map.push(builder.pos,builder.pos+text.length,content) if(ie&&ie_version<9){mustWrap=true} builder.pos+=text.length}else{content=document.createDocumentFragment() var pos=0 while(true){special.lastIndex=pos var m=special.exec(text) var skipped=m?m.index-pos:text.length-pos if(skipped){var txt=document.createTextNode(displayText.slice(pos,pos+skipped)) if(ie&&ie_version<9){content.appendChild(elt("span",[txt]))} else{content.appendChild(txt)} builder.map.push(builder.pos,builder.pos+skipped,txt) builder.col+=skipped builder.pos+=skipped} if(!m){break} pos+=skipped+1 var txt$1=(void 0) if(m[0]=="\t"){var tabSize=builder.cm.options.tabSize,tabWidth=tabSize-builder.col%tabSize txt$1=content.appendChild(elt("span",spaceStr(tabWidth),"cm-tab")) txt$1.setAttribute("role","presentation") txt$1.setAttribute("cm-text","\t") builder.col+=tabWidth}else if(m[0]=="\r"||m[0]=="\n"){txt$1=content.appendChild(elt("span",m[0]=="\r"?"\u240d":"\u2424","cm-invalidchar")) txt$1.setAttribute("cm-text",m[0]) builder.col+=1}else{txt$1=builder.cm.options.specialCharPlaceholder(m[0]) txt$1.setAttribute("cm-text",m[0]) if(ie&&ie_version<9){content.appendChild(elt("span",[txt$1]))} else{content.appendChild(txt$1)} builder.col+=1} builder.map.push(builder.pos,builder.pos+1,txt$1) builder.pos++}} builder.trailingSpace=displayText.charCodeAt(text.length-1)==32 if(style||startStyle||endStyle||mustWrap||css){var fullStyle=style||"" if(startStyle){fullStyle+=startStyle} if(endStyle){fullStyle+=endStyle} var token=elt("span",[content],fullStyle,css) if(title){token.title=title} return builder.content.appendChild(token)} builder.content.appendChild(content)} function splitSpaces(text,trailingBefore){if(text.length>1&&!/ /.test(text)){return text} var spaceBefore=trailingBefore,result="" for(var i=0;istart&&part.from<=start){break}} if(part.to>=end){return inner(builder,text,style,startStyle,endStyle,title,css)} inner(builder,text.slice(0,part.to-start),style,startStyle,null,title,css) startStyle=null text=text.slice(part.to-start) start=part.to}}} function buildCollapsedSpan(builder,size,marker,ignoreWidget){var widget=!ignoreWidget&&marker.widgetNode if(widget){builder.map.push(builder.pos,builder.pos+size,widget)} if(!ignoreWidget&&builder.cm.display.input.needsContentAttribute){if(!widget) {widget=builder.content.appendChild(document.createElement("span"))} widget.setAttribute("cm-marker",marker.id)} if(widget){builder.cm.display.input.setUneditable(widget) builder.content.appendChild(widget)} builder.pos+=size builder.trailingSpace=false} function insertLineContent(line,builder,styles){var spans=line.markedSpans,allText=line.text,at=0 if(!spans){for(var i$1=1;i$1pos||m.collapsed&&sp.to==pos&&sp.from==pos)){if(sp.to!=null&&sp.to!=pos&&nextChange>sp.to){nextChange=sp.to spanEndStyle=""} if(m.className){spanStyle+=" "+m.className} if(m.css){css=(css?css+";":"")+m.css} if(m.startStyle&&sp.from==pos){spanStartStyle+=" "+m.startStyle} if(m.endStyle&&sp.to==nextChange){(endStyles||(endStyles=[])).push(m.endStyle,sp.to)} if(m.title&&!title){title=m.title} if(m.collapsed&&(!collapsed||compareCollapsedMarkers(collapsed.marker,m)<0)) {collapsed=sp}}else if(sp.from>pos&&nextChange>sp.from){nextChange=sp.from}} if(endStyles){for(var j$1=0;j$1=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):text builder.addToken(builder,tokenText,style?style+spanStyle:spanStyle,spanStartStyle,pos+tokenText.length==nextChange?spanEndStyle:"",title,css)} if(end>=upto){text=text.slice(upto-pos);pos=upto;break} pos=end spanStartStyle=""} text=allText.slice(at,at=styles[i++]) style=interpretTokenStyle(styles[i++],builder.cm.options)}}} function LineView(doc,line,lineN){ this.line=line this.rest=visualLineContinued(line) this.size=this.rest?lineNo(lst(this.rest))-lineN+1:1 this.node=this.text=null this.hidden=lineIsHidden(doc,line)} function buildViewArray(cm,from,to){var array=[],nextPos for(var pos=from;pos2) {heights.push((cur.bottom+next.top)/2-rect.top)}}} heights.push(rect.bottom-rect.top)}} function mapFromLineView(lineView,line,lineN){if(lineView.line==line) {return{map:lineView.measure.map,cache:lineView.measure.cache}} for(var i=0;ilineN) {return{map:lineView.measure.maps[i$1],cache:lineView.measure.caches[i$1],before:true}}}} function updateExternalMeasurement(cm,line){line=visualLine(line) var lineN=lineNo(line) var view=cm.display.externalMeasured=new LineView(cm.doc,line,lineN) view.lineN=lineN var built=view.built=buildLineContent(cm,view) view.text=built.pre removeChildrenAndAdd(cm.display.lineMeasure,built.pre) return view} function measureChar(cm,line,ch,bias){return measureCharPrepared(cm,prepareMeasureForLine(cm,line),ch,bias)} function findViewForLine(cm,lineN){if(lineN>=cm.display.viewFrom&&lineN=ext.lineN&&lineNch){end=mEnd-mStart start=end-1 if(ch>=mEnd){collapse="right"}} if(start!=null){node=map[i+2] if(mStart==mEnd&&bias==(node.insertLeft?"left":"right")) {collapse=bias} if(bias=="left"&&start==0) {while(i&&map[i-2]==map[i-3]&&map[i-1].insertLeft){node=map[(i-=3)+2] collapse="left"}} if(bias=="right"&&start==mEnd-mStart) {while(i=0;i$1--){if((rect=rects[i$1]).left!=rect.right){break}}} return rect} function measureCharInner(cm,prepared,ch,bias){var place=nodeAndOffsetInLineMap(prepared.map,ch,bias) var node=place.node,start=place.start,end=place.end,collapse=place.collapse var rect if(node.nodeType==3){for(var i$1=0;i$1<4;i$1++){ while(start&&isExtendingChar(prepared.line.text.charAt(place.coverStart+start))){--start} while(place.coverStart+end0){collapse=bias="right"} var rects if(cm.options.lineWrapping&&(rects=node.getClientRects()).length>1) {rect=rects[bias=="right"?rects.length-1:0]} else {rect=node.getBoundingClientRect()}} if(ie&&ie_version<9&&!start&&(!rect||!rect.left&&!rect.right)){var rSpan=node.parentNode.getClientRects()[0] if(rSpan) {rect={left:rSpan.left,right:rSpan.left+charWidth(cm.display),top:rSpan.top,bottom:rSpan.bottom}} else {rect=nullRect}} var rtop=rect.top-prepared.rect.top,rbot=rect.bottom-prepared.rect.top var mid=(rtop+rbot)/2 var heights=prepared.view.measure.heights var i=0 for(;ipart.from){return get(ch-1)} return get(ch,right)} var order=getOrder(lineObj),ch=pos.ch if(!order){return get(ch)} var partPos=getBidiPartAt(order,ch) var val=getBidi(ch,partPos) if(bidiOther!=null){val.other=getBidi(ch,bidiOther)} return val} function estimateCoords(cm,pos){var left=0 pos=clipPos(cm.doc,pos) if(!cm.options.lineWrapping){left=charWidth(cm.display)*pos.ch} var lineObj=getLine(cm.doc,pos.line) var top=heightAtLine(lineObj)+paddingTop(cm.display) return{left:left,right:left,top:top,bottom:top+lineObj.height}} function PosWithInfo(line,ch,outside,xRel){var pos=Pos(line,ch) pos.xRel=xRel if(outside){pos.outside=true} return pos} function coordsChar(cm,x,y){var doc=cm.doc y+=cm.display.viewOffset if(y<0){return PosWithInfo(doc.first,0,true,-1)} var lineN=lineAtHeight(doc,y),last=doc.first+doc.size-1 if(lineN>last) {return PosWithInfo(doc.first+doc.size-1,getLine(doc,last).text.length,true,1)} if(x<0){x=0} var lineObj=getLine(doc,lineN) for(;;){var found=coordsCharInner(cm,lineObj,lineN,x,y) var merged=collapsedSpanAtEnd(lineObj) var mergedPos=merged&&merged.find(0,true) if(merged&&(found.ch>mergedPos.from.ch||found.ch==mergedPos.from.ch&&found.xRel>0)) {lineN=lineNo(lineObj=mergedPos.to.line)} else {return found}}} function coordsCharInner(cm,lineObj,lineNo,x,y){var innerOff=y-heightAtLine(lineObj) var wrongLine=false,adjust=2*cm.display.wrapper.clientWidth var preparedMeasure=prepareMeasureForLine(cm,lineObj) function getX(ch){var sp=cursorCoords(cm,Pos(lineNo,ch),"line",lineObj,preparedMeasure) wrongLine=true if(innerOff>sp.bottom){return sp.left-adjust} else if(innerOfftoX){return PosWithInfo(lineNo,to,toOutside,1)} for(;;){if(bidi?to==from||to==moveVisually(lineObj,from,1):to-from<=1){var ch=x0&&ch1){var charSize=measureCharPrepared(cm,preparedMeasure,ch,"right") if(innerOff<=charSize.bottom&&innerOff>=charSize.top&&Math.abs(x-charSize.right)1?1:0) return pos} var step=Math.ceil(dist/2),middle=from+step if(bidi){middle=from for(var i=0;ix){to=middle;toX=middleX;if(toOutside=wrongLine){toX+=1000;}dist=step} else{from=middle;fromX=middleX;fromOutside=wrongLine;dist-=step}}} var measureText function textHeight(display){if(display.cachedTextHeight!=null){return display.cachedTextHeight} if(measureText==null){measureText=elt("pre") for(var i=0;i<49;++i){measureText.appendChild(document.createTextNode("x")) measureText.appendChild(elt("br"))} measureText.appendChild(document.createTextNode("x"))} removeChildrenAndAdd(display.measure,measureText) var height=measureText.offsetHeight/50 if(height>3){display.cachedTextHeight=height} removeChildren(display.measure) return height||1} function charWidth(display){if(display.cachedCharWidth!=null){return display.cachedCharWidth} var anchor=elt("span","xxxxxxxxxx") var pre=elt("pre",[anchor]) removeChildrenAndAdd(display.measure,pre) var rect=anchor.getBoundingClientRect(),width=(rect.right-rect.left)/10 if(width>2){display.cachedCharWidth=width} return width||10} function getDimensions(cm){var d=cm.display,left={},width={} var gutterLeft=d.gutters.clientLeft for(var n=d.gutters.firstChild,i=0;n;n=n.nextSibling,++i){left[cm.options.gutters[i]]=n.offsetLeft+n.clientLeft+gutterLeft width[cm.options.gutters[i]]=n.clientWidth} return{fixedPos:compensateForHScroll(d),gutterTotalWidth:d.gutters.offsetWidth,gutterLeft:left,gutterWidth:width,wrapperWidth:d.wrapper.clientWidth}} function compensateForHScroll(display){return display.scroller.getBoundingClientRect().left-display.sizer.getBoundingClientRect().left} function estimateHeight(cm){var th=textHeight(cm.display),wrapping=cm.options.lineWrapping var perLine=wrapping&&Math.max(5,cm.display.scroller.clientWidth/charWidth(cm.display)-3) return function(line){if(lineIsHidden(cm.doc,line)){return 0} var widgetsHeight=0 if(line.widgets){for(var i=0;i=cm.display.viewTo){return null} n-=cm.display.viewFrom if(n<0){return null} var view=cm.display.view for(var i=0;i=cm.display.viewTo||range.to().line3){ add(left,leftPos.top,null,leftPos.bottom) left=leftSide if(leftPos.bottomend.bottom||rightPos.bottom==end.bottom&&rightPos.right>end.right) {end=rightPos} if(left0) {display.blinker=setInterval(function(){return display.cursorDiv.style.visibility=(on=!on)?"":"hidden";},cm.options.cursorBlinkRate)} else if(cm.options.cursorBlinkRate<0) {display.cursorDiv.style.visibility="hidden"}} function ensureFocus(cm){if(!cm.state.focused){cm.display.input.focus();onFocus(cm)}} function delayBlurEvent(cm){cm.state.delayingBlurEvent=true setTimeout(function(){if(cm.state.delayingBlurEvent){cm.state.delayingBlurEvent=false onBlur(cm)}},100)} function onFocus(cm,e){if(cm.state.delayingBlurEvent){cm.state.delayingBlurEvent=false} if(cm.options.readOnly=="nocursor"){return} if(!cm.state.focused){signal(cm,"focus",cm,e) cm.state.focused=true addClass(cm.display.wrapper,"CodeMirror-focused") if(!cm.curOp&&cm.display.selForContextMenu!=cm.doc.sel){cm.display.input.reset() if(webkit){setTimeout(function(){return cm.display.input.reset(true);},20)} } cm.display.input.receivedFocus()} restartBlink(cm)} function onBlur(cm,e){if(cm.state.delayingBlurEvent){return} if(cm.state.focused){signal(cm,"blur",cm,e) cm.state.focused=false rmClass(cm.display.wrapper,"CodeMirror-focused")} clearInterval(cm.display.blinker) setTimeout(function(){if(!cm.state.focused){cm.display.shift=false}},150)} function alignHorizontally(cm){var display=cm.display,view=display.view if(!display.alignWidgets&&(!display.gutters.firstChild||!cm.options.fixedGutter)){return} var comp=compensateForHScroll(display)-display.scroller.scrollLeft+cm.doc.scrollLeft var gutterW=display.gutters.offsetWidth,left=comp+"px" for(var i=0;i.001||diff<-.001){updateLineHeight(cur.line,height) updateWidgetHeight(cur.line) if(cur.rest){for(var j=0;j=to){from=lineAtHeight(doc,heightAtLine(getLine(doc,ensureTo))-display.wrapper.clientHeight) to=ensureTo}} return{from:from,to:Math.max(to,from+1)}} function setScrollTop(cm,val){if(Math.abs(cm.doc.scrollTop-val)<2){return} cm.doc.scrollTop=val if(!gecko){updateDisplaySimple(cm,{top:val})} if(cm.display.scroller.scrollTop!=val){cm.display.scroller.scrollTop=val} cm.display.scrollbars.setScrollTop(val) if(gecko){updateDisplaySimple(cm)} startWorker(cm,100)} function setScrollLeft(cm,val,isScroller){if(isScroller?val==cm.doc.scrollLeft:Math.abs(cm.doc.scrollLeft-val)<2){return} val=Math.min(val,cm.display.scroller.scrollWidth-cm.display.scroller.clientWidth) cm.doc.scrollLeft=val alignHorizontally(cm) if(cm.display.scroller.scrollLeft!=val){cm.display.scroller.scrollLeft=val} cm.display.scrollbars.setScrollLeft(val)} var wheelSamples=0;var wheelPixelsPerUnit=null; if(ie){wheelPixelsPerUnit=-.53} else if(gecko){wheelPixelsPerUnit=15} else if(chrome){wheelPixelsPerUnit=-.7} else if(safari){wheelPixelsPerUnit=-1/3} function wheelEventDelta(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.wheelDelta} return{x:dx,y:dy}} function wheelEventPixels(e){var delta=wheelEventDelta(e) delta.x*=wheelPixelsPerUnit delta.y*=wheelPixelsPerUnit return delta} function onScrollWheel(cm,e){var delta=wheelEventDelta(e),dx=delta.x,dy=delta.y var display=cm.display,scroll=display.scroller var canScrollX=scroll.scrollWidth>scroll.clientWidth var canScrollY=scroll.scrollHeight>scroll.clientHeight if(!(dx&&canScrollX||dy&&canScrollY)){return} if(dy&&mac&&webkit){outer:for(var cur=e.target,view=display.view;cur!=scroll;cur=cur.parentNode){for(var i=0;imeasure.clientWidth+1 var needsV=measure.scrollHeight>measure.clientHeight+1 var sWidth=measure.nativeBarWidth if(needsV){this.vert.style.display="block" this.vert.style.bottom=needsH?sWidth+"px":"0" var totalHeight=measure.viewHeight-(needsH?sWidth:0) this.vert.firstChild.style.height=Math.max(0,measure.scrollHeight-measure.clientHeight+totalHeight)+"px"}else{this.vert.style.display="" this.vert.firstChild.style.height="0"} if(needsH){this.horiz.style.display="block" this.horiz.style.right=needsV?sWidth+"px":"0" this.horiz.style.left=measure.barLeft+"px" var totalWidth=measure.viewWidth-measure.barLeft-(needsV?sWidth:0) this.horiz.firstChild.style.width=(measure.scrollWidth-measure.clientWidth+totalWidth)+"px"}else{this.horiz.style.display="" this.horiz.firstChild.style.width="0"} if(!this.checkedZeroWidth&&measure.clientHeight>0){if(sWidth==0){this.zeroWidthHack()} this.checkedZeroWidth=true} return{right:needsV?sWidth:0,bottom:needsH?sWidth:0}};NativeScrollbars.prototype.setScrollLeft=function(pos){if(this.horiz.scrollLeft!=pos){this.horiz.scrollLeft=pos} if(this.disableHoriz){this.enableZeroWidthBar(this.horiz,this.disableHoriz)}};NativeScrollbars.prototype.setScrollTop=function(pos){if(this.vert.scrollTop!=pos){this.vert.scrollTop=pos} if(this.disableVert){this.enableZeroWidthBar(this.vert,this.disableVert)}};NativeScrollbars.prototype.zeroWidthHack=function(){var w=mac&&!mac_geMountainLion?"12px":"18px" this.horiz.style.height=this.vert.style.width=w this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none" this.disableHoriz=new Delayed this.disableVert=new Delayed};NativeScrollbars.prototype.enableZeroWidthBar=function(bar,delay){bar.style.pointerEvents="auto" function maybeDisable(){ var box=bar.getBoundingClientRect() var elt=document.elementFromPoint(box.left+1,box.bottom-1) if(elt!=bar){bar.style.pointerEvents="none"} else{delay.set(1000,maybeDisable)}} delay.set(1000,maybeDisable)};NativeScrollbars.prototype.clear=function(){var parent=this.horiz.parentNode parent.removeChild(this.horiz) parent.removeChild(this.vert)};var NullScrollbars=function(){};NullScrollbars.prototype.update=function(){return{bottom:0,right:0}};NullScrollbars.prototype.setScrollLeft=function(){};NullScrollbars.prototype.setScrollTop=function(){};NullScrollbars.prototype.clear=function(){};function updateScrollbars(cm,measure){if(!measure){measure=measureForScrollbars(cm)} var startWidth=cm.display.barWidth,startHeight=cm.display.barHeight updateScrollbarsInner(cm,measure) for(var i=0;i<4&&startWidth!=cm.display.barWidth||startHeight!=cm.display.barHeight;i++){if(startWidth!=cm.display.barWidth&&cm.options.lineWrapping) {updateHeightsInViewport(cm)} updateScrollbarsInner(cm,measureForScrollbars(cm)) startWidth=cm.display.barWidth;startHeight=cm.display.barHeight}} function updateScrollbarsInner(cm,measure){var d=cm.display var sizes=d.scrollbars.update(measure) d.sizer.style.paddingRight=(d.barWidth=sizes.right)+"px" d.sizer.style.paddingBottom=(d.barHeight=sizes.bottom)+"px" d.heightForcer.style.borderBottom=sizes.bottom+"px solid transparent" if(sizes.right&&sizes.bottom){d.scrollbarFiller.style.display="block" d.scrollbarFiller.style.height=sizes.bottom+"px" d.scrollbarFiller.style.width=sizes.right+"px"}else{d.scrollbarFiller.style.display=""} if(sizes.bottom&&cm.options.coverGutterNextToScrollbar&&cm.options.fixedGutter){d.gutterFiller.style.display="block" d.gutterFiller.style.height=sizes.bottom+"px" d.gutterFiller.style.width=measure.gutterWidth+"px"}else{d.gutterFiller.style.display=""}} var scrollbarModel={"native":NativeScrollbars,"null":NullScrollbars} function initScrollbars(cm){if(cm.display.scrollbars){cm.display.scrollbars.clear() if(cm.display.scrollbars.addClass) {rmClass(cm.display.wrapper,cm.display.scrollbars.addClass)}} cm.display.scrollbars=new scrollbarModel[cm.options.scrollbarStyle](function(node){cm.display.wrapper.insertBefore(node,cm.display.scrollbarFiller) on(node,"mousedown",function(){if(cm.state.focused){setTimeout(function(){return cm.display.input.focus();},0)}}) node.setAttribute("cm-not-content","true")},function(pos,axis){if(axis=="horizontal"){setScrollLeft(cm,pos)} else{setScrollTop(cm,pos)}},cm) if(cm.display.scrollbars.addClass) {addClass(cm.display.wrapper,cm.display.scrollbars.addClass)}} function maybeScrollWindow(cm,coords){if(signalDOMEvent(cm,"scrollCursorIntoView")){return} var display=cm.display,box=display.sizer.getBoundingClientRect(),doScroll=null if(coords.top+box.top<0){doScroll=true} else if(coords.bottom+box.top>(window.innerHeight||document.documentElement.clientHeight)){doScroll=false} if(doScroll!=null&&!phantom){var scrollNode=elt("div","\u200b",null,("position: absolute;\n top: "+(coords.top-display.viewOffset-paddingTop(cm.display))+"px;\n height: "+(coords.bottom-coords.top+scrollGap(cm)+display.barHeight)+"px;\n left: "+(coords.left)+"px; width: 2px;")) cm.display.lineSpace.appendChild(scrollNode) scrollNode.scrollIntoView(doScroll) cm.display.lineSpace.removeChild(scrollNode)}} function scrollPosIntoView(cm,pos,end,margin){if(margin==null){margin=0} var coords for(var limit=0;limit<5;limit++){var changed=false coords=cursorCoords(cm,pos) var endCoords=!end||end==pos?coords:cursorCoords(cm,end) var scrollPos=calculateScrollPos(cm,Math.min(coords.left,endCoords.left),Math.min(coords.top,endCoords.top)-margin,Math.max(coords.left,endCoords.left),Math.max(coords.bottom,endCoords.bottom)+margin) var startTop=cm.doc.scrollTop,startLeft=cm.doc.scrollLeft if(scrollPos.scrollTop!=null){setScrollTop(cm,scrollPos.scrollTop) if(Math.abs(cm.doc.scrollTop-startTop)>1){changed=true}} if(scrollPos.scrollLeft!=null){setScrollLeft(cm,scrollPos.scrollLeft) if(Math.abs(cm.doc.scrollLeft-startLeft)>1){changed=true}} if(!changed){break}} return coords} function scrollIntoView(cm,x1,y1,x2,y2){var scrollPos=calculateScrollPos(cm,x1,y1,x2,y2) if(scrollPos.scrollTop!=null){setScrollTop(cm,scrollPos.scrollTop)} if(scrollPos.scrollLeft!=null){setScrollLeft(cm,scrollPos.scrollLeft)}} function calculateScrollPos(cm,x1,y1,x2,y2){var display=cm.display,snapMargin=textHeight(cm.display) if(y1<0){y1=0} var screentop=cm.curOp&&cm.curOp.scrollTop!=null?cm.curOp.scrollTop:display.scroller.scrollTop var screen=displayHeight(cm),result={} if(y2-y1>screen){y2=y1+screen} var docBottom=cm.doc.height+paddingVert(display) var atTop=y1docBottom-snapMargin if(y1screentop+screen){var newTop=Math.min(y1,(atBottom?docBottom:y2)-screen) if(newTop!=screentop){result.scrollTop=newTop}} var screenleft=cm.curOp&&cm.curOp.scrollLeft!=null?cm.curOp.scrollLeft:display.scroller.scrollLeft var screenw=displayWidth(cm)-(cm.options.fixedGutter?display.gutters.offsetWidth:0) var tooWide=x2-x1>screenw if(tooWide){x2=x1+screenw} if(x1<10) {result.scrollLeft=0} else if(x1screenw+screenleft-3) {result.scrollLeft=x2+(tooWide?0:10)-screenw} return result} function addToScrollPos(cm,left,top){if(left!=null||top!=null){resolveScrollToPos(cm)} if(left!=null) {cm.curOp.scrollLeft=(cm.curOp.scrollLeft==null?cm.doc.scrollLeft:cm.curOp.scrollLeft)+left} if(top!=null) {cm.curOp.scrollTop=(cm.curOp.scrollTop==null?cm.doc.scrollTop:cm.curOp.scrollTop)+top}} function ensureCursorVisible(cm){resolveScrollToPos(cm) var cur=cm.getCursor(),from=cur,to=cur if(!cm.options.lineWrapping){from=cur.ch?Pos(cur.line,cur.ch-1):cur to=Pos(cur.line,cur.ch+1)} cm.curOp.scrollToPos={from:from,to:to,margin:cm.options.cursorScrollMargin,isCursor:true}} function resolveScrollToPos(cm){var range=cm.curOp.scrollToPos if(range){cm.curOp.scrollToPos=null var from=estimateCoords(cm,range.from),to=estimateCoords(cm,range.to) var sPos=calculateScrollPos(cm,Math.min(from.left,to.left),Math.min(from.top,to.top)-range.margin,Math.max(from.right,to.right),Math.max(from.bottom,to.bottom)+range.margin) cm.scrollTo(sPos.scrollLeft,sPos.scrollTop)}} var nextOpId=0 function startOperation(cm){cm.curOp={cm:cm,viewChanged:false, startHeight:cm.doc.height, forceUpdate:false, updateInput:null, typing:false,changeObjs:null, cursorActivityHandlers:null, cursorActivityCalled:0, selectionChanged:false, updateMaxLine:false, scrollLeft:null,scrollTop:null, scrollToPos:null, focus:false,id:++nextOpId } pushOperation(cm.curOp)} function endOperation(cm){var op=cm.curOp finishOperation(op,function(group){for(var i=0;i=display.viewTo)||display.maxLineChanged&&cm.options.lineWrapping op.update=op.mustUpdate&&new DisplayUpdate(cm,op.mustUpdate&&{top:op.scrollTop,ensure:op.scrollToPos},op.forceUpdate)} function endOperation_W1(op){op.updatedDisplay=op.mustUpdate&&updateDisplayIfNeeded(op.cm,op.update)} function endOperation_R2(op){var cm=op.cm,display=cm.display if(op.updatedDisplay){updateHeightsInViewport(cm)} op.barMeasure=measureForScrollbars(cm) if(display.maxLineChanged&&!cm.options.lineWrapping){op.adjustWidthTo=measureChar(cm,display.maxLine,display.maxLine.text.length).left+3 cm.display.sizerWidth=op.adjustWidthTo op.barMeasure.scrollWidth=Math.max(display.scroller.clientWidth,display.sizer.offsetLeft+op.adjustWidthTo+scrollGap(cm)+cm.display.barWidth) op.maxScrollLeft=Math.max(0,display.sizer.offsetLeft+op.adjustWidthTo-displayWidth(cm))} if(op.updatedDisplay||op.selectionChanged) {op.preparedSelection=display.input.prepareSelection(op.focus)}} function endOperation_W2(op){var cm=op.cm if(op.adjustWidthTo!=null){cm.display.sizer.style.minWidth=op.adjustWidthTo+"px" if(op.maxScrollLeft