ace.js 613 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285
  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() { return this; })();
  38. if (!global && typeof window != "undefined") global = window; // strict mode
  39. if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
  40. return;
  41. var define = function(module, deps, payload) {
  42. if (typeof module !== "string") {
  43. if (define.original)
  44. define.original.apply(this, arguments);
  45. else {
  46. console.error("dropping module because define wasn\'t a string.");
  47. console.trace();
  48. }
  49. return;
  50. }
  51. if (arguments.length == 2)
  52. payload = deps;
  53. if (!define.modules[module]) {
  54. define.payloads[module] = payload;
  55. define.modules[module] = null;
  56. }
  57. };
  58. define.modules = {};
  59. define.payloads = {};
  60. /**
  61. * Get at functionality ace.define()ed using the function above
  62. */
  63. var _require = function(parentId, module, callback) {
  64. if (typeof module === "string") {
  65. var payload = lookup(parentId, module);
  66. if (payload != undefined) {
  67. callback && callback();
  68. return payload;
  69. }
  70. } else if (Object.prototype.toString.call(module) === "[object Array]") {
  71. var params = [];
  72. for (var i = 0, l = module.length; i < l; ++i) {
  73. var dep = lookup(parentId, module[i]);
  74. if (dep == undefined && require.original)
  75. return;
  76. params.push(dep);
  77. }
  78. return callback && callback.apply(null, params) || true;
  79. }
  80. };
  81. var require = function(module, callback) {
  82. var packagedModule = _require("", module, callback);
  83. if (packagedModule == undefined && require.original)
  84. return require.original.apply(this, arguments);
  85. return packagedModule;
  86. };
  87. var normalizeModule = function(parentId, moduleName) {
  88. // normalize plugin requires
  89. if (moduleName.indexOf("!") !== -1) {
  90. var chunks = moduleName.split("!");
  91. return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
  92. }
  93. // normalize relative requires
  94. if (moduleName.charAt(0) == ".") {
  95. var base = parentId.split("/").slice(0, -1).join("/");
  96. moduleName = base + "/" + moduleName;
  97. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  98. var previous = moduleName;
  99. moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  100. }
  101. }
  102. return moduleName;
  103. };
  104. /**
  105. * Internal function to lookup moduleNames and resolve them by calling the
  106. * definition function if needed.
  107. */
  108. var lookup = function(parentId, moduleName) {
  109. moduleName = normalizeModule(parentId, moduleName);
  110. var module = define.modules[moduleName];
  111. if (!module) {
  112. module = define.payloads[moduleName];
  113. if (typeof module === 'function') {
  114. var exports = {};
  115. var mod = {
  116. id: moduleName,
  117. uri: '',
  118. exports: exports,
  119. packaged: true
  120. };
  121. var req = function(module, callback) {
  122. return _require(moduleName, module, callback);
  123. };
  124. var returnValue = module(req, exports, mod);
  125. exports = returnValue || mod.exports;
  126. define.modules[moduleName] = exports;
  127. delete define.payloads[moduleName];
  128. }
  129. module = define.modules[moduleName] = exports || module;
  130. }
  131. return module;
  132. };
  133. function exportAce(ns) {
  134. var root = global;
  135. if (ns) {
  136. if (!global[ns])
  137. global[ns] = {};
  138. root = global[ns];
  139. }
  140. if (!root.define || !root.define.packaged) {
  141. define.original = root.define;
  142. root.define = define;
  143. root.define.packaged = true;
  144. }
  145. if (!root.require || !root.require.packaged) {
  146. require.original = root.require;
  147. root.require = require;
  148. root.require.packaged = true;
  149. }
  150. }
  151. exportAce(ACE_NAMESPACE);
  152. })();
  153. ace.define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) {
  154. "use strict";
  155. var real = {
  156. exec: RegExp.prototype.exec,
  157. test: RegExp.prototype.test,
  158. match: String.prototype.match,
  159. replace: String.prototype.replace,
  160. split: String.prototype.split
  161. },
  162. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  163. compliantLastIndexIncrement = function () {
  164. var x = /^/g;
  165. real.test.call(x, "");
  166. return !x.lastIndex;
  167. }();
  168. if (compliantLastIndexIncrement && compliantExecNpcg)
  169. return;
  170. RegExp.prototype.exec = function (str) {
  171. var match = real.exec.apply(this, arguments),
  172. name, r2;
  173. if ( typeof(str) == 'string' && match) {
  174. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  175. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  176. real.replace.call(str.slice(match.index), r2, function () {
  177. for (var i = 1; i < arguments.length - 2; i++) {
  178. if (arguments[i] === undefined)
  179. match[i] = undefined;
  180. }
  181. });
  182. }
  183. if (this._xregexp && this._xregexp.captureNames) {
  184. for (var i = 1; i < match.length; i++) {
  185. name = this._xregexp.captureNames[i - 1];
  186. if (name)
  187. match[name] = match[i];
  188. }
  189. }
  190. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  191. this.lastIndex--;
  192. }
  193. return match;
  194. };
  195. if (!compliantLastIndexIncrement) {
  196. RegExp.prototype.test = function (str) {
  197. var match = real.exec.call(this, str);
  198. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  199. this.lastIndex--;
  200. return !!match;
  201. };
  202. }
  203. function getNativeFlags (regex) {
  204. return (regex.global ? "g" : "") +
  205. (regex.ignoreCase ? "i" : "") +
  206. (regex.multiline ? "m" : "") +
  207. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  208. (regex.sticky ? "y" : "");
  209. }
  210. function indexOf (array, item, from) {
  211. if (Array.prototype.indexOf) // Use the native array method if available
  212. return array.indexOf(item, from);
  213. for (var i = from || 0; i < array.length; i++) {
  214. if (array[i] === item)
  215. return i;
  216. }
  217. return -1;
  218. }
  219. });
  220. ace.define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
  221. function Empty() {}
  222. if (!Function.prototype.bind) {
  223. Function.prototype.bind = function bind(that) { // .length is 1
  224. var target = this;
  225. if (typeof target != "function") {
  226. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  227. }
  228. var args = slice.call(arguments, 1); // for normal call
  229. var bound = function () {
  230. if (this instanceof bound) {
  231. var result = target.apply(
  232. this,
  233. args.concat(slice.call(arguments))
  234. );
  235. if (Object(result) === result) {
  236. return result;
  237. }
  238. return this;
  239. } else {
  240. return target.apply(
  241. that,
  242. args.concat(slice.call(arguments))
  243. );
  244. }
  245. };
  246. if(target.prototype) {
  247. Empty.prototype = target.prototype;
  248. bound.prototype = new Empty();
  249. Empty.prototype = null;
  250. }
  251. return bound;
  252. };
  253. }
  254. var call = Function.prototype.call;
  255. var prototypeOfArray = Array.prototype;
  256. var prototypeOfObject = Object.prototype;
  257. var slice = prototypeOfArray.slice;
  258. var _toString = call.bind(prototypeOfObject.toString);
  259. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  260. var defineGetter;
  261. var defineSetter;
  262. var lookupGetter;
  263. var lookupSetter;
  264. var supportsAccessors;
  265. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  266. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  267. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  268. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  269. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  270. }
  271. if ([1,2].splice(0).length != 2) {
  272. if(function() { // test IE < 9 to splice bug - see issue #138
  273. function makeArray(l) {
  274. var a = new Array(l+2);
  275. a[0] = a[1] = 0;
  276. return a;
  277. }
  278. var array = [], lengthBefore;
  279. array.splice.apply(array, makeArray(20));
  280. array.splice.apply(array, makeArray(26));
  281. lengthBefore = array.length; //46
  282. array.splice(5, 0, "XXX"); // add one element
  283. lengthBefore + 1 == array.length
  284. if (lengthBefore + 1 == array.length) {
  285. return true;// has right splice implementation without bugs
  286. }
  287. }()) {//IE 6/7
  288. var array_splice = Array.prototype.splice;
  289. Array.prototype.splice = function(start, deleteCount) {
  290. if (!arguments.length) {
  291. return [];
  292. } else {
  293. return array_splice.apply(this, [
  294. start === void 0 ? 0 : start,
  295. deleteCount === void 0 ? (this.length - start) : deleteCount
  296. ].concat(slice.call(arguments, 2)))
  297. }
  298. };
  299. } else {//IE8
  300. Array.prototype.splice = function(pos, removeCount){
  301. var length = this.length;
  302. if (pos > 0) {
  303. if (pos > length)
  304. pos = length;
  305. } else if (pos == void 0) {
  306. pos = 0;
  307. } else if (pos < 0) {
  308. pos = Math.max(length + pos, 0);
  309. }
  310. if (!(pos+removeCount < length))
  311. removeCount = length - pos;
  312. var removed = this.slice(pos, pos+removeCount);
  313. var insert = slice.call(arguments, 2);
  314. var add = insert.length;
  315. if (pos === length) {
  316. if (add) {
  317. this.push.apply(this, insert);
  318. }
  319. } else {
  320. var remove = Math.min(removeCount, length - pos);
  321. var tailOldPos = pos + remove;
  322. var tailNewPos = tailOldPos + add - remove;
  323. var tailCount = length - tailOldPos;
  324. var lengthAfterRemove = length - remove;
  325. if (tailNewPos < tailOldPos) { // case A
  326. for (var i = 0; i < tailCount; ++i) {
  327. this[tailNewPos+i] = this[tailOldPos+i];
  328. }
  329. } else if (tailNewPos > tailOldPos) { // case B
  330. for (i = tailCount; i--; ) {
  331. this[tailNewPos+i] = this[tailOldPos+i];
  332. }
  333. } // else, add == remove (nothing to do)
  334. if (add && pos === lengthAfterRemove) {
  335. this.length = lengthAfterRemove; // truncate array
  336. this.push.apply(this, insert);
  337. } else {
  338. this.length = lengthAfterRemove + add; // reserves space
  339. for (i = 0; i < add; ++i) {
  340. this[pos+i] = insert[i];
  341. }
  342. }
  343. }
  344. return removed;
  345. };
  346. }
  347. }
  348. if (!Array.isArray) {
  349. Array.isArray = function isArray(obj) {
  350. return _toString(obj) == "[object Array]";
  351. };
  352. }
  353. var boxedString = Object("a"),
  354. splitString = boxedString[0] != "a" || !(0 in boxedString);
  355. if (!Array.prototype.forEach) {
  356. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  357. var object = toObject(this),
  358. self = splitString && _toString(this) == "[object String]" ?
  359. this.split("") :
  360. object,
  361. thisp = arguments[1],
  362. i = -1,
  363. length = self.length >>> 0;
  364. if (_toString(fun) != "[object Function]") {
  365. throw new TypeError(); // TODO message
  366. }
  367. while (++i < length) {
  368. if (i in self) {
  369. fun.call(thisp, self[i], i, object);
  370. }
  371. }
  372. };
  373. }
  374. if (!Array.prototype.map) {
  375. Array.prototype.map = function map(fun /*, thisp*/) {
  376. var object = toObject(this),
  377. self = splitString && _toString(this) == "[object String]" ?
  378. this.split("") :
  379. object,
  380. length = self.length >>> 0,
  381. result = Array(length),
  382. thisp = arguments[1];
  383. if (_toString(fun) != "[object Function]") {
  384. throw new TypeError(fun + " is not a function");
  385. }
  386. for (var i = 0; i < length; i++) {
  387. if (i in self)
  388. result[i] = fun.call(thisp, self[i], i, object);
  389. }
  390. return result;
  391. };
  392. }
  393. if (!Array.prototype.filter) {
  394. Array.prototype.filter = function filter(fun /*, thisp */) {
  395. var object = toObject(this),
  396. self = splitString && _toString(this) == "[object String]" ?
  397. this.split("") :
  398. object,
  399. length = self.length >>> 0,
  400. result = [],
  401. value,
  402. thisp = arguments[1];
  403. if (_toString(fun) != "[object Function]") {
  404. throw new TypeError(fun + " is not a function");
  405. }
  406. for (var i = 0; i < length; i++) {
  407. if (i in self) {
  408. value = self[i];
  409. if (fun.call(thisp, value, i, object)) {
  410. result.push(value);
  411. }
  412. }
  413. }
  414. return result;
  415. };
  416. }
  417. if (!Array.prototype.every) {
  418. Array.prototype.every = function every(fun /*, thisp */) {
  419. var object = toObject(this),
  420. self = splitString && _toString(this) == "[object String]" ?
  421. this.split("") :
  422. object,
  423. length = self.length >>> 0,
  424. thisp = arguments[1];
  425. if (_toString(fun) != "[object Function]") {
  426. throw new TypeError(fun + " is not a function");
  427. }
  428. for (var i = 0; i < length; i++) {
  429. if (i in self && !fun.call(thisp, self[i], i, object)) {
  430. return false;
  431. }
  432. }
  433. return true;
  434. };
  435. }
  436. if (!Array.prototype.some) {
  437. Array.prototype.some = function some(fun /*, thisp */) {
  438. var object = toObject(this),
  439. self = splitString && _toString(this) == "[object String]" ?
  440. this.split("") :
  441. object,
  442. length = self.length >>> 0,
  443. thisp = arguments[1];
  444. if (_toString(fun) != "[object Function]") {
  445. throw new TypeError(fun + " is not a function");
  446. }
  447. for (var i = 0; i < length; i++) {
  448. if (i in self && fun.call(thisp, self[i], i, object)) {
  449. return true;
  450. }
  451. }
  452. return false;
  453. };
  454. }
  455. if (!Array.prototype.reduce) {
  456. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  457. var object = toObject(this),
  458. self = splitString && _toString(this) == "[object String]" ?
  459. this.split("") :
  460. object,
  461. length = self.length >>> 0;
  462. if (_toString(fun) != "[object Function]") {
  463. throw new TypeError(fun + " is not a function");
  464. }
  465. if (!length && arguments.length == 1) {
  466. throw new TypeError("reduce of empty array with no initial value");
  467. }
  468. var i = 0;
  469. var result;
  470. if (arguments.length >= 2) {
  471. result = arguments[1];
  472. } else {
  473. do {
  474. if (i in self) {
  475. result = self[i++];
  476. break;
  477. }
  478. if (++i >= length) {
  479. throw new TypeError("reduce of empty array with no initial value");
  480. }
  481. } while (true);
  482. }
  483. for (; i < length; i++) {
  484. if (i in self) {
  485. result = fun.call(void 0, result, self[i], i, object);
  486. }
  487. }
  488. return result;
  489. };
  490. }
  491. if (!Array.prototype.reduceRight) {
  492. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  493. var object = toObject(this),
  494. self = splitString && _toString(this) == "[object String]" ?
  495. this.split("") :
  496. object,
  497. length = self.length >>> 0;
  498. if (_toString(fun) != "[object Function]") {
  499. throw new TypeError(fun + " is not a function");
  500. }
  501. if (!length && arguments.length == 1) {
  502. throw new TypeError("reduceRight of empty array with no initial value");
  503. }
  504. var result, i = length - 1;
  505. if (arguments.length >= 2) {
  506. result = arguments[1];
  507. } else {
  508. do {
  509. if (i in self) {
  510. result = self[i--];
  511. break;
  512. }
  513. if (--i < 0) {
  514. throw new TypeError("reduceRight of empty array with no initial value");
  515. }
  516. } while (true);
  517. }
  518. do {
  519. if (i in this) {
  520. result = fun.call(void 0, result, self[i], i, object);
  521. }
  522. } while (i--);
  523. return result;
  524. };
  525. }
  526. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  527. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  528. var self = splitString && _toString(this) == "[object String]" ?
  529. this.split("") :
  530. toObject(this),
  531. length = self.length >>> 0;
  532. if (!length) {
  533. return -1;
  534. }
  535. var i = 0;
  536. if (arguments.length > 1) {
  537. i = toInteger(arguments[1]);
  538. }
  539. i = i >= 0 ? i : Math.max(0, length + i);
  540. for (; i < length; i++) {
  541. if (i in self && self[i] === sought) {
  542. return i;
  543. }
  544. }
  545. return -1;
  546. };
  547. }
  548. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  549. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  550. var self = splitString && _toString(this) == "[object String]" ?
  551. this.split("") :
  552. toObject(this),
  553. length = self.length >>> 0;
  554. if (!length) {
  555. return -1;
  556. }
  557. var i = length - 1;
  558. if (arguments.length > 1) {
  559. i = Math.min(i, toInteger(arguments[1]));
  560. }
  561. i = i >= 0 ? i : length - Math.abs(i);
  562. for (; i >= 0; i--) {
  563. if (i in self && sought === self[i]) {
  564. return i;
  565. }
  566. }
  567. return -1;
  568. };
  569. }
  570. if (!Object.getPrototypeOf) {
  571. Object.getPrototypeOf = function getPrototypeOf(object) {
  572. return object.__proto__ || (
  573. object.constructor ?
  574. object.constructor.prototype :
  575. prototypeOfObject
  576. );
  577. };
  578. }
  579. if (!Object.getOwnPropertyDescriptor) {
  580. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  581. "non-object: ";
  582. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  583. if ((typeof object != "object" && typeof object != "function") || object === null)
  584. throw new TypeError(ERR_NON_OBJECT + object);
  585. if (!owns(object, property))
  586. return;
  587. var descriptor, getter, setter;
  588. descriptor = { enumerable: true, configurable: true };
  589. if (supportsAccessors) {
  590. var prototype = object.__proto__;
  591. object.__proto__ = prototypeOfObject;
  592. var getter = lookupGetter(object, property);
  593. var setter = lookupSetter(object, property);
  594. object.__proto__ = prototype;
  595. if (getter || setter) {
  596. if (getter) descriptor.get = getter;
  597. if (setter) descriptor.set = setter;
  598. return descriptor;
  599. }
  600. }
  601. descriptor.value = object[property];
  602. return descriptor;
  603. };
  604. }
  605. if (!Object.getOwnPropertyNames) {
  606. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  607. return Object.keys(object);
  608. };
  609. }
  610. if (!Object.create) {
  611. var createEmpty;
  612. if (Object.prototype.__proto__ === null) {
  613. createEmpty = function () {
  614. return { "__proto__": null };
  615. };
  616. } else {
  617. createEmpty = function () {
  618. var empty = {};
  619. for (var i in empty)
  620. empty[i] = null;
  621. empty.constructor =
  622. empty.hasOwnProperty =
  623. empty.propertyIsEnumerable =
  624. empty.isPrototypeOf =
  625. empty.toLocaleString =
  626. empty.toString =
  627. empty.valueOf =
  628. empty.__proto__ = null;
  629. return empty;
  630. }
  631. }
  632. Object.create = function create(prototype, properties) {
  633. var object;
  634. if (prototype === null) {
  635. object = createEmpty();
  636. } else {
  637. if (typeof prototype != "object")
  638. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  639. var Type = function () {};
  640. Type.prototype = prototype;
  641. object = new Type();
  642. object.__proto__ = prototype;
  643. }
  644. if (properties !== void 0)
  645. Object.defineProperties(object, properties);
  646. return object;
  647. };
  648. }
  649. function doesDefinePropertyWork(object) {
  650. try {
  651. Object.defineProperty(object, "sentinel", {});
  652. return "sentinel" in object;
  653. } catch (exception) {
  654. }
  655. }
  656. if (Object.defineProperty) {
  657. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  658. var definePropertyWorksOnDom = typeof document == "undefined" ||
  659. doesDefinePropertyWork(document.createElement("div"));
  660. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  661. var definePropertyFallback = Object.defineProperty;
  662. }
  663. }
  664. if (!Object.defineProperty || definePropertyFallback) {
  665. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  666. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  667. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  668. "on this javascript engine";
  669. Object.defineProperty = function defineProperty(object, property, descriptor) {
  670. if ((typeof object != "object" && typeof object != "function") || object === null)
  671. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  672. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  673. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  674. if (definePropertyFallback) {
  675. try {
  676. return definePropertyFallback.call(Object, object, property, descriptor);
  677. } catch (exception) {
  678. }
  679. }
  680. if (owns(descriptor, "value")) {
  681. if (supportsAccessors && (lookupGetter(object, property) ||
  682. lookupSetter(object, property)))
  683. {
  684. var prototype = object.__proto__;
  685. object.__proto__ = prototypeOfObject;
  686. delete object[property];
  687. object[property] = descriptor.value;
  688. object.__proto__ = prototype;
  689. } else {
  690. object[property] = descriptor.value;
  691. }
  692. } else {
  693. if (!supportsAccessors)
  694. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  695. if (owns(descriptor, "get"))
  696. defineGetter(object, property, descriptor.get);
  697. if (owns(descriptor, "set"))
  698. defineSetter(object, property, descriptor.set);
  699. }
  700. return object;
  701. };
  702. }
  703. if (!Object.defineProperties) {
  704. Object.defineProperties = function defineProperties(object, properties) {
  705. for (var property in properties) {
  706. if (owns(properties, property))
  707. Object.defineProperty(object, property, properties[property]);
  708. }
  709. return object;
  710. };
  711. }
  712. if (!Object.seal) {
  713. Object.seal = function seal(object) {
  714. return object;
  715. };
  716. }
  717. if (!Object.freeze) {
  718. Object.freeze = function freeze(object) {
  719. return object;
  720. };
  721. }
  722. try {
  723. Object.freeze(function () {});
  724. } catch (exception) {
  725. Object.freeze = (function freeze(freezeObject) {
  726. return function freeze(object) {
  727. if (typeof object == "function") {
  728. return object;
  729. } else {
  730. return freezeObject(object);
  731. }
  732. };
  733. })(Object.freeze);
  734. }
  735. if (!Object.preventExtensions) {
  736. Object.preventExtensions = function preventExtensions(object) {
  737. return object;
  738. };
  739. }
  740. if (!Object.isSealed) {
  741. Object.isSealed = function isSealed(object) {
  742. return false;
  743. };
  744. }
  745. if (!Object.isFrozen) {
  746. Object.isFrozen = function isFrozen(object) {
  747. return false;
  748. };
  749. }
  750. if (!Object.isExtensible) {
  751. Object.isExtensible = function isExtensible(object) {
  752. if (Object(object) === object) {
  753. throw new TypeError(); // TODO message
  754. }
  755. var name = '';
  756. while (owns(object, name)) {
  757. name += '?';
  758. }
  759. object[name] = true;
  760. var returnValue = owns(object, name);
  761. delete object[name];
  762. return returnValue;
  763. };
  764. }
  765. if (!Object.keys) {
  766. var hasDontEnumBug = true,
  767. dontEnums = [
  768. "toString",
  769. "toLocaleString",
  770. "valueOf",
  771. "hasOwnProperty",
  772. "isPrototypeOf",
  773. "propertyIsEnumerable",
  774. "constructor"
  775. ],
  776. dontEnumsLength = dontEnums.length;
  777. for (var key in {"toString": null}) {
  778. hasDontEnumBug = false;
  779. }
  780. Object.keys = function keys(object) {
  781. if (
  782. (typeof object != "object" && typeof object != "function") ||
  783. object === null
  784. ) {
  785. throw new TypeError("Object.keys called on a non-object");
  786. }
  787. var keys = [];
  788. for (var name in object) {
  789. if (owns(object, name)) {
  790. keys.push(name);
  791. }
  792. }
  793. if (hasDontEnumBug) {
  794. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  795. var dontEnum = dontEnums[i];
  796. if (owns(object, dontEnum)) {
  797. keys.push(dontEnum);
  798. }
  799. }
  800. }
  801. return keys;
  802. };
  803. }
  804. if (!Date.now) {
  805. Date.now = function now() {
  806. return new Date().getTime();
  807. };
  808. }
  809. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  810. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  811. "\u2029\uFEFF";
  812. if (!String.prototype.trim || ws.trim()) {
  813. ws = "[" + ws + "]";
  814. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  815. trimEndRegexp = new RegExp(ws + ws + "*$");
  816. String.prototype.trim = function trim() {
  817. return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
  818. };
  819. }
  820. function toInteger(n) {
  821. n = +n;
  822. if (n !== n) { // isNaN
  823. n = 0;
  824. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  825. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  826. }
  827. return n;
  828. }
  829. function isPrimitive(input) {
  830. var type = typeof input;
  831. return (
  832. input === null ||
  833. type === "undefined" ||
  834. type === "boolean" ||
  835. type === "number" ||
  836. type === "string"
  837. );
  838. }
  839. function toPrimitive(input) {
  840. var val, valueOf, toString;
  841. if (isPrimitive(input)) {
  842. return input;
  843. }
  844. valueOf = input.valueOf;
  845. if (typeof valueOf === "function") {
  846. val = valueOf.call(input);
  847. if (isPrimitive(val)) {
  848. return val;
  849. }
  850. }
  851. toString = input.toString;
  852. if (typeof toString === "function") {
  853. val = toString.call(input);
  854. if (isPrimitive(val)) {
  855. return val;
  856. }
  857. }
  858. throw new TypeError();
  859. }
  860. var toObject = function (o) {
  861. if (o == null) { // this matches both null and undefined
  862. throw new TypeError("can't convert "+o+" to object");
  863. }
  864. return Object(o);
  865. };
  866. });
  867. ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) {
  868. "use strict";
  869. require("./regexp");
  870. require("./es5-shim");
  871. });
  872. ace.define("ace/lib/dom",["require","exports","module"], function(require, exports, module) {
  873. "use strict";
  874. var XHTML_NS = "http://www.w3.org/1999/xhtml";
  875. exports.getDocumentHead = function(doc) {
  876. if (!doc)
  877. doc = document;
  878. return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
  879. }
  880. exports.createElement = function(tag, ns) {
  881. return document.createElementNS ?
  882. document.createElementNS(ns || XHTML_NS, tag) :
  883. document.createElement(tag);
  884. };
  885. exports.hasCssClass = function(el, name) {
  886. var classes = (el.className || "").split(/\s+/g);
  887. return classes.indexOf(name) !== -1;
  888. };
  889. exports.addCssClass = function(el, name) {
  890. if (!exports.hasCssClass(el, name)) {
  891. el.className += " " + name;
  892. }
  893. };
  894. exports.removeCssClass = function(el, name) {
  895. var classes = el.className.split(/\s+/g);
  896. while (true) {
  897. var index = classes.indexOf(name);
  898. if (index == -1) {
  899. break;
  900. }
  901. classes.splice(index, 1);
  902. }
  903. el.className = classes.join(" ");
  904. };
  905. exports.toggleCssClass = function(el, name) {
  906. var classes = el.className.split(/\s+/g), add = true;
  907. while (true) {
  908. var index = classes.indexOf(name);
  909. if (index == -1) {
  910. break;
  911. }
  912. add = false;
  913. classes.splice(index, 1);
  914. }
  915. if(add)
  916. classes.push(name);
  917. el.className = classes.join(" ");
  918. return add;
  919. };
  920. exports.setCssClass = function(node, className, include) {
  921. if (include) {
  922. exports.addCssClass(node, className);
  923. } else {
  924. exports.removeCssClass(node, className);
  925. }
  926. };
  927. exports.hasCssString = function(id, doc) {
  928. var index = 0, sheets;
  929. doc = doc || document;
  930. if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
  931. while (index < sheets.length)
  932. if (sheets[index++].owningElement.id === id) return true;
  933. } else if ((sheets = doc.getElementsByTagName("style"))) {
  934. while (index < sheets.length)
  935. if (sheets[index++].id === id) return true;
  936. }
  937. return false;
  938. };
  939. exports.importCssString = function importCssString(cssText, id, doc) {
  940. doc = doc || document;
  941. if (id && exports.hasCssString(id, doc))
  942. return null;
  943. var style;
  944. if (doc.createStyleSheet) {
  945. style = doc.createStyleSheet();
  946. style.cssText = cssText;
  947. if (id)
  948. style.owningElement.id = id;
  949. } else {
  950. style = doc.createElementNS
  951. ? doc.createElementNS(XHTML_NS, "style")
  952. : doc.createElement("style");
  953. style.appendChild(doc.createTextNode(cssText));
  954. if (id)
  955. style.id = id;
  956. exports.getDocumentHead(doc).appendChild(style);
  957. }
  958. };
  959. exports.importCssStylsheet = function(uri, doc) {
  960. if (doc.createStyleSheet) {
  961. doc.createStyleSheet(uri);
  962. } else {
  963. var link = exports.createElement('link');
  964. link.rel = 'stylesheet';
  965. link.href = uri;
  966. exports.getDocumentHead(doc).appendChild(link);
  967. }
  968. };
  969. exports.getInnerWidth = function(element) {
  970. return (
  971. parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
  972. parseInt(exports.computedStyle(element, "paddingRight"), 10) +
  973. element.clientWidth
  974. );
  975. };
  976. exports.getInnerHeight = function(element) {
  977. return (
  978. parseInt(exports.computedStyle(element, "paddingTop"), 10) +
  979. parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
  980. element.clientHeight
  981. );
  982. };
  983. if (typeof document == "undefined")
  984. return;
  985. if (window.pageYOffset !== undefined) {
  986. exports.getPageScrollTop = function() {
  987. return window.pageYOffset;
  988. };
  989. exports.getPageScrollLeft = function() {
  990. return window.pageXOffset;
  991. };
  992. }
  993. else {
  994. exports.getPageScrollTop = function() {
  995. return document.body.scrollTop;
  996. };
  997. exports.getPageScrollLeft = function() {
  998. return document.body.scrollLeft;
  999. };
  1000. }
  1001. if (window.getComputedStyle)
  1002. exports.computedStyle = function(element, style) {
  1003. if (style)
  1004. return (window.getComputedStyle(element, "") || {})[style] || "";
  1005. return window.getComputedStyle(element, "") || {};
  1006. };
  1007. else
  1008. exports.computedStyle = function(element, style) {
  1009. if (style)
  1010. return element.currentStyle[style];
  1011. return element.currentStyle;
  1012. };
  1013. exports.scrollbarWidth = function(document) {
  1014. var inner = exports.createElement("ace_inner");
  1015. inner.style.width = "100%";
  1016. inner.style.minWidth = "0px";
  1017. inner.style.height = "200px";
  1018. inner.style.display = "block";
  1019. var outer = exports.createElement("ace_outer");
  1020. var style = outer.style;
  1021. style.position = "absolute";
  1022. style.left = "-10000px";
  1023. style.overflow = "hidden";
  1024. style.width = "200px";
  1025. style.minWidth = "0px";
  1026. style.height = "150px";
  1027. style.display = "block";
  1028. outer.appendChild(inner);
  1029. var body = document.documentElement;
  1030. body.appendChild(outer);
  1031. var noScrollbar = inner.offsetWidth;
  1032. style.overflow = "scroll";
  1033. var withScrollbar = inner.offsetWidth;
  1034. if (noScrollbar == withScrollbar) {
  1035. withScrollbar = outer.clientWidth;
  1036. }
  1037. body.removeChild(outer);
  1038. return noScrollbar-withScrollbar;
  1039. };
  1040. exports.setInnerHtml = function(el, innerHtml) {
  1041. var element = el.cloneNode(false);//document.createElement("div");
  1042. element.innerHTML = innerHtml;
  1043. el.parentNode.replaceChild(element, el);
  1044. return element;
  1045. };
  1046. if ("textContent" in document.documentElement) {
  1047. exports.setInnerText = function(el, innerText) {
  1048. el.textContent = innerText;
  1049. };
  1050. exports.getInnerText = function(el) {
  1051. return el.textContent;
  1052. };
  1053. }
  1054. else {
  1055. exports.setInnerText = function(el, innerText) {
  1056. el.innerText = innerText;
  1057. };
  1058. exports.getInnerText = function(el) {
  1059. return el.innerText;
  1060. };
  1061. }
  1062. exports.getParentWindow = function(document) {
  1063. return document.defaultView || document.parentWindow;
  1064. };
  1065. });
  1066. ace.define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
  1067. "use strict";
  1068. exports.inherits = function(ctor, superCtor) {
  1069. ctor.super_ = superCtor;
  1070. ctor.prototype = Object.create(superCtor.prototype, {
  1071. constructor: {
  1072. value: ctor,
  1073. enumerable: false,
  1074. writable: true,
  1075. configurable: true
  1076. }
  1077. });
  1078. };
  1079. exports.mixin = function(obj, mixin) {
  1080. for (var key in mixin) {
  1081. obj[key] = mixin[key];
  1082. }
  1083. return obj;
  1084. };
  1085. exports.implement = function(proto, mixin) {
  1086. exports.mixin(proto, mixin);
  1087. };
  1088. });
  1089. ace.define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(require, exports, module) {
  1090. "use strict";
  1091. require("./fixoldbrowsers");
  1092. var oop = require("./oop");
  1093. var Keys = (function() {
  1094. var ret = {
  1095. MODIFIER_KEYS: {
  1096. 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
  1097. },
  1098. KEY_MODS: {
  1099. "ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
  1100. "super": 8, "meta": 8, "command": 8, "cmd": 8
  1101. },
  1102. FUNCTION_KEYS : {
  1103. 8 : "Backspace",
  1104. 9 : "Tab",
  1105. 13 : "Return",
  1106. 19 : "Pause",
  1107. 27 : "Esc",
  1108. 32 : "Space",
  1109. 33 : "PageUp",
  1110. 34 : "PageDown",
  1111. 35 : "End",
  1112. 36 : "Home",
  1113. 37 : "Left",
  1114. 38 : "Up",
  1115. 39 : "Right",
  1116. 40 : "Down",
  1117. 44 : "Print",
  1118. 45 : "Insert",
  1119. 46 : "Delete",
  1120. 96 : "Numpad0",
  1121. 97 : "Numpad1",
  1122. 98 : "Numpad2",
  1123. 99 : "Numpad3",
  1124. 100: "Numpad4",
  1125. 101: "Numpad5",
  1126. 102: "Numpad6",
  1127. 103: "Numpad7",
  1128. 104: "Numpad8",
  1129. 105: "Numpad9",
  1130. '-13': "NumpadEnter",
  1131. 112: "F1",
  1132. 113: "F2",
  1133. 114: "F3",
  1134. 115: "F4",
  1135. 116: "F5",
  1136. 117: "F6",
  1137. 118: "F7",
  1138. 119: "F8",
  1139. 120: "F9",
  1140. 121: "F10",
  1141. 122: "F11",
  1142. 123: "F12",
  1143. 144: "Numlock",
  1144. 145: "Scrolllock"
  1145. },
  1146. PRINTABLE_KEYS: {
  1147. 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
  1148. 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
  1149. 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
  1150. 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
  1151. 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
  1152. 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
  1153. 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
  1154. 219: '[', 220: '\\',221: ']', 222: '\''
  1155. }
  1156. };
  1157. var name, i;
  1158. for (i in ret.FUNCTION_KEYS) {
  1159. name = ret.FUNCTION_KEYS[i].toLowerCase();
  1160. ret[name] = parseInt(i, 10);
  1161. }
  1162. for (i in ret.PRINTABLE_KEYS) {
  1163. name = ret.PRINTABLE_KEYS[i].toLowerCase();
  1164. ret[name] = parseInt(i, 10);
  1165. }
  1166. oop.mixin(ret, ret.MODIFIER_KEYS);
  1167. oop.mixin(ret, ret.PRINTABLE_KEYS);
  1168. oop.mixin(ret, ret.FUNCTION_KEYS);
  1169. ret.enter = ret["return"];
  1170. ret.escape = ret.esc;
  1171. ret.del = ret["delete"];
  1172. ret[173] = '-';
  1173. (function() {
  1174. var mods = ["cmd", "ctrl", "alt", "shift"];
  1175. for (var i = Math.pow(2, mods.length); i--;) {
  1176. ret.KEY_MODS[i] = mods.filter(function(x) {
  1177. return i & ret.KEY_MODS[x];
  1178. }).join("-") + "-";
  1179. }
  1180. })();
  1181. ret.KEY_MODS[0] = "";
  1182. ret.KEY_MODS[-1] = "input-";
  1183. return ret;
  1184. })();
  1185. oop.mixin(exports, Keys);
  1186. exports.keyCodeToString = function(keyCode) {
  1187. var keyString = Keys[keyCode];
  1188. if (typeof keyString != "string")
  1189. keyString = String.fromCharCode(keyCode);
  1190. return keyString.toLowerCase();
  1191. };
  1192. });
  1193. ace.define("ace/lib/useragent",["require","exports","module"], function(require, exports, module) {
  1194. "use strict";
  1195. exports.OS = {
  1196. LINUX: "LINUX",
  1197. MAC: "MAC",
  1198. WINDOWS: "WINDOWS"
  1199. };
  1200. exports.getOS = function() {
  1201. if (exports.isMac) {
  1202. return exports.OS.MAC;
  1203. } else if (exports.isLinux) {
  1204. return exports.OS.LINUX;
  1205. } else {
  1206. return exports.OS.WINDOWS;
  1207. }
  1208. };
  1209. if (typeof navigator != "object")
  1210. return;
  1211. var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
  1212. var ua = navigator.userAgent;
  1213. exports.isWin = (os == "win");
  1214. exports.isMac = (os == "mac");
  1215. exports.isLinux = (os == "linux");
  1216. exports.isIE =
  1217. (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
  1218. ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
  1219. : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
  1220. exports.isOldIE = exports.isIE && exports.isIE < 9;
  1221. exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
  1222. exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
  1223. exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
  1224. exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
  1225. exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
  1226. exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
  1227. exports.isIPad = ua.indexOf("iPad") >= 0;
  1228. exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
  1229. exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
  1230. });
  1231. ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  1232. "use strict";
  1233. var keys = require("./keys");
  1234. var useragent = require("./useragent");
  1235. exports.addListener = function(elem, type, callback) {
  1236. if (elem.addEventListener) {
  1237. return elem.addEventListener(type, callback, false);
  1238. }
  1239. if (elem.attachEvent) {
  1240. var wrapper = function() {
  1241. callback.call(elem, window.event);
  1242. };
  1243. callback._wrapper = wrapper;
  1244. elem.attachEvent("on" + type, wrapper);
  1245. }
  1246. };
  1247. exports.removeListener = function(elem, type, callback) {
  1248. if (elem.removeEventListener) {
  1249. return elem.removeEventListener(type, callback, false);
  1250. }
  1251. if (elem.detachEvent) {
  1252. elem.detachEvent("on" + type, callback._wrapper || callback);
  1253. }
  1254. };
  1255. exports.stopEvent = function(e) {
  1256. exports.stopPropagation(e);
  1257. exports.preventDefault(e);
  1258. return false;
  1259. };
  1260. exports.stopPropagation = function(e) {
  1261. if (e.stopPropagation)
  1262. e.stopPropagation();
  1263. else
  1264. e.cancelBubble = true;
  1265. };
  1266. exports.preventDefault = function(e) {
  1267. if (e.preventDefault)
  1268. e.preventDefault();
  1269. else
  1270. e.returnValue = false;
  1271. };
  1272. exports.getButton = function(e) {
  1273. if (e.type == "dblclick")
  1274. return 0;
  1275. if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
  1276. return 2;
  1277. if (e.preventDefault) {
  1278. return e.button;
  1279. }
  1280. else {
  1281. return {1:0, 2:2, 4:1}[e.button];
  1282. }
  1283. };
  1284. exports.capture = function(el, eventHandler, releaseCaptureHandler) {
  1285. function onMouseUp(e) {
  1286. eventHandler && eventHandler(e);
  1287. releaseCaptureHandler && releaseCaptureHandler(e);
  1288. exports.removeListener(document, "mousemove", eventHandler, true);
  1289. exports.removeListener(document, "mouseup", onMouseUp, true);
  1290. exports.removeListener(document, "dragstart", onMouseUp, true);
  1291. }
  1292. exports.addListener(document, "mousemove", eventHandler, true);
  1293. exports.addListener(document, "mouseup", onMouseUp, true);
  1294. exports.addListener(document, "dragstart", onMouseUp, true);
  1295. return onMouseUp;
  1296. };
  1297. exports.addMouseWheelListener = function(el, callback) {
  1298. if ("onmousewheel" in el) {
  1299. exports.addListener(el, "mousewheel", function(e) {
  1300. var factor = 8;
  1301. if (e.wheelDeltaX !== undefined) {
  1302. e.wheelX = -e.wheelDeltaX / factor;
  1303. e.wheelY = -e.wheelDeltaY / factor;
  1304. } else {
  1305. e.wheelX = 0;
  1306. e.wheelY = -e.wheelDelta / factor;
  1307. }
  1308. callback(e);
  1309. });
  1310. } else if ("onwheel" in el) {
  1311. exports.addListener(el, "wheel", function(e) {
  1312. var factor = 0.35;
  1313. switch (e.deltaMode) {
  1314. case e.DOM_DELTA_PIXEL:
  1315. e.wheelX = e.deltaX * factor || 0;
  1316. e.wheelY = e.deltaY * factor || 0;
  1317. break;
  1318. case e.DOM_DELTA_LINE:
  1319. case e.DOM_DELTA_PAGE:
  1320. e.wheelX = (e.deltaX || 0) * 5;
  1321. e.wheelY = (e.deltaY || 0) * 5;
  1322. break;
  1323. }
  1324. callback(e);
  1325. });
  1326. } else {
  1327. exports.addListener(el, "DOMMouseScroll", function(e) {
  1328. if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
  1329. e.wheelX = (e.detail || 0) * 5;
  1330. e.wheelY = 0;
  1331. } else {
  1332. e.wheelX = 0;
  1333. e.wheelY = (e.detail || 0) * 5;
  1334. }
  1335. callback(e);
  1336. });
  1337. }
  1338. };
  1339. exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
  1340. var clicks = 0;
  1341. var startX, startY, timer;
  1342. var eventNames = {
  1343. 2: "dblclick",
  1344. 3: "tripleclick",
  1345. 4: "quadclick"
  1346. };
  1347. exports.addListener(el, "mousedown", function(e) {
  1348. if (exports.getButton(e) !== 0) {
  1349. clicks = 0;
  1350. } else if (e.detail > 1) {
  1351. clicks++;
  1352. if (clicks > 4)
  1353. clicks = 1;
  1354. } else {
  1355. clicks = 1;
  1356. }
  1357. if (useragent.isIE) {
  1358. var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
  1359. if (!timer || isNewClick)
  1360. clicks = 1;
  1361. if (timer)
  1362. clearTimeout(timer);
  1363. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1364. if (clicks == 1) {
  1365. startX = e.clientX;
  1366. startY = e.clientY;
  1367. }
  1368. }
  1369. e._clicks = clicks;
  1370. eventHandler[callbackName]("mousedown", e);
  1371. if (clicks > 4)
  1372. clicks = 0;
  1373. else if (clicks > 1)
  1374. return eventHandler[callbackName](eventNames[clicks], e);
  1375. });
  1376. if (useragent.isOldIE) {
  1377. exports.addListener(el, "dblclick", function(e) {
  1378. clicks = 2;
  1379. if (timer)
  1380. clearTimeout(timer);
  1381. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1382. eventHandler[callbackName]("mousedown", e);
  1383. eventHandler[callbackName](eventNames[clicks], e);
  1384. });
  1385. }
  1386. };
  1387. var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window)
  1388. ? function(e) {
  1389. return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
  1390. }
  1391. : function(e) {
  1392. return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
  1393. };
  1394. exports.getModifierString = function(e) {
  1395. return keys.KEY_MODS[getModifierHash(e)];
  1396. };
  1397. function normalizeCommandKeys(callback, e, keyCode) {
  1398. var hashId = getModifierHash(e);
  1399. if (!useragent.isMac && pressedKeys) {
  1400. if (pressedKeys[91] || pressedKeys[92])
  1401. hashId |= 8;
  1402. if (pressedKeys.altGr) {
  1403. if ((3 & hashId) != 3)
  1404. pressedKeys.altGr = 0;
  1405. else
  1406. return;
  1407. }
  1408. if (keyCode === 18 || keyCode === 17) {
  1409. var location = "location" in e ? e.location : e.keyLocation;
  1410. if (keyCode === 17 && location === 1) {
  1411. if (pressedKeys[keyCode] == 1)
  1412. ts = e.timeStamp;
  1413. } else if (keyCode === 18 && hashId === 3 && location === 2) {
  1414. var dt = e.timestamp - ts;
  1415. if (dt < 50)
  1416. pressedKeys.altGr = true;
  1417. }
  1418. }
  1419. }
  1420. if (keyCode in keys.MODIFIER_KEYS) {
  1421. keyCode = -1;
  1422. }
  1423. if (hashId & 8 && (keyCode === 91 || keyCode === 93)) {
  1424. keyCode = -1;
  1425. }
  1426. if (!hashId && keyCode === 13) {
  1427. var location = "location" in e ? e.location : e.keyLocation;
  1428. if (location === 3) {
  1429. callback(e, hashId, -keyCode);
  1430. if (e.defaultPrevented)
  1431. return;
  1432. }
  1433. }
  1434. if (useragent.isChromeOS && hashId & 8) {
  1435. callback(e, hashId, keyCode);
  1436. if (e.defaultPrevented)
  1437. return;
  1438. else
  1439. hashId &= ~8;
  1440. }
  1441. if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
  1442. return false;
  1443. }
  1444. return callback(e, hashId, keyCode);
  1445. }
  1446. var pressedKeys = null;
  1447. var ts = 0;
  1448. exports.addCommandKeyListener = function(el, callback) {
  1449. var addListener = exports.addListener;
  1450. if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
  1451. var lastKeyDownKeyCode = null;
  1452. addListener(el, "keydown", function(e) {
  1453. lastKeyDownKeyCode = e.keyCode;
  1454. });
  1455. addListener(el, "keypress", function(e) {
  1456. return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
  1457. });
  1458. } else {
  1459. var lastDefaultPrevented = null;
  1460. addListener(el, "keydown", function(e) {
  1461. pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1;
  1462. var result = normalizeCommandKeys(callback, e, e.keyCode);
  1463. lastDefaultPrevented = e.defaultPrevented;
  1464. return result;
  1465. });
  1466. addListener(el, "keypress", function(e) {
  1467. if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  1468. exports.stopEvent(e);
  1469. lastDefaultPrevented = null;
  1470. }
  1471. });
  1472. addListener(el, "keyup", function(e) {
  1473. pressedKeys[e.keyCode] = null;
  1474. });
  1475. if (!pressedKeys) {
  1476. pressedKeys = Object.create(null);
  1477. addListener(window, "focus", function(e) {
  1478. pressedKeys = Object.create(null);
  1479. });
  1480. }
  1481. }
  1482. };
  1483. if (window.postMessage && !useragent.isOldIE) {
  1484. var postMessageId = 1;
  1485. exports.nextTick = function(callback, win) {
  1486. win = win || window;
  1487. var messageName = "zero-timeout-message-" + postMessageId;
  1488. exports.addListener(win, "message", function listener(e) {
  1489. if (e.data == messageName) {
  1490. exports.stopPropagation(e);
  1491. exports.removeListener(win, "message", listener);
  1492. callback();
  1493. }
  1494. });
  1495. win.postMessage(messageName, "*");
  1496. };
  1497. }
  1498. exports.nextFrame = window.requestAnimationFrame ||
  1499. window.mozRequestAnimationFrame ||
  1500. window.webkitRequestAnimationFrame ||
  1501. window.msRequestAnimationFrame ||
  1502. window.oRequestAnimationFrame;
  1503. if (exports.nextFrame)
  1504. exports.nextFrame = exports.nextFrame.bind(window);
  1505. else
  1506. exports.nextFrame = function(callback) {
  1507. setTimeout(callback, 17);
  1508. };
  1509. });
  1510. ace.define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1511. "use strict";
  1512. exports.last = function(a) {
  1513. return a[a.length - 1];
  1514. };
  1515. exports.stringReverse = function(string) {
  1516. return string.split("").reverse().join("");
  1517. };
  1518. exports.stringRepeat = function (string, count) {
  1519. var result = '';
  1520. while (count > 0) {
  1521. if (count & 1)
  1522. result += string;
  1523. if (count >>= 1)
  1524. string += string;
  1525. }
  1526. return result;
  1527. };
  1528. var trimBeginRegexp = /^\s\s*/;
  1529. var trimEndRegexp = /\s\s*$/;
  1530. exports.stringTrimLeft = function (string) {
  1531. return string.replace(trimBeginRegexp, '');
  1532. };
  1533. exports.stringTrimRight = function (string) {
  1534. return string.replace(trimEndRegexp, '');
  1535. };
  1536. exports.copyObject = function(obj) {
  1537. var copy = {};
  1538. for (var key in obj) {
  1539. copy[key] = obj[key];
  1540. }
  1541. return copy;
  1542. };
  1543. exports.copyArray = function(array){
  1544. var copy = [];
  1545. for (var i=0, l=array.length; i<l; i++) {
  1546. if (array[i] && typeof array[i] == "object")
  1547. copy[i] = this.copyObject( array[i] );
  1548. else
  1549. copy[i] = array[i];
  1550. }
  1551. return copy;
  1552. };
  1553. exports.deepCopy = function (obj) {
  1554. // FUGLY HAX because deepCopy explodes
  1555. // as Ember.js monkeypatches JS native objects
  1556. return obj;
  1557. // END HAX
  1558. if (typeof obj !== "object" || !obj)
  1559. return obj;
  1560. var cons = obj.constructor;
  1561. if (cons === RegExp)
  1562. return obj;
  1563. var copy = cons();
  1564. for (var key in obj) {
  1565. if (typeof obj[key] === "object") {
  1566. copy[key] = exports.deepCopy(obj[key]);
  1567. } else {
  1568. copy[key] = obj[key];
  1569. }
  1570. }
  1571. return copy;
  1572. };
  1573. exports.arrayToMap = function(arr) {
  1574. var map = {};
  1575. for (var i=0; i<arr.length; i++) {
  1576. map[arr[i]] = 1;
  1577. }
  1578. return map;
  1579. };
  1580. exports.createMap = function(props) {
  1581. var map = Object.create(null);
  1582. for (var i in props) {
  1583. map[i] = props[i];
  1584. }
  1585. return map;
  1586. };
  1587. exports.arrayRemove = function(array, value) {
  1588. for (var i = 0; i <= array.length; i++) {
  1589. if (value === array[i]) {
  1590. array.splice(i, 1);
  1591. }
  1592. }
  1593. };
  1594. exports.escapeRegExp = function(str) {
  1595. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1596. };
  1597. exports.escapeHTML = function(str) {
  1598. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1599. };
  1600. exports.getMatchOffsets = function(string, regExp) {
  1601. var matches = [];
  1602. string.replace(regExp, function(str) {
  1603. matches.push({
  1604. offset: arguments[arguments.length-2],
  1605. length: str.length
  1606. });
  1607. });
  1608. return matches;
  1609. };
  1610. exports.deferredCall = function(fcn) {
  1611. var timer = null;
  1612. var callback = function() {
  1613. timer = null;
  1614. fcn();
  1615. };
  1616. var deferred = function(timeout) {
  1617. deferred.cancel();
  1618. timer = setTimeout(callback, timeout || 0);
  1619. return deferred;
  1620. };
  1621. deferred.schedule = deferred;
  1622. deferred.call = function() {
  1623. this.cancel();
  1624. fcn();
  1625. return deferred;
  1626. };
  1627. deferred.cancel = function() {
  1628. clearTimeout(timer);
  1629. timer = null;
  1630. return deferred;
  1631. };
  1632. deferred.isPending = function() {
  1633. return timer;
  1634. };
  1635. return deferred;
  1636. };
  1637. exports.delayedCall = function(fcn, defaultTimeout) {
  1638. var timer = null;
  1639. var callback = function() {
  1640. timer = null;
  1641. fcn();
  1642. };
  1643. var _self = function(timeout) {
  1644. if (timer == null)
  1645. timer = setTimeout(callback, timeout || defaultTimeout);
  1646. };
  1647. _self.delay = function(timeout) {
  1648. timer && clearTimeout(timer);
  1649. timer = setTimeout(callback, timeout || defaultTimeout);
  1650. };
  1651. _self.schedule = _self;
  1652. _self.call = function() {
  1653. this.cancel();
  1654. fcn();
  1655. };
  1656. _self.cancel = function() {
  1657. timer && clearTimeout(timer);
  1658. timer = null;
  1659. };
  1660. _self.isPending = function() {
  1661. return timer;
  1662. };
  1663. return _self;
  1664. };
  1665. });
  1666. ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
  1667. "use strict";
  1668. var event = require("../lib/event");
  1669. var useragent = require("../lib/useragent");
  1670. var dom = require("../lib/dom");
  1671. var lang = require("../lib/lang");
  1672. var BROKEN_SETDATA = useragent.isChrome < 18;
  1673. var USE_IE_MIME_TYPE = useragent.isIE;
  1674. var TextInput = function(parentNode, host) {
  1675. var text = dom.createElement("textarea");
  1676. text.className = "ace_text-input";
  1677. if (useragent.isTouchPad)
  1678. text.setAttribute("x-palm-disable-auto-cap", true);
  1679. text.setAttribute("wrap", "off");
  1680. text.setAttribute("autocorrect", "off");
  1681. text.setAttribute("autocapitalize", "off");
  1682. text.setAttribute("spellcheck", false);
  1683. text.style.opacity = "0";
  1684. if (useragent.isOldIE) text.style.top = "-1000px";
  1685. parentNode.insertBefore(text, parentNode.firstChild);
  1686. var PLACEHOLDER = "\x01\x01";
  1687. var copied = false;
  1688. var pasted = false;
  1689. var inComposition = false;
  1690. var tempStyle = '';
  1691. var isSelectionEmpty = true;
  1692. try { var isFocused = document.activeElement === text; } catch(e) {}
  1693. event.addListener(text, "blur", function(e) {
  1694. host.onBlur(e);
  1695. isFocused = false;
  1696. });
  1697. event.addListener(text, "focus", function(e) {
  1698. isFocused = true;
  1699. host.onFocus(e);
  1700. resetSelection();
  1701. });
  1702. this.focus = function() {
  1703. if (tempStyle) return text.focus();
  1704. text.style.position = "fixed";
  1705. text.style.top = "-1000px";
  1706. text.focus();
  1707. setTimeout(function() {
  1708. text.style.position = "";
  1709. }, 0);
  1710. };
  1711. this.blur = function() { text.blur(); };
  1712. this.isFocused = function() {
  1713. return isFocused;
  1714. };
  1715. var syncSelection = lang.delayedCall(function() {
  1716. isFocused && resetSelection(isSelectionEmpty);
  1717. });
  1718. var syncValue = lang.delayedCall(function() {
  1719. if (!inComposition) {
  1720. text.value = PLACEHOLDER;
  1721. isFocused && resetSelection();
  1722. }
  1723. });
  1724. function resetSelection(isEmpty) {
  1725. if (inComposition)
  1726. return;
  1727. inComposition = true;
  1728. if (inputHandler) {
  1729. selectionStart = 0;
  1730. selectionEnd = isEmpty ? 0 : text.value.length - 1;
  1731. } else {
  1732. var selectionStart = isEmpty ? 2 : 1;
  1733. var selectionEnd = 2;
  1734. }
  1735. try {
  1736. text.setSelectionRange(selectionStart, selectionEnd);
  1737. } catch(e){}
  1738. inComposition = false;
  1739. }
  1740. function resetValue() {
  1741. if (inComposition)
  1742. return;
  1743. text.value = PLACEHOLDER;
  1744. if (useragent.isWebKit)
  1745. syncValue.schedule();
  1746. }
  1747. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  1748. if (host.selection.isEmpty() != isSelectionEmpty) {
  1749. isSelectionEmpty = !isSelectionEmpty;
  1750. syncSelection.schedule();
  1751. }
  1752. });
  1753. resetValue();
  1754. if (isFocused)
  1755. host.onFocus();
  1756. var isAllSelected = function(text) {
  1757. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  1758. };
  1759. if (!text.setSelectionRange && text.createTextRange) {
  1760. text.setSelectionRange = function(selectionStart, selectionEnd) {
  1761. var range = this.createTextRange();
  1762. range.collapse(true);
  1763. range.moveStart('character', selectionStart);
  1764. range.moveEnd('character', selectionEnd);
  1765. range.select();
  1766. };
  1767. isAllSelected = function(text) {
  1768. try {
  1769. var range = text.ownerDocument.selection.createRange();
  1770. }catch(e) {}
  1771. if (!range || range.parentElement() != text) return false;
  1772. return range.text == text.value;
  1773. }
  1774. }
  1775. if (useragent.isOldIE) {
  1776. var inPropertyChange = false;
  1777. var onPropertyChange = function(e){
  1778. if (inPropertyChange)
  1779. return;
  1780. var data = text.value;
  1781. if (inComposition || !data || data == PLACEHOLDER)
  1782. return;
  1783. if (e && data == PLACEHOLDER[0])
  1784. return syncProperty.schedule();
  1785. sendText(data);
  1786. inPropertyChange = true;
  1787. resetValue();
  1788. inPropertyChange = false;
  1789. };
  1790. var syncProperty = lang.delayedCall(onPropertyChange);
  1791. event.addListener(text, "propertychange", onPropertyChange);
  1792. var keytable = { 13:1, 27:1 };
  1793. event.addListener(text, "keyup", function (e) {
  1794. if (inComposition && (!text.value || keytable[e.keyCode]))
  1795. setTimeout(onCompositionEnd, 0);
  1796. if ((text.value.charCodeAt(0)||0) < 129) {
  1797. return syncProperty.call();
  1798. }
  1799. inComposition ? onCompositionUpdate() : onCompositionStart();
  1800. });
  1801. event.addListener(text, "keydown", function (e) {
  1802. syncProperty.schedule(50);
  1803. });
  1804. }
  1805. var onSelect = function(e) {
  1806. if (copied) {
  1807. copied = false;
  1808. } else if (isAllSelected(text)) {
  1809. host.selectAll();
  1810. resetSelection();
  1811. } else if (inputHandler) {
  1812. resetSelection(host.selection.isEmpty());
  1813. }
  1814. };
  1815. var inputHandler = null;
  1816. this.setInputHandler = function(cb) {inputHandler = cb};
  1817. this.getInputHandler = function() {return inputHandler};
  1818. var afterContextMenu = false;
  1819. var sendText = function(data) {
  1820. if (inputHandler) {
  1821. data = inputHandler(data);
  1822. inputHandler = null;
  1823. }
  1824. if (pasted) {
  1825. resetSelection();
  1826. if (data)
  1827. host.onPaste(data);
  1828. pasted = false;
  1829. } else if (data == PLACEHOLDER.charAt(0)) {
  1830. if (afterContextMenu)
  1831. host.execCommand("del", {source: "ace"});
  1832. else // some versions of android do not fire keydown when pressing backspace
  1833. host.execCommand("backspace", {source: "ace"});
  1834. } else {
  1835. if (data.substring(0, 2) == PLACEHOLDER)
  1836. data = data.substr(2);
  1837. else if (data.charAt(0) == PLACEHOLDER.charAt(0))
  1838. data = data.substr(1);
  1839. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1840. data = data.slice(0, -1);
  1841. if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1842. data = data.slice(0, -1);
  1843. if (data)
  1844. host.onTextInput(data);
  1845. }
  1846. if (afterContextMenu)
  1847. afterContextMenu = false;
  1848. };
  1849. var onInput = function(e) {
  1850. if (inComposition)
  1851. return;
  1852. var data = text.value;
  1853. sendText(data);
  1854. resetValue();
  1855. };
  1856. var handleClipboardData = function(e, data) {
  1857. var clipboardData = e.clipboardData || window.clipboardData;
  1858. if (!clipboardData || BROKEN_SETDATA)
  1859. return;
  1860. var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
  1861. if (data) {
  1862. return clipboardData.setData(mime, data) !== false;
  1863. } else {
  1864. return clipboardData.getData(mime);
  1865. }
  1866. };
  1867. var doCopy = function(e, isCut) {
  1868. var data = host.getCopyText();
  1869. if (!data)
  1870. return event.preventDefault(e);
  1871. if (handleClipboardData(e, data)) {
  1872. isCut ? host.onCut() : host.onCopy();
  1873. event.preventDefault(e);
  1874. } else {
  1875. copied = true;
  1876. text.value = data;
  1877. text.select();
  1878. setTimeout(function(){
  1879. copied = false;
  1880. resetValue();
  1881. resetSelection();
  1882. isCut ? host.onCut() : host.onCopy();
  1883. });
  1884. }
  1885. };
  1886. var onCut = function(e) {
  1887. doCopy(e, true);
  1888. };
  1889. var onCopy = function(e) {
  1890. doCopy(e, false);
  1891. };
  1892. var onPaste = function(e) {
  1893. var data = handleClipboardData(e);
  1894. if (typeof data == "string") {
  1895. if (data)
  1896. host.onPaste(data);
  1897. if (useragent.isIE)
  1898. setTimeout(resetSelection);
  1899. event.preventDefault(e);
  1900. }
  1901. else {
  1902. text.value = "";
  1903. pasted = true;
  1904. }
  1905. };
  1906. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  1907. event.addListener(text, "select", onSelect);
  1908. event.addListener(text, "input", onInput);
  1909. event.addListener(text, "cut", onCut);
  1910. event.addListener(text, "copy", onCopy);
  1911. event.addListener(text, "paste", onPaste);
  1912. if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
  1913. event.addListener(parentNode, "keydown", function(e) {
  1914. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  1915. return;
  1916. switch (e.keyCode) {
  1917. case 67:
  1918. onCopy(e);
  1919. break;
  1920. case 86:
  1921. onPaste(e);
  1922. break;
  1923. case 88:
  1924. onCut(e);
  1925. break;
  1926. }
  1927. });
  1928. }
  1929. var onCompositionStart = function(e) {
  1930. if (inComposition || !host.onCompositionStart || host.$readOnly)
  1931. return;
  1932. inComposition = {};
  1933. host.onCompositionStart();
  1934. setTimeout(onCompositionUpdate, 0);
  1935. host.on("mousedown", onCompositionEnd);
  1936. if (!host.selection.isEmpty()) {
  1937. host.insert("");
  1938. host.session.markUndoGroup();
  1939. host.selection.clearSelection();
  1940. }
  1941. host.session.markUndoGroup();
  1942. };
  1943. var onCompositionUpdate = function() {
  1944. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  1945. return;
  1946. var val = text.value.replace(/\x01/g, "");
  1947. if (inComposition.lastValue === val) return;
  1948. host.onCompositionUpdate(val);
  1949. if (inComposition.lastValue)
  1950. host.undo();
  1951. inComposition.lastValue = val;
  1952. if (inComposition.lastValue) {
  1953. var r = host.selection.getRange();
  1954. host.insert(inComposition.lastValue);
  1955. host.session.markUndoGroup();
  1956. inComposition.range = host.selection.getRange();
  1957. host.selection.setRange(r);
  1958. host.selection.clearSelection();
  1959. }
  1960. };
  1961. var onCompositionEnd = function(e) {
  1962. if (!host.onCompositionEnd || host.$readOnly) return;
  1963. var c = inComposition;
  1964. inComposition = false;
  1965. var timer = setTimeout(function() {
  1966. timer = null;
  1967. var str = text.value.replace(/\x01/g, "");
  1968. if (inComposition)
  1969. return;
  1970. else if (str == c.lastValue)
  1971. resetValue();
  1972. else if (!c.lastValue && str) {
  1973. resetValue();
  1974. sendText(str);
  1975. }
  1976. });
  1977. inputHandler = function compositionInputHandler(str) {
  1978. if (timer)
  1979. clearTimeout(timer);
  1980. str = str.replace(/\x01/g, "");
  1981. if (str == c.lastValue)
  1982. return "";
  1983. if (c.lastValue && timer)
  1984. host.undo();
  1985. return str;
  1986. };
  1987. host.onCompositionEnd();
  1988. host.removeListener("mousedown", onCompositionEnd);
  1989. if (e.type == "compositionend" && c.range) {
  1990. host.selection.setRange(c.range);
  1991. }
  1992. };
  1993. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  1994. event.addListener(text, "compositionstart", onCompositionStart);
  1995. if (useragent.isGecko) {
  1996. event.addListener(text, "text", function(){syncComposition.schedule()});
  1997. } else {
  1998. event.addListener(text, "keyup", function(){syncComposition.schedule()});
  1999. event.addListener(text, "keydown", function(){syncComposition.schedule()});
  2000. }
  2001. event.addListener(text, "compositionend", onCompositionEnd);
  2002. this.getElement = function() {
  2003. return text;
  2004. };
  2005. this.setReadOnly = function(readOnly) {
  2006. text.readOnly = readOnly;
  2007. };
  2008. this.onContextMenu = function(e) {
  2009. afterContextMenu = true;
  2010. resetSelection(host.selection.isEmpty());
  2011. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2012. this.moveToMouse(e, true);
  2013. };
  2014. this.moveToMouse = function(e, bringToFront) {
  2015. if (!bringToFront && useragent.isOldIE)
  2016. return;
  2017. if (!tempStyle)
  2018. tempStyle = text.style.cssText;
  2019. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2020. + "height:" + text.style.height + ";"
  2021. + (useragent.isIE ? "opacity:0.1;" : "");
  2022. var rect = host.container.getBoundingClientRect();
  2023. var style = dom.computedStyle(host.container);
  2024. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2025. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2026. var maxTop = rect.bottom - top - text.clientHeight -2;
  2027. var move = function(e) {
  2028. text.style.left = e.clientX - left - 2 + "px";
  2029. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2030. };
  2031. move(e);
  2032. if (e.type != "mousedown")
  2033. return;
  2034. if (host.renderer.$keepTextAreaAtCursor)
  2035. host.renderer.$keepTextAreaAtCursor = null;
  2036. if (useragent.isWin && !useragent.isOldIE)
  2037. event.capture(host.container, move, onContextMenuClose);
  2038. };
  2039. this.onContextMenuClose = onContextMenuClose;
  2040. var closeTimeout;
  2041. function onContextMenuClose() {
  2042. clearTimeout(closeTimeout)
  2043. closeTimeout = setTimeout(function () {
  2044. if (tempStyle) {
  2045. text.style.cssText = tempStyle;
  2046. tempStyle = '';
  2047. }
  2048. if (host.renderer.$keepTextAreaAtCursor == null) {
  2049. host.renderer.$keepTextAreaAtCursor = true;
  2050. host.renderer.$moveTextAreaToCursor();
  2051. }
  2052. }, useragent.isOldIE ? 200 : 0);
  2053. }
  2054. var onContextMenu = function(e) {
  2055. host.textInput.onContextMenu(e);
  2056. onContextMenuClose();
  2057. };
  2058. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2059. event.addListener(text, "contextmenu", onContextMenu);
  2060. };
  2061. exports.TextInput = TextInput;
  2062. });
  2063. ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2064. "use strict";
  2065. var dom = require("../lib/dom");
  2066. var event = require("../lib/event");
  2067. var useragent = require("../lib/useragent");
  2068. var DRAG_OFFSET = 0; // pixels
  2069. function DefaultHandlers(mouseHandler) {
  2070. mouseHandler.$clickSelection = null;
  2071. var editor = mouseHandler.editor;
  2072. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  2073. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  2074. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  2075. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  2076. editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
  2077. var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
  2078. "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
  2079. exports.forEach(function(x) {
  2080. mouseHandler[x] = this[x];
  2081. }, this);
  2082. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  2083. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  2084. }
  2085. (function() {
  2086. this.onMouseDown = function(ev) {
  2087. var inSelection = ev.inSelection();
  2088. var pos = ev.getDocumentPosition();
  2089. this.mousedownEvent = ev;
  2090. var editor = this.editor;
  2091. var button = ev.getButton();
  2092. if (button !== 0) {
  2093. var selectionRange = editor.getSelectionRange();
  2094. var selectionEmpty = selectionRange.isEmpty();
  2095. editor.$blockScrolling++;
  2096. if (selectionEmpty)
  2097. editor.selection.moveToPosition(pos);
  2098. editor.$blockScrolling--;
  2099. editor.textInput.onContextMenu(ev.domEvent);
  2100. return; // stopping event here breaks contextmenu on ff mac
  2101. }
  2102. this.mousedownEvent.time = Date.now();
  2103. if (inSelection && !editor.isFocused()) {
  2104. editor.focus();
  2105. if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
  2106. this.setState("focusWait");
  2107. this.captureMouse(ev);
  2108. return;
  2109. }
  2110. }
  2111. this.captureMouse(ev);
  2112. this.startSelect(pos, ev.domEvent._clicks > 1);
  2113. return ev.preventDefault();
  2114. };
  2115. this.startSelect = function(pos, waitForClickSelection) {
  2116. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  2117. var editor = this.editor;
  2118. editor.$blockScrolling++;
  2119. if (this.mousedownEvent.getShiftKey())
  2120. editor.selection.selectToPosition(pos);
  2121. else if (!waitForClickSelection)
  2122. editor.selection.moveToPosition(pos);
  2123. if (!waitForClickSelection)
  2124. this.select();
  2125. if (editor.renderer.scroller.setCapture) {
  2126. editor.renderer.scroller.setCapture();
  2127. }
  2128. editor.setStyle("ace_selecting");
  2129. this.setState("select");
  2130. editor.$blockScrolling--;
  2131. };
  2132. this.select = function() {
  2133. var anchor, editor = this.editor;
  2134. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2135. editor.$blockScrolling++;
  2136. if (this.$clickSelection) {
  2137. var cmp = this.$clickSelection.comparePoint(cursor);
  2138. if (cmp == -1) {
  2139. anchor = this.$clickSelection.end;
  2140. } else if (cmp == 1) {
  2141. anchor = this.$clickSelection.start;
  2142. } else {
  2143. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2144. cursor = orientedRange.cursor;
  2145. anchor = orientedRange.anchor;
  2146. }
  2147. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2148. }
  2149. editor.selection.selectToPosition(cursor);
  2150. editor.$blockScrolling--;
  2151. editor.renderer.scrollCursorIntoView();
  2152. };
  2153. this.extendSelectionBy = function(unitName) {
  2154. var anchor, editor = this.editor;
  2155. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2156. var range = editor.selection[unitName](cursor.row, cursor.column);
  2157. editor.$blockScrolling++;
  2158. if (this.$clickSelection) {
  2159. var cmpStart = this.$clickSelection.comparePoint(range.start);
  2160. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  2161. if (cmpStart == -1 && cmpEnd <= 0) {
  2162. anchor = this.$clickSelection.end;
  2163. if (range.end.row != cursor.row || range.end.column != cursor.column)
  2164. cursor = range.start;
  2165. } else if (cmpEnd == 1 && cmpStart >= 0) {
  2166. anchor = this.$clickSelection.start;
  2167. if (range.start.row != cursor.row || range.start.column != cursor.column)
  2168. cursor = range.end;
  2169. } else if (cmpStart == -1 && cmpEnd == 1) {
  2170. cursor = range.end;
  2171. anchor = range.start;
  2172. } else {
  2173. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2174. cursor = orientedRange.cursor;
  2175. anchor = orientedRange.anchor;
  2176. }
  2177. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2178. }
  2179. editor.selection.selectToPosition(cursor);
  2180. editor.$blockScrolling--;
  2181. editor.renderer.scrollCursorIntoView();
  2182. };
  2183. this.selectEnd =
  2184. this.selectAllEnd =
  2185. this.selectByWordsEnd =
  2186. this.selectByLinesEnd = function() {
  2187. this.$clickSelection = null;
  2188. this.editor.unsetStyle("ace_selecting");
  2189. if (this.editor.renderer.scroller.releaseCapture) {
  2190. this.editor.renderer.scroller.releaseCapture();
  2191. }
  2192. };
  2193. this.focusWait = function() {
  2194. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2195. var time = Date.now();
  2196. if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
  2197. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2198. };
  2199. this.onDoubleClick = function(ev) {
  2200. var pos = ev.getDocumentPosition();
  2201. var editor = this.editor;
  2202. var session = editor.session;
  2203. var range = session.getBracketRange(pos);
  2204. if (range) {
  2205. if (range.isEmpty()) {
  2206. range.start.column--;
  2207. range.end.column++;
  2208. }
  2209. this.setState("select");
  2210. } else {
  2211. range = editor.selection.getWordRange(pos.row, pos.column);
  2212. this.setState("selectByWords");
  2213. }
  2214. this.$clickSelection = range;
  2215. this.select();
  2216. };
  2217. this.onTripleClick = function(ev) {
  2218. var pos = ev.getDocumentPosition();
  2219. var editor = this.editor;
  2220. this.setState("selectByLines");
  2221. var range = editor.getSelectionRange();
  2222. if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
  2223. this.$clickSelection = editor.selection.getLineRange(range.start.row);
  2224. this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
  2225. } else {
  2226. this.$clickSelection = editor.selection.getLineRange(pos.row);
  2227. }
  2228. this.select();
  2229. };
  2230. this.onQuadClick = function(ev) {
  2231. var editor = this.editor;
  2232. editor.selectAll();
  2233. this.$clickSelection = editor.getSelectionRange();
  2234. this.setState("selectAll");
  2235. };
  2236. this.onMouseWheel = function(ev) {
  2237. if (ev.getAccelKey())
  2238. return;
  2239. if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
  2240. ev.wheelX = ev.wheelY;
  2241. ev.wheelY = 0;
  2242. }
  2243. var t = ev.domEvent.timeStamp;
  2244. var dt = t - (this.$lastScrollTime||0);
  2245. var editor = this.editor;
  2246. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2247. if (isScrolable || dt < 200) {
  2248. this.$lastScrollTime = t;
  2249. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2250. return ev.stop();
  2251. }
  2252. };
  2253. }).call(DefaultHandlers.prototype);
  2254. exports.DefaultHandlers = DefaultHandlers;
  2255. function calcDistance(ax, ay, bx, by) {
  2256. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2257. }
  2258. function calcRangeOrientation(range, cursor) {
  2259. if (range.start.row == range.end.row)
  2260. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  2261. else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
  2262. var cmp = cursor.column - 4;
  2263. else
  2264. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  2265. if (cmp < 0)
  2266. return {cursor: range.start, anchor: range.end};
  2267. else
  2268. return {cursor: range.end, anchor: range.start};
  2269. }
  2270. });
  2271. ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
  2272. "use strict";
  2273. var oop = require("./lib/oop");
  2274. var dom = require("./lib/dom");
  2275. function Tooltip (parentNode) {
  2276. this.isOpen = false;
  2277. this.$element = null;
  2278. this.$parentNode = parentNode;
  2279. }
  2280. (function() {
  2281. this.$init = function() {
  2282. this.$element = dom.createElement("div");
  2283. this.$element.className = "ace_tooltip";
  2284. this.$element.style.display = "none";
  2285. this.$parentNode.appendChild(this.$element);
  2286. return this.$element;
  2287. };
  2288. this.getElement = function() {
  2289. return this.$element || this.$init();
  2290. };
  2291. this.setText = function(text) {
  2292. dom.setInnerText(this.getElement(), text);
  2293. };
  2294. this.setHtml = function(html) {
  2295. this.getElement().innerHTML = html;
  2296. };
  2297. this.setPosition = function(x, y) {
  2298. this.getElement().style.left = x + "px";
  2299. this.getElement().style.top = y + "px";
  2300. };
  2301. this.setClassName = function(className) {
  2302. dom.addCssClass(this.getElement(), className);
  2303. };
  2304. this.show = function(text, x, y) {
  2305. if (text != null)
  2306. this.setText(text);
  2307. if (x != null && y != null)
  2308. this.setPosition(x, y);
  2309. if (!this.isOpen) {
  2310. this.getElement().style.display = "block";
  2311. this.isOpen = true;
  2312. }
  2313. };
  2314. this.hide = function() {
  2315. if (this.isOpen) {
  2316. this.getElement().style.display = "none";
  2317. this.isOpen = false;
  2318. }
  2319. };
  2320. this.getHeight = function() {
  2321. return this.getElement().offsetHeight;
  2322. };
  2323. this.getWidth = function() {
  2324. return this.getElement().offsetWidth;
  2325. };
  2326. }).call(Tooltip.prototype);
  2327. exports.Tooltip = Tooltip;
  2328. });
  2329. 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) {
  2330. "use strict";
  2331. var dom = require("../lib/dom");
  2332. var oop = require("../lib/oop");
  2333. var event = require("../lib/event");
  2334. var Tooltip = require("../tooltip").Tooltip;
  2335. function GutterHandler(mouseHandler) {
  2336. var editor = mouseHandler.editor;
  2337. var gutter = editor.renderer.$gutterLayer;
  2338. var tooltip = new GutterTooltip(editor.container);
  2339. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  2340. if (!editor.isFocused() || e.getButton() != 0)
  2341. return;
  2342. var gutterRegion = gutter.getRegion(e);
  2343. if (gutterRegion == "foldWidgets")
  2344. return;
  2345. var row = e.getDocumentPosition().row;
  2346. var selection = editor.session.selection;
  2347. if (e.getShiftKey())
  2348. selection.selectTo(row, 0);
  2349. else {
  2350. if (e.domEvent.detail == 2) {
  2351. editor.selectAll();
  2352. return e.preventDefault();
  2353. }
  2354. mouseHandler.$clickSelection = editor.selection.getLineRange(row);
  2355. }
  2356. mouseHandler.setState("selectByLines");
  2357. mouseHandler.captureMouse(e);
  2358. return e.preventDefault();
  2359. });
  2360. var tooltipTimeout, mouseEvent, tooltipAnnotation;
  2361. function showTooltip() {
  2362. var row = mouseEvent.getDocumentPosition().row;
  2363. var annotation = gutter.$annotations[row];
  2364. if (!annotation)
  2365. return hideTooltip();
  2366. var maxRow = editor.session.getLength();
  2367. if (row == maxRow) {
  2368. var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
  2369. var pos = mouseEvent.$pos;
  2370. if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
  2371. return hideTooltip();
  2372. }
  2373. if (tooltipAnnotation == annotation)
  2374. return;
  2375. tooltipAnnotation = annotation.text.join("<br/>");
  2376. tooltip.setHtml(tooltipAnnotation);
  2377. tooltip.show();
  2378. editor.on("mousewheel", hideTooltip);
  2379. if (mouseHandler.$tooltipFollowsMouse) {
  2380. moveTooltip(mouseEvent);
  2381. } else {
  2382. var gutterElement = gutter.$cells[editor.session.documentToScreenRow(row, 0)].element;
  2383. var rect = gutterElement.getBoundingClientRect();
  2384. var style = tooltip.getElement().style;
  2385. style.left = rect.right + "px";
  2386. style.top = rect.bottom + "px";
  2387. }
  2388. }
  2389. function hideTooltip() {
  2390. if (tooltipTimeout)
  2391. tooltipTimeout = clearTimeout(tooltipTimeout);
  2392. if (tooltipAnnotation) {
  2393. tooltip.hide();
  2394. tooltipAnnotation = null;
  2395. editor.removeEventListener("mousewheel", hideTooltip);
  2396. }
  2397. }
  2398. function moveTooltip(e) {
  2399. tooltip.setPosition(e.x, e.y);
  2400. }
  2401. mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
  2402. var target = e.domEvent.target || e.domEvent.srcElement;
  2403. if (dom.hasCssClass(target, "ace_fold-widget"))
  2404. return hideTooltip();
  2405. if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
  2406. moveTooltip(e);
  2407. mouseEvent = e;
  2408. if (tooltipTimeout)
  2409. return;
  2410. tooltipTimeout = setTimeout(function() {
  2411. tooltipTimeout = null;
  2412. if (mouseEvent && !mouseHandler.isMousePressed)
  2413. showTooltip();
  2414. else
  2415. hideTooltip();
  2416. }, 50);
  2417. });
  2418. event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
  2419. mouseEvent = null;
  2420. if (!tooltipAnnotation || tooltipTimeout)
  2421. return;
  2422. tooltipTimeout = setTimeout(function() {
  2423. tooltipTimeout = null;
  2424. hideTooltip();
  2425. }, 50);
  2426. });
  2427. editor.on("changeSession", hideTooltip);
  2428. }
  2429. function GutterTooltip(parentNode) {
  2430. Tooltip.call(this, parentNode);
  2431. }
  2432. oop.inherits(GutterTooltip, Tooltip);
  2433. (function(){
  2434. this.setPosition = function(x, y) {
  2435. var windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2436. var windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2437. var width = this.getWidth();
  2438. var height = this.getHeight();
  2439. x += 15;
  2440. y += 15;
  2441. if (x + width > windowWidth) {
  2442. x -= (x + width) - windowWidth;
  2443. }
  2444. if (y + height > windowHeight) {
  2445. y -= 20 + height;
  2446. }
  2447. Tooltip.prototype.setPosition.call(this, x, y);
  2448. };
  2449. }).call(GutterTooltip.prototype);
  2450. exports.GutterHandler = GutterHandler;
  2451. });
  2452. ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2453. "use strict";
  2454. var event = require("../lib/event");
  2455. var useragent = require("../lib/useragent");
  2456. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  2457. this.domEvent = domEvent;
  2458. this.editor = editor;
  2459. this.x = this.clientX = domEvent.clientX;
  2460. this.y = this.clientY = domEvent.clientY;
  2461. this.$pos = null;
  2462. this.$inSelection = null;
  2463. this.propagationStopped = false;
  2464. this.defaultPrevented = false;
  2465. };
  2466. (function() {
  2467. this.stopPropagation = function() {
  2468. event.stopPropagation(this.domEvent);
  2469. this.propagationStopped = true;
  2470. };
  2471. this.preventDefault = function() {
  2472. event.preventDefault(this.domEvent);
  2473. this.defaultPrevented = true;
  2474. };
  2475. this.stop = function() {
  2476. this.stopPropagation();
  2477. this.preventDefault();
  2478. };
  2479. this.getDocumentPosition = function() {
  2480. if (this.$pos)
  2481. return this.$pos;
  2482. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  2483. return this.$pos;
  2484. };
  2485. this.inSelection = function() {
  2486. if (this.$inSelection !== null)
  2487. return this.$inSelection;
  2488. var editor = this.editor;
  2489. var selectionRange = editor.getSelectionRange();
  2490. if (selectionRange.isEmpty())
  2491. this.$inSelection = false;
  2492. else {
  2493. var pos = this.getDocumentPosition();
  2494. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  2495. }
  2496. return this.$inSelection;
  2497. };
  2498. this.getButton = function() {
  2499. return event.getButton(this.domEvent);
  2500. };
  2501. this.getShiftKey = function() {
  2502. return this.domEvent.shiftKey;
  2503. };
  2504. this.getAccelKey = useragent.isMac
  2505. ? function() { return this.domEvent.metaKey; }
  2506. : function() { return this.domEvent.ctrlKey; };
  2507. }).call(MouseEvent.prototype);
  2508. });
  2509. ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2510. "use strict";
  2511. var dom = require("../lib/dom");
  2512. var event = require("../lib/event");
  2513. var useragent = require("../lib/useragent");
  2514. var AUTOSCROLL_DELAY = 200;
  2515. var SCROLL_CURSOR_DELAY = 200;
  2516. var SCROLL_CURSOR_HYSTERESIS = 5;
  2517. function DragdropHandler(mouseHandler) {
  2518. var editor = mouseHandler.editor;
  2519. var blankImage = dom.createElement("img");
  2520. blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  2521. if (useragent.isOpera)
  2522. blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
  2523. var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
  2524. exports.forEach(function(x) {
  2525. mouseHandler[x] = this[x];
  2526. }, this);
  2527. editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
  2528. var mouseTarget = editor.container;
  2529. var dragSelectionMarker, x, y;
  2530. var timerId, range;
  2531. var dragCursor, counter = 0;
  2532. var dragOperation;
  2533. var isInternal;
  2534. var autoScrollStartTime;
  2535. var cursorMovedTime;
  2536. var cursorPointOnCaretMoved;
  2537. this.onDragStart = function(e) {
  2538. if (this.cancelDrag || !mouseTarget.draggable) {
  2539. var self = this;
  2540. setTimeout(function(){
  2541. self.startSelect();
  2542. self.captureMouse(e);
  2543. }, 0);
  2544. return e.preventDefault();
  2545. }
  2546. range = editor.getSelectionRange();
  2547. var dataTransfer = e.dataTransfer;
  2548. dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
  2549. if (useragent.isOpera) {
  2550. editor.container.appendChild(blankImage);
  2551. blankImage.scrollTop = 0;
  2552. }
  2553. dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
  2554. if (useragent.isOpera) {
  2555. editor.container.removeChild(blankImage);
  2556. }
  2557. dataTransfer.clearData();
  2558. dataTransfer.setData("Text", editor.session.getTextRange());
  2559. isInternal = true;
  2560. this.setState("drag");
  2561. };
  2562. this.onDragEnd = function(e) {
  2563. mouseTarget.draggable = false;
  2564. isInternal = false;
  2565. this.setState(null);
  2566. if (!editor.getReadOnly()) {
  2567. var dropEffect = e.dataTransfer.dropEffect;
  2568. if (!dragOperation && dropEffect == "move")
  2569. editor.session.remove(editor.getSelectionRange());
  2570. editor.renderer.$cursorLayer.setBlinking(true);
  2571. }
  2572. this.editor.unsetStyle("ace_dragging");
  2573. this.editor.renderer.setCursorStyle("");
  2574. };
  2575. this.onDragEnter = function(e) {
  2576. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2577. return;
  2578. x = e.clientX;
  2579. y = e.clientY;
  2580. if (!dragSelectionMarker)
  2581. addDragMarker();
  2582. counter++;
  2583. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2584. return event.preventDefault(e);
  2585. };
  2586. this.onDragOver = function(e) {
  2587. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2588. return;
  2589. x = e.clientX;
  2590. y = e.clientY;
  2591. if (!dragSelectionMarker) {
  2592. addDragMarker();
  2593. counter++;
  2594. }
  2595. if (onMouseMoveTimer !== null)
  2596. onMouseMoveTimer = null;
  2597. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2598. return event.preventDefault(e);
  2599. };
  2600. this.onDragLeave = function(e) {
  2601. counter--;
  2602. if (counter <= 0 && dragSelectionMarker) {
  2603. clearDragMarker();
  2604. dragOperation = null;
  2605. return event.preventDefault(e);
  2606. }
  2607. };
  2608. this.onDrop = function(e) {
  2609. if (!dragCursor)
  2610. return;
  2611. var dataTransfer = e.dataTransfer;
  2612. if (isInternal) {
  2613. switch (dragOperation) {
  2614. case "move":
  2615. if (range.contains(dragCursor.row, dragCursor.column)) {
  2616. range = {
  2617. start: dragCursor,
  2618. end: dragCursor
  2619. };
  2620. } else {
  2621. range = editor.moveText(range, dragCursor);
  2622. }
  2623. break;
  2624. case "copy":
  2625. range = editor.moveText(range, dragCursor, true);
  2626. break;
  2627. }
  2628. } else {
  2629. var dropData = dataTransfer.getData('Text');
  2630. range = {
  2631. start: dragCursor,
  2632. end: editor.session.insert(dragCursor, dropData)
  2633. };
  2634. editor.focus();
  2635. dragOperation = null;
  2636. }
  2637. clearDragMarker();
  2638. return event.preventDefault(e);
  2639. };
  2640. event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
  2641. event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
  2642. event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
  2643. event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
  2644. event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
  2645. event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
  2646. function scrollCursorIntoView(cursor, prevCursor) {
  2647. var now = Date.now();
  2648. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2649. var hMovement = !prevCursor || cursor.column != prevCursor.column;
  2650. if (!cursorMovedTime || vMovement || hMovement) {
  2651. editor.$blockScrolling += 1;
  2652. editor.moveCursorToPosition(cursor);
  2653. editor.$blockScrolling -= 1;
  2654. cursorMovedTime = now;
  2655. cursorPointOnCaretMoved = {x: x, y: y};
  2656. } else {
  2657. var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
  2658. if (distance > SCROLL_CURSOR_HYSTERESIS) {
  2659. cursorMovedTime = null;
  2660. } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
  2661. editor.renderer.scrollCursorIntoView();
  2662. cursorMovedTime = null;
  2663. }
  2664. }
  2665. }
  2666. function autoScroll(cursor, prevCursor) {
  2667. var now = Date.now();
  2668. var lineHeight = editor.renderer.layerConfig.lineHeight;
  2669. var characterWidth = editor.renderer.layerConfig.characterWidth;
  2670. var editorRect = editor.renderer.scroller.getBoundingClientRect();
  2671. var offsets = {
  2672. x: {
  2673. left: x - editorRect.left,
  2674. right: editorRect.right - x
  2675. },
  2676. y: {
  2677. top: y - editorRect.top,
  2678. bottom: editorRect.bottom - y
  2679. }
  2680. };
  2681. var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
  2682. var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
  2683. var scrollCursor = {row: cursor.row, column: cursor.column};
  2684. if (nearestXOffset / characterWidth <= 2) {
  2685. scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
  2686. }
  2687. if (nearestYOffset / lineHeight <= 1) {
  2688. scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
  2689. }
  2690. var vScroll = cursor.row != scrollCursor.row;
  2691. var hScroll = cursor.column != scrollCursor.column;
  2692. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2693. if (vScroll || (hScroll && !vMovement)) {
  2694. if (!autoScrollStartTime)
  2695. autoScrollStartTime = now;
  2696. else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
  2697. editor.renderer.scrollCursorIntoView(scrollCursor);
  2698. } else {
  2699. autoScrollStartTime = null;
  2700. }
  2701. }
  2702. function onDragInterval() {
  2703. var prevCursor = dragCursor;
  2704. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  2705. scrollCursorIntoView(dragCursor, prevCursor);
  2706. autoScroll(dragCursor, prevCursor);
  2707. }
  2708. function addDragMarker() {
  2709. range = editor.selection.toOrientedRange();
  2710. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
  2711. editor.clearSelection();
  2712. if (editor.isFocused())
  2713. editor.renderer.$cursorLayer.setBlinking(false);
  2714. clearInterval(timerId);
  2715. onDragInterval();
  2716. timerId = setInterval(onDragInterval, 20);
  2717. counter = 0;
  2718. event.addListener(document, "mousemove", onMouseMove);
  2719. }
  2720. function clearDragMarker() {
  2721. clearInterval(timerId);
  2722. editor.session.removeMarker(dragSelectionMarker);
  2723. dragSelectionMarker = null;
  2724. editor.$blockScrolling += 1;
  2725. editor.selection.fromOrientedRange(range);
  2726. editor.$blockScrolling -= 1;
  2727. if (editor.isFocused() && !isInternal)
  2728. editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
  2729. range = null;
  2730. dragCursor = null;
  2731. counter = 0;
  2732. autoScrollStartTime = null;
  2733. cursorMovedTime = null;
  2734. event.removeListener(document, "mousemove", onMouseMove);
  2735. }
  2736. var onMouseMoveTimer = null;
  2737. function onMouseMove() {
  2738. if (onMouseMoveTimer == null) {
  2739. onMouseMoveTimer = setTimeout(function() {
  2740. if (onMouseMoveTimer != null && dragSelectionMarker)
  2741. clearDragMarker();
  2742. }, 20);
  2743. }
  2744. }
  2745. function canAccept(dataTransfer) {
  2746. var types = dataTransfer.types;
  2747. return !types || Array.prototype.some.call(types, function(type) {
  2748. return type == 'text/plain' || type == 'Text';
  2749. });
  2750. }
  2751. function getDropEffect(e) {
  2752. var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
  2753. var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
  2754. var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
  2755. var effectAllowed = "uninitialized";
  2756. try {
  2757. effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
  2758. } catch (e) {}
  2759. var dropEffect = "none";
  2760. if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
  2761. dropEffect = "copy";
  2762. else if (moveAllowed.indexOf(effectAllowed) >= 0)
  2763. dropEffect = "move";
  2764. else if (copyAllowed.indexOf(effectAllowed) >= 0)
  2765. dropEffect = "copy";
  2766. return dropEffect;
  2767. }
  2768. }
  2769. (function() {
  2770. this.dragWait = function() {
  2771. var interval = Date.now() - this.mousedownEvent.time;
  2772. if (interval > this.editor.getDragDelay())
  2773. this.startDrag();
  2774. };
  2775. this.dragWaitEnd = function() {
  2776. var target = this.editor.container;
  2777. target.draggable = false;
  2778. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2779. this.selectEnd();
  2780. };
  2781. this.dragReadyEnd = function(e) {
  2782. this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
  2783. this.editor.unsetStyle("ace_dragging");
  2784. this.editor.renderer.setCursorStyle("");
  2785. this.dragWaitEnd();
  2786. };
  2787. this.startDrag = function(){
  2788. this.cancelDrag = false;
  2789. var editor = this.editor;
  2790. var target = editor.container;
  2791. target.draggable = true;
  2792. editor.renderer.$cursorLayer.setBlinking(false);
  2793. editor.setStyle("ace_dragging");
  2794. var cursorStyle = useragent.isWin ? "default" : "move";
  2795. editor.renderer.setCursorStyle(cursorStyle);
  2796. this.setState("dragReady");
  2797. };
  2798. this.onMouseDrag = function(e) {
  2799. var target = this.editor.container;
  2800. if (useragent.isIE && this.state == "dragReady") {
  2801. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2802. if (distance > 3)
  2803. target.dragDrop();
  2804. }
  2805. if (this.state === "dragWait") {
  2806. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2807. if (distance > 0) {
  2808. target.draggable = false;
  2809. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2810. }
  2811. }
  2812. };
  2813. this.onMouseDown = function(e) {
  2814. if (!this.$dragEnabled)
  2815. return;
  2816. this.mousedownEvent = e;
  2817. var editor = this.editor;
  2818. var inSelection = e.inSelection();
  2819. var button = e.getButton();
  2820. var clickCount = e.domEvent.detail || 1;
  2821. if (clickCount === 1 && button === 0 && inSelection) {
  2822. if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
  2823. return;
  2824. this.mousedownEvent.time = Date.now();
  2825. var eventTarget = e.domEvent.target || e.domEvent.srcElement;
  2826. if ("unselectable" in eventTarget)
  2827. eventTarget.unselectable = "on";
  2828. if (editor.getDragDelay()) {
  2829. if (useragent.isWebKit) {
  2830. this.cancelDrag = true;
  2831. var mouseTarget = editor.container;
  2832. mouseTarget.draggable = true;
  2833. }
  2834. this.setState("dragWait");
  2835. } else {
  2836. this.startDrag();
  2837. }
  2838. this.captureMouse(e, this.onMouseDrag.bind(this));
  2839. e.defaultPrevented = true;
  2840. }
  2841. };
  2842. }).call(DragdropHandler.prototype);
  2843. function calcDistance(ax, ay, bx, by) {
  2844. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2845. }
  2846. exports.DragdropHandler = DragdropHandler;
  2847. });
  2848. ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  2849. "use strict";
  2850. var dom = require("./dom");
  2851. exports.get = function (url, callback) {
  2852. var xhr = new XMLHttpRequest();
  2853. xhr.open('GET', url, true);
  2854. xhr.onreadystatechange = function () {
  2855. if (xhr.readyState === 4) {
  2856. callback(xhr.responseText);
  2857. }
  2858. };
  2859. xhr.send(null);
  2860. };
  2861. exports.loadScript = function(path, callback) {
  2862. var head = dom.getDocumentHead();
  2863. var s = document.createElement('script');
  2864. s.src = path;
  2865. head.appendChild(s);
  2866. s.onload = s.onreadystatechange = function(_, isAbort) {
  2867. if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
  2868. s = s.onload = s.onreadystatechange = null;
  2869. if (!isAbort)
  2870. callback();
  2871. }
  2872. };
  2873. };
  2874. exports.qualifyURL = function(url) {
  2875. var a = document.createElement('a');
  2876. a.href = url;
  2877. return a.href;
  2878. }
  2879. });
  2880. ace.define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  2881. "use strict";
  2882. var EventEmitter = {};
  2883. var stopPropagation = function() { this.propagationStopped = true; };
  2884. var preventDefault = function() { this.defaultPrevented = true; };
  2885. EventEmitter._emit =
  2886. EventEmitter._dispatchEvent = function(eventName, e) {
  2887. this._eventRegistry || (this._eventRegistry = {});
  2888. this._defaultHandlers || (this._defaultHandlers = {});
  2889. var listeners = this._eventRegistry[eventName] || [];
  2890. var defaultHandler = this._defaultHandlers[eventName];
  2891. if (!listeners.length && !defaultHandler)
  2892. return;
  2893. if (typeof e != "object" || !e)
  2894. e = {};
  2895. if (!e.type)
  2896. e.type = eventName;
  2897. if (!e.stopPropagation)
  2898. e.stopPropagation = stopPropagation;
  2899. if (!e.preventDefault)
  2900. e.preventDefault = preventDefault;
  2901. listeners = listeners.slice();
  2902. for (var i=0; i<listeners.length; i++) {
  2903. listeners[i](e, this);
  2904. if (e.propagationStopped)
  2905. break;
  2906. }
  2907. if (defaultHandler && !e.defaultPrevented)
  2908. return defaultHandler(e, this);
  2909. };
  2910. EventEmitter._signal = function(eventName, e) {
  2911. var listeners = (this._eventRegistry || {})[eventName];
  2912. if (!listeners)
  2913. return;
  2914. listeners = listeners.slice();
  2915. for (var i=0; i<listeners.length; i++)
  2916. listeners[i](e, this);
  2917. };
  2918. EventEmitter.once = function(eventName, callback) {
  2919. var _self = this;
  2920. callback && this.addEventListener(eventName, function newCallback() {
  2921. _self.removeEventListener(eventName, newCallback);
  2922. callback.apply(null, arguments);
  2923. });
  2924. };
  2925. EventEmitter.setDefaultHandler = function(eventName, callback) {
  2926. var handlers = this._defaultHandlers
  2927. if (!handlers)
  2928. handlers = this._defaultHandlers = {_disabled_: {}};
  2929. if (handlers[eventName]) {
  2930. var old = handlers[eventName];
  2931. var disabled = handlers._disabled_[eventName];
  2932. if (!disabled)
  2933. handlers._disabled_[eventName] = disabled = [];
  2934. disabled.push(old);
  2935. var i = disabled.indexOf(callback);
  2936. if (i != -1)
  2937. disabled.splice(i, 1);
  2938. }
  2939. handlers[eventName] = callback;
  2940. };
  2941. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  2942. var handlers = this._defaultHandlers
  2943. if (!handlers)
  2944. return;
  2945. var disabled = handlers._disabled_[eventName];
  2946. if (handlers[eventName] == callback) {
  2947. var old = handlers[eventName];
  2948. if (disabled)
  2949. this.setDefaultHandler(eventName, disabled.pop());
  2950. } else if (disabled) {
  2951. var i = disabled.indexOf(callback);
  2952. if (i != -1)
  2953. disabled.splice(i, 1);
  2954. }
  2955. };
  2956. EventEmitter.on =
  2957. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  2958. this._eventRegistry = this._eventRegistry || {};
  2959. var listeners = this._eventRegistry[eventName];
  2960. if (!listeners)
  2961. listeners = this._eventRegistry[eventName] = [];
  2962. if (listeners.indexOf(callback) == -1)
  2963. listeners[capturing ? "unshift" : "push"](callback);
  2964. return callback;
  2965. };
  2966. EventEmitter.off =
  2967. EventEmitter.removeListener =
  2968. EventEmitter.removeEventListener = function(eventName, callback) {
  2969. this._eventRegistry = this._eventRegistry || {};
  2970. var listeners = this._eventRegistry[eventName];
  2971. if (!listeners)
  2972. return;
  2973. var index = listeners.indexOf(callback);
  2974. if (index !== -1)
  2975. listeners.splice(index, 1);
  2976. };
  2977. EventEmitter.removeAllListeners = function(eventName) {
  2978. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  2979. };
  2980. exports.EventEmitter = EventEmitter;
  2981. });
  2982. ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  2983. "no use strict";
  2984. var oop = require("./oop");
  2985. var EventEmitter = require("./event_emitter").EventEmitter;
  2986. var optionsProvider = {
  2987. setOptions: function(optList) {
  2988. Object.keys(optList).forEach(function(key) {
  2989. this.setOption(key, optList[key]);
  2990. }, this);
  2991. },
  2992. getOptions: function(optionNames) {
  2993. var result = {};
  2994. if (!optionNames) {
  2995. optionNames = Object.keys(this.$options);
  2996. } else if (!Array.isArray(optionNames)) {
  2997. result = optionNames;
  2998. optionNames = Object.keys(result);
  2999. }
  3000. optionNames.forEach(function(key) {
  3001. result[key] = this.getOption(key);
  3002. }, this);
  3003. return result;
  3004. },
  3005. setOption: function(name, value) {
  3006. if (this["$" + name] === value)
  3007. return;
  3008. var opt = this.$options[name];
  3009. if (!opt) {
  3010. return warn('misspelled option "' + name + '"');
  3011. }
  3012. if (opt.forwardTo)
  3013. return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
  3014. if (!opt.handlesSet)
  3015. this["$" + name] = value;
  3016. if (opt && opt.set)
  3017. opt.set.call(this, value);
  3018. },
  3019. getOption: function(name) {
  3020. var opt = this.$options[name];
  3021. if (!opt) {
  3022. return warn('misspelled option "' + name + '"');
  3023. }
  3024. if (opt.forwardTo)
  3025. return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
  3026. return opt && opt.get ? opt.get.call(this) : this["$" + name];
  3027. }
  3028. };
  3029. function warn(message) {
  3030. if (typeof console != "undefined" && console.warn)
  3031. console.warn.apply(console, arguments);
  3032. }
  3033. function reportError(msg, data) {
  3034. var e = new Error(msg);
  3035. e.data = data;
  3036. if (typeof console == "object" && console.error)
  3037. console.error(e);
  3038. setTimeout(function() { throw e; });
  3039. }
  3040. var AppConfig = function() {
  3041. this.$defaultOptions = {};
  3042. };
  3043. (function() {
  3044. oop.implement(this, EventEmitter);
  3045. this.defineOptions = function(obj, path, options) {
  3046. if (!obj.$options)
  3047. this.$defaultOptions[path] = obj.$options = {};
  3048. Object.keys(options).forEach(function(key) {
  3049. var opt = options[key];
  3050. if (typeof opt == "string")
  3051. opt = {forwardTo: opt};
  3052. opt.name || (opt.name = key);
  3053. obj.$options[opt.name] = opt;
  3054. if ("initialValue" in opt)
  3055. obj["$" + opt.name] = opt.initialValue;
  3056. });
  3057. oop.implement(obj, optionsProvider);
  3058. return this;
  3059. };
  3060. this.resetOptions = function(obj) {
  3061. Object.keys(obj.$options).forEach(function(key) {
  3062. var opt = obj.$options[key];
  3063. if ("value" in opt)
  3064. obj.setOption(key, opt.value);
  3065. });
  3066. };
  3067. this.setDefaultValue = function(path, name, value) {
  3068. var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
  3069. if (opts[name]) {
  3070. if (opts.forwardTo)
  3071. this.setDefaultValue(opts.forwardTo, name, value);
  3072. else
  3073. opts[name].value = value;
  3074. }
  3075. };
  3076. this.setDefaultValues = function(path, optionHash) {
  3077. Object.keys(optionHash).forEach(function(key) {
  3078. this.setDefaultValue(path, key, optionHash[key]);
  3079. }, this);
  3080. };
  3081. this.warn = warn;
  3082. this.reportError = reportError;
  3083. }).call(AppConfig.prototype);
  3084. exports.AppConfig = AppConfig;
  3085. });
  3086. ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) {
  3087. "no use strict";
  3088. var lang = require("./lib/lang");
  3089. var oop = require("./lib/oop");
  3090. var net = require("./lib/net");
  3091. var AppConfig = require("./lib/app_config").AppConfig;
  3092. module.exports = exports = new AppConfig();
  3093. var global = (function() {
  3094. return this;
  3095. })();
  3096. var options = {
  3097. packaged: false,
  3098. workerPath: null,
  3099. modePath: null,
  3100. themePath: null,
  3101. basePath: "",
  3102. suffix: ".js",
  3103. $moduleUrls: {}
  3104. };
  3105. exports.get = function(key) {
  3106. if (!options.hasOwnProperty(key))
  3107. throw new Error("Unknown config key: " + key);
  3108. return options[key];
  3109. };
  3110. exports.set = function(key, value) {
  3111. if (!options.hasOwnProperty(key))
  3112. throw new Error("Unknown config key: " + key);
  3113. options[key] = value;
  3114. };
  3115. exports.all = function() {
  3116. return lang.copyObject(options);
  3117. };
  3118. exports.moduleUrl = function(name, component) {
  3119. if (options.$moduleUrls[name])
  3120. return options.$moduleUrls[name];
  3121. var parts = name.split("/");
  3122. component = component || parts[parts.length - 2] || "";
  3123. var sep = component == "snippets" ? "/" : "-";
  3124. var base = parts[parts.length - 1];
  3125. if (component == "worker" && sep == "-") {
  3126. var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
  3127. base = base.replace(re, "");
  3128. }
  3129. if ((!base || base == component) && parts.length > 1)
  3130. base = parts[parts.length - 2];
  3131. var path = options[component + "Path"];
  3132. if (path == null) {
  3133. path = options.basePath;
  3134. } else if (sep == "/") {
  3135. component = sep = "";
  3136. }
  3137. if (path && path.slice(-1) != "/")
  3138. path += "/";
  3139. return path + component + sep + base + this.get("suffix");
  3140. };
  3141. exports.setModuleUrl = function(name, subst) {
  3142. return options.$moduleUrls[name] = subst;
  3143. };
  3144. exports.$loading = {};
  3145. exports.loadModule = function(moduleName, onLoad) {
  3146. var module, moduleType;
  3147. if (Array.isArray(moduleName)) {
  3148. moduleType = moduleName[0];
  3149. moduleName = moduleName[1];
  3150. }
  3151. try {
  3152. module = require(moduleName);
  3153. } catch (e) {}
  3154. if (module && !exports.$loading[moduleName])
  3155. return onLoad && onLoad(module);
  3156. if (!exports.$loading[moduleName])
  3157. exports.$loading[moduleName] = [];
  3158. exports.$loading[moduleName].push(onLoad);
  3159. if (exports.$loading[moduleName].length > 1)
  3160. return;
  3161. var afterLoad = function() {
  3162. require([moduleName], function(module) {
  3163. exports._emit("load.module", {name: moduleName, module: module});
  3164. var listeners = exports.$loading[moduleName];
  3165. exports.$loading[moduleName] = null;
  3166. listeners.forEach(function(onLoad) {
  3167. onLoad && onLoad(module);
  3168. });
  3169. });
  3170. };
  3171. if (!exports.get("packaged"))
  3172. return afterLoad();
  3173. net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
  3174. };
  3175. init(true);function init(packaged) {
  3176. options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
  3177. if (!global.document)
  3178. return "";
  3179. var scriptOptions = {};
  3180. var scriptUrl = "";
  3181. var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
  3182. var currentDocument = currentScript && currentScript.ownerDocument || document;
  3183. var scripts = currentDocument.getElementsByTagName("script");
  3184. for (var i=0; i<scripts.length; i++) {
  3185. var script = scripts[i];
  3186. var src = script.src || script.getAttribute("src");
  3187. if (!src)
  3188. continue;
  3189. var attributes = script.attributes;
  3190. for (var j=0, l=attributes.length; j < l; j++) {
  3191. var attr = attributes[j];
  3192. if (attr.name.indexOf("data-ace-") === 0) {
  3193. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  3194. }
  3195. }
  3196. var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
  3197. if (m)
  3198. scriptUrl = m[1];
  3199. }
  3200. if (scriptUrl) {
  3201. scriptOptions.base = scriptOptions.base || scriptUrl;
  3202. scriptOptions.packaged = true;
  3203. }
  3204. scriptOptions.basePath = scriptOptions.base;
  3205. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  3206. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  3207. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  3208. delete scriptOptions.base;
  3209. for (var key in scriptOptions)
  3210. if (typeof scriptOptions[key] !== "undefined")
  3211. exports.set(key, scriptOptions[key]);
  3212. };
  3213. exports.init = init;
  3214. function deHyphenate(str) {
  3215. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  3216. }
  3217. });
  3218. 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) {
  3219. "use strict";
  3220. var event = require("../lib/event");
  3221. var useragent = require("../lib/useragent");
  3222. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3223. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3224. var MouseEvent = require("./mouse_event").MouseEvent;
  3225. var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
  3226. var config = require("../config");
  3227. var MouseHandler = function(editor) {
  3228. var _self = this;
  3229. this.editor = editor;
  3230. new DefaultHandlers(this);
  3231. new DefaultGutterHandler(this);
  3232. new DragdropHandler(this);
  3233. var focusEditor = function(e) {
  3234. if (!document.hasFocus || !document.hasFocus())
  3235. window.focus();
  3236. editor.focus();
  3237. };
  3238. var mouseTarget = editor.renderer.getMouseEventTarget();
  3239. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3240. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3241. event.addMultiMouseDownListener(mouseTarget, [400, 300, 250], this, "onMouseEvent");
  3242. if (editor.renderer.scrollBarV) {
  3243. event.addMultiMouseDownListener(editor.renderer.scrollBarV.inner, [400, 300, 250], this, "onMouseEvent");
  3244. event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [400, 300, 250], this, "onMouseEvent");
  3245. if (useragent.isIE) {
  3246. event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
  3247. event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
  3248. }
  3249. }
  3250. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3251. var gutterEl = editor.renderer.$gutter;
  3252. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3253. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3254. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3255. event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
  3256. event.addListener(mouseTarget, "mousedown", focusEditor);
  3257. event.addListener(gutterEl, "mousedown", function(e) {
  3258. editor.focus();
  3259. return event.preventDefault(e);
  3260. });
  3261. editor.on("mousemove", function(e){
  3262. if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
  3263. return;
  3264. var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
  3265. var range = editor.session.selection.getRange();
  3266. var renderer = editor.renderer;
  3267. if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
  3268. renderer.setCursorStyle("default");
  3269. } else {
  3270. renderer.setCursorStyle("");
  3271. }
  3272. });
  3273. };
  3274. (function() {
  3275. this.onMouseEvent = function(name, e) {
  3276. this.editor._emit(name, new MouseEvent(e, this.editor));
  3277. };
  3278. this.onMouseMove = function(name, e) {
  3279. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3280. if (!listeners || !listeners.length)
  3281. return;
  3282. this.editor._emit(name, new MouseEvent(e, this.editor));
  3283. };
  3284. this.onMouseWheel = function(name, e) {
  3285. var mouseEvent = new MouseEvent(e, this.editor);
  3286. mouseEvent.speed = this.$scrollSpeed * 2;
  3287. mouseEvent.wheelX = e.wheelX;
  3288. mouseEvent.wheelY = e.wheelY;
  3289. this.editor._emit(name, mouseEvent);
  3290. };
  3291. this.setState = function(state) {
  3292. this.state = state;
  3293. };
  3294. this.captureMouse = function(ev, mouseMoveHandler) {
  3295. this.x = ev.x;
  3296. this.y = ev.y;
  3297. this.isMousePressed = true;
  3298. var renderer = this.editor.renderer;
  3299. if (renderer.$keepTextAreaAtCursor)
  3300. renderer.$keepTextAreaAtCursor = null;
  3301. var self = this;
  3302. var onMouseMove = function(e) {
  3303. if (!e) return;
  3304. if (useragent.isWebKit && !e.which && self.releaseMouse)
  3305. return self.releaseMouse();
  3306. self.x = e.clientX;
  3307. self.y = e.clientY;
  3308. mouseMoveHandler && mouseMoveHandler(e);
  3309. self.mouseEvent = new MouseEvent(e, self.editor);
  3310. self.$mouseMoved = true;
  3311. };
  3312. var onCaptureEnd = function(e) {
  3313. clearInterval(timerId);
  3314. onCaptureInterval();
  3315. self[self.state + "End"] && self[self.state + "End"](e);
  3316. self.state = "";
  3317. if (renderer.$keepTextAreaAtCursor == null) {
  3318. renderer.$keepTextAreaAtCursor = true;
  3319. renderer.$moveTextAreaToCursor();
  3320. }
  3321. self.isMousePressed = false;
  3322. self.$onCaptureMouseMove = self.releaseMouse = null;
  3323. e && self.onMouseEvent("mouseup", e);
  3324. };
  3325. var onCaptureInterval = function() {
  3326. self[self.state] && self[self.state]();
  3327. self.$mouseMoved = false;
  3328. };
  3329. if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
  3330. return setTimeout(function() {onCaptureEnd(ev);});
  3331. }
  3332. self.$onCaptureMouseMove = onMouseMove;
  3333. self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3334. var timerId = setInterval(onCaptureInterval, 20);
  3335. };
  3336. this.releaseMouse = null;
  3337. this.cancelContextMenu = function() {
  3338. var stop = function(e) {
  3339. if (e && e.domEvent && e.domEvent.type != "contextmenu")
  3340. return;
  3341. this.editor.off("nativecontextmenu", stop);
  3342. if (e && e.domEvent)
  3343. event.stopEvent(e.domEvent);
  3344. }.bind(this);
  3345. setTimeout(stop, 10);
  3346. this.editor.on("nativecontextmenu", stop);
  3347. };
  3348. }).call(MouseHandler.prototype);
  3349. config.defineOptions(MouseHandler.prototype, "mouseHandler", {
  3350. scrollSpeed: {initialValue: 2},
  3351. dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
  3352. dragEnabled: {initialValue: true},
  3353. focusTimout: {initialValue: 0},
  3354. tooltipFollowsMouse: {initialValue: true}
  3355. });
  3356. exports.MouseHandler = MouseHandler;
  3357. });
  3358. ace.define("ace/mouse/fold_handler",["require","exports","module"], function(require, exports, module) {
  3359. "use strict";
  3360. function FoldHandler(editor) {
  3361. editor.on("click", function(e) {
  3362. var position = e.getDocumentPosition();
  3363. var session = editor.session;
  3364. var fold = session.getFoldAt(position.row, position.column, 1);
  3365. if (fold) {
  3366. if (e.getAccelKey())
  3367. session.removeFold(fold);
  3368. else
  3369. session.expandFold(fold);
  3370. e.stop();
  3371. }
  3372. });
  3373. editor.on("gutterclick", function(e) {
  3374. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3375. if (gutterRegion == "foldWidgets") {
  3376. var row = e.getDocumentPosition().row;
  3377. var session = editor.session;
  3378. if (session.foldWidgets && session.foldWidgets[row])
  3379. editor.session.onFoldWidgetClick(row, e);
  3380. if (!editor.isFocused())
  3381. editor.focus();
  3382. e.stop();
  3383. }
  3384. });
  3385. editor.on("gutterdblclick", function(e) {
  3386. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3387. if (gutterRegion == "foldWidgets") {
  3388. var row = e.getDocumentPosition().row;
  3389. var session = editor.session;
  3390. var data = session.getParentFoldRangeData(row, true);
  3391. var range = data.range || data.firstRange;
  3392. if (range) {
  3393. row = range.start.row;
  3394. var fold = session.getFoldAt(row, session.getLine(row).length, 1);
  3395. if (fold) {
  3396. session.removeFold(fold);
  3397. } else {
  3398. session.addFold("...", range);
  3399. editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
  3400. }
  3401. }
  3402. e.stop();
  3403. }
  3404. });
  3405. }
  3406. exports.FoldHandler = FoldHandler;
  3407. });
  3408. ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module) {
  3409. "use strict";
  3410. var keyUtil = require("../lib/keys");
  3411. var event = require("../lib/event");
  3412. var KeyBinding = function(editor) {
  3413. this.$editor = editor;
  3414. this.$data = {editor: editor};
  3415. this.$handlers = [];
  3416. this.setDefaultHandler(editor.commands);
  3417. };
  3418. (function() {
  3419. this.setDefaultHandler = function(kb) {
  3420. this.removeKeyboardHandler(this.$defaultHandler);
  3421. this.$defaultHandler = kb;
  3422. this.addKeyboardHandler(kb, 0);
  3423. };
  3424. this.setKeyboardHandler = function(kb) {
  3425. var h = this.$handlers;
  3426. if (h[h.length - 1] == kb)
  3427. return;
  3428. while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
  3429. this.removeKeyboardHandler(h[h.length - 1]);
  3430. this.addKeyboardHandler(kb, 1);
  3431. };
  3432. this.addKeyboardHandler = function(kb, pos) {
  3433. if (!kb)
  3434. return;
  3435. if (typeof kb == "function" && !kb.handleKeyboard)
  3436. kb.handleKeyboard = kb;
  3437. var i = this.$handlers.indexOf(kb);
  3438. if (i != -1)
  3439. this.$handlers.splice(i, 1);
  3440. if (pos == undefined)
  3441. this.$handlers.push(kb);
  3442. else
  3443. this.$handlers.splice(pos, 0, kb);
  3444. if (i == -1 && kb.attach)
  3445. kb.attach(this.$editor);
  3446. };
  3447. this.removeKeyboardHandler = function(kb) {
  3448. var i = this.$handlers.indexOf(kb);
  3449. if (i == -1)
  3450. return false;
  3451. this.$handlers.splice(i, 1);
  3452. kb.detach && kb.detach(this.$editor);
  3453. return true;
  3454. };
  3455. this.getKeyboardHandler = function() {
  3456. return this.$handlers[this.$handlers.length - 1];
  3457. };
  3458. this.getStatusText = function() {
  3459. var data = this.$data;
  3460. var editor = data.editor;
  3461. return this.$handlers.map(function(h) {
  3462. return h.getStatusText && h.getStatusText(editor, data) || "";
  3463. }).filter(Boolean).join(" ");
  3464. };
  3465. this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
  3466. var toExecute;
  3467. var success = false;
  3468. var commands = this.$editor.commands;
  3469. for (var i = this.$handlers.length; i--;) {
  3470. toExecute = this.$handlers[i].handleKeyboard(
  3471. this.$data, hashId, keyString, keyCode, e
  3472. );
  3473. if (!toExecute || !toExecute.command)
  3474. continue;
  3475. if (toExecute.command == "null") {
  3476. success = true;
  3477. } else {
  3478. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3479. }
  3480. if (success && e && hashId != -1 &&
  3481. toExecute.passEvent != true && toExecute.command.passEvent != true
  3482. ) {
  3483. event.stopEvent(e);
  3484. }
  3485. if (success)
  3486. break;
  3487. }
  3488. return success;
  3489. };
  3490. this.onCommandKey = function(e, hashId, keyCode) {
  3491. var keyString = keyUtil.keyCodeToString(keyCode);
  3492. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3493. };
  3494. this.onTextInput = function(text) {
  3495. var success = this.$callKeyboardHandlers(-1, text);
  3496. if (!success)
  3497. this.$editor.commands.exec("insertstring", this.$editor, text);
  3498. };
  3499. }).call(KeyBinding.prototype);
  3500. exports.KeyBinding = KeyBinding;
  3501. });
  3502. ace.define("ace/range",["require","exports","module"], function(require, exports, module) {
  3503. "use strict";
  3504. var comparePoints = function(p1, p2) {
  3505. return p1.row - p2.row || p1.column - p2.column;
  3506. };
  3507. var Range = function(startRow, startColumn, endRow, endColumn) {
  3508. this.start = {
  3509. row: startRow,
  3510. column: startColumn
  3511. };
  3512. this.end = {
  3513. row: endRow,
  3514. column: endColumn
  3515. };
  3516. };
  3517. (function() {
  3518. this.isEqual = function(range) {
  3519. return this.start.row === range.start.row &&
  3520. this.end.row === range.end.row &&
  3521. this.start.column === range.start.column &&
  3522. this.end.column === range.end.column;
  3523. };
  3524. this.toString = function() {
  3525. return ("Range: [" + this.start.row + "/" + this.start.column +
  3526. "] -> [" + this.end.row + "/" + this.end.column + "]");
  3527. };
  3528. this.contains = function(row, column) {
  3529. return this.compare(row, column) == 0;
  3530. };
  3531. this.compareRange = function(range) {
  3532. var cmp,
  3533. end = range.end,
  3534. start = range.start;
  3535. cmp = this.compare(end.row, end.column);
  3536. if (cmp == 1) {
  3537. cmp = this.compare(start.row, start.column);
  3538. if (cmp == 1) {
  3539. return 2;
  3540. } else if (cmp == 0) {
  3541. return 1;
  3542. } else {
  3543. return 0;
  3544. }
  3545. } else if (cmp == -1) {
  3546. return -2;
  3547. } else {
  3548. cmp = this.compare(start.row, start.column);
  3549. if (cmp == -1) {
  3550. return -1;
  3551. } else if (cmp == 1) {
  3552. return 42;
  3553. } else {
  3554. return 0;
  3555. }
  3556. }
  3557. };
  3558. this.comparePoint = function(p) {
  3559. return this.compare(p.row, p.column);
  3560. };
  3561. this.containsRange = function(range) {
  3562. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  3563. };
  3564. this.intersects = function(range) {
  3565. var cmp = this.compareRange(range);
  3566. return (cmp == -1 || cmp == 0 || cmp == 1);
  3567. };
  3568. this.isEnd = function(row, column) {
  3569. return this.end.row == row && this.end.column == column;
  3570. };
  3571. this.isStart = function(row, column) {
  3572. return this.start.row == row && this.start.column == column;
  3573. };
  3574. this.setStart = function(row, column) {
  3575. if (typeof row == "object") {
  3576. this.start.column = row.column;
  3577. this.start.row = row.row;
  3578. } else {
  3579. this.start.row = row;
  3580. this.start.column = column;
  3581. }
  3582. };
  3583. this.setEnd = function(row, column) {
  3584. if (typeof row == "object") {
  3585. this.end.column = row.column;
  3586. this.end.row = row.row;
  3587. } else {
  3588. this.end.row = row;
  3589. this.end.column = column;
  3590. }
  3591. };
  3592. this.inside = function(row, column) {
  3593. if (this.compare(row, column) == 0) {
  3594. if (this.isEnd(row, column) || this.isStart(row, column)) {
  3595. return false;
  3596. } else {
  3597. return true;
  3598. }
  3599. }
  3600. return false;
  3601. };
  3602. this.insideStart = function(row, column) {
  3603. if (this.compare(row, column) == 0) {
  3604. if (this.isEnd(row, column)) {
  3605. return false;
  3606. } else {
  3607. return true;
  3608. }
  3609. }
  3610. return false;
  3611. };
  3612. this.insideEnd = function(row, column) {
  3613. if (this.compare(row, column) == 0) {
  3614. if (this.isStart(row, column)) {
  3615. return false;
  3616. } else {
  3617. return true;
  3618. }
  3619. }
  3620. return false;
  3621. };
  3622. this.compare = function(row, column) {
  3623. if (!this.isMultiLine()) {
  3624. if (row === this.start.row) {
  3625. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  3626. };
  3627. }
  3628. if (row < this.start.row)
  3629. return -1;
  3630. if (row > this.end.row)
  3631. return 1;
  3632. if (this.start.row === row)
  3633. return column >= this.start.column ? 0 : -1;
  3634. if (this.end.row === row)
  3635. return column <= this.end.column ? 0 : 1;
  3636. return 0;
  3637. };
  3638. this.compareStart = function(row, column) {
  3639. if (this.start.row == row && this.start.column == column) {
  3640. return -1;
  3641. } else {
  3642. return this.compare(row, column);
  3643. }
  3644. };
  3645. this.compareEnd = function(row, column) {
  3646. if (this.end.row == row && this.end.column == column) {
  3647. return 1;
  3648. } else {
  3649. return this.compare(row, column);
  3650. }
  3651. };
  3652. this.compareInside = function(row, column) {
  3653. if (this.end.row == row && this.end.column == column) {
  3654. return 1;
  3655. } else if (this.start.row == row && this.start.column == column) {
  3656. return -1;
  3657. } else {
  3658. return this.compare(row, column);
  3659. }
  3660. };
  3661. this.clipRows = function(firstRow, lastRow) {
  3662. if (this.end.row > lastRow)
  3663. var end = {row: lastRow + 1, column: 0};
  3664. else if (this.end.row < firstRow)
  3665. var end = {row: firstRow, column: 0};
  3666. if (this.start.row > lastRow)
  3667. var start = {row: lastRow + 1, column: 0};
  3668. else if (this.start.row < firstRow)
  3669. var start = {row: firstRow, column: 0};
  3670. return Range.fromPoints(start || this.start, end || this.end);
  3671. };
  3672. this.extend = function(row, column) {
  3673. var cmp = this.compare(row, column);
  3674. if (cmp == 0)
  3675. return this;
  3676. else if (cmp == -1)
  3677. var start = {row: row, column: column};
  3678. else
  3679. var end = {row: row, column: column};
  3680. return Range.fromPoints(start || this.start, end || this.end);
  3681. };
  3682. this.isEmpty = function() {
  3683. return (this.start.row === this.end.row && this.start.column === this.end.column);
  3684. };
  3685. this.isMultiLine = function() {
  3686. return (this.start.row !== this.end.row);
  3687. };
  3688. this.clone = function() {
  3689. return Range.fromPoints(this.start, this.end);
  3690. };
  3691. this.collapseRows = function() {
  3692. if (this.end.column == 0)
  3693. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  3694. else
  3695. return new Range(this.start.row, 0, this.end.row, 0)
  3696. };
  3697. this.toScreenRange = function(session) {
  3698. var screenPosStart = session.documentToScreenPosition(this.start);
  3699. var screenPosEnd = session.documentToScreenPosition(this.end);
  3700. return new Range(
  3701. screenPosStart.row, screenPosStart.column,
  3702. screenPosEnd.row, screenPosEnd.column
  3703. );
  3704. };
  3705. this.moveBy = function(row, column) {
  3706. this.start.row += row;
  3707. this.start.column += column;
  3708. this.end.row += row;
  3709. this.end.column += column;
  3710. };
  3711. }).call(Range.prototype);
  3712. Range.fromPoints = function(start, end) {
  3713. return new Range(start.row, start.column, end.row, end.column);
  3714. };
  3715. Range.comparePoints = comparePoints;
  3716. Range.comparePoints = function(p1, p2) {
  3717. return p1.row - p2.row || p1.column - p2.column;
  3718. };
  3719. exports.Range = Range;
  3720. });
  3721. ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
  3722. "use strict";
  3723. var oop = require("./lib/oop");
  3724. var lang = require("./lib/lang");
  3725. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  3726. var Range = require("./range").Range;
  3727. var Selection = function(session) {
  3728. this.session = session;
  3729. this.doc = session.getDocument();
  3730. this.clearSelection();
  3731. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  3732. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  3733. var self = this;
  3734. this.lead.on("change", function(e) {
  3735. self._emit("changeCursor");
  3736. if (!self.$isEmpty)
  3737. self._emit("changeSelection");
  3738. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  3739. self.$desiredColumn = null;
  3740. });
  3741. this.selectionAnchor.on("change", function() {
  3742. if (!self.$isEmpty)
  3743. self._emit("changeSelection");
  3744. });
  3745. };
  3746. (function() {
  3747. oop.implement(this, EventEmitter);
  3748. this.isEmpty = function() {
  3749. return (this.$isEmpty || (
  3750. this.anchor.row == this.lead.row &&
  3751. this.anchor.column == this.lead.column
  3752. ));
  3753. };
  3754. this.isMultiLine = function() {
  3755. if (this.isEmpty()) {
  3756. return false;
  3757. }
  3758. return this.getRange().isMultiLine();
  3759. };
  3760. this.getCursor = function() {
  3761. return this.lead.getPosition();
  3762. };
  3763. this.setSelectionAnchor = function(row, column) {
  3764. this.anchor.setPosition(row, column);
  3765. if (this.$isEmpty) {
  3766. this.$isEmpty = false;
  3767. this._emit("changeSelection");
  3768. }
  3769. };
  3770. this.getSelectionAnchor = function() {
  3771. if (this.$isEmpty)
  3772. return this.getSelectionLead();
  3773. else
  3774. return this.anchor.getPosition();
  3775. };
  3776. this.getSelectionLead = function() {
  3777. return this.lead.getPosition();
  3778. };
  3779. this.shiftSelection = function(columns) {
  3780. if (this.$isEmpty) {
  3781. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  3782. return;
  3783. }
  3784. var anchor = this.getSelectionAnchor();
  3785. var lead = this.getSelectionLead();
  3786. var isBackwards = this.isBackwards();
  3787. if (!isBackwards || anchor.column !== 0)
  3788. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  3789. if (isBackwards || lead.column !== 0) {
  3790. this.$moveSelection(function() {
  3791. this.moveCursorTo(lead.row, lead.column + columns);
  3792. });
  3793. }
  3794. };
  3795. this.isBackwards = function() {
  3796. var anchor = this.anchor;
  3797. var lead = this.lead;
  3798. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  3799. };
  3800. this.getRange = function() {
  3801. var anchor = this.anchor;
  3802. var lead = this.lead;
  3803. if (this.isEmpty())
  3804. return Range.fromPoints(lead, lead);
  3805. if (this.isBackwards()) {
  3806. return Range.fromPoints(lead, anchor);
  3807. }
  3808. else {
  3809. return Range.fromPoints(anchor, lead);
  3810. }
  3811. };
  3812. this.clearSelection = function() {
  3813. if (!this.$isEmpty) {
  3814. this.$isEmpty = true;
  3815. this._emit("changeSelection");
  3816. }
  3817. };
  3818. this.selectAll = function() {
  3819. var lastRow = this.doc.getLength() - 1;
  3820. this.setSelectionAnchor(0, 0);
  3821. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  3822. };
  3823. this.setRange =
  3824. this.setSelectionRange = function(range, reverse) {
  3825. if (reverse) {
  3826. this.setSelectionAnchor(range.end.row, range.end.column);
  3827. this.selectTo(range.start.row, range.start.column);
  3828. } else {
  3829. this.setSelectionAnchor(range.start.row, range.start.column);
  3830. this.selectTo(range.end.row, range.end.column);
  3831. }
  3832. if (this.getRange().isEmpty())
  3833. this.$isEmpty = true;
  3834. this.$desiredColumn = null;
  3835. };
  3836. this.$moveSelection = function(mover) {
  3837. var lead = this.lead;
  3838. if (this.$isEmpty)
  3839. this.setSelectionAnchor(lead.row, lead.column);
  3840. mover.call(this);
  3841. };
  3842. this.selectTo = function(row, column) {
  3843. this.$moveSelection(function() {
  3844. this.moveCursorTo(row, column);
  3845. });
  3846. };
  3847. this.selectToPosition = function(pos) {
  3848. this.$moveSelection(function() {
  3849. this.moveCursorToPosition(pos);
  3850. });
  3851. };
  3852. this.moveTo = function(row, column) {
  3853. this.clearSelection();
  3854. this.moveCursorTo(row, column);
  3855. };
  3856. this.moveToPosition = function(pos) {
  3857. this.clearSelection();
  3858. this.moveCursorToPosition(pos);
  3859. };
  3860. this.selectUp = function() {
  3861. this.$moveSelection(this.moveCursorUp);
  3862. };
  3863. this.selectDown = function() {
  3864. this.$moveSelection(this.moveCursorDown);
  3865. };
  3866. this.selectRight = function() {
  3867. this.$moveSelection(this.moveCursorRight);
  3868. };
  3869. this.selectLeft = function() {
  3870. this.$moveSelection(this.moveCursorLeft);
  3871. };
  3872. this.selectLineStart = function() {
  3873. this.$moveSelection(this.moveCursorLineStart);
  3874. };
  3875. this.selectLineEnd = function() {
  3876. this.$moveSelection(this.moveCursorLineEnd);
  3877. };
  3878. this.selectFileEnd = function() {
  3879. this.$moveSelection(this.moveCursorFileEnd);
  3880. };
  3881. this.selectFileStart = function() {
  3882. this.$moveSelection(this.moveCursorFileStart);
  3883. };
  3884. this.selectWordRight = function() {
  3885. this.$moveSelection(this.moveCursorWordRight);
  3886. };
  3887. this.selectWordLeft = function() {
  3888. this.$moveSelection(this.moveCursorWordLeft);
  3889. };
  3890. this.getWordRange = function(row, column) {
  3891. if (typeof column == "undefined") {
  3892. var cursor = row || this.lead;
  3893. row = cursor.row;
  3894. column = cursor.column;
  3895. }
  3896. return this.session.getWordRange(row, column);
  3897. };
  3898. this.selectWord = function() {
  3899. this.setSelectionRange(this.getWordRange());
  3900. };
  3901. this.selectAWord = function() {
  3902. var cursor = this.getCursor();
  3903. var range = this.session.getAWordRange(cursor.row, cursor.column);
  3904. this.setSelectionRange(range);
  3905. };
  3906. this.getLineRange = function(row, excludeLastChar) {
  3907. var rowStart = typeof row == "number" ? row : this.lead.row;
  3908. var rowEnd;
  3909. var foldLine = this.session.getFoldLine(rowStart);
  3910. if (foldLine) {
  3911. rowStart = foldLine.start.row;
  3912. rowEnd = foldLine.end.row;
  3913. } else {
  3914. rowEnd = rowStart;
  3915. }
  3916. if (excludeLastChar === true)
  3917. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  3918. else
  3919. return new Range(rowStart, 0, rowEnd + 1, 0);
  3920. };
  3921. this.selectLine = function() {
  3922. this.setSelectionRange(this.getLineRange());
  3923. };
  3924. this.moveCursorUp = function() {
  3925. this.moveCursorBy(-1, 0);
  3926. };
  3927. this.moveCursorDown = function() {
  3928. this.moveCursorBy(1, 0);
  3929. };
  3930. this.moveCursorLeft = function() {
  3931. var cursor = this.lead.getPosition(),
  3932. fold;
  3933. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  3934. this.moveCursorTo(fold.start.row, fold.start.column);
  3935. } else if (cursor.column === 0) {
  3936. if (cursor.row > 0) {
  3937. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  3938. }
  3939. }
  3940. else {
  3941. var tabSize = this.session.getTabSize();
  3942. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
  3943. this.moveCursorBy(0, -tabSize);
  3944. else
  3945. this.moveCursorBy(0, -1);
  3946. }
  3947. };
  3948. this.moveCursorRight = function() {
  3949. var cursor = this.lead.getPosition(),
  3950. fold;
  3951. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  3952. this.moveCursorTo(fold.end.row, fold.end.column);
  3953. }
  3954. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  3955. if (this.lead.row < this.doc.getLength() - 1) {
  3956. this.moveCursorTo(this.lead.row + 1, 0);
  3957. }
  3958. }
  3959. else {
  3960. var tabSize = this.session.getTabSize();
  3961. var cursor = this.lead;
  3962. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
  3963. this.moveCursorBy(0, tabSize);
  3964. else
  3965. this.moveCursorBy(0, 1);
  3966. }
  3967. };
  3968. this.moveCursorLineStart = function() {
  3969. var row = this.lead.row;
  3970. var column = this.lead.column;
  3971. var screenRow = this.session.documentToScreenRow(row, column);
  3972. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  3973. var beforeCursor = this.session.getDisplayLine(
  3974. row, null, firstColumnPosition.row,
  3975. firstColumnPosition.column
  3976. );
  3977. var leadingSpace = beforeCursor.match(/^\s*/);
  3978. if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
  3979. firstColumnPosition.column += leadingSpace[0].length;
  3980. this.moveCursorToPosition(firstColumnPosition);
  3981. };
  3982. this.moveCursorLineEnd = function() {
  3983. var lead = this.lead;
  3984. var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  3985. if (this.lead.column == lineEnd.column) {
  3986. var line = this.session.getLine(lineEnd.row);
  3987. if (lineEnd.column == line.length) {
  3988. var textEnd = line.search(/\s+$/);
  3989. if (textEnd > 0)
  3990. lineEnd.column = textEnd;
  3991. }
  3992. }
  3993. this.moveCursorTo(lineEnd.row, lineEnd.column);
  3994. };
  3995. this.moveCursorFileEnd = function() {
  3996. var row = this.doc.getLength() - 1;
  3997. var column = this.doc.getLine(row).length;
  3998. this.moveCursorTo(row, column);
  3999. };
  4000. this.moveCursorFileStart = function() {
  4001. this.moveCursorTo(0, 0);
  4002. };
  4003. this.moveCursorLongWordRight = function() {
  4004. var row = this.lead.row;
  4005. var column = this.lead.column;
  4006. var line = this.doc.getLine(row);
  4007. var rightOfCursor = line.substring(column);
  4008. var match;
  4009. this.session.nonTokenRe.lastIndex = 0;
  4010. this.session.tokenRe.lastIndex = 0;
  4011. var fold = this.session.getFoldAt(row, column, 1);
  4012. if (fold) {
  4013. this.moveCursorTo(fold.end.row, fold.end.column);
  4014. return;
  4015. }
  4016. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  4017. column += this.session.nonTokenRe.lastIndex;
  4018. this.session.nonTokenRe.lastIndex = 0;
  4019. rightOfCursor = line.substring(column);
  4020. }
  4021. if (column >= line.length) {
  4022. this.moveCursorTo(row, line.length);
  4023. this.moveCursorRight();
  4024. if (row < this.doc.getLength() - 1)
  4025. this.moveCursorWordRight();
  4026. return;
  4027. }
  4028. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4029. column += this.session.tokenRe.lastIndex;
  4030. this.session.tokenRe.lastIndex = 0;
  4031. }
  4032. this.moveCursorTo(row, column);
  4033. };
  4034. this.moveCursorLongWordLeft = function() {
  4035. var row = this.lead.row;
  4036. var column = this.lead.column;
  4037. var fold;
  4038. if (fold = this.session.getFoldAt(row, column, -1)) {
  4039. this.moveCursorTo(fold.start.row, fold.start.column);
  4040. return;
  4041. }
  4042. var str = this.session.getFoldStringAt(row, column, -1);
  4043. if (str == null) {
  4044. str = this.doc.getLine(row).substring(0, column);
  4045. }
  4046. var leftOfCursor = lang.stringReverse(str);
  4047. var match;
  4048. this.session.nonTokenRe.lastIndex = 0;
  4049. this.session.tokenRe.lastIndex = 0;
  4050. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  4051. column -= this.session.nonTokenRe.lastIndex;
  4052. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  4053. this.session.nonTokenRe.lastIndex = 0;
  4054. }
  4055. if (column <= 0) {
  4056. this.moveCursorTo(row, 0);
  4057. this.moveCursorLeft();
  4058. if (row > 0)
  4059. this.moveCursorWordLeft();
  4060. return;
  4061. }
  4062. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  4063. column -= this.session.tokenRe.lastIndex;
  4064. this.session.tokenRe.lastIndex = 0;
  4065. }
  4066. this.moveCursorTo(row, column);
  4067. };
  4068. this.$shortWordEndIndex = function(rightOfCursor) {
  4069. var match, index = 0, ch;
  4070. var whitespaceRe = /\s/;
  4071. var tokenRe = this.session.tokenRe;
  4072. tokenRe.lastIndex = 0;
  4073. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4074. index = this.session.tokenRe.lastIndex;
  4075. } else {
  4076. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4077. index ++;
  4078. if (index < 1) {
  4079. tokenRe.lastIndex = 0;
  4080. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  4081. tokenRe.lastIndex = 0;
  4082. index ++;
  4083. if (whitespaceRe.test(ch)) {
  4084. if (index > 2) {
  4085. index--;
  4086. break;
  4087. } else {
  4088. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4089. index ++;
  4090. if (index > 2)
  4091. break;
  4092. }
  4093. }
  4094. }
  4095. }
  4096. }
  4097. tokenRe.lastIndex = 0;
  4098. return index;
  4099. };
  4100. this.moveCursorShortWordRight = function() {
  4101. var row = this.lead.row;
  4102. var column = this.lead.column;
  4103. var line = this.doc.getLine(row);
  4104. var rightOfCursor = line.substring(column);
  4105. var fold = this.session.getFoldAt(row, column, 1);
  4106. if (fold)
  4107. return this.moveCursorTo(fold.end.row, fold.end.column);
  4108. if (column == line.length) {
  4109. var l = this.doc.getLength();
  4110. do {
  4111. row++;
  4112. rightOfCursor = this.doc.getLine(row);
  4113. } while (row < l && /^\s*$/.test(rightOfCursor));
  4114. if (!/^\s+/.test(rightOfCursor))
  4115. rightOfCursor = "";
  4116. column = 0;
  4117. }
  4118. var index = this.$shortWordEndIndex(rightOfCursor);
  4119. this.moveCursorTo(row, column + index);
  4120. };
  4121. this.moveCursorShortWordLeft = function() {
  4122. var row = this.lead.row;
  4123. var column = this.lead.column;
  4124. var fold;
  4125. if (fold = this.session.getFoldAt(row, column, -1))
  4126. return this.moveCursorTo(fold.start.row, fold.start.column);
  4127. var line = this.session.getLine(row).substring(0, column);
  4128. if (column === 0) {
  4129. do {
  4130. row--;
  4131. line = this.doc.getLine(row);
  4132. } while (row > 0 && /^\s*$/.test(line));
  4133. column = line.length;
  4134. if (!/\s+$/.test(line))
  4135. line = "";
  4136. }
  4137. var leftOfCursor = lang.stringReverse(line);
  4138. var index = this.$shortWordEndIndex(leftOfCursor);
  4139. return this.moveCursorTo(row, column - index);
  4140. };
  4141. this.moveCursorWordRight = function() {
  4142. if (this.session.$selectLongWords)
  4143. this.moveCursorLongWordRight();
  4144. else
  4145. this.moveCursorShortWordRight();
  4146. };
  4147. this.moveCursorWordLeft = function() {
  4148. if (this.session.$selectLongWords)
  4149. this.moveCursorLongWordLeft();
  4150. else
  4151. this.moveCursorShortWordLeft();
  4152. };
  4153. this.moveCursorBy = function(rows, chars) {
  4154. var screenPos = this.session.documentToScreenPosition(
  4155. this.lead.row,
  4156. this.lead.column
  4157. );
  4158. if (chars === 0) {
  4159. if (this.$desiredColumn)
  4160. screenPos.column = this.$desiredColumn;
  4161. else
  4162. this.$desiredColumn = screenPos.column;
  4163. }
  4164. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
  4165. if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
  4166. if (this.session.lineWidgets && this.session.lineWidgets[docPos.row])
  4167. docPos.row++;
  4168. }
  4169. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  4170. };
  4171. this.moveCursorToPosition = function(position) {
  4172. this.moveCursorTo(position.row, position.column);
  4173. };
  4174. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  4175. var fold = this.session.getFoldAt(row, column, 1);
  4176. if (fold) {
  4177. row = fold.start.row;
  4178. column = fold.start.column;
  4179. }
  4180. this.$keepDesiredColumnOnChange = true;
  4181. this.lead.setPosition(row, column);
  4182. this.$keepDesiredColumnOnChange = false;
  4183. if (!keepDesiredColumn)
  4184. this.$desiredColumn = null;
  4185. };
  4186. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  4187. var pos = this.session.screenToDocumentPosition(row, column);
  4188. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  4189. };
  4190. this.detach = function() {
  4191. this.lead.detach();
  4192. this.anchor.detach();
  4193. this.session = this.doc = null;
  4194. };
  4195. this.fromOrientedRange = function(range) {
  4196. this.setSelectionRange(range, range.cursor == range.start);
  4197. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  4198. };
  4199. this.toOrientedRange = function(range) {
  4200. var r = this.getRange();
  4201. if (range) {
  4202. range.start.column = r.start.column;
  4203. range.start.row = r.start.row;
  4204. range.end.column = r.end.column;
  4205. range.end.row = r.end.row;
  4206. } else {
  4207. range = r;
  4208. }
  4209. range.cursor = this.isBackwards() ? range.start : range.end;
  4210. range.desiredColumn = this.$desiredColumn;
  4211. return range;
  4212. };
  4213. this.getRangeOfMovements = function(func) {
  4214. var start = this.getCursor();
  4215. try {
  4216. func.call(null, this);
  4217. var end = this.getCursor();
  4218. return Range.fromPoints(start,end);
  4219. } catch(e) {
  4220. return Range.fromPoints(start,start);
  4221. } finally {
  4222. this.moveCursorToPosition(start);
  4223. }
  4224. };
  4225. this.toJSON = function() {
  4226. if (this.rangeCount) {
  4227. var data = this.ranges.map(function(r) {
  4228. var r1 = r.clone();
  4229. r1.isBackwards = r.cursor == r.start;
  4230. return r1;
  4231. });
  4232. } else {
  4233. var data = this.getRange();
  4234. data.isBackwards = this.isBackwards();
  4235. }
  4236. return data;
  4237. };
  4238. this.fromJSON = function(data) {
  4239. if (data.start == undefined) {
  4240. if (this.rangeList) {
  4241. this.toSingleRange(data[0]);
  4242. for (var i = data.length; i--; ) {
  4243. var r = Range.fromPoints(data[i].start, data[i].end);
  4244. if (data.isBackwards)
  4245. r.cursor = r.start;
  4246. this.addRange(r, true);
  4247. }
  4248. return;
  4249. } else
  4250. data = data[0];
  4251. }
  4252. if (this.rangeList)
  4253. this.toSingleRange(data);
  4254. this.setSelectionRange(data, data.isBackwards);
  4255. };
  4256. this.isEqual = function(data) {
  4257. if ((data.length || this.rangeCount) && data.length != this.rangeCount)
  4258. return false;
  4259. if (!data.length || !this.ranges)
  4260. return this.getRange().isEqual(data);
  4261. for (var i = this.ranges.length; i--; ) {
  4262. if (!this.ranges[i].isEqual(data[i]))
  4263. return false;
  4264. }
  4265. return true;
  4266. };
  4267. }).call(Selection.prototype);
  4268. exports.Selection = Selection;
  4269. });
  4270. ace.define("ace/tokenizer",["require","exports","module","ace/config"], function(require, exports, module) {
  4271. "use strict";
  4272. var config = require("./config");
  4273. var MAX_TOKEN_COUNT = 2000;
  4274. var Tokenizer = function(rules) {
  4275. this.states = rules;
  4276. this.regExps = {};
  4277. this.matchMappings = {};
  4278. for (var key in this.states) {
  4279. var state = this.states[key];
  4280. var ruleRegExps = [];
  4281. var matchTotal = 0;
  4282. var mapping = this.matchMappings[key] = {defaultToken: "text"};
  4283. var flag = "g";
  4284. var splitterRurles = [];
  4285. for (var i = 0; i < state.length; i++) {
  4286. var rule = state[i];
  4287. if (rule.defaultToken)
  4288. mapping.defaultToken = rule.defaultToken;
  4289. if (rule.caseInsensitive)
  4290. flag = "gi";
  4291. if (rule.regex == null)
  4292. continue;
  4293. if (rule.regex instanceof RegExp)
  4294. rule.regex = rule.regex.toString().slice(1, -1);
  4295. var adjustedregex = rule.regex;
  4296. var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
  4297. if (Array.isArray(rule.token)) {
  4298. if (rule.token.length == 1 || matchcount == 1) {
  4299. rule.token = rule.token[0];
  4300. } else if (matchcount - 1 != rule.token.length) {
  4301. this.reportError("number of classes and regexp groups doesn't match", {
  4302. rule: rule,
  4303. groupCount: matchcount - 1
  4304. });
  4305. rule.token = rule.token[0];
  4306. } else {
  4307. rule.tokenArray = rule.token;
  4308. rule.token = null;
  4309. rule.onMatch = this.$arrayTokens;
  4310. }
  4311. } else if (typeof rule.token == "function" && !rule.onMatch) {
  4312. if (matchcount > 1)
  4313. rule.onMatch = this.$applyToken;
  4314. else
  4315. rule.onMatch = rule.token;
  4316. }
  4317. if (matchcount > 1) {
  4318. if (/\\\d/.test(rule.regex)) {
  4319. adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
  4320. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  4321. });
  4322. } else {
  4323. matchcount = 1;
  4324. adjustedregex = this.removeCapturingGroups(rule.regex);
  4325. }
  4326. if (!rule.splitRegex && typeof rule.token != "string")
  4327. splitterRurles.push(rule); // flag will be known only at the very end
  4328. }
  4329. mapping[matchTotal] = i;
  4330. matchTotal += matchcount;
  4331. ruleRegExps.push(adjustedregex);
  4332. if (!rule.onMatch)
  4333. rule.onMatch = null;
  4334. }
  4335. if (!ruleRegExps.length) {
  4336. mapping[0] = 0;
  4337. ruleRegExps.push("$");
  4338. }
  4339. splitterRurles.forEach(function(rule) {
  4340. rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
  4341. }, this);
  4342. this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
  4343. }
  4344. };
  4345. (function() {
  4346. this.$setMaxTokenCount = function(m) {
  4347. MAX_TOKEN_COUNT = m | 0;
  4348. };
  4349. this.$applyToken = function(str) {
  4350. var values = this.splitRegex.exec(str).slice(1);
  4351. var types = this.token.apply(this, values);
  4352. if (typeof types === "string")
  4353. return [{type: types, value: str}];
  4354. var tokens = [];
  4355. for (var i = 0, l = types.length; i < l; i++) {
  4356. if (values[i])
  4357. tokens[tokens.length] = {
  4358. type: types[i],
  4359. value: values[i]
  4360. };
  4361. }
  4362. return tokens;
  4363. },
  4364. this.$arrayTokens = function(str) {
  4365. if (!str)
  4366. return [];
  4367. var values = this.splitRegex.exec(str);
  4368. if (!values)
  4369. return "text";
  4370. var tokens = [];
  4371. var types = this.tokenArray;
  4372. for (var i = 0, l = types.length; i < l; i++) {
  4373. if (values[i + 1])
  4374. tokens[tokens.length] = {
  4375. type: types[i],
  4376. value: values[i + 1]
  4377. };
  4378. }
  4379. return tokens;
  4380. };
  4381. this.removeCapturingGroups = function(src) {
  4382. var r = src.replace(
  4383. /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
  4384. function(x, y) {return y ? "(?:" : x;}
  4385. );
  4386. return r;
  4387. };
  4388. this.createSplitterRegexp = function(src, flag) {
  4389. if (src.indexOf("(?=") != -1) {
  4390. var stack = 0;
  4391. var inChClass = false;
  4392. var lastCapture = {};
  4393. src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
  4394. m, esc, parenOpen, parenClose, square, index
  4395. ) {
  4396. if (inChClass) {
  4397. inChClass = square != "]";
  4398. } else if (square) {
  4399. inChClass = true;
  4400. } else if (parenClose) {
  4401. if (stack == lastCapture.stack) {
  4402. lastCapture.end = index+1;
  4403. lastCapture.stack = -1;
  4404. }
  4405. stack--;
  4406. } else if (parenOpen) {
  4407. stack++;
  4408. if (parenOpen.length != 1) {
  4409. lastCapture.stack = stack
  4410. lastCapture.start = index;
  4411. }
  4412. }
  4413. return m;
  4414. });
  4415. if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
  4416. src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
  4417. }
  4418. return new RegExp(src, (flag||"").replace("g", ""));
  4419. };
  4420. this.getLineTokens = function(line, startState) {
  4421. if (startState && typeof startState != "string") {
  4422. var stack = startState.slice(0);
  4423. startState = stack[0];
  4424. if (startState === "#tmp") {
  4425. stack.shift()
  4426. startState = stack.shift()
  4427. }
  4428. } else
  4429. var stack = [];
  4430. var currentState = startState || "start";
  4431. var state = this.states[currentState];
  4432. if (!state) {
  4433. currentState = "start";
  4434. state = this.states[currentState];
  4435. }
  4436. var mapping = this.matchMappings[currentState];
  4437. var re = this.regExps[currentState];
  4438. re.lastIndex = 0;
  4439. var match, tokens = [];
  4440. var lastIndex = 0;
  4441. var matchAttempts = 0;
  4442. var token = {type: null, value: ""};
  4443. while (match = re.exec(line)) {
  4444. var type = mapping.defaultToken;
  4445. var rule = null;
  4446. var value = match[0];
  4447. var index = re.lastIndex;
  4448. if (index - value.length > lastIndex) {
  4449. var skipped = line.substring(lastIndex, index - value.length);
  4450. if (token.type == type) {
  4451. token.value += skipped;
  4452. } else {
  4453. if (token.type)
  4454. tokens.push(token);
  4455. token = {type: type, value: skipped};
  4456. }
  4457. }
  4458. for (var i = 0; i < match.length-2; i++) {
  4459. if (match[i + 1] === undefined)
  4460. continue;
  4461. rule = state[mapping[i]];
  4462. if (rule.onMatch)
  4463. type = rule.onMatch(value, currentState, stack);
  4464. else
  4465. type = rule.token;
  4466. if (rule.next) {
  4467. if (typeof rule.next == "string") {
  4468. currentState = rule.next;
  4469. } else {
  4470. currentState = rule.next(currentState, stack);
  4471. }
  4472. state = this.states[currentState];
  4473. if (!state) {
  4474. this.reportError("state doesn't exist", currentState);
  4475. currentState = "start";
  4476. state = this.states[currentState];
  4477. }
  4478. mapping = this.matchMappings[currentState];
  4479. lastIndex = index;
  4480. re = this.regExps[currentState];
  4481. re.lastIndex = index;
  4482. }
  4483. break;
  4484. }
  4485. if (value) {
  4486. if (typeof type === "string") {
  4487. if ((!rule || rule.merge !== false) && token.type === type) {
  4488. token.value += value;
  4489. } else {
  4490. if (token.type)
  4491. tokens.push(token);
  4492. token = {type: type, value: value};
  4493. }
  4494. } else if (type) {
  4495. if (token.type)
  4496. tokens.push(token);
  4497. token = {type: null, value: ""};
  4498. for (var i = 0; i < type.length; i++)
  4499. tokens.push(type[i]);
  4500. }
  4501. }
  4502. if (lastIndex == line.length)
  4503. break;
  4504. lastIndex = index;
  4505. if (matchAttempts++ > MAX_TOKEN_COUNT) {
  4506. if (matchAttempts > 2 * line.length) {
  4507. this.reportError("infinite loop with in ace tokenizer", {
  4508. startState: startState,
  4509. line: line
  4510. });
  4511. }
  4512. while (lastIndex < line.length) {
  4513. if (token.type)
  4514. tokens.push(token);
  4515. token = {
  4516. value: line.substring(lastIndex, lastIndex += 2000),
  4517. type: "overflow"
  4518. };
  4519. }
  4520. currentState = "start";
  4521. stack = [];
  4522. break;
  4523. }
  4524. }
  4525. if (token.type)
  4526. tokens.push(token);
  4527. if (stack.length > 1) {
  4528. if (stack[0] !== currentState)
  4529. stack.unshift("#tmp", currentState);
  4530. }
  4531. return {
  4532. tokens : tokens,
  4533. state : stack.length ? stack : currentState
  4534. };
  4535. };
  4536. this.reportError = config.reportError;
  4537. }).call(Tokenizer.prototype);
  4538. exports.Tokenizer = Tokenizer;
  4539. });
  4540. ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
  4541. "use strict";
  4542. var lang = require("../lib/lang");
  4543. var TextHighlightRules = function() {
  4544. this.$rules = {
  4545. "start" : [{
  4546. token : "empty_line",
  4547. regex : '^$'
  4548. }, {
  4549. defaultToken : "text"
  4550. }]
  4551. };
  4552. };
  4553. (function() {
  4554. this.addRules = function(rules, prefix) {
  4555. if (!prefix) {
  4556. for (var key in rules)
  4557. this.$rules[key] = rules[key];
  4558. return;
  4559. }
  4560. for (var key in rules) {
  4561. var state = rules[key];
  4562. for (var i = 0; i < state.length; i++) {
  4563. var rule = state[i];
  4564. if (rule.next || rule.onMatch) {
  4565. if (typeof rule.next != "string") {
  4566. if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
  4567. rule.nextState = prefix + rule.nextState;
  4568. } else {
  4569. if (rule.next.indexOf(prefix) !== 0)
  4570. rule.next = prefix + rule.next;
  4571. }
  4572. }
  4573. }
  4574. this.$rules[prefix + key] = state;
  4575. }
  4576. };
  4577. this.getRules = function() {
  4578. return this.$rules;
  4579. };
  4580. this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
  4581. var embedRules = typeof HighlightRules == "function"
  4582. ? new HighlightRules().getRules()
  4583. : HighlightRules;
  4584. if (states) {
  4585. for (var i = 0; i < states.length; i++)
  4586. states[i] = prefix + states[i];
  4587. } else {
  4588. states = [];
  4589. for (var key in embedRules)
  4590. states.push(prefix + key);
  4591. }
  4592. this.addRules(embedRules, prefix);
  4593. if (escapeRules) {
  4594. var addRules = Array.prototype[append ? "push" : "unshift"];
  4595. for (var i = 0; i < states.length; i++)
  4596. addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  4597. }
  4598. if (!this.$embeds)
  4599. this.$embeds = [];
  4600. this.$embeds.push(prefix);
  4601. };
  4602. this.getEmbeds = function() {
  4603. return this.$embeds;
  4604. };
  4605. var pushState = function(currentState, stack) {
  4606. if (currentState != "start" || stack.length)
  4607. stack.unshift(this.nextState, currentState);
  4608. return this.nextState;
  4609. };
  4610. var popState = function(currentState, stack) {
  4611. stack.shift();
  4612. return stack.shift() || "start";
  4613. };
  4614. this.normalizeRules = function() {
  4615. var id = 0;
  4616. var rules = this.$rules;
  4617. function processState(key) {
  4618. var state = rules[key];
  4619. state.processed = true;
  4620. for (var i = 0; i < state.length; i++) {
  4621. var rule = state[i];
  4622. if (!rule.regex && rule.start) {
  4623. rule.regex = rule.start;
  4624. if (!rule.next)
  4625. rule.next = [];
  4626. rule.next.push({
  4627. defaultToken: rule.token
  4628. }, {
  4629. token: rule.token + ".end",
  4630. regex: rule.end || rule.start,
  4631. next: "pop"
  4632. });
  4633. rule.token = rule.token + ".start";
  4634. rule.push = true;
  4635. }
  4636. var next = rule.next || rule.push;
  4637. if (next && Array.isArray(next)) {
  4638. var stateName = rule.stateName;
  4639. if (!stateName) {
  4640. stateName = rule.token;
  4641. if (typeof stateName != "string")
  4642. stateName = stateName[0] || "";
  4643. if (rules[stateName])
  4644. stateName += id++;
  4645. }
  4646. rules[stateName] = next;
  4647. rule.next = stateName;
  4648. processState(stateName);
  4649. } else if (next == "pop") {
  4650. rule.next = popState;
  4651. }
  4652. if (rule.push) {
  4653. rule.nextState = rule.next || rule.push;
  4654. rule.next = pushState;
  4655. delete rule.push;
  4656. }
  4657. if (rule.rules) {
  4658. for (var r in rule.rules) {
  4659. if (rules[r]) {
  4660. if (rules[r].push)
  4661. rules[r].push.apply(rules[r], rule.rules[r]);
  4662. } else {
  4663. rules[r] = rule.rules[r];
  4664. }
  4665. }
  4666. }
  4667. if (rule.include || typeof rule == "string") {
  4668. var includeName = rule.include || rule;
  4669. var toInsert = rules[includeName];
  4670. } else if (Array.isArray(rule))
  4671. toInsert = rule;
  4672. if (toInsert) {
  4673. var args = [i, 1].concat(toInsert);
  4674. if (rule.noEscape)
  4675. args = args.filter(function(x) {return !x.next;});
  4676. state.splice.apply(state, args);
  4677. i--;
  4678. toInsert = null;
  4679. }
  4680. if (rule.keywordMap) {
  4681. rule.token = this.createKeywordMapper(
  4682. rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
  4683. );
  4684. delete rule.defaultToken;
  4685. }
  4686. }
  4687. }
  4688. Object.keys(rules).forEach(processState, this);
  4689. };
  4690. this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
  4691. var keywords = Object.create(null);
  4692. Object.keys(map).forEach(function(className) {
  4693. var a = map[className];
  4694. if (ignoreCase)
  4695. a = a.toLowerCase();
  4696. var list = a.split(splitChar || "|");
  4697. for (var i = list.length; i--; )
  4698. keywords[list[i]] = className;
  4699. });
  4700. if (Object.getPrototypeOf(keywords)) {
  4701. keywords.__proto__ = null;
  4702. }
  4703. this.$keywordList = Object.keys(keywords);
  4704. map = null;
  4705. return ignoreCase
  4706. ? function(value) {return keywords[value.toLowerCase()] || defaultToken }
  4707. : function(value) {return keywords[value] || defaultToken };
  4708. };
  4709. this.getKeywords = function() {
  4710. return this.$keywords;
  4711. };
  4712. }).call(TextHighlightRules.prototype);
  4713. exports.TextHighlightRules = TextHighlightRules;
  4714. });
  4715. ace.define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
  4716. "use strict";
  4717. var Behaviour = function() {
  4718. this.$behaviours = {};
  4719. };
  4720. (function () {
  4721. this.add = function (name, action, callback) {
  4722. switch (undefined) {
  4723. case this.$behaviours:
  4724. this.$behaviours = {};
  4725. case this.$behaviours[name]:
  4726. this.$behaviours[name] = {};
  4727. }
  4728. this.$behaviours[name][action] = callback;
  4729. }
  4730. this.addBehaviours = function (behaviours) {
  4731. for (var key in behaviours) {
  4732. for (var action in behaviours[key]) {
  4733. this.add(key, action, behaviours[key][action]);
  4734. }
  4735. }
  4736. }
  4737. this.remove = function (name) {
  4738. if (this.$behaviours && this.$behaviours[name]) {
  4739. delete this.$behaviours[name];
  4740. }
  4741. }
  4742. this.inherit = function (mode, filter) {
  4743. if (typeof mode === "function") {
  4744. var behaviours = new mode().getBehaviours(filter);
  4745. } else {
  4746. var behaviours = mode.getBehaviours(filter);
  4747. }
  4748. this.addBehaviours(behaviours);
  4749. }
  4750. this.getBehaviours = function (filter) {
  4751. if (!filter) {
  4752. return this.$behaviours;
  4753. } else {
  4754. var ret = {}
  4755. for (var i = 0; i < filter.length; i++) {
  4756. if (this.$behaviours[filter[i]]) {
  4757. ret[filter[i]] = this.$behaviours[filter[i]];
  4758. }
  4759. }
  4760. return ret;
  4761. }
  4762. }
  4763. }).call(Behaviour.prototype);
  4764. exports.Behaviour = Behaviour;
  4765. });
  4766. ace.define("ace/unicode",["require","exports","module"], function(require, exports, module) {
  4767. "use strict";
  4768. exports.packages = {};
  4769. addUnicodePackage({
  4770. 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",
  4771. 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",
  4772. 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",
  4773. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  4774. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  4775. 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",
  4776. 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",
  4777. 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",
  4778. 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",
  4779. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  4780. 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",
  4781. 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",
  4782. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  4783. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  4784. 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",
  4785. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  4786. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  4787. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  4788. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  4789. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  4790. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  4791. 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",
  4792. 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",
  4793. 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",
  4794. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  4795. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  4796. 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",
  4797. Z: "002000A01680180E2000-200A20282029202F205F3000",
  4798. Zs: "002000A01680180E2000-200A202F205F3000",
  4799. Zl: "2028",
  4800. Zp: "2029",
  4801. 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",
  4802. Cc: "0000-001F007F-009F",
  4803. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  4804. Co: "E000-F8FF",
  4805. Cs: "D800-DFFF",
  4806. 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"
  4807. });
  4808. function addUnicodePackage (pack) {
  4809. var codePoint = /\w{4}/g;
  4810. for (var name in pack)
  4811. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  4812. };
  4813. });
  4814. ace.define("ace/token_iterator",["require","exports","module"], function(require, exports, module) {
  4815. "use strict";
  4816. var TokenIterator = function(session, initialRow, initialColumn) {
  4817. this.$session = session;
  4818. this.$row = initialRow;
  4819. this.$rowTokens = session.getTokens(initialRow);
  4820. var token = session.getTokenAt(initialRow, initialColumn);
  4821. this.$tokenIndex = token ? token.index : -1;
  4822. };
  4823. (function() {
  4824. this.stepBackward = function() {
  4825. this.$tokenIndex -= 1;
  4826. while (this.$tokenIndex < 0) {
  4827. this.$row -= 1;
  4828. if (this.$row < 0) {
  4829. this.$row = 0;
  4830. return null;
  4831. }
  4832. this.$rowTokens = this.$session.getTokens(this.$row);
  4833. this.$tokenIndex = this.$rowTokens.length - 1;
  4834. }
  4835. return this.$rowTokens[this.$tokenIndex];
  4836. };
  4837. this.stepForward = function() {
  4838. this.$tokenIndex += 1;
  4839. var rowCount;
  4840. while (this.$tokenIndex >= this.$rowTokens.length) {
  4841. this.$row += 1;
  4842. if (!rowCount)
  4843. rowCount = this.$session.getLength();
  4844. if (this.$row >= rowCount) {
  4845. this.$row = rowCount - 1;
  4846. return null;
  4847. }
  4848. this.$rowTokens = this.$session.getTokens(this.$row);
  4849. this.$tokenIndex = 0;
  4850. }
  4851. return this.$rowTokens[this.$tokenIndex];
  4852. };
  4853. this.getCurrentToken = function () {
  4854. return this.$rowTokens[this.$tokenIndex];
  4855. };
  4856. this.getCurrentTokenRow = function () {
  4857. return this.$row;
  4858. };
  4859. this.getCurrentTokenColumn = function() {
  4860. var rowTokens = this.$rowTokens;
  4861. var tokenIndex = this.$tokenIndex;
  4862. var column = rowTokens[tokenIndex].start;
  4863. if (column !== undefined)
  4864. return column;
  4865. column = 0;
  4866. while (tokenIndex > 0) {
  4867. tokenIndex -= 1;
  4868. column += rowTokens[tokenIndex].value.length;
  4869. }
  4870. return column;
  4871. };
  4872. }).call(TokenIterator.prototype);
  4873. exports.TokenIterator = TokenIterator;
  4874. });
  4875. 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) {
  4876. "use strict";
  4877. var Tokenizer = require("../tokenizer").Tokenizer;
  4878. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4879. var Behaviour = require("./behaviour").Behaviour;
  4880. var unicode = require("../unicode");
  4881. var lang = require("../lib/lang");
  4882. var TokenIterator = require("../token_iterator").TokenIterator;
  4883. var Range = require("../range").Range;
  4884. var Mode = function() {
  4885. this.HighlightRules = TextHighlightRules;
  4886. this.$behaviour = new Behaviour();
  4887. };
  4888. (function() {
  4889. this.tokenRe = new RegExp("^["
  4890. + unicode.packages.L
  4891. + unicode.packages.Mn + unicode.packages.Mc
  4892. + unicode.packages.Nd
  4893. + unicode.packages.Pc + "\\$_]+", "g"
  4894. );
  4895. this.nonTokenRe = new RegExp("^(?:[^"
  4896. + unicode.packages.L
  4897. + unicode.packages.Mn + unicode.packages.Mc
  4898. + unicode.packages.Nd
  4899. + unicode.packages.Pc + "\\$_]|\\s])+", "g"
  4900. );
  4901. this.getTokenizer = function() {
  4902. if (!this.$tokenizer) {
  4903. this.$highlightRules = this.$highlightRules || new this.HighlightRules();
  4904. this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
  4905. }
  4906. return this.$tokenizer;
  4907. };
  4908. this.lineCommentStart = "";
  4909. this.blockComment = "";
  4910. this.toggleCommentLines = function(state, session, startRow, endRow) {
  4911. var doc = session.doc;
  4912. var ignoreBlankLines = true;
  4913. var shouldRemove = true;
  4914. var minIndent = Infinity;
  4915. var tabSize = session.getTabSize();
  4916. var insertAtTabStop = false;
  4917. if (!this.lineCommentStart) {
  4918. if (!this.blockComment)
  4919. return false;
  4920. var lineCommentStart = this.blockComment.start;
  4921. var lineCommentEnd = this.blockComment.end;
  4922. var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
  4923. var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
  4924. var comment = function(line, i) {
  4925. if (testRemove(line, i))
  4926. return;
  4927. if (!ignoreBlankLines || /\S/.test(line)) {
  4928. doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
  4929. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  4930. }
  4931. };
  4932. var uncomment = function(line, i) {
  4933. var m;
  4934. if (m = line.match(regexpEnd))
  4935. doc.removeInLine(i, line.length - m[0].length, line.length);
  4936. if (m = line.match(regexpStart))
  4937. doc.removeInLine(i, m[1].length, m[0].length);
  4938. };
  4939. var testRemove = function(line, row) {
  4940. if (regexpStart.test(line))
  4941. return true;
  4942. var tokens = session.getTokens(row);
  4943. for (var i = 0; i < tokens.length; i++) {
  4944. if (tokens[i].type === 'comment')
  4945. return true;
  4946. }
  4947. };
  4948. } else {
  4949. if (Array.isArray(this.lineCommentStart)) {
  4950. var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
  4951. var lineCommentStart = this.lineCommentStart[0];
  4952. } else {
  4953. var regexpStart = lang.escapeRegExp(this.lineCommentStart);
  4954. var lineCommentStart = this.lineCommentStart;
  4955. }
  4956. regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
  4957. insertAtTabStop = session.getUseSoftTabs();
  4958. var uncomment = function(line, i) {
  4959. var m = line.match(regexpStart);
  4960. if (!m) return;
  4961. var start = m[1].length, end = m[0].length;
  4962. if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
  4963. end--;
  4964. doc.removeInLine(i, start, end);
  4965. };
  4966. var commentWithSpace = lineCommentStart + " ";
  4967. var comment = function(line, i) {
  4968. if (!ignoreBlankLines || /\S/.test(line)) {
  4969. if (shouldInsertSpace(line, minIndent, minIndent))
  4970. doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
  4971. else
  4972. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  4973. }
  4974. };
  4975. var testRemove = function(line, i) {
  4976. return regexpStart.test(line);
  4977. };
  4978. var shouldInsertSpace = function(line, before, after) {
  4979. var spaces = 0;
  4980. while (before-- && line.charAt(before) == " ")
  4981. spaces++;
  4982. if (spaces % tabSize != 0)
  4983. return false;
  4984. var spaces = 0;
  4985. while (line.charAt(after++) == " ")
  4986. spaces++;
  4987. if (tabSize > 2)
  4988. return spaces % tabSize != tabSize - 1;
  4989. else
  4990. return spaces % tabSize == 0;
  4991. return true;
  4992. };
  4993. }
  4994. function iter(fun) {
  4995. for (var i = startRow; i <= endRow; i++)
  4996. fun(doc.getLine(i), i);
  4997. }
  4998. var minEmptyLength = Infinity;
  4999. iter(function(line, i) {
  5000. var indent = line.search(/\S/);
  5001. if (indent !== -1) {
  5002. if (indent < minIndent)
  5003. minIndent = indent;
  5004. if (shouldRemove && !testRemove(line, i))
  5005. shouldRemove = false;
  5006. } else if (minEmptyLength > line.length) {
  5007. minEmptyLength = line.length;
  5008. }
  5009. });
  5010. if (minIndent == Infinity) {
  5011. minIndent = minEmptyLength;
  5012. ignoreBlankLines = false;
  5013. shouldRemove = false;
  5014. }
  5015. if (insertAtTabStop && minIndent % tabSize != 0)
  5016. minIndent = Math.floor(minIndent / tabSize) * tabSize;
  5017. iter(shouldRemove ? uncomment : comment);
  5018. };
  5019. this.toggleBlockComment = function(state, session, range, cursor) {
  5020. var comment = this.blockComment;
  5021. if (!comment)
  5022. return;
  5023. if (!comment.start && comment[0])
  5024. comment = comment[0];
  5025. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5026. var token = iterator.getCurrentToken();
  5027. var sel = session.selection;
  5028. var initialRange = session.selection.toOrientedRange();
  5029. var startRow, colDiff;
  5030. if (token && /comment/.test(token.type)) {
  5031. var startRange, endRange;
  5032. while (token && /comment/.test(token.type)) {
  5033. var i = token.value.indexOf(comment.start);
  5034. if (i != -1) {
  5035. var row = iterator.getCurrentTokenRow();
  5036. var column = iterator.getCurrentTokenColumn() + i;
  5037. startRange = new Range(row, column, row, column + comment.start.length);
  5038. break;
  5039. }
  5040. token = iterator.stepBackward();
  5041. }
  5042. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5043. var token = iterator.getCurrentToken();
  5044. while (token && /comment/.test(token.type)) {
  5045. var i = token.value.indexOf(comment.end);
  5046. if (i != -1) {
  5047. var row = iterator.getCurrentTokenRow();
  5048. var column = iterator.getCurrentTokenColumn() + i;
  5049. endRange = new Range(row, column, row, column + comment.end.length);
  5050. break;
  5051. }
  5052. token = iterator.stepForward();
  5053. }
  5054. if (endRange)
  5055. session.remove(endRange);
  5056. if (startRange) {
  5057. session.remove(startRange);
  5058. startRow = startRange.start.row;
  5059. colDiff = -comment.start.length;
  5060. }
  5061. } else {
  5062. colDiff = comment.start.length;
  5063. startRow = range.start.row;
  5064. session.insert(range.end, comment.end);
  5065. session.insert(range.start, comment.start);
  5066. }
  5067. if (initialRange.start.row == startRow)
  5068. initialRange.start.column += colDiff;
  5069. if (initialRange.end.row == startRow)
  5070. initialRange.end.column += colDiff;
  5071. session.selection.fromOrientedRange(initialRange);
  5072. };
  5073. this.getNextLineIndent = function(state, line, tab) {
  5074. return this.$getIndent(line);
  5075. };
  5076. this.checkOutdent = function(state, line, input) {
  5077. return false;
  5078. };
  5079. this.autoOutdent = function(state, doc, row) {
  5080. };
  5081. this.$getIndent = function(line) {
  5082. return line.match(/^\s*/)[0];
  5083. };
  5084. this.createWorker = function(session) {
  5085. return null;
  5086. };
  5087. this.createModeDelegates = function (mapping) {
  5088. this.$embeds = [];
  5089. this.$modes = {};
  5090. for (var i in mapping) {
  5091. if (mapping[i]) {
  5092. this.$embeds.push(i);
  5093. this.$modes[i] = new mapping[i]();
  5094. }
  5095. }
  5096. var delegations = ['toggleBlockComment', 'toggleCommentLines', 'getNextLineIndent',
  5097. 'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions'];
  5098. for (var i = 0; i < delegations.length; i++) {
  5099. (function(scope) {
  5100. var functionName = delegations[i];
  5101. var defaultHandler = scope[functionName];
  5102. scope[delegations[i]] = function() {
  5103. return this.$delegator(functionName, arguments, defaultHandler);
  5104. };
  5105. } (this));
  5106. }
  5107. };
  5108. this.$delegator = function(method, args, defaultHandler) {
  5109. var state = args[0];
  5110. if (typeof state != "string")
  5111. state = state[0];
  5112. for (var i = 0; i < this.$embeds.length; i++) {
  5113. if (!this.$modes[this.$embeds[i]]) continue;
  5114. var split = state.split(this.$embeds[i]);
  5115. if (!split[0] && split[1]) {
  5116. args[0] = split[1];
  5117. var mode = this.$modes[this.$embeds[i]];
  5118. return mode[method].apply(mode, args);
  5119. }
  5120. }
  5121. var ret = defaultHandler.apply(this, args);
  5122. return defaultHandler ? ret : undefined;
  5123. };
  5124. this.transformAction = function(state, action, editor, session, param) {
  5125. if (this.$behaviour) {
  5126. var behaviours = this.$behaviour.getBehaviours();
  5127. for (var key in behaviours) {
  5128. if (behaviours[key][action]) {
  5129. var ret = behaviours[key][action].apply(this, arguments);
  5130. if (ret) {
  5131. return ret;
  5132. }
  5133. }
  5134. }
  5135. }
  5136. };
  5137. this.getKeywords = function(append) {
  5138. if (!this.completionKeywords) {
  5139. var rules = this.$tokenizer.rules;
  5140. var completionKeywords = [];
  5141. for (var rule in rules) {
  5142. var ruleItr = rules[rule];
  5143. for (var r = 0, l = ruleItr.length; r < l; r++) {
  5144. if (typeof ruleItr[r].token === "string") {
  5145. if (/keyword|support|storage/.test(ruleItr[r].token))
  5146. completionKeywords.push(ruleItr[r].regex);
  5147. }
  5148. else if (typeof ruleItr[r].token === "object") {
  5149. for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
  5150. if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
  5151. var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
  5152. completionKeywords.push(rule.substr(1, rule.length - 2));
  5153. }
  5154. }
  5155. }
  5156. }
  5157. }
  5158. this.completionKeywords = completionKeywords;
  5159. }
  5160. if (!append)
  5161. return this.$keywordList;
  5162. return completionKeywords.concat(this.$keywordList || []);
  5163. };
  5164. this.$createKeywordList = function() {
  5165. if (!this.$highlightRules)
  5166. this.getTokenizer();
  5167. return this.$keywordList = this.$highlightRules.$keywordList || [];
  5168. };
  5169. this.getCompletions = function(state, session, pos, prefix) {
  5170. var keywords = this.$keywordList || this.$createKeywordList();
  5171. return keywords.map(function(word) {
  5172. return {
  5173. name: word,
  5174. value: word,
  5175. score: 0,
  5176. meta: "keyword"
  5177. };
  5178. });
  5179. };
  5180. this.$id = "ace/mode/text";
  5181. }).call(Mode.prototype);
  5182. exports.Mode = Mode;
  5183. });
  5184. ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5185. "use strict";
  5186. var oop = require("./lib/oop");
  5187. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5188. var Anchor = exports.Anchor = function(doc, row, column) {
  5189. this.$onChange = this.onChange.bind(this);
  5190. this.attach(doc);
  5191. if (typeof column == "undefined")
  5192. this.setPosition(row.row, row.column);
  5193. else
  5194. this.setPosition(row, column);
  5195. };
  5196. (function() {
  5197. oop.implement(this, EventEmitter);
  5198. this.getPosition = function() {
  5199. return this.$clipPositionToDocument(this.row, this.column);
  5200. };
  5201. this.getDocument = function() {
  5202. return this.document;
  5203. };
  5204. this.$insertRight = false;
  5205. this.onChange = function(e) {
  5206. var delta = e.data;
  5207. var range = delta.range;
  5208. if (range.start.row == range.end.row && range.start.row != this.row)
  5209. return;
  5210. if (range.start.row > this.row)
  5211. return;
  5212. if (range.start.row == this.row && range.start.column > this.column)
  5213. return;
  5214. var row = this.row;
  5215. var column = this.column;
  5216. var start = range.start;
  5217. var end = range.end;
  5218. if (delta.action === "insertText") {
  5219. if (start.row === row && start.column <= column) {
  5220. if (start.column === column && this.$insertRight) {
  5221. } else if (start.row === end.row) {
  5222. column += end.column - start.column;
  5223. } else {
  5224. column -= start.column;
  5225. row += end.row - start.row;
  5226. }
  5227. } else if (start.row !== end.row && start.row < row) {
  5228. row += end.row - start.row;
  5229. }
  5230. } else if (delta.action === "insertLines") {
  5231. if (start.row === row && column === 0 && this.$insertRight) {
  5232. }
  5233. else if (start.row <= row) {
  5234. row += end.row - start.row;
  5235. }
  5236. } else if (delta.action === "removeText") {
  5237. if (start.row === row && start.column < column) {
  5238. if (end.column >= column)
  5239. column = start.column;
  5240. else
  5241. column = Math.max(0, column - (end.column - start.column));
  5242. } else if (start.row !== end.row && start.row < row) {
  5243. if (end.row === row)
  5244. column = Math.max(0, column - end.column) + start.column;
  5245. row -= (end.row - start.row);
  5246. } else if (end.row === row) {
  5247. row -= end.row - start.row;
  5248. column = Math.max(0, column - end.column) + start.column;
  5249. }
  5250. } else if (delta.action == "removeLines") {
  5251. if (start.row <= row) {
  5252. if (end.row <= row)
  5253. row -= end.row - start.row;
  5254. else {
  5255. row = start.row;
  5256. column = 0;
  5257. }
  5258. }
  5259. }
  5260. this.setPosition(row, column, true);
  5261. };
  5262. this.setPosition = function(row, column, noClip) {
  5263. var pos;
  5264. if (noClip) {
  5265. pos = {
  5266. row: row,
  5267. column: column
  5268. };
  5269. } else {
  5270. pos = this.$clipPositionToDocument(row, column);
  5271. }
  5272. if (this.row == pos.row && this.column == pos.column)
  5273. return;
  5274. var old = {
  5275. row: this.row,
  5276. column: this.column
  5277. };
  5278. this.row = pos.row;
  5279. this.column = pos.column;
  5280. this._signal("change", {
  5281. old: old,
  5282. value: pos
  5283. });
  5284. };
  5285. this.detach = function() {
  5286. this.document.removeEventListener("change", this.$onChange);
  5287. };
  5288. this.attach = function(doc) {
  5289. this.document = doc || this.document;
  5290. this.document.on("change", this.$onChange);
  5291. };
  5292. this.$clipPositionToDocument = function(row, column) {
  5293. var pos = {};
  5294. if (row >= this.document.getLength()) {
  5295. pos.row = Math.max(0, this.document.getLength() - 1);
  5296. pos.column = this.document.getLine(pos.row).length;
  5297. }
  5298. else if (row < 0) {
  5299. pos.row = 0;
  5300. pos.column = 0;
  5301. }
  5302. else {
  5303. pos.row = row;
  5304. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  5305. }
  5306. if (column < 0)
  5307. pos.column = 0;
  5308. return pos;
  5309. };
  5310. }).call(Anchor.prototype);
  5311. });
  5312. ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  5313. "use strict";
  5314. var oop = require("./lib/oop");
  5315. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5316. var Range = require("./range").Range;
  5317. var Anchor = require("./anchor").Anchor;
  5318. var Document = function(text) {
  5319. this.$lines = [];
  5320. if (text.length === 0) {
  5321. this.$lines = [""];
  5322. } else if (Array.isArray(text)) {
  5323. this._insertLines(0, text);
  5324. } else {
  5325. this.insert({row: 0, column:0}, text);
  5326. }
  5327. };
  5328. (function() {
  5329. oop.implement(this, EventEmitter);
  5330. this.setValue = function(text) {
  5331. var len = this.getLength();
  5332. this.remove(new Range(0, 0, len, this.getLine(len-1).length));
  5333. this.insert({row: 0, column:0}, text);
  5334. };
  5335. this.getValue = function() {
  5336. return this.getAllLines().join(this.getNewLineCharacter());
  5337. };
  5338. this.createAnchor = function(row, column) {
  5339. return new Anchor(this, row, column);
  5340. };
  5341. if ("aaa".split(/a/).length === 0)
  5342. this.$split = function(text) {
  5343. return text.replace(/\r\n|\r/g, "\n").split("\n");
  5344. };
  5345. else
  5346. this.$split = function(text) {
  5347. return text.split(/\r\n|\r|\n/);
  5348. };
  5349. this.$detectNewLine = function(text) {
  5350. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  5351. this.$autoNewLine = match ? match[1] : "\n";
  5352. this._signal("changeNewLineMode");
  5353. };
  5354. this.getNewLineCharacter = function() {
  5355. switch (this.$newLineMode) {
  5356. case "windows":
  5357. return "\r\n";
  5358. case "unix":
  5359. return "\n";
  5360. default:
  5361. return this.$autoNewLine || "\n";
  5362. }
  5363. };
  5364. this.$autoNewLine = "";
  5365. this.$newLineMode = "auto";
  5366. this.setNewLineMode = function(newLineMode) {
  5367. if (this.$newLineMode === newLineMode)
  5368. return;
  5369. this.$newLineMode = newLineMode;
  5370. this._signal("changeNewLineMode");
  5371. };
  5372. this.getNewLineMode = function() {
  5373. return this.$newLineMode;
  5374. };
  5375. this.isNewLine = function(text) {
  5376. return (text == "\r\n" || text == "\r" || text == "\n");
  5377. };
  5378. this.getLine = function(row) {
  5379. return this.$lines[row] || "";
  5380. };
  5381. this.getLines = function(firstRow, lastRow) {
  5382. return this.$lines.slice(firstRow, lastRow + 1);
  5383. };
  5384. this.getAllLines = function() {
  5385. return this.getLines(0, this.getLength());
  5386. };
  5387. this.getLength = function() {
  5388. return this.$lines.length;
  5389. };
  5390. this.getTextRange = function(range) {
  5391. if (range.start.row == range.end.row) {
  5392. return this.getLine(range.start.row)
  5393. .substring(range.start.column, range.end.column);
  5394. }
  5395. var lines = this.getLines(range.start.row, range.end.row);
  5396. lines[0] = (lines[0] || "").substring(range.start.column);
  5397. var l = lines.length - 1;
  5398. if (range.end.row - range.start.row == l)
  5399. lines[l] = lines[l].substring(0, range.end.column);
  5400. return lines.join(this.getNewLineCharacter());
  5401. };
  5402. this.$clipPosition = function(position) {
  5403. var length = this.getLength();
  5404. if (position.row >= length) {
  5405. position.row = Math.max(0, length - 1);
  5406. position.column = this.getLine(length-1).length;
  5407. } else if (position.row < 0)
  5408. position.row = 0;
  5409. return position;
  5410. };
  5411. this.insert = function(position, text) {
  5412. if (!text || text.length === 0)
  5413. return position;
  5414. position = this.$clipPosition(position);
  5415. if (this.getLength() <= 1)
  5416. this.$detectNewLine(text);
  5417. var lines = this.$split(text);
  5418. var firstLine = lines.splice(0, 1)[0];
  5419. var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
  5420. position = this.insertInLine(position, firstLine);
  5421. if (lastLine !== null) {
  5422. position = this.insertNewLine(position); // terminate first line
  5423. position = this._insertLines(position.row, lines);
  5424. position = this.insertInLine(position, lastLine || "");
  5425. }
  5426. return position;
  5427. };
  5428. this.insertLines = function(row, lines) {
  5429. if (row >= this.getLength())
  5430. return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
  5431. return this._insertLines(Math.max(row, 0), lines);
  5432. };
  5433. this._insertLines = function(row, lines) {
  5434. if (lines.length == 0)
  5435. return {row: row, column: 0};
  5436. while (lines.length > 20000) {
  5437. var end = this._insertLines(row, lines.slice(0, 20000));
  5438. lines = lines.slice(20000);
  5439. row = end.row;
  5440. }
  5441. var args = [row, 0];
  5442. args.push.apply(args, lines);
  5443. this.$lines.splice.apply(this.$lines, args);
  5444. var range = new Range(row, 0, row + lines.length, 0);
  5445. var delta = {
  5446. action: "insertLines",
  5447. range: range,
  5448. lines: lines
  5449. };
  5450. this._signal("change", { data: delta });
  5451. return range.end;
  5452. };
  5453. this.insertNewLine = function(position) {
  5454. position = this.$clipPosition(position);
  5455. var line = this.$lines[position.row] || "";
  5456. this.$lines[position.row] = line.substring(0, position.column);
  5457. this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
  5458. var end = {
  5459. row : position.row + 1,
  5460. column : 0
  5461. };
  5462. var delta = {
  5463. action: "insertText",
  5464. range: Range.fromPoints(position, end),
  5465. text: this.getNewLineCharacter()
  5466. };
  5467. this._signal("change", { data: delta });
  5468. return end;
  5469. };
  5470. this.insertInLine = function(position, text) {
  5471. if (text.length == 0)
  5472. return position;
  5473. var line = this.$lines[position.row] || "";
  5474. this.$lines[position.row] = line.substring(0, position.column) + text
  5475. + line.substring(position.column);
  5476. var end = {
  5477. row : position.row,
  5478. column : position.column + text.length
  5479. };
  5480. var delta = {
  5481. action: "insertText",
  5482. range: Range.fromPoints(position, end),
  5483. text: text
  5484. };
  5485. this._signal("change", { data: delta });
  5486. return end;
  5487. };
  5488. this.remove = function(range) {
  5489. if (!(range instanceof Range))
  5490. range = Range.fromPoints(range.start, range.end);
  5491. range.start = this.$clipPosition(range.start);
  5492. range.end = this.$clipPosition(range.end);
  5493. if (range.isEmpty())
  5494. return range.start;
  5495. var firstRow = range.start.row;
  5496. var lastRow = range.end.row;
  5497. if (range.isMultiLine()) {
  5498. var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
  5499. var lastFullRow = lastRow - 1;
  5500. if (range.end.column > 0)
  5501. this.removeInLine(lastRow, 0, range.end.column);
  5502. if (lastFullRow >= firstFullRow)
  5503. this._removeLines(firstFullRow, lastFullRow);
  5504. if (firstFullRow != firstRow) {
  5505. this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
  5506. this.removeNewLine(range.start.row);
  5507. }
  5508. }
  5509. else {
  5510. this.removeInLine(firstRow, range.start.column, range.end.column);
  5511. }
  5512. return range.start;
  5513. };
  5514. this.removeInLine = function(row, startColumn, endColumn) {
  5515. if (startColumn == endColumn)
  5516. return;
  5517. var range = new Range(row, startColumn, row, endColumn);
  5518. var line = this.getLine(row);
  5519. var removed = line.substring(startColumn, endColumn);
  5520. var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
  5521. this.$lines.splice(row, 1, newLine);
  5522. var delta = {
  5523. action: "removeText",
  5524. range: range,
  5525. text: removed
  5526. };
  5527. this._signal("change", { data: delta });
  5528. return range.start;
  5529. };
  5530. this.removeLines = function(firstRow, lastRow) {
  5531. if (firstRow < 0 || lastRow >= this.getLength())
  5532. return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
  5533. return this._removeLines(firstRow, lastRow);
  5534. };
  5535. this._removeLines = function(firstRow, lastRow) {
  5536. var range = new Range(firstRow, 0, lastRow + 1, 0);
  5537. var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
  5538. var delta = {
  5539. action: "removeLines",
  5540. range: range,
  5541. nl: this.getNewLineCharacter(),
  5542. lines: removed
  5543. };
  5544. this._signal("change", { data: delta });
  5545. return removed;
  5546. };
  5547. this.removeNewLine = function(row) {
  5548. var firstLine = this.getLine(row);
  5549. var secondLine = this.getLine(row+1);
  5550. var range = new Range(row, firstLine.length, row+1, 0);
  5551. var line = firstLine + secondLine;
  5552. this.$lines.splice(row, 2, line);
  5553. var delta = {
  5554. action: "removeText",
  5555. range: range,
  5556. text: this.getNewLineCharacter()
  5557. };
  5558. this._signal("change", { data: delta });
  5559. };
  5560. this.replace = function(range, text) {
  5561. if (!(range instanceof Range))
  5562. range = Range.fromPoints(range.start, range.end);
  5563. if (text.length == 0 && range.isEmpty())
  5564. return range.start;
  5565. if (text == this.getTextRange(range))
  5566. return range.end;
  5567. this.remove(range);
  5568. if (text) {
  5569. var end = this.insert(range.start, text);
  5570. }
  5571. else {
  5572. end = range.start;
  5573. }
  5574. return end;
  5575. };
  5576. this.applyDeltas = function(deltas) {
  5577. for (var i=0; i<deltas.length; i++) {
  5578. var delta = deltas[i];
  5579. var range = Range.fromPoints(delta.range.start, delta.range.end);
  5580. if (delta.action == "insertLines")
  5581. this.insertLines(range.start.row, delta.lines);
  5582. else if (delta.action == "insertText")
  5583. this.insert(range.start, delta.text);
  5584. else if (delta.action == "removeLines")
  5585. this._removeLines(range.start.row, range.end.row - 1);
  5586. else if (delta.action == "removeText")
  5587. this.remove(range);
  5588. }
  5589. };
  5590. this.revertDeltas = function(deltas) {
  5591. for (var i=deltas.length-1; i>=0; i--) {
  5592. var delta = deltas[i];
  5593. var range = Range.fromPoints(delta.range.start, delta.range.end);
  5594. if (delta.action == "insertLines")
  5595. this._removeLines(range.start.row, range.end.row - 1);
  5596. else if (delta.action == "insertText")
  5597. this.remove(range);
  5598. else if (delta.action == "removeLines")
  5599. this._insertLines(range.start.row, delta.lines);
  5600. else if (delta.action == "removeText")
  5601. this.insert(range.start, delta.text);
  5602. }
  5603. };
  5604. this.indexToPosition = function(index, startRow) {
  5605. var lines = this.$lines || this.getAllLines();
  5606. var newlineLength = this.getNewLineCharacter().length;
  5607. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  5608. index -= lines[i].length + newlineLength;
  5609. if (index < 0)
  5610. return {row: i, column: index + lines[i].length + newlineLength};
  5611. }
  5612. return {row: l-1, column: lines[l-1].length};
  5613. };
  5614. this.positionToIndex = function(pos, startRow) {
  5615. var lines = this.$lines || this.getAllLines();
  5616. var newlineLength = this.getNewLineCharacter().length;
  5617. var index = 0;
  5618. var row = Math.min(pos.row, lines.length);
  5619. for (var i = startRow || 0; i < row; ++i)
  5620. index += lines[i].length + newlineLength;
  5621. return index + pos.column;
  5622. };
  5623. }).call(Document.prototype);
  5624. exports.Document = Document;
  5625. });
  5626. ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5627. "use strict";
  5628. var oop = require("./lib/oop");
  5629. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5630. var BackgroundTokenizer = function(tokenizer, editor) {
  5631. this.running = false;
  5632. this.lines = [];
  5633. this.states = [];
  5634. this.currentLine = 0;
  5635. this.tokenizer = tokenizer;
  5636. var self = this;
  5637. this.$worker = function() {
  5638. if (!self.running) { return; }
  5639. var workerStart = new Date();
  5640. var currentLine = self.currentLine;
  5641. var endLine = -1;
  5642. var doc = self.doc;
  5643. while (self.lines[currentLine])
  5644. currentLine++;
  5645. var startLine = currentLine;
  5646. var len = doc.getLength();
  5647. var processedLines = 0;
  5648. self.running = false;
  5649. while (currentLine < len) {
  5650. self.$tokenizeRow(currentLine);
  5651. endLine = currentLine;
  5652. do {
  5653. currentLine++;
  5654. } while (self.lines[currentLine]);
  5655. processedLines ++;
  5656. if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
  5657. self.running = setTimeout(self.$worker, 20);
  5658. break;
  5659. }
  5660. }
  5661. self.currentLine = currentLine;
  5662. if (startLine <= endLine)
  5663. self.fireUpdateEvent(startLine, endLine);
  5664. };
  5665. };
  5666. (function(){
  5667. oop.implement(this, EventEmitter);
  5668. this.setTokenizer = function(tokenizer) {
  5669. this.tokenizer = tokenizer;
  5670. this.lines = [];
  5671. this.states = [];
  5672. this.start(0);
  5673. };
  5674. this.setDocument = function(doc) {
  5675. this.doc = doc;
  5676. this.lines = [];
  5677. this.states = [];
  5678. this.stop();
  5679. };
  5680. this.fireUpdateEvent = function(firstRow, lastRow) {
  5681. var data = {
  5682. first: firstRow,
  5683. last: lastRow
  5684. };
  5685. this._signal("update", {data: data});
  5686. };
  5687. this.start = function(startRow) {
  5688. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  5689. this.lines.splice(this.currentLine, this.lines.length);
  5690. this.states.splice(this.currentLine, this.states.length);
  5691. this.stop();
  5692. this.running = setTimeout(this.$worker, 700);
  5693. };
  5694. this.scheduleStart = function() {
  5695. if (!this.running)
  5696. this.running = setTimeout(this.$worker, 700);
  5697. }
  5698. this.$updateOnChange = function(delta) {
  5699. var range = delta.range;
  5700. var startRow = range.start.row;
  5701. var len = range.end.row - startRow;
  5702. if (len === 0) {
  5703. this.lines[startRow] = null;
  5704. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  5705. this.lines.splice(startRow, len + 1, null);
  5706. this.states.splice(startRow, len + 1, null);
  5707. } else {
  5708. var args = Array(len + 1);
  5709. args.unshift(startRow, 1);
  5710. this.lines.splice.apply(this.lines, args);
  5711. this.states.splice.apply(this.states, args);
  5712. }
  5713. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  5714. this.stop();
  5715. };
  5716. this.stop = function() {
  5717. if (this.running)
  5718. clearTimeout(this.running);
  5719. this.running = false;
  5720. };
  5721. this.getTokens = function(row) {
  5722. return this.lines[row] || this.$tokenizeRow(row);
  5723. };
  5724. this.getState = function(row) {
  5725. if (this.currentLine == row)
  5726. this.$tokenizeRow(row);
  5727. return this.states[row] || "start";
  5728. };
  5729. this.$tokenizeRow = function(row) {
  5730. var line = this.doc.getLine(row);
  5731. var state = this.states[row - 1];
  5732. var data = this.tokenizer.getLineTokens(line, state, row);
  5733. if (this.states[row] + "" !== data.state + "") {
  5734. this.states[row] = data.state;
  5735. this.lines[row + 1] = null;
  5736. if (this.currentLine > row + 1)
  5737. this.currentLine = row + 1;
  5738. } else if (this.currentLine == row) {
  5739. this.currentLine = row + 1;
  5740. }
  5741. return this.lines[row] = data.tokens;
  5742. };
  5743. }).call(BackgroundTokenizer.prototype);
  5744. exports.BackgroundTokenizer = BackgroundTokenizer;
  5745. });
  5746. ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  5747. "use strict";
  5748. var lang = require("./lib/lang");
  5749. var oop = require("./lib/oop");
  5750. var Range = require("./range").Range;
  5751. var SearchHighlight = function(regExp, clazz, type) {
  5752. this.setRegexp(regExp);
  5753. this.clazz = clazz;
  5754. this.type = type || "text";
  5755. };
  5756. (function() {
  5757. this.MAX_RANGES = 500;
  5758. this.setRegexp = function(regExp) {
  5759. if (this.regExp+"" == regExp+"")
  5760. return;
  5761. this.regExp = regExp;
  5762. this.cache = [];
  5763. };
  5764. this.update = function(html, markerLayer, session, config) {
  5765. if (!this.regExp)
  5766. return;
  5767. var start = config.firstRow, end = config.lastRow;
  5768. for (var i = start; i <= end; i++) {
  5769. var ranges = this.cache[i];
  5770. if (ranges == null) {
  5771. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  5772. if (ranges.length > this.MAX_RANGES)
  5773. ranges = ranges.slice(0, this.MAX_RANGES);
  5774. ranges = ranges.map(function(match) {
  5775. return new Range(i, match.offset, i, match.offset + match.length);
  5776. });
  5777. this.cache[i] = ranges.length ? ranges : "";
  5778. }
  5779. for (var j = ranges.length; j --; ) {
  5780. markerLayer.drawSingleLineMarker(
  5781. html, ranges[j].toScreenRange(session), this.clazz, config);
  5782. }
  5783. }
  5784. };
  5785. }).call(SearchHighlight.prototype);
  5786. exports.SearchHighlight = SearchHighlight;
  5787. });
  5788. ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
  5789. "use strict";
  5790. var Range = require("../range").Range;
  5791. function FoldLine(foldData, folds) {
  5792. this.foldData = foldData;
  5793. if (Array.isArray(folds)) {
  5794. this.folds = folds;
  5795. } else {
  5796. folds = this.folds = [ folds ];
  5797. }
  5798. var last = folds[folds.length - 1];
  5799. this.range = new Range(folds[0].start.row, folds[0].start.column,
  5800. last.end.row, last.end.column);
  5801. this.start = this.range.start;
  5802. this.end = this.range.end;
  5803. this.folds.forEach(function(fold) {
  5804. fold.setFoldLine(this);
  5805. }, this);
  5806. }
  5807. (function() {
  5808. this.shiftRow = function(shift) {
  5809. this.start.row += shift;
  5810. this.end.row += shift;
  5811. this.folds.forEach(function(fold) {
  5812. fold.start.row += shift;
  5813. fold.end.row += shift;
  5814. });
  5815. };
  5816. this.addFold = function(fold) {
  5817. if (fold.sameRow) {
  5818. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  5819. throw new Error("Can't add a fold to this FoldLine as it has no connection");
  5820. }
  5821. this.folds.push(fold);
  5822. this.folds.sort(function(a, b) {
  5823. return -a.range.compareEnd(b.start.row, b.start.column);
  5824. });
  5825. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  5826. this.end.row = fold.end.row;
  5827. this.end.column = fold.end.column;
  5828. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  5829. this.start.row = fold.start.row;
  5830. this.start.column = fold.start.column;
  5831. }
  5832. } else if (fold.start.row == this.end.row) {
  5833. this.folds.push(fold);
  5834. this.end.row = fold.end.row;
  5835. this.end.column = fold.end.column;
  5836. } else if (fold.end.row == this.start.row) {
  5837. this.folds.unshift(fold);
  5838. this.start.row = fold.start.row;
  5839. this.start.column = fold.start.column;
  5840. } else {
  5841. throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
  5842. }
  5843. fold.foldLine = this;
  5844. };
  5845. this.containsRow = function(row) {
  5846. return row >= this.start.row && row <= this.end.row;
  5847. };
  5848. this.walk = function(callback, endRow, endColumn) {
  5849. var lastEnd = 0,
  5850. folds = this.folds,
  5851. fold,
  5852. cmp, stop, isNewRow = true;
  5853. if (endRow == null) {
  5854. endRow = this.end.row;
  5855. endColumn = this.end.column;
  5856. }
  5857. for (var i = 0; i < folds.length; i++) {
  5858. fold = folds[i];
  5859. cmp = fold.range.compareStart(endRow, endColumn);
  5860. if (cmp == -1) {
  5861. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5862. return;
  5863. }
  5864. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  5865. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  5866. if (stop || cmp === 0) {
  5867. return;
  5868. }
  5869. isNewRow = !fold.sameRow;
  5870. lastEnd = fold.end.column;
  5871. }
  5872. callback(null, endRow, endColumn, lastEnd, isNewRow);
  5873. };
  5874. this.getNextFoldTo = function(row, column) {
  5875. var fold, cmp;
  5876. for (var i = 0; i < this.folds.length; i++) {
  5877. fold = this.folds[i];
  5878. cmp = fold.range.compareEnd(row, column);
  5879. if (cmp == -1) {
  5880. return {
  5881. fold: fold,
  5882. kind: "after"
  5883. };
  5884. } else if (cmp === 0) {
  5885. return {
  5886. fold: fold,
  5887. kind: "inside"
  5888. };
  5889. }
  5890. }
  5891. return null;
  5892. };
  5893. this.addRemoveChars = function(row, column, len) {
  5894. var ret = this.getNextFoldTo(row, column),
  5895. fold, folds;
  5896. if (ret) {
  5897. fold = ret.fold;
  5898. if (ret.kind == "inside"
  5899. && fold.start.column != column
  5900. && fold.start.row != row)
  5901. {
  5902. window.console && window.console.log(row, column, fold);
  5903. } else if (fold.start.row == row) {
  5904. folds = this.folds;
  5905. var i = folds.indexOf(fold);
  5906. if (i === 0) {
  5907. this.start.column += len;
  5908. }
  5909. for (i; i < folds.length; i++) {
  5910. fold = folds[i];
  5911. fold.start.column += len;
  5912. if (!fold.sameRow) {
  5913. return;
  5914. }
  5915. fold.end.column += len;
  5916. }
  5917. this.end.column += len;
  5918. }
  5919. }
  5920. };
  5921. this.split = function(row, column) {
  5922. var pos = this.getNextFoldTo(row, column);
  5923. if (!pos || pos.kind == "inside")
  5924. return null;
  5925. var fold = pos.fold;
  5926. var folds = this.folds;
  5927. var foldData = this.foldData;
  5928. var i = folds.indexOf(fold);
  5929. var foldBefore = folds[i - 1];
  5930. this.end.row = foldBefore.end.row;
  5931. this.end.column = foldBefore.end.column;
  5932. folds = folds.splice(i, folds.length - i);
  5933. var newFoldLine = new FoldLine(foldData, folds);
  5934. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  5935. return newFoldLine;
  5936. };
  5937. this.merge = function(foldLineNext) {
  5938. var folds = foldLineNext.folds;
  5939. for (var i = 0; i < folds.length; i++) {
  5940. this.addFold(folds[i]);
  5941. }
  5942. var foldData = this.foldData;
  5943. foldData.splice(foldData.indexOf(foldLineNext), 1);
  5944. };
  5945. this.toString = function() {
  5946. var ret = [this.range.toString() + ": [" ];
  5947. this.folds.forEach(function(fold) {
  5948. ret.push(" " + fold.toString());
  5949. });
  5950. ret.push("]");
  5951. return ret.join("\n");
  5952. };
  5953. this.idxToPosition = function(idx) {
  5954. var lastFoldEndColumn = 0;
  5955. for (var i = 0; i < this.folds.length; i++) {
  5956. var fold = this.folds[i];
  5957. idx -= fold.start.column - lastFoldEndColumn;
  5958. if (idx < 0) {
  5959. return {
  5960. row: fold.start.row,
  5961. column: fold.start.column + idx
  5962. };
  5963. }
  5964. idx -= fold.placeholder.length;
  5965. if (idx < 0) {
  5966. return fold.start;
  5967. }
  5968. lastFoldEndColumn = fold.end.column;
  5969. }
  5970. return {
  5971. row: this.end.row,
  5972. column: this.end.column + idx
  5973. };
  5974. };
  5975. }).call(FoldLine.prototype);
  5976. exports.FoldLine = FoldLine;
  5977. });
  5978. ace.define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
  5979. "use strict";
  5980. var Range = require("./range").Range;
  5981. var comparePoints = Range.comparePoints;
  5982. var RangeList = function() {
  5983. this.ranges = [];
  5984. };
  5985. (function() {
  5986. this.comparePoints = comparePoints;
  5987. this.pointIndex = function(pos, excludeEdges, startIndex) {
  5988. var list = this.ranges;
  5989. for (var i = startIndex || 0; i < list.length; i++) {
  5990. var range = list[i];
  5991. var cmpEnd = comparePoints(pos, range.end);
  5992. if (cmpEnd > 0)
  5993. continue;
  5994. var cmpStart = comparePoints(pos, range.start);
  5995. if (cmpEnd === 0)
  5996. return excludeEdges && cmpStart !== 0 ? -i-2 : i;
  5997. if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
  5998. return i;
  5999. return -i-1;
  6000. }
  6001. return -i - 1;
  6002. };
  6003. this.add = function(range) {
  6004. var excludeEdges = !range.isEmpty();
  6005. var startIndex = this.pointIndex(range.start, excludeEdges);
  6006. if (startIndex < 0)
  6007. startIndex = -startIndex - 1;
  6008. var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
  6009. if (endIndex < 0)
  6010. endIndex = -endIndex - 1;
  6011. else
  6012. endIndex++;
  6013. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  6014. };
  6015. this.addList = function(list) {
  6016. var removed = [];
  6017. for (var i = list.length; i--; ) {
  6018. removed.push.call(removed, this.add(list[i]));
  6019. }
  6020. return removed;
  6021. };
  6022. this.substractPoint = function(pos) {
  6023. var i = this.pointIndex(pos);
  6024. if (i >= 0)
  6025. return this.ranges.splice(i, 1);
  6026. };
  6027. this.merge = function() {
  6028. var removed = [];
  6029. var list = this.ranges;
  6030. list = list.sort(function(a, b) {
  6031. return comparePoints(a.start, b.start);
  6032. });
  6033. var next = list[0], range;
  6034. for (var i = 1; i < list.length; i++) {
  6035. range = next;
  6036. next = list[i];
  6037. var cmp = comparePoints(range.end, next.start);
  6038. if (cmp < 0)
  6039. continue;
  6040. if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
  6041. continue;
  6042. if (comparePoints(range.end, next.end) < 0) {
  6043. range.end.row = next.end.row;
  6044. range.end.column = next.end.column;
  6045. }
  6046. list.splice(i, 1);
  6047. removed.push(next);
  6048. next = range;
  6049. i--;
  6050. }
  6051. this.ranges = list;
  6052. return removed;
  6053. };
  6054. this.contains = function(row, column) {
  6055. return this.pointIndex({row: row, column: column}) >= 0;
  6056. };
  6057. this.containsPoint = function(pos) {
  6058. return this.pointIndex(pos) >= 0;
  6059. };
  6060. this.rangeAtPoint = function(pos) {
  6061. var i = this.pointIndex(pos);
  6062. if (i >= 0)
  6063. return this.ranges[i];
  6064. };
  6065. this.clipRows = function(startRow, endRow) {
  6066. var list = this.ranges;
  6067. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  6068. return [];
  6069. var startIndex = this.pointIndex({row: startRow, column: 0});
  6070. if (startIndex < 0)
  6071. startIndex = -startIndex - 1;
  6072. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  6073. if (endIndex < 0)
  6074. endIndex = -endIndex - 1;
  6075. var clipped = [];
  6076. for (var i = startIndex; i < endIndex; i++) {
  6077. clipped.push(list[i]);
  6078. }
  6079. return clipped;
  6080. };
  6081. this.removeAll = function() {
  6082. return this.ranges.splice(0, this.ranges.length);
  6083. };
  6084. this.attach = function(session) {
  6085. if (this.session)
  6086. this.detach();
  6087. this.session = session;
  6088. this.onChange = this.$onChange.bind(this);
  6089. this.session.on('change', this.onChange);
  6090. };
  6091. this.detach = function() {
  6092. if (!this.session)
  6093. return;
  6094. this.session.removeListener('change', this.onChange);
  6095. this.session = null;
  6096. };
  6097. this.$onChange = function(e) {
  6098. var changeRange = e.data.range;
  6099. if (e.data.action[0] == "i"){
  6100. var start = changeRange.start;
  6101. var end = changeRange.end;
  6102. } else {
  6103. var end = changeRange.start;
  6104. var start = changeRange.end;
  6105. }
  6106. var startRow = start.row;
  6107. var endRow = end.row;
  6108. var lineDif = endRow - startRow;
  6109. var colDiff = -start.column + end.column;
  6110. var ranges = this.ranges;
  6111. for (var i = 0, n = ranges.length; i < n; i++) {
  6112. var r = ranges[i];
  6113. if (r.end.row < startRow)
  6114. continue;
  6115. if (r.start.row > startRow)
  6116. break;
  6117. if (r.start.row == startRow && r.start.column >= start.column ) {
  6118. if (r.start.column == start.column && this.$insertRight) {
  6119. } else {
  6120. r.start.column += colDiff;
  6121. r.start.row += lineDif;
  6122. }
  6123. }
  6124. if (r.end.row == startRow && r.end.column >= start.column) {
  6125. if (r.end.column == start.column && this.$insertRight) {
  6126. continue;
  6127. }
  6128. if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
  6129. if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
  6130. r.end.column -= colDiff;
  6131. }
  6132. r.end.column += colDiff;
  6133. r.end.row += lineDif;
  6134. }
  6135. }
  6136. if (lineDif != 0 && i < n) {
  6137. for (; i < n; i++) {
  6138. var r = ranges[i];
  6139. r.start.row += lineDif;
  6140. r.end.row += lineDif;
  6141. }
  6142. }
  6143. };
  6144. }).call(RangeList.prototype);
  6145. exports.RangeList = RangeList;
  6146. });
  6147. ace.define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
  6148. "use strict";
  6149. var Range = require("../range").Range;
  6150. var RangeList = require("../range_list").RangeList;
  6151. var oop = require("../lib/oop")
  6152. var Fold = exports.Fold = function(range, placeholder) {
  6153. this.foldLine = null;
  6154. this.placeholder = placeholder;
  6155. this.range = range;
  6156. this.start = range.start;
  6157. this.end = range.end;
  6158. this.sameRow = range.start.row == range.end.row;
  6159. this.subFolds = this.ranges = [];
  6160. };
  6161. oop.inherits(Fold, RangeList);
  6162. (function() {
  6163. this.toString = function() {
  6164. return '"' + this.placeholder + '" ' + this.range.toString();
  6165. };
  6166. this.setFoldLine = function(foldLine) {
  6167. this.foldLine = foldLine;
  6168. this.subFolds.forEach(function(fold) {
  6169. fold.setFoldLine(foldLine);
  6170. });
  6171. };
  6172. this.clone = function() {
  6173. var range = this.range.clone();
  6174. var fold = new Fold(range, this.placeholder);
  6175. this.subFolds.forEach(function(subFold) {
  6176. fold.subFolds.push(subFold.clone());
  6177. });
  6178. fold.collapseChildren = this.collapseChildren;
  6179. return fold;
  6180. };
  6181. this.addSubFold = function(fold) {
  6182. if (this.range.isEqual(fold))
  6183. return;
  6184. if (!this.range.containsRange(fold))
  6185. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6186. consumeRange(fold, this.start);
  6187. var row = fold.start.row, column = fold.start.column;
  6188. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  6189. cmp = this.subFolds[i].range.compare(row, column);
  6190. if (cmp != 1)
  6191. break;
  6192. }
  6193. var afterStart = this.subFolds[i];
  6194. if (cmp == 0)
  6195. return afterStart.addSubFold(fold);
  6196. var row = fold.range.end.row, column = fold.range.end.column;
  6197. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  6198. cmp = this.subFolds[j].range.compare(row, column);
  6199. if (cmp != 1)
  6200. break;
  6201. }
  6202. var afterEnd = this.subFolds[j];
  6203. if (cmp == 0)
  6204. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6205. var consumedFolds = this.subFolds.splice(i, j - i, fold);
  6206. fold.setFoldLine(this.foldLine);
  6207. return fold;
  6208. };
  6209. this.restoreRange = function(range) {
  6210. return restoreRange(range, this.start);
  6211. };
  6212. }).call(Fold.prototype);
  6213. function consumePoint(point, anchor) {
  6214. point.row -= anchor.row;
  6215. if (point.row == 0)
  6216. point.column -= anchor.column;
  6217. }
  6218. function consumeRange(range, anchor) {
  6219. consumePoint(range.start, anchor);
  6220. consumePoint(range.end, anchor);
  6221. }
  6222. function restorePoint(point, anchor) {
  6223. if (point.row == 0)
  6224. point.column += anchor.column;
  6225. point.row += anchor.row;
  6226. }
  6227. function restoreRange(range, anchor) {
  6228. restorePoint(range.start, anchor);
  6229. restorePoint(range.end, anchor);
  6230. }
  6231. });
  6232. 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) {
  6233. "use strict";
  6234. var Range = require("../range").Range;
  6235. var FoldLine = require("./fold_line").FoldLine;
  6236. var Fold = require("./fold").Fold;
  6237. var TokenIterator = require("../token_iterator").TokenIterator;
  6238. function Folding() {
  6239. this.getFoldAt = function(row, column, side) {
  6240. var foldLine = this.getFoldLine(row);
  6241. if (!foldLine)
  6242. return null;
  6243. var folds = foldLine.folds;
  6244. for (var i = 0; i < folds.length; i++) {
  6245. var fold = folds[i];
  6246. if (fold.range.contains(row, column)) {
  6247. if (side == 1 && fold.range.isEnd(row, column)) {
  6248. continue;
  6249. } else if (side == -1 && fold.range.isStart(row, column)) {
  6250. continue;
  6251. }
  6252. return fold;
  6253. }
  6254. }
  6255. };
  6256. this.getFoldsInRange = function(range) {
  6257. var start = range.start;
  6258. var end = range.end;
  6259. var foldLines = this.$foldData;
  6260. var foundFolds = [];
  6261. start.column += 1;
  6262. end.column -= 1;
  6263. for (var i = 0; i < foldLines.length; i++) {
  6264. var cmp = foldLines[i].range.compareRange(range);
  6265. if (cmp == 2) {
  6266. continue;
  6267. }
  6268. else if (cmp == -2) {
  6269. break;
  6270. }
  6271. var folds = foldLines[i].folds;
  6272. for (var j = 0; j < folds.length; j++) {
  6273. var fold = folds[j];
  6274. cmp = fold.range.compareRange(range);
  6275. if (cmp == -2) {
  6276. break;
  6277. } else if (cmp == 2) {
  6278. continue;
  6279. } else
  6280. if (cmp == 42) {
  6281. break;
  6282. }
  6283. foundFolds.push(fold);
  6284. }
  6285. }
  6286. start.column -= 1;
  6287. end.column += 1;
  6288. return foundFolds;
  6289. };
  6290. this.getFoldsInRangeList = function(ranges) {
  6291. if (Array.isArray(ranges)) {
  6292. var folds = [];
  6293. ranges.forEach(function(range) {
  6294. folds = folds.concat(this.getFoldsInRange(range));
  6295. }, this);
  6296. } else {
  6297. var folds = this.getFoldsInRange(ranges);
  6298. }
  6299. return folds;
  6300. }
  6301. this.getAllFolds = function() {
  6302. var folds = [];
  6303. var foldLines = this.$foldData;
  6304. for (var i = 0; i < foldLines.length; i++)
  6305. for (var j = 0; j < foldLines[i].folds.length; j++)
  6306. folds.push(foldLines[i].folds[j]);
  6307. return folds;
  6308. };
  6309. this.getFoldStringAt = function(row, column, trim, foldLine) {
  6310. foldLine = foldLine || this.getFoldLine(row);
  6311. if (!foldLine)
  6312. return null;
  6313. var lastFold = {
  6314. end: { column: 0 }
  6315. };
  6316. var str, fold;
  6317. for (var i = 0; i < foldLine.folds.length; i++) {
  6318. fold = foldLine.folds[i];
  6319. var cmp = fold.range.compareEnd(row, column);
  6320. if (cmp == -1) {
  6321. str = this
  6322. .getLine(fold.start.row)
  6323. .substring(lastFold.end.column, fold.start.column);
  6324. break;
  6325. }
  6326. else if (cmp === 0) {
  6327. return null;
  6328. }
  6329. lastFold = fold;
  6330. }
  6331. if (!str)
  6332. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  6333. if (trim == -1)
  6334. return str.substring(0, column - lastFold.end.column);
  6335. else if (trim == 1)
  6336. return str.substring(column - lastFold.end.column);
  6337. else
  6338. return str;
  6339. };
  6340. this.getFoldLine = function(docRow, startFoldLine) {
  6341. var foldData = this.$foldData;
  6342. var i = 0;
  6343. if (startFoldLine)
  6344. i = foldData.indexOf(startFoldLine);
  6345. if (i == -1)
  6346. i = 0;
  6347. for (i; i < foldData.length; i++) {
  6348. var foldLine = foldData[i];
  6349. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  6350. return foldLine;
  6351. } else if (foldLine.end.row > docRow) {
  6352. return null;
  6353. }
  6354. }
  6355. return null;
  6356. };
  6357. this.getNextFoldLine = function(docRow, startFoldLine) {
  6358. var foldData = this.$foldData;
  6359. var i = 0;
  6360. if (startFoldLine)
  6361. i = foldData.indexOf(startFoldLine);
  6362. if (i == -1)
  6363. i = 0;
  6364. for (i; i < foldData.length; i++) {
  6365. var foldLine = foldData[i];
  6366. if (foldLine.end.row >= docRow) {
  6367. return foldLine;
  6368. }
  6369. }
  6370. return null;
  6371. };
  6372. this.getFoldedRowCount = function(first, last) {
  6373. var foldData = this.$foldData, rowCount = last-first+1;
  6374. for (var i = 0; i < foldData.length; i++) {
  6375. var foldLine = foldData[i],
  6376. end = foldLine.end.row,
  6377. start = foldLine.start.row;
  6378. if (end >= last) {
  6379. if(start < last) {
  6380. if(start >= first)
  6381. rowCount -= last-start;
  6382. else
  6383. rowCount = 0;//in one fold
  6384. }
  6385. break;
  6386. } else if(end >= first){
  6387. if (start >= first) //fold inside range
  6388. rowCount -= end-start;
  6389. else
  6390. rowCount -= end-first+1;
  6391. }
  6392. }
  6393. return rowCount;
  6394. };
  6395. this.$addFoldLine = function(foldLine) {
  6396. this.$foldData.push(foldLine);
  6397. this.$foldData.sort(function(a, b) {
  6398. return a.start.row - b.start.row;
  6399. });
  6400. return foldLine;
  6401. };
  6402. this.addFold = function(placeholder, range) {
  6403. var foldData = this.$foldData;
  6404. var added = false;
  6405. var fold;
  6406. if (placeholder instanceof Fold)
  6407. fold = placeholder;
  6408. else {
  6409. fold = new Fold(range, placeholder);
  6410. fold.collapseChildren = range.collapseChildren;
  6411. }
  6412. this.$clipRangeToDocument(fold.range);
  6413. var startRow = fold.start.row;
  6414. var startColumn = fold.start.column;
  6415. var endRow = fold.end.row;
  6416. var endColumn = fold.end.column;
  6417. if (!(startRow < endRow ||
  6418. startRow == endRow && startColumn <= endColumn - 2))
  6419. throw new Error("The range has to be at least 2 characters width");
  6420. var startFold = this.getFoldAt(startRow, startColumn, 1);
  6421. var endFold = this.getFoldAt(endRow, endColumn, -1);
  6422. if (startFold && endFold == startFold)
  6423. return startFold.addSubFold(fold);
  6424. if (startFold && !startFold.range.isStart(startRow, startColumn))
  6425. this.removeFold(startFold);
  6426. if (endFold && !endFold.range.isEnd(endRow, endColumn))
  6427. this.removeFold(endFold);
  6428. var folds = this.getFoldsInRange(fold.range);
  6429. if (folds.length > 0) {
  6430. this.removeFolds(folds);
  6431. folds.forEach(function(subFold) {
  6432. fold.addSubFold(subFold);
  6433. });
  6434. }
  6435. for (var i = 0; i < foldData.length; i++) {
  6436. var foldLine = foldData[i];
  6437. if (endRow == foldLine.start.row) {
  6438. foldLine.addFold(fold);
  6439. added = true;
  6440. break;
  6441. } else if (startRow == foldLine.end.row) {
  6442. foldLine.addFold(fold);
  6443. added = true;
  6444. if (!fold.sameRow) {
  6445. var foldLineNext = foldData[i + 1];
  6446. if (foldLineNext && foldLineNext.start.row == endRow) {
  6447. foldLine.merge(foldLineNext);
  6448. break;
  6449. }
  6450. }
  6451. break;
  6452. } else if (endRow <= foldLine.start.row) {
  6453. break;
  6454. }
  6455. }
  6456. if (!added)
  6457. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  6458. if (this.$useWrapMode)
  6459. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  6460. else
  6461. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  6462. this.$modified = true;
  6463. this._emit("changeFold", { data: fold, action: "add" });
  6464. return fold;
  6465. };
  6466. this.addFolds = function(folds) {
  6467. folds.forEach(function(fold) {
  6468. this.addFold(fold);
  6469. }, this);
  6470. };
  6471. this.removeFold = function(fold) {
  6472. var foldLine = fold.foldLine;
  6473. var startRow = foldLine.start.row;
  6474. var endRow = foldLine.end.row;
  6475. var foldLines = this.$foldData;
  6476. var folds = foldLine.folds;
  6477. if (folds.length == 1) {
  6478. foldLines.splice(foldLines.indexOf(foldLine), 1);
  6479. } else
  6480. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  6481. folds.pop();
  6482. foldLine.end.row = folds[folds.length - 1].end.row;
  6483. foldLine.end.column = folds[folds.length - 1].end.column;
  6484. } else
  6485. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  6486. folds.shift();
  6487. foldLine.start.row = folds[0].start.row;
  6488. foldLine.start.column = folds[0].start.column;
  6489. } else
  6490. if (fold.sameRow) {
  6491. folds.splice(folds.indexOf(fold), 1);
  6492. } else
  6493. {
  6494. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  6495. folds = newFoldLine.folds;
  6496. folds.shift();
  6497. newFoldLine.start.row = folds[0].start.row;
  6498. newFoldLine.start.column = folds[0].start.column;
  6499. }
  6500. if (!this.$updating) {
  6501. if (this.$useWrapMode)
  6502. this.$updateWrapData(startRow, endRow);
  6503. else
  6504. this.$updateRowLengthCache(startRow, endRow);
  6505. }
  6506. this.$modified = true;
  6507. this._emit("changeFold", { data: fold, action: "remove" });
  6508. };
  6509. this.removeFolds = function(folds) {
  6510. var cloneFolds = [];
  6511. for (var i = 0; i < folds.length; i++) {
  6512. cloneFolds.push(folds[i]);
  6513. }
  6514. cloneFolds.forEach(function(fold) {
  6515. this.removeFold(fold);
  6516. }, this);
  6517. this.$modified = true;
  6518. };
  6519. this.expandFold = function(fold) {
  6520. this.removeFold(fold);
  6521. fold.subFolds.forEach(function(subFold) {
  6522. fold.restoreRange(subFold);
  6523. this.addFold(subFold);
  6524. }, this);
  6525. if (fold.collapseChildren > 0) {
  6526. this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
  6527. }
  6528. fold.subFolds = [];
  6529. };
  6530. this.expandFolds = function(folds) {
  6531. folds.forEach(function(fold) {
  6532. this.expandFold(fold);
  6533. }, this);
  6534. };
  6535. this.unfold = function(location, expandInner) {
  6536. var range, folds;
  6537. if (location == null) {
  6538. range = new Range(0, 0, this.getLength(), 0);
  6539. expandInner = true;
  6540. } else if (typeof location == "number")
  6541. range = new Range(location, 0, location, this.getLine(location).length);
  6542. else if ("row" in location)
  6543. range = Range.fromPoints(location, location);
  6544. else
  6545. range = location;
  6546. folds = this.getFoldsInRangeList(range);
  6547. if (expandInner) {
  6548. this.removeFolds(folds);
  6549. } else {
  6550. var subFolds = folds;
  6551. while (subFolds.length) {
  6552. this.expandFolds(subFolds);
  6553. subFolds = this.getFoldsInRangeList(range);
  6554. }
  6555. }
  6556. if (folds.length)
  6557. return folds;
  6558. };
  6559. this.isRowFolded = function(docRow, startFoldRow) {
  6560. return !!this.getFoldLine(docRow, startFoldRow);
  6561. };
  6562. this.getRowFoldEnd = function(docRow, startFoldRow) {
  6563. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6564. return foldLine ? foldLine.end.row : docRow;
  6565. };
  6566. this.getRowFoldStart = function(docRow, startFoldRow) {
  6567. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6568. return foldLine ? foldLine.start.row : docRow;
  6569. };
  6570. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  6571. if (startRow == null)
  6572. startRow = foldLine.start.row;
  6573. if (startColumn == null)
  6574. startColumn = 0;
  6575. if (endRow == null)
  6576. endRow = foldLine.end.row;
  6577. if (endColumn == null)
  6578. endColumn = this.getLine(endRow).length;
  6579. var doc = this.doc;
  6580. var textLine = "";
  6581. foldLine.walk(function(placeholder, row, column, lastColumn) {
  6582. if (row < startRow)
  6583. return;
  6584. if (row == startRow) {
  6585. if (column < startColumn)
  6586. return;
  6587. lastColumn = Math.max(startColumn, lastColumn);
  6588. }
  6589. if (placeholder != null) {
  6590. textLine += placeholder;
  6591. } else {
  6592. textLine += doc.getLine(row).substring(lastColumn, column);
  6593. }
  6594. }, endRow, endColumn);
  6595. return textLine;
  6596. };
  6597. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  6598. var foldLine = this.getFoldLine(row);
  6599. if (!foldLine) {
  6600. var line;
  6601. line = this.doc.getLine(row);
  6602. return line.substring(startColumn || 0, endColumn || line.length);
  6603. } else {
  6604. return this.getFoldDisplayLine(
  6605. foldLine, row, endColumn, startRow, startColumn);
  6606. }
  6607. };
  6608. this.$cloneFoldData = function() {
  6609. var fd = [];
  6610. fd = this.$foldData.map(function(foldLine) {
  6611. var folds = foldLine.folds.map(function(fold) {
  6612. return fold.clone();
  6613. });
  6614. return new FoldLine(fd, folds);
  6615. });
  6616. return fd;
  6617. };
  6618. this.toggleFold = function(tryToUnfold) {
  6619. var selection = this.selection;
  6620. var range = selection.getRange();
  6621. var fold;
  6622. var bracketPos;
  6623. if (range.isEmpty()) {
  6624. var cursor = range.start;
  6625. fold = this.getFoldAt(cursor.row, cursor.column);
  6626. if (fold) {
  6627. this.expandFold(fold);
  6628. return;
  6629. } else if (bracketPos = this.findMatchingBracket(cursor)) {
  6630. if (range.comparePoint(bracketPos) == 1) {
  6631. range.end = bracketPos;
  6632. } else {
  6633. range.start = bracketPos;
  6634. range.start.column++;
  6635. range.end.column--;
  6636. }
  6637. } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  6638. if (range.comparePoint(bracketPos) == 1)
  6639. range.end = bracketPos;
  6640. else
  6641. range.start = bracketPos;
  6642. range.start.column++;
  6643. } else {
  6644. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  6645. }
  6646. } else {
  6647. var folds = this.getFoldsInRange(range);
  6648. if (tryToUnfold && folds.length) {
  6649. this.expandFolds(folds);
  6650. return;
  6651. } else if (folds.length == 1 ) {
  6652. fold = folds[0];
  6653. }
  6654. }
  6655. if (!fold)
  6656. fold = this.getFoldAt(range.start.row, range.start.column);
  6657. if (fold && fold.range.toString() == range.toString()) {
  6658. this.expandFold(fold);
  6659. return;
  6660. }
  6661. var placeholder = "...";
  6662. if (!range.isMultiLine()) {
  6663. placeholder = this.getTextRange(range);
  6664. if(placeholder.length < 4)
  6665. return;
  6666. placeholder = placeholder.trim().substring(0, 2) + "..";
  6667. }
  6668. this.addFold(placeholder, range);
  6669. };
  6670. this.getCommentFoldRange = function(row, column, dir) {
  6671. var iterator = new TokenIterator(this, row, column);
  6672. var token = iterator.getCurrentToken();
  6673. if (token && /^comment|string/.test(token.type)) {
  6674. var range = new Range();
  6675. var re = new RegExp(token.type.replace(/\..*/, "\\."));
  6676. if (dir != 1) {
  6677. do {
  6678. token = iterator.stepBackward();
  6679. } while(token && re.test(token.type));
  6680. iterator.stepForward();
  6681. }
  6682. range.start.row = iterator.getCurrentTokenRow();
  6683. range.start.column = iterator.getCurrentTokenColumn() + 2;
  6684. iterator = new TokenIterator(this, row, column);
  6685. if (dir != -1) {
  6686. do {
  6687. token = iterator.stepForward();
  6688. } while(token && re.test(token.type));
  6689. token = iterator.stepBackward();
  6690. } else
  6691. token = iterator.getCurrentToken();
  6692. range.end.row = iterator.getCurrentTokenRow();
  6693. range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
  6694. return range;
  6695. }
  6696. };
  6697. this.foldAll = function(startRow, endRow, depth) {
  6698. if (depth == undefined)
  6699. depth = 100000; // JSON.stringify doesn't hanle Infinity
  6700. var foldWidgets = this.foldWidgets;
  6701. if (!foldWidgets)
  6702. return; // mode doesn't support folding
  6703. endRow = endRow || this.getLength();
  6704. startRow = startRow || 0;
  6705. for (var row = startRow; row < endRow; row++) {
  6706. if (foldWidgets[row] == null)
  6707. foldWidgets[row] = this.getFoldWidget(row);
  6708. if (foldWidgets[row] != "start")
  6709. continue;
  6710. var range = this.getFoldWidgetRange(row);
  6711. if (range && range.isMultiLine()
  6712. && range.end.row <= endRow
  6713. && range.start.row >= startRow
  6714. ) {
  6715. row = range.end.row;
  6716. try {
  6717. var fold = this.addFold("...", range);
  6718. if (fold)
  6719. fold.collapseChildren = depth;
  6720. } catch(e) {}
  6721. }
  6722. }
  6723. };
  6724. this.$foldStyles = {
  6725. "manual": 1,
  6726. "markbegin": 1,
  6727. "markbeginend": 1
  6728. };
  6729. this.$foldStyle = "markbegin";
  6730. this.setFoldStyle = function(style) {
  6731. if (!this.$foldStyles[style])
  6732. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  6733. if (this.$foldStyle == style)
  6734. return;
  6735. this.$foldStyle = style;
  6736. if (style == "manual")
  6737. this.unfold();
  6738. var mode = this.$foldMode;
  6739. this.$setFolding(null);
  6740. this.$setFolding(mode);
  6741. };
  6742. this.$setFolding = function(foldMode) {
  6743. if (this.$foldMode == foldMode)
  6744. return;
  6745. this.$foldMode = foldMode;
  6746. this.off('change', this.$updateFoldWidgets);
  6747. this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6748. this._emit("changeAnnotation");
  6749. if (!foldMode || this.$foldStyle == "manual") {
  6750. this.foldWidgets = null;
  6751. return;
  6752. }
  6753. this.foldWidgets = [];
  6754. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  6755. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  6756. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  6757. this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
  6758. this.on('change', this.$updateFoldWidgets);
  6759. this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6760. };
  6761. this.getParentFoldRangeData = function (row, ignoreCurrent) {
  6762. var fw = this.foldWidgets;
  6763. if (!fw || (ignoreCurrent && fw[row]))
  6764. return {};
  6765. var i = row - 1, firstRange;
  6766. while (i >= 0) {
  6767. var c = fw[i];
  6768. if (c == null)
  6769. c = fw[i] = this.getFoldWidget(i);
  6770. if (c == "start") {
  6771. var range = this.getFoldWidgetRange(i);
  6772. if (!firstRange)
  6773. firstRange = range;
  6774. if (range && range.end.row >= row)
  6775. break;
  6776. }
  6777. i--;
  6778. }
  6779. return {
  6780. range: i !== -1 && range,
  6781. firstRange: firstRange
  6782. };
  6783. }
  6784. this.onFoldWidgetClick = function(row, e) {
  6785. e = e.domEvent;
  6786. var options = {
  6787. children: e.shiftKey,
  6788. all: e.ctrlKey || e.metaKey,
  6789. siblings: e.altKey
  6790. };
  6791. var range = this.$toggleFoldWidget(row, options);
  6792. if (!range) {
  6793. var el = (e.target || e.srcElement)
  6794. if (el && /ace_fold-widget/.test(el.className))
  6795. el.className += " ace_invalid";
  6796. }
  6797. };
  6798. this.$toggleFoldWidget = function(row, options) {
  6799. if (!this.getFoldWidget)
  6800. return;
  6801. var type = this.getFoldWidget(row);
  6802. var line = this.getLine(row);
  6803. var dir = type === "end" ? -1 : 1;
  6804. var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
  6805. if (fold) {
  6806. if (options.children || options.all)
  6807. this.removeFold(fold);
  6808. else
  6809. this.expandFold(fold);
  6810. return;
  6811. }
  6812. var range = this.getFoldWidgetRange(row, true);
  6813. if (range && !range.isMultiLine()) {
  6814. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  6815. if (fold && range.isEqual(fold.range)) {
  6816. this.removeFold(fold);
  6817. return;
  6818. }
  6819. }
  6820. if (options.siblings) {
  6821. var data = this.getParentFoldRangeData(row);
  6822. if (data.range) {
  6823. var startRow = data.range.start.row + 1;
  6824. var endRow = data.range.end.row;
  6825. }
  6826. this.foldAll(startRow, endRow, options.all ? 10000 : 0);
  6827. } else if (options.children) {
  6828. endRow = range ? range.end.row : this.getLength();
  6829. this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
  6830. } else if (range) {
  6831. if (options.all)
  6832. range.collapseChildren = 10000;
  6833. this.addFold("...", range);
  6834. }
  6835. return range;
  6836. };
  6837. this.toggleFoldWidget = function(toggleParent) {
  6838. var row = this.selection.getCursor().row;
  6839. row = this.getRowFoldStart(row);
  6840. var range = this.$toggleFoldWidget(row, {});
  6841. if (range)
  6842. return;
  6843. var data = this.getParentFoldRangeData(row, true);
  6844. range = data.range || data.firstRange;
  6845. if (range) {
  6846. row = range.start.row;
  6847. var fold = this.getFoldAt(row, this.getLine(row).length, 1);
  6848. if (fold) {
  6849. this.removeFold(fold);
  6850. } else {
  6851. this.addFold("...", range);
  6852. }
  6853. }
  6854. };
  6855. this.updateFoldWidgets = function(e) {
  6856. var delta = e.data;
  6857. var range = delta.range;
  6858. var firstRow = range.start.row;
  6859. var len = range.end.row - firstRow;
  6860. if (len === 0) {
  6861. this.foldWidgets[firstRow] = null;
  6862. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  6863. this.foldWidgets.splice(firstRow, len + 1, null);
  6864. } else {
  6865. var args = Array(len + 1);
  6866. args.unshift(firstRow, 1);
  6867. this.foldWidgets.splice.apply(this.foldWidgets, args);
  6868. }
  6869. };
  6870. this.tokenizerUpdateFoldWidgets = function(e) {
  6871. var rows = e.data;
  6872. if (rows.first != rows.last) {
  6873. if (this.foldWidgets.length > rows.first)
  6874. this.foldWidgets.splice(rows.first, this.foldWidgets.length);
  6875. }
  6876. }
  6877. }
  6878. exports.Folding = Folding;
  6879. });
  6880. ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
  6881. "use strict";
  6882. var TokenIterator = require("../token_iterator").TokenIterator;
  6883. var Range = require("../range").Range;
  6884. function BracketMatch() {
  6885. this.findMatchingBracket = function(position, chr) {
  6886. if (position.column == 0) return null;
  6887. var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
  6888. if (charBeforeCursor == "") return null;
  6889. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  6890. if (!match)
  6891. return null;
  6892. if (match[1])
  6893. return this.$findClosingBracket(match[1], position);
  6894. else
  6895. return this.$findOpeningBracket(match[2], position);
  6896. };
  6897. this.getBracketRange = function(pos) {
  6898. var line = this.getLine(pos.row);
  6899. var before = true, range;
  6900. var chr = line.charAt(pos.column-1);
  6901. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  6902. if (!match) {
  6903. chr = line.charAt(pos.column);
  6904. pos = {row: pos.row, column: pos.column + 1};
  6905. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  6906. before = false;
  6907. }
  6908. if (!match)
  6909. return null;
  6910. if (match[1]) {
  6911. var bracketPos = this.$findClosingBracket(match[1], pos);
  6912. if (!bracketPos)
  6913. return null;
  6914. range = Range.fromPoints(pos, bracketPos);
  6915. if (!before) {
  6916. range.end.column++;
  6917. range.start.column--;
  6918. }
  6919. range.cursor = range.end;
  6920. } else {
  6921. var bracketPos = this.$findOpeningBracket(match[2], pos);
  6922. if (!bracketPos)
  6923. return null;
  6924. range = Range.fromPoints(bracketPos, pos);
  6925. if (!before) {
  6926. range.start.column++;
  6927. range.end.column--;
  6928. }
  6929. range.cursor = range.start;
  6930. }
  6931. return range;
  6932. };
  6933. this.$brackets = {
  6934. ")": "(",
  6935. "(": ")",
  6936. "]": "[",
  6937. "[": "]",
  6938. "{": "}",
  6939. "}": "{"
  6940. };
  6941. this.$findOpeningBracket = function(bracket, position, typeRe) {
  6942. var openBracket = this.$brackets[bracket];
  6943. var depth = 1;
  6944. var iterator = new TokenIterator(this, position.row, position.column);
  6945. var token = iterator.getCurrentToken();
  6946. if (!token)
  6947. token = iterator.stepForward();
  6948. if (!token)
  6949. return;
  6950. if (!typeRe){
  6951. typeRe = new RegExp(
  6952. "(\\.?" +
  6953. token.type.replace(".", "\\.").replace("rparen", ".paren")
  6954. .replace(/\b(?:end|start|begin)\b/, "")
  6955. + ")+"
  6956. );
  6957. }
  6958. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  6959. var value = token.value;
  6960. while (true) {
  6961. while (valueIndex >= 0) {
  6962. var chr = value.charAt(valueIndex);
  6963. if (chr == openBracket) {
  6964. depth -= 1;
  6965. if (depth == 0) {
  6966. return {row: iterator.getCurrentTokenRow(),
  6967. column: valueIndex + iterator.getCurrentTokenColumn()};
  6968. }
  6969. }
  6970. else if (chr == bracket) {
  6971. depth += 1;
  6972. }
  6973. valueIndex -= 1;
  6974. }
  6975. do {
  6976. token = iterator.stepBackward();
  6977. } while (token && !typeRe.test(token.type));
  6978. if (token == null)
  6979. break;
  6980. value = token.value;
  6981. valueIndex = value.length - 1;
  6982. }
  6983. return null;
  6984. };
  6985. this.$findClosingBracket = function(bracket, position, typeRe) {
  6986. var closingBracket = this.$brackets[bracket];
  6987. var depth = 1;
  6988. var iterator = new TokenIterator(this, position.row, position.column);
  6989. var token = iterator.getCurrentToken();
  6990. if (!token)
  6991. token = iterator.stepForward();
  6992. if (!token)
  6993. return;
  6994. if (!typeRe){
  6995. typeRe = new RegExp(
  6996. "(\\.?" +
  6997. token.type.replace(".", "\\.").replace("lparen", ".paren")
  6998. .replace(/\b(?:end|start|begin)\b/, "")
  6999. + ")+"
  7000. );
  7001. }
  7002. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  7003. while (true) {
  7004. var value = token.value;
  7005. var valueLength = value.length;
  7006. while (valueIndex < valueLength) {
  7007. var chr = value.charAt(valueIndex);
  7008. if (chr == closingBracket) {
  7009. depth -= 1;
  7010. if (depth == 0) {
  7011. return {row: iterator.getCurrentTokenRow(),
  7012. column: valueIndex + iterator.getCurrentTokenColumn()};
  7013. }
  7014. }
  7015. else if (chr == bracket) {
  7016. depth += 1;
  7017. }
  7018. valueIndex += 1;
  7019. }
  7020. do {
  7021. token = iterator.stepForward();
  7022. } while (token && !typeRe.test(token.type));
  7023. if (token == null)
  7024. break;
  7025. valueIndex = 0;
  7026. }
  7027. return null;
  7028. };
  7029. }
  7030. exports.BracketMatch = BracketMatch;
  7031. });
  7032. 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) {
  7033. "use strict";
  7034. var oop = require("./lib/oop");
  7035. var lang = require("./lib/lang");
  7036. var config = require("./config");
  7037. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7038. var Selection = require("./selection").Selection;
  7039. var TextMode = require("./mode/text").Mode;
  7040. var Range = require("./range").Range;
  7041. var Document = require("./document").Document;
  7042. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  7043. var SearchHighlight = require("./search_highlight").SearchHighlight;
  7044. var EditSession = function(text, mode) {
  7045. this.$breakpoints = [];
  7046. this.$decorations = [];
  7047. this.$frontMarkers = {};
  7048. this.$backMarkers = {};
  7049. this.$markerId = 1;
  7050. this.$undoSelect = true;
  7051. this.$foldData = [];
  7052. this.$foldData.toString = function() {
  7053. return this.join("\n");
  7054. }
  7055. this.on("changeFold", this.onChangeFold.bind(this));
  7056. this.$onChange = this.onChange.bind(this);
  7057. if (typeof text != "object" || !text.getLine)
  7058. text = new Document(text);
  7059. this.setDocument(text);
  7060. this.selection = new Selection(this);
  7061. config.resetOptions(this);
  7062. this.setMode(mode);
  7063. config._signal("session", this);
  7064. };
  7065. (function() {
  7066. oop.implement(this, EventEmitter);
  7067. this.setDocument = function(doc) {
  7068. if (this.doc)
  7069. this.doc.removeListener("change", this.$onChange);
  7070. this.doc = doc;
  7071. doc.on("change", this.$onChange);
  7072. if (this.bgTokenizer)
  7073. this.bgTokenizer.setDocument(this.getDocument());
  7074. this.resetCaches();
  7075. };
  7076. this.getDocument = function() {
  7077. return this.doc;
  7078. };
  7079. this.$resetRowCache = function(docRow) {
  7080. if (!docRow) {
  7081. this.$docRowCache = [];
  7082. this.$screenRowCache = [];
  7083. return;
  7084. }
  7085. var l = this.$docRowCache.length;
  7086. var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
  7087. if (l > i) {
  7088. this.$docRowCache.splice(i, l);
  7089. this.$screenRowCache.splice(i, l);
  7090. }
  7091. };
  7092. this.$getRowCacheIndex = function(cacheArray, val) {
  7093. var low = 0;
  7094. var hi = cacheArray.length - 1;
  7095. while (low <= hi) {
  7096. var mid = (low + hi) >> 1;
  7097. var c = cacheArray[mid];
  7098. if (val > c)
  7099. low = mid + 1;
  7100. else if (val < c)
  7101. hi = mid - 1;
  7102. else
  7103. return mid;
  7104. }
  7105. return low -1;
  7106. };
  7107. this.resetCaches = function() {
  7108. this.$modified = true;
  7109. this.$wrapData = [];
  7110. this.$rowLengthCache = [];
  7111. this.$resetRowCache(0);
  7112. if (this.bgTokenizer)
  7113. this.bgTokenizer.start(0);
  7114. };
  7115. this.onChangeFold = function(e) {
  7116. var fold = e.data;
  7117. this.$resetRowCache(fold.start.row);
  7118. };
  7119. this.onChange = function(e) {
  7120. var delta = e.data;
  7121. this.$modified = true;
  7122. this.$resetRowCache(delta.range.start.row);
  7123. var removedFolds = this.$updateInternalDataOnChange(e);
  7124. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  7125. this.$deltasDoc.push(delta);
  7126. if (removedFolds && removedFolds.length != 0) {
  7127. this.$deltasFold.push({
  7128. action: "removeFolds",
  7129. folds: removedFolds
  7130. });
  7131. }
  7132. this.$informUndoManager.schedule();
  7133. }
  7134. this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
  7135. this._signal("change", e);
  7136. };
  7137. this.setValue = function(text) {
  7138. this.doc.setValue(text);
  7139. this.selection.moveTo(0, 0);
  7140. this.$resetRowCache(0);
  7141. this.$deltas = [];
  7142. this.$deltasDoc = [];
  7143. this.$deltasFold = [];
  7144. this.setUndoManager(this.$undoManager);
  7145. this.getUndoManager().reset();
  7146. };
  7147. this.getValue =
  7148. this.toString = function() {
  7149. return this.doc.getValue();
  7150. };
  7151. this.getSelection = function() {
  7152. return this.selection;
  7153. };
  7154. this.getState = function(row) {
  7155. return this.bgTokenizer.getState(row);
  7156. };
  7157. this.getTokens = function(row) {
  7158. return this.bgTokenizer.getTokens(row);
  7159. };
  7160. this.getTokenAt = function(row, column) {
  7161. var tokens = this.bgTokenizer.getTokens(row);
  7162. var token, c = 0;
  7163. if (column == null) {
  7164. i = tokens.length - 1;
  7165. c = this.getLine(row).length;
  7166. } else {
  7167. for (var i = 0; i < tokens.length; i++) {
  7168. c += tokens[i].value.length;
  7169. if (c >= column)
  7170. break;
  7171. }
  7172. }
  7173. token = tokens[i];
  7174. if (!token)
  7175. return null;
  7176. token.index = i;
  7177. token.start = c - token.value.length;
  7178. return token;
  7179. };
  7180. this.setUndoManager = function(undoManager) {
  7181. this.$undoManager = undoManager;
  7182. this.$deltas = [];
  7183. this.$deltasDoc = [];
  7184. this.$deltasFold = [];
  7185. if (this.$informUndoManager)
  7186. this.$informUndoManager.cancel();
  7187. if (undoManager) {
  7188. var self = this;
  7189. this.$syncInformUndoManager = function() {
  7190. self.$informUndoManager.cancel();
  7191. if (self.$deltasFold.length) {
  7192. self.$deltas.push({
  7193. group: "fold",
  7194. deltas: self.$deltasFold
  7195. });
  7196. self.$deltasFold = [];
  7197. }
  7198. if (self.$deltasDoc.length) {
  7199. self.$deltas.push({
  7200. group: "doc",
  7201. deltas: self.$deltasDoc
  7202. });
  7203. self.$deltasDoc = [];
  7204. }
  7205. if (self.$deltas.length > 0) {
  7206. undoManager.execute({
  7207. action: "aceupdate",
  7208. args: [self.$deltas, self],
  7209. merge: self.mergeUndoDeltas
  7210. });
  7211. }
  7212. self.mergeUndoDeltas = false;
  7213. self.$deltas = [];
  7214. };
  7215. this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
  7216. }
  7217. };
  7218. this.markUndoGroup = function() {
  7219. if (this.$syncInformUndoManager)
  7220. this.$syncInformUndoManager();
  7221. };
  7222. this.$defaultUndoManager = {
  7223. undo: function() {},
  7224. redo: function() {},
  7225. reset: function() {}
  7226. };
  7227. this.getUndoManager = function() {
  7228. return this.$undoManager || this.$defaultUndoManager;
  7229. };
  7230. this.getTabString = function() {
  7231. if (this.getUseSoftTabs()) {
  7232. return lang.stringRepeat(" ", this.getTabSize());
  7233. } else {
  7234. return "\t";
  7235. }
  7236. };
  7237. this.setUseSoftTabs = function(val) {
  7238. this.setOption("useSoftTabs", val);
  7239. };
  7240. this.getUseSoftTabs = function() {
  7241. return this.$useSoftTabs && !this.$mode.$indentWithTabs;
  7242. };
  7243. this.setTabSize = function(tabSize) {
  7244. this.setOption("tabSize", tabSize);
  7245. };
  7246. this.getTabSize = function() {
  7247. return this.$tabSize;
  7248. };
  7249. this.isTabStop = function(position) {
  7250. return this.$useSoftTabs && (position.column % this.$tabSize === 0);
  7251. };
  7252. this.$overwrite = false;
  7253. this.setOverwrite = function(overwrite) {
  7254. this.setOption("overwrite", overwrite);
  7255. };
  7256. this.getOverwrite = function() {
  7257. return this.$overwrite;
  7258. };
  7259. this.toggleOverwrite = function() {
  7260. this.setOverwrite(!this.$overwrite);
  7261. };
  7262. this.addGutterDecoration = function(row, className) {
  7263. if (!this.$decorations[row])
  7264. this.$decorations[row] = "";
  7265. this.$decorations[row] += " " + className;
  7266. this._signal("changeBreakpoint", {});
  7267. };
  7268. this.removeGutterDecoration = function(row, className) {
  7269. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  7270. this._signal("changeBreakpoint", {});
  7271. };
  7272. this.getBreakpoints = function() {
  7273. return this.$breakpoints;
  7274. };
  7275. this.setBreakpoints = function(rows) {
  7276. this.$breakpoints = [];
  7277. for (var i=0; i<rows.length; i++) {
  7278. this.$breakpoints[rows[i]] = "ace_breakpoint";
  7279. }
  7280. this._signal("changeBreakpoint", {});
  7281. };
  7282. this.clearBreakpoints = function() {
  7283. this.$breakpoints = [];
  7284. this._signal("changeBreakpoint", {});
  7285. };
  7286. this.setBreakpoint = function(row, className) {
  7287. if (className === undefined)
  7288. className = "ace_breakpoint";
  7289. if (className)
  7290. this.$breakpoints[row] = className;
  7291. else
  7292. delete this.$breakpoints[row];
  7293. this._signal("changeBreakpoint", {});
  7294. };
  7295. this.clearBreakpoint = function(row) {
  7296. delete this.$breakpoints[row];
  7297. this._signal("changeBreakpoint", {});
  7298. };
  7299. this.addMarker = function(range, clazz, type, inFront) {
  7300. var id = this.$markerId++;
  7301. var marker = {
  7302. range : range,
  7303. type : type || "line",
  7304. renderer: typeof type == "function" ? type : null,
  7305. clazz : clazz,
  7306. inFront: !!inFront,
  7307. id: id
  7308. };
  7309. if (inFront) {
  7310. this.$frontMarkers[id] = marker;
  7311. this._signal("changeFrontMarker");
  7312. } else {
  7313. this.$backMarkers[id] = marker;
  7314. this._signal("changeBackMarker");
  7315. }
  7316. return id;
  7317. };
  7318. this.addDynamicMarker = function(marker, inFront) {
  7319. if (!marker.update)
  7320. return;
  7321. var id = this.$markerId++;
  7322. marker.id = id;
  7323. marker.inFront = !!inFront;
  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 marker;
  7332. };
  7333. this.removeMarker = function(markerId) {
  7334. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  7335. if (!marker)
  7336. return;
  7337. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  7338. if (marker) {
  7339. delete (markers[markerId]);
  7340. this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  7341. }
  7342. };
  7343. this.getMarkers = function(inFront) {
  7344. return inFront ? this.$frontMarkers : this.$backMarkers;
  7345. };
  7346. this.highlight = function(re) {
  7347. if (!this.$searchHighlight) {
  7348. var highlight = new SearchHighlight(null, "ace_selected-word", "text");
  7349. this.$searchHighlight = this.addDynamicMarker(highlight);
  7350. }
  7351. this.$searchHighlight.setRegexp(re);
  7352. };
  7353. this.highlightLines = function(startRow, endRow, clazz, inFront) {
  7354. if (typeof endRow != "number") {
  7355. clazz = endRow;
  7356. endRow = startRow;
  7357. }
  7358. if (!clazz)
  7359. clazz = "ace_step";
  7360. var range = new Range(startRow, 0, endRow, Infinity);
  7361. range.id = this.addMarker(range, clazz, "fullLine", inFront);
  7362. return range;
  7363. };
  7364. this.setAnnotations = function(annotations) {
  7365. this.$annotations = annotations;
  7366. this._signal("changeAnnotation", {});
  7367. };
  7368. this.getAnnotations = function() {
  7369. return this.$annotations || [];
  7370. };
  7371. this.clearAnnotations = function() {
  7372. this.setAnnotations([]);
  7373. };
  7374. this.$detectNewLine = function(text) {
  7375. var match = text.match(/^.*?(\r?\n)/m);
  7376. if (match) {
  7377. this.$autoNewLine = match[1];
  7378. } else {
  7379. this.$autoNewLine = "\n";
  7380. }
  7381. };
  7382. this.getWordRange = function(row, column) {
  7383. var line = this.getLine(row);
  7384. var inToken = false;
  7385. if (column > 0)
  7386. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  7387. if (!inToken)
  7388. inToken = !!line.charAt(column).match(this.tokenRe);
  7389. if (inToken)
  7390. var re = this.tokenRe;
  7391. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  7392. var re = /\s/;
  7393. else
  7394. var re = this.nonTokenRe;
  7395. var start = column;
  7396. if (start > 0) {
  7397. do {
  7398. start--;
  7399. }
  7400. while (start >= 0 && line.charAt(start).match(re));
  7401. start++;
  7402. }
  7403. var end = column;
  7404. while (end < line.length && line.charAt(end).match(re)) {
  7405. end++;
  7406. }
  7407. return new Range(row, start, row, end);
  7408. };
  7409. this.getAWordRange = function(row, column) {
  7410. var wordRange = this.getWordRange(row, column);
  7411. var line = this.getLine(wordRange.end.row);
  7412. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  7413. wordRange.end.column += 1;
  7414. }
  7415. return wordRange;
  7416. };
  7417. this.setNewLineMode = function(newLineMode) {
  7418. this.doc.setNewLineMode(newLineMode);
  7419. };
  7420. this.getNewLineMode = function() {
  7421. return this.doc.getNewLineMode();
  7422. };
  7423. this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
  7424. this.getUseWorker = function() { return this.$useWorker; };
  7425. this.onReloadTokenizer = function(e) {
  7426. var rows = e.data;
  7427. this.bgTokenizer.start(rows.first);
  7428. this._signal("tokenizerUpdate", e);
  7429. };
  7430. this.$modes = {};
  7431. this.$mode = null;
  7432. this.$modeId = null;
  7433. this.setMode = function(mode, cb) {
  7434. if (mode && typeof mode === "object") {
  7435. if (mode.getTokenizer)
  7436. return this.$onChangeMode(mode);
  7437. var options = mode;
  7438. var path = options.path;
  7439. } else {
  7440. path = mode || "ace/mode/text";
  7441. }
  7442. if (!this.$modes["ace/mode/text"])
  7443. this.$modes["ace/mode/text"] = new TextMode();
  7444. if (this.$modes[path] && !options) {
  7445. this.$onChangeMode(this.$modes[path]);
  7446. cb && cb();
  7447. return;
  7448. }
  7449. this.$modeId = path;
  7450. config.loadModule(["mode", path], function(m) {
  7451. if (this.$modeId !== path)
  7452. return cb && cb();
  7453. if (this.$modes[path] && !options) {
  7454. this.$onChangeMode(this.$modes[path]);
  7455. } else if (m && m.Mode) {
  7456. m = new m.Mode(options);
  7457. if (!options) {
  7458. this.$modes[path] = m;
  7459. m.$id = path;
  7460. }
  7461. this.$onChangeMode(m);
  7462. }
  7463. cb && cb();
  7464. }.bind(this));
  7465. if (!this.$mode)
  7466. this.$onChangeMode(this.$modes["ace/mode/text"], true);
  7467. };
  7468. this.$onChangeMode = function(mode, $isPlaceholder) {
  7469. if (!$isPlaceholder)
  7470. this.$modeId = mode.$id;
  7471. if (this.$mode === mode)
  7472. return;
  7473. this.$mode = mode;
  7474. this.$stopWorker();
  7475. if (this.$useWorker)
  7476. this.$startWorker();
  7477. var tokenizer = mode.getTokenizer();
  7478. if(tokenizer.addEventListener !== undefined) {
  7479. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  7480. tokenizer.addEventListener("update", onReloadTokenizer);
  7481. }
  7482. if (!this.bgTokenizer) {
  7483. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  7484. var _self = this;
  7485. this.bgTokenizer.addEventListener("update", function(e) {
  7486. _self._signal("tokenizerUpdate", e);
  7487. });
  7488. } else {
  7489. this.bgTokenizer.setTokenizer(tokenizer);
  7490. }
  7491. this.bgTokenizer.setDocument(this.getDocument());
  7492. this.tokenRe = mode.tokenRe;
  7493. this.nonTokenRe = mode.nonTokenRe;
  7494. if (!$isPlaceholder) {
  7495. if (mode.attachToSession)
  7496. mode.attachToSession(this);
  7497. this.$options.wrapMethod.set.call(this, this.$wrapMethod);
  7498. this.$setFolding(mode.foldingRules);
  7499. this.bgTokenizer.start(0);
  7500. this._emit("changeMode");
  7501. }
  7502. };
  7503. this.$stopWorker = function() {
  7504. if (this.$worker) {
  7505. this.$worker.terminate();
  7506. this.$worker = null;
  7507. }
  7508. };
  7509. this.$startWorker = function() {
  7510. try {
  7511. this.$worker = this.$mode.createWorker(this);
  7512. } catch (e) {
  7513. config.warn("Could not load worker", e);
  7514. this.$worker = null;
  7515. }
  7516. };
  7517. this.getMode = function() {
  7518. return this.$mode;
  7519. };
  7520. this.$scrollTop = 0;
  7521. this.setScrollTop = function(scrollTop) {
  7522. if (this.$scrollTop === scrollTop || isNaN(scrollTop))
  7523. return;
  7524. this.$scrollTop = scrollTop;
  7525. this._signal("changeScrollTop", scrollTop);
  7526. };
  7527. this.getScrollTop = function() {
  7528. return this.$scrollTop;
  7529. };
  7530. this.$scrollLeft = 0;
  7531. this.setScrollLeft = function(scrollLeft) {
  7532. if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
  7533. return;
  7534. this.$scrollLeft = scrollLeft;
  7535. this._signal("changeScrollLeft", scrollLeft);
  7536. };
  7537. this.getScrollLeft = function() {
  7538. return this.$scrollLeft;
  7539. };
  7540. this.getScreenWidth = function() {
  7541. this.$computeWidth();
  7542. if (this.lineWidgets)
  7543. return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
  7544. return this.screenWidth;
  7545. };
  7546. this.getLineWidgetMaxWidth = function() {
  7547. if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
  7548. var width = 0;
  7549. this.lineWidgets.forEach(function(w) {
  7550. if (w && w.screenWidth > width)
  7551. width = w.screenWidth;
  7552. });
  7553. return this.lineWidgetWidth = width;
  7554. };
  7555. this.$computeWidth = function(force) {
  7556. if (this.$modified || force) {
  7557. this.$modified = false;
  7558. if (this.$useWrapMode)
  7559. return this.screenWidth = this.$wrapLimit;
  7560. var lines = this.doc.getAllLines();
  7561. var cache = this.$rowLengthCache;
  7562. var longestScreenLine = 0;
  7563. var foldIndex = 0;
  7564. var foldLine = this.$foldData[foldIndex];
  7565. var foldStart = foldLine ? foldLine.start.row : Infinity;
  7566. var len = lines.length;
  7567. for (var i = 0; i < len; i++) {
  7568. if (i > foldStart) {
  7569. i = foldLine.end.row + 1;
  7570. if (i >= len)
  7571. break;
  7572. foldLine = this.$foldData[foldIndex++];
  7573. foldStart = foldLine ? foldLine.start.row : Infinity;
  7574. }
  7575. if (cache[i] == null)
  7576. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  7577. if (cache[i] > longestScreenLine)
  7578. longestScreenLine = cache[i];
  7579. }
  7580. this.screenWidth = longestScreenLine;
  7581. }
  7582. };
  7583. this.getLine = function(row) {
  7584. return this.doc.getLine(row);
  7585. };
  7586. this.getLines = function(firstRow, lastRow) {
  7587. return this.doc.getLines(firstRow, lastRow);
  7588. };
  7589. this.getLength = function() {
  7590. return this.doc.getLength();
  7591. };
  7592. this.getTextRange = function(range) {
  7593. return this.doc.getTextRange(range || this.selection.getRange());
  7594. };
  7595. this.insert = function(position, text) {
  7596. return this.doc.insert(position, text);
  7597. };
  7598. this.remove = function(range) {
  7599. return this.doc.remove(range);
  7600. };
  7601. this.undoChanges = function(deltas, dontSelect) {
  7602. if (!deltas.length)
  7603. return;
  7604. this.$fromUndo = true;
  7605. var lastUndoRange = null;
  7606. for (var i = deltas.length - 1; i != -1; i--) {
  7607. var delta = deltas[i];
  7608. if (delta.group == "doc") {
  7609. this.doc.revertDeltas(delta.deltas);
  7610. lastUndoRange =
  7611. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  7612. } else {
  7613. delta.deltas.forEach(function(foldDelta) {
  7614. this.addFolds(foldDelta.folds);
  7615. }, this);
  7616. }
  7617. }
  7618. this.$fromUndo = false;
  7619. lastUndoRange &&
  7620. this.$undoSelect &&
  7621. !dontSelect &&
  7622. this.selection.setSelectionRange(lastUndoRange);
  7623. return lastUndoRange;
  7624. };
  7625. this.redoChanges = function(deltas, dontSelect) {
  7626. if (!deltas.length)
  7627. return;
  7628. this.$fromUndo = true;
  7629. var lastUndoRange = null;
  7630. for (var i = 0; i < deltas.length; i++) {
  7631. var delta = deltas[i];
  7632. if (delta.group == "doc") {
  7633. this.doc.applyDeltas(delta.deltas);
  7634. lastUndoRange =
  7635. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  7636. }
  7637. }
  7638. this.$fromUndo = false;
  7639. lastUndoRange &&
  7640. this.$undoSelect &&
  7641. !dontSelect &&
  7642. this.selection.setSelectionRange(lastUndoRange);
  7643. return lastUndoRange;
  7644. };
  7645. this.setUndoSelect = function(enable) {
  7646. this.$undoSelect = enable;
  7647. };
  7648. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  7649. function isInsert(delta) {
  7650. var insert =
  7651. delta.action === "insertText" || delta.action === "insertLines";
  7652. return isUndo ? !insert : insert;
  7653. }
  7654. var delta = deltas[0];
  7655. var range, point;
  7656. var lastDeltaIsInsert = false;
  7657. if (isInsert(delta)) {
  7658. range = Range.fromPoints(delta.range.start, delta.range.end);
  7659. lastDeltaIsInsert = true;
  7660. } else {
  7661. range = Range.fromPoints(delta.range.start, delta.range.start);
  7662. lastDeltaIsInsert = false;
  7663. }
  7664. for (var i = 1; i < deltas.length; i++) {
  7665. delta = deltas[i];
  7666. if (isInsert(delta)) {
  7667. point = delta.range.start;
  7668. if (range.compare(point.row, point.column) == -1) {
  7669. range.setStart(delta.range.start);
  7670. }
  7671. point = delta.range.end;
  7672. if (range.compare(point.row, point.column) == 1) {
  7673. range.setEnd(delta.range.end);
  7674. }
  7675. lastDeltaIsInsert = true;
  7676. } else {
  7677. point = delta.range.start;
  7678. if (range.compare(point.row, point.column) == -1) {
  7679. range =
  7680. Range.fromPoints(delta.range.start, delta.range.start);
  7681. }
  7682. lastDeltaIsInsert = false;
  7683. }
  7684. }
  7685. if (lastUndoRange != null) {
  7686. if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
  7687. lastUndoRange.start.column += range.end.column - range.start.column;
  7688. lastUndoRange.end.column += range.end.column - range.start.column;
  7689. }
  7690. var cmp = lastUndoRange.compareRange(range);
  7691. if (cmp == 1) {
  7692. range.setStart(lastUndoRange.start);
  7693. } else if (cmp == -1) {
  7694. range.setEnd(lastUndoRange.end);
  7695. }
  7696. }
  7697. return range;
  7698. };
  7699. this.replace = function(range, text) {
  7700. return this.doc.replace(range, text);
  7701. };
  7702. this.moveText = function(fromRange, toPosition, copy) {
  7703. var text = this.getTextRange(fromRange);
  7704. var folds = this.getFoldsInRange(fromRange);
  7705. var toRange = Range.fromPoints(toPosition, toPosition);
  7706. if (!copy) {
  7707. this.remove(fromRange);
  7708. var rowDiff = fromRange.start.row - fromRange.end.row;
  7709. var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
  7710. if (collDiff) {
  7711. if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
  7712. toRange.start.column += collDiff;
  7713. if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
  7714. toRange.end.column += collDiff;
  7715. }
  7716. if (rowDiff && toRange.start.row >= fromRange.end.row) {
  7717. toRange.start.row += rowDiff;
  7718. toRange.end.row += rowDiff;
  7719. }
  7720. }
  7721. toRange.end = this.insert(toRange.start, text);
  7722. if (folds.length) {
  7723. var oldStart = fromRange.start;
  7724. var newStart = toRange.start;
  7725. var rowDiff = newStart.row - oldStart.row;
  7726. var collDiff = newStart.column - oldStart.column;
  7727. this.addFolds(folds.map(function(x) {
  7728. x = x.clone();
  7729. if (x.start.row == oldStart.row)
  7730. x.start.column += collDiff;
  7731. if (x.end.row == oldStart.row)
  7732. x.end.column += collDiff;
  7733. x.start.row += rowDiff;
  7734. x.end.row += rowDiff;
  7735. return x;
  7736. }));
  7737. }
  7738. return toRange;
  7739. };
  7740. this.indentRows = function(startRow, endRow, indentString) {
  7741. indentString = indentString.replace(/\t/g, this.getTabString());
  7742. for (var row=startRow; row<=endRow; row++)
  7743. this.insert({row: row, column:0}, indentString);
  7744. };
  7745. this.outdentRows = function (range) {
  7746. var rowRange = range.collapseRows();
  7747. var deleteRange = new Range(0, 0, 0, 0);
  7748. var size = this.getTabSize();
  7749. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  7750. var line = this.getLine(i);
  7751. deleteRange.start.row = i;
  7752. deleteRange.end.row = i;
  7753. for (var j = 0; j < size; ++j)
  7754. if (line.charAt(j) != ' ')
  7755. break;
  7756. if (j < size && line.charAt(j) == '\t') {
  7757. deleteRange.start.column = j;
  7758. deleteRange.end.column = j + 1;
  7759. } else {
  7760. deleteRange.start.column = 0;
  7761. deleteRange.end.column = j;
  7762. }
  7763. this.remove(deleteRange);
  7764. }
  7765. };
  7766. this.$moveLines = function(firstRow, lastRow, dir) {
  7767. firstRow = this.getRowFoldStart(firstRow);
  7768. lastRow = this.getRowFoldEnd(lastRow);
  7769. if (dir < 0) {
  7770. var row = this.getRowFoldStart(firstRow + dir);
  7771. if (row < 0) return 0;
  7772. var diff = row-firstRow;
  7773. } else if (dir > 0) {
  7774. var row = this.getRowFoldEnd(lastRow + dir);
  7775. if (row > this.doc.getLength()-1) return 0;
  7776. var diff = row-lastRow;
  7777. } else {
  7778. firstRow = this.$clipRowToDocument(firstRow);
  7779. lastRow = this.$clipRowToDocument(lastRow);
  7780. var diff = lastRow - firstRow + 1;
  7781. }
  7782. var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
  7783. var folds = this.getFoldsInRange(range).map(function(x){
  7784. x = x.clone();
  7785. x.start.row += diff;
  7786. x.end.row += diff;
  7787. return x;
  7788. });
  7789. var lines = dir == 0
  7790. ? this.doc.getLines(firstRow, lastRow)
  7791. : this.doc.removeLines(firstRow, lastRow);
  7792. this.doc.insertLines(firstRow+diff, lines);
  7793. folds.length && this.addFolds(folds);
  7794. return diff;
  7795. };
  7796. this.moveLinesUp = function(firstRow, lastRow) {
  7797. return this.$moveLines(firstRow, lastRow, -1);
  7798. };
  7799. this.moveLinesDown = function(firstRow, lastRow) {
  7800. return this.$moveLines(firstRow, lastRow, 1);
  7801. };
  7802. this.duplicateLines = function(firstRow, lastRow) {
  7803. return this.$moveLines(firstRow, lastRow, 0);
  7804. };
  7805. this.$clipRowToDocument = function(row) {
  7806. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  7807. };
  7808. this.$clipColumnToRow = function(row, column) {
  7809. if (column < 0)
  7810. return 0;
  7811. return Math.min(this.doc.getLine(row).length, column);
  7812. };
  7813. this.$clipPositionToDocument = function(row, column) {
  7814. column = Math.max(0, column);
  7815. if (row < 0) {
  7816. row = 0;
  7817. column = 0;
  7818. } else {
  7819. var len = this.doc.getLength();
  7820. if (row >= len) {
  7821. row = len - 1;
  7822. column = this.doc.getLine(len-1).length;
  7823. } else {
  7824. column = Math.min(this.doc.getLine(row).length, column);
  7825. }
  7826. }
  7827. return {
  7828. row: row,
  7829. column: column
  7830. };
  7831. };
  7832. this.$clipRangeToDocument = function(range) {
  7833. if (range.start.row < 0) {
  7834. range.start.row = 0;
  7835. range.start.column = 0;
  7836. } else {
  7837. range.start.column = this.$clipColumnToRow(
  7838. range.start.row,
  7839. range.start.column
  7840. );
  7841. }
  7842. var len = this.doc.getLength() - 1;
  7843. if (range.end.row > len) {
  7844. range.end.row = len;
  7845. range.end.column = this.doc.getLine(len).length;
  7846. } else {
  7847. range.end.column = this.$clipColumnToRow(
  7848. range.end.row,
  7849. range.end.column
  7850. );
  7851. }
  7852. return range;
  7853. };
  7854. this.$wrapLimit = 80;
  7855. this.$useWrapMode = false;
  7856. this.$wrapLimitRange = {
  7857. min : null,
  7858. max : null
  7859. };
  7860. this.setUseWrapMode = function(useWrapMode) {
  7861. if (useWrapMode != this.$useWrapMode) {
  7862. this.$useWrapMode = useWrapMode;
  7863. this.$modified = true;
  7864. this.$resetRowCache(0);
  7865. if (useWrapMode) {
  7866. var len = this.getLength();
  7867. this.$wrapData = Array(len);
  7868. this.$updateWrapData(0, len - 1);
  7869. }
  7870. this._signal("changeWrapMode");
  7871. }
  7872. };
  7873. this.getUseWrapMode = function() {
  7874. return this.$useWrapMode;
  7875. };
  7876. this.setWrapLimitRange = function(min, max) {
  7877. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  7878. this.$wrapLimitRange = { min: min, max: max };
  7879. this.$modified = true;
  7880. if (this.$useWrapMode)
  7881. this._signal("changeWrapMode");
  7882. }
  7883. };
  7884. this.adjustWrapLimit = function(desiredLimit, $printMargin) {
  7885. var limits = this.$wrapLimitRange;
  7886. if (limits.max < 0)
  7887. limits = {min: $printMargin, max: $printMargin};
  7888. var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
  7889. if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
  7890. this.$wrapLimit = wrapLimit;
  7891. this.$modified = true;
  7892. if (this.$useWrapMode) {
  7893. this.$updateWrapData(0, this.getLength() - 1);
  7894. this.$resetRowCache(0);
  7895. this._signal("changeWrapLimit");
  7896. }
  7897. return true;
  7898. }
  7899. return false;
  7900. };
  7901. this.$constrainWrapLimit = function(wrapLimit, min, max) {
  7902. if (min)
  7903. wrapLimit = Math.max(min, wrapLimit);
  7904. if (max)
  7905. wrapLimit = Math.min(max, wrapLimit);
  7906. return wrapLimit;
  7907. };
  7908. this.getWrapLimit = function() {
  7909. return this.$wrapLimit;
  7910. };
  7911. this.setWrapLimit = function (limit) {
  7912. this.setWrapLimitRange(limit, limit);
  7913. };
  7914. this.getWrapLimitRange = function() {
  7915. return {
  7916. min : this.$wrapLimitRange.min,
  7917. max : this.$wrapLimitRange.max
  7918. };
  7919. };
  7920. this.$updateInternalDataOnChange = function(e) {
  7921. var useWrapMode = this.$useWrapMode;
  7922. var len;
  7923. var action = e.data.action;
  7924. var firstRow = e.data.range.start.row;
  7925. var lastRow = e.data.range.end.row;
  7926. var start = e.data.range.start;
  7927. var end = e.data.range.end;
  7928. var removedFolds = null;
  7929. if (action.indexOf("Lines") != -1) {
  7930. if (action == "insertLines") {
  7931. lastRow = firstRow + (e.data.lines.length);
  7932. } else {
  7933. lastRow = firstRow;
  7934. }
  7935. len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
  7936. } else {
  7937. len = lastRow - firstRow;
  7938. }
  7939. this.$updating = true;
  7940. if (len != 0) {
  7941. if (action.indexOf("remove") != -1) {
  7942. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  7943. var foldLines = this.$foldData;
  7944. removedFolds = this.getFoldsInRange(e.data.range);
  7945. this.removeFolds(removedFolds);
  7946. var foldLine = this.getFoldLine(end.row);
  7947. var idx = 0;
  7948. if (foldLine) {
  7949. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  7950. foldLine.shiftRow(-len);
  7951. var foldLineBefore = this.getFoldLine(firstRow);
  7952. if (foldLineBefore && foldLineBefore !== foldLine) {
  7953. foldLineBefore.merge(foldLine);
  7954. foldLine = foldLineBefore;
  7955. }
  7956. idx = foldLines.indexOf(foldLine) + 1;
  7957. }
  7958. for (idx; idx < foldLines.length; idx++) {
  7959. var foldLine = foldLines[idx];
  7960. if (foldLine.start.row >= end.row) {
  7961. foldLine.shiftRow(-len);
  7962. }
  7963. }
  7964. lastRow = firstRow;
  7965. } else {
  7966. var args = Array(len);
  7967. args.unshift(firstRow, 0);
  7968. var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
  7969. arr.splice.apply(arr, args);
  7970. var foldLines = this.$foldData;
  7971. var foldLine = this.getFoldLine(firstRow);
  7972. var idx = 0;
  7973. if (foldLine) {
  7974. var cmp = foldLine.range.compareInside(start.row, start.column);
  7975. if (cmp == 0) {
  7976. foldLine = foldLine.split(start.row, start.column);
  7977. if (foldLine) {
  7978. foldLine.shiftRow(len);
  7979. foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
  7980. }
  7981. } else
  7982. if (cmp == -1) {
  7983. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  7984. foldLine.shiftRow(len);
  7985. }
  7986. idx = foldLines.indexOf(foldLine) + 1;
  7987. }
  7988. for (idx; idx < foldLines.length; idx++) {
  7989. var foldLine = foldLines[idx];
  7990. if (foldLine.start.row >= firstRow) {
  7991. foldLine.shiftRow(len);
  7992. }
  7993. }
  7994. }
  7995. } else {
  7996. len = Math.abs(e.data.range.start.column - e.data.range.end.column);
  7997. if (action.indexOf("remove") != -1) {
  7998. removedFolds = this.getFoldsInRange(e.data.range);
  7999. this.removeFolds(removedFolds);
  8000. len = -len;
  8001. }
  8002. var foldLine = this.getFoldLine(firstRow);
  8003. if (foldLine) {
  8004. foldLine.addRemoveChars(firstRow, start.column, len);
  8005. }
  8006. }
  8007. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  8008. console.error("doc.getLength() and $wrapData.length have to be the same!");
  8009. }
  8010. this.$updating = false;
  8011. if (useWrapMode)
  8012. this.$updateWrapData(firstRow, lastRow);
  8013. else
  8014. this.$updateRowLengthCache(firstRow, lastRow);
  8015. return removedFolds;
  8016. };
  8017. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  8018. this.$rowLengthCache[firstRow] = null;
  8019. this.$rowLengthCache[lastRow] = null;
  8020. };
  8021. this.$updateWrapData = function(firstRow, lastRow) {
  8022. var lines = this.doc.getAllLines();
  8023. var tabSize = this.getTabSize();
  8024. var wrapData = this.$wrapData;
  8025. var wrapLimit = this.$wrapLimit;
  8026. var tokens;
  8027. var foldLine;
  8028. var row = firstRow;
  8029. lastRow = Math.min(lastRow, lines.length - 1);
  8030. while (row <= lastRow) {
  8031. foldLine = this.getFoldLine(row, foldLine);
  8032. if (!foldLine) {
  8033. tokens = this.$getDisplayTokens(lines[row]);
  8034. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8035. row ++;
  8036. } else {
  8037. tokens = [];
  8038. foldLine.walk(function(placeholder, row, column, lastColumn) {
  8039. var walkTokens;
  8040. if (placeholder != null) {
  8041. walkTokens = this.$getDisplayTokens(
  8042. placeholder, tokens.length);
  8043. walkTokens[0] = PLACEHOLDER_START;
  8044. for (var i = 1; i < walkTokens.length; i++) {
  8045. walkTokens[i] = PLACEHOLDER_BODY;
  8046. }
  8047. } else {
  8048. walkTokens = this.$getDisplayTokens(
  8049. lines[row].substring(lastColumn, column),
  8050. tokens.length);
  8051. }
  8052. tokens = tokens.concat(walkTokens);
  8053. }.bind(this),
  8054. foldLine.end.row,
  8055. lines[foldLine.end.row].length + 1
  8056. );
  8057. wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8058. row = foldLine.end.row + 1;
  8059. }
  8060. }
  8061. };
  8062. var CHAR = 1,
  8063. CHAR_EXT = 2,
  8064. PLACEHOLDER_START = 3,
  8065. PLACEHOLDER_BODY = 4,
  8066. PUNCTUATION = 9,
  8067. SPACE = 10,
  8068. TAB = 11,
  8069. TAB_SPACE = 12;
  8070. this.$computeWrapSplits = function(tokens, wrapLimit) {
  8071. if (tokens.length == 0) {
  8072. return [];
  8073. }
  8074. var splits = [];
  8075. var displayLength = tokens.length;
  8076. var lastSplit = 0, lastDocSplit = 0;
  8077. var isCode = this.$wrapAsCode;
  8078. function addSplit(screenPos) {
  8079. var displayed = tokens.slice(lastSplit, screenPos);
  8080. var len = displayed.length;
  8081. displayed.join("").
  8082. replace(/12/g, function() {
  8083. len -= 1;
  8084. }).
  8085. replace(/2/g, function() {
  8086. len -= 1;
  8087. });
  8088. lastDocSplit += len;
  8089. splits.push(lastDocSplit);
  8090. lastSplit = screenPos;
  8091. }
  8092. while (displayLength - lastSplit > wrapLimit) {
  8093. var split = lastSplit + wrapLimit;
  8094. if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
  8095. addSplit(split);
  8096. continue;
  8097. }
  8098. if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
  8099. for (split; split != lastSplit - 1; split--) {
  8100. if (tokens[split] == PLACEHOLDER_START) {
  8101. break;
  8102. }
  8103. }
  8104. if (split > lastSplit) {
  8105. addSplit(split);
  8106. continue;
  8107. }
  8108. split = lastSplit + wrapLimit;
  8109. for (split; split < tokens.length; split++) {
  8110. if (tokens[split] != PLACEHOLDER_BODY) {
  8111. break;
  8112. }
  8113. }
  8114. if (split == tokens.length) {
  8115. break; // Breaks the while-loop.
  8116. }
  8117. addSplit(split);
  8118. continue;
  8119. }
  8120. var minSplit = Math.max(split - (isCode ? 10 : wrapLimit-(wrapLimit>>2)), lastSplit - 1);
  8121. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8122. split --;
  8123. }
  8124. if (isCode) {
  8125. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8126. split --;
  8127. }
  8128. while (split > minSplit && tokens[split] == PUNCTUATION) {
  8129. split --;
  8130. }
  8131. } else {
  8132. while (split > minSplit && tokens[split] < SPACE) {
  8133. split --;
  8134. }
  8135. }
  8136. if (split > minSplit) {
  8137. addSplit(++split);
  8138. continue;
  8139. }
  8140. split = lastSplit + wrapLimit;
  8141. if (tokens[split] == CHAR_EXT)
  8142. split--;
  8143. addSplit(split);
  8144. }
  8145. return splits;
  8146. };
  8147. this.$getDisplayTokens = function(str, offset) {
  8148. var arr = [];
  8149. var tabSize;
  8150. offset = offset || 0;
  8151. for (var i = 0; i < str.length; i++) {
  8152. var c = str.charCodeAt(i);
  8153. if (c == 9) {
  8154. tabSize = this.getScreenTabSize(arr.length + offset);
  8155. arr.push(TAB);
  8156. for (var n = 1; n < tabSize; n++) {
  8157. arr.push(TAB_SPACE);
  8158. }
  8159. }
  8160. else if (c == 32) {
  8161. arr.push(SPACE);
  8162. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  8163. arr.push(PUNCTUATION);
  8164. }
  8165. else if (c >= 0x1100 && isFullWidth(c)) {
  8166. arr.push(CHAR, CHAR_EXT);
  8167. } else {
  8168. arr.push(CHAR);
  8169. }
  8170. }
  8171. return arr;
  8172. };
  8173. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8174. if (maxScreenColumn == 0)
  8175. return [0, 0];
  8176. if (maxScreenColumn == null)
  8177. maxScreenColumn = Infinity;
  8178. screenColumn = screenColumn || 0;
  8179. var c, column;
  8180. for (column = 0; column < str.length; column++) {
  8181. c = str.charCodeAt(column);
  8182. if (c == 9) {
  8183. screenColumn += this.getScreenTabSize(screenColumn);
  8184. }
  8185. else if (c >= 0x1100 && isFullWidth(c)) {
  8186. screenColumn += 2;
  8187. } else {
  8188. screenColumn += 1;
  8189. }
  8190. if (screenColumn > maxScreenColumn) {
  8191. break;
  8192. }
  8193. }
  8194. return [screenColumn, column];
  8195. };
  8196. this.lineWidgets = null;
  8197. this.getRowLength = function(row) {
  8198. if (this.lineWidgets)
  8199. var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  8200. else
  8201. h = 0
  8202. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8203. return 1 + h;
  8204. } else {
  8205. return this.$wrapData[row].length + 1 + h;
  8206. }
  8207. };
  8208. this.getRowLineCount = function(row) {
  8209. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8210. return 1;
  8211. } else {
  8212. return this.$wrapData[row].length + 1;
  8213. }
  8214. };
  8215. this.getScreenLastRowColumn = function(screenRow) {
  8216. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8217. return this.documentToScreenColumn(pos.row, pos.column);
  8218. };
  8219. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  8220. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8221. return this.getScreenLastRowColumn(screenRow);
  8222. };
  8223. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  8224. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8225. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  8226. };
  8227. this.getRowSplitData = function(row) {
  8228. if (!this.$useWrapMode) {
  8229. return undefined;
  8230. } else {
  8231. return this.$wrapData[row];
  8232. }
  8233. };
  8234. this.getScreenTabSize = function(screenColumn) {
  8235. return this.$tabSize - screenColumn % this.$tabSize;
  8236. };
  8237. this.screenToDocumentRow = function(screenRow, screenColumn) {
  8238. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  8239. };
  8240. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  8241. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  8242. };
  8243. this.screenToDocumentPosition = function(screenRow, screenColumn) {
  8244. if (screenRow < 0)
  8245. return {row: 0, column: 0};
  8246. var line;
  8247. var docRow = 0;
  8248. var docColumn = 0;
  8249. var column;
  8250. var row = 0;
  8251. var rowLength = 0;
  8252. var rowCache = this.$screenRowCache;
  8253. var i = this.$getRowCacheIndex(rowCache, screenRow);
  8254. var l = rowCache.length;
  8255. if (l && i >= 0) {
  8256. var row = rowCache[i];
  8257. var docRow = this.$docRowCache[i];
  8258. var doCache = screenRow > rowCache[l - 1];
  8259. } else {
  8260. var doCache = !l;
  8261. }
  8262. var maxRow = this.getLength() - 1;
  8263. var foldLine = this.getNextFoldLine(docRow);
  8264. var foldStart = foldLine ? foldLine.start.row : Infinity;
  8265. while (row <= screenRow) {
  8266. rowLength = this.getRowLength(docRow);
  8267. if (row + rowLength > screenRow || docRow >= maxRow) {
  8268. break;
  8269. } else {
  8270. row += rowLength;
  8271. docRow++;
  8272. if (docRow > foldStart) {
  8273. docRow = foldLine.end.row+1;
  8274. foldLine = this.getNextFoldLine(docRow, foldLine);
  8275. foldStart = foldLine ? foldLine.start.row : Infinity;
  8276. }
  8277. }
  8278. if (doCache) {
  8279. this.$docRowCache.push(docRow);
  8280. this.$screenRowCache.push(row);
  8281. }
  8282. }
  8283. if (foldLine && foldLine.start.row <= docRow) {
  8284. line = this.getFoldDisplayLine(foldLine);
  8285. docRow = foldLine.start.row;
  8286. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  8287. return {
  8288. row: maxRow,
  8289. column: this.getLine(maxRow).length
  8290. };
  8291. } else {
  8292. line = this.getLine(docRow);
  8293. foldLine = null;
  8294. }
  8295. if (this.$useWrapMode) {
  8296. var splits = this.$wrapData[docRow];
  8297. if (splits) {
  8298. var splitIndex = Math.floor(screenRow - row);
  8299. column = splits[splitIndex];
  8300. if(splitIndex > 0 && splits.length) {
  8301. docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
  8302. line = line.substring(docColumn);
  8303. }
  8304. }
  8305. }
  8306. docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
  8307. if (this.$useWrapMode && docColumn >= column)
  8308. docColumn = column - 1;
  8309. if (foldLine)
  8310. return foldLine.idxToPosition(docColumn);
  8311. return {row: docRow, column: docColumn};
  8312. };
  8313. this.documentToScreenPosition = function(docRow, docColumn) {
  8314. if (typeof docColumn === "undefined")
  8315. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  8316. else
  8317. pos = this.$clipPositionToDocument(docRow, docColumn);
  8318. docRow = pos.row;
  8319. docColumn = pos.column;
  8320. var screenRow = 0;
  8321. var foldStartRow = null;
  8322. var fold = null;
  8323. fold = this.getFoldAt(docRow, docColumn, 1);
  8324. if (fold) {
  8325. docRow = fold.start.row;
  8326. docColumn = fold.start.column;
  8327. }
  8328. var rowEnd, row = 0;
  8329. var rowCache = this.$docRowCache;
  8330. var i = this.$getRowCacheIndex(rowCache, docRow);
  8331. var l = rowCache.length;
  8332. if (l && i >= 0) {
  8333. var row = rowCache[i];
  8334. var screenRow = this.$screenRowCache[i];
  8335. var doCache = docRow > rowCache[l - 1];
  8336. } else {
  8337. var doCache = !l;
  8338. }
  8339. var foldLine = this.getNextFoldLine(row);
  8340. var foldStart = foldLine ?foldLine.start.row :Infinity;
  8341. while (row < docRow) {
  8342. if (row >= foldStart) {
  8343. rowEnd = foldLine.end.row + 1;
  8344. if (rowEnd > docRow)
  8345. break;
  8346. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  8347. foldStart = foldLine ?foldLine.start.row :Infinity;
  8348. }
  8349. else {
  8350. rowEnd = row + 1;
  8351. }
  8352. screenRow += this.getRowLength(row);
  8353. row = rowEnd;
  8354. if (doCache) {
  8355. this.$docRowCache.push(row);
  8356. this.$screenRowCache.push(screenRow);
  8357. }
  8358. }
  8359. var textLine = "";
  8360. if (foldLine && row >= foldStart) {
  8361. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  8362. foldStartRow = foldLine.start.row;
  8363. } else {
  8364. textLine = this.getLine(docRow).substring(0, docColumn);
  8365. foldStartRow = docRow;
  8366. }
  8367. if (this.$useWrapMode) {
  8368. var wrapRow = this.$wrapData[foldStartRow];
  8369. if (wrapRow) {
  8370. var screenRowOffset = 0;
  8371. while (textLine.length >= wrapRow[screenRowOffset]) {
  8372. screenRow ++;
  8373. screenRowOffset++;
  8374. }
  8375. textLine = textLine.substring(
  8376. wrapRow[screenRowOffset - 1] || 0, textLine.length
  8377. );
  8378. }
  8379. }
  8380. return {
  8381. row: screenRow,
  8382. column: this.$getStringScreenWidth(textLine)[0]
  8383. };
  8384. };
  8385. this.documentToScreenColumn = function(row, docColumn) {
  8386. return this.documentToScreenPosition(row, docColumn).column;
  8387. };
  8388. this.documentToScreenRow = function(docRow, docColumn) {
  8389. return this.documentToScreenPosition(docRow, docColumn).row;
  8390. };
  8391. this.getScreenLength = function() {
  8392. var screenRows = 0;
  8393. var fold = null;
  8394. if (!this.$useWrapMode) {
  8395. screenRows = this.getLength();
  8396. var foldData = this.$foldData;
  8397. for (var i = 0; i < foldData.length; i++) {
  8398. fold = foldData[i];
  8399. screenRows -= fold.end.row - fold.start.row;
  8400. }
  8401. } else {
  8402. var lastRow = this.$wrapData.length;
  8403. var row = 0, i = 0;
  8404. var fold = this.$foldData[i++];
  8405. var foldStart = fold ? fold.start.row :Infinity;
  8406. while (row < lastRow) {
  8407. var splits = this.$wrapData[row];
  8408. screenRows += splits ? splits.length + 1 : 1;
  8409. row ++;
  8410. if (row > foldStart) {
  8411. row = fold.end.row+1;
  8412. fold = this.$foldData[i++];
  8413. foldStart = fold ?fold.start.row :Infinity;
  8414. }
  8415. }
  8416. }
  8417. if (this.lineWidgets)
  8418. screenRows += this.$getWidgetScreenLength();
  8419. return screenRows;
  8420. };
  8421. this.$setFontMetrics = function(fm) {
  8422. };
  8423. this.destroy = function() {
  8424. if (this.bgTokenizer) {
  8425. this.bgTokenizer.setDocument(null);
  8426. this.bgTokenizer = null;
  8427. }
  8428. this.$stopWorker();
  8429. };
  8430. function isFullWidth(c) {
  8431. if (c < 0x1100)
  8432. return false;
  8433. return c >= 0x1100 && c <= 0x115F ||
  8434. c >= 0x11A3 && c <= 0x11A7 ||
  8435. c >= 0x11FA && c <= 0x11FF ||
  8436. c >= 0x2329 && c <= 0x232A ||
  8437. c >= 0x2E80 && c <= 0x2E99 ||
  8438. c >= 0x2E9B && c <= 0x2EF3 ||
  8439. c >= 0x2F00 && c <= 0x2FD5 ||
  8440. c >= 0x2FF0 && c <= 0x2FFB ||
  8441. c >= 0x3000 && c <= 0x303E ||
  8442. c >= 0x3041 && c <= 0x3096 ||
  8443. c >= 0x3099 && c <= 0x30FF ||
  8444. c >= 0x3105 && c <= 0x312D ||
  8445. c >= 0x3131 && c <= 0x318E ||
  8446. c >= 0x3190 && c <= 0x31BA ||
  8447. c >= 0x31C0 && c <= 0x31E3 ||
  8448. c >= 0x31F0 && c <= 0x321E ||
  8449. c >= 0x3220 && c <= 0x3247 ||
  8450. c >= 0x3250 && c <= 0x32FE ||
  8451. c >= 0x3300 && c <= 0x4DBF ||
  8452. c >= 0x4E00 && c <= 0xA48C ||
  8453. c >= 0xA490 && c <= 0xA4C6 ||
  8454. c >= 0xA960 && c <= 0xA97C ||
  8455. c >= 0xAC00 && c <= 0xD7A3 ||
  8456. c >= 0xD7B0 && c <= 0xD7C6 ||
  8457. c >= 0xD7CB && c <= 0xD7FB ||
  8458. c >= 0xF900 && c <= 0xFAFF ||
  8459. c >= 0xFE10 && c <= 0xFE19 ||
  8460. c >= 0xFE30 && c <= 0xFE52 ||
  8461. c >= 0xFE54 && c <= 0xFE66 ||
  8462. c >= 0xFE68 && c <= 0xFE6B ||
  8463. c >= 0xFF01 && c <= 0xFF60 ||
  8464. c >= 0xFFE0 && c <= 0xFFE6;
  8465. };
  8466. }).call(EditSession.prototype);
  8467. require("./edit_session/folding").Folding.call(EditSession.prototype);
  8468. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  8469. config.defineOptions(EditSession.prototype, "session", {
  8470. wrap: {
  8471. set: function(value) {
  8472. if (!value || value == "off")
  8473. value = false;
  8474. else if (value == "free")
  8475. value = true;
  8476. else if (value == "printMargin")
  8477. value = -1;
  8478. else if (typeof value == "string")
  8479. value = parseInt(value, 10) || false;
  8480. if (this.$wrap == value)
  8481. return;
  8482. this.$wrap = value;
  8483. if (!value) {
  8484. this.setUseWrapMode(false);
  8485. } else {
  8486. var col = typeof value == "number" ? value : null;
  8487. this.setWrapLimitRange(col, col);
  8488. this.setUseWrapMode(true);
  8489. }
  8490. },
  8491. get: function() {
  8492. if (this.getUseWrapMode()) {
  8493. if (this.$wrap == -1)
  8494. return "printMargin";
  8495. if (!this.getWrapLimitRange().min)
  8496. return "free";
  8497. return this.$wrap;
  8498. }
  8499. return "off";
  8500. },
  8501. handlesSet: true
  8502. },
  8503. wrapMethod: {
  8504. set: function(val) {
  8505. val = val == "auto"
  8506. ? this.$mode.type != "text"
  8507. : val != "text";
  8508. if (val != this.$wrapAsCode) {
  8509. this.$wrapAsCode = val;
  8510. if (this.$useWrapMode) {
  8511. this.$modified = true;
  8512. this.$resetRowCache(0);
  8513. this.$updateWrapData(0, this.getLength() - 1);
  8514. }
  8515. }
  8516. },
  8517. initialValue: "auto"
  8518. },
  8519. firstLineNumber: {
  8520. set: function() {this._signal("changeBreakpoint");},
  8521. initialValue: 1
  8522. },
  8523. useWorker: {
  8524. set: function(useWorker) {
  8525. this.$useWorker = useWorker;
  8526. this.$stopWorker();
  8527. if (useWorker)
  8528. this.$startWorker();
  8529. },
  8530. initialValue: true
  8531. },
  8532. useSoftTabs: {initialValue: true},
  8533. tabSize: {
  8534. set: function(tabSize) {
  8535. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  8536. this.$modified = true;
  8537. this.$rowLengthCache = [];
  8538. this.$tabSize = tabSize;
  8539. this._signal("changeTabSize");
  8540. },
  8541. initialValue: 4,
  8542. handlesSet: true
  8543. },
  8544. overwrite: {
  8545. set: function(val) {this._signal("changeOverwrite");},
  8546. initialValue: false
  8547. },
  8548. newLineMode: {
  8549. set: function(val) {this.doc.setNewLineMode(val)},
  8550. get: function() {return this.doc.getNewLineMode()},
  8551. handlesSet: true
  8552. },
  8553. mode: {
  8554. set: function(val) { this.setMode(val) },
  8555. get: function() { return this.$modeId }
  8556. }
  8557. });
  8558. exports.EditSession = EditSession;
  8559. });
  8560. ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  8561. "use strict";
  8562. var lang = require("./lib/lang");
  8563. var oop = require("./lib/oop");
  8564. var Range = require("./range").Range;
  8565. var Search = function() {
  8566. this.$options = {};
  8567. };
  8568. (function() {
  8569. this.set = function(options) {
  8570. oop.mixin(this.$options, options);
  8571. return this;
  8572. };
  8573. this.getOptions = function() {
  8574. return lang.copyObject(this.$options);
  8575. };
  8576. this.setOptions = function(options) {
  8577. this.$options = options;
  8578. };
  8579. this.find = function(session) {
  8580. var options = this.$options;
  8581. var iterator = this.$matchIterator(session, options);
  8582. if (!iterator)
  8583. return false;
  8584. var firstRange = null;
  8585. iterator.forEach(function(range, row, offset) {
  8586. if (!range.start) {
  8587. var column = range.offset + (offset || 0);
  8588. firstRange = new Range(row, column, row, column + range.length);
  8589. if (!range.length && options.start && options.start.start
  8590. && options.skipCurrent != false && firstRange.isEqual(options.start)
  8591. ) {
  8592. firstRange = null;
  8593. return false;
  8594. }
  8595. } else
  8596. firstRange = range;
  8597. return true;
  8598. });
  8599. return firstRange;
  8600. };
  8601. this.findAll = function(session) {
  8602. var options = this.$options;
  8603. if (!options.needle)
  8604. return [];
  8605. this.$assembleRegExp(options);
  8606. var range = options.range;
  8607. var lines = range
  8608. ? session.getLines(range.start.row, range.end.row)
  8609. : session.doc.getAllLines();
  8610. var ranges = [];
  8611. var re = options.re;
  8612. if (options.$isMultiLine) {
  8613. var len = re.length;
  8614. var maxRow = lines.length - len;
  8615. var prevRange;
  8616. outer: for (var row = re.offset || 0; row <= maxRow; row++) {
  8617. for (var j = 0; j < len; j++)
  8618. if (lines[row + j].search(re[j]) == -1)
  8619. continue outer;
  8620. var startLine = lines[row];
  8621. var line = lines[row + len - 1];
  8622. var startIndex = startLine.length - startLine.match(re[0])[0].length;
  8623. var endIndex = line.match(re[len - 1])[0].length;
  8624. if (prevRange && prevRange.end.row === row &&
  8625. prevRange.end.column > startIndex
  8626. ) {
  8627. continue;
  8628. }
  8629. ranges.push(prevRange = new Range(
  8630. row, startIndex, row + len - 1, endIndex
  8631. ));
  8632. if (len > 2)
  8633. row = row + len - 2;
  8634. }
  8635. } else {
  8636. for (var i = 0; i < lines.length; i++) {
  8637. var matches = lang.getMatchOffsets(lines[i], re);
  8638. for (var j = 0; j < matches.length; j++) {
  8639. var match = matches[j];
  8640. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  8641. }
  8642. }
  8643. }
  8644. if (range) {
  8645. var startColumn = range.start.column;
  8646. var endColumn = range.start.column;
  8647. var i = 0, j = ranges.length - 1;
  8648. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  8649. i++;
  8650. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  8651. j--;
  8652. ranges = ranges.slice(i, j + 1);
  8653. for (i = 0, j = ranges.length; i < j; i++) {
  8654. ranges[i].start.row += range.start.row;
  8655. ranges[i].end.row += range.start.row;
  8656. }
  8657. }
  8658. return ranges;
  8659. };
  8660. this.replace = function(input, replacement) {
  8661. var options = this.$options;
  8662. var re = this.$assembleRegExp(options);
  8663. if (options.$isMultiLine)
  8664. return replacement;
  8665. if (!re)
  8666. return;
  8667. var match = re.exec(input);
  8668. if (!match || match[0].length != input.length)
  8669. return null;
  8670. replacement = input.replace(re, replacement);
  8671. if (options.preserveCase) {
  8672. replacement = replacement.split("");
  8673. for (var i = Math.min(input.length, input.length); i--; ) {
  8674. var ch = input[i];
  8675. if (ch && ch.toLowerCase() != ch)
  8676. replacement[i] = replacement[i].toUpperCase();
  8677. else
  8678. replacement[i] = replacement[i].toLowerCase();
  8679. }
  8680. replacement = replacement.join("");
  8681. }
  8682. return replacement;
  8683. };
  8684. this.$matchIterator = function(session, options) {
  8685. var re = this.$assembleRegExp(options);
  8686. if (!re)
  8687. return false;
  8688. var callback;
  8689. if (options.$isMultiLine) {
  8690. var len = re.length;
  8691. var matchIterator = function(line, row, offset) {
  8692. var startIndex = line.search(re[0]);
  8693. if (startIndex == -1)
  8694. return;
  8695. for (var i = 1; i < len; i++) {
  8696. line = session.getLine(row + i);
  8697. if (line.search(re[i]) == -1)
  8698. return;
  8699. }
  8700. var endIndex = line.match(re[len - 1])[0].length;
  8701. var range = new Range(row, startIndex, row + len - 1, endIndex);
  8702. if (re.offset == 1) {
  8703. range.start.row--;
  8704. range.start.column = Number.MAX_VALUE;
  8705. } else if (offset)
  8706. range.start.column += offset;
  8707. if (callback(range))
  8708. return true;
  8709. };
  8710. } else if (options.backwards) {
  8711. var matchIterator = function(line, row, startIndex) {
  8712. var matches = lang.getMatchOffsets(line, re);
  8713. for (var i = matches.length-1; i >= 0; i--)
  8714. if (callback(matches[i], row, startIndex))
  8715. return true;
  8716. };
  8717. } else {
  8718. var matchIterator = function(line, row, startIndex) {
  8719. var matches = lang.getMatchOffsets(line, re);
  8720. for (var i = 0; i < matches.length; i++)
  8721. if (callback(matches[i], row, startIndex))
  8722. return true;
  8723. };
  8724. }
  8725. var lineIterator = this.$lineIterator(session, options);
  8726. return {
  8727. forEach: function(_callback) {
  8728. callback = _callback;
  8729. lineIterator.forEach(matchIterator);
  8730. }
  8731. };
  8732. };
  8733. this.$assembleRegExp = function(options, $disableFakeMultiline) {
  8734. if (options.needle instanceof RegExp)
  8735. return options.re = options.needle;
  8736. var needle = options.needle;
  8737. if (!options.needle)
  8738. return options.re = false;
  8739. if (!options.regExp)
  8740. needle = lang.escapeRegExp(needle);
  8741. if (options.wholeWord)
  8742. needle = "\\b" + needle + "\\b";
  8743. var modifier = options.caseSensitive ? "gm" : "gmi";
  8744. options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
  8745. if (options.$isMultiLine)
  8746. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  8747. try {
  8748. var re = new RegExp(needle, modifier);
  8749. } catch(e) {
  8750. re = false;
  8751. }
  8752. return options.re = re;
  8753. };
  8754. this.$assembleMultilineRegExp = function(needle, modifier) {
  8755. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  8756. var re = [];
  8757. for (var i = 0; i < parts.length; i++) try {
  8758. re.push(new RegExp(parts[i], modifier));
  8759. } catch(e) {
  8760. return false;
  8761. }
  8762. if (parts[0] == "") {
  8763. re.shift();
  8764. re.offset = 1;
  8765. } else {
  8766. re.offset = 0;
  8767. }
  8768. return re;
  8769. };
  8770. this.$lineIterator = function(session, options) {
  8771. var backwards = options.backwards == true;
  8772. var skipCurrent = options.skipCurrent != false;
  8773. var range = options.range;
  8774. var start = options.start;
  8775. if (!start)
  8776. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  8777. if (start.start)
  8778. start = start[skipCurrent != backwards ? "end" : "start"];
  8779. var firstRow = range ? range.start.row : 0;
  8780. var lastRow = range ? range.end.row : session.getLength() - 1;
  8781. var forEach = backwards ? function(callback) {
  8782. var row = start.row;
  8783. var line = session.getLine(row).substring(0, start.column);
  8784. if (callback(line, row))
  8785. return;
  8786. for (row--; row >= firstRow; row--)
  8787. if (callback(session.getLine(row), row))
  8788. return;
  8789. if (options.wrap == false)
  8790. return;
  8791. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  8792. if (callback(session.getLine(row), row))
  8793. return;
  8794. } : function(callback) {
  8795. var row = start.row;
  8796. var line = session.getLine(row).substr(start.column);
  8797. if (callback(line, row, start.column))
  8798. return;
  8799. for (row = row+1; row <= lastRow; row++)
  8800. if (callback(session.getLine(row), row))
  8801. return;
  8802. if (options.wrap == false)
  8803. return;
  8804. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  8805. if (callback(session.getLine(row), row))
  8806. return;
  8807. };
  8808. return {forEach: forEach};
  8809. };
  8810. }).call(Search.prototype);
  8811. exports.Search = Search;
  8812. });
  8813. ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  8814. "use strict";
  8815. var keyUtil = require("../lib/keys");
  8816. var useragent = require("../lib/useragent");
  8817. var KEY_MODS = keyUtil.KEY_MODS;
  8818. function HashHandler(config, platform) {
  8819. this.platform = platform || (useragent.isMac ? "mac" : "win");
  8820. this.commands = {};
  8821. this.commandKeyBinding = {};
  8822. this.addCommands(config);
  8823. this.$singleCommand = true;
  8824. }
  8825. function MultiHashHandler(config, platform) {
  8826. HashHandler.call(this, config, platform);
  8827. this.$singleCommand = false;
  8828. }
  8829. MultiHashHandler.prototype = HashHandler.prototype;
  8830. (function() {
  8831. this.addCommand = function(command) {
  8832. if (this.commands[command.name])
  8833. this.removeCommand(command);
  8834. this.commands[command.name] = command;
  8835. if (command.bindKey)
  8836. this._buildKeyHash(command);
  8837. };
  8838. this.removeCommand = function(command, keepCommand) {
  8839. var name = command && (typeof command === 'string' ? command : command.name);
  8840. command = this.commands[name];
  8841. if (!keepCommand)
  8842. delete this.commands[name];
  8843. var ckb = this.commandKeyBinding;
  8844. for (var keyId in ckb) {
  8845. var cmdGroup = ckb[keyId];
  8846. if (cmdGroup == command) {
  8847. delete ckb[keyId];
  8848. } else if (Array.isArray(cmdGroup)) {
  8849. var i = cmdGroup.indexOf(command);
  8850. if (i != -1) {
  8851. cmdGroup.splice(i, 1);
  8852. if (cmdGroup.length == 1)
  8853. ckb[keyId] = cmdGroup[0];
  8854. }
  8855. }
  8856. }
  8857. };
  8858. this.bindKey = function(key, command, asDefault) {
  8859. if (typeof key == "object")
  8860. key = key[this.platform];
  8861. if (!key)
  8862. return;
  8863. if (typeof command == "function")
  8864. return this.addCommand({exec: command, bindKey: key, name: command.name || key});
  8865. key.split("|").forEach(function(keyPart) {
  8866. var chain = "";
  8867. if (keyPart.indexOf(" ") != -1) {
  8868. var parts = keyPart.split(/\s+/);
  8869. keyPart = parts.pop();
  8870. parts.forEach(function(keyPart) {
  8871. var binding = this.parseKeys(keyPart);
  8872. var id = KEY_MODS[binding.hashId] + binding.key;
  8873. chain += (chain ? " " : "") + id;
  8874. this._addCommandToBinding(chain, "chainKeys");
  8875. }, this);
  8876. chain += " ";
  8877. }
  8878. var binding = this.parseKeys(keyPart);
  8879. var id = KEY_MODS[binding.hashId] + binding.key;
  8880. this._addCommandToBinding(chain + id, command, asDefault);
  8881. }, this);
  8882. };
  8883. this._addCommandToBinding = function(keyId, command, asDefault) {
  8884. var ckb = this.commandKeyBinding, i;
  8885. if (!command) {
  8886. delete ckb[keyId];
  8887. } else if (!ckb[keyId] || this.$singleCommand) {
  8888. ckb[keyId] = command;
  8889. } else {
  8890. if (!Array.isArray(ckb[keyId])) {
  8891. ckb[keyId] = [ckb[keyId]];
  8892. } else if ((i = ckb[keyId].indexOf(command)) != -1) {
  8893. ckb[keyId].splice(i, 1);
  8894. }
  8895. if (asDefault || command.isDefault)
  8896. ckb[keyId].unshift(command);
  8897. else
  8898. ckb[keyId].push(command);
  8899. }
  8900. };
  8901. this.addCommands = function(commands) {
  8902. commands && Object.keys(commands).forEach(function(name) {
  8903. var command = commands[name];
  8904. if (!command)
  8905. return;
  8906. if (typeof command === "string")
  8907. return this.bindKey(command, name);
  8908. if (typeof command === "function")
  8909. command = { exec: command };
  8910. if (typeof command !== "object")
  8911. return;
  8912. if (!command.name)
  8913. command.name = name;
  8914. this.addCommand(command);
  8915. }, this);
  8916. };
  8917. this.removeCommands = function(commands) {
  8918. Object.keys(commands).forEach(function(name) {
  8919. this.removeCommand(commands[name]);
  8920. }, this);
  8921. };
  8922. this.bindKeys = function(keyList) {
  8923. Object.keys(keyList).forEach(function(key) {
  8924. this.bindKey(key, keyList[key]);
  8925. }, this);
  8926. };
  8927. this._buildKeyHash = function(command) {
  8928. this.bindKey(command.bindKey, command);
  8929. };
  8930. this.parseKeys = function(keys) {
  8931. var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
  8932. var key = parts.pop();
  8933. var keyCode = keyUtil[key];
  8934. if (keyUtil.FUNCTION_KEYS[keyCode])
  8935. key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
  8936. else if (!parts.length)
  8937. return {key: key, hashId: -1};
  8938. else if (parts.length == 1 && parts[0] == "shift")
  8939. return {key: key.toUpperCase(), hashId: -1};
  8940. var hashId = 0;
  8941. for (var i = parts.length; i--;) {
  8942. var modifier = keyUtil.KEY_MODS[parts[i]];
  8943. if (modifier == null) {
  8944. if (typeof console != "undefined")
  8945. console.error("invalid modifier " + parts[i] + " in " + keys);
  8946. return false;
  8947. }
  8948. hashId |= modifier;
  8949. }
  8950. return {key: key, hashId: hashId};
  8951. };
  8952. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  8953. var key = KEY_MODS[hashId] + keyString;
  8954. return this.commandKeyBinding[key];
  8955. };
  8956. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  8957. var key = KEY_MODS[hashId] + keyString;
  8958. var command = this.commandKeyBinding[key];
  8959. if (data.$keyChain) {
  8960. data.$keyChain += " " + key;
  8961. command = this.commandKeyBinding[data.$keyChain] || command;
  8962. }
  8963. if (command) {
  8964. if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
  8965. data.$keyChain = data.$keyChain || key;
  8966. return {command: "null"};
  8967. }
  8968. }
  8969. if (data.$keyChain && keyCode > 0)
  8970. data.$keyChain = "";
  8971. return {command: command};
  8972. };
  8973. }).call(HashHandler.prototype);
  8974. exports.HashHandler = HashHandler;
  8975. exports.MultiHashHandler = MultiHashHandler;
  8976. });
  8977. ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
  8978. "use strict";
  8979. var oop = require("../lib/oop");
  8980. var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
  8981. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  8982. var CommandManager = function(platform, commands) {
  8983. MultiHashHandler.call(this, commands, platform);
  8984. this.byName = this.commands;
  8985. this.setDefaultHandler("exec", function(e) {
  8986. return e.command.exec(e.editor, e.args || {});
  8987. });
  8988. };
  8989. oop.inherits(CommandManager, MultiHashHandler);
  8990. (function() {
  8991. oop.implement(this, EventEmitter);
  8992. this.exec = function(command, editor, args) {
  8993. if (Array.isArray(command)) {
  8994. for (var i = command.length; i--; ) {
  8995. if (this.exec(command[i], editor, args)) return true;
  8996. }
  8997. return false;
  8998. }
  8999. if (typeof command === "string")
  9000. command = this.commands[command];
  9001. if (!command)
  9002. return false;
  9003. if (editor && editor.$readOnly && !command.readOnly)
  9004. return false;
  9005. var e = {editor: editor, command: command, args: args};
  9006. e.returnValue = this._emit("exec", e);
  9007. this._signal("afterExec", e);
  9008. return e.returnValue === false ? false : true;
  9009. };
  9010. this.toggleRecording = function(editor) {
  9011. if (this.$inReplay)
  9012. return;
  9013. editor && editor._emit("changeStatus");
  9014. if (this.recording) {
  9015. this.macro.pop();
  9016. this.removeEventListener("exec", this.$addCommandToMacro);
  9017. if (!this.macro.length)
  9018. this.macro = this.oldMacro;
  9019. return this.recording = false;
  9020. }
  9021. if (!this.$addCommandToMacro) {
  9022. this.$addCommandToMacro = function(e) {
  9023. this.macro.push([e.command, e.args]);
  9024. }.bind(this);
  9025. }
  9026. this.oldMacro = this.macro;
  9027. this.macro = [];
  9028. this.on("exec", this.$addCommandToMacro);
  9029. return this.recording = true;
  9030. };
  9031. this.replay = function(editor) {
  9032. if (this.$inReplay || !this.macro)
  9033. return;
  9034. if (this.recording)
  9035. return this.toggleRecording(editor);
  9036. try {
  9037. this.$inReplay = true;
  9038. this.macro.forEach(function(x) {
  9039. if (typeof x == "string")
  9040. this.exec(x, editor);
  9041. else
  9042. this.exec(x[0], editor, x[1]);
  9043. }, this);
  9044. } finally {
  9045. this.$inReplay = false;
  9046. }
  9047. };
  9048. this.trimMacro = function(m) {
  9049. return m.map(function(x){
  9050. if (typeof x[0] != "string")
  9051. x[0] = x[0].name;
  9052. if (!x[1])
  9053. x = x[0];
  9054. return x;
  9055. });
  9056. };
  9057. }).call(CommandManager.prototype);
  9058. exports.CommandManager = CommandManager;
  9059. });
  9060. ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
  9061. "use strict";
  9062. var lang = require("../lib/lang");
  9063. var config = require("../config");
  9064. var Range = require("../range").Range;
  9065. function bindKey(win, mac) {
  9066. return {win: win, mac: mac};
  9067. }
  9068. exports.commands = [{
  9069. name: "showSettingsMenu",
  9070. bindKey: bindKey("Ctrl-,", "Command-,"),
  9071. exec: function(editor) {
  9072. config.loadModule("ace/ext/settings_menu", function(module) {
  9073. module.init(editor);
  9074. editor.showSettingsMenu();
  9075. });
  9076. },
  9077. readOnly: true
  9078. }, {
  9079. name: "goToNextError",
  9080. bindKey: bindKey("Alt-E", "Ctrl-E"),
  9081. exec: function(editor) {
  9082. config.loadModule("ace/ext/error_marker", function(module) {
  9083. module.showErrorMarker(editor, 1);
  9084. });
  9085. },
  9086. scrollIntoView: "animate",
  9087. readOnly: true
  9088. }, {
  9089. name: "goToPreviousError",
  9090. bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
  9091. exec: function(editor) {
  9092. config.loadModule("ace/ext/error_marker", function(module) {
  9093. module.showErrorMarker(editor, -1);
  9094. });
  9095. },
  9096. scrollIntoView: "animate",
  9097. readOnly: true
  9098. }, {
  9099. name: "selectall",
  9100. bindKey: bindKey("Ctrl-A", "Command-A"),
  9101. exec: function(editor) { editor.selectAll(); },
  9102. readOnly: true
  9103. }, {
  9104. name: "centerselection",
  9105. bindKey: bindKey(null, "Ctrl-L"),
  9106. exec: function(editor) { editor.centerSelection(); },
  9107. readOnly: true
  9108. }, {
  9109. name: "gotoline",
  9110. bindKey: bindKey("Ctrl-L", "Command-L"),
  9111. exec: function(editor) {
  9112. var line = parseInt(prompt("Enter line number:"), 10);
  9113. if (!isNaN(line)) {
  9114. editor.gotoLine(line);
  9115. }
  9116. },
  9117. readOnly: true
  9118. }, {
  9119. name: "fold",
  9120. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  9121. exec: function(editor) { editor.session.toggleFold(false); },
  9122. multiSelectAction: "forEach",
  9123. scrollIntoView: "center",
  9124. readOnly: true
  9125. }, {
  9126. name: "unfold",
  9127. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  9128. exec: function(editor) { editor.session.toggleFold(true); },
  9129. multiSelectAction: "forEach",
  9130. scrollIntoView: "center",
  9131. readOnly: true
  9132. }, {
  9133. name: "toggleFoldWidget",
  9134. bindKey: bindKey("F2", "F2"),
  9135. exec: function(editor) { editor.session.toggleFoldWidget(); },
  9136. multiSelectAction: "forEach",
  9137. scrollIntoView: "center",
  9138. readOnly: true
  9139. }, {
  9140. name: "toggleParentFoldWidget",
  9141. bindKey: bindKey("Alt-F2", "Alt-F2"),
  9142. exec: function(editor) { editor.session.toggleFoldWidget(true); },
  9143. multiSelectAction: "forEach",
  9144. scrollIntoView: "center",
  9145. readOnly: true
  9146. }, {
  9147. name: "foldall",
  9148. bindKey: bindKey(null, "Ctrl-Command-Option-0"),
  9149. exec: function(editor) { editor.session.foldAll(); },
  9150. scrollIntoView: "center",
  9151. readOnly: true
  9152. }, {
  9153. name: "foldOther",
  9154. bindKey: bindKey("Alt-0", "Command-Option-0"),
  9155. exec: function(editor) {
  9156. editor.session.foldAll();
  9157. editor.session.unfold(editor.selection.getAllRanges());
  9158. },
  9159. scrollIntoView: "center",
  9160. readOnly: true
  9161. }, {
  9162. name: "unfoldall",
  9163. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  9164. exec: function(editor) { editor.session.unfold(); },
  9165. scrollIntoView: "center",
  9166. readOnly: true
  9167. }, {
  9168. name: "findnext",
  9169. bindKey: bindKey("Ctrl-K", "Command-G"),
  9170. exec: function(editor) { editor.findNext(); },
  9171. multiSelectAction: "forEach",
  9172. scrollIntoView: "center",
  9173. readOnly: true
  9174. }, {
  9175. name: "findprevious",
  9176. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  9177. exec: function(editor) { editor.findPrevious(); },
  9178. multiSelectAction: "forEach",
  9179. scrollIntoView: "center",
  9180. readOnly: true
  9181. }, {
  9182. name: "selectOrFindNext",
  9183. bindKey: bindKey("Alt-K", "Ctrl-G"),
  9184. exec: function(editor) {
  9185. if (editor.selection.isEmpty())
  9186. editor.selection.selectWord();
  9187. else
  9188. editor.findNext();
  9189. },
  9190. readOnly: true
  9191. }, {
  9192. name: "selectOrFindPrevious",
  9193. bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
  9194. exec: function(editor) {
  9195. if (editor.selection.isEmpty())
  9196. editor.selection.selectWord();
  9197. else
  9198. editor.findPrevious();
  9199. },
  9200. readOnly: true
  9201. }, {
  9202. name: "find",
  9203. bindKey: bindKey("Ctrl-F", "Command-F"),
  9204. exec: function(editor) {
  9205. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
  9206. },
  9207. readOnly: true
  9208. }, {
  9209. name: "overwrite",
  9210. bindKey: "Insert",
  9211. exec: function(editor) { editor.toggleOverwrite(); },
  9212. readOnly: true
  9213. }, {
  9214. name: "selecttostart",
  9215. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
  9216. exec: function(editor) { editor.getSelection().selectFileStart(); },
  9217. multiSelectAction: "forEach",
  9218. readOnly: true,
  9219. scrollIntoView: "animate",
  9220. aceCommandGroup: "fileJump"
  9221. }, {
  9222. name: "gotostart",
  9223. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  9224. exec: function(editor) { editor.navigateFileStart(); },
  9225. multiSelectAction: "forEach",
  9226. readOnly: true,
  9227. scrollIntoView: "animate",
  9228. aceCommandGroup: "fileJump"
  9229. }, {
  9230. name: "selectup",
  9231. bindKey: bindKey("Shift-Up", "Shift-Up"),
  9232. exec: function(editor) { editor.getSelection().selectUp(); },
  9233. multiSelectAction: "forEach",
  9234. scrollIntoView: "cursor",
  9235. readOnly: true
  9236. }, {
  9237. name: "golineup",
  9238. bindKey: bindKey("Up", "Up|Ctrl-P"),
  9239. exec: function(editor, args) { editor.navigateUp(args.times); },
  9240. multiSelectAction: "forEach",
  9241. scrollIntoView: "cursor",
  9242. readOnly: true
  9243. }, {
  9244. name: "selecttoend",
  9245. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
  9246. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  9247. multiSelectAction: "forEach",
  9248. readOnly: true,
  9249. scrollIntoView: "animate",
  9250. aceCommandGroup: "fileJump"
  9251. }, {
  9252. name: "gotoend",
  9253. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  9254. exec: function(editor) { editor.navigateFileEnd(); },
  9255. multiSelectAction: "forEach",
  9256. readOnly: true,
  9257. scrollIntoView: "animate",
  9258. aceCommandGroup: "fileJump"
  9259. }, {
  9260. name: "selectdown",
  9261. bindKey: bindKey("Shift-Down", "Shift-Down"),
  9262. exec: function(editor) { editor.getSelection().selectDown(); },
  9263. multiSelectAction: "forEach",
  9264. scrollIntoView: "cursor",
  9265. readOnly: true
  9266. }, {
  9267. name: "golinedown",
  9268. bindKey: bindKey("Down", "Down|Ctrl-N"),
  9269. exec: function(editor, args) { editor.navigateDown(args.times); },
  9270. multiSelectAction: "forEach",
  9271. scrollIntoView: "cursor",
  9272. readOnly: true
  9273. }, {
  9274. name: "selectwordleft",
  9275. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  9276. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  9277. multiSelectAction: "forEach",
  9278. scrollIntoView: "cursor",
  9279. readOnly: true
  9280. }, {
  9281. name: "gotowordleft",
  9282. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  9283. exec: function(editor) { editor.navigateWordLeft(); },
  9284. multiSelectAction: "forEach",
  9285. scrollIntoView: "cursor",
  9286. readOnly: true
  9287. }, {
  9288. name: "selecttolinestart",
  9289. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
  9290. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9291. multiSelectAction: "forEach",
  9292. scrollIntoView: "cursor",
  9293. readOnly: true
  9294. }, {
  9295. name: "gotolinestart",
  9296. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  9297. exec: function(editor) { editor.navigateLineStart(); },
  9298. multiSelectAction: "forEach",
  9299. scrollIntoView: "cursor",
  9300. readOnly: true
  9301. }, {
  9302. name: "selectleft",
  9303. bindKey: bindKey("Shift-Left", "Shift-Left"),
  9304. exec: function(editor) { editor.getSelection().selectLeft(); },
  9305. multiSelectAction: "forEach",
  9306. scrollIntoView: "cursor",
  9307. readOnly: true
  9308. }, {
  9309. name: "gotoleft",
  9310. bindKey: bindKey("Left", "Left|Ctrl-B"),
  9311. exec: function(editor, args) { editor.navigateLeft(args.times); },
  9312. multiSelectAction: "forEach",
  9313. scrollIntoView: "cursor",
  9314. readOnly: true
  9315. }, {
  9316. name: "selectwordright",
  9317. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  9318. exec: function(editor) { editor.getSelection().selectWordRight(); },
  9319. multiSelectAction: "forEach",
  9320. scrollIntoView: "cursor",
  9321. readOnly: true
  9322. }, {
  9323. name: "gotowordright",
  9324. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  9325. exec: function(editor) { editor.navigateWordRight(); },
  9326. multiSelectAction: "forEach",
  9327. scrollIntoView: "cursor",
  9328. readOnly: true
  9329. }, {
  9330. name: "selecttolineend",
  9331. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
  9332. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9333. multiSelectAction: "forEach",
  9334. scrollIntoView: "cursor",
  9335. readOnly: true
  9336. }, {
  9337. name: "gotolineend",
  9338. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  9339. exec: function(editor) { editor.navigateLineEnd(); },
  9340. multiSelectAction: "forEach",
  9341. scrollIntoView: "cursor",
  9342. readOnly: true
  9343. }, {
  9344. name: "selectright",
  9345. bindKey: bindKey("Shift-Right", "Shift-Right"),
  9346. exec: function(editor) { editor.getSelection().selectRight(); },
  9347. multiSelectAction: "forEach",
  9348. scrollIntoView: "cursor",
  9349. readOnly: true
  9350. }, {
  9351. name: "gotoright",
  9352. bindKey: bindKey("Right", "Right|Ctrl-F"),
  9353. exec: function(editor, args) { editor.navigateRight(args.times); },
  9354. multiSelectAction: "forEach",
  9355. scrollIntoView: "cursor",
  9356. readOnly: true
  9357. }, {
  9358. name: "selectpagedown",
  9359. bindKey: "Shift-PageDown",
  9360. exec: function(editor) { editor.selectPageDown(); },
  9361. readOnly: true
  9362. }, {
  9363. name: "pagedown",
  9364. bindKey: bindKey(null, "Option-PageDown"),
  9365. exec: function(editor) { editor.scrollPageDown(); },
  9366. readOnly: true
  9367. }, {
  9368. name: "gotopagedown",
  9369. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  9370. exec: function(editor) { editor.gotoPageDown(); },
  9371. readOnly: true
  9372. }, {
  9373. name: "selectpageup",
  9374. bindKey: "Shift-PageUp",
  9375. exec: function(editor) { editor.selectPageUp(); },
  9376. readOnly: true
  9377. }, {
  9378. name: "pageup",
  9379. bindKey: bindKey(null, "Option-PageUp"),
  9380. exec: function(editor) { editor.scrollPageUp(); },
  9381. readOnly: true
  9382. }, {
  9383. name: "gotopageup",
  9384. bindKey: "PageUp",
  9385. exec: function(editor) { editor.gotoPageUp(); },
  9386. readOnly: true
  9387. }, {
  9388. name: "scrollup",
  9389. bindKey: bindKey("Ctrl-Up", null),
  9390. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  9391. readOnly: true
  9392. }, {
  9393. name: "scrolldown",
  9394. bindKey: bindKey("Ctrl-Down", null),
  9395. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  9396. readOnly: true
  9397. }, {
  9398. name: "selectlinestart",
  9399. bindKey: "Shift-Home",
  9400. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9401. multiSelectAction: "forEach",
  9402. scrollIntoView: "cursor",
  9403. readOnly: true
  9404. }, {
  9405. name: "selectlineend",
  9406. bindKey: "Shift-End",
  9407. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9408. multiSelectAction: "forEach",
  9409. scrollIntoView: "cursor",
  9410. readOnly: true
  9411. }, {
  9412. name: "togglerecording",
  9413. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  9414. exec: function(editor) { editor.commands.toggleRecording(editor); },
  9415. readOnly: true
  9416. }, {
  9417. name: "replaymacro",
  9418. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  9419. exec: function(editor) { editor.commands.replay(editor); },
  9420. readOnly: true
  9421. }, {
  9422. name: "jumptomatching",
  9423. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  9424. exec: function(editor) { editor.jumpToMatching(); },
  9425. multiSelectAction: "forEach",
  9426. scrollIntoView: "animate",
  9427. readOnly: true
  9428. }, {
  9429. name: "selecttomatching",
  9430. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  9431. exec: function(editor) { editor.jumpToMatching(true); },
  9432. multiSelectAction: "forEach",
  9433. scrollIntoView: "animate",
  9434. readOnly: true
  9435. }, {
  9436. name: "expandToMatching",
  9437. bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
  9438. exec: function(editor) { editor.jumpToMatching(true, true); },
  9439. multiSelectAction: "forEach",
  9440. scrollIntoView: "animate",
  9441. readOnly: true
  9442. }, {
  9443. name: "passKeysToBrowser",
  9444. bindKey: bindKey(null, null),
  9445. exec: function() {},
  9446. passEvent: true,
  9447. readOnly: true
  9448. },
  9449. {
  9450. name: "cut",
  9451. exec: function(editor) {
  9452. var range = editor.getSelectionRange();
  9453. editor._emit("cut", range);
  9454. if (!editor.selection.isEmpty()) {
  9455. editor.session.remove(range);
  9456. editor.clearSelection();
  9457. }
  9458. },
  9459. scrollIntoView: "cursor",
  9460. multiSelectAction: "forEach"
  9461. }, {
  9462. name: "removeline",
  9463. bindKey: bindKey("Ctrl-D", "Command-D"),
  9464. exec: function(editor) { editor.removeLines(); },
  9465. scrollIntoView: "cursor",
  9466. multiSelectAction: "forEachLine"
  9467. }, {
  9468. name: "duplicateSelection",
  9469. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  9470. exec: function(editor) { editor.duplicateSelection(); },
  9471. scrollIntoView: "cursor",
  9472. multiSelectAction: "forEach"
  9473. }, {
  9474. name: "sortlines",
  9475. bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
  9476. exec: function(editor) { editor.sortLines(); },
  9477. scrollIntoView: "selection",
  9478. multiSelectAction: "forEachLine"
  9479. }, {
  9480. name: "togglecomment",
  9481. bindKey: bindKey("Ctrl-/", "Command-/"),
  9482. exec: function(editor) { editor.toggleCommentLines(); },
  9483. multiSelectAction: "forEachLine",
  9484. scrollIntoView: "selectionPart"
  9485. }, {
  9486. name: "toggleBlockComment",
  9487. bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
  9488. exec: function(editor) { editor.toggleBlockComment(); },
  9489. multiSelectAction: "forEach",
  9490. scrollIntoView: "selectionPart"
  9491. }, {
  9492. name: "modifyNumberUp",
  9493. bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
  9494. exec: function(editor) { editor.modifyNumber(1); },
  9495. scrollIntoView: "cursor",
  9496. multiSelectAction: "forEach"
  9497. }, {
  9498. name: "modifyNumberDown",
  9499. bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
  9500. exec: function(editor) { editor.modifyNumber(-1); },
  9501. scrollIntoView: "cursor",
  9502. multiSelectAction: "forEach"
  9503. }, {
  9504. name: "replace",
  9505. bindKey: bindKey("Ctrl-H", "Command-Option-F"),
  9506. exec: function(editor) {
  9507. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
  9508. }
  9509. }, {
  9510. name: "undo",
  9511. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  9512. exec: function(editor) { editor.undo(); }
  9513. }, {
  9514. name: "redo",
  9515. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  9516. exec: function(editor) { editor.redo(); }
  9517. }, {
  9518. name: "copylinesup",
  9519. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  9520. exec: function(editor) { editor.copyLinesUp(); },
  9521. scrollIntoView: "cursor"
  9522. }, {
  9523. name: "movelinesup",
  9524. bindKey: bindKey("Alt-Up", "Option-Up"),
  9525. exec: function(editor) { editor.moveLinesUp(); },
  9526. scrollIntoView: "cursor"
  9527. }, {
  9528. name: "copylinesdown",
  9529. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  9530. exec: function(editor) { editor.copyLinesDown(); },
  9531. scrollIntoView: "cursor"
  9532. }, {
  9533. name: "movelinesdown",
  9534. bindKey: bindKey("Alt-Down", "Option-Down"),
  9535. exec: function(editor) { editor.moveLinesDown(); },
  9536. scrollIntoView: "cursor"
  9537. }, {
  9538. name: "del",
  9539. bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
  9540. exec: function(editor) { editor.remove("right"); },
  9541. multiSelectAction: "forEach",
  9542. scrollIntoView: "cursor"
  9543. }, {
  9544. name: "backspace",
  9545. bindKey: bindKey(
  9546. "Shift-Backspace|Backspace",
  9547. "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  9548. ),
  9549. exec: function(editor) { editor.remove("left"); },
  9550. multiSelectAction: "forEach",
  9551. scrollIntoView: "cursor"
  9552. }, {
  9553. name: "cut_or_delete",
  9554. bindKey: bindKey("Shift-Delete", null),
  9555. exec: function(editor) {
  9556. if (editor.selection.isEmpty()) {
  9557. editor.remove("left");
  9558. } else {
  9559. return false;
  9560. }
  9561. },
  9562. multiSelectAction: "forEach",
  9563. scrollIntoView: "cursor"
  9564. }, {
  9565. name: "removetolinestart",
  9566. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  9567. exec: function(editor) { editor.removeToLineStart(); },
  9568. multiSelectAction: "forEach",
  9569. scrollIntoView: "cursor"
  9570. }, {
  9571. name: "removetolineend",
  9572. bindKey: bindKey("Alt-Delete", "Ctrl-K"),
  9573. exec: function(editor) { editor.removeToLineEnd(); },
  9574. multiSelectAction: "forEach",
  9575. scrollIntoView: "cursor"
  9576. }, {
  9577. name: "removewordleft",
  9578. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  9579. exec: function(editor) { editor.removeWordLeft(); },
  9580. multiSelectAction: "forEach",
  9581. scrollIntoView: "cursor"
  9582. }, {
  9583. name: "removewordright",
  9584. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  9585. exec: function(editor) { editor.removeWordRight(); },
  9586. multiSelectAction: "forEach",
  9587. scrollIntoView: "cursor"
  9588. }, {
  9589. name: "outdent",
  9590. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  9591. exec: function(editor) { editor.blockOutdent(); },
  9592. multiSelectAction: "forEach",
  9593. scrollIntoView: "selectionPart"
  9594. }, {
  9595. name: "indent",
  9596. bindKey: bindKey("Tab", "Tab"),
  9597. exec: function(editor) { editor.indent(); },
  9598. multiSelectAction: "forEach",
  9599. scrollIntoView: "selectionPart"
  9600. }, {
  9601. name: "blockoutdent",
  9602. bindKey: bindKey("Ctrl-[", "Ctrl-["),
  9603. exec: function(editor) { editor.blockOutdent(); },
  9604. multiSelectAction: "forEachLine",
  9605. scrollIntoView: "selectionPart"
  9606. }, {
  9607. name: "blockindent",
  9608. bindKey: bindKey("Ctrl-]", "Ctrl-]"),
  9609. exec: function(editor) { editor.blockIndent(); },
  9610. multiSelectAction: "forEachLine",
  9611. scrollIntoView: "selectionPart"
  9612. }, {
  9613. name: "insertstring",
  9614. exec: function(editor, str) { editor.insert(str); },
  9615. multiSelectAction: "forEach",
  9616. scrollIntoView: "cursor"
  9617. }, {
  9618. name: "inserttext",
  9619. exec: function(editor, args) {
  9620. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  9621. },
  9622. multiSelectAction: "forEach",
  9623. scrollIntoView: "cursor"
  9624. }, {
  9625. name: "splitline",
  9626. bindKey: bindKey(null, "Ctrl-O"),
  9627. exec: function(editor) { editor.splitLine(); },
  9628. multiSelectAction: "forEach",
  9629. scrollIntoView: "cursor"
  9630. }, {
  9631. name: "transposeletters",
  9632. bindKey: bindKey("Ctrl-T", "Ctrl-T"),
  9633. exec: function(editor) { editor.transposeLetters(); },
  9634. multiSelectAction: function(editor) {editor.transposeSelections(1); },
  9635. scrollIntoView: "cursor"
  9636. }, {
  9637. name: "touppercase",
  9638. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  9639. exec: function(editor) { editor.toUpperCase(); },
  9640. multiSelectAction: "forEach",
  9641. scrollIntoView: "cursor"
  9642. }, {
  9643. name: "tolowercase",
  9644. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  9645. exec: function(editor) { editor.toLowerCase(); },
  9646. multiSelectAction: "forEach",
  9647. scrollIntoView: "cursor"
  9648. }, {
  9649. name: "expandtoline",
  9650. bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
  9651. exec: function(editor) {
  9652. var range = editor.selection.getRange();
  9653. range.start.column = range.end.column = 0;
  9654. range.end.row++;
  9655. editor.selection.setRange(range, false);
  9656. },
  9657. multiSelectAction: "forEach",
  9658. scrollIntoView: "cursor",
  9659. readOnly: true
  9660. }, {
  9661. name: "joinlines",
  9662. bindKey: bindKey(null, null),
  9663. exec: function(editor) {
  9664. var isBackwards = editor.selection.isBackwards();
  9665. var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
  9666. var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
  9667. var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
  9668. var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
  9669. var selectedCount = selectedText.replace(/\n\s*/, " ").length;
  9670. var insertLine = editor.session.doc.getLine(selectionStart.row);
  9671. for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
  9672. var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
  9673. if (curLine.length !== 0) {
  9674. curLine = " " + curLine;
  9675. }
  9676. insertLine += curLine;
  9677. }
  9678. if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
  9679. insertLine += editor.session.doc.getNewLineCharacter();
  9680. }
  9681. editor.clearSelection();
  9682. editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
  9683. if (selectedCount > 0) {
  9684. editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
  9685. editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
  9686. } else {
  9687. firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
  9688. editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
  9689. }
  9690. },
  9691. multiSelectAction: "forEach",
  9692. readOnly: true
  9693. }, {
  9694. name: "invertSelection",
  9695. bindKey: bindKey(null, null),
  9696. exec: function(editor) {
  9697. var endRow = editor.session.doc.getLength() - 1;
  9698. var endCol = editor.session.doc.getLine(endRow).length;
  9699. var ranges = editor.selection.rangeList.ranges;
  9700. var newRanges = [];
  9701. if (ranges.length < 1) {
  9702. ranges = [editor.selection.getRange()];
  9703. }
  9704. for (var i = 0; i < ranges.length; i++) {
  9705. if (i == (ranges.length - 1)) {
  9706. if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
  9707. newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
  9708. }
  9709. }
  9710. if (i === 0) {
  9711. if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
  9712. newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
  9713. }
  9714. } else {
  9715. newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
  9716. }
  9717. }
  9718. editor.exitMultiSelectMode();
  9719. editor.clearSelection();
  9720. for(var i = 0; i < newRanges.length; i++) {
  9721. editor.selection.addRange(newRanges[i], false);
  9722. }
  9723. },
  9724. readOnly: true,
  9725. scrollIntoView: "none"
  9726. }];
  9727. });
  9728. 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) {
  9729. "use strict";
  9730. require("./lib/fixoldbrowsers");
  9731. var oop = require("./lib/oop");
  9732. var dom = require("./lib/dom");
  9733. var lang = require("./lib/lang");
  9734. var useragent = require("./lib/useragent");
  9735. var TextInput = require("./keyboard/textinput").TextInput;
  9736. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  9737. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  9738. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  9739. var EditSession = require("./edit_session").EditSession;
  9740. var Search = require("./search").Search;
  9741. var Range = require("./range").Range;
  9742. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  9743. var CommandManager = require("./commands/command_manager").CommandManager;
  9744. var defaultCommands = require("./commands/default_commands").commands;
  9745. var config = require("./config");
  9746. var TokenIterator = require("./token_iterator").TokenIterator;
  9747. var Editor = function(renderer, session) {
  9748. var container = renderer.getContainerElement();
  9749. this.container = container;
  9750. this.renderer = renderer;
  9751. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  9752. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  9753. this.renderer.textarea = this.textInput.getElement();
  9754. this.keyBinding = new KeyBinding(this);
  9755. this.$mouseHandler = new MouseHandler(this);
  9756. new FoldHandler(this);
  9757. this.$blockScrolling = 0;
  9758. this.$search = new Search().set({
  9759. wrap: true
  9760. });
  9761. this.$historyTracker = this.$historyTracker.bind(this);
  9762. this.commands.on("exec", this.$historyTracker);
  9763. this.$initOperationListeners();
  9764. this._$emitInputEvent = lang.delayedCall(function() {
  9765. this._signal("input", {});
  9766. if (this.session && this.session.bgTokenizer)
  9767. this.session.bgTokenizer.scheduleStart();
  9768. }.bind(this));
  9769. this.on("change", function(_, _self) {
  9770. _self._$emitInputEvent.schedule(31);
  9771. });
  9772. this.setSession(session || new EditSession(""));
  9773. config.resetOptions(this);
  9774. config._signal("editor", this);
  9775. };
  9776. (function(){
  9777. oop.implement(this, EventEmitter);
  9778. this.$initOperationListeners = function() {
  9779. function last(a) {return a[a.length - 1]}
  9780. this.selections = [];
  9781. this.commands.on("exec", this.startOperation.bind(this), true);
  9782. this.commands.on("afterExec", this.endOperation.bind(this), true);
  9783. this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
  9784. this.on("change", function() {
  9785. this.curOp || this.startOperation();
  9786. this.curOp.docChanged = true;
  9787. }.bind(this), true);
  9788. this.on("changeSelection", function() {
  9789. this.curOp || this.startOperation();
  9790. this.curOp.selectionChanged = true;
  9791. }.bind(this), true);
  9792. };
  9793. this.curOp = null;
  9794. this.prevOp = {};
  9795. this.startOperation = function(commadEvent) {
  9796. if (this.curOp) {
  9797. if (!commadEvent || this.curOp.command)
  9798. return;
  9799. this.prevOp = this.curOp;
  9800. }
  9801. if (!commadEvent) {
  9802. this.previousCommand = null;
  9803. commadEvent = {};
  9804. }
  9805. this.$opResetTimer.schedule();
  9806. this.curOp = {
  9807. command: commadEvent.command || {},
  9808. args: commadEvent.args,
  9809. scrollTop: this.renderer.scrollTop
  9810. };
  9811. if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
  9812. this.$blockScrolling++;
  9813. };
  9814. this.endOperation = function(e) {
  9815. if (this.curOp) {
  9816. if (e && e.returnValue === false)
  9817. return this.curOp = null;
  9818. this._signal("beforeEndOperation");
  9819. var command = this.curOp.command;
  9820. if (command.name && this.$blockScrolling > 0)
  9821. this.$blockScrolling--;
  9822. if (command && command.scrollIntoView) {
  9823. switch (command.scrollIntoView) {
  9824. case "center":
  9825. this.renderer.scrollCursorIntoView(null, 0.5);
  9826. break;
  9827. case "animate":
  9828. case "cursor":
  9829. this.renderer.scrollCursorIntoView();
  9830. break;
  9831. case "selectionPart":
  9832. var range = this.selection.getRange();
  9833. var config = this.renderer.layerConfig;
  9834. if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
  9835. this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
  9836. }
  9837. break;
  9838. default:
  9839. break;
  9840. }
  9841. if (command.scrollIntoView == "animate")
  9842. this.renderer.animateScrolling(this.curOp.scrollTop);
  9843. }
  9844. this.prevOp = this.curOp;
  9845. this.curOp = null;
  9846. }
  9847. };
  9848. this.$mergeableCommands = ["backspace", "del", "insertstring"];
  9849. this.$historyTracker = function(e) {
  9850. if (!this.$mergeUndoDeltas)
  9851. return;
  9852. var prev = this.prevOp;
  9853. var mergeableCommands = this.$mergeableCommands;
  9854. var shouldMerge = prev.command && (e.command.name == prev.command.name);
  9855. if (e.command.name == "insertstring") {
  9856. var text = e.args;
  9857. if (this.mergeNextCommand === undefined)
  9858. this.mergeNextCommand = true;
  9859. shouldMerge = shouldMerge
  9860. && this.mergeNextCommand // previous command allows to coalesce with
  9861. && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
  9862. this.mergeNextCommand = true;
  9863. } else {
  9864. shouldMerge = shouldMerge
  9865. && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
  9866. }
  9867. if (
  9868. this.$mergeUndoDeltas != "always"
  9869. && Date.now() - this.sequenceStartTime > 2000
  9870. ) {
  9871. shouldMerge = false; // the sequence is too long
  9872. }
  9873. if (shouldMerge)
  9874. this.session.mergeUndoDeltas = true;
  9875. else if (mergeableCommands.indexOf(e.command.name) !== -1)
  9876. this.sequenceStartTime = Date.now();
  9877. };
  9878. this.setKeyboardHandler = function(keyboardHandler, cb) {
  9879. if (keyboardHandler && typeof keyboardHandler === "string") {
  9880. this.$keybindingId = keyboardHandler;
  9881. var _self = this;
  9882. config.loadModule(["keybinding", keyboardHandler], function(module) {
  9883. if (_self.$keybindingId == keyboardHandler)
  9884. _self.keyBinding.setKeyboardHandler(module && module.handler);
  9885. cb && cb();
  9886. });
  9887. } else {
  9888. this.$keybindingId = null;
  9889. this.keyBinding.setKeyboardHandler(keyboardHandler);
  9890. cb && cb();
  9891. }
  9892. };
  9893. this.getKeyboardHandler = function() {
  9894. return this.keyBinding.getKeyboardHandler();
  9895. };
  9896. this.setSession = function(session) {
  9897. if (this.session == session)
  9898. return;
  9899. var oldSession = this.session;
  9900. if (oldSession) {
  9901. this.session.removeEventListener("change", this.$onDocumentChange);
  9902. this.session.removeEventListener("changeMode", this.$onChangeMode);
  9903. this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  9904. this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
  9905. this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  9906. this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
  9907. this.session.removeEventListener("onChangeFold", this.$onChangeFold);
  9908. this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  9909. this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
  9910. this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  9911. this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
  9912. this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
  9913. this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
  9914. this.session.removeEventListener("changeScrollLeft", this.$onScrollLeftChange);
  9915. var selection = this.session.getSelection();
  9916. selection.removeEventListener("changeCursor", this.$onCursorChange);
  9917. selection.removeEventListener("changeSelection", this.$onSelectionChange);
  9918. }
  9919. this.session = session;
  9920. if (session) {
  9921. this.$onDocumentChange = this.onDocumentChange.bind(this);
  9922. session.addEventListener("change", this.$onDocumentChange);
  9923. this.renderer.setSession(session);
  9924. this.$onChangeMode = this.onChangeMode.bind(this);
  9925. session.addEventListener("changeMode", this.$onChangeMode);
  9926. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  9927. session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
  9928. this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
  9929. session.addEventListener("changeTabSize", this.$onChangeTabSize);
  9930. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  9931. session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
  9932. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  9933. session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
  9934. this.$onChangeFold = this.onChangeFold.bind(this);
  9935. session.addEventListener("changeFold", this.$onChangeFold);
  9936. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  9937. this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
  9938. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  9939. this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
  9940. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  9941. this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
  9942. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  9943. this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
  9944. this.$onCursorChange = this.onCursorChange.bind(this);
  9945. this.session.addEventListener("changeOverwrite", this.$onCursorChange);
  9946. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  9947. this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
  9948. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  9949. this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
  9950. this.selection = session.getSelection();
  9951. this.selection.addEventListener("changeCursor", this.$onCursorChange);
  9952. this.$onSelectionChange = this.onSelectionChange.bind(this);
  9953. this.selection.addEventListener("changeSelection", this.$onSelectionChange);
  9954. this.onChangeMode();
  9955. this.$blockScrolling += 1;
  9956. this.onCursorChange();
  9957. this.$blockScrolling -= 1;
  9958. this.onScrollTopChange();
  9959. this.onScrollLeftChange();
  9960. this.onSelectionChange();
  9961. this.onChangeFrontMarker();
  9962. this.onChangeBackMarker();
  9963. this.onChangeBreakpoint();
  9964. this.onChangeAnnotation();
  9965. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  9966. this.renderer.updateFull();
  9967. } else {
  9968. this.selection = null;
  9969. this.renderer.setSession(session);
  9970. }
  9971. this._signal("changeSession", {
  9972. session: session,
  9973. oldSession: oldSession
  9974. });
  9975. oldSession && oldSession._signal("changeEditor", {oldEditor: this});
  9976. session && session._signal("changeEditor", {editor: this});
  9977. };
  9978. this.getSession = function() {
  9979. return this.session;
  9980. };
  9981. this.setValue = function(val, cursorPos) {
  9982. this.session.doc.setValue(val);
  9983. if (!cursorPos)
  9984. this.selectAll();
  9985. else if (cursorPos == 1)
  9986. this.navigateFileEnd();
  9987. else if (cursorPos == -1)
  9988. this.navigateFileStart();
  9989. return val;
  9990. };
  9991. this.getValue = function() {
  9992. return this.session.getValue();
  9993. };
  9994. this.getSelection = function() {
  9995. return this.selection;
  9996. };
  9997. this.resize = function(force) {
  9998. this.renderer.onResize(force);
  9999. };
  10000. this.setTheme = function(theme, cb) {
  10001. this.renderer.setTheme(theme, cb);
  10002. };
  10003. this.getTheme = function() {
  10004. return this.renderer.getTheme();
  10005. };
  10006. this.setStyle = function(style) {
  10007. this.renderer.setStyle(style);
  10008. };
  10009. this.unsetStyle = function(style) {
  10010. this.renderer.unsetStyle(style);
  10011. };
  10012. this.getFontSize = function () {
  10013. return this.getOption("fontSize") ||
  10014. dom.computedStyle(this.container, "fontSize");
  10015. };
  10016. this.setFontSize = function(size) {
  10017. this.setOption("fontSize", size);
  10018. };
  10019. this.$highlightBrackets = function() {
  10020. if (this.session.$bracketHighlight) {
  10021. this.session.removeMarker(this.session.$bracketHighlight);
  10022. this.session.$bracketHighlight = null;
  10023. }
  10024. if (this.$highlightPending) {
  10025. return;
  10026. }
  10027. var self = this;
  10028. this.$highlightPending = true;
  10029. setTimeout(function() {
  10030. self.$highlightPending = false;
  10031. var session = self.session;
  10032. if (!session || !session.bgTokenizer) return;
  10033. var pos = session.findMatchingBracket(self.getCursorPosition());
  10034. if (pos) {
  10035. var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
  10036. } else if (session.$mode.getMatching) {
  10037. var range = session.$mode.getMatching(self.session);
  10038. }
  10039. if (range)
  10040. session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
  10041. }, 50);
  10042. };
  10043. this.$highlightTags = function() {
  10044. if (this.$highlightTagPending)
  10045. return;
  10046. var self = this;
  10047. this.$highlightTagPending = true;
  10048. setTimeout(function() {
  10049. self.$highlightTagPending = false;
  10050. var session = self.session;
  10051. if (!session || !session.bgTokenizer) return;
  10052. var pos = self.getCursorPosition();
  10053. var iterator = new TokenIterator(self.session, pos.row, pos.column);
  10054. var token = iterator.getCurrentToken();
  10055. if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
  10056. session.removeMarker(session.$tagHighlight);
  10057. session.$tagHighlight = null;
  10058. return;
  10059. }
  10060. if (token.type.indexOf("tag-open") != -1) {
  10061. token = iterator.stepForward();
  10062. if (!token)
  10063. return;
  10064. }
  10065. var tag = token.value;
  10066. var depth = 0;
  10067. var prevToken = iterator.stepBackward();
  10068. if (prevToken.value == '<'){
  10069. do {
  10070. prevToken = token;
  10071. token = iterator.stepForward();
  10072. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10073. if (prevToken.value === '<'){
  10074. depth++;
  10075. } else if (prevToken.value === '</'){
  10076. depth--;
  10077. }
  10078. }
  10079. } while (token && depth >= 0);
  10080. } else {
  10081. do {
  10082. token = prevToken;
  10083. prevToken = iterator.stepBackward();
  10084. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10085. if (prevToken.value === '<') {
  10086. depth++;
  10087. } else if (prevToken.value === '</') {
  10088. depth--;
  10089. }
  10090. }
  10091. } while (prevToken && depth <= 0);
  10092. iterator.stepForward();
  10093. }
  10094. if (!token) {
  10095. session.removeMarker(session.$tagHighlight);
  10096. session.$tagHighlight = null;
  10097. return;
  10098. }
  10099. var row = iterator.getCurrentTokenRow();
  10100. var column = iterator.getCurrentTokenColumn();
  10101. var range = new Range(row, column, row, column+token.value.length);
  10102. if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
  10103. session.removeMarker(session.$tagHighlight);
  10104. session.$tagHighlight = null;
  10105. }
  10106. if (range && !session.$tagHighlight)
  10107. session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
  10108. }, 50);
  10109. };
  10110. this.focus = function() {
  10111. var _self = this;
  10112. setTimeout(function() {
  10113. _self.textInput.focus();
  10114. });
  10115. this.textInput.focus();
  10116. };
  10117. this.isFocused = function() {
  10118. return this.textInput.isFocused();
  10119. };
  10120. this.blur = function() {
  10121. this.textInput.blur();
  10122. };
  10123. this.onFocus = function(e) {
  10124. if (this.$isFocused)
  10125. return;
  10126. this.$isFocused = true;
  10127. this.renderer.showCursor();
  10128. this.renderer.visualizeFocus();
  10129. this._emit("focus", e);
  10130. };
  10131. this.onBlur = function(e) {
  10132. if (!this.$isFocused)
  10133. return;
  10134. this.$isFocused = false;
  10135. this.renderer.hideCursor();
  10136. this.renderer.visualizeBlur();
  10137. this._emit("blur", e);
  10138. };
  10139. this.$cursorChange = function() {
  10140. this.renderer.updateCursor();
  10141. };
  10142. this.onDocumentChange = function(e) {
  10143. var delta = e.data;
  10144. var range = delta.range;
  10145. var lastRow;
  10146. if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
  10147. lastRow = range.end.row;
  10148. else
  10149. lastRow = Infinity;
  10150. this.renderer.updateLines(range.start.row, lastRow, this.session.$useWrapMode);
  10151. this._signal("change", e);
  10152. this.$cursorChange();
  10153. this.$updateHighlightActiveLine();
  10154. };
  10155. this.onTokenizerUpdate = function(e) {
  10156. var rows = e.data;
  10157. this.renderer.updateLines(rows.first, rows.last);
  10158. };
  10159. this.onScrollTopChange = function() {
  10160. this.renderer.scrollToY(this.session.getScrollTop());
  10161. };
  10162. this.onScrollLeftChange = function() {
  10163. this.renderer.scrollToX(this.session.getScrollLeft());
  10164. };
  10165. this.onCursorChange = function() {
  10166. this.$cursorChange();
  10167. if (!this.$blockScrolling) {
  10168. config.warn("Automatically scrolling cursor into view after selection change",
  10169. "this will be disabled in the next version",
  10170. "set editor.$blockScrolling = Infinity to disable this message"
  10171. );
  10172. this.renderer.scrollCursorIntoView();
  10173. }
  10174. this.$highlightBrackets();
  10175. this.$highlightTags();
  10176. this.$updateHighlightActiveLine();
  10177. this._signal("changeSelection");
  10178. };
  10179. this.$updateHighlightActiveLine = function() {
  10180. var session = this.getSession();
  10181. var highlight;
  10182. if (this.$highlightActiveLine) {
  10183. if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
  10184. highlight = this.getCursorPosition();
  10185. if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
  10186. highlight = false;
  10187. }
  10188. if (session.$highlightLineMarker && !highlight) {
  10189. session.removeMarker(session.$highlightLineMarker.id);
  10190. session.$highlightLineMarker = null;
  10191. } else if (!session.$highlightLineMarker && highlight) {
  10192. var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
  10193. range.id = session.addMarker(range, "ace_active-line", "screenLine");
  10194. session.$highlightLineMarker = range;
  10195. } else if (highlight) {
  10196. session.$highlightLineMarker.start.row = highlight.row;
  10197. session.$highlightLineMarker.end.row = highlight.row;
  10198. session.$highlightLineMarker.start.column = highlight.column;
  10199. session._signal("changeBackMarker");
  10200. }
  10201. };
  10202. this.onSelectionChange = function(e) {
  10203. var session = this.session;
  10204. if (session.$selectionMarker) {
  10205. session.removeMarker(session.$selectionMarker);
  10206. }
  10207. session.$selectionMarker = null;
  10208. if (!this.selection.isEmpty()) {
  10209. var range = this.selection.getRange();
  10210. var style = this.getSelectionStyle();
  10211. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  10212. } else {
  10213. this.$updateHighlightActiveLine();
  10214. }
  10215. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
  10216. this.session.highlight(re);
  10217. this._signal("changeSelection");
  10218. };
  10219. this.$getSelectionHighLightRegexp = function() {
  10220. var session = this.session;
  10221. var selection = this.getSelectionRange();
  10222. if (selection.isEmpty() || selection.isMultiLine())
  10223. return;
  10224. var startOuter = selection.start.column - 1;
  10225. var endOuter = selection.end.column + 1;
  10226. var line = session.getLine(selection.start.row);
  10227. var lineCols = line.length;
  10228. var needle = line.substring(Math.max(startOuter, 0),
  10229. Math.min(endOuter, lineCols));
  10230. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  10231. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  10232. return;
  10233. needle = line.substring(selection.start.column, selection.end.column);
  10234. if (!/^[\w\d]+$/.test(needle))
  10235. return;
  10236. var re = this.$search.$assembleRegExp({
  10237. wholeWord: true,
  10238. caseSensitive: true,
  10239. needle: needle
  10240. });
  10241. return re;
  10242. };
  10243. this.onChangeFrontMarker = function() {
  10244. this.renderer.updateFrontMarkers();
  10245. };
  10246. this.onChangeBackMarker = function() {
  10247. this.renderer.updateBackMarkers();
  10248. };
  10249. this.onChangeBreakpoint = function() {
  10250. this.renderer.updateBreakpoints();
  10251. };
  10252. this.onChangeAnnotation = function() {
  10253. this.renderer.setAnnotations(this.session.getAnnotations());
  10254. };
  10255. this.onChangeMode = function(e) {
  10256. this.renderer.updateText();
  10257. this._emit("changeMode", e);
  10258. };
  10259. this.onChangeWrapLimit = function() {
  10260. this.renderer.updateFull();
  10261. };
  10262. this.onChangeWrapMode = function() {
  10263. this.renderer.onResize(true);
  10264. };
  10265. this.onChangeFold = function() {
  10266. this.$updateHighlightActiveLine();
  10267. this.renderer.updateFull();
  10268. };
  10269. this.getSelectedText = function() {
  10270. return this.session.getTextRange(this.getSelectionRange());
  10271. };
  10272. this.getCopyText = function() {
  10273. var text = this.getSelectedText();
  10274. this._signal("copy", text);
  10275. return text;
  10276. };
  10277. this.onCopy = function() {
  10278. this.commands.exec("copy", this);
  10279. };
  10280. this.onCut = function() {
  10281. this.commands.exec("cut", this);
  10282. };
  10283. this.onPaste = function(text) {
  10284. if (this.$readOnly)
  10285. return;
  10286. var e = {text: text};
  10287. this._signal("paste", e);
  10288. text = e.text;
  10289. if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
  10290. this.insert(text);
  10291. } else {
  10292. var lines = text.split(/\r\n|\r|\n/);
  10293. var ranges = this.selection.rangeList.ranges;
  10294. if (lines.length > ranges.length || lines.length < 2 || !lines[1])
  10295. return this.commands.exec("insertstring", this, text);
  10296. for (var i = ranges.length; i--;) {
  10297. var range = ranges[i];
  10298. if (!range.isEmpty())
  10299. this.session.remove(range);
  10300. this.session.insert(range.start, lines[i]);
  10301. }
  10302. }
  10303. this.renderer.scrollCursorIntoView();
  10304. };
  10305. this.execCommand = function(command, args) {
  10306. return this.commands.exec(command, this, args);
  10307. };
  10308. this.insert = function(text, pasted) {
  10309. var session = this.session;
  10310. var mode = session.getMode();
  10311. var cursor = this.getCursorPosition();
  10312. if (this.getBehavioursEnabled() && !pasted) {
  10313. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  10314. if (transform) {
  10315. if (text !== transform.text) {
  10316. this.session.mergeUndoDeltas = false;
  10317. this.$mergeNextCommand = false;
  10318. }
  10319. text = transform.text;
  10320. }
  10321. }
  10322. if (text == "\t")
  10323. text = this.session.getTabString();
  10324. if (!this.selection.isEmpty()) {
  10325. var range = this.getSelectionRange();
  10326. cursor = this.session.remove(range);
  10327. this.clearSelection();
  10328. }
  10329. else if (this.session.getOverwrite()) {
  10330. var range = new Range.fromPoints(cursor, cursor);
  10331. range.end.column += text.length;
  10332. this.session.remove(range);
  10333. }
  10334. if (text == "\n" || text == "\r\n") {
  10335. var line = session.getLine(cursor.row);
  10336. if (cursor.column > line.search(/\S|$/)) {
  10337. var d = line.substr(cursor.column).search(/\S|$/);
  10338. session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
  10339. }
  10340. }
  10341. this.clearSelection();
  10342. var start = cursor.column;
  10343. var lineState = session.getState(cursor.row);
  10344. var line = session.getLine(cursor.row);
  10345. var shouldOutdent = mode.checkOutdent(lineState, line, text);
  10346. var end = session.insert(cursor, text);
  10347. if (transform && transform.selection) {
  10348. if (transform.selection.length == 2) { // Transform relative to the current column
  10349. this.selection.setSelectionRange(
  10350. new Range(cursor.row, start + transform.selection[0],
  10351. cursor.row, start + transform.selection[1]));
  10352. } else { // Transform relative to the current row.
  10353. this.selection.setSelectionRange(
  10354. new Range(cursor.row + transform.selection[0],
  10355. transform.selection[1],
  10356. cursor.row + transform.selection[2],
  10357. transform.selection[3]));
  10358. }
  10359. }
  10360. if (session.getDocument().isNewLine(text)) {
  10361. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  10362. session.insert({row: cursor.row+1, column: 0}, lineIndent);
  10363. }
  10364. if (shouldOutdent)
  10365. mode.autoOutdent(lineState, session, cursor.row);
  10366. };
  10367. this.onTextInput = function(text) {
  10368. this.keyBinding.onTextInput(text);
  10369. };
  10370. this.onCommandKey = function(e, hashId, keyCode) {
  10371. this.keyBinding.onCommandKey(e, hashId, keyCode);
  10372. };
  10373. this.setOverwrite = function(overwrite) {
  10374. this.session.setOverwrite(overwrite);
  10375. };
  10376. this.getOverwrite = function() {
  10377. return this.session.getOverwrite();
  10378. };
  10379. this.toggleOverwrite = function() {
  10380. this.session.toggleOverwrite();
  10381. };
  10382. this.setScrollSpeed = function(speed) {
  10383. this.setOption("scrollSpeed", speed);
  10384. };
  10385. this.getScrollSpeed = function() {
  10386. return this.getOption("scrollSpeed");
  10387. };
  10388. this.setDragDelay = function(dragDelay) {
  10389. this.setOption("dragDelay", dragDelay);
  10390. };
  10391. this.getDragDelay = function() {
  10392. return this.getOption("dragDelay");
  10393. };
  10394. this.setSelectionStyle = function(val) {
  10395. this.setOption("selectionStyle", val);
  10396. };
  10397. this.getSelectionStyle = function() {
  10398. return this.getOption("selectionStyle");
  10399. };
  10400. this.setHighlightActiveLine = function(shouldHighlight) {
  10401. this.setOption("highlightActiveLine", shouldHighlight);
  10402. };
  10403. this.getHighlightActiveLine = function() {
  10404. return this.getOption("highlightActiveLine");
  10405. };
  10406. this.setHighlightGutterLine = function(shouldHighlight) {
  10407. this.setOption("highlightGutterLine", shouldHighlight);
  10408. };
  10409. this.getHighlightGutterLine = function() {
  10410. return this.getOption("highlightGutterLine");
  10411. };
  10412. this.setHighlightSelectedWord = function(shouldHighlight) {
  10413. this.setOption("highlightSelectedWord", shouldHighlight);
  10414. };
  10415. this.getHighlightSelectedWord = function() {
  10416. return this.$highlightSelectedWord;
  10417. };
  10418. this.setAnimatedScroll = function(shouldAnimate){
  10419. this.renderer.setAnimatedScroll(shouldAnimate);
  10420. };
  10421. this.getAnimatedScroll = function(){
  10422. return this.renderer.getAnimatedScroll();
  10423. };
  10424. this.setShowInvisibles = function(showInvisibles) {
  10425. this.renderer.setShowInvisibles(showInvisibles);
  10426. };
  10427. this.getShowInvisibles = function() {
  10428. return this.renderer.getShowInvisibles();
  10429. };
  10430. this.setDisplayIndentGuides = function(display) {
  10431. this.renderer.setDisplayIndentGuides(display);
  10432. };
  10433. this.getDisplayIndentGuides = function() {
  10434. return this.renderer.getDisplayIndentGuides();
  10435. };
  10436. this.setShowPrintMargin = function(showPrintMargin) {
  10437. this.renderer.setShowPrintMargin(showPrintMargin);
  10438. };
  10439. this.getShowPrintMargin = function() {
  10440. return this.renderer.getShowPrintMargin();
  10441. };
  10442. this.setPrintMarginColumn = function(showPrintMargin) {
  10443. this.renderer.setPrintMarginColumn(showPrintMargin);
  10444. };
  10445. this.getPrintMarginColumn = function() {
  10446. return this.renderer.getPrintMarginColumn();
  10447. };
  10448. this.setReadOnly = function(readOnly) {
  10449. this.setOption("readOnly", readOnly);
  10450. };
  10451. this.getReadOnly = function() {
  10452. return this.getOption("readOnly");
  10453. };
  10454. this.setBehavioursEnabled = function (enabled) {
  10455. this.setOption("behavioursEnabled", enabled);
  10456. };
  10457. this.getBehavioursEnabled = function () {
  10458. return this.getOption("behavioursEnabled");
  10459. };
  10460. this.setWrapBehavioursEnabled = function (enabled) {
  10461. this.setOption("wrapBehavioursEnabled", enabled);
  10462. };
  10463. this.getWrapBehavioursEnabled = function () {
  10464. return this.getOption("wrapBehavioursEnabled");
  10465. };
  10466. this.setShowFoldWidgets = function(show) {
  10467. this.setOption("showFoldWidgets", show);
  10468. };
  10469. this.getShowFoldWidgets = function() {
  10470. return this.getOption("showFoldWidgets");
  10471. };
  10472. this.setFadeFoldWidgets = function(fade) {
  10473. this.setOption("fadeFoldWidgets", fade);
  10474. };
  10475. this.getFadeFoldWidgets = function() {
  10476. return this.getOption("fadeFoldWidgets");
  10477. };
  10478. this.remove = function(dir) {
  10479. if (this.selection.isEmpty()){
  10480. if (dir == "left")
  10481. this.selection.selectLeft();
  10482. else
  10483. this.selection.selectRight();
  10484. }
  10485. var range = this.getSelectionRange();
  10486. if (this.getBehavioursEnabled()) {
  10487. var session = this.session;
  10488. var state = session.getState(range.start.row);
  10489. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  10490. if (range.end.column === 0) {
  10491. var text = session.getTextRange(range);
  10492. if (text[text.length - 1] == "\n") {
  10493. var line = session.getLine(range.end.row);
  10494. if (/^\s+$/.test(line)) {
  10495. range.end.column = line.length;
  10496. }
  10497. }
  10498. }
  10499. if (new_range)
  10500. range = new_range;
  10501. }
  10502. this.session.remove(range);
  10503. this.clearSelection();
  10504. };
  10505. this.removeWordRight = function() {
  10506. if (this.selection.isEmpty())
  10507. this.selection.selectWordRight();
  10508. this.session.remove(this.getSelectionRange());
  10509. this.clearSelection();
  10510. };
  10511. this.removeWordLeft = function() {
  10512. if (this.selection.isEmpty())
  10513. this.selection.selectWordLeft();
  10514. this.session.remove(this.getSelectionRange());
  10515. this.clearSelection();
  10516. };
  10517. this.removeToLineStart = function() {
  10518. if (this.selection.isEmpty())
  10519. this.selection.selectLineStart();
  10520. this.session.remove(this.getSelectionRange());
  10521. this.clearSelection();
  10522. };
  10523. this.removeToLineEnd = function() {
  10524. if (this.selection.isEmpty())
  10525. this.selection.selectLineEnd();
  10526. var range = this.getSelectionRange();
  10527. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  10528. range.end.column = 0;
  10529. range.end.row++;
  10530. }
  10531. this.session.remove(range);
  10532. this.clearSelection();
  10533. };
  10534. this.splitLine = function() {
  10535. if (!this.selection.isEmpty()) {
  10536. this.session.remove(this.getSelectionRange());
  10537. this.clearSelection();
  10538. }
  10539. var cursor = this.getCursorPosition();
  10540. this.insert("\n");
  10541. this.moveCursorToPosition(cursor);
  10542. };
  10543. this.transposeLetters = function() {
  10544. if (!this.selection.isEmpty()) {
  10545. return;
  10546. }
  10547. var cursor = this.getCursorPosition();
  10548. var column = cursor.column;
  10549. if (column === 0)
  10550. return;
  10551. var line = this.session.getLine(cursor.row);
  10552. var swap, range;
  10553. if (column < line.length) {
  10554. swap = line.charAt(column) + line.charAt(column-1);
  10555. range = new Range(cursor.row, column-1, cursor.row, column+1);
  10556. }
  10557. else {
  10558. swap = line.charAt(column-1) + line.charAt(column-2);
  10559. range = new Range(cursor.row, column-2, cursor.row, column);
  10560. }
  10561. this.session.replace(range, swap);
  10562. };
  10563. this.toLowerCase = function() {
  10564. var originalRange = this.getSelectionRange();
  10565. if (this.selection.isEmpty()) {
  10566. this.selection.selectWord();
  10567. }
  10568. var range = this.getSelectionRange();
  10569. var text = this.session.getTextRange(range);
  10570. this.session.replace(range, text.toLowerCase());
  10571. this.selection.setSelectionRange(originalRange);
  10572. };
  10573. this.toUpperCase = 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.toUpperCase());
  10581. this.selection.setSelectionRange(originalRange);
  10582. };
  10583. this.indent = function() {
  10584. var session = this.session;
  10585. var range = this.getSelectionRange();
  10586. if (range.start.row < range.end.row) {
  10587. var rows = this.$getSelectedRows();
  10588. session.indentRows(rows.first, rows.last, "\t");
  10589. return;
  10590. } else if (range.start.column < range.end.column) {
  10591. var text = session.getTextRange(range);
  10592. if (!/^\s+$/.test(text)) {
  10593. var rows = this.$getSelectedRows();
  10594. session.indentRows(rows.first, rows.last, "\t");
  10595. return;
  10596. }
  10597. }
  10598. var line = session.getLine(range.start.row);
  10599. var position = range.start;
  10600. var size = session.getTabSize();
  10601. var column = session.documentToScreenColumn(position.row, position.column);
  10602. if (this.session.getUseSoftTabs()) {
  10603. var count = (size - column % size);
  10604. var indentString = lang.stringRepeat(" ", count);
  10605. } else {
  10606. var count = column % size;
  10607. while (line[range.start.column] == " " && count) {
  10608. range.start.column--;
  10609. count--;
  10610. }
  10611. this.selection.setSelectionRange(range);
  10612. indentString = "\t";
  10613. }
  10614. return this.insert(indentString);
  10615. };
  10616. this.blockIndent = function() {
  10617. var rows = this.$getSelectedRows();
  10618. this.session.indentRows(rows.first, rows.last, "\t");
  10619. };
  10620. this.blockOutdent = function() {
  10621. var selection = this.session.getSelection();
  10622. this.session.outdentRows(selection.getRange());
  10623. };
  10624. this.sortLines = function() {
  10625. var rows = this.$getSelectedRows();
  10626. var session = this.session;
  10627. var lines = [];
  10628. for (i = rows.first; i <= rows.last; i++)
  10629. lines.push(session.getLine(i));
  10630. lines.sort(function(a, b) {
  10631. if (a.toLowerCase() < b.toLowerCase()) return -1;
  10632. if (a.toLowerCase() > b.toLowerCase()) return 1;
  10633. return 0;
  10634. });
  10635. var deleteRange = new Range(0, 0, 0, 0);
  10636. for (var i = rows.first; i <= rows.last; i++) {
  10637. var line = session.getLine(i);
  10638. deleteRange.start.row = i;
  10639. deleteRange.end.row = i;
  10640. deleteRange.end.column = line.length;
  10641. session.replace(deleteRange, lines[i-rows.first]);
  10642. }
  10643. };
  10644. this.toggleCommentLines = function() {
  10645. var state = this.session.getState(this.getCursorPosition().row);
  10646. var rows = this.$getSelectedRows();
  10647. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  10648. };
  10649. this.toggleBlockComment = function() {
  10650. var cursor = this.getCursorPosition();
  10651. var state = this.session.getState(cursor.row);
  10652. var range = this.getSelectionRange();
  10653. this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
  10654. };
  10655. this.getNumberAt = function(row, column) {
  10656. var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
  10657. _numberRx.lastIndex = 0;
  10658. var s = this.session.getLine(row);
  10659. while (_numberRx.lastIndex < column) {
  10660. var m = _numberRx.exec(s);
  10661. if(m.index <= column && m.index+m[0].length >= column){
  10662. var number = {
  10663. value: m[0],
  10664. start: m.index,
  10665. end: m.index+m[0].length
  10666. };
  10667. return number;
  10668. }
  10669. }
  10670. return null;
  10671. };
  10672. this.modifyNumber = function(amount) {
  10673. var row = this.selection.getCursor().row;
  10674. var column = this.selection.getCursor().column;
  10675. var charRange = new Range(row, column-1, row, column);
  10676. var c = this.session.getTextRange(charRange);
  10677. if (!isNaN(parseFloat(c)) && isFinite(c)) {
  10678. var nr = this.getNumberAt(row, column);
  10679. if (nr) {
  10680. var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
  10681. var decimals = nr.start + nr.value.length - fp;
  10682. var t = parseFloat(nr.value);
  10683. t *= Math.pow(10, decimals);
  10684. if(fp !== nr.end && column < fp){
  10685. amount *= Math.pow(10, nr.end - column - 1);
  10686. } else {
  10687. amount *= Math.pow(10, nr.end - column);
  10688. }
  10689. t += amount;
  10690. t /= Math.pow(10, decimals);
  10691. var nnr = t.toFixed(decimals);
  10692. var replaceRange = new Range(row, nr.start, row, nr.end);
  10693. this.session.replace(replaceRange, nnr);
  10694. this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
  10695. }
  10696. }
  10697. };
  10698. this.removeLines = function() {
  10699. var rows = this.$getSelectedRows();
  10700. var range;
  10701. if (rows.first === 0 || rows.last+1 < this.session.getLength())
  10702. range = new Range(rows.first, 0, rows.last+1, 0);
  10703. else
  10704. range = new Range(
  10705. rows.first-1, this.session.getLine(rows.first-1).length,
  10706. rows.last, this.session.getLine(rows.last).length
  10707. );
  10708. this.session.remove(range);
  10709. this.clearSelection();
  10710. };
  10711. this.duplicateSelection = function() {
  10712. var sel = this.selection;
  10713. var doc = this.session;
  10714. var range = sel.getRange();
  10715. var reverse = sel.isBackwards();
  10716. if (range.isEmpty()) {
  10717. var row = range.start.row;
  10718. doc.duplicateLines(row, row);
  10719. } else {
  10720. var point = reverse ? range.start : range.end;
  10721. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  10722. range.start = point;
  10723. range.end = endPoint;
  10724. sel.setSelectionRange(range, reverse);
  10725. }
  10726. };
  10727. this.moveLinesDown = function() {
  10728. this.$moveLines(1, false);
  10729. };
  10730. this.moveLinesUp = function() {
  10731. this.$moveLines(-1, false);
  10732. };
  10733. this.moveText = function(range, toPosition, copy) {
  10734. return this.session.moveText(range, toPosition, copy);
  10735. };
  10736. this.copyLinesUp = function() {
  10737. this.$moveLines(-1, true);
  10738. };
  10739. this.copyLinesDown = function() {
  10740. this.$moveLines(1, true);
  10741. };
  10742. this.$moveLines = function(dir, copy) {
  10743. var rows, moved;
  10744. var selection = this.selection;
  10745. if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
  10746. var range = selection.toOrientedRange();
  10747. rows = this.$getSelectedRows(range);
  10748. moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
  10749. if (copy && dir == -1) moved = 0;
  10750. range.moveBy(moved, 0);
  10751. selection.fromOrientedRange(range);
  10752. } else {
  10753. var ranges = selection.rangeList.ranges;
  10754. selection.rangeList.detach(this.session);
  10755. this.inVirtualSelectionMode = true;
  10756. var diff = 0;
  10757. var totalDiff = 0;
  10758. var l = ranges.length;
  10759. for (var i = 0; i < l; i++) {
  10760. var rangeIndex = i;
  10761. ranges[i].moveBy(diff, 0);
  10762. rows = this.$getSelectedRows(ranges[i]);
  10763. var first = rows.first;
  10764. var last = rows.last;
  10765. while (++i < l) {
  10766. if (totalDiff) ranges[i].moveBy(totalDiff, 0);
  10767. var subRows = this.$getSelectedRows(ranges[i]);
  10768. if (copy && subRows.first != last)
  10769. break;
  10770. else if (!copy && subRows.first > last + 1)
  10771. break;
  10772. last = subRows.last;
  10773. }
  10774. i--;
  10775. diff = this.session.$moveLines(first, last, copy ? 0 : dir);
  10776. if (copy && dir == -1) rangeIndex = i + 1;
  10777. while (rangeIndex <= i) {
  10778. ranges[rangeIndex].moveBy(diff, 0);
  10779. rangeIndex++;
  10780. }
  10781. if (!copy) diff = 0;
  10782. totalDiff += diff;
  10783. }
  10784. selection.fromOrientedRange(selection.ranges[0]);
  10785. selection.rangeList.attach(this.session);
  10786. this.inVirtualSelectionMode = false;
  10787. }
  10788. };
  10789. this.$getSelectedRows = function(range) {
  10790. range = (range || this.getSelectionRange()).collapseRows();
  10791. return {
  10792. first: this.session.getRowFoldStart(range.start.row),
  10793. last: this.session.getRowFoldEnd(range.end.row)
  10794. };
  10795. };
  10796. this.onCompositionStart = function(text) {
  10797. this.renderer.showComposition(this.getCursorPosition());
  10798. };
  10799. this.onCompositionUpdate = function(text) {
  10800. this.renderer.setCompositionText(text);
  10801. };
  10802. this.onCompositionEnd = function() {
  10803. this.renderer.hideComposition();
  10804. };
  10805. this.getFirstVisibleRow = function() {
  10806. return this.renderer.getFirstVisibleRow();
  10807. };
  10808. this.getLastVisibleRow = function() {
  10809. return this.renderer.getLastVisibleRow();
  10810. };
  10811. this.isRowVisible = function(row) {
  10812. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  10813. };
  10814. this.isRowFullyVisible = function(row) {
  10815. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  10816. };
  10817. this.$getVisibleRowCount = function() {
  10818. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  10819. };
  10820. this.$moveByPage = function(dir, select) {
  10821. var renderer = this.renderer;
  10822. var config = this.renderer.layerConfig;
  10823. var rows = dir * Math.floor(config.height / config.lineHeight);
  10824. this.$blockScrolling++;
  10825. if (select === true) {
  10826. this.selection.$moveSelection(function(){
  10827. this.moveCursorBy(rows, 0);
  10828. });
  10829. } else if (select === false) {
  10830. this.selection.moveCursorBy(rows, 0);
  10831. this.selection.clearSelection();
  10832. }
  10833. this.$blockScrolling--;
  10834. var scrollTop = renderer.scrollTop;
  10835. renderer.scrollBy(0, rows * config.lineHeight);
  10836. if (select != null)
  10837. renderer.scrollCursorIntoView(null, 0.5);
  10838. renderer.animateScrolling(scrollTop);
  10839. };
  10840. this.selectPageDown = function() {
  10841. this.$moveByPage(1, true);
  10842. };
  10843. this.selectPageUp = function() {
  10844. this.$moveByPage(-1, true);
  10845. };
  10846. this.gotoPageDown = function() {
  10847. this.$moveByPage(1, false);
  10848. };
  10849. this.gotoPageUp = function() {
  10850. this.$moveByPage(-1, false);
  10851. };
  10852. this.scrollPageDown = function() {
  10853. this.$moveByPage(1);
  10854. };
  10855. this.scrollPageUp = function() {
  10856. this.$moveByPage(-1);
  10857. };
  10858. this.scrollToRow = function(row) {
  10859. this.renderer.scrollToRow(row);
  10860. };
  10861. this.scrollToLine = function(line, center, animate, callback) {
  10862. this.renderer.scrollToLine(line, center, animate, callback);
  10863. };
  10864. this.centerSelection = function() {
  10865. var range = this.getSelectionRange();
  10866. var pos = {
  10867. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  10868. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  10869. };
  10870. this.renderer.alignCursor(pos, 0.5);
  10871. };
  10872. this.getCursorPosition = function() {
  10873. return this.selection.getCursor();
  10874. };
  10875. this.getCursorPositionScreen = function() {
  10876. return this.session.documentToScreenPosition(this.getCursorPosition());
  10877. };
  10878. this.getSelectionRange = function() {
  10879. return this.selection.getRange();
  10880. };
  10881. this.selectAll = function() {
  10882. this.$blockScrolling += 1;
  10883. this.selection.selectAll();
  10884. this.$blockScrolling -= 1;
  10885. };
  10886. this.clearSelection = function() {
  10887. this.selection.clearSelection();
  10888. };
  10889. this.moveCursorTo = function(row, column) {
  10890. this.selection.moveCursorTo(row, column);
  10891. };
  10892. this.moveCursorToPosition = function(pos) {
  10893. this.selection.moveCursorToPosition(pos);
  10894. };
  10895. this.jumpToMatching = function(select, expand) {
  10896. var cursor = this.getCursorPosition();
  10897. var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
  10898. var prevToken = iterator.getCurrentToken();
  10899. var token = prevToken || iterator.stepForward();
  10900. if (!token) return;
  10901. var matchType;
  10902. var found = false;
  10903. var depth = {};
  10904. var i = cursor.column - token.start;
  10905. var bracketType;
  10906. var brackets = {
  10907. ")": "(",
  10908. "(": "(",
  10909. "]": "[",
  10910. "[": "[",
  10911. "{": "{",
  10912. "}": "{"
  10913. };
  10914. do {
  10915. if (token.value.match(/[{}()\[\]]/g)) {
  10916. for (; i < token.value.length && !found; i++) {
  10917. if (!brackets[token.value[i]]) {
  10918. continue;
  10919. }
  10920. bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
  10921. if (isNaN(depth[bracketType])) {
  10922. depth[bracketType] = 0;
  10923. }
  10924. switch (token.value[i]) {
  10925. case '(':
  10926. case '[':
  10927. case '{':
  10928. depth[bracketType]++;
  10929. break;
  10930. case ')':
  10931. case ']':
  10932. case '}':
  10933. depth[bracketType]--;
  10934. if (depth[bracketType] === -1) {
  10935. matchType = 'bracket';
  10936. found = true;
  10937. }
  10938. break;
  10939. }
  10940. }
  10941. }
  10942. else if (token && token.type.indexOf('tag-name') !== -1) {
  10943. if (isNaN(depth[token.value])) {
  10944. depth[token.value] = 0;
  10945. }
  10946. if (prevToken.value === '<') {
  10947. depth[token.value]++;
  10948. }
  10949. else if (prevToken.value === '</') {
  10950. depth[token.value]--;
  10951. }
  10952. if (depth[token.value] === -1) {
  10953. matchType = 'tag';
  10954. found = true;
  10955. }
  10956. }
  10957. if (!found) {
  10958. prevToken = token;
  10959. token = iterator.stepForward();
  10960. i = 0;
  10961. }
  10962. } while (token && !found);
  10963. if (!matchType)
  10964. return;
  10965. var range, pos;
  10966. if (matchType === 'bracket') {
  10967. range = this.session.getBracketRange(cursor);
  10968. if (!range) {
  10969. range = new Range(
  10970. iterator.getCurrentTokenRow(),
  10971. iterator.getCurrentTokenColumn() + i - 1,
  10972. iterator.getCurrentTokenRow(),
  10973. iterator.getCurrentTokenColumn() + i - 1
  10974. );
  10975. pos = range.start;
  10976. if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
  10977. range = this.session.getBracketRange(pos);
  10978. }
  10979. }
  10980. else if (matchType === 'tag') {
  10981. if (token && token.type.indexOf('tag-name') !== -1)
  10982. var tag = token.value;
  10983. else
  10984. return;
  10985. range = new Range(
  10986. iterator.getCurrentTokenRow(),
  10987. iterator.getCurrentTokenColumn() - 2,
  10988. iterator.getCurrentTokenRow(),
  10989. iterator.getCurrentTokenColumn() - 2
  10990. );
  10991. if (range.compare(cursor.row, cursor.column) === 0) {
  10992. found = false;
  10993. do {
  10994. token = prevToken;
  10995. prevToken = iterator.stepBackward();
  10996. if (prevToken) {
  10997. if (prevToken.type.indexOf('tag-close') !== -1) {
  10998. range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
  10999. }
  11000. if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11001. if (prevToken.value === '<') {
  11002. depth[tag]++;
  11003. }
  11004. else if (prevToken.value === '</') {
  11005. depth[tag]--;
  11006. }
  11007. if (depth[tag] === 0)
  11008. found = true;
  11009. }
  11010. }
  11011. } while (prevToken && !found);
  11012. }
  11013. if (token && token.type.indexOf('tag-name')) {
  11014. pos = range.start;
  11015. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11016. pos = range.end;
  11017. }
  11018. }
  11019. pos = range && range.cursor || pos;
  11020. if (pos) {
  11021. if (select) {
  11022. if (range && expand) {
  11023. this.selection.setRange(range);
  11024. } else if (range && range.isEqual(this.getSelectionRange())) {
  11025. this.clearSelection();
  11026. } else {
  11027. this.selection.selectTo(pos.row, pos.column);
  11028. }
  11029. } else {
  11030. this.selection.moveTo(pos.row, pos.column);
  11031. }
  11032. }
  11033. };
  11034. this.gotoLine = function(lineNumber, column, animate) {
  11035. this.selection.clearSelection();
  11036. this.session.unfold({row: lineNumber - 1, column: column || 0});
  11037. this.$blockScrolling += 1;
  11038. this.exitMultiSelectMode && this.exitMultiSelectMode();
  11039. this.moveCursorTo(lineNumber - 1, column || 0);
  11040. this.$blockScrolling -= 1;
  11041. if (!this.isRowFullyVisible(lineNumber - 1))
  11042. this.scrollToLine(lineNumber - 1, true, animate);
  11043. };
  11044. this.navigateTo = function(row, column) {
  11045. this.selection.moveTo(row, column);
  11046. };
  11047. this.navigateUp = function(times) {
  11048. if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
  11049. var selectionStart = this.selection.anchor.getPosition();
  11050. return this.moveCursorToPosition(selectionStart);
  11051. }
  11052. this.selection.clearSelection();
  11053. this.selection.moveCursorBy(-times || -1, 0);
  11054. };
  11055. this.navigateDown = function(times) {
  11056. if (this.selection.isMultiLine() && this.selection.isBackwards()) {
  11057. var selectionEnd = this.selection.anchor.getPosition();
  11058. return this.moveCursorToPosition(selectionEnd);
  11059. }
  11060. this.selection.clearSelection();
  11061. this.selection.moveCursorBy(times || 1, 0);
  11062. };
  11063. this.navigateLeft = function(times) {
  11064. if (!this.selection.isEmpty()) {
  11065. var selectionStart = this.getSelectionRange().start;
  11066. this.moveCursorToPosition(selectionStart);
  11067. }
  11068. else {
  11069. times = times || 1;
  11070. while (times--) {
  11071. this.selection.moveCursorLeft();
  11072. }
  11073. }
  11074. this.clearSelection();
  11075. };
  11076. this.navigateRight = function(times) {
  11077. if (!this.selection.isEmpty()) {
  11078. var selectionEnd = this.getSelectionRange().end;
  11079. this.moveCursorToPosition(selectionEnd);
  11080. }
  11081. else {
  11082. times = times || 1;
  11083. while (times--) {
  11084. this.selection.moveCursorRight();
  11085. }
  11086. }
  11087. this.clearSelection();
  11088. };
  11089. this.navigateLineStart = function() {
  11090. this.selection.moveCursorLineStart();
  11091. this.clearSelection();
  11092. };
  11093. this.navigateLineEnd = function() {
  11094. this.selection.moveCursorLineEnd();
  11095. this.clearSelection();
  11096. };
  11097. this.navigateFileEnd = function() {
  11098. this.selection.moveCursorFileEnd();
  11099. this.clearSelection();
  11100. };
  11101. this.navigateFileStart = function() {
  11102. this.selection.moveCursorFileStart();
  11103. this.clearSelection();
  11104. };
  11105. this.navigateWordRight = function() {
  11106. this.selection.moveCursorWordRight();
  11107. this.clearSelection();
  11108. };
  11109. this.navigateWordLeft = function() {
  11110. this.selection.moveCursorWordLeft();
  11111. this.clearSelection();
  11112. };
  11113. this.replace = function(replacement, options) {
  11114. if (options)
  11115. this.$search.set(options);
  11116. var range = this.$search.find(this.session);
  11117. var replaced = 0;
  11118. if (!range)
  11119. return replaced;
  11120. if (this.$tryReplace(range, replacement)) {
  11121. replaced = 1;
  11122. }
  11123. if (range !== null) {
  11124. this.selection.setSelectionRange(range);
  11125. this.renderer.scrollSelectionIntoView(range.start, range.end);
  11126. }
  11127. return replaced;
  11128. };
  11129. this.replaceAll = function(replacement, options) {
  11130. if (options) {
  11131. this.$search.set(options);
  11132. }
  11133. var ranges = this.$search.findAll(this.session);
  11134. var replaced = 0;
  11135. if (!ranges.length)
  11136. return replaced;
  11137. this.$blockScrolling += 1;
  11138. var selection = this.getSelectionRange();
  11139. this.selection.moveTo(0, 0);
  11140. for (var i = ranges.length - 1; i >= 0; --i) {
  11141. if(this.$tryReplace(ranges[i], replacement)) {
  11142. replaced++;
  11143. }
  11144. }
  11145. this.selection.setSelectionRange(selection);
  11146. this.$blockScrolling -= 1;
  11147. return replaced;
  11148. };
  11149. this.$tryReplace = function(range, replacement) {
  11150. var input = this.session.getTextRange(range);
  11151. replacement = this.$search.replace(input, replacement);
  11152. if (replacement !== null) {
  11153. range.end = this.session.replace(range, replacement);
  11154. return range;
  11155. } else {
  11156. return null;
  11157. }
  11158. };
  11159. this.getLastSearchOptions = function() {
  11160. return this.$search.getOptions();
  11161. };
  11162. this.find = function(needle, options, animate) {
  11163. if (!options)
  11164. options = {};
  11165. if (typeof needle == "string" || needle instanceof RegExp)
  11166. options.needle = needle;
  11167. else if (typeof needle == "object")
  11168. oop.mixin(options, needle);
  11169. var range = this.selection.getRange();
  11170. if (options.needle == null) {
  11171. needle = this.session.getTextRange(range)
  11172. || this.$search.$options.needle;
  11173. if (!needle) {
  11174. range = this.session.getWordRange(range.start.row, range.start.column);
  11175. needle = this.session.getTextRange(range);
  11176. }
  11177. this.$search.set({needle: needle});
  11178. }
  11179. this.$search.set(options);
  11180. if (!options.start)
  11181. this.$search.set({start: range});
  11182. var newRange = this.$search.find(this.session);
  11183. if (options.preventScroll)
  11184. return newRange;
  11185. if (newRange) {
  11186. this.revealRange(newRange, animate);
  11187. return newRange;
  11188. }
  11189. if (options.backwards)
  11190. range.start = range.end;
  11191. else
  11192. range.end = range.start;
  11193. this.selection.setRange(range);
  11194. };
  11195. this.findNext = function(options, animate) {
  11196. this.find({skipCurrent: true, backwards: false}, options, animate);
  11197. };
  11198. this.findPrevious = function(options, animate) {
  11199. this.find(options, {skipCurrent: true, backwards: true}, animate);
  11200. };
  11201. this.revealRange = function(range, animate) {
  11202. this.$blockScrolling += 1;
  11203. this.session.unfold(range);
  11204. this.selection.setSelectionRange(range);
  11205. this.$blockScrolling -= 1;
  11206. var scrollTop = this.renderer.scrollTop;
  11207. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  11208. if (animate !== false)
  11209. this.renderer.animateScrolling(scrollTop);
  11210. };
  11211. this.undo = function() {
  11212. this.$blockScrolling++;
  11213. this.session.getUndoManager().undo();
  11214. this.$blockScrolling--;
  11215. this.renderer.scrollCursorIntoView(null, 0.5);
  11216. };
  11217. this.redo = function() {
  11218. this.$blockScrolling++;
  11219. this.session.getUndoManager().redo();
  11220. this.$blockScrolling--;
  11221. this.renderer.scrollCursorIntoView(null, 0.5);
  11222. };
  11223. this.destroy = function() {
  11224. this.renderer.destroy();
  11225. this._signal("destroy", this);
  11226. if (this.session) {
  11227. this.session.destroy();
  11228. }
  11229. };
  11230. this.setAutoScrollEditorIntoView = function(enable) {
  11231. if (!enable)
  11232. return;
  11233. var rect;
  11234. var self = this;
  11235. var shouldScroll = false;
  11236. if (!this.$scrollAnchor)
  11237. this.$scrollAnchor = document.createElement("div");
  11238. var scrollAnchor = this.$scrollAnchor;
  11239. scrollAnchor.style.cssText = "position:absolute";
  11240. this.container.insertBefore(scrollAnchor, this.container.firstChild);
  11241. var onChangeSelection = this.on("changeSelection", function() {
  11242. shouldScroll = true;
  11243. });
  11244. var onBeforeRender = this.renderer.on("beforeRender", function() {
  11245. if (shouldScroll)
  11246. rect = self.renderer.container.getBoundingClientRect();
  11247. });
  11248. var onAfterRender = this.renderer.on("afterRender", function() {
  11249. if (shouldScroll && rect && (self.isFocused()
  11250. || self.searchBox && self.searchBox.isFocused())
  11251. ) {
  11252. var renderer = self.renderer;
  11253. var pos = renderer.$cursorLayer.$pixelPos;
  11254. var config = renderer.layerConfig;
  11255. var top = pos.top - config.offset;
  11256. if (pos.top >= 0 && top + rect.top < 0) {
  11257. shouldScroll = true;
  11258. } else if (pos.top < config.height &&
  11259. pos.top + rect.top + config.lineHeight > window.innerHeight) {
  11260. shouldScroll = false;
  11261. } else {
  11262. shouldScroll = null;
  11263. }
  11264. if (shouldScroll != null) {
  11265. scrollAnchor.style.top = top + "px";
  11266. scrollAnchor.style.left = pos.left + "px";
  11267. scrollAnchor.style.height = config.lineHeight + "px";
  11268. scrollAnchor.scrollIntoView(shouldScroll);
  11269. }
  11270. shouldScroll = rect = null;
  11271. }
  11272. });
  11273. this.setAutoScrollEditorIntoView = function(enable) {
  11274. if (enable)
  11275. return;
  11276. delete this.setAutoScrollEditorIntoView;
  11277. this.removeEventListener("changeSelection", onChangeSelection);
  11278. this.renderer.removeEventListener("afterRender", onAfterRender);
  11279. this.renderer.removeEventListener("beforeRender", onBeforeRender);
  11280. };
  11281. };
  11282. this.$resetCursorStyle = function() {
  11283. var style = this.$cursorStyle || "ace";
  11284. var cursorLayer = this.renderer.$cursorLayer;
  11285. if (!cursorLayer)
  11286. return;
  11287. cursorLayer.setSmoothBlinking(/smooth/.test(style));
  11288. cursorLayer.isBlinking = !this.$readOnly && style != "wide";
  11289. dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
  11290. };
  11291. }).call(Editor.prototype);
  11292. config.defineOptions(Editor.prototype, "editor", {
  11293. selectionStyle: {
  11294. set: function(style) {
  11295. this.onSelectionChange();
  11296. this._signal("changeSelectionStyle", {data: style});
  11297. },
  11298. initialValue: "line"
  11299. },
  11300. highlightActiveLine: {
  11301. set: function() {this.$updateHighlightActiveLine();},
  11302. initialValue: true
  11303. },
  11304. highlightSelectedWord: {
  11305. set: function(shouldHighlight) {this.$onSelectionChange();},
  11306. initialValue: true
  11307. },
  11308. readOnly: {
  11309. set: function(readOnly) {
  11310. this.$resetCursorStyle();
  11311. },
  11312. initialValue: false
  11313. },
  11314. cursorStyle: {
  11315. set: function(val) { this.$resetCursorStyle(); },
  11316. values: ["ace", "slim", "smooth", "wide"],
  11317. initialValue: "ace"
  11318. },
  11319. mergeUndoDeltas: {
  11320. values: [false, true, "always"],
  11321. initialValue: true
  11322. },
  11323. behavioursEnabled: {initialValue: true},
  11324. wrapBehavioursEnabled: {initialValue: true},
  11325. autoScrollEditorIntoView: {
  11326. set: function(val) {this.setAutoScrollEditorIntoView(val)}
  11327. },
  11328. hScrollBarAlwaysVisible: "renderer",
  11329. vScrollBarAlwaysVisible: "renderer",
  11330. highlightGutterLine: "renderer",
  11331. animatedScroll: "renderer",
  11332. showInvisibles: "renderer",
  11333. showPrintMargin: "renderer",
  11334. printMarginColumn: "renderer",
  11335. printMargin: "renderer",
  11336. fadeFoldWidgets: "renderer",
  11337. showFoldWidgets: "renderer",
  11338. showLineNumbers: "renderer",
  11339. showGutter: "renderer",
  11340. displayIndentGuides: "renderer",
  11341. fontSize: "renderer",
  11342. fontFamily: "renderer",
  11343. maxLines: "renderer",
  11344. minLines: "renderer",
  11345. scrollPastEnd: "renderer",
  11346. fixedWidthGutter: "renderer",
  11347. theme: "renderer",
  11348. scrollSpeed: "$mouseHandler",
  11349. dragDelay: "$mouseHandler",
  11350. dragEnabled: "$mouseHandler",
  11351. focusTimout: "$mouseHandler",
  11352. tooltipFollowsMouse: "$mouseHandler",
  11353. firstLineNumber: "session",
  11354. overwrite: "session",
  11355. newLineMode: "session",
  11356. useWorker: "session",
  11357. useSoftTabs: "session",
  11358. tabSize: "session",
  11359. wrap: "session",
  11360. foldStyle: "session",
  11361. mode: "session"
  11362. });
  11363. exports.Editor = Editor;
  11364. });
  11365. ace.define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
  11366. "use strict";
  11367. var UndoManager = function() {
  11368. this.reset();
  11369. };
  11370. (function() {
  11371. this.execute = function(options) {
  11372. var deltas = options.args[0];
  11373. this.$doc = options.args[1];
  11374. if (options.merge && this.hasUndo()){
  11375. this.dirtyCounter--;
  11376. deltas = this.$undoStack.pop().concat(deltas);
  11377. }
  11378. this.$undoStack.push(deltas);
  11379. this.$redoStack = [];
  11380. if (this.dirtyCounter < 0) {
  11381. this.dirtyCounter = NaN;
  11382. }
  11383. this.dirtyCounter++;
  11384. };
  11385. this.undo = function(dontSelect) {
  11386. var deltas = this.$undoStack.pop();
  11387. var undoSelectionRange = null;
  11388. if (deltas) {
  11389. undoSelectionRange =
  11390. this.$doc.undoChanges(deltas, dontSelect);
  11391. this.$redoStack.push(deltas);
  11392. this.dirtyCounter--;
  11393. }
  11394. return undoSelectionRange;
  11395. };
  11396. this.redo = function(dontSelect) {
  11397. var deltas = this.$redoStack.pop();
  11398. var redoSelectionRange = null;
  11399. if (deltas) {
  11400. redoSelectionRange =
  11401. this.$doc.redoChanges(deltas, dontSelect);
  11402. this.$undoStack.push(deltas);
  11403. this.dirtyCounter++;
  11404. }
  11405. return redoSelectionRange;
  11406. };
  11407. this.reset = function() {
  11408. this.$undoStack = [];
  11409. this.$redoStack = [];
  11410. this.dirtyCounter = 0;
  11411. };
  11412. this.hasUndo = function() {
  11413. return this.$undoStack.length > 0;
  11414. };
  11415. this.hasRedo = function() {
  11416. return this.$redoStack.length > 0;
  11417. };
  11418. this.markClean = function() {
  11419. this.dirtyCounter = 0;
  11420. };
  11421. this.isClean = function() {
  11422. return this.dirtyCounter === 0;
  11423. };
  11424. }).call(UndoManager.prototype);
  11425. exports.UndoManager = UndoManager;
  11426. });
  11427. 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) {
  11428. "use strict";
  11429. var dom = require("../lib/dom");
  11430. var oop = require("../lib/oop");
  11431. var lang = require("../lib/lang");
  11432. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11433. var Gutter = function(parentEl) {
  11434. this.element = dom.createElement("div");
  11435. this.element.className = "ace_layer ace_gutter-layer";
  11436. parentEl.appendChild(this.element);
  11437. this.setShowFoldWidgets(this.$showFoldWidgets);
  11438. this.gutterWidth = 0;
  11439. this.$annotations = [];
  11440. this.$updateAnnotations = this.$updateAnnotations.bind(this);
  11441. this.$cells = [];
  11442. };
  11443. (function() {
  11444. oop.implement(this, EventEmitter);
  11445. this.setSession = function(session) {
  11446. if (this.session)
  11447. this.session.removeEventListener("change", this.$updateAnnotations);
  11448. this.session = session;
  11449. if (session)
  11450. session.on("change", this.$updateAnnotations);
  11451. };
  11452. this.addGutterDecoration = function(row, className){
  11453. if (window.console)
  11454. console.warn && console.warn("deprecated use session.addGutterDecoration");
  11455. this.session.addGutterDecoration(row, className);
  11456. };
  11457. this.removeGutterDecoration = function(row, className){
  11458. if (window.console)
  11459. console.warn && console.warn("deprecated use session.removeGutterDecoration");
  11460. this.session.removeGutterDecoration(row, className);
  11461. };
  11462. this.setAnnotations = function(annotations) {
  11463. this.$annotations = [];
  11464. for (var i = 0; i < annotations.length; i++) {
  11465. var annotation = annotations[i];
  11466. var row = annotation.row;
  11467. var rowInfo = this.$annotations[row];
  11468. if (!rowInfo)
  11469. rowInfo = this.$annotations[row] = {text: []};
  11470. var annoText = annotation.text;
  11471. annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
  11472. if (rowInfo.text.indexOf(annoText) === -1)
  11473. rowInfo.text.push(annoText);
  11474. var type = annotation.type;
  11475. if (type == "error")
  11476. rowInfo.className = " ace_error";
  11477. else if (type == "warning" && rowInfo.className != " ace_error")
  11478. rowInfo.className = " ace_warning";
  11479. else if (type == "info" && (!rowInfo.className))
  11480. rowInfo.className = " ace_info";
  11481. }
  11482. };
  11483. this.$updateAnnotations = function (e) {
  11484. if (!this.$annotations.length)
  11485. return;
  11486. var delta = e.data;
  11487. var range = delta.range;
  11488. var firstRow = range.start.row;
  11489. var len = range.end.row - firstRow;
  11490. if (len === 0) {
  11491. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  11492. this.$annotations.splice(firstRow, len + 1, null);
  11493. } else {
  11494. var args = new Array(len + 1);
  11495. args.unshift(firstRow, 1);
  11496. this.$annotations.splice.apply(this.$annotations, args);
  11497. }
  11498. };
  11499. this.update = function(config) {
  11500. var session = this.session;
  11501. var firstRow = config.firstRow;
  11502. var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
  11503. session.getLength() - 1);
  11504. var fold = session.getNextFoldLine(firstRow);
  11505. var foldStart = fold ? fold.start.row : Infinity;
  11506. var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
  11507. var breakpoints = session.$breakpoints;
  11508. var decorations = session.$decorations;
  11509. var firstLineNumber = session.$firstLineNumber;
  11510. var lastLineNumber = 0;
  11511. var gutterRenderer = session.gutterRenderer || this.$renderer;
  11512. var cell = null;
  11513. var index = -1;
  11514. var row = firstRow;
  11515. while (true) {
  11516. if (row > foldStart) {
  11517. row = fold.end.row + 1;
  11518. fold = session.getNextFoldLine(row, fold);
  11519. foldStart = fold ? fold.start.row : Infinity;
  11520. }
  11521. if (row > lastRow) {
  11522. while (this.$cells.length > index + 1) {
  11523. cell = this.$cells.pop();
  11524. this.element.removeChild(cell.element);
  11525. }
  11526. break;
  11527. }
  11528. cell = this.$cells[++index];
  11529. if (!cell) {
  11530. cell = {element: null, textNode: null, foldWidget: null};
  11531. cell.element = dom.createElement("div");
  11532. cell.textNode = document.createTextNode('');
  11533. cell.element.appendChild(cell.textNode);
  11534. this.element.appendChild(cell.element);
  11535. this.$cells[index] = cell;
  11536. }
  11537. var className = "ace_gutter-cell ";
  11538. if (breakpoints[row])
  11539. className += breakpoints[row];
  11540. if (decorations[row])
  11541. className += decorations[row];
  11542. if (this.$annotations[row])
  11543. className += this.$annotations[row].className;
  11544. if (cell.element.className != className)
  11545. cell.element.className = className;
  11546. var height = session.getRowLength(row) * config.lineHeight + "px";
  11547. if (height != cell.element.style.height)
  11548. cell.element.style.height = height;
  11549. if (foldWidgets) {
  11550. var c = foldWidgets[row];
  11551. if (c == null)
  11552. c = foldWidgets[row] = session.getFoldWidget(row);
  11553. }
  11554. if (c) {
  11555. if (!cell.foldWidget) {
  11556. cell.foldWidget = dom.createElement("span");
  11557. cell.element.appendChild(cell.foldWidget);
  11558. }
  11559. var className = "ace_fold-widget ace_" + c;
  11560. if (c == "start" && row == foldStart && row < fold.end.row)
  11561. className += " ace_closed";
  11562. else
  11563. className += " ace_open";
  11564. if (cell.foldWidget.className != className)
  11565. cell.foldWidget.className = className;
  11566. var height = config.lineHeight + "px";
  11567. if (cell.foldWidget.style.height != height)
  11568. cell.foldWidget.style.height = height;
  11569. } else {
  11570. if (cell.foldWidget) {
  11571. cell.element.removeChild(cell.foldWidget);
  11572. cell.foldWidget = null;
  11573. }
  11574. }
  11575. var text = lastLineNumber = gutterRenderer
  11576. ? gutterRenderer.getText(session, row)
  11577. : row + firstLineNumber;
  11578. if (text != cell.textNode.data)
  11579. cell.textNode.data = text;
  11580. row++;
  11581. }
  11582. this.element.style.height = config.minHeight + "px";
  11583. if (this.$fixedWidth || session.$useWrapMode)
  11584. lastLineNumber = session.getLength() + firstLineNumber;
  11585. var gutterWidth = gutterRenderer
  11586. ? gutterRenderer.getWidth(session, lastLineNumber, config)
  11587. : lastLineNumber.toString().length * config.characterWidth;
  11588. var padding = this.$padding || this.$computePadding();
  11589. gutterWidth += padding.left + padding.right;
  11590. if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
  11591. this.gutterWidth = gutterWidth;
  11592. this.element.style.width = Math.ceil(this.gutterWidth) + "px";
  11593. this._emit("changeGutterWidth", gutterWidth);
  11594. }
  11595. };
  11596. this.$fixedWidth = false;
  11597. this.$showLineNumbers = true;
  11598. this.$renderer = "";
  11599. this.setShowLineNumbers = function(show) {
  11600. this.$renderer = !show && {
  11601. getWidth: function() {return ""},
  11602. getText: function() {return ""}
  11603. };
  11604. };
  11605. this.getShowLineNumbers = function() {
  11606. return this.$showLineNumbers;
  11607. };
  11608. this.$showFoldWidgets = true;
  11609. this.setShowFoldWidgets = function(show) {
  11610. if (show)
  11611. dom.addCssClass(this.element, "ace_folding-enabled");
  11612. else
  11613. dom.removeCssClass(this.element, "ace_folding-enabled");
  11614. this.$showFoldWidgets = show;
  11615. this.$padding = null;
  11616. };
  11617. this.getShowFoldWidgets = function() {
  11618. return this.$showFoldWidgets;
  11619. };
  11620. this.$computePadding = function() {
  11621. if (!this.element.firstChild)
  11622. return {left: 0, right: 0};
  11623. var style = dom.computedStyle(this.element.firstChild);
  11624. this.$padding = {};
  11625. this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
  11626. this.$padding.right = parseInt(style.paddingRight) || 0;
  11627. return this.$padding;
  11628. };
  11629. this.getRegion = function(point) {
  11630. var padding = this.$padding || this.$computePadding();
  11631. var rect = this.element.getBoundingClientRect();
  11632. if (point.x < padding.left + rect.left)
  11633. return "markers";
  11634. if (this.$showFoldWidgets && point.x > rect.right - padding.right)
  11635. return "foldWidgets";
  11636. };
  11637. }).call(Gutter.prototype);
  11638. exports.Gutter = Gutter;
  11639. });
  11640. ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
  11641. "use strict";
  11642. var Range = require("../range").Range;
  11643. var dom = require("../lib/dom");
  11644. var Marker = function(parentEl) {
  11645. this.element = dom.createElement("div");
  11646. this.element.className = "ace_layer ace_marker-layer";
  11647. parentEl.appendChild(this.element);
  11648. };
  11649. (function() {
  11650. this.$padding = 0;
  11651. this.setPadding = function(padding) {
  11652. this.$padding = padding;
  11653. };
  11654. this.setSession = function(session) {
  11655. this.session = session;
  11656. };
  11657. this.setMarkers = function(markers) {
  11658. this.markers = markers;
  11659. };
  11660. this.update = function(config) {
  11661. var config = config || this.config;
  11662. if (!config)
  11663. return;
  11664. this.config = config;
  11665. var html = [];
  11666. for (var key in this.markers) {
  11667. var marker = this.markers[key];
  11668. if (!marker.range) {
  11669. marker.update(html, this, this.session, config);
  11670. continue;
  11671. }
  11672. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  11673. if (range.isEmpty()) continue;
  11674. range = range.toScreenRange(this.session);
  11675. if (marker.renderer) {
  11676. var top = this.$getTop(range.start.row, config);
  11677. var left = this.$padding + range.start.column * config.characterWidth;
  11678. marker.renderer(html, range, left, top, config);
  11679. } else if (marker.type == "fullLine") {
  11680. this.drawFullLineMarker(html, range, marker.clazz, config);
  11681. } else if (marker.type == "screenLine") {
  11682. this.drawScreenLineMarker(html, range, marker.clazz, config);
  11683. } else if (range.isMultiLine()) {
  11684. if (marker.type == "text")
  11685. this.drawTextMarker(html, range, marker.clazz, config);
  11686. else
  11687. this.drawMultiLineMarker(html, range, marker.clazz, config);
  11688. } else {
  11689. this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
  11690. }
  11691. }
  11692. this.element.innerHTML = html.join("");
  11693. };
  11694. this.$getTop = function(row, layerConfig) {
  11695. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  11696. };
  11697. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
  11698. var row = range.start.row;
  11699. var lineRange = new Range(
  11700. row, range.start.column,
  11701. row, this.session.getScreenLastRowColumn(row)
  11702. );
  11703. this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, extraStyle);
  11704. row = range.end.row;
  11705. lineRange = new Range(row, 0, row, range.end.column);
  11706. this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, extraStyle);
  11707. for (row = range.start.row + 1; row < range.end.row; row++) {
  11708. lineRange.start.row = row;
  11709. lineRange.end.row = row;
  11710. lineRange.end.column = this.session.getScreenLastRowColumn(row);
  11711. this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, extraStyle);
  11712. }
  11713. };
  11714. this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11715. var padding = this.$padding;
  11716. var height = config.lineHeight;
  11717. var top = this.$getTop(range.start.row, config);
  11718. var left = padding + range.start.column * config.characterWidth;
  11719. extraStyle = extraStyle || "";
  11720. stringBuilder.push(
  11721. "<div class='", clazz, " ace_start' style='",
  11722. "height:", height, "px;",
  11723. "right:0;",
  11724. "top:", top, "px;",
  11725. "left:", left, "px;", extraStyle, "'></div>"
  11726. );
  11727. top = this.$getTop(range.end.row, config);
  11728. var width = range.end.column * config.characterWidth;
  11729. stringBuilder.push(
  11730. "<div class='", clazz, "' style='",
  11731. "height:", height, "px;",
  11732. "width:", width, "px;",
  11733. "top:", top, "px;",
  11734. "left:", padding, "px;", extraStyle, "'></div>"
  11735. );
  11736. height = (range.end.row - range.start.row - 1) * config.lineHeight;
  11737. if (height < 0)
  11738. return;
  11739. top = this.$getTop(range.start.row + 1, config);
  11740. stringBuilder.push(
  11741. "<div class='", clazz, "' style='",
  11742. "height:", height, "px;",
  11743. "right:0;",
  11744. "top:", top, "px;",
  11745. "left:", padding, "px;", extraStyle, "'></div>"
  11746. );
  11747. };
  11748. this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  11749. var height = config.lineHeight;
  11750. var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
  11751. var top = this.$getTop(range.start.row, config);
  11752. var left = this.$padding + range.start.column * config.characterWidth;
  11753. stringBuilder.push(
  11754. "<div class='", clazz, "' style='",
  11755. "height:", height, "px;",
  11756. "width:", width, "px;",
  11757. "top:", top, "px;",
  11758. "left:", left, "px;", extraStyle || "", "'></div>"
  11759. );
  11760. };
  11761. this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11762. var top = this.$getTop(range.start.row, config);
  11763. var height = config.lineHeight;
  11764. if (range.start.row != range.end.row)
  11765. height += this.$getTop(range.end.row, config) - top;
  11766. stringBuilder.push(
  11767. "<div class='", clazz, "' style='",
  11768. "height:", height, "px;",
  11769. "top:", top, "px;",
  11770. "left:0;right:0;", extraStyle || "", "'></div>"
  11771. );
  11772. };
  11773. this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11774. var top = this.$getTop(range.start.row, config);
  11775. var height = config.lineHeight;
  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. }).call(Marker.prototype);
  11784. exports.Marker = Marker;
  11785. });
  11786. 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) {
  11787. "use strict";
  11788. var oop = require("../lib/oop");
  11789. var dom = require("../lib/dom");
  11790. var lang = require("../lib/lang");
  11791. var useragent = require("../lib/useragent");
  11792. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11793. var Text = function(parentEl) {
  11794. this.element = dom.createElement("div");
  11795. this.element.className = "ace_layer ace_text-layer";
  11796. parentEl.appendChild(this.element);
  11797. this.$updateEolChar = this.$updateEolChar.bind(this);
  11798. };
  11799. (function() {
  11800. oop.implement(this, EventEmitter);
  11801. this.EOF_CHAR = "\xB6";
  11802. this.EOL_CHAR_LF = "\xAC";
  11803. this.EOL_CHAR_CRLF = "\xa4";
  11804. this.EOL_CHAR = this.EOL_CHAR_LF;
  11805. this.TAB_CHAR = "\u2192"; //"\u21E5";
  11806. this.SPACE_CHAR = "\xB7";
  11807. this.$padding = 0;
  11808. this.$updateEolChar = function() {
  11809. var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
  11810. ? this.EOL_CHAR_LF
  11811. : this.EOL_CHAR_CRLF;
  11812. if (this.EOL_CHAR != EOL_CHAR) {
  11813. this.EOL_CHAR = EOL_CHAR;
  11814. return true;
  11815. }
  11816. }
  11817. this.setPadding = function(padding) {
  11818. this.$padding = padding;
  11819. this.element.style.padding = "0 " + padding + "px";
  11820. };
  11821. this.getLineHeight = function() {
  11822. return this.$fontMetrics.$characterSize.height || 0;
  11823. };
  11824. this.getCharacterWidth = function() {
  11825. return this.$fontMetrics.$characterSize.width || 0;
  11826. };
  11827. this.$setFontMetrics = function(measure) {
  11828. this.$fontMetrics = measure;
  11829. this.$fontMetrics.on("changeCharacterSize", function(e) {
  11830. this._signal("changeCharacterSize", e);
  11831. }.bind(this));
  11832. this.$pollSizeChanges();
  11833. }
  11834. this.checkForSizeChanges = function() {
  11835. this.$fontMetrics.checkForSizeChanges();
  11836. };
  11837. this.$pollSizeChanges = function() {
  11838. return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
  11839. };
  11840. this.setSession = function(session) {
  11841. this.session = session;
  11842. if (session)
  11843. this.$computeTabString();
  11844. };
  11845. this.showInvisibles = false;
  11846. this.setShowInvisibles = function(showInvisibles) {
  11847. if (this.showInvisibles == showInvisibles)
  11848. return false;
  11849. this.showInvisibles = showInvisibles;
  11850. this.$computeTabString();
  11851. return true;
  11852. };
  11853. this.displayIndentGuides = true;
  11854. this.setDisplayIndentGuides = function(display) {
  11855. if (this.displayIndentGuides == display)
  11856. return false;
  11857. this.displayIndentGuides = display;
  11858. this.$computeTabString();
  11859. return true;
  11860. };
  11861. this.$tabStrings = [];
  11862. this.onChangeTabSize =
  11863. this.$computeTabString = function() {
  11864. var tabSize = this.session.getTabSize();
  11865. this.tabSize = tabSize;
  11866. var tabStr = this.$tabStrings = [0];
  11867. for (var i = 1; i < tabSize + 1; i++) {
  11868. if (this.showInvisibles) {
  11869. tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
  11870. + this.TAB_CHAR
  11871. + lang.stringRepeat(" ", i - 1)
  11872. + "</span>");
  11873. } else {
  11874. tabStr.push(lang.stringRepeat(" ", i));
  11875. }
  11876. }
  11877. if (this.displayIndentGuides) {
  11878. this.$indentGuideRe = /\s\S| \t|\t |\s$/;
  11879. var className = "ace_indent-guide";
  11880. var spaceClass = "";
  11881. var tabClass = "";
  11882. if (this.showInvisibles) {
  11883. className += " ace_invisible";
  11884. spaceClass = " ace_invisible_space";
  11885. tabClass = " ace_invisible_tab";
  11886. var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
  11887. var tabContent = this.TAB_CHAR + lang.stringRepeat(" ", this.tabSize - 1);
  11888. } else{
  11889. var spaceContent = lang.stringRepeat(" ", this.tabSize);
  11890. var tabContent = spaceContent;
  11891. }
  11892. this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
  11893. this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
  11894. }
  11895. };
  11896. this.updateLines = function(config, firstRow, lastRow) {
  11897. if (this.config.lastRow != config.lastRow ||
  11898. this.config.firstRow != config.firstRow) {
  11899. this.scrollLines(config);
  11900. }
  11901. this.config = config;
  11902. var first = Math.max(firstRow, config.firstRow);
  11903. var last = Math.min(lastRow, config.lastRow);
  11904. var lineElements = this.element.childNodes;
  11905. var lineElementsIdx = 0;
  11906. for (var row = config.firstRow; row < first; row++) {
  11907. var foldLine = this.session.getFoldLine(row);
  11908. if (foldLine) {
  11909. if (foldLine.containsRow(first)) {
  11910. first = foldLine.start.row;
  11911. break;
  11912. } else {
  11913. row = foldLine.end.row;
  11914. }
  11915. }
  11916. lineElementsIdx ++;
  11917. }
  11918. var row = first;
  11919. var foldLine = this.session.getNextFoldLine(row);
  11920. var foldStart = foldLine ? foldLine.start.row : Infinity;
  11921. while (true) {
  11922. if (row > foldStart) {
  11923. row = foldLine.end.row+1;
  11924. foldLine = this.session.getNextFoldLine(row, foldLine);
  11925. foldStart = foldLine ? foldLine.start.row :Infinity;
  11926. }
  11927. if (row > last)
  11928. break;
  11929. var lineElement = lineElements[lineElementsIdx++];
  11930. if (lineElement) {
  11931. var html = [];
  11932. this.$renderLine(
  11933. html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
  11934. );
  11935. lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  11936. lineElement.innerHTML = html.join("");
  11937. }
  11938. row++;
  11939. }
  11940. };
  11941. this.scrollLines = function(config) {
  11942. var oldConfig = this.config;
  11943. this.config = config;
  11944. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  11945. return this.update(config);
  11946. if (config.lastRow < oldConfig.firstRow)
  11947. return this.update(config);
  11948. var el = this.element;
  11949. if (oldConfig.firstRow < config.firstRow)
  11950. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  11951. el.removeChild(el.firstChild);
  11952. if (oldConfig.lastRow > config.lastRow)
  11953. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  11954. el.removeChild(el.lastChild);
  11955. if (config.firstRow < oldConfig.firstRow) {
  11956. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  11957. if (el.firstChild)
  11958. el.insertBefore(fragment, el.firstChild);
  11959. else
  11960. el.appendChild(fragment);
  11961. }
  11962. if (config.lastRow > oldConfig.lastRow) {
  11963. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  11964. el.appendChild(fragment);
  11965. }
  11966. };
  11967. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  11968. var fragment = this.element.ownerDocument.createDocumentFragment();
  11969. var row = firstRow;
  11970. var foldLine = this.session.getNextFoldLine(row);
  11971. var foldStart = foldLine ? foldLine.start.row : Infinity;
  11972. while (true) {
  11973. if (row > foldStart) {
  11974. row = foldLine.end.row+1;
  11975. foldLine = this.session.getNextFoldLine(row, foldLine);
  11976. foldStart = foldLine ? foldLine.start.row : Infinity;
  11977. }
  11978. if (row > lastRow)
  11979. break;
  11980. var container = dom.createElement("div");
  11981. var html = [];
  11982. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  11983. container.innerHTML = html.join("");
  11984. if (this.$useLineGroups()) {
  11985. container.className = 'ace_line_group';
  11986. fragment.appendChild(container);
  11987. container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  11988. } else {
  11989. while(container.firstChild)
  11990. fragment.appendChild(container.firstChild);
  11991. }
  11992. row++;
  11993. }
  11994. return fragment;
  11995. };
  11996. this.update = function(config) {
  11997. this.config = config;
  11998. var html = [];
  11999. var firstRow = config.firstRow, lastRow = config.lastRow;
  12000. var row = firstRow;
  12001. var foldLine = this.session.getNextFoldLine(row);
  12002. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12003. while (true) {
  12004. if (row > foldStart) {
  12005. row = foldLine.end.row+1;
  12006. foldLine = this.session.getNextFoldLine(row, foldLine);
  12007. foldStart = foldLine ? foldLine.start.row :Infinity;
  12008. }
  12009. if (row > lastRow)
  12010. break;
  12011. if (this.$useLineGroups())
  12012. html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>")
  12013. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12014. if (this.$useLineGroups())
  12015. html.push("</div>"); // end the line group
  12016. row++;
  12017. }
  12018. this.element.innerHTML = html.join("");
  12019. };
  12020. this.$textToken = {
  12021. "text": true,
  12022. "rparen": true,
  12023. "lparen": true
  12024. };
  12025. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  12026. var self = this;
  12027. 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;
  12028. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  12029. if (a) {
  12030. return self.showInvisibles
  12031. ? "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>"
  12032. : c;
  12033. } else if (c == "&") {
  12034. return "&#38;";
  12035. } else if (c == "<") {
  12036. return "&#60;";
  12037. } else if (c == "\t") {
  12038. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  12039. screenColumn += tabSize - 1;
  12040. return self.$tabStrings[tabSize];
  12041. } else if (c == "\u3000") {
  12042. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
  12043. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  12044. screenColumn += 1;
  12045. return "<span class='" + classToUse + "' style='width:" +
  12046. (self.config.characterWidth * 2) +
  12047. "px'>" + space + "</span>";
  12048. } else if (b) {
  12049. return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
  12050. } else {
  12051. screenColumn += 1;
  12052. return "<span class='ace_cjk' style='width:" +
  12053. (self.config.characterWidth * 2) +
  12054. "px'>" + c + "</span>";
  12055. }
  12056. };
  12057. var output = value.replace(replaceReg, replaceFunc);
  12058. if (!this.$textToken[token.type]) {
  12059. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  12060. var style = "";
  12061. if (token.type == "fold")
  12062. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  12063. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  12064. }
  12065. else {
  12066. stringBuilder.push(output);
  12067. }
  12068. return screenColumn + value.length;
  12069. };
  12070. this.renderIndentGuide = function(stringBuilder, value, max) {
  12071. var cols = value.search(this.$indentGuideRe);
  12072. if (cols <= 0 || cols >= max)
  12073. return value;
  12074. if (value[0] == " ") {
  12075. cols -= cols % this.tabSize;
  12076. stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
  12077. return value.substr(cols);
  12078. } else if (value[0] == "\t") {
  12079. stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
  12080. return value.substr(cols);
  12081. }
  12082. return value;
  12083. };
  12084. this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
  12085. var chars = 0;
  12086. var split = 0;
  12087. var splitChars = splits[0];
  12088. var screenColumn = 0;
  12089. for (var i = 0; i < tokens.length; i++) {
  12090. var token = tokens[i];
  12091. var value = token.value;
  12092. if (i == 0 && this.displayIndentGuides) {
  12093. chars = value.length;
  12094. value = this.renderIndentGuide(stringBuilder, value, splitChars);
  12095. if (!value)
  12096. continue;
  12097. chars -= value.length;
  12098. }
  12099. if (chars + value.length < splitChars) {
  12100. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12101. chars += value.length;
  12102. } else {
  12103. while (chars + value.length >= splitChars) {
  12104. screenColumn = this.$renderToken(
  12105. stringBuilder, screenColumn,
  12106. token, value.substring(0, splitChars - chars)
  12107. );
  12108. value = value.substring(splitChars - chars);
  12109. chars = splitChars;
  12110. if (!onlyContents) {
  12111. stringBuilder.push("</div>",
  12112. "<div class='ace_line' style='height:",
  12113. this.config.lineHeight, "px'>"
  12114. );
  12115. }
  12116. split ++;
  12117. screenColumn = 0;
  12118. splitChars = splits[split] || Number.MAX_VALUE;
  12119. }
  12120. if (value.length != 0) {
  12121. chars += value.length;
  12122. screenColumn = this.$renderToken(
  12123. stringBuilder, screenColumn, token, value
  12124. );
  12125. }
  12126. }
  12127. }
  12128. };
  12129. this.$renderSimpleLine = function(stringBuilder, tokens) {
  12130. var screenColumn = 0;
  12131. var token = tokens[0];
  12132. var value = token.value;
  12133. if (this.displayIndentGuides)
  12134. value = this.renderIndentGuide(stringBuilder, value);
  12135. if (value)
  12136. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12137. for (var i = 1; i < tokens.length; i++) {
  12138. token = tokens[i];
  12139. value = token.value;
  12140. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12141. }
  12142. };
  12143. this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
  12144. if (!foldLine && foldLine != false)
  12145. foldLine = this.session.getFoldLine(row);
  12146. if (foldLine)
  12147. var tokens = this.$getFoldLineTokens(row, foldLine);
  12148. else
  12149. var tokens = this.session.getTokens(row);
  12150. if (!onlyContents) {
  12151. stringBuilder.push(
  12152. "<div class='ace_line' style='height:",
  12153. this.config.lineHeight * (
  12154. this.$useLineGroups() ? 1 :this.session.getRowLength(row)
  12155. ), "px'>"
  12156. );
  12157. }
  12158. if (tokens.length) {
  12159. var splits = this.session.getRowSplitData(row);
  12160. if (splits && splits.length)
  12161. this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
  12162. else
  12163. this.$renderSimpleLine(stringBuilder, tokens);
  12164. }
  12165. if (this.showInvisibles) {
  12166. if (foldLine)
  12167. row = foldLine.end.row
  12168. stringBuilder.push(
  12169. "<span class='ace_invisible ace_invisible_eol'>",
  12170. row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
  12171. "</span>"
  12172. );
  12173. }
  12174. if (!onlyContents)
  12175. stringBuilder.push("</div>");
  12176. };
  12177. this.$getFoldLineTokens = function(row, foldLine) {
  12178. var session = this.session;
  12179. var renderTokens = [];
  12180. function addTokens(tokens, from, to) {
  12181. var idx = 0, col = 0;
  12182. while ((col + tokens[idx].value.length) < from) {
  12183. col += tokens[idx].value.length;
  12184. idx++;
  12185. if (idx == tokens.length)
  12186. return;
  12187. }
  12188. if (col != from) {
  12189. var value = tokens[idx].value.substring(from - col);
  12190. if (value.length > (to - from))
  12191. value = value.substring(0, to - from);
  12192. renderTokens.push({
  12193. type: tokens[idx].type,
  12194. value: value
  12195. });
  12196. col = from + value.length;
  12197. idx += 1;
  12198. }
  12199. while (col < to && idx < tokens.length) {
  12200. var value = tokens[idx].value;
  12201. if (value.length + col > to) {
  12202. renderTokens.push({
  12203. type: tokens[idx].type,
  12204. value: value.substring(0, to - col)
  12205. });
  12206. } else
  12207. renderTokens.push(tokens[idx]);
  12208. col += value.length;
  12209. idx += 1;
  12210. }
  12211. }
  12212. var tokens = session.getTokens(row);
  12213. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  12214. if (placeholder != null) {
  12215. renderTokens.push({
  12216. type: "fold",
  12217. value: placeholder
  12218. });
  12219. } else {
  12220. if (isNewRow)
  12221. tokens = session.getTokens(row);
  12222. if (tokens.length)
  12223. addTokens(tokens, lastColumn, column);
  12224. }
  12225. }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  12226. return renderTokens;
  12227. };
  12228. this.$useLineGroups = function() {
  12229. return this.session.getUseWrapMode();
  12230. };
  12231. this.destroy = function() {
  12232. clearInterval(this.$pollSizeChangesTimer);
  12233. if (this.$measureNode)
  12234. this.$measureNode.parentNode.removeChild(this.$measureNode);
  12235. delete this.$measureNode;
  12236. };
  12237. }).call(Text.prototype);
  12238. exports.Text = Text;
  12239. });
  12240. ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  12241. "use strict";
  12242. var dom = require("../lib/dom");
  12243. var IE8;
  12244. var Cursor = function(parentEl) {
  12245. this.element = dom.createElement("div");
  12246. this.element.className = "ace_layer ace_cursor-layer";
  12247. parentEl.appendChild(this.element);
  12248. if (IE8 === undefined)
  12249. IE8 = "opacity" in this.element;
  12250. this.isVisible = false;
  12251. this.isBlinking = true;
  12252. this.blinkInterval = 1000;
  12253. this.smoothBlinking = false;
  12254. this.cursors = [];
  12255. this.cursor = this.addCursor();
  12256. dom.addCssClass(this.element, "ace_hidden-cursors");
  12257. this.$updateCursors = this.$updateVisibility.bind(this);
  12258. };
  12259. (function() {
  12260. this.$updateVisibility = function(val) {
  12261. var cursors = this.cursors;
  12262. for (var i = cursors.length; i--; )
  12263. cursors[i].style.visibility = val ? "" : "hidden";
  12264. };
  12265. this.$updateOpacity = function(val) {
  12266. var cursors = this.cursors;
  12267. for (var i = cursors.length; i--; )
  12268. cursors[i].style.opacity = val ? "" : "0";
  12269. };
  12270. this.$padding = 0;
  12271. this.setPadding = function(padding) {
  12272. this.$padding = padding;
  12273. };
  12274. this.setSession = function(session) {
  12275. this.session = session;
  12276. };
  12277. this.setBlinking = function(blinking) {
  12278. if (blinking != this.isBlinking){
  12279. this.isBlinking = blinking;
  12280. this.restartTimer();
  12281. }
  12282. };
  12283. this.setBlinkInterval = function(blinkInterval) {
  12284. if (blinkInterval != this.blinkInterval){
  12285. this.blinkInterval = blinkInterval;
  12286. this.restartTimer();
  12287. }
  12288. };
  12289. this.setSmoothBlinking = function(smoothBlinking) {
  12290. if (smoothBlinking != this.smoothBlinking && !IE8) {
  12291. this.smoothBlinking = smoothBlinking;
  12292. dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
  12293. this.$updateCursors(true);
  12294. this.$updateCursors = (smoothBlinking
  12295. ? this.$updateOpacity
  12296. : this.$updateVisibility).bind(this);
  12297. this.restartTimer();
  12298. }
  12299. };
  12300. this.addCursor = function() {
  12301. var el = dom.createElement("div");
  12302. el.className = "ace_cursor";
  12303. this.element.appendChild(el);
  12304. this.cursors.push(el);
  12305. return el;
  12306. };
  12307. this.removeCursor = function() {
  12308. if (this.cursors.length > 1) {
  12309. var el = this.cursors.pop();
  12310. el.parentNode.removeChild(el);
  12311. return el;
  12312. }
  12313. };
  12314. this.hideCursor = function() {
  12315. this.isVisible = false;
  12316. dom.addCssClass(this.element, "ace_hidden-cursors");
  12317. this.restartTimer();
  12318. };
  12319. this.showCursor = function() {
  12320. this.isVisible = true;
  12321. dom.removeCssClass(this.element, "ace_hidden-cursors");
  12322. this.restartTimer();
  12323. };
  12324. this.restartTimer = function() {
  12325. var update = this.$updateCursors;
  12326. clearInterval(this.intervalId);
  12327. clearTimeout(this.timeoutId);
  12328. if (this.smoothBlinking) {
  12329. dom.removeCssClass(this.element, "ace_smooth-blinking");
  12330. }
  12331. update(true);
  12332. if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
  12333. return;
  12334. if (this.smoothBlinking) {
  12335. setTimeout(function(){
  12336. dom.addCssClass(this.element, "ace_smooth-blinking");
  12337. }.bind(this));
  12338. }
  12339. var blink = function(){
  12340. this.timeoutId = setTimeout(function() {
  12341. update(false);
  12342. }, 0.6 * this.blinkInterval);
  12343. }.bind(this);
  12344. this.intervalId = setInterval(function() {
  12345. update(true);
  12346. blink();
  12347. }, this.blinkInterval);
  12348. blink();
  12349. };
  12350. this.getPixelPosition = function(position, onScreen) {
  12351. if (!this.config || !this.session)
  12352. return {left : 0, top : 0};
  12353. if (!position)
  12354. position = this.session.selection.getCursor();
  12355. var pos = this.session.documentToScreenPosition(position);
  12356. var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
  12357. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  12358. this.config.lineHeight;
  12359. return {left : cursorLeft, top : cursorTop};
  12360. };
  12361. this.update = function(config) {
  12362. this.config = config;
  12363. var selections = this.session.$selectionMarkers;
  12364. var i = 0, cursorIndex = 0;
  12365. if (selections === undefined || selections.length === 0){
  12366. selections = [{cursor: null}];
  12367. }
  12368. for (var i = 0, n = selections.length; i < n; i++) {
  12369. var pixelPos = this.getPixelPosition(selections[i].cursor, true);
  12370. if ((pixelPos.top > config.height + config.offset ||
  12371. pixelPos.top < 0) && i > 1) {
  12372. continue;
  12373. }
  12374. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  12375. if (!this.drawCursor) {
  12376. style.left = pixelPos.left + "px";
  12377. style.top = pixelPos.top + "px";
  12378. style.width = config.characterWidth + "px";
  12379. style.height = config.lineHeight + "px";
  12380. } else {
  12381. this.drawCursor(style, pixelPos, config, selections[i], this.session);
  12382. }
  12383. }
  12384. while (this.cursors.length > cursorIndex)
  12385. this.removeCursor();
  12386. var overwrite = this.session.getOverwrite();
  12387. this.$setOverwrite(overwrite);
  12388. this.$pixelPos = pixelPos;
  12389. this.restartTimer();
  12390. };
  12391. this.drawCursor = null;
  12392. this.$setOverwrite = function(overwrite) {
  12393. if (overwrite != this.overwrite) {
  12394. this.overwrite = overwrite;
  12395. if (overwrite)
  12396. dom.addCssClass(this.element, "ace_overwrite-cursors");
  12397. else
  12398. dom.removeCssClass(this.element, "ace_overwrite-cursors");
  12399. }
  12400. };
  12401. this.destroy = function() {
  12402. clearInterval(this.intervalId);
  12403. clearTimeout(this.timeoutId);
  12404. };
  12405. }).call(Cursor.prototype);
  12406. exports.Cursor = Cursor;
  12407. });
  12408. ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
  12409. "use strict";
  12410. var oop = require("./lib/oop");
  12411. var dom = require("./lib/dom");
  12412. var event = require("./lib/event");
  12413. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12414. var ScrollBar = function(parent) {
  12415. this.element = dom.createElement("div");
  12416. this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
  12417. this.inner = dom.createElement("div");
  12418. this.inner.className = "ace_scrollbar-inner";
  12419. this.element.appendChild(this.inner);
  12420. parent.appendChild(this.element);
  12421. this.setVisible(false);
  12422. this.skipEvent = false;
  12423. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  12424. event.addListener(this.element, "mousedown", event.preventDefault);
  12425. };
  12426. (function() {
  12427. oop.implement(this, EventEmitter);
  12428. this.setVisible = function(isVisible) {
  12429. this.element.style.display = isVisible ? "" : "none";
  12430. this.isVisible = isVisible;
  12431. };
  12432. }).call(ScrollBar.prototype);
  12433. var VScrollBar = function(parent, renderer) {
  12434. ScrollBar.call(this, parent);
  12435. this.scrollTop = 0;
  12436. renderer.$scrollbarWidth =
  12437. this.width = dom.scrollbarWidth(parent.ownerDocument);
  12438. this.inner.style.width =
  12439. this.element.style.width = (this.width || 15) + 5 + "px";
  12440. };
  12441. oop.inherits(VScrollBar, ScrollBar);
  12442. (function() {
  12443. this.classSuffix = '-v';
  12444. this.onScroll = function() {
  12445. if (!this.skipEvent) {
  12446. this.scrollTop = this.element.scrollTop;
  12447. this._emit("scroll", {data: this.scrollTop});
  12448. }
  12449. this.skipEvent = false;
  12450. };
  12451. this.getWidth = function() {
  12452. return this.isVisible ? this.width : 0;
  12453. };
  12454. this.setHeight = function(height) {
  12455. this.element.style.height = height + "px";
  12456. };
  12457. this.setInnerHeight = function(height) {
  12458. this.inner.style.height = height + "px";
  12459. };
  12460. this.setScrollHeight = function(height) {
  12461. this.inner.style.height = height + "px";
  12462. };
  12463. this.setScrollTop = function(scrollTop) {
  12464. if (this.scrollTop != scrollTop) {
  12465. this.skipEvent = true;
  12466. this.scrollTop = this.element.scrollTop = scrollTop;
  12467. }
  12468. };
  12469. }).call(VScrollBar.prototype);
  12470. var HScrollBar = function(parent, renderer) {
  12471. ScrollBar.call(this, parent);
  12472. this.scrollLeft = 0;
  12473. this.height = renderer.$scrollbarWidth;
  12474. this.inner.style.height =
  12475. this.element.style.height = (this.height || 15) + 5 + "px";
  12476. };
  12477. oop.inherits(HScrollBar, ScrollBar);
  12478. (function() {
  12479. this.classSuffix = '-h';
  12480. this.onScroll = function() {
  12481. if (!this.skipEvent) {
  12482. this.scrollLeft = this.element.scrollLeft;
  12483. this._emit("scroll", {data: this.scrollLeft});
  12484. }
  12485. this.skipEvent = false;
  12486. };
  12487. this.getHeight = function() {
  12488. return this.isVisible ? this.height : 0;
  12489. };
  12490. this.setWidth = function(width) {
  12491. this.element.style.width = width + "px";
  12492. };
  12493. this.setInnerWidth = function(width) {
  12494. this.inner.style.width = width + "px";
  12495. };
  12496. this.setScrollWidth = function(width) {
  12497. this.inner.style.width = width + "px";
  12498. };
  12499. this.setScrollLeft = function(scrollLeft) {
  12500. if (this.scrollLeft != scrollLeft) {
  12501. this.skipEvent = true;
  12502. this.scrollLeft = this.element.scrollLeft = scrollLeft;
  12503. }
  12504. };
  12505. }).call(HScrollBar.prototype);
  12506. exports.ScrollBar = VScrollBar; // backward compatibility
  12507. exports.ScrollBarV = VScrollBar; // backward compatibility
  12508. exports.ScrollBarH = HScrollBar; // backward compatibility
  12509. exports.VScrollBar = VScrollBar;
  12510. exports.HScrollBar = HScrollBar;
  12511. });
  12512. ace.define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
  12513. "use strict";
  12514. var event = require("./lib/event");
  12515. var RenderLoop = function(onRender, win) {
  12516. this.onRender = onRender;
  12517. this.pending = false;
  12518. this.changes = 0;
  12519. this.window = win || window;
  12520. };
  12521. (function() {
  12522. this.schedule = function(change) {
  12523. this.changes = this.changes | change;
  12524. if (!this.pending && this.changes) {
  12525. this.pending = true;
  12526. var _self = this;
  12527. event.nextFrame(function() {
  12528. _self.pending = false;
  12529. var changes;
  12530. while (changes = _self.changes) {
  12531. _self.changes = 0;
  12532. _self.onRender(changes);
  12533. }
  12534. }, this.window);
  12535. }
  12536. };
  12537. }).call(RenderLoop.prototype);
  12538. exports.RenderLoop = RenderLoop;
  12539. });
  12540. 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) {
  12541. var oop = require("../lib/oop");
  12542. var dom = require("../lib/dom");
  12543. var lang = require("../lib/lang");
  12544. var useragent = require("../lib/useragent");
  12545. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12546. var CHAR_COUNT = 0;
  12547. var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
  12548. this.el = dom.createElement("div");
  12549. this.$setMeasureNodeStyles(this.el.style, true);
  12550. this.$main = dom.createElement("div");
  12551. this.$setMeasureNodeStyles(this.$main.style);
  12552. this.$measureNode = dom.createElement("div");
  12553. this.$setMeasureNodeStyles(this.$measureNode.style);
  12554. this.el.appendChild(this.$main);
  12555. this.el.appendChild(this.$measureNode);
  12556. parentEl.appendChild(this.el);
  12557. if (!CHAR_COUNT)
  12558. this.$testFractionalRect();
  12559. this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
  12560. this.$characterSize = {width: 0, height: 0};
  12561. this.checkForSizeChanges();
  12562. };
  12563. (function() {
  12564. oop.implement(this, EventEmitter);
  12565. this.$characterSize = {width: 0, height: 0};
  12566. this.$testFractionalRect = function() {
  12567. var el = dom.createElement("div");
  12568. this.$setMeasureNodeStyles(el.style);
  12569. el.style.width = "0.2px";
  12570. document.documentElement.appendChild(el);
  12571. var w = el.getBoundingClientRect().width;
  12572. if (w > 0 && w < 1)
  12573. CHAR_COUNT = 50;
  12574. else
  12575. CHAR_COUNT = 100;
  12576. el.parentNode.removeChild(el);
  12577. };
  12578. this.$setMeasureNodeStyles = function(style, isRoot) {
  12579. style.width = style.height = "auto";
  12580. style.left = style.top = "0px";
  12581. style.visibility = "hidden";
  12582. style.position = "absolute";
  12583. style.whiteSpace = "pre";
  12584. if (useragent.isIE < 8) {
  12585. style["font-family"] = "inherit";
  12586. } else {
  12587. style.font = "inherit";
  12588. }
  12589. style.overflow = isRoot ? "hidden" : "visible";
  12590. };
  12591. this.checkForSizeChanges = function() {
  12592. var size = this.$measureSizes();
  12593. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  12594. this.$measureNode.style.fontWeight = "bold";
  12595. var boldSize = this.$measureSizes();
  12596. this.$measureNode.style.fontWeight = "";
  12597. this.$characterSize = size;
  12598. this.charSizes = Object.create(null);
  12599. this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
  12600. this._emit("changeCharacterSize", {data: size});
  12601. }
  12602. };
  12603. this.$pollSizeChanges = function() {
  12604. if (this.$pollSizeChangesTimer)
  12605. return this.$pollSizeChangesTimer;
  12606. var self = this;
  12607. return this.$pollSizeChangesTimer = setInterval(function() {
  12608. self.checkForSizeChanges();
  12609. }, 500);
  12610. };
  12611. this.setPolling = function(val) {
  12612. if (val) {
  12613. this.$pollSizeChanges();
  12614. } else {
  12615. if (this.$pollSizeChangesTimer)
  12616. this.$pollSizeChangesTimer;
  12617. }
  12618. };
  12619. this.$measureSizes = function() {
  12620. if (CHAR_COUNT === 50) {
  12621. var rect = null;
  12622. try {
  12623. rect = this.$measureNode.getBoundingClientRect();
  12624. } catch(e) {
  12625. rect = {width: 0, height:0 };
  12626. };
  12627. var size = {
  12628. height: rect.height,
  12629. width: rect.width / CHAR_COUNT
  12630. };
  12631. } else {
  12632. var size = {
  12633. height: this.$measureNode.clientHeight,
  12634. width: this.$measureNode.clientWidth / CHAR_COUNT
  12635. };
  12636. }
  12637. if (size.width === 0 || size.height === 0)
  12638. return null;
  12639. return size;
  12640. };
  12641. this.$measureCharWidth = function(ch) {
  12642. this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
  12643. var rect = this.$main.getBoundingClientRect();
  12644. return rect.width / CHAR_COUNT;
  12645. };
  12646. this.getCharacterWidth = function(ch) {
  12647. var w = this.charSizes[ch];
  12648. if (w === undefined) {
  12649. this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
  12650. }
  12651. return w;
  12652. };
  12653. this.destroy = function() {
  12654. clearInterval(this.$pollSizeChangesTimer);
  12655. if (this.el && this.el.parentNode)
  12656. this.el.parentNode.removeChild(this.el);
  12657. };
  12658. }).call(FontMetrics.prototype);
  12659. });
  12660. 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) {
  12661. "use strict";
  12662. var oop = require("./lib/oop");
  12663. var dom = require("./lib/dom");
  12664. var config = require("./config");
  12665. var useragent = require("./lib/useragent");
  12666. var GutterLayer = require("./layer/gutter").Gutter;
  12667. var MarkerLayer = require("./layer/marker").Marker;
  12668. var TextLayer = require("./layer/text").Text;
  12669. var CursorLayer = require("./layer/cursor").Cursor;
  12670. var HScrollBar = require("./scrollbar").HScrollBar;
  12671. var VScrollBar = require("./scrollbar").VScrollBar;
  12672. var RenderLoop = require("./renderloop").RenderLoop;
  12673. var FontMetrics = require("./layer/font_metrics").FontMetrics;
  12674. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12675. var editorCss = ".ace_editor {\
  12676. position: relative;\
  12677. overflow: hidden;\
  12678. font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
  12679. direction: ltr;\
  12680. }\
  12681. .ace_scroller {\
  12682. position: absolute;\
  12683. overflow: hidden;\
  12684. top: 0;\
  12685. bottom: 0;\
  12686. background-color: inherit;\
  12687. -ms-user-select: none;\
  12688. -moz-user-select: none;\
  12689. -webkit-user-select: none;\
  12690. user-select: none;\
  12691. cursor: text;\
  12692. }\
  12693. .ace_content {\
  12694. position: absolute;\
  12695. -moz-box-sizing: border-box;\
  12696. -webkit-box-sizing: border-box;\
  12697. box-sizing: border-box;\
  12698. min-width: 100%;\
  12699. }\
  12700. .ace_dragging .ace_scroller:before{\
  12701. position: absolute;\
  12702. top: 0;\
  12703. left: 0;\
  12704. right: 0;\
  12705. bottom: 0;\
  12706. content: '';\
  12707. background: rgba(250, 250, 250, 0.01);\
  12708. z-index: 1000;\
  12709. }\
  12710. .ace_dragging.ace_dark .ace_scroller:before{\
  12711. background: rgba(0, 0, 0, 0.01);\
  12712. }\
  12713. .ace_selecting, .ace_selecting * {\
  12714. cursor: text !important;\
  12715. }\
  12716. .ace_gutter {\
  12717. position: absolute;\
  12718. overflow : hidden;\
  12719. width: auto;\
  12720. top: 0;\
  12721. bottom: 0;\
  12722. left: 0;\
  12723. cursor: default;\
  12724. z-index: 4;\
  12725. -ms-user-select: none;\
  12726. -moz-user-select: none;\
  12727. -webkit-user-select: none;\
  12728. user-select: none;\
  12729. }\
  12730. .ace_gutter-active-line {\
  12731. position: absolute;\
  12732. left: 0;\
  12733. right: 0;\
  12734. }\
  12735. .ace_scroller.ace_scroll-left {\
  12736. box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
  12737. }\
  12738. .ace_gutter-cell {\
  12739. padding-left: 19px;\
  12740. padding-right: 6px;\
  12741. background-repeat: no-repeat;\
  12742. }\
  12743. .ace_gutter-cell.ace_error {\
  12744. 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==\");\
  12745. background-repeat: no-repeat;\
  12746. background-position: 2px center;\
  12747. }\
  12748. .ace_gutter-cell.ace_warning {\
  12749. 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==\");\
  12750. background-position: 2px center;\
  12751. }\
  12752. .ace_gutter-cell.ace_info {\
  12753. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
  12754. background-position: 2px center;\
  12755. }\
  12756. .ace_dark .ace_gutter-cell.ace_info {\
  12757. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
  12758. }\
  12759. .ace_scrollbar {\
  12760. position: absolute;\
  12761. right: 0;\
  12762. bottom: 0;\
  12763. z-index: 6;\
  12764. }\
  12765. .ace_scrollbar-inner {\
  12766. position: absolute;\
  12767. cursor: text;\
  12768. left: 0;\
  12769. top: 0;\
  12770. }\
  12771. .ace_scrollbar-v{\
  12772. overflow-x: hidden;\
  12773. overflow-y: scroll;\
  12774. top: 0;\
  12775. }\
  12776. .ace_scrollbar-h {\
  12777. overflow-x: scroll;\
  12778. overflow-y: hidden;\
  12779. left: 0;\
  12780. }\
  12781. .ace_print-margin {\
  12782. position: absolute;\
  12783. height: 100%;\
  12784. }\
  12785. .ace_text-input {\
  12786. position: absolute;\
  12787. z-index: 0;\
  12788. width: 0.5em;\
  12789. height: 1em;\
  12790. opacity: 0;\
  12791. background: transparent;\
  12792. -moz-appearance: none;\
  12793. appearance: none;\
  12794. border: none;\
  12795. resize: none;\
  12796. outline: none;\
  12797. overflow: hidden;\
  12798. font: inherit;\
  12799. padding: 0 1px;\
  12800. margin: 0 -1px;\
  12801. text-indent: -1em;\
  12802. -ms-user-select: text;\
  12803. -moz-user-select: text;\
  12804. -webkit-user-select: text;\
  12805. user-select: text;\
  12806. }\
  12807. .ace_text-input.ace_composition {\
  12808. background: inherit;\
  12809. color: inherit;\
  12810. z-index: 1000;\
  12811. opacity: 1;\
  12812. text-indent: 0;\
  12813. }\
  12814. .ace_layer {\
  12815. z-index: 1;\
  12816. position: absolute;\
  12817. overflow: hidden;\
  12818. word-wrap: normal;\
  12819. white-space: pre;\
  12820. height: 100%;\
  12821. width: 100%;\
  12822. -moz-box-sizing: border-box;\
  12823. -webkit-box-sizing: border-box;\
  12824. box-sizing: border-box;\
  12825. pointer-events: none;\
  12826. }\
  12827. .ace_gutter-layer {\
  12828. position: relative;\
  12829. width: auto;\
  12830. text-align: right;\
  12831. pointer-events: auto;\
  12832. }\
  12833. .ace_text-layer {\
  12834. font: inherit !important;\
  12835. }\
  12836. .ace_cjk {\
  12837. display: inline-block;\
  12838. text-align: center;\
  12839. }\
  12840. .ace_cursor-layer {\
  12841. z-index: 4;\
  12842. }\
  12843. .ace_cursor {\
  12844. z-index: 4;\
  12845. position: absolute;\
  12846. -moz-box-sizing: border-box;\
  12847. -webkit-box-sizing: border-box;\
  12848. box-sizing: border-box;\
  12849. border-left: 2px solid\
  12850. }\
  12851. .ace_slim-cursors .ace_cursor {\
  12852. border-left-width: 1px;\
  12853. }\
  12854. .ace_overwrite-cursors .ace_cursor {\
  12855. border-left-width: 0;\
  12856. border-bottom: 1px solid;\
  12857. }\
  12858. .ace_hidden-cursors .ace_cursor {\
  12859. opacity: 0.2;\
  12860. }\
  12861. .ace_smooth-blinking .ace_cursor {\
  12862. -webkit-transition: opacity 0.18s;\
  12863. transition: opacity 0.18s;\
  12864. }\
  12865. .ace_editor.ace_multiselect .ace_cursor {\
  12866. border-left-width: 1px;\
  12867. }\
  12868. .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
  12869. position: absolute;\
  12870. z-index: 3;\
  12871. }\
  12872. .ace_marker-layer .ace_selection {\
  12873. position: absolute;\
  12874. z-index: 5;\
  12875. }\
  12876. .ace_marker-layer .ace_bracket {\
  12877. position: absolute;\
  12878. z-index: 6;\
  12879. }\
  12880. .ace_marker-layer .ace_active-line {\
  12881. position: absolute;\
  12882. z-index: 2;\
  12883. }\
  12884. .ace_marker-layer .ace_selected-word {\
  12885. position: absolute;\
  12886. z-index: 4;\
  12887. -moz-box-sizing: border-box;\
  12888. -webkit-box-sizing: border-box;\
  12889. box-sizing: border-box;\
  12890. }\
  12891. .ace_line .ace_fold {\
  12892. -moz-box-sizing: border-box;\
  12893. -webkit-box-sizing: border-box;\
  12894. box-sizing: border-box;\
  12895. display: inline-block;\
  12896. height: 11px;\
  12897. margin-top: -2px;\
  12898. vertical-align: middle;\
  12899. background-image:\
  12900. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  12901. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
  12902. background-repeat: no-repeat, repeat-x;\
  12903. background-position: center center, top left;\
  12904. color: transparent;\
  12905. border: 1px solid black;\
  12906. border-radius: 2px;\
  12907. cursor: pointer;\
  12908. pointer-events: auto;\
  12909. }\
  12910. .ace_dark .ace_fold {\
  12911. }\
  12912. .ace_fold:hover{\
  12913. background-image:\
  12914. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  12915. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
  12916. }\
  12917. .ace_tooltip {\
  12918. background-color: #FFF;\
  12919. background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
  12920. background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
  12921. border: 1px solid gray;\
  12922. border-radius: 1px;\
  12923. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
  12924. color: black;\
  12925. max-width: 100%;\
  12926. padding: 3px 4px;\
  12927. position: fixed;\
  12928. z-index: 999999;\
  12929. -moz-box-sizing: border-box;\
  12930. -webkit-box-sizing: border-box;\
  12931. box-sizing: border-box;\
  12932. cursor: default;\
  12933. white-space: pre;\
  12934. word-wrap: break-word;\
  12935. line-height: normal;\
  12936. font-style: normal;\
  12937. font-weight: normal;\
  12938. letter-spacing: normal;\
  12939. pointer-events: none;\
  12940. }\
  12941. .ace_folding-enabled > .ace_gutter-cell {\
  12942. padding-right: 13px;\
  12943. }\
  12944. .ace_fold-widget {\
  12945. -moz-box-sizing: border-box;\
  12946. -webkit-box-sizing: border-box;\
  12947. box-sizing: border-box;\
  12948. margin: 0 -12px 0 1px;\
  12949. display: none;\
  12950. width: 11px;\
  12951. vertical-align: top;\
  12952. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
  12953. background-repeat: no-repeat;\
  12954. background-position: center;\
  12955. border-radius: 3px;\
  12956. border: 1px solid transparent;\
  12957. cursor: pointer;\
  12958. }\
  12959. .ace_folding-enabled .ace_fold-widget {\
  12960. display: inline-block; \
  12961. }\
  12962. .ace_fold-widget.ace_end {\
  12963. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
  12964. }\
  12965. .ace_fold-widget.ace_closed {\
  12966. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
  12967. }\
  12968. .ace_fold-widget:hover {\
  12969. border: 1px solid rgba(0, 0, 0, 0.3);\
  12970. background-color: rgba(255, 255, 255, 0.2);\
  12971. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
  12972. }\
  12973. .ace_fold-widget:active {\
  12974. border: 1px solid rgba(0, 0, 0, 0.4);\
  12975. background-color: rgba(0, 0, 0, 0.05);\
  12976. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
  12977. }\
  12978. .ace_dark .ace_fold-widget {\
  12979. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
  12980. }\
  12981. .ace_dark .ace_fold-widget.ace_end {\
  12982. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
  12983. }\
  12984. .ace_dark .ace_fold-widget.ace_closed {\
  12985. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
  12986. }\
  12987. .ace_dark .ace_fold-widget:hover {\
  12988. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  12989. background-color: rgba(255, 255, 255, 0.1);\
  12990. }\
  12991. .ace_dark .ace_fold-widget:active {\
  12992. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  12993. }\
  12994. .ace_fold-widget.ace_invalid {\
  12995. background-color: #FFB4B4;\
  12996. border-color: #DE5555;\
  12997. }\
  12998. .ace_fade-fold-widgets .ace_fold-widget {\
  12999. -webkit-transition: opacity 0.4s ease 0.05s;\
  13000. transition: opacity 0.4s ease 0.05s;\
  13001. opacity: 0;\
  13002. }\
  13003. .ace_fade-fold-widgets:hover .ace_fold-widget {\
  13004. -webkit-transition: opacity 0.05s ease 0.05s;\
  13005. transition: opacity 0.05s ease 0.05s;\
  13006. opacity:1;\
  13007. }\
  13008. .ace_underline {\
  13009. text-decoration: underline;\
  13010. }\
  13011. .ace_bold {\
  13012. font-weight: bold;\
  13013. }\
  13014. .ace_nobold .ace_bold {\
  13015. font-weight: normal;\
  13016. }\
  13017. .ace_italic {\
  13018. font-style: italic;\
  13019. }\
  13020. .ace_error-marker {\
  13021. background-color: rgba(255, 0, 0,0.2);\
  13022. position: absolute;\
  13023. z-index: 9;\
  13024. }\
  13025. .ace_highlight-marker {\
  13026. background-color: rgba(255, 255, 0,0.2);\
  13027. position: absolute;\
  13028. z-index: 8;\
  13029. }\
  13030. ";
  13031. dom.importCssString(editorCss, "ace_editor.css");
  13032. var VirtualRenderer = function(container, theme) {
  13033. var _self = this;
  13034. this.container = container || dom.createElement("div");
  13035. this.$keepTextAreaAtCursor = !useragent.isOldIE;
  13036. dom.addCssClass(this.container, "ace_editor");
  13037. this.setTheme(theme);
  13038. this.$gutter = dom.createElement("div");
  13039. this.$gutter.className = "ace_gutter";
  13040. this.container.appendChild(this.$gutter);
  13041. this.scroller = dom.createElement("div");
  13042. this.scroller.className = "ace_scroller";
  13043. this.container.appendChild(this.scroller);
  13044. this.content = dom.createElement("div");
  13045. this.content.className = "ace_content";
  13046. this.scroller.appendChild(this.content);
  13047. this.$gutterLayer = new GutterLayer(this.$gutter);
  13048. this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
  13049. this.$markerBack = new MarkerLayer(this.content);
  13050. var textLayer = this.$textLayer = new TextLayer(this.content);
  13051. this.canvas = textLayer.element;
  13052. this.$markerFront = new MarkerLayer(this.content);
  13053. this.$cursorLayer = new CursorLayer(this.content);
  13054. this.$horizScroll = false;
  13055. this.$vScroll = false;
  13056. this.scrollBar =
  13057. this.scrollBarV = new VScrollBar(this.container, this);
  13058. this.scrollBarH = new HScrollBar(this.container, this);
  13059. this.scrollBarV.addEventListener("scroll", function(e) {
  13060. if (!_self.$scrollAnimation)
  13061. _self.session.setScrollTop(e.data - _self.scrollMargin.top);
  13062. });
  13063. this.scrollBarH.addEventListener("scroll", function(e) {
  13064. if (!_self.$scrollAnimation)
  13065. _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
  13066. });
  13067. this.scrollTop = 0;
  13068. this.scrollLeft = 0;
  13069. this.cursorPos = {
  13070. row : 0,
  13071. column : 0
  13072. };
  13073. this.$fontMetrics = new FontMetrics(this.container, 500);
  13074. this.$textLayer.$setFontMetrics(this.$fontMetrics);
  13075. this.$textLayer.addEventListener("changeCharacterSize", function(e) {
  13076. _self.updateCharacterSize();
  13077. _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
  13078. _self._signal("changeCharacterSize", e);
  13079. });
  13080. this.$size = {
  13081. width: 0,
  13082. height: 0,
  13083. scrollerHeight: 0,
  13084. scrollerWidth: 0,
  13085. $dirty: true
  13086. };
  13087. this.layerConfig = {
  13088. width : 1,
  13089. padding : 0,
  13090. firstRow : 0,
  13091. firstRowScreen: 0,
  13092. lastRow : 0,
  13093. lineHeight : 0,
  13094. characterWidth : 0,
  13095. minHeight : 1,
  13096. maxHeight : 1,
  13097. offset : 0,
  13098. height : 1,
  13099. gutterOffset: 1
  13100. };
  13101. this.scrollMargin = {
  13102. left: 0,
  13103. right: 0,
  13104. top: 0,
  13105. bottom: 0,
  13106. v: 0,
  13107. h: 0
  13108. };
  13109. this.$loop = new RenderLoop(
  13110. this.$renderChanges.bind(this),
  13111. this.container.ownerDocument.defaultView
  13112. );
  13113. this.$loop.schedule(this.CHANGE_FULL);
  13114. this.updateCharacterSize();
  13115. this.setPadding(4);
  13116. config.resetOptions(this);
  13117. config._emit("renderer", this);
  13118. };
  13119. (function() {
  13120. this.CHANGE_CURSOR = 1;
  13121. this.CHANGE_MARKER = 2;
  13122. this.CHANGE_GUTTER = 4;
  13123. this.CHANGE_SCROLL = 8;
  13124. this.CHANGE_LINES = 16;
  13125. this.CHANGE_TEXT = 32;
  13126. this.CHANGE_SIZE = 64;
  13127. this.CHANGE_MARKER_BACK = 128;
  13128. this.CHANGE_MARKER_FRONT = 256;
  13129. this.CHANGE_FULL = 512;
  13130. this.CHANGE_H_SCROLL = 1024;
  13131. oop.implement(this, EventEmitter);
  13132. this.updateCharacterSize = function() {
  13133. if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
  13134. this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
  13135. this.setStyle("ace_nobold", !this.$allowBoldFonts);
  13136. }
  13137. this.layerConfig.characterWidth =
  13138. this.characterWidth = this.$textLayer.getCharacterWidth();
  13139. this.layerConfig.lineHeight =
  13140. this.lineHeight = this.$textLayer.getLineHeight();
  13141. this.$updatePrintMargin();
  13142. };
  13143. this.setSession = function(session) {
  13144. if (this.session)
  13145. this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
  13146. this.session = session;
  13147. if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
  13148. session.setScrollTop(-this.scrollMargin.top);
  13149. this.$cursorLayer.setSession(session);
  13150. this.$markerBack.setSession(session);
  13151. this.$markerFront.setSession(session);
  13152. this.$gutterLayer.setSession(session);
  13153. this.$textLayer.setSession(session);
  13154. if (!session)
  13155. return;
  13156. this.$loop.schedule(this.CHANGE_FULL);
  13157. this.session.$setFontMetrics(this.$fontMetrics);
  13158. this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
  13159. this.onChangeNewLineMode()
  13160. this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
  13161. };
  13162. this.updateLines = function(firstRow, lastRow, force) {
  13163. if (lastRow === undefined)
  13164. lastRow = Infinity;
  13165. if (!this.$changedLines) {
  13166. this.$changedLines = {
  13167. firstRow: firstRow,
  13168. lastRow: lastRow
  13169. };
  13170. }
  13171. else {
  13172. if (this.$changedLines.firstRow > firstRow)
  13173. this.$changedLines.firstRow = firstRow;
  13174. if (this.$changedLines.lastRow < lastRow)
  13175. this.$changedLines.lastRow = lastRow;
  13176. }
  13177. if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
  13178. if (force)
  13179. this.$changedLines.lastRow = this.layerConfig.lastRow;
  13180. else
  13181. return;
  13182. }
  13183. if (this.$changedLines.firstRow > this.layerConfig.lastRow)
  13184. return;
  13185. this.$loop.schedule(this.CHANGE_LINES);
  13186. };
  13187. this.onChangeNewLineMode = function() {
  13188. this.$loop.schedule(this.CHANGE_TEXT);
  13189. this.$textLayer.$updateEolChar();
  13190. };
  13191. this.onChangeTabSize = function() {
  13192. this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
  13193. this.$textLayer.onChangeTabSize();
  13194. };
  13195. this.updateText = function() {
  13196. this.$loop.schedule(this.CHANGE_TEXT);
  13197. };
  13198. this.updateFull = function(force) {
  13199. if (force)
  13200. this.$renderChanges(this.CHANGE_FULL, true);
  13201. else
  13202. this.$loop.schedule(this.CHANGE_FULL);
  13203. };
  13204. this.updateFontSize = function() {
  13205. this.$textLayer.checkForSizeChanges();
  13206. };
  13207. this.$changes = 0;
  13208. this.$updateSizeAsync = function() {
  13209. if (this.$loop.pending)
  13210. this.$size.$dirty = true;
  13211. else
  13212. this.onResize();
  13213. };
  13214. this.onResize = function(force, gutterWidth, width, height) {
  13215. if (this.resizing > 2)
  13216. return;
  13217. else if (this.resizing > 0)
  13218. this.resizing++;
  13219. else
  13220. this.resizing = force ? 1 : 0;
  13221. var el = this.container;
  13222. if (!height)
  13223. height = el.clientHeight || el.scrollHeight;
  13224. if (!width)
  13225. width = el.clientWidth || el.scrollWidth;
  13226. var changes = this.$updateCachedSize(force, gutterWidth, width, height);
  13227. if (!this.$size.scrollerHeight || (!width && !height))
  13228. return this.resizing = 0;
  13229. if (force)
  13230. this.$gutterLayer.$padding = null;
  13231. if (force)
  13232. this.$renderChanges(changes | this.$changes, true);
  13233. else
  13234. this.$loop.schedule(changes | this.$changes);
  13235. if (this.resizing)
  13236. this.resizing = 0;
  13237. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  13238. };
  13239. this.$updateCachedSize = function(force, gutterWidth, width, height) {
  13240. height -= (this.$extraHeight || 0);
  13241. var changes = 0;
  13242. var size = this.$size;
  13243. var oldSize = {
  13244. width: size.width,
  13245. height: size.height,
  13246. scrollerHeight: size.scrollerHeight,
  13247. scrollerWidth: size.scrollerWidth
  13248. };
  13249. if (height && (force || size.height != height)) {
  13250. size.height = height;
  13251. changes |= this.CHANGE_SIZE;
  13252. size.scrollerHeight = size.height;
  13253. if (this.$horizScroll)
  13254. size.scrollerHeight -= this.scrollBarH.getHeight();
  13255. this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
  13256. changes = changes | this.CHANGE_SCROLL;
  13257. }
  13258. if (width && (force || size.width != width)) {
  13259. changes |= this.CHANGE_SIZE;
  13260. size.width = width;
  13261. if (gutterWidth == null)
  13262. gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13263. this.gutterWidth = gutterWidth;
  13264. this.scrollBarH.element.style.left =
  13265. this.scroller.style.left = gutterWidth + "px";
  13266. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
  13267. this.scrollBarH.element.style.right =
  13268. this.scroller.style.right = this.scrollBarV.getWidth() + "px";
  13269. this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
  13270. if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  13271. changes |= this.CHANGE_FULL;
  13272. }
  13273. size.$dirty = !width || !height;
  13274. if (changes)
  13275. this._signal("resize", oldSize);
  13276. return changes;
  13277. };
  13278. this.onGutterResize = function() {
  13279. var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13280. if (gutterWidth != this.gutterWidth)
  13281. this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
  13282. if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
  13283. this.$loop.schedule(this.CHANGE_FULL);
  13284. } else if (this.$size.$dirty) {
  13285. this.$loop.schedule(this.CHANGE_FULL);
  13286. } else {
  13287. this.$computeLayerConfig();
  13288. this.$loop.schedule(this.CHANGE_MARKER);
  13289. }
  13290. };
  13291. this.adjustWrapLimit = function() {
  13292. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  13293. var limit = Math.floor(availableWidth / this.characterWidth);
  13294. return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
  13295. };
  13296. this.setAnimatedScroll = function(shouldAnimate){
  13297. this.setOption("animatedScroll", shouldAnimate);
  13298. };
  13299. this.getAnimatedScroll = function() {
  13300. return this.$animatedScroll;
  13301. };
  13302. this.setShowInvisibles = function(showInvisibles) {
  13303. this.setOption("showInvisibles", showInvisibles);
  13304. };
  13305. this.getShowInvisibles = function() {
  13306. return this.getOption("showInvisibles");
  13307. };
  13308. this.getDisplayIndentGuides = function() {
  13309. return this.getOption("displayIndentGuides");
  13310. };
  13311. this.setDisplayIndentGuides = function(display) {
  13312. this.setOption("displayIndentGuides", display);
  13313. };
  13314. this.setShowPrintMargin = function(showPrintMargin) {
  13315. this.setOption("showPrintMargin", showPrintMargin);
  13316. };
  13317. this.getShowPrintMargin = function() {
  13318. return this.getOption("showPrintMargin");
  13319. };
  13320. this.setPrintMarginColumn = function(showPrintMargin) {
  13321. this.setOption("printMarginColumn", showPrintMargin);
  13322. };
  13323. this.getPrintMarginColumn = function() {
  13324. return this.getOption("printMarginColumn");
  13325. };
  13326. this.getShowGutter = function(){
  13327. return this.getOption("showGutter");
  13328. };
  13329. this.setShowGutter = function(show){
  13330. return this.setOption("showGutter", show);
  13331. };
  13332. this.getFadeFoldWidgets = function(){
  13333. return this.getOption("fadeFoldWidgets")
  13334. };
  13335. this.setFadeFoldWidgets = function(show) {
  13336. this.setOption("fadeFoldWidgets", show);
  13337. };
  13338. this.setHighlightGutterLine = function(shouldHighlight) {
  13339. this.setOption("highlightGutterLine", shouldHighlight);
  13340. };
  13341. this.getHighlightGutterLine = function() {
  13342. return this.getOption("highlightGutterLine");
  13343. };
  13344. this.$updateGutterLineHighlight = function() {
  13345. var pos = this.$cursorLayer.$pixelPos;
  13346. var height = this.layerConfig.lineHeight;
  13347. if (this.session.getUseWrapMode()) {
  13348. var cursor = this.session.selection.getCursor();
  13349. cursor.column = 0;
  13350. pos = this.$cursorLayer.getPixelPosition(cursor, true);
  13351. height *= this.session.getRowLength(cursor.row);
  13352. }
  13353. this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
  13354. this.$gutterLineHighlight.style.height = height + "px";
  13355. };
  13356. this.$updatePrintMargin = function() {
  13357. if (!this.$showPrintMargin && !this.$printMarginEl)
  13358. return;
  13359. if (!this.$printMarginEl) {
  13360. var containerEl = dom.createElement("div");
  13361. containerEl.className = "ace_layer ace_print-margin-layer";
  13362. this.$printMarginEl = dom.createElement("div");
  13363. this.$printMarginEl.className = "ace_print-margin";
  13364. containerEl.appendChild(this.$printMarginEl);
  13365. this.content.insertBefore(containerEl, this.content.firstChild);
  13366. }
  13367. var style = this.$printMarginEl.style;
  13368. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  13369. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  13370. if (this.session && this.session.$wrap == -1)
  13371. this.adjustWrapLimit();
  13372. };
  13373. this.getContainerElement = function() {
  13374. return this.container;
  13375. };
  13376. this.getMouseEventTarget = function() {
  13377. return this.content;
  13378. };
  13379. this.getTextAreaContainer = function() {
  13380. return this.container;
  13381. };
  13382. this.$moveTextAreaToCursor = function() {
  13383. if (!this.$keepTextAreaAtCursor)
  13384. return;
  13385. var config = this.layerConfig;
  13386. var posTop = this.$cursorLayer.$pixelPos.top;
  13387. var posLeft = this.$cursorLayer.$pixelPos.left;
  13388. posTop -= config.offset;
  13389. var style = this.textarea.style;
  13390. var h = this.lineHeight;
  13391. if (posTop < 0 || posTop > config.height - h) {
  13392. style.top = style.left = "0";
  13393. return;
  13394. }
  13395. var w = this.characterWidth;
  13396. if (this.$composition) {
  13397. var val = this.textarea.value.replace(/^\x01+/, "");
  13398. w *= (this.session.$getStringScreenWidth(val)[0]+2);
  13399. h += 2;
  13400. }
  13401. posLeft -= this.scrollLeft;
  13402. if (posLeft > this.$size.scrollerWidth - w)
  13403. posLeft = this.$size.scrollerWidth - w;
  13404. posLeft += this.gutterWidth;
  13405. style.height = h + "px";
  13406. style.width = w + "px";
  13407. style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
  13408. style.top = Math.min(posTop, this.$size.height - h) + "px";
  13409. };
  13410. this.getFirstVisibleRow = function() {
  13411. return this.layerConfig.firstRow;
  13412. };
  13413. this.getFirstFullyVisibleRow = function() {
  13414. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  13415. };
  13416. this.getLastFullyVisibleRow = function() {
  13417. var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
  13418. return this.layerConfig.firstRow - 1 + flint;
  13419. };
  13420. this.getLastVisibleRow = function() {
  13421. return this.layerConfig.lastRow;
  13422. };
  13423. this.$padding = null;
  13424. this.setPadding = function(padding) {
  13425. this.$padding = padding;
  13426. this.$textLayer.setPadding(padding);
  13427. this.$cursorLayer.setPadding(padding);
  13428. this.$markerFront.setPadding(padding);
  13429. this.$markerBack.setPadding(padding);
  13430. this.$loop.schedule(this.CHANGE_FULL);
  13431. this.$updatePrintMargin();
  13432. };
  13433. this.setScrollMargin = function(top, bottom, left, right) {
  13434. var sm = this.scrollMargin;
  13435. sm.top = top|0;
  13436. sm.bottom = bottom|0;
  13437. sm.right = right|0;
  13438. sm.left = left|0;
  13439. sm.v = sm.top + sm.bottom;
  13440. sm.h = sm.left + sm.right;
  13441. if (sm.top && this.scrollTop <= 0 && this.session)
  13442. this.session.setScrollTop(-sm.top);
  13443. this.updateFull();
  13444. };
  13445. this.getHScrollBarAlwaysVisible = function() {
  13446. return this.$hScrollBarAlwaysVisible;
  13447. };
  13448. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  13449. this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
  13450. };
  13451. this.getVScrollBarAlwaysVisible = function() {
  13452. return this.$vScrollBarAlwaysVisible;
  13453. };
  13454. this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
  13455. this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
  13456. };
  13457. this.$updateScrollBarV = function() {
  13458. var scrollHeight = this.layerConfig.maxHeight;
  13459. var scrollerHeight = this.$size.scrollerHeight;
  13460. if (!this.$maxLines && this.$scrollPastEnd) {
  13461. scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
  13462. if (this.scrollTop > scrollHeight - scrollerHeight) {
  13463. scrollHeight = this.scrollTop + scrollerHeight;
  13464. this.scrollBarV.scrollTop = null;
  13465. }
  13466. }
  13467. this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
  13468. this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
  13469. };
  13470. this.$updateScrollBarH = function() {
  13471. this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
  13472. this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
  13473. };
  13474. this.$frozen = false;
  13475. this.freeze = function() {
  13476. this.$frozen = true;
  13477. };
  13478. this.unfreeze = function() {
  13479. this.$frozen = false;
  13480. };
  13481. this.$renderChanges = function(changes, force) {
  13482. if (this.$changes) {
  13483. changes |= this.$changes;
  13484. this.$changes = 0;
  13485. }
  13486. if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
  13487. this.$changes |= changes;
  13488. return;
  13489. }
  13490. if (this.$size.$dirty) {
  13491. this.$changes |= changes;
  13492. return this.onResize(true);
  13493. }
  13494. if (!this.lineHeight) {
  13495. this.$textLayer.checkForSizeChanges();
  13496. }
  13497. this._signal("beforeRender");
  13498. var config = this.layerConfig;
  13499. if (changes & this.CHANGE_FULL ||
  13500. changes & this.CHANGE_SIZE ||
  13501. changes & this.CHANGE_TEXT ||
  13502. changes & this.CHANGE_LINES ||
  13503. changes & this.CHANGE_SCROLL ||
  13504. changes & this.CHANGE_H_SCROLL
  13505. ) {
  13506. changes |= this.$computeLayerConfig();
  13507. if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
  13508. var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
  13509. if (st > 0) {
  13510. this.scrollTop = st;
  13511. changes = changes | this.CHANGE_SCROLL;
  13512. changes |= this.$computeLayerConfig();
  13513. }
  13514. }
  13515. config = this.layerConfig;
  13516. this.$updateScrollBarV();
  13517. if (changes & this.CHANGE_H_SCROLL)
  13518. this.$updateScrollBarH();
  13519. this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
  13520. this.content.style.marginTop = (-config.offset) + "px";
  13521. this.content.style.width = config.width + 2 * this.$padding + "px";
  13522. this.content.style.height = config.minHeight + "px";
  13523. }
  13524. if (changes & this.CHANGE_H_SCROLL) {
  13525. this.content.style.marginLeft = -this.scrollLeft + "px";
  13526. this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
  13527. }
  13528. if (changes & this.CHANGE_FULL) {
  13529. this.$textLayer.update(config);
  13530. if (this.$showGutter)
  13531. this.$gutterLayer.update(config);
  13532. this.$markerBack.update(config);
  13533. this.$markerFront.update(config);
  13534. this.$cursorLayer.update(config);
  13535. this.$moveTextAreaToCursor();
  13536. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13537. this._signal("afterRender");
  13538. return;
  13539. }
  13540. if (changes & this.CHANGE_SCROLL) {
  13541. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  13542. this.$textLayer.update(config);
  13543. else
  13544. this.$textLayer.scrollLines(config);
  13545. if (this.$showGutter)
  13546. this.$gutterLayer.update(config);
  13547. this.$markerBack.update(config);
  13548. this.$markerFront.update(config);
  13549. this.$cursorLayer.update(config);
  13550. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13551. this.$moveTextAreaToCursor();
  13552. this._signal("afterRender");
  13553. return;
  13554. }
  13555. if (changes & this.CHANGE_TEXT) {
  13556. this.$textLayer.update(config);
  13557. if (this.$showGutter)
  13558. this.$gutterLayer.update(config);
  13559. }
  13560. else if (changes & this.CHANGE_LINES) {
  13561. if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
  13562. this.$gutterLayer.update(config);
  13563. }
  13564. else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
  13565. if (this.$showGutter)
  13566. this.$gutterLayer.update(config);
  13567. }
  13568. if (changes & this.CHANGE_CURSOR) {
  13569. this.$cursorLayer.update(config);
  13570. this.$moveTextAreaToCursor();
  13571. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13572. }
  13573. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  13574. this.$markerFront.update(config);
  13575. }
  13576. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  13577. this.$markerBack.update(config);
  13578. }
  13579. this._signal("afterRender");
  13580. };
  13581. this.$autosize = function() {
  13582. var height = this.session.getScreenLength() * this.lineHeight;
  13583. var maxHeight = this.$maxLines * this.lineHeight;
  13584. var desiredHeight = Math.max(
  13585. (this.$minLines||1) * this.lineHeight,
  13586. Math.min(maxHeight, height)
  13587. ) + this.scrollMargin.v + (this.$extraHeight || 0);
  13588. var vScroll = height > maxHeight;
  13589. if (desiredHeight != this.desiredHeight ||
  13590. this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
  13591. if (vScroll != this.$vScroll) {
  13592. this.$vScroll = vScroll;
  13593. this.scrollBarV.setVisible(vScroll);
  13594. }
  13595. var w = this.container.clientWidth;
  13596. this.container.style.height = desiredHeight + "px";
  13597. this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
  13598. this.desiredHeight = desiredHeight;
  13599. this._signal("autosize");
  13600. }
  13601. };
  13602. this.$computeLayerConfig = function() {
  13603. if (this.$maxLines && this.lineHeight > 1)
  13604. this.$autosize();
  13605. var session = this.session;
  13606. var size = this.$size;
  13607. var hideScrollbars = size.height <= 2 * this.lineHeight;
  13608. var screenLines = this.session.getScreenLength();
  13609. var maxHeight = screenLines * this.lineHeight;
  13610. var offset = this.scrollTop % this.lineHeight;
  13611. var minHeight = size.scrollerHeight + this.lineHeight;
  13612. var longestLine = this.$getLongestLine();
  13613. var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
  13614. size.scrollerWidth - longestLine - 2 * this.$padding < 0);
  13615. var hScrollChanged = this.$horizScroll !== horizScroll;
  13616. if (hScrollChanged) {
  13617. this.$horizScroll = horizScroll;
  13618. this.scrollBarH.setVisible(horizScroll);
  13619. }
  13620. var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
  13621. ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
  13622. : 0;
  13623. maxHeight += scrollPastEnd;
  13624. this.session.setScrollTop(Math.max(-this.scrollMargin.top,
  13625. Math.min(this.scrollTop, maxHeight - size.scrollerHeight + this.scrollMargin.bottom)));
  13626. this.session.setScrollLeft(Math.max(-this.scrollMargin.left, Math.min(this.scrollLeft,
  13627. longestLine + 2 * this.$padding - size.scrollerWidth + this.scrollMargin.right)));
  13628. var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
  13629. size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop);
  13630. var vScrollChanged = this.$vScroll !== vScroll;
  13631. if (vScrollChanged) {
  13632. this.$vScroll = vScroll;
  13633. this.scrollBarV.setVisible(vScroll);
  13634. }
  13635. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  13636. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  13637. var lastRow = firstRow + lineCount;
  13638. var firstRowScreen, firstRowHeight;
  13639. var lineHeight = this.lineHeight;
  13640. firstRow = session.screenToDocumentRow(firstRow, 0);
  13641. var foldLine = session.getFoldLine(firstRow);
  13642. if (foldLine) {
  13643. firstRow = foldLine.start.row;
  13644. }
  13645. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  13646. firstRowHeight = session.getRowLength(firstRow) * lineHeight;
  13647. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  13648. minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
  13649. firstRowHeight;
  13650. offset = this.scrollTop - firstRowScreen * lineHeight;
  13651. var changes = 0;
  13652. if (this.layerConfig.width != longestLine)
  13653. changes = this.CHANGE_H_SCROLL;
  13654. if (hScrollChanged || vScrollChanged) {
  13655. changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
  13656. this._signal("scrollbarVisibilityChanged");
  13657. if (vScrollChanged)
  13658. longestLine = this.$getLongestLine();
  13659. }
  13660. this.layerConfig = {
  13661. width : longestLine,
  13662. padding : this.$padding,
  13663. firstRow : firstRow,
  13664. firstRowScreen: firstRowScreen,
  13665. lastRow : lastRow,
  13666. lineHeight : lineHeight,
  13667. characterWidth : this.characterWidth,
  13668. minHeight : minHeight,
  13669. maxHeight : maxHeight,
  13670. offset : offset,
  13671. gutterOffset : Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)),
  13672. height : this.$size.scrollerHeight
  13673. };
  13674. return changes;
  13675. };
  13676. this.$updateLines = function() {
  13677. var firstRow = this.$changedLines.firstRow;
  13678. var lastRow = this.$changedLines.lastRow;
  13679. this.$changedLines = null;
  13680. var layerConfig = this.layerConfig;
  13681. if (firstRow > layerConfig.lastRow + 1) { return; }
  13682. if (lastRow < layerConfig.firstRow) { return; }
  13683. if (lastRow === Infinity) {
  13684. if (this.$showGutter)
  13685. this.$gutterLayer.update(layerConfig);
  13686. this.$textLayer.update(layerConfig);
  13687. return;
  13688. }
  13689. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  13690. return true;
  13691. };
  13692. this.$getLongestLine = function() {
  13693. var charCount = this.session.getScreenWidth();
  13694. if (this.showInvisibles && !this.session.$useWrapMode)
  13695. charCount += 1;
  13696. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  13697. };
  13698. this.updateFrontMarkers = function() {
  13699. this.$markerFront.setMarkers(this.session.getMarkers(true));
  13700. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  13701. };
  13702. this.updateBackMarkers = function() {
  13703. this.$markerBack.setMarkers(this.session.getMarkers());
  13704. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  13705. };
  13706. this.addGutterDecoration = function(row, className){
  13707. this.$gutterLayer.addGutterDecoration(row, className);
  13708. };
  13709. this.removeGutterDecoration = function(row, className){
  13710. this.$gutterLayer.removeGutterDecoration(row, className);
  13711. };
  13712. this.updateBreakpoints = function(rows) {
  13713. this.$loop.schedule(this.CHANGE_GUTTER);
  13714. };
  13715. this.setAnnotations = function(annotations) {
  13716. this.$gutterLayer.setAnnotations(annotations);
  13717. this.$loop.schedule(this.CHANGE_GUTTER);
  13718. };
  13719. this.updateCursor = function() {
  13720. this.$loop.schedule(this.CHANGE_CURSOR);
  13721. };
  13722. this.hideCursor = function() {
  13723. this.$cursorLayer.hideCursor();
  13724. };
  13725. this.showCursor = function() {
  13726. this.$cursorLayer.showCursor();
  13727. };
  13728. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  13729. this.scrollCursorIntoView(anchor, offset);
  13730. this.scrollCursorIntoView(lead, offset);
  13731. };
  13732. this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
  13733. if (this.$size.scrollerHeight === 0)
  13734. return;
  13735. var pos = this.$cursorLayer.getPixelPosition(cursor);
  13736. var left = pos.left;
  13737. var top = pos.top;
  13738. var topMargin = $viewMargin && $viewMargin.top || 0;
  13739. var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
  13740. var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
  13741. if (scrollTop + topMargin > top) {
  13742. if (offset)
  13743. top -= offset * this.$size.scrollerHeight;
  13744. if (top === 0)
  13745. top = -this.scrollMargin.top;
  13746. this.session.setScrollTop(top);
  13747. } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
  13748. if (offset)
  13749. top += offset * this.$size.scrollerHeight;
  13750. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  13751. }
  13752. var scrollLeft = this.scrollLeft;
  13753. if (scrollLeft > left) {
  13754. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  13755. left = -this.scrollMargin.left;
  13756. this.session.setScrollLeft(left);
  13757. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  13758. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  13759. } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
  13760. this.session.setScrollLeft(0);
  13761. }
  13762. };
  13763. this.getScrollTop = function() {
  13764. return this.session.getScrollTop();
  13765. };
  13766. this.getScrollLeft = function() {
  13767. return this.session.getScrollLeft();
  13768. };
  13769. this.getScrollTopRow = function() {
  13770. return this.scrollTop / this.lineHeight;
  13771. };
  13772. this.getScrollBottomRow = function() {
  13773. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  13774. };
  13775. this.scrollToRow = function(row) {
  13776. this.session.setScrollTop(row * this.lineHeight);
  13777. };
  13778. this.alignCursor = function(cursor, alignment) {
  13779. if (typeof cursor == "number")
  13780. cursor = {row: cursor, column: 0};
  13781. var pos = this.$cursorLayer.getPixelPosition(cursor);
  13782. var h = this.$size.scrollerHeight - this.lineHeight;
  13783. var offset = pos.top - h * (alignment || 0);
  13784. this.session.setScrollTop(offset);
  13785. return offset;
  13786. };
  13787. this.STEPS = 8;
  13788. this.$calcSteps = function(fromValue, toValue){
  13789. var i = 0;
  13790. var l = this.STEPS;
  13791. var steps = [];
  13792. var func = function(t, x_min, dx) {
  13793. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  13794. };
  13795. for (i = 0; i < l; ++i)
  13796. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  13797. return steps;
  13798. };
  13799. this.scrollToLine = function(line, center, animate, callback) {
  13800. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  13801. var offset = pos.top;
  13802. if (center)
  13803. offset -= this.$size.scrollerHeight / 2;
  13804. var initialScroll = this.scrollTop;
  13805. this.session.setScrollTop(offset);
  13806. if (animate !== false)
  13807. this.animateScrolling(initialScroll, callback);
  13808. };
  13809. this.animateScrolling = function(fromValue, callback) {
  13810. var toValue = this.scrollTop;
  13811. if (!this.$animatedScroll)
  13812. return;
  13813. var _self = this;
  13814. if (fromValue == toValue)
  13815. return;
  13816. if (this.$scrollAnimation) {
  13817. var oldSteps = this.$scrollAnimation.steps;
  13818. if (oldSteps.length) {
  13819. fromValue = oldSteps[0];
  13820. if (fromValue == toValue)
  13821. return;
  13822. }
  13823. }
  13824. var steps = _self.$calcSteps(fromValue, toValue);
  13825. this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
  13826. clearInterval(this.$timer);
  13827. _self.session.setScrollTop(steps.shift());
  13828. _self.session.$scrollTop = toValue;
  13829. this.$timer = setInterval(function() {
  13830. if (steps.length) {
  13831. _self.session.setScrollTop(steps.shift());
  13832. _self.session.$scrollTop = toValue;
  13833. } else if (toValue != null) {
  13834. _self.session.$scrollTop = -1;
  13835. _self.session.setScrollTop(toValue);
  13836. toValue = null;
  13837. } else {
  13838. _self.$timer = clearInterval(_self.$timer);
  13839. _self.$scrollAnimation = null;
  13840. callback && callback();
  13841. }
  13842. }, 10);
  13843. };
  13844. this.scrollToY = function(scrollTop) {
  13845. if (this.scrollTop !== scrollTop) {
  13846. this.$loop.schedule(this.CHANGE_SCROLL);
  13847. this.scrollTop = scrollTop;
  13848. }
  13849. };
  13850. this.scrollToX = function(scrollLeft) {
  13851. if (this.scrollLeft !== scrollLeft)
  13852. this.scrollLeft = scrollLeft;
  13853. this.$loop.schedule(this.CHANGE_H_SCROLL);
  13854. };
  13855. this.scrollTo = function(x, y) {
  13856. this.session.setScrollTop(y);
  13857. this.session.setScrollLeft(y);
  13858. };
  13859. this.scrollBy = function(deltaX, deltaY) {
  13860. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  13861. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  13862. };
  13863. this.isScrollableBy = function(deltaX, deltaY) {
  13864. if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
  13865. return true;
  13866. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
  13867. - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
  13868. return true;
  13869. if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
  13870. return true;
  13871. if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
  13872. - this.layerConfig.width < -1 + this.scrollMargin.right)
  13873. return true;
  13874. };
  13875. this.pixelToScreenCoordinates = function(x, y) {
  13876. var canvasPos = this.scroller.getBoundingClientRect();
  13877. var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
  13878. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  13879. var col = Math.round(offset);
  13880. return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
  13881. };
  13882. this.screenToTextCoordinates = function(x, y) {
  13883. var canvasPos = this.scroller.getBoundingClientRect();
  13884. var col = Math.round(
  13885. (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
  13886. );
  13887. var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
  13888. return this.session.screenToDocumentPosition(row, Math.max(col, 0));
  13889. };
  13890. this.textToScreenCoordinates = function(row, column) {
  13891. var canvasPos = this.scroller.getBoundingClientRect();
  13892. var pos = this.session.documentToScreenPosition(row, column);
  13893. var x = this.$padding + Math.round(pos.column * this.characterWidth);
  13894. var y = pos.row * this.lineHeight;
  13895. return {
  13896. pageX: canvasPos.left + x - this.scrollLeft,
  13897. pageY: canvasPos.top + y - this.scrollTop
  13898. };
  13899. };
  13900. this.visualizeFocus = function() {
  13901. dom.addCssClass(this.container, "ace_focus");
  13902. };
  13903. this.visualizeBlur = function() {
  13904. dom.removeCssClass(this.container, "ace_focus");
  13905. };
  13906. this.showComposition = function(position) {
  13907. if (!this.$composition)
  13908. this.$composition = {
  13909. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  13910. cssText: this.textarea.style.cssText
  13911. };
  13912. this.$keepTextAreaAtCursor = true;
  13913. dom.addCssClass(this.textarea, "ace_composition");
  13914. this.textarea.style.cssText = "";
  13915. this.$moveTextAreaToCursor();
  13916. };
  13917. this.setCompositionText = function(text) {
  13918. this.$moveTextAreaToCursor();
  13919. };
  13920. this.hideComposition = function() {
  13921. if (!this.$composition)
  13922. return;
  13923. dom.removeCssClass(this.textarea, "ace_composition");
  13924. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  13925. this.textarea.style.cssText = this.$composition.cssText;
  13926. this.$composition = null;
  13927. };
  13928. this.setTheme = function(theme, cb) {
  13929. var _self = this;
  13930. this.$themeId = theme;
  13931. _self._dispatchEvent('themeChange',{theme:theme});
  13932. if (!theme || typeof theme == "string") {
  13933. var moduleName = theme || this.$options.theme.initialValue;
  13934. config.loadModule(["theme", moduleName], afterLoad);
  13935. } else {
  13936. afterLoad(theme);
  13937. }
  13938. function afterLoad(module) {
  13939. if (_self.$themeId != theme)
  13940. return cb && cb();
  13941. if (!module.cssClass)
  13942. return;
  13943. dom.importCssString(
  13944. module.cssText,
  13945. module.cssClass,
  13946. _self.container.ownerDocument
  13947. );
  13948. if (_self.theme)
  13949. dom.removeCssClass(_self.container, _self.theme.cssClass);
  13950. var padding = "padding" in module ? module.padding
  13951. : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
  13952. if (_self.$padding && padding != _self.$padding)
  13953. _self.setPadding(padding);
  13954. _self.$theme = module.cssClass;
  13955. _self.theme = module;
  13956. dom.addCssClass(_self.container, module.cssClass);
  13957. dom.setCssClass(_self.container, "ace_dark", module.isDark);
  13958. if (_self.$size) {
  13959. _self.$size.width = 0;
  13960. _self.$updateSizeAsync();
  13961. }
  13962. _self._dispatchEvent('themeLoaded', {theme:module});
  13963. cb && cb();
  13964. }
  13965. };
  13966. this.getTheme = function() {
  13967. return this.$themeId;
  13968. };
  13969. this.setStyle = function(style, include) {
  13970. dom.setCssClass(this.container, style, include !== false);
  13971. };
  13972. this.unsetStyle = function(style) {
  13973. dom.removeCssClass(this.container, style);
  13974. };
  13975. this.setCursorStyle = function(style) {
  13976. if (this.scroller.style.cursor != style)
  13977. this.scroller.style.cursor = style;
  13978. };
  13979. this.setMouseCursor = function(cursorStyle) {
  13980. this.scroller.style.cursor = cursorStyle;
  13981. };
  13982. this.destroy = function() {
  13983. this.$textLayer.destroy();
  13984. this.$cursorLayer.destroy();
  13985. };
  13986. }).call(VirtualRenderer.prototype);
  13987. config.defineOptions(VirtualRenderer.prototype, "renderer", {
  13988. animatedScroll: {initialValue: false},
  13989. showInvisibles: {
  13990. set: function(value) {
  13991. if (this.$textLayer.setShowInvisibles(value))
  13992. this.$loop.schedule(this.CHANGE_TEXT);
  13993. },
  13994. initialValue: false
  13995. },
  13996. showPrintMargin: {
  13997. set: function() { this.$updatePrintMargin(); },
  13998. initialValue: true
  13999. },
  14000. printMarginColumn: {
  14001. set: function() { this.$updatePrintMargin(); },
  14002. initialValue: 80
  14003. },
  14004. printMargin: {
  14005. set: function(val) {
  14006. if (typeof val == "number")
  14007. this.$printMarginColumn = val;
  14008. this.$showPrintMargin = !!val;
  14009. this.$updatePrintMargin();
  14010. },
  14011. get: function() {
  14012. return this.$showPrintMargin && this.$printMarginColumn;
  14013. }
  14014. },
  14015. showGutter: {
  14016. set: function(show){
  14017. this.$gutter.style.display = show ? "block" : "none";
  14018. this.$loop.schedule(this.CHANGE_FULL);
  14019. this.onGutterResize();
  14020. },
  14021. initialValue: true
  14022. },
  14023. fadeFoldWidgets: {
  14024. set: function(show) {
  14025. dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
  14026. },
  14027. initialValue: false
  14028. },
  14029. showFoldWidgets: {
  14030. set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
  14031. initialValue: true
  14032. },
  14033. showLineNumbers: {
  14034. set: function(show) {
  14035. this.$gutterLayer.setShowLineNumbers(show);
  14036. this.$loop.schedule(this.CHANGE_GUTTER);
  14037. },
  14038. initialValue: true
  14039. },
  14040. displayIndentGuides: {
  14041. set: function(show) {
  14042. if (this.$textLayer.setDisplayIndentGuides(show))
  14043. this.$loop.schedule(this.CHANGE_TEXT);
  14044. },
  14045. initialValue: true
  14046. },
  14047. highlightGutterLine: {
  14048. set: function(shouldHighlight) {
  14049. if (!this.$gutterLineHighlight) {
  14050. this.$gutterLineHighlight = dom.createElement("div");
  14051. this.$gutterLineHighlight.className = "ace_gutter-active-line";
  14052. this.$gutter.appendChild(this.$gutterLineHighlight);
  14053. return;
  14054. }
  14055. this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
  14056. if (this.$cursorLayer.$pixelPos)
  14057. this.$updateGutterLineHighlight();
  14058. },
  14059. initialValue: false,
  14060. value: true
  14061. },
  14062. hScrollBarAlwaysVisible: {
  14063. set: function(val) {
  14064. if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
  14065. this.$loop.schedule(this.CHANGE_SCROLL);
  14066. },
  14067. initialValue: false
  14068. },
  14069. vScrollBarAlwaysVisible: {
  14070. set: function(val) {
  14071. if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
  14072. this.$loop.schedule(this.CHANGE_SCROLL);
  14073. },
  14074. initialValue: false
  14075. },
  14076. fontSize: {
  14077. set: function(size) {
  14078. if (typeof size == "number")
  14079. size = size + "px";
  14080. this.container.style.fontSize = size;
  14081. this.updateFontSize();
  14082. },
  14083. initialValue: 12
  14084. },
  14085. fontFamily: {
  14086. set: function(name) {
  14087. this.container.style.fontFamily = name;
  14088. this.updateFontSize();
  14089. }
  14090. },
  14091. maxLines: {
  14092. set: function(val) {
  14093. this.updateFull();
  14094. }
  14095. },
  14096. minLines: {
  14097. set: function(val) {
  14098. this.updateFull();
  14099. }
  14100. },
  14101. scrollPastEnd: {
  14102. set: function(val) {
  14103. val = +val || 0;
  14104. if (this.$scrollPastEnd == val)
  14105. return;
  14106. this.$scrollPastEnd = val;
  14107. this.$loop.schedule(this.CHANGE_SCROLL);
  14108. },
  14109. initialValue: 0,
  14110. handlesSet: true
  14111. },
  14112. fixedWidthGutter: {
  14113. set: function(val) {
  14114. this.$gutterLayer.$fixedWidth = !!val;
  14115. this.$loop.schedule(this.CHANGE_GUTTER);
  14116. }
  14117. },
  14118. theme: {
  14119. set: function(val) { this.setTheme(val) },
  14120. get: function() { return this.$themeId || this.theme; },
  14121. initialValue: "./theme/textmate",
  14122. handlesSet: true
  14123. }
  14124. });
  14125. exports.VirtualRenderer = VirtualRenderer;
  14126. });
  14127. 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) {
  14128. "use strict";
  14129. var oop = require("../lib/oop");
  14130. var net = require("../lib/net");
  14131. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  14132. var config = require("../config");
  14133. var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
  14134. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14135. this.changeListener = this.changeListener.bind(this);
  14136. this.onMessage = this.onMessage.bind(this);
  14137. if (require.nameToUrl && !require.toUrl)
  14138. require.toUrl = require.nameToUrl;
  14139. if (config.get("packaged") || !require.toUrl) {
  14140. workerUrl = workerUrl || config.moduleUrl(mod, "worker");
  14141. } else {
  14142. var normalizePath = this.$normalizePath;
  14143. workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
  14144. var tlns = {};
  14145. topLevelNamespaces.forEach(function(ns) {
  14146. tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
  14147. });
  14148. }
  14149. try {
  14150. this.$worker = new Worker(workerUrl);
  14151. } catch(e) {
  14152. if (e instanceof window.DOMException) {
  14153. var blob = this.$workerBlob(workerUrl);
  14154. var URL = window.URL || window.webkitURL;
  14155. var blobURL = URL.createObjectURL(blob);
  14156. this.$worker = new Worker(blobURL);
  14157. URL.revokeObjectURL(blobURL);
  14158. } else {
  14159. throw e;
  14160. }
  14161. }
  14162. this.$worker.postMessage({
  14163. init : true,
  14164. tlns : tlns,
  14165. module : mod,
  14166. classname : classname
  14167. });
  14168. this.callbackId = 1;
  14169. this.callbacks = {};
  14170. this.$worker.onmessage = this.onMessage;
  14171. };
  14172. (function(){
  14173. oop.implement(this, EventEmitter);
  14174. this.onMessage = function(e) {
  14175. var msg = e.data;
  14176. switch(msg.type) {
  14177. case "event":
  14178. this._signal(msg.name, {data: msg.data});
  14179. break;
  14180. case "call":
  14181. var callback = this.callbacks[msg.id];
  14182. if (callback) {
  14183. callback(msg.data);
  14184. delete this.callbacks[msg.id];
  14185. }
  14186. break;
  14187. case "error":
  14188. this.reportError(msg.data);
  14189. break;
  14190. case "log":
  14191. window.console && console.log && console.log.apply(console, msg.data);
  14192. break;
  14193. }
  14194. };
  14195. this.reportError = function(err) {
  14196. window.console && console.error && console.error(err);
  14197. };
  14198. this.$normalizePath = function(path) {
  14199. return net.qualifyURL(path);
  14200. };
  14201. this.terminate = function() {
  14202. this._signal("terminate", {});
  14203. this.deltaQueue = null;
  14204. this.$worker.terminate();
  14205. this.$worker = null;
  14206. if (this.$doc)
  14207. this.$doc.off("change", this.changeListener);
  14208. this.$doc = null;
  14209. };
  14210. this.send = function(cmd, args) {
  14211. this.$worker.postMessage({command: cmd, args: args});
  14212. };
  14213. this.call = function(cmd, args, callback) {
  14214. if (callback) {
  14215. var id = this.callbackId++;
  14216. this.callbacks[id] = callback;
  14217. args.push(id);
  14218. }
  14219. this.send(cmd, args);
  14220. };
  14221. this.emit = function(event, data) {
  14222. try {
  14223. this.$worker.postMessage({event: event, data: {data: data.data}});
  14224. }
  14225. catch(ex) {
  14226. console.error(ex.stack);
  14227. }
  14228. };
  14229. this.attachToDocument = function(doc) {
  14230. if(this.$doc)
  14231. this.terminate();
  14232. this.$doc = doc;
  14233. this.call("setValue", [doc.getValue()]);
  14234. doc.on("change", this.changeListener);
  14235. };
  14236. this.changeListener = function(e) {
  14237. if (!this.deltaQueue) {
  14238. this.deltaQueue = [e.data];
  14239. setTimeout(this.$sendDeltaQueue, 0);
  14240. } else
  14241. this.deltaQueue.push(e.data);
  14242. };
  14243. this.$sendDeltaQueue = function() {
  14244. var q = this.deltaQueue;
  14245. if (!q) return;
  14246. this.deltaQueue = null;
  14247. if (q.length > 20 && q.length > this.$doc.getLength() >> 1) {
  14248. this.call("setValue", [this.$doc.getValue()]);
  14249. } else
  14250. this.emit("change", {data: q});
  14251. };
  14252. this.$workerBlob = function(workerUrl) {
  14253. var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
  14254. try {
  14255. return new Blob([script], {"type": "application/javascript"});
  14256. } catch (e) { // Backwards-compatibility
  14257. var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
  14258. var blobBuilder = new BlobBuilder();
  14259. blobBuilder.append(script);
  14260. return blobBuilder.getBlob("application/javascript");
  14261. }
  14262. };
  14263. }).call(WorkerClient.prototype);
  14264. var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
  14265. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14266. this.changeListener = this.changeListener.bind(this);
  14267. this.callbackId = 1;
  14268. this.callbacks = {};
  14269. this.messageBuffer = [];
  14270. var main = null;
  14271. var emitSync = false;
  14272. var sender = Object.create(EventEmitter);
  14273. var _self = this;
  14274. this.$worker = {};
  14275. this.$worker.terminate = function() {};
  14276. this.$worker.postMessage = function(e) {
  14277. _self.messageBuffer.push(e);
  14278. if (main) {
  14279. if (emitSync)
  14280. setTimeout(processNext);
  14281. else
  14282. processNext();
  14283. }
  14284. };
  14285. this.setEmitSync = function(val) { emitSync = val };
  14286. var processNext = function() {
  14287. var msg = _self.messageBuffer.shift();
  14288. if (msg.command)
  14289. main[msg.command].apply(main, msg.args);
  14290. else if (msg.event)
  14291. sender._signal(msg.event, msg.data);
  14292. };
  14293. sender.postMessage = function(msg) {
  14294. _self.onMessage({data: msg});
  14295. };
  14296. sender.callback = function(data, callbackId) {
  14297. this.postMessage({type: "call", id: callbackId, data: data});
  14298. };
  14299. sender.emit = function(name, data) {
  14300. this.postMessage({type: "event", name: name, data: data});
  14301. };
  14302. config.loadModule(["worker", mod], function(Main) {
  14303. main = new Main[classname](sender);
  14304. while (_self.messageBuffer.length)
  14305. processNext();
  14306. });
  14307. };
  14308. UIWorkerClient.prototype = WorkerClient.prototype;
  14309. exports.UIWorkerClient = UIWorkerClient;
  14310. exports.WorkerClient = WorkerClient;
  14311. });
  14312. ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
  14313. "use strict";
  14314. var Range = require("./range").Range;
  14315. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14316. var oop = require("./lib/oop");
  14317. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  14318. var _self = this;
  14319. this.length = length;
  14320. this.session = session;
  14321. this.doc = session.getDocument();
  14322. this.mainClass = mainClass;
  14323. this.othersClass = othersClass;
  14324. this.$onUpdate = this.onUpdate.bind(this);
  14325. this.doc.on("change", this.$onUpdate);
  14326. this.$others = others;
  14327. this.$onCursorChange = function() {
  14328. setTimeout(function() {
  14329. _self.onCursorChange();
  14330. });
  14331. };
  14332. this.$pos = pos;
  14333. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  14334. this.$undoStackDepth = undoStack.length;
  14335. this.setup();
  14336. session.selection.on("changeCursor", this.$onCursorChange);
  14337. };
  14338. (function() {
  14339. oop.implement(this, EventEmitter);
  14340. this.setup = function() {
  14341. var _self = this;
  14342. var doc = this.doc;
  14343. var session = this.session;
  14344. var pos = this.$pos;
  14345. this.selectionBefore = session.selection.toJSON();
  14346. if (session.selection.inMultiSelectMode)
  14347. session.selection.toSingleRange();
  14348. this.pos = doc.createAnchor(pos.row, pos.column);
  14349. this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  14350. this.pos.on("change", function(event) {
  14351. session.removeMarker(_self.markerId);
  14352. _self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
  14353. });
  14354. this.others = [];
  14355. this.$others.forEach(function(other) {
  14356. var anchor = doc.createAnchor(other.row, other.column);
  14357. _self.others.push(anchor);
  14358. });
  14359. session.setUndoSelect(false);
  14360. };
  14361. this.showOtherMarkers = function() {
  14362. if(this.othersActive) return;
  14363. var session = this.session;
  14364. var _self = this;
  14365. this.othersActive = true;
  14366. this.others.forEach(function(anchor) {
  14367. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  14368. anchor.on("change", function(event) {
  14369. session.removeMarker(anchor.markerId);
  14370. anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
  14371. });
  14372. });
  14373. };
  14374. this.hideOtherMarkers = function() {
  14375. if(!this.othersActive) return;
  14376. this.othersActive = false;
  14377. for (var i = 0; i < this.others.length; i++) {
  14378. this.session.removeMarker(this.others[i].markerId);
  14379. }
  14380. };
  14381. this.onUpdate = function(event) {
  14382. var delta = event.data;
  14383. var range = delta.range;
  14384. if(range.start.row !== range.end.row) return;
  14385. if(range.start.row !== this.pos.row) return;
  14386. if (this.$updating) return;
  14387. this.$updating = true;
  14388. var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column;
  14389. if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
  14390. var distanceFromStart = range.start.column - this.pos.column;
  14391. this.length += lengthDiff;
  14392. if(!this.session.$fromUndo) {
  14393. if(delta.action === "insertText") {
  14394. for (var i = this.others.length - 1; i >= 0; i--) {
  14395. var otherPos = this.others[i];
  14396. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14397. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  14398. newPos.column += lengthDiff;
  14399. this.doc.insert(newPos, delta.text);
  14400. }
  14401. } else if(delta.action === "removeText") {
  14402. for (var i = this.others.length - 1; i >= 0; i--) {
  14403. var otherPos = this.others[i];
  14404. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14405. if(otherPos.row === range.start.row && range.start.column < otherPos.column)
  14406. newPos.column += lengthDiff;
  14407. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  14408. }
  14409. }
  14410. if(range.start.column === this.pos.column && delta.action === "insertText") {
  14411. setTimeout(function() {
  14412. this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
  14413. for (var i = 0; i < this.others.length; i++) {
  14414. var other = this.others[i];
  14415. var newPos = {row: other.row, column: other.column - lengthDiff};
  14416. if(other.row === range.start.row && range.start.column < other.column)
  14417. newPos.column += lengthDiff;
  14418. other.setPosition(newPos.row, newPos.column);
  14419. }
  14420. }.bind(this), 0);
  14421. }
  14422. else if(range.start.column === this.pos.column && delta.action === "removeText") {
  14423. setTimeout(function() {
  14424. for (var i = 0; i < this.others.length; i++) {
  14425. var other = this.others[i];
  14426. if(other.row === range.start.row && range.start.column < other.column) {
  14427. other.setPosition(other.row, other.column - lengthDiff);
  14428. }
  14429. }
  14430. }.bind(this), 0);
  14431. }
  14432. }
  14433. this.pos._emit("change", {value: this.pos});
  14434. for (var i = 0; i < this.others.length; i++) {
  14435. this.others[i]._emit("change", {value: this.others[i]});
  14436. }
  14437. }
  14438. this.$updating = false;
  14439. };
  14440. this.onCursorChange = function(event) {
  14441. if (this.$updating || !this.session) return;
  14442. var pos = this.session.selection.getCursor();
  14443. if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  14444. this.showOtherMarkers();
  14445. this._emit("cursorEnter", event);
  14446. } else {
  14447. this.hideOtherMarkers();
  14448. this._emit("cursorLeave", event);
  14449. }
  14450. };
  14451. this.detach = function() {
  14452. this.session.removeMarker(this.markerId);
  14453. this.hideOtherMarkers();
  14454. this.doc.removeEventListener("change", this.$onUpdate);
  14455. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  14456. this.pos.detach();
  14457. for (var i = 0; i < this.others.length; i++) {
  14458. this.others[i].detach();
  14459. }
  14460. this.session.setUndoSelect(true);
  14461. this.session = null;
  14462. };
  14463. this.cancel = function() {
  14464. if(this.$undoStackDepth === -1)
  14465. throw Error("Canceling placeholders only supported with undo manager attached to session.");
  14466. var undoManager = this.session.getUndoManager();
  14467. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  14468. for (var i = 0; i < undosRequired; i++) {
  14469. undoManager.undo(true);
  14470. }
  14471. if (this.selectionBefore)
  14472. this.session.selection.fromJSON(this.selectionBefore);
  14473. };
  14474. }).call(PlaceHolder.prototype);
  14475. exports.PlaceHolder = PlaceHolder;
  14476. });
  14477. ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  14478. var event = require("../lib/event");
  14479. var useragent = require("../lib/useragent");
  14480. function isSamePoint(p1, p2) {
  14481. return p1.row == p2.row && p1.column == p2.column;
  14482. }
  14483. function onMouseDown(e) {
  14484. var ev = e.domEvent;
  14485. var alt = ev.altKey;
  14486. var shift = ev.shiftKey;
  14487. var ctrl = ev.ctrlKey;
  14488. var accel = e.getAccelKey();
  14489. var button = e.getButton();
  14490. if (ctrl && useragent.isMac)
  14491. button = ev.button;
  14492. if (e.editor.inMultiSelectMode && button == 2) {
  14493. e.editor.textInput.onContextMenu(e.domEvent);
  14494. return;
  14495. }
  14496. if (!ctrl && !alt && !accel) {
  14497. if (button === 0 && e.editor.inMultiSelectMode)
  14498. e.editor.exitMultiSelectMode();
  14499. return;
  14500. }
  14501. if (button !== 0)
  14502. return;
  14503. var editor = e.editor;
  14504. var selection = editor.selection;
  14505. var isMultiSelect = editor.inMultiSelectMode;
  14506. var pos = e.getDocumentPosition();
  14507. var cursor = selection.getCursor();
  14508. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  14509. var mouseX = e.x, mouseY = e.y;
  14510. var onMouseSelection = function(e) {
  14511. mouseX = e.clientX;
  14512. mouseY = e.clientY;
  14513. };
  14514. var session = editor.session;
  14515. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14516. var screenCursor = screenAnchor;
  14517. var selectionMode;
  14518. if (editor.$mouseHandler.$enableJumpToDef) {
  14519. if (ctrl && alt || accel && alt)
  14520. selectionMode = "add";
  14521. else if (alt)
  14522. selectionMode = "block";
  14523. } else {
  14524. if (accel && !alt) {
  14525. selectionMode = "add";
  14526. if (!isMultiSelect && shift)
  14527. return;
  14528. } else if (alt) {
  14529. selectionMode = "block";
  14530. }
  14531. }
  14532. if (selectionMode && useragent.isMac && ev.ctrlKey) {
  14533. editor.$mouseHandler.cancelContextMenu();
  14534. }
  14535. if (selectionMode == "add") {
  14536. if (!isMultiSelect && inSelection)
  14537. return; // dragging
  14538. if (!isMultiSelect) {
  14539. var range = selection.toOrientedRange();
  14540. editor.addSelectionMarker(range);
  14541. }
  14542. var oldRange = selection.rangeList.rangeAtPoint(pos);
  14543. editor.$blockScrolling++;
  14544. editor.inVirtualSelectionMode = true;
  14545. if (shift) {
  14546. oldRange = null;
  14547. range = selection.ranges[0];
  14548. editor.removeSelectionMarker(range);
  14549. }
  14550. editor.once("mouseup", function() {
  14551. var tmpSel = selection.toOrientedRange();
  14552. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  14553. selection.substractPoint(tmpSel.cursor);
  14554. else {
  14555. if (shift) {
  14556. selection.substractPoint(range.cursor);
  14557. } else if (range) {
  14558. editor.removeSelectionMarker(range);
  14559. selection.addRange(range);
  14560. }
  14561. selection.addRange(tmpSel);
  14562. }
  14563. editor.$blockScrolling--;
  14564. editor.inVirtualSelectionMode = false;
  14565. });
  14566. } else if (selectionMode == "block") {
  14567. e.stop();
  14568. editor.inVirtualSelectionMode = true;
  14569. var initialRange;
  14570. var rectSel = [];
  14571. var blockSelect = function() {
  14572. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14573. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
  14574. if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
  14575. return;
  14576. screenCursor = newCursor;
  14577. editor.$blockScrolling++;
  14578. editor.selection.moveToPosition(cursor);
  14579. editor.renderer.scrollCursorIntoView();
  14580. editor.removeSelectionMarkers(rectSel);
  14581. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  14582. if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
  14583. rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
  14584. rectSel.forEach(editor.addSelectionMarker, editor);
  14585. editor.updateSelectionMarkers();
  14586. editor.$blockScrolling--;
  14587. };
  14588. editor.$blockScrolling++;
  14589. if (isMultiSelect && !accel) {
  14590. selection.toSingleRange();
  14591. } else if (!isMultiSelect && accel) {
  14592. initialRange = selection.toOrientedRange();
  14593. editor.addSelectionMarker(initialRange);
  14594. }
  14595. if (shift)
  14596. screenAnchor = session.documentToScreenPosition(selection.lead);
  14597. else
  14598. selection.moveToPosition(pos);
  14599. editor.$blockScrolling--;
  14600. screenCursor = {row: -1, column: -1};
  14601. var onMouseSelectionEnd = function(e) {
  14602. clearInterval(timerId);
  14603. editor.removeSelectionMarkers(rectSel);
  14604. if (!rectSel.length)
  14605. rectSel = [selection.toOrientedRange()];
  14606. editor.$blockScrolling++;
  14607. if (initialRange) {
  14608. editor.removeSelectionMarker(initialRange);
  14609. selection.toSingleRange(initialRange);
  14610. }
  14611. for (var i = 0; i < rectSel.length; i++)
  14612. selection.addRange(rectSel[i]);
  14613. editor.inVirtualSelectionMode = false;
  14614. editor.$mouseHandler.$clickSelection = null;
  14615. editor.$blockScrolling--;
  14616. };
  14617. var onSelectionInterval = blockSelect;
  14618. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  14619. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  14620. return e.preventDefault();
  14621. }
  14622. }
  14623. exports.onMouseDown = onMouseDown;
  14624. });
  14625. ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
  14626. exports.defaultCommands = [{
  14627. name: "addCursorAbove",
  14628. exec: function(editor) { editor.selectMoreLines(-1); },
  14629. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  14630. scrollIntoView: "cursor",
  14631. readonly: true
  14632. }, {
  14633. name: "addCursorBelow",
  14634. exec: function(editor) { editor.selectMoreLines(1); },
  14635. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  14636. scrollIntoView: "cursor",
  14637. readonly: true
  14638. }, {
  14639. name: "addCursorAboveSkipCurrent",
  14640. exec: function(editor) { editor.selectMoreLines(-1, true); },
  14641. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  14642. scrollIntoView: "cursor",
  14643. readonly: true
  14644. }, {
  14645. name: "addCursorBelowSkipCurrent",
  14646. exec: function(editor) { editor.selectMoreLines(1, true); },
  14647. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  14648. scrollIntoView: "cursor",
  14649. readonly: true
  14650. }, {
  14651. name: "selectMoreBefore",
  14652. exec: function(editor) { editor.selectMore(-1); },
  14653. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  14654. scrollIntoView: "cursor",
  14655. readonly: true
  14656. }, {
  14657. name: "selectMoreAfter",
  14658. exec: function(editor) { editor.selectMore(1); },
  14659. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  14660. scrollIntoView: "cursor",
  14661. readonly: true
  14662. }, {
  14663. name: "selectNextBefore",
  14664. exec: function(editor) { editor.selectMore(-1, true); },
  14665. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  14666. scrollIntoView: "cursor",
  14667. readonly: true
  14668. }, {
  14669. name: "selectNextAfter",
  14670. exec: function(editor) { editor.selectMore(1, true); },
  14671. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  14672. scrollIntoView: "cursor",
  14673. readonly: true
  14674. }, {
  14675. name: "splitIntoLines",
  14676. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  14677. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  14678. readonly: true
  14679. }, {
  14680. name: "alignCursors",
  14681. exec: function(editor) { editor.alignCursors(); },
  14682. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  14683. scrollIntoView: "cursor"
  14684. }, {
  14685. name: "findAll",
  14686. exec: function(editor) { editor.findAll(); },
  14687. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  14688. scrollIntoView: "cursor",
  14689. readonly: true
  14690. }];
  14691. exports.multiSelectCommands = [{
  14692. name: "singleSelection",
  14693. bindKey: "esc",
  14694. exec: function(editor) { editor.exitMultiSelectMode(); },
  14695. scrollIntoView: "cursor",
  14696. readonly: true,
  14697. isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
  14698. }];
  14699. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  14700. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  14701. });
  14702. 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) {
  14703. var RangeList = require("./range_list").RangeList;
  14704. var Range = require("./range").Range;
  14705. var Selection = require("./selection").Selection;
  14706. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  14707. var event = require("./lib/event");
  14708. var lang = require("./lib/lang");
  14709. var commands = require("./commands/multi_select_commands");
  14710. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  14711. var Search = require("./search").Search;
  14712. var search = new Search();
  14713. function find(session, needle, dir) {
  14714. search.$options.wrap = true;
  14715. search.$options.needle = needle;
  14716. search.$options.backwards = dir == -1;
  14717. return search.find(session);
  14718. }
  14719. var EditSession = require("./edit_session").EditSession;
  14720. (function() {
  14721. this.getSelectionMarkers = function() {
  14722. return this.$selectionMarkers;
  14723. };
  14724. }).call(EditSession.prototype);
  14725. (function() {
  14726. this.ranges = null;
  14727. this.rangeList = null;
  14728. this.addRange = function(range, $blockChangeEvents) {
  14729. if (!range)
  14730. return;
  14731. if (!this.inMultiSelectMode && this.rangeCount === 0) {
  14732. var oldRange = this.toOrientedRange();
  14733. this.rangeList.add(oldRange);
  14734. this.rangeList.add(range);
  14735. if (this.rangeList.ranges.length != 2) {
  14736. this.rangeList.removeAll();
  14737. return $blockChangeEvents || this.fromOrientedRange(range);
  14738. }
  14739. this.rangeList.removeAll();
  14740. this.rangeList.add(oldRange);
  14741. this.$onAddRange(oldRange);
  14742. }
  14743. if (!range.cursor)
  14744. range.cursor = range.end;
  14745. var removed = this.rangeList.add(range);
  14746. this.$onAddRange(range);
  14747. if (removed.length)
  14748. this.$onRemoveRange(removed);
  14749. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  14750. this._signal("multiSelect");
  14751. this.inMultiSelectMode = true;
  14752. this.session.$undoSelect = false;
  14753. this.rangeList.attach(this.session);
  14754. }
  14755. return $blockChangeEvents || this.fromOrientedRange(range);
  14756. };
  14757. this.toSingleRange = function(range) {
  14758. range = range || this.ranges[0];
  14759. var removed = this.rangeList.removeAll();
  14760. if (removed.length)
  14761. this.$onRemoveRange(removed);
  14762. range && this.fromOrientedRange(range);
  14763. };
  14764. this.substractPoint = function(pos) {
  14765. var removed = this.rangeList.substractPoint(pos);
  14766. if (removed) {
  14767. this.$onRemoveRange(removed);
  14768. return removed[0];
  14769. }
  14770. };
  14771. this.mergeOverlappingRanges = function() {
  14772. var removed = this.rangeList.merge();
  14773. if (removed.length)
  14774. this.$onRemoveRange(removed);
  14775. else if(this.ranges[0])
  14776. this.fromOrientedRange(this.ranges[0]);
  14777. };
  14778. this.$onAddRange = function(range) {
  14779. this.rangeCount = this.rangeList.ranges.length;
  14780. this.ranges.unshift(range);
  14781. this._signal("addRange", {range: range});
  14782. };
  14783. this.$onRemoveRange = function(removed) {
  14784. this.rangeCount = this.rangeList.ranges.length;
  14785. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  14786. var lastRange = this.rangeList.ranges.pop();
  14787. removed.push(lastRange);
  14788. this.rangeCount = 0;
  14789. }
  14790. for (var i = removed.length; i--; ) {
  14791. var index = this.ranges.indexOf(removed[i]);
  14792. this.ranges.splice(index, 1);
  14793. }
  14794. this._signal("removeRange", {ranges: removed});
  14795. if (this.rangeCount === 0 && this.inMultiSelectMode) {
  14796. this.inMultiSelectMode = false;
  14797. this._signal("singleSelect");
  14798. this.session.$undoSelect = true;
  14799. this.rangeList.detach(this.session);
  14800. }
  14801. lastRange = lastRange || this.ranges[0];
  14802. if (lastRange && !lastRange.isEqual(this.getRange()))
  14803. this.fromOrientedRange(lastRange);
  14804. };
  14805. this.$initRangeList = function() {
  14806. if (this.rangeList)
  14807. return;
  14808. this.rangeList = new RangeList();
  14809. this.ranges = [];
  14810. this.rangeCount = 0;
  14811. };
  14812. this.getAllRanges = function() {
  14813. return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
  14814. };
  14815. this.splitIntoLines = function () {
  14816. if (this.rangeCount > 1) {
  14817. var ranges = this.rangeList.ranges;
  14818. var lastRange = ranges[ranges.length - 1];
  14819. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  14820. this.toSingleRange();
  14821. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  14822. } else {
  14823. var range = this.getRange();
  14824. var isBackwards = this.isBackwards();
  14825. var startRow = range.start.row;
  14826. var endRow = range.end.row;
  14827. if (startRow == endRow) {
  14828. if (isBackwards)
  14829. var start = range.end, end = range.start;
  14830. else
  14831. var start = range.start, end = range.end;
  14832. this.addRange(Range.fromPoints(end, end));
  14833. this.addRange(Range.fromPoints(start, start));
  14834. return;
  14835. }
  14836. var rectSel = [];
  14837. var r = this.getLineRange(startRow, true);
  14838. r.start.column = range.start.column;
  14839. rectSel.push(r);
  14840. for (var i = startRow + 1; i < endRow; i++)
  14841. rectSel.push(this.getLineRange(i, true));
  14842. r = this.getLineRange(endRow, true);
  14843. r.end.column = range.end.column;
  14844. rectSel.push(r);
  14845. rectSel.forEach(this.addRange, this);
  14846. }
  14847. };
  14848. this.toggleBlockSelection = function () {
  14849. if (this.rangeCount > 1) {
  14850. var ranges = this.rangeList.ranges;
  14851. var lastRange = ranges[ranges.length - 1];
  14852. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  14853. this.toSingleRange();
  14854. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  14855. } else {
  14856. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  14857. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  14858. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  14859. rectSel.forEach(this.addRange, this);
  14860. }
  14861. };
  14862. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  14863. var rectSel = [];
  14864. var xBackwards = screenCursor.column < screenAnchor.column;
  14865. if (xBackwards) {
  14866. var startColumn = screenCursor.column;
  14867. var endColumn = screenAnchor.column;
  14868. } else {
  14869. var startColumn = screenAnchor.column;
  14870. var endColumn = screenCursor.column;
  14871. }
  14872. var yBackwards = screenCursor.row < screenAnchor.row;
  14873. if (yBackwards) {
  14874. var startRow = screenCursor.row;
  14875. var endRow = screenAnchor.row;
  14876. } else {
  14877. var startRow = screenAnchor.row;
  14878. var endRow = screenCursor.row;
  14879. }
  14880. if (startColumn < 0)
  14881. startColumn = 0;
  14882. if (startRow < 0)
  14883. startRow = 0;
  14884. if (startRow == endRow)
  14885. includeEmptyLines = true;
  14886. for (var row = startRow; row <= endRow; row++) {
  14887. var range = Range.fromPoints(
  14888. this.session.screenToDocumentPosition(row, startColumn),
  14889. this.session.screenToDocumentPosition(row, endColumn)
  14890. );
  14891. if (range.isEmpty()) {
  14892. if (docEnd && isSamePoint(range.end, docEnd))
  14893. break;
  14894. var docEnd = range.end;
  14895. }
  14896. range.cursor = xBackwards ? range.start : range.end;
  14897. rectSel.push(range);
  14898. }
  14899. if (yBackwards)
  14900. rectSel.reverse();
  14901. if (!includeEmptyLines) {
  14902. var end = rectSel.length - 1;
  14903. while (rectSel[end].isEmpty() && end > 0)
  14904. end--;
  14905. if (end > 0) {
  14906. var start = 0;
  14907. while (rectSel[start].isEmpty())
  14908. start++;
  14909. }
  14910. for (var i = end; i >= start; i--) {
  14911. if (rectSel[i].isEmpty())
  14912. rectSel.splice(i, 1);
  14913. }
  14914. }
  14915. return rectSel;
  14916. };
  14917. }).call(Selection.prototype);
  14918. var Editor = require("./editor").Editor;
  14919. (function() {
  14920. this.updateSelectionMarkers = function() {
  14921. this.renderer.updateCursor();
  14922. this.renderer.updateBackMarkers();
  14923. };
  14924. this.addSelectionMarker = function(orientedRange) {
  14925. if (!orientedRange.cursor)
  14926. orientedRange.cursor = orientedRange.end;
  14927. var style = this.getSelectionStyle();
  14928. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  14929. this.session.$selectionMarkers.push(orientedRange);
  14930. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  14931. return orientedRange;
  14932. };
  14933. this.removeSelectionMarker = function(range) {
  14934. if (!range.marker)
  14935. return;
  14936. this.session.removeMarker(range.marker);
  14937. var index = this.session.$selectionMarkers.indexOf(range);
  14938. if (index != -1)
  14939. this.session.$selectionMarkers.splice(index, 1);
  14940. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  14941. };
  14942. this.removeSelectionMarkers = function(ranges) {
  14943. var markerList = this.session.$selectionMarkers;
  14944. for (var i = ranges.length; i--; ) {
  14945. var range = ranges[i];
  14946. if (!range.marker)
  14947. continue;
  14948. this.session.removeMarker(range.marker);
  14949. var index = markerList.indexOf(range);
  14950. if (index != -1)
  14951. markerList.splice(index, 1);
  14952. }
  14953. this.session.selectionMarkerCount = markerList.length;
  14954. };
  14955. this.$onAddRange = function(e) {
  14956. this.addSelectionMarker(e.range);
  14957. this.renderer.updateCursor();
  14958. this.renderer.updateBackMarkers();
  14959. };
  14960. this.$onRemoveRange = function(e) {
  14961. this.removeSelectionMarkers(e.ranges);
  14962. this.renderer.updateCursor();
  14963. this.renderer.updateBackMarkers();
  14964. };
  14965. this.$onMultiSelect = function(e) {
  14966. if (this.inMultiSelectMode)
  14967. return;
  14968. this.inMultiSelectMode = true;
  14969. this.setStyle("ace_multiselect");
  14970. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  14971. this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
  14972. this.renderer.updateCursor();
  14973. this.renderer.updateBackMarkers();
  14974. };
  14975. this.$onSingleSelect = function(e) {
  14976. if (this.session.multiSelect.inVirtualMode)
  14977. return;
  14978. this.inMultiSelectMode = false;
  14979. this.unsetStyle("ace_multiselect");
  14980. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  14981. this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
  14982. this.renderer.updateCursor();
  14983. this.renderer.updateBackMarkers();
  14984. this._emit("changeSelection");
  14985. };
  14986. this.$onMultiSelectExec = function(e) {
  14987. var command = e.command;
  14988. var editor = e.editor;
  14989. if (!editor.multiSelect)
  14990. return;
  14991. if (!command.multiSelectAction) {
  14992. var result = command.exec(editor, e.args || {});
  14993. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  14994. editor.multiSelect.mergeOverlappingRanges();
  14995. } else if (command.multiSelectAction == "forEach") {
  14996. result = editor.forEachSelection(command, e.args);
  14997. } else if (command.multiSelectAction == "forEachLine") {
  14998. result = editor.forEachSelection(command, e.args, true);
  14999. } else if (command.multiSelectAction == "single") {
  15000. editor.exitMultiSelectMode();
  15001. result = command.exec(editor, e.args || {});
  15002. } else {
  15003. result = command.multiSelectAction(editor, e.args || {});
  15004. }
  15005. return result;
  15006. };
  15007. this.forEachSelection = function(cmd, args, options) {
  15008. if (this.inVirtualSelectionMode)
  15009. return;
  15010. var keepOrder = options && options.keepOrder;
  15011. var $byLines = options == true || options && options.$byLines
  15012. var session = this.session;
  15013. var selection = this.selection;
  15014. var rangeList = selection.rangeList;
  15015. var ranges = (keepOrder ? selection : rangeList).ranges;
  15016. var result;
  15017. if (!ranges.length)
  15018. return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15019. var reg = selection._eventRegistry;
  15020. selection._eventRegistry = {};
  15021. var tmpSel = new Selection(session);
  15022. this.inVirtualSelectionMode = true;
  15023. for (var i = ranges.length; i--;) {
  15024. if ($byLines) {
  15025. while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
  15026. i--;
  15027. }
  15028. tmpSel.fromOrientedRange(ranges[i]);
  15029. tmpSel.index = i;
  15030. this.selection = session.selection = tmpSel;
  15031. var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15032. if (!result && cmdResult !== undefined)
  15033. result = cmdResult;
  15034. tmpSel.toOrientedRange(ranges[i]);
  15035. }
  15036. tmpSel.detach();
  15037. this.selection = session.selection = selection;
  15038. this.inVirtualSelectionMode = false;
  15039. selection._eventRegistry = reg;
  15040. selection.mergeOverlappingRanges();
  15041. var anim = this.renderer.$scrollAnimation;
  15042. this.onCursorChange();
  15043. this.onSelectionChange();
  15044. if (anim && anim.from == anim.to)
  15045. this.renderer.animateScrolling(anim.from);
  15046. return result;
  15047. };
  15048. this.exitMultiSelectMode = function() {
  15049. if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
  15050. return;
  15051. this.multiSelect.toSingleRange();
  15052. };
  15053. this.getSelectedText = function() {
  15054. var text = "";
  15055. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15056. var ranges = this.multiSelect.rangeList.ranges;
  15057. var buf = [];
  15058. for (var i = 0; i < ranges.length; i++) {
  15059. buf.push(this.session.getTextRange(ranges[i]));
  15060. }
  15061. var nl = this.session.getDocument().getNewLineCharacter();
  15062. text = buf.join(nl);
  15063. if (text.length == (buf.length - 1) * nl.length)
  15064. text = "";
  15065. } else if (!this.selection.isEmpty()) {
  15066. text = this.session.getTextRange(this.getSelectionRange());
  15067. }
  15068. return text;
  15069. };
  15070. this.$checkMultiselectChange = function(e, anchor) {
  15071. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15072. var range = this.multiSelect.ranges[0];
  15073. if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
  15074. return;
  15075. var pos = anchor == this.multiSelect.anchor
  15076. ? range.cursor == range.start ? range.end : range.start
  15077. : range.cursor;
  15078. if (pos.row != anchor.row
  15079. || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
  15080. this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
  15081. }
  15082. };
  15083. this.findAll = function(needle, options, additive) {
  15084. options = options || {};
  15085. options.needle = needle || options.needle;
  15086. if (options.needle == undefined) {
  15087. var range = this.selection.isEmpty()
  15088. ? this.selection.getWordRange()
  15089. : this.selection.getRange();
  15090. options.needle = this.session.getTextRange(range);
  15091. }
  15092. this.$search.set(options);
  15093. var ranges = this.$search.findAll(this.session);
  15094. if (!ranges.length)
  15095. return 0;
  15096. this.$blockScrolling += 1;
  15097. var selection = this.multiSelect;
  15098. if (!additive)
  15099. selection.toSingleRange(ranges[0]);
  15100. for (var i = ranges.length; i--; )
  15101. selection.addRange(ranges[i], true);
  15102. if (range && selection.rangeList.rangeAtPoint(range.start))
  15103. selection.addRange(range, true);
  15104. this.$blockScrolling -= 1;
  15105. return ranges.length;
  15106. };
  15107. this.selectMoreLines = function(dir, skip) {
  15108. var range = this.selection.toOrientedRange();
  15109. var isBackwards = range.cursor == range.end;
  15110. var screenLead = this.session.documentToScreenPosition(range.cursor);
  15111. if (this.selection.$desiredColumn)
  15112. screenLead.column = this.selection.$desiredColumn;
  15113. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  15114. if (!range.isEmpty()) {
  15115. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  15116. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  15117. } else {
  15118. var anchor = lead;
  15119. }
  15120. if (isBackwards) {
  15121. var newRange = Range.fromPoints(lead, anchor);
  15122. newRange.cursor = newRange.start;
  15123. } else {
  15124. var newRange = Range.fromPoints(anchor, lead);
  15125. newRange.cursor = newRange.end;
  15126. }
  15127. newRange.desiredColumn = screenLead.column;
  15128. if (!this.selection.inMultiSelectMode) {
  15129. this.selection.addRange(range);
  15130. } else {
  15131. if (skip)
  15132. var toRemove = range.cursor;
  15133. }
  15134. this.selection.addRange(newRange);
  15135. if (toRemove)
  15136. this.selection.substractPoint(toRemove);
  15137. };
  15138. this.transposeSelections = function(dir) {
  15139. var session = this.session;
  15140. var sel = session.multiSelect;
  15141. var all = sel.ranges;
  15142. for (var i = all.length; i--; ) {
  15143. var range = all[i];
  15144. if (range.isEmpty()) {
  15145. var tmp = session.getWordRange(range.start.row, range.start.column);
  15146. range.start.row = tmp.start.row;
  15147. range.start.column = tmp.start.column;
  15148. range.end.row = tmp.end.row;
  15149. range.end.column = tmp.end.column;
  15150. }
  15151. }
  15152. sel.mergeOverlappingRanges();
  15153. var words = [];
  15154. for (var i = all.length; i--; ) {
  15155. var range = all[i];
  15156. words.unshift(session.getTextRange(range));
  15157. }
  15158. if (dir < 0)
  15159. words.unshift(words.pop());
  15160. else
  15161. words.push(words.shift());
  15162. for (var i = all.length; i--; ) {
  15163. var range = all[i];
  15164. var tmp = range.clone();
  15165. session.replace(range, words[i]);
  15166. range.start.row = tmp.start.row;
  15167. range.start.column = tmp.start.column;
  15168. }
  15169. };
  15170. this.selectMore = function(dir, skip, stopAtFirst) {
  15171. var session = this.session;
  15172. var sel = session.multiSelect;
  15173. var range = sel.toOrientedRange();
  15174. if (range.isEmpty()) {
  15175. range = session.getWordRange(range.start.row, range.start.column);
  15176. range.cursor = dir == -1 ? range.start : range.end;
  15177. this.multiSelect.addRange(range);
  15178. if (stopAtFirst)
  15179. return;
  15180. }
  15181. var needle = session.getTextRange(range);
  15182. var newRange = find(session, needle, dir);
  15183. if (newRange) {
  15184. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  15185. this.$blockScrolling += 1;
  15186. this.session.unfold(newRange);
  15187. this.multiSelect.addRange(newRange);
  15188. this.$blockScrolling -= 1;
  15189. this.renderer.scrollCursorIntoView(null, 0.5);
  15190. }
  15191. if (skip)
  15192. this.multiSelect.substractPoint(range.cursor);
  15193. };
  15194. this.alignCursors = function() {
  15195. var session = this.session;
  15196. var sel = session.multiSelect;
  15197. var ranges = sel.ranges;
  15198. var row = -1;
  15199. var sameRowRanges = ranges.filter(function(r) {
  15200. if (r.cursor.row == row)
  15201. return true;
  15202. row = r.cursor.row;
  15203. });
  15204. if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
  15205. var range = this.selection.getRange();
  15206. var fr = range.start.row, lr = range.end.row;
  15207. var guessRange = fr == lr;
  15208. if (guessRange) {
  15209. var max = this.session.getLength();
  15210. var line;
  15211. do {
  15212. line = this.session.getLine(lr);
  15213. } while (/[=:]/.test(line) && ++lr < max);
  15214. do {
  15215. line = this.session.getLine(fr);
  15216. } while (/[=:]/.test(line) && --fr > 0);
  15217. if (fr < 0) fr = 0;
  15218. if (lr >= max) lr = max - 1;
  15219. }
  15220. var lines = this.session.doc.removeLines(fr, lr);
  15221. lines = this.$reAlignText(lines, guessRange);
  15222. this.session.doc.insert({row: fr, column: 0}, lines.join("\n") + "\n");
  15223. if (!guessRange) {
  15224. range.start.column = 0;
  15225. range.end.column = lines[lines.length - 1].length;
  15226. }
  15227. this.selection.setRange(range);
  15228. } else {
  15229. sameRowRanges.forEach(function(r) {
  15230. sel.substractPoint(r.cursor);
  15231. });
  15232. var maxCol = 0;
  15233. var minSpace = Infinity;
  15234. var spaceOffsets = ranges.map(function(r) {
  15235. var p = r.cursor;
  15236. var line = session.getLine(p.row);
  15237. var spaceOffset = line.substr(p.column).search(/\S/g);
  15238. if (spaceOffset == -1)
  15239. spaceOffset = 0;
  15240. if (p.column > maxCol)
  15241. maxCol = p.column;
  15242. if (spaceOffset < minSpace)
  15243. minSpace = spaceOffset;
  15244. return spaceOffset;
  15245. });
  15246. ranges.forEach(function(r, i) {
  15247. var p = r.cursor;
  15248. var l = maxCol - p.column;
  15249. var d = spaceOffsets[i] - minSpace;
  15250. if (l > d)
  15251. session.insert(p, lang.stringRepeat(" ", l - d));
  15252. else
  15253. session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
  15254. r.start.column = r.end.column = maxCol;
  15255. r.start.row = r.end.row = p.row;
  15256. r.cursor = r.end;
  15257. });
  15258. sel.fromOrientedRange(ranges[0]);
  15259. this.renderer.updateCursor();
  15260. this.renderer.updateBackMarkers();
  15261. }
  15262. };
  15263. this.$reAlignText = function(lines, forceLeft) {
  15264. var isLeftAligned = true, isRightAligned = true;
  15265. var startW, textW, endW;
  15266. return lines.map(function(line) {
  15267. var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
  15268. if (!m)
  15269. return [line];
  15270. if (startW == null) {
  15271. startW = m[1].length;
  15272. textW = m[2].length;
  15273. endW = m[3].length;
  15274. return m;
  15275. }
  15276. if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
  15277. isRightAligned = false;
  15278. if (startW != m[1].length)
  15279. isLeftAligned = false;
  15280. if (startW > m[1].length)
  15281. startW = m[1].length;
  15282. if (textW < m[2].length)
  15283. textW = m[2].length;
  15284. if (endW > m[3].length)
  15285. endW = m[3].length;
  15286. return m;
  15287. }).map(forceLeft ? alignLeft :
  15288. isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
  15289. function spaces(n) {
  15290. return lang.stringRepeat(" ", n);
  15291. }
  15292. function alignLeft(m) {
  15293. return !m[2] ? m[0] : spaces(startW) + m[2]
  15294. + spaces(textW - m[2].length + endW)
  15295. + m[4].replace(/^([=:])\s+/, "$1 ");
  15296. }
  15297. function alignRight(m) {
  15298. return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
  15299. + spaces(endW, " ")
  15300. + m[4].replace(/^([=:])\s+/, "$1 ");
  15301. }
  15302. function unAlign(m) {
  15303. return !m[2] ? m[0] : spaces(startW) + m[2]
  15304. + spaces(endW)
  15305. + m[4].replace(/^([=:])\s+/, "$1 ");
  15306. }
  15307. };
  15308. }).call(Editor.prototype);
  15309. function isSamePoint(p1, p2) {
  15310. return p1.row == p2.row && p1.column == p2.column;
  15311. }
  15312. exports.onSessionChange = function(e) {
  15313. var session = e.session;
  15314. if (session && !session.multiSelect) {
  15315. session.$selectionMarkers = [];
  15316. session.selection.$initRangeList();
  15317. session.multiSelect = session.selection;
  15318. }
  15319. this.multiSelect = session && session.multiSelect;
  15320. var oldSession = e.oldSession;
  15321. if (oldSession) {
  15322. oldSession.multiSelect.off("addRange", this.$onAddRange);
  15323. oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
  15324. oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
  15325. oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
  15326. oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
  15327. oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
  15328. }
  15329. if (session) {
  15330. session.multiSelect.on("addRange", this.$onAddRange);
  15331. session.multiSelect.on("removeRange", this.$onRemoveRange);
  15332. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  15333. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  15334. session.multiSelect.lead.on("change", this.$checkMultiselectChange);
  15335. session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
  15336. }
  15337. if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  15338. if (session.selection.inMultiSelectMode)
  15339. this.$onMultiSelect();
  15340. else
  15341. this.$onSingleSelect();
  15342. }
  15343. };
  15344. function MultiSelect(editor) {
  15345. if (editor.$multiselectOnSessionChange)
  15346. return;
  15347. editor.$onAddRange = editor.$onAddRange.bind(editor);
  15348. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  15349. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  15350. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  15351. editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
  15352. editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
  15353. editor.$multiselectOnSessionChange(editor);
  15354. editor.on("changeSession", editor.$multiselectOnSessionChange);
  15355. editor.on("mousedown", onMouseDown);
  15356. editor.commands.addCommands(commands.defaultCommands);
  15357. addAltCursorListeners(editor);
  15358. }
  15359. function addAltCursorListeners(editor){
  15360. var el = editor.textInput.getElement();
  15361. var altCursor = false;
  15362. event.addListener(el, "keydown", function(e) {
  15363. if (e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey)) {
  15364. if (!altCursor) {
  15365. editor.renderer.setMouseCursor("crosshair");
  15366. altCursor = true;
  15367. }
  15368. } else if (altCursor) {
  15369. reset();
  15370. }
  15371. });
  15372. event.addListener(el, "keyup", reset);
  15373. event.addListener(el, "blur", reset);
  15374. function reset(e) {
  15375. if (altCursor) {
  15376. editor.renderer.setMouseCursor("");
  15377. altCursor = false;
  15378. }
  15379. }
  15380. }
  15381. exports.MultiSelect = MultiSelect;
  15382. require("./config").defineOptions(Editor.prototype, "editor", {
  15383. enableMultiselect: {
  15384. set: function(val) {
  15385. MultiSelect(this);
  15386. if (val) {
  15387. this.on("changeSession", this.$multiselectOnSessionChange);
  15388. this.on("mousedown", onMouseDown);
  15389. } else {
  15390. this.off("changeSession", this.$multiselectOnSessionChange);
  15391. this.off("mousedown", onMouseDown);
  15392. }
  15393. },
  15394. value: true
  15395. }
  15396. });
  15397. });
  15398. ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
  15399. "use strict";
  15400. var Range = require("../../range").Range;
  15401. var FoldMode = exports.FoldMode = function() {};
  15402. (function() {
  15403. this.foldingStartMarker = null;
  15404. this.foldingStopMarker = null;
  15405. this.getFoldWidget = function(session, foldStyle, row) {
  15406. var line = session.getLine(row);
  15407. if (this.foldingStartMarker.test(line))
  15408. return "start";
  15409. if (foldStyle == "markbeginend"
  15410. && this.foldingStopMarker
  15411. && this.foldingStopMarker.test(line))
  15412. return "end";
  15413. return "";
  15414. };
  15415. this.getFoldWidgetRange = function(session, foldStyle, row) {
  15416. return null;
  15417. };
  15418. this.indentationBlock = function(session, row, column) {
  15419. var re = /\S/;
  15420. var line = session.getLine(row);
  15421. var startLevel = line.search(re);
  15422. if (startLevel == -1)
  15423. return;
  15424. var startColumn = column || line.length;
  15425. var maxRow = session.getLength();
  15426. var startRow = row;
  15427. var endRow = row;
  15428. while (++row < maxRow) {
  15429. var level = session.getLine(row).search(re);
  15430. if (level == -1)
  15431. continue;
  15432. if (level <= startLevel)
  15433. break;
  15434. endRow = row;
  15435. }
  15436. if (endRow > startRow) {
  15437. var endColumn = session.getLine(endRow).length;
  15438. return new Range(startRow, startColumn, endRow, endColumn);
  15439. }
  15440. };
  15441. this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
  15442. var start = {row: row, column: column + 1};
  15443. var end = session.$findClosingBracket(bracket, start, typeRe);
  15444. if (!end)
  15445. return;
  15446. var fw = session.foldWidgets[end.row];
  15447. if (fw == null)
  15448. fw = session.getFoldWidget(end.row);
  15449. if (fw == "start" && end.row > start.row) {
  15450. end.row --;
  15451. end.column = session.getLine(end.row).length;
  15452. }
  15453. return Range.fromPoints(start, end);
  15454. };
  15455. this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
  15456. var end = {row: row, column: column};
  15457. var start = session.$findOpeningBracket(bracket, end);
  15458. if (!start)
  15459. return;
  15460. start.column++;
  15461. end.column--;
  15462. return Range.fromPoints(start, end);
  15463. };
  15464. }).call(FoldMode.prototype);
  15465. });
  15466. ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  15467. "use strict";
  15468. exports.isDark = false;
  15469. exports.cssClass = "ace-tm";
  15470. exports.cssText = ".ace-tm .ace_gutter {\
  15471. background: #f0f0f0;\
  15472. color: #333;\
  15473. }\
  15474. .ace-tm .ace_print-margin {\
  15475. width: 1px;\
  15476. background: #e8e8e8;\
  15477. }\
  15478. .ace-tm .ace_fold {\
  15479. background-color: #6B72E6;\
  15480. }\
  15481. .ace-tm {\
  15482. background-color: #FFFFFF;\
  15483. color: black;\
  15484. }\
  15485. .ace-tm .ace_cursor {\
  15486. color: black;\
  15487. }\
  15488. .ace-tm .ace_invisible {\
  15489. color: rgb(191, 191, 191);\
  15490. }\
  15491. .ace-tm .ace_storage,\
  15492. .ace-tm .ace_keyword {\
  15493. color: blue;\
  15494. }\
  15495. .ace-tm .ace_constant {\
  15496. color: rgb(197, 6, 11);\
  15497. }\
  15498. .ace-tm .ace_constant.ace_buildin {\
  15499. color: rgb(88, 72, 246);\
  15500. }\
  15501. .ace-tm .ace_constant.ace_language {\
  15502. color: rgb(88, 92, 246);\
  15503. }\
  15504. .ace-tm .ace_constant.ace_library {\
  15505. color: rgb(6, 150, 14);\
  15506. }\
  15507. .ace-tm .ace_invalid {\
  15508. background-color: rgba(255, 0, 0, 0.1);\
  15509. color: red;\
  15510. }\
  15511. .ace-tm .ace_support.ace_function {\
  15512. color: rgb(60, 76, 114);\
  15513. }\
  15514. .ace-tm .ace_support.ace_constant {\
  15515. color: rgb(6, 150, 14);\
  15516. }\
  15517. .ace-tm .ace_support.ace_type,\
  15518. .ace-tm .ace_support.ace_class {\
  15519. color: rgb(109, 121, 222);\
  15520. }\
  15521. .ace-tm .ace_keyword.ace_operator {\
  15522. color: rgb(104, 118, 135);\
  15523. }\
  15524. .ace-tm .ace_string {\
  15525. color: rgb(3, 106, 7);\
  15526. }\
  15527. .ace-tm .ace_comment {\
  15528. color: rgb(76, 136, 107);\
  15529. }\
  15530. .ace-tm .ace_comment.ace_doc {\
  15531. color: rgb(0, 102, 255);\
  15532. }\
  15533. .ace-tm .ace_comment.ace_doc.ace_tag {\
  15534. color: rgb(128, 159, 191);\
  15535. }\
  15536. .ace-tm .ace_constant.ace_numeric {\
  15537. color: rgb(0, 0, 205);\
  15538. }\
  15539. .ace-tm .ace_variable {\
  15540. color: rgb(49, 132, 149);\
  15541. }\
  15542. .ace-tm .ace_xml-pe {\
  15543. color: rgb(104, 104, 91);\
  15544. }\
  15545. .ace-tm .ace_entity.ace_name.ace_function {\
  15546. color: #0000A2;\
  15547. }\
  15548. .ace-tm .ace_heading {\
  15549. color: rgb(12, 7, 255);\
  15550. }\
  15551. .ace-tm .ace_list {\
  15552. color:rgb(185, 6, 144);\
  15553. }\
  15554. .ace-tm .ace_meta.ace_tag {\
  15555. color:rgb(0, 22, 142);\
  15556. }\
  15557. .ace-tm .ace_string.ace_regex {\
  15558. color: rgb(255, 0, 0)\
  15559. }\
  15560. .ace-tm .ace_marker-layer .ace_selection {\
  15561. background: rgb(181, 213, 255);\
  15562. }\
  15563. .ace-tm.ace_multiselect .ace_selection.ace_start {\
  15564. box-shadow: 0 0 3px 0px white;\
  15565. border-radius: 2px;\
  15566. }\
  15567. .ace-tm .ace_marker-layer .ace_step {\
  15568. background: rgb(252, 255, 0);\
  15569. }\
  15570. .ace-tm .ace_marker-layer .ace_stack {\
  15571. background: rgb(164, 229, 101);\
  15572. }\
  15573. .ace-tm .ace_marker-layer .ace_bracket {\
  15574. margin: -1px 0 0 -1px;\
  15575. border: 1px solid rgb(192, 192, 192);\
  15576. }\
  15577. .ace-tm .ace_marker-layer .ace_active-line {\
  15578. background: rgba(0, 0, 0, 0.07);\
  15579. }\
  15580. .ace-tm .ace_gutter-active-line {\
  15581. background-color : #dcdcdc;\
  15582. }\
  15583. .ace-tm .ace_marker-layer .ace_selected-word {\
  15584. background: rgb(250, 250, 255);\
  15585. border: 1px solid rgb(200, 200, 250);\
  15586. }\
  15587. .ace-tm .ace_indent-guide {\
  15588. background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
  15589. }\
  15590. ";
  15591. var dom = require("../lib/dom");
  15592. dom.importCssString(exports.cssText, exports.cssClass);
  15593. });
  15594. ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
  15595. "use strict";
  15596. var oop = require("./lib/oop");
  15597. var dom = require("./lib/dom");
  15598. var Range = require("./range").Range;
  15599. function LineWidgets(session) {
  15600. this.session = session;
  15601. this.session.widgetManager = this;
  15602. this.session.getRowLength = this.getRowLength;
  15603. this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
  15604. this.updateOnChange = this.updateOnChange.bind(this);
  15605. this.renderWidgets = this.renderWidgets.bind(this);
  15606. this.measureWidgets = this.measureWidgets.bind(this);
  15607. this.session._changedWidgets = [];
  15608. this.$onChangeEditor = this.$onChangeEditor.bind(this);
  15609. this.session.on("change", this.updateOnChange);
  15610. this.session.on("changeEditor", this.$onChangeEditor);
  15611. }
  15612. (function() {
  15613. this.getRowLength = function(row) {
  15614. var h;
  15615. if (this.lineWidgets)
  15616. h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  15617. else
  15618. h = 0;
  15619. if (!this.$useWrapMode || !this.$wrapData[row]) {
  15620. return 1 + h;
  15621. } else {
  15622. return this.$wrapData[row].length + 1 + h;
  15623. }
  15624. };
  15625. this.$getWidgetScreenLength = function() {
  15626. var screenRows = 0;
  15627. this.lineWidgets.forEach(function(w){
  15628. if (w && w.rowCount)
  15629. screenRows +=w.rowCount;
  15630. });
  15631. return screenRows;
  15632. };
  15633. this.$onChangeEditor = function(e) {
  15634. this.attach(e.editor);
  15635. };
  15636. this.attach = function(editor) {
  15637. if (editor && editor.widgetManager && editor.widgetManager != this)
  15638. editor.widgetManager.detach();
  15639. if (this.editor == editor)
  15640. return;
  15641. this.detach();
  15642. this.editor = editor;
  15643. if (editor) {
  15644. editor.widgetManager = this;
  15645. editor.renderer.on("beforeRender", this.measureWidgets);
  15646. editor.renderer.on("afterRender", this.renderWidgets);
  15647. }
  15648. };
  15649. this.detach = function(e) {
  15650. var editor = this.editor;
  15651. if (!editor)
  15652. return;
  15653. this.editor = null;
  15654. editor.widgetManager = null;
  15655. editor.renderer.off("beforeRender", this.measureWidgets);
  15656. editor.renderer.off("afterRender", this.renderWidgets);
  15657. var lineWidgets = this.session.lineWidgets;
  15658. lineWidgets && lineWidgets.forEach(function(w) {
  15659. if (w && w.el && w.el.parentNode) {
  15660. w._inDocument = false;
  15661. w.el.parentNode.removeChild(w.el);
  15662. }
  15663. });
  15664. };
  15665. this.updateOnChange = function(e) {
  15666. var lineWidgets = this.session.lineWidgets;
  15667. if (!lineWidgets) return;
  15668. var delta = e.data;
  15669. var range = delta.range;
  15670. var startRow = range.start.row;
  15671. var len = range.end.row - startRow;
  15672. if (len === 0) {
  15673. } else if (delta.action == "removeText" || delta.action == "removeLines") {
  15674. var removed = lineWidgets.splice(startRow + 1, len);
  15675. removed.forEach(function(w) {
  15676. w && this.removeLineWidget(w);
  15677. }, this);
  15678. this.$updateRows();
  15679. } else {
  15680. var args = new Array(len);
  15681. args.unshift(startRow, 0);
  15682. lineWidgets.splice.apply(lineWidgets, args);
  15683. this.$updateRows();
  15684. }
  15685. };
  15686. this.$updateRows = function() {
  15687. var lineWidgets = this.session.lineWidgets;
  15688. if (!lineWidgets) return;
  15689. var noWidgets = true;
  15690. lineWidgets.forEach(function(w, i) {
  15691. if (w) {
  15692. noWidgets = false;
  15693. w.row = i;
  15694. }
  15695. });
  15696. if (noWidgets)
  15697. this.session.lineWidgets = null;
  15698. };
  15699. this.addLineWidget = function(w) {
  15700. if (!this.session.lineWidgets)
  15701. this.session.lineWidgets = new Array(this.session.getLength());
  15702. this.session.lineWidgets[w.row] = w;
  15703. var renderer = this.editor.renderer;
  15704. if (w.html && !w.el) {
  15705. w.el = dom.createElement("div");
  15706. w.el.innerHTML = w.html;
  15707. }
  15708. if (w.el) {
  15709. dom.addCssClass(w.el, "ace_lineWidgetContainer");
  15710. w.el.style.position = "absolute";
  15711. w.el.style.zIndex = 5;
  15712. renderer.container.appendChild(w.el);
  15713. w._inDocument = true;
  15714. }
  15715. if (!w.coverGutter) {
  15716. w.el.style.zIndex = 3;
  15717. }
  15718. if (!w.pixelHeight) {
  15719. w.pixelHeight = w.el.offsetHeight;
  15720. }
  15721. if (w.rowCount == null)
  15722. w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
  15723. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  15724. this.$updateRows();
  15725. this.renderWidgets(null, renderer);
  15726. return w;
  15727. };
  15728. this.removeLineWidget = function(w) {
  15729. w._inDocument = false;
  15730. if (w.el && w.el.parentNode)
  15731. w.el.parentNode.removeChild(w.el);
  15732. if (w.editor && w.editor.destroy) try {
  15733. w.editor.destroy();
  15734. } catch(e){}
  15735. if (this.session.lineWidgets)
  15736. this.session.lineWidgets[w.row] = undefined;
  15737. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  15738. this.$updateRows();
  15739. };
  15740. this.onWidgetChanged = function(w) {
  15741. this.session._changedWidgets.push(w);
  15742. this.editor && this.editor.renderer.updateFull();
  15743. };
  15744. this.measureWidgets = function(e, renderer) {
  15745. var changedWidgets = this.session._changedWidgets;
  15746. var config = renderer.layerConfig;
  15747. if (!changedWidgets || !changedWidgets.length) return;
  15748. var min = Infinity;
  15749. for (var i = 0; i < changedWidgets.length; i++) {
  15750. var w = changedWidgets[i];
  15751. if (!w._inDocument) {
  15752. w._inDocument = true;
  15753. renderer.container.appendChild(w.el);
  15754. }
  15755. w.h = w.el.offsetHeight;
  15756. if (!w.fixedWidth) {
  15757. w.w = w.el.offsetWidth;
  15758. w.screenWidth = Math.ceil(w.w / config.characterWidth);
  15759. }
  15760. var rowCount = w.h / config.lineHeight;
  15761. if (w.coverLine) {
  15762. rowCount -= this.session.getRowLineCount(w.row);
  15763. if (rowCount < 0)
  15764. rowCount = 0;
  15765. }
  15766. if (w.rowCount != rowCount) {
  15767. w.rowCount = rowCount;
  15768. if (w.row < min)
  15769. min = w.row;
  15770. }
  15771. }
  15772. if (min != Infinity) {
  15773. this.session._emit("changeFold", {data:{start:{row: min}}});
  15774. this.session.lineWidgetWidth = null;
  15775. }
  15776. this.session._changedWidgets = [];
  15777. };
  15778. this.renderWidgets = function(e, renderer) {
  15779. var config = renderer.layerConfig;
  15780. var lineWidgets = this.session.lineWidgets;
  15781. if (!lineWidgets)
  15782. return;
  15783. var first = Math.min(this.firstRow, config.firstRow);
  15784. var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
  15785. while (first > 0 && !lineWidgets[first])
  15786. first--;
  15787. this.firstRow = config.firstRow;
  15788. this.lastRow = config.lastRow;
  15789. renderer.$cursorLayer.config = config;
  15790. for (var i = first; i <= last; i++) {
  15791. var w = lineWidgets[i];
  15792. if (!w || !w.el) continue;
  15793. if (!w._inDocument) {
  15794. w._inDocument = true;
  15795. renderer.container.appendChild(w.el);
  15796. }
  15797. var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
  15798. if (!w.coverLine)
  15799. top += config.lineHeight * this.session.getRowLineCount(w.row);
  15800. w.el.style.top = top - config.offset + "px";
  15801. var left = w.coverGutter ? 0 : renderer.gutterWidth;
  15802. if (!w.fixedWidth)
  15803. left -= renderer.scrollLeft;
  15804. w.el.style.left = left + "px";
  15805. if (w.fixedWidth) {
  15806. w.el.style.right = renderer.scrollBar.getWidth() + "px";
  15807. } else {
  15808. w.el.style.right = "";
  15809. }
  15810. }
  15811. };
  15812. }).call(LineWidgets.prototype);
  15813. exports.LineWidgets = LineWidgets;
  15814. });
  15815. ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
  15816. "use strict";
  15817. var LineWidgets = require("../line_widgets").LineWidgets;
  15818. var dom = require("../lib/dom");
  15819. var Range = require("../range").Range;
  15820. function binarySearch(array, needle, comparator) {
  15821. var first = 0;
  15822. var last = array.length - 1;
  15823. while (first <= last) {
  15824. var mid = (first + last) >> 1;
  15825. var c = comparator(needle, array[mid]);
  15826. if (c > 0)
  15827. first = mid + 1;
  15828. else if (c < 0)
  15829. last = mid - 1;
  15830. else
  15831. return mid;
  15832. }
  15833. return -(first + 1);
  15834. }
  15835. function findAnnotations(session, row, dir) {
  15836. var annotations = session.getAnnotations().sort(Range.comparePoints);
  15837. if (!annotations.length)
  15838. return;
  15839. var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
  15840. if (i < 0)
  15841. i = -i - 1;
  15842. if (i >= annotations.length)
  15843. i = dir > 0 ? 0 : annotations.length - 1;
  15844. else if (i === 0 && dir < 0)
  15845. i = annotations.length - 1;
  15846. var annotation = annotations[i];
  15847. if (!annotation || !dir)
  15848. return;
  15849. if (annotation.row === row) {
  15850. do {
  15851. annotation = annotations[i += dir];
  15852. } while (annotation && annotation.row === row);
  15853. if (!annotation)
  15854. return annotations.slice();
  15855. }
  15856. var matched = [];
  15857. row = annotation.row;
  15858. do {
  15859. matched[dir < 0 ? "unshift" : "push"](annotation);
  15860. annotation = annotations[i += dir];
  15861. } while (annotation && annotation.row == row);
  15862. return matched.length && matched;
  15863. }
  15864. exports.showErrorMarker = function(editor, dir) {
  15865. var session = editor.session;
  15866. if (!session.widgetManager) {
  15867. session.widgetManager = new LineWidgets(session);
  15868. session.widgetManager.attach(editor);
  15869. }
  15870. var pos = editor.getCursorPosition();
  15871. var row = pos.row;
  15872. var oldWidget = session.lineWidgets && session.lineWidgets[row];
  15873. if (oldWidget) {
  15874. oldWidget.destroy();
  15875. } else {
  15876. row -= dir;
  15877. }
  15878. var annotations = findAnnotations(session, row, dir);
  15879. var gutterAnno;
  15880. if (annotations) {
  15881. var annotation = annotations[0];
  15882. pos.column = (annotation.pos && typeof annotation.column != "number"
  15883. ? annotation.pos.sc
  15884. : annotation.column) || 0;
  15885. pos.row = annotation.row;
  15886. gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
  15887. } else if (oldWidget) {
  15888. return;
  15889. } else {
  15890. gutterAnno = {
  15891. text: ["Looks good!"],
  15892. className: "ace_ok"
  15893. };
  15894. }
  15895. editor.session.unfold(pos.row);
  15896. editor.selection.moveToPosition(pos);
  15897. var w = {
  15898. row: pos.row,
  15899. fixedWidth: true,
  15900. coverGutter: true,
  15901. el: dom.createElement("div")
  15902. };
  15903. var el = w.el.appendChild(dom.createElement("div"));
  15904. var arrow = w.el.appendChild(dom.createElement("div"));
  15905. arrow.className = "error_widget_arrow " + gutterAnno.className;
  15906. var left = editor.renderer.$cursorLayer
  15907. .getPixelPosition(pos).left;
  15908. arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
  15909. w.el.className = "error_widget_wrapper";
  15910. el.className = "error_widget " + gutterAnno.className;
  15911. el.innerHTML = gutterAnno.text.join("<br>");
  15912. el.appendChild(dom.createElement("div"));
  15913. var kb = function(_, hashId, keyString) {
  15914. if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
  15915. w.destroy();
  15916. return {command: "null"};
  15917. }
  15918. };
  15919. w.destroy = function() {
  15920. if (editor.$mouseHandler.isMousePressed)
  15921. return;
  15922. editor.keyBinding.removeKeyboardHandler(kb);
  15923. session.widgetManager.removeLineWidget(w);
  15924. editor.off("changeSelection", w.destroy);
  15925. editor.off("changeSession", w.destroy);
  15926. editor.off("mouseup", w.destroy);
  15927. editor.off("change", w.destroy);
  15928. };
  15929. editor.keyBinding.addKeyboardHandler(kb);
  15930. editor.on("changeSelection", w.destroy);
  15931. editor.on("changeSession", w.destroy);
  15932. editor.on("mouseup", w.destroy);
  15933. editor.on("change", w.destroy);
  15934. editor.session.widgetManager.addLineWidget(w);
  15935. w.el.onmousedown = editor.focus.bind(editor);
  15936. editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
  15937. };
  15938. dom.importCssString("\
  15939. .error_widget_wrapper {\
  15940. background: inherit;\
  15941. color: inherit;\
  15942. border:none\
  15943. }\
  15944. .error_widget {\
  15945. border-top: solid 2px;\
  15946. border-bottom: solid 2px;\
  15947. margin: 5px 0;\
  15948. padding: 10px 40px;\
  15949. white-space: pre-wrap;\
  15950. }\
  15951. .error_widget.ace_error, .error_widget_arrow.ace_error{\
  15952. border-color: #ff5a5a\
  15953. }\
  15954. .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
  15955. border-color: #F1D817\
  15956. }\
  15957. .error_widget.ace_info, .error_widget_arrow.ace_info{\
  15958. border-color: #5a5a5a\
  15959. }\
  15960. .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
  15961. border-color: #5aaa5a\
  15962. }\
  15963. .error_widget_arrow {\
  15964. position: absolute;\
  15965. border: solid 5px;\
  15966. border-top-color: transparent!important;\
  15967. border-right-color: transparent!important;\
  15968. border-left-color: transparent!important;\
  15969. top: -5px;\
  15970. }\
  15971. ", "");
  15972. });
  15973. 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) {
  15974. "use strict";
  15975. require("./lib/fixoldbrowsers");
  15976. var dom = require("./lib/dom");
  15977. var event = require("./lib/event");
  15978. var Editor = require("./editor").Editor;
  15979. var EditSession = require("./edit_session").EditSession;
  15980. var UndoManager = require("./undomanager").UndoManager;
  15981. var Renderer = require("./virtual_renderer").VirtualRenderer;
  15982. require("./worker/worker_client");
  15983. require("./keyboard/hash_handler");
  15984. require("./placeholder");
  15985. require("./multi_select");
  15986. require("./mode/folding/fold_mode");
  15987. require("./theme/textmate");
  15988. require("./ext/error_marker");
  15989. exports.config = require("./config");
  15990. exports.require = require;
  15991. exports.edit = function(el) {
  15992. if (typeof(el) == "string") {
  15993. var _id = el;
  15994. el = document.getElementById(_id);
  15995. if (!el)
  15996. throw new Error("ace.edit can't find div #" + _id);
  15997. }
  15998. if (el && el.env && el.env.editor instanceof Editor)
  15999. return el.env.editor;
  16000. var value = "";
  16001. if (el && /input|textarea/i.test(el.tagName)) {
  16002. var oldNode = el;
  16003. value = oldNode.value;
  16004. el = dom.createElement("pre");
  16005. oldNode.parentNode.replaceChild(el, oldNode);
  16006. } else {
  16007. value = dom.getInnerText(el);
  16008. el.innerHTML = '';
  16009. }
  16010. var doc = exports.createEditSession(value);
  16011. var editor = new Editor(new Renderer(el));
  16012. editor.setSession(doc);
  16013. var env = {
  16014. document: doc,
  16015. editor: editor,
  16016. onResize: editor.resize.bind(editor, null)
  16017. };
  16018. if (oldNode) env.textarea = oldNode;
  16019. event.addListener(window, "resize", env.onResize);
  16020. editor.on("destroy", function() {
  16021. event.removeListener(window, "resize", env.onResize);
  16022. env.editor.container.env = null; // prevent memory leak on old ie
  16023. });
  16024. editor.container.env = editor.env = env;
  16025. return editor;
  16026. };
  16027. exports.createEditSession = function(text, mode) {
  16028. var doc = new EditSession(text, mode);
  16029. doc.setUndoManager(new UndoManager());
  16030. return doc;
  16031. }
  16032. exports.EditSession = EditSession;
  16033. exports.UndoManager = UndoManager;
  16034. });
  16035. (function() {
  16036. ace.require(["ace/ace"], function(a) {
  16037. a && a.config.init(true);
  16038. if (!window.ace)
  16039. window.ace = a;
  16040. for (var key in a) if (a.hasOwnProperty(key))
  16041. window.ace[key] = a[key];
  16042. });
  16043. })();