Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ace.js 616KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2010, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. /**
  31. * Define a module along with a payload
  32. * @param module a name for the payload
  33. * @param payload a function to call with (require, exports, module) params
  34. */
  35. (function() {
  36. var ACE_NAMESPACE = "ace";
  37. var global = (function() {
  38. return this;
  39. })();
  40. if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
  41. return;
  42. var _define = function(module, deps, payload) {
  43. if (typeof module !== 'string') {
  44. if (_define.original)
  45. _define.original.apply(window, arguments);
  46. else {
  47. console.error('dropping module because define wasn\'t a string.');
  48. console.trace();
  49. }
  50. return;
  51. }
  52. if (arguments.length == 2)
  53. payload = deps;
  54. if (!_define.modules) {
  55. _define.modules = {};
  56. _define.payloads = {};
  57. }
  58. _define.payloads[module] = payload;
  59. _define.modules[module] = null;
  60. };
  61. /**
  62. * Get at functionality ace.define()ed using the function above
  63. */
  64. var _require = function(parentId, module, callback) {
  65. if (Object.prototype.toString.call(module) === "[object Array]") {
  66. var params = [];
  67. for (var i = 0, l = module.length; i < l; ++i) {
  68. var dep = lookup(parentId, module[i]);
  69. if (!dep && _require.original)
  70. return _require.original.apply(window, arguments);
  71. params.push(dep);
  72. }
  73. if (callback) {
  74. callback.apply(null, params);
  75. }
  76. }
  77. else if (typeof module === 'string') {
  78. var payload = lookup(parentId, module);
  79. if (!payload && _require.original)
  80. return _require.original.apply(window, arguments);
  81. if (callback) {
  82. callback();
  83. }
  84. return payload;
  85. }
  86. else {
  87. if (_require.original)
  88. return _require.original.apply(window, arguments);
  89. }
  90. };
  91. var normalizeModule = function(parentId, moduleName) {
  92. // normalize plugin requires
  93. if (moduleName.indexOf("!") !== -1) {
  94. var chunks = moduleName.split("!");
  95. return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
  96. }
  97. // normalize relative requires
  98. if (moduleName.charAt(0) == ".") {
  99. var base = parentId.split("/").slice(0, -1).join("/");
  100. moduleName = base + "/" + moduleName;
  101. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  102. var previous = moduleName;
  103. moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  104. }
  105. }
  106. return moduleName;
  107. };
  108. /**
  109. * Internal function to lookup moduleNames and resolve them by calling the
  110. * definition function if needed.
  111. */
  112. var lookup = function(parentId, moduleName) {
  113. moduleName = normalizeModule(parentId, moduleName);
  114. var module = _define.modules[moduleName];
  115. if (!module) {
  116. module = _define.payloads[moduleName];
  117. if (typeof module === 'function') {
  118. var exports = {};
  119. var mod = {
  120. id: moduleName,
  121. uri: '',
  122. exports: exports,
  123. packaged: true
  124. };
  125. var req = function(module, callback) {
  126. return _require(moduleName, module, callback);
  127. };
  128. var returnValue = module(req, exports, mod);
  129. exports = returnValue || mod.exports;
  130. _define.modules[moduleName] = exports;
  131. delete _define.payloads[moduleName];
  132. }
  133. module = _define.modules[moduleName] = exports || module;
  134. }
  135. return module;
  136. };
  137. function exportAce(ns) {
  138. var require = function(module, callback) {
  139. return _require("", module, callback);
  140. };
  141. var root = global;
  142. if (ns) {
  143. if (!global[ns])
  144. global[ns] = {};
  145. root = global[ns];
  146. }
  147. if (!root.define || !root.define.packaged) {
  148. _define.original = root.define;
  149. root.define = _define;
  150. root.define.packaged = true;
  151. }
  152. if (!root.require || !root.require.packaged) {
  153. _require.original = root.require;
  154. root.require = require;
  155. root.require.packaged = true;
  156. }
  157. }
  158. exportAce(ACE_NAMESPACE);
  159. })();
  160. ace.define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) {
  161. "use strict";
  162. var real = {
  163. exec: RegExp.prototype.exec,
  164. test: RegExp.prototype.test,
  165. match: String.prototype.match,
  166. replace: String.prototype.replace,
  167. split: String.prototype.split
  168. },
  169. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  170. compliantLastIndexIncrement = function () {
  171. var x = /^/g;
  172. real.test.call(x, "");
  173. return !x.lastIndex;
  174. }();
  175. if (compliantLastIndexIncrement && compliantExecNpcg)
  176. return;
  177. RegExp.prototype.exec = function (str) {
  178. var match = real.exec.apply(this, arguments),
  179. name, r2;
  180. if ( typeof(str) == 'string' && match) {
  181. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  182. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  183. real.replace.call(str.slice(match.index), r2, function () {
  184. for (var i = 1; i < arguments.length - 2; i++) {
  185. if (arguments[i] === undefined)
  186. match[i] = undefined;
  187. }
  188. });
  189. }
  190. if (this._xregexp && this._xregexp.captureNames) {
  191. for (var i = 1; i < match.length; i++) {
  192. name = this._xregexp.captureNames[i - 1];
  193. if (name)
  194. match[name] = match[i];
  195. }
  196. }
  197. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  198. this.lastIndex--;
  199. }
  200. return match;
  201. };
  202. if (!compliantLastIndexIncrement) {
  203. RegExp.prototype.test = function (str) {
  204. var match = real.exec.call(this, str);
  205. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  206. this.lastIndex--;
  207. return !!match;
  208. };
  209. }
  210. function getNativeFlags (regex) {
  211. return (regex.global ? "g" : "") +
  212. (regex.ignoreCase ? "i" : "") +
  213. (regex.multiline ? "m" : "") +
  214. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  215. (regex.sticky ? "y" : "");
  216. }
  217. function indexOf (array, item, from) {
  218. if (Array.prototype.indexOf) // Use the native array method if available
  219. return array.indexOf(item, from);
  220. for (var i = from || 0; i < array.length; i++) {
  221. if (array[i] === item)
  222. return i;
  223. }
  224. return -1;
  225. }
  226. });
  227. ace.define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
  228. function Empty() {}
  229. if (!Function.prototype.bind) {
  230. Function.prototype.bind = function bind(that) { // .length is 1
  231. var target = this;
  232. if (typeof target != "function") {
  233. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  234. }
  235. var args = slice.call(arguments, 1); // for normal call
  236. var bound = function () {
  237. if (this instanceof bound) {
  238. var result = target.apply(
  239. this,
  240. args.concat(slice.call(arguments))
  241. );
  242. if (Object(result) === result) {
  243. return result;
  244. }
  245. return this;
  246. } else {
  247. return target.apply(
  248. that,
  249. args.concat(slice.call(arguments))
  250. );
  251. }
  252. };
  253. if(target.prototype) {
  254. Empty.prototype = target.prototype;
  255. bound.prototype = new Empty();
  256. Empty.prototype = null;
  257. }
  258. return bound;
  259. };
  260. }
  261. var call = Function.prototype.call;
  262. var prototypeOfArray = Array.prototype;
  263. var prototypeOfObject = Object.prototype;
  264. var slice = prototypeOfArray.slice;
  265. var _toString = call.bind(prototypeOfObject.toString);
  266. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  267. var defineGetter;
  268. var defineSetter;
  269. var lookupGetter;
  270. var lookupSetter;
  271. var supportsAccessors;
  272. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  273. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  274. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  275. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  276. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  277. }
  278. if ([1,2].splice(0).length != 2) {
  279. if(function() { // test IE < 9 to splice bug - see issue #138
  280. function makeArray(l) {
  281. var a = new Array(l+2);
  282. a[0] = a[1] = 0;
  283. return a;
  284. }
  285. var array = [], lengthBefore;
  286. array.splice.apply(array, makeArray(20));
  287. array.splice.apply(array, makeArray(26));
  288. lengthBefore = array.length; //46
  289. array.splice(5, 0, "XXX"); // add one element
  290. lengthBefore + 1 == array.length
  291. if (lengthBefore + 1 == array.length) {
  292. return true;// has right splice implementation without bugs
  293. }
  294. }()) {//IE 6/7
  295. var array_splice = Array.prototype.splice;
  296. Array.prototype.splice = function(start, deleteCount) {
  297. if (!arguments.length) {
  298. return [];
  299. } else {
  300. return array_splice.apply(this, [
  301. start === void 0 ? 0 : start,
  302. deleteCount === void 0 ? (this.length - start) : deleteCount
  303. ].concat(slice.call(arguments, 2)))
  304. }
  305. };
  306. } else {//IE8
  307. Array.prototype.splice = function(pos, removeCount){
  308. var length = this.length;
  309. if (pos > 0) {
  310. if (pos > length)
  311. pos = length;
  312. } else if (pos == void 0) {
  313. pos = 0;
  314. } else if (pos < 0) {
  315. pos = Math.max(length + pos, 0);
  316. }
  317. if (!(pos+removeCount < length))
  318. removeCount = length - pos;
  319. var removed = this.slice(pos, pos+removeCount);
  320. var insert = slice.call(arguments, 2);
  321. var add = insert.length;
  322. if (pos === length) {
  323. if (add) {
  324. this.push.apply(this, insert);
  325. }
  326. } else {
  327. var remove = Math.min(removeCount, length - pos);
  328. var tailOldPos = pos + remove;
  329. var tailNewPos = tailOldPos + add - remove;
  330. var tailCount = length - tailOldPos;
  331. var lengthAfterRemove = length - remove;
  332. if (tailNewPos < tailOldPos) { // case A
  333. for (var i = 0; i < tailCount; ++i) {
  334. this[tailNewPos+i] = this[tailOldPos+i];
  335. }
  336. } else if (tailNewPos > tailOldPos) { // case B
  337. for (i = tailCount; i--; ) {
  338. this[tailNewPos+i] = this[tailOldPos+i];
  339. }
  340. } // else, add == remove (nothing to do)
  341. if (add && pos === lengthAfterRemove) {
  342. this.length = lengthAfterRemove; // truncate array
  343. this.push.apply(this, insert);
  344. } else {
  345. this.length = lengthAfterRemove + add; // reserves space
  346. for (i = 0; i < add; ++i) {
  347. this[pos+i] = insert[i];
  348. }
  349. }
  350. }
  351. return removed;
  352. };
  353. }
  354. }
  355. if (!Array.isArray) {
  356. Array.isArray = function isArray(obj) {
  357. return _toString(obj) == "[object Array]";
  358. };
  359. }
  360. var boxedString = Object("a"),
  361. splitString = boxedString[0] != "a" || !(0 in boxedString);
  362. if (!Array.prototype.forEach) {
  363. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  364. var object = toObject(this),
  365. self = splitString && _toString(this) == "[object String]" ?
  366. this.split("") :
  367. object,
  368. thisp = arguments[1],
  369. i = -1,
  370. length = self.length >>> 0;
  371. if (_toString(fun) != "[object Function]") {
  372. throw new TypeError(); // TODO message
  373. }
  374. while (++i < length) {
  375. if (i in self) {
  376. fun.call(thisp, self[i], i, object);
  377. }
  378. }
  379. };
  380. }
  381. if (!Array.prototype.map) {
  382. Array.prototype.map = function map(fun /*, thisp*/) {
  383. var object = toObject(this),
  384. self = splitString && _toString(this) == "[object String]" ?
  385. this.split("") :
  386. object,
  387. length = self.length >>> 0,
  388. result = Array(length),
  389. thisp = arguments[1];
  390. if (_toString(fun) != "[object Function]") {
  391. throw new TypeError(fun + " is not a function");
  392. }
  393. for (var i = 0; i < length; i++) {
  394. if (i in self)
  395. result[i] = fun.call(thisp, self[i], i, object);
  396. }
  397. return result;
  398. };
  399. }
  400. if (!Array.prototype.filter) {
  401. Array.prototype.filter = function filter(fun /*, thisp */) {
  402. var object = toObject(this),
  403. self = splitString && _toString(this) == "[object String]" ?
  404. this.split("") :
  405. object,
  406. length = self.length >>> 0,
  407. result = [],
  408. value,
  409. thisp = arguments[1];
  410. if (_toString(fun) != "[object Function]") {
  411. throw new TypeError(fun + " is not a function");
  412. }
  413. for (var i = 0; i < length; i++) {
  414. if (i in self) {
  415. value = self[i];
  416. if (fun.call(thisp, value, i, object)) {
  417. result.push(value);
  418. }
  419. }
  420. }
  421. return result;
  422. };
  423. }
  424. if (!Array.prototype.every) {
  425. Array.prototype.every = function every(fun /*, thisp */) {
  426. var object = toObject(this),
  427. self = splitString && _toString(this) == "[object String]" ?
  428. this.split("") :
  429. object,
  430. length = self.length >>> 0,
  431. thisp = arguments[1];
  432. if (_toString(fun) != "[object Function]") {
  433. throw new TypeError(fun + " is not a function");
  434. }
  435. for (var i = 0; i < length; i++) {
  436. if (i in self && !fun.call(thisp, self[i], i, object)) {
  437. return false;
  438. }
  439. }
  440. return true;
  441. };
  442. }
  443. if (!Array.prototype.some) {
  444. Array.prototype.some = function some(fun /*, thisp */) {
  445. var object = toObject(this),
  446. self = splitString && _toString(this) == "[object String]" ?
  447. this.split("") :
  448. object,
  449. length = self.length >>> 0,
  450. thisp = arguments[1];
  451. if (_toString(fun) != "[object Function]") {
  452. throw new TypeError(fun + " is not a function");
  453. }
  454. for (var i = 0; i < length; i++) {
  455. if (i in self && fun.call(thisp, self[i], i, object)) {
  456. return true;
  457. }
  458. }
  459. return false;
  460. };
  461. }
  462. if (!Array.prototype.reduce) {
  463. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  464. var object = toObject(this),
  465. self = splitString && _toString(this) == "[object String]" ?
  466. this.split("") :
  467. object,
  468. length = self.length >>> 0;
  469. if (_toString(fun) != "[object Function]") {
  470. throw new TypeError(fun + " is not a function");
  471. }
  472. if (!length && arguments.length == 1) {
  473. throw new TypeError("reduce of empty array with no initial value");
  474. }
  475. var i = 0;
  476. var result;
  477. if (arguments.length >= 2) {
  478. result = arguments[1];
  479. } else {
  480. do {
  481. if (i in self) {
  482. result = self[i++];
  483. break;
  484. }
  485. if (++i >= length) {
  486. throw new TypeError("reduce of empty array with no initial value");
  487. }
  488. } while (true);
  489. }
  490. for (; i < length; i++) {
  491. if (i in self) {
  492. result = fun.call(void 0, result, self[i], i, object);
  493. }
  494. }
  495. return result;
  496. };
  497. }
  498. if (!Array.prototype.reduceRight) {
  499. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  500. var object = toObject(this),
  501. self = splitString && _toString(this) == "[object String]" ?
  502. this.split("") :
  503. object,
  504. length = self.length >>> 0;
  505. if (_toString(fun) != "[object Function]") {
  506. throw new TypeError(fun + " is not a function");
  507. }
  508. if (!length && arguments.length == 1) {
  509. throw new TypeError("reduceRight of empty array with no initial value");
  510. }
  511. var result, i = length - 1;
  512. if (arguments.length >= 2) {
  513. result = arguments[1];
  514. } else {
  515. do {
  516. if (i in self) {
  517. result = self[i--];
  518. break;
  519. }
  520. if (--i < 0) {
  521. throw new TypeError("reduceRight of empty array with no initial value");
  522. }
  523. } while (true);
  524. }
  525. do {
  526. if (i in this) {
  527. result = fun.call(void 0, result, self[i], i, object);
  528. }
  529. } while (i--);
  530. return result;
  531. };
  532. }
  533. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  534. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  535. var self = splitString && _toString(this) == "[object String]" ?
  536. this.split("") :
  537. toObject(this),
  538. length = self.length >>> 0;
  539. if (!length) {
  540. return -1;
  541. }
  542. var i = 0;
  543. if (arguments.length > 1) {
  544. i = toInteger(arguments[1]);
  545. }
  546. i = i >= 0 ? i : Math.max(0, length + i);
  547. for (; i < length; i++) {
  548. if (i in self && self[i] === sought) {
  549. return i;
  550. }
  551. }
  552. return -1;
  553. };
  554. }
  555. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  556. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  557. var self = splitString && _toString(this) == "[object String]" ?
  558. this.split("") :
  559. toObject(this),
  560. length = self.length >>> 0;
  561. if (!length) {
  562. return -1;
  563. }
  564. var i = length - 1;
  565. if (arguments.length > 1) {
  566. i = Math.min(i, toInteger(arguments[1]));
  567. }
  568. i = i >= 0 ? i : length - Math.abs(i);
  569. for (; i >= 0; i--) {
  570. if (i in self && sought === self[i]) {
  571. return i;
  572. }
  573. }
  574. return -1;
  575. };
  576. }
  577. if (!Object.getPrototypeOf) {
  578. Object.getPrototypeOf = function getPrototypeOf(object) {
  579. return object.__proto__ || (
  580. object.constructor ?
  581. object.constructor.prototype :
  582. prototypeOfObject
  583. );
  584. };
  585. }
  586. if (!Object.getOwnPropertyDescriptor) {
  587. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  588. "non-object: ";
  589. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  590. if ((typeof object != "object" && typeof object != "function") || object === null)
  591. throw new TypeError(ERR_NON_OBJECT + object);
  592. if (!owns(object, property))
  593. return;
  594. var descriptor, getter, setter;
  595. descriptor = { enumerable: true, configurable: true };
  596. if (supportsAccessors) {
  597. var prototype = object.__proto__;
  598. object.__proto__ = prototypeOfObject;
  599. var getter = lookupGetter(object, property);
  600. var setter = lookupSetter(object, property);
  601. object.__proto__ = prototype;
  602. if (getter || setter) {
  603. if (getter) descriptor.get = getter;
  604. if (setter) descriptor.set = setter;
  605. return descriptor;
  606. }
  607. }
  608. descriptor.value = object[property];
  609. return descriptor;
  610. };
  611. }
  612. if (!Object.getOwnPropertyNames) {
  613. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  614. return Object.keys(object);
  615. };
  616. }
  617. if (!Object.create) {
  618. var createEmpty;
  619. if (Object.prototype.__proto__ === null) {
  620. createEmpty = function () {
  621. return { "__proto__": null };
  622. };
  623. } else {
  624. createEmpty = function () {
  625. var empty = {};
  626. for (var i in empty)
  627. empty[i] = null;
  628. empty.constructor =
  629. empty.hasOwnProperty =
  630. empty.propertyIsEnumerable =
  631. empty.isPrototypeOf =
  632. empty.toLocaleString =
  633. empty.toString =
  634. empty.valueOf =
  635. empty.__proto__ = null;
  636. return empty;
  637. }
  638. }
  639. Object.create = function create(prototype, properties) {
  640. var object;
  641. if (prototype === null) {
  642. object = createEmpty();
  643. } else {
  644. if (typeof prototype != "object")
  645. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  646. var Type = function () {};
  647. Type.prototype = prototype;
  648. object = new Type();
  649. object.__proto__ = prototype;
  650. }
  651. if (properties !== void 0)
  652. Object.defineProperties(object, properties);
  653. return object;
  654. };
  655. }
  656. function doesDefinePropertyWork(object) {
  657. try {
  658. Object.defineProperty(object, "sentinel", {});
  659. return "sentinel" in object;
  660. } catch (exception) {
  661. }
  662. }
  663. if (Object.defineProperty) {
  664. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  665. var definePropertyWorksOnDom = typeof document == "undefined" ||
  666. doesDefinePropertyWork(document.createElement("div"));
  667. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  668. var definePropertyFallback = Object.defineProperty;
  669. }
  670. }
  671. if (!Object.defineProperty || definePropertyFallback) {
  672. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  673. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  674. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  675. "on this javascript engine";
  676. Object.defineProperty = function defineProperty(object, property, descriptor) {
  677. if ((typeof object != "object" && typeof object != "function") || object === null)
  678. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  679. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  680. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  681. if (definePropertyFallback) {
  682. try {
  683. return definePropertyFallback.call(Object, object, property, descriptor);
  684. } catch (exception) {
  685. }
  686. }
  687. if (owns(descriptor, "value")) {
  688. if (supportsAccessors && (lookupGetter(object, property) ||
  689. lookupSetter(object, property)))
  690. {
  691. var prototype = object.__proto__;
  692. object.__proto__ = prototypeOfObject;
  693. delete object[property];
  694. object[property] = descriptor.value;
  695. object.__proto__ = prototype;
  696. } else {
  697. object[property] = descriptor.value;
  698. }
  699. } else {
  700. if (!supportsAccessors)
  701. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  702. if (owns(descriptor, "get"))
  703. defineGetter(object, property, descriptor.get);
  704. if (owns(descriptor, "set"))
  705. defineSetter(object, property, descriptor.set);
  706. }
  707. return object;
  708. };
  709. }
  710. if (!Object.defineProperties) {
  711. Object.defineProperties = function defineProperties(object, properties) {
  712. for (var property in properties) {
  713. if (owns(properties, property))
  714. Object.defineProperty(object, property, properties[property]);
  715. }
  716. return object;
  717. };
  718. }
  719. if (!Object.seal) {
  720. Object.seal = function seal(object) {
  721. return object;
  722. };
  723. }
  724. if (!Object.freeze) {
  725. Object.freeze = function freeze(object) {
  726. return object;
  727. };
  728. }
  729. try {
  730. Object.freeze(function () {});
  731. } catch (exception) {
  732. Object.freeze = (function freeze(freezeObject) {
  733. return function freeze(object) {
  734. if (typeof object == "function") {
  735. return object;
  736. } else {
  737. return freezeObject(object);
  738. }
  739. };
  740. })(Object.freeze);
  741. }
  742. if (!Object.preventExtensions) {
  743. Object.preventExtensions = function preventExtensions(object) {
  744. return object;
  745. };
  746. }
  747. if (!Object.isSealed) {
  748. Object.isSealed = function isSealed(object) {
  749. return false;
  750. };
  751. }
  752. if (!Object.isFrozen) {
  753. Object.isFrozen = function isFrozen(object) {
  754. return false;
  755. };
  756. }
  757. if (!Object.isExtensible) {
  758. Object.isExtensible = function isExtensible(object) {
  759. if (Object(object) === object) {
  760. throw new TypeError(); // TODO message
  761. }
  762. var name = '';
  763. while (owns(object, name)) {
  764. name += '?';
  765. }
  766. object[name] = true;
  767. var returnValue = owns(object, name);
  768. delete object[name];
  769. return returnValue;
  770. };
  771. }
  772. if (!Object.keys) {
  773. var hasDontEnumBug = true,
  774. dontEnums = [
  775. "toString",
  776. "toLocaleString",
  777. "valueOf",
  778. "hasOwnProperty",
  779. "isPrototypeOf",
  780. "propertyIsEnumerable",
  781. "constructor"
  782. ],
  783. dontEnumsLength = dontEnums.length;
  784. for (var key in {"toString": null}) {
  785. hasDontEnumBug = false;
  786. }
  787. Object.keys = function keys(object) {
  788. if (
  789. (typeof object != "object" && typeof object != "function") ||
  790. object === null
  791. ) {
  792. throw new TypeError("Object.keys called on a non-object");
  793. }
  794. var keys = [];
  795. for (var name in object) {
  796. if (owns(object, name)) {
  797. keys.push(name);
  798. }
  799. }
  800. if (hasDontEnumBug) {
  801. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  802. var dontEnum = dontEnums[i];
  803. if (owns(object, dontEnum)) {
  804. keys.push(dontEnum);
  805. }
  806. }
  807. }
  808. return keys;
  809. };
  810. }
  811. if (!Date.now) {
  812. Date.now = function now() {
  813. return new Date().getTime();
  814. };
  815. }
  816. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  817. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  818. "\u2029\uFEFF";
  819. if (!String.prototype.trim || ws.trim()) {
  820. ws = "[" + ws + "]";
  821. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  822. trimEndRegexp = new RegExp(ws + ws + "*$");
  823. String.prototype.trim = function trim() {
  824. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  825. };
  826. }
  827. function toInteger(n) {
  828. n = +n;
  829. if (n !== n) { // isNaN
  830. n = 0;
  831. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  832. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  833. }
  834. return n;
  835. }
  836. function isPrimitive(input) {
  837. var type = typeof input;
  838. return (
  839. input === null ||
  840. type === "undefined" ||
  841. type === "boolean" ||
  842. type === "number" ||
  843. type === "string"
  844. );
  845. }
  846. function toPrimitive(input) {
  847. var val, valueOf, toString;
  848. if (isPrimitive(input)) {
  849. return input;
  850. }
  851. valueOf = input.valueOf;
  852. if (typeof valueOf === "function") {
  853. val = valueOf.call(input);
  854. if (isPrimitive(val)) {
  855. return val;
  856. }
  857. }
  858. toString = input.toString;
  859. if (typeof toString === "function") {
  860. val = toString.call(input);
  861. if (isPrimitive(val)) {
  862. return val;
  863. }
  864. }
  865. throw new TypeError();
  866. }
  867. var toObject = function (o) {
  868. if (o == null) { // this matches both null and undefined
  869. throw new TypeError("can't convert "+o+" to object");
  870. }
  871. return Object(o);
  872. };
  873. });
  874. ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) {
  875. "use strict";
  876. require("./regexp");
  877. require("./es5-shim");
  878. });
  879. ace.define("ace/lib/dom",["require","exports","module"], function(require, exports, module) {
  880. "use strict";
  881. var XHTML_NS = "http://www.w3.org/1999/xhtml";
  882. exports.getDocumentHead = function(doc) {
  883. if (!doc)
  884. doc = document;
  885. return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
  886. }
  887. exports.createElement = function(tag, ns) {
  888. return document.createElementNS ?
  889. document.createElementNS(ns || XHTML_NS, tag) :
  890. document.createElement(tag);
  891. };
  892. exports.hasCssClass = function(el, name) {
  893. var classes = (el.className || "").split(/\s+/g);
  894. return classes.indexOf(name) !== -1;
  895. };
  896. exports.addCssClass = function(el, name) {
  897. if (!exports.hasCssClass(el, name)) {
  898. el.className += " " + name;
  899. }
  900. };
  901. exports.removeCssClass = function(el, name) {
  902. var classes = el.className.split(/\s+/g);
  903. while (true) {
  904. var index = classes.indexOf(name);
  905. if (index == -1) {
  906. break;
  907. }
  908. classes.splice(index, 1);
  909. }
  910. el.className = classes.join(" ");
  911. };
  912. exports.toggleCssClass = function(el, name) {
  913. var classes = el.className.split(/\s+/g), add = true;
  914. while (true) {
  915. var index = classes.indexOf(name);
  916. if (index == -1) {
  917. break;
  918. }
  919. add = false;
  920. classes.splice(index, 1);
  921. }
  922. if(add)
  923. classes.push(name);
  924. el.className = classes.join(" ");
  925. return add;
  926. };
  927. exports.setCssClass = function(node, className, include) {
  928. if (include) {
  929. exports.addCssClass(node, className);
  930. } else {
  931. exports.removeCssClass(node, className);
  932. }
  933. };
  934. exports.hasCssString = function(id, doc) {
  935. var index = 0, sheets;
  936. doc = doc || document;
  937. if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
  938. while (index < sheets.length)
  939. if (sheets[index++].owningElement.id === id) return true;
  940. } else if ((sheets = doc.getElementsByTagName("style"))) {
  941. while (index < sheets.length)
  942. if (sheets[index++].id === id) return true;
  943. }
  944. return false;
  945. };
  946. exports.importCssString = function importCssString(cssText, id, doc) {
  947. doc = doc || document;
  948. if (id && exports.hasCssString(id, doc))
  949. return null;
  950. var style;
  951. if (doc.createStyleSheet) {
  952. style = doc.createStyleSheet();
  953. style.cssText = cssText;
  954. if (id)
  955. style.owningElement.id = id;
  956. } else {
  957. style = doc.createElementNS
  958. ? doc.createElementNS(XHTML_NS, "style")
  959. : doc.createElement("style");
  960. style.appendChild(doc.createTextNode(cssText));
  961. if (id)
  962. style.id = id;
  963. exports.getDocumentHead(doc).appendChild(style);
  964. }
  965. };
  966. exports.importCssStylsheet = function(uri, doc) {
  967. if (doc.createStyleSheet) {
  968. doc.createStyleSheet(uri);
  969. } else {
  970. var link = exports.createElement('link');
  971. link.rel = 'stylesheet';
  972. link.href = uri;
  973. exports.getDocumentHead(doc).appendChild(link);
  974. }
  975. };
  976. exports.getInnerWidth = function(element) {
  977. return (
  978. parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
  979. parseInt(exports.computedStyle(element, "paddingRight"), 10) +
  980. element.clientWidth
  981. );
  982. };
  983. exports.getInnerHeight = function(element) {
  984. return (
  985. parseInt(exports.computedStyle(element, "paddingTop"), 10) +
  986. parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
  987. element.clientHeight
  988. );
  989. };
  990. if (typeof document == "undefined")
  991. return;
  992. if (window.pageYOffset !== undefined) {
  993. exports.getPageScrollTop = function() {
  994. return window.pageYOffset;
  995. };
  996. exports.getPageScrollLeft = function() {
  997. return window.pageXOffset;
  998. };
  999. }
  1000. else {
  1001. exports.getPageScrollTop = function() {
  1002. return document.body.scrollTop;
  1003. };
  1004. exports.getPageScrollLeft = function() {
  1005. return document.body.scrollLeft;
  1006. };
  1007. }
  1008. if (window.getComputedStyle)
  1009. exports.computedStyle = function(element, style) {
  1010. if (style)
  1011. return (window.getComputedStyle(element, "") || {})[style] || "";
  1012. return window.getComputedStyle(element, "") || {};
  1013. };
  1014. else
  1015. exports.computedStyle = function(element, style) {
  1016. if (style)
  1017. return element.currentStyle[style];
  1018. return element.currentStyle;
  1019. };
  1020. exports.scrollbarWidth = function(document) {
  1021. var inner = exports.createElement("ace_inner");
  1022. inner.style.width = "100%";
  1023. inner.style.minWidth = "0px";
  1024. inner.style.height = "200px";
  1025. inner.style.display = "block";
  1026. var outer = exports.createElement("ace_outer");
  1027. var style = outer.style;
  1028. style.position = "absolute";
  1029. style.left = "-10000px";
  1030. style.overflow = "hidden";
  1031. style.width = "200px";
  1032. style.minWidth = "0px";
  1033. style.height = "150px";
  1034. style.display = "block";
  1035. outer.appendChild(inner);
  1036. var body = document.documentElement;
  1037. body.appendChild(outer);
  1038. var noScrollbar = inner.offsetWidth;
  1039. style.overflow = "scroll";
  1040. var withScrollbar = inner.offsetWidth;
  1041. if (noScrollbar == withScrollbar) {
  1042. withScrollbar = outer.clientWidth;
  1043. }
  1044. body.removeChild(outer);
  1045. return noScrollbar-withScrollbar;
  1046. };
  1047. exports.setInnerHtml = function(el, innerHtml) {
  1048. var element = el.cloneNode(false);//document.createElement("div");
  1049. element.innerHTML = innerHtml;
  1050. el.parentNode.replaceChild(element, el);
  1051. return element;
  1052. };
  1053. if ("textContent" in document.documentElement) {
  1054. exports.setInnerText = function(el, innerText) {
  1055. el.textContent = innerText;
  1056. };
  1057. exports.getInnerText = function(el) {
  1058. return el.textContent;
  1059. };
  1060. }
  1061. else {
  1062. exports.setInnerText = function(el, innerText) {
  1063. el.innerText = innerText;
  1064. };
  1065. exports.getInnerText = function(el) {
  1066. return el.innerText;
  1067. };
  1068. }
  1069. exports.getParentWindow = function(document) {
  1070. return document.defaultView || document.parentWindow;
  1071. };
  1072. });
  1073. ace.define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
  1074. "use strict";
  1075. exports.inherits = function(ctor, superCtor) {
  1076. ctor.super_ = superCtor;
  1077. ctor.prototype = Object.create(superCtor.prototype, {
  1078. constructor: {
  1079. value: ctor,
  1080. enumerable: false,
  1081. writable: true,
  1082. configurable: true
  1083. }
  1084. });
  1085. };
  1086. exports.mixin = function(obj, mixin) {
  1087. for (var key in mixin) {
  1088. obj[key] = mixin[key];
  1089. }
  1090. return obj;
  1091. };
  1092. exports.implement = function(proto, mixin) {
  1093. exports.mixin(proto, mixin);
  1094. };
  1095. });
  1096. ace.define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(require, exports, module) {
  1097. "use strict";
  1098. require("./fixoldbrowsers");
  1099. var oop = require("./oop");
  1100. var Keys = (function() {
  1101. var ret = {
  1102. MODIFIER_KEYS: {
  1103. 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
  1104. },
  1105. KEY_MODS: {
  1106. "ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
  1107. "super": 8, "meta": 8, "command": 8, "cmd": 8
  1108. },
  1109. FUNCTION_KEYS : {
  1110. 8 : "Backspace",
  1111. 9 : "Tab",
  1112. 13 : "Return",
  1113. 19 : "Pause",
  1114. 27 : "Esc",
  1115. 32 : "Space",
  1116. 33 : "PageUp",
  1117. 34 : "PageDown",
  1118. 35 : "End",
  1119. 36 : "Home",
  1120. 37 : "Left",
  1121. 38 : "Up",
  1122. 39 : "Right",
  1123. 40 : "Down",
  1124. 44 : "Print",
  1125. 45 : "Insert",
  1126. 46 : "Delete",
  1127. 96 : "Numpad0",
  1128. 97 : "Numpad1",
  1129. 98 : "Numpad2",
  1130. 99 : "Numpad3",
  1131. 100: "Numpad4",
  1132. 101: "Numpad5",
  1133. 102: "Numpad6",
  1134. 103: "Numpad7",
  1135. 104: "Numpad8",
  1136. 105: "Numpad9",
  1137. '-13': "NumpadEnter",
  1138. 112: "F1",
  1139. 113: "F2",
  1140. 114: "F3",
  1141. 115: "F4",
  1142. 116: "F5",
  1143. 117: "F6",
  1144. 118: "F7",
  1145. 119: "F8",
  1146. 120: "F9",
  1147. 121: "F10",
  1148. 122: "F11",
  1149. 123: "F12",
  1150. 144: "Numlock",
  1151. 145: "Scrolllock"
  1152. },
  1153. PRINTABLE_KEYS: {
  1154. 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
  1155. 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
  1156. 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
  1157. 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
  1158. 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
  1159. 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
  1160. 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', 219: '[',
  1161. 220: '\\',221: ']', 222: '\''
  1162. }
  1163. };
  1164. var name, i;
  1165. for (i in ret.FUNCTION_KEYS) {
  1166. name = ret.FUNCTION_KEYS[i].toLowerCase();
  1167. ret[name] = parseInt(i, 10);
  1168. }
  1169. for (i in ret.PRINTABLE_KEYS) {
  1170. name = ret.PRINTABLE_KEYS[i].toLowerCase();
  1171. ret[name] = parseInt(i, 10);
  1172. }
  1173. oop.mixin(ret, ret.MODIFIER_KEYS);
  1174. oop.mixin(ret, ret.PRINTABLE_KEYS);
  1175. oop.mixin(ret, ret.FUNCTION_KEYS);
  1176. ret.enter = ret["return"];
  1177. ret.escape = ret.esc;
  1178. ret.del = ret["delete"];
  1179. ret[173] = '-';
  1180. (function() {
  1181. var mods = ["cmd", "ctrl", "alt", "shift"];
  1182. for (var i = Math.pow(2, mods.length); i--;) {
  1183. ret.KEY_MODS[i] = mods.filter(function(x) {
  1184. return i & ret.KEY_MODS[x];
  1185. }).join("-") + "-";
  1186. }
  1187. })();
  1188. ret.KEY_MODS[0] = "";
  1189. ret.KEY_MODS[-1] = "input";
  1190. return ret;
  1191. })();
  1192. oop.mixin(exports, Keys);
  1193. exports.keyCodeToString = function(keyCode) {
  1194. var keyString = Keys[keyCode];
  1195. if (typeof keyString != "string")
  1196. keyString = String.fromCharCode(keyCode);
  1197. return keyString.toLowerCase();
  1198. };
  1199. });
  1200. ace.define("ace/lib/useragent",["require","exports","module"], function(require, exports, module) {
  1201. "use strict";
  1202. exports.OS = {
  1203. LINUX: "LINUX",
  1204. MAC: "MAC",
  1205. WINDOWS: "WINDOWS"
  1206. };
  1207. exports.getOS = function() {
  1208. if (exports.isMac) {
  1209. return exports.OS.MAC;
  1210. } else if (exports.isLinux) {
  1211. return exports.OS.LINUX;
  1212. } else {
  1213. return exports.OS.WINDOWS;
  1214. }
  1215. };
  1216. if (typeof navigator != "object")
  1217. return;
  1218. var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
  1219. var ua = navigator.userAgent;
  1220. exports.isWin = (os == "win");
  1221. exports.isMac = (os == "mac");
  1222. exports.isLinux = (os == "linux");
  1223. exports.isIE =
  1224. (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
  1225. ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
  1226. : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
  1227. exports.isOldIE = exports.isIE && exports.isIE < 9;
  1228. exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
  1229. exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
  1230. exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
  1231. exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
  1232. exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
  1233. exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
  1234. exports.isIPad = ua.indexOf("iPad") >= 0;
  1235. exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
  1236. exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
  1237. });
  1238. ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  1239. "use strict";
  1240. var keys = require("./keys");
  1241. var useragent = require("./useragent");
  1242. exports.addListener = function(elem, type, callback) {
  1243. if (elem.addEventListener) {
  1244. return elem.addEventListener(type, callback, false);
  1245. }
  1246. if (elem.attachEvent) {
  1247. var wrapper = function() {
  1248. callback.call(elem, window.event);
  1249. };
  1250. callback._wrapper = wrapper;
  1251. elem.attachEvent("on" + type, wrapper);
  1252. }
  1253. };
  1254. exports.removeListener = function(elem, type, callback) {
  1255. if (elem.removeEventListener) {
  1256. return elem.removeEventListener(type, callback, false);
  1257. }
  1258. if (elem.detachEvent) {
  1259. elem.detachEvent("on" + type, callback._wrapper || callback);
  1260. }
  1261. };
  1262. exports.stopEvent = function(e) {
  1263. exports.stopPropagation(e);
  1264. exports.preventDefault(e);
  1265. return false;
  1266. };
  1267. exports.stopPropagation = function(e) {
  1268. if (e.stopPropagation)
  1269. e.stopPropagation();
  1270. else
  1271. e.cancelBubble = true;
  1272. };
  1273. exports.preventDefault = function(e) {
  1274. if (e.preventDefault)
  1275. e.preventDefault();
  1276. else
  1277. e.returnValue = false;
  1278. };
  1279. exports.getButton = function(e) {
  1280. if (e.type == "dblclick")
  1281. return 0;
  1282. if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
  1283. return 2;
  1284. if (e.preventDefault) {
  1285. return e.button;
  1286. }
  1287. else {
  1288. return {1:0, 2:2, 4:1}[e.button];
  1289. }
  1290. };
  1291. exports.capture = function(el, eventHandler, releaseCaptureHandler) {
  1292. function onMouseUp(e) {
  1293. eventHandler && eventHandler(e);
  1294. releaseCaptureHandler && releaseCaptureHandler(e);
  1295. exports.removeListener(document, "mousemove", eventHandler, true);
  1296. exports.removeListener(document, "mouseup", onMouseUp, true);
  1297. exports.removeListener(document, "dragstart", onMouseUp, true);
  1298. }
  1299. exports.addListener(document, "mousemove", eventHandler, true);
  1300. exports.addListener(document, "mouseup", onMouseUp, true);
  1301. exports.addListener(document, "dragstart", onMouseUp, true);
  1302. return onMouseUp;
  1303. };
  1304. exports.addMouseWheelListener = function(el, callback) {
  1305. if ("onmousewheel" in el) {
  1306. exports.addListener(el, "mousewheel", function(e) {
  1307. var factor = 8;
  1308. if (e.wheelDeltaX !== undefined) {
  1309. e.wheelX = -e.wheelDeltaX / factor;
  1310. e.wheelY = -e.wheelDeltaY / factor;
  1311. } else {
  1312. e.wheelX = 0;
  1313. e.wheelY = -e.wheelDelta / factor;
  1314. }
  1315. callback(e);
  1316. });
  1317. } else if ("onwheel" in el) {
  1318. exports.addListener(el, "wheel", function(e) {
  1319. var factor = 0.35;
  1320. switch (e.deltaMode) {
  1321. case e.DOM_DELTA_PIXEL:
  1322. e.wheelX = e.deltaX * factor || 0;
  1323. e.wheelY = e.deltaY * factor || 0;
  1324. break;
  1325. case e.DOM_DELTA_LINE:
  1326. case e.DOM_DELTA_PAGE:
  1327. e.wheelX = (e.deltaX || 0) * 5;
  1328. e.wheelY = (e.deltaY || 0) * 5;
  1329. break;
  1330. }
  1331. callback(e);
  1332. });
  1333. } else {
  1334. exports.addListener(el, "DOMMouseScroll", function(e) {
  1335. if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
  1336. e.wheelX = (e.detail || 0) * 5;
  1337. e.wheelY = 0;
  1338. } else {
  1339. e.wheelX = 0;
  1340. e.wheelY = (e.detail || 0) * 5;
  1341. }
  1342. callback(e);
  1343. });
  1344. }
  1345. };
  1346. exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
  1347. var clicks = 0;
  1348. var startX, startY, timer;
  1349. var eventNames = {
  1350. 2: "dblclick",
  1351. 3: "tripleclick",
  1352. 4: "quadclick"
  1353. };
  1354. exports.addListener(el, "mousedown", function(e) {
  1355. if (exports.getButton(e) !== 0) {
  1356. clicks = 0;
  1357. } else if (e.detail > 1) {
  1358. clicks++;
  1359. if (clicks > 4)
  1360. clicks = 1;
  1361. } else {
  1362. clicks = 1;
  1363. }
  1364. if (useragent.isIE) {
  1365. var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
  1366. if (!timer || isNewClick)
  1367. clicks = 1;
  1368. if (timer)
  1369. clearTimeout(timer);
  1370. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1371. if (clicks == 1) {
  1372. startX = e.clientX;
  1373. startY = e.clientY;
  1374. }
  1375. }
  1376. e._clicks = clicks;
  1377. eventHandler[callbackName]("mousedown", e);
  1378. if (clicks > 4)
  1379. clicks = 0;
  1380. else if (clicks > 1)
  1381. return eventHandler[callbackName](eventNames[clicks], e);
  1382. });
  1383. if (useragent.isOldIE) {
  1384. exports.addListener(el, "dblclick", function(e) {
  1385. clicks = 2;
  1386. if (timer)
  1387. clearTimeout(timer);
  1388. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1389. eventHandler[callbackName]("mousedown", e);
  1390. eventHandler[callbackName](eventNames[clicks], e);
  1391. });
  1392. }
  1393. };
  1394. var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window)
  1395. ? function(e) {
  1396. return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
  1397. }
  1398. : function(e) {
  1399. return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
  1400. };
  1401. exports.getModifierString = function(e) {
  1402. return keys.KEY_MODS[getModifierHash(e)];
  1403. };
  1404. function normalizeCommandKeys(callback, e, keyCode) {
  1405. var hashId = getModifierHash(e);
  1406. if (!useragent.isMac && pressedKeys) {
  1407. if (pressedKeys[91] || pressedKeys[92])
  1408. hashId |= 8;
  1409. if (pressedKeys.altGr) {
  1410. if ((3 & hashId) != 3)
  1411. pressedKeys.altGr = 0;
  1412. else
  1413. return;
  1414. }
  1415. if (keyCode === 18 || keyCode === 17) {
  1416. var location = "location" in e ? e.location : e.keyLocation;
  1417. if (keyCode === 17 && location === 1) {
  1418. ts = e.timeStamp;
  1419. } else if (keyCode === 18 && hashId === 3 && location === 2) {
  1420. var dt = -ts;
  1421. ts = e.timeStamp;
  1422. dt += ts;
  1423. if (dt < 3)
  1424. pressedKeys.altGr = true;
  1425. }
  1426. }
  1427. }
  1428. if (keyCode in keys.MODIFIER_KEYS) {
  1429. switch (keys.MODIFIER_KEYS[keyCode]) {
  1430. case "Alt":
  1431. hashId = 2;
  1432. break;
  1433. case "Shift":
  1434. hashId = 4;
  1435. break;
  1436. case "Ctrl":
  1437. hashId = 1;
  1438. break;
  1439. default:
  1440. hashId = 8;
  1441. break;
  1442. }
  1443. keyCode = -1;
  1444. }
  1445. if (hashId & 8 && (keyCode === 91 || keyCode === 93)) {
  1446. keyCode = -1;
  1447. }
  1448. if (!hashId && keyCode === 13) {
  1449. var location = "location" in e ? e.location : e.keyLocation;
  1450. if (location === 3) {
  1451. callback(e, hashId, -keyCode);
  1452. if (e.defaultPrevented)
  1453. return;
  1454. }
  1455. }
  1456. if (useragent.isChromeOS && hashId & 8) {
  1457. callback(e, hashId, keyCode);
  1458. if (e.defaultPrevented)
  1459. return;
  1460. else
  1461. hashId &= ~8;
  1462. }
  1463. if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
  1464. return false;
  1465. }
  1466. return callback(e, hashId, keyCode);
  1467. }
  1468. var pressedKeys = null;
  1469. var ts = 0;
  1470. exports.addCommandKeyListener = function(el, callback) {
  1471. var addListener = exports.addListener;
  1472. if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
  1473. var lastKeyDownKeyCode = null;
  1474. addListener(el, "keydown", function(e) {
  1475. lastKeyDownKeyCode = e.keyCode;
  1476. });
  1477. addListener(el, "keypress", function(e) {
  1478. return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
  1479. });
  1480. } else {
  1481. var lastDefaultPrevented = null;
  1482. addListener(el, "keydown", function(e) {
  1483. pressedKeys[e.keyCode] = true;
  1484. var result = normalizeCommandKeys(callback, e, e.keyCode);
  1485. lastDefaultPrevented = e.defaultPrevented;
  1486. return result;
  1487. });
  1488. addListener(el, "keypress", function(e) {
  1489. if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  1490. exports.stopEvent(e);
  1491. lastDefaultPrevented = null;
  1492. }
  1493. });
  1494. addListener(el, "keyup", function(e) {
  1495. pressedKeys[e.keyCode] = null;
  1496. });
  1497. if (!pressedKeys) {
  1498. pressedKeys = Object.create(null);
  1499. addListener(window, "focus", function(e) {
  1500. pressedKeys = Object.create(null);
  1501. });
  1502. }
  1503. }
  1504. };
  1505. if (window.postMessage && !useragent.isOldIE) {
  1506. var postMessageId = 1;
  1507. exports.nextTick = function(callback, win) {
  1508. win = win || window;
  1509. var messageName = "zero-timeout-message-" + postMessageId;
  1510. exports.addListener(win, "message", function listener(e) {
  1511. if (e.data == messageName) {
  1512. exports.stopPropagation(e);
  1513. exports.removeListener(win, "message", listener);
  1514. callback();
  1515. }
  1516. });
  1517. win.postMessage(messageName, "*");
  1518. };
  1519. }
  1520. exports.nextFrame = window.requestAnimationFrame ||
  1521. window.mozRequestAnimationFrame ||
  1522. window.webkitRequestAnimationFrame ||
  1523. window.msRequestAnimationFrame ||
  1524. window.oRequestAnimationFrame;
  1525. if (exports.nextFrame)
  1526. exports.nextFrame = exports.nextFrame.bind(window);
  1527. else
  1528. exports.nextFrame = function(callback) {
  1529. setTimeout(callback, 17);
  1530. };
  1531. });
  1532. ace.define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1533. "use strict";
  1534. exports.last = function(a) {
  1535. return a[a.length - 1];
  1536. };
  1537. exports.stringReverse = function(string) {
  1538. return string.split("").reverse().join("");
  1539. };
  1540. exports.stringRepeat = function (string, count) {
  1541. var result = '';
  1542. while (count > 0) {
  1543. if (count & 1)
  1544. result += string;
  1545. if (count >>= 1)
  1546. string += string;
  1547. }
  1548. return result;
  1549. };
  1550. var trimBeginRegexp = /^\s\s*/;
  1551. var trimEndRegexp = /\s\s*$/;
  1552. exports.stringTrimLeft = function (string) {
  1553. return string.replace(trimBeginRegexp, '');
  1554. };
  1555. exports.stringTrimRight = function (string) {
  1556. return string.replace(trimEndRegexp, '');
  1557. };
  1558. exports.copyObject = function(obj) {
  1559. var copy = {};
  1560. for (var key in obj) {
  1561. copy[key] = obj[key];
  1562. }
  1563. return copy;
  1564. };
  1565. exports.copyArray = function(array){
  1566. var copy = [];
  1567. for (var i=0, l=array.length; i<l; i++) {
  1568. if (array[i] && typeof array[i] == "object")
  1569. copy[i] = this.copyObject( array[i] );
  1570. else
  1571. copy[i] = array[i];
  1572. }
  1573. return copy;
  1574. };
  1575. exports.deepCopy = function (obj) {
  1576. if (typeof obj !== "object" || !obj)
  1577. return obj;
  1578. var cons = obj.constructor;
  1579. if (cons === RegExp)
  1580. return obj;
  1581. var copy = cons();
  1582. for (var key in obj) {
  1583. if (typeof obj[key] === "object") {
  1584. copy[key] = exports.deepCopy(obj[key]);
  1585. } else {
  1586. copy[key] = obj[key];
  1587. }
  1588. }
  1589. return copy;
  1590. };
  1591. exports.arrayToMap = function(arr) {
  1592. var map = {};
  1593. for (var i=0; i<arr.length; i++) {
  1594. map[arr[i]] = 1;
  1595. }
  1596. return map;
  1597. };
  1598. exports.createMap = function(props) {
  1599. var map = Object.create(null);
  1600. for (var i in props) {
  1601. map[i] = props[i];
  1602. }
  1603. return map;
  1604. };
  1605. exports.arrayRemove = function(array, value) {
  1606. for (var i = 0; i <= array.length; i++) {
  1607. if (value === array[i]) {
  1608. array.splice(i, 1);
  1609. }
  1610. }
  1611. };
  1612. exports.escapeRegExp = function(str) {
  1613. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1614. };
  1615. exports.escapeHTML = function(str) {
  1616. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1617. };
  1618. exports.getMatchOffsets = function(string, regExp) {
  1619. var matches = [];
  1620. string.replace(regExp, function(str) {
  1621. matches.push({
  1622. offset: arguments[arguments.length-2],
  1623. length: str.length
  1624. });
  1625. });
  1626. return matches;
  1627. };
  1628. exports.deferredCall = function(fcn) {
  1629. var timer = null;
  1630. var callback = function() {
  1631. timer = null;
  1632. fcn();
  1633. };
  1634. var deferred = function(timeout) {
  1635. deferred.cancel();
  1636. timer = setTimeout(callback, timeout || 0);
  1637. return deferred;
  1638. };
  1639. deferred.schedule = deferred;
  1640. deferred.call = function() {
  1641. this.cancel();
  1642. fcn();
  1643. return deferred;
  1644. };
  1645. deferred.cancel = function() {
  1646. clearTimeout(timer);
  1647. timer = null;
  1648. return deferred;
  1649. };
  1650. deferred.isPending = function() {
  1651. return timer;
  1652. };
  1653. return deferred;
  1654. };
  1655. exports.delayedCall = function(fcn, defaultTimeout) {
  1656. var timer = null;
  1657. var callback = function() {
  1658. timer = null;
  1659. fcn();
  1660. };
  1661. var _self = function(timeout) {
  1662. if (timer == null)
  1663. timer = setTimeout(callback, timeout || defaultTimeout);
  1664. };
  1665. _self.delay = function(timeout) {
  1666. timer && clearTimeout(timer);
  1667. timer = setTimeout(callback, timeout || defaultTimeout);
  1668. };
  1669. _self.schedule = _self;
  1670. _self.call = function() {
  1671. this.cancel();
  1672. fcn();
  1673. };
  1674. _self.cancel = function() {
  1675. timer && clearTimeout(timer);
  1676. timer = null;
  1677. };
  1678. _self.isPending = function() {
  1679. return timer;
  1680. };
  1681. return _self;
  1682. };
  1683. });
  1684. ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
  1685. "use strict";
  1686. var event = require("../lib/event");
  1687. var useragent = require("../lib/useragent");
  1688. var dom = require("../lib/dom");
  1689. var lang = require("../lib/lang");
  1690. var BROKEN_SETDATA = useragent.isChrome < 18;
  1691. var USE_IE_MIME_TYPE = useragent.isIE;
  1692. var TextInput = function(parentNode, host) {
  1693. var text = dom.createElement("textarea");
  1694. text.className = "ace_text-input";
  1695. if (useragent.isTouchPad)
  1696. text.setAttribute("x-palm-disable-auto-cap", true);
  1697. text.setAttribute("wrap", "off");
  1698. text.setAttribute("autocorrect", "off");
  1699. text.setAttribute("autocapitalize", "off");
  1700. text.setAttribute("spellcheck", false);
  1701. text.style.opacity = "0";
  1702. if (useragent.isOldIE) text.style.top = "-100px";
  1703. parentNode.insertBefore(text, parentNode.firstChild);
  1704. var PLACEHOLDER = "\x01\x01";
  1705. var copied = false;
  1706. var pasted = false;
  1707. var inComposition = false;
  1708. var tempStyle = '';
  1709. var isSelectionEmpty = true;
  1710. try { var isFocused = document.activeElement === text; } catch(e) {}
  1711. event.addListener(text, "blur", function(e) {
  1712. host.onBlur(e);
  1713. isFocused = false;
  1714. });
  1715. event.addListener(text, "focus", function(e) {
  1716. isFocused = true;
  1717. host.onFocus(e);
  1718. resetSelection();
  1719. });
  1720. this.focus = function() {
  1721. text.style.position = "fixed";
  1722. text.style.top = "-10000000px";
  1723. text.focus();
  1724. setTimeout(function() {
  1725. text.style.position = "";
  1726. }, 0);
  1727. };
  1728. this.blur = function() { text.blur(); };
  1729. this.isFocused = function() {
  1730. return isFocused;
  1731. };
  1732. var syncSelection = lang.delayedCall(function() {
  1733. isFocused && resetSelection(isSelectionEmpty);
  1734. });
  1735. var syncValue = lang.delayedCall(function() {
  1736. if (!inComposition) {
  1737. text.value = PLACEHOLDER;
  1738. isFocused && resetSelection();
  1739. }
  1740. });
  1741. function resetSelection(isEmpty) {
  1742. if (inComposition)
  1743. return;
  1744. if (inputHandler) {
  1745. selectionStart = 0;
  1746. selectionEnd = isEmpty ? 0 : text.value.length - 1;
  1747. } else {
  1748. var selectionStart = isEmpty ? 2 : 1;
  1749. var selectionEnd = 2;
  1750. }
  1751. try {
  1752. text.setSelectionRange(selectionStart, selectionEnd);
  1753. } catch(e){}
  1754. }
  1755. function resetValue() {
  1756. if (inComposition)
  1757. return;
  1758. text.value = PLACEHOLDER;
  1759. if (useragent.isWebKit)
  1760. syncValue.schedule();
  1761. }
  1762. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  1763. if (host.selection.isEmpty() != isSelectionEmpty) {
  1764. isSelectionEmpty = !isSelectionEmpty;
  1765. syncSelection.schedule();
  1766. }
  1767. });
  1768. resetValue();
  1769. if (isFocused)
  1770. host.onFocus();
  1771. var isAllSelected = function(text) {
  1772. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  1773. };
  1774. if (!text.setSelectionRange && text.createTextRange) {
  1775. text.setSelectionRange = function(selectionStart, selectionEnd) {
  1776. var range = this.createTextRange();
  1777. range.collapse(true);
  1778. range.moveStart('character', selectionStart);
  1779. range.moveEnd('character', selectionEnd);
  1780. range.select();
  1781. };
  1782. isAllSelected = function(text) {
  1783. try {
  1784. var range = text.ownerDocument.selection.createRange();
  1785. }catch(e) {}
  1786. if (!range || range.parentElement() != text) return false;
  1787. return range.text == text.value;
  1788. }
  1789. }
  1790. if (useragent.isOldIE) {
  1791. var inPropertyChange = false;
  1792. var onPropertyChange = function(e){
  1793. if (inPropertyChange)
  1794. return;
  1795. var data = text.value;
  1796. if (inComposition || !data || data == PLACEHOLDER)
  1797. return;
  1798. if (e && data == PLACEHOLDER[0])
  1799. return syncProperty.schedule();
  1800. sendText(data);
  1801. inPropertyChange = true;
  1802. resetValue();
  1803. inPropertyChange = false;
  1804. };
  1805. var syncProperty = lang.delayedCall(onPropertyChange);
  1806. event.addListener(text, "propertychange", onPropertyChange);
  1807. var keytable = { 13:1, 27:1 };
  1808. event.addListener(text, "keyup", function (e) {
  1809. if (inComposition && (!text.value || keytable[e.keyCode]))
  1810. setTimeout(onCompositionEnd, 0);
  1811. if ((text.value.charCodeAt(0)||0) < 129) {
  1812. return syncProperty.call();
  1813. }
  1814. inComposition ? onCompositionUpdate() : onCompositionStart();
  1815. });
  1816. event.addListener(text, "keydown", function (e) {
  1817. syncProperty.schedule(50);
  1818. });
  1819. }
  1820. var onSelect = function(e) {
  1821. if (copied) {
  1822. copied = false;
  1823. } else if (isAllSelected(text)) {
  1824. host.selectAll();
  1825. resetSelection();
  1826. } else if (inputHandler) {
  1827. resetSelection(host.selection.isEmpty());
  1828. }
  1829. };
  1830. var inputHandler = null;
  1831. this.setInputHandler = function(cb) {inputHandler = cb};
  1832. this.getInputHandler = function() {return inputHandler};
  1833. var afterContextMenu = false;
  1834. var sendText = function(data) {
  1835. if (inputHandler) {
  1836. data = inputHandler(data);
  1837. inputHandler = null;
  1838. }
  1839. if (pasted) {
  1840. resetSelection();
  1841. if (data)
  1842. host.onPaste(data);
  1843. pasted = false;
  1844. } else if (data == PLACEHOLDER.charAt(0)) {
  1845. if (afterContextMenu)
  1846. host.execCommand("del", {source: "ace"});
  1847. else // some versions of android do not fire keydown when pressing backspace
  1848. host.execCommand("backspace", {source: "ace"});
  1849. } else {
  1850. if (data.substring(0, 2) == PLACEHOLDER)
  1851. data = data.substr(2);
  1852. else if (data.charAt(0) == PLACEHOLDER.charAt(0))
  1853. data = data.substr(1);
  1854. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1855. data = data.slice(0, -1);
  1856. if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1857. data = data.slice(0, -1);
  1858. if (data)
  1859. host.onTextInput(data);
  1860. }
  1861. if (afterContextMenu)
  1862. afterContextMenu = false;
  1863. };
  1864. var onInput = function(e) {
  1865. if (inComposition)
  1866. return;
  1867. var data = text.value;
  1868. sendText(data);
  1869. resetValue();
  1870. };
  1871. var handleClipboardData = function(e, data) {
  1872. var clipboardData = e.clipboardData || window.clipboardData;
  1873. if (!clipboardData || BROKEN_SETDATA)
  1874. return;
  1875. var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
  1876. if (data) {
  1877. return clipboardData.setData(mime, data) !== false;
  1878. } else {
  1879. return clipboardData.getData(mime);
  1880. }
  1881. };
  1882. var doCopy = function(e, isCut) {
  1883. var data = host.getCopyText();
  1884. if (!data)
  1885. return event.preventDefault(e);
  1886. if (handleClipboardData(e, data)) {
  1887. isCut ? host.onCut() : host.onCopy();
  1888. event.preventDefault(e);
  1889. } else {
  1890. copied = true;
  1891. text.value = data;
  1892. text.select();
  1893. setTimeout(function(){
  1894. copied = false;
  1895. resetValue();
  1896. resetSelection();
  1897. isCut ? host.onCut() : host.onCopy();
  1898. });
  1899. }
  1900. };
  1901. var onCut = function(e) {
  1902. doCopy(e, true);
  1903. };
  1904. var onCopy = function(e) {
  1905. doCopy(e, false);
  1906. };
  1907. var onPaste = function(e) {
  1908. var data = handleClipboardData(e);
  1909. if (typeof data == "string") {
  1910. if (data)
  1911. host.onPaste(data);
  1912. if (useragent.isIE)
  1913. setTimeout(resetSelection);
  1914. event.preventDefault(e);
  1915. }
  1916. else {
  1917. text.value = "";
  1918. pasted = true;
  1919. }
  1920. };
  1921. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  1922. event.addListener(text, "select", onSelect);
  1923. event.addListener(text, "input", onInput);
  1924. event.addListener(text, "cut", onCut);
  1925. event.addListener(text, "copy", onCopy);
  1926. event.addListener(text, "paste", onPaste);
  1927. if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
  1928. event.addListener(parentNode, "keydown", function(e) {
  1929. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  1930. return;
  1931. switch (e.keyCode) {
  1932. case 67:
  1933. onCopy(e);
  1934. break;
  1935. case 86:
  1936. onPaste(e);
  1937. break;
  1938. case 88:
  1939. onCut(e);
  1940. break;
  1941. }
  1942. });
  1943. }
  1944. var onCompositionStart = function(e) {
  1945. if (inComposition || !host.onCompositionStart || host.$readOnly)
  1946. return;
  1947. inComposition = {};
  1948. host.onCompositionStart();
  1949. setTimeout(onCompositionUpdate, 0);
  1950. host.on("mousedown", onCompositionEnd);
  1951. if (!host.selection.isEmpty()) {
  1952. host.insert("");
  1953. host.session.markUndoGroup();
  1954. host.selection.clearSelection();
  1955. }
  1956. host.session.markUndoGroup();
  1957. };
  1958. var onCompositionUpdate = function() {
  1959. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  1960. return;
  1961. var val = text.value.replace(/\x01/g, "");
  1962. if (inComposition.lastValue === val) return;
  1963. host.onCompositionUpdate(val);
  1964. if (inComposition.lastValue)
  1965. host.undo();
  1966. inComposition.lastValue = val;
  1967. if (inComposition.lastValue) {
  1968. var r = host.selection.getRange();
  1969. host.insert(inComposition.lastValue);
  1970. host.session.markUndoGroup();
  1971. inComposition.range = host.selection.getRange();
  1972. host.selection.setRange(r);
  1973. host.selection.clearSelection();
  1974. }
  1975. };
  1976. var onCompositionEnd = function(e) {
  1977. if (!host.onCompositionEnd || host.$readOnly) return;
  1978. var c = inComposition;
  1979. inComposition = false;
  1980. var timer = setTimeout(function() {
  1981. timer = null;
  1982. var str = text.value.replace(/\x01/g, "");
  1983. if (inComposition)
  1984. return;
  1985. else if (str == c.lastValue)
  1986. resetValue();
  1987. else if (!c.lastValue && str) {
  1988. resetValue();
  1989. sendText(str);
  1990. }
  1991. });
  1992. inputHandler = function compositionInputHandler(str) {
  1993. if (timer)
  1994. clearTimeout(timer);
  1995. str = str.replace(/\x01/g, "");
  1996. if (str == c.lastValue)
  1997. return "";
  1998. if (c.lastValue && timer)
  1999. host.undo();
  2000. return str;
  2001. };
  2002. host.onCompositionEnd();
  2003. host.removeListener("mousedown", onCompositionEnd);
  2004. if (e.type == "compositionend" && c.range) {
  2005. host.selection.setRange(c.range);
  2006. }
  2007. };
  2008. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  2009. event.addListener(text, "compositionstart", onCompositionStart);
  2010. if (useragent.isGecko) {
  2011. event.addListener(text, "text", function(){syncComposition.schedule()});
  2012. } else {
  2013. event.addListener(text, "keyup", function(){syncComposition.schedule()});
  2014. event.addListener(text, "keydown", function(){syncComposition.schedule()});
  2015. }
  2016. event.addListener(text, "compositionend", onCompositionEnd);
  2017. this.getElement = function() {
  2018. return text;
  2019. };
  2020. this.setReadOnly = function(readOnly) {
  2021. text.readOnly = readOnly;
  2022. };
  2023. this.onContextMenu = function(e) {
  2024. afterContextMenu = true;
  2025. resetSelection(host.selection.isEmpty());
  2026. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2027. this.moveToMouse(e, true);
  2028. };
  2029. this.moveToMouse = function(e, bringToFront) {
  2030. if (!bringToFront && useragent.isOldIE)
  2031. return;
  2032. if (!tempStyle)
  2033. tempStyle = text.style.cssText;
  2034. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2035. + "height:" + text.style.height + ";"
  2036. + (useragent.isIE ? "opacity:0.1;" : "");
  2037. var rect = host.container.getBoundingClientRect();
  2038. var style = dom.computedStyle(host.container);
  2039. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2040. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2041. var maxTop = rect.bottom - top - text.clientHeight -2;
  2042. var move = function(e) {
  2043. text.style.left = e.clientX - left - 2 + "px";
  2044. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2045. };
  2046. move(e);
  2047. if (e.type != "mousedown")
  2048. return;
  2049. if (host.renderer.$keepTextAreaAtCursor)
  2050. host.renderer.$keepTextAreaAtCursor = null;
  2051. if (useragent.isWin && !useragent.isOldIE)
  2052. event.capture(host.container, move, onContextMenuClose);
  2053. };
  2054. this.onContextMenuClose = onContextMenuClose;
  2055. var closeTimeout;
  2056. function onContextMenuClose() {
  2057. clearTimeout(closeTimeout)
  2058. closeTimeout = setTimeout(function () {
  2059. if (tempStyle) {
  2060. text.style.cssText = tempStyle;
  2061. tempStyle = '';
  2062. }
  2063. if (host.renderer.$keepTextAreaAtCursor == null) {
  2064. host.renderer.$keepTextAreaAtCursor = true;
  2065. host.renderer.$moveTextAreaToCursor();
  2066. }
  2067. }, useragent.isOldIE ? 200 : 0);
  2068. }
  2069. var onContextMenu = function(e) {
  2070. host.textInput.onContextMenu(e);
  2071. onContextMenuClose();
  2072. };
  2073. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2074. event.addListener(text, "contextmenu", onContextMenu);
  2075. };
  2076. exports.TextInput = TextInput;
  2077. });
  2078. ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2079. "use strict";
  2080. var dom = require("../lib/dom");
  2081. var event = require("../lib/event");
  2082. var useragent = require("../lib/useragent");
  2083. var DRAG_OFFSET = 0; // pixels
  2084. function DefaultHandlers(mouseHandler) {
  2085. mouseHandler.$clickSelection = null;
  2086. var editor = mouseHandler.editor;
  2087. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  2088. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  2089. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  2090. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  2091. editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
  2092. var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
  2093. "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
  2094. exports.forEach(function(x) {
  2095. mouseHandler[x] = this[x];
  2096. }, this);
  2097. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  2098. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  2099. }
  2100. (function() {
  2101. this.onMouseDown = function(ev) {
  2102. var inSelection = ev.inSelection();
  2103. var pos = ev.getDocumentPosition();
  2104. this.mousedownEvent = ev;
  2105. var editor = this.editor;
  2106. var button = ev.getButton();
  2107. if (button !== 0) {
  2108. var selectionRange = editor.getSelectionRange();
  2109. var selectionEmpty = selectionRange.isEmpty();
  2110. editor.$blockScrolling++;
  2111. if (selectionEmpty)
  2112. editor.selection.moveToPosition(pos);
  2113. editor.$blockScrolling--;
  2114. editor.textInput.onContextMenu(ev.domEvent);
  2115. return; // stopping event here breaks contextmenu on ff mac
  2116. }
  2117. this.mousedownEvent.time = Date.now();
  2118. if (inSelection && !editor.isFocused()) {
  2119. editor.focus();
  2120. if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
  2121. this.setState("focusWait");
  2122. this.captureMouse(ev);
  2123. return;
  2124. }
  2125. }
  2126. this.captureMouse(ev);
  2127. this.startSelect(pos, ev.domEvent._clicks > 1);
  2128. return ev.preventDefault();
  2129. };
  2130. this.startSelect = function(pos, waitForClickSelection) {
  2131. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  2132. var editor = this.editor;
  2133. editor.$blockScrolling++;
  2134. if (this.mousedownEvent.getShiftKey())
  2135. editor.selection.selectToPosition(pos);
  2136. else if (!waitForClickSelection)
  2137. editor.selection.moveToPosition(pos);
  2138. if (!waitForClickSelection)
  2139. this.select();
  2140. if (editor.renderer.scroller.setCapture) {
  2141. editor.renderer.scroller.setCapture();
  2142. }
  2143. editor.setStyle("ace_selecting");
  2144. this.setState("select");
  2145. editor.$blockScrolling--;
  2146. };
  2147. this.select = function() {
  2148. var anchor, editor = this.editor;
  2149. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2150. editor.$blockScrolling++;
  2151. if (this.$clickSelection) {
  2152. var cmp = this.$clickSelection.comparePoint(cursor);
  2153. if (cmp == -1) {
  2154. anchor = this.$clickSelection.end;
  2155. } else if (cmp == 1) {
  2156. anchor = this.$clickSelection.start;
  2157. } else {
  2158. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2159. cursor = orientedRange.cursor;
  2160. anchor = orientedRange.anchor;
  2161. }
  2162. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2163. }
  2164. editor.selection.selectToPosition(cursor);
  2165. editor.$blockScrolling--;
  2166. editor.renderer.scrollCursorIntoView();
  2167. };
  2168. this.extendSelectionBy = function(unitName) {
  2169. var anchor, editor = this.editor;
  2170. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2171. var range = editor.selection[unitName](cursor.row, cursor.column);
  2172. editor.$blockScrolling++;
  2173. if (this.$clickSelection) {
  2174. var cmpStart = this.$clickSelection.comparePoint(range.start);
  2175. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  2176. if (cmpStart == -1 && cmpEnd <= 0) {
  2177. anchor = this.$clickSelection.end;
  2178. if (range.end.row != cursor.row || range.end.column != cursor.column)
  2179. cursor = range.start;
  2180. } else if (cmpEnd == 1 && cmpStart >= 0) {
  2181. anchor = this.$clickSelection.start;
  2182. if (range.start.row != cursor.row || range.start.column != cursor.column)
  2183. cursor = range.end;
  2184. } else if (cmpStart == -1 && cmpEnd == 1) {
  2185. cursor = range.end;
  2186. anchor = range.start;
  2187. } else {
  2188. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2189. cursor = orientedRange.cursor;
  2190. anchor = orientedRange.anchor;
  2191. }
  2192. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2193. }
  2194. editor.selection.selectToPosition(cursor);
  2195. editor.$blockScrolling--;
  2196. editor.renderer.scrollCursorIntoView();
  2197. };
  2198. this.selectEnd =
  2199. this.selectAllEnd =
  2200. this.selectByWordsEnd =
  2201. this.selectByLinesEnd = function() {
  2202. this.$clickSelection = null;
  2203. this.editor.unsetStyle("ace_selecting");
  2204. if (this.editor.renderer.scroller.releaseCapture) {
  2205. this.editor.renderer.scroller.releaseCapture();
  2206. }
  2207. };
  2208. this.focusWait = function() {
  2209. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2210. var time = Date.now();
  2211. if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
  2212. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2213. };
  2214. this.onDoubleClick = function(ev) {
  2215. var pos = ev.getDocumentPosition();
  2216. var editor = this.editor;
  2217. var session = editor.session;
  2218. var range = session.getBracketRange(pos);
  2219. if (range) {
  2220. if (range.isEmpty()) {
  2221. range.start.column--;
  2222. range.end.column++;
  2223. }
  2224. this.setState("select");
  2225. } else {
  2226. range = editor.selection.getWordRange(pos.row, pos.column);
  2227. this.setState("selectByWords");
  2228. }
  2229. this.$clickSelection = range;
  2230. this.select();
  2231. };
  2232. this.onTripleClick = function(ev) {
  2233. var pos = ev.getDocumentPosition();
  2234. var editor = this.editor;
  2235. this.setState("selectByLines");
  2236. var range = editor.getSelectionRange();
  2237. if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
  2238. this.$clickSelection = editor.selection.getLineRange(range.start.row);
  2239. this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
  2240. } else {
  2241. this.$clickSelection = editor.selection.getLineRange(pos.row);
  2242. }
  2243. this.select();
  2244. };
  2245. this.onQuadClick = function(ev) {
  2246. var editor = this.editor;
  2247. editor.selectAll();
  2248. this.$clickSelection = editor.getSelectionRange();
  2249. this.setState("selectAll");
  2250. };
  2251. this.onMouseWheel = function(ev) {
  2252. if (ev.getAccelKey())
  2253. return;
  2254. if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
  2255. ev.wheelX = ev.wheelY;
  2256. ev.wheelY = 0;
  2257. }
  2258. var t = ev.domEvent.timeStamp;
  2259. var dt = t - (this.$lastScrollTime||0);
  2260. var editor = this.editor;
  2261. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2262. if (isScrolable || dt < 200) {
  2263. this.$lastScrollTime = t;
  2264. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2265. return ev.stop();
  2266. }
  2267. };
  2268. }).call(DefaultHandlers.prototype);
  2269. exports.DefaultHandlers = DefaultHandlers;
  2270. function calcDistance(ax, ay, bx, by) {
  2271. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2272. }
  2273. function calcRangeOrientation(range, cursor) {
  2274. if (range.start.row == range.end.row)
  2275. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  2276. else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
  2277. var cmp = cursor.column - 4;
  2278. else
  2279. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  2280. if (cmp < 0)
  2281. return {cursor: range.start, anchor: range.end};
  2282. else
  2283. return {cursor: range.end, anchor: range.start};
  2284. }
  2285. });
  2286. ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
  2287. "use strict";
  2288. var oop = require("./lib/oop");
  2289. var dom = require("./lib/dom");
  2290. function Tooltip (parentNode) {
  2291. this.isOpen = false;
  2292. this.$element = null;
  2293. this.$parentNode = parentNode;
  2294. }
  2295. (function() {
  2296. this.$init = function() {
  2297. this.$element = dom.createElement("div");
  2298. this.$element.className = "ace_tooltip";
  2299. this.$element.style.display = "none";
  2300. this.$parentNode.appendChild(this.$element);
  2301. return this.$element;
  2302. };
  2303. this.getElement = function() {
  2304. return this.$element || this.$init();
  2305. };
  2306. this.setText = function(text) {
  2307. dom.setInnerText(this.getElement(), text);
  2308. };
  2309. this.setHtml = function(html) {
  2310. this.getElement().innerHTML = html;
  2311. };
  2312. this.setPosition = function(x, y) {
  2313. this.getElement().style.left = x + "px";
  2314. this.getElement().style.top = y + "px";
  2315. };
  2316. this.setClassName = function(className) {
  2317. dom.addCssClass(this.getElement(), className);
  2318. };
  2319. this.show = function(text, x, y) {
  2320. if (text != null)
  2321. this.setText(text);
  2322. if (x != null && y != null)
  2323. this.setPosition(x, y);
  2324. if (!this.isOpen) {
  2325. this.getElement().style.display = "block";
  2326. this.isOpen = true;
  2327. }
  2328. };
  2329. this.hide = function() {
  2330. if (this.isOpen) {
  2331. this.getElement().style.display = "none";
  2332. this.isOpen = false;
  2333. }
  2334. };
  2335. this.getHeight = function() {
  2336. return this.getElement().offsetHeight;
  2337. };
  2338. this.getWidth = function() {
  2339. return this.getElement().offsetWidth;
  2340. };
  2341. }).call(Tooltip.prototype);
  2342. exports.Tooltip = Tooltip;
  2343. });
  2344. ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"], function(require, exports, module) {
  2345. "use strict";
  2346. var dom = require("../lib/dom");
  2347. var oop = require("../lib/oop");
  2348. var event = require("../lib/event");
  2349. var Tooltip = require("../tooltip").Tooltip;
  2350. function GutterHandler(mouseHandler) {
  2351. var editor = mouseHandler.editor;
  2352. var gutter = editor.renderer.$gutterLayer;
  2353. var tooltip = new GutterTooltip(editor.container);
  2354. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  2355. if (!editor.isFocused() || e.getButton() != 0)
  2356. return;
  2357. var gutterRegion = gutter.getRegion(e);
  2358. if (gutterRegion == "foldWidgets")
  2359. return;
  2360. var row = e.getDocumentPosition().row;
  2361. var selection = editor.session.selection;
  2362. if (e.getShiftKey())
  2363. selection.selectTo(row, 0);
  2364. else {
  2365. if (e.domEvent.detail == 2) {
  2366. editor.selectAll();
  2367. return e.preventDefault();
  2368. }
  2369. mouseHandler.$clickSelection = editor.selection.getLineRange(row);
  2370. }
  2371. mouseHandler.setState("selectByLines");
  2372. mouseHandler.captureMouse(e);
  2373. return e.preventDefault();
  2374. });
  2375. var tooltipTimeout, mouseEvent, tooltipAnnotation;
  2376. function showTooltip() {
  2377. var row = mouseEvent.getDocumentPosition().row;
  2378. var annotation = gutter.$annotations[row];
  2379. if (!annotation)
  2380. return hideTooltip();
  2381. var maxRow = editor.session.getLength();
  2382. if (row == maxRow) {
  2383. var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
  2384. var pos = mouseEvent.$pos;
  2385. if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
  2386. return hideTooltip();
  2387. }
  2388. if (tooltipAnnotation == annotation)
  2389. return;
  2390. tooltipAnnotation = annotation.text.join("<br/>");
  2391. tooltip.setHtml(tooltipAnnotation);
  2392. tooltip.show();
  2393. editor.on("mousewheel", hideTooltip);
  2394. if (mouseHandler.$tooltipFollowsMouse) {
  2395. moveTooltip(mouseEvent);
  2396. } else {
  2397. var gutterElement = gutter.$cells[editor.session.documentToScreenRow(row, 0)].element;
  2398. var rect = gutterElement.getBoundingClientRect();
  2399. var style = tooltip.getElement().style;
  2400. style.left = rect.right + "px";
  2401. style.top = rect.bottom + "px";
  2402. }
  2403. }
  2404. function hideTooltip() {
  2405. if (tooltipTimeout)
  2406. tooltipTimeout = clearTimeout(tooltipTimeout);
  2407. if (tooltipAnnotation) {
  2408. tooltip.hide();
  2409. tooltipAnnotation = null;
  2410. editor.removeEventListener("mousewheel", hideTooltip);
  2411. }
  2412. }
  2413. function moveTooltip(e) {
  2414. tooltip.setPosition(e.x, e.y);
  2415. }
  2416. mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
  2417. var target = e.domEvent.target || e.domEvent.srcElement;
  2418. if (dom.hasCssClass(target, "ace_fold-widget"))
  2419. return hideTooltip();
  2420. if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
  2421. moveTooltip(e);
  2422. mouseEvent = e;
  2423. if (tooltipTimeout)
  2424. return;
  2425. tooltipTimeout = setTimeout(function() {
  2426. tooltipTimeout = null;
  2427. if (mouseEvent && !mouseHandler.isMousePressed)
  2428. showTooltip();
  2429. else
  2430. hideTooltip();
  2431. }, 50);
  2432. });
  2433. event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
  2434. mouseEvent = null;
  2435. if (!tooltipAnnotation || tooltipTimeout)
  2436. return;
  2437. tooltipTimeout = setTimeout(function() {
  2438. tooltipTimeout = null;
  2439. hideTooltip();
  2440. }, 50);
  2441. });
  2442. editor.on("changeSession", hideTooltip);
  2443. }
  2444. function GutterTooltip(parentNode) {
  2445. Tooltip.call(this, parentNode);
  2446. }
  2447. oop.inherits(GutterTooltip, Tooltip);
  2448. (function(){
  2449. this.setPosition = function(x, y) {
  2450. var windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2451. var windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2452. var width = this.getWidth();
  2453. var height = this.getHeight();
  2454. x += 15;
  2455. y += 15;
  2456. if (x + width > windowWidth) {
  2457. x -= (x + width) - windowWidth;
  2458. }
  2459. if (y + height > windowHeight) {
  2460. y -= 20 + height;
  2461. }
  2462. Tooltip.prototype.setPosition.call(this, x, y);
  2463. };
  2464. }).call(GutterTooltip.prototype);
  2465. exports.GutterHandler = GutterHandler;
  2466. });
  2467. ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2468. "use strict";
  2469. var event = require("../lib/event");
  2470. var useragent = require("../lib/useragent");
  2471. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  2472. this.domEvent = domEvent;
  2473. this.editor = editor;
  2474. this.x = this.clientX = domEvent.clientX;
  2475. this.y = this.clientY = domEvent.clientY;
  2476. this.$pos = null;
  2477. this.$inSelection = null;
  2478. this.propagationStopped = false;
  2479. this.defaultPrevented = false;
  2480. };
  2481. (function() {
  2482. this.stopPropagation = function() {
  2483. event.stopPropagation(this.domEvent);
  2484. this.propagationStopped = true;
  2485. };
  2486. this.preventDefault = function() {
  2487. event.preventDefault(this.domEvent);
  2488. this.defaultPrevented = true;
  2489. };
  2490. this.stop = function() {
  2491. this.stopPropagation();
  2492. this.preventDefault();
  2493. };
  2494. this.getDocumentPosition = function() {
  2495. if (this.$pos)
  2496. return this.$pos;
  2497. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  2498. return this.$pos;
  2499. };
  2500. this.inSelection = function() {
  2501. if (this.$inSelection !== null)
  2502. return this.$inSelection;
  2503. var editor = this.editor;
  2504. var selectionRange = editor.getSelectionRange();
  2505. if (selectionRange.isEmpty())
  2506. this.$inSelection = false;
  2507. else {
  2508. var pos = this.getDocumentPosition();
  2509. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  2510. }
  2511. return this.$inSelection;
  2512. };
  2513. this.getButton = function() {
  2514. return event.getButton(this.domEvent);
  2515. };
  2516. this.getShiftKey = function() {
  2517. return this.domEvent.shiftKey;
  2518. };
  2519. this.getAccelKey = useragent.isMac
  2520. ? function() { return this.domEvent.metaKey; }
  2521. : function() { return this.domEvent.ctrlKey; };
  2522. }).call(MouseEvent.prototype);
  2523. });
  2524. ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2525. "use strict";
  2526. var dom = require("../lib/dom");
  2527. var event = require("../lib/event");
  2528. var useragent = require("../lib/useragent");
  2529. var AUTOSCROLL_DELAY = 200;
  2530. var SCROLL_CURSOR_DELAY = 200;
  2531. var SCROLL_CURSOR_HYSTERESIS = 5;
  2532. function DragdropHandler(mouseHandler) {
  2533. var editor = mouseHandler.editor;
  2534. var blankImage = dom.createElement("img");
  2535. blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  2536. if (useragent.isOpera)
  2537. blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
  2538. var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
  2539. exports.forEach(function(x) {
  2540. mouseHandler[x] = this[x];
  2541. }, this);
  2542. editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
  2543. var mouseTarget = editor.container;
  2544. var dragSelectionMarker, x, y;
  2545. var timerId, range;
  2546. var dragCursor, counter = 0;
  2547. var dragOperation;
  2548. var isInternal;
  2549. var autoScrollStartTime;
  2550. var cursorMovedTime;
  2551. var cursorPointOnCaretMoved;
  2552. this.onDragStart = function(e) {
  2553. if (this.cancelDrag || !mouseTarget.draggable) {
  2554. var self = this;
  2555. setTimeout(function(){
  2556. self.startSelect();
  2557. self.captureMouse(e);
  2558. }, 0);
  2559. return e.preventDefault();
  2560. }
  2561. range = editor.getSelectionRange();
  2562. var dataTransfer = e.dataTransfer;
  2563. dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
  2564. if (useragent.isOpera) {
  2565. editor.container.appendChild(blankImage);
  2566. blankImage.scrollTop = 0;
  2567. }
  2568. dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
  2569. if (useragent.isOpera) {
  2570. editor.container.removeChild(blankImage);
  2571. }
  2572. dataTransfer.clearData();
  2573. dataTransfer.setData("Text", editor.session.getTextRange());
  2574. isInternal = true;
  2575. this.setState("drag");
  2576. };
  2577. this.onDragEnd = function(e) {
  2578. mouseTarget.draggable = false;
  2579. isInternal = false;
  2580. this.setState(null);
  2581. if (!editor.getReadOnly()) {
  2582. var dropEffect = e.dataTransfer.dropEffect;
  2583. if (!dragOperation && dropEffect == "move")
  2584. editor.session.remove(editor.getSelectionRange());
  2585. editor.renderer.$cursorLayer.setBlinking(true);
  2586. }
  2587. this.editor.unsetStyle("ace_dragging");
  2588. this.editor.renderer.setCursorStyle("");
  2589. };
  2590. this.onDragEnter = function(e) {
  2591. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2592. return;
  2593. x = e.clientX;
  2594. y = e.clientY;
  2595. if (!dragSelectionMarker)
  2596. addDragMarker();
  2597. counter++;
  2598. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2599. return event.preventDefault(e);
  2600. };
  2601. this.onDragOver = function(e) {
  2602. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2603. return;
  2604. x = e.clientX;
  2605. y = e.clientY;
  2606. if (!dragSelectionMarker) {
  2607. addDragMarker();
  2608. counter++;
  2609. }
  2610. if (onMouseMoveTimer !== null)
  2611. onMouseMoveTimer = null;
  2612. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2613. return event.preventDefault(e);
  2614. };
  2615. this.onDragLeave = function(e) {
  2616. counter--;
  2617. if (counter <= 0 && dragSelectionMarker) {
  2618. clearDragMarker();
  2619. dragOperation = null;
  2620. return event.preventDefault(e);
  2621. }
  2622. };
  2623. this.onDrop = function(e) {
  2624. if (!dragCursor)
  2625. return;
  2626. var dataTransfer = e.dataTransfer;
  2627. if (isInternal) {
  2628. switch (dragOperation) {
  2629. case "move":
  2630. if (range.contains(dragCursor.row, dragCursor.column)) {
  2631. range = {
  2632. start: dragCursor,
  2633. end: dragCursor
  2634. };
  2635. } else {
  2636. range = editor.moveText(range, dragCursor);
  2637. }
  2638. break;
  2639. case "copy":
  2640. range = editor.moveText(range, dragCursor, true);
  2641. break;
  2642. }
  2643. } else {
  2644. var dropData = dataTransfer.getData('Text');
  2645. range = {
  2646. start: dragCursor,
  2647. end: editor.session.insert(dragCursor, dropData)
  2648. };
  2649. editor.focus();
  2650. dragOperation = null;
  2651. }
  2652. clearDragMarker();
  2653. return event.preventDefault(e);
  2654. };
  2655. event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
  2656. event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
  2657. event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
  2658. event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
  2659. event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
  2660. event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
  2661. function scrollCursorIntoView(cursor, prevCursor) {
  2662. var now = Date.now();
  2663. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2664. var hMovement = !prevCursor || cursor.column != prevCursor.column;
  2665. if (!cursorMovedTime || vMovement || hMovement) {
  2666. editor.$blockScrolling += 1;
  2667. editor.moveCursorToPosition(cursor);
  2668. editor.$blockScrolling -= 1;
  2669. cursorMovedTime = now;
  2670. cursorPointOnCaretMoved = {x: x, y: y};
  2671. } else {
  2672. var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
  2673. if (distance > SCROLL_CURSOR_HYSTERESIS) {
  2674. cursorMovedTime = null;
  2675. } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
  2676. editor.renderer.scrollCursorIntoView();
  2677. cursorMovedTime = null;
  2678. }
  2679. }
  2680. }
  2681. function autoScroll(cursor, prevCursor) {
  2682. var now = Date.now();
  2683. var lineHeight = editor.renderer.layerConfig.lineHeight;
  2684. var characterWidth = editor.renderer.layerConfig.characterWidth;
  2685. var editorRect = editor.renderer.scroller.getBoundingClientRect();
  2686. var offsets = {
  2687. x: {
  2688. left: x - editorRect.left,
  2689. right: editorRect.right - x
  2690. },
  2691. y: {
  2692. top: y - editorRect.top,
  2693. bottom: editorRect.bottom - y
  2694. }
  2695. };
  2696. var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
  2697. var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
  2698. var scrollCursor = {row: cursor.row, column: cursor.column};
  2699. if (nearestXOffset / characterWidth <= 2) {
  2700. scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
  2701. }
  2702. if (nearestYOffset / lineHeight <= 1) {
  2703. scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
  2704. }
  2705. var vScroll = cursor.row != scrollCursor.row;
  2706. var hScroll = cursor.column != scrollCursor.column;
  2707. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2708. if (vScroll || (hScroll && !vMovement)) {
  2709. if (!autoScrollStartTime)
  2710. autoScrollStartTime = now;
  2711. else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
  2712. editor.renderer.scrollCursorIntoView(scrollCursor);
  2713. } else {
  2714. autoScrollStartTime = null;
  2715. }
  2716. }
  2717. function onDragInterval() {
  2718. var prevCursor = dragCursor;
  2719. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  2720. scrollCursorIntoView(dragCursor, prevCursor);
  2721. autoScroll(dragCursor, prevCursor);
  2722. }
  2723. function addDragMarker() {
  2724. range = editor.selection.toOrientedRange();
  2725. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
  2726. editor.clearSelection();
  2727. if (editor.isFocused())
  2728. editor.renderer.$cursorLayer.setBlinking(false);
  2729. clearInterval(timerId);
  2730. onDragInterval();
  2731. timerId = setInterval(onDragInterval, 20);
  2732. counter = 0;
  2733. event.addListener(document, "mousemove", onMouseMove);
  2734. }
  2735. function clearDragMarker() {
  2736. clearInterval(timerId);
  2737. editor.session.removeMarker(dragSelectionMarker);
  2738. dragSelectionMarker = null;
  2739. editor.$blockScrolling += 1;
  2740. editor.selection.fromOrientedRange(range);
  2741. editor.$blockScrolling -= 1;
  2742. if (editor.isFocused() && !isInternal)
  2743. editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
  2744. range = null;
  2745. dragCursor = null;
  2746. counter = 0;
  2747. autoScrollStartTime = null;
  2748. cursorMovedTime = null;
  2749. event.removeListener(document, "mousemove", onMouseMove);
  2750. }
  2751. var onMouseMoveTimer = null;
  2752. function onMouseMove() {
  2753. if (onMouseMoveTimer == null) {
  2754. onMouseMoveTimer = setTimeout(function() {
  2755. if (onMouseMoveTimer != null && dragSelectionMarker)
  2756. clearDragMarker();
  2757. }, 20);
  2758. }
  2759. }
  2760. function canAccept(dataTransfer) {
  2761. var types = dataTransfer.types;
  2762. return !types || Array.prototype.some.call(types, function(type) {
  2763. return type == 'text/plain' || type == 'Text';
  2764. });
  2765. }
  2766. function getDropEffect(e) {
  2767. var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
  2768. var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
  2769. var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
  2770. var effectAllowed = "uninitialized";
  2771. try {
  2772. effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
  2773. } catch (e) {}
  2774. var dropEffect = "none";
  2775. if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
  2776. dropEffect = "copy";
  2777. else if (moveAllowed.indexOf(effectAllowed) >= 0)
  2778. dropEffect = "move";
  2779. else if (copyAllowed.indexOf(effectAllowed) >= 0)
  2780. dropEffect = "copy";
  2781. return dropEffect;
  2782. }
  2783. }
  2784. (function() {
  2785. this.dragWait = function() {
  2786. var interval = Date.now() - this.mousedownEvent.time;
  2787. if (interval > this.editor.getDragDelay())
  2788. this.startDrag();
  2789. };
  2790. this.dragWaitEnd = function() {
  2791. var target = this.editor.container;
  2792. target.draggable = false;
  2793. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2794. this.selectEnd();
  2795. };
  2796. this.dragReadyEnd = function(e) {
  2797. this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
  2798. this.editor.unsetStyle("ace_dragging");
  2799. this.editor.renderer.setCursorStyle("");
  2800. this.dragWaitEnd();
  2801. };
  2802. this.startDrag = function(){
  2803. this.cancelDrag = false;
  2804. var editor = this.editor;
  2805. var target = editor.container;
  2806. target.draggable = true;
  2807. editor.renderer.$cursorLayer.setBlinking(false);
  2808. editor.setStyle("ace_dragging");
  2809. var cursorStyle = useragent.isWin ? "default" : "move";
  2810. editor.renderer.setCursorStyle(cursorStyle);
  2811. this.setState("dragReady");
  2812. };
  2813. this.onMouseDrag = function(e) {
  2814. var target = this.editor.container;
  2815. if (useragent.isIE && this.state == "dragReady") {
  2816. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2817. if (distance > 3)
  2818. target.dragDrop();
  2819. }
  2820. if (this.state === "dragWait") {
  2821. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2822. if (distance > 0) {
  2823. target.draggable = false;
  2824. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2825. }
  2826. }
  2827. };
  2828. this.onMouseDown = function(e) {
  2829. if (!this.$dragEnabled)
  2830. return;
  2831. this.mousedownEvent = e;
  2832. var editor = this.editor;
  2833. var inSelection = e.inSelection();
  2834. var button = e.getButton();
  2835. var clickCount = e.domEvent.detail || 1;
  2836. if (clickCount === 1 && button === 0 && inSelection) {
  2837. if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
  2838. return;
  2839. this.mousedownEvent.time = Date.now();
  2840. var eventTarget = e.domEvent.target || e.domEvent.srcElement;
  2841. if ("unselectable" in eventTarget)
  2842. eventTarget.unselectable = "on";
  2843. if (editor.getDragDelay()) {
  2844. if (useragent.isWebKit) {
  2845. this.cancelDrag = true;
  2846. var mouseTarget = editor.container;
  2847. mouseTarget.draggable = true;
  2848. }
  2849. this.setState("dragWait");
  2850. } else {
  2851. this.startDrag();
  2852. }
  2853. this.captureMouse(e, this.onMouseDrag.bind(this));
  2854. e.defaultPrevented = true;
  2855. }
  2856. };
  2857. }).call(DragdropHandler.prototype);
  2858. function calcDistance(ax, ay, bx, by) {
  2859. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2860. }
  2861. exports.DragdropHandler = DragdropHandler;
  2862. });
  2863. ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  2864. "use strict";
  2865. var dom = require("./dom");
  2866. exports.get = function (url, callback) {
  2867. var xhr = new XMLHttpRequest();
  2868. xhr.open('GET', url, true);
  2869. xhr.onreadystatechange = function () {
  2870. if (xhr.readyState === 4) {
  2871. callback(xhr.responseText);
  2872. }
  2873. };
  2874. xhr.send(null);
  2875. };
  2876. exports.loadScript = function(path, callback) {
  2877. var head = dom.getDocumentHead();
  2878. var s = document.createElement('script');
  2879. s.src = path;
  2880. head.appendChild(s);
  2881. s.onload = s.onreadystatechange = function(_, isAbort) {
  2882. if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
  2883. s = s.onload = s.onreadystatechange = null;
  2884. if (!isAbort)
  2885. callback();
  2886. }
  2887. };
  2888. };
  2889. exports.qualifyURL = function(url) {
  2890. var a = document.createElement('a');
  2891. a.href = url;
  2892. return a.href;
  2893. }
  2894. });
  2895. ace.define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  2896. "use strict";
  2897. var EventEmitter = {};
  2898. var stopPropagation = function() { this.propagationStopped = true; };
  2899. var preventDefault = function() { this.defaultPrevented = true; };
  2900. EventEmitter._emit =
  2901. EventEmitter._dispatchEvent = function(eventName, e) {
  2902. this._eventRegistry || (this._eventRegistry = {});
  2903. this._defaultHandlers || (this._defaultHandlers = {});
  2904. var listeners = this._eventRegistry[eventName] || [];
  2905. var defaultHandler = this._defaultHandlers[eventName];
  2906. if (!listeners.length && !defaultHandler)
  2907. return;
  2908. if (typeof e != "object" || !e)
  2909. e = {};
  2910. if (!e.type)
  2911. e.type = eventName;
  2912. if (!e.stopPropagation)
  2913. e.stopPropagation = stopPropagation;
  2914. if (!e.preventDefault)
  2915. e.preventDefault = preventDefault;
  2916. listeners = listeners.slice();
  2917. for (var i=0; i<listeners.length; i++) {
  2918. listeners[i](e, this);
  2919. if (e.propagationStopped)
  2920. break;
  2921. }
  2922. if (defaultHandler && !e.defaultPrevented)
  2923. return defaultHandler(e, this);
  2924. };
  2925. EventEmitter._signal = function(eventName, e) {
  2926. var listeners = (this._eventRegistry || {})[eventName];
  2927. if (!listeners)
  2928. return;
  2929. listeners = listeners.slice();
  2930. for (var i=0; i<listeners.length; i++)
  2931. listeners[i](e, this);
  2932. };
  2933. EventEmitter.once = function(eventName, callback) {
  2934. var _self = this;
  2935. callback && this.addEventListener(eventName, function newCallback() {
  2936. _self.removeEventListener(eventName, newCallback);
  2937. callback.apply(null, arguments);
  2938. });
  2939. };
  2940. EventEmitter.setDefaultHandler = function(eventName, callback) {
  2941. var handlers = this._defaultHandlers
  2942. if (!handlers)
  2943. handlers = this._defaultHandlers = {_disabled_: {}};
  2944. if (handlers[eventName]) {
  2945. var old = handlers[eventName];
  2946. var disabled = handlers._disabled_[eventName];
  2947. if (!disabled)
  2948. handlers._disabled_[eventName] = disabled = [];
  2949. disabled.push(old);
  2950. var i = disabled.indexOf(callback);
  2951. if (i != -1)
  2952. disabled.splice(i, 1);
  2953. }
  2954. handlers[eventName] = callback;
  2955. };
  2956. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  2957. var handlers = this._defaultHandlers
  2958. if (!handlers)
  2959. return;
  2960. var disabled = handlers._disabled_[eventName];
  2961. if (handlers[eventName] == callback) {
  2962. var old = handlers[eventName];
  2963. if (disabled)
  2964. this.setDefaultHandler(eventName, disabled.pop());
  2965. } else if (disabled) {
  2966. var i = disabled.indexOf(callback);
  2967. if (i != -1)
  2968. disabled.splice(i, 1);
  2969. }
  2970. };
  2971. EventEmitter.on =
  2972. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  2973. this._eventRegistry = this._eventRegistry || {};
  2974. var listeners = this._eventRegistry[eventName];
  2975. if (!listeners)
  2976. listeners = this._eventRegistry[eventName] = [];
  2977. if (listeners.indexOf(callback) == -1)
  2978. listeners[capturing ? "unshift" : "push"](callback);
  2979. return callback;
  2980. };
  2981. EventEmitter.off =
  2982. EventEmitter.removeListener =
  2983. EventEmitter.removeEventListener = function(eventName, callback) {
  2984. this._eventRegistry = this._eventRegistry || {};
  2985. var listeners = this._eventRegistry[eventName];
  2986. if (!listeners)
  2987. return;
  2988. var index = listeners.indexOf(callback);
  2989. if (index !== -1)
  2990. listeners.splice(index, 1);
  2991. };
  2992. EventEmitter.removeAllListeners = function(eventName) {
  2993. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  2994. };
  2995. exports.EventEmitter = EventEmitter;
  2996. });
  2997. ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  2998. "no use strict";
  2999. var oop = require("./oop");
  3000. var EventEmitter = require("./event_emitter").EventEmitter;
  3001. var optionsProvider = {
  3002. setOptions: function(optList) {
  3003. Object.keys(optList).forEach(function(key) {
  3004. this.setOption(key, optList[key]);
  3005. }, this);
  3006. },
  3007. getOptions: function(optionNames) {
  3008. var result = {};
  3009. if (!optionNames) {
  3010. optionNames = Object.keys(this.$options);
  3011. } else if (!Array.isArray(optionNames)) {
  3012. result = optionNames;
  3013. optionNames = Object.keys(result);
  3014. }
  3015. optionNames.forEach(function(key) {
  3016. result[key] = this.getOption(key);
  3017. }, this);
  3018. return result;
  3019. },
  3020. setOption: function(name, value) {
  3021. if (this["$" + name] === value)
  3022. return;
  3023. var opt = this.$options[name];
  3024. if (!opt) {
  3025. return warn('misspelled option "' + name + '"');
  3026. }
  3027. if (opt.forwardTo)
  3028. return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
  3029. if (!opt.handlesSet)
  3030. this["$" + name] = value;
  3031. if (opt && opt.set)
  3032. opt.set.call(this, value);
  3033. },
  3034. getOption: function(name) {
  3035. var opt = this.$options[name];
  3036. if (!opt) {
  3037. return warn('misspelled option "' + name + '"');
  3038. }
  3039. if (opt.forwardTo)
  3040. return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
  3041. return opt && opt.get ? opt.get.call(this) : this["$" + name];
  3042. }
  3043. };
  3044. function warn(message) {
  3045. if (typeof console != "undefined" && console.warn)
  3046. console.warn.apply(console, arguments);
  3047. }
  3048. function reportError(msg, data) {
  3049. var e = new Error(msg);
  3050. e.data = data;
  3051. if (typeof console == "object" && console.error)
  3052. console.error(e);
  3053. setTimeout(function() { throw e; });
  3054. }
  3055. var AppConfig = function() {
  3056. this.$defaultOptions = {};
  3057. };
  3058. (function() {
  3059. oop.implement(this, EventEmitter);
  3060. this.defineOptions = function(obj, path, options) {
  3061. if (!obj.$options)
  3062. this.$defaultOptions[path] = obj.$options = {};
  3063. Object.keys(options).forEach(function(key) {
  3064. var opt = options[key];
  3065. if (typeof opt == "string")
  3066. opt = {forwardTo: opt};
  3067. opt.name || (opt.name = key);
  3068. obj.$options[opt.name] = opt;
  3069. if ("initialValue" in opt)
  3070. obj["$" + opt.name] = opt.initialValue;
  3071. });
  3072. oop.implement(obj, optionsProvider);
  3073. return this;
  3074. };
  3075. this.resetOptions = function(obj) {
  3076. Object.keys(obj.$options).forEach(function(key) {
  3077. var opt = obj.$options[key];
  3078. if ("value" in opt)
  3079. obj.setOption(key, opt.value);
  3080. });
  3081. };
  3082. this.setDefaultValue = function(path, name, value) {
  3083. var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
  3084. if (opts[name]) {
  3085. if (opts.forwardTo)
  3086. this.setDefaultValue(opts.forwardTo, name, value);
  3087. else
  3088. opts[name].value = value;
  3089. }
  3090. };
  3091. this.setDefaultValues = function(path, optionHash) {
  3092. Object.keys(optionHash).forEach(function(key) {
  3093. this.setDefaultValue(path, key, optionHash[key]);
  3094. }, this);
  3095. };
  3096. this.warn = warn;
  3097. this.reportError = reportError;
  3098. }).call(AppConfig.prototype);
  3099. exports.AppConfig = AppConfig;
  3100. });
  3101. ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) {
  3102. "no use strict";
  3103. var lang = require("./lib/lang");
  3104. var oop = require("./lib/oop");
  3105. var net = require("./lib/net");
  3106. var AppConfig = require("./lib/app_config").AppConfig;
  3107. module.exports = exports = new AppConfig();
  3108. var global = (function() {
  3109. return this;
  3110. })();
  3111. var options = {
  3112. packaged: false,
  3113. workerPath: null,
  3114. modePath: null,
  3115. themePath: null,
  3116. basePath: "",
  3117. suffix: ".js",
  3118. $moduleUrls: {}
  3119. };
  3120. exports.get = function(key) {
  3121. if (!options.hasOwnProperty(key))
  3122. throw new Error("Unknown config key: " + key);
  3123. return options[key];
  3124. };
  3125. exports.set = function(key, value) {
  3126. if (!options.hasOwnProperty(key))
  3127. throw new Error("Unknown config key: " + key);
  3128. options[key] = value;
  3129. };
  3130. exports.all = function() {
  3131. return lang.copyObject(options);
  3132. };
  3133. exports.moduleUrl = function(name, component) {
  3134. if (options.$moduleUrls[name])
  3135. return options.$moduleUrls[name];
  3136. var parts = name.split("/");
  3137. component = component || parts[parts.length - 2] || "";
  3138. var sep = component == "snippets" ? "/" : "-";
  3139. var base = parts[parts.length - 1];
  3140. if (component == "worker" && sep == "-") {
  3141. var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
  3142. base = base.replace(re, "");
  3143. }
  3144. if ((!base || base == component) && parts.length > 1)
  3145. base = parts[parts.length - 2];
  3146. var path = options[component + "Path"];
  3147. if (path == null) {
  3148. path = options.basePath;
  3149. } else if (sep == "/") {
  3150. component = sep = "";
  3151. }
  3152. if (path && path.slice(-1) != "/")
  3153. path += "/";
  3154. return path + component + sep + base + this.get("suffix");
  3155. };
  3156. exports.setModuleUrl = function(name, subst) {
  3157. return options.$moduleUrls[name] = subst;
  3158. };
  3159. exports.$loading = {};
  3160. exports.loadModule = function(moduleName, onLoad) {
  3161. var module, moduleType;
  3162. if (Array.isArray(moduleName)) {
  3163. moduleType = moduleName[0];
  3164. moduleName = moduleName[1];
  3165. }
  3166. try {
  3167. module = require(moduleName);
  3168. } catch (e) {}
  3169. if (module && !exports.$loading[moduleName])
  3170. return onLoad && onLoad(module);
  3171. if (!exports.$loading[moduleName])
  3172. exports.$loading[moduleName] = [];
  3173. exports.$loading[moduleName].push(onLoad);
  3174. if (exports.$loading[moduleName].length > 1)
  3175. return;
  3176. var afterLoad = function() {
  3177. require([moduleName], function(module) {
  3178. exports._emit("load.module", {name: moduleName, module: module});
  3179. var listeners = exports.$loading[moduleName];
  3180. exports.$loading[moduleName] = null;
  3181. listeners.forEach(function(onLoad) {
  3182. onLoad && onLoad(module);
  3183. });
  3184. });
  3185. };
  3186. if (!exports.get("packaged"))
  3187. return afterLoad();
  3188. net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
  3189. };
  3190. init(true);function init(packaged) {
  3191. options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
  3192. if (!global.document)
  3193. return "";
  3194. var scriptOptions = {};
  3195. var scriptUrl = "";
  3196. var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
  3197. var currentDocument = currentScript && currentScript.ownerDocument || document;
  3198. var scripts = currentDocument.getElementsByTagName("script");
  3199. for (var i=0; i<scripts.length; i++) {
  3200. var script = scripts[i];
  3201. var src = script.src || script.getAttribute("src");
  3202. if (!src)
  3203. continue;
  3204. var attributes = script.attributes;
  3205. for (var j=0, l=attributes.length; j < l; j++) {
  3206. var attr = attributes[j];
  3207. if (attr.name.indexOf("data-ace-") === 0) {
  3208. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  3209. }
  3210. }
  3211. var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
  3212. if (m)
  3213. scriptUrl = m[1];
  3214. }
  3215. if (scriptUrl) {
  3216. scriptOptions.base = scriptOptions.base || scriptUrl;
  3217. scriptOptions.packaged = true;
  3218. }
  3219. scriptOptions.basePath = scriptOptions.base;
  3220. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  3221. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  3222. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  3223. delete scriptOptions.base;
  3224. for (var key in scriptOptions)
  3225. if (typeof scriptOptions[key] !== "undefined")
  3226. exports.set(key, scriptOptions[key]);
  3227. };
  3228. exports.init = init;
  3229. function deHyphenate(str) {
  3230. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  3231. }
  3232. });
  3233. ace.define("ace/mouse/mouse_handler",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/mouse/default_handlers","ace/mouse/default_gutter_handler","ace/mouse/mouse_event","ace/mouse/dragdrop_handler","ace/config"], function(require, exports, module) {
  3234. "use strict";
  3235. var event = require("../lib/event");
  3236. var useragent = require("../lib/useragent");
  3237. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3238. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3239. var MouseEvent = require("./mouse_event").MouseEvent;
  3240. var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
  3241. var config = require("../config");
  3242. var MouseHandler = function(editor) {
  3243. var _self = this;
  3244. this.editor = editor;
  3245. new DefaultHandlers(this);
  3246. new DefaultGutterHandler(this);
  3247. new DragdropHandler(this);
  3248. var focusEditor = function(e) {
  3249. if (!document.hasFocus || !document.hasFocus())
  3250. window.focus();
  3251. editor.focus();
  3252. };
  3253. var mouseTarget = editor.renderer.getMouseEventTarget();
  3254. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3255. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3256. event.addMultiMouseDownListener(mouseTarget, [400, 300, 250], this, "onMouseEvent");
  3257. if (editor.renderer.scrollBarV) {
  3258. event.addMultiMouseDownListener(editor.renderer.scrollBarV.inner, [400, 300, 250], this, "onMouseEvent");
  3259. event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [400, 300, 250], this, "onMouseEvent");
  3260. if (useragent.isIE) {
  3261. event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
  3262. event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
  3263. }
  3264. }
  3265. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3266. var gutterEl = editor.renderer.$gutter;
  3267. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3268. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3269. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3270. event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
  3271. event.addListener(mouseTarget, "mousedown", focusEditor);
  3272. event.addListener(gutterEl, "mousedown", function(e) {
  3273. editor.focus();
  3274. return event.preventDefault(e);
  3275. });
  3276. editor.on("mousemove", function(e){
  3277. if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
  3278. return;
  3279. var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
  3280. var range = editor.session.selection.getRange();
  3281. var renderer = editor.renderer;
  3282. if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
  3283. renderer.setCursorStyle("default");
  3284. } else {
  3285. renderer.setCursorStyle("");
  3286. }
  3287. });
  3288. };
  3289. (function() {
  3290. this.onMouseEvent = function(name, e) {
  3291. this.editor._emit(name, new MouseEvent(e, this.editor));
  3292. };
  3293. this.onMouseMove = function(name, e) {
  3294. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3295. if (!listeners || !listeners.length)
  3296. return;
  3297. this.editor._emit(name, new MouseEvent(e, this.editor));
  3298. };
  3299. this.onMouseWheel = function(name, e) {
  3300. var mouseEvent = new MouseEvent(e, this.editor);
  3301. mouseEvent.speed = this.$scrollSpeed * 2;
  3302. mouseEvent.wheelX = e.wheelX;
  3303. mouseEvent.wheelY = e.wheelY;
  3304. this.editor._emit(name, mouseEvent);
  3305. };
  3306. this.setState = function(state) {
  3307. this.state = state;
  3308. };
  3309. this.captureMouse = function(ev, mouseMoveHandler) {
  3310. this.x = ev.x;
  3311. this.y = ev.y;
  3312. this.isMousePressed = true;
  3313. var renderer = this.editor.renderer;
  3314. if (renderer.$keepTextAreaAtCursor)
  3315. renderer.$keepTextAreaAtCursor = null;
  3316. var self = this;
  3317. var onMouseMove = function(e) {
  3318. if (!e) return;
  3319. if (useragent.isWebKit && !e.which && self.releaseMouse)
  3320. return self.releaseMouse();
  3321. self.x = e.clientX;
  3322. self.y = e.clientY;
  3323. mouseMoveHandler && mouseMoveHandler(e);
  3324. self.mouseEvent = new MouseEvent(e, self.editor);
  3325. self.$mouseMoved = true;
  3326. };
  3327. var onCaptureEnd = function(e) {
  3328. clearInterval(timerId);
  3329. onCaptureInterval();
  3330. self[self.state + "End"] && self[self.state + "End"](e);
  3331. self.state = "";
  3332. if (renderer.$keepTextAreaAtCursor == null) {
  3333. renderer.$keepTextAreaAtCursor = true;
  3334. renderer.$moveTextAreaToCursor();
  3335. }
  3336. self.isMousePressed = false;
  3337. self.$onCaptureMouseMove = self.releaseMouse = null;
  3338. e && self.onMouseEvent("mouseup", e);
  3339. };
  3340. var onCaptureInterval = function() {
  3341. self[self.state] && self[self.state]();
  3342. self.$mouseMoved = false;
  3343. };
  3344. if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
  3345. return setTimeout(function() {onCaptureEnd(ev);});
  3346. }
  3347. self.$onCaptureMouseMove = onMouseMove;
  3348. self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3349. var timerId = setInterval(onCaptureInterval, 20);
  3350. };
  3351. this.releaseMouse = null;
  3352. this.cancelContextMenu = function() {
  3353. var stop = function(e) {
  3354. if (e && e.domEvent && e.domEvent.type != "contextmenu")
  3355. return;
  3356. this.editor.off("nativecontextmenu", stop);
  3357. if (e && e.domEvent)
  3358. event.stopEvent(e.domEvent);
  3359. }.bind(this);
  3360. setTimeout(stop, 10);
  3361. this.editor.on("nativecontextmenu", stop);
  3362. };
  3363. }).call(MouseHandler.prototype);
  3364. config.defineOptions(MouseHandler.prototype, "mouseHandler", {
  3365. scrollSpeed: {initialValue: 2},
  3366. dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
  3367. dragEnabled: {initialValue: true},
  3368. focusTimout: {initialValue: 0},
  3369. tooltipFollowsMouse: {initialValue: true}
  3370. });
  3371. exports.MouseHandler = MouseHandler;
  3372. });
  3373. ace.define("ace/mouse/fold_handler",["require","exports","module"], function(require, exports, module) {
  3374. "use strict";
  3375. function FoldHandler(editor) {
  3376. editor.on("click", function(e) {
  3377. var position = e.getDocumentPosition();
  3378. var session = editor.session;
  3379. var fold = session.getFoldAt(position.row, position.column, 1);
  3380. if (fold) {
  3381. if (e.getAccelKey())
  3382. session.removeFold(fold);
  3383. else
  3384. session.expandFold(fold);
  3385. e.stop();
  3386. }
  3387. });
  3388. editor.on("gutterclick", function(e) {
  3389. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3390. if (gutterRegion == "foldWidgets") {
  3391. var row = e.getDocumentPosition().row;
  3392. var session = editor.session;
  3393. if (session.foldWidgets && session.foldWidgets[row])
  3394. editor.session.onFoldWidgetClick(row, e);
  3395. if (!editor.isFocused())
  3396. editor.focus();
  3397. e.stop();
  3398. }
  3399. });
  3400. editor.on("gutterdblclick", function(e) {
  3401. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3402. if (gutterRegion == "foldWidgets") {
  3403. var row = e.getDocumentPosition().row;
  3404. var session = editor.session;
  3405. var data = session.getParentFoldRangeData(row, true);
  3406. var range = data.range || data.firstRange;
  3407. if (range) {
  3408. row = range.start.row;
  3409. var fold = session.getFoldAt(row, session.getLine(row).length, 1);
  3410. if (fold) {
  3411. session.removeFold(fold);
  3412. } else {
  3413. session.addFold("...", range);
  3414. editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
  3415. }
  3416. }
  3417. e.stop();
  3418. }
  3419. });
  3420. }
  3421. exports.FoldHandler = FoldHandler;
  3422. });
  3423. ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module) {
  3424. "use strict";
  3425. var keyUtil = require("../lib/keys");
  3426. var event = require("../lib/event");
  3427. var KeyBinding = function(editor) {
  3428. this.$editor = editor;
  3429. this.$data = {editor: editor};
  3430. this.$handlers = [];
  3431. this.setDefaultHandler(editor.commands);
  3432. };
  3433. (function() {
  3434. this.setDefaultHandler = function(kb) {
  3435. this.removeKeyboardHandler(this.$defaultHandler);
  3436. this.$defaultHandler = kb;
  3437. this.addKeyboardHandler(kb, 0);
  3438. };
  3439. this.setKeyboardHandler = function(kb) {
  3440. var h = this.$handlers;
  3441. if (h[h.length - 1] == kb)
  3442. return;
  3443. while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
  3444. this.removeKeyboardHandler(h[h.length - 1]);
  3445. this.addKeyboardHandler(kb, 1);
  3446. };
  3447. this.addKeyboardHandler = function(kb, pos) {
  3448. if (!kb)
  3449. return;
  3450. if (typeof kb == "function" && !kb.handleKeyboard)
  3451. kb.handleKeyboard = kb;
  3452. var i = this.$handlers.indexOf(kb);
  3453. if (i != -1)
  3454. this.$handlers.splice(i, 1);
  3455. if (pos == undefined)
  3456. this.$handlers.push(kb);
  3457. else
  3458. this.$handlers.splice(pos, 0, kb);
  3459. if (i == -1 && kb.attach)
  3460. kb.attach(this.$editor);
  3461. };
  3462. this.removeKeyboardHandler = function(kb) {
  3463. var i = this.$handlers.indexOf(kb);
  3464. if (i == -1)
  3465. return false;
  3466. this.$handlers.splice(i, 1);
  3467. kb.detach && kb.detach(this.$editor);
  3468. return true;
  3469. };
  3470. this.getKeyboardHandler = function() {
  3471. return this.$handlers[this.$handlers.length - 1];
  3472. };
  3473. this.getStatusText = function() {
  3474. var data = this.$data;
  3475. var editor = data.editor;
  3476. return this.$handlers.map(function(h) {
  3477. return h.getStatusText && h.getStatusText(editor, data) || "";
  3478. }).filter(Boolean).join(" ");
  3479. };
  3480. this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
  3481. var toExecute;
  3482. var success = false;
  3483. var commands = this.$editor.commands;
  3484. for (var i = this.$handlers.length; i--;) {
  3485. toExecute = this.$handlers[i].handleKeyboard(
  3486. this.$data, hashId, keyString, keyCode, e
  3487. );
  3488. if (!toExecute || !toExecute.command)
  3489. continue;
  3490. if (toExecute.command == "null") {
  3491. success = true;
  3492. } else {
  3493. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3494. }
  3495. if (success && e && hashId != -1 &&
  3496. toExecute.passEvent != true && toExecute.command.passEvent != true
  3497. ) {
  3498. event.stopEvent(e);
  3499. }
  3500. if (success)
  3501. break;
  3502. }
  3503. return success;
  3504. };
  3505. this.onCommandKey = function(e, hashId, keyCode) {
  3506. var keyString = keyUtil.keyCodeToString(keyCode);
  3507. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3508. };
  3509. this.onTextInput = function(text) {
  3510. var success = this.$callKeyboardHandlers(-1, text);
  3511. if (!success)
  3512. this.$editor.commands.exec("insertstring", this.$editor, text);
  3513. };
  3514. }).call(KeyBinding.prototype);
  3515. exports.KeyBinding = KeyBinding;
  3516. });
  3517. ace.define("ace/range",["require","exports","module"], function(require, exports, module) {
  3518. "use strict";
  3519. var comparePoints = function(p1, p2) {
  3520. return p1.row - p2.row || p1.column - p2.column;
  3521. };
  3522. var Range = function(startRow, startColumn, endRow, endColumn) {
  3523. this.start = {
  3524. row: startRow,
  3525. column: startColumn
  3526. };
  3527. this.end = {
  3528. row: endRow,
  3529. column: endColumn
  3530. };
  3531. };
  3532. (function() {
  3533. this.isEqual = function(range) {
  3534. return this.start.row === range.start.row &&
  3535. this.end.row === range.end.row &&
  3536. this.start.column === range.start.column &&
  3537. this.end.column === range.end.column;
  3538. };
  3539. this.toString = function() {
  3540. return ("Range: [" + this.start.row + "/" + this.start.column +
  3541. "] -> [" + this.end.row + "/" + this.end.column + "]");
  3542. };
  3543. this.contains = function(row, column) {
  3544. return this.compare(row, column) == 0;
  3545. };
  3546. this.compareRange = function(range) {
  3547. var cmp,
  3548. end = range.end,
  3549. start = range.start;
  3550. cmp = this.compare(end.row, end.column);
  3551. if (cmp == 1) {
  3552. cmp = this.compare(start.row, start.column);
  3553. if (cmp == 1) {
  3554. return 2;
  3555. } else if (cmp == 0) {
  3556. return 1;
  3557. } else {
  3558. return 0;
  3559. }
  3560. } else if (cmp == -1) {
  3561. return -2;
  3562. } else {
  3563. cmp = this.compare(start.row, start.column);
  3564. if (cmp == -1) {
  3565. return -1;
  3566. } else if (cmp == 1) {
  3567. return 42;
  3568. } else {
  3569. return 0;
  3570. }
  3571. }
  3572. };
  3573. this.comparePoint = function(p) {
  3574. return this.compare(p.row, p.column);
  3575. };
  3576. this.containsRange = function(range) {
  3577. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  3578. };
  3579. this.intersects = function(range) {
  3580. var cmp = this.compareRange(range);
  3581. return (cmp == -1 || cmp == 0 || cmp == 1);
  3582. };
  3583. this.isEnd = function(row, column) {
  3584. return this.end.row == row && this.end.column == column;
  3585. };
  3586. this.isStart = function(row, column) {
  3587. return this.start.row == row && this.start.column == column;
  3588. };
  3589. this.setStart = function(row, column) {
  3590. if (typeof row == "object") {
  3591. this.start.column = row.column;
  3592. this.start.row = row.row;
  3593. } else {
  3594. this.start.row = row;
  3595. this.start.column = column;
  3596. }
  3597. };
  3598. this.setEnd = function(row, column) {
  3599. if (typeof row == "object") {
  3600. this.end.column = row.column;
  3601. this.end.row = row.row;
  3602. } else {
  3603. this.end.row = row;
  3604. this.end.column = column;
  3605. }
  3606. };
  3607. this.inside = function(row, column) {
  3608. if (this.compare(row, column) == 0) {
  3609. if (this.isEnd(row, column) || this.isStart(row, column)) {
  3610. return false;
  3611. } else {
  3612. return true;
  3613. }
  3614. }
  3615. return false;
  3616. };
  3617. this.insideStart = function(row, column) {
  3618. if (this.compare(row, column) == 0) {
  3619. if (this.isEnd(row, column)) {
  3620. return false;
  3621. } else {
  3622. return true;
  3623. }
  3624. }
  3625. return false;
  3626. };
  3627. this.insideEnd = function(row, column) {
  3628. if (this.compare(row, column) == 0) {
  3629. if (this.isStart(row, column)) {
  3630. return false;
  3631. } else {
  3632. return true;
  3633. }
  3634. }
  3635. return false;
  3636. };
  3637. this.compare = function(row, column) {
  3638. if (!this.isMultiLine()) {
  3639. if (row === this.start.row) {
  3640. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  3641. };
  3642. }
  3643. if (row < this.start.row)
  3644. return -1;
  3645. if (row > this.end.row)
  3646. return 1;
  3647. if (this.start.row === row)
  3648. return column >= this.start.column ? 0 : -1;
  3649. if (this.end.row === row)
  3650. return column <= this.end.column ? 0 : 1;
  3651. return 0;
  3652. };
  3653. this.compareStart = function(row, column) {
  3654. if (this.start.row == row && this.start.column == column) {
  3655. return -1;
  3656. } else {
  3657. return this.compare(row, column);
  3658. }
  3659. };
  3660. this.compareEnd = function(row, column) {
  3661. if (this.end.row == row && this.end.column == column) {
  3662. return 1;
  3663. } else {
  3664. return this.compare(row, column);
  3665. }
  3666. };
  3667. this.compareInside = function(row, column) {
  3668. if (this.end.row == row && this.end.column == column) {
  3669. return 1;
  3670. } else if (this.start.row == row && this.start.column == column) {
  3671. return -1;
  3672. } else {
  3673. return this.compare(row, column);
  3674. }
  3675. };
  3676. this.clipRows = function(firstRow, lastRow) {
  3677. if (this.end.row > lastRow)
  3678. var end = {row: lastRow + 1, column: 0};
  3679. else if (this.end.row < firstRow)
  3680. var end = {row: firstRow, column: 0};
  3681. if (this.start.row > lastRow)
  3682. var start = {row: lastRow + 1, column: 0};
  3683. else if (this.start.row < firstRow)
  3684. var start = {row: firstRow, column: 0};
  3685. return Range.fromPoints(start || this.start, end || this.end);
  3686. };
  3687. this.extend = function(row, column) {
  3688. var cmp = this.compare(row, column);
  3689. if (cmp == 0)
  3690. return this;
  3691. else if (cmp == -1)
  3692. var start = {row: row, column: column};
  3693. else
  3694. var end = {row: row, column: column};
  3695. return Range.fromPoints(start || this.start, end || this.end);
  3696. };
  3697. this.isEmpty = function() {
  3698. return (this.start.row === this.end.row && this.start.column === this.end.column);
  3699. };
  3700. this.isMultiLine = function() {
  3701. return (this.start.row !== this.end.row);
  3702. };
  3703. this.clone = function() {
  3704. return Range.fromPoints(this.start, this.end);
  3705. };
  3706. this.collapseRows = function() {
  3707. if (this.end.column == 0)
  3708. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  3709. else
  3710. return new Range(this.start.row, 0, this.end.row, 0)
  3711. };
  3712. this.toScreenRange = function(session) {
  3713. var screenPosStart = session.documentToScreenPosition(this.start);
  3714. var screenPosEnd = session.documentToScreenPosition(this.end);
  3715. return new Range(
  3716. screenPosStart.row, screenPosStart.column,
  3717. screenPosEnd.row, screenPosEnd.column
  3718. );
  3719. };
  3720. this.moveBy = function(row, column) {
  3721. this.start.row += row;
  3722. this.start.column += column;
  3723. this.end.row += row;
  3724. this.end.column += column;
  3725. };
  3726. }).call(Range.prototype);
  3727. Range.fromPoints = function(start, end) {
  3728. return new Range(start.row, start.column, end.row, end.column);
  3729. };
  3730. Range.comparePoints = comparePoints;
  3731. Range.comparePoints = function(p1, p2) {
  3732. return p1.row - p2.row || p1.column - p2.column;
  3733. };
  3734. exports.Range = Range;
  3735. });
  3736. ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
  3737. "use strict";
  3738. var oop = require("./lib/oop");
  3739. var lang = require("./lib/lang");
  3740. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  3741. var Range = require("./range").Range;
  3742. var Selection = function(session) {
  3743. this.session = session;
  3744. this.doc = session.getDocument();
  3745. this.clearSelection();
  3746. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  3747. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  3748. var self = this;
  3749. this.lead.on("change", function(e) {
  3750. self._emit("changeCursor");
  3751. if (!self.$isEmpty)
  3752. self._emit("changeSelection");
  3753. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  3754. self.$desiredColumn = null;
  3755. });
  3756. this.selectionAnchor.on("change", function() {
  3757. if (!self.$isEmpty)
  3758. self._emit("changeSelection");
  3759. });
  3760. };
  3761. (function() {
  3762. oop.implement(this, EventEmitter);
  3763. this.isEmpty = function() {
  3764. return (this.$isEmpty || (
  3765. this.anchor.row == this.lead.row &&
  3766. this.anchor.column == this.lead.column
  3767. ));
  3768. };
  3769. this.isMultiLine = function() {
  3770. if (this.isEmpty()) {
  3771. return false;
  3772. }
  3773. return this.getRange().isMultiLine();
  3774. };
  3775. this.getCursor = function() {
  3776. return this.lead.getPosition();
  3777. };
  3778. this.setSelectionAnchor = function(row, column) {
  3779. this.anchor.setPosition(row, column);
  3780. if (this.$isEmpty) {
  3781. this.$isEmpty = false;
  3782. this._emit("changeSelection");
  3783. }
  3784. };
  3785. this.getSelectionAnchor = function() {
  3786. if (this.$isEmpty)
  3787. return this.getSelectionLead();
  3788. else
  3789. return this.anchor.getPosition();
  3790. };
  3791. this.getSelectionLead = function() {
  3792. return this.lead.getPosition();
  3793. };
  3794. this.shiftSelection = function(columns) {
  3795. if (this.$isEmpty) {
  3796. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  3797. return;
  3798. }
  3799. var anchor = this.getSelectionAnchor();
  3800. var lead = this.getSelectionLead();
  3801. var isBackwards = this.isBackwards();
  3802. if (!isBackwards || anchor.column !== 0)
  3803. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  3804. if (isBackwards || lead.column !== 0) {
  3805. this.$moveSelection(function() {
  3806. this.moveCursorTo(lead.row, lead.column + columns);
  3807. });
  3808. }
  3809. };
  3810. this.isBackwards = function() {
  3811. var anchor = this.anchor;
  3812. var lead = this.lead;
  3813. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  3814. };
  3815. this.getRange = function() {
  3816. var anchor = this.anchor;
  3817. var lead = this.lead;
  3818. if (this.isEmpty())
  3819. return Range.fromPoints(lead, lead);
  3820. if (this.isBackwards()) {
  3821. return Range.fromPoints(lead, anchor);
  3822. }
  3823. else {
  3824. return Range.fromPoints(anchor, lead);
  3825. }
  3826. };
  3827. this.clearSelection = function() {
  3828. if (!this.$isEmpty) {
  3829. this.$isEmpty = true;
  3830. this._emit("changeSelection");
  3831. }
  3832. };
  3833. this.selectAll = function() {
  3834. var lastRow = this.doc.getLength() - 1;
  3835. this.setSelectionAnchor(0, 0);
  3836. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  3837. };
  3838. this.setRange =
  3839. this.setSelectionRange = function(range, reverse) {
  3840. if (reverse) {
  3841. this.setSelectionAnchor(range.end.row, range.end.column);
  3842. this.selectTo(range.start.row, range.start.column);
  3843. } else {
  3844. this.setSelectionAnchor(range.start.row, range.start.column);
  3845. this.selectTo(range.end.row, range.end.column);
  3846. }
  3847. if (this.getRange().isEmpty())
  3848. this.$isEmpty = true;
  3849. this.$desiredColumn = null;
  3850. };
  3851. this.$moveSelection = function(mover) {
  3852. var lead = this.lead;
  3853. if (this.$isEmpty)
  3854. this.setSelectionAnchor(lead.row, lead.column);
  3855. mover.call(this);
  3856. };
  3857. this.selectTo = function(row, column) {
  3858. this.$moveSelection(function() {
  3859. this.moveCursorTo(row, column);
  3860. });
  3861. };
  3862. this.selectToPosition = function(pos) {
  3863. this.$moveSelection(function() {
  3864. this.moveCursorToPosition(pos);
  3865. });
  3866. };
  3867. this.moveTo = function(row, column) {
  3868. this.clearSelection();
  3869. this.moveCursorTo(row, column);
  3870. };
  3871. this.moveToPosition = function(pos) {
  3872. this.clearSelection();
  3873. this.moveCursorToPosition(pos);
  3874. };
  3875. this.selectUp = function() {
  3876. this.$moveSelection(this.moveCursorUp);
  3877. };
  3878. this.selectDown = function() {
  3879. this.$moveSelection(this.moveCursorDown);
  3880. };
  3881. this.selectRight = function() {
  3882. this.$moveSelection(this.moveCursorRight);
  3883. };
  3884. this.selectLeft = function() {
  3885. this.$moveSelection(this.moveCursorLeft);
  3886. };
  3887. this.selectLineStart = function() {
  3888. this.$moveSelection(this.moveCursorLineStart);
  3889. };
  3890. this.selectLineEnd = function() {
  3891. this.$moveSelection(this.moveCursorLineEnd);
  3892. };
  3893. this.selectFileEnd = function() {
  3894. this.$moveSelection(this.moveCursorFileEnd);
  3895. };
  3896. this.selectFileStart = function() {
  3897. this.$moveSelection(this.moveCursorFileStart);
  3898. };
  3899. this.selectWordRight = function() {
  3900. this.$moveSelection(this.moveCursorWordRight);
  3901. };
  3902. this.selectWordLeft = function() {
  3903. this.$moveSelection(this.moveCursorWordLeft);
  3904. };
  3905. this.getWordRange = function(row, column) {
  3906. if (typeof column == "undefined") {
  3907. var cursor = row || this.lead;
  3908. row = cursor.row;
  3909. column = cursor.column;
  3910. }
  3911. return this.session.getWordRange(row, column);
  3912. };
  3913. this.selectWord = function() {
  3914. this.setSelectionRange(this.getWordRange());
  3915. };
  3916. this.selectAWord = function() {
  3917. var cursor = this.getCursor();
  3918. var range = this.session.getAWordRange(cursor.row, cursor.column);
  3919. this.setSelectionRange(range);
  3920. };
  3921. this.getLineRange = function(row, excludeLastChar) {
  3922. var rowStart = typeof row == "number" ? row : this.lead.row;
  3923. var rowEnd;
  3924. var foldLine = this.session.getFoldLine(rowStart);
  3925. if (foldLine) {
  3926. rowStart = foldLine.start.row;
  3927. rowEnd = foldLine.end.row;
  3928. } else {
  3929. rowEnd = rowStart;
  3930. }
  3931. if (excludeLastChar === true)
  3932. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  3933. else
  3934. return new Range(rowStart, 0, rowEnd + 1, 0);
  3935. };
  3936. this.selectLine = function() {
  3937. this.setSelectionRange(this.getLineRange());
  3938. };
  3939. this.moveCursorUp = function() {
  3940. this.moveCursorBy(-1, 0);
  3941. };
  3942. this.moveCursorDown = function() {
  3943. this.moveCursorBy(1, 0);
  3944. };
  3945. this.moveCursorLeft = function() {
  3946. var cursor = this.lead.getPosition(),
  3947. fold;
  3948. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  3949. this.moveCursorTo(fold.start.row, fold.start.column);
  3950. } else if (cursor.column === 0) {
  3951. if (cursor.row > 0) {
  3952. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  3953. }
  3954. }
  3955. else {
  3956. var tabSize = this.session.getTabSize();
  3957. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
  3958. this.moveCursorBy(0, -tabSize);
  3959. else
  3960. this.moveCursorBy(0, -1);
  3961. }
  3962. };
  3963. this.moveCursorRight = function() {
  3964. var cursor = this.lead.getPosition(),
  3965. fold;
  3966. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  3967. this.moveCursorTo(fold.end.row, fold.end.column);
  3968. }
  3969. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  3970. if (this.lead.row < this.doc.getLength() - 1) {
  3971. this.moveCursorTo(this.lead.row + 1, 0);
  3972. }
  3973. }
  3974. else {
  3975. var tabSize = this.session.getTabSize();
  3976. var cursor = this.lead;
  3977. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
  3978. this.moveCursorBy(0, tabSize);
  3979. else
  3980. this.moveCursorBy(0, 1);
  3981. }
  3982. };
  3983. this.moveCursorLineStart = function() {
  3984. var row = this.lead.row;
  3985. var column = this.lead.column;
  3986. var screenRow = this.session.documentToScreenRow(row, column);
  3987. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  3988. var beforeCursor = this.session.getDisplayLine(
  3989. row, null, firstColumnPosition.row,
  3990. firstColumnPosition.column
  3991. );
  3992. var leadingSpace = beforeCursor.match(/^\s*/);
  3993. if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
  3994. firstColumnPosition.column += leadingSpace[0].length;
  3995. this.moveCursorToPosition(firstColumnPosition);
  3996. };
  3997. this.moveCursorLineEnd = function() {
  3998. var lead = this.lead;
  3999. var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  4000. if (this.lead.column == lineEnd.column) {
  4001. var line = this.session.getLine(lineEnd.row);
  4002. if (lineEnd.column == line.length) {
  4003. var textEnd = line.search(/\s+$/);
  4004. if (textEnd > 0)
  4005. lineEnd.column = textEnd;
  4006. }
  4007. }
  4008. this.moveCursorTo(lineEnd.row, lineEnd.column);
  4009. };
  4010. this.moveCursorFileEnd = function() {
  4011. var row = this.doc.getLength() - 1;
  4012. var column = this.doc.getLine(row).length;
  4013. this.moveCursorTo(row, column);
  4014. };
  4015. this.moveCursorFileStart = function() {
  4016. this.moveCursorTo(0, 0);
  4017. };
  4018. this.moveCursorLongWordRight = function() {
  4019. var row = this.lead.row;
  4020. var column = this.lead.column;
  4021. var line = this.doc.getLine(row);
  4022. var rightOfCursor = line.substring(column);
  4023. var match;
  4024. this.session.nonTokenRe.lastIndex = 0;
  4025. this.session.tokenRe.lastIndex = 0;
  4026. var fold = this.session.getFoldAt(row, column, 1);
  4027. if (fold) {
  4028. this.moveCursorTo(fold.end.row, fold.end.column);
  4029. return;
  4030. }
  4031. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  4032. column += this.session.nonTokenRe.lastIndex;
  4033. this.session.nonTokenRe.lastIndex = 0;
  4034. rightOfCursor = line.substring(column);
  4035. }
  4036. if (column >= line.length) {
  4037. this.moveCursorTo(row, line.length);
  4038. this.moveCursorRight();
  4039. if (row < this.doc.getLength() - 1)
  4040. this.moveCursorWordRight();
  4041. return;
  4042. }
  4043. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4044. column += this.session.tokenRe.lastIndex;
  4045. this.session.tokenRe.lastIndex = 0;
  4046. }
  4047. this.moveCursorTo(row, column);
  4048. };
  4049. this.moveCursorLongWordLeft = function() {
  4050. var row = this.lead.row;
  4051. var column = this.lead.column;
  4052. var fold;
  4053. if (fold = this.session.getFoldAt(row, column, -1)) {
  4054. this.moveCursorTo(fold.start.row, fold.start.column);
  4055. return;
  4056. }
  4057. var str = this.session.getFoldStringAt(row, column, -1);
  4058. if (str == null) {
  4059. str = this.doc.getLine(row).substring(0, column);
  4060. }
  4061. var leftOfCursor = lang.stringReverse(str);
  4062. var match;
  4063. this.session.nonTokenRe.lastIndex = 0;
  4064. this.session.tokenRe.lastIndex = 0;
  4065. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  4066. column -= this.session.nonTokenRe.lastIndex;
  4067. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  4068. this.session.nonTokenRe.lastIndex = 0;
  4069. }
  4070. if (column <= 0) {
  4071. this.moveCursorTo(row, 0);
  4072. this.moveCursorLeft();
  4073. if (row > 0)
  4074. this.moveCursorWordLeft();
  4075. return;
  4076. }
  4077. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  4078. column -= this.session.tokenRe.lastIndex;
  4079. this.session.tokenRe.lastIndex = 0;
  4080. }
  4081. this.moveCursorTo(row, column);
  4082. };
  4083. this.$shortWordEndIndex = function(rightOfCursor) {
  4084. var match, index = 0, ch;
  4085. var whitespaceRe = /\s/;
  4086. var tokenRe = this.session.tokenRe;
  4087. tokenRe.lastIndex = 0;
  4088. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4089. index = this.session.tokenRe.lastIndex;
  4090. } else {
  4091. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4092. index ++;
  4093. if (index < 1) {
  4094. tokenRe.lastIndex = 0;
  4095. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  4096. tokenRe.lastIndex = 0;
  4097. index ++;
  4098. if (whitespaceRe.test(ch)) {
  4099. if (index > 2) {
  4100. index--;
  4101. break;
  4102. } else {
  4103. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4104. index ++;
  4105. if (index > 2)
  4106. break;
  4107. }
  4108. }
  4109. }
  4110. }
  4111. }
  4112. tokenRe.lastIndex = 0;
  4113. return index;
  4114. };
  4115. this.moveCursorShortWordRight = function() {
  4116. var row = this.lead.row;
  4117. var column = this.lead.column;
  4118. var line = this.doc.getLine(row);
  4119. var rightOfCursor = line.substring(column);
  4120. var fold = this.session.getFoldAt(row, column, 1);
  4121. if (fold)
  4122. return this.moveCursorTo(fold.end.row, fold.end.column);
  4123. if (column == line.length) {
  4124. var l = this.doc.getLength();
  4125. do {
  4126. row++;
  4127. rightOfCursor = this.doc.getLine(row);
  4128. } while (row < l && /^\s*$/.test(rightOfCursor));
  4129. if (!/^\s+/.test(rightOfCursor))
  4130. rightOfCursor = "";
  4131. column = 0;
  4132. }
  4133. var index = this.$shortWordEndIndex(rightOfCursor);
  4134. this.moveCursorTo(row, column + index);
  4135. };
  4136. this.moveCursorShortWordLeft = function() {
  4137. var row = this.lead.row;
  4138. var column = this.lead.column;
  4139. var fold;
  4140. if (fold = this.session.getFoldAt(row, column, -1))
  4141. return this.moveCursorTo(fold.start.row, fold.start.column);
  4142. var line = this.session.getLine(row).substring(0, column);
  4143. if (column === 0) {
  4144. do {
  4145. row--;
  4146. line = this.doc.getLine(row);
  4147. } while (row > 0 && /^\s*$/.test(line));
  4148. column = line.length;
  4149. if (!/\s+$/.test(line))
  4150. line = "";
  4151. }
  4152. var leftOfCursor = lang.stringReverse(line);
  4153. var index = this.$shortWordEndIndex(leftOfCursor);
  4154. return this.moveCursorTo(row, column - index);
  4155. };
  4156. this.moveCursorWordRight = function() {
  4157. if (this.session.$selectLongWords)
  4158. this.moveCursorLongWordRight();
  4159. else
  4160. this.moveCursorShortWordRight();
  4161. };
  4162. this.moveCursorWordLeft = function() {
  4163. if (this.session.$selectLongWords)
  4164. this.moveCursorLongWordLeft();
  4165. else
  4166. this.moveCursorShortWordLeft();
  4167. };
  4168. this.moveCursorBy = function(rows, chars) {
  4169. var screenPos = this.session.documentToScreenPosition(
  4170. this.lead.row,
  4171. this.lead.column
  4172. );
  4173. if (chars === 0) {
  4174. if (this.$desiredColumn)
  4175. screenPos.column = this.$desiredColumn;
  4176. else
  4177. this.$desiredColumn = screenPos.column;
  4178. }
  4179. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
  4180. if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
  4181. if (this.session.lineWidgets && this.session.lineWidgets[docPos.row])
  4182. docPos.row++;
  4183. }
  4184. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  4185. };
  4186. this.moveCursorToPosition = function(position) {
  4187. this.moveCursorTo(position.row, position.column);
  4188. };
  4189. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  4190. var fold = this.session.getFoldAt(row, column, 1);
  4191. if (fold) {
  4192. row = fold.start.row;
  4193. column = fold.start.column;
  4194. }
  4195. this.$keepDesiredColumnOnChange = true;
  4196. this.lead.setPosition(row, column);
  4197. this.$keepDesiredColumnOnChange = false;
  4198. if (!keepDesiredColumn)
  4199. this.$desiredColumn = null;
  4200. };
  4201. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  4202. var pos = this.session.screenToDocumentPosition(row, column);
  4203. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  4204. };
  4205. this.detach = function() {
  4206. this.lead.detach();
  4207. this.anchor.detach();
  4208. this.session = this.doc = null;
  4209. };
  4210. this.fromOrientedRange = function(range) {
  4211. this.setSelectionRange(range, range.cursor == range.start);
  4212. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  4213. };
  4214. this.toOrientedRange = function(range) {
  4215. var r = this.getRange();
  4216. if (range) {
  4217. range.start.column = r.start.column;
  4218. range.start.row = r.start.row;
  4219. range.end.column = r.end.column;
  4220. range.end.row = r.end.row;
  4221. } else {
  4222. range = r;
  4223. }
  4224. range.cursor = this.isBackwards() ? range.start : range.end;
  4225. range.desiredColumn = this.$desiredColumn;
  4226. return range;
  4227. };
  4228. this.getRangeOfMovements = function(func) {
  4229. var start = this.getCursor();
  4230. try {
  4231. func.call(null, this);
  4232. var end = this.getCursor();
  4233. return Range.fromPoints(start,end);
  4234. } catch(e) {
  4235. return Range.fromPoints(start,start);
  4236. } finally {
  4237. this.moveCursorToPosition(start);
  4238. }
  4239. };
  4240. this.toJSON = function() {
  4241. if (this.rangeCount) {
  4242. var data = this.ranges.map(function(r) {
  4243. var r1 = r.clone();
  4244. r1.isBackwards = r.cursor == r.start;
  4245. return r1;
  4246. });
  4247. } else {
  4248. var data = this.getRange();
  4249. data.isBackwards = this.isBackwards();
  4250. }
  4251. return data;
  4252. };
  4253. this.fromJSON = function(data) {
  4254. if (data.start == undefined) {
  4255. if (this.rangeList) {
  4256. this.toSingleRange(data[0]);
  4257. for (var i = data.length; i--; ) {
  4258. var r = Range.fromPoints(data[i].start, data[i].end);
  4259. if (data.isBackwards)
  4260. r.cursor = r.start;
  4261. this.addRange(r, true);
  4262. }
  4263. return;
  4264. } else
  4265. data = data[0];
  4266. }
  4267. if (this.rangeList)
  4268. this.toSingleRange(data);
  4269. this.setSelectionRange(data, data.isBackwards);
  4270. };
  4271. this.isEqual = function(data) {
  4272. if ((data.length || this.rangeCount) && data.length != this.rangeCount)
  4273. return false;
  4274. if (!data.length || !this.ranges)
  4275. return this.getRange().isEqual(data);
  4276. for (var i = this.ranges.length; i--; ) {
  4277. if (!this.ranges[i].isEqual(data[i]))
  4278. return false;
  4279. }
  4280. return true;
  4281. };
  4282. }).call(Selection.prototype);
  4283. exports.Selection = Selection;
  4284. });
  4285. ace.define("ace/tokenizer",["require","exports","module","ace/config"], function(require, exports, module) {
  4286. "use strict";
  4287. var config = require("./config");
  4288. var MAX_TOKEN_COUNT = 2000;
  4289. var Tokenizer = function(rules) {
  4290. this.states = rules;
  4291. this.regExps = {};
  4292. this.matchMappings = {};
  4293. for (var key in this.states) {
  4294. var state = this.states[key];
  4295. var ruleRegExps = [];
  4296. var matchTotal = 0;
  4297. var mapping = this.matchMappings[key] = {defaultToken: "text"};
  4298. var flag = "g";
  4299. var splitterRurles = [];
  4300. for (var i = 0; i < state.length; i++) {
  4301. var rule = state[i];
  4302. if (rule.defaultToken)
  4303. mapping.defaultToken = rule.defaultToken;
  4304. if (rule.caseInsensitive)
  4305. flag = "gi";
  4306. if (rule.regex == null)
  4307. continue;
  4308. if (rule.regex instanceof RegExp)
  4309. rule.regex = rule.regex.toString().slice(1, -1);
  4310. var adjustedregex = rule.regex;
  4311. var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
  4312. if (Array.isArray(rule.token)) {
  4313. if (rule.token.length == 1 || matchcount == 1) {
  4314. rule.token = rule.token[0];
  4315. } else if (matchcount - 1 != rule.token.length) {
  4316. this.reportError("number of classes and regexp groups doesn't match", {
  4317. rule: rule,
  4318. groupCount: matchcount - 1
  4319. });
  4320. rule.token = rule.token[0];
  4321. } else {
  4322. rule.tokenArray = rule.token;
  4323. rule.token = null;
  4324. rule.onMatch = this.$arrayTokens;
  4325. }
  4326. } else if (typeof rule.token == "function" && !rule.onMatch) {
  4327. if (matchcount > 1)
  4328. rule.onMatch = this.$applyToken;
  4329. else
  4330. rule.onMatch = rule.token;
  4331. }
  4332. if (matchcount > 1) {
  4333. if (/\\\d/.test(rule.regex)) {
  4334. adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
  4335. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  4336. });
  4337. } else {
  4338. matchcount = 1;
  4339. adjustedregex = this.removeCapturingGroups(rule.regex);
  4340. }
  4341. if (!rule.splitRegex && typeof rule.token != "string")
  4342. splitterRurles.push(rule); // flag will be known only at the very end
  4343. }
  4344. mapping[matchTotal] = i;
  4345. matchTotal += matchcount;
  4346. ruleRegExps.push(adjustedregex);
  4347. if (!rule.onMatch)
  4348. rule.onMatch = null;
  4349. }
  4350. if (!ruleRegExps.length) {
  4351. mapping[0] = 0;
  4352. ruleRegExps.push("$");
  4353. }
  4354. splitterRurles.forEach(function(rule) {
  4355. rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
  4356. }, this);
  4357. this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
  4358. }
  4359. };
  4360. (function() {
  4361. this.$setMaxTokenCount = function(m) {
  4362. MAX_TOKEN_COUNT = m | 0;
  4363. };
  4364. this.$applyToken = function(str) {
  4365. var values = this.splitRegex.exec(str).slice(1);
  4366. var types = this.token.apply(this, values);
  4367. if (typeof types === "string")
  4368. return [{type: types, value: str}];
  4369. var tokens = [];
  4370. for (var i = 0, l = types.length; i < l; i++) {
  4371. if (values[i])
  4372. tokens[tokens.length] = {
  4373. type: types[i],
  4374. value: values[i]
  4375. };
  4376. }
  4377. return tokens;
  4378. },
  4379. this.$arrayTokens = function(str) {
  4380. if (!str)
  4381. return [];
  4382. var values = this.splitRegex.exec(str);
  4383. if (!values)
  4384. return "text";
  4385. var tokens = [];
  4386. var types = this.tokenArray;
  4387. for (var i = 0, l = types.length; i < l; i++) {
  4388. if (values[i + 1])
  4389. tokens[tokens.length] = {
  4390. type: types[i],
  4391. value: values[i + 1]
  4392. };
  4393. }
  4394. return tokens;
  4395. };
  4396. this.removeCapturingGroups = function(src) {
  4397. var r = src.replace(
  4398. /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
  4399. function(x, y) {return y ? "(?:" : x;}
  4400. );
  4401. return r;
  4402. };
  4403. this.createSplitterRegexp = function(src, flag) {
  4404. if (src.indexOf("(?=") != -1) {
  4405. var stack = 0;
  4406. var inChClass = false;
  4407. var lastCapture = {};
  4408. src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
  4409. m, esc, parenOpen, parenClose, square, index
  4410. ) {
  4411. if (inChClass) {
  4412. inChClass = square != "]";
  4413. } else if (square) {
  4414. inChClass = true;
  4415. } else if (parenClose) {
  4416. if (stack == lastCapture.stack) {
  4417. lastCapture.end = index+1;
  4418. lastCapture.stack = -1;
  4419. }
  4420. stack--;
  4421. } else if (parenOpen) {
  4422. stack++;
  4423. if (parenOpen.length != 1) {
  4424. lastCapture.stack = stack
  4425. lastCapture.start = index;
  4426. }
  4427. }
  4428. return m;
  4429. });
  4430. if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
  4431. src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
  4432. }
  4433. return new RegExp(src, (flag||"").replace("g", ""));
  4434. };
  4435. this.getLineTokens = function(line, startState) {
  4436. if (startState && typeof startState != "string") {
  4437. var stack = startState.slice(0);
  4438. startState = stack[0];
  4439. if (startState === "#tmp") {
  4440. stack.shift()
  4441. startState = stack.shift()
  4442. }
  4443. } else
  4444. var stack = [];
  4445. var currentState = startState || "start";
  4446. var state = this.states[currentState];
  4447. if (!state) {
  4448. currentState = "start";
  4449. state = this.states[currentState];
  4450. }
  4451. var mapping = this.matchMappings[currentState];
  4452. var re = this.regExps[currentState];
  4453. re.lastIndex = 0;
  4454. var match, tokens = [];
  4455. var lastIndex = 0;
  4456. var matchAttempts = 0;
  4457. var token = {type: null, value: ""};
  4458. while (match = re.exec(line)) {
  4459. var type = mapping.defaultToken;
  4460. var rule = null;
  4461. var value = match[0];
  4462. var index = re.lastIndex;
  4463. if (index - value.length > lastIndex) {
  4464. var skipped = line.substring(lastIndex, index - value.length);
  4465. if (token.type == type) {
  4466. token.value += skipped;
  4467. } else {
  4468. if (token.type)
  4469. tokens.push(token);
  4470. token = {type: type, value: skipped};
  4471. }
  4472. }
  4473. for (var i = 0; i < match.length-2; i++) {
  4474. if (match[i + 1] === undefined)
  4475. continue;
  4476. rule = state[mapping[i]];
  4477. if (rule.onMatch)
  4478. type = rule.onMatch(value, currentState, stack);
  4479. else
  4480. type = rule.token;
  4481. if (rule.next) {
  4482. if (typeof rule.next == "string") {
  4483. currentState = rule.next;
  4484. } else {
  4485. currentState = rule.next(currentState, stack);
  4486. }
  4487. state = this.states[currentState];
  4488. if (!state) {
  4489. this.reportError("state doesn't exist", currentState);
  4490. currentState = "start";
  4491. state = this.states[currentState];
  4492. }
  4493. mapping = this.matchMappings[currentState];
  4494. lastIndex = index;
  4495. re = this.regExps[currentState];
  4496. re.lastIndex = index;
  4497. }
  4498. break;
  4499. }
  4500. if (value) {
  4501. if (typeof type === "string") {
  4502. if ((!rule || rule.merge !== false) && token.type === type) {
  4503. token.value += value;
  4504. } else {
  4505. if (token.type)
  4506. tokens.push(token);
  4507. token = {type: type, value: value};
  4508. }
  4509. } else if (type) {
  4510. if (token.type)
  4511. tokens.push(token);
  4512. token = {type: null, value: ""};
  4513. for (var i = 0; i < type.length; i++)
  4514. tokens.push(type[i]);
  4515. }
  4516. }
  4517. if (lastIndex == line.length)
  4518. break;
  4519. lastIndex = index;
  4520. if (matchAttempts++ > MAX_TOKEN_COUNT) {
  4521. if (matchAttempts > 2 * line.length) {
  4522. this.reportError("infinite loop with in ace tokenizer", {
  4523. startState: startState,
  4524. line: line
  4525. });
  4526. }
  4527. while (lastIndex < line.length) {
  4528. if (token.type)
  4529. tokens.push(token);
  4530. token = {
  4531. value: line.substring(lastIndex, lastIndex += 2000),
  4532. type: "overflow"
  4533. };
  4534. }
  4535. currentState = "start";
  4536. stack = [];
  4537. break;
  4538. }
  4539. }
  4540. if (token.type)
  4541. tokens.push(token);
  4542. if (stack.length > 1) {
  4543. if (stack[0] !== currentState)
  4544. stack.unshift("#tmp", currentState);
  4545. }
  4546. return {
  4547. tokens : tokens,
  4548. state : stack.length ? stack : currentState
  4549. };
  4550. };
  4551. this.reportError = config.reportError;
  4552. }).call(Tokenizer.prototype);
  4553. exports.Tokenizer = Tokenizer;
  4554. });
  4555. ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
  4556. "use strict";
  4557. var lang = require("../lib/lang");
  4558. var TextHighlightRules = function() {
  4559. this.$rules = {
  4560. "start" : [{
  4561. token : "empty_line",
  4562. regex : '^$'
  4563. }, {
  4564. defaultToken : "text"
  4565. }]
  4566. };
  4567. };
  4568. (function() {
  4569. this.addRules = function(rules, prefix) {
  4570. if (!prefix) {
  4571. for (var key in rules)
  4572. this.$rules[key] = rules[key];
  4573. return;
  4574. }
  4575. for (var key in rules) {
  4576. var state = rules[key];
  4577. for (var i = 0; i < state.length; i++) {
  4578. var rule = state[i];
  4579. if (rule.next || rule.onMatch) {
  4580. if (typeof rule.next != "string") {
  4581. if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
  4582. rule.nextState = prefix + rule.nextState;
  4583. } else {
  4584. if (rule.next.indexOf(prefix) !== 0)
  4585. rule.next = prefix + rule.next;
  4586. }
  4587. }
  4588. }
  4589. this.$rules[prefix + key] = state;
  4590. }
  4591. };
  4592. this.getRules = function() {
  4593. return this.$rules;
  4594. };
  4595. this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
  4596. var embedRules = typeof HighlightRules == "function"
  4597. ? new HighlightRules().getRules()
  4598. : HighlightRules;
  4599. if (states) {
  4600. for (var i = 0; i < states.length; i++)
  4601. states[i] = prefix + states[i];
  4602. } else {
  4603. states = [];
  4604. for (var key in embedRules)
  4605. states.push(prefix + key);
  4606. }
  4607. this.addRules(embedRules, prefix);
  4608. if (escapeRules) {
  4609. var addRules = Array.prototype[append ? "push" : "unshift"];
  4610. for (var i = 0; i < states.length; i++)
  4611. addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  4612. }
  4613. if (!this.$embeds)
  4614. this.$embeds = [];
  4615. this.$embeds.push(prefix);
  4616. };
  4617. this.getEmbeds = function() {
  4618. return this.$embeds;
  4619. };
  4620. var pushState = function(currentState, stack) {
  4621. if (currentState != "start" || stack.length)
  4622. stack.unshift(this.nextState, currentState);
  4623. return this.nextState;
  4624. };
  4625. var popState = function(currentState, stack) {
  4626. stack.shift();
  4627. return stack.shift() || "start";
  4628. };
  4629. this.normalizeRules = function() {
  4630. var id = 0;
  4631. var rules = this.$rules;
  4632. function processState(key) {
  4633. var state = rules[key];
  4634. state.processed = true;
  4635. for (var i = 0; i < state.length; i++) {
  4636. var rule = state[i];
  4637. if (!rule.regex && rule.start) {
  4638. rule.regex = rule.start;
  4639. if (!rule.next)
  4640. rule.next = [];
  4641. rule.next.push({
  4642. defaultToken: rule.token
  4643. }, {
  4644. token: rule.token + ".end",
  4645. regex: rule.end || rule.start,
  4646. next: "pop"
  4647. });
  4648. rule.token = rule.token + ".start";
  4649. rule.push = true;
  4650. }
  4651. var next = rule.next || rule.push;
  4652. if (next && Array.isArray(next)) {
  4653. var stateName = rule.stateName;
  4654. if (!stateName) {
  4655. stateName = rule.token;
  4656. if (typeof stateName != "string")
  4657. stateName = stateName[0] || "";
  4658. if (rules[stateName])
  4659. stateName += id++;
  4660. }
  4661. rules[stateName] = next;
  4662. rule.next = stateName;
  4663. processState(stateName);
  4664. } else if (next == "pop") {
  4665. rule.next = popState;
  4666. }
  4667. if (rule.push) {
  4668. rule.nextState = rule.next || rule.push;
  4669. rule.next = pushState;
  4670. delete rule.push;
  4671. }
  4672. if (rule.rules) {
  4673. for (var r in rule.rules) {
  4674. if (rules[r]) {
  4675. if (rules[r].push)
  4676. rules[r].push.apply(rules[r], rule.rules[r]);
  4677. } else {
  4678. rules[r] = rule.rules[r];
  4679. }
  4680. }
  4681. }
  4682. if (rule.include || typeof rule == "string") {
  4683. var includeName = rule.include || rule;
  4684. var toInsert = rules[includeName];
  4685. } else if (Array.isArray(rule))
  4686. toInsert = rule;
  4687. if (toInsert) {
  4688. var args = [i, 1].concat(toInsert);
  4689. if (rule.noEscape)
  4690. args = args.filter(function(x) {return !x.next;});
  4691. state.splice.apply(state, args);
  4692. i--;
  4693. toInsert = null;
  4694. }
  4695. if (rule.keywordMap) {
  4696. rule.token = this.createKeywordMapper(
  4697. rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
  4698. );
  4699. delete rule.defaultToken;
  4700. }
  4701. }
  4702. }
  4703. Object.keys(rules).forEach(processState, this);
  4704. };
  4705. this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
  4706. var keywords = Object.create(null);
  4707. Object.keys(map).forEach(function(className) {
  4708. var a = map[className];
  4709. if (ignoreCase)
  4710. a = a.toLowerCase();
  4711. var list = a.split(splitChar || "|");
  4712. for (var i = list.length; i--; )
  4713. keywords[list[i]] = className;
  4714. });
  4715. if (Object.getPrototypeOf(keywords)) {
  4716. keywords.__proto__ = null;
  4717. }
  4718. this.$keywordList = Object.keys(keywords);
  4719. map = null;
  4720. return ignoreCase
  4721. ? function(value) {return keywords[value.toLowerCase()] || defaultToken }
  4722. : function(value) {return keywords[value] || defaultToken };
  4723. };
  4724. this.getKeywords = function() {
  4725. return this.$keywords;
  4726. };
  4727. }).call(TextHighlightRules.prototype);
  4728. exports.TextHighlightRules = TextHighlightRules;
  4729. });
  4730. ace.define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
  4731. "use strict";
  4732. var Behaviour = function() {
  4733. this.$behaviours = {};
  4734. };
  4735. (function () {
  4736. this.add = function (name, action, callback) {
  4737. switch (undefined) {
  4738. case this.$behaviours:
  4739. this.$behaviours = {};
  4740. case this.$behaviours[name]:
  4741. this.$behaviours[name] = {};
  4742. }
  4743. this.$behaviours[name][action] = callback;
  4744. }
  4745. this.addBehaviours = function (behaviours) {
  4746. for (var key in behaviours) {
  4747. for (var action in behaviours[key]) {
  4748. this.add(key, action, behaviours[key][action]);
  4749. }
  4750. }
  4751. }
  4752. this.remove = function (name) {
  4753. if (this.$behaviours && this.$behaviours[name]) {
  4754. delete this.$behaviours[name];
  4755. }
  4756. }
  4757. this.inherit = function (mode, filter) {
  4758. if (typeof mode === "function") {
  4759. var behaviours = new mode().getBehaviours(filter);
  4760. } else {
  4761. var behaviours = mode.getBehaviours(filter);
  4762. }
  4763. this.addBehaviours(behaviours);
  4764. }
  4765. this.getBehaviours = function (filter) {
  4766. if (!filter) {
  4767. return this.$behaviours;
  4768. } else {
  4769. var ret = {}
  4770. for (var i = 0; i < filter.length; i++) {
  4771. if (this.$behaviours[filter[i]]) {
  4772. ret[filter[i]] = this.$behaviours[filter[i]];
  4773. }
  4774. }
  4775. return ret;
  4776. }
  4777. }
  4778. }).call(Behaviour.prototype);
  4779. exports.Behaviour = Behaviour;
  4780. });
  4781. ace.define("ace/unicode",["require","exports","module"], function(require, exports, module) {
  4782. "use strict";
  4783. exports.packages = {};
  4784. addUnicodePackage({
  4785. L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
  4786. Ll: "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A",
  4787. Lu: "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A",
  4788. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  4789. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  4790. Lo: "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
  4791. M: "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26",
  4792. Mn: "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26",
  4793. Mc: "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC",
  4794. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  4795. N: "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
  4796. Nd: "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
  4797. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  4798. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  4799. P: "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65",
  4800. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  4801. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  4802. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  4803. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  4804. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  4805. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  4806. Po: "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65",
  4807. S: "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD",
  4808. Sm: "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC",
  4809. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  4810. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  4811. So: "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD",
  4812. Z: "002000A01680180E2000-200A20282029202F205F3000",
  4813. Zs: "002000A01680180E2000-200A202F205F3000",
  4814. Zl: "2028",
  4815. Zp: "2029",
  4816. C: "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF",
  4817. Cc: "0000-001F007F-009F",
  4818. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  4819. Co: "E000-F8FF",
  4820. Cs: "D800-DFFF",
  4821. Cn: "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF"
  4822. });
  4823. function addUnicodePackage (pack) {
  4824. var codePoint = /\w{4}/g;
  4825. for (var name in pack)
  4826. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  4827. };
  4828. });
  4829. ace.define("ace/token_iterator",["require","exports","module"], function(require, exports, module) {
  4830. "use strict";
  4831. var TokenIterator = function(session, initialRow, initialColumn) {
  4832. this.$session = session;
  4833. this.$row = initialRow;
  4834. this.$rowTokens = session.getTokens(initialRow);
  4835. var token = session.getTokenAt(initialRow, initialColumn);
  4836. this.$tokenIndex = token ? token.index : -1;
  4837. };
  4838. (function() {
  4839. this.stepBackward = function() {
  4840. this.$tokenIndex -= 1;
  4841. while (this.$tokenIndex < 0) {
  4842. this.$row -= 1;
  4843. if (this.$row < 0) {
  4844. this.$row = 0;
  4845. return null;
  4846. }
  4847. this.$rowTokens = this.$session.getTokens(this.$row);
  4848. this.$tokenIndex = this.$rowTokens.length - 1;
  4849. }
  4850. return this.$rowTokens[this.$tokenIndex];
  4851. };
  4852. this.stepForward = function() {
  4853. this.$tokenIndex += 1;
  4854. var rowCount;
  4855. while (this.$tokenIndex >= this.$rowTokens.length) {
  4856. this.$row += 1;
  4857. if (!rowCount)
  4858. rowCount = this.$session.getLength();
  4859. if (this.$row >= rowCount) {
  4860. this.$row = rowCount - 1;
  4861. return null;
  4862. }
  4863. this.$rowTokens = this.$session.getTokens(this.$row);
  4864. this.$tokenIndex = 0;
  4865. }
  4866. return this.$rowTokens[this.$tokenIndex];
  4867. };
  4868. this.getCurrentToken = function () {
  4869. return this.$rowTokens[this.$tokenIndex];
  4870. };
  4871. this.getCurrentTokenRow = function () {
  4872. return this.$row;
  4873. };
  4874. this.getCurrentTokenColumn = function() {
  4875. var rowTokens = this.$rowTokens;
  4876. var tokenIndex = this.$tokenIndex;
  4877. var column = rowTokens[tokenIndex].start;
  4878. if (column !== undefined)
  4879. return column;
  4880. column = 0;
  4881. while (tokenIndex > 0) {
  4882. tokenIndex -= 1;
  4883. column += rowTokens[tokenIndex].value.length;
  4884. }
  4885. return column;
  4886. };
  4887. }).call(TokenIterator.prototype);
  4888. exports.TokenIterator = TokenIterator;
  4889. });
  4890. ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(require, exports, module) {
  4891. "use strict";
  4892. var Tokenizer = require("../tokenizer").Tokenizer;
  4893. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4894. var Behaviour = require("./behaviour").Behaviour;
  4895. var unicode = require("../unicode");
  4896. var lang = require("../lib/lang");
  4897. var TokenIterator = require("../token_iterator").TokenIterator;
  4898. var Range = require("../range").Range;
  4899. var Mode = function() {
  4900. this.HighlightRules = TextHighlightRules;
  4901. this.$behaviour = new Behaviour();
  4902. };
  4903. (function() {
  4904. this.tokenRe = new RegExp("^["
  4905. + unicode.packages.L
  4906. + unicode.packages.Mn + unicode.packages.Mc
  4907. + unicode.packages.Nd
  4908. + unicode.packages.Pc + "\\$_]+", "g"
  4909. );
  4910. this.nonTokenRe = new RegExp("^(?:[^"
  4911. + unicode.packages.L
  4912. + unicode.packages.Mn + unicode.packages.Mc
  4913. + unicode.packages.Nd
  4914. + unicode.packages.Pc + "\\$_]|\\s])+", "g"
  4915. );
  4916. this.getTokenizer = function() {
  4917. if (!this.$tokenizer) {
  4918. this.$highlightRules = this.$highlightRules || new this.HighlightRules();
  4919. this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
  4920. }
  4921. return this.$tokenizer;
  4922. };
  4923. this.lineCommentStart = "";
  4924. this.blockComment = "";
  4925. this.toggleCommentLines = function(state, session, startRow, endRow) {
  4926. var doc = session.doc;
  4927. var ignoreBlankLines = true;
  4928. var shouldRemove = true;
  4929. var minIndent = Infinity;
  4930. var tabSize = session.getTabSize();
  4931. var insertAtTabStop = false;
  4932. if (!this.lineCommentStart) {
  4933. if (!this.blockComment)
  4934. return false;
  4935. var lineCommentStart = this.blockComment.start;
  4936. var lineCommentEnd = this.blockComment.end;
  4937. var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
  4938. var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
  4939. var comment = function(line, i) {
  4940. if (testRemove(line, i))
  4941. return;
  4942. if (!ignoreBlankLines || /\S/.test(line)) {
  4943. doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
  4944. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  4945. }
  4946. };
  4947. var uncomment = function(line, i) {
  4948. var m;
  4949. if (m = line.match(regexpEnd))
  4950. doc.removeInLine(i, line.length - m[0].length, line.length);
  4951. if (m = line.match(regexpStart))
  4952. doc.removeInLine(i, m[1].length, m[0].length);
  4953. };
  4954. var testRemove = function(line, row) {
  4955. if (regexpStart.test(line))
  4956. return true;
  4957. var tokens = session.getTokens(row);
  4958. for (var i = 0; i < tokens.length; i++) {
  4959. if (tokens[i].type === 'comment')
  4960. return true;
  4961. }
  4962. };
  4963. } else {
  4964. if (Array.isArray(this.lineCommentStart)) {
  4965. var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
  4966. var lineCommentStart = this.lineCommentStart[0];
  4967. } else {
  4968. var regexpStart = lang.escapeRegExp(this.lineCommentStart);
  4969. var lineCommentStart = this.lineCommentStart;
  4970. }
  4971. regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
  4972. insertAtTabStop = session.getUseSoftTabs();
  4973. var uncomment = function(line, i) {
  4974. var m = line.match(regexpStart);
  4975. if (!m) return;
  4976. var start = m[1].length, end = m[0].length;
  4977. if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
  4978. end--;
  4979. doc.removeInLine(i, start, end);
  4980. };
  4981. var commentWithSpace = lineCommentStart + " ";
  4982. var comment = function(line, i) {
  4983. if (!ignoreBlankLines || /\S/.test(line)) {
  4984. if (shouldInsertSpace(line, minIndent, minIndent))
  4985. doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
  4986. else
  4987. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  4988. }
  4989. };
  4990. var testRemove = function(line, i) {
  4991. return regexpStart.test(line);
  4992. };
  4993. var shouldInsertSpace = function(line, before, after) {
  4994. var spaces = 0;
  4995. while (before-- && line.charAt(before) == " ")
  4996. spaces++;
  4997. if (spaces % tabSize != 0)
  4998. return false;
  4999. var spaces = 0;
  5000. while (line.charAt(after++) == " ")
  5001. spaces++;
  5002. if (tabSize > 2)
  5003. return spaces % tabSize != tabSize - 1;
  5004. else
  5005. return spaces % tabSize == 0;
  5006. return true;
  5007. };
  5008. }
  5009. function iter(fun) {
  5010. for (var i = startRow; i <= endRow; i++)
  5011. fun(doc.getLine(i), i);
  5012. }
  5013. var minEmptyLength = Infinity;
  5014. iter(function(line, i) {
  5015. var indent = line.search(/\S/);
  5016. if (indent !== -1) {
  5017. if (indent < minIndent)
  5018. minIndent = indent;
  5019. if (shouldRemove && !testRemove(line, i))
  5020. shouldRemove = false;
  5021. } else if (minEmptyLength > line.length) {
  5022. minEmptyLength = line.length;
  5023. }
  5024. });
  5025. if (minIndent == Infinity) {
  5026. minIndent = minEmptyLength;
  5027. ignoreBlankLines = false;
  5028. shouldRemove = false;
  5029. }
  5030. if (insertAtTabStop && minIndent % tabSize != 0)
  5031. minIndent = Math.floor(minIndent / tabSize) * tabSize;
  5032. iter(shouldRemove ? uncomment : comment);
  5033. };
  5034. this.toggleBlockComment = function(state, session, range, cursor) {
  5035. var comment = this.blockComment;
  5036. if (!comment)
  5037. return;
  5038. if (!comment.start && comment[0])
  5039. comment = comment[0];
  5040. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5041. var token = iterator.getCurrentToken();
  5042. var sel = session.selection;
  5043. var initialRange = session.selection.toOrientedRange();
  5044. var startRow, colDiff;
  5045. if (token && /comment/.test(token.type)) {
  5046. var startRange, endRange;
  5047. while (token && /comment/.test(token.type)) {
  5048. var i = token.value.indexOf(comment.start);
  5049. if (i != -1) {
  5050. var row = iterator.getCurrentTokenRow();
  5051. var column = iterator.getCurrentTokenColumn() + i;
  5052. startRange = new Range(row, column, row, column + comment.start.length);
  5053. break;
  5054. }
  5055. token = iterator.stepBackward();
  5056. }
  5057. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5058. var token = iterator.getCurrentToken();
  5059. while (token && /comment/.test(token.type)) {
  5060. var i = token.value.indexOf(comment.end);
  5061. if (i != -1) {
  5062. var row = iterator.getCurrentTokenRow();
  5063. var column = iterator.getCurrentTokenColumn() + i;
  5064. endRange = new Range(row, column, row, column + comment.end.length);
  5065. break;
  5066. }
  5067. token = iterator.stepForward();
  5068. }
  5069. if (endRange)
  5070. session.remove(endRange);
  5071. if (startRange) {
  5072. session.remove(startRange);
  5073. startRow = startRange.start.row;
  5074. colDiff = -comment.start.length;
  5075. }
  5076. } else {
  5077. colDiff = comment.start.length;
  5078. startRow = range.start.row;
  5079. session.insert(range.end, comment.end);
  5080. session.insert(range.start, comment.start);
  5081. }
  5082. if (initialRange.start.row == startRow)
  5083. initialRange.start.column += colDiff;
  5084. if (initialRange.end.row == startRow)
  5085. initialRange.end.column += colDiff;
  5086. session.selection.fromOrientedRange(initialRange);
  5087. };
  5088. this.getNextLineIndent = function(state, line, tab) {
  5089. return this.$getIndent(line);
  5090. };
  5091. this.checkOutdent = function(state, line, input) {
  5092. return false;
  5093. };
  5094. this.autoOutdent = function(state, doc, row) {
  5095. };
  5096. this.$getIndent = function(line) {
  5097. return line.match(/^\s*/)[0];
  5098. };
  5099. this.createWorker = function(session) {
  5100. return null;
  5101. };
  5102. this.createModeDelegates = function (mapping) {
  5103. this.$embeds = [];
  5104. this.$modes = {};
  5105. for (var i in mapping) {
  5106. if (mapping[i]) {
  5107. this.$embeds.push(i);
  5108. this.$modes[i] = new mapping[i]();
  5109. }
  5110. }
  5111. var delegations = ['toggleBlockComment', 'toggleCommentLines', 'getNextLineIndent',
  5112. 'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions'];
  5113. for (var i = 0; i < delegations.length; i++) {
  5114. (function(scope) {
  5115. var functionName = delegations[i];
  5116. var defaultHandler = scope[functionName];
  5117. scope[delegations[i]] = function() {
  5118. return this.$delegator(functionName, arguments, defaultHandler);
  5119. };
  5120. } (this));
  5121. }
  5122. };
  5123. this.$delegator = function(method, args, defaultHandler) {
  5124. var state = args[0];
  5125. if (typeof state != "string")
  5126. state = state[0];
  5127. for (var i = 0; i < this.$embeds.length; i++) {
  5128. if (!this.$modes[this.$embeds[i]]) continue;
  5129. var split = state.split(this.$embeds[i]);
  5130. if (!split[0] && split[1]) {
  5131. args[0] = split[1];
  5132. var mode = this.$modes[this.$embeds[i]];
  5133. return mode[method].apply(mode, args);
  5134. }
  5135. }
  5136. var ret = defaultHandler.apply(this, args);
  5137. return defaultHandler ? ret : undefined;
  5138. };
  5139. this.transformAction = function(state, action, editor, session, param) {
  5140. if (this.$behaviour) {
  5141. var behaviours = this.$behaviour.getBehaviours();
  5142. for (var key in behaviours) {
  5143. if (behaviours[key][action]) {
  5144. var ret = behaviours[key][action].apply(this, arguments);
  5145. if (ret) {
  5146. return ret;
  5147. }
  5148. }
  5149. }
  5150. }
  5151. };
  5152. this.getKeywords = function(append) {
  5153. if (!this.completionKeywords) {
  5154. var rules = this.$tokenizer.rules;
  5155. var completionKeywords = [];
  5156. for (var rule in rules) {
  5157. var ruleItr = rules[rule];
  5158. for (var r = 0, l = ruleItr.length; r < l; r++) {
  5159. if (typeof ruleItr[r].token === "string") {
  5160. if (/keyword|support|storage/.test(ruleItr[r].token))
  5161. completionKeywords.push(ruleItr[r].regex);
  5162. }
  5163. else if (typeof ruleItr[r].token === "object") {
  5164. for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
  5165. if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
  5166. var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
  5167. completionKeywords.push(rule.substr(1, rule.length - 2));
  5168. }
  5169. }
  5170. }
  5171. }
  5172. }
  5173. this.completionKeywords = completionKeywords;
  5174. }
  5175. if (!append)
  5176. return this.$keywordList;
  5177. return completionKeywords.concat(this.$keywordList || []);
  5178. };
  5179. this.$createKeywordList = function() {
  5180. if (!this.$highlightRules)
  5181. this.getTokenizer();
  5182. return this.$keywordList = this.$highlightRules.$keywordList || [];
  5183. };
  5184. this.getCompletions = function(state, session, pos, prefix) {
  5185. var keywords = this.$keywordList || this.$createKeywordList();
  5186. return keywords.map(function(word) {
  5187. return {
  5188. name: word,
  5189. value: word,
  5190. score: 0,
  5191. meta: "keyword"
  5192. };
  5193. });
  5194. };
  5195. this.$id = "ace/mode/text";
  5196. }).call(Mode.prototype);
  5197. exports.Mode = Mode;
  5198. });
  5199. ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5200. "use strict";
  5201. var oop = require("./lib/oop");
  5202. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5203. var Anchor = exports.Anchor = function(doc, row, column) {
  5204. this.$onChange = this.onChange.bind(this);
  5205. this.attach(doc);
  5206. if (typeof column == "undefined")
  5207. this.setPosition(row.row, row.column);
  5208. else
  5209. this.setPosition(row, column);
  5210. };
  5211. (function() {
  5212. oop.implement(this, EventEmitter);
  5213. this.getPosition = function() {
  5214. return this.$clipPositionToDocument(this.row, this.column);
  5215. };
  5216. this.getDocument = function() {
  5217. return this.document;
  5218. };
  5219. this.$insertRight = false;
  5220. this.onChange = function(e) {
  5221. var delta = e.data;
  5222. var range = delta.range;
  5223. if (range.start.row == range.end.row && range.start.row != this.row)
  5224. return;
  5225. if (range.start.row > this.row)
  5226. return;
  5227. if (range.start.row == this.row && range.start.column > this.column)
  5228. return;
  5229. var row = this.row;
  5230. var column = this.column;
  5231. var start = range.start;
  5232. var end = range.end;
  5233. if (delta.action === "insertText") {
  5234. if (start.row === row && start.column <= column) {
  5235. if (start.column === column && this.$insertRight) {
  5236. } else if (start.row === end.row) {
  5237. column += end.column - start.column;
  5238. } else {
  5239. column -= start.column;
  5240. row += end.row - start.row;
  5241. }
  5242. } else if (start.row !== end.row && start.row < row) {
  5243. row += end.row - start.row;
  5244. }
  5245. } else if (delta.action === "insertLines") {
  5246. if (start.row === row && column === 0 && this.$insertRight) {
  5247. }
  5248. else if (start.row <= row) {
  5249. row += end.row - start.row;
  5250. }
  5251. } else if (delta.action === "removeText") {
  5252. if (start.row === row && start.column < column) {
  5253. if (end.column >= column)
  5254. column = start.column;
  5255. else
  5256. column = Math.max(0, column - (end.column - start.column));
  5257. } else if (start.row !== end.row && start.row < row) {
  5258. if (end.row === row)
  5259. column = Math.max(0, column - end.column) + start.column;
  5260. row -= (end.row - start.row);
  5261. } else if (end.row === row) {
  5262. row -= end.row - start.row;
  5263. column = Math.max(0, column - end.column) + start.column;
  5264. }
  5265. } else if (delta.action == "removeLines") {
  5266. if (start.row <= row) {
  5267. if (end.row <= row)
  5268. row -= end.row - start.row;
  5269. else {
  5270. row = start.row;
  5271. column = 0;
  5272. }
  5273. }
  5274. }
  5275. this.setPosition(row, column, true);
  5276. };
  5277. this.setPosition = function(row, column, noClip) {
  5278. var pos;
  5279. if (noClip) {
  5280. pos = {
  5281. row: row,
  5282. column: column
  5283. };
  5284. } else {
  5285. pos = this.$clipPositionToDocument(row, column);
  5286. }
  5287. if (this.row == pos.row && this.column == pos.column)
  5288. return;
  5289. var old = {
  5290. row: this.row,
  5291. column: this.column
  5292. };
  5293. this.row = pos.row;
  5294. this.column = pos.column;
  5295. this._signal("change", {
  5296. old: old,
  5297. value: pos
  5298. });
  5299. };
  5300. this.detach = function() {
  5301. this.document.removeEventListener("change", this.$onChange);
  5302. };
  5303. this.attach = function(doc) {
  5304. this.document = doc || this.document;
  5305. this.document.on("change", this.$onChange);
  5306. };
  5307. this.$clipPositionToDocument = function(row, column) {
  5308. var pos = {};
  5309. if (row >= this.document.getLength()) {
  5310. pos.row = Math.max(0, this.document.getLength() - 1);
  5311. pos.column = this.document.getLine(pos.row).length;
  5312. }
  5313. else if (row < 0) {
  5314. pos.row = 0;
  5315. pos.column = 0;
  5316. }
  5317. else {
  5318. pos.row = row;
  5319. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  5320. }
  5321. if (column < 0)
  5322. pos.column = 0;
  5323. return pos;
  5324. };
  5325. }).call(Anchor.prototype);
  5326. });
  5327. ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  5328. "use strict";
  5329. var oop = require("./lib/oop");
  5330. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5331. var Range = require("./range").Range;
  5332. var Anchor = require("./anchor").Anchor;
  5333. var Document = function(text) {
  5334. this.$lines = [];
  5335. if (text.length === 0) {
  5336. this.$lines = [""];
  5337. } else if (Array.isArray(text)) {
  5338. this._insertLines(0, text);
  5339. } else {
  5340. this.insert({row: 0, column:0}, text);
  5341. }
  5342. };
  5343. (function() {
  5344. oop.implement(this, EventEmitter);
  5345. this.setValue = function(text) {
  5346. var len = this.getLength();
  5347. this.remove(new Range(0, 0, len, this.getLine(len-1).length));
  5348. this.insert({row: 0, column:0}, text);
  5349. };
  5350. this.getValue = function() {
  5351. return this.getAllLines().join(this.getNewLineCharacter());
  5352. };
  5353. this.createAnchor = function(row, column) {
  5354. return new Anchor(this, row, column);
  5355. };
  5356. if ("aaa".split(/a/).length === 0)
  5357. this.$split = function(text) {
  5358. return text.replace(/\r\n|\r/g, "\n").split("\n");
  5359. };
  5360. else
  5361. this.$split = function(text) {
  5362. return text.split(/\r\n|\r|\n/);
  5363. };
  5364. this.$detectNewLine = function(text) {
  5365. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  5366. this.$autoNewLine = match ? match[1] : "\n";
  5367. this._signal("changeNewLineMode");
  5368. };
  5369. this.getNewLineCharacter = function() {
  5370. switch (this.$newLineMode) {
  5371. case "windows":
  5372. return "\r\n";
  5373. case "unix":
  5374. return "\n";
  5375. default:
  5376. return this.$autoNewLine || "\n";
  5377. }
  5378. };
  5379. this.$autoNewLine = "";
  5380. this.$newLineMode = "auto";
  5381. this.setNewLineMode = function(newLineMode) {
  5382. if (this.$newLineMode === newLineMode)
  5383. return;
  5384. this.$newLineMode = newLineMode;
  5385. this._signal("changeNewLineMode");
  5386. };
  5387. this.getNewLineMode = function() {
  5388. return this.$newLineMode;
  5389. };
  5390. this.isNewLine = function(text) {
  5391. return (text == "\r\n" || text == "\r" || text == "\n");
  5392. };
  5393. this.getLine = function(row) {
  5394. return this.$lines[row] || "";
  5395. };
  5396. this.getLines = function(firstRow, lastRow) {
  5397. return this.$lines.slice(firstRow, lastRow + 1);
  5398. };
  5399. this.getAllLines = function() {
  5400. return this.getLines(0, this.getLength());
  5401. };
  5402. this.getLength = function() {
  5403. return this.$lines.length;
  5404. };
  5405. this.getTextRange = function(range) {
  5406. if (range.start.row == range.end.row) {
  5407. return this.getLine(range.start.row)
  5408. .substring(range.start.column, range.end.column);
  5409. }
  5410. var lines = this.getLines(range.start.row, range.end.row);
  5411. lines[0] = (lines[0] || "").substring(range.start.column);
  5412. var l = lines.length - 1;
  5413. if (range.end.row - range.start.row == l)
  5414. lines[l] = lines[l].substring(0, range.end.column);
  5415. return lines.join(this.getNewLineCharacter());
  5416. };
  5417. this.$clipPosition = function(position) {
  5418. var length = this.getLength();
  5419. if (position.row >= length) {
  5420. position.row = Math.max(0, length - 1);
  5421. position.column = this.getLine(length-1).length;
  5422. } else if (position.row < 0)
  5423. position.row = 0;
  5424. return position;
  5425. };
  5426. this.insert = function(position, text) {
  5427. if (!text || text.length === 0)
  5428. return position;
  5429. position = this.$clipPosition(position);
  5430. if (this.getLength() <= 1)
  5431. this.$detectNewLine(text);
  5432. var lines = this.$split(text);
  5433. var firstLine = lines.splice(0, 1)[0];
  5434. var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
  5435. position = this.insertInLine(position, firstLine);
  5436. if (lastLine !== null) {
  5437. position = this.insertNewLine(position); // terminate first line
  5438. position = this._insertLines(position.row, lines);
  5439. position = this.insertInLine(position, lastLine || "");
  5440. }
  5441. return position;
  5442. };
  5443. this.insertLines = function(row, lines) {
  5444. if (row >= this.getLength())
  5445. return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
  5446. return this._insertLines(Math.max(row, 0), lines);
  5447. };
  5448. this._insertLines = function(row, lines) {
  5449. if (lines.length == 0)
  5450. return {row: row, column: 0};
  5451. while (lines.length > 0xF000) {
  5452. var end = this._insertLines(row, lines.slice(0, 0xF000));
  5453. lines = lines.slice(0xF000);
  5454. row = end.row;
  5455. }
  5456. var args = [row, 0];
  5457. args.push.apply(args, lines);
  5458. this.$lines.splice.apply(this.$lines, args);
  5459. var range = new Range(row, 0, row + lines.length, 0);
  5460. var delta = {
  5461. action: "insertLines",
  5462. range: range,
  5463. lines: lines
  5464. };
  5465. this._signal("change", { data: delta });
  5466. return range.end;
  5467. };
  5468. this.insertNewLine = function(position) {
  5469. position = this.$clipPosition(position);
  5470. var line = this.$lines[position.row] || "";
  5471. this.$lines[position.row] = line.substring(0, position.column);
  5472. this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
  5473. var end = {
  5474. row : position.row + 1,
  5475. column : 0
  5476. };
  5477. var delta = {
  5478. action: "insertText",
  5479. range: Range.fromPoints(position, end),
  5480. text: this.getNewLineCharacter()
  5481. };
  5482. this._signal("change", { data: delta });
  5483. return end;
  5484. };
  5485. this.insertInLine = function(position, text) {
  5486. if (text.length == 0)
  5487. return position;
  5488. var line = this.$lines[position.row] || "";
  5489. this.$lines[position.row] = line.substring(0, position.column) + text
  5490. + line.substring(position.column);
  5491. var end = {
  5492. row : position.row,
  5493. column : position.column + text.length
  5494. };
  5495. var delta = {
  5496. action: "insertText",
  5497. range: Range.fromPoints(position, end),
  5498. text: text
  5499. };
  5500. this._signal("change", { data: delta });
  5501. return end;
  5502. };
  5503. this.remove = function(range) {
  5504. if (!(range instanceof Range))
  5505. range = Range.fromPoints(range.start, range.end);
  5506. range.start = this.$clipPosition(range.start);
  5507. range.end = this.$clipPosition(range.end);
  5508. if (range.isEmpty())
  5509. return range.start;
  5510. var firstRow = range.start.row;
  5511. var lastRow = range.end.row;
  5512. if (range.isMultiLine()) {
  5513. var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
  5514. var lastFullRow = lastRow - 1;
  5515. if (range.end.column > 0)
  5516. this.removeInLine(lastRow, 0, range.end.column);
  5517. if (lastFullRow >= firstFullRow)
  5518. this._removeLines(firstFullRow, lastFullRow);
  5519. if (firstFullRow != firstRow) {
  5520. this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
  5521. this.removeNewLine(range.start.row);
  5522. }
  5523. }
  5524. else {
  5525. this.removeInLine(firstRow, range.start.column, range.end.column);
  5526. }
  5527. return range.start;
  5528. };
  5529. this.removeInLine = function(row, startColumn, endColumn) {
  5530. if (startColumn == endColumn)
  5531. return;
  5532. var range = new Range(row, startColumn, row, endColumn);
  5533. var line = this.getLine(row);
  5534. var removed = line.substring(startColumn, endColumn);
  5535. var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
  5536. this.$lines.splice(row, 1, newLine);
  5537. var delta = {
  5538. action: "removeText",
  5539. range: range,
  5540. text: removed
  5541. };
  5542. this._signal("change", { data: delta });
  5543. return range.start;
  5544. };
  5545. this.removeLines = function(firstRow, lastRow) {
  5546. if (firstRow < 0 || lastRow >= this.getLength())
  5547. return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
  5548. return this._removeLines(firstRow, lastRow);
  5549. };
  5550. this._removeLines = function(firstRow, lastRow) {
  5551. var range = new Range(firstRow, 0, lastRow + 1, 0);
  5552. var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
  5553. var delta = {
  5554. action: "removeLines",
  5555. range: range,
  5556. nl: this.getNewLineCharacter(),
  5557. lines: removed
  5558. };
  5559. this._signal("change", { data: delta });
  5560. return removed;
  5561. };
  5562. this.removeNewLine = function(row) {
  5563. var firstLine = this.getLine(row);
  5564. var secondLine = this.getLine(row+1);
  5565. var range = new Range(row, firstLine.length, row+1, 0);
  5566. var line = firstLine + secondLine;
  5567. this.$lines.splice(row, 2, line);
  5568. var delta = {
  5569. action: "removeText",
  5570. range: range,
  5571. text: this.getNewLineCharacter()
  5572. };
  5573. this._signal("change", { data: delta });
  5574. };
  5575. this.replace = function(range, text) {
  5576. if (!(range instanceof Range))
  5577. range = Range.fromPoints(range.start, range.end);
  5578. if (text.length == 0 && range.isEmpty())
  5579. return range.start;
  5580. if (text == this.getTextRange(range))
  5581. return range.end;
  5582. this.remove(range);
  5583. if (text) {
  5584. var end = this.insert(range.start, text);
  5585. }
  5586. else {
  5587. end = range.start;
  5588. }
  5589. return end;
  5590. };
  5591. this.applyDeltas = function(deltas) {
  5592. for (var i=0; i<deltas.length; i++) {
  5593. var delta = deltas[i];
  5594. var range = Range.fromPoints(delta.range.start, delta.range.end);
  5595. if (delta.action == "insertLines")
  5596. this.insertLines(range.start.row, delta.lines);
  5597. else if (delta.action == "insertText")
  5598. this.insert(range.start, delta.text);
  5599. else if (delta.action == "removeLines")
  5600. this._removeLines(range.start.row, range.end.row - 1);
  5601. else if (delta.action == "removeText")
  5602. this.remove(range);
  5603. }
  5604. };
  5605. this.revertDeltas = function(deltas) {
  5606. for (var i=deltas.length-1; i>=0; i--) {
  5607. var delta = deltas[i];
  5608. var range = Range.fromPoints(delta.range.start, delta.range.end);
  5609. if (delta.action == "insertLines")
  5610. this._removeLines(range.start.row, range.end.row - 1);
  5611. else if (delta.action == "insertText")
  5612. this.remove(range);
  5613. else if (delta.action == "removeLines")
  5614. this._insertLines(range.start.row, delta.lines);
  5615. else if (delta.action == "removeText")
  5616. this.insert(range.start, delta.text);
  5617. }
  5618. };
  5619. this.indexToPosition = function(index, startRow) {
  5620. var lines = this.$lines || this.getAllLines();
  5621. var newlineLength = this.getNewLineCharacter().length;
  5622. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  5623. index -= lines[i].length + newlineLength;
  5624. if (index < 0)
  5625. return {row: i, column: index + lines[i].length + newlineLength};
  5626. }
  5627. return {row: l-1, column: lines[l-1].length};
  5628. };
  5629. this.positionToIndex = function(pos, startRow) {
  5630. var lines = this.$lines || this.getAllLines();
  5631. var newlineLength = this.getNewLineCharacter().length;
  5632. var index = 0;
  5633. var row = Math.min(pos.row, lines.length);
  5634. for (var i = startRow || 0; i < row; ++i)
  5635. index += lines[i].length + newlineLength;
  5636. return index + pos.column;
  5637. };
  5638. }).call(Document.prototype);
  5639. exports.Document = Document;
  5640. });
  5641. ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5642. "use strict";
  5643. var oop = require("./lib/oop");
  5644. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5645. var BackgroundTokenizer = function(tokenizer, editor) {
  5646. this.running = false;
  5647. this.lines = [];
  5648. this.states = [];
  5649. this.currentLine = 0;
  5650. this.tokenizer = tokenizer;
  5651. var self = this;
  5652. this.$worker = function() {
  5653. if (!self.running) { return; }
  5654. var workerStart = new Date();
  5655. var currentLine = self.currentLine;
  5656. var endLine = -1;
  5657. var doc = self.doc;
  5658. while (self.lines[currentLine])
  5659. currentLine++;
  5660. var startLine = currentLine;
  5661. var len = doc.getLength();
  5662. var processedLines = 0;
  5663. self.running = false;
  5664. while (currentLine < len) {
  5665. self.$tokenizeRow(currentLine);
  5666. endLine = currentLine;
  5667. do {
  5668. currentLine++;
  5669. } while (self.lines[currentLine]);
  5670. processedLines ++;
  5671. if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
  5672. self.running = setTimeout(self.$worker, 20);
  5673. break;
  5674. }
  5675. }
  5676. self.currentLine = currentLine;
  5677. if (startLine <= endLine)
  5678. self.fireUpdateEvent(startLine, endLine);
  5679. };
  5680. };
  5681. (function(){
  5682. oop.implement(this, EventEmitter);
  5683. this.setTokenizer = function(tokenizer) {
  5684. this.tokenizer = tokenizer;
  5685. this.lines = [];
  5686. this.states = [];
  5687. this.start(0);
  5688. };
  5689. this.setDocument = function(doc) {
  5690. this.doc = doc;
  5691. this.lines = [];
  5692. this.states = [];
  5693. this.stop();
  5694. };
  5695. this.fireUpdateEvent = function(firstRow, lastRow) {
  5696. var data = {
  5697. first: firstRow,
  5698. last: lastRow
  5699. };
  5700. this._signal("update", {data: data});
  5701. };
  5702. this.start = function(startRow) {
  5703. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  5704. this.lines.splice(this.currentLine, this.lines.length);
  5705. this.states.splice(this.currentLine, this.states.length);
  5706. this.stop();
  5707. this.running = setTimeout(this.$worker, 700);
  5708. };
  5709. this.scheduleStart = function() {
  5710. if (!this.running)
  5711. this.running = setTimeout(this.$worker, 700);
  5712. }
  5713. this.$updateOnChange = function(delta) {
  5714. var range = delta.range;
  5715. var startRow = range.start.row;
  5716. var len = range.end.row - startRow;
  5717. if (len === 0) {
  5718. this.lines[startRow] = null;
  5719. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  5720. this.lines.splice(startRow, len + 1, null);
  5721. this.states.splice(startRow, len + 1, null);
  5722. } else {
  5723. var args = Array(len + 1);
  5724. args.unshift(startRow, 1);
  5725. this.lines.splice.apply(this.lines, args);
  5726. this.states.splice.apply(this.states, args);
  5727. }
  5728. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  5729. this.stop();
  5730. };
  5731. this.stop = function() {
  5732. if (this.running)
  5733. clearTimeout(this.running);
  5734. this.running = false;
  5735. };
  5736. this.getTokens = function(row) {
  5737. return this.lines[row] || this.$tokenizeRow(row);
  5738. };
  5739. this.getState = function(row) {
  5740. if (this.currentLine == row)
  5741. this.$tokenizeRow(row);
  5742. return this.states[row] || "start";
  5743. };
  5744. this.$tokenizeRow = function(row) {
  5745. var line = this.doc.getLine(row);
  5746. var state = this.states[row - 1];
  5747. var data = this.tokenizer.getLineTokens(line, state, row);
  5748. if (this.states[row] + "" !== data.state + "") {
  5749. this.states[row] = data.state;
  5750. this.lines[row + 1] = null;
  5751. if (this.currentLine > row + 1)
  5752. this.currentLine = row + 1;
  5753. } else if (this.currentLine == row) {
  5754. this.currentLine = row + 1;
  5755. }
  5756. return this.lines[row] = data.tokens;
  5757. };
  5758. }).call(BackgroundTokenizer.prototype);
  5759. exports.BackgroundTokenizer = BackgroundTokenizer;
  5760. });
  5761. ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  5762. "use strict";
  5763. var lang = require("./lib/lang");
  5764. var oop = require("./lib/oop");
  5765. var Range = require("./range").Range;
  5766. var SearchHighlight = function(regExp, clazz, type) {
  5767. this.setRegexp(regExp);
  5768. this.clazz = clazz;
  5769. this.type = type || "text";
  5770. };
  5771. (function() {
  5772. this.MAX_RANGES = 500;
  5773. this.setRegexp = function(regExp) {
  5774. if (this.regExp+"" == regExp+"")
  5775. return;
  5776. this.regExp = regExp;
  5777. this.cache = [];
  5778. };
  5779. this.update = function(html, markerLayer, session, config) {
  5780. if (!this.regExp)
  5781. return;
  5782. var start = config.firstRow, end = config.lastRow;
  5783. for (var i = start; i <= end; i++) {
  5784. var ranges = this.cache[i];
  5785. if (ranges == null) {
  5786. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  5787. if (ranges.length > this.MAX_RANGES)
  5788. ranges = ranges.slice(0, this.MAX_RANGES);
  5789. ranges = ranges.map(function(match) {
  5790. return new Range(i, match.offset, i, match.offset + match.length);
  5791. });
  5792. this.cache[i] = ranges.length ? ranges : "";
  5793. }
  5794. for (var j = ranges.length; j --; ) {
  5795. markerLayer.drawSingleLineMarker(
  5796. html, ranges[j].toScreenRange(session), this.clazz, config);
  5797. }
  5798. }
  5799. };
  5800. }).call(SearchHighlight.prototype);
  5801. exports.SearchHighlight = SearchHighlight;
  5802. });
  5803. ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
  5804. "use strict";
  5805. var Range = require("../range").Range;
  5806. function FoldLine(foldData, folds) {
  5807. this.foldData = foldData;
  5808. if (Array.isArray(folds)) {
  5809. this.folds = folds;
  5810. } else {
  5811. folds = this.folds = [ folds ];
  5812. }
  5813. var last = folds[folds.length - 1];
  5814. this.range = new Range(folds[0].start.row, folds[0].start.column,
  5815. last.end.row, last.end.column);
  5816. this.start = this.range.start;
  5817. this.end = this.range.end;
  5818. this.folds.forEach(function(fold) {
  5819. fold.setFoldLine(this);
  5820. }, this);
  5821. }
  5822. (function() {
  5823. this.shiftRow = function(shift) {
  5824. this.start.row += shift;
  5825. this.end.row += shift;
  5826. this.folds.forEach(function(fold) {
  5827. fold.start.row += shift;
  5828. fold.end.row += shift;
  5829. });
  5830. };
  5831. this.addFold = function(fold) {
  5832. if (fold.sameRow) {
  5833. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  5834. throw new Error("Can't add a fold to this FoldLine as it has no connection");
  5835. }
  5836. this.folds.push(fold);
  5837. this.folds.sort(function(a, b) {
  5838. return -a.range.compareEnd(b.start.row, b.start.column);
  5839. });
  5840. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  5841. this.end.row = fold.end.row;
  5842. this.end.column = fold.end.column;
  5843. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  5844. this.start.row = fold.start.row;
  5845. this.start.column = fold.start.column;
  5846. }
  5847. } else if (fold.start.row == this.end.row) {
  5848. this.folds.push(fold);
  5849. this.end.row = fold.end.row;
  5850. this.end.column = fold.end.column;
  5851. } else if (fold.end.row == this.start.row) {
  5852. this.folds.unshift(fold);
  5853. this.start.row = fold.start.row;
  5854. this.start.column = fold.start.column;
  5855. } else {
  5856. throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
  5857. }
  5858. fold.foldLine = this;
  5859. };
  5860. this.containsRow = function(row) {
  5861. return row >= this.start.row && row <= this.end.row;
  5862. };
  5863. this.walk = function(callback, endRow, endColumn) {
  5864. var lastEnd = 0,
  5865. folds = this.folds,
  5866. fold,
  5867. cmp, stop, isNewRow = true;
  5868. if (endRow == null) {
  5869. endRow = this.end.row;
  5870. endColumn = this.end.column;
  5871. }
  5872. for (var i = 0; i < folds.length; i++) {
  5873. fold = folds[i];
  5874. cmp = fold.range.compareStart(endRow, endColumn);
  5875. if (cmp == -1) {
  5876. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5877. return;
  5878. }
  5879. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  5880. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  5881. if (stop || cmp === 0) {
  5882. return;
  5883. }
  5884. isNewRow = !fold.sameRow;
  5885. lastEnd = fold.end.column;
  5886. }
  5887. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5888. };
  5889. this.getNextFoldTo = function(row, column) {
  5890. var fold, cmp;
  5891. for (var i = 0; i < this.folds.length; i++) {
  5892. fold = this.folds[i];
  5893. cmp = fold.range.compareEnd(row, column);
  5894. if (cmp == -1) {
  5895. return {
  5896. fold: fold,
  5897. kind: "after"
  5898. };
  5899. } else if (cmp === 0) {
  5900. return {
  5901. fold: fold,
  5902. kind: "inside"
  5903. };
  5904. }
  5905. }
  5906. return null;
  5907. };
  5908. this.addRemoveChars = function(row, column, len) {
  5909. var ret = this.getNextFoldTo(row, column),
  5910. fold, folds;
  5911. if (ret) {
  5912. fold = ret.fold;
  5913. if (ret.kind == "inside"
  5914. && fold.start.column != column
  5915. && fold.start.row != row)
  5916. {
  5917. window.console && window.console.log(row, column, fold);
  5918. } else if (fold.start.row == row) {
  5919. folds = this.folds;
  5920. var i = folds.indexOf(fold);
  5921. if (i === 0) {
  5922. this.start.column += len;
  5923. }
  5924. for (i; i < folds.length; i++) {
  5925. fold = folds[i];
  5926. fold.start.column += len;
  5927. if (!fold.sameRow) {
  5928. return;
  5929. }
  5930. fold.end.column += len;
  5931. }
  5932. this.end.column += len;
  5933. }
  5934. }
  5935. };
  5936. this.split = function(row, column) {
  5937. var pos = this.getNextFoldTo(row, column);
  5938. if (!pos || pos.kind == "inside")
  5939. return null;
  5940. var fold = pos.fold;
  5941. var folds = this.folds;
  5942. var foldData = this.foldData;
  5943. var i = folds.indexOf(fold);
  5944. var foldBefore = folds[i - 1];
  5945. this.end.row = foldBefore.end.row;
  5946. this.end.column = foldBefore.end.column;
  5947. folds = folds.splice(i, folds.length - i);
  5948. var newFoldLine = new FoldLine(foldData, folds);
  5949. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  5950. return newFoldLine;
  5951. };
  5952. this.merge = function(foldLineNext) {
  5953. var folds = foldLineNext.folds;
  5954. for (var i = 0; i < folds.length; i++) {
  5955. this.addFold(folds[i]);
  5956. }
  5957. var foldData = this.foldData;
  5958. foldData.splice(foldData.indexOf(foldLineNext), 1);
  5959. };
  5960. this.toString = function() {
  5961. var ret = [this.range.toString() + ": [" ];
  5962. this.folds.forEach(function(fold) {
  5963. ret.push(" " + fold.toString());
  5964. });
  5965. ret.push("]");
  5966. return ret.join("\n");
  5967. };
  5968. this.idxToPosition = function(idx) {
  5969. var lastFoldEndColumn = 0;
  5970. for (var i = 0; i < this.folds.length; i++) {
  5971. var fold = this.folds[i];
  5972. idx -= fold.start.column - lastFoldEndColumn;
  5973. if (idx < 0) {
  5974. return {
  5975. row: fold.start.row,
  5976. column: fold.start.column + idx
  5977. };
  5978. }
  5979. idx -= fold.placeholder.length;
  5980. if (idx < 0) {
  5981. return fold.start;
  5982. }
  5983. lastFoldEndColumn = fold.end.column;
  5984. }
  5985. return {
  5986. row: this.end.row,
  5987. column: this.end.column + idx
  5988. };
  5989. };
  5990. }).call(FoldLine.prototype);
  5991. exports.FoldLine = FoldLine;
  5992. });
  5993. ace.define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
  5994. "use strict";
  5995. var Range = require("./range").Range;
  5996. var comparePoints = Range.comparePoints;
  5997. var RangeList = function() {
  5998. this.ranges = [];
  5999. };
  6000. (function() {
  6001. this.comparePoints = comparePoints;
  6002. this.pointIndex = function(pos, excludeEdges, startIndex) {
  6003. var list = this.ranges;
  6004. for (var i = startIndex || 0; i < list.length; i++) {
  6005. var range = list[i];
  6006. var cmpEnd = comparePoints(pos, range.end);
  6007. if (cmpEnd > 0)
  6008. continue;
  6009. var cmpStart = comparePoints(pos, range.start);
  6010. if (cmpEnd === 0)
  6011. return excludeEdges && cmpStart !== 0 ? -i-2 : i;
  6012. if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
  6013. return i;
  6014. return -i-1;
  6015. }
  6016. return -i - 1;
  6017. };
  6018. this.add = function(range) {
  6019. var excludeEdges = !range.isEmpty();
  6020. var startIndex = this.pointIndex(range.start, excludeEdges);
  6021. if (startIndex < 0)
  6022. startIndex = -startIndex - 1;
  6023. var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
  6024. if (endIndex < 0)
  6025. endIndex = -endIndex - 1;
  6026. else
  6027. endIndex++;
  6028. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  6029. };
  6030. this.addList = function(list) {
  6031. var removed = [];
  6032. for (var i = list.length; i--; ) {
  6033. removed.push.call(removed, this.add(list[i]));
  6034. }
  6035. return removed;
  6036. };
  6037. this.substractPoint = function(pos) {
  6038. var i = this.pointIndex(pos);
  6039. if (i >= 0)
  6040. return this.ranges.splice(i, 1);
  6041. };
  6042. this.merge = function() {
  6043. var removed = [];
  6044. var list = this.ranges;
  6045. list = list.sort(function(a, b) {
  6046. return comparePoints(a.start, b.start);
  6047. });
  6048. var next = list[0], range;
  6049. for (var i = 1; i < list.length; i++) {
  6050. range = next;
  6051. next = list[i];
  6052. var cmp = comparePoints(range.end, next.start);
  6053. if (cmp < 0)
  6054. continue;
  6055. if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
  6056. continue;
  6057. if (comparePoints(range.end, next.end) < 0) {
  6058. range.end.row = next.end.row;
  6059. range.end.column = next.end.column;
  6060. }
  6061. list.splice(i, 1);
  6062. removed.push(next);
  6063. next = range;
  6064. i--;
  6065. }
  6066. this.ranges = list;
  6067. return removed;
  6068. };
  6069. this.contains = function(row, column) {
  6070. return this.pointIndex({row: row, column: column}) >= 0;
  6071. };
  6072. this.containsPoint = function(pos) {
  6073. return this.pointIndex(pos) >= 0;
  6074. };
  6075. this.rangeAtPoint = function(pos) {
  6076. var i = this.pointIndex(pos);
  6077. if (i >= 0)
  6078. return this.ranges[i];
  6079. };
  6080. this.clipRows = function(startRow, endRow) {
  6081. var list = this.ranges;
  6082. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  6083. return [];
  6084. var startIndex = this.pointIndex({row: startRow, column: 0});
  6085. if (startIndex < 0)
  6086. startIndex = -startIndex - 1;
  6087. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  6088. if (endIndex < 0)
  6089. endIndex = -endIndex - 1;
  6090. var clipped = [];
  6091. for (var i = startIndex; i < endIndex; i++) {
  6092. clipped.push(list[i]);
  6093. }
  6094. return clipped;
  6095. };
  6096. this.removeAll = function() {
  6097. return this.ranges.splice(0, this.ranges.length);
  6098. };
  6099. this.attach = function(session) {
  6100. if (this.session)
  6101. this.detach();
  6102. this.session = session;
  6103. this.onChange = this.$onChange.bind(this);
  6104. this.session.on('change', this.onChange);
  6105. };
  6106. this.detach = function() {
  6107. if (!this.session)
  6108. return;
  6109. this.session.removeListener('change', this.onChange);
  6110. this.session = null;
  6111. };
  6112. this.$onChange = function(e) {
  6113. var changeRange = e.data.range;
  6114. if (e.data.action[0] == "i"){
  6115. var start = changeRange.start;
  6116. var end = changeRange.end;
  6117. } else {
  6118. var end = changeRange.start;
  6119. var start = changeRange.end;
  6120. }
  6121. var startRow = start.row;
  6122. var endRow = end.row;
  6123. var lineDif = endRow - startRow;
  6124. var colDiff = -start.column + end.column;
  6125. var ranges = this.ranges;
  6126. for (var i = 0, n = ranges.length; i < n; i++) {
  6127. var r = ranges[i];
  6128. if (r.end.row < startRow)
  6129. continue;
  6130. if (r.start.row > startRow)
  6131. break;
  6132. if (r.start.row == startRow && r.start.column >= start.column ) {
  6133. if (r.start.column == start.column && this.$insertRight) {
  6134. } else {
  6135. r.start.column += colDiff;
  6136. r.start.row += lineDif;
  6137. }
  6138. }
  6139. if (r.end.row == startRow && r.end.column >= start.column) {
  6140. if (r.end.column == start.column && this.$insertRight) {
  6141. continue;
  6142. }
  6143. if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
  6144. if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
  6145. r.end.column -= colDiff;
  6146. }
  6147. r.end.column += colDiff;
  6148. r.end.row += lineDif;
  6149. }
  6150. }
  6151. if (lineDif != 0 && i < n) {
  6152. for (; i < n; i++) {
  6153. var r = ranges[i];
  6154. r.start.row += lineDif;
  6155. r.end.row += lineDif;
  6156. }
  6157. }
  6158. };
  6159. }).call(RangeList.prototype);
  6160. exports.RangeList = RangeList;
  6161. });
  6162. ace.define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
  6163. "use strict";
  6164. var Range = require("../range").Range;
  6165. var RangeList = require("../range_list").RangeList;
  6166. var oop = require("../lib/oop")
  6167. var Fold = exports.Fold = function(range, placeholder) {
  6168. this.foldLine = null;
  6169. this.placeholder = placeholder;
  6170. this.range = range;
  6171. this.start = range.start;
  6172. this.end = range.end;
  6173. this.sameRow = range.start.row == range.end.row;
  6174. this.subFolds = this.ranges = [];
  6175. };
  6176. oop.inherits(Fold, RangeList);
  6177. (function() {
  6178. this.toString = function() {
  6179. return '"' + this.placeholder + '" ' + this.range.toString();
  6180. };
  6181. this.setFoldLine = function(foldLine) {
  6182. this.foldLine = foldLine;
  6183. this.subFolds.forEach(function(fold) {
  6184. fold.setFoldLine(foldLine);
  6185. });
  6186. };
  6187. this.clone = function() {
  6188. var range = this.range.clone();
  6189. var fold = new Fold(range, this.placeholder);
  6190. this.subFolds.forEach(function(subFold) {
  6191. fold.subFolds.push(subFold.clone());
  6192. });
  6193. fold.collapseChildren = this.collapseChildren;
  6194. return fold;
  6195. };
  6196. this.addSubFold = function(fold) {
  6197. if (this.range.isEqual(fold))
  6198. return;
  6199. if (!this.range.containsRange(fold))
  6200. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6201. consumeRange(fold, this.start);
  6202. var row = fold.start.row, column = fold.start.column;
  6203. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  6204. cmp = this.subFolds[i].range.compare(row, column);
  6205. if (cmp != 1)
  6206. break;
  6207. }
  6208. var afterStart = this.subFolds[i];
  6209. if (cmp == 0)
  6210. return afterStart.addSubFold(fold);
  6211. var row = fold.range.end.row, column = fold.range.end.column;
  6212. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  6213. cmp = this.subFolds[j].range.compare(row, column);
  6214. if (cmp != 1)
  6215. break;
  6216. }
  6217. var afterEnd = this.subFolds[j];
  6218. if (cmp == 0)
  6219. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6220. var consumedFolds = this.subFolds.splice(i, j - i, fold);
  6221. fold.setFoldLine(this.foldLine);
  6222. return fold;
  6223. };
  6224. this.restoreRange = function(range) {
  6225. return restoreRange(range, this.start);
  6226. };
  6227. }).call(Fold.prototype);
  6228. function consumePoint(point, anchor) {
  6229. point.row -= anchor.row;
  6230. if (point.row == 0)
  6231. point.column -= anchor.column;
  6232. }
  6233. function consumeRange(range, anchor) {
  6234. consumePoint(range.start, anchor);
  6235. consumePoint(range.end, anchor);
  6236. }
  6237. function restorePoint(point, anchor) {
  6238. if (point.row == 0)
  6239. point.column += anchor.column;
  6240. point.row += anchor.row;
  6241. }
  6242. function restoreRange(range, anchor) {
  6243. restorePoint(range.start, anchor);
  6244. restorePoint(range.end, anchor);
  6245. }
  6246. });
  6247. ace.define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator"], function(require, exports, module) {
  6248. "use strict";
  6249. var Range = require("../range").Range;
  6250. var FoldLine = require("./fold_line").FoldLine;
  6251. var Fold = require("./fold").Fold;
  6252. var TokenIterator = require("../token_iterator").TokenIterator;
  6253. function Folding() {
  6254. this.getFoldAt = function(row, column, side) {
  6255. var foldLine = this.getFoldLine(row);
  6256. if (!foldLine)
  6257. return null;
  6258. var folds = foldLine.folds;
  6259. for (var i = 0; i < folds.length; i++) {
  6260. var fold = folds[i];
  6261. if (fold.range.contains(row, column)) {
  6262. if (side == 1 && fold.range.isEnd(row, column)) {
  6263. continue;
  6264. } else if (side == -1 && fold.range.isStart(row, column)) {
  6265. continue;
  6266. }
  6267. return fold;
  6268. }
  6269. }
  6270. };
  6271. this.getFoldsInRange = function(range) {
  6272. var start = range.start;
  6273. var end = range.end;
  6274. var foldLines = this.$foldData;
  6275. var foundFolds = [];
  6276. start.column += 1;
  6277. end.column -= 1;
  6278. for (var i = 0; i < foldLines.length; i++) {
  6279. var cmp = foldLines[i].range.compareRange(range);
  6280. if (cmp == 2) {
  6281. continue;
  6282. }
  6283. else if (cmp == -2) {
  6284. break;
  6285. }
  6286. var folds = foldLines[i].folds;
  6287. for (var j = 0; j < folds.length; j++) {
  6288. var fold = folds[j];
  6289. cmp = fold.range.compareRange(range);
  6290. if (cmp == -2) {
  6291. break;
  6292. } else if (cmp == 2) {
  6293. continue;
  6294. } else
  6295. if (cmp == 42) {
  6296. break;
  6297. }
  6298. foundFolds.push(fold);
  6299. }
  6300. }
  6301. start.column -= 1;
  6302. end.column += 1;
  6303. return foundFolds;
  6304. };
  6305. this.getFoldsInRangeList = function(ranges) {
  6306. if (Array.isArray(ranges)) {
  6307. var folds = [];
  6308. ranges.forEach(function(range) {
  6309. folds = folds.concat(this.getFoldsInRange(range));
  6310. }, this);
  6311. } else {
  6312. var folds = this.getFoldsInRange(ranges);
  6313. }
  6314. return folds;
  6315. }
  6316. this.getAllFolds = function() {
  6317. var folds = [];
  6318. var foldLines = this.$foldData;
  6319. for (var i = 0; i < foldLines.length; i++)
  6320. for (var j = 0; j < foldLines[i].folds.length; j++)
  6321. folds.push(foldLines[i].folds[j]);
  6322. return folds;
  6323. };
  6324. this.getFoldStringAt = function(row, column, trim, foldLine) {
  6325. foldLine = foldLine || this.getFoldLine(row);
  6326. if (!foldLine)
  6327. return null;
  6328. var lastFold = {
  6329. end: { column: 0 }
  6330. };
  6331. var str, fold;
  6332. for (var i = 0; i < foldLine.folds.length; i++) {
  6333. fold = foldLine.folds[i];
  6334. var cmp = fold.range.compareEnd(row, column);
  6335. if (cmp == -1) {
  6336. str = this
  6337. .getLine(fold.start.row)
  6338. .substring(lastFold.end.column, fold.start.column);
  6339. break;
  6340. }
  6341. else if (cmp === 0) {
  6342. return null;
  6343. }
  6344. lastFold = fold;
  6345. }
  6346. if (!str)
  6347. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  6348. if (trim == -1)
  6349. return str.substring(0, column - lastFold.end.column);
  6350. else if (trim == 1)
  6351. return str.substring(column - lastFold.end.column);
  6352. else
  6353. return str;
  6354. };
  6355. this.getFoldLine = function(docRow, startFoldLine) {
  6356. var foldData = this.$foldData;
  6357. var i = 0;
  6358. if (startFoldLine)
  6359. i = foldData.indexOf(startFoldLine);
  6360. if (i == -1)
  6361. i = 0;
  6362. for (i; i < foldData.length; i++) {
  6363. var foldLine = foldData[i];
  6364. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  6365. return foldLine;
  6366. } else if (foldLine.end.row > docRow) {
  6367. return null;
  6368. }
  6369. }
  6370. return null;
  6371. };
  6372. this.getNextFoldLine = function(docRow, startFoldLine) {
  6373. var foldData = this.$foldData;
  6374. var i = 0;
  6375. if (startFoldLine)
  6376. i = foldData.indexOf(startFoldLine);
  6377. if (i == -1)
  6378. i = 0;
  6379. for (i; i < foldData.length; i++) {
  6380. var foldLine = foldData[i];
  6381. if (foldLine.end.row >= docRow) {
  6382. return foldLine;
  6383. }
  6384. }
  6385. return null;
  6386. };
  6387. this.getFoldedRowCount = function(first, last) {
  6388. var foldData = this.$foldData, rowCount = last-first+1;
  6389. for (var i = 0; i < foldData.length; i++) {
  6390. var foldLine = foldData[i],
  6391. end = foldLine.end.row,
  6392. start = foldLine.start.row;
  6393. if (end >= last) {
  6394. if(start < last) {
  6395. if(start >= first)
  6396. rowCount -= last-start;
  6397. else
  6398. rowCount = 0;//in one fold
  6399. }
  6400. break;
  6401. } else if(end >= first){
  6402. if (start >= first) //fold inside range
  6403. rowCount -= end-start;
  6404. else
  6405. rowCount -= end-first+1;
  6406. }
  6407. }
  6408. return rowCount;
  6409. };
  6410. this.$addFoldLine = function(foldLine) {
  6411. this.$foldData.push(foldLine);
  6412. this.$foldData.sort(function(a, b) {
  6413. return a.start.row - b.start.row;
  6414. });
  6415. return foldLine;
  6416. };
  6417. this.addFold = function(placeholder, range) {
  6418. var foldData = this.$foldData;
  6419. var added = false;
  6420. var fold;
  6421. if (placeholder instanceof Fold)
  6422. fold = placeholder;
  6423. else {
  6424. fold = new Fold(range, placeholder);
  6425. fold.collapseChildren = range.collapseChildren;
  6426. }
  6427. this.$clipRangeToDocument(fold.range);
  6428. var startRow = fold.start.row;
  6429. var startColumn = fold.start.column;
  6430. var endRow = fold.end.row;
  6431. var endColumn = fold.end.column;
  6432. if (!(startRow < endRow ||
  6433. startRow == endRow && startColumn <= endColumn - 2))
  6434. throw new Error("The range has to be at least 2 characters width");
  6435. var startFold = this.getFoldAt(startRow, startColumn, 1);
  6436. var endFold = this.getFoldAt(endRow, endColumn, -1);
  6437. if (startFold && endFold == startFold)
  6438. return startFold.addSubFold(fold);
  6439. if (startFold && !startFold.range.isStart(startRow, startColumn))
  6440. this.removeFold(startFold);
  6441. if (endFold && !endFold.range.isEnd(endRow, endColumn))
  6442. this.removeFold(endFold);
  6443. var folds = this.getFoldsInRange(fold.range);
  6444. if (folds.length > 0) {
  6445. this.removeFolds(folds);
  6446. folds.forEach(function(subFold) {
  6447. fold.addSubFold(subFold);
  6448. });
  6449. }
  6450. for (var i = 0; i < foldData.length; i++) {
  6451. var foldLine = foldData[i];
  6452. if (endRow == foldLine.start.row) {
  6453. foldLine.addFold(fold);
  6454. added = true;
  6455. break;
  6456. } else if (startRow == foldLine.end.row) {
  6457. foldLine.addFold(fold);
  6458. added = true;
  6459. if (!fold.sameRow) {
  6460. var foldLineNext = foldData[i + 1];
  6461. if (foldLineNext && foldLineNext.start.row == endRow) {
  6462. foldLine.merge(foldLineNext);
  6463. break;
  6464. }
  6465. }
  6466. break;
  6467. } else if (endRow <= foldLine.start.row) {
  6468. break;
  6469. }
  6470. }
  6471. if (!added)
  6472. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  6473. if (this.$useWrapMode)
  6474. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  6475. else
  6476. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  6477. this.$modified = true;
  6478. this._emit("changeFold", { data: fold, action: "add" });
  6479. return fold;
  6480. };
  6481. this.addFolds = function(folds) {
  6482. folds.forEach(function(fold) {
  6483. this.addFold(fold);
  6484. }, this);
  6485. };
  6486. this.removeFold = function(fold) {
  6487. var foldLine = fold.foldLine;
  6488. var startRow = foldLine.start.row;
  6489. var endRow = foldLine.end.row;
  6490. var foldLines = this.$foldData;
  6491. var folds = foldLine.folds;
  6492. if (folds.length == 1) {
  6493. foldLines.splice(foldLines.indexOf(foldLine), 1);
  6494. } else
  6495. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  6496. folds.pop();
  6497. foldLine.end.row = folds[folds.length - 1].end.row;
  6498. foldLine.end.column = folds[folds.length - 1].end.column;
  6499. } else
  6500. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  6501. folds.shift();
  6502. foldLine.start.row = folds[0].start.row;
  6503. foldLine.start.column = folds[0].start.column;
  6504. } else
  6505. if (fold.sameRow) {
  6506. folds.splice(folds.indexOf(fold), 1);
  6507. } else
  6508. {
  6509. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  6510. folds = newFoldLine.folds;
  6511. folds.shift();
  6512. newFoldLine.start.row = folds[0].start.row;
  6513. newFoldLine.start.column = folds[0].start.column;
  6514. }
  6515. if (!this.$updating) {
  6516. if (this.$useWrapMode)
  6517. this.$updateWrapData(startRow, endRow);
  6518. else
  6519. this.$updateRowLengthCache(startRow, endRow);
  6520. }
  6521. this.$modified = true;
  6522. this._emit("changeFold", { data: fold, action: "remove" });
  6523. };
  6524. this.removeFolds = function(folds) {
  6525. var cloneFolds = [];
  6526. for (var i = 0; i < folds.length; i++) {
  6527. cloneFolds.push(folds[i]);
  6528. }
  6529. cloneFolds.forEach(function(fold) {
  6530. this.removeFold(fold);
  6531. }, this);
  6532. this.$modified = true;
  6533. };
  6534. this.expandFold = function(fold) {
  6535. this.removeFold(fold);
  6536. fold.subFolds.forEach(function(subFold) {
  6537. fold.restoreRange(subFold);
  6538. this.addFold(subFold);
  6539. }, this);
  6540. if (fold.collapseChildren > 0) {
  6541. this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
  6542. }
  6543. fold.subFolds = [];
  6544. };
  6545. this.expandFolds = function(folds) {
  6546. folds.forEach(function(fold) {
  6547. this.expandFold(fold);
  6548. }, this);
  6549. };
  6550. this.unfold = function(location, expandInner) {
  6551. var range, folds;
  6552. if (location == null) {
  6553. range = new Range(0, 0, this.getLength(), 0);
  6554. expandInner = true;
  6555. } else if (typeof location == "number")
  6556. range = new Range(location, 0, location, this.getLine(location).length);
  6557. else if ("row" in location)
  6558. range = Range.fromPoints(location, location);
  6559. else
  6560. range = location;
  6561. folds = this.getFoldsInRangeList(range);
  6562. if (expandInner) {
  6563. this.removeFolds(folds);
  6564. } else {
  6565. var subFolds = folds;
  6566. while (subFolds.length) {
  6567. this.expandFolds(subFolds);
  6568. subFolds = this.getFoldsInRangeList(range);
  6569. }
  6570. }
  6571. if (folds.length)
  6572. return folds;
  6573. };
  6574. this.isRowFolded = function(docRow, startFoldRow) {
  6575. return !!this.getFoldLine(docRow, startFoldRow);
  6576. };
  6577. this.getRowFoldEnd = function(docRow, startFoldRow) {
  6578. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6579. return foldLine ? foldLine.end.row : docRow;
  6580. };
  6581. this.getRowFoldStart = function(docRow, startFoldRow) {
  6582. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6583. return foldLine ? foldLine.start.row : docRow;
  6584. };
  6585. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  6586. if (startRow == null)
  6587. startRow = foldLine.start.row;
  6588. if (startColumn == null)
  6589. startColumn = 0;
  6590. if (endRow == null)
  6591. endRow = foldLine.end.row;
  6592. if (endColumn == null)
  6593. endColumn = this.getLine(endRow).length;
  6594. var doc = this.doc;
  6595. var textLine = "";
  6596. foldLine.walk(function(placeholder, row, column, lastColumn) {
  6597. if (row < startRow)
  6598. return;
  6599. if (row == startRow) {
  6600. if (column < startColumn)
  6601. return;
  6602. lastColumn = Math.max(startColumn, lastColumn);
  6603. }
  6604. if (placeholder != null) {
  6605. textLine += placeholder;
  6606. } else {
  6607. textLine += doc.getLine(row).substring(lastColumn, column);
  6608. }
  6609. }, endRow, endColumn);
  6610. return textLine;
  6611. };
  6612. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  6613. var foldLine = this.getFoldLine(row);
  6614. if (!foldLine) {
  6615. var line;
  6616. line = this.doc.getLine(row);
  6617. return line.substring(startColumn || 0, endColumn || line.length);
  6618. } else {
  6619. return this.getFoldDisplayLine(
  6620. foldLine, row, endColumn, startRow, startColumn);
  6621. }
  6622. };
  6623. this.$cloneFoldData = function() {
  6624. var fd = [];
  6625. fd = this.$foldData.map(function(foldLine) {
  6626. var folds = foldLine.folds.map(function(fold) {
  6627. return fold.clone();
  6628. });
  6629. return new FoldLine(fd, folds);
  6630. });
  6631. return fd;
  6632. };
  6633. this.toggleFold = function(tryToUnfold) {
  6634. var selection = this.selection;
  6635. var range = selection.getRange();
  6636. var fold;
  6637. var bracketPos;
  6638. if (range.isEmpty()) {
  6639. var cursor = range.start;
  6640. fold = this.getFoldAt(cursor.row, cursor.column);
  6641. if (fold) {
  6642. this.expandFold(fold);
  6643. return;
  6644. } else if (bracketPos = this.findMatchingBracket(cursor)) {
  6645. if (range.comparePoint(bracketPos) == 1) {
  6646. range.end = bracketPos;
  6647. } else {
  6648. range.start = bracketPos;
  6649. range.start.column++;
  6650. range.end.column--;
  6651. }
  6652. } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  6653. if (range.comparePoint(bracketPos) == 1)
  6654. range.end = bracketPos;
  6655. else
  6656. range.start = bracketPos;
  6657. range.start.column++;
  6658. } else {
  6659. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  6660. }
  6661. } else {
  6662. var folds = this.getFoldsInRange(range);
  6663. if (tryToUnfold && folds.length) {
  6664. this.expandFolds(folds);
  6665. return;
  6666. } else if (folds.length == 1 ) {
  6667. fold = folds[0];
  6668. }
  6669. }
  6670. if (!fold)
  6671. fold = this.getFoldAt(range.start.row, range.start.column);
  6672. if (fold && fold.range.toString() == range.toString()) {
  6673. this.expandFold(fold);
  6674. return;
  6675. }
  6676. var placeholder = "...";
  6677. if (!range.isMultiLine()) {
  6678. placeholder = this.getTextRange(range);
  6679. if(placeholder.length < 4)
  6680. return;
  6681. placeholder = placeholder.trim().substring(0, 2) + "..";
  6682. }
  6683. this.addFold(placeholder, range);
  6684. };
  6685. this.getCommentFoldRange = function(row, column, dir) {
  6686. var iterator = new TokenIterator(this, row, column);
  6687. var token = iterator.getCurrentToken();
  6688. if (token && /^comment|string/.test(token.type)) {
  6689. var range = new Range();
  6690. var re = new RegExp(token.type.replace(/\..*/, "\\."));
  6691. if (dir != 1) {
  6692. do {
  6693. token = iterator.stepBackward();
  6694. } while(token && re.test(token.type));
  6695. iterator.stepForward();
  6696. }
  6697. range.start.row = iterator.getCurrentTokenRow();
  6698. range.start.column = iterator.getCurrentTokenColumn() + 2;
  6699. iterator = new TokenIterator(this, row, column);
  6700. if (dir != -1) {
  6701. do {
  6702. token = iterator.stepForward();
  6703. } while(token && re.test(token.type));
  6704. token = iterator.stepBackward();
  6705. } else
  6706. token = iterator.getCurrentToken();
  6707. range.end.row = iterator.getCurrentTokenRow();
  6708. range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
  6709. return range;
  6710. }
  6711. };
  6712. this.foldAll = function(startRow, endRow, depth) {
  6713. if (depth == undefined)
  6714. depth = 100000; // JSON.stringify doesn't hanle Infinity
  6715. var foldWidgets = this.foldWidgets;
  6716. if (!foldWidgets)
  6717. return; // mode doesn't support folding
  6718. endRow = endRow || this.getLength();
  6719. startRow = startRow || 0;
  6720. for (var row = startRow; row < endRow; row++) {
  6721. if (foldWidgets[row] == null)
  6722. foldWidgets[row] = this.getFoldWidget(row);
  6723. if (foldWidgets[row] != "start")
  6724. continue;
  6725. var range = this.getFoldWidgetRange(row);
  6726. if (range && range.isMultiLine()
  6727. && range.end.row <= endRow
  6728. && range.start.row >= startRow
  6729. ) {
  6730. row = range.end.row;
  6731. try {
  6732. var fold = this.addFold("...", range);
  6733. if (fold)
  6734. fold.collapseChildren = depth;
  6735. } catch(e) {}
  6736. }
  6737. }
  6738. };
  6739. this.$foldStyles = {
  6740. "manual": 1,
  6741. "markbegin": 1,
  6742. "markbeginend": 1
  6743. };
  6744. this.$foldStyle = "markbegin";
  6745. this.setFoldStyle = function(style) {
  6746. if (!this.$foldStyles[style])
  6747. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  6748. if (this.$foldStyle == style)
  6749. return;
  6750. this.$foldStyle = style;
  6751. if (style == "manual")
  6752. this.unfold();
  6753. var mode = this.$foldMode;
  6754. this.$setFolding(null);
  6755. this.$setFolding(mode);
  6756. };
  6757. this.$setFolding = function(foldMode) {
  6758. if (this.$foldMode == foldMode)
  6759. return;
  6760. this.$foldMode = foldMode;
  6761. this.off('change', this.$updateFoldWidgets);
  6762. this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6763. this._emit("changeAnnotation");
  6764. if (!foldMode || this.$foldStyle == "manual") {
  6765. this.foldWidgets = null;
  6766. return;
  6767. }
  6768. this.foldWidgets = [];
  6769. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  6770. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  6771. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  6772. this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
  6773. this.on('change', this.$updateFoldWidgets);
  6774. this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6775. };
  6776. this.getParentFoldRangeData = function (row, ignoreCurrent) {
  6777. var fw = this.foldWidgets;
  6778. if (!fw || (ignoreCurrent && fw[row]))
  6779. return {};
  6780. var i = row - 1, firstRange;
  6781. while (i >= 0) {
  6782. var c = fw[i];
  6783. if (c == null)
  6784. c = fw[i] = this.getFoldWidget(i);
  6785. if (c == "start") {
  6786. var range = this.getFoldWidgetRange(i);
  6787. if (!firstRange)
  6788. firstRange = range;
  6789. if (range && range.end.row >= row)
  6790. break;
  6791. }
  6792. i--;
  6793. }
  6794. return {
  6795. range: i !== -1 && range,
  6796. firstRange: firstRange
  6797. };
  6798. }
  6799. this.onFoldWidgetClick = function(row, e) {
  6800. e = e.domEvent;
  6801. var options = {
  6802. children: e.shiftKey,
  6803. all: e.ctrlKey || e.metaKey,
  6804. siblings: e.altKey
  6805. };
  6806. var range = this.$toggleFoldWidget(row, options);
  6807. if (!range) {
  6808. var el = (e.target || e.srcElement)
  6809. if (el && /ace_fold-widget/.test(el.className))
  6810. el.className += " ace_invalid";
  6811. }
  6812. };
  6813. this.$toggleFoldWidget = function(row, options) {
  6814. if (!this.getFoldWidget)
  6815. return;
  6816. var type = this.getFoldWidget(row);
  6817. var line = this.getLine(row);
  6818. var dir = type === "end" ? -1 : 1;
  6819. var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
  6820. if (fold) {
  6821. if (options.children || options.all)
  6822. this.removeFold(fold);
  6823. else
  6824. this.expandFold(fold);
  6825. return;
  6826. }
  6827. var range = this.getFoldWidgetRange(row, true);
  6828. if (range && !range.isMultiLine()) {
  6829. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  6830. if (fold && range.isEqual(fold.range)) {
  6831. this.removeFold(fold);
  6832. return;
  6833. }
  6834. }
  6835. if (options.siblings) {
  6836. var data = this.getParentFoldRangeData(row);
  6837. if (data.range) {
  6838. var startRow = data.range.start.row + 1;
  6839. var endRow = data.range.end.row;
  6840. }
  6841. this.foldAll(startRow, endRow, options.all ? 10000 : 0);
  6842. } else if (options.children) {
  6843. endRow = range ? range.end.row : this.getLength();
  6844. this.foldAll(row + 1, range.end.row, options.all ? 10000 : 0);
  6845. } else if (range) {
  6846. if (options.all)
  6847. range.collapseChildren = 10000;
  6848. this.addFold("...", range);
  6849. }
  6850. return range;
  6851. };
  6852. this.toggleFoldWidget = function(toggleParent) {
  6853. var row = this.selection.getCursor().row;
  6854. row = this.getRowFoldStart(row);
  6855. var range = this.$toggleFoldWidget(row, {});
  6856. if (range)
  6857. return;
  6858. var data = this.getParentFoldRangeData(row, true);
  6859. range = data.range || data.firstRange;
  6860. if (range) {
  6861. row = range.start.row;
  6862. var fold = this.getFoldAt(row, this.getLine(row).length, 1);
  6863. if (fold) {
  6864. this.removeFold(fold);
  6865. } else {
  6866. this.addFold("...", range);
  6867. }
  6868. }
  6869. };
  6870. this.updateFoldWidgets = function(e) {
  6871. var delta = e.data;
  6872. var range = delta.range;
  6873. var firstRow = range.start.row;
  6874. var len = range.end.row - firstRow;
  6875. if (len === 0) {
  6876. this.foldWidgets[firstRow] = null;
  6877. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  6878. this.foldWidgets.splice(firstRow, len + 1, null);
  6879. } else {
  6880. var args = Array(len + 1);
  6881. args.unshift(firstRow, 1);
  6882. this.foldWidgets.splice.apply(this.foldWidgets, args);
  6883. }
  6884. };
  6885. this.tokenizerUpdateFoldWidgets = function(e) {
  6886. var rows = e.data;
  6887. if (rows.first != rows.last) {
  6888. if (this.foldWidgets.length > rows.first)
  6889. this.foldWidgets.splice(rows.first, this.foldWidgets.length);
  6890. }
  6891. }
  6892. }
  6893. exports.Folding = Folding;
  6894. });
  6895. ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
  6896. "use strict";
  6897. var TokenIterator = require("../token_iterator").TokenIterator;
  6898. var Range = require("../range").Range;
  6899. function BracketMatch() {
  6900. this.findMatchingBracket = function(position, chr) {
  6901. if (position.column == 0) return null;
  6902. var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
  6903. if (charBeforeCursor == "") return null;
  6904. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  6905. if (!match)
  6906. return null;
  6907. if (match[1])
  6908. return this.$findClosingBracket(match[1], position);
  6909. else
  6910. return this.$findOpeningBracket(match[2], position);
  6911. };
  6912. this.getBracketRange = function(pos) {
  6913. var line = this.getLine(pos.row);
  6914. var before = true, range;
  6915. var chr = line.charAt(pos.column-1);
  6916. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  6917. if (!match) {
  6918. chr = line.charAt(pos.column);
  6919. pos = {row: pos.row, column: pos.column + 1};
  6920. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  6921. before = false;
  6922. }
  6923. if (!match)
  6924. return null;
  6925. if (match[1]) {
  6926. var bracketPos = this.$findClosingBracket(match[1], pos);
  6927. if (!bracketPos)
  6928. return null;
  6929. range = Range.fromPoints(pos, bracketPos);
  6930. if (!before) {
  6931. range.end.column++;
  6932. range.start.column--;
  6933. }
  6934. range.cursor = range.end;
  6935. } else {
  6936. var bracketPos = this.$findOpeningBracket(match[2], pos);
  6937. if (!bracketPos)
  6938. return null;
  6939. range = Range.fromPoints(bracketPos, pos);
  6940. if (!before) {
  6941. range.start.column++;
  6942. range.end.column--;
  6943. }
  6944. range.cursor = range.start;
  6945. }
  6946. return range;
  6947. };
  6948. this.$brackets = {
  6949. ")": "(",
  6950. "(": ")",
  6951. "]": "[",
  6952. "[": "]",
  6953. "{": "}",
  6954. "}": "{"
  6955. };
  6956. this.$findOpeningBracket = function(bracket, position, typeRe) {
  6957. var openBracket = this.$brackets[bracket];
  6958. var depth = 1;
  6959. var iterator = new TokenIterator(this, position.row, position.column);
  6960. var token = iterator.getCurrentToken();
  6961. if (!token)
  6962. token = iterator.stepForward();
  6963. if (!token)
  6964. return;
  6965. if (!typeRe){
  6966. typeRe = new RegExp(
  6967. "(\\.?" +
  6968. token.type.replace(".", "\\.").replace("rparen", ".paren")
  6969. .replace(/\b(?:end|start|begin)\b/, "")
  6970. + ")+"
  6971. );
  6972. }
  6973. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  6974. var value = token.value;
  6975. while (true) {
  6976. while (valueIndex >= 0) {
  6977. var chr = value.charAt(valueIndex);
  6978. if (chr == openBracket) {
  6979. depth -= 1;
  6980. if (depth == 0) {
  6981. return {row: iterator.getCurrentTokenRow(),
  6982. column: valueIndex + iterator.getCurrentTokenColumn()};
  6983. }
  6984. }
  6985. else if (chr == bracket) {
  6986. depth += 1;
  6987. }
  6988. valueIndex -= 1;
  6989. }
  6990. do {
  6991. token = iterator.stepBackward();
  6992. } while (token && !typeRe.test(token.type));
  6993. if (token == null)
  6994. break;
  6995. value = token.value;
  6996. valueIndex = value.length - 1;
  6997. }
  6998. return null;
  6999. };
  7000. this.$findClosingBracket = function(bracket, position, typeRe) {
  7001. var closingBracket = this.$brackets[bracket];
  7002. var depth = 1;
  7003. var iterator = new TokenIterator(this, position.row, position.column);
  7004. var token = iterator.getCurrentToken();
  7005. if (!token)
  7006. token = iterator.stepForward();
  7007. if (!token)
  7008. return;
  7009. if (!typeRe){
  7010. typeRe = new RegExp(
  7011. "(\\.?" +
  7012. token.type.replace(".", "\\.").replace("lparen", ".paren")
  7013. .replace(/\b(?:end|start|begin)\b/, "")
  7014. + ")+"
  7015. );
  7016. }
  7017. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  7018. while (true) {
  7019. var value = token.value;
  7020. var valueLength = value.length;
  7021. while (valueIndex < valueLength) {
  7022. var chr = value.charAt(valueIndex);
  7023. if (chr == closingBracket) {
  7024. depth -= 1;
  7025. if (depth == 0) {
  7026. return {row: iterator.getCurrentTokenRow(),
  7027. column: valueIndex + iterator.getCurrentTokenColumn()};
  7028. }
  7029. }
  7030. else if (chr == bracket) {
  7031. depth += 1;
  7032. }
  7033. valueIndex += 1;
  7034. }
  7035. do {
  7036. token = iterator.stepForward();
  7037. } while (token && !typeRe.test(token.type));
  7038. if (token == null)
  7039. break;
  7040. valueIndex = 0;
  7041. }
  7042. return null;
  7043. };
  7044. }
  7045. exports.BracketMatch = BracketMatch;
  7046. });
  7047. ace.define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/config","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/search_highlight","ace/edit_session/folding","ace/edit_session/bracket_match"], function(require, exports, module) {
  7048. "use strict";
  7049. var oop = require("./lib/oop");
  7050. var lang = require("./lib/lang");
  7051. var config = require("./config");
  7052. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7053. var Selection = require("./selection").Selection;
  7054. var TextMode = require("./mode/text").Mode;
  7055. var Range = require("./range").Range;
  7056. var Document = require("./document").Document;
  7057. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  7058. var SearchHighlight = require("./search_highlight").SearchHighlight;
  7059. var EditSession = function(text, mode) {
  7060. this.$breakpoints = [];
  7061. this.$decorations = [];
  7062. this.$frontMarkers = {};
  7063. this.$backMarkers = {};
  7064. this.$markerId = 1;
  7065. this.$undoSelect = true;
  7066. this.$foldData = [];
  7067. this.$foldData.toString = function() {
  7068. return this.join("\n");
  7069. }
  7070. this.on("changeFold", this.onChangeFold.bind(this));
  7071. this.$onChange = this.onChange.bind(this);
  7072. if (typeof text != "object" || !text.getLine)
  7073. text = new Document(text);
  7074. this.setDocument(text);
  7075. this.selection = new Selection(this);
  7076. config.resetOptions(this);
  7077. this.setMode(mode);
  7078. config._signal("session", this);
  7079. };
  7080. (function() {
  7081. oop.implement(this, EventEmitter);
  7082. this.setDocument = function(doc) {
  7083. if (this.doc)
  7084. this.doc.removeListener("change", this.$onChange);
  7085. this.doc = doc;
  7086. doc.on("change", this.$onChange);
  7087. if (this.bgTokenizer)
  7088. this.bgTokenizer.setDocument(this.getDocument());
  7089. this.resetCaches();
  7090. };
  7091. this.getDocument = function() {
  7092. return this.doc;
  7093. };
  7094. this.$resetRowCache = function(docRow) {
  7095. if (!docRow) {
  7096. this.$docRowCache = [];
  7097. this.$screenRowCache = [];
  7098. return;
  7099. }
  7100. var l = this.$docRowCache.length;
  7101. var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
  7102. if (l > i) {
  7103. this.$docRowCache.splice(i, l);
  7104. this.$screenRowCache.splice(i, l);
  7105. }
  7106. };
  7107. this.$getRowCacheIndex = function(cacheArray, val) {
  7108. var low = 0;
  7109. var hi = cacheArray.length - 1;
  7110. while (low <= hi) {
  7111. var mid = (low + hi) >> 1;
  7112. var c = cacheArray[mid];
  7113. if (val > c)
  7114. low = mid + 1;
  7115. else if (val < c)
  7116. hi = mid - 1;
  7117. else
  7118. return mid;
  7119. }
  7120. return low -1;
  7121. };
  7122. this.resetCaches = function() {
  7123. this.$modified = true;
  7124. this.$wrapData = [];
  7125. this.$rowLengthCache = [];
  7126. this.$resetRowCache(0);
  7127. if (this.bgTokenizer)
  7128. this.bgTokenizer.start(0);
  7129. };
  7130. this.onChangeFold = function(e) {
  7131. var fold = e.data;
  7132. this.$resetRowCache(fold.start.row);
  7133. };
  7134. this.onChange = function(e) {
  7135. var delta = e.data;
  7136. this.$modified = true;
  7137. this.$resetRowCache(delta.range.start.row);
  7138. var removedFolds = this.$updateInternalDataOnChange(e);
  7139. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  7140. this.$deltasDoc.push(delta);
  7141. if (removedFolds && removedFolds.length != 0) {
  7142. this.$deltasFold.push({
  7143. action: "removeFolds",
  7144. folds: removedFolds
  7145. });
  7146. }
  7147. this.$informUndoManager.schedule();
  7148. }
  7149. this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
  7150. this._signal("change", e);
  7151. };
  7152. this.setValue = function(text) {
  7153. this.doc.setValue(text);
  7154. this.selection.moveTo(0, 0);
  7155. this.$resetRowCache(0);
  7156. this.$deltas = [];
  7157. this.$deltasDoc = [];
  7158. this.$deltasFold = [];
  7159. this.setUndoManager(this.$undoManager);
  7160. this.getUndoManager().reset();
  7161. };
  7162. this.getValue =
  7163. this.toString = function() {
  7164. return this.doc.getValue();
  7165. };
  7166. this.getSelection = function() {
  7167. return this.selection;
  7168. };
  7169. this.getState = function(row) {
  7170. return this.bgTokenizer.getState(row);
  7171. };
  7172. this.getTokens = function(row) {
  7173. return this.bgTokenizer.getTokens(row);
  7174. };
  7175. this.getTokenAt = function(row, column) {
  7176. var tokens = this.bgTokenizer.getTokens(row);
  7177. var token, c = 0;
  7178. if (column == null) {
  7179. i = tokens.length - 1;
  7180. c = this.getLine(row).length;
  7181. } else {
  7182. for (var i = 0; i < tokens.length; i++) {
  7183. c += tokens[i].value.length;
  7184. if (c >= column)
  7185. break;
  7186. }
  7187. }
  7188. token = tokens[i];
  7189. if (!token)
  7190. return null;
  7191. token.index = i;
  7192. token.start = c - token.value.length;
  7193. return token;
  7194. };
  7195. this.setUndoManager = function(undoManager) {
  7196. this.$undoManager = undoManager;
  7197. this.$deltas = [];
  7198. this.$deltasDoc = [];
  7199. this.$deltasFold = [];
  7200. if (this.$informUndoManager)
  7201. this.$informUndoManager.cancel();
  7202. if (undoManager) {
  7203. var self = this;
  7204. this.$syncInformUndoManager = function() {
  7205. self.$informUndoManager.cancel();
  7206. if (self.$deltasFold.length) {
  7207. self.$deltas.push({
  7208. group: "fold",
  7209. deltas: self.$deltasFold
  7210. });
  7211. self.$deltasFold = [];
  7212. }
  7213. if (self.$deltasDoc.length) {
  7214. self.$deltas.push({
  7215. group: "doc",
  7216. deltas: self.$deltasDoc
  7217. });
  7218. self.$deltasDoc = [];
  7219. }
  7220. if (self.$deltas.length > 0) {
  7221. undoManager.execute({
  7222. action: "aceupdate",
  7223. args: [self.$deltas, self],
  7224. merge: self.mergeUndoDeltas
  7225. });
  7226. }
  7227. self.mergeUndoDeltas = false;
  7228. self.$deltas = [];
  7229. };
  7230. this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
  7231. }
  7232. };
  7233. this.markUndoGroup = function() {
  7234. if (this.$syncInformUndoManager)
  7235. this.$syncInformUndoManager();
  7236. };
  7237. this.$defaultUndoManager = {
  7238. undo: function() {},
  7239. redo: function() {},
  7240. reset: function() {}
  7241. };
  7242. this.getUndoManager = function() {
  7243. return this.$undoManager || this.$defaultUndoManager;
  7244. };
  7245. this.getTabString = function() {
  7246. if (this.getUseSoftTabs()) {
  7247. return lang.stringRepeat(" ", this.getTabSize());
  7248. } else {
  7249. return "\t";
  7250. }
  7251. };
  7252. this.setUseSoftTabs = function(val) {
  7253. this.setOption("useSoftTabs", val);
  7254. };
  7255. this.getUseSoftTabs = function() {
  7256. return this.$useSoftTabs && !this.$mode.$indentWithTabs;
  7257. };
  7258. this.setTabSize = function(tabSize) {
  7259. this.setOption("tabSize", tabSize);
  7260. };
  7261. this.getTabSize = function() {
  7262. return this.$tabSize;
  7263. };
  7264. this.isTabStop = function(position) {
  7265. return this.$useSoftTabs && (position.column % this.$tabSize === 0);
  7266. };
  7267. this.$overwrite = false;
  7268. this.setOverwrite = function(overwrite) {
  7269. this.setOption("overwrite", overwrite);
  7270. };
  7271. this.getOverwrite = function() {
  7272. return this.$overwrite;
  7273. };
  7274. this.toggleOverwrite = function() {
  7275. this.setOverwrite(!this.$overwrite);
  7276. };
  7277. this.addGutterDecoration = function(row, className) {
  7278. if (!this.$decorations[row])
  7279. this.$decorations[row] = "";
  7280. this.$decorations[row] += " " + className;
  7281. this._signal("changeBreakpoint", {});
  7282. };
  7283. this.removeGutterDecoration = function(row, className) {
  7284. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  7285. this._signal("changeBreakpoint", {});
  7286. };
  7287. this.getBreakpoints = function() {
  7288. return this.$breakpoints;
  7289. };
  7290. this.setBreakpoints = function(rows) {
  7291. this.$breakpoints = [];
  7292. for (var i=0; i<rows.length; i++) {
  7293. this.$breakpoints[rows[i]] = "ace_breakpoint";
  7294. }
  7295. this._signal("changeBreakpoint", {});
  7296. };
  7297. this.clearBreakpoints = function() {
  7298. this.$breakpoints = [];
  7299. this._signal("changeBreakpoint", {});
  7300. };
  7301. this.setBreakpoint = function(row, className) {
  7302. if (className === undefined)
  7303. className = "ace_breakpoint";
  7304. if (className)
  7305. this.$breakpoints[row] = className;
  7306. else
  7307. delete this.$breakpoints[row];
  7308. this._signal("changeBreakpoint", {});
  7309. };
  7310. this.clearBreakpoint = function(row) {
  7311. delete this.$breakpoints[row];
  7312. this._signal("changeBreakpoint", {});
  7313. };
  7314. this.addMarker = function(range, clazz, type, inFront) {
  7315. var id = this.$markerId++;
  7316. var marker = {
  7317. range : range,
  7318. type : type || "line",
  7319. renderer: typeof type == "function" ? type : null,
  7320. clazz : clazz,
  7321. inFront: !!inFront,
  7322. id: id
  7323. };
  7324. if (inFront) {
  7325. this.$frontMarkers[id] = marker;
  7326. this._signal("changeFrontMarker");
  7327. } else {
  7328. this.$backMarkers[id] = marker;
  7329. this._signal("changeBackMarker");
  7330. }
  7331. return id;
  7332. };
  7333. this.addDynamicMarker = function(marker, inFront) {
  7334. if (!marker.update)
  7335. return;
  7336. var id = this.$markerId++;
  7337. marker.id = id;
  7338. marker.inFront = !!inFront;
  7339. if (inFront) {
  7340. this.$frontMarkers[id] = marker;
  7341. this._signal("changeFrontMarker");
  7342. } else {
  7343. this.$backMarkers[id] = marker;
  7344. this._signal("changeBackMarker");
  7345. }
  7346. return marker;
  7347. };
  7348. this.removeMarker = function(markerId) {
  7349. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  7350. if (!marker)
  7351. return;
  7352. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  7353. if (marker) {
  7354. delete (markers[markerId]);
  7355. this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  7356. }
  7357. };
  7358. this.getMarkers = function(inFront) {
  7359. return inFront ? this.$frontMarkers : this.$backMarkers;
  7360. };
  7361. this.highlight = function(re) {
  7362. if (!this.$searchHighlight) {
  7363. var highlight = new SearchHighlight(null, "ace_selected-word", "text");
  7364. this.$searchHighlight = this.addDynamicMarker(highlight);
  7365. }
  7366. this.$searchHighlight.setRegexp(re);
  7367. };
  7368. this.highlightLines = function(startRow, endRow, clazz, inFront) {
  7369. if (typeof endRow != "number") {
  7370. clazz = endRow;
  7371. endRow = startRow;
  7372. }
  7373. if (!clazz)
  7374. clazz = "ace_step";
  7375. var range = new Range(startRow, 0, endRow, Infinity);
  7376. range.id = this.addMarker(range, clazz, "fullLine", inFront);
  7377. return range;
  7378. };
  7379. this.setAnnotations = function(annotations) {
  7380. this.$annotations = annotations;
  7381. this._signal("changeAnnotation", {});
  7382. };
  7383. this.getAnnotations = function() {
  7384. return this.$annotations || [];
  7385. };
  7386. this.clearAnnotations = function() {
  7387. this.setAnnotations([]);
  7388. };
  7389. this.$detectNewLine = function(text) {
  7390. var match = text.match(/^.*?(\r?\n)/m);
  7391. if (match) {
  7392. this.$autoNewLine = match[1];
  7393. } else {
  7394. this.$autoNewLine = "\n";
  7395. }
  7396. };
  7397. this.getWordRange = function(row, column) {
  7398. var line = this.getLine(row);
  7399. var inToken = false;
  7400. if (column > 0)
  7401. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  7402. if (!inToken)
  7403. inToken = !!line.charAt(column).match(this.tokenRe);
  7404. if (inToken)
  7405. var re = this.tokenRe;
  7406. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  7407. var re = /\s/;
  7408. else
  7409. var re = this.nonTokenRe;
  7410. var start = column;
  7411. if (start > 0) {
  7412. do {
  7413. start--;
  7414. }
  7415. while (start >= 0 && line.charAt(start).match(re));
  7416. start++;
  7417. }
  7418. var end = column;
  7419. while (end < line.length && line.charAt(end).match(re)) {
  7420. end++;
  7421. }
  7422. return new Range(row, start, row, end);
  7423. };
  7424. this.getAWordRange = function(row, column) {
  7425. var wordRange = this.getWordRange(row, column);
  7426. var line = this.getLine(wordRange.end.row);
  7427. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  7428. wordRange.end.column += 1;
  7429. }
  7430. return wordRange;
  7431. };
  7432. this.setNewLineMode = function(newLineMode) {
  7433. this.doc.setNewLineMode(newLineMode);
  7434. };
  7435. this.getNewLineMode = function() {
  7436. return this.doc.getNewLineMode();
  7437. };
  7438. this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
  7439. this.getUseWorker = function() { return this.$useWorker; };
  7440. this.onReloadTokenizer = function(e) {
  7441. var rows = e.data;
  7442. this.bgTokenizer.start(rows.first);
  7443. this._signal("tokenizerUpdate", e);
  7444. };
  7445. this.$modes = {};
  7446. this.$mode = null;
  7447. this.$modeId = null;
  7448. this.setMode = function(mode, cb) {
  7449. if (mode && typeof mode === "object") {
  7450. if (mode.getTokenizer)
  7451. return this.$onChangeMode(mode);
  7452. var options = mode;
  7453. var path = options.path;
  7454. } else {
  7455. path = mode || "ace/mode/text";
  7456. }
  7457. if (!this.$modes["ace/mode/text"])
  7458. this.$modes["ace/mode/text"] = new TextMode();
  7459. if (this.$modes[path] && !options) {
  7460. this.$onChangeMode(this.$modes[path]);
  7461. cb && cb();
  7462. return;
  7463. }
  7464. this.$modeId = path;
  7465. config.loadModule(["mode", path], function(m) {
  7466. if (this.$modeId !== path)
  7467. return cb && cb();
  7468. if (this.$modes[path] && !options)
  7469. return this.$onChangeMode(this.$modes[path]);
  7470. if (m && m.Mode) {
  7471. m = new m.Mode(options);
  7472. if (!options) {
  7473. this.$modes[path] = m;
  7474. m.$id = path;
  7475. }
  7476. this.$onChangeMode(m);
  7477. cb && cb();
  7478. }
  7479. }.bind(this));
  7480. if (!this.$mode)
  7481. this.$onChangeMode(this.$modes["ace/mode/text"], true);
  7482. };
  7483. this.$onChangeMode = function(mode, $isPlaceholder) {
  7484. if (!$isPlaceholder)
  7485. this.$modeId = mode.$id;
  7486. if (this.$mode === mode)
  7487. return;
  7488. this.$mode = mode;
  7489. this.$stopWorker();
  7490. if (this.$useWorker)
  7491. this.$startWorker();
  7492. var tokenizer = mode.getTokenizer();
  7493. if(tokenizer.addEventListener !== undefined) {
  7494. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  7495. tokenizer.addEventListener("update", onReloadTokenizer);
  7496. }
  7497. if (!this.bgTokenizer) {
  7498. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  7499. var _self = this;
  7500. this.bgTokenizer.addEventListener("update", function(e) {
  7501. _self._signal("tokenizerUpdate", e);
  7502. });
  7503. } else {
  7504. this.bgTokenizer.setTokenizer(tokenizer);
  7505. }
  7506. this.bgTokenizer.setDocument(this.getDocument());
  7507. this.tokenRe = mode.tokenRe;
  7508. this.nonTokenRe = mode.nonTokenRe;
  7509. if (!$isPlaceholder) {
  7510. if (mode.attachToSession)
  7511. mode.attachToSession(this);
  7512. this.$options.wrapMethod.set.call(this, this.$wrapMethod);
  7513. this.$setFolding(mode.foldingRules);
  7514. this.bgTokenizer.start(0);
  7515. this._emit("changeMode");
  7516. }
  7517. };
  7518. this.$stopWorker = function() {
  7519. if (this.$worker) {
  7520. this.$worker.terminate();
  7521. this.$worker = null;
  7522. }
  7523. };
  7524. this.$startWorker = function() {
  7525. try {
  7526. this.$worker = this.$mode.createWorker(this);
  7527. } catch (e) {
  7528. config.warn("Could not load worker", e);
  7529. this.$worker = null;
  7530. }
  7531. };
  7532. this.getMode = function() {
  7533. return this.$mode;
  7534. };
  7535. this.$scrollTop = 0;
  7536. this.setScrollTop = function(scrollTop) {
  7537. if (this.$scrollTop === scrollTop || isNaN(scrollTop))
  7538. return;
  7539. this.$scrollTop = scrollTop;
  7540. this._signal("changeScrollTop", scrollTop);
  7541. };
  7542. this.getScrollTop = function() {
  7543. return this.$scrollTop;
  7544. };
  7545. this.$scrollLeft = 0;
  7546. this.setScrollLeft = function(scrollLeft) {
  7547. if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
  7548. return;
  7549. this.$scrollLeft = scrollLeft;
  7550. this._signal("changeScrollLeft", scrollLeft);
  7551. };
  7552. this.getScrollLeft = function() {
  7553. return this.$scrollLeft;
  7554. };
  7555. this.getScreenWidth = function() {
  7556. this.$computeWidth();
  7557. if (this.lineWidgets)
  7558. return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
  7559. return this.screenWidth;
  7560. };
  7561. this.getLineWidgetMaxWidth = function() {
  7562. if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
  7563. var width = 0;
  7564. this.lineWidgets.forEach(function(w) {
  7565. if (w && w.screenWidth > width)
  7566. width = w.screenWidth;
  7567. });
  7568. return this.lineWidgetWidth = width;
  7569. };
  7570. this.$computeWidth = function(force) {
  7571. if (this.$modified || force) {
  7572. this.$modified = false;
  7573. if (this.$useWrapMode)
  7574. return this.screenWidth = this.$wrapLimit;
  7575. var lines = this.doc.getAllLines();
  7576. var cache = this.$rowLengthCache;
  7577. var longestScreenLine = 0;
  7578. var foldIndex = 0;
  7579. var foldLine = this.$foldData[foldIndex];
  7580. var foldStart = foldLine ? foldLine.start.row : Infinity;
  7581. var len = lines.length;
  7582. for (var i = 0; i < len; i++) {
  7583. if (i > foldStart) {
  7584. i = foldLine.end.row + 1;
  7585. if (i >= len)
  7586. break;
  7587. foldLine = this.$foldData[foldIndex++];
  7588. foldStart = foldLine ? foldLine.start.row : Infinity;
  7589. }
  7590. if (cache[i] == null)
  7591. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  7592. if (cache[i] > longestScreenLine)
  7593. longestScreenLine = cache[i];
  7594. }
  7595. this.screenWidth = longestScreenLine;
  7596. }
  7597. };
  7598. this.getLine = function(row) {
  7599. return this.doc.getLine(row);
  7600. };
  7601. this.getLines = function(firstRow, lastRow) {
  7602. return this.doc.getLines(firstRow, lastRow);
  7603. };
  7604. this.getLength = function() {
  7605. return this.doc.getLength();
  7606. };
  7607. this.getTextRange = function(range) {
  7608. return this.doc.getTextRange(range || this.selection.getRange());
  7609. };
  7610. this.insert = function(position, text) {
  7611. return this.doc.insert(position, text);
  7612. };
  7613. this.remove = function(range) {
  7614. return this.doc.remove(range);
  7615. };
  7616. this.undoChanges = function(deltas, dontSelect) {
  7617. if (!deltas.length)
  7618. return;
  7619. this.$fromUndo = true;
  7620. var lastUndoRange = null;
  7621. for (var i = deltas.length - 1; i != -1; i--) {
  7622. var delta = deltas[i];
  7623. if (delta.group == "doc") {
  7624. this.doc.revertDeltas(delta.deltas);
  7625. lastUndoRange =
  7626. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  7627. } else {
  7628. delta.deltas.forEach(function(foldDelta) {
  7629. this.addFolds(foldDelta.folds);
  7630. }, this);
  7631. }
  7632. }
  7633. this.$fromUndo = false;
  7634. lastUndoRange &&
  7635. this.$undoSelect &&
  7636. !dontSelect &&
  7637. this.selection.setSelectionRange(lastUndoRange);
  7638. return lastUndoRange;
  7639. };
  7640. this.redoChanges = function(deltas, dontSelect) {
  7641. if (!deltas.length)
  7642. return;
  7643. this.$fromUndo = true;
  7644. var lastUndoRange = null;
  7645. for (var i = 0; i < deltas.length; i++) {
  7646. var delta = deltas[i];
  7647. if (delta.group == "doc") {
  7648. this.doc.applyDeltas(delta.deltas);
  7649. lastUndoRange =
  7650. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  7651. }
  7652. }
  7653. this.$fromUndo = false;
  7654. lastUndoRange &&
  7655. this.$undoSelect &&
  7656. !dontSelect &&
  7657. this.selection.setSelectionRange(lastUndoRange);
  7658. return lastUndoRange;
  7659. };
  7660. this.setUndoSelect = function(enable) {
  7661. this.$undoSelect = enable;
  7662. };
  7663. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  7664. function isInsert(delta) {
  7665. var insert =
  7666. delta.action === "insertText" || delta.action === "insertLines";
  7667. return isUndo ? !insert : insert;
  7668. }
  7669. var delta = deltas[0];
  7670. var range, point;
  7671. var lastDeltaIsInsert = false;
  7672. if (isInsert(delta)) {
  7673. range = Range.fromPoints(delta.range.start, delta.range.end);
  7674. lastDeltaIsInsert = true;
  7675. } else {
  7676. range = Range.fromPoints(delta.range.start, delta.range.start);
  7677. lastDeltaIsInsert = false;
  7678. }
  7679. for (var i = 1; i < deltas.length; i++) {
  7680. delta = deltas[i];
  7681. if (isInsert(delta)) {
  7682. point = delta.range.start;
  7683. if (range.compare(point.row, point.column) == -1) {
  7684. range.setStart(delta.range.start);
  7685. }
  7686. point = delta.range.end;
  7687. if (range.compare(point.row, point.column) == 1) {
  7688. range.setEnd(delta.range.end);
  7689. }
  7690. lastDeltaIsInsert = true;
  7691. } else {
  7692. point = delta.range.start;
  7693. if (range.compare(point.row, point.column) == -1) {
  7694. range =
  7695. Range.fromPoints(delta.range.start, delta.range.start);
  7696. }
  7697. lastDeltaIsInsert = false;
  7698. }
  7699. }
  7700. if (lastUndoRange != null) {
  7701. if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
  7702. lastUndoRange.start.column += range.end.column - range.start.column;
  7703. lastUndoRange.end.column += range.end.column - range.start.column;
  7704. }
  7705. var cmp = lastUndoRange.compareRange(range);
  7706. if (cmp == 1) {
  7707. range.setStart(lastUndoRange.start);
  7708. } else if (cmp == -1) {
  7709. range.setEnd(lastUndoRange.end);
  7710. }
  7711. }
  7712. return range;
  7713. };
  7714. this.replace = function(range, text) {
  7715. return this.doc.replace(range, text);
  7716. };
  7717. this.moveText = function(fromRange, toPosition, copy) {
  7718. var text = this.getTextRange(fromRange);
  7719. var folds = this.getFoldsInRange(fromRange);
  7720. var toRange = Range.fromPoints(toPosition, toPosition);
  7721. if (!copy) {
  7722. this.remove(fromRange);
  7723. var rowDiff = fromRange.start.row - fromRange.end.row;
  7724. var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
  7725. if (collDiff) {
  7726. if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
  7727. toRange.start.column += collDiff;
  7728. if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
  7729. toRange.end.column += collDiff;
  7730. }
  7731. if (rowDiff && toRange.start.row >= fromRange.end.row) {
  7732. toRange.start.row += rowDiff;
  7733. toRange.end.row += rowDiff;
  7734. }
  7735. }
  7736. toRange.end = this.insert(toRange.start, text);
  7737. if (folds.length) {
  7738. var oldStart = fromRange.start;
  7739. var newStart = toRange.start;
  7740. var rowDiff = newStart.row - oldStart.row;
  7741. var collDiff = newStart.column - oldStart.column;
  7742. this.addFolds(folds.map(function(x) {
  7743. x = x.clone();
  7744. if (x.start.row == oldStart.row)
  7745. x.start.column += collDiff;
  7746. if (x.end.row == oldStart.row)
  7747. x.end.column += collDiff;
  7748. x.start.row += rowDiff;
  7749. x.end.row += rowDiff;
  7750. return x;
  7751. }));
  7752. }
  7753. return toRange;
  7754. };
  7755. this.indentRows = function(startRow, endRow, indentString) {
  7756. indentString = indentString.replace(/\t/g, this.getTabString());
  7757. for (var row=startRow; row<=endRow; row++)
  7758. this.insert({row: row, column:0}, indentString);
  7759. };
  7760. this.outdentRows = function (range) {
  7761. var rowRange = range.collapseRows();
  7762. var deleteRange = new Range(0, 0, 0, 0);
  7763. var size = this.getTabSize();
  7764. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  7765. var line = this.getLine(i);
  7766. deleteRange.start.row = i;
  7767. deleteRange.end.row = i;
  7768. for (var j = 0; j < size; ++j)
  7769. if (line.charAt(j) != ' ')
  7770. break;
  7771. if (j < size && line.charAt(j) == '\t') {
  7772. deleteRange.start.column = j;
  7773. deleteRange.end.column = j + 1;
  7774. } else {
  7775. deleteRange.start.column = 0;
  7776. deleteRange.end.column = j;
  7777. }
  7778. this.remove(deleteRange);
  7779. }
  7780. };
  7781. this.$moveLines = function(firstRow, lastRow, dir) {
  7782. firstRow = this.getRowFoldStart(firstRow);
  7783. lastRow = this.getRowFoldEnd(lastRow);
  7784. if (dir < 0) {
  7785. var row = this.getRowFoldStart(firstRow + dir);
  7786. if (row < 0) return 0;
  7787. var diff = row-firstRow;
  7788. } else if (dir > 0) {
  7789. var row = this.getRowFoldEnd(lastRow + dir);
  7790. if (row > this.doc.getLength()-1) return 0;
  7791. var diff = row-lastRow;
  7792. } else {
  7793. firstRow = this.$clipRowToDocument(firstRow);
  7794. lastRow = this.$clipRowToDocument(lastRow);
  7795. var diff = lastRow - firstRow + 1;
  7796. }
  7797. var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
  7798. var folds = this.getFoldsInRange(range).map(function(x){
  7799. x = x.clone();
  7800. x.start.row += diff;
  7801. x.end.row += diff;
  7802. return x;
  7803. });
  7804. var lines = dir == 0
  7805. ? this.doc.getLines(firstRow, lastRow)
  7806. : this.doc.removeLines(firstRow, lastRow);
  7807. this.doc.insertLines(firstRow+diff, lines);
  7808. folds.length && this.addFolds(folds);
  7809. return diff;
  7810. };
  7811. this.moveLinesUp = function(firstRow, lastRow) {
  7812. return this.$moveLines(firstRow, lastRow, -1);
  7813. };
  7814. this.moveLinesDown = function(firstRow, lastRow) {
  7815. return this.$moveLines(firstRow, lastRow, 1);
  7816. };
  7817. this.duplicateLines = function(firstRow, lastRow) {
  7818. return this.$moveLines(firstRow, lastRow, 0);
  7819. };
  7820. this.$clipRowToDocument = function(row) {
  7821. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  7822. };
  7823. this.$clipColumnToRow = function(row, column) {
  7824. if (column < 0)
  7825. return 0;
  7826. return Math.min(this.doc.getLine(row).length, column);
  7827. };
  7828. this.$clipPositionToDocument = function(row, column) {
  7829. column = Math.max(0, column);
  7830. if (row < 0) {
  7831. row = 0;
  7832. column = 0;
  7833. } else {
  7834. var len = this.doc.getLength();
  7835. if (row >= len) {
  7836. row = len - 1;
  7837. column = this.doc.getLine(len-1).length;
  7838. } else {
  7839. column = Math.min(this.doc.getLine(row).length, column);
  7840. }
  7841. }
  7842. return {
  7843. row: row,
  7844. column: column
  7845. };
  7846. };
  7847. this.$clipRangeToDocument = function(range) {
  7848. if (range.start.row < 0) {
  7849. range.start.row = 0;
  7850. range.start.column = 0;
  7851. } else {
  7852. range.start.column = this.$clipColumnToRow(
  7853. range.start.row,
  7854. range.start.column
  7855. );
  7856. }
  7857. var len = this.doc.getLength() - 1;
  7858. if (range.end.row > len) {
  7859. range.end.row = len;
  7860. range.end.column = this.doc.getLine(len).length;
  7861. } else {
  7862. range.end.column = this.$clipColumnToRow(
  7863. range.end.row,
  7864. range.end.column
  7865. );
  7866. }
  7867. return range;
  7868. };
  7869. this.$wrapLimit = 80;
  7870. this.$useWrapMode = false;
  7871. this.$wrapLimitRange = {
  7872. min : null,
  7873. max : null
  7874. };
  7875. this.setUseWrapMode = function(useWrapMode) {
  7876. if (useWrapMode != this.$useWrapMode) {
  7877. this.$useWrapMode = useWrapMode;
  7878. this.$modified = true;
  7879. this.$resetRowCache(0);
  7880. if (useWrapMode) {
  7881. var len = this.getLength();
  7882. this.$wrapData = Array(len);
  7883. this.$updateWrapData(0, len - 1);
  7884. }
  7885. this._signal("changeWrapMode");
  7886. }
  7887. };
  7888. this.getUseWrapMode = function() {
  7889. return this.$useWrapMode;
  7890. };
  7891. this.setWrapLimitRange = function(min, max) {
  7892. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  7893. this.$wrapLimitRange = {
  7894. min: min,
  7895. max: max
  7896. };
  7897. this.$modified = true;
  7898. this._signal("changeWrapMode");
  7899. }
  7900. };
  7901. this.adjustWrapLimit = function(desiredLimit, $printMargin) {
  7902. var limits = this.$wrapLimitRange;
  7903. if (limits.max < 0)
  7904. limits = {min: $printMargin, max: $printMargin};
  7905. var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
  7906. if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
  7907. this.$wrapLimit = wrapLimit;
  7908. this.$modified = true;
  7909. if (this.$useWrapMode) {
  7910. this.$updateWrapData(0, this.getLength() - 1);
  7911. this.$resetRowCache(0);
  7912. this._signal("changeWrapLimit");
  7913. }
  7914. return true;
  7915. }
  7916. return false;
  7917. };
  7918. this.$constrainWrapLimit = function(wrapLimit, min, max) {
  7919. if (min)
  7920. wrapLimit = Math.max(min, wrapLimit);
  7921. if (max)
  7922. wrapLimit = Math.min(max, wrapLimit);
  7923. return wrapLimit;
  7924. };
  7925. this.getWrapLimit = function() {
  7926. return this.$wrapLimit;
  7927. };
  7928. this.setWrapLimit = function (limit) {
  7929. this.setWrapLimitRange(limit, limit);
  7930. };
  7931. this.getWrapLimitRange = function() {
  7932. return {
  7933. min : this.$wrapLimitRange.min,
  7934. max : this.$wrapLimitRange.max
  7935. };
  7936. };
  7937. this.$updateInternalDataOnChange = function(e) {
  7938. var useWrapMode = this.$useWrapMode;
  7939. var len;
  7940. var action = e.data.action;
  7941. var firstRow = e.data.range.start.row;
  7942. var lastRow = e.data.range.end.row;
  7943. var start = e.data.range.start;
  7944. var end = e.data.range.end;
  7945. var removedFolds = null;
  7946. if (action.indexOf("Lines") != -1) {
  7947. if (action == "insertLines") {
  7948. lastRow = firstRow + (e.data.lines.length);
  7949. } else {
  7950. lastRow = firstRow;
  7951. }
  7952. len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
  7953. } else {
  7954. len = lastRow - firstRow;
  7955. }
  7956. this.$updating = true;
  7957. if (len != 0) {
  7958. if (action.indexOf("remove") != -1) {
  7959. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  7960. var foldLines = this.$foldData;
  7961. removedFolds = this.getFoldsInRange(e.data.range);
  7962. this.removeFolds(removedFolds);
  7963. var foldLine = this.getFoldLine(end.row);
  7964. var idx = 0;
  7965. if (foldLine) {
  7966. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  7967. foldLine.shiftRow(-len);
  7968. var foldLineBefore = this.getFoldLine(firstRow);
  7969. if (foldLineBefore && foldLineBefore !== foldLine) {
  7970. foldLineBefore.merge(foldLine);
  7971. foldLine = foldLineBefore;
  7972. }
  7973. idx = foldLines.indexOf(foldLine) + 1;
  7974. }
  7975. for (idx; idx < foldLines.length; idx++) {
  7976. var foldLine = foldLines[idx];
  7977. if (foldLine.start.row >= end.row) {
  7978. foldLine.shiftRow(-len);
  7979. }
  7980. }
  7981. lastRow = firstRow;
  7982. } else {
  7983. var args = Array(len);
  7984. args.unshift(firstRow, 0);
  7985. var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
  7986. arr.splice.apply(arr, args);
  7987. var foldLines = this.$foldData;
  7988. var foldLine = this.getFoldLine(firstRow);
  7989. var idx = 0;
  7990. if (foldLine) {
  7991. var cmp = foldLine.range.compareInside(start.row, start.column);
  7992. if (cmp == 0) {
  7993. foldLine = foldLine.split(start.row, start.column);
  7994. if (foldLine) {
  7995. foldLine.shiftRow(len);
  7996. foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
  7997. }
  7998. } else
  7999. if (cmp == -1) {
  8000. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  8001. foldLine.shiftRow(len);
  8002. }
  8003. idx = foldLines.indexOf(foldLine) + 1;
  8004. }
  8005. for (idx; idx < foldLines.length; idx++) {
  8006. var foldLine = foldLines[idx];
  8007. if (foldLine.start.row >= firstRow) {
  8008. foldLine.shiftRow(len);
  8009. }
  8010. }
  8011. }
  8012. } else {
  8013. len = Math.abs(e.data.range.start.column - e.data.range.end.column);
  8014. if (action.indexOf("remove") != -1) {
  8015. removedFolds = this.getFoldsInRange(e.data.range);
  8016. this.removeFolds(removedFolds);
  8017. len = -len;
  8018. }
  8019. var foldLine = this.getFoldLine(firstRow);
  8020. if (foldLine) {
  8021. foldLine.addRemoveChars(firstRow, start.column, len);
  8022. }
  8023. }
  8024. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  8025. console.error("doc.getLength() and $wrapData.length have to be the same!");
  8026. }
  8027. this.$updating = false;
  8028. if (useWrapMode)
  8029. this.$updateWrapData(firstRow, lastRow);
  8030. else
  8031. this.$updateRowLengthCache(firstRow, lastRow);
  8032. return removedFolds;
  8033. };
  8034. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  8035. this.$rowLengthCache[firstRow] = null;
  8036. this.$rowLengthCache[lastRow] = null;
  8037. };
  8038. this.$updateWrapData = function(firstRow, lastRow) {
  8039. var lines = this.doc.getAllLines();
  8040. var tabSize = this.getTabSize();
  8041. var wrapData = this.$wrapData;
  8042. var wrapLimit = this.$wrapLimit;
  8043. var tokens;
  8044. var foldLine;
  8045. var row = firstRow;
  8046. lastRow = Math.min(lastRow, lines.length - 1);
  8047. while (row <= lastRow) {
  8048. foldLine = this.getFoldLine(row, foldLine);
  8049. if (!foldLine) {
  8050. tokens = this.$getDisplayTokens(lines[row]);
  8051. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8052. row ++;
  8053. } else {
  8054. tokens = [];
  8055. foldLine.walk(function(placeholder, row, column, lastColumn) {
  8056. var walkTokens;
  8057. if (placeholder != null) {
  8058. walkTokens = this.$getDisplayTokens(
  8059. placeholder, tokens.length);
  8060. walkTokens[0] = PLACEHOLDER_START;
  8061. for (var i = 1; i < walkTokens.length; i++) {
  8062. walkTokens[i] = PLACEHOLDER_BODY;
  8063. }
  8064. } else {
  8065. walkTokens = this.$getDisplayTokens(
  8066. lines[row].substring(lastColumn, column),
  8067. tokens.length);
  8068. }
  8069. tokens = tokens.concat(walkTokens);
  8070. }.bind(this),
  8071. foldLine.end.row,
  8072. lines[foldLine.end.row].length + 1
  8073. );
  8074. wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8075. row = foldLine.end.row + 1;
  8076. }
  8077. }
  8078. };
  8079. var CHAR = 1,
  8080. CHAR_EXT = 2,
  8081. PLACEHOLDER_START = 3,
  8082. PLACEHOLDER_BODY = 4,
  8083. PUNCTUATION = 9,
  8084. SPACE = 10,
  8085. TAB = 11,
  8086. TAB_SPACE = 12;
  8087. this.$computeWrapSplits = function(tokens, wrapLimit) {
  8088. if (tokens.length == 0) {
  8089. return [];
  8090. }
  8091. var splits = [];
  8092. var displayLength = tokens.length;
  8093. var lastSplit = 0, lastDocSplit = 0;
  8094. var isCode = this.$wrapAsCode;
  8095. function addSplit(screenPos) {
  8096. var displayed = tokens.slice(lastSplit, screenPos);
  8097. var len = displayed.length;
  8098. displayed.join("").
  8099. replace(/12/g, function() {
  8100. len -= 1;
  8101. }).
  8102. replace(/2/g, function() {
  8103. len -= 1;
  8104. });
  8105. lastDocSplit += len;
  8106. splits.push(lastDocSplit);
  8107. lastSplit = screenPos;
  8108. }
  8109. while (displayLength - lastSplit > wrapLimit) {
  8110. var split = lastSplit + wrapLimit;
  8111. if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
  8112. addSplit(split);
  8113. continue;
  8114. }
  8115. if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
  8116. for (split; split != lastSplit - 1; split--) {
  8117. if (tokens[split] == PLACEHOLDER_START) {
  8118. break;
  8119. }
  8120. }
  8121. if (split > lastSplit) {
  8122. addSplit(split);
  8123. continue;
  8124. }
  8125. split = lastSplit + wrapLimit;
  8126. for (split; split < tokens.length; split++) {
  8127. if (tokens[split] != PLACEHOLDER_BODY) {
  8128. break;
  8129. }
  8130. }
  8131. if (split == tokens.length) {
  8132. break; // Breaks the while-loop.
  8133. }
  8134. addSplit(split);
  8135. continue;
  8136. }
  8137. var minSplit = Math.max(split - (isCode ? 10 : wrapLimit-(wrapLimit>>2)), lastSplit - 1);
  8138. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8139. split --;
  8140. }
  8141. if (isCode) {
  8142. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8143. split --;
  8144. }
  8145. while (split > minSplit && tokens[split] == PUNCTUATION) {
  8146. split --;
  8147. }
  8148. } else {
  8149. while (split > minSplit && tokens[split] < SPACE) {
  8150. split --;
  8151. }
  8152. }
  8153. if (split > minSplit) {
  8154. addSplit(++split);
  8155. continue;
  8156. }
  8157. split = lastSplit + wrapLimit;
  8158. if (tokens[split] == CHAR_EXT)
  8159. split--;
  8160. addSplit(split);
  8161. }
  8162. return splits;
  8163. };
  8164. this.$getDisplayTokens = function(str, offset) {
  8165. var arr = [];
  8166. var tabSize;
  8167. offset = offset || 0;
  8168. for (var i = 0; i < str.length; i++) {
  8169. var c = str.charCodeAt(i);
  8170. if (c == 9) {
  8171. tabSize = this.getScreenTabSize(arr.length + offset);
  8172. arr.push(TAB);
  8173. for (var n = 1; n < tabSize; n++) {
  8174. arr.push(TAB_SPACE);
  8175. }
  8176. }
  8177. else if (c == 32) {
  8178. arr.push(SPACE);
  8179. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  8180. arr.push(PUNCTUATION);
  8181. }
  8182. else if (c >= 0x1100 && isFullWidth(c)) {
  8183. arr.push(CHAR, CHAR_EXT);
  8184. } else {
  8185. arr.push(CHAR);
  8186. }
  8187. }
  8188. return arr;
  8189. };
  8190. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8191. if (maxScreenColumn == 0)
  8192. return [0, 0];
  8193. if (maxScreenColumn == null)
  8194. maxScreenColumn = Infinity;
  8195. screenColumn = screenColumn || 0;
  8196. var c, column;
  8197. for (column = 0; column < str.length; column++) {
  8198. c = str.charCodeAt(column);
  8199. if (c == 9) {
  8200. screenColumn += this.getScreenTabSize(screenColumn);
  8201. }
  8202. else if (c >= 0x1100 && isFullWidth(c)) {
  8203. screenColumn += 2;
  8204. } else {
  8205. screenColumn += 1;
  8206. }
  8207. if (screenColumn > maxScreenColumn) {
  8208. break;
  8209. }
  8210. }
  8211. return [screenColumn, column];
  8212. };
  8213. this.lineWidgets = null;
  8214. this.getRowLength = function(row) {
  8215. if (this.lineWidgets)
  8216. var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  8217. else
  8218. h = 0
  8219. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8220. return 1 + h;
  8221. } else {
  8222. return this.$wrapData[row].length + 1 + h;
  8223. }
  8224. };
  8225. this.getRowLineCount = function(row) {
  8226. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8227. return 1;
  8228. } else {
  8229. return this.$wrapData[row].length + 1;
  8230. }
  8231. };
  8232. this.getScreenLastRowColumn = function(screenRow) {
  8233. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8234. return this.documentToScreenColumn(pos.row, pos.column);
  8235. };
  8236. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  8237. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8238. return this.getScreenLastRowColumn(screenRow);
  8239. };
  8240. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  8241. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8242. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  8243. };
  8244. this.getRowSplitData = function(row) {
  8245. if (!this.$useWrapMode) {
  8246. return undefined;
  8247. } else {
  8248. return this.$wrapData[row];
  8249. }
  8250. };
  8251. this.getScreenTabSize = function(screenColumn) {
  8252. return this.$tabSize - screenColumn % this.$tabSize;
  8253. };
  8254. this.screenToDocumentRow = function(screenRow, screenColumn) {
  8255. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  8256. };
  8257. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  8258. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  8259. };
  8260. this.screenToDocumentPosition = function(screenRow, screenColumn) {
  8261. if (screenRow < 0)
  8262. return {row: 0, column: 0};
  8263. var line;
  8264. var docRow = 0;
  8265. var docColumn = 0;
  8266. var column;
  8267. var row = 0;
  8268. var rowLength = 0;
  8269. var rowCache = this.$screenRowCache;
  8270. var i = this.$getRowCacheIndex(rowCache, screenRow);
  8271. var l = rowCache.length;
  8272. if (l && i >= 0) {
  8273. var row = rowCache[i];
  8274. var docRow = this.$docRowCache[i];
  8275. var doCache = screenRow > rowCache[l - 1];
  8276. } else {
  8277. var doCache = !l;
  8278. }
  8279. var maxRow = this.getLength() - 1;
  8280. var foldLine = this.getNextFoldLine(docRow);
  8281. var foldStart = foldLine ? foldLine.start.row : Infinity;
  8282. while (row <= screenRow) {
  8283. rowLength = this.getRowLength(docRow);
  8284. if (row + rowLength > screenRow || docRow >= maxRow) {
  8285. break;
  8286. } else {
  8287. row += rowLength;
  8288. docRow++;
  8289. if (docRow > foldStart) {
  8290. docRow = foldLine.end.row+1;
  8291. foldLine = this.getNextFoldLine(docRow, foldLine);
  8292. foldStart = foldLine ? foldLine.start.row : Infinity;
  8293. }
  8294. }
  8295. if (doCache) {
  8296. this.$docRowCache.push(docRow);
  8297. this.$screenRowCache.push(row);
  8298. }
  8299. }
  8300. if (foldLine && foldLine.start.row <= docRow) {
  8301. line = this.getFoldDisplayLine(foldLine);
  8302. docRow = foldLine.start.row;
  8303. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  8304. return {
  8305. row: maxRow,
  8306. column: this.getLine(maxRow).length
  8307. };
  8308. } else {
  8309. line = this.getLine(docRow);
  8310. foldLine = null;
  8311. }
  8312. if (this.$useWrapMode) {
  8313. var splits = this.$wrapData[docRow];
  8314. if (splits) {
  8315. var splitIndex = Math.floor(screenRow - row);
  8316. column = splits[splitIndex];
  8317. if(splitIndex > 0 && splits.length) {
  8318. docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
  8319. line = line.substring(docColumn);
  8320. }
  8321. }
  8322. }
  8323. docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
  8324. if (this.$useWrapMode && docColumn >= column)
  8325. docColumn = column - 1;
  8326. if (foldLine)
  8327. return foldLine.idxToPosition(docColumn);
  8328. return {row: docRow, column: docColumn};
  8329. };
  8330. this.documentToScreenPosition = function(docRow, docColumn) {
  8331. if (typeof docColumn === "undefined")
  8332. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  8333. else
  8334. pos = this.$clipPositionToDocument(docRow, docColumn);
  8335. docRow = pos.row;
  8336. docColumn = pos.column;
  8337. var screenRow = 0;
  8338. var foldStartRow = null;
  8339. var fold = null;
  8340. fold = this.getFoldAt(docRow, docColumn, 1);
  8341. if (fold) {
  8342. docRow = fold.start.row;
  8343. docColumn = fold.start.column;
  8344. }
  8345. var rowEnd, row = 0;
  8346. var rowCache = this.$docRowCache;
  8347. var i = this.$getRowCacheIndex(rowCache, docRow);
  8348. var l = rowCache.length;
  8349. if (l && i >= 0) {
  8350. var row = rowCache[i];
  8351. var screenRow = this.$screenRowCache[i];
  8352. var doCache = docRow > rowCache[l - 1];
  8353. } else {
  8354. var doCache = !l;
  8355. }
  8356. var foldLine = this.getNextFoldLine(row);
  8357. var foldStart = foldLine ?foldLine.start.row :Infinity;
  8358. while (row < docRow) {
  8359. if (row >= foldStart) {
  8360. rowEnd = foldLine.end.row + 1;
  8361. if (rowEnd > docRow)
  8362. break;
  8363. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  8364. foldStart = foldLine ?foldLine.start.row :Infinity;
  8365. }
  8366. else {
  8367. rowEnd = row + 1;
  8368. }
  8369. screenRow += this.getRowLength(row);
  8370. row = rowEnd;
  8371. if (doCache) {
  8372. this.$docRowCache.push(row);
  8373. this.$screenRowCache.push(screenRow);
  8374. }
  8375. }
  8376. var textLine = "";
  8377. if (foldLine && row >= foldStart) {
  8378. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  8379. foldStartRow = foldLine.start.row;
  8380. } else {
  8381. textLine = this.getLine(docRow).substring(0, docColumn);
  8382. foldStartRow = docRow;
  8383. }
  8384. if (this.$useWrapMode) {
  8385. var wrapRow = this.$wrapData[foldStartRow];
  8386. if (wrapRow) {
  8387. var screenRowOffset = 0;
  8388. while (textLine.length >= wrapRow[screenRowOffset]) {
  8389. screenRow ++;
  8390. screenRowOffset++;
  8391. }
  8392. textLine = textLine.substring(
  8393. wrapRow[screenRowOffset - 1] || 0, textLine.length
  8394. );
  8395. }
  8396. }
  8397. return {
  8398. row: screenRow,
  8399. column: this.$getStringScreenWidth(textLine)[0]
  8400. };
  8401. };
  8402. this.documentToScreenColumn = function(row, docColumn) {
  8403. return this.documentToScreenPosition(row, docColumn).column;
  8404. };
  8405. this.documentToScreenRow = function(docRow, docColumn) {
  8406. return this.documentToScreenPosition(docRow, docColumn).row;
  8407. };
  8408. this.getScreenLength = function() {
  8409. var screenRows = 0;
  8410. var fold = null;
  8411. if (!this.$useWrapMode) {
  8412. screenRows = this.getLength();
  8413. var foldData = this.$foldData;
  8414. for (var i = 0; i < foldData.length; i++) {
  8415. fold = foldData[i];
  8416. screenRows -= fold.end.row - fold.start.row;
  8417. }
  8418. } else {
  8419. var lastRow = this.$wrapData.length;
  8420. var row = 0, i = 0;
  8421. var fold = this.$foldData[i++];
  8422. var foldStart = fold ? fold.start.row :Infinity;
  8423. while (row < lastRow) {
  8424. var splits = this.$wrapData[row];
  8425. screenRows += splits ? splits.length + 1 : 1;
  8426. row ++;
  8427. if (row > foldStart) {
  8428. row = fold.end.row+1;
  8429. fold = this.$foldData[i++];
  8430. foldStart = fold ?fold.start.row :Infinity;
  8431. }
  8432. }
  8433. }
  8434. if (this.lineWidgets)
  8435. screenRows += this.$getWidgetScreenLength();
  8436. return screenRows;
  8437. };
  8438. this.$setFontMetrics = function(fm) {
  8439. };
  8440. this.destroy = function() {
  8441. if (this.bgTokenizer) {
  8442. this.bgTokenizer.setDocument(null);
  8443. this.bgTokenizer = null;
  8444. }
  8445. this.$stopWorker();
  8446. };
  8447. function isFullWidth(c) {
  8448. if (c < 0x1100)
  8449. return false;
  8450. return c >= 0x1100 && c <= 0x115F ||
  8451. c >= 0x11A3 && c <= 0x11A7 ||
  8452. c >= 0x11FA && c <= 0x11FF ||
  8453. c >= 0x2329 && c <= 0x232A ||
  8454. c >= 0x2E80 && c <= 0x2E99 ||
  8455. c >= 0x2E9B && c <= 0x2EF3 ||
  8456. c >= 0x2F00 && c <= 0x2FD5 ||
  8457. c >= 0x2FF0 && c <= 0x2FFB ||
  8458. c >= 0x3000 && c <= 0x303E ||
  8459. c >= 0x3041 && c <= 0x3096 ||
  8460. c >= 0x3099 && c <= 0x30FF ||
  8461. c >= 0x3105 && c <= 0x312D ||
  8462. c >= 0x3131 && c <= 0x318E ||
  8463. c >= 0x3190 && c <= 0x31BA ||
  8464. c >= 0x31C0 && c <= 0x31E3 ||
  8465. c >= 0x31F0 && c <= 0x321E ||
  8466. c >= 0x3220 && c <= 0x3247 ||
  8467. c >= 0x3250 && c <= 0x32FE ||
  8468. c >= 0x3300 && c <= 0x4DBF ||
  8469. c >= 0x4E00 && c <= 0xA48C ||
  8470. c >= 0xA490 && c <= 0xA4C6 ||
  8471. c >= 0xA960 && c <= 0xA97C ||
  8472. c >= 0xAC00 && c <= 0xD7A3 ||
  8473. c >= 0xD7B0 && c <= 0xD7C6 ||
  8474. c >= 0xD7CB && c <= 0xD7FB ||
  8475. c >= 0xF900 && c <= 0xFAFF ||
  8476. c >= 0xFE10 && c <= 0xFE19 ||
  8477. c >= 0xFE30 && c <= 0xFE52 ||
  8478. c >= 0xFE54 && c <= 0xFE66 ||
  8479. c >= 0xFE68 && c <= 0xFE6B ||
  8480. c >= 0xFF01 && c <= 0xFF60 ||
  8481. c >= 0xFFE0 && c <= 0xFFE6;
  8482. };
  8483. }).call(EditSession.prototype);
  8484. require("./edit_session/folding").Folding.call(EditSession.prototype);
  8485. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  8486. config.defineOptions(EditSession.prototype, "session", {
  8487. wrap: {
  8488. set: function(value) {
  8489. if (!value || value == "off")
  8490. value = false;
  8491. else if (value == "free")
  8492. value = true;
  8493. else if (value == "printMargin")
  8494. value = -1;
  8495. else if (typeof value == "string")
  8496. value = parseInt(value, 10) || false;
  8497. if (this.$wrap == value)
  8498. return;
  8499. if (!value) {
  8500. this.setUseWrapMode(false);
  8501. } else {
  8502. var col = typeof value == "number" ? value : null;
  8503. this.setWrapLimitRange(col, col);
  8504. this.setUseWrapMode(true);
  8505. }
  8506. this.$wrap = value;
  8507. },
  8508. get: function() {
  8509. if (this.getUseWrapMode()) {
  8510. if (this.$wrap == -1)
  8511. return "printMargin";
  8512. if (!this.getWrapLimitRange().min)
  8513. return "free";
  8514. return this.$wrap;
  8515. }
  8516. return "off";
  8517. },
  8518. handlesSet: true
  8519. },
  8520. wrapMethod: {
  8521. set: function(val) {
  8522. val = val == "auto"
  8523. ? this.$mode.type != "text"
  8524. : val != "text";
  8525. if (val != this.$wrapAsCode) {
  8526. this.$wrapAsCode = val;
  8527. if (this.$useWrapMode) {
  8528. this.$modified = true;
  8529. this.$resetRowCache(0);
  8530. this.$updateWrapData(0, this.getLength() - 1);
  8531. }
  8532. }
  8533. },
  8534. initialValue: "auto"
  8535. },
  8536. firstLineNumber: {
  8537. set: function() {this._signal("changeBreakpoint");},
  8538. initialValue: 1
  8539. },
  8540. useWorker: {
  8541. set: function(useWorker) {
  8542. this.$useWorker = useWorker;
  8543. this.$stopWorker();
  8544. if (useWorker)
  8545. this.$startWorker();
  8546. },
  8547. initialValue: true
  8548. },
  8549. useSoftTabs: {initialValue: true},
  8550. tabSize: {
  8551. set: function(tabSize) {
  8552. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  8553. this.$modified = true;
  8554. this.$rowLengthCache = [];
  8555. this.$tabSize = tabSize;
  8556. this._signal("changeTabSize");
  8557. },
  8558. initialValue: 4,
  8559. handlesSet: true
  8560. },
  8561. overwrite: {
  8562. set: function(val) {this._signal("changeOverwrite");},
  8563. initialValue: false
  8564. },
  8565. newLineMode: {
  8566. set: function(val) {this.doc.setNewLineMode(val)},
  8567. get: function() {return this.doc.getNewLineMode()},
  8568. handlesSet: true
  8569. },
  8570. mode: {
  8571. set: function(val) { this.setMode(val) },
  8572. get: function() { return this.$modeId }
  8573. }
  8574. });
  8575. exports.EditSession = EditSession;
  8576. });
  8577. ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  8578. "use strict";
  8579. var lang = require("./lib/lang");
  8580. var oop = require("./lib/oop");
  8581. var Range = require("./range").Range;
  8582. var Search = function() {
  8583. this.$options = {};
  8584. };
  8585. (function() {
  8586. this.set = function(options) {
  8587. oop.mixin(this.$options, options);
  8588. return this;
  8589. };
  8590. this.getOptions = function() {
  8591. return lang.copyObject(this.$options);
  8592. };
  8593. this.setOptions = function(options) {
  8594. this.$options = options;
  8595. };
  8596. this.find = function(session) {
  8597. var options = this.$options;
  8598. var iterator = this.$matchIterator(session, options);
  8599. if (!iterator)
  8600. return false;
  8601. var firstRange = null;
  8602. iterator.forEach(function(range, row, offset) {
  8603. if (!range.start) {
  8604. var column = range.offset + (offset || 0);
  8605. firstRange = new Range(row, column, row, column + range.length);
  8606. if (!range.length && options.start && options.start.start
  8607. && options.skipCurrent != false && firstRange.isEqual(options.start)
  8608. ) {
  8609. firstRange = null;
  8610. return false;
  8611. }
  8612. } else
  8613. firstRange = range;
  8614. return true;
  8615. });
  8616. return firstRange;
  8617. };
  8618. this.findAll = function(session) {
  8619. var options = this.$options;
  8620. if (!options.needle)
  8621. return [];
  8622. this.$assembleRegExp(options);
  8623. var range = options.range;
  8624. var lines = range
  8625. ? session.getLines(range.start.row, range.end.row)
  8626. : session.doc.getAllLines();
  8627. var ranges = [];
  8628. var re = options.re;
  8629. if (options.$isMultiLine) {
  8630. var len = re.length;
  8631. var maxRow = lines.length - len;
  8632. var prevRange;
  8633. outer: for (var row = re.offset || 0; row <= maxRow; row++) {
  8634. for (var j = 0; j < len; j++)
  8635. if (lines[row + j].search(re[j]) == -1)
  8636. continue outer;
  8637. var startLine = lines[row];
  8638. var line = lines[row + len - 1];
  8639. var startIndex = startLine.length - startLine.match(re[0])[0].length;
  8640. var endIndex = line.match(re[len - 1])[0].length;
  8641. if (prevRange && prevRange.end.row === row &&
  8642. prevRange.end.column > startIndex
  8643. ) {
  8644. continue;
  8645. }
  8646. ranges.push(prevRange = new Range(
  8647. row, startIndex, row + len - 1, endIndex
  8648. ));
  8649. if (len > 2)
  8650. row = row + len - 2;
  8651. }
  8652. } else {
  8653. for (var i = 0; i < lines.length; i++) {
  8654. var matches = lang.getMatchOffsets(lines[i], re);
  8655. for (var j = 0; j < matches.length; j++) {
  8656. var match = matches[j];
  8657. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  8658. }
  8659. }
  8660. }
  8661. if (range) {
  8662. var startColumn = range.start.column;
  8663. var endColumn = range.start.column;
  8664. var i = 0, j = ranges.length - 1;
  8665. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  8666. i++;
  8667. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  8668. j--;
  8669. ranges = ranges.slice(i, j + 1);
  8670. for (i = 0, j = ranges.length; i < j; i++) {
  8671. ranges[i].start.row += range.start.row;
  8672. ranges[i].end.row += range.start.row;
  8673. }
  8674. }
  8675. return ranges;
  8676. };
  8677. this.replace = function(input, replacement) {
  8678. var options = this.$options;
  8679. var re = this.$assembleRegExp(options);
  8680. if (options.$isMultiLine)
  8681. return replacement;
  8682. if (!re)
  8683. return;
  8684. var match = re.exec(input);
  8685. if (!match || match[0].length != input.length)
  8686. return null;
  8687. replacement = input.replace(re, replacement);
  8688. if (options.preserveCase) {
  8689. replacement = replacement.split("");
  8690. for (var i = Math.min(input.length, input.length); i--; ) {
  8691. var ch = input[i];
  8692. if (ch && ch.toLowerCase() != ch)
  8693. replacement[i] = replacement[i].toUpperCase();
  8694. else
  8695. replacement[i] = replacement[i].toLowerCase();
  8696. }
  8697. replacement = replacement.join("");
  8698. }
  8699. return replacement;
  8700. };
  8701. this.$matchIterator = function(session, options) {
  8702. var re = this.$assembleRegExp(options);
  8703. if (!re)
  8704. return false;
  8705. var callback;
  8706. if (options.$isMultiLine) {
  8707. var len = re.length;
  8708. var matchIterator = function(line, row, offset) {
  8709. var startIndex = line.search(re[0]);
  8710. if (startIndex == -1)
  8711. return;
  8712. for (var i = 1; i < len; i++) {
  8713. line = session.getLine(row + i);
  8714. if (line.search(re[i]) == -1)
  8715. return;
  8716. }
  8717. var endIndex = line.match(re[len - 1])[0].length;
  8718. var range = new Range(row, startIndex, row + len - 1, endIndex);
  8719. if (re.offset == 1) {
  8720. range.start.row--;
  8721. range.start.column = Number.MAX_VALUE;
  8722. } else if (offset)
  8723. range.start.column += offset;
  8724. if (callback(range))
  8725. return true;
  8726. };
  8727. } else if (options.backwards) {
  8728. var matchIterator = function(line, row, startIndex) {
  8729. var matches = lang.getMatchOffsets(line, re);
  8730. for (var i = matches.length-1; i >= 0; i--)
  8731. if (callback(matches[i], row, startIndex))
  8732. return true;
  8733. };
  8734. } else {
  8735. var matchIterator = function(line, row, startIndex) {
  8736. var matches = lang.getMatchOffsets(line, re);
  8737. for (var i = 0; i < matches.length; i++)
  8738. if (callback(matches[i], row, startIndex))
  8739. return true;
  8740. };
  8741. }
  8742. var lineIterator = this.$lineIterator(session, options);
  8743. return {
  8744. forEach: function(_callback) {
  8745. callback = _callback;
  8746. lineIterator.forEach(matchIterator);
  8747. }
  8748. };
  8749. };
  8750. this.$assembleRegExp = function(options, $disableFakeMultiline) {
  8751. if (options.needle instanceof RegExp)
  8752. return options.re = options.needle;
  8753. var needle = options.needle;
  8754. if (!options.needle)
  8755. return options.re = false;
  8756. if (!options.regExp)
  8757. needle = lang.escapeRegExp(needle);
  8758. if (options.wholeWord)
  8759. needle = "\\b" + needle + "\\b";
  8760. var modifier = options.caseSensitive ? "gm" : "gmi";
  8761. options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
  8762. if (options.$isMultiLine)
  8763. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  8764. try {
  8765. var re = new RegExp(needle, modifier);
  8766. } catch(e) {
  8767. re = false;
  8768. }
  8769. return options.re = re;
  8770. };
  8771. this.$assembleMultilineRegExp = function(needle, modifier) {
  8772. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  8773. var re = [];
  8774. for (var i = 0; i < parts.length; i++) try {
  8775. re.push(new RegExp(parts[i], modifier));
  8776. } catch(e) {
  8777. return false;
  8778. }
  8779. if (parts[0] == "") {
  8780. re.shift();
  8781. re.offset = 1;
  8782. } else {
  8783. re.offset = 0;
  8784. }
  8785. return re;
  8786. };
  8787. this.$lineIterator = function(session, options) {
  8788. var backwards = options.backwards == true;
  8789. var skipCurrent = options.skipCurrent != false;
  8790. var range = options.range;
  8791. var start = options.start;
  8792. if (!start)
  8793. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  8794. if (start.start)
  8795. start = start[skipCurrent != backwards ? "end" : "start"];
  8796. var firstRow = range ? range.start.row : 0;
  8797. var lastRow = range ? range.end.row : session.getLength() - 1;
  8798. var forEach = backwards ? function(callback) {
  8799. var row = start.row;
  8800. var line = session.getLine(row).substring(0, start.column);
  8801. if (callback(line, row))
  8802. return;
  8803. for (row--; row >= firstRow; row--)
  8804. if (callback(session.getLine(row), row))
  8805. return;
  8806. if (options.wrap == false)
  8807. return;
  8808. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  8809. if (callback(session.getLine(row), row))
  8810. return;
  8811. } : function(callback) {
  8812. var row = start.row;
  8813. var line = session.getLine(row).substr(start.column);
  8814. if (callback(line, row, start.column))
  8815. return;
  8816. for (row = row+1; row <= lastRow; row++)
  8817. if (callback(session.getLine(row), row))
  8818. return;
  8819. if (options.wrap == false)
  8820. return;
  8821. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  8822. if (callback(session.getLine(row), row))
  8823. return;
  8824. };
  8825. return {forEach: forEach};
  8826. };
  8827. }).call(Search.prototype);
  8828. exports.Search = Search;
  8829. });
  8830. ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  8831. "use strict";
  8832. var keyUtil = require("../lib/keys");
  8833. var useragent = require("../lib/useragent");
  8834. var KEY_MODS = keyUtil.KEY_MODS;
  8835. function HashHandler(config, platform) {
  8836. this.platform = platform || (useragent.isMac ? "mac" : "win");
  8837. this.commands = {};
  8838. this.commandKeyBinding = {};
  8839. this.addCommands(config);
  8840. this.$singleCommand = true;
  8841. }
  8842. function MultiHashHandler(config, platform) {
  8843. HashHandler.call(this, config, platform);
  8844. this.$singleCommand = false;
  8845. }
  8846. MultiHashHandler.prototype = HashHandler.prototype;
  8847. (function() {
  8848. this.addCommand = function(command) {
  8849. if (this.commands[command.name])
  8850. this.removeCommand(command);
  8851. this.commands[command.name] = command;
  8852. if (command.bindKey)
  8853. this._buildKeyHash(command);
  8854. };
  8855. this.removeCommand = function(command, keepCommand) {
  8856. var name = command && (typeof command === 'string' ? command : command.name);
  8857. command = this.commands[name];
  8858. if (!keepCommand)
  8859. delete this.commands[name];
  8860. var ckb = this.commandKeyBinding;
  8861. for (var keyId in ckb) {
  8862. var cmdGroup = ckb[keyId];
  8863. if (cmdGroup == command) {
  8864. delete ckb[keyId];
  8865. } else if (Array.isArray(cmdGroup)) {
  8866. var i = cmdGroup.indexOf(command);
  8867. if (i != -1) {
  8868. cmdGroup.splice(i, 1);
  8869. if (cmdGroup.length == 1)
  8870. ckb[keyId] = cmdGroup[0];
  8871. }
  8872. }
  8873. }
  8874. };
  8875. this.bindKey = function(key, command, asDefault) {
  8876. if (typeof key == "object")
  8877. key = key[this.platform];
  8878. if (!key)
  8879. return;
  8880. if (typeof command == "function")
  8881. return this.addCommand({exec: command, bindKey: key, name: command.name || key});
  8882. key.split("|").forEach(function(keyPart) {
  8883. var chain = "";
  8884. if (keyPart.indexOf(" ") != -1) {
  8885. var parts = keyPart.split(/\s+/);
  8886. keyPart = parts.pop();
  8887. parts.forEach(function(keyPart) {
  8888. var binding = this.parseKeys(keyPart);
  8889. var id = KEY_MODS[binding.hashId] + binding.key;
  8890. chain += (chain ? " " : "") + id;
  8891. this._addCommandToBinding(chain, "chainKeys");
  8892. }, this);
  8893. chain += " ";
  8894. }
  8895. var binding = this.parseKeys(keyPart);
  8896. var id = KEY_MODS[binding.hashId] + binding.key;
  8897. this._addCommandToBinding(chain + id, command, asDefault);
  8898. }, this);
  8899. };
  8900. this._addCommandToBinding = function(keyId, command, asDefault) {
  8901. var ckb = this.commandKeyBinding, i;
  8902. if (!command) {
  8903. delete ckb[keyId];
  8904. } else if (!ckb[keyId] || this.$singleCommand) {
  8905. ckb[keyId] = command;
  8906. } else {
  8907. if (!Array.isArray(ckb[keyId])) {
  8908. ckb[keyId] = [ckb[keyId]];
  8909. } else if ((i = ckb[keyId].indexOf(command)) != -1) {
  8910. ckb[keyId].splice(i, 1);
  8911. }
  8912. if (asDefault || command.isDefault)
  8913. ckb[keyId].unshift(command);
  8914. else
  8915. ckb[keyId].push(command);
  8916. }
  8917. };
  8918. this.addCommands = function(commands) {
  8919. commands && Object.keys(commands).forEach(function(name) {
  8920. var command = commands[name];
  8921. if (!command)
  8922. return;
  8923. if (typeof command === "string")
  8924. return this.bindKey(command, name);
  8925. if (typeof command === "function")
  8926. command = { exec: command };
  8927. if (typeof command !== "object")
  8928. return;
  8929. if (!command.name)
  8930. command.name = name;
  8931. this.addCommand(command);
  8932. }, this);
  8933. };
  8934. this.removeCommands = function(commands) {
  8935. Object.keys(commands).forEach(function(name) {
  8936. this.removeCommand(commands[name]);
  8937. }, this);
  8938. };
  8939. this.bindKeys = function(keyList) {
  8940. Object.keys(keyList).forEach(function(key) {
  8941. this.bindKey(key, keyList[key]);
  8942. }, this);
  8943. };
  8944. this._buildKeyHash = function(command) {
  8945. this.bindKey(command.bindKey, command);
  8946. };
  8947. this.parseKeys = function(keys) {
  8948. var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
  8949. var key = parts.pop();
  8950. var keyCode = keyUtil[key];
  8951. if (keyUtil.FUNCTION_KEYS[keyCode])
  8952. key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
  8953. else if (!parts.length)
  8954. return {key: key, hashId: -1};
  8955. else if (parts.length == 1 && parts[0] == "shift")
  8956. return {key: key.toUpperCase(), hashId: -1};
  8957. var hashId = 0;
  8958. for (var i = parts.length; i--;) {
  8959. var modifier = keyUtil.KEY_MODS[parts[i]];
  8960. if (modifier == null) {
  8961. if (typeof console != "undefined")
  8962. console.error("invalid modifier " + parts[i] + " in " + keys);
  8963. return false;
  8964. }
  8965. hashId |= modifier;
  8966. }
  8967. return {key: key, hashId: hashId};
  8968. };
  8969. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  8970. var key = KEY_MODS[hashId] + keyString;
  8971. return this.commandKeyBinding[key];
  8972. };
  8973. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  8974. var key = KEY_MODS[hashId] + keyString;
  8975. var command = this.commandKeyBinding[key];
  8976. if (data.$keyChain) {
  8977. data.$keyChain += " " + key;
  8978. command = this.commandKeyBinding[data.$keyChain] || command;
  8979. }
  8980. if (command) {
  8981. if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
  8982. data.$keyChain = data.$keyChain || key;
  8983. return {command: "null"};
  8984. }
  8985. }
  8986. if (data.$keyChain && keyCode > 0)
  8987. data.$keyChain = "";
  8988. return {command: command};
  8989. };
  8990. }).call(HashHandler.prototype);
  8991. exports.HashHandler = HashHandler;
  8992. exports.MultiHashHandler = MultiHashHandler;
  8993. });
  8994. ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
  8995. "use strict";
  8996. var oop = require("../lib/oop");
  8997. var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
  8998. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  8999. var CommandManager = function(platform, commands) {
  9000. MultiHashHandler.call(this, commands, platform);
  9001. this.byName = this.commands;
  9002. this.setDefaultHandler("exec", function(e) {
  9003. return e.command.exec(e.editor, e.args || {});
  9004. });
  9005. };
  9006. oop.inherits(CommandManager, MultiHashHandler);
  9007. (function() {
  9008. oop.implement(this, EventEmitter);
  9009. this.exec = function(command, editor, args) {
  9010. if (Array.isArray(command)) {
  9011. for (var i = command.length; i--; ) {
  9012. if (this.exec(command[i], editor, args)) return true;
  9013. }
  9014. return false;
  9015. }
  9016. if (typeof command === "string")
  9017. command = this.commands[command];
  9018. if (!command)
  9019. return false;
  9020. if (editor && editor.$readOnly && !command.readOnly)
  9021. return false;
  9022. var e = {editor: editor, command: command, args: args};
  9023. e.returnValue = this._emit("exec", e);
  9024. this._signal("afterExec", e);
  9025. return e.returnValue === false ? false : true;
  9026. };
  9027. this.toggleRecording = function(editor) {
  9028. if (this.$inReplay)
  9029. return;
  9030. editor && editor._emit("changeStatus");
  9031. if (this.recording) {
  9032. this.macro.pop();
  9033. this.removeEventListener("exec", this.$addCommandToMacro);
  9034. if (!this.macro.length)
  9035. this.macro = this.oldMacro;
  9036. return this.recording = false;
  9037. }
  9038. if (!this.$addCommandToMacro) {
  9039. this.$addCommandToMacro = function(e) {
  9040. this.macro.push([e.command, e.args]);
  9041. }.bind(this);
  9042. }
  9043. this.oldMacro = this.macro;
  9044. this.macro = [];
  9045. this.on("exec", this.$addCommandToMacro);
  9046. return this.recording = true;
  9047. };
  9048. this.replay = function(editor) {
  9049. if (this.$inReplay || !this.macro)
  9050. return;
  9051. if (this.recording)
  9052. return this.toggleRecording(editor);
  9053. try {
  9054. this.$inReplay = true;
  9055. this.macro.forEach(function(x) {
  9056. if (typeof x == "string")
  9057. this.exec(x, editor);
  9058. else
  9059. this.exec(x[0], editor, x[1]);
  9060. }, this);
  9061. } finally {
  9062. this.$inReplay = false;
  9063. }
  9064. };
  9065. this.trimMacro = function(m) {
  9066. return m.map(function(x){
  9067. if (typeof x[0] != "string")
  9068. x[0] = x[0].name;
  9069. if (!x[1])
  9070. x = x[0];
  9071. return x;
  9072. });
  9073. };
  9074. }).call(CommandManager.prototype);
  9075. exports.CommandManager = CommandManager;
  9076. });
  9077. ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
  9078. "use strict";
  9079. var lang = require("../lib/lang");
  9080. var config = require("../config");
  9081. var Range = require("../range").Range;
  9082. function bindKey(win, mac) {
  9083. return {win: win, mac: mac};
  9084. }
  9085. exports.commands = [{
  9086. name: "showSettingsMenu",
  9087. bindKey: bindKey("Ctrl-,", "Command-,"),
  9088. exec: function(editor) {
  9089. config.loadModule("ace/ext/settings_menu", function(module) {
  9090. module.init(editor);
  9091. editor.showSettingsMenu();
  9092. });
  9093. },
  9094. readOnly: true
  9095. }, {
  9096. name: "goToNextError",
  9097. bindKey: bindKey("Alt-E", "Ctrl-E"),
  9098. exec: function(editor) {
  9099. config.loadModule("ace/ext/error_marker", function(module) {
  9100. module.showErrorMarker(editor, 1);
  9101. });
  9102. },
  9103. scrollIntoView: "animate",
  9104. readOnly: true
  9105. }, {
  9106. name: "goToPreviousError",
  9107. bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
  9108. exec: function(editor) {
  9109. config.loadModule("ace/ext/error_marker", function(module) {
  9110. module.showErrorMarker(editor, -1);
  9111. });
  9112. },
  9113. scrollIntoView: "animate",
  9114. readOnly: true
  9115. }, {
  9116. name: "selectall",
  9117. bindKey: bindKey("Ctrl-A", "Command-A"),
  9118. exec: function(editor) { editor.selectAll(); },
  9119. readOnly: true
  9120. }, {
  9121. name: "centerselection",
  9122. bindKey: bindKey(null, "Ctrl-L"),
  9123. exec: function(editor) { editor.centerSelection(); },
  9124. readOnly: true
  9125. }, {
  9126. name: "gotoline",
  9127. bindKey: bindKey("Ctrl-L", "Command-L"),
  9128. exec: function(editor) {
  9129. var line = parseInt(prompt("Enter line number:"), 10);
  9130. if (!isNaN(line)) {
  9131. editor.gotoLine(line);
  9132. }
  9133. },
  9134. readOnly: true
  9135. }, {
  9136. name: "fold",
  9137. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  9138. exec: function(editor) { editor.session.toggleFold(false); },
  9139. scrollIntoView: "center",
  9140. readOnly: true
  9141. }, {
  9142. name: "unfold",
  9143. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  9144. exec: function(editor) { editor.session.toggleFold(true); },
  9145. scrollIntoView: "center",
  9146. readOnly: true
  9147. }, {
  9148. name: "toggleFoldWidget",
  9149. bindKey: bindKey("F2", "F2"),
  9150. exec: function(editor) { editor.session.toggleFoldWidget(); },
  9151. scrollIntoView: "center",
  9152. readOnly: true
  9153. }, {
  9154. name: "toggleParentFoldWidget",
  9155. bindKey: bindKey("Alt-F2", "Alt-F2"),
  9156. exec: function(editor) { editor.session.toggleFoldWidget(true); },
  9157. scrollIntoView: "center",
  9158. readOnly: true
  9159. }, {
  9160. name: "foldall",
  9161. bindKey: bindKey("Ctrl-Alt-0", "Ctrl-Command-Option-0"),
  9162. exec: function(editor) { editor.session.foldAll(); },
  9163. scrollIntoView: "center",
  9164. readOnly: true
  9165. }, {
  9166. name: "foldOther",
  9167. bindKey: bindKey("Alt-0", "Command-Option-0"),
  9168. exec: function(editor) {
  9169. editor.session.foldAll();
  9170. editor.session.unfold(editor.selection.getAllRanges());
  9171. },
  9172. scrollIntoView: "center",
  9173. readOnly: true
  9174. }, {
  9175. name: "unfoldall",
  9176. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  9177. exec: function(editor) { editor.session.unfold(); },
  9178. scrollIntoView: "center",
  9179. readOnly: true
  9180. }, {
  9181. name: "findnext",
  9182. bindKey: bindKey("Ctrl-K", "Command-G"),
  9183. exec: function(editor) { editor.findNext(); },
  9184. multiSelectAction: "forEach",
  9185. scrollIntoView: "center",
  9186. readOnly: true
  9187. }, {
  9188. name: "findprevious",
  9189. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  9190. exec: function(editor) { editor.findPrevious(); },
  9191. multiSelectAction: "forEach",
  9192. scrollIntoView: "center",
  9193. readOnly: true
  9194. }, {
  9195. name: "selectOrFindNext",
  9196. bindKey: bindKey("Alt-K", "Ctrl-G"),
  9197. exec: function(editor) {
  9198. if (editor.selection.isEmpty())
  9199. editor.selection.selectWord();
  9200. else
  9201. editor.findNext();
  9202. },
  9203. readOnly: true
  9204. }, {
  9205. name: "selectOrFindPrevious",
  9206. bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
  9207. exec: function(editor) {
  9208. if (editor.selection.isEmpty())
  9209. editor.selection.selectWord();
  9210. else
  9211. editor.findPrevious();
  9212. },
  9213. readOnly: true
  9214. }, {
  9215. name: "find",
  9216. bindKey: bindKey("Ctrl-F", "Command-F"),
  9217. exec: function(editor) {
  9218. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
  9219. },
  9220. readOnly: true
  9221. }, {
  9222. name: "overwrite",
  9223. bindKey: "Insert",
  9224. exec: function(editor) { editor.toggleOverwrite(); },
  9225. readOnly: true
  9226. }, {
  9227. name: "selecttostart",
  9228. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
  9229. exec: function(editor) { editor.getSelection().selectFileStart(); },
  9230. multiSelectAction: "forEach",
  9231. readOnly: true,
  9232. scrollIntoView: "animate",
  9233. aceCommandGroup: "fileJump"
  9234. }, {
  9235. name: "gotostart",
  9236. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  9237. exec: function(editor) { editor.navigateFileStart(); },
  9238. multiSelectAction: "forEach",
  9239. readOnly: true,
  9240. scrollIntoView: "animate",
  9241. aceCommandGroup: "fileJump"
  9242. }, {
  9243. name: "selectup",
  9244. bindKey: bindKey("Shift-Up", "Shift-Up"),
  9245. exec: function(editor) { editor.getSelection().selectUp(); },
  9246. multiSelectAction: "forEach",
  9247. scrollIntoView: "cursor",
  9248. readOnly: true
  9249. }, {
  9250. name: "golineup",
  9251. bindKey: bindKey("Up", "Up|Ctrl-P"),
  9252. exec: function(editor, args) { editor.navigateUp(args.times); },
  9253. multiSelectAction: "forEach",
  9254. scrollIntoView: "cursor",
  9255. readOnly: true
  9256. }, {
  9257. name: "selecttoend",
  9258. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
  9259. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  9260. multiSelectAction: "forEach",
  9261. readOnly: true,
  9262. scrollIntoView: "animate",
  9263. aceCommandGroup: "fileJump"
  9264. }, {
  9265. name: "gotoend",
  9266. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  9267. exec: function(editor) { editor.navigateFileEnd(); },
  9268. multiSelectAction: "forEach",
  9269. readOnly: true,
  9270. scrollIntoView: "animate",
  9271. aceCommandGroup: "fileJump"
  9272. }, {
  9273. name: "selectdown",
  9274. bindKey: bindKey("Shift-Down", "Shift-Down"),
  9275. exec: function(editor) { editor.getSelection().selectDown(); },
  9276. multiSelectAction: "forEach",
  9277. scrollIntoView: "cursor",
  9278. readOnly: true
  9279. }, {
  9280. name: "golinedown",
  9281. bindKey: bindKey("Down", "Down|Ctrl-N"),
  9282. exec: function(editor, args) { editor.navigateDown(args.times); },
  9283. multiSelectAction: "forEach",
  9284. scrollIntoView: "cursor",
  9285. readOnly: true
  9286. }, {
  9287. name: "selectwordleft",
  9288. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  9289. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  9290. multiSelectAction: "forEach",
  9291. scrollIntoView: "cursor",
  9292. readOnly: true
  9293. }, {
  9294. name: "gotowordleft",
  9295. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  9296. exec: function(editor) { editor.navigateWordLeft(); },
  9297. multiSelectAction: "forEach",
  9298. scrollIntoView: "cursor",
  9299. readOnly: true
  9300. }, {
  9301. name: "selecttolinestart",
  9302. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
  9303. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9304. multiSelectAction: "forEach",
  9305. scrollIntoView: "cursor",
  9306. readOnly: true
  9307. }, {
  9308. name: "gotolinestart",
  9309. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  9310. exec: function(editor) { editor.navigateLineStart(); },
  9311. multiSelectAction: "forEach",
  9312. scrollIntoView: "cursor",
  9313. readOnly: true
  9314. }, {
  9315. name: "selectleft",
  9316. bindKey: bindKey("Shift-Left", "Shift-Left"),
  9317. exec: function(editor) { editor.getSelection().selectLeft(); },
  9318. multiSelectAction: "forEach",
  9319. scrollIntoView: "cursor",
  9320. readOnly: true
  9321. }, {
  9322. name: "gotoleft",
  9323. bindKey: bindKey("Left", "Left|Ctrl-B"),
  9324. exec: function(editor, args) { editor.navigateLeft(args.times); },
  9325. multiSelectAction: "forEach",
  9326. scrollIntoView: "cursor",
  9327. readOnly: true
  9328. }, {
  9329. name: "selectwordright",
  9330. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  9331. exec: function(editor) { editor.getSelection().selectWordRight(); },
  9332. multiSelectAction: "forEach",
  9333. scrollIntoView: "cursor",
  9334. readOnly: true
  9335. }, {
  9336. name: "gotowordright",
  9337. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  9338. exec: function(editor) { editor.navigateWordRight(); },
  9339. multiSelectAction: "forEach",
  9340. scrollIntoView: "cursor",
  9341. readOnly: true
  9342. }, {
  9343. name: "selecttolineend",
  9344. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
  9345. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9346. multiSelectAction: "forEach",
  9347. scrollIntoView: "cursor",
  9348. readOnly: true
  9349. }, {
  9350. name: "gotolineend",
  9351. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  9352. exec: function(editor) { editor.navigateLineEnd(); },
  9353. multiSelectAction: "forEach",
  9354. scrollIntoView: "cursor",
  9355. readOnly: true
  9356. }, {
  9357. name: "selectright",
  9358. bindKey: bindKey("Shift-Right", "Shift-Right"),
  9359. exec: function(editor) { editor.getSelection().selectRight(); },
  9360. multiSelectAction: "forEach",
  9361. scrollIntoView: "cursor",
  9362. readOnly: true
  9363. }, {
  9364. name: "gotoright",
  9365. bindKey: bindKey("Right", "Right|Ctrl-F"),
  9366. exec: function(editor, args) { editor.navigateRight(args.times); },
  9367. multiSelectAction: "forEach",
  9368. scrollIntoView: "cursor",
  9369. readOnly: true
  9370. }, {
  9371. name: "selectpagedown",
  9372. bindKey: "Shift-PageDown",
  9373. exec: function(editor) { editor.selectPageDown(); },
  9374. readOnly: true
  9375. }, {
  9376. name: "pagedown",
  9377. bindKey: bindKey(null, "Option-PageDown"),
  9378. exec: function(editor) { editor.scrollPageDown(); },
  9379. readOnly: true
  9380. }, {
  9381. name: "gotopagedown",
  9382. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  9383. exec: function(editor) { editor.gotoPageDown(); },
  9384. readOnly: true
  9385. }, {
  9386. name: "selectpageup",
  9387. bindKey: "Shift-PageUp",
  9388. exec: function(editor) { editor.selectPageUp(); },
  9389. readOnly: true
  9390. }, {
  9391. name: "pageup",
  9392. bindKey: bindKey(null, "Option-PageUp"),
  9393. exec: function(editor) { editor.scrollPageUp(); },
  9394. readOnly: true
  9395. }, {
  9396. name: "gotopageup",
  9397. bindKey: "PageUp",
  9398. exec: function(editor) { editor.gotoPageUp(); },
  9399. readOnly: true
  9400. }, {
  9401. name: "scrollup",
  9402. bindKey: bindKey("Ctrl-Up", null),
  9403. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  9404. readOnly: true
  9405. }, {
  9406. name: "scrolldown",
  9407. bindKey: bindKey("Ctrl-Down", null),
  9408. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  9409. readOnly: true
  9410. }, {
  9411. name: "selectlinestart",
  9412. bindKey: "Shift-Home",
  9413. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9414. multiSelectAction: "forEach",
  9415. scrollIntoView: "cursor",
  9416. readOnly: true
  9417. }, {
  9418. name: "selectlineend",
  9419. bindKey: "Shift-End",
  9420. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9421. multiSelectAction: "forEach",
  9422. scrollIntoView: "cursor",
  9423. readOnly: true
  9424. }, {
  9425. name: "togglerecording",
  9426. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  9427. exec: function(editor) { editor.commands.toggleRecording(editor); },
  9428. readOnly: true
  9429. }, {
  9430. name: "replaymacro",
  9431. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  9432. exec: function(editor) { editor.commands.replay(editor); },
  9433. readOnly: true
  9434. }, {
  9435. name: "jumptomatching",
  9436. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  9437. exec: function(editor) { editor.jumpToMatching(); },
  9438. multiSelectAction: "forEach",
  9439. scrollIntoView: "animate",
  9440. readOnly: true
  9441. }, {
  9442. name: "selecttomatching",
  9443. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  9444. exec: function(editor) { editor.jumpToMatching(true); },
  9445. multiSelectAction: "forEach",
  9446. scrollIntoView: "animate",
  9447. readOnly: true
  9448. }, {
  9449. name: "expandToMatching",
  9450. bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
  9451. exec: function(editor) { editor.jumpToMatching(true, true); },
  9452. multiSelectAction: "forEach",
  9453. scrollIntoView: "animate",
  9454. readOnly: true
  9455. }, {
  9456. name: "passKeysToBrowser",
  9457. bindKey: bindKey("null", "null"),
  9458. exec: function() {},
  9459. passEvent: true,
  9460. readOnly: true
  9461. },
  9462. {
  9463. name: "cut",
  9464. exec: function(editor) {
  9465. var range = editor.getSelectionRange();
  9466. editor._emit("cut", range);
  9467. if (!editor.selection.isEmpty()) {
  9468. editor.session.remove(range);
  9469. editor.clearSelection();
  9470. }
  9471. },
  9472. scrollIntoView: "cursor",
  9473. multiSelectAction: "forEach"
  9474. }, {
  9475. name: "removeline",
  9476. bindKey: bindKey("Ctrl-D", "Command-D"),
  9477. exec: function(editor) { editor.removeLines(); },
  9478. scrollIntoView: "cursor",
  9479. multiSelectAction: "forEachLine"
  9480. }, {
  9481. name: "duplicateSelection",
  9482. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  9483. exec: function(editor) { editor.duplicateSelection(); },
  9484. scrollIntoView: "cursor",
  9485. multiSelectAction: "forEach"
  9486. }, {
  9487. name: "sortlines",
  9488. bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
  9489. exec: function(editor) { editor.sortLines(); },
  9490. scrollIntoView: "selection",
  9491. multiSelectAction: "forEachLine"
  9492. }, {
  9493. name: "togglecomment",
  9494. bindKey: bindKey("Ctrl-/", "Command-/"),
  9495. exec: function(editor) { editor.toggleCommentLines(); },
  9496. multiSelectAction: "forEachLine",
  9497. scrollIntoView: "selectionPart"
  9498. }, {
  9499. name: "toggleBlockComment",
  9500. bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
  9501. exec: function(editor) { editor.toggleBlockComment(); },
  9502. multiSelectAction: "forEach",
  9503. scrollIntoView: "selectionPart"
  9504. }, {
  9505. name: "modifyNumberUp",
  9506. bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
  9507. exec: function(editor) { editor.modifyNumber(1); },
  9508. scrollIntoView: "cursor",
  9509. multiSelectAction: "forEach"
  9510. }, {
  9511. name: "modifyNumberDown",
  9512. bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
  9513. exec: function(editor) { editor.modifyNumber(-1); },
  9514. scrollIntoView: "cursor",
  9515. multiSelectAction: "forEach"
  9516. }, {
  9517. name: "replace",
  9518. bindKey: bindKey("Ctrl-H", "Command-Option-F"),
  9519. exec: function(editor) {
  9520. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
  9521. }
  9522. }, {
  9523. name: "undo",
  9524. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  9525. exec: function(editor) { editor.undo(); }
  9526. }, {
  9527. name: "redo",
  9528. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  9529. exec: function(editor) { editor.redo(); }
  9530. }, {
  9531. name: "copylinesup",
  9532. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  9533. exec: function(editor) { editor.copyLinesUp(); },
  9534. scrollIntoView: "cursor"
  9535. }, {
  9536. name: "movelinesup",
  9537. bindKey: bindKey("Alt-Up", "Option-Up"),
  9538. exec: function(editor) { editor.moveLinesUp(); },
  9539. scrollIntoView: "cursor"
  9540. }, {
  9541. name: "copylinesdown",
  9542. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  9543. exec: function(editor) { editor.copyLinesDown(); },
  9544. scrollIntoView: "cursor"
  9545. }, {
  9546. name: "movelinesdown",
  9547. bindKey: bindKey("Alt-Down", "Option-Down"),
  9548. exec: function(editor) { editor.moveLinesDown(); },
  9549. scrollIntoView: "cursor"
  9550. }, {
  9551. name: "del",
  9552. bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
  9553. exec: function(editor) { editor.remove("right"); },
  9554. multiSelectAction: "forEach",
  9555. scrollIntoView: "cursor"
  9556. }, {
  9557. name: "backspace",
  9558. bindKey: bindKey(
  9559. "Shift-Backspace|Backspace",
  9560. "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  9561. ),
  9562. exec: function(editor) { editor.remove("left"); },
  9563. multiSelectAction: "forEach",
  9564. scrollIntoView: "cursor"
  9565. }, {
  9566. name: "cut_or_delete",
  9567. bindKey: bindKey("Shift-Delete", null),
  9568. exec: function(editor) {
  9569. if (editor.selection.isEmpty()) {
  9570. editor.remove("left");
  9571. } else {
  9572. return false;
  9573. }
  9574. },
  9575. multiSelectAction: "forEach",
  9576. scrollIntoView: "cursor"
  9577. }, {
  9578. name: "removetolinestart",
  9579. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  9580. exec: function(editor) { editor.removeToLineStart(); },
  9581. multiSelectAction: "forEach",
  9582. scrollIntoView: "cursor"
  9583. }, {
  9584. name: "removetolineend",
  9585. bindKey: bindKey("Alt-Delete", "Ctrl-K"),
  9586. exec: function(editor) { editor.removeToLineEnd(); },
  9587. multiSelectAction: "forEach",
  9588. scrollIntoView: "cursor"
  9589. }, {
  9590. name: "removewordleft",
  9591. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  9592. exec: function(editor) { editor.removeWordLeft(); },
  9593. multiSelectAction: "forEach",
  9594. scrollIntoView: "cursor"
  9595. }, {
  9596. name: "removewordright",
  9597. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  9598. exec: function(editor) { editor.removeWordRight(); },
  9599. multiSelectAction: "forEach",
  9600. scrollIntoView: "cursor"
  9601. }, {
  9602. name: "outdent",
  9603. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  9604. exec: function(editor) { editor.blockOutdent(); },
  9605. multiSelectAction: "forEach",
  9606. scrollIntoView: "selectionPart"
  9607. }, {
  9608. name: "indent",
  9609. bindKey: bindKey("Tab", "Tab"),
  9610. exec: function(editor) { editor.indent(); },
  9611. multiSelectAction: "forEach",
  9612. scrollIntoView: "selectionPart"
  9613. }, {
  9614. name: "blockoutdent",
  9615. bindKey: bindKey("Ctrl-[", "Ctrl-["),
  9616. exec: function(editor) { editor.blockOutdent(); },
  9617. multiSelectAction: "forEachLine",
  9618. scrollIntoView: "selectionPart"
  9619. }, {
  9620. name: "blockindent",
  9621. bindKey: bindKey("Ctrl-]", "Ctrl-]"),
  9622. exec: function(editor) { editor.blockIndent(); },
  9623. multiSelectAction: "forEachLine",
  9624. scrollIntoView: "selectionPart"
  9625. }, {
  9626. name: "insertstring",
  9627. exec: function(editor, str) { editor.insert(str); },
  9628. multiSelectAction: "forEach",
  9629. scrollIntoView: "cursor"
  9630. }, {
  9631. name: "inserttext",
  9632. exec: function(editor, args) {
  9633. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  9634. },
  9635. multiSelectAction: "forEach",
  9636. scrollIntoView: "cursor"
  9637. }, {
  9638. name: "splitline",
  9639. bindKey: bindKey(null, "Ctrl-O"),
  9640. exec: function(editor) { editor.splitLine(); },
  9641. multiSelectAction: "forEach",
  9642. scrollIntoView: "cursor"
  9643. }, {
  9644. name: "transposeletters",
  9645. bindKey: bindKey("Ctrl-T", "Ctrl-T"),
  9646. exec: function(editor) { editor.transposeLetters(); },
  9647. multiSelectAction: function(editor) {editor.transposeSelections(1); },
  9648. scrollIntoView: "cursor"
  9649. }, {
  9650. name: "touppercase",
  9651. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  9652. exec: function(editor) { editor.toUpperCase(); },
  9653. multiSelectAction: "forEach",
  9654. scrollIntoView: "cursor"
  9655. }, {
  9656. name: "tolowercase",
  9657. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  9658. exec: function(editor) { editor.toLowerCase(); },
  9659. multiSelectAction: "forEach",
  9660. scrollIntoView: "cursor"
  9661. }, {
  9662. name: "expandtoline",
  9663. bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
  9664. exec: function(editor) {
  9665. var range = editor.selection.getRange();
  9666. range.start.column = range.end.column = 0;
  9667. range.end.row++;
  9668. editor.selection.setRange(range, false);
  9669. },
  9670. multiSelectAction: "forEach",
  9671. scrollIntoView: "cursor",
  9672. readOnly: true
  9673. }, {
  9674. name: "joinlines",
  9675. bindKey: bindKey(null, null),
  9676. exec: function(editor) {
  9677. var isBackwards = editor.selection.isBackwards();
  9678. var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
  9679. var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
  9680. var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
  9681. var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
  9682. var selectedCount = selectedText.replace(/\n\s*/, " ").length;
  9683. var insertLine = editor.session.doc.getLine(selectionStart.row);
  9684. for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
  9685. var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
  9686. if (curLine.length !== 0) {
  9687. curLine = " " + curLine;
  9688. }
  9689. insertLine += curLine;
  9690. }
  9691. if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
  9692. insertLine += editor.session.doc.getNewLineCharacter();
  9693. }
  9694. editor.clearSelection();
  9695. editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
  9696. if (selectedCount > 0) {
  9697. editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
  9698. editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
  9699. } else {
  9700. firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
  9701. editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
  9702. }
  9703. },
  9704. multiSelectAction: "forEach",
  9705. readOnly: true
  9706. }, {
  9707. name: "invertSelection",
  9708. bindKey: bindKey(null, null),
  9709. exec: function(editor) {
  9710. var endRow = editor.session.doc.getLength() - 1;
  9711. var endCol = editor.session.doc.getLine(endRow).length;
  9712. var ranges = editor.selection.rangeList.ranges;
  9713. var newRanges = [];
  9714. if (ranges.length < 1) {
  9715. ranges = [editor.selection.getRange()];
  9716. }
  9717. for (var i = 0; i < ranges.length; i++) {
  9718. if (i == (ranges.length - 1)) {
  9719. if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
  9720. newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
  9721. }
  9722. }
  9723. if (i === 0) {
  9724. if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
  9725. newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
  9726. }
  9727. } else {
  9728. newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
  9729. }
  9730. }
  9731. editor.exitMultiSelectMode();
  9732. editor.clearSelection();
  9733. for(var i = 0; i < newRanges.length; i++) {
  9734. editor.selection.addRange(newRanges[i], false);
  9735. }
  9736. },
  9737. readOnly: true,
  9738. scrollIntoView: "none"
  9739. }];
  9740. });
  9741. ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator"], function(require, exports, module) {
  9742. "use strict";
  9743. require("./lib/fixoldbrowsers");
  9744. var oop = require("./lib/oop");
  9745. var dom = require("./lib/dom");
  9746. var lang = require("./lib/lang");
  9747. var useragent = require("./lib/useragent");
  9748. var TextInput = require("./keyboard/textinput").TextInput;
  9749. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  9750. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  9751. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  9752. var EditSession = require("./edit_session").EditSession;
  9753. var Search = require("./search").Search;
  9754. var Range = require("./range").Range;
  9755. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  9756. var CommandManager = require("./commands/command_manager").CommandManager;
  9757. var defaultCommands = require("./commands/default_commands").commands;
  9758. var config = require("./config");
  9759. var TokenIterator = require("./token_iterator").TokenIterator;
  9760. var Editor = function(renderer, session) {
  9761. var container = renderer.getContainerElement();
  9762. this.container = container;
  9763. this.renderer = renderer;
  9764. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  9765. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  9766. this.renderer.textarea = this.textInput.getElement();
  9767. this.keyBinding = new KeyBinding(this);
  9768. this.$mouseHandler = new MouseHandler(this);
  9769. new FoldHandler(this);
  9770. this.$blockScrolling = 0;
  9771. this.$search = new Search().set({
  9772. wrap: true
  9773. });
  9774. this.$historyTracker = this.$historyTracker.bind(this);
  9775. this.commands.on("exec", this.$historyTracker);
  9776. this.$initOperationListeners();
  9777. this._$emitInputEvent = lang.delayedCall(function() {
  9778. this._signal("input", {});
  9779. if (this.session && this.session.bgTokenizer)
  9780. this.session.bgTokenizer.scheduleStart();
  9781. }.bind(this));
  9782. this.on("change", function(_, _self) {
  9783. _self._$emitInputEvent.schedule(31);
  9784. });
  9785. this.setSession(session || new EditSession(""));
  9786. config.resetOptions(this);
  9787. config._signal("editor", this);
  9788. };
  9789. (function(){
  9790. oop.implement(this, EventEmitter);
  9791. this.$initOperationListeners = function() {
  9792. function last(a) {return a[a.length - 1]}
  9793. this.selections = [];
  9794. this.commands.on("exec", this.startOperation.bind(this), true);
  9795. this.commands.on("afterExec", this.endOperation.bind(this), true);
  9796. this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
  9797. this.on("change", function() {
  9798. this.curOp || this.startOperation();
  9799. this.curOp.docChanged = true;
  9800. }.bind(this), true);
  9801. this.on("changeSelection", function() {
  9802. this.curOp || this.startOperation();
  9803. this.curOp.selectionChanged = true;
  9804. }.bind(this), true);
  9805. };
  9806. this.curOp = null;
  9807. this.prevOp = {};
  9808. this.startOperation = function(commadEvent) {
  9809. if (this.curOp) {
  9810. if (!commadEvent || this.curOp.command)
  9811. return;
  9812. this.prevOp = this.curOp;
  9813. }
  9814. if (!commadEvent) {
  9815. this.previousCommand = null;
  9816. commadEvent = {};
  9817. }
  9818. this.$opResetTimer.schedule();
  9819. this.curOp = {
  9820. command: commadEvent.command || {},
  9821. args: commadEvent.args,
  9822. scrollTop: this.renderer.scrollTop
  9823. };
  9824. if (this.curOp.command.name)
  9825. this.$blockScrolling++;
  9826. };
  9827. this.endOperation = function(e) {
  9828. if (this.curOp) {
  9829. if (e && e.returnValue === false)
  9830. return this.curOp = null;
  9831. this._signal("beforeEndOperation");
  9832. var command = this.curOp.command;
  9833. if (command.name && this.$blockScrolling)
  9834. this.$blockScrolling--;
  9835. if (command && command.scrollIntoView) {
  9836. switch (command.scrollIntoView) {
  9837. case "center":
  9838. this.renderer.scrollCursorIntoView(null, 0.5);
  9839. break;
  9840. case "animate":
  9841. case "cursor":
  9842. this.renderer.scrollCursorIntoView();
  9843. break;
  9844. case "selectionPart":
  9845. var range = this.selection.getRange();
  9846. var config = this.renderer.layerConfig;
  9847. if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
  9848. this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
  9849. }
  9850. break;
  9851. default:
  9852. break;
  9853. }
  9854. if (command.scrollIntoView == "animate")
  9855. this.renderer.animateScrolling(this.curOp.scrollTop);
  9856. }
  9857. this.prevOp = this.curOp;
  9858. this.curOp = null;
  9859. }
  9860. };
  9861. this.$mergeableCommands = ["backspace", "del", "insertstring"];
  9862. this.$historyTracker = function(e) {
  9863. if (!this.$mergeUndoDeltas)
  9864. return;
  9865. var prev = this.prevOp;
  9866. var mergeableCommands = this.$mergeableCommands;
  9867. var shouldMerge = prev.command && (e.command.name == prev.command.name);
  9868. if (e.command.name == "insertstring") {
  9869. var text = e.args;
  9870. if (this.mergeNextCommand === undefined)
  9871. this.mergeNextCommand = true;
  9872. shouldMerge = shouldMerge
  9873. && this.mergeNextCommand // previous command allows to coalesce with
  9874. && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
  9875. this.mergeNextCommand = true;
  9876. } else {
  9877. shouldMerge = shouldMerge
  9878. && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
  9879. }
  9880. if (
  9881. this.$mergeUndoDeltas != "always"
  9882. && Date.now() - this.sequenceStartTime > 2000
  9883. ) {
  9884. shouldMerge = false; // the sequence is too long
  9885. }
  9886. if (shouldMerge)
  9887. this.session.mergeUndoDeltas = true;
  9888. else if (mergeableCommands.indexOf(e.command.name) !== -1)
  9889. this.sequenceStartTime = Date.now();
  9890. };
  9891. this.setKeyboardHandler = function(keyboardHandler, cb) {
  9892. if (keyboardHandler && typeof keyboardHandler === "string") {
  9893. this.$keybindingId = keyboardHandler;
  9894. var _self = this;
  9895. config.loadModule(["keybinding", keyboardHandler], function(module) {
  9896. if (_self.$keybindingId == keyboardHandler)
  9897. _self.keyBinding.setKeyboardHandler(module && module.handler);
  9898. cb && cb();
  9899. });
  9900. } else {
  9901. this.$keybindingId = null;
  9902. this.keyBinding.setKeyboardHandler(keyboardHandler);
  9903. cb && cb();
  9904. }
  9905. };
  9906. this.getKeyboardHandler = function() {
  9907. return this.keyBinding.getKeyboardHandler();
  9908. };
  9909. this.setSession = function(session) {
  9910. if (this.session == session)
  9911. return;
  9912. var oldSession = this.session;
  9913. if (oldSession) {
  9914. this.session.removeEventListener("change", this.$onDocumentChange);
  9915. this.session.removeEventListener("changeMode", this.$onChangeMode);
  9916. this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  9917. this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
  9918. this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  9919. this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
  9920. this.session.removeEventListener("onChangeFold", this.$onChangeFold);
  9921. this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  9922. this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
  9923. this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  9924. this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
  9925. this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
  9926. this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
  9927. this.session.removeEventListener("changeScrollLeft", this.$onScrollLeftChange);
  9928. var selection = this.session.getSelection();
  9929. selection.removeEventListener("changeCursor", this.$onCursorChange);
  9930. selection.removeEventListener("changeSelection", this.$onSelectionChange);
  9931. }
  9932. this.session = session;
  9933. if (session) {
  9934. this.$onDocumentChange = this.onDocumentChange.bind(this);
  9935. session.addEventListener("change", this.$onDocumentChange);
  9936. this.renderer.setSession(session);
  9937. this.$onChangeMode = this.onChangeMode.bind(this);
  9938. session.addEventListener("changeMode", this.$onChangeMode);
  9939. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  9940. session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  9941. this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
  9942. session.addEventListener("changeTabSize", this.$onChangeTabSize);
  9943. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  9944. session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  9945. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  9946. session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
  9947. this.$onChangeFold = this.onChangeFold.bind(this);
  9948. session.addEventListener("changeFold", this.$onChangeFold);
  9949. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  9950. this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  9951. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  9952. this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
  9953. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  9954. this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  9955. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  9956. this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
  9957. this.$onCursorChange = this.onCursorChange.bind(this);
  9958. this.session.addEventListener("changeOverwrite", this.$onCursorChange);
  9959. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  9960. this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
  9961. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  9962. this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
  9963. this.selection = session.getSelection();
  9964. this.selection.addEventListener("changeCursor", this.$onCursorChange);
  9965. this.$onSelectionChange = this.onSelectionChange.bind(this);
  9966. this.selection.addEventListener("changeSelection", this.$onSelectionChange);
  9967. this.onChangeMode();
  9968. this.$blockScrolling += 1;
  9969. this.onCursorChange();
  9970. this.$blockScrolling -= 1;
  9971. this.onScrollTopChange();
  9972. this.onScrollLeftChange();
  9973. this.onSelectionChange();
  9974. this.onChangeFrontMarker();
  9975. this.onChangeBackMarker();
  9976. this.onChangeBreakpoint();
  9977. this.onChangeAnnotation();
  9978. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  9979. this.renderer.updateFull();
  9980. } else {
  9981. this.selection = null;
  9982. this.renderer.setSession(session);
  9983. }
  9984. this._signal("changeSession", {
  9985. session: session,
  9986. oldSession: oldSession
  9987. });
  9988. oldSession && oldSession._signal("changeEditor", {oldEditor: this});
  9989. session && session._signal("changeEditor", {editor: this});
  9990. };
  9991. this.getSession = function() {
  9992. return this.session;
  9993. };
  9994. this.setValue = function(val, cursorPos) {
  9995. this.session.doc.setValue(val);
  9996. if (!cursorPos)
  9997. this.selectAll();
  9998. else if (cursorPos == 1)
  9999. this.navigateFileEnd();
  10000. else if (cursorPos == -1)
  10001. this.navigateFileStart();
  10002. return val;
  10003. };
  10004. this.getValue = function() {
  10005. return this.session.getValue();
  10006. };
  10007. this.getSelection = function() {
  10008. return this.selection;
  10009. };
  10010. this.resize = function(force) {
  10011. this.renderer.onResize(force);
  10012. };
  10013. this.setTheme = function(theme, cb) {
  10014. this.renderer.setTheme(theme, cb);
  10015. };
  10016. this.getTheme = function() {
  10017. return this.renderer.getTheme();
  10018. };
  10019. this.setStyle = function(style) {
  10020. this.renderer.setStyle(style);
  10021. };
  10022. this.unsetStyle = function(style) {
  10023. this.renderer.unsetStyle(style);
  10024. };
  10025. this.getFontSize = function () {
  10026. return this.getOption("fontSize") ||
  10027. dom.computedStyle(this.container, "fontSize");
  10028. };
  10029. this.setFontSize = function(size) {
  10030. this.setOption("fontSize", size);
  10031. };
  10032. this.$highlightBrackets = function() {
  10033. if (this.session.$bracketHighlight) {
  10034. this.session.removeMarker(this.session.$bracketHighlight);
  10035. this.session.$bracketHighlight = null;
  10036. }
  10037. if (this.$highlightPending) {
  10038. return;
  10039. }
  10040. var self = this;
  10041. this.$highlightPending = true;
  10042. setTimeout(function() {
  10043. self.$highlightPending = false;
  10044. var session = self.session;
  10045. if (!session || !session.bgTokenizer) return;
  10046. var pos = session.findMatchingBracket(self.getCursorPosition());
  10047. if (pos) {
  10048. var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
  10049. } else if (session.$mode.getMatching) {
  10050. var range = session.$mode.getMatching(self.session);
  10051. }
  10052. if (range)
  10053. session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
  10054. }, 50);
  10055. };
  10056. this.$highlightTags = function() {
  10057. if (this.$highlightTagPending)
  10058. return;
  10059. var self = this;
  10060. this.$highlightTagPending = true;
  10061. setTimeout(function() {
  10062. self.$highlightTagPending = false;
  10063. var session = self.session;
  10064. if (!session || !session.bgTokenizer) return;
  10065. var pos = self.getCursorPosition();
  10066. var iterator = new TokenIterator(self.session, pos.row, pos.column);
  10067. var token = iterator.getCurrentToken();
  10068. if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
  10069. session.removeMarker(session.$tagHighlight);
  10070. session.$tagHighlight = null;
  10071. return;
  10072. }
  10073. if (token.type.indexOf("tag-open") != -1)
  10074. token = iterator.stepForward();
  10075. var tag = token.value;
  10076. var depth = 0;
  10077. var prevToken = iterator.stepBackward();
  10078. if (prevToken.value == '<'){
  10079. do {
  10080. prevToken = token;
  10081. token = iterator.stepForward();
  10082. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10083. if (prevToken.value === '<'){
  10084. depth++;
  10085. } else if (prevToken.value === '</'){
  10086. depth--;
  10087. }
  10088. }
  10089. } while (token && depth >= 0);
  10090. } else {
  10091. do {
  10092. token = prevToken;
  10093. prevToken = iterator.stepBackward();
  10094. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10095. if (prevToken.value === '<') {
  10096. depth++;
  10097. } else if (prevToken.value === '</') {
  10098. depth--;
  10099. }
  10100. }
  10101. } while (prevToken && depth <= 0);
  10102. iterator.stepForward();
  10103. }
  10104. if (!token) {
  10105. session.removeMarker(session.$tagHighlight);
  10106. session.$tagHighlight = null;
  10107. return;
  10108. }
  10109. var row = iterator.getCurrentTokenRow();
  10110. var column = iterator.getCurrentTokenColumn();
  10111. var range = new Range(row, column, row, column+token.value.length);
  10112. if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
  10113. session.removeMarker(session.$tagHighlight);
  10114. session.$tagHighlight = null;
  10115. }
  10116. if (range && !session.$tagHighlight)
  10117. session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
  10118. }, 50);
  10119. };
  10120. this.focus = function() {
  10121. var _self = this;
  10122. setTimeout(function() {
  10123. _self.textInput.focus();
  10124. });
  10125. this.textInput.focus();
  10126. };
  10127. this.isFocused = function() {
  10128. return this.textInput.isFocused();
  10129. };
  10130. this.blur = function() {
  10131. this.textInput.blur();
  10132. };
  10133. this.onFocus = function(e) {
  10134. if (this.$isFocused)
  10135. return;
  10136. this.$isFocused = true;
  10137. this.renderer.showCursor();
  10138. this.renderer.visualizeFocus();
  10139. this._emit("focus", e);
  10140. };
  10141. this.onBlur = function(e) {
  10142. if (!this.$isFocused)
  10143. return;
  10144. this.$isFocused = false;
  10145. this.renderer.hideCursor();
  10146. this.renderer.visualizeBlur();
  10147. this._emit("blur", e);
  10148. };
  10149. this.$cursorChange = function() {
  10150. this.renderer.updateCursor();
  10151. };
  10152. this.onDocumentChange = function(e) {
  10153. var delta = e.data;
  10154. var range = delta.range;
  10155. var lastRow;
  10156. if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
  10157. lastRow = range.end.row;
  10158. else
  10159. lastRow = Infinity;
  10160. this.renderer.updateLines(range.start.row, lastRow, this.session.$useWrapMode);
  10161. this._signal("change", e);
  10162. this.$cursorChange();
  10163. this.$updateHighlightActiveLine();
  10164. };
  10165. this.onTokenizerUpdate = function(e) {
  10166. var rows = e.data;
  10167. this.renderer.updateLines(rows.first, rows.last);
  10168. };
  10169. this.onScrollTopChange = function() {
  10170. this.renderer.scrollToY(this.session.getScrollTop());
  10171. };
  10172. this.onScrollLeftChange = function() {
  10173. this.renderer.scrollToX(this.session.getScrollLeft());
  10174. };
  10175. this.onCursorChange = function() {
  10176. this.$cursorChange();
  10177. if (!this.$blockScrolling) {
  10178. config.warn("Automatically scrolling cursor into view after selection change",
  10179. "this will be disabled in the next version",
  10180. "set editor.$blockScrolling = Infinity to disable this message"
  10181. );
  10182. this.renderer.scrollCursorIntoView();
  10183. }
  10184. this.$highlightBrackets();
  10185. this.$highlightTags();
  10186. this.$updateHighlightActiveLine();
  10187. this._signal("changeSelection");
  10188. };
  10189. this.$updateHighlightActiveLine = function() {
  10190. var session = this.getSession();
  10191. var highlight;
  10192. if (this.$highlightActiveLine) {
  10193. if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
  10194. highlight = this.getCursorPosition();
  10195. if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
  10196. highlight = false;
  10197. }
  10198. if (session.$highlightLineMarker && !highlight) {
  10199. session.removeMarker(session.$highlightLineMarker.id);
  10200. session.$highlightLineMarker = null;
  10201. } else if (!session.$highlightLineMarker && highlight) {
  10202. var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
  10203. range.id = session.addMarker(range, "ace_active-line", "screenLine");
  10204. session.$highlightLineMarker = range;
  10205. } else if (highlight) {
  10206. session.$highlightLineMarker.start.row = highlight.row;
  10207. session.$highlightLineMarker.end.row = highlight.row;
  10208. session.$highlightLineMarker.start.column = highlight.column;
  10209. session._signal("changeBackMarker");
  10210. }
  10211. };
  10212. this.onSelectionChange = function(e) {
  10213. var session = this.session;
  10214. if (session.$selectionMarker) {
  10215. session.removeMarker(session.$selectionMarker);
  10216. }
  10217. session.$selectionMarker = null;
  10218. if (!this.selection.isEmpty()) {
  10219. var range = this.selection.getRange();
  10220. var style = this.getSelectionStyle();
  10221. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  10222. } else {
  10223. this.$updateHighlightActiveLine();
  10224. }
  10225. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
  10226. this.session.highlight(re);
  10227. this._signal("changeSelection");
  10228. };
  10229. this.$getSelectionHighLightRegexp = function() {
  10230. var session = this.session;
  10231. var selection = this.getSelectionRange();
  10232. if (selection.isEmpty() || selection.isMultiLine())
  10233. return;
  10234. var startOuter = selection.start.column - 1;
  10235. var endOuter = selection.end.column + 1;
  10236. var line = session.getLine(selection.start.row);
  10237. var lineCols = line.length;
  10238. var needle = line.substring(Math.max(startOuter, 0),
  10239. Math.min(endOuter, lineCols));
  10240. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  10241. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  10242. return;
  10243. needle = line.substring(selection.start.column, selection.end.column);
  10244. if (!/^[\w\d]+$/.test(needle))
  10245. return;
  10246. var re = this.$search.$assembleRegExp({
  10247. wholeWord: true,
  10248. caseSensitive: true,
  10249. needle: needle
  10250. });
  10251. return re;
  10252. };
  10253. this.onChangeFrontMarker = function() {
  10254. this.renderer.updateFrontMarkers();
  10255. };
  10256. this.onChangeBackMarker = function() {
  10257. this.renderer.updateBackMarkers();
  10258. };
  10259. this.onChangeBreakpoint = function() {
  10260. this.renderer.updateBreakpoints();
  10261. };
  10262. this.onChangeAnnotation = function() {
  10263. this.renderer.setAnnotations(this.session.getAnnotations());
  10264. };
  10265. this.onChangeMode = function(e) {
  10266. this.renderer.updateText();
  10267. this._emit("changeMode", e);
  10268. };
  10269. this.onChangeWrapLimit = function() {
  10270. this.renderer.updateFull();
  10271. };
  10272. this.onChangeWrapMode = function() {
  10273. this.renderer.onResize(true);
  10274. };
  10275. this.onChangeFold = function() {
  10276. this.$updateHighlightActiveLine();
  10277. this.renderer.updateFull();
  10278. };
  10279. this.getSelectedText = function() {
  10280. return this.session.getTextRange(this.getSelectionRange());
  10281. };
  10282. this.getCopyText = function() {
  10283. var text = this.getSelectedText();
  10284. this._signal("copy", text);
  10285. return text;
  10286. };
  10287. this.onCopy = function() {
  10288. this.commands.exec("copy", this);
  10289. };
  10290. this.onCut = function() {
  10291. this.commands.exec("cut", this);
  10292. };
  10293. this.onPaste = function(text) {
  10294. if (this.$readOnly)
  10295. return;
  10296. var e = {text: text};
  10297. this._signal("paste", e);
  10298. text = e.text;
  10299. if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
  10300. this.insert(text);
  10301. } else {
  10302. var lines = text.split(/\r\n|\r|\n/);
  10303. var ranges = this.selection.rangeList.ranges;
  10304. if (lines.length > ranges.length || lines.length < 2 || !lines[1])
  10305. return this.commands.exec("insertstring", this, text);
  10306. for (var i = ranges.length; i--;) {
  10307. var range = ranges[i];
  10308. if (!range.isEmpty())
  10309. this.session.remove(range);
  10310. this.session.insert(range.start, lines[i]);
  10311. }
  10312. }
  10313. this.renderer.scrollCursorIntoView();
  10314. };
  10315. this.execCommand = function(command, args) {
  10316. return this.commands.exec(command, this, args);
  10317. };
  10318. this.insert = function(text, pasted) {
  10319. var session = this.session;
  10320. var mode = session.getMode();
  10321. var cursor = this.getCursorPosition();
  10322. if (this.getBehavioursEnabled() && !pasted) {
  10323. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  10324. if (transform) {
  10325. if (text !== transform.text) {
  10326. this.session.mergeUndoDeltas = false;
  10327. this.$mergeNextCommand = false;
  10328. }
  10329. text = transform.text;
  10330. }
  10331. }
  10332. if (text == "\t")
  10333. text = this.session.getTabString();
  10334. if (!this.selection.isEmpty()) {
  10335. var range = this.getSelectionRange();
  10336. cursor = this.session.remove(range);
  10337. this.clearSelection();
  10338. }
  10339. else if (this.session.getOverwrite()) {
  10340. var range = new Range.fromPoints(cursor, cursor);
  10341. range.end.column += text.length;
  10342. this.session.remove(range);
  10343. }
  10344. if (text == "\n" || text == "\r\n") {
  10345. var line = session.getLine(cursor.row);
  10346. if (cursor.column > line.search(/\S|$/)) {
  10347. var d = line.substr(cursor.column).search(/\S|$/);
  10348. session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
  10349. }
  10350. }
  10351. this.clearSelection();
  10352. var start = cursor.column;
  10353. var lineState = session.getState(cursor.row);
  10354. var line = session.getLine(cursor.row);
  10355. var shouldOutdent = mode.checkOutdent(lineState, line, text);
  10356. var end = session.insert(cursor, text);
  10357. if (transform && transform.selection) {
  10358. if (transform.selection.length == 2) { // Transform relative to the current column
  10359. this.selection.setSelectionRange(
  10360. new Range(cursor.row, start + transform.selection[0],
  10361. cursor.row, start + transform.selection[1]));
  10362. } else { // Transform relative to the current row.
  10363. this.selection.setSelectionRange(
  10364. new Range(cursor.row + transform.selection[0],
  10365. transform.selection[1],
  10366. cursor.row + transform.selection[2],
  10367. transform.selection[3]));
  10368. }
  10369. }
  10370. if (session.getDocument().isNewLine(text)) {
  10371. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  10372. session.insert({row: cursor.row+1, column: 0}, lineIndent);
  10373. }
  10374. if (shouldOutdent)
  10375. mode.autoOutdent(lineState, session, cursor.row);
  10376. };
  10377. this.onTextInput = function(text) {
  10378. this.keyBinding.onTextInput(text);
  10379. };
  10380. this.onCommandKey = function(e, hashId, keyCode) {
  10381. this.keyBinding.onCommandKey(e, hashId, keyCode);
  10382. };
  10383. this.setOverwrite = function(overwrite) {
  10384. this.session.setOverwrite(overwrite);
  10385. };
  10386. this.getOverwrite = function() {
  10387. return this.session.getOverwrite();
  10388. };
  10389. this.toggleOverwrite = function() {
  10390. this.session.toggleOverwrite();
  10391. };
  10392. this.setScrollSpeed = function(speed) {
  10393. this.setOption("scrollSpeed", speed);
  10394. };
  10395. this.getScrollSpeed = function() {
  10396. return this.getOption("scrollSpeed");
  10397. };
  10398. this.setDragDelay = function(dragDelay) {
  10399. this.setOption("dragDelay", dragDelay);
  10400. };
  10401. this.getDragDelay = function() {
  10402. return this.getOption("dragDelay");
  10403. };
  10404. this.setSelectionStyle = function(val) {
  10405. this.setOption("selectionStyle", val);
  10406. };
  10407. this.getSelectionStyle = function() {
  10408. return this.getOption("selectionStyle");
  10409. };
  10410. this.setHighlightActiveLine = function(shouldHighlight) {
  10411. this.setOption("highlightActiveLine", shouldHighlight);
  10412. };
  10413. this.getHighlightActiveLine = function() {
  10414. return this.getOption("highlightActiveLine");
  10415. };
  10416. this.setHighlightGutterLine = function(shouldHighlight) {
  10417. this.setOption("highlightGutterLine", shouldHighlight);
  10418. };
  10419. this.getHighlightGutterLine = function() {
  10420. return this.getOption("highlightGutterLine");
  10421. };
  10422. this.setHighlightSelectedWord = function(shouldHighlight) {
  10423. this.setOption("highlightSelectedWord", shouldHighlight);
  10424. };
  10425. this.getHighlightSelectedWord = function() {
  10426. return this.$highlightSelectedWord;
  10427. };
  10428. this.setAnimatedScroll = function(shouldAnimate){
  10429. this.renderer.setAnimatedScroll(shouldAnimate);
  10430. };
  10431. this.getAnimatedScroll = function(){
  10432. return this.renderer.getAnimatedScroll();
  10433. };
  10434. this.setShowInvisibles = function(showInvisibles) {
  10435. this.renderer.setShowInvisibles(showInvisibles);
  10436. };
  10437. this.getShowInvisibles = function() {
  10438. return this.renderer.getShowInvisibles();
  10439. };
  10440. this.setDisplayIndentGuides = function(display) {
  10441. this.renderer.setDisplayIndentGuides(display);
  10442. };
  10443. this.getDisplayIndentGuides = function() {
  10444. return this.renderer.getDisplayIndentGuides();
  10445. };
  10446. this.setShowPrintMargin = function(showPrintMargin) {
  10447. this.renderer.setShowPrintMargin(showPrintMargin);
  10448. };
  10449. this.getShowPrintMargin = function() {
  10450. return this.renderer.getShowPrintMargin();
  10451. };
  10452. this.setPrintMarginColumn = function(showPrintMargin) {
  10453. this.renderer.setPrintMarginColumn(showPrintMargin);
  10454. };
  10455. this.getPrintMarginColumn = function() {
  10456. return this.renderer.getPrintMarginColumn();
  10457. };
  10458. this.setReadOnly = function(readOnly) {
  10459. this.setOption("readOnly", readOnly);
  10460. };
  10461. this.getReadOnly = function() {
  10462. return this.getOption("readOnly");
  10463. };
  10464. this.setBehavioursEnabled = function (enabled) {
  10465. this.setOption("behavioursEnabled", enabled);
  10466. };
  10467. this.getBehavioursEnabled = function () {
  10468. return this.getOption("behavioursEnabled");
  10469. };
  10470. this.setWrapBehavioursEnabled = function (enabled) {
  10471. this.setOption("wrapBehavioursEnabled", enabled);
  10472. };
  10473. this.getWrapBehavioursEnabled = function () {
  10474. return this.getOption("wrapBehavioursEnabled");
  10475. };
  10476. this.setShowFoldWidgets = function(show) {
  10477. this.setOption("showFoldWidgets", show);
  10478. };
  10479. this.getShowFoldWidgets = function() {
  10480. return this.getOption("showFoldWidgets");
  10481. };
  10482. this.setFadeFoldWidgets = function(fade) {
  10483. this.setOption("fadeFoldWidgets", fade);
  10484. };
  10485. this.getFadeFoldWidgets = function() {
  10486. return this.getOption("fadeFoldWidgets");
  10487. };
  10488. this.remove = function(dir) {
  10489. if (this.selection.isEmpty()){
  10490. if (dir == "left")
  10491. this.selection.selectLeft();
  10492. else
  10493. this.selection.selectRight();
  10494. }
  10495. var range = this.getSelectionRange();
  10496. if (this.getBehavioursEnabled()) {
  10497. var session = this.session;
  10498. var state = session.getState(range.start.row);
  10499. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  10500. if (range.end.column === 0) {
  10501. var text = session.getTextRange(range);
  10502. if (text[text.length - 1] == "\n") {
  10503. var line = session.getLine(range.end.row);
  10504. if (/^\s+$/.test(line)) {
  10505. range.end.column = line.length;
  10506. }
  10507. }
  10508. }
  10509. if (new_range)
  10510. range = new_range;
  10511. }
  10512. this.session.remove(range);
  10513. this.clearSelection();
  10514. };
  10515. this.removeWordRight = function() {
  10516. if (this.selection.isEmpty())
  10517. this.selection.selectWordRight();
  10518. this.session.remove(this.getSelectionRange());
  10519. this.clearSelection();
  10520. };
  10521. this.removeWordLeft = function() {
  10522. if (this.selection.isEmpty())
  10523. this.selection.selectWordLeft();
  10524. this.session.remove(this.getSelectionRange());
  10525. this.clearSelection();
  10526. };
  10527. this.removeToLineStart = function() {
  10528. if (this.selection.isEmpty())
  10529. this.selection.selectLineStart();
  10530. this.session.remove(this.getSelectionRange());
  10531. this.clearSelection();
  10532. };
  10533. this.removeToLineEnd = function() {
  10534. if (this.selection.isEmpty())
  10535. this.selection.selectLineEnd();
  10536. var range = this.getSelectionRange();
  10537. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  10538. range.end.column = 0;
  10539. range.end.row++;
  10540. }
  10541. this.session.remove(range);
  10542. this.clearSelection();
  10543. };
  10544. this.splitLine = function() {
  10545. if (!this.selection.isEmpty()) {
  10546. this.session.remove(this.getSelectionRange());
  10547. this.clearSelection();
  10548. }
  10549. var cursor = this.getCursorPosition();
  10550. this.insert("\n");
  10551. this.moveCursorToPosition(cursor);
  10552. };
  10553. this.transposeLetters = function() {
  10554. if (!this.selection.isEmpty()) {
  10555. return;
  10556. }
  10557. var cursor = this.getCursorPosition();
  10558. var column = cursor.column;
  10559. if (column === 0)
  10560. return;
  10561. var line = this.session.getLine(cursor.row);
  10562. var swap, range;
  10563. if (column < line.length) {
  10564. swap = line.charAt(column) + line.charAt(column-1);
  10565. range = new Range(cursor.row, column-1, cursor.row, column+1);
  10566. }
  10567. else {
  10568. swap = line.charAt(column-1) + line.charAt(column-2);
  10569. range = new Range(cursor.row, column-2, cursor.row, column);
  10570. }
  10571. this.session.replace(range, swap);
  10572. };
  10573. this.toLowerCase = function() {
  10574. var originalRange = this.getSelectionRange();
  10575. if (this.selection.isEmpty()) {
  10576. this.selection.selectWord();
  10577. }
  10578. var range = this.getSelectionRange();
  10579. var text = this.session.getTextRange(range);
  10580. this.session.replace(range, text.toLowerCase());
  10581. this.selection.setSelectionRange(originalRange);
  10582. };
  10583. this.toUpperCase = function() {
  10584. var originalRange = this.getSelectionRange();
  10585. if (this.selection.isEmpty()) {
  10586. this.selection.selectWord();
  10587. }
  10588. var range = this.getSelectionRange();
  10589. var text = this.session.getTextRange(range);
  10590. this.session.replace(range, text.toUpperCase());
  10591. this.selection.setSelectionRange(originalRange);
  10592. };
  10593. this.indent = function() {
  10594. var session = this.session;
  10595. var range = this.getSelectionRange();
  10596. if (range.start.row < range.end.row) {
  10597. var rows = this.$getSelectedRows();
  10598. session.indentRows(rows.first, rows.last, "\t");
  10599. return;
  10600. } else if (range.start.column < range.end.column) {
  10601. var text = session.getTextRange(range);
  10602. if (!/^\s+$/.test(text)) {
  10603. var rows = this.$getSelectedRows();
  10604. session.indentRows(rows.first, rows.last, "\t");
  10605. return;
  10606. }
  10607. }
  10608. var line = session.getLine(range.start.row);
  10609. var position = range.start;
  10610. var size = session.getTabSize();
  10611. var column = session.documentToScreenColumn(position.row, position.column);
  10612. if (this.session.getUseSoftTabs()) {
  10613. var count = (size - column % size);
  10614. var indentString = lang.stringRepeat(" ", count);
  10615. } else {
  10616. var count = column % size;
  10617. while (line[range.start.column] == " " && count) {
  10618. range.start.column--;
  10619. count--;
  10620. }
  10621. this.selection.setSelectionRange(range);
  10622. indentString = "\t";
  10623. }
  10624. return this.insert(indentString);
  10625. };
  10626. this.blockIndent = function() {
  10627. var rows = this.$getSelectedRows();
  10628. this.session.indentRows(rows.first, rows.last, "\t");
  10629. };
  10630. this.blockOutdent = function() {
  10631. var selection = this.session.getSelection();
  10632. this.session.outdentRows(selection.getRange());
  10633. };
  10634. this.sortLines = function() {
  10635. var rows = this.$getSelectedRows();
  10636. var session = this.session;
  10637. var lines = [];
  10638. for (i = rows.first; i <= rows.last; i++)
  10639. lines.push(session.getLine(i));
  10640. lines.sort(function(a, b) {
  10641. if (a.toLowerCase() < b.toLowerCase()) return -1;
  10642. if (a.toLowerCase() > b.toLowerCase()) return 1;
  10643. return 0;
  10644. });
  10645. var deleteRange = new Range(0, 0, 0, 0);
  10646. for (var i = rows.first; i <= rows.last; i++) {
  10647. var line = session.getLine(i);
  10648. deleteRange.start.row = i;
  10649. deleteRange.end.row = i;
  10650. deleteRange.end.column = line.length;
  10651. session.replace(deleteRange, lines[i-rows.first]);
  10652. }
  10653. };
  10654. this.toggleCommentLines = function() {
  10655. var state = this.session.getState(this.getCursorPosition().row);
  10656. var rows = this.$getSelectedRows();
  10657. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  10658. };
  10659. this.toggleBlockComment = function() {
  10660. var cursor = this.getCursorPosition();
  10661. var state = this.session.getState(cursor.row);
  10662. var range = this.getSelectionRange();
  10663. this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
  10664. };
  10665. this.getNumberAt = function(row, column) {
  10666. var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
  10667. _numberRx.lastIndex = 0;
  10668. var s = this.session.getLine(row);
  10669. while (_numberRx.lastIndex < column) {
  10670. var m = _numberRx.exec(s);
  10671. if(m.index <= column && m.index+m[0].length >= column){
  10672. var number = {
  10673. value: m[0],
  10674. start: m.index,
  10675. end: m.index+m[0].length
  10676. };
  10677. return number;
  10678. }
  10679. }
  10680. return null;
  10681. };
  10682. this.modifyNumber = function(amount) {
  10683. var row = this.selection.getCursor().row;
  10684. var column = this.selection.getCursor().column;
  10685. var charRange = new Range(row, column-1, row, column);
  10686. var c = this.session.getTextRange(charRange);
  10687. if (!isNaN(parseFloat(c)) && isFinite(c)) {
  10688. var nr = this.getNumberAt(row, column);
  10689. if (nr) {
  10690. var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
  10691. var decimals = nr.start + nr.value.length - fp;
  10692. var t = parseFloat(nr.value);
  10693. t *= Math.pow(10, decimals);
  10694. if(fp !== nr.end && column < fp){
  10695. amount *= Math.pow(10, nr.end - column - 1);
  10696. } else {
  10697. amount *= Math.pow(10, nr.end - column);
  10698. }
  10699. t += amount;
  10700. t /= Math.pow(10, decimals);
  10701. var nnr = t.toFixed(decimals);
  10702. var replaceRange = new Range(row, nr.start, row, nr.end);
  10703. this.session.replace(replaceRange, nnr);
  10704. this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
  10705. }
  10706. }
  10707. };
  10708. this.removeLines = function() {
  10709. var rows = this.$getSelectedRows();
  10710. var range;
  10711. if (rows.first === 0 || rows.last+1 < this.session.getLength())
  10712. range = new Range(rows.first, 0, rows.last+1, 0);
  10713. else
  10714. range = new Range(
  10715. rows.first-1, this.session.getLine(rows.first-1).length,
  10716. rows.last, this.session.getLine(rows.last).length
  10717. );
  10718. this.session.remove(range);
  10719. this.clearSelection();
  10720. };
  10721. this.duplicateSelection = function() {
  10722. var sel = this.selection;
  10723. var doc = this.session;
  10724. var range = sel.getRange();
  10725. var reverse = sel.isBackwards();
  10726. if (range.isEmpty()) {
  10727. var row = range.start.row;
  10728. doc.duplicateLines(row, row);
  10729. } else {
  10730. var point = reverse ? range.start : range.end;
  10731. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  10732. range.start = point;
  10733. range.end = endPoint;
  10734. sel.setSelectionRange(range, reverse);
  10735. }
  10736. };
  10737. this.moveLinesDown = function() {
  10738. this.$moveLines(1, false);
  10739. };
  10740. this.moveLinesUp = function() {
  10741. this.$moveLines(-1, false);
  10742. };
  10743. this.moveText = function(range, toPosition, copy) {
  10744. return this.session.moveText(range, toPosition, copy);
  10745. };
  10746. this.copyLinesUp = function() {
  10747. this.$moveLines(-1, true);
  10748. };
  10749. this.copyLinesDown = function() {
  10750. this.$moveLines(1, true);
  10751. };
  10752. this.$moveLines = function(dir, copy) {
  10753. var rows, moved;
  10754. var selection = this.selection;
  10755. if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
  10756. var range = selection.toOrientedRange();
  10757. rows = this.$getSelectedRows(range);
  10758. moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
  10759. if (copy && dir == -1) moved = 0;
  10760. range.moveBy(moved, 0);
  10761. selection.fromOrientedRange(range);
  10762. } else {
  10763. var ranges = selection.rangeList.ranges;
  10764. selection.rangeList.detach(this.session);
  10765. this.inVirtualSelectionMode = true;
  10766. var diff = 0;
  10767. var totalDiff = 0;
  10768. var l = ranges.length;
  10769. for (var i = 0; i < l; i++) {
  10770. var rangeIndex = i;
  10771. ranges[i].moveBy(diff, 0);
  10772. rows = this.$getSelectedRows(ranges[i]);
  10773. var first = rows.first;
  10774. var last = rows.last;
  10775. while (++i < l) {
  10776. if (totalDiff) ranges[i].moveBy(totalDiff, 0);
  10777. var subRows = this.$getSelectedRows(ranges[i]);
  10778. if (copy && subRows.first != last)
  10779. break;
  10780. else if (!copy && subRows.first > last + 1)
  10781. break;
  10782. last = subRows.last;
  10783. }
  10784. i--;
  10785. diff = this.session.$moveLines(first, last, copy ? 0 : dir);
  10786. if (copy && dir == -1) rangeIndex = i + 1;
  10787. while (rangeIndex <= i) {
  10788. ranges[rangeIndex].moveBy(diff, 0);
  10789. rangeIndex++;
  10790. }
  10791. if (!copy) diff = 0;
  10792. totalDiff += diff;
  10793. }
  10794. selection.fromOrientedRange(selection.ranges[0]);
  10795. selection.rangeList.attach(this.session);
  10796. this.inVirtualSelectionMode = false;
  10797. }
  10798. };
  10799. this.$getSelectedRows = function(range) {
  10800. range = (range || this.getSelectionRange()).collapseRows();
  10801. return {
  10802. first: this.session.getRowFoldStart(range.start.row),
  10803. last: this.session.getRowFoldEnd(range.end.row)
  10804. };
  10805. };
  10806. this.onCompositionStart = function(text) {
  10807. this.renderer.showComposition(this.getCursorPosition());
  10808. };
  10809. this.onCompositionUpdate = function(text) {
  10810. this.renderer.setCompositionText(text);
  10811. };
  10812. this.onCompositionEnd = function() {
  10813. this.renderer.hideComposition();
  10814. };
  10815. this.getFirstVisibleRow = function() {
  10816. return this.renderer.getFirstVisibleRow();
  10817. };
  10818. this.getLastVisibleRow = function() {
  10819. return this.renderer.getLastVisibleRow();
  10820. };
  10821. this.isRowVisible = function(row) {
  10822. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  10823. };
  10824. this.isRowFullyVisible = function(row) {
  10825. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  10826. };
  10827. this.$getVisibleRowCount = function() {
  10828. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  10829. };
  10830. this.$moveByPage = function(dir, select) {
  10831. var renderer = this.renderer;
  10832. var config = this.renderer.layerConfig;
  10833. var rows = dir * Math.floor(config.height / config.lineHeight);
  10834. this.$blockScrolling++;
  10835. if (select === true) {
  10836. this.selection.$moveSelection(function(){
  10837. this.moveCursorBy(rows, 0);
  10838. });
  10839. } else if (select === false) {
  10840. this.selection.moveCursorBy(rows, 0);
  10841. this.selection.clearSelection();
  10842. }
  10843. this.$blockScrolling--;
  10844. var scrollTop = renderer.scrollTop;
  10845. renderer.scrollBy(0, rows * config.lineHeight);
  10846. if (select != null)
  10847. renderer.scrollCursorIntoView(null, 0.5);
  10848. renderer.animateScrolling(scrollTop);
  10849. };
  10850. this.selectPageDown = function() {
  10851. this.$moveByPage(1, true);
  10852. };
  10853. this.selectPageUp = function() {
  10854. this.$moveByPage(-1, true);
  10855. };
  10856. this.gotoPageDown = function() {
  10857. this.$moveByPage(1, false);
  10858. };
  10859. this.gotoPageUp = function() {
  10860. this.$moveByPage(-1, false);
  10861. };
  10862. this.scrollPageDown = function() {
  10863. this.$moveByPage(1);
  10864. };
  10865. this.scrollPageUp = function() {
  10866. this.$moveByPage(-1);
  10867. };
  10868. this.scrollToRow = function(row) {
  10869. this.renderer.scrollToRow(row);
  10870. };
  10871. this.scrollToLine = function(line, center, animate, callback) {
  10872. this.renderer.scrollToLine(line, center, animate, callback);
  10873. };
  10874. this.centerSelection = function() {
  10875. var range = this.getSelectionRange();
  10876. var pos = {
  10877. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  10878. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  10879. };
  10880. this.renderer.alignCursor(pos, 0.5);
  10881. };
  10882. this.getCursorPosition = function() {
  10883. return this.selection.getCursor();
  10884. };
  10885. this.getCursorPositionScreen = function() {
  10886. return this.session.documentToScreenPosition(this.getCursorPosition());
  10887. };
  10888. this.getSelectionRange = function() {
  10889. return this.selection.getRange();
  10890. };
  10891. this.selectAll = function() {
  10892. this.$blockScrolling += 1;
  10893. this.selection.selectAll();
  10894. this.$blockScrolling -= 1;
  10895. };
  10896. this.clearSelection = function() {
  10897. this.selection.clearSelection();
  10898. };
  10899. this.moveCursorTo = function(row, column) {
  10900. this.selection.moveCursorTo(row, column);
  10901. };
  10902. this.moveCursorToPosition = function(pos) {
  10903. this.selection.moveCursorToPosition(pos);
  10904. };
  10905. this.jumpToMatching = function(select, expand) {
  10906. var cursor = this.getCursorPosition();
  10907. var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
  10908. var prevToken = iterator.getCurrentToken();
  10909. var token = prevToken || iterator.stepForward();
  10910. if (!token) return;
  10911. var matchType;
  10912. var found = false;
  10913. var depth = {};
  10914. var i = cursor.column - token.start;
  10915. var bracketType;
  10916. var brackets = {
  10917. ")": "(",
  10918. "(": "(",
  10919. "]": "[",
  10920. "[": "[",
  10921. "{": "{",
  10922. "}": "{"
  10923. };
  10924. do {
  10925. if (token.value.match(/[{}()\[\]]/g)) {
  10926. for (; i < token.value.length && !found; i++) {
  10927. if (!brackets[token.value[i]]) {
  10928. continue;
  10929. }
  10930. bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
  10931. if (isNaN(depth[bracketType])) {
  10932. depth[bracketType] = 0;
  10933. }
  10934. switch (token.value[i]) {
  10935. case '(':
  10936. case '[':
  10937. case '{':
  10938. depth[bracketType]++;
  10939. break;
  10940. case ')':
  10941. case ']':
  10942. case '}':
  10943. depth[bracketType]--;
  10944. if (depth[bracketType] === -1) {
  10945. matchType = 'bracket';
  10946. found = true;
  10947. }
  10948. break;
  10949. }
  10950. }
  10951. }
  10952. else if (token && token.type.indexOf('tag-name') !== -1) {
  10953. if (isNaN(depth[token.value])) {
  10954. depth[token.value] = 0;
  10955. }
  10956. if (prevToken.value === '<') {
  10957. depth[token.value]++;
  10958. }
  10959. else if (prevToken.value === '</') {
  10960. depth[token.value]--;
  10961. }
  10962. if (depth[token.value] === -1) {
  10963. matchType = 'tag';
  10964. found = true;
  10965. }
  10966. }
  10967. if (!found) {
  10968. prevToken = token;
  10969. token = iterator.stepForward();
  10970. i = 0;
  10971. }
  10972. } while (token && !found);
  10973. if (!matchType)
  10974. return;
  10975. var range, pos;
  10976. if (matchType === 'bracket') {
  10977. range = this.session.getBracketRange(cursor);
  10978. if (!range) {
  10979. range = new Range(
  10980. iterator.getCurrentTokenRow(),
  10981. iterator.getCurrentTokenColumn() + i - 1,
  10982. iterator.getCurrentTokenRow(),
  10983. iterator.getCurrentTokenColumn() + i - 1
  10984. );
  10985. pos = range.start;
  10986. if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
  10987. range = this.session.getBracketRange(pos);
  10988. }
  10989. }
  10990. else if (matchType === 'tag') {
  10991. if (token && token.type.indexOf('tag-name') !== -1)
  10992. var tag = token.value;
  10993. else
  10994. return;
  10995. range = new Range(
  10996. iterator.getCurrentTokenRow(),
  10997. iterator.getCurrentTokenColumn() - 2,
  10998. iterator.getCurrentTokenRow(),
  10999. iterator.getCurrentTokenColumn() - 2
  11000. );
  11001. if (range.compare(cursor.row, cursor.column) === 0) {
  11002. found = false;
  11003. do {
  11004. token = prevToken;
  11005. prevToken = iterator.stepBackward();
  11006. if (prevToken) {
  11007. if (prevToken.type.indexOf('tag-close') !== -1) {
  11008. range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
  11009. }
  11010. if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11011. if (prevToken.value === '<') {
  11012. depth[tag]++;
  11013. }
  11014. else if (prevToken.value === '</') {
  11015. depth[tag]--;
  11016. }
  11017. if (depth[tag] === 0)
  11018. found = true;
  11019. }
  11020. }
  11021. } while (prevToken && !found);
  11022. }
  11023. if (token && token.type.indexOf('tag-name')) {
  11024. pos = range.start;
  11025. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11026. pos = range.end;
  11027. }
  11028. }
  11029. pos = range && range.cursor || pos;
  11030. if (pos) {
  11031. if (select) {
  11032. if (range && expand) {
  11033. this.selection.setRange(range);
  11034. } else if (range && range.isEqual(this.getSelectionRange())) {
  11035. this.clearSelection();
  11036. } else {
  11037. this.selection.selectTo(pos.row, pos.column);
  11038. }
  11039. } else {
  11040. this.selection.moveTo(pos.row, pos.column);
  11041. }
  11042. }
  11043. };
  11044. this.gotoLine = function(lineNumber, column, animate) {
  11045. this.selection.clearSelection();
  11046. this.session.unfold({row: lineNumber - 1, column: column || 0});
  11047. this.$blockScrolling += 1;
  11048. this.exitMultiSelectMode && this.exitMultiSelectMode();
  11049. this.moveCursorTo(lineNumber - 1, column || 0);
  11050. this.$blockScrolling -= 1;
  11051. if (!this.isRowFullyVisible(lineNumber - 1))
  11052. this.scrollToLine(lineNumber - 1, true, animate);
  11053. };
  11054. this.navigateTo = function(row, column) {
  11055. this.selection.moveTo(row, column);
  11056. };
  11057. this.navigateUp = function(times) {
  11058. if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
  11059. var selectionStart = this.selection.anchor.getPosition();
  11060. return this.moveCursorToPosition(selectionStart);
  11061. }
  11062. this.selection.clearSelection();
  11063. this.selection.moveCursorBy(-times || -1, 0);
  11064. };
  11065. this.navigateDown = function(times) {
  11066. if (this.selection.isMultiLine() && this.selection.isBackwards()) {
  11067. var selectionEnd = this.selection.anchor.getPosition();
  11068. return this.moveCursorToPosition(selectionEnd);
  11069. }
  11070. this.selection.clearSelection();
  11071. this.selection.moveCursorBy(times || 1, 0);
  11072. };
  11073. this.navigateLeft = function(times) {
  11074. if (!this.selection.isEmpty()) {
  11075. var selectionStart = this.getSelectionRange().start;
  11076. this.moveCursorToPosition(selectionStart);
  11077. }
  11078. else {
  11079. times = times || 1;
  11080. while (times--) {
  11081. this.selection.moveCursorLeft();
  11082. }
  11083. }
  11084. this.clearSelection();
  11085. };
  11086. this.navigateRight = function(times) {
  11087. if (!this.selection.isEmpty()) {
  11088. var selectionEnd = this.getSelectionRange().end;
  11089. this.moveCursorToPosition(selectionEnd);
  11090. }
  11091. else {
  11092. times = times || 1;
  11093. while (times--) {
  11094. this.selection.moveCursorRight();
  11095. }
  11096. }
  11097. this.clearSelection();
  11098. };
  11099. this.navigateLineStart = function() {
  11100. this.selection.moveCursorLineStart();
  11101. this.clearSelection();
  11102. };
  11103. this.navigateLineEnd = function() {
  11104. this.selection.moveCursorLineEnd();
  11105. this.clearSelection();
  11106. };
  11107. this.navigateFileEnd = function() {
  11108. this.selection.moveCursorFileEnd();
  11109. this.clearSelection();
  11110. };
  11111. this.navigateFileStart = function() {
  11112. this.selection.moveCursorFileStart();
  11113. this.clearSelection();
  11114. };
  11115. this.navigateWordRight = function() {
  11116. this.selection.moveCursorWordRight();
  11117. this.clearSelection();
  11118. };
  11119. this.navigateWordLeft = function() {
  11120. this.selection.moveCursorWordLeft();
  11121. this.clearSelection();
  11122. };
  11123. this.replace = function(replacement, options) {
  11124. if (options)
  11125. this.$search.set(options);
  11126. var range = this.$search.find(this.session);
  11127. var replaced = 0;
  11128. if (!range)
  11129. return replaced;
  11130. if (this.$tryReplace(range, replacement)) {
  11131. replaced = 1;
  11132. }
  11133. if (range !== null) {
  11134. this.selection.setSelectionRange(range);
  11135. this.renderer.scrollSelectionIntoView(range.start, range.end);
  11136. }
  11137. return replaced;
  11138. };
  11139. this.replaceAll = function(replacement, options) {
  11140. if (options) {
  11141. this.$search.set(options);
  11142. }
  11143. var ranges = this.$search.findAll(this.session);
  11144. var replaced = 0;
  11145. if (!ranges.length)
  11146. return replaced;
  11147. this.$blockScrolling += 1;
  11148. var selection = this.getSelectionRange();
  11149. this.selection.moveTo(0, 0);
  11150. for (var i = ranges.length - 1; i >= 0; --i) {
  11151. if(this.$tryReplace(ranges[i], replacement)) {
  11152. replaced++;
  11153. }
  11154. }
  11155. this.selection.setSelectionRange(selection);
  11156. this.$blockScrolling -= 1;
  11157. return replaced;
  11158. };
  11159. this.$tryReplace = function(range, replacement) {
  11160. var input = this.session.getTextRange(range);
  11161. replacement = this.$search.replace(input, replacement);
  11162. if (replacement !== null) {
  11163. range.end = this.session.replace(range, replacement);
  11164. return range;
  11165. } else {
  11166. return null;
  11167. }
  11168. };
  11169. this.getLastSearchOptions = function() {
  11170. return this.$search.getOptions();
  11171. };
  11172. this.find = function(needle, options, animate) {
  11173. if (!options)
  11174. options = {};
  11175. if (typeof needle == "string" || needle instanceof RegExp)
  11176. options.needle = needle;
  11177. else if (typeof needle == "object")
  11178. oop.mixin(options, needle);
  11179. var range = this.selection.getRange();
  11180. if (options.needle == null) {
  11181. needle = this.session.getTextRange(range)
  11182. || this.$search.$options.needle;
  11183. if (!needle) {
  11184. range = this.session.getWordRange(range.start.row, range.start.column);
  11185. needle = this.session.getTextRange(range);
  11186. }
  11187. this.$search.set({needle: needle});
  11188. }
  11189. this.$search.set(options);
  11190. if (!options.start)
  11191. this.$search.set({start: range});
  11192. var newRange = this.$search.find(this.session);
  11193. if (options.preventScroll)
  11194. return newRange;
  11195. if (newRange) {
  11196. this.revealRange(newRange, animate);
  11197. return newRange;
  11198. }
  11199. if (options.backwards)
  11200. range.start = range.end;
  11201. else
  11202. range.end = range.start;
  11203. this.selection.setRange(range);
  11204. };
  11205. this.findNext = function(options, animate) {
  11206. this.find({skipCurrent: true, backwards: false}, options, animate);
  11207. };
  11208. this.findPrevious = function(options, animate) {
  11209. this.find(options, {skipCurrent: true, backwards: true}, animate);
  11210. };
  11211. this.revealRange = function(range, animate) {
  11212. this.$blockScrolling += 1;
  11213. this.session.unfold(range);
  11214. this.selection.setSelectionRange(range);
  11215. this.$blockScrolling -= 1;
  11216. var scrollTop = this.renderer.scrollTop;
  11217. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  11218. if (animate !== false)
  11219. this.renderer.animateScrolling(scrollTop);
  11220. };
  11221. this.undo = function() {
  11222. this.$blockScrolling++;
  11223. this.session.getUndoManager().undo();
  11224. this.$blockScrolling--;
  11225. this.renderer.scrollCursorIntoView(null, 0.5);
  11226. };
  11227. this.redo = function() {
  11228. this.$blockScrolling++;
  11229. this.session.getUndoManager().redo();
  11230. this.$blockScrolling--;
  11231. this.renderer.scrollCursorIntoView(null, 0.5);
  11232. };
  11233. this.destroy = function() {
  11234. this.renderer.destroy();
  11235. this._signal("destroy", this);
  11236. if (this.session) {
  11237. this.session.destroy();
  11238. }
  11239. };
  11240. this.setAutoScrollEditorIntoView = function(enable) {
  11241. if (!enable)
  11242. return;
  11243. var rect;
  11244. var self = this;
  11245. var shouldScroll = false;
  11246. if (!this.$scrollAnchor)
  11247. this.$scrollAnchor = document.createElement("div");
  11248. var scrollAnchor = this.$scrollAnchor;
  11249. scrollAnchor.style.cssText = "position:absolute";
  11250. this.container.insertBefore(scrollAnchor, this.container.firstChild);
  11251. var onChangeSelection = this.on("changeSelection", function() {
  11252. shouldScroll = true;
  11253. });
  11254. var onBeforeRender = this.renderer.on("beforeRender", function() {
  11255. if (shouldScroll)
  11256. rect = self.renderer.container.getBoundingClientRect();
  11257. });
  11258. var onAfterRender = this.renderer.on("afterRender", function() {
  11259. if (shouldScroll && rect && (self.isFocused()
  11260. || self.searchBox && self.searchBox.isFocused())
  11261. ) {
  11262. var renderer = self.renderer;
  11263. var pos = renderer.$cursorLayer.$pixelPos;
  11264. var config = renderer.layerConfig;
  11265. var top = pos.top - config.offset;
  11266. if (pos.top >= 0 && top + rect.top < 0) {
  11267. shouldScroll = true;
  11268. } else if (pos.top < config.height &&
  11269. pos.top + rect.top + config.lineHeight > window.innerHeight) {
  11270. shouldScroll = false;
  11271. } else {
  11272. shouldScroll = null;
  11273. }
  11274. if (shouldScroll != null) {
  11275. scrollAnchor.style.top = top + "px";
  11276. scrollAnchor.style.left = pos.left + "px";
  11277. scrollAnchor.style.height = config.lineHeight + "px";
  11278. scrollAnchor.scrollIntoView(shouldScroll);
  11279. }
  11280. shouldScroll = rect = null;
  11281. }
  11282. });
  11283. this.setAutoScrollEditorIntoView = function(enable) {
  11284. if (enable)
  11285. return;
  11286. delete this.setAutoScrollEditorIntoView;
  11287. this.removeEventListener("changeSelection", onChangeSelection);
  11288. this.renderer.removeEventListener("afterRender", onAfterRender);
  11289. this.renderer.removeEventListener("beforeRender", onBeforeRender);
  11290. };
  11291. };
  11292. this.$resetCursorStyle = function() {
  11293. var style = this.$cursorStyle || "ace";
  11294. var cursorLayer = this.renderer.$cursorLayer;
  11295. if (!cursorLayer)
  11296. return;
  11297. cursorLayer.setSmoothBlinking(/smooth/.test(style));
  11298. cursorLayer.isBlinking = !this.$readOnly && style != "wide";
  11299. dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
  11300. };
  11301. }).call(Editor.prototype);
  11302. config.defineOptions(Editor.prototype, "editor", {
  11303. selectionStyle: {
  11304. set: function(style) {
  11305. this.onSelectionChange();
  11306. this._signal("changeSelectionStyle", {data: style});
  11307. },
  11308. initialValue: "line"
  11309. },
  11310. highlightActiveLine: {
  11311. set: function() {this.$updateHighlightActiveLine();},
  11312. initialValue: true
  11313. },
  11314. highlightSelectedWord: {
  11315. set: function(shouldHighlight) {this.$onSelectionChange();},
  11316. initialValue: true
  11317. },
  11318. readOnly: {
  11319. set: function(readOnly) {
  11320. this.$resetCursorStyle();
  11321. },
  11322. initialValue: false
  11323. },
  11324. cursorStyle: {
  11325. set: function(val) { this.$resetCursorStyle(); },
  11326. values: ["ace", "slim", "smooth", "wide"],
  11327. initialValue: "ace"
  11328. },
  11329. mergeUndoDeltas: {
  11330. values: [false, true, "always"],
  11331. initialValue: true
  11332. },
  11333. behavioursEnabled: {initialValue: true},
  11334. wrapBehavioursEnabled: {initialValue: true},
  11335. autoScrollEditorIntoView: {
  11336. set: function(val) {this.setAutoScrollEditorIntoView(val)}
  11337. },
  11338. hScrollBarAlwaysVisible: "renderer",
  11339. vScrollBarAlwaysVisible: "renderer",
  11340. highlightGutterLine: "renderer",
  11341. animatedScroll: "renderer",
  11342. showInvisibles: "renderer",
  11343. showPrintMargin: "renderer",
  11344. printMarginColumn: "renderer",
  11345. printMargin: "renderer",
  11346. fadeFoldWidgets: "renderer",
  11347. showFoldWidgets: "renderer",
  11348. showLineNumbers: "renderer",
  11349. showGutter: "renderer",
  11350. displayIndentGuides: "renderer",
  11351. fontSize: "renderer",
  11352. fontFamily: "renderer",
  11353. maxLines: "renderer",
  11354. minLines: "renderer",
  11355. scrollPastEnd: "renderer",
  11356. fixedWidthGutter: "renderer",
  11357. theme: "renderer",
  11358. scrollSpeed: "$mouseHandler",
  11359. dragDelay: "$mouseHandler",
  11360. dragEnabled: "$mouseHandler",
  11361. focusTimout: "$mouseHandler",
  11362. tooltipFollowsMouse: "$mouseHandler",
  11363. firstLineNumber: "session",
  11364. overwrite: "session",
  11365. newLineMode: "session",
  11366. useWorker: "session",
  11367. useSoftTabs: "session",
  11368. tabSize: "session",
  11369. wrap: "session",
  11370. foldStyle: "session",
  11371. mode: "session"
  11372. });
  11373. exports.Editor = Editor;
  11374. });
  11375. ace.define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
  11376. "use strict";
  11377. var UndoManager = function() {
  11378. this.reset();
  11379. };
  11380. (function() {
  11381. this.execute = function(options) {
  11382. var deltas = options.args[0];
  11383. this.$doc = options.args[1];
  11384. if (options.merge && this.hasUndo()){
  11385. this.dirtyCounter--;
  11386. deltas = this.$undoStack.pop().concat(deltas);
  11387. }
  11388. this.$undoStack.push(deltas);
  11389. this.$redoStack = [];
  11390. if (this.dirtyCounter < 0) {
  11391. this.dirtyCounter = NaN;
  11392. }
  11393. this.dirtyCounter++;
  11394. };
  11395. this.undo = function(dontSelect) {
  11396. var deltas = this.$undoStack.pop();
  11397. var undoSelectionRange = null;
  11398. if (deltas) {
  11399. undoSelectionRange =
  11400. this.$doc.undoChanges(deltas, dontSelect);
  11401. this.$redoStack.push(deltas);
  11402. this.dirtyCounter--;
  11403. }
  11404. return undoSelectionRange;
  11405. };
  11406. this.redo = function(dontSelect) {
  11407. var deltas = this.$redoStack.pop();
  11408. var redoSelectionRange = null;
  11409. if (deltas) {
  11410. redoSelectionRange =
  11411. this.$doc.redoChanges(deltas, dontSelect);
  11412. this.$undoStack.push(deltas);
  11413. this.dirtyCounter++;
  11414. }
  11415. return redoSelectionRange;
  11416. };
  11417. this.reset = function() {
  11418. this.$undoStack = [];
  11419. this.$redoStack = [];
  11420. this.dirtyCounter = 0;
  11421. };
  11422. this.hasUndo = function() {
  11423. return this.$undoStack.length > 0;
  11424. };
  11425. this.hasRedo = function() {
  11426. return this.$redoStack.length > 0;
  11427. };
  11428. this.markClean = function() {
  11429. this.dirtyCounter = 0;
  11430. };
  11431. this.isClean = function() {
  11432. return this.dirtyCounter === 0;
  11433. };
  11434. }).call(UndoManager.prototype);
  11435. exports.UndoManager = UndoManager;
  11436. });
  11437. ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"], function(require, exports, module) {
  11438. "use strict";
  11439. var dom = require("../lib/dom");
  11440. var oop = require("../lib/oop");
  11441. var lang = require("../lib/lang");
  11442. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11443. var Gutter = function(parentEl) {
  11444. this.element = dom.createElement("div");
  11445. this.element.className = "ace_layer ace_gutter-layer";
  11446. parentEl.appendChild(this.element);
  11447. this.setShowFoldWidgets(this.$showFoldWidgets);
  11448. this.gutterWidth = 0;
  11449. this.$annotations = [];
  11450. this.$updateAnnotations = this.$updateAnnotations.bind(this);
  11451. this.$cells = [];
  11452. };
  11453. (function() {
  11454. oop.implement(this, EventEmitter);
  11455. this.setSession = function(session) {
  11456. if (this.session)
  11457. this.session.removeEventListener("change", this.$updateAnnotations);
  11458. this.session = session;
  11459. if (session)
  11460. session.on("change", this.$updateAnnotations);
  11461. };
  11462. this.addGutterDecoration = function(row, className){
  11463. if (window.console)
  11464. console.warn && console.warn("deprecated use session.addGutterDecoration");
  11465. this.session.addGutterDecoration(row, className);
  11466. };
  11467. this.removeGutterDecoration = function(row, className){
  11468. if (window.console)
  11469. console.warn && console.warn("deprecated use session.removeGutterDecoration");
  11470. this.session.removeGutterDecoration(row, className);
  11471. };
  11472. this.setAnnotations = function(annotations) {
  11473. this.$annotations = [];
  11474. for (var i = 0; i < annotations.length; i++) {
  11475. var annotation = annotations[i];
  11476. var row = annotation.row;
  11477. var rowInfo = this.$annotations[row];
  11478. if (!rowInfo)
  11479. rowInfo = this.$annotations[row] = {text: []};
  11480. var annoText = annotation.text;
  11481. annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
  11482. if (rowInfo.text.indexOf(annoText) === -1)
  11483. rowInfo.text.push(annoText);
  11484. var type = annotation.type;
  11485. if (type == "error")
  11486. rowInfo.className = " ace_error";
  11487. else if (type == "warning" && rowInfo.className != " ace_error")
  11488. rowInfo.className = " ace_warning";
  11489. else if (type == "info" && (!rowInfo.className))
  11490. rowInfo.className = " ace_info";
  11491. }
  11492. };
  11493. this.$updateAnnotations = function (e) {
  11494. if (!this.$annotations.length)
  11495. return;
  11496. var delta = e.data;
  11497. var range = delta.range;
  11498. var firstRow = range.start.row;
  11499. var len = range.end.row - firstRow;
  11500. if (len === 0) {
  11501. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  11502. this.$annotations.splice(firstRow, len + 1, null);
  11503. } else {
  11504. var args = new Array(len + 1);
  11505. args.unshift(firstRow, 1);
  11506. this.$annotations.splice.apply(this.$annotations, args);
  11507. }
  11508. };
  11509. this.update = function(config) {
  11510. var session = this.session;
  11511. var firstRow = config.firstRow;
  11512. var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
  11513. session.getLength() - 1);
  11514. var fold = session.getNextFoldLine(firstRow);
  11515. var foldStart = fold ? fold.start.row : Infinity;
  11516. var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
  11517. var breakpoints = session.$breakpoints;
  11518. var decorations = session.$decorations;
  11519. var firstLineNumber = session.$firstLineNumber;
  11520. var lastLineNumber = 0;
  11521. var gutterRenderer = session.gutterRenderer || this.$renderer;
  11522. var cell = null;
  11523. var index = -1;
  11524. var row = firstRow;
  11525. while (true) {
  11526. if (row > foldStart) {
  11527. row = fold.end.row + 1;
  11528. fold = session.getNextFoldLine(row, fold);
  11529. foldStart = fold ? fold.start.row : Infinity;
  11530. }
  11531. if (row > lastRow) {
  11532. while (this.$cells.length > index + 1) {
  11533. cell = this.$cells.pop();
  11534. this.element.removeChild(cell.element);
  11535. }
  11536. break;
  11537. }
  11538. cell = this.$cells[++index];
  11539. if (!cell) {
  11540. cell = {element: null, textNode: null, foldWidget: null};
  11541. cell.element = dom.createElement("div");
  11542. cell.textNode = document.createTextNode('');
  11543. cell.element.appendChild(cell.textNode);
  11544. this.element.appendChild(cell.element);
  11545. this.$cells[index] = cell;
  11546. }
  11547. var className = "ace_gutter-cell ";
  11548. if (breakpoints[row])
  11549. className += breakpoints[row];
  11550. if (decorations[row])
  11551. className += decorations[row];
  11552. if (this.$annotations[row])
  11553. className += this.$annotations[row].className;
  11554. if (cell.element.className != className)
  11555. cell.element.className = className;
  11556. var height = session.getRowLength(row) * config.lineHeight + "px";
  11557. if (height != cell.element.style.height)
  11558. cell.element.style.height = height;
  11559. if (foldWidgets) {
  11560. var c = foldWidgets[row];
  11561. if (c == null)
  11562. c = foldWidgets[row] = session.getFoldWidget(row);
  11563. }
  11564. if (c) {
  11565. if (!cell.foldWidget) {
  11566. cell.foldWidget = dom.createElement("span");
  11567. cell.element.appendChild(cell.foldWidget);
  11568. }
  11569. var className = "ace_fold-widget ace_" + c;
  11570. if (c == "start" && row == foldStart && row < fold.end.row)
  11571. className += " ace_closed";
  11572. else
  11573. className += " ace_open";
  11574. if (cell.foldWidget.className != className)
  11575. cell.foldWidget.className = className;
  11576. var height = config.lineHeight + "px";
  11577. if (cell.foldWidget.style.height != height)
  11578. cell.foldWidget.style.height = height;
  11579. } else {
  11580. if (cell.foldWidget) {
  11581. cell.element.removeChild(cell.foldWidget);
  11582. cell.foldWidget = null;
  11583. }
  11584. }
  11585. var text = lastLineNumber = gutterRenderer
  11586. ? gutterRenderer.getText(session, row)
  11587. : row + firstLineNumber;
  11588. if (text != cell.textNode.data)
  11589. cell.textNode.data = text;
  11590. row++;
  11591. }
  11592. this.element.style.height = config.minHeight + "px";
  11593. if (this.$fixedWidth || session.$useWrapMode)
  11594. lastLineNumber = session.getLength() + firstLineNumber;
  11595. var gutterWidth = gutterRenderer
  11596. ? gutterRenderer.getWidth(session, lastLineNumber, config)
  11597. : lastLineNumber.toString().length * config.characterWidth;
  11598. var padding = this.$padding || this.$computePadding();
  11599. gutterWidth += padding.left + padding.right;
  11600. if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
  11601. this.gutterWidth = gutterWidth;
  11602. this.element.style.width = Math.ceil(this.gutterWidth) + "px";
  11603. this._emit("changeGutterWidth", gutterWidth);
  11604. }
  11605. };
  11606. this.$fixedWidth = false;
  11607. this.$showLineNumbers = true;
  11608. this.$renderer = "";
  11609. this.setShowLineNumbers = function(show) {
  11610. this.$renderer = !show && {
  11611. getWidth: function() {return ""},
  11612. getText: function() {return ""}
  11613. };
  11614. };
  11615. this.getShowLineNumbers = function() {
  11616. return this.$showLineNumbers;
  11617. };
  11618. this.$showFoldWidgets = true;
  11619. this.setShowFoldWidgets = function(show) {
  11620. if (show)
  11621. dom.addCssClass(this.element, "ace_folding-enabled");
  11622. else
  11623. dom.removeCssClass(this.element, "ace_folding-enabled");
  11624. this.$showFoldWidgets = show;
  11625. this.$padding = null;
  11626. };
  11627. this.getShowFoldWidgets = function() {
  11628. return this.$showFoldWidgets;
  11629. };
  11630. this.$computePadding = function() {
  11631. if (!this.element.firstChild)
  11632. return {left: 0, right: 0};
  11633. var style = dom.computedStyle(this.element.firstChild);
  11634. this.$padding = {};
  11635. this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
  11636. this.$padding.right = parseInt(style.paddingRight) || 0;
  11637. return this.$padding;
  11638. };
  11639. this.getRegion = function(point) {
  11640. var padding = this.$padding || this.$computePadding();
  11641. var rect = this.element.getBoundingClientRect();
  11642. if (point.x < padding.left + rect.left)
  11643. return "markers";
  11644. if (this.$showFoldWidgets && point.x > rect.right - padding.right)
  11645. return "foldWidgets";
  11646. };
  11647. }).call(Gutter.prototype);
  11648. exports.Gutter = Gutter;
  11649. });
  11650. ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
  11651. "use strict";
  11652. var Range = require("../range").Range;
  11653. var dom = require("../lib/dom");
  11654. var Marker = function(parentEl) {
  11655. this.element = dom.createElement("div");
  11656. this.element.className = "ace_layer ace_marker-layer";
  11657. parentEl.appendChild(this.element);
  11658. };
  11659. (function() {
  11660. this.$padding = 0;
  11661. this.setPadding = function(padding) {
  11662. this.$padding = padding;
  11663. };
  11664. this.setSession = function(session) {
  11665. this.session = session;
  11666. };
  11667. this.setMarkers = function(markers) {
  11668. this.markers = markers;
  11669. };
  11670. this.update = function(config) {
  11671. var config = config || this.config;
  11672. if (!config)
  11673. return;
  11674. this.config = config;
  11675. var html = [];
  11676. for (var key in this.markers) {
  11677. var marker = this.markers[key];
  11678. if (!marker.range) {
  11679. marker.update(html, this, this.session, config);
  11680. continue;
  11681. }
  11682. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  11683. if (range.isEmpty()) continue;
  11684. range = range.toScreenRange(this.session);
  11685. if (marker.renderer) {
  11686. var top = this.$getTop(range.start.row, config);
  11687. var left = this.$padding + range.start.column * config.characterWidth;
  11688. marker.renderer(html, range, left, top, config);
  11689. } else if (marker.type == "fullLine") {
  11690. this.drawFullLineMarker(html, range, marker.clazz, config);
  11691. } else if (marker.type == "screenLine") {
  11692. this.drawScreenLineMarker(html, range, marker.clazz, config);
  11693. } else if (range.isMultiLine()) {
  11694. if (marker.type == "text")
  11695. this.drawTextMarker(html, range, marker.clazz, config);
  11696. else
  11697. this.drawMultiLineMarker(html, range, marker.clazz, config);
  11698. } else {
  11699. this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
  11700. }
  11701. }
  11702. this.element.innerHTML = html.join("");
  11703. };
  11704. this.$getTop = function(row, layerConfig) {
  11705. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  11706. };
  11707. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
  11708. var row = range.start.row;
  11709. var lineRange = new Range(
  11710. row, range.start.column,
  11711. row, this.session.getScreenLastRowColumn(row)
  11712. );
  11713. this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, extraStyle);
  11714. row = range.end.row;
  11715. lineRange = new Range(row, 0, row, range.end.column);
  11716. this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, extraStyle);
  11717. for (row = range.start.row + 1; row < range.end.row; row++) {
  11718. lineRange.start.row = row;
  11719. lineRange.end.row = row;
  11720. lineRange.end.column = this.session.getScreenLastRowColumn(row);
  11721. this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, extraStyle);
  11722. }
  11723. };
  11724. this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11725. var padding = this.$padding;
  11726. var height = config.lineHeight;
  11727. var top = this.$getTop(range.start.row, config);
  11728. var left = padding + range.start.column * config.characterWidth;
  11729. extraStyle = extraStyle || "";
  11730. stringBuilder.push(
  11731. "<div class='", clazz, " ace_start' style='",
  11732. "height:", height, "px;",
  11733. "right:0;",
  11734. "top:", top, "px;",
  11735. "left:", left, "px;", extraStyle, "'></div>"
  11736. );
  11737. top = this.$getTop(range.end.row, config);
  11738. var width = range.end.column * config.characterWidth;
  11739. stringBuilder.push(
  11740. "<div class='", clazz, "' style='",
  11741. "height:", height, "px;",
  11742. "width:", width, "px;",
  11743. "top:", top, "px;",
  11744. "left:", padding, "px;", extraStyle, "'></div>"
  11745. );
  11746. height = (range.end.row - range.start.row - 1) * config.lineHeight;
  11747. if (height < 0)
  11748. return;
  11749. top = this.$getTop(range.start.row + 1, config);
  11750. stringBuilder.push(
  11751. "<div class='", clazz, "' style='",
  11752. "height:", height, "px;",
  11753. "right:0;",
  11754. "top:", top, "px;",
  11755. "left:", padding, "px;", extraStyle, "'></div>"
  11756. );
  11757. };
  11758. this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  11759. var height = config.lineHeight;
  11760. var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
  11761. var top = this.$getTop(range.start.row, config);
  11762. var left = this.$padding + range.start.column * config.characterWidth;
  11763. stringBuilder.push(
  11764. "<div class='", clazz, "' style='",
  11765. "height:", height, "px;",
  11766. "width:", width, "px;",
  11767. "top:", top, "px;",
  11768. "left:", left, "px;", extraStyle || "", "'></div>"
  11769. );
  11770. };
  11771. this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11772. var top = this.$getTop(range.start.row, config);
  11773. var height = config.lineHeight;
  11774. if (range.start.row != range.end.row)
  11775. height += this.$getTop(range.end.row, config) - top;
  11776. stringBuilder.push(
  11777. "<div class='", clazz, "' style='",
  11778. "height:", height, "px;",
  11779. "top:", top, "px;",
  11780. "left:0;right:0;", extraStyle || "", "'></div>"
  11781. );
  11782. };
  11783. this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11784. var top = this.$getTop(range.start.row, config);
  11785. var height = config.lineHeight;
  11786. stringBuilder.push(
  11787. "<div class='", clazz, "' style='",
  11788. "height:", height, "px;",
  11789. "top:", top, "px;",
  11790. "left:0;right:0;", extraStyle || "", "'></div>"
  11791. );
  11792. };
  11793. }).call(Marker.prototype);
  11794. exports.Marker = Marker;
  11795. });
  11796. ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module) {
  11797. "use strict";
  11798. var oop = require("../lib/oop");
  11799. var dom = require("../lib/dom");
  11800. var lang = require("../lib/lang");
  11801. var useragent = require("../lib/useragent");
  11802. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11803. var Text = function(parentEl) {
  11804. this.element = dom.createElement("div");
  11805. this.element.className = "ace_layer ace_text-layer";
  11806. parentEl.appendChild(this.element);
  11807. this.$updateEolChar = this.$updateEolChar.bind(this);
  11808. };
  11809. (function() {
  11810. oop.implement(this, EventEmitter);
  11811. this.EOF_CHAR = "\xB6";
  11812. this.EOL_CHAR_LF = "\xAC";
  11813. this.EOL_CHAR_CRLF = "\xa4";
  11814. this.EOL_CHAR = this.EOL_CHAR_LF;
  11815. this.TAB_CHAR = "\u2192"; //"\u21E5";
  11816. this.SPACE_CHAR = "\xB7";
  11817. this.$padding = 0;
  11818. this.$updateEolChar = function() {
  11819. var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
  11820. ? this.EOL_CHAR_LF
  11821. : this.EOL_CHAR_CRLF;
  11822. if (this.EOL_CHAR != EOL_CHAR) {
  11823. this.EOL_CHAR = EOL_CHAR;
  11824. return true;
  11825. }
  11826. }
  11827. this.setPadding = function(padding) {
  11828. this.$padding = padding;
  11829. this.element.style.padding = "0 " + padding + "px";
  11830. };
  11831. this.getLineHeight = function() {
  11832. return this.$fontMetrics.$characterSize.height || 0;
  11833. };
  11834. this.getCharacterWidth = function() {
  11835. return this.$fontMetrics.$characterSize.width || 0;
  11836. };
  11837. this.$setFontMetrics = function(measure) {
  11838. this.$fontMetrics = measure;
  11839. this.$fontMetrics.on("changeCharacterSize", function(e) {
  11840. this._signal("changeCharacterSize", e);
  11841. }.bind(this));
  11842. this.$pollSizeChanges();
  11843. }
  11844. this.checkForSizeChanges = function() {
  11845. this.$fontMetrics.checkForSizeChanges();
  11846. };
  11847. this.$pollSizeChanges = function() {
  11848. return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
  11849. };
  11850. this.setSession = function(session) {
  11851. this.session = session;
  11852. if (session)
  11853. this.$computeTabString();
  11854. };
  11855. this.showInvisibles = false;
  11856. this.setShowInvisibles = function(showInvisibles) {
  11857. if (this.showInvisibles == showInvisibles)
  11858. return false;
  11859. this.showInvisibles = showInvisibles;
  11860. this.$computeTabString();
  11861. return true;
  11862. };
  11863. this.displayIndentGuides = true;
  11864. this.setDisplayIndentGuides = function(display) {
  11865. if (this.displayIndentGuides == display)
  11866. return false;
  11867. this.displayIndentGuides = display;
  11868. this.$computeTabString();
  11869. return true;
  11870. };
  11871. this.$tabStrings = [];
  11872. this.onChangeTabSize =
  11873. this.$computeTabString = function() {
  11874. var tabSize = this.session.getTabSize();
  11875. this.tabSize = tabSize;
  11876. var tabStr = this.$tabStrings = [0];
  11877. for (var i = 1; i < tabSize + 1; i++) {
  11878. if (this.showInvisibles) {
  11879. tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
  11880. + this.TAB_CHAR
  11881. + lang.stringRepeat("\xa0", i - 1)
  11882. + "</span>");
  11883. } else {
  11884. tabStr.push(lang.stringRepeat("\xa0", i));
  11885. }
  11886. }
  11887. if (this.displayIndentGuides) {
  11888. this.$indentGuideRe = /\s\S| \t|\t |\s$/;
  11889. var className = "ace_indent-guide";
  11890. var spaceClass = "";
  11891. var tabClass = "";
  11892. if (this.showInvisibles) {
  11893. className += " ace_invisible";
  11894. spaceClass = " ace_invisible_space";
  11895. tabClass = " ace_invisible_tab";
  11896. var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
  11897. var tabContent = this.TAB_CHAR + lang.stringRepeat("\xa0", this.tabSize - 1);
  11898. } else{
  11899. var spaceContent = lang.stringRepeat("\xa0", this.tabSize);
  11900. var tabContent = spaceContent;
  11901. }
  11902. this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
  11903. this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
  11904. }
  11905. };
  11906. this.updateLines = function(config, firstRow, lastRow) {
  11907. if (this.config.lastRow != config.lastRow ||
  11908. this.config.firstRow != config.firstRow) {
  11909. this.scrollLines(config);
  11910. }
  11911. this.config = config;
  11912. var first = Math.max(firstRow, config.firstRow);
  11913. var last = Math.min(lastRow, config.lastRow);
  11914. var lineElements = this.element.childNodes;
  11915. var lineElementsIdx = 0;
  11916. for (var row = config.firstRow; row < first; row++) {
  11917. var foldLine = this.session.getFoldLine(row);
  11918. if (foldLine) {
  11919. if (foldLine.containsRow(first)) {
  11920. first = foldLine.start.row;
  11921. break;
  11922. } else {
  11923. row = foldLine.end.row;
  11924. }
  11925. }
  11926. lineElementsIdx ++;
  11927. }
  11928. var row = first;
  11929. var foldLine = this.session.getNextFoldLine(row);
  11930. var foldStart = foldLine ? foldLine.start.row : Infinity;
  11931. while (true) {
  11932. if (row > foldStart) {
  11933. row = foldLine.end.row+1;
  11934. foldLine = this.session.getNextFoldLine(row, foldLine);
  11935. foldStart = foldLine ? foldLine.start.row :Infinity;
  11936. }
  11937. if (row > last)
  11938. break;
  11939. var lineElement = lineElements[lineElementsIdx++];
  11940. if (lineElement) {
  11941. var html = [];
  11942. this.$renderLine(
  11943. html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
  11944. );
  11945. lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  11946. lineElement.innerHTML = html.join("");
  11947. }
  11948. row++;
  11949. }
  11950. };
  11951. this.scrollLines = function(config) {
  11952. var oldConfig = this.config;
  11953. this.config = config;
  11954. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  11955. return this.update(config);
  11956. if (config.lastRow < oldConfig.firstRow)
  11957. return this.update(config);
  11958. var el = this.element;
  11959. if (oldConfig.firstRow < config.firstRow)
  11960. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  11961. el.removeChild(el.firstChild);
  11962. if (oldConfig.lastRow > config.lastRow)
  11963. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  11964. el.removeChild(el.lastChild);
  11965. if (config.firstRow < oldConfig.firstRow) {
  11966. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  11967. if (el.firstChild)
  11968. el.insertBefore(fragment, el.firstChild);
  11969. else
  11970. el.appendChild(fragment);
  11971. }
  11972. if (config.lastRow > oldConfig.lastRow) {
  11973. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  11974. el.appendChild(fragment);
  11975. }
  11976. };
  11977. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  11978. var fragment = this.element.ownerDocument.createDocumentFragment();
  11979. var row = firstRow;
  11980. var foldLine = this.session.getNextFoldLine(row);
  11981. var foldStart = foldLine ? foldLine.start.row : Infinity;
  11982. while (true) {
  11983. if (row > foldStart) {
  11984. row = foldLine.end.row+1;
  11985. foldLine = this.session.getNextFoldLine(row, foldLine);
  11986. foldStart = foldLine ? foldLine.start.row : Infinity;
  11987. }
  11988. if (row > lastRow)
  11989. break;
  11990. var container = dom.createElement("div");
  11991. var html = [];
  11992. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  11993. container.innerHTML = html.join("");
  11994. if (this.$useLineGroups()) {
  11995. container.className = 'ace_line_group';
  11996. fragment.appendChild(container);
  11997. container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  11998. } else {
  11999. while(container.firstChild)
  12000. fragment.appendChild(container.firstChild);
  12001. }
  12002. row++;
  12003. }
  12004. return fragment;
  12005. };
  12006. this.update = function(config) {
  12007. this.config = config;
  12008. var html = [];
  12009. var firstRow = config.firstRow, lastRow = config.lastRow;
  12010. var row = firstRow;
  12011. var foldLine = this.session.getNextFoldLine(row);
  12012. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12013. while (true) {
  12014. if (row > foldStart) {
  12015. row = foldLine.end.row+1;
  12016. foldLine = this.session.getNextFoldLine(row, foldLine);
  12017. foldStart = foldLine ? foldLine.start.row :Infinity;
  12018. }
  12019. if (row > lastRow)
  12020. break;
  12021. if (this.$useLineGroups())
  12022. html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>")
  12023. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12024. if (this.$useLineGroups())
  12025. html.push("</div>"); // end the line group
  12026. row++;
  12027. }
  12028. this.element.innerHTML = html.join("");
  12029. };
  12030. this.$textToken = {
  12031. "text": true,
  12032. "rparen": true,
  12033. "lparen": true
  12034. };
  12035. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  12036. var self = this;
  12037. var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
  12038. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  12039. if (a) {
  12040. return self.showInvisibles ?
  12041. "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>" :
  12042. lang.stringRepeat("\xa0", c.length);
  12043. } else if (c == "&") {
  12044. return "&#38;";
  12045. } else if (c == "<") {
  12046. return "&#60;";
  12047. } else if (c == "\t") {
  12048. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  12049. screenColumn += tabSize - 1;
  12050. return self.$tabStrings[tabSize];
  12051. } else if (c == "\u3000") {
  12052. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
  12053. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  12054. screenColumn += 1;
  12055. return "<span class='" + classToUse + "' style='width:" +
  12056. (self.config.characterWidth * 2) +
  12057. "px'>" + space + "</span>";
  12058. } else if (b) {
  12059. return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
  12060. } else {
  12061. screenColumn += 1;
  12062. return "<span class='ace_cjk' style='width:" +
  12063. (self.config.characterWidth * 2) +
  12064. "px'>" + c + "</span>";
  12065. }
  12066. };
  12067. var output = value.replace(replaceReg, replaceFunc);
  12068. if (!this.$textToken[token.type]) {
  12069. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  12070. var style = "";
  12071. if (token.type == "fold")
  12072. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  12073. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  12074. }
  12075. else {
  12076. stringBuilder.push(output);
  12077. }
  12078. return screenColumn + value.length;
  12079. };
  12080. this.renderIndentGuide = function(stringBuilder, value, max) {
  12081. var cols = value.search(this.$indentGuideRe);
  12082. if (cols <= 0 || cols >= max)
  12083. return value;
  12084. if (value[0] == " ") {
  12085. cols -= cols % this.tabSize;
  12086. stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
  12087. return value.substr(cols);
  12088. } else if (value[0] == "\t") {
  12089. stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
  12090. return value.substr(cols);
  12091. }
  12092. return value;
  12093. };
  12094. this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
  12095. var chars = 0;
  12096. var split = 0;
  12097. var splitChars = splits[0];
  12098. var screenColumn = 0;
  12099. for (var i = 0; i < tokens.length; i++) {
  12100. var token = tokens[i];
  12101. var value = token.value;
  12102. if (i == 0 && this.displayIndentGuides) {
  12103. chars = value.length;
  12104. value = this.renderIndentGuide(stringBuilder, value, splitChars);
  12105. if (!value)
  12106. continue;
  12107. chars -= value.length;
  12108. }
  12109. if (chars + value.length < splitChars) {
  12110. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12111. chars += value.length;
  12112. } else {
  12113. while (chars + value.length >= splitChars) {
  12114. screenColumn = this.$renderToken(
  12115. stringBuilder, screenColumn,
  12116. token, value.substring(0, splitChars - chars)
  12117. );
  12118. value = value.substring(splitChars - chars);
  12119. chars = splitChars;
  12120. if (!onlyContents) {
  12121. stringBuilder.push("</div>",
  12122. "<div class='ace_line' style='height:",
  12123. this.config.lineHeight, "px'>"
  12124. );
  12125. }
  12126. split ++;
  12127. screenColumn = 0;
  12128. splitChars = splits[split] || Number.MAX_VALUE;
  12129. }
  12130. if (value.length != 0) {
  12131. chars += value.length;
  12132. screenColumn = this.$renderToken(
  12133. stringBuilder, screenColumn, token, value
  12134. );
  12135. }
  12136. }
  12137. }
  12138. };
  12139. this.$renderSimpleLine = function(stringBuilder, tokens) {
  12140. var screenColumn = 0;
  12141. var token = tokens[0];
  12142. var value = token.value;
  12143. if (this.displayIndentGuides)
  12144. value = this.renderIndentGuide(stringBuilder, value);
  12145. if (value)
  12146. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12147. for (var i = 1; i < tokens.length; i++) {
  12148. token = tokens[i];
  12149. value = token.value;
  12150. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12151. }
  12152. };
  12153. this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
  12154. if (!foldLine && foldLine != false)
  12155. foldLine = this.session.getFoldLine(row);
  12156. if (foldLine)
  12157. var tokens = this.$getFoldLineTokens(row, foldLine);
  12158. else
  12159. var tokens = this.session.getTokens(row);
  12160. if (!onlyContents) {
  12161. stringBuilder.push(
  12162. "<div class='ace_line' style='height:",
  12163. this.config.lineHeight * (
  12164. this.$useLineGroups() ? 1 :this.session.getRowLength(row)
  12165. ), "px'>"
  12166. );
  12167. }
  12168. if (tokens.length) {
  12169. var splits = this.session.getRowSplitData(row);
  12170. if (splits && splits.length)
  12171. this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
  12172. else
  12173. this.$renderSimpleLine(stringBuilder, tokens);
  12174. }
  12175. if (this.showInvisibles) {
  12176. if (foldLine)
  12177. row = foldLine.end.row
  12178. stringBuilder.push(
  12179. "<span class='ace_invisible ace_invisible_eol'>",
  12180. row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
  12181. "</span>"
  12182. );
  12183. }
  12184. if (!onlyContents)
  12185. stringBuilder.push("</div>");
  12186. };
  12187. this.$getFoldLineTokens = function(row, foldLine) {
  12188. var session = this.session;
  12189. var renderTokens = [];
  12190. function addTokens(tokens, from, to) {
  12191. var idx = 0, col = 0;
  12192. while ((col + tokens[idx].value.length) < from) {
  12193. col += tokens[idx].value.length;
  12194. idx++;
  12195. if (idx == tokens.length)
  12196. return;
  12197. }
  12198. if (col != from) {
  12199. var value = tokens[idx].value.substring(from - col);
  12200. if (value.length > (to - from))
  12201. value = value.substring(0, to - from);
  12202. renderTokens.push({
  12203. type: tokens[idx].type,
  12204. value: value
  12205. });
  12206. col = from + value.length;
  12207. idx += 1;
  12208. }
  12209. while (col < to && idx < tokens.length) {
  12210. var value = tokens[idx].value;
  12211. if (value.length + col > to) {
  12212. renderTokens.push({
  12213. type: tokens[idx].type,
  12214. value: value.substring(0, to - col)
  12215. });
  12216. } else
  12217. renderTokens.push(tokens[idx]);
  12218. col += value.length;
  12219. idx += 1;
  12220. }
  12221. }
  12222. var tokens = session.getTokens(row);
  12223. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  12224. if (placeholder != null) {
  12225. renderTokens.push({
  12226. type: "fold",
  12227. value: placeholder
  12228. });
  12229. } else {
  12230. if (isNewRow)
  12231. tokens = session.getTokens(row);
  12232. if (tokens.length)
  12233. addTokens(tokens, lastColumn, column);
  12234. }
  12235. }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  12236. return renderTokens;
  12237. };
  12238. this.$useLineGroups = function() {
  12239. return this.session.getUseWrapMode();
  12240. };
  12241. this.destroy = function() {
  12242. clearInterval(this.$pollSizeChangesTimer);
  12243. if (this.$measureNode)
  12244. this.$measureNode.parentNode.removeChild(this.$measureNode);
  12245. delete this.$measureNode;
  12246. };
  12247. }).call(Text.prototype);
  12248. exports.Text = Text;
  12249. });
  12250. ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  12251. "use strict";
  12252. var dom = require("../lib/dom");
  12253. var IE8;
  12254. var Cursor = function(parentEl) {
  12255. this.element = dom.createElement("div");
  12256. this.element.className = "ace_layer ace_cursor-layer";
  12257. parentEl.appendChild(this.element);
  12258. if (IE8 === undefined)
  12259. IE8 = "opacity" in this.element;
  12260. this.isVisible = false;
  12261. this.isBlinking = true;
  12262. this.blinkInterval = 1000;
  12263. this.smoothBlinking = false;
  12264. this.cursors = [];
  12265. this.cursor = this.addCursor();
  12266. dom.addCssClass(this.element, "ace_hidden-cursors");
  12267. this.$updateCursors = this.$updateVisibility.bind(this);
  12268. };
  12269. (function() {
  12270. this.$updateVisibility = function(val) {
  12271. var cursors = this.cursors;
  12272. for (var i = cursors.length; i--; )
  12273. cursors[i].style.visibility = val ? "" : "hidden";
  12274. };
  12275. this.$updateOpacity = function(val) {
  12276. var cursors = this.cursors;
  12277. for (var i = cursors.length; i--; )
  12278. cursors[i].style.opacity = val ? "" : "0";
  12279. };
  12280. this.$padding = 0;
  12281. this.setPadding = function(padding) {
  12282. this.$padding = padding;
  12283. };
  12284. this.setSession = function(session) {
  12285. this.session = session;
  12286. };
  12287. this.setBlinking = function(blinking) {
  12288. if (blinking != this.isBlinking){
  12289. this.isBlinking = blinking;
  12290. this.restartTimer();
  12291. }
  12292. };
  12293. this.setBlinkInterval = function(blinkInterval) {
  12294. if (blinkInterval != this.blinkInterval){
  12295. this.blinkInterval = blinkInterval;
  12296. this.restartTimer();
  12297. }
  12298. };
  12299. this.setSmoothBlinking = function(smoothBlinking) {
  12300. if (smoothBlinking != this.smoothBlinking && !IE8) {
  12301. this.smoothBlinking = smoothBlinking;
  12302. dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
  12303. this.$updateCursors(true);
  12304. this.$updateCursors = (smoothBlinking
  12305. ? this.$updateOpacity
  12306. : this.$updateVisibility).bind(this);
  12307. this.restartTimer();
  12308. }
  12309. };
  12310. this.addCursor = function() {
  12311. var el = dom.createElement("div");
  12312. el.className = "ace_cursor";
  12313. this.element.appendChild(el);
  12314. this.cursors.push(el);
  12315. return el;
  12316. };
  12317. this.removeCursor = function() {
  12318. if (this.cursors.length > 1) {
  12319. var el = this.cursors.pop();
  12320. el.parentNode.removeChild(el);
  12321. return el;
  12322. }
  12323. };
  12324. this.hideCursor = function() {
  12325. this.isVisible = false;
  12326. dom.addCssClass(this.element, "ace_hidden-cursors");
  12327. this.restartTimer();
  12328. };
  12329. this.showCursor = function() {
  12330. this.isVisible = true;
  12331. dom.removeCssClass(this.element, "ace_hidden-cursors");
  12332. this.restartTimer();
  12333. };
  12334. this.restartTimer = function() {
  12335. var update = this.$updateCursors;
  12336. clearInterval(this.intervalId);
  12337. clearTimeout(this.timeoutId);
  12338. if (this.smoothBlinking) {
  12339. dom.removeCssClass(this.element, "ace_smooth-blinking");
  12340. }
  12341. update(true);
  12342. if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
  12343. return;
  12344. if (this.smoothBlinking) {
  12345. setTimeout(function(){
  12346. dom.addCssClass(this.element, "ace_smooth-blinking");
  12347. }.bind(this));
  12348. }
  12349. var blink = function(){
  12350. this.timeoutId = setTimeout(function() {
  12351. update(false);
  12352. }, 0.6 * this.blinkInterval);
  12353. }.bind(this);
  12354. this.intervalId = setInterval(function() {
  12355. update(true);
  12356. blink();
  12357. }, this.blinkInterval);
  12358. blink();
  12359. };
  12360. this.getPixelPosition = function(position, onScreen) {
  12361. if (!this.config || !this.session)
  12362. return {left : 0, top : 0};
  12363. if (!position)
  12364. position = this.session.selection.getCursor();
  12365. var pos = this.session.documentToScreenPosition(position);
  12366. var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
  12367. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  12368. this.config.lineHeight;
  12369. return {left : cursorLeft, top : cursorTop};
  12370. };
  12371. this.update = function(config) {
  12372. this.config = config;
  12373. var selections = this.session.$selectionMarkers;
  12374. var i = 0, cursorIndex = 0;
  12375. if (selections === undefined || selections.length === 0){
  12376. selections = [{cursor: null}];
  12377. }
  12378. for (var i = 0, n = selections.length; i < n; i++) {
  12379. var pixelPos = this.getPixelPosition(selections[i].cursor, true);
  12380. if ((pixelPos.top > config.height + config.offset ||
  12381. pixelPos.top < 0) && i > 1) {
  12382. continue;
  12383. }
  12384. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  12385. if (!this.drawCursor) {
  12386. style.left = pixelPos.left + "px";
  12387. style.top = pixelPos.top + "px";
  12388. style.width = config.characterWidth + "px";
  12389. style.height = config.lineHeight + "px";
  12390. } else {
  12391. this.drawCursor(style, pixelPos, config, selections[i], this.session);
  12392. }
  12393. }
  12394. while (this.cursors.length > cursorIndex)
  12395. this.removeCursor();
  12396. var overwrite = this.session.getOverwrite();
  12397. this.$setOverwrite(overwrite);
  12398. this.$pixelPos = pixelPos;
  12399. this.restartTimer();
  12400. };
  12401. this.drawCursor = null;
  12402. this.$setOverwrite = function(overwrite) {
  12403. if (overwrite != this.overwrite) {
  12404. this.overwrite = overwrite;
  12405. if (overwrite)
  12406. dom.addCssClass(this.element, "ace_overwrite-cursors");
  12407. else
  12408. dom.removeCssClass(this.element, "ace_overwrite-cursors");
  12409. }
  12410. };
  12411. this.destroy = function() {
  12412. clearInterval(this.intervalId);
  12413. clearTimeout(this.timeoutId);
  12414. };
  12415. }).call(Cursor.prototype);
  12416. exports.Cursor = Cursor;
  12417. });
  12418. ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
  12419. "use strict";
  12420. var oop = require("./lib/oop");
  12421. var dom = require("./lib/dom");
  12422. var event = require("./lib/event");
  12423. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12424. var ScrollBar = function(parent) {
  12425. this.element = dom.createElement("div");
  12426. this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
  12427. this.inner = dom.createElement("div");
  12428. this.inner.className = "ace_scrollbar-inner";
  12429. this.element.appendChild(this.inner);
  12430. parent.appendChild(this.element);
  12431. this.setVisible(false);
  12432. this.skipEvent = false;
  12433. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  12434. event.addListener(this.element, "mousedown", event.preventDefault);
  12435. };
  12436. (function() {
  12437. oop.implement(this, EventEmitter);
  12438. this.setVisible = function(isVisible) {
  12439. this.element.style.display = isVisible ? "" : "none";
  12440. this.isVisible = isVisible;
  12441. };
  12442. }).call(ScrollBar.prototype);
  12443. var VScrollBar = function(parent, renderer) {
  12444. ScrollBar.call(this, parent);
  12445. this.scrollTop = 0;
  12446. renderer.$scrollbarWidth =
  12447. this.width = dom.scrollbarWidth(parent.ownerDocument);
  12448. this.inner.style.width =
  12449. this.element.style.width = (this.width || 15) + 5 + "px";
  12450. };
  12451. oop.inherits(VScrollBar, ScrollBar);
  12452. (function() {
  12453. this.classSuffix = '-v';
  12454. this.onScroll = function() {
  12455. if (!this.skipEvent) {
  12456. this.scrollTop = this.element.scrollTop;
  12457. this._emit("scroll", {data: this.scrollTop});
  12458. }
  12459. this.skipEvent = false;
  12460. };
  12461. this.getWidth = function() {
  12462. return this.isVisible ? this.width : 0;
  12463. };
  12464. this.setHeight = function(height) {
  12465. this.element.style.height = height + "px";
  12466. };
  12467. this.setInnerHeight = function(height) {
  12468. this.inner.style.height = height + "px";
  12469. };
  12470. this.setScrollHeight = function(height) {
  12471. this.inner.style.height = height + "px";
  12472. };
  12473. this.setScrollTop = function(scrollTop) {
  12474. if (this.scrollTop != scrollTop) {
  12475. this.skipEvent = true;
  12476. this.scrollTop = this.element.scrollTop = scrollTop;
  12477. }
  12478. };
  12479. }).call(VScrollBar.prototype);
  12480. var HScrollBar = function(parent, renderer) {
  12481. ScrollBar.call(this, parent);
  12482. this.scrollLeft = 0;
  12483. this.height = renderer.$scrollbarWidth;
  12484. this.inner.style.height =
  12485. this.element.style.height = (this.height || 15) + 5 + "px";
  12486. };
  12487. oop.inherits(HScrollBar, ScrollBar);
  12488. (function() {
  12489. this.classSuffix = '-h';
  12490. this.onScroll = function() {
  12491. if (!this.skipEvent) {
  12492. this.scrollLeft = this.element.scrollLeft;
  12493. this._emit("scroll", {data: this.scrollLeft});
  12494. }
  12495. this.skipEvent = false;
  12496. };
  12497. this.getHeight = function() {
  12498. return this.isVisible ? this.height : 0;
  12499. };
  12500. this.setWidth = function(width) {
  12501. this.element.style.width = width + "px";
  12502. };
  12503. this.setInnerWidth = function(width) {
  12504. this.inner.style.width = width + "px";
  12505. };
  12506. this.setScrollWidth = function(width) {
  12507. this.inner.style.width = width + "px";
  12508. };
  12509. this.setScrollLeft = function(scrollLeft) {
  12510. if (this.scrollLeft != scrollLeft) {
  12511. this.skipEvent = true;
  12512. this.scrollLeft = this.element.scrollLeft = scrollLeft;
  12513. }
  12514. };
  12515. }).call(HScrollBar.prototype);
  12516. exports.ScrollBar = VScrollBar; // backward compatibility
  12517. exports.ScrollBarV = VScrollBar; // backward compatibility
  12518. exports.ScrollBarH = HScrollBar; // backward compatibility
  12519. exports.VScrollBar = VScrollBar;
  12520. exports.HScrollBar = HScrollBar;
  12521. });
  12522. ace.define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
  12523. "use strict";
  12524. var event = require("./lib/event");
  12525. var RenderLoop = function(onRender, win) {
  12526. this.onRender = onRender;
  12527. this.pending = false;
  12528. this.changes = 0;
  12529. this.window = win || window;
  12530. };
  12531. (function() {
  12532. this.schedule = function(change) {
  12533. this.changes = this.changes | change;
  12534. if (!this.pending && this.changes) {
  12535. this.pending = true;
  12536. var _self = this;
  12537. event.nextFrame(function() {
  12538. _self.pending = false;
  12539. var changes;
  12540. while (changes = _self.changes) {
  12541. _self.changes = 0;
  12542. _self.onRender(changes);
  12543. }
  12544. }, this.window);
  12545. }
  12546. };
  12547. }).call(RenderLoop.prototype);
  12548. exports.RenderLoop = RenderLoop;
  12549. });
  12550. ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module) {
  12551. var oop = require("../lib/oop");
  12552. var dom = require("../lib/dom");
  12553. var lang = require("../lib/lang");
  12554. var useragent = require("../lib/useragent");
  12555. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12556. var CHAR_COUNT = 0;
  12557. var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
  12558. this.el = dom.createElement("div");
  12559. this.$setMeasureNodeStyles(this.el.style, true);
  12560. this.$main = dom.createElement("div");
  12561. this.$setMeasureNodeStyles(this.$main.style);
  12562. this.$measureNode = dom.createElement("div");
  12563. this.$setMeasureNodeStyles(this.$measureNode.style);
  12564. this.el.appendChild(this.$main);
  12565. this.el.appendChild(this.$measureNode);
  12566. parentEl.appendChild(this.el);
  12567. if (!CHAR_COUNT)
  12568. this.$testFractionalRect();
  12569. this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
  12570. this.$characterSize = {width: 0, height: 0};
  12571. this.checkForSizeChanges();
  12572. };
  12573. (function() {
  12574. oop.implement(this, EventEmitter);
  12575. this.$characterSize = {width: 0, height: 0};
  12576. this.$testFractionalRect = function() {
  12577. var el = dom.createElement("div");
  12578. this.$setMeasureNodeStyles(el.style);
  12579. el.style.width = "0.2px";
  12580. document.documentElement.appendChild(el);
  12581. var w = el.getBoundingClientRect().width;
  12582. if (w > 0 && w < 1)
  12583. CHAR_COUNT = 50;
  12584. else
  12585. CHAR_COUNT = 100;
  12586. el.parentNode.removeChild(el);
  12587. };
  12588. this.$setMeasureNodeStyles = function(style, isRoot) {
  12589. style.width = style.height = "auto";
  12590. style.left = style.top = "0px";
  12591. style.visibility = "hidden";
  12592. style.position = "absolute";
  12593. style.whiteSpace = "pre";
  12594. if (useragent.isIE < 8) {
  12595. style["font-family"] = "inherit";
  12596. } else {
  12597. style.font = "inherit";
  12598. }
  12599. style.overflow = isRoot ? "hidden" : "visible";
  12600. };
  12601. this.checkForSizeChanges = function() {
  12602. var size = this.$measureSizes();
  12603. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  12604. this.$measureNode.style.fontWeight = "bold";
  12605. var boldSize = this.$measureSizes();
  12606. this.$measureNode.style.fontWeight = "";
  12607. this.$characterSize = size;
  12608. this.charSizes = Object.create(null);
  12609. this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
  12610. this._emit("changeCharacterSize", {data: size});
  12611. }
  12612. };
  12613. this.$pollSizeChanges = function() {
  12614. if (this.$pollSizeChangesTimer)
  12615. return this.$pollSizeChangesTimer;
  12616. var self = this;
  12617. return this.$pollSizeChangesTimer = setInterval(function() {
  12618. self.checkForSizeChanges();
  12619. }, 500);
  12620. };
  12621. this.setPolling = function(val) {
  12622. if (val) {
  12623. this.$pollSizeChanges();
  12624. } else {
  12625. if (this.$pollSizeChangesTimer)
  12626. this.$pollSizeChangesTimer;
  12627. }
  12628. };
  12629. this.$measureSizes = function() {
  12630. if (CHAR_COUNT === 50) {
  12631. var rect = null;
  12632. try {
  12633. rect = this.$measureNode.getBoundingClientRect();
  12634. } catch(e) {
  12635. rect = {width: 0, height:0 };
  12636. };
  12637. var size = {
  12638. height: rect.height,
  12639. width: rect.width / CHAR_COUNT
  12640. };
  12641. } else {
  12642. var size = {
  12643. height: this.$measureNode.clientHeight,
  12644. width: this.$measureNode.clientWidth / CHAR_COUNT
  12645. };
  12646. }
  12647. if (size.width === 0 || size.height === 0)
  12648. return null;
  12649. return size;
  12650. };
  12651. this.$measureCharWidth = function(ch) {
  12652. this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
  12653. var rect = this.$main.getBoundingClientRect();
  12654. return rect.width / CHAR_COUNT;
  12655. };
  12656. this.getCharacterWidth = function(ch) {
  12657. var w = this.charSizes[ch];
  12658. if (w === undefined) {
  12659. this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
  12660. }
  12661. return w;
  12662. };
  12663. this.destroy = function() {
  12664. clearInterval(this.$pollSizeChangesTimer);
  12665. if (this.el && this.el.parentNode)
  12666. this.el.parentNode.removeChild(this.el);
  12667. };
  12668. }).call(FontMetrics.prototype);
  12669. });
  12670. ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/lib/useragent","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter"], function(require, exports, module) {
  12671. "use strict";
  12672. var oop = require("./lib/oop");
  12673. var dom = require("./lib/dom");
  12674. var config = require("./config");
  12675. var useragent = require("./lib/useragent");
  12676. var GutterLayer = require("./layer/gutter").Gutter;
  12677. var MarkerLayer = require("./layer/marker").Marker;
  12678. var TextLayer = require("./layer/text").Text;
  12679. var CursorLayer = require("./layer/cursor").Cursor;
  12680. var HScrollBar = require("./scrollbar").HScrollBar;
  12681. var VScrollBar = require("./scrollbar").VScrollBar;
  12682. var RenderLoop = require("./renderloop").RenderLoop;
  12683. var FontMetrics = require("./layer/font_metrics").FontMetrics;
  12684. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12685. var editorCss = ".ace_editor {\
  12686. position: relative;\
  12687. overflow: hidden;\
  12688. font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
  12689. direction: ltr;\
  12690. }\
  12691. .ace_scroller {\
  12692. position: absolute;\
  12693. overflow: hidden;\
  12694. top: 0;\
  12695. bottom: 0;\
  12696. background-color: inherit;\
  12697. -ms-user-select: none;\
  12698. -moz-user-select: none;\
  12699. -webkit-user-select: none;\
  12700. user-select: none;\
  12701. cursor: text;\
  12702. }\
  12703. .ace_content {\
  12704. position: absolute;\
  12705. -moz-box-sizing: border-box;\
  12706. -webkit-box-sizing: border-box;\
  12707. box-sizing: border-box;\
  12708. min-width: 100%;\
  12709. }\
  12710. .ace_dragging .ace_scroller:before{\
  12711. position: absolute;\
  12712. top: 0;\
  12713. left: 0;\
  12714. right: 0;\
  12715. bottom: 0;\
  12716. content: '';\
  12717. background: rgba(250, 250, 250, 0.01);\
  12718. z-index: 1000;\
  12719. }\
  12720. .ace_dragging.ace_dark .ace_scroller:before{\
  12721. background: rgba(0, 0, 0, 0.01);\
  12722. }\
  12723. .ace_selecting, .ace_selecting * {\
  12724. cursor: text !important;\
  12725. }\
  12726. .ace_gutter {\
  12727. position: absolute;\
  12728. overflow : hidden;\
  12729. width: auto;\
  12730. top: 0;\
  12731. bottom: 0;\
  12732. left: 0;\
  12733. cursor: default;\
  12734. z-index: 4;\
  12735. -ms-user-select: none;\
  12736. -moz-user-select: none;\
  12737. -webkit-user-select: none;\
  12738. user-select: none;\
  12739. }\
  12740. .ace_gutter-active-line {\
  12741. position: absolute;\
  12742. left: 0;\
  12743. right: 0;\
  12744. }\
  12745. .ace_scroller.ace_scroll-left {\
  12746. box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
  12747. }\
  12748. .ace_gutter-cell {\
  12749. padding-left: 19px;\
  12750. padding-right: 6px;\
  12751. background-repeat: no-repeat;\
  12752. }\
  12753. .ace_gutter-cell.ace_error {\
  12754. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\
  12755. background-repeat: no-repeat;\
  12756. background-position: 2px center;\
  12757. }\
  12758. .ace_gutter-cell.ace_warning {\
  12759. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\
  12760. background-position: 2px center;\
  12761. }\
  12762. .ace_gutter-cell.ace_info {\
  12763. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
  12764. background-position: 2px center;\
  12765. }\
  12766. .ace_dark .ace_gutter-cell.ace_info {\
  12767. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
  12768. }\
  12769. .ace_scrollbar {\
  12770. position: absolute;\
  12771. right: 0;\
  12772. bottom: 0;\
  12773. z-index: 6;\
  12774. }\
  12775. .ace_scrollbar-inner {\
  12776. position: absolute;\
  12777. cursor: text;\
  12778. left: 0;\
  12779. top: 0;\
  12780. }\
  12781. .ace_scrollbar-v{\
  12782. overflow-x: hidden;\
  12783. overflow-y: scroll;\
  12784. top: 0;\
  12785. }\
  12786. .ace_scrollbar-h {\
  12787. overflow-x: scroll;\
  12788. overflow-y: hidden;\
  12789. left: 0;\
  12790. }\
  12791. .ace_print-margin {\
  12792. position: absolute;\
  12793. height: 100%;\
  12794. }\
  12795. .ace_text-input {\
  12796. position: absolute;\
  12797. z-index: 0;\
  12798. width: 0.5em;\
  12799. height: 1em;\
  12800. opacity: 0;\
  12801. background: transparent;\
  12802. -moz-appearance: none;\
  12803. appearance: none;\
  12804. border: none;\
  12805. resize: none;\
  12806. outline: none;\
  12807. overflow: hidden;\
  12808. font: inherit;\
  12809. padding: 0 1px;\
  12810. margin: 0 -1px;\
  12811. text-indent: -1em;\
  12812. -ms-user-select: text;\
  12813. -moz-user-select: text;\
  12814. -webkit-user-select: text;\
  12815. user-select: text;\
  12816. }\
  12817. .ace_text-input.ace_composition {\
  12818. background: inherit;\
  12819. color: inherit;\
  12820. z-index: 1000;\
  12821. opacity: 1;\
  12822. text-indent: 0;\
  12823. }\
  12824. .ace_layer {\
  12825. z-index: 1;\
  12826. position: absolute;\
  12827. overflow: hidden;\
  12828. white-space: pre;\
  12829. height: 100%;\
  12830. width: 100%;\
  12831. -moz-box-sizing: border-box;\
  12832. -webkit-box-sizing: border-box;\
  12833. box-sizing: border-box;\
  12834. pointer-events: none;\
  12835. }\
  12836. .ace_gutter-layer {\
  12837. position: relative;\
  12838. width: auto;\
  12839. text-align: right;\
  12840. pointer-events: auto;\
  12841. }\
  12842. .ace_text-layer {\
  12843. font: inherit !important;\
  12844. }\
  12845. .ace_cjk {\
  12846. display: inline-block;\
  12847. text-align: center;\
  12848. }\
  12849. .ace_cursor-layer {\
  12850. z-index: 4;\
  12851. }\
  12852. .ace_cursor {\
  12853. z-index: 4;\
  12854. position: absolute;\
  12855. -moz-box-sizing: border-box;\
  12856. -webkit-box-sizing: border-box;\
  12857. box-sizing: border-box;\
  12858. border-left: 2px solid\
  12859. }\
  12860. .ace_slim-cursors .ace_cursor {\
  12861. border-left-width: 1px;\
  12862. }\
  12863. .ace_overwrite-cursors .ace_cursor {\
  12864. border-left-width: 0;\
  12865. border-bottom: 1px solid;\
  12866. }\
  12867. .ace_hidden-cursors .ace_cursor {\
  12868. opacity: 0.2;\
  12869. }\
  12870. .ace_smooth-blinking .ace_cursor {\
  12871. -webkit-transition: opacity 0.18s;\
  12872. transition: opacity 0.18s;\
  12873. }\
  12874. .ace_editor.ace_multiselect .ace_cursor {\
  12875. border-left-width: 1px;\
  12876. }\
  12877. .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
  12878. position: absolute;\
  12879. z-index: 3;\
  12880. }\
  12881. .ace_marker-layer .ace_selection {\
  12882. position: absolute;\
  12883. z-index: 5;\
  12884. }\
  12885. .ace_marker-layer .ace_bracket {\
  12886. position: absolute;\
  12887. z-index: 6;\
  12888. }\
  12889. .ace_marker-layer .ace_active-line {\
  12890. position: absolute;\
  12891. z-index: 2;\
  12892. }\
  12893. .ace_marker-layer .ace_selected-word {\
  12894. position: absolute;\
  12895. z-index: 4;\
  12896. -moz-box-sizing: border-box;\
  12897. -webkit-box-sizing: border-box;\
  12898. box-sizing: border-box;\
  12899. }\
  12900. .ace_line .ace_fold {\
  12901. -moz-box-sizing: border-box;\
  12902. -webkit-box-sizing: border-box;\
  12903. box-sizing: border-box;\
  12904. display: inline-block;\
  12905. height: 11px;\
  12906. margin-top: -2px;\
  12907. vertical-align: middle;\
  12908. background-image:\
  12909. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  12910. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
  12911. background-repeat: no-repeat, repeat-x;\
  12912. background-position: center center, top left;\
  12913. color: transparent;\
  12914. border: 1px solid black;\
  12915. border-radius: 2px;\
  12916. cursor: pointer;\
  12917. pointer-events: auto;\
  12918. }\
  12919. .ace_dark .ace_fold {\
  12920. }\
  12921. .ace_fold:hover{\
  12922. background-image:\
  12923. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  12924. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
  12925. }\
  12926. .ace_tooltip {\
  12927. background-color: #FFF;\
  12928. background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
  12929. background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
  12930. border: 1px solid gray;\
  12931. border-radius: 1px;\
  12932. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
  12933. color: black;\
  12934. max-width: 100%;\
  12935. padding: 3px 4px;\
  12936. position: fixed;\
  12937. z-index: 999999;\
  12938. -moz-box-sizing: border-box;\
  12939. -webkit-box-sizing: border-box;\
  12940. box-sizing: border-box;\
  12941. cursor: default;\
  12942. white-space: pre;\
  12943. word-wrap: break-word;\
  12944. line-height: normal;\
  12945. font-style: normal;\
  12946. font-weight: normal;\
  12947. letter-spacing: normal;\
  12948. pointer-events: none;\
  12949. }\
  12950. .ace_folding-enabled > .ace_gutter-cell {\
  12951. padding-right: 13px;\
  12952. }\
  12953. .ace_fold-widget {\
  12954. -moz-box-sizing: border-box;\
  12955. -webkit-box-sizing: border-box;\
  12956. box-sizing: border-box;\
  12957. margin: 0 -12px 0 1px;\
  12958. display: none;\
  12959. width: 11px;\
  12960. vertical-align: top;\
  12961. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
  12962. background-repeat: no-repeat;\
  12963. background-position: center;\
  12964. border-radius: 3px;\
  12965. border: 1px solid transparent;\
  12966. cursor: pointer;\
  12967. }\
  12968. .ace_folding-enabled .ace_fold-widget {\
  12969. display: inline-block; \
  12970. }\
  12971. .ace_fold-widget.ace_end {\
  12972. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
  12973. }\
  12974. .ace_fold-widget.ace_closed {\
  12975. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
  12976. }\
  12977. .ace_fold-widget:hover {\
  12978. border: 1px solid rgba(0, 0, 0, 0.3);\
  12979. background-color: rgba(255, 255, 255, 0.2);\
  12980. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
  12981. }\
  12982. .ace_fold-widget:active {\
  12983. border: 1px solid rgba(0, 0, 0, 0.4);\
  12984. background-color: rgba(0, 0, 0, 0.05);\
  12985. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
  12986. }\
  12987. .ace_dark .ace_fold-widget {\
  12988. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
  12989. }\
  12990. .ace_dark .ace_fold-widget.ace_end {\
  12991. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
  12992. }\
  12993. .ace_dark .ace_fold-widget.ace_closed {\
  12994. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
  12995. }\
  12996. .ace_dark .ace_fold-widget:hover {\
  12997. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  12998. background-color: rgba(255, 255, 255, 0.1);\
  12999. }\
  13000. .ace_dark .ace_fold-widget:active {\
  13001. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13002. }\
  13003. .ace_fold-widget.ace_invalid {\
  13004. background-color: #FFB4B4;\
  13005. border-color: #DE5555;\
  13006. }\
  13007. .ace_fade-fold-widgets .ace_fold-widget {\
  13008. -webkit-transition: opacity 0.4s ease 0.05s;\
  13009. transition: opacity 0.4s ease 0.05s;\
  13010. opacity: 0;\
  13011. }\
  13012. .ace_fade-fold-widgets:hover .ace_fold-widget {\
  13013. -webkit-transition: opacity 0.05s ease 0.05s;\
  13014. transition: opacity 0.05s ease 0.05s;\
  13015. opacity:1;\
  13016. }\
  13017. .ace_underline {\
  13018. text-decoration: underline;\
  13019. }\
  13020. .ace_bold {\
  13021. font-weight: bold;\
  13022. }\
  13023. .ace_nobold .ace_bold {\
  13024. font-weight: normal;\
  13025. }\
  13026. .ace_italic {\
  13027. font-style: italic;\
  13028. }\
  13029. .ace_error-marker {\
  13030. background-color: rgba(255, 0, 0,0.2);\
  13031. position: absolute;\
  13032. z-index: 9;\
  13033. }\
  13034. .ace_highlight-marker {\
  13035. background-color: rgba(255, 255, 0,0.2);\
  13036. position: absolute;\
  13037. z-index: 8;\
  13038. }\
  13039. ";
  13040. dom.importCssString(editorCss, "ace_editor");
  13041. var VirtualRenderer = function(container, theme) {
  13042. var _self = this;
  13043. this.container = container || dom.createElement("div");
  13044. this.$keepTextAreaAtCursor = !useragent.isOldIE;
  13045. dom.addCssClass(this.container, "ace_editor");
  13046. this.setTheme(theme);
  13047. this.$gutter = dom.createElement("div");
  13048. this.$gutter.className = "ace_gutter";
  13049. this.container.appendChild(this.$gutter);
  13050. this.scroller = dom.createElement("div");
  13051. this.scroller.className = "ace_scroller";
  13052. this.container.appendChild(this.scroller);
  13053. this.content = dom.createElement("div");
  13054. this.content.className = "ace_content";
  13055. this.scroller.appendChild(this.content);
  13056. this.$gutterLayer = new GutterLayer(this.$gutter);
  13057. this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
  13058. this.$markerBack = new MarkerLayer(this.content);
  13059. var textLayer = this.$textLayer = new TextLayer(this.content);
  13060. this.canvas = textLayer.element;
  13061. this.$markerFront = new MarkerLayer(this.content);
  13062. this.$cursorLayer = new CursorLayer(this.content);
  13063. this.$horizScroll = false;
  13064. this.$vScroll = false;
  13065. this.scrollBar =
  13066. this.scrollBarV = new VScrollBar(this.container, this);
  13067. this.scrollBarH = new HScrollBar(this.container, this);
  13068. this.scrollBarV.addEventListener("scroll", function(e) {
  13069. if (!_self.$scrollAnimation)
  13070. _self.session.setScrollTop(e.data - _self.scrollMargin.top);
  13071. });
  13072. this.scrollBarH.addEventListener("scroll", function(e) {
  13073. if (!_self.$scrollAnimation)
  13074. _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
  13075. });
  13076. this.scrollTop = 0;
  13077. this.scrollLeft = 0;
  13078. this.cursorPos = {
  13079. row : 0,
  13080. column : 0
  13081. };
  13082. this.$fontMetrics = new FontMetrics(this.container, 500);
  13083. this.$textLayer.$setFontMetrics(this.$fontMetrics);
  13084. this.$textLayer.addEventListener("changeCharacterSize", function(e) {
  13085. _self.updateCharacterSize();
  13086. _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
  13087. _self._signal("changeCharacterSize", e);
  13088. });
  13089. this.$size = {
  13090. width: 0,
  13091. height: 0,
  13092. scrollerHeight: 0,
  13093. scrollerWidth: 0,
  13094. $dirty: true
  13095. };
  13096. this.layerConfig = {
  13097. width : 1,
  13098. padding : 0,
  13099. firstRow : 0,
  13100. firstRowScreen: 0,
  13101. lastRow : 0,
  13102. lineHeight : 0,
  13103. characterWidth : 0,
  13104. minHeight : 1,
  13105. maxHeight : 1,
  13106. offset : 0,
  13107. height : 1,
  13108. gutterOffset: 1
  13109. };
  13110. this.scrollMargin = {
  13111. left: 0,
  13112. right: 0,
  13113. top: 0,
  13114. bottom: 0,
  13115. v: 0,
  13116. h: 0
  13117. };
  13118. this.$loop = new RenderLoop(
  13119. this.$renderChanges.bind(this),
  13120. this.container.ownerDocument.defaultView
  13121. );
  13122. this.$loop.schedule(this.CHANGE_FULL);
  13123. this.updateCharacterSize();
  13124. this.setPadding(4);
  13125. config.resetOptions(this);
  13126. config._emit("renderer", this);
  13127. };
  13128. (function() {
  13129. this.CHANGE_CURSOR = 1;
  13130. this.CHANGE_MARKER = 2;
  13131. this.CHANGE_GUTTER = 4;
  13132. this.CHANGE_SCROLL = 8;
  13133. this.CHANGE_LINES = 16;
  13134. this.CHANGE_TEXT = 32;
  13135. this.CHANGE_SIZE = 64;
  13136. this.CHANGE_MARKER_BACK = 128;
  13137. this.CHANGE_MARKER_FRONT = 256;
  13138. this.CHANGE_FULL = 512;
  13139. this.CHANGE_H_SCROLL = 1024;
  13140. oop.implement(this, EventEmitter);
  13141. this.updateCharacterSize = function() {
  13142. if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
  13143. this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
  13144. this.setStyle("ace_nobold", !this.$allowBoldFonts);
  13145. }
  13146. this.layerConfig.characterWidth =
  13147. this.characterWidth = this.$textLayer.getCharacterWidth();
  13148. this.layerConfig.lineHeight =
  13149. this.lineHeight = this.$textLayer.getLineHeight();
  13150. this.$updatePrintMargin();
  13151. };
  13152. this.setSession = function(session) {
  13153. if (this.session)
  13154. this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
  13155. this.session = session;
  13156. if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
  13157. session.setScrollTop(-this.scrollMargin.top);
  13158. this.$cursorLayer.setSession(session);
  13159. this.$markerBack.setSession(session);
  13160. this.$markerFront.setSession(session);
  13161. this.$gutterLayer.setSession(session);
  13162. this.$textLayer.setSession(session);
  13163. if (!session)
  13164. return;
  13165. this.$loop.schedule(this.CHANGE_FULL);
  13166. this.session.$setFontMetrics(this.$fontMetrics);
  13167. this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
  13168. this.onChangeNewLineMode()
  13169. this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
  13170. };
  13171. this.updateLines = function(firstRow, lastRow, force) {
  13172. if (lastRow === undefined)
  13173. lastRow = Infinity;
  13174. if (!this.$changedLines) {
  13175. this.$changedLines = {
  13176. firstRow: firstRow,
  13177. lastRow: lastRow
  13178. };
  13179. }
  13180. else {
  13181. if (this.$changedLines.firstRow > firstRow)
  13182. this.$changedLines.firstRow = firstRow;
  13183. if (this.$changedLines.lastRow < lastRow)
  13184. this.$changedLines.lastRow = lastRow;
  13185. }
  13186. if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
  13187. if (force)
  13188. this.$changedLines.lastRow = this.layerConfig.lastRow;
  13189. else
  13190. return;
  13191. }
  13192. if (this.$changedLines.firstRow > this.layerConfig.lastRow)
  13193. return;
  13194. this.$loop.schedule(this.CHANGE_LINES);
  13195. };
  13196. this.onChangeNewLineMode = function() {
  13197. this.$loop.schedule(this.CHANGE_TEXT);
  13198. this.$textLayer.$updateEolChar();
  13199. };
  13200. this.onChangeTabSize = function() {
  13201. this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
  13202. this.$textLayer.onChangeTabSize();
  13203. };
  13204. this.updateText = function() {
  13205. this.$loop.schedule(this.CHANGE_TEXT);
  13206. };
  13207. this.updateFull = function(force) {
  13208. if (force)
  13209. this.$renderChanges(this.CHANGE_FULL, true);
  13210. else
  13211. this.$loop.schedule(this.CHANGE_FULL);
  13212. };
  13213. this.updateFontSize = function() {
  13214. this.$textLayer.checkForSizeChanges();
  13215. };
  13216. this.$changes = 0;
  13217. this.$updateSizeAsync = function() {
  13218. if (this.$loop.pending)
  13219. this.$size.$dirty = true;
  13220. else
  13221. this.onResize();
  13222. };
  13223. this.onResize = function(force, gutterWidth, width, height) {
  13224. if (this.resizing > 2)
  13225. return;
  13226. else if (this.resizing > 0)
  13227. this.resizing++;
  13228. else
  13229. this.resizing = force ? 1 : 0;
  13230. var el = this.container;
  13231. if (!height)
  13232. height = el.clientHeight || el.scrollHeight;
  13233. if (!width)
  13234. width = el.clientWidth || el.scrollWidth;
  13235. var changes = this.$updateCachedSize(force, gutterWidth, width, height);
  13236. if (!this.$size.scrollerHeight || (!width && !height))
  13237. return this.resizing = 0;
  13238. if (force)
  13239. this.$gutterLayer.$padding = null;
  13240. if (force)
  13241. this.$renderChanges(changes | this.$changes, true);
  13242. else
  13243. this.$loop.schedule(changes | this.$changes);
  13244. if (this.resizing)
  13245. this.resizing = 0;
  13246. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  13247. };
  13248. this.$updateCachedSize = function(force, gutterWidth, width, height) {
  13249. height -= (this.$extraHeight || 0);
  13250. var changes = 0;
  13251. var size = this.$size;
  13252. var oldSize = {
  13253. width: size.width,
  13254. height: size.height,
  13255. scrollerHeight: size.scrollerHeight,
  13256. scrollerWidth: size.scrollerWidth
  13257. };
  13258. if (height && (force || size.height != height)) {
  13259. size.height = height;
  13260. changes |= this.CHANGE_SIZE;
  13261. size.scrollerHeight = size.height;
  13262. if (this.$horizScroll)
  13263. size.scrollerHeight -= this.scrollBarH.getHeight();
  13264. this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
  13265. changes = changes | this.CHANGE_SCROLL;
  13266. }
  13267. if (width && (force || size.width != width)) {
  13268. changes |= this.CHANGE_SIZE;
  13269. size.width = width;
  13270. if (gutterWidth == null)
  13271. gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13272. this.gutterWidth = gutterWidth;
  13273. this.scrollBarH.element.style.left =
  13274. this.scroller.style.left = gutterWidth + "px";
  13275. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
  13276. this.scrollBarH.element.style.right =
  13277. this.scroller.style.right = this.scrollBarV.getWidth() + "px";
  13278. this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
  13279. if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  13280. changes |= this.CHANGE_FULL;
  13281. }
  13282. size.$dirty = !width || !height;
  13283. if (changes)
  13284. this._signal("resize", oldSize);
  13285. return changes;
  13286. };
  13287. this.onGutterResize = function() {
  13288. var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13289. if (gutterWidth != this.gutterWidth)
  13290. this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
  13291. if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
  13292. this.$loop.schedule(this.CHANGE_FULL);
  13293. } else if (this.$size.$dirty) {
  13294. this.$loop.schedule(this.CHANGE_FULL);
  13295. } else {
  13296. this.$computeLayerConfig();
  13297. this.$loop.schedule(this.CHANGE_MARKER);
  13298. }
  13299. };
  13300. this.adjustWrapLimit = function() {
  13301. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  13302. var limit = Math.floor(availableWidth / this.characterWidth);
  13303. return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
  13304. };
  13305. this.setAnimatedScroll = function(shouldAnimate){
  13306. this.setOption("animatedScroll", shouldAnimate);
  13307. };
  13308. this.getAnimatedScroll = function() {
  13309. return this.$animatedScroll;
  13310. };
  13311. this.setShowInvisibles = function(showInvisibles) {
  13312. this.setOption("showInvisibles", showInvisibles);
  13313. };
  13314. this.getShowInvisibles = function() {
  13315. return this.getOption("showInvisibles");
  13316. };
  13317. this.getDisplayIndentGuides = function() {
  13318. return this.getOption("displayIndentGuides");
  13319. };
  13320. this.setDisplayIndentGuides = function(display) {
  13321. this.setOption("displayIndentGuides", display);
  13322. };
  13323. this.setShowPrintMargin = function(showPrintMargin) {
  13324. this.setOption("showPrintMargin", showPrintMargin);
  13325. };
  13326. this.getShowPrintMargin = function() {
  13327. return this.getOption("showPrintMargin");
  13328. };
  13329. this.setPrintMarginColumn = function(showPrintMargin) {
  13330. this.setOption("printMarginColumn", showPrintMargin);
  13331. };
  13332. this.getPrintMarginColumn = function() {
  13333. return this.getOption("printMarginColumn");
  13334. };
  13335. this.getShowGutter = function(){
  13336. return this.getOption("showGutter");
  13337. };
  13338. this.setShowGutter = function(show){
  13339. return this.setOption("showGutter", show);
  13340. };
  13341. this.getFadeFoldWidgets = function(){
  13342. return this.getOption("fadeFoldWidgets")
  13343. };
  13344. this.setFadeFoldWidgets = function(show) {
  13345. this.setOption("fadeFoldWidgets", show);
  13346. };
  13347. this.setHighlightGutterLine = function(shouldHighlight) {
  13348. this.setOption("highlightGutterLine", shouldHighlight);
  13349. };
  13350. this.getHighlightGutterLine = function() {
  13351. return this.getOption("highlightGutterLine");
  13352. };
  13353. this.$updateGutterLineHighlight = function() {
  13354. var pos = this.$cursorLayer.$pixelPos;
  13355. var height = this.layerConfig.lineHeight;
  13356. if (this.session.getUseWrapMode()) {
  13357. var cursor = this.session.selection.getCursor();
  13358. cursor.column = 0;
  13359. pos = this.$cursorLayer.getPixelPosition(cursor, true);
  13360. height *= this.session.getRowLength(cursor.row);
  13361. }
  13362. this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
  13363. this.$gutterLineHighlight.style.height = height + "px";
  13364. };
  13365. this.$updatePrintMargin = function() {
  13366. if (!this.$showPrintMargin && !this.$printMarginEl)
  13367. return;
  13368. if (!this.$printMarginEl) {
  13369. var containerEl = dom.createElement("div");
  13370. containerEl.className = "ace_layer ace_print-margin-layer";
  13371. this.$printMarginEl = dom.createElement("div");
  13372. this.$printMarginEl.className = "ace_print-margin";
  13373. containerEl.appendChild(this.$printMarginEl);
  13374. this.content.insertBefore(containerEl, this.content.firstChild);
  13375. }
  13376. var style = this.$printMarginEl.style;
  13377. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  13378. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  13379. if (this.session && this.session.$wrap == -1)
  13380. this.adjustWrapLimit();
  13381. };
  13382. this.getContainerElement = function() {
  13383. return this.container;
  13384. };
  13385. this.getMouseEventTarget = function() {
  13386. return this.content;
  13387. };
  13388. this.getTextAreaContainer = function() {
  13389. return this.container;
  13390. };
  13391. this.$moveTextAreaToCursor = function() {
  13392. if (!this.$keepTextAreaAtCursor)
  13393. return;
  13394. var config = this.layerConfig;
  13395. var posTop = this.$cursorLayer.$pixelPos.top;
  13396. var posLeft = this.$cursorLayer.$pixelPos.left;
  13397. posTop -= config.offset;
  13398. var style = this.textarea.style;
  13399. var h = this.lineHeight;
  13400. if (posTop < 0 || posTop > config.height - h) {
  13401. style.top = style.left = "0";
  13402. return;
  13403. }
  13404. var w = this.characterWidth;
  13405. if (this.$composition) {
  13406. var val = this.textarea.value.replace(/^\x01+/, "");
  13407. w *= (this.session.$getStringScreenWidth(val)[0]+2);
  13408. h += 2;
  13409. }
  13410. posLeft -= this.scrollLeft;
  13411. if (posLeft > this.$size.scrollerWidth - w)
  13412. posLeft = this.$size.scrollerWidth - w;
  13413. posLeft += this.gutterWidth;
  13414. style.height = h + "px";
  13415. style.width = w + "px";
  13416. style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
  13417. style.top = Math.min(posTop, this.$size.height - h) + "px";
  13418. };
  13419. this.getFirstVisibleRow = function() {
  13420. return this.layerConfig.firstRow;
  13421. };
  13422. this.getFirstFullyVisibleRow = function() {
  13423. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  13424. };
  13425. this.getLastFullyVisibleRow = function() {
  13426. var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
  13427. return this.layerConfig.firstRow - 1 + flint;
  13428. };
  13429. this.getLastVisibleRow = function() {
  13430. return this.layerConfig.lastRow;
  13431. };
  13432. this.$padding = null;
  13433. this.setPadding = function(padding) {
  13434. this.$padding = padding;
  13435. this.$textLayer.setPadding(padding);
  13436. this.$cursorLayer.setPadding(padding);
  13437. this.$markerFront.setPadding(padding);
  13438. this.$markerBack.setPadding(padding);
  13439. this.$loop.schedule(this.CHANGE_FULL);
  13440. this.$updatePrintMargin();
  13441. };
  13442. this.setScrollMargin = function(top, bottom, left, right) {
  13443. var sm = this.scrollMargin;
  13444. sm.top = top|0;
  13445. sm.bottom = bottom|0;
  13446. sm.right = right|0;
  13447. sm.left = left|0;
  13448. sm.v = sm.top + sm.bottom;
  13449. sm.h = sm.left + sm.right;
  13450. if (sm.top && this.scrollTop <= 0 && this.session)
  13451. this.session.setScrollTop(-sm.top);
  13452. this.updateFull();
  13453. };
  13454. this.getHScrollBarAlwaysVisible = function() {
  13455. return this.$hScrollBarAlwaysVisible;
  13456. };
  13457. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  13458. this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
  13459. };
  13460. this.getVScrollBarAlwaysVisible = function() {
  13461. return this.$hScrollBarAlwaysVisible;
  13462. };
  13463. this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
  13464. this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
  13465. };
  13466. this.$updateScrollBarV = function() {
  13467. var scrollHeight = this.layerConfig.maxHeight;
  13468. var scrollerHeight = this.$size.scrollerHeight;
  13469. if (!this.$maxLines && this.$scrollPastEnd) {
  13470. scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
  13471. if (this.scrollTop > scrollHeight - scrollerHeight) {
  13472. scrollHeight = this.scrollTop + scrollerHeight;
  13473. this.scrollBarV.scrollTop = null;
  13474. }
  13475. }
  13476. this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
  13477. this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
  13478. };
  13479. this.$updateScrollBarH = function() {
  13480. this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
  13481. this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
  13482. };
  13483. this.$frozen = false;
  13484. this.freeze = function() {
  13485. this.$frozen = true;
  13486. };
  13487. this.unfreeze = function() {
  13488. this.$frozen = false;
  13489. };
  13490. this.$renderChanges = function(changes, force) {
  13491. if (this.$changes) {
  13492. changes |= this.$changes;
  13493. this.$changes = 0;
  13494. }
  13495. if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
  13496. this.$changes |= changes;
  13497. return;
  13498. }
  13499. if (this.$size.$dirty) {
  13500. this.$changes |= changes;
  13501. return this.onResize(true);
  13502. }
  13503. if (!this.lineHeight) {
  13504. this.$textLayer.checkForSizeChanges();
  13505. }
  13506. this._signal("beforeRender");
  13507. var config = this.layerConfig;
  13508. if (changes & this.CHANGE_FULL ||
  13509. changes & this.CHANGE_SIZE ||
  13510. changes & this.CHANGE_TEXT ||
  13511. changes & this.CHANGE_LINES ||
  13512. changes & this.CHANGE_SCROLL ||
  13513. changes & this.CHANGE_H_SCROLL
  13514. ) {
  13515. changes |= this.$computeLayerConfig();
  13516. if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
  13517. var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
  13518. if (st > 0) {
  13519. this.scrollTop = st;
  13520. changes = changes | this.CHANGE_SCROLL;
  13521. changes |= this.$computeLayerConfig();
  13522. }
  13523. }
  13524. config = this.layerConfig;
  13525. this.$updateScrollBarV();
  13526. if (changes & this.CHANGE_H_SCROLL)
  13527. this.$updateScrollBarH();
  13528. this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
  13529. this.content.style.marginTop = (-config.offset) + "px";
  13530. this.content.style.width = config.width + 2 * this.$padding + "px";
  13531. this.content.style.height = config.minHeight + "px";
  13532. }
  13533. if (changes & this.CHANGE_H_SCROLL) {
  13534. this.content.style.marginLeft = -this.scrollLeft + "px";
  13535. this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
  13536. }
  13537. if (changes & this.CHANGE_FULL) {
  13538. this.$textLayer.update(config);
  13539. if (this.$showGutter)
  13540. this.$gutterLayer.update(config);
  13541. this.$markerBack.update(config);
  13542. this.$markerFront.update(config);
  13543. this.$cursorLayer.update(config);
  13544. this.$moveTextAreaToCursor();
  13545. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13546. this._signal("afterRender");
  13547. return;
  13548. }
  13549. if (changes & this.CHANGE_SCROLL) {
  13550. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  13551. this.$textLayer.update(config);
  13552. else
  13553. this.$textLayer.scrollLines(config);
  13554. if (this.$showGutter)
  13555. this.$gutterLayer.update(config);
  13556. this.$markerBack.update(config);
  13557. this.$markerFront.update(config);
  13558. this.$cursorLayer.update(config);
  13559. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13560. this.$moveTextAreaToCursor();
  13561. this._signal("afterRender");
  13562. return;
  13563. }
  13564. if (changes & this.CHANGE_TEXT) {
  13565. this.$textLayer.update(config);
  13566. if (this.$showGutter)
  13567. this.$gutterLayer.update(config);
  13568. }
  13569. else if (changes & this.CHANGE_LINES) {
  13570. if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
  13571. this.$gutterLayer.update(config);
  13572. }
  13573. else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
  13574. if (this.$showGutter)
  13575. this.$gutterLayer.update(config);
  13576. }
  13577. if (changes & this.CHANGE_CURSOR) {
  13578. this.$cursorLayer.update(config);
  13579. this.$moveTextAreaToCursor();
  13580. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13581. }
  13582. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  13583. this.$markerFront.update(config);
  13584. }
  13585. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  13586. this.$markerBack.update(config);
  13587. }
  13588. this._signal("afterRender");
  13589. };
  13590. this.$autosize = function() {
  13591. var height = this.session.getScreenLength() * this.lineHeight;
  13592. var maxHeight = this.$maxLines * this.lineHeight;
  13593. var desiredHeight = Math.max(
  13594. (this.$minLines||1) * this.lineHeight,
  13595. Math.min(maxHeight, height)
  13596. ) + this.scrollMargin.v + (this.$extraHeight || 0);
  13597. var vScroll = height > maxHeight;
  13598. if (desiredHeight != this.desiredHeight ||
  13599. this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
  13600. if (vScroll != this.$vScroll) {
  13601. this.$vScroll = vScroll;
  13602. this.scrollBarV.setVisible(vScroll);
  13603. }
  13604. var w = this.container.clientWidth;
  13605. this.container.style.height = desiredHeight + "px";
  13606. this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
  13607. this.desiredHeight = desiredHeight;
  13608. this._signal("autosize");
  13609. }
  13610. };
  13611. this.$computeLayerConfig = function() {
  13612. if (this.$maxLines && this.lineHeight > 1)
  13613. this.$autosize();
  13614. var session = this.session;
  13615. var size = this.$size;
  13616. var hideScrollbars = size.height <= 2 * this.lineHeight;
  13617. var screenLines = this.session.getScreenLength();
  13618. var maxHeight = screenLines * this.lineHeight;
  13619. var offset = this.scrollTop % this.lineHeight;
  13620. var minHeight = size.scrollerHeight + this.lineHeight;
  13621. var longestLine = this.$getLongestLine();
  13622. var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
  13623. size.scrollerWidth - longestLine - 2 * this.$padding < 0);
  13624. var hScrollChanged = this.$horizScroll !== horizScroll;
  13625. if (hScrollChanged) {
  13626. this.$horizScroll = horizScroll;
  13627. this.scrollBarH.setVisible(horizScroll);
  13628. }
  13629. var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
  13630. ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
  13631. : 0;
  13632. maxHeight += scrollPastEnd;
  13633. this.session.setScrollTop(Math.max(-this.scrollMargin.top,
  13634. Math.min(this.scrollTop, maxHeight - size.scrollerHeight + this.scrollMargin.bottom)));
  13635. this.session.setScrollLeft(Math.max(-this.scrollMargin.left, Math.min(this.scrollLeft,
  13636. longestLine + 2 * this.$padding - size.scrollerWidth + this.scrollMargin.right)));
  13637. var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
  13638. size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop);
  13639. var vScrollChanged = this.$vScroll !== vScroll;
  13640. if (vScrollChanged) {
  13641. this.$vScroll = vScroll;
  13642. this.scrollBarV.setVisible(vScroll);
  13643. }
  13644. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  13645. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  13646. var lastRow = firstRow + lineCount;
  13647. var firstRowScreen, firstRowHeight;
  13648. var lineHeight = this.lineHeight;
  13649. firstRow = session.screenToDocumentRow(firstRow, 0);
  13650. var foldLine = session.getFoldLine(firstRow);
  13651. if (foldLine) {
  13652. firstRow = foldLine.start.row;
  13653. }
  13654. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  13655. firstRowHeight = session.getRowLength(firstRow) * lineHeight;
  13656. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  13657. minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
  13658. firstRowHeight;
  13659. offset = this.scrollTop - firstRowScreen * lineHeight;
  13660. var changes = 0;
  13661. if (this.layerConfig.width != longestLine)
  13662. changes = this.CHANGE_H_SCROLL;
  13663. if (hScrollChanged || vScrollChanged) {
  13664. changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
  13665. this._signal("scrollbarVisibilityChanged");
  13666. if (vScrollChanged)
  13667. longestLine = this.$getLongestLine();
  13668. }
  13669. this.layerConfig = {
  13670. width : longestLine,
  13671. padding : this.$padding,
  13672. firstRow : firstRow,
  13673. firstRowScreen: firstRowScreen,
  13674. lastRow : lastRow,
  13675. lineHeight : lineHeight,
  13676. characterWidth : this.characterWidth,
  13677. minHeight : minHeight,
  13678. maxHeight : maxHeight,
  13679. offset : offset,
  13680. gutterOffset : Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)),
  13681. height : this.$size.scrollerHeight
  13682. };
  13683. return changes;
  13684. };
  13685. this.$updateLines = function() {
  13686. var firstRow = this.$changedLines.firstRow;
  13687. var lastRow = this.$changedLines.lastRow;
  13688. this.$changedLines = null;
  13689. var layerConfig = this.layerConfig;
  13690. if (firstRow > layerConfig.lastRow + 1) { return; }
  13691. if (lastRow < layerConfig.firstRow) { return; }
  13692. if (lastRow === Infinity) {
  13693. if (this.$showGutter)
  13694. this.$gutterLayer.update(layerConfig);
  13695. this.$textLayer.update(layerConfig);
  13696. return;
  13697. }
  13698. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  13699. return true;
  13700. };
  13701. this.$getLongestLine = function() {
  13702. var charCount = this.session.getScreenWidth();
  13703. if (this.showInvisibles && !this.session.$useWrapMode)
  13704. charCount += 1;
  13705. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  13706. };
  13707. this.updateFrontMarkers = function() {
  13708. this.$markerFront.setMarkers(this.session.getMarkers(true));
  13709. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  13710. };
  13711. this.updateBackMarkers = function() {
  13712. this.$markerBack.setMarkers(this.session.getMarkers());
  13713. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  13714. };
  13715. this.addGutterDecoration = function(row, className){
  13716. this.$gutterLayer.addGutterDecoration(row, className);
  13717. };
  13718. this.removeGutterDecoration = function(row, className){
  13719. this.$gutterLayer.removeGutterDecoration(row, className);
  13720. };
  13721. this.updateBreakpoints = function(rows) {
  13722. this.$loop.schedule(this.CHANGE_GUTTER);
  13723. };
  13724. this.setAnnotations = function(annotations) {
  13725. this.$gutterLayer.setAnnotations(annotations);
  13726. this.$loop.schedule(this.CHANGE_GUTTER);
  13727. };
  13728. this.updateCursor = function() {
  13729. this.$loop.schedule(this.CHANGE_CURSOR);
  13730. };
  13731. this.hideCursor = function() {
  13732. this.$cursorLayer.hideCursor();
  13733. };
  13734. this.showCursor = function() {
  13735. this.$cursorLayer.showCursor();
  13736. };
  13737. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  13738. this.scrollCursorIntoView(anchor, offset);
  13739. this.scrollCursorIntoView(lead, offset);
  13740. };
  13741. this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
  13742. if (this.$size.scrollerHeight === 0)
  13743. return;
  13744. var pos = this.$cursorLayer.getPixelPosition(cursor);
  13745. var left = pos.left;
  13746. var top = pos.top;
  13747. var topMargin = $viewMargin && $viewMargin.top || 0;
  13748. var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
  13749. var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
  13750. if (scrollTop + topMargin > top) {
  13751. if (offset)
  13752. top -= offset * this.$size.scrollerHeight;
  13753. if (top === 0)
  13754. top = -this.scrollMargin.top;
  13755. this.session.setScrollTop(top);
  13756. } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
  13757. if (offset)
  13758. top += offset * this.$size.scrollerHeight;
  13759. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  13760. }
  13761. var scrollLeft = this.scrollLeft;
  13762. if (scrollLeft > left) {
  13763. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  13764. left = -this.scrollMargin.left;
  13765. this.session.setScrollLeft(left);
  13766. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  13767. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  13768. } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
  13769. this.session.setScrollLeft(0);
  13770. }
  13771. };
  13772. this.getScrollTop = function() {
  13773. return this.session.getScrollTop();
  13774. };
  13775. this.getScrollLeft = function() {
  13776. return this.session.getScrollLeft();
  13777. };
  13778. this.getScrollTopRow = function() {
  13779. return this.scrollTop / this.lineHeight;
  13780. };
  13781. this.getScrollBottomRow = function() {
  13782. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  13783. };
  13784. this.scrollToRow = function(row) {
  13785. this.session.setScrollTop(row * this.lineHeight);
  13786. };
  13787. this.alignCursor = function(cursor, alignment) {
  13788. if (typeof cursor == "number")
  13789. cursor = {row: cursor, column: 0};
  13790. var pos = this.$cursorLayer.getPixelPosition(cursor);
  13791. var h = this.$size.scrollerHeight - this.lineHeight;
  13792. var offset = pos.top - h * (alignment || 0);
  13793. this.session.setScrollTop(offset);
  13794. return offset;
  13795. };
  13796. this.STEPS = 8;
  13797. this.$calcSteps = function(fromValue, toValue){
  13798. var i = 0;
  13799. var l = this.STEPS;
  13800. var steps = [];
  13801. var func = function(t, x_min, dx) {
  13802. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  13803. };
  13804. for (i = 0; i < l; ++i)
  13805. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  13806. return steps;
  13807. };
  13808. this.scrollToLine = function(line, center, animate, callback) {
  13809. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  13810. var offset = pos.top;
  13811. if (center)
  13812. offset -= this.$size.scrollerHeight / 2;
  13813. var initialScroll = this.scrollTop;
  13814. this.session.setScrollTop(offset);
  13815. if (animate !== false)
  13816. this.animateScrolling(initialScroll, callback);
  13817. };
  13818. this.animateScrolling = function(fromValue, callback) {
  13819. var toValue = this.scrollTop;
  13820. if (!this.$animatedScroll)
  13821. return;
  13822. var _self = this;
  13823. if (fromValue == toValue)
  13824. return;
  13825. if (this.$scrollAnimation) {
  13826. var oldSteps = this.$scrollAnimation.steps;
  13827. if (oldSteps.length) {
  13828. fromValue = oldSteps[0];
  13829. if (fromValue == toValue)
  13830. return;
  13831. }
  13832. }
  13833. var steps = _self.$calcSteps(fromValue, toValue);
  13834. this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
  13835. clearInterval(this.$timer);
  13836. _self.session.setScrollTop(steps.shift());
  13837. _self.session.$scrollTop = toValue;
  13838. this.$timer = setInterval(function() {
  13839. if (steps.length) {
  13840. _self.session.setScrollTop(steps.shift());
  13841. _self.session.$scrollTop = toValue;
  13842. } else if (toValue != null) {
  13843. _self.session.$scrollTop = -1;
  13844. _self.session.setScrollTop(toValue);
  13845. toValue = null;
  13846. } else {
  13847. _self.$timer = clearInterval(_self.$timer);
  13848. _self.$scrollAnimation = null;
  13849. callback && callback();
  13850. }
  13851. }, 10);
  13852. };
  13853. this.scrollToY = function(scrollTop) {
  13854. if (this.scrollTop !== scrollTop) {
  13855. this.$loop.schedule(this.CHANGE_SCROLL);
  13856. this.scrollTop = scrollTop;
  13857. }
  13858. };
  13859. this.scrollToX = function(scrollLeft) {
  13860. if (this.scrollLeft !== scrollLeft)
  13861. this.scrollLeft = scrollLeft;
  13862. this.$loop.schedule(this.CHANGE_H_SCROLL);
  13863. };
  13864. this.scrollTo = function(x, y) {
  13865. this.session.setScrollTop(y);
  13866. this.session.setScrollLeft(y);
  13867. };
  13868. this.scrollBy = function(deltaX, deltaY) {
  13869. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  13870. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  13871. };
  13872. this.isScrollableBy = function(deltaX, deltaY) {
  13873. if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
  13874. return true;
  13875. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
  13876. - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
  13877. return true;
  13878. if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
  13879. return true;
  13880. if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
  13881. - this.layerConfig.width < -1 + this.scrollMargin.right)
  13882. return true;
  13883. };
  13884. this.pixelToScreenCoordinates = function(x, y) {
  13885. var canvasPos = this.scroller.getBoundingClientRect();
  13886. var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
  13887. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  13888. var col = Math.round(offset);
  13889. return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
  13890. };
  13891. this.screenToTextCoordinates = function(x, y) {
  13892. var canvasPos = this.scroller.getBoundingClientRect();
  13893. var col = Math.round(
  13894. (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
  13895. );
  13896. var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
  13897. return this.session.screenToDocumentPosition(row, Math.max(col, 0));
  13898. };
  13899. this.textToScreenCoordinates = function(row, column) {
  13900. var canvasPos = this.scroller.getBoundingClientRect();
  13901. var pos = this.session.documentToScreenPosition(row, column);
  13902. var x = this.$padding + Math.round(pos.column * this.characterWidth);
  13903. var y = pos.row * this.lineHeight;
  13904. return {
  13905. pageX: canvasPos.left + x - this.scrollLeft,
  13906. pageY: canvasPos.top + y - this.scrollTop
  13907. };
  13908. };
  13909. this.visualizeFocus = function() {
  13910. dom.addCssClass(this.container, "ace_focus");
  13911. };
  13912. this.visualizeBlur = function() {
  13913. dom.removeCssClass(this.container, "ace_focus");
  13914. };
  13915. this.showComposition = function(position) {
  13916. if (!this.$composition)
  13917. this.$composition = {
  13918. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  13919. cssText: this.textarea.style.cssText
  13920. };
  13921. this.$keepTextAreaAtCursor = true;
  13922. dom.addCssClass(this.textarea, "ace_composition");
  13923. this.textarea.style.cssText = "";
  13924. this.$moveTextAreaToCursor();
  13925. };
  13926. this.setCompositionText = function(text) {
  13927. this.$moveTextAreaToCursor();
  13928. };
  13929. this.hideComposition = function() {
  13930. if (!this.$composition)
  13931. return;
  13932. dom.removeCssClass(this.textarea, "ace_composition");
  13933. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  13934. this.textarea.style.cssText = this.$composition.cssText;
  13935. this.$composition = null;
  13936. };
  13937. this.setTheme = function(theme, cb) {
  13938. var _self = this;
  13939. this.$themeId = theme;
  13940. _self._dispatchEvent('themeChange',{theme:theme});
  13941. if (!theme || typeof theme == "string") {
  13942. var moduleName = theme || this.$options.theme.initialValue;
  13943. config.loadModule(["theme", moduleName], afterLoad);
  13944. } else {
  13945. afterLoad(theme);
  13946. }
  13947. function afterLoad(module) {
  13948. if (_self.$themeId != theme)
  13949. return cb && cb();
  13950. if (!module.cssClass)
  13951. return;
  13952. dom.importCssString(
  13953. module.cssText,
  13954. module.cssClass,
  13955. _self.container.ownerDocument
  13956. );
  13957. if (_self.theme)
  13958. dom.removeCssClass(_self.container, _self.theme.cssClass);
  13959. var padding = "padding" in module ? module.padding
  13960. : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
  13961. if (_self.$padding && padding != _self.$padding)
  13962. _self.setPadding(padding);
  13963. _self.$theme = module.cssClass;
  13964. _self.theme = module;
  13965. dom.addCssClass(_self.container, module.cssClass);
  13966. dom.setCssClass(_self.container, "ace_dark", module.isDark);
  13967. if (_self.$size) {
  13968. _self.$size.width = 0;
  13969. _self.$updateSizeAsync();
  13970. }
  13971. _self._dispatchEvent('themeLoaded', {theme:module});
  13972. cb && cb();
  13973. }
  13974. };
  13975. this.getTheme = function() {
  13976. return this.$themeId;
  13977. };
  13978. this.setStyle = function(style, include) {
  13979. dom.setCssClass(this.container, style, include !== false);
  13980. };
  13981. this.unsetStyle = function(style) {
  13982. dom.removeCssClass(this.container, style);
  13983. };
  13984. this.setCursorStyle = function(style) {
  13985. if (this.scroller.style.cursor != style)
  13986. this.scroller.style.cursor = style;
  13987. };
  13988. this.setMouseCursor = function(cursorStyle) {
  13989. this.scroller.style.cursor = cursorStyle;
  13990. };
  13991. this.destroy = function() {
  13992. this.$textLayer.destroy();
  13993. this.$cursorLayer.destroy();
  13994. };
  13995. }).call(VirtualRenderer.prototype);
  13996. config.defineOptions(VirtualRenderer.prototype, "renderer", {
  13997. animatedScroll: {initialValue: false},
  13998. showInvisibles: {
  13999. set: function(value) {
  14000. if (this.$textLayer.setShowInvisibles(value))
  14001. this.$loop.schedule(this.CHANGE_TEXT);
  14002. },
  14003. initialValue: false
  14004. },
  14005. showPrintMargin: {
  14006. set: function() { this.$updatePrintMargin(); },
  14007. initialValue: true
  14008. },
  14009. printMarginColumn: {
  14010. set: function() { this.$updatePrintMargin(); },
  14011. initialValue: 80
  14012. },
  14013. printMargin: {
  14014. set: function(val) {
  14015. if (typeof val == "number")
  14016. this.$printMarginColumn = val;
  14017. this.$showPrintMargin = !!val;
  14018. this.$updatePrintMargin();
  14019. },
  14020. get: function() {
  14021. return this.$showPrintMargin && this.$printMarginColumn;
  14022. }
  14023. },
  14024. showGutter: {
  14025. set: function(show){
  14026. this.$gutter.style.display = show ? "block" : "none";
  14027. this.$loop.schedule(this.CHANGE_FULL);
  14028. this.onGutterResize();
  14029. },
  14030. initialValue: true
  14031. },
  14032. fadeFoldWidgets: {
  14033. set: function(show) {
  14034. dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
  14035. },
  14036. initialValue: false
  14037. },
  14038. showFoldWidgets: {
  14039. set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
  14040. initialValue: true
  14041. },
  14042. showLineNumbers: {
  14043. set: function(show) {
  14044. this.$gutterLayer.setShowLineNumbers(show);
  14045. this.$loop.schedule(this.CHANGE_GUTTER);
  14046. },
  14047. initialValue: true
  14048. },
  14049. displayIndentGuides: {
  14050. set: function(show) {
  14051. if (this.$textLayer.setDisplayIndentGuides(show))
  14052. this.$loop.schedule(this.CHANGE_TEXT);
  14053. },
  14054. initialValue: true
  14055. },
  14056. highlightGutterLine: {
  14057. set: function(shouldHighlight) {
  14058. if (!this.$gutterLineHighlight) {
  14059. this.$gutterLineHighlight = dom.createElement("div");
  14060. this.$gutterLineHighlight.className = "ace_gutter-active-line";
  14061. this.$gutter.appendChild(this.$gutterLineHighlight);
  14062. return;
  14063. }
  14064. this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
  14065. if (this.$cursorLayer.$pixelPos)
  14066. this.$updateGutterLineHighlight();
  14067. },
  14068. initialValue: false,
  14069. value: true
  14070. },
  14071. hScrollBarAlwaysVisible: {
  14072. set: function(val) {
  14073. if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
  14074. this.$loop.schedule(this.CHANGE_SCROLL);
  14075. },
  14076. initialValue: false
  14077. },
  14078. vScrollBarAlwaysVisible: {
  14079. set: function(val) {
  14080. if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
  14081. this.$loop.schedule(this.CHANGE_SCROLL);
  14082. },
  14083. initialValue: false
  14084. },
  14085. fontSize: {
  14086. set: function(size) {
  14087. if (typeof size == "number")
  14088. size = size + "px";
  14089. this.container.style.fontSize = size;
  14090. this.updateFontSize();
  14091. },
  14092. initialValue: 12
  14093. },
  14094. fontFamily: {
  14095. set: function(name) {
  14096. this.container.style.fontFamily = name;
  14097. this.updateFontSize();
  14098. }
  14099. },
  14100. maxLines: {
  14101. set: function(val) {
  14102. this.updateFull();
  14103. }
  14104. },
  14105. minLines: {
  14106. set: function(val) {
  14107. this.updateFull();
  14108. }
  14109. },
  14110. scrollPastEnd: {
  14111. set: function(val) {
  14112. val = +val || 0;
  14113. if (this.$scrollPastEnd == val)
  14114. return;
  14115. this.$scrollPastEnd = val;
  14116. this.$loop.schedule(this.CHANGE_SCROLL);
  14117. },
  14118. initialValue: 0,
  14119. handlesSet: true
  14120. },
  14121. fixedWidthGutter: {
  14122. set: function(val) {
  14123. this.$gutterLayer.$fixedWidth = !!val;
  14124. this.$loop.schedule(this.CHANGE_GUTTER);
  14125. }
  14126. },
  14127. theme: {
  14128. set: function(val) { this.setTheme(val) },
  14129. get: function() { return this.$themeId || this.theme; },
  14130. initialValue: "./theme/textmate",
  14131. handlesSet: true
  14132. }
  14133. });
  14134. exports.VirtualRenderer = VirtualRenderer;
  14135. });
  14136. ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"], function(require, exports, module) {
  14137. "use strict";
  14138. var oop = require("../lib/oop");
  14139. var net = require("../lib/net");
  14140. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  14141. var config = require("../config");
  14142. var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
  14143. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14144. this.changeListener = this.changeListener.bind(this);
  14145. this.onMessage = this.onMessage.bind(this);
  14146. if (require.nameToUrl && !require.toUrl)
  14147. require.toUrl = require.nameToUrl;
  14148. if (config.get("packaged") || !require.toUrl) {
  14149. workerUrl = workerUrl || config.moduleUrl(mod, "worker");
  14150. } else {
  14151. var normalizePath = this.$normalizePath;
  14152. workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
  14153. var tlns = {};
  14154. topLevelNamespaces.forEach(function(ns) {
  14155. tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
  14156. });
  14157. }
  14158. try {
  14159. this.$worker = new Worker(workerUrl);
  14160. } catch(e) {
  14161. if (e instanceof window.DOMException) {
  14162. var blob = this.$workerBlob(workerUrl);
  14163. var URL = window.URL || window.webkitURL;
  14164. var blobURL = URL.createObjectURL(blob);
  14165. this.$worker = new Worker(blobURL);
  14166. URL.revokeObjectURL(blobURL);
  14167. } else {
  14168. throw e;
  14169. }
  14170. }
  14171. this.$worker.postMessage({
  14172. init : true,
  14173. tlns : tlns,
  14174. module : mod,
  14175. classname : classname
  14176. });
  14177. this.callbackId = 1;
  14178. this.callbacks = {};
  14179. this.$worker.onmessage = this.onMessage;
  14180. };
  14181. (function(){
  14182. oop.implement(this, EventEmitter);
  14183. this.onMessage = function(e) {
  14184. var msg = e.data;
  14185. switch(msg.type) {
  14186. case "event":
  14187. this._signal(msg.name, {data: msg.data});
  14188. break;
  14189. case "call":
  14190. var callback = this.callbacks[msg.id];
  14191. if (callback) {
  14192. callback(msg.data);
  14193. delete this.callbacks[msg.id];
  14194. }
  14195. break;
  14196. case "error":
  14197. this.reportError(msg.data);
  14198. break;
  14199. case "log":
  14200. window.console && console.log && console.log.apply(console, msg.data);
  14201. break;
  14202. }
  14203. };
  14204. this.reportError = function(err) {
  14205. window.console && console.error && console.error(err);
  14206. };
  14207. this.$normalizePath = function(path) {
  14208. return net.qualifyURL(path);
  14209. };
  14210. this.terminate = function() {
  14211. this._signal("terminate", {});
  14212. this.deltaQueue = null;
  14213. this.$worker.terminate();
  14214. this.$worker = null;
  14215. if (this.$doc)
  14216. this.$doc.off("change", this.changeListener);
  14217. this.$doc = null;
  14218. };
  14219. this.send = function(cmd, args) {
  14220. this.$worker.postMessage({command: cmd, args: args});
  14221. };
  14222. this.call = function(cmd, args, callback) {
  14223. if (callback) {
  14224. var id = this.callbackId++;
  14225. this.callbacks[id] = callback;
  14226. args.push(id);
  14227. }
  14228. this.send(cmd, args);
  14229. };
  14230. this.emit = function(event, data) {
  14231. try {
  14232. this.$worker.postMessage({event: event, data: {data: data.data}});
  14233. }
  14234. catch(ex) {
  14235. console.error(ex.stack);
  14236. }
  14237. };
  14238. this.attachToDocument = function(doc) {
  14239. if(this.$doc)
  14240. this.terminate();
  14241. this.$doc = doc;
  14242. this.call("setValue", [doc.getValue()]);
  14243. doc.on("change", this.changeListener);
  14244. };
  14245. this.changeListener = function(e) {
  14246. if (!this.deltaQueue) {
  14247. this.deltaQueue = [e.data];
  14248. setTimeout(this.$sendDeltaQueue, 0);
  14249. } else
  14250. this.deltaQueue.push(e.data);
  14251. };
  14252. this.$sendDeltaQueue = function() {
  14253. var q = this.deltaQueue;
  14254. if (!q) return;
  14255. this.deltaQueue = null;
  14256. if (q.length > 20 && q.length > this.$doc.getLength() >> 1) {
  14257. this.call("setValue", [this.$doc.getValue()]);
  14258. } else
  14259. this.emit("change", {data: q});
  14260. };
  14261. this.$workerBlob = function(workerUrl) {
  14262. var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
  14263. try {
  14264. return new Blob([script], {"type": "application/javascript"});
  14265. } catch (e) { // Backwards-compatibility
  14266. var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
  14267. var blobBuilder = new BlobBuilder();
  14268. blobBuilder.append(script);
  14269. return blobBuilder.getBlob("application/javascript");
  14270. }
  14271. };
  14272. }).call(WorkerClient.prototype);
  14273. var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
  14274. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14275. this.changeListener = this.changeListener.bind(this);
  14276. this.callbackId = 1;
  14277. this.callbacks = {};
  14278. this.messageBuffer = [];
  14279. var main = null;
  14280. var emitSync = false;
  14281. var sender = Object.create(EventEmitter);
  14282. var _self = this;
  14283. this.$worker = {};
  14284. this.$worker.terminate = function() {};
  14285. this.$worker.postMessage = function(e) {
  14286. _self.messageBuffer.push(e);
  14287. if (main) {
  14288. if (emitSync)
  14289. setTimeout(processNext);
  14290. else
  14291. processNext();
  14292. }
  14293. };
  14294. this.setEmitSync = function(val) { emitSync = val };
  14295. var processNext = function() {
  14296. var msg = _self.messageBuffer.shift();
  14297. if (msg.command)
  14298. main[msg.command].apply(main, msg.args);
  14299. else if (msg.event)
  14300. sender._signal(msg.event, msg.data);
  14301. };
  14302. sender.postMessage = function(msg) {
  14303. _self.onMessage({data: msg});
  14304. };
  14305. sender.callback = function(data, callbackId) {
  14306. this.postMessage({type: "call", id: callbackId, data: data});
  14307. };
  14308. sender.emit = function(name, data) {
  14309. this.postMessage({type: "event", name: name, data: data});
  14310. };
  14311. config.loadModule(["worker", mod], function(Main) {
  14312. main = new Main[classname](sender);
  14313. while (_self.messageBuffer.length)
  14314. processNext();
  14315. });
  14316. };
  14317. UIWorkerClient.prototype = WorkerClient.prototype;
  14318. exports.UIWorkerClient = UIWorkerClient;
  14319. exports.WorkerClient = WorkerClient;
  14320. });
  14321. ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
  14322. "use strict";
  14323. var Range = require("./range").Range;
  14324. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14325. var oop = require("./lib/oop");
  14326. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  14327. var _self = this;
  14328. this.length = length;
  14329. this.session = session;
  14330. this.doc = session.getDocument();
  14331. this.mainClass = mainClass;
  14332. this.othersClass = othersClass;
  14333. this.$onUpdate = this.onUpdate.bind(this);
  14334. this.doc.on("change", this.$onUpdate);
  14335. this.$others = others;
  14336. this.$onCursorChange = function() {
  14337. setTimeout(function() {
  14338. _self.onCursorChange();
  14339. });
  14340. };
  14341. this.$pos = pos;
  14342. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  14343. this.$undoStackDepth = undoStack.length;
  14344. this.setup();
  14345. session.selection.on("changeCursor", this.$onCursorChange);
  14346. };
  14347. (function() {
  14348. oop.implement(this, EventEmitter);
  14349. this.setup = function() {
  14350. var _self = this;
  14351. var doc = this.doc;
  14352. var session = this.session;
  14353. var pos = this.$pos;
  14354. this.selectionBefore = session.selection.toJSON();
  14355. if (session.selection.inMultiSelectMode)
  14356. session.selection.toSingleRange();
  14357. this.pos = doc.createAnchor(pos.row, pos.column);
  14358. this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  14359. this.pos.on("change", function(event) {
  14360. session.removeMarker(_self.markerId);
  14361. _self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
  14362. });
  14363. this.others = [];
  14364. this.$others.forEach(function(other) {
  14365. var anchor = doc.createAnchor(other.row, other.column);
  14366. _self.others.push(anchor);
  14367. });
  14368. session.setUndoSelect(false);
  14369. };
  14370. this.showOtherMarkers = function() {
  14371. if(this.othersActive) return;
  14372. var session = this.session;
  14373. var _self = this;
  14374. this.othersActive = true;
  14375. this.others.forEach(function(anchor) {
  14376. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  14377. anchor.on("change", function(event) {
  14378. session.removeMarker(anchor.markerId);
  14379. anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
  14380. });
  14381. });
  14382. };
  14383. this.hideOtherMarkers = function() {
  14384. if(!this.othersActive) return;
  14385. this.othersActive = false;
  14386. for (var i = 0; i < this.others.length; i++) {
  14387. this.session.removeMarker(this.others[i].markerId);
  14388. }
  14389. };
  14390. this.onUpdate = function(event) {
  14391. var delta = event.data;
  14392. var range = delta.range;
  14393. if(range.start.row !== range.end.row) return;
  14394. if(range.start.row !== this.pos.row) return;
  14395. if (this.$updating) return;
  14396. this.$updating = true;
  14397. var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column;
  14398. if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
  14399. var distanceFromStart = range.start.column - this.pos.column;
  14400. this.length += lengthDiff;
  14401. if(!this.session.$fromUndo) {
  14402. if(delta.action === "insertText") {
  14403. for (var i = this.others.length - 1; i >= 0; i--) {
  14404. var otherPos = this.others[i];
  14405. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14406. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  14407. newPos.column += lengthDiff;
  14408. this.doc.insert(newPos, delta.text);
  14409. }
  14410. } else if(delta.action === "removeText") {
  14411. for (var i = this.others.length - 1; i >= 0; i--) {
  14412. var otherPos = this.others[i];
  14413. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14414. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  14415. newPos.column += lengthDiff;
  14416. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  14417. }
  14418. }
  14419. if(range.start.column === this.pos.column && delta.action === "insertText") {
  14420. setTimeout(function() {
  14421. this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
  14422. for (var i = 0; i < this.others.length; i++) {
  14423. var other = this.others[i];
  14424. var newPos = {row: other.row, column: other.column - lengthDiff};
  14425. if(other.row === range.start.row && range.start.column < other.column)
  14426. newPos.column += lengthDiff;
  14427. other.setPosition(newPos.row, newPos.column);
  14428. }
  14429. }.bind(this), 0);
  14430. }
  14431. else if(range.start.column === this.pos.column && delta.action === "removeText") {
  14432. setTimeout(function() {
  14433. for (var i = 0; i < this.others.length; i++) {
  14434. var other = this.others[i];
  14435. if(other.row === range.start.row && range.start.column < other.column) {
  14436. other.setPosition(other.row, other.column - lengthDiff);
  14437. }
  14438. }
  14439. }.bind(this), 0);
  14440. }
  14441. }
  14442. this.pos._emit("change", {value: this.pos});
  14443. for (var i = 0; i < this.others.length; i++) {
  14444. this.others[i]._emit("change", {value: this.others[i]});
  14445. }
  14446. }
  14447. this.$updating = false;
  14448. };
  14449. this.onCursorChange = function(event) {
  14450. if (this.$updating || !this.session) return;
  14451. var pos = this.session.selection.getCursor();
  14452. if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  14453. this.showOtherMarkers();
  14454. this._emit("cursorEnter", event);
  14455. } else {
  14456. this.hideOtherMarkers();
  14457. this._emit("cursorLeave", event);
  14458. }
  14459. };
  14460. this.detach = function() {
  14461. this.session.removeMarker(this.markerId);
  14462. this.hideOtherMarkers();
  14463. this.doc.removeEventListener("change", this.$onUpdate);
  14464. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  14465. this.pos.detach();
  14466. for (var i = 0; i < this.others.length; i++) {
  14467. this.others[i].detach();
  14468. }
  14469. this.session.setUndoSelect(true);
  14470. this.session = null;
  14471. };
  14472. this.cancel = function() {
  14473. if(this.$undoStackDepth === -1)
  14474. throw Error("Canceling placeholders only supported with undo manager attached to session.");
  14475. var undoManager = this.session.getUndoManager();
  14476. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  14477. for (var i = 0; i < undosRequired; i++) {
  14478. undoManager.undo(true);
  14479. }
  14480. if (this.selectionBefore)
  14481. this.session.selection.fromJSON(this.selectionBefore);
  14482. };
  14483. }).call(PlaceHolder.prototype);
  14484. exports.PlaceHolder = PlaceHolder;
  14485. });
  14486. ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  14487. var event = require("../lib/event");
  14488. var useragent = require("../lib/useragent");
  14489. function isSamePoint(p1, p2) {
  14490. return p1.row == p2.row && p1.column == p2.column;
  14491. }
  14492. function onMouseDown(e) {
  14493. var ev = e.domEvent;
  14494. var alt = ev.altKey;
  14495. var shift = ev.shiftKey;
  14496. var ctrl = ev.ctrlKey;
  14497. var accel = e.getAccelKey();
  14498. var button = e.getButton();
  14499. if (ctrl && useragent.isMac)
  14500. button = ev.button;
  14501. if (e.editor.inMultiSelectMode && button == 2) {
  14502. e.editor.textInput.onContextMenu(e.domEvent);
  14503. return;
  14504. }
  14505. if (!ctrl && !alt && !accel) {
  14506. if (button === 0 && e.editor.inMultiSelectMode)
  14507. e.editor.exitMultiSelectMode();
  14508. return;
  14509. }
  14510. if (button !== 0)
  14511. return;
  14512. var editor = e.editor;
  14513. var selection = editor.selection;
  14514. var isMultiSelect = editor.inMultiSelectMode;
  14515. var pos = e.getDocumentPosition();
  14516. var cursor = selection.getCursor();
  14517. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  14518. var mouseX = e.x, mouseY = e.y;
  14519. var onMouseSelection = function(e) {
  14520. mouseX = e.clientX;
  14521. mouseY = e.clientY;
  14522. };
  14523. var session = editor.session;
  14524. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14525. var screenCursor = screenAnchor;
  14526. var selectionMode;
  14527. if (editor.$mouseHandler.$enableJumpToDef) {
  14528. if (ctrl && alt || accel && alt)
  14529. selectionMode = "add";
  14530. else if (alt)
  14531. selectionMode = "block";
  14532. } else {
  14533. if (accel && !alt) {
  14534. selectionMode = "add";
  14535. if (!isMultiSelect && shift)
  14536. return;
  14537. } else if (alt) {
  14538. selectionMode = "block";
  14539. }
  14540. }
  14541. if (selectionMode && useragent.isMac && ev.ctrlKey) {
  14542. editor.$mouseHandler.cancelContextMenu();
  14543. }
  14544. if (selectionMode == "add") {
  14545. if (!isMultiSelect && inSelection)
  14546. return; // dragging
  14547. if (!isMultiSelect) {
  14548. var range = selection.toOrientedRange();
  14549. editor.addSelectionMarker(range);
  14550. }
  14551. var oldRange = selection.rangeList.rangeAtPoint(pos);
  14552. editor.$blockScrolling++;
  14553. editor.inVirtualSelectionMode = true;
  14554. if (shift) {
  14555. oldRange = null;
  14556. range = selection.ranges[0];
  14557. editor.removeSelectionMarker(range);
  14558. }
  14559. editor.once("mouseup", function() {
  14560. var tmpSel = selection.toOrientedRange();
  14561. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  14562. selection.substractPoint(tmpSel.cursor);
  14563. else {
  14564. if (shift) {
  14565. selection.substractPoint(range.cursor);
  14566. } else if (range) {
  14567. editor.removeSelectionMarker(range);
  14568. selection.addRange(range);
  14569. }
  14570. selection.addRange(tmpSel);
  14571. }
  14572. editor.$blockScrolling--;
  14573. editor.inVirtualSelectionMode = false;
  14574. });
  14575. } else if (selectionMode == "block") {
  14576. e.stop();
  14577. editor.inVirtualSelectionMode = true;
  14578. var initialRange;
  14579. var rectSel = [];
  14580. var blockSelect = function() {
  14581. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14582. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
  14583. if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
  14584. return;
  14585. screenCursor = newCursor;
  14586. editor.$blockScrolling++;
  14587. editor.selection.moveToPosition(cursor);
  14588. editor.renderer.scrollCursorIntoView();
  14589. editor.removeSelectionMarkers(rectSel);
  14590. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  14591. if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
  14592. rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
  14593. rectSel.forEach(editor.addSelectionMarker, editor);
  14594. editor.updateSelectionMarkers();
  14595. editor.$blockScrolling--;
  14596. };
  14597. editor.$blockScrolling++;
  14598. if (isMultiSelect && !accel) {
  14599. selection.toSingleRange();
  14600. } else if (!isMultiSelect && accel) {
  14601. initialRange = selection.toOrientedRange();
  14602. editor.addSelectionMarker(initialRange);
  14603. }
  14604. if (shift)
  14605. screenAnchor = session.documentToScreenPosition(selection.lead);
  14606. else
  14607. selection.moveToPosition(pos);
  14608. editor.$blockScrolling--;
  14609. screenCursor = {row: -1, column: -1};
  14610. var onMouseSelectionEnd = function(e) {
  14611. clearInterval(timerId);
  14612. editor.removeSelectionMarkers(rectSel);
  14613. if (!rectSel.length)
  14614. rectSel = [selection.toOrientedRange()];
  14615. editor.$blockScrolling++;
  14616. if (initialRange) {
  14617. editor.removeSelectionMarker(initialRange);
  14618. selection.toSingleRange(initialRange);
  14619. }
  14620. for (var i = 0; i < rectSel.length; i++)
  14621. selection.addRange(rectSel[i]);
  14622. editor.inVirtualSelectionMode = false;
  14623. editor.$mouseHandler.$clickSelection = null;
  14624. editor.$blockScrolling--;
  14625. };
  14626. var onSelectionInterval = blockSelect;
  14627. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  14628. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  14629. return e.preventDefault();
  14630. }
  14631. }
  14632. exports.onMouseDown = onMouseDown;
  14633. });
  14634. ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
  14635. exports.defaultCommands = [{
  14636. name: "addCursorAbove",
  14637. exec: function(editor) { editor.selectMoreLines(-1); },
  14638. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  14639. scrollIntoView: "cursor",
  14640. readonly: true
  14641. }, {
  14642. name: "addCursorBelow",
  14643. exec: function(editor) { editor.selectMoreLines(1); },
  14644. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  14645. scrollIntoView: "cursor",
  14646. readonly: true
  14647. }, {
  14648. name: "addCursorAboveSkipCurrent",
  14649. exec: function(editor) { editor.selectMoreLines(-1, true); },
  14650. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  14651. scrollIntoView: "cursor",
  14652. readonly: true
  14653. }, {
  14654. name: "addCursorBelowSkipCurrent",
  14655. exec: function(editor) { editor.selectMoreLines(1, true); },
  14656. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  14657. scrollIntoView: "cursor",
  14658. readonly: true
  14659. }, {
  14660. name: "selectMoreBefore",
  14661. exec: function(editor) { editor.selectMore(-1); },
  14662. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  14663. scrollIntoView: "cursor",
  14664. readonly: true
  14665. }, {
  14666. name: "selectMoreAfter",
  14667. exec: function(editor) { editor.selectMore(1); },
  14668. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  14669. scrollIntoView: "cursor",
  14670. readonly: true
  14671. }, {
  14672. name: "selectNextBefore",
  14673. exec: function(editor) { editor.selectMore(-1, true); },
  14674. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  14675. scrollIntoView: "cursor",
  14676. readonly: true
  14677. }, {
  14678. name: "selectNextAfter",
  14679. exec: function(editor) { editor.selectMore(1, true); },
  14680. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  14681. scrollIntoView: "cursor",
  14682. readonly: true
  14683. }, {
  14684. name: "splitIntoLines",
  14685. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  14686. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  14687. readonly: true
  14688. }, {
  14689. name: "alignCursors",
  14690. exec: function(editor) { editor.alignCursors(); },
  14691. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  14692. scrollIntoView: "cursor"
  14693. }, {
  14694. name: "findAll",
  14695. exec: function(editor) { editor.findAll(); },
  14696. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  14697. scrollIntoView: "cursor",
  14698. readonly: true
  14699. }];
  14700. exports.multiSelectCommands = [{
  14701. name: "singleSelection",
  14702. bindKey: "esc",
  14703. exec: function(editor) { editor.exitMultiSelectMode(); },
  14704. scrollIntoView: "cursor",
  14705. readonly: true,
  14706. isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
  14707. }];
  14708. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  14709. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  14710. });
  14711. ace.define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"], function(require, exports, module) {
  14712. var RangeList = require("./range_list").RangeList;
  14713. var Range = require("./range").Range;
  14714. var Selection = require("./selection").Selection;
  14715. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  14716. var event = require("./lib/event");
  14717. var lang = require("./lib/lang");
  14718. var commands = require("./commands/multi_select_commands");
  14719. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  14720. var Search = require("./search").Search;
  14721. var search = new Search();
  14722. function find(session, needle, dir) {
  14723. search.$options.wrap = true;
  14724. search.$options.needle = needle;
  14725. search.$options.backwards = dir == -1;
  14726. return search.find(session);
  14727. }
  14728. var EditSession = require("./edit_session").EditSession;
  14729. (function() {
  14730. this.getSelectionMarkers = function() {
  14731. return this.$selectionMarkers;
  14732. };
  14733. }).call(EditSession.prototype);
  14734. (function() {
  14735. this.ranges = null;
  14736. this.rangeList = null;
  14737. this.addRange = function(range, $blockChangeEvents) {
  14738. if (!range)
  14739. return;
  14740. if (!this.inMultiSelectMode && this.rangeCount === 0) {
  14741. var oldRange = this.toOrientedRange();
  14742. this.rangeList.add(oldRange);
  14743. this.rangeList.add(range);
  14744. if (this.rangeList.ranges.length != 2) {
  14745. this.rangeList.removeAll();
  14746. return $blockChangeEvents || this.fromOrientedRange(range);
  14747. }
  14748. this.rangeList.removeAll();
  14749. this.rangeList.add(oldRange);
  14750. this.$onAddRange(oldRange);
  14751. }
  14752. if (!range.cursor)
  14753. range.cursor = range.end;
  14754. var removed = this.rangeList.add(range);
  14755. this.$onAddRange(range);
  14756. if (removed.length)
  14757. this.$onRemoveRange(removed);
  14758. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  14759. this._signal("multiSelect");
  14760. this.inMultiSelectMode = true;
  14761. this.session.$undoSelect = false;
  14762. this.rangeList.attach(this.session);
  14763. }
  14764. return $blockChangeEvents || this.fromOrientedRange(range);
  14765. };
  14766. this.toSingleRange = function(range) {
  14767. range = range || this.ranges[0];
  14768. var removed = this.rangeList.removeAll();
  14769. if (removed.length)
  14770. this.$onRemoveRange(removed);
  14771. range && this.fromOrientedRange(range);
  14772. };
  14773. this.substractPoint = function(pos) {
  14774. var removed = this.rangeList.substractPoint(pos);
  14775. if (removed) {
  14776. this.$onRemoveRange(removed);
  14777. return removed[0];
  14778. }
  14779. };
  14780. this.mergeOverlappingRanges = function() {
  14781. var removed = this.rangeList.merge();
  14782. if (removed.length)
  14783. this.$onRemoveRange(removed);
  14784. else if(this.ranges[0])
  14785. this.fromOrientedRange(this.ranges[0]);
  14786. };
  14787. this.$onAddRange = function(range) {
  14788. this.rangeCount = this.rangeList.ranges.length;
  14789. this.ranges.unshift(range);
  14790. this._signal("addRange", {range: range});
  14791. };
  14792. this.$onRemoveRange = function(removed) {
  14793. this.rangeCount = this.rangeList.ranges.length;
  14794. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  14795. var lastRange = this.rangeList.ranges.pop();
  14796. removed.push(lastRange);
  14797. this.rangeCount = 0;
  14798. }
  14799. for (var i = removed.length; i--; ) {
  14800. var index = this.ranges.indexOf(removed[i]);
  14801. this.ranges.splice(index, 1);
  14802. }
  14803. this._signal("removeRange", {ranges: removed});
  14804. if (this.rangeCount === 0 && this.inMultiSelectMode) {
  14805. this.inMultiSelectMode = false;
  14806. this._signal("singleSelect");
  14807. this.session.$undoSelect = true;
  14808. this.rangeList.detach(this.session);
  14809. }
  14810. lastRange = lastRange || this.ranges[0];
  14811. if (lastRange && !lastRange.isEqual(this.getRange()))
  14812. this.fromOrientedRange(lastRange);
  14813. };
  14814. this.$initRangeList = function() {
  14815. if (this.rangeList)
  14816. return;
  14817. this.rangeList = new RangeList();
  14818. this.ranges = [];
  14819. this.rangeCount = 0;
  14820. };
  14821. this.getAllRanges = function() {
  14822. return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
  14823. };
  14824. this.splitIntoLines = function () {
  14825. if (this.rangeCount > 1) {
  14826. var ranges = this.rangeList.ranges;
  14827. var lastRange = ranges[ranges.length - 1];
  14828. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  14829. this.toSingleRange();
  14830. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  14831. } else {
  14832. var range = this.getRange();
  14833. var isBackwards = this.isBackwards();
  14834. var startRow = range.start.row;
  14835. var endRow = range.end.row;
  14836. if (startRow == endRow) {
  14837. if (isBackwards)
  14838. var start = range.end, end = range.start;
  14839. else
  14840. var start = range.start, end = range.end;
  14841. this.addRange(Range.fromPoints(end, end));
  14842. this.addRange(Range.fromPoints(start, start));
  14843. return;
  14844. }
  14845. var rectSel = [];
  14846. var r = this.getLineRange(startRow, true);
  14847. r.start.column = range.start.column;
  14848. rectSel.push(r);
  14849. for (var i = startRow + 1; i < endRow; i++)
  14850. rectSel.push(this.getLineRange(i, true));
  14851. r = this.getLineRange(endRow, true);
  14852. r.end.column = range.end.column;
  14853. rectSel.push(r);
  14854. rectSel.forEach(this.addRange, this);
  14855. }
  14856. };
  14857. this.toggleBlockSelection = function () {
  14858. if (this.rangeCount > 1) {
  14859. var ranges = this.rangeList.ranges;
  14860. var lastRange = ranges[ranges.length - 1];
  14861. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  14862. this.toSingleRange();
  14863. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  14864. } else {
  14865. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  14866. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  14867. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  14868. rectSel.forEach(this.addRange, this);
  14869. }
  14870. };
  14871. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  14872. var rectSel = [];
  14873. var xBackwards = screenCursor.column < screenAnchor.column;
  14874. if (xBackwards) {
  14875. var startColumn = screenCursor.column;
  14876. var endColumn = screenAnchor.column;
  14877. } else {
  14878. var startColumn = screenAnchor.column;
  14879. var endColumn = screenCursor.column;
  14880. }
  14881. var yBackwards = screenCursor.row < screenAnchor.row;
  14882. if (yBackwards) {
  14883. var startRow = screenCursor.row;
  14884. var endRow = screenAnchor.row;
  14885. } else {
  14886. var startRow = screenAnchor.row;
  14887. var endRow = screenCursor.row;
  14888. }
  14889. if (startColumn < 0)
  14890. startColumn = 0;
  14891. if (startRow < 0)
  14892. startRow = 0;
  14893. if (startRow == endRow)
  14894. includeEmptyLines = true;
  14895. for (var row = startRow; row <= endRow; row++) {
  14896. var range = Range.fromPoints(
  14897. this.session.screenToDocumentPosition(row, startColumn),
  14898. this.session.screenToDocumentPosition(row, endColumn)
  14899. );
  14900. if (range.isEmpty()) {
  14901. if (docEnd && isSamePoint(range.end, docEnd))
  14902. break;
  14903. var docEnd = range.end;
  14904. }
  14905. range.cursor = xBackwards ? range.start : range.end;
  14906. rectSel.push(range);
  14907. }
  14908. if (yBackwards)
  14909. rectSel.reverse();
  14910. if (!includeEmptyLines) {
  14911. var end = rectSel.length - 1;
  14912. while (rectSel[end].isEmpty() && end > 0)
  14913. end--;
  14914. if (end > 0) {
  14915. var start = 0;
  14916. while (rectSel[start].isEmpty())
  14917. start++;
  14918. }
  14919. for (var i = end; i >= start; i--) {
  14920. if (rectSel[i].isEmpty())
  14921. rectSel.splice(i, 1);
  14922. }
  14923. }
  14924. return rectSel;
  14925. };
  14926. }).call(Selection.prototype);
  14927. var Editor = require("./editor").Editor;
  14928. (function() {
  14929. this.updateSelectionMarkers = function() {
  14930. this.renderer.updateCursor();
  14931. this.renderer.updateBackMarkers();
  14932. };
  14933. this.addSelectionMarker = function(orientedRange) {
  14934. if (!orientedRange.cursor)
  14935. orientedRange.cursor = orientedRange.end;
  14936. var style = this.getSelectionStyle();
  14937. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  14938. this.session.$selectionMarkers.push(orientedRange);
  14939. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  14940. return orientedRange;
  14941. };
  14942. this.removeSelectionMarker = function(range) {
  14943. if (!range.marker)
  14944. return;
  14945. this.session.removeMarker(range.marker);
  14946. var index = this.session.$selectionMarkers.indexOf(range);
  14947. if (index != -1)
  14948. this.session.$selectionMarkers.splice(index, 1);
  14949. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  14950. };
  14951. this.removeSelectionMarkers = function(ranges) {
  14952. var markerList = this.session.$selectionMarkers;
  14953. for (var i = ranges.length; i--; ) {
  14954. var range = ranges[i];
  14955. if (!range.marker)
  14956. continue;
  14957. this.session.removeMarker(range.marker);
  14958. var index = markerList.indexOf(range);
  14959. if (index != -1)
  14960. markerList.splice(index, 1);
  14961. }
  14962. this.session.selectionMarkerCount = markerList.length;
  14963. };
  14964. this.$onAddRange = function(e) {
  14965. this.addSelectionMarker(e.range);
  14966. this.renderer.updateCursor();
  14967. this.renderer.updateBackMarkers();
  14968. };
  14969. this.$onRemoveRange = function(e) {
  14970. this.removeSelectionMarkers(e.ranges);
  14971. this.renderer.updateCursor();
  14972. this.renderer.updateBackMarkers();
  14973. };
  14974. this.$onMultiSelect = function(e) {
  14975. if (this.inMultiSelectMode)
  14976. return;
  14977. this.inMultiSelectMode = true;
  14978. this.setStyle("ace_multiselect");
  14979. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  14980. this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
  14981. this.renderer.updateCursor();
  14982. this.renderer.updateBackMarkers();
  14983. };
  14984. this.$onSingleSelect = function(e) {
  14985. if (this.session.multiSelect.inVirtualMode)
  14986. return;
  14987. this.inMultiSelectMode = false;
  14988. this.unsetStyle("ace_multiselect");
  14989. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  14990. this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
  14991. this.renderer.updateCursor();
  14992. this.renderer.updateBackMarkers();
  14993. this._emit("changeSelection");
  14994. };
  14995. this.$onMultiSelectExec = function(e) {
  14996. var command = e.command;
  14997. var editor = e.editor;
  14998. if (!editor.multiSelect)
  14999. return;
  15000. if (!command.multiSelectAction) {
  15001. var result = command.exec(editor, e.args || {});
  15002. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  15003. editor.multiSelect.mergeOverlappingRanges();
  15004. } else if (command.multiSelectAction == "forEach") {
  15005. result = editor.forEachSelection(command, e.args);
  15006. } else if (command.multiSelectAction == "forEachLine") {
  15007. result = editor.forEachSelection(command, e.args, true);
  15008. } else if (command.multiSelectAction == "single") {
  15009. editor.exitMultiSelectMode();
  15010. result = command.exec(editor, e.args || {});
  15011. } else {
  15012. result = command.multiSelectAction(editor, e.args || {});
  15013. }
  15014. return result;
  15015. };
  15016. this.forEachSelection = function(cmd, args, options) {
  15017. if (this.inVirtualSelectionMode)
  15018. return;
  15019. var keepOrder = options && options.keepOrder;
  15020. var $byLines = options == true || options && options.$byLines
  15021. var session = this.session;
  15022. var selection = this.selection;
  15023. var rangeList = selection.rangeList;
  15024. var ranges = (keepOrder ? selection : rangeList).ranges;
  15025. var result;
  15026. if (!ranges.length)
  15027. return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15028. var reg = selection._eventRegistry;
  15029. selection._eventRegistry = {};
  15030. var tmpSel = new Selection(session);
  15031. this.inVirtualSelectionMode = true;
  15032. for (var i = ranges.length; i--;) {
  15033. if ($byLines) {
  15034. while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
  15035. i--;
  15036. }
  15037. tmpSel.fromOrientedRange(ranges[i]);
  15038. tmpSel.index = i;
  15039. this.selection = session.selection = tmpSel;
  15040. var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15041. if (!result && cmdResult !== undefined)
  15042. result = cmdResult;
  15043. tmpSel.toOrientedRange(ranges[i]);
  15044. }
  15045. tmpSel.detach();
  15046. this.selection = session.selection = selection;
  15047. this.inVirtualSelectionMode = false;
  15048. selection._eventRegistry = reg;
  15049. selection.mergeOverlappingRanges();
  15050. var anim = this.renderer.$scrollAnimation;
  15051. this.onCursorChange();
  15052. this.onSelectionChange();
  15053. if (anim && anim.from == anim.to)
  15054. this.renderer.animateScrolling(anim.from);
  15055. return result;
  15056. };
  15057. this.exitMultiSelectMode = function() {
  15058. if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
  15059. return;
  15060. this.multiSelect.toSingleRange();
  15061. };
  15062. this.getSelectedText = function() {
  15063. var text = "";
  15064. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15065. var ranges = this.multiSelect.rangeList.ranges;
  15066. var buf = [];
  15067. for (var i = 0; i < ranges.length; i++) {
  15068. buf.push(this.session.getTextRange(ranges[i]));
  15069. }
  15070. var nl = this.session.getDocument().getNewLineCharacter();
  15071. text = buf.join(nl);
  15072. if (text.length == (buf.length - 1) * nl.length)
  15073. text = "";
  15074. } else if (!this.selection.isEmpty()) {
  15075. text = this.session.getTextRange(this.getSelectionRange());
  15076. }
  15077. return text;
  15078. };
  15079. this.$checkMultiselectChange = function(e, anchor) {
  15080. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15081. var range = this.multiSelect.ranges[0];
  15082. if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
  15083. return;
  15084. var pos = anchor == this.multiSelect.anchor
  15085. ? range.cursor == range.start ? range.end : range.start
  15086. : range.cursor;
  15087. if (pos.row != anchor.row
  15088. || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
  15089. this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
  15090. }
  15091. };
  15092. this.findAll = function(needle, options, additive) {
  15093. options = options || {};
  15094. options.needle = needle || options.needle;
  15095. if (options.needle == undefined) {
  15096. var range = this.selection.isEmpty()
  15097. ? this.selection.getWordRange()
  15098. : this.selection.getRange();
  15099. options.needle = this.session.getTextRange(range);
  15100. }
  15101. this.$search.set(options);
  15102. var ranges = this.$search.findAll(this.session);
  15103. if (!ranges.length)
  15104. return 0;
  15105. this.$blockScrolling += 1;
  15106. var selection = this.multiSelect;
  15107. if (!additive)
  15108. selection.toSingleRange(ranges[0]);
  15109. for (var i = ranges.length; i--; )
  15110. selection.addRange(ranges[i], true);
  15111. if (range && selection.rangeList.rangeAtPoint(range.start))
  15112. selection.addRange(range, true);
  15113. this.$blockScrolling -= 1;
  15114. return ranges.length;
  15115. };
  15116. this.selectMoreLines = function(dir, skip) {
  15117. var range = this.selection.toOrientedRange();
  15118. var isBackwards = range.cursor == range.end;
  15119. var screenLead = this.session.documentToScreenPosition(range.cursor);
  15120. if (this.selection.$desiredColumn)
  15121. screenLead.column = this.selection.$desiredColumn;
  15122. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  15123. if (!range.isEmpty()) {
  15124. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  15125. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  15126. } else {
  15127. var anchor = lead;
  15128. }
  15129. if (isBackwards) {
  15130. var newRange = Range.fromPoints(lead, anchor);
  15131. newRange.cursor = newRange.start;
  15132. } else {
  15133. var newRange = Range.fromPoints(anchor, lead);
  15134. newRange.cursor = newRange.end;
  15135. }
  15136. newRange.desiredColumn = screenLead.column;
  15137. if (!this.selection.inMultiSelectMode) {
  15138. this.selection.addRange(range);
  15139. } else {
  15140. if (skip)
  15141. var toRemove = range.cursor;
  15142. }
  15143. this.selection.addRange(newRange);
  15144. if (toRemove)
  15145. this.selection.substractPoint(toRemove);
  15146. };
  15147. this.transposeSelections = function(dir) {
  15148. var session = this.session;
  15149. var sel = session.multiSelect;
  15150. var all = sel.ranges;
  15151. for (var i = all.length; i--; ) {
  15152. var range = all[i];
  15153. if (range.isEmpty()) {
  15154. var tmp = session.getWordRange(range.start.row, range.start.column);
  15155. range.start.row = tmp.start.row;
  15156. range.start.column = tmp.start.column;
  15157. range.end.row = tmp.end.row;
  15158. range.end.column = tmp.end.column;
  15159. }
  15160. }
  15161. sel.mergeOverlappingRanges();
  15162. var words = [];
  15163. for (var i = all.length; i--; ) {
  15164. var range = all[i];
  15165. words.unshift(session.getTextRange(range));
  15166. }
  15167. if (dir < 0)
  15168. words.unshift(words.pop());
  15169. else
  15170. words.push(words.shift());
  15171. for (var i = all.length; i--; ) {
  15172. var range = all[i];
  15173. var tmp = range.clone();
  15174. session.replace(range, words[i]);
  15175. range.start.row = tmp.start.row;
  15176. range.start.column = tmp.start.column;
  15177. }
  15178. };
  15179. this.selectMore = function(dir, skip, stopAtFirst) {
  15180. var session = this.session;
  15181. var sel = session.multiSelect;
  15182. var range = sel.toOrientedRange();
  15183. if (range.isEmpty()) {
  15184. range = session.getWordRange(range.start.row, range.start.column);
  15185. range.cursor = dir == -1 ? range.start : range.end;
  15186. this.multiSelect.addRange(range);
  15187. if (stopAtFirst)
  15188. return;
  15189. }
  15190. var needle = session.getTextRange(range);
  15191. var newRange = find(session, needle, dir);
  15192. if (newRange) {
  15193. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  15194. this.$blockScrolling += 1;
  15195. this.session.unfold(newRange);
  15196. this.multiSelect.addRange(newRange);
  15197. this.$blockScrolling -= 1;
  15198. this.renderer.scrollCursorIntoView(null, 0.5);
  15199. }
  15200. if (skip)
  15201. this.multiSelect.substractPoint(range.cursor);
  15202. };
  15203. this.alignCursors = function() {
  15204. var session = this.session;
  15205. var sel = session.multiSelect;
  15206. var ranges = sel.ranges;
  15207. var row = -1;
  15208. var sameRowRanges = ranges.filter(function(r) {
  15209. if (r.cursor.row == row)
  15210. return true;
  15211. row = r.cursor.row;
  15212. });
  15213. if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
  15214. var range = this.selection.getRange();
  15215. var fr = range.start.row, lr = range.end.row;
  15216. var guessRange = fr == lr;
  15217. if (guessRange) {
  15218. var max = this.session.getLength();
  15219. var line;
  15220. do {
  15221. line = this.session.getLine(lr);
  15222. } while (/[=:]/.test(line) && ++lr < max);
  15223. do {
  15224. line = this.session.getLine(fr);
  15225. } while (/[=:]/.test(line) && --fr > 0);
  15226. if (fr < 0) fr = 0;
  15227. if (lr >= max) lr = max - 1;
  15228. }
  15229. var lines = this.session.doc.removeLines(fr, lr);
  15230. lines = this.$reAlignText(lines, guessRange);
  15231. this.session.doc.insert({row: fr, column: 0}, lines.join("\n") + "\n");
  15232. if (!guessRange) {
  15233. range.start.column = 0;
  15234. range.end.column = lines[lines.length - 1].length;
  15235. }
  15236. this.selection.setRange(range);
  15237. } else {
  15238. sameRowRanges.forEach(function(r) {
  15239. sel.substractPoint(r.cursor);
  15240. });
  15241. var maxCol = 0;
  15242. var minSpace = Infinity;
  15243. var spaceOffsets = ranges.map(function(r) {
  15244. var p = r.cursor;
  15245. var line = session.getLine(p.row);
  15246. var spaceOffset = line.substr(p.column).search(/\S/g);
  15247. if (spaceOffset == -1)
  15248. spaceOffset = 0;
  15249. if (p.column > maxCol)
  15250. maxCol = p.column;
  15251. if (spaceOffset < minSpace)
  15252. minSpace = spaceOffset;
  15253. return spaceOffset;
  15254. });
  15255. ranges.forEach(function(r, i) {
  15256. var p = r.cursor;
  15257. var l = maxCol - p.column;
  15258. var d = spaceOffsets[i] - minSpace;
  15259. if (l > d)
  15260. session.insert(p, lang.stringRepeat(" ", l - d));
  15261. else
  15262. session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
  15263. r.start.column = r.end.column = maxCol;
  15264. r.start.row = r.end.row = p.row;
  15265. r.cursor = r.end;
  15266. });
  15267. sel.fromOrientedRange(ranges[0]);
  15268. this.renderer.updateCursor();
  15269. this.renderer.updateBackMarkers();
  15270. }
  15271. };
  15272. this.$reAlignText = function(lines, forceLeft) {
  15273. var isLeftAligned = true, isRightAligned = true;
  15274. var startW, textW, endW;
  15275. return lines.map(function(line) {
  15276. var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
  15277. if (!m)
  15278. return [line];
  15279. if (startW == null) {
  15280. startW = m[1].length;
  15281. textW = m[2].length;
  15282. endW = m[3].length;
  15283. return m;
  15284. }
  15285. if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
  15286. isRightAligned = false;
  15287. if (startW != m[1].length)
  15288. isLeftAligned = false;
  15289. if (startW > m[1].length)
  15290. startW = m[1].length;
  15291. if (textW < m[2].length)
  15292. textW = m[2].length;
  15293. if (endW > m[3].length)
  15294. endW = m[3].length;
  15295. return m;
  15296. }).map(forceLeft ? alignLeft :
  15297. isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
  15298. function spaces(n) {
  15299. return lang.stringRepeat(" ", n);
  15300. }
  15301. function alignLeft(m) {
  15302. return !m[2] ? m[0] : spaces(startW) + m[2]
  15303. + spaces(textW - m[2].length + endW)
  15304. + m[4].replace(/^([=:])\s+/, "$1 ");
  15305. }
  15306. function alignRight(m) {
  15307. return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
  15308. + spaces(endW, " ")
  15309. + m[4].replace(/^([=:])\s+/, "$1 ");
  15310. }
  15311. function unAlign(m) {
  15312. return !m[2] ? m[0] : spaces(startW) + m[2]
  15313. + spaces(endW)
  15314. + m[4].replace(/^([=:])\s+/, "$1 ");
  15315. }
  15316. };
  15317. }).call(Editor.prototype);
  15318. function isSamePoint(p1, p2) {
  15319. return p1.row == p2.row && p1.column == p2.column;
  15320. }
  15321. exports.onSessionChange = function(e) {
  15322. var session = e.session;
  15323. if (session && !session.multiSelect) {
  15324. session.$selectionMarkers = [];
  15325. session.selection.$initRangeList();
  15326. session.multiSelect = session.selection;
  15327. }
  15328. this.multiSelect = session && session.multiSelect;
  15329. var oldSession = e.oldSession;
  15330. if (oldSession) {
  15331. oldSession.multiSelect.off("addRange", this.$onAddRange);
  15332. oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
  15333. oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
  15334. oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
  15335. oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
  15336. oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
  15337. }
  15338. if (session) {
  15339. session.multiSelect.on("addRange", this.$onAddRange);
  15340. session.multiSelect.on("removeRange", this.$onRemoveRange);
  15341. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  15342. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  15343. session.multiSelect.lead.on("change", this.$checkMultiselectChange);
  15344. session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
  15345. }
  15346. if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  15347. if (session.selection.inMultiSelectMode)
  15348. this.$onMultiSelect();
  15349. else
  15350. this.$onSingleSelect();
  15351. }
  15352. };
  15353. function MultiSelect(editor) {
  15354. if (editor.$multiselectOnSessionChange)
  15355. return;
  15356. editor.$onAddRange = editor.$onAddRange.bind(editor);
  15357. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  15358. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  15359. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  15360. editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
  15361. editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
  15362. editor.$multiselectOnSessionChange(editor);
  15363. editor.on("changeSession", editor.$multiselectOnSessionChange);
  15364. editor.on("mousedown", onMouseDown);
  15365. editor.commands.addCommands(commands.defaultCommands);
  15366. addAltCursorListeners(editor);
  15367. }
  15368. function addAltCursorListeners(editor){
  15369. var el = editor.textInput.getElement();
  15370. var altCursor = false;
  15371. event.addListener(el, "keydown", function(e) {
  15372. if (e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey)) {
  15373. if (!altCursor) {
  15374. editor.renderer.setMouseCursor("crosshair");
  15375. altCursor = true;
  15376. }
  15377. } else if (altCursor) {
  15378. reset();
  15379. }
  15380. });
  15381. event.addListener(el, "keyup", reset);
  15382. event.addListener(el, "blur", reset);
  15383. function reset(e) {
  15384. if (altCursor) {
  15385. editor.renderer.setMouseCursor("");
  15386. altCursor = false;
  15387. }
  15388. }
  15389. }
  15390. exports.MultiSelect = MultiSelect;
  15391. require("./config").defineOptions(Editor.prototype, "editor", {
  15392. enableMultiselect: {
  15393. set: function(val) {
  15394. MultiSelect(this);
  15395. if (val) {
  15396. this.on("changeSession", this.$multiselectOnSessionChange);
  15397. this.on("mousedown", onMouseDown);
  15398. } else {
  15399. this.off("changeSession", this.$multiselectOnSessionChange);
  15400. this.off("mousedown", onMouseDown);
  15401. }
  15402. },
  15403. value: true
  15404. }
  15405. });
  15406. });
  15407. ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
  15408. "use strict";
  15409. var Range = require("../../range").Range;
  15410. var FoldMode = exports.FoldMode = function() {};
  15411. (function() {
  15412. this.foldingStartMarker = null;
  15413. this.foldingStopMarker = null;
  15414. this.getFoldWidget = function(session, foldStyle, row) {
  15415. var line = session.getLine(row);
  15416. if (this.foldingStartMarker.test(line))
  15417. return "start";
  15418. if (foldStyle == "markbeginend"
  15419. && this.foldingStopMarker
  15420. && this.foldingStopMarker.test(line))
  15421. return "end";
  15422. return "";
  15423. };
  15424. this.getFoldWidgetRange = function(session, foldStyle, row) {
  15425. return null;
  15426. };
  15427. this.indentationBlock = function(session, row, column) {
  15428. var re = /\S/;
  15429. var line = session.getLine(row);
  15430. var startLevel = line.search(re);
  15431. if (startLevel == -1)
  15432. return;
  15433. var startColumn = column || line.length;
  15434. var maxRow = session.getLength();
  15435. var startRow = row;
  15436. var endRow = row;
  15437. while (++row < maxRow) {
  15438. var level = session.getLine(row).search(re);
  15439. if (level == -1)
  15440. continue;
  15441. if (level <= startLevel)
  15442. break;
  15443. endRow = row;
  15444. }
  15445. if (endRow > startRow) {
  15446. var endColumn = session.getLine(endRow).length;
  15447. return new Range(startRow, startColumn, endRow, endColumn);
  15448. }
  15449. };
  15450. this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
  15451. var start = {row: row, column: column + 1};
  15452. var end = session.$findClosingBracket(bracket, start, typeRe);
  15453. if (!end)
  15454. return;
  15455. var fw = session.foldWidgets[end.row];
  15456. if (fw == null)
  15457. fw = session.getFoldWidget(end.row);
  15458. if (fw == "start" && end.row > start.row) {
  15459. end.row --;
  15460. end.column = session.getLine(end.row).length;
  15461. }
  15462. return Range.fromPoints(start, end);
  15463. };
  15464. this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
  15465. var end = {row: row, column: column};
  15466. var start = session.$findOpeningBracket(bracket, end);
  15467. if (!start)
  15468. return;
  15469. start.column++;
  15470. end.column--;
  15471. return Range.fromPoints(start, end);
  15472. };
  15473. }).call(FoldMode.prototype);
  15474. });
  15475. ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  15476. "use strict";
  15477. exports.isDark = false;
  15478. exports.cssClass = "ace-tm";
  15479. exports.cssText = ".ace-tm .ace_gutter {\
  15480. background: #f0f0f0;\
  15481. color: #333;\
  15482. }\
  15483. .ace-tm .ace_print-margin {\
  15484. width: 1px;\
  15485. background: #e8e8e8;\
  15486. }\
  15487. .ace-tm .ace_fold {\
  15488. background-color: #6B72E6;\
  15489. }\
  15490. .ace-tm {\
  15491. background-color: #FFFFFF;\
  15492. color: black;\
  15493. }\
  15494. .ace-tm .ace_cursor {\
  15495. color: black;\
  15496. }\
  15497. .ace-tm .ace_invisible {\
  15498. color: rgb(191, 191, 191);\
  15499. }\
  15500. .ace-tm .ace_storage,\
  15501. .ace-tm .ace_keyword {\
  15502. color: blue;\
  15503. }\
  15504. .ace-tm .ace_constant {\
  15505. color: rgb(197, 6, 11);\
  15506. }\
  15507. .ace-tm .ace_constant.ace_buildin {\
  15508. color: rgb(88, 72, 246);\
  15509. }\
  15510. .ace-tm .ace_constant.ace_language {\
  15511. color: rgb(88, 92, 246);\
  15512. }\
  15513. .ace-tm .ace_constant.ace_library {\
  15514. color: rgb(6, 150, 14);\
  15515. }\
  15516. .ace-tm .ace_invalid {\
  15517. background-color: rgba(255, 0, 0, 0.1);\
  15518. color: red;\
  15519. }\
  15520. .ace-tm .ace_support.ace_function {\
  15521. color: rgb(60, 76, 114);\
  15522. }\
  15523. .ace-tm .ace_support.ace_constant {\
  15524. color: rgb(6, 150, 14);\
  15525. }\
  15526. .ace-tm .ace_support.ace_type,\
  15527. .ace-tm .ace_support.ace_class {\
  15528. color: rgb(109, 121, 222);\
  15529. }\
  15530. .ace-tm .ace_keyword.ace_operator {\
  15531. color: rgb(104, 118, 135);\
  15532. }\
  15533. .ace-tm .ace_string {\
  15534. color: rgb(3, 106, 7);\
  15535. }\
  15536. .ace-tm .ace_comment {\
  15537. color: rgb(76, 136, 107);\
  15538. }\
  15539. .ace-tm .ace_comment.ace_doc {\
  15540. color: rgb(0, 102, 255);\
  15541. }\
  15542. .ace-tm .ace_comment.ace_doc.ace_tag {\
  15543. color: rgb(128, 159, 191);\
  15544. }\
  15545. .ace-tm .ace_constant.ace_numeric {\
  15546. color: rgb(0, 0, 205);\
  15547. }\
  15548. .ace-tm .ace_variable {\
  15549. color: rgb(49, 132, 149);\
  15550. }\
  15551. .ace-tm .ace_xml-pe {\
  15552. color: rgb(104, 104, 91);\
  15553. }\
  15554. .ace-tm .ace_entity.ace_name.ace_function {\
  15555. color: #0000A2;\
  15556. }\
  15557. .ace-tm .ace_heading {\
  15558. color: rgb(12, 7, 255);\
  15559. }\
  15560. .ace-tm .ace_list {\
  15561. color:rgb(185, 6, 144);\
  15562. }\
  15563. .ace-tm .ace_meta.ace_tag {\
  15564. color:rgb(0, 22, 142);\
  15565. }\
  15566. .ace-tm .ace_string.ace_regex {\
  15567. color: rgb(255, 0, 0)\
  15568. }\
  15569. .ace-tm .ace_marker-layer .ace_selection {\
  15570. background: rgb(181, 213, 255);\
  15571. }\
  15572. .ace-tm.ace_multiselect .ace_selection.ace_start {\
  15573. box-shadow: 0 0 3px 0px white;\
  15574. border-radius: 2px;\
  15575. }\
  15576. .ace-tm .ace_marker-layer .ace_step {\
  15577. background: rgb(252, 255, 0);\
  15578. }\
  15579. .ace-tm .ace_marker-layer .ace_stack {\
  15580. background: rgb(164, 229, 101);\
  15581. }\
  15582. .ace-tm .ace_marker-layer .ace_bracket {\
  15583. margin: -1px 0 0 -1px;\
  15584. border: 1px solid rgb(192, 192, 192);\
  15585. }\
  15586. .ace-tm .ace_marker-layer .ace_active-line {\
  15587. background: rgba(0, 0, 0, 0.07);\
  15588. }\
  15589. .ace-tm .ace_gutter-active-line {\
  15590. background-color : #dcdcdc;\
  15591. }\
  15592. .ace-tm .ace_marker-layer .ace_selected-word {\
  15593. background: rgb(250, 250, 255);\
  15594. border: 1px solid rgb(200, 200, 250);\
  15595. }\
  15596. .ace-tm .ace_indent-guide {\
  15597. background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
  15598. }\
  15599. ";
  15600. var dom = require("../lib/dom");
  15601. dom.importCssString(exports.cssText, exports.cssClass);
  15602. });
  15603. ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
  15604. "use strict";
  15605. var oop = require("./lib/oop");
  15606. var dom = require("./lib/dom");
  15607. var Range = require("./range").Range;
  15608. function LineWidgets(session) {
  15609. this.session = session;
  15610. this.session.widgetManager = this;
  15611. this.session.getRowLength = this.getRowLength;
  15612. this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
  15613. this.updateOnChange = this.updateOnChange.bind(this);
  15614. this.renderWidgets = this.renderWidgets.bind(this);
  15615. this.measureWidgets = this.measureWidgets.bind(this);
  15616. this.session._changedWidgets = [];
  15617. this.$onChangeEditor = this.$onChangeEditor.bind(this);
  15618. this.session.on("change", this.updateOnChange);
  15619. this.session.on("changeEditor", this.$onChangeEditor);
  15620. }
  15621. (function() {
  15622. this.getRowLength = function(row) {
  15623. var h;
  15624. if (this.lineWidgets)
  15625. h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  15626. else
  15627. h = 0;
  15628. if (!this.$useWrapMode || !this.$wrapData[row]) {
  15629. return 1 + h;
  15630. } else {
  15631. return this.$wrapData[row].length + 1 + h;
  15632. }
  15633. };
  15634. this.$getWidgetScreenLength = function() {
  15635. var screenRows = 0;
  15636. this.lineWidgets.forEach(function(w){
  15637. if (w && w.rowCount)
  15638. screenRows +=w.rowCount;
  15639. });
  15640. return screenRows;
  15641. };
  15642. this.$onChangeEditor = function(e) {
  15643. this.attach(e.editor);
  15644. };
  15645. this.attach = function(editor) {
  15646. if (editor && editor.widgetManager && editor.widgetManager != this)
  15647. editor.widgetManager.detach();
  15648. if (this.editor == editor)
  15649. return;
  15650. this.detach();
  15651. this.editor = editor;
  15652. if (editor) {
  15653. editor.widgetManager = this;
  15654. editor.renderer.on("beforeRender", this.measureWidgets);
  15655. editor.renderer.on("afterRender", this.renderWidgets);
  15656. }
  15657. };
  15658. this.detach = function(e) {
  15659. var editor = this.editor;
  15660. if (!editor)
  15661. return;
  15662. this.editor = null;
  15663. editor.widgetManager = null;
  15664. editor.renderer.off("beforeRender", this.measureWidgets);
  15665. editor.renderer.off("afterRender", this.renderWidgets);
  15666. var lineWidgets = this.session.lineWidgets;
  15667. lineWidgets && lineWidgets.forEach(function(w) {
  15668. if (w && w.el && w.el.parentNode) {
  15669. w._inDocument = false;
  15670. w.el.parentNode.removeChild(w.el);
  15671. }
  15672. });
  15673. };
  15674. this.updateOnChange = function(e) {
  15675. var lineWidgets = this.session.lineWidgets;
  15676. if (!lineWidgets) return;
  15677. var delta = e.data;
  15678. var range = delta.range;
  15679. var startRow = range.start.row;
  15680. var len = range.end.row - startRow;
  15681. if (len === 0) {
  15682. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  15683. var removed = lineWidgets.splice(startRow + 1, len);
  15684. removed.forEach(function(w) {
  15685. w && this.removeLineWidget(w);
  15686. }, this);
  15687. this.$updateRows();
  15688. } else {
  15689. var args = new Array(len);
  15690. args.unshift(startRow, 0);
  15691. lineWidgets.splice.apply(lineWidgets, args);
  15692. this.$updateRows();
  15693. }
  15694. };
  15695. this.$updateRows = function() {
  15696. var lineWidgets = this.session.lineWidgets;
  15697. if (!lineWidgets) return;
  15698. var noWidgets = true;
  15699. lineWidgets.forEach(function(w, i) {
  15700. if (w) {
  15701. noWidgets = false;
  15702. w.row = i;
  15703. }
  15704. });
  15705. if (noWidgets)
  15706. this.session.lineWidgets = null;
  15707. };
  15708. this.addLineWidget = function(w) {
  15709. if (!this.session.lineWidgets)
  15710. this.session.lineWidgets = new Array(this.session.getLength());
  15711. this.session.lineWidgets[w.row] = w;
  15712. var renderer = this.editor.renderer;
  15713. if (w.html && !w.el) {
  15714. w.el = dom.createElement("div");
  15715. w.el.innerHTML = w.html;
  15716. }
  15717. if (w.el) {
  15718. dom.addCssClass(w.el, "ace_lineWidgetContainer");
  15719. w.el.style.position = "absolute";
  15720. w.el.style.zIndex = 5;
  15721. renderer.container.appendChild(w.el);
  15722. w._inDocument = true;
  15723. }
  15724. if (!w.coverGutter) {
  15725. w.el.style.zIndex = 3;
  15726. }
  15727. if (!w.pixelHeight) {
  15728. w.pixelHeight = w.el.offsetHeight;
  15729. }
  15730. if (w.rowCount == null)
  15731. w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
  15732. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  15733. this.$updateRows();
  15734. this.renderWidgets(null, renderer);
  15735. return w;
  15736. };
  15737. this.removeLineWidget = function(w) {
  15738. w._inDocument = false;
  15739. if (w.el && w.el.parentNode)
  15740. w.el.parentNode.removeChild(w.el);
  15741. if (w.editor && w.editor.destroy) try {
  15742. w.editor.destroy();
  15743. } catch(e){}
  15744. if (this.session.lineWidgets)
  15745. this.session.lineWidgets[w.row] = undefined;
  15746. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  15747. this.$updateRows();
  15748. };
  15749. this.onWidgetChanged = function(w) {
  15750. this.session._changedWidgets.push(w);
  15751. this.editor && this.editor.renderer.updateFull();
  15752. };
  15753. this.measureWidgets = function(e, renderer) {
  15754. var changedWidgets = this.session._changedWidgets;
  15755. var config = renderer.layerConfig;
  15756. if (!changedWidgets || !changedWidgets.length) return;
  15757. var min = Infinity;
  15758. for (var i = 0; i < changedWidgets.length; i++) {
  15759. var w = changedWidgets[i];
  15760. if (!w._inDocument) {
  15761. w._inDocument = true;
  15762. renderer.container.appendChild(w.el);
  15763. }
  15764. w.h = w.el.offsetHeight;
  15765. if (!w.fixedWidth) {
  15766. w.w = w.el.offsetWidth;
  15767. w.screenWidth = Math.ceil(w.w / config.characterWidth);
  15768. }
  15769. var rowCount = w.h / config.lineHeight;
  15770. if (w.coverLine) {
  15771. rowCount -= this.session.getRowLineCount(w.row);
  15772. if (rowCount < 0)
  15773. rowCount = 0;
  15774. }
  15775. if (w.rowCount != rowCount) {
  15776. w.rowCount = rowCount;
  15777. if (w.row < min)
  15778. min = w.row;
  15779. }
  15780. }
  15781. if (min != Infinity) {
  15782. this.session._emit("changeFold", {data:{start:{row: min}}});
  15783. this.session.lineWidgetWidth = null;
  15784. }
  15785. this.session._changedWidgets = [];
  15786. };
  15787. this.renderWidgets = function(e, renderer) {
  15788. var config = renderer.layerConfig;
  15789. var lineWidgets = this.session.lineWidgets;
  15790. if (!lineWidgets)
  15791. return;
  15792. var first = Math.min(this.firstRow, config.firstRow);
  15793. var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
  15794. while (first > 0 && !lineWidgets[first])
  15795. first--;
  15796. this.firstRow = config.firstRow;
  15797. this.lastRow = config.lastRow;
  15798. renderer.$cursorLayer.config = config;
  15799. for (var i = first; i <= last; i++) {
  15800. var w = lineWidgets[i];
  15801. if (!w || !w.el) continue;
  15802. if (!w._inDocument) {
  15803. w._inDocument = true;
  15804. renderer.container.appendChild(w.el);
  15805. }
  15806. var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
  15807. if (!w.coverLine)
  15808. top += config.lineHeight * this.session.getRowLineCount(w.row);
  15809. w.el.style.top = top - config.offset + "px";
  15810. var left = w.coverGutter ? 0 : renderer.gutterWidth;
  15811. if (!w.fixedWidth)
  15812. left -= renderer.scrollLeft;
  15813. w.el.style.left = left + "px";
  15814. if (w.fixedWidth) {
  15815. w.el.style.right = renderer.scrollBar.getWidth() + "px";
  15816. } else {
  15817. w.el.style.right = "";
  15818. }
  15819. }
  15820. };
  15821. }).call(LineWidgets.prototype);
  15822. exports.LineWidgets = LineWidgets;
  15823. });
  15824. ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
  15825. "use strict";
  15826. var LineWidgets = require("../line_widgets").LineWidgets;
  15827. var dom = require("../lib/dom");
  15828. var Range = require("../range").Range;
  15829. function binarySearch(array, needle, comparator) {
  15830. var first = 0;
  15831. var last = array.length - 1;
  15832. while (first <= last) {
  15833. var mid = (first + last) >> 1;
  15834. var c = comparator(needle, array[mid]);
  15835. if (c > 0)
  15836. first = mid + 1;
  15837. else if (c < 0)
  15838. last = mid - 1;
  15839. else
  15840. return mid;
  15841. }
  15842. return -(first + 1);
  15843. }
  15844. function findAnnotations(session, row, dir) {
  15845. var annotations = session.getAnnotations().sort(Range.comparePoints);
  15846. if (!annotations.length)
  15847. return;
  15848. var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
  15849. if (i < 0)
  15850. i = -i - 1;
  15851. if (i >= annotations.length - 1)
  15852. i = dir > 0 ? 0 : annotations.length - 1;
  15853. else if (i === 0 && dir < 0)
  15854. i = annotations.length - 1;
  15855. var annotation = annotations[i];
  15856. if (!annotation || !dir)
  15857. return;
  15858. if (annotation.row === row) {
  15859. do {
  15860. annotation = annotations[i += dir];
  15861. } while (annotation && annotation.row === row);
  15862. if (!annotation)
  15863. return annotations.slice();
  15864. }
  15865. var matched = [];
  15866. row = annotation.row;
  15867. do {
  15868. matched[dir < 0 ? "unshift" : "push"](annotation);
  15869. annotation = annotations[i += dir];
  15870. } while (annotation && annotation.row == row);
  15871. return matched.length && matched;
  15872. }
  15873. exports.showErrorMarker = function(editor, dir) {
  15874. var session = editor.session;
  15875. if (!session.widgetManager) {
  15876. session.widgetManager = new LineWidgets(session);
  15877. session.widgetManager.attach(editor);
  15878. }
  15879. var pos = editor.getCursorPosition();
  15880. var row = pos.row;
  15881. var oldWidget = session.lineWidgets && session.lineWidgets[row];
  15882. if (oldWidget) {
  15883. oldWidget.destroy();
  15884. } else {
  15885. row -= dir;
  15886. }
  15887. var annotations = findAnnotations(session, row, dir);
  15888. var gutterAnno;
  15889. if (annotations) {
  15890. var annotation = annotations[0];
  15891. pos.column = (annotation.pos && typeof annotation.column != "number"
  15892. ? annotation.pos.sc
  15893. : annotation.column) || 0;
  15894. pos.row = annotation.row;
  15895. gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
  15896. } else if (oldWidget) {
  15897. return;
  15898. } else {
  15899. gutterAnno = {
  15900. text: ["Looks good!"],
  15901. className: "ace_ok"
  15902. };
  15903. }
  15904. editor.session.unfold(pos.row);
  15905. editor.selection.moveToPosition(pos);
  15906. var w = {
  15907. row: pos.row,
  15908. fixedWidth: true,
  15909. coverGutter: true,
  15910. el: dom.createElement("div")
  15911. };
  15912. var el = w.el.appendChild(dom.createElement("div"));
  15913. var arrow = w.el.appendChild(dom.createElement("div"));
  15914. arrow.className = "error_widget_arrow " + gutterAnno.className;
  15915. var left = editor.renderer.$cursorLayer
  15916. .getPixelPosition(pos).left;
  15917. arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
  15918. w.el.className = "error_widget_wrapper";
  15919. el.className = "error_widget " + gutterAnno.className;
  15920. el.innerHTML = gutterAnno.text.join("<br>");
  15921. el.appendChild(dom.createElement("div"));
  15922. var kb = function(_, hashId, keyString) {
  15923. if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
  15924. w.destroy();
  15925. return {command: "null"};
  15926. }
  15927. };
  15928. w.destroy = function() {
  15929. if (editor.$mouseHandler.isMousePressed)
  15930. return;
  15931. editor.keyBinding.removeKeyboardHandler(kb);
  15932. session.widgetManager.removeLineWidget(w);
  15933. editor.off("changeSelection", w.destroy);
  15934. editor.off("changeSession", w.destroy);
  15935. editor.off("mouseup", w.destroy);
  15936. editor.off("change", w.destroy);
  15937. };
  15938. editor.keyBinding.addKeyboardHandler(kb);
  15939. editor.on("changeSelection", w.destroy);
  15940. editor.on("changeSession", w.destroy);
  15941. editor.on("mouseup", w.destroy);
  15942. editor.on("change", w.destroy);
  15943. editor.session.widgetManager.addLineWidget(w);
  15944. w.el.onmousedown = editor.focus.bind(editor);
  15945. editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
  15946. };
  15947. dom.importCssString("\
  15948. .error_widget_wrapper {\
  15949. background: inherit;\
  15950. color: inherit;\
  15951. border:none\
  15952. }\
  15953. .error_widget {\
  15954. border-top: solid 2px;\
  15955. border-bottom: solid 2px;\
  15956. margin: 5px 0;\
  15957. padding: 10px 40px;\
  15958. white-space: pre-wrap;\
  15959. }\
  15960. .error_widget.ace_error, .error_widget_arrow.ace_error{\
  15961. border-color: #ff5a5a\
  15962. }\
  15963. .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
  15964. border-color: #F1D817\
  15965. }\
  15966. .error_widget.ace_info, .error_widget_arrow.ace_info{\
  15967. border-color: #5a5a5a\
  15968. }\
  15969. .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
  15970. border-color: #5aaa5a\
  15971. }\
  15972. .error_widget_arrow {\
  15973. position: absolute;\
  15974. border: solid 5px;\
  15975. border-top-color: transparent!important;\
  15976. border-right-color: transparent!important;\
  15977. border-left-color: transparent!important;\
  15978. top: -5px;\
  15979. }\
  15980. ", "");
  15981. });
  15982. ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"], function(require, exports, module) {
  15983. "use strict";
  15984. require("./lib/fixoldbrowsers");
  15985. var dom = require("./lib/dom");
  15986. var event = require("./lib/event");
  15987. var Editor = require("./editor").Editor;
  15988. var EditSession = require("./edit_session").EditSession;
  15989. var UndoManager = require("./undomanager").UndoManager;
  15990. var Renderer = require("./virtual_renderer").VirtualRenderer;
  15991. require("./worker/worker_client");
  15992. require("./keyboard/hash_handler");
  15993. require("./placeholder");
  15994. require("./multi_select");
  15995. require("./mode/folding/fold_mode");
  15996. require("./theme/textmate");
  15997. require("./ext/error_marker");
  15998. exports.config = require("./config");
  15999. exports.require = require;
  16000. exports.edit = function(el) {
  16001. if (typeof(el) == "string") {
  16002. var _id = el;
  16003. el = document.getElementById(_id);
  16004. if (!el)
  16005. throw new Error("ace.edit can't find div #" + _id);
  16006. }
  16007. if (el && el.env && el.env.editor instanceof Editor)
  16008. return el.env.editor;
  16009. var value = "";
  16010. if (el && /input|textarea/i.test(el.tagName)) {
  16011. var oldNode = el;
  16012. value = oldNode.value;
  16013. el = dom.createElement("pre");
  16014. oldNode.parentNode.replaceChild(el, oldNode);
  16015. } else {
  16016. value = dom.getInnerText(el);
  16017. el.innerHTML = '';
  16018. }
  16019. var doc = exports.createEditSession(value);
  16020. var editor = new Editor(new Renderer(el));
  16021. editor.setSession(doc);
  16022. var env = {
  16023. document: doc,
  16024. editor: editor,
  16025. onResize: editor.resize.bind(editor, null)
  16026. };
  16027. if (oldNode) env.textarea = oldNode;
  16028. event.addListener(window, "resize", env.onResize);
  16029. editor.on("destroy", function() {
  16030. event.removeListener(window, "resize", env.onResize);
  16031. env.editor.container.env = null; // prevent memory leak on old ie
  16032. });
  16033. editor.container.env = editor.env = env;
  16034. return editor;
  16035. };
  16036. exports.createEditSession = function(text, mode) {
  16037. var doc = new EditSession(text, mode);
  16038. doc.setUndoManager(new UndoManager());
  16039. return doc;
  16040. }
  16041. exports.EditSession = EditSession;
  16042. exports.UndoManager = UndoManager;
  16043. });
  16044. (function() {
  16045. ace.require(["ace/ace"], function(a) {
  16046. a && a.config.init(true);
  16047. if (!window.ace)
  16048. window.ace = a;
  16049. for (var key in a) if (a.hasOwnProperty(key))
  16050. window.ace[key] = a[key];
  16051. });
  16052. })();