ace.js 630 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673
  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 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 (id)
  945. cssText += "\n/*# sourceURL=ace/css/" + id + " */";
  946. if (doc.createStyleSheet) {
  947. style = doc.createStyleSheet();
  948. style.cssText = cssText;
  949. if (id)
  950. style.owningElement.id = id;
  951. } else {
  952. style = exports.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. exports.scrollbarWidth = function(document) {
  984. var inner = exports.createElement("ace_inner");
  985. inner.style.width = "100%";
  986. inner.style.minWidth = "0px";
  987. inner.style.height = "200px";
  988. inner.style.display = "block";
  989. var outer = exports.createElement("ace_outer");
  990. var style = outer.style;
  991. style.position = "absolute";
  992. style.left = "-10000px";
  993. style.overflow = "hidden";
  994. style.width = "200px";
  995. style.minWidth = "0px";
  996. style.height = "150px";
  997. style.display = "block";
  998. outer.appendChild(inner);
  999. var body = document.documentElement;
  1000. body.appendChild(outer);
  1001. var noScrollbar = inner.offsetWidth;
  1002. style.overflow = "scroll";
  1003. var withScrollbar = inner.offsetWidth;
  1004. if (noScrollbar == withScrollbar) {
  1005. withScrollbar = outer.clientWidth;
  1006. }
  1007. body.removeChild(outer);
  1008. return noScrollbar-withScrollbar;
  1009. };
  1010. if (typeof document == "undefined") {
  1011. exports.importCssString = function() {};
  1012. return;
  1013. }
  1014. if (window.pageYOffset !== undefined) {
  1015. exports.getPageScrollTop = function() {
  1016. return window.pageYOffset;
  1017. };
  1018. exports.getPageScrollLeft = function() {
  1019. return window.pageXOffset;
  1020. };
  1021. }
  1022. else {
  1023. exports.getPageScrollTop = function() {
  1024. return document.body.scrollTop;
  1025. };
  1026. exports.getPageScrollLeft = function() {
  1027. return document.body.scrollLeft;
  1028. };
  1029. }
  1030. if (window.getComputedStyle)
  1031. exports.computedStyle = function(element, style) {
  1032. if (style)
  1033. return (window.getComputedStyle(element, "") || {})[style] || "";
  1034. return window.getComputedStyle(element, "") || {};
  1035. };
  1036. else
  1037. exports.computedStyle = function(element, style) {
  1038. if (style)
  1039. return element.currentStyle[style];
  1040. return element.currentStyle;
  1041. };
  1042. exports.setInnerHtml = function(el, innerHtml) {
  1043. var element = el.cloneNode(false);//document.createElement("div");
  1044. element.innerHTML = innerHtml;
  1045. el.parentNode.replaceChild(element, el);
  1046. return element;
  1047. };
  1048. if ("textContent" in document.documentElement) {
  1049. exports.setInnerText = function(el, innerText) {
  1050. el.textContent = innerText;
  1051. };
  1052. exports.getInnerText = function(el) {
  1053. return el.textContent;
  1054. };
  1055. }
  1056. else {
  1057. exports.setInnerText = function(el, innerText) {
  1058. el.innerText = innerText;
  1059. };
  1060. exports.getInnerText = function(el) {
  1061. return el.innerText;
  1062. };
  1063. }
  1064. exports.getParentWindow = function(document) {
  1065. return document.defaultView || document.parentWindow;
  1066. };
  1067. });
  1068. ace.define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
  1069. "use strict";
  1070. exports.inherits = function(ctor, superCtor) {
  1071. ctor.super_ = superCtor;
  1072. ctor.prototype = Object.create(superCtor.prototype, {
  1073. constructor: {
  1074. value: ctor,
  1075. enumerable: false,
  1076. writable: true,
  1077. configurable: true
  1078. }
  1079. });
  1080. };
  1081. exports.mixin = function(obj, mixin) {
  1082. for (var key in mixin) {
  1083. obj[key] = mixin[key];
  1084. }
  1085. return obj;
  1086. };
  1087. exports.implement = function(proto, mixin) {
  1088. exports.mixin(proto, mixin);
  1089. };
  1090. });
  1091. ace.define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(require, exports, module) {
  1092. "use strict";
  1093. require("./fixoldbrowsers");
  1094. var oop = require("./oop");
  1095. var Keys = (function() {
  1096. var ret = {
  1097. MODIFIER_KEYS: {
  1098. 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
  1099. },
  1100. KEY_MODS: {
  1101. "ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
  1102. "super": 8, "meta": 8, "command": 8, "cmd": 8
  1103. },
  1104. FUNCTION_KEYS : {
  1105. 8 : "Backspace",
  1106. 9 : "Tab",
  1107. 13 : "Return",
  1108. 19 : "Pause",
  1109. 27 : "Esc",
  1110. 32 : "Space",
  1111. 33 : "PageUp",
  1112. 34 : "PageDown",
  1113. 35 : "End",
  1114. 36 : "Home",
  1115. 37 : "Left",
  1116. 38 : "Up",
  1117. 39 : "Right",
  1118. 40 : "Down",
  1119. 44 : "Print",
  1120. 45 : "Insert",
  1121. 46 : "Delete",
  1122. 96 : "Numpad0",
  1123. 97 : "Numpad1",
  1124. 98 : "Numpad2",
  1125. 99 : "Numpad3",
  1126. 100: "Numpad4",
  1127. 101: "Numpad5",
  1128. 102: "Numpad6",
  1129. 103: "Numpad7",
  1130. 104: "Numpad8",
  1131. 105: "Numpad9",
  1132. '-13': "NumpadEnter",
  1133. 112: "F1",
  1134. 113: "F2",
  1135. 114: "F3",
  1136. 115: "F4",
  1137. 116: "F5",
  1138. 117: "F6",
  1139. 118: "F7",
  1140. 119: "F8",
  1141. 120: "F9",
  1142. 121: "F10",
  1143. 122: "F11",
  1144. 123: "F12",
  1145. 144: "Numlock",
  1146. 145: "Scrolllock"
  1147. },
  1148. PRINTABLE_KEYS: {
  1149. 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
  1150. 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
  1151. 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
  1152. 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
  1153. 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
  1154. 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
  1155. 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
  1156. 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*'
  1157. }
  1158. };
  1159. var name, i;
  1160. for (i in ret.FUNCTION_KEYS) {
  1161. name = ret.FUNCTION_KEYS[i].toLowerCase();
  1162. ret[name] = parseInt(i, 10);
  1163. }
  1164. for (i in ret.PRINTABLE_KEYS) {
  1165. name = ret.PRINTABLE_KEYS[i].toLowerCase();
  1166. ret[name] = parseInt(i, 10);
  1167. }
  1168. oop.mixin(ret, ret.MODIFIER_KEYS);
  1169. oop.mixin(ret, ret.PRINTABLE_KEYS);
  1170. oop.mixin(ret, ret.FUNCTION_KEYS);
  1171. ret.enter = ret["return"];
  1172. ret.escape = ret.esc;
  1173. ret.del = ret["delete"];
  1174. ret[173] = '-';
  1175. (function() {
  1176. var mods = ["cmd", "ctrl", "alt", "shift"];
  1177. for (var i = Math.pow(2, mods.length); i--;) {
  1178. ret.KEY_MODS[i] = mods.filter(function(x) {
  1179. return i & ret.KEY_MODS[x];
  1180. }).join("-") + "-";
  1181. }
  1182. })();
  1183. ret.KEY_MODS[0] = "";
  1184. ret.KEY_MODS[-1] = "input-";
  1185. return ret;
  1186. })();
  1187. oop.mixin(exports, Keys);
  1188. exports.keyCodeToString = function(keyCode) {
  1189. var keyString = Keys[keyCode];
  1190. if (typeof keyString != "string")
  1191. keyString = String.fromCharCode(keyCode);
  1192. return keyString.toLowerCase();
  1193. };
  1194. });
  1195. ace.define("ace/lib/useragent",["require","exports","module"], function(require, exports, module) {
  1196. "use strict";
  1197. exports.OS = {
  1198. LINUX: "LINUX",
  1199. MAC: "MAC",
  1200. WINDOWS: "WINDOWS"
  1201. };
  1202. exports.getOS = function() {
  1203. if (exports.isMac) {
  1204. return exports.OS.MAC;
  1205. } else if (exports.isLinux) {
  1206. return exports.OS.LINUX;
  1207. } else {
  1208. return exports.OS.WINDOWS;
  1209. }
  1210. };
  1211. if (typeof navigator != "object")
  1212. return;
  1213. var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
  1214. var ua = navigator.userAgent;
  1215. exports.isWin = (os == "win");
  1216. exports.isMac = (os == "mac");
  1217. exports.isLinux = (os == "linux");
  1218. exports.isIE =
  1219. (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
  1220. ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
  1221. : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
  1222. exports.isOldIE = exports.isIE && exports.isIE < 9;
  1223. exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
  1224. exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
  1225. exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
  1226. exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
  1227. exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
  1228. exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
  1229. exports.isIPad = ua.indexOf("iPad") >= 0;
  1230. exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
  1231. exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
  1232. });
  1233. ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  1234. "use strict";
  1235. var keys = require("./keys");
  1236. var useragent = require("./useragent");
  1237. var pressedKeys = null;
  1238. var ts = 0;
  1239. exports.addListener = function(elem, type, callback) {
  1240. if (elem.addEventListener) {
  1241. return elem.addEventListener(type, callback, false);
  1242. }
  1243. if (elem.attachEvent) {
  1244. var wrapper = function() {
  1245. callback.call(elem, window.event);
  1246. };
  1247. callback._wrapper = wrapper;
  1248. elem.attachEvent("on" + type, wrapper);
  1249. }
  1250. };
  1251. exports.removeListener = function(elem, type, callback) {
  1252. if (elem.removeEventListener) {
  1253. return elem.removeEventListener(type, callback, false);
  1254. }
  1255. if (elem.detachEvent) {
  1256. elem.detachEvent("on" + type, callback._wrapper || callback);
  1257. }
  1258. };
  1259. exports.stopEvent = function(e) {
  1260. exports.stopPropagation(e);
  1261. exports.preventDefault(e);
  1262. return false;
  1263. };
  1264. exports.stopPropagation = function(e) {
  1265. if (e.stopPropagation)
  1266. e.stopPropagation();
  1267. else
  1268. e.cancelBubble = true;
  1269. };
  1270. exports.preventDefault = function(e) {
  1271. if (e.preventDefault)
  1272. e.preventDefault();
  1273. else
  1274. e.returnValue = false;
  1275. };
  1276. exports.getButton = function(e) {
  1277. if (e.type == "dblclick")
  1278. return 0;
  1279. if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
  1280. return 2;
  1281. if (e.preventDefault) {
  1282. return e.button;
  1283. }
  1284. else {
  1285. return {1:0, 2:2, 4:1}[e.button];
  1286. }
  1287. };
  1288. exports.capture = function(el, eventHandler, releaseCaptureHandler) {
  1289. function onMouseUp(e) {
  1290. eventHandler && eventHandler(e);
  1291. releaseCaptureHandler && releaseCaptureHandler(e);
  1292. exports.removeListener(document, "mousemove", eventHandler, true);
  1293. exports.removeListener(document, "mouseup", onMouseUp, true);
  1294. exports.removeListener(document, "dragstart", onMouseUp, true);
  1295. }
  1296. exports.addListener(document, "mousemove", eventHandler, true);
  1297. exports.addListener(document, "mouseup", onMouseUp, true);
  1298. exports.addListener(document, "dragstart", onMouseUp, true);
  1299. return onMouseUp;
  1300. };
  1301. exports.addTouchMoveListener = function (el, callback) {
  1302. if ("ontouchmove" in el) {
  1303. var startx, starty;
  1304. exports.addListener(el, "touchstart", function (e) {
  1305. var touchObj = e.changedTouches[0];
  1306. startx = touchObj.clientX;
  1307. starty = touchObj.clientY;
  1308. });
  1309. exports.addListener(el, "touchmove", function (e) {
  1310. var factor = 1,
  1311. touchObj = e.changedTouches[0];
  1312. e.wheelX = -(touchObj.clientX - startx) / factor;
  1313. e.wheelY = -(touchObj.clientY - starty) / factor;
  1314. startx = touchObj.clientX;
  1315. starty = touchObj.clientY;
  1316. callback(e);
  1317. });
  1318. }
  1319. };
  1320. exports.addMouseWheelListener = function(el, callback) {
  1321. if ("onmousewheel" in el) {
  1322. exports.addListener(el, "mousewheel", function(e) {
  1323. var factor = 8;
  1324. if (e.wheelDeltaX !== undefined) {
  1325. e.wheelX = -e.wheelDeltaX / factor;
  1326. e.wheelY = -e.wheelDeltaY / factor;
  1327. } else {
  1328. e.wheelX = 0;
  1329. e.wheelY = -e.wheelDelta / factor;
  1330. }
  1331. callback(e);
  1332. });
  1333. } else if ("onwheel" in el) {
  1334. exports.addListener(el, "wheel", function(e) {
  1335. var factor = 0.35;
  1336. switch (e.deltaMode) {
  1337. case e.DOM_DELTA_PIXEL:
  1338. e.wheelX = e.deltaX * factor || 0;
  1339. e.wheelY = e.deltaY * factor || 0;
  1340. break;
  1341. case e.DOM_DELTA_LINE:
  1342. case e.DOM_DELTA_PAGE:
  1343. e.wheelX = (e.deltaX || 0) * 5;
  1344. e.wheelY = (e.deltaY || 0) * 5;
  1345. break;
  1346. }
  1347. callback(e);
  1348. });
  1349. } else {
  1350. exports.addListener(el, "DOMMouseScroll", function(e) {
  1351. if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
  1352. e.wheelX = (e.detail || 0) * 5;
  1353. e.wheelY = 0;
  1354. } else {
  1355. e.wheelX = 0;
  1356. e.wheelY = (e.detail || 0) * 5;
  1357. }
  1358. callback(e);
  1359. });
  1360. }
  1361. };
  1362. exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName) {
  1363. var clicks = 0;
  1364. var startX, startY, timer;
  1365. var eventNames = {
  1366. 2: "dblclick",
  1367. 3: "tripleclick",
  1368. 4: "quadclick"
  1369. };
  1370. function onMousedown(e) {
  1371. if (exports.getButton(e) !== 0) {
  1372. clicks = 0;
  1373. } else if (e.detail > 1) {
  1374. clicks++;
  1375. if (clicks > 4)
  1376. clicks = 1;
  1377. } else {
  1378. clicks = 1;
  1379. }
  1380. if (useragent.isIE) {
  1381. var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
  1382. if (!timer || isNewClick)
  1383. clicks = 1;
  1384. if (timer)
  1385. clearTimeout(timer);
  1386. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1387. if (clicks == 1) {
  1388. startX = e.clientX;
  1389. startY = e.clientY;
  1390. }
  1391. }
  1392. e._clicks = clicks;
  1393. eventHandler[callbackName]("mousedown", e);
  1394. if (clicks > 4)
  1395. clicks = 0;
  1396. else if (clicks > 1)
  1397. return eventHandler[callbackName](eventNames[clicks], e);
  1398. }
  1399. function onDblclick(e) {
  1400. clicks = 2;
  1401. if (timer)
  1402. clearTimeout(timer);
  1403. timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
  1404. eventHandler[callbackName]("mousedown", e);
  1405. eventHandler[callbackName](eventNames[clicks], e);
  1406. }
  1407. if (!Array.isArray(elements))
  1408. elements = [elements];
  1409. elements.forEach(function(el) {
  1410. exports.addListener(el, "mousedown", onMousedown);
  1411. if (useragent.isOldIE)
  1412. exports.addListener(el, "dblclick", onDblclick);
  1413. });
  1414. };
  1415. var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window)
  1416. ? function(e) {
  1417. return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
  1418. }
  1419. : function(e) {
  1420. return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
  1421. };
  1422. exports.getModifierString = function(e) {
  1423. return keys.KEY_MODS[getModifierHash(e)];
  1424. };
  1425. function normalizeCommandKeys(callback, e, keyCode) {
  1426. var hashId = getModifierHash(e);
  1427. if (!useragent.isMac && pressedKeys) {
  1428. if (pressedKeys.OSKey)
  1429. hashId |= 8;
  1430. if (pressedKeys.altGr) {
  1431. if ((3 & hashId) != 3)
  1432. pressedKeys.altGr = 0;
  1433. else
  1434. return;
  1435. }
  1436. if (keyCode === 18 || keyCode === 17) {
  1437. var location = "location" in e ? e.location : e.keyLocation;
  1438. if (keyCode === 17 && location === 1) {
  1439. if (pressedKeys[keyCode] == 1)
  1440. ts = e.timeStamp;
  1441. } else if (keyCode === 18 && hashId === 3 && location === 2) {
  1442. var dt = e.timeStamp - ts;
  1443. if (dt < 50)
  1444. pressedKeys.altGr = true;
  1445. }
  1446. }
  1447. }
  1448. if (keyCode in keys.MODIFIER_KEYS) {
  1449. keyCode = -1;
  1450. }
  1451. if (hashId & 8 && (keyCode >= 91 && keyCode <= 93)) {
  1452. keyCode = -1;
  1453. }
  1454. if (!hashId && keyCode === 13) {
  1455. var location = "location" in e ? e.location : e.keyLocation;
  1456. if (location === 3) {
  1457. callback(e, hashId, -keyCode);
  1458. if (e.defaultPrevented)
  1459. return;
  1460. }
  1461. }
  1462. if (useragent.isChromeOS && hashId & 8) {
  1463. callback(e, hashId, keyCode);
  1464. if (e.defaultPrevented)
  1465. return;
  1466. else
  1467. hashId &= ~8;
  1468. }
  1469. if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
  1470. return false;
  1471. }
  1472. return callback(e, hashId, keyCode);
  1473. }
  1474. exports.addCommandKeyListener = function(el, callback) {
  1475. var addListener = exports.addListener;
  1476. if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
  1477. var lastKeyDownKeyCode = null;
  1478. addListener(el, "keydown", function(e) {
  1479. lastKeyDownKeyCode = e.keyCode;
  1480. });
  1481. addListener(el, "keypress", function(e) {
  1482. return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
  1483. });
  1484. } else {
  1485. var lastDefaultPrevented = null;
  1486. addListener(el, "keydown", function(e) {
  1487. var keyCode = e.keyCode;
  1488. pressedKeys[keyCode] = (pressedKeys[keyCode] || 0) + 1;
  1489. if (keyCode == 91 || keyCode == 92) {
  1490. pressedKeys.OSKey = true;
  1491. } else if (pressedKeys.OSKey) {
  1492. if (e.timeStamp - pressedKeys.lastT > 200 && pressedKeys.count == 1)
  1493. resetPressedKeys();
  1494. }
  1495. if (pressedKeys[keyCode] == 1)
  1496. pressedKeys.count++;
  1497. pressedKeys.lastT = e.timeStamp;
  1498. var result = normalizeCommandKeys(callback, e, keyCode);
  1499. lastDefaultPrevented = e.defaultPrevented;
  1500. return result;
  1501. });
  1502. addListener(el, "keypress", function(e) {
  1503. if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  1504. exports.stopEvent(e);
  1505. lastDefaultPrevented = null;
  1506. }
  1507. });
  1508. addListener(el, "keyup", function(e) {
  1509. var keyCode = e.keyCode;
  1510. if (!pressedKeys[keyCode]) {
  1511. resetPressedKeys();
  1512. } else {
  1513. pressedKeys.count = Math.max(pressedKeys.count - 1, 0);
  1514. }
  1515. if (keyCode == 91 || keyCode == 92) {
  1516. pressedKeys.OSKey = false;
  1517. }
  1518. pressedKeys[keyCode] = null;
  1519. });
  1520. if (!pressedKeys) {
  1521. resetPressedKeys();
  1522. addListener(window, "focus", resetPressedKeys);
  1523. }
  1524. }
  1525. };
  1526. function resetPressedKeys() {
  1527. pressedKeys = Object.create(null);
  1528. pressedKeys.count = 0;
  1529. pressedKeys.lastT = 0;
  1530. }
  1531. if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
  1532. var postMessageId = 1;
  1533. exports.nextTick = function(callback, win) {
  1534. win = win || window;
  1535. var messageName = "zero-timeout-message-" + postMessageId;
  1536. exports.addListener(win, "message", function listener(e) {
  1537. if (e.data == messageName) {
  1538. exports.stopPropagation(e);
  1539. exports.removeListener(win, "message", listener);
  1540. callback();
  1541. }
  1542. });
  1543. win.postMessage(messageName, "*");
  1544. };
  1545. }
  1546. exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
  1547. || window.mozRequestAnimationFrame
  1548. || window.webkitRequestAnimationFrame
  1549. || window.msRequestAnimationFrame
  1550. || window.oRequestAnimationFrame);
  1551. if (exports.nextFrame)
  1552. exports.nextFrame = exports.nextFrame.bind(window);
  1553. else
  1554. exports.nextFrame = function(callback) {
  1555. setTimeout(callback, 17);
  1556. };
  1557. });
  1558. ace.define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1559. "use strict";
  1560. exports.last = function(a) {
  1561. return a[a.length - 1];
  1562. };
  1563. exports.stringReverse = function(string) {
  1564. return string.split("").reverse().join("");
  1565. };
  1566. exports.stringRepeat = function (string, count) {
  1567. var result = '';
  1568. while (count > 0) {
  1569. if (count & 1)
  1570. result += string;
  1571. if (count >>= 1)
  1572. string += string;
  1573. }
  1574. return result;
  1575. };
  1576. var trimBeginRegexp = /^\s\s*/;
  1577. var trimEndRegexp = /\s\s*$/;
  1578. exports.stringTrimLeft = function (string) {
  1579. return string.replace(trimBeginRegexp, '');
  1580. };
  1581. exports.stringTrimRight = function (string) {
  1582. return string.replace(trimEndRegexp, '');
  1583. };
  1584. exports.copyObject = function(obj) {
  1585. var copy = {};
  1586. for (var key in obj) {
  1587. copy[key] = obj[key];
  1588. }
  1589. return copy;
  1590. };
  1591. exports.copyArray = function(array){
  1592. var copy = [];
  1593. for (var i=0, l=array.length; i<l; i++) {
  1594. if (array[i] && typeof array[i] == "object")
  1595. copy[i] = this.copyObject( array[i] );
  1596. else
  1597. copy[i] = array[i];
  1598. }
  1599. return copy;
  1600. };
  1601. exports.deepCopy = function deepCopy(obj) {
  1602. if (typeof obj !== "object" || !obj)
  1603. return obj;
  1604. var copy;
  1605. if (Array.isArray(obj)) {
  1606. copy = [];
  1607. for (var key = 0; key < obj.length; key++) {
  1608. copy[key] = deepCopy(obj[key]);
  1609. }
  1610. return copy;
  1611. }
  1612. var cons = obj.constructor;
  1613. if (cons === RegExp)
  1614. return obj;
  1615. copy = cons();
  1616. for (var key in obj) {
  1617. copy[key] = deepCopy(obj[key]);
  1618. }
  1619. return copy;
  1620. };
  1621. exports.arrayToMap = function(arr) {
  1622. var map = {};
  1623. for (var i=0; i<arr.length; i++) {
  1624. map[arr[i]] = 1;
  1625. }
  1626. return map;
  1627. };
  1628. exports.createMap = function(props) {
  1629. var map = Object.create(null);
  1630. for (var i in props) {
  1631. map[i] = props[i];
  1632. }
  1633. return map;
  1634. };
  1635. exports.arrayRemove = function(array, value) {
  1636. for (var i = 0; i <= array.length; i++) {
  1637. if (value === array[i]) {
  1638. array.splice(i, 1);
  1639. }
  1640. }
  1641. };
  1642. exports.escapeRegExp = function(str) {
  1643. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1644. };
  1645. exports.escapeHTML = function(str) {
  1646. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1647. };
  1648. exports.getMatchOffsets = function(string, regExp) {
  1649. var matches = [];
  1650. string.replace(regExp, function(str) {
  1651. matches.push({
  1652. offset: arguments[arguments.length-2],
  1653. length: str.length
  1654. });
  1655. });
  1656. return matches;
  1657. };
  1658. exports.deferredCall = function(fcn) {
  1659. var timer = null;
  1660. var callback = function() {
  1661. timer = null;
  1662. fcn();
  1663. };
  1664. var deferred = function(timeout) {
  1665. deferred.cancel();
  1666. timer = setTimeout(callback, timeout || 0);
  1667. return deferred;
  1668. };
  1669. deferred.schedule = deferred;
  1670. deferred.call = function() {
  1671. this.cancel();
  1672. fcn();
  1673. return deferred;
  1674. };
  1675. deferred.cancel = function() {
  1676. clearTimeout(timer);
  1677. timer = null;
  1678. return deferred;
  1679. };
  1680. deferred.isPending = function() {
  1681. return timer;
  1682. };
  1683. return deferred;
  1684. };
  1685. exports.delayedCall = function(fcn, defaultTimeout) {
  1686. var timer = null;
  1687. var callback = function() {
  1688. timer = null;
  1689. fcn();
  1690. };
  1691. var _self = function(timeout) {
  1692. if (timer == null)
  1693. timer = setTimeout(callback, timeout || defaultTimeout);
  1694. };
  1695. _self.delay = function(timeout) {
  1696. timer && clearTimeout(timer);
  1697. timer = setTimeout(callback, timeout || defaultTimeout);
  1698. };
  1699. _self.schedule = _self;
  1700. _self.call = function() {
  1701. this.cancel();
  1702. fcn();
  1703. };
  1704. _self.cancel = function() {
  1705. timer && clearTimeout(timer);
  1706. timer = null;
  1707. };
  1708. _self.isPending = function() {
  1709. return timer;
  1710. };
  1711. return _self;
  1712. };
  1713. });
  1714. ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
  1715. "use strict";
  1716. var event = require("../lib/event");
  1717. var useragent = require("../lib/useragent");
  1718. var dom = require("../lib/dom");
  1719. var lang = require("../lib/lang");
  1720. var BROKEN_SETDATA = useragent.isChrome < 18;
  1721. var USE_IE_MIME_TYPE = useragent.isIE;
  1722. var TextInput = function(parentNode, host) {
  1723. var text = dom.createElement("textarea");
  1724. text.className = "ace_text-input";
  1725. if (useragent.isTouchPad)
  1726. text.setAttribute("x-palm-disable-auto-cap", true);
  1727. text.setAttribute("wrap", "off");
  1728. text.setAttribute("autocorrect", "off");
  1729. text.setAttribute("autocapitalize", "off");
  1730. text.setAttribute("spellcheck", false);
  1731. text.style.opacity = "0";
  1732. if (useragent.isOldIE) text.style.top = "-1000px";
  1733. parentNode.insertBefore(text, parentNode.firstChild);
  1734. var PLACEHOLDER = "\x01\x01";
  1735. var copied = false;
  1736. var pasted = false;
  1737. var inComposition = false;
  1738. var tempStyle = '';
  1739. var isSelectionEmpty = true;
  1740. try { var isFocused = document.activeElement === text; } catch(e) {}
  1741. event.addListener(text, "blur", function(e) {
  1742. host.onBlur(e);
  1743. isFocused = false;
  1744. });
  1745. event.addListener(text, "focus", function(e) {
  1746. isFocused = true;
  1747. host.onFocus(e);
  1748. resetSelection();
  1749. });
  1750. this.focus = function() {
  1751. if (tempStyle) return text.focus();
  1752. var top = text.style.top;
  1753. text.style.position = "fixed";
  1754. text.style.top = "0px";
  1755. text.focus();
  1756. setTimeout(function() {
  1757. text.style.position = "";
  1758. if (text.style.top == "0px")
  1759. text.style.top = top;
  1760. }, 0);
  1761. };
  1762. this.blur = function() {
  1763. text.blur();
  1764. };
  1765. this.isFocused = function() {
  1766. return isFocused;
  1767. };
  1768. var syncSelection = lang.delayedCall(function() {
  1769. isFocused && resetSelection(isSelectionEmpty);
  1770. });
  1771. var syncValue = lang.delayedCall(function() {
  1772. if (!inComposition) {
  1773. text.value = PLACEHOLDER;
  1774. isFocused && resetSelection();
  1775. }
  1776. });
  1777. function resetSelection(isEmpty) {
  1778. if (inComposition)
  1779. return;
  1780. inComposition = true;
  1781. if (inputHandler) {
  1782. selectionStart = 0;
  1783. selectionEnd = isEmpty ? 0 : text.value.length - 1;
  1784. } else {
  1785. var selectionStart = isEmpty ? 2 : 1;
  1786. var selectionEnd = 2;
  1787. }
  1788. try {
  1789. text.setSelectionRange(selectionStart, selectionEnd);
  1790. } catch(e){}
  1791. inComposition = false;
  1792. }
  1793. function resetValue() {
  1794. if (inComposition)
  1795. return;
  1796. text.value = PLACEHOLDER;
  1797. if (useragent.isWebKit)
  1798. syncValue.schedule();
  1799. }
  1800. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  1801. if (host.selection.isEmpty() != isSelectionEmpty) {
  1802. isSelectionEmpty = !isSelectionEmpty;
  1803. syncSelection.schedule();
  1804. }
  1805. });
  1806. resetValue();
  1807. if (isFocused)
  1808. host.onFocus();
  1809. var isAllSelected = function(text) {
  1810. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  1811. };
  1812. if (!text.setSelectionRange && text.createTextRange) {
  1813. text.setSelectionRange = function(selectionStart, selectionEnd) {
  1814. var range = this.createTextRange();
  1815. range.collapse(true);
  1816. range.moveStart('character', selectionStart);
  1817. range.moveEnd('character', selectionEnd);
  1818. range.select();
  1819. };
  1820. isAllSelected = function(text) {
  1821. try {
  1822. var range = text.ownerDocument.selection.createRange();
  1823. }catch(e) {}
  1824. if (!range || range.parentElement() != text) return false;
  1825. return range.text == text.value;
  1826. }
  1827. }
  1828. if (useragent.isOldIE) {
  1829. var inPropertyChange = false;
  1830. var onPropertyChange = function(e){
  1831. if (inPropertyChange)
  1832. return;
  1833. var data = text.value;
  1834. if (inComposition || !data || data == PLACEHOLDER)
  1835. return;
  1836. if (e && data == PLACEHOLDER[0])
  1837. return syncProperty.schedule();
  1838. sendText(data);
  1839. inPropertyChange = true;
  1840. resetValue();
  1841. inPropertyChange = false;
  1842. };
  1843. var syncProperty = lang.delayedCall(onPropertyChange);
  1844. event.addListener(text, "propertychange", onPropertyChange);
  1845. var keytable = { 13:1, 27:1 };
  1846. event.addListener(text, "keyup", function (e) {
  1847. if (inComposition && (!text.value || keytable[e.keyCode]))
  1848. setTimeout(onCompositionEnd, 0);
  1849. if ((text.value.charCodeAt(0)||0) < 129) {
  1850. return syncProperty.call();
  1851. }
  1852. inComposition ? onCompositionUpdate() : onCompositionStart();
  1853. });
  1854. event.addListener(text, "keydown", function (e) {
  1855. syncProperty.schedule(50);
  1856. });
  1857. }
  1858. var onSelect = function(e) {
  1859. if (copied) {
  1860. copied = false;
  1861. } else if (isAllSelected(text)) {
  1862. host.selectAll();
  1863. resetSelection();
  1864. } else if (inputHandler) {
  1865. resetSelection(host.selection.isEmpty());
  1866. }
  1867. };
  1868. var inputHandler = null;
  1869. this.setInputHandler = function(cb) {inputHandler = cb};
  1870. this.getInputHandler = function() {return inputHandler};
  1871. var afterContextMenu = false;
  1872. var sendText = function(data) {
  1873. if (inputHandler) {
  1874. data = inputHandler(data);
  1875. inputHandler = null;
  1876. }
  1877. if (pasted) {
  1878. resetSelection();
  1879. if (data)
  1880. host.onPaste(data);
  1881. pasted = false;
  1882. } else if (data == PLACEHOLDER.charAt(0)) {
  1883. if (afterContextMenu)
  1884. host.execCommand("del", {source: "ace"});
  1885. else // some versions of android do not fire keydown when pressing backspace
  1886. host.execCommand("backspace", {source: "ace"});
  1887. } else {
  1888. if (data.substring(0, 2) == PLACEHOLDER)
  1889. data = data.substr(2);
  1890. else if (data.charAt(0) == PLACEHOLDER.charAt(0))
  1891. data = data.substr(1);
  1892. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1893. data = data.slice(0, -1);
  1894. if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1895. data = data.slice(0, -1);
  1896. if (data)
  1897. host.onTextInput(data);
  1898. }
  1899. if (afterContextMenu)
  1900. afterContextMenu = false;
  1901. };
  1902. var onInput = function(e) {
  1903. if (inComposition)
  1904. return;
  1905. var data = text.value;
  1906. sendText(data);
  1907. resetValue();
  1908. };
  1909. var handleClipboardData = function(e, data) {
  1910. var clipboardData = e.clipboardData || window.clipboardData;
  1911. if (!clipboardData || BROKEN_SETDATA)
  1912. return;
  1913. var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
  1914. if (data) {
  1915. return clipboardData.setData(mime, data) !== false;
  1916. } else {
  1917. return clipboardData.getData(mime);
  1918. }
  1919. };
  1920. var doCopy = function(e, isCut) {
  1921. var data = host.getCopyText();
  1922. if (!data)
  1923. return event.preventDefault(e);
  1924. if (handleClipboardData(e, data)) {
  1925. isCut ? host.onCut() : host.onCopy();
  1926. event.preventDefault(e);
  1927. } else {
  1928. copied = true;
  1929. text.value = data;
  1930. text.select();
  1931. setTimeout(function(){
  1932. copied = false;
  1933. resetValue();
  1934. resetSelection();
  1935. isCut ? host.onCut() : host.onCopy();
  1936. });
  1937. }
  1938. };
  1939. var onCut = function(e) {
  1940. doCopy(e, true);
  1941. };
  1942. var onCopy = function(e) {
  1943. doCopy(e, false);
  1944. };
  1945. var onPaste = function(e) {
  1946. var data = handleClipboardData(e);
  1947. if (typeof data == "string") {
  1948. if (data)
  1949. host.onPaste(data, e);
  1950. if (useragent.isIE)
  1951. setTimeout(resetSelection);
  1952. event.preventDefault(e);
  1953. }
  1954. else {
  1955. text.value = "";
  1956. pasted = true;
  1957. }
  1958. };
  1959. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  1960. event.addListener(text, "select", onSelect);
  1961. event.addListener(text, "input", onInput);
  1962. event.addListener(text, "cut", onCut);
  1963. event.addListener(text, "copy", onCopy);
  1964. event.addListener(text, "paste", onPaste);
  1965. if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
  1966. event.addListener(parentNode, "keydown", function(e) {
  1967. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  1968. return;
  1969. switch (e.keyCode) {
  1970. case 67:
  1971. onCopy(e);
  1972. break;
  1973. case 86:
  1974. onPaste(e);
  1975. break;
  1976. case 88:
  1977. onCut(e);
  1978. break;
  1979. }
  1980. });
  1981. }
  1982. var onCompositionStart = function(e) {
  1983. if (inComposition || !host.onCompositionStart || host.$readOnly)
  1984. return;
  1985. inComposition = {};
  1986. host.onCompositionStart();
  1987. setTimeout(onCompositionUpdate, 0);
  1988. host.on("mousedown", onCompositionEnd);
  1989. if (!host.selection.isEmpty()) {
  1990. host.insert("");
  1991. host.session.markUndoGroup();
  1992. host.selection.clearSelection();
  1993. }
  1994. host.session.markUndoGroup();
  1995. };
  1996. var onCompositionUpdate = function() {
  1997. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  1998. return;
  1999. var val = text.value.replace(/\x01/g, "");
  2000. if (inComposition.lastValue === val) return;
  2001. host.onCompositionUpdate(val);
  2002. if (inComposition.lastValue)
  2003. host.undo();
  2004. inComposition.lastValue = val;
  2005. if (inComposition.lastValue) {
  2006. var r = host.selection.getRange();
  2007. host.insert(inComposition.lastValue);
  2008. host.session.markUndoGroup();
  2009. inComposition.range = host.selection.getRange();
  2010. host.selection.setRange(r);
  2011. host.selection.clearSelection();
  2012. }
  2013. };
  2014. var onCompositionEnd = function(e) {
  2015. if (!host.onCompositionEnd || host.$readOnly) return;
  2016. var c = inComposition;
  2017. inComposition = false;
  2018. var timer = setTimeout(function() {
  2019. timer = null;
  2020. var str = text.value.replace(/\x01/g, "");
  2021. if (inComposition)
  2022. return;
  2023. else if (str == c.lastValue)
  2024. resetValue();
  2025. else if (!c.lastValue && str) {
  2026. resetValue();
  2027. sendText(str);
  2028. }
  2029. });
  2030. inputHandler = function compositionInputHandler(str) {
  2031. if (timer)
  2032. clearTimeout(timer);
  2033. str = str.replace(/\x01/g, "");
  2034. if (str == c.lastValue)
  2035. return "";
  2036. if (c.lastValue && timer)
  2037. host.undo();
  2038. return str;
  2039. };
  2040. host.onCompositionEnd();
  2041. host.removeListener("mousedown", onCompositionEnd);
  2042. if (e.type == "compositionend" && c.range) {
  2043. host.selection.setRange(c.range);
  2044. }
  2045. };
  2046. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  2047. event.addListener(text, "compositionstart", onCompositionStart);
  2048. if (useragent.isGecko) {
  2049. event.addListener(text, "text", function(){syncComposition.schedule()});
  2050. } else {
  2051. event.addListener(text, "keyup", function(){syncComposition.schedule()});
  2052. event.addListener(text, "keydown", function(){syncComposition.schedule()});
  2053. }
  2054. event.addListener(text, "compositionend", onCompositionEnd);
  2055. this.getElement = function() {
  2056. return text;
  2057. };
  2058. this.setReadOnly = function(readOnly) {
  2059. text.readOnly = readOnly;
  2060. };
  2061. this.onContextMenu = function(e) {
  2062. afterContextMenu = true;
  2063. resetSelection(host.selection.isEmpty());
  2064. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2065. this.moveToMouse(e, true);
  2066. };
  2067. this.moveToMouse = function(e, bringToFront) {
  2068. if (!bringToFront && useragent.isOldIE)
  2069. return;
  2070. if (!tempStyle)
  2071. tempStyle = text.style.cssText;
  2072. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2073. + "height:" + text.style.height + ";"
  2074. + (useragent.isIE ? "opacity:0.1;" : "");
  2075. var rect = host.container.getBoundingClientRect();
  2076. var style = dom.computedStyle(host.container);
  2077. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2078. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2079. var maxTop = rect.bottom - top - text.clientHeight -2;
  2080. var move = function(e) {
  2081. text.style.left = e.clientX - left - 2 + "px";
  2082. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2083. };
  2084. move(e);
  2085. if (e.type != "mousedown")
  2086. return;
  2087. if (host.renderer.$keepTextAreaAtCursor)
  2088. host.renderer.$keepTextAreaAtCursor = null;
  2089. clearTimeout(closeTimeout);
  2090. if (useragent.isWin && !useragent.isOldIE)
  2091. event.capture(host.container, move, onContextMenuClose);
  2092. };
  2093. this.onContextMenuClose = onContextMenuClose;
  2094. var closeTimeout;
  2095. function onContextMenuClose() {
  2096. clearTimeout(closeTimeout);
  2097. closeTimeout = setTimeout(function () {
  2098. if (tempStyle) {
  2099. text.style.cssText = tempStyle;
  2100. tempStyle = '';
  2101. }
  2102. if (host.renderer.$keepTextAreaAtCursor == null) {
  2103. host.renderer.$keepTextAreaAtCursor = true;
  2104. host.renderer.$moveTextAreaToCursor();
  2105. }
  2106. }, useragent.isOldIE ? 200 : 0);
  2107. }
  2108. var onContextMenu = function(e) {
  2109. host.textInput.onContextMenu(e);
  2110. onContextMenuClose();
  2111. };
  2112. event.addListener(text, "mouseup", onContextMenu);
  2113. event.addListener(text, "mousedown", function(e) {
  2114. e.preventDefault();
  2115. onContextMenuClose();
  2116. });
  2117. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2118. event.addListener(text, "contextmenu", onContextMenu);
  2119. };
  2120. exports.TextInput = TextInput;
  2121. });
  2122. ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2123. "use strict";
  2124. var dom = require("../lib/dom");
  2125. var event = require("../lib/event");
  2126. var useragent = require("../lib/useragent");
  2127. var DRAG_OFFSET = 0; // pixels
  2128. function DefaultHandlers(mouseHandler) {
  2129. mouseHandler.$clickSelection = null;
  2130. var editor = mouseHandler.editor;
  2131. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  2132. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  2133. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  2134. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  2135. editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
  2136. editor.setDefaultHandler("touchmove", this.onTouchMove.bind(mouseHandler));
  2137. var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
  2138. "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
  2139. exports.forEach(function(x) {
  2140. mouseHandler[x] = this[x];
  2141. }, this);
  2142. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  2143. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  2144. }
  2145. (function() {
  2146. this.onMouseDown = function(ev) {
  2147. var inSelection = ev.inSelection();
  2148. var pos = ev.getDocumentPosition();
  2149. this.mousedownEvent = ev;
  2150. var editor = this.editor;
  2151. var button = ev.getButton();
  2152. if (button !== 0) {
  2153. var selectionRange = editor.getSelectionRange();
  2154. var selectionEmpty = selectionRange.isEmpty();
  2155. editor.$blockScrolling++;
  2156. if (selectionEmpty || button == 1)
  2157. editor.selection.moveToPosition(pos);
  2158. editor.$blockScrolling--;
  2159. if (button == 2)
  2160. editor.textInput.onContextMenu(ev.domEvent);
  2161. return; // stopping event here breaks contextmenu on ff mac
  2162. }
  2163. this.mousedownEvent.time = Date.now();
  2164. if (inSelection && !editor.isFocused()) {
  2165. editor.focus();
  2166. if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
  2167. this.setState("focusWait");
  2168. this.captureMouse(ev);
  2169. return;
  2170. }
  2171. }
  2172. this.captureMouse(ev);
  2173. this.startSelect(pos, ev.domEvent._clicks > 1);
  2174. return ev.preventDefault();
  2175. };
  2176. this.startSelect = function(pos, waitForClickSelection) {
  2177. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  2178. var editor = this.editor;
  2179. editor.$blockScrolling++;
  2180. if (this.mousedownEvent.getShiftKey())
  2181. editor.selection.selectToPosition(pos);
  2182. else if (!waitForClickSelection)
  2183. editor.selection.moveToPosition(pos);
  2184. if (!waitForClickSelection)
  2185. this.select();
  2186. if (editor.renderer.scroller.setCapture) {
  2187. editor.renderer.scroller.setCapture();
  2188. }
  2189. editor.setStyle("ace_selecting");
  2190. this.setState("select");
  2191. editor.$blockScrolling--;
  2192. };
  2193. this.select = function() {
  2194. var anchor, editor = this.editor;
  2195. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2196. editor.$blockScrolling++;
  2197. if (this.$clickSelection) {
  2198. var cmp = this.$clickSelection.comparePoint(cursor);
  2199. if (cmp == -1) {
  2200. anchor = this.$clickSelection.end;
  2201. } else if (cmp == 1) {
  2202. anchor = this.$clickSelection.start;
  2203. } else {
  2204. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2205. cursor = orientedRange.cursor;
  2206. anchor = orientedRange.anchor;
  2207. }
  2208. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2209. }
  2210. editor.selection.selectToPosition(cursor);
  2211. editor.$blockScrolling--;
  2212. editor.renderer.scrollCursorIntoView();
  2213. };
  2214. this.extendSelectionBy = function(unitName) {
  2215. var anchor, editor = this.editor;
  2216. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2217. var range = editor.selection[unitName](cursor.row, cursor.column);
  2218. editor.$blockScrolling++;
  2219. if (this.$clickSelection) {
  2220. var cmpStart = this.$clickSelection.comparePoint(range.start);
  2221. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  2222. if (cmpStart == -1 && cmpEnd <= 0) {
  2223. anchor = this.$clickSelection.end;
  2224. if (range.end.row != cursor.row || range.end.column != cursor.column)
  2225. cursor = range.start;
  2226. } else if (cmpEnd == 1 && cmpStart >= 0) {
  2227. anchor = this.$clickSelection.start;
  2228. if (range.start.row != cursor.row || range.start.column != cursor.column)
  2229. cursor = range.end;
  2230. } else if (cmpStart == -1 && cmpEnd == 1) {
  2231. cursor = range.end;
  2232. anchor = range.start;
  2233. } else {
  2234. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2235. cursor = orientedRange.cursor;
  2236. anchor = orientedRange.anchor;
  2237. }
  2238. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2239. }
  2240. editor.selection.selectToPosition(cursor);
  2241. editor.$blockScrolling--;
  2242. editor.renderer.scrollCursorIntoView();
  2243. };
  2244. this.selectEnd =
  2245. this.selectAllEnd =
  2246. this.selectByWordsEnd =
  2247. this.selectByLinesEnd = function() {
  2248. this.$clickSelection = null;
  2249. this.editor.unsetStyle("ace_selecting");
  2250. if (this.editor.renderer.scroller.releaseCapture) {
  2251. this.editor.renderer.scroller.releaseCapture();
  2252. }
  2253. };
  2254. this.focusWait = function() {
  2255. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2256. var time = Date.now();
  2257. if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
  2258. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2259. };
  2260. this.onDoubleClick = function(ev) {
  2261. var pos = ev.getDocumentPosition();
  2262. var editor = this.editor;
  2263. var session = editor.session;
  2264. var range = session.getBracketRange(pos);
  2265. if (range) {
  2266. if (range.isEmpty()) {
  2267. range.start.column--;
  2268. range.end.column++;
  2269. }
  2270. this.setState("select");
  2271. } else {
  2272. range = editor.selection.getWordRange(pos.row, pos.column);
  2273. this.setState("selectByWords");
  2274. }
  2275. this.$clickSelection = range;
  2276. this.select();
  2277. };
  2278. this.onTripleClick = function(ev) {
  2279. var pos = ev.getDocumentPosition();
  2280. var editor = this.editor;
  2281. this.setState("selectByLines");
  2282. var range = editor.getSelectionRange();
  2283. if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
  2284. this.$clickSelection = editor.selection.getLineRange(range.start.row);
  2285. this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
  2286. } else {
  2287. this.$clickSelection = editor.selection.getLineRange(pos.row);
  2288. }
  2289. this.select();
  2290. };
  2291. this.onQuadClick = function(ev) {
  2292. var editor = this.editor;
  2293. editor.selectAll();
  2294. this.$clickSelection = editor.getSelectionRange();
  2295. this.setState("selectAll");
  2296. };
  2297. this.onMouseWheel = function(ev) {
  2298. if (ev.getAccelKey())
  2299. return;
  2300. if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
  2301. ev.wheelX = ev.wheelY;
  2302. ev.wheelY = 0;
  2303. }
  2304. var t = ev.domEvent.timeStamp;
  2305. var dt = t - (this.$lastScrollTime||0);
  2306. var editor = this.editor;
  2307. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2308. if (isScrolable || dt < 200) {
  2309. this.$lastScrollTime = t;
  2310. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2311. return ev.stop();
  2312. }
  2313. };
  2314. this.onTouchMove = function (ev) {
  2315. var t = ev.domEvent.timeStamp;
  2316. var dt = t - (this.$lastScrollTime || 0);
  2317. var editor = this.editor;
  2318. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2319. if (isScrolable || dt < 200) {
  2320. this.$lastScrollTime = t;
  2321. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2322. return ev.stop();
  2323. }
  2324. };
  2325. }).call(DefaultHandlers.prototype);
  2326. exports.DefaultHandlers = DefaultHandlers;
  2327. function calcDistance(ax, ay, bx, by) {
  2328. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2329. }
  2330. function calcRangeOrientation(range, cursor) {
  2331. if (range.start.row == range.end.row)
  2332. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  2333. else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
  2334. var cmp = cursor.column - 4;
  2335. else
  2336. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  2337. if (cmp < 0)
  2338. return {cursor: range.start, anchor: range.end};
  2339. else
  2340. return {cursor: range.end, anchor: range.start};
  2341. }
  2342. });
  2343. ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
  2344. "use strict";
  2345. var oop = require("./lib/oop");
  2346. var dom = require("./lib/dom");
  2347. function Tooltip (parentNode) {
  2348. this.isOpen = false;
  2349. this.$element = null;
  2350. this.$parentNode = parentNode;
  2351. }
  2352. (function() {
  2353. this.$init = function() {
  2354. this.$element = dom.createElement("div");
  2355. this.$element.className = "ace_tooltip";
  2356. this.$element.style.display = "none";
  2357. this.$parentNode.appendChild(this.$element);
  2358. return this.$element;
  2359. };
  2360. this.getElement = function() {
  2361. return this.$element || this.$init();
  2362. };
  2363. this.setText = function(text) {
  2364. dom.setInnerText(this.getElement(), text);
  2365. };
  2366. this.setHtml = function(html) {
  2367. this.getElement().innerHTML = html;
  2368. };
  2369. this.setPosition = function(x, y) {
  2370. this.getElement().style.left = x + "px";
  2371. this.getElement().style.top = y + "px";
  2372. };
  2373. this.setClassName = function(className) {
  2374. dom.addCssClass(this.getElement(), className);
  2375. };
  2376. this.show = function(text, x, y) {
  2377. if (text != null)
  2378. this.setText(text);
  2379. if (x != null && y != null)
  2380. this.setPosition(x, y);
  2381. if (!this.isOpen) {
  2382. this.getElement().style.display = "block";
  2383. this.isOpen = true;
  2384. }
  2385. };
  2386. this.hide = function() {
  2387. if (this.isOpen) {
  2388. this.getElement().style.display = "none";
  2389. this.isOpen = false;
  2390. }
  2391. };
  2392. this.getHeight = function() {
  2393. return this.getElement().offsetHeight;
  2394. };
  2395. this.getWidth = function() {
  2396. return this.getElement().offsetWidth;
  2397. };
  2398. }).call(Tooltip.prototype);
  2399. exports.Tooltip = Tooltip;
  2400. });
  2401. 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) {
  2402. "use strict";
  2403. var dom = require("../lib/dom");
  2404. var oop = require("../lib/oop");
  2405. var event = require("../lib/event");
  2406. var Tooltip = require("../tooltip").Tooltip;
  2407. function GutterHandler(mouseHandler) {
  2408. var editor = mouseHandler.editor;
  2409. var gutter = editor.renderer.$gutterLayer;
  2410. var tooltip = new GutterTooltip(editor.container);
  2411. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  2412. if (!editor.isFocused() || e.getButton() != 0)
  2413. return;
  2414. var gutterRegion = gutter.getRegion(e);
  2415. if (gutterRegion == "foldWidgets")
  2416. return;
  2417. var row = e.getDocumentPosition().row;
  2418. var selection = editor.session.selection;
  2419. if (e.getShiftKey())
  2420. selection.selectTo(row, 0);
  2421. else {
  2422. if (e.domEvent.detail == 2) {
  2423. editor.selectAll();
  2424. return e.preventDefault();
  2425. }
  2426. mouseHandler.$clickSelection = editor.selection.getLineRange(row);
  2427. }
  2428. mouseHandler.setState("selectByLines");
  2429. mouseHandler.captureMouse(e);
  2430. return e.preventDefault();
  2431. });
  2432. var tooltipTimeout, mouseEvent, tooltipAnnotation;
  2433. function showTooltip() {
  2434. var row = mouseEvent.getDocumentPosition().row;
  2435. var annotation = gutter.$annotations[row];
  2436. if (!annotation)
  2437. return hideTooltip();
  2438. var maxRow = editor.session.getLength();
  2439. if (row == maxRow) {
  2440. var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
  2441. var pos = mouseEvent.$pos;
  2442. if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
  2443. return hideTooltip();
  2444. }
  2445. if (tooltipAnnotation == annotation)
  2446. return;
  2447. tooltipAnnotation = annotation.text.join("<br/>");
  2448. tooltip.setHtml(tooltipAnnotation);
  2449. tooltip.show();
  2450. editor.on("mousewheel", hideTooltip);
  2451. if (mouseHandler.$tooltipFollowsMouse) {
  2452. moveTooltip(mouseEvent);
  2453. } else {
  2454. var gutterElement = mouseEvent.domEvent.target;
  2455. var rect = gutterElement.getBoundingClientRect();
  2456. var style = tooltip.getElement().style;
  2457. style.left = rect.right + "px";
  2458. style.top = rect.bottom + "px";
  2459. }
  2460. }
  2461. function hideTooltip() {
  2462. if (tooltipTimeout)
  2463. tooltipTimeout = clearTimeout(tooltipTimeout);
  2464. if (tooltipAnnotation) {
  2465. tooltip.hide();
  2466. tooltipAnnotation = null;
  2467. editor.removeEventListener("mousewheel", hideTooltip);
  2468. }
  2469. }
  2470. function moveTooltip(e) {
  2471. tooltip.setPosition(e.x, e.y);
  2472. }
  2473. mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
  2474. var target = e.domEvent.target || e.domEvent.srcElement;
  2475. if (dom.hasCssClass(target, "ace_fold-widget"))
  2476. return hideTooltip();
  2477. if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
  2478. moveTooltip(e);
  2479. mouseEvent = e;
  2480. if (tooltipTimeout)
  2481. return;
  2482. tooltipTimeout = setTimeout(function() {
  2483. tooltipTimeout = null;
  2484. if (mouseEvent && !mouseHandler.isMousePressed)
  2485. showTooltip();
  2486. else
  2487. hideTooltip();
  2488. }, 50);
  2489. });
  2490. event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
  2491. mouseEvent = null;
  2492. if (!tooltipAnnotation || tooltipTimeout)
  2493. return;
  2494. tooltipTimeout = setTimeout(function() {
  2495. tooltipTimeout = null;
  2496. hideTooltip();
  2497. }, 50);
  2498. });
  2499. editor.on("changeSession", hideTooltip);
  2500. }
  2501. function GutterTooltip(parentNode) {
  2502. Tooltip.call(this, parentNode);
  2503. }
  2504. oop.inherits(GutterTooltip, Tooltip);
  2505. (function(){
  2506. this.setPosition = function(x, y) {
  2507. var windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2508. var windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2509. var width = this.getWidth();
  2510. var height = this.getHeight();
  2511. x += 15;
  2512. y += 15;
  2513. if (x + width > windowWidth) {
  2514. x -= (x + width) - windowWidth;
  2515. }
  2516. if (y + height > windowHeight) {
  2517. y -= 20 + height;
  2518. }
  2519. Tooltip.prototype.setPosition.call(this, x, y);
  2520. };
  2521. }).call(GutterTooltip.prototype);
  2522. exports.GutterHandler = GutterHandler;
  2523. });
  2524. ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2525. "use strict";
  2526. var event = require("../lib/event");
  2527. var useragent = require("../lib/useragent");
  2528. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  2529. this.domEvent = domEvent;
  2530. this.editor = editor;
  2531. this.x = this.clientX = domEvent.clientX;
  2532. this.y = this.clientY = domEvent.clientY;
  2533. this.$pos = null;
  2534. this.$inSelection = null;
  2535. this.propagationStopped = false;
  2536. this.defaultPrevented = false;
  2537. };
  2538. (function() {
  2539. this.stopPropagation = function() {
  2540. event.stopPropagation(this.domEvent);
  2541. this.propagationStopped = true;
  2542. };
  2543. this.preventDefault = function() {
  2544. event.preventDefault(this.domEvent);
  2545. this.defaultPrevented = true;
  2546. };
  2547. this.stop = function() {
  2548. this.stopPropagation();
  2549. this.preventDefault();
  2550. };
  2551. this.getDocumentPosition = function() {
  2552. if (this.$pos)
  2553. return this.$pos;
  2554. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  2555. return this.$pos;
  2556. };
  2557. this.inSelection = function() {
  2558. if (this.$inSelection !== null)
  2559. return this.$inSelection;
  2560. var editor = this.editor;
  2561. var selectionRange = editor.getSelectionRange();
  2562. if (selectionRange.isEmpty())
  2563. this.$inSelection = false;
  2564. else {
  2565. var pos = this.getDocumentPosition();
  2566. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  2567. }
  2568. return this.$inSelection;
  2569. };
  2570. this.getButton = function() {
  2571. return event.getButton(this.domEvent);
  2572. };
  2573. this.getShiftKey = function() {
  2574. return this.domEvent.shiftKey;
  2575. };
  2576. this.getAccelKey = useragent.isMac
  2577. ? function() { return this.domEvent.metaKey; }
  2578. : function() { return this.domEvent.ctrlKey; };
  2579. }).call(MouseEvent.prototype);
  2580. });
  2581. ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2582. "use strict";
  2583. var dom = require("../lib/dom");
  2584. var event = require("../lib/event");
  2585. var useragent = require("../lib/useragent");
  2586. var AUTOSCROLL_DELAY = 200;
  2587. var SCROLL_CURSOR_DELAY = 200;
  2588. var SCROLL_CURSOR_HYSTERESIS = 5;
  2589. function DragdropHandler(mouseHandler) {
  2590. var editor = mouseHandler.editor;
  2591. var blankImage = dom.createElement("img");
  2592. blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  2593. if (useragent.isOpera)
  2594. blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
  2595. var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
  2596. exports.forEach(function(x) {
  2597. mouseHandler[x] = this[x];
  2598. }, this);
  2599. editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
  2600. var mouseTarget = editor.container;
  2601. var dragSelectionMarker, x, y;
  2602. var timerId, range;
  2603. var dragCursor, counter = 0;
  2604. var dragOperation;
  2605. var isInternal;
  2606. var autoScrollStartTime;
  2607. var cursorMovedTime;
  2608. var cursorPointOnCaretMoved;
  2609. this.onDragStart = function(e) {
  2610. if (this.cancelDrag || !mouseTarget.draggable) {
  2611. var self = this;
  2612. setTimeout(function(){
  2613. self.startSelect();
  2614. self.captureMouse(e);
  2615. }, 0);
  2616. return e.preventDefault();
  2617. }
  2618. range = editor.getSelectionRange();
  2619. var dataTransfer = e.dataTransfer;
  2620. dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
  2621. if (useragent.isOpera) {
  2622. editor.container.appendChild(blankImage);
  2623. blankImage.scrollTop = 0;
  2624. }
  2625. dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
  2626. if (useragent.isOpera) {
  2627. editor.container.removeChild(blankImage);
  2628. }
  2629. dataTransfer.clearData();
  2630. dataTransfer.setData("Text", editor.session.getTextRange());
  2631. isInternal = true;
  2632. this.setState("drag");
  2633. };
  2634. this.onDragEnd = function(e) {
  2635. mouseTarget.draggable = false;
  2636. isInternal = false;
  2637. this.setState(null);
  2638. if (!editor.getReadOnly()) {
  2639. var dropEffect = e.dataTransfer.dropEffect;
  2640. if (!dragOperation && dropEffect == "move")
  2641. editor.session.remove(editor.getSelectionRange());
  2642. editor.renderer.$cursorLayer.setBlinking(true);
  2643. }
  2644. this.editor.unsetStyle("ace_dragging");
  2645. this.editor.renderer.setCursorStyle("");
  2646. };
  2647. this.onDragEnter = function(e) {
  2648. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2649. return;
  2650. x = e.clientX;
  2651. y = e.clientY;
  2652. if (!dragSelectionMarker)
  2653. addDragMarker();
  2654. counter++;
  2655. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2656. return event.preventDefault(e);
  2657. };
  2658. this.onDragOver = function(e) {
  2659. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2660. return;
  2661. x = e.clientX;
  2662. y = e.clientY;
  2663. if (!dragSelectionMarker) {
  2664. addDragMarker();
  2665. counter++;
  2666. }
  2667. if (onMouseMoveTimer !== null)
  2668. onMouseMoveTimer = null;
  2669. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2670. return event.preventDefault(e);
  2671. };
  2672. this.onDragLeave = function(e) {
  2673. counter--;
  2674. if (counter <= 0 && dragSelectionMarker) {
  2675. clearDragMarker();
  2676. dragOperation = null;
  2677. return event.preventDefault(e);
  2678. }
  2679. };
  2680. this.onDrop = function(e) {
  2681. if (!dragCursor)
  2682. return;
  2683. var dataTransfer = e.dataTransfer;
  2684. if (isInternal) {
  2685. switch (dragOperation) {
  2686. case "move":
  2687. if (range.contains(dragCursor.row, dragCursor.column)) {
  2688. range = {
  2689. start: dragCursor,
  2690. end: dragCursor
  2691. };
  2692. } else {
  2693. range = editor.moveText(range, dragCursor);
  2694. }
  2695. break;
  2696. case "copy":
  2697. range = editor.moveText(range, dragCursor, true);
  2698. break;
  2699. }
  2700. } else {
  2701. var dropData = dataTransfer.getData('Text');
  2702. range = {
  2703. start: dragCursor,
  2704. end: editor.session.insert(dragCursor, dropData)
  2705. };
  2706. editor.focus();
  2707. dragOperation = null;
  2708. }
  2709. clearDragMarker();
  2710. return event.preventDefault(e);
  2711. };
  2712. event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
  2713. event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
  2714. event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
  2715. event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
  2716. event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
  2717. event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
  2718. function scrollCursorIntoView(cursor, prevCursor) {
  2719. var now = Date.now();
  2720. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2721. var hMovement = !prevCursor || cursor.column != prevCursor.column;
  2722. if (!cursorMovedTime || vMovement || hMovement) {
  2723. editor.$blockScrolling += 1;
  2724. editor.moveCursorToPosition(cursor);
  2725. editor.$blockScrolling -= 1;
  2726. cursorMovedTime = now;
  2727. cursorPointOnCaretMoved = {x: x, y: y};
  2728. } else {
  2729. var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
  2730. if (distance > SCROLL_CURSOR_HYSTERESIS) {
  2731. cursorMovedTime = null;
  2732. } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
  2733. editor.renderer.scrollCursorIntoView();
  2734. cursorMovedTime = null;
  2735. }
  2736. }
  2737. }
  2738. function autoScroll(cursor, prevCursor) {
  2739. var now = Date.now();
  2740. var lineHeight = editor.renderer.layerConfig.lineHeight;
  2741. var characterWidth = editor.renderer.layerConfig.characterWidth;
  2742. var editorRect = editor.renderer.scroller.getBoundingClientRect();
  2743. var offsets = {
  2744. x: {
  2745. left: x - editorRect.left,
  2746. right: editorRect.right - x
  2747. },
  2748. y: {
  2749. top: y - editorRect.top,
  2750. bottom: editorRect.bottom - y
  2751. }
  2752. };
  2753. var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
  2754. var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
  2755. var scrollCursor = {row: cursor.row, column: cursor.column};
  2756. if (nearestXOffset / characterWidth <= 2) {
  2757. scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
  2758. }
  2759. if (nearestYOffset / lineHeight <= 1) {
  2760. scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
  2761. }
  2762. var vScroll = cursor.row != scrollCursor.row;
  2763. var hScroll = cursor.column != scrollCursor.column;
  2764. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2765. if (vScroll || (hScroll && !vMovement)) {
  2766. if (!autoScrollStartTime)
  2767. autoScrollStartTime = now;
  2768. else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
  2769. editor.renderer.scrollCursorIntoView(scrollCursor);
  2770. } else {
  2771. autoScrollStartTime = null;
  2772. }
  2773. }
  2774. function onDragInterval() {
  2775. var prevCursor = dragCursor;
  2776. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  2777. scrollCursorIntoView(dragCursor, prevCursor);
  2778. autoScroll(dragCursor, prevCursor);
  2779. }
  2780. function addDragMarker() {
  2781. range = editor.selection.toOrientedRange();
  2782. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
  2783. editor.clearSelection();
  2784. if (editor.isFocused())
  2785. editor.renderer.$cursorLayer.setBlinking(false);
  2786. clearInterval(timerId);
  2787. onDragInterval();
  2788. timerId = setInterval(onDragInterval, 20);
  2789. counter = 0;
  2790. event.addListener(document, "mousemove", onMouseMove);
  2791. }
  2792. function clearDragMarker() {
  2793. clearInterval(timerId);
  2794. editor.session.removeMarker(dragSelectionMarker);
  2795. dragSelectionMarker = null;
  2796. editor.$blockScrolling += 1;
  2797. editor.selection.fromOrientedRange(range);
  2798. editor.$blockScrolling -= 1;
  2799. if (editor.isFocused() && !isInternal)
  2800. editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
  2801. range = null;
  2802. dragCursor = null;
  2803. counter = 0;
  2804. autoScrollStartTime = null;
  2805. cursorMovedTime = null;
  2806. event.removeListener(document, "mousemove", onMouseMove);
  2807. }
  2808. var onMouseMoveTimer = null;
  2809. function onMouseMove() {
  2810. if (onMouseMoveTimer == null) {
  2811. onMouseMoveTimer = setTimeout(function() {
  2812. if (onMouseMoveTimer != null && dragSelectionMarker)
  2813. clearDragMarker();
  2814. }, 20);
  2815. }
  2816. }
  2817. function canAccept(dataTransfer) {
  2818. var types = dataTransfer.types;
  2819. return !types || Array.prototype.some.call(types, function(type) {
  2820. return type == 'text/plain' || type == 'Text';
  2821. });
  2822. }
  2823. function getDropEffect(e) {
  2824. var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
  2825. var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
  2826. var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
  2827. var effectAllowed = "uninitialized";
  2828. try {
  2829. effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
  2830. } catch (e) {}
  2831. var dropEffect = "none";
  2832. if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
  2833. dropEffect = "copy";
  2834. else if (moveAllowed.indexOf(effectAllowed) >= 0)
  2835. dropEffect = "move";
  2836. else if (copyAllowed.indexOf(effectAllowed) >= 0)
  2837. dropEffect = "copy";
  2838. return dropEffect;
  2839. }
  2840. }
  2841. (function() {
  2842. this.dragWait = function() {
  2843. var interval = Date.now() - this.mousedownEvent.time;
  2844. if (interval > this.editor.getDragDelay())
  2845. this.startDrag();
  2846. };
  2847. this.dragWaitEnd = function() {
  2848. var target = this.editor.container;
  2849. target.draggable = false;
  2850. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2851. this.selectEnd();
  2852. };
  2853. this.dragReadyEnd = function(e) {
  2854. this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
  2855. this.editor.unsetStyle("ace_dragging");
  2856. this.editor.renderer.setCursorStyle("");
  2857. this.dragWaitEnd();
  2858. };
  2859. this.startDrag = function(){
  2860. this.cancelDrag = false;
  2861. var editor = this.editor;
  2862. var target = editor.container;
  2863. target.draggable = true;
  2864. editor.renderer.$cursorLayer.setBlinking(false);
  2865. editor.setStyle("ace_dragging");
  2866. var cursorStyle = useragent.isWin ? "default" : "move";
  2867. editor.renderer.setCursorStyle(cursorStyle);
  2868. this.setState("dragReady");
  2869. };
  2870. this.onMouseDrag = function(e) {
  2871. var target = this.editor.container;
  2872. if (useragent.isIE && this.state == "dragReady") {
  2873. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2874. if (distance > 3)
  2875. target.dragDrop();
  2876. }
  2877. if (this.state === "dragWait") {
  2878. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2879. if (distance > 0) {
  2880. target.draggable = false;
  2881. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2882. }
  2883. }
  2884. };
  2885. this.onMouseDown = function(e) {
  2886. if (!this.$dragEnabled)
  2887. return;
  2888. this.mousedownEvent = e;
  2889. var editor = this.editor;
  2890. var inSelection = e.inSelection();
  2891. var button = e.getButton();
  2892. var clickCount = e.domEvent.detail || 1;
  2893. if (clickCount === 1 && button === 0 && inSelection) {
  2894. if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
  2895. return;
  2896. this.mousedownEvent.time = Date.now();
  2897. var eventTarget = e.domEvent.target || e.domEvent.srcElement;
  2898. if ("unselectable" in eventTarget)
  2899. eventTarget.unselectable = "on";
  2900. if (editor.getDragDelay()) {
  2901. if (useragent.isWebKit) {
  2902. this.cancelDrag = true;
  2903. var mouseTarget = editor.container;
  2904. mouseTarget.draggable = true;
  2905. }
  2906. this.setState("dragWait");
  2907. } else {
  2908. this.startDrag();
  2909. }
  2910. this.captureMouse(e, this.onMouseDrag.bind(this));
  2911. e.defaultPrevented = true;
  2912. }
  2913. };
  2914. }).call(DragdropHandler.prototype);
  2915. function calcDistance(ax, ay, bx, by) {
  2916. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2917. }
  2918. exports.DragdropHandler = DragdropHandler;
  2919. });
  2920. ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  2921. "use strict";
  2922. var dom = require("./dom");
  2923. exports.get = function (url, callback) {
  2924. var xhr = new XMLHttpRequest();
  2925. xhr.open('GET', url, true);
  2926. xhr.onreadystatechange = function () {
  2927. if (xhr.readyState === 4) {
  2928. callback(xhr.responseText);
  2929. }
  2930. };
  2931. xhr.send(null);
  2932. };
  2933. exports.loadScript = function(path, callback) {
  2934. var head = dom.getDocumentHead();
  2935. var s = document.createElement('script');
  2936. s.src = path;
  2937. head.appendChild(s);
  2938. s.onload = s.onreadystatechange = function(_, isAbort) {
  2939. if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
  2940. s = s.onload = s.onreadystatechange = null;
  2941. if (!isAbort)
  2942. callback();
  2943. }
  2944. };
  2945. };
  2946. exports.qualifyURL = function(url) {
  2947. var a = document.createElement('a');
  2948. a.href = url;
  2949. return a.href;
  2950. }
  2951. });
  2952. ace.define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  2953. "use strict";
  2954. var EventEmitter = {};
  2955. var stopPropagation = function() { this.propagationStopped = true; };
  2956. var preventDefault = function() { this.defaultPrevented = true; };
  2957. EventEmitter._emit =
  2958. EventEmitter._dispatchEvent = function(eventName, e) {
  2959. this._eventRegistry || (this._eventRegistry = {});
  2960. this._defaultHandlers || (this._defaultHandlers = {});
  2961. var listeners = this._eventRegistry[eventName] || [];
  2962. var defaultHandler = this._defaultHandlers[eventName];
  2963. if (!listeners.length && !defaultHandler)
  2964. return;
  2965. if (typeof e != "object" || !e)
  2966. e = {};
  2967. if (!e.type)
  2968. e.type = eventName;
  2969. if (!e.stopPropagation)
  2970. e.stopPropagation = stopPropagation;
  2971. if (!e.preventDefault)
  2972. e.preventDefault = preventDefault;
  2973. listeners = listeners.slice();
  2974. for (var i=0; i<listeners.length; i++) {
  2975. listeners[i](e, this);
  2976. if (e.propagationStopped)
  2977. break;
  2978. }
  2979. if (defaultHandler && !e.defaultPrevented)
  2980. return defaultHandler(e, this);
  2981. };
  2982. EventEmitter._signal = function(eventName, e) {
  2983. var listeners = (this._eventRegistry || {})[eventName];
  2984. if (!listeners)
  2985. return;
  2986. listeners = listeners.slice();
  2987. for (var i=0; i<listeners.length; i++)
  2988. listeners[i](e, this);
  2989. };
  2990. EventEmitter.once = function(eventName, callback) {
  2991. var _self = this;
  2992. callback && this.addEventListener(eventName, function newCallback() {
  2993. _self.removeEventListener(eventName, newCallback);
  2994. callback.apply(null, arguments);
  2995. });
  2996. };
  2997. EventEmitter.setDefaultHandler = function(eventName, callback) {
  2998. var handlers = this._defaultHandlers
  2999. if (!handlers)
  3000. handlers = this._defaultHandlers = {_disabled_: {}};
  3001. if (handlers[eventName]) {
  3002. var old = handlers[eventName];
  3003. var disabled = handlers._disabled_[eventName];
  3004. if (!disabled)
  3005. handlers._disabled_[eventName] = disabled = [];
  3006. disabled.push(old);
  3007. var i = disabled.indexOf(callback);
  3008. if (i != -1)
  3009. disabled.splice(i, 1);
  3010. }
  3011. handlers[eventName] = callback;
  3012. };
  3013. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  3014. var handlers = this._defaultHandlers
  3015. if (!handlers)
  3016. return;
  3017. var disabled = handlers._disabled_[eventName];
  3018. if (handlers[eventName] == callback) {
  3019. var old = handlers[eventName];
  3020. if (disabled)
  3021. this.setDefaultHandler(eventName, disabled.pop());
  3022. } else if (disabled) {
  3023. var i = disabled.indexOf(callback);
  3024. if (i != -1)
  3025. disabled.splice(i, 1);
  3026. }
  3027. };
  3028. EventEmitter.on =
  3029. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  3030. this._eventRegistry = this._eventRegistry || {};
  3031. var listeners = this._eventRegistry[eventName];
  3032. if (!listeners)
  3033. listeners = this._eventRegistry[eventName] = [];
  3034. if (listeners.indexOf(callback) == -1)
  3035. listeners[capturing ? "unshift" : "push"](callback);
  3036. return callback;
  3037. };
  3038. EventEmitter.off =
  3039. EventEmitter.removeListener =
  3040. EventEmitter.removeEventListener = function(eventName, callback) {
  3041. this._eventRegistry = this._eventRegistry || {};
  3042. var listeners = this._eventRegistry[eventName];
  3043. if (!listeners)
  3044. return;
  3045. var index = listeners.indexOf(callback);
  3046. if (index !== -1)
  3047. listeners.splice(index, 1);
  3048. };
  3049. EventEmitter.removeAllListeners = function(eventName) {
  3050. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  3051. };
  3052. exports.EventEmitter = EventEmitter;
  3053. });
  3054. ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  3055. "no use strict";
  3056. var oop = require("./oop");
  3057. var EventEmitter = require("./event_emitter").EventEmitter;
  3058. var optionsProvider = {
  3059. setOptions: function(optList) {
  3060. Object.keys(optList).forEach(function(key) {
  3061. this.setOption(key, optList[key]);
  3062. }, this);
  3063. },
  3064. getOptions: function(optionNames) {
  3065. var result = {};
  3066. if (!optionNames) {
  3067. optionNames = Object.keys(this.$options);
  3068. } else if (!Array.isArray(optionNames)) {
  3069. result = optionNames;
  3070. optionNames = Object.keys(result);
  3071. }
  3072. optionNames.forEach(function(key) {
  3073. result[key] = this.getOption(key);
  3074. }, this);
  3075. return result;
  3076. },
  3077. setOption: function(name, value) {
  3078. if (this["$" + name] === value)
  3079. return;
  3080. var opt = this.$options[name];
  3081. if (!opt) {
  3082. return warn('misspelled option "' + name + '"');
  3083. }
  3084. if (opt.forwardTo)
  3085. return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
  3086. if (!opt.handlesSet)
  3087. this["$" + name] = value;
  3088. if (opt && opt.set)
  3089. opt.set.call(this, value);
  3090. },
  3091. getOption: function(name) {
  3092. var opt = this.$options[name];
  3093. if (!opt) {
  3094. return warn('misspelled option "' + name + '"');
  3095. }
  3096. if (opt.forwardTo)
  3097. return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
  3098. return opt && opt.get ? opt.get.call(this) : this["$" + name];
  3099. }
  3100. };
  3101. function warn(message) {
  3102. if (typeof console != "undefined" && console.warn)
  3103. console.warn.apply(console, arguments);
  3104. }
  3105. function reportError(msg, data) {
  3106. var e = new Error(msg);
  3107. e.data = data;
  3108. if (typeof console == "object" && console.error)
  3109. console.error(e);
  3110. setTimeout(function() { throw e; });
  3111. }
  3112. var AppConfig = function() {
  3113. this.$defaultOptions = {};
  3114. };
  3115. (function() {
  3116. oop.implement(this, EventEmitter);
  3117. this.defineOptions = function(obj, path, options) {
  3118. if (!obj.$options)
  3119. this.$defaultOptions[path] = obj.$options = {};
  3120. Object.keys(options).forEach(function(key) {
  3121. var opt = options[key];
  3122. if (typeof opt == "string")
  3123. opt = {forwardTo: opt};
  3124. opt.name || (opt.name = key);
  3125. obj.$options[opt.name] = opt;
  3126. if ("initialValue" in opt)
  3127. obj["$" + opt.name] = opt.initialValue;
  3128. });
  3129. oop.implement(obj, optionsProvider);
  3130. return this;
  3131. };
  3132. this.resetOptions = function(obj) {
  3133. Object.keys(obj.$options).forEach(function(key) {
  3134. var opt = obj.$options[key];
  3135. if ("value" in opt)
  3136. obj.setOption(key, opt.value);
  3137. });
  3138. };
  3139. this.setDefaultValue = function(path, name, value) {
  3140. var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
  3141. if (opts[name]) {
  3142. if (opts.forwardTo)
  3143. this.setDefaultValue(opts.forwardTo, name, value);
  3144. else
  3145. opts[name].value = value;
  3146. }
  3147. };
  3148. this.setDefaultValues = function(path, optionHash) {
  3149. Object.keys(optionHash).forEach(function(key) {
  3150. this.setDefaultValue(path, key, optionHash[key]);
  3151. }, this);
  3152. };
  3153. this.warn = warn;
  3154. this.reportError = reportError;
  3155. }).call(AppConfig.prototype);
  3156. exports.AppConfig = AppConfig;
  3157. });
  3158. ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) {
  3159. "no use strict";
  3160. var lang = require("./lib/lang");
  3161. var oop = require("./lib/oop");
  3162. var net = require("./lib/net");
  3163. var AppConfig = require("./lib/app_config").AppConfig;
  3164. module.exports = exports = new AppConfig();
  3165. var global = (function() {
  3166. return this || typeof window != "undefined" && window;
  3167. })();
  3168. var options = {
  3169. packaged: false,
  3170. workerPath: null,
  3171. modePath: null,
  3172. themePath: null,
  3173. basePath: "",
  3174. suffix: ".js",
  3175. $moduleUrls: {}
  3176. };
  3177. exports.get = function(key) {
  3178. if (!options.hasOwnProperty(key))
  3179. throw new Error("Unknown config key: " + key);
  3180. return options[key];
  3181. };
  3182. exports.set = function(key, value) {
  3183. if (!options.hasOwnProperty(key))
  3184. throw new Error("Unknown config key: " + key);
  3185. options[key] = value;
  3186. };
  3187. exports.all = function() {
  3188. return lang.copyObject(options);
  3189. };
  3190. exports.moduleUrl = function(name, component) {
  3191. if (options.$moduleUrls[name])
  3192. return options.$moduleUrls[name];
  3193. var parts = name.split("/");
  3194. component = component || parts[parts.length - 2] || "";
  3195. var sep = component == "snippets" ? "/" : "-";
  3196. var base = parts[parts.length - 1];
  3197. if (component == "worker" && sep == "-") {
  3198. var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
  3199. base = base.replace(re, "");
  3200. }
  3201. if ((!base || base == component) && parts.length > 1)
  3202. base = parts[parts.length - 2];
  3203. var path = options[component + "Path"];
  3204. if (path == null) {
  3205. path = options.basePath;
  3206. } else if (sep == "/") {
  3207. component = sep = "";
  3208. }
  3209. if (path && path.slice(-1) != "/")
  3210. path += "/";
  3211. return path + component + sep + base + this.get("suffix");
  3212. };
  3213. exports.setModuleUrl = function(name, subst) {
  3214. return options.$moduleUrls[name] = subst;
  3215. };
  3216. exports.$loading = {};
  3217. exports.loadModule = function(moduleName, onLoad) {
  3218. var module, moduleType;
  3219. if (Array.isArray(moduleName)) {
  3220. moduleType = moduleName[0];
  3221. moduleName = moduleName[1];
  3222. }
  3223. try {
  3224. module = require(moduleName);
  3225. } catch (e) {}
  3226. if (module && !exports.$loading[moduleName])
  3227. return onLoad && onLoad(module);
  3228. if (!exports.$loading[moduleName])
  3229. exports.$loading[moduleName] = [];
  3230. exports.$loading[moduleName].push(onLoad);
  3231. if (exports.$loading[moduleName].length > 1)
  3232. return;
  3233. var afterLoad = function() {
  3234. require([moduleName], function(module) {
  3235. exports._emit("load.module", {name: moduleName, module: module});
  3236. var listeners = exports.$loading[moduleName];
  3237. exports.$loading[moduleName] = null;
  3238. listeners.forEach(function(onLoad) {
  3239. onLoad && onLoad(module);
  3240. });
  3241. });
  3242. };
  3243. if (!exports.get("packaged"))
  3244. return afterLoad();
  3245. net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
  3246. };
  3247. init(true);function init(packaged) {
  3248. if (!global || !global.document)
  3249. return;
  3250. options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
  3251. var scriptOptions = {};
  3252. var scriptUrl = "";
  3253. var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
  3254. var currentDocument = currentScript && currentScript.ownerDocument || document;
  3255. var scripts = currentDocument.getElementsByTagName("script");
  3256. for (var i=0; i<scripts.length; i++) {
  3257. var script = scripts[i];
  3258. var src = script.src || script.getAttribute("src");
  3259. if (!src)
  3260. continue;
  3261. var attributes = script.attributes;
  3262. for (var j=0, l=attributes.length; j < l; j++) {
  3263. var attr = attributes[j];
  3264. if (attr.name.indexOf("data-ace-") === 0) {
  3265. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  3266. }
  3267. }
  3268. var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
  3269. if (m)
  3270. scriptUrl = m[1];
  3271. }
  3272. if (scriptUrl) {
  3273. scriptOptions.base = scriptOptions.base || scriptUrl;
  3274. scriptOptions.packaged = true;
  3275. }
  3276. scriptOptions.basePath = scriptOptions.base;
  3277. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  3278. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  3279. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  3280. delete scriptOptions.base;
  3281. for (var key in scriptOptions)
  3282. if (typeof scriptOptions[key] !== "undefined")
  3283. exports.set(key, scriptOptions[key]);
  3284. }
  3285. exports.init = init;
  3286. function deHyphenate(str) {
  3287. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  3288. }
  3289. });
  3290. 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) {
  3291. "use strict";
  3292. var event = require("../lib/event");
  3293. var useragent = require("../lib/useragent");
  3294. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3295. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3296. var MouseEvent = require("./mouse_event").MouseEvent;
  3297. var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
  3298. var config = require("../config");
  3299. var MouseHandler = function(editor) {
  3300. var _self = this;
  3301. this.editor = editor;
  3302. new DefaultHandlers(this);
  3303. new DefaultGutterHandler(this);
  3304. new DragdropHandler(this);
  3305. var focusEditor = function(e) {
  3306. var windowBlurred = !document.hasFocus || !document.hasFocus()
  3307. || !editor.isFocused() && document.activeElement == (editor.textInput && editor.textInput.getElement())
  3308. if (windowBlurred)
  3309. window.focus();
  3310. editor.focus();
  3311. };
  3312. var mouseTarget = editor.renderer.getMouseEventTarget();
  3313. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3314. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3315. event.addMultiMouseDownListener([
  3316. mouseTarget,
  3317. editor.renderer.scrollBarV && editor.renderer.scrollBarV.inner,
  3318. editor.renderer.scrollBarH && editor.renderer.scrollBarH.inner,
  3319. editor.textInput && editor.textInput.getElement()
  3320. ].filter(Boolean), [400, 300, 250], this, "onMouseEvent");
  3321. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3322. event.addTouchMoveListener(editor.container, this.onTouchMove.bind(this, "touchmove"));
  3323. var gutterEl = editor.renderer.$gutter;
  3324. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3325. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3326. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3327. event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
  3328. event.addListener(mouseTarget, "mousedown", focusEditor);
  3329. event.addListener(gutterEl, "mousedown", focusEditor);
  3330. if (useragent.isIE && editor.renderer.scrollBarV) {
  3331. event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
  3332. event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
  3333. }
  3334. editor.on("mousemove", function(e){
  3335. if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
  3336. return;
  3337. var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
  3338. var range = editor.session.selection.getRange();
  3339. var renderer = editor.renderer;
  3340. if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
  3341. renderer.setCursorStyle("default");
  3342. } else {
  3343. renderer.setCursorStyle("");
  3344. }
  3345. });
  3346. };
  3347. (function() {
  3348. this.onMouseEvent = function(name, e) {
  3349. this.editor._emit(name, new MouseEvent(e, this.editor));
  3350. };
  3351. this.onMouseMove = function(name, e) {
  3352. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3353. if (!listeners || !listeners.length)
  3354. return;
  3355. this.editor._emit(name, new MouseEvent(e, this.editor));
  3356. };
  3357. this.onMouseWheel = function(name, e) {
  3358. var mouseEvent = new MouseEvent(e, this.editor);
  3359. mouseEvent.speed = this.$scrollSpeed * 2;
  3360. mouseEvent.wheelX = e.wheelX;
  3361. mouseEvent.wheelY = e.wheelY;
  3362. this.editor._emit(name, mouseEvent);
  3363. };
  3364. this.onTouchMove = function (name, e) {
  3365. var mouseEvent = new MouseEvent(e, this.editor);
  3366. mouseEvent.speed = 1;//this.$scrollSpeed * 2;
  3367. mouseEvent.wheelX = e.wheelX;
  3368. mouseEvent.wheelY = e.wheelY;
  3369. this.editor._emit(name, mouseEvent);
  3370. };
  3371. this.setState = function(state) {
  3372. this.state = state;
  3373. };
  3374. this.captureMouse = function(ev, mouseMoveHandler) {
  3375. this.x = ev.x;
  3376. this.y = ev.y;
  3377. this.isMousePressed = true;
  3378. var renderer = this.editor.renderer;
  3379. if (renderer.$keepTextAreaAtCursor)
  3380. renderer.$keepTextAreaAtCursor = null;
  3381. var self = this;
  3382. var onMouseMove = function(e) {
  3383. if (!e) return;
  3384. if (useragent.isWebKit && !e.which && self.releaseMouse)
  3385. return self.releaseMouse();
  3386. self.x = e.clientX;
  3387. self.y = e.clientY;
  3388. mouseMoveHandler && mouseMoveHandler(e);
  3389. self.mouseEvent = new MouseEvent(e, self.editor);
  3390. self.$mouseMoved = true;
  3391. };
  3392. var onCaptureEnd = function(e) {
  3393. clearInterval(timerId);
  3394. onCaptureInterval();
  3395. self[self.state + "End"] && self[self.state + "End"](e);
  3396. self.state = "";
  3397. if (renderer.$keepTextAreaAtCursor == null) {
  3398. renderer.$keepTextAreaAtCursor = true;
  3399. renderer.$moveTextAreaToCursor();
  3400. }
  3401. self.isMousePressed = false;
  3402. self.$onCaptureMouseMove = self.releaseMouse = null;
  3403. e && self.onMouseEvent("mouseup", e);
  3404. };
  3405. var onCaptureInterval = function() {
  3406. self[self.state] && self[self.state]();
  3407. self.$mouseMoved = false;
  3408. };
  3409. if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
  3410. return setTimeout(function() {onCaptureEnd(ev);});
  3411. }
  3412. self.$onCaptureMouseMove = onMouseMove;
  3413. self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3414. var timerId = setInterval(onCaptureInterval, 20);
  3415. };
  3416. this.releaseMouse = null;
  3417. this.cancelContextMenu = function() {
  3418. var stop = function(e) {
  3419. if (e && e.domEvent && e.domEvent.type != "contextmenu")
  3420. return;
  3421. this.editor.off("nativecontextmenu", stop);
  3422. if (e && e.domEvent)
  3423. event.stopEvent(e.domEvent);
  3424. }.bind(this);
  3425. setTimeout(stop, 10);
  3426. this.editor.on("nativecontextmenu", stop);
  3427. };
  3428. }).call(MouseHandler.prototype);
  3429. config.defineOptions(MouseHandler.prototype, "mouseHandler", {
  3430. scrollSpeed: {initialValue: 2},
  3431. dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
  3432. dragEnabled: {initialValue: true},
  3433. focusTimout: {initialValue: 0},
  3434. tooltipFollowsMouse: {initialValue: true}
  3435. });
  3436. exports.MouseHandler = MouseHandler;
  3437. });
  3438. ace.define("ace/mouse/fold_handler",["require","exports","module"], function(require, exports, module) {
  3439. "use strict";
  3440. function FoldHandler(editor) {
  3441. editor.on("click", function(e) {
  3442. var position = e.getDocumentPosition();
  3443. var session = editor.session;
  3444. var fold = session.getFoldAt(position.row, position.column, 1);
  3445. if (fold) {
  3446. if (e.getAccelKey())
  3447. session.removeFold(fold);
  3448. else
  3449. session.expandFold(fold);
  3450. e.stop();
  3451. }
  3452. });
  3453. editor.on("gutterclick", function(e) {
  3454. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3455. if (gutterRegion == "foldWidgets") {
  3456. var row = e.getDocumentPosition().row;
  3457. var session = editor.session;
  3458. if (session.foldWidgets && session.foldWidgets[row])
  3459. editor.session.onFoldWidgetClick(row, e);
  3460. if (!editor.isFocused())
  3461. editor.focus();
  3462. e.stop();
  3463. }
  3464. });
  3465. editor.on("gutterdblclick", function(e) {
  3466. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3467. if (gutterRegion == "foldWidgets") {
  3468. var row = e.getDocumentPosition().row;
  3469. var session = editor.session;
  3470. var data = session.getParentFoldRangeData(row, true);
  3471. var range = data.range || data.firstRange;
  3472. if (range) {
  3473. row = range.start.row;
  3474. var fold = session.getFoldAt(row, session.getLine(row).length, 1);
  3475. if (fold) {
  3476. session.removeFold(fold);
  3477. } else {
  3478. session.addFold("...", range);
  3479. editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
  3480. }
  3481. }
  3482. e.stop();
  3483. }
  3484. });
  3485. }
  3486. exports.FoldHandler = FoldHandler;
  3487. });
  3488. ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module) {
  3489. "use strict";
  3490. var keyUtil = require("../lib/keys");
  3491. var event = require("../lib/event");
  3492. var KeyBinding = function(editor) {
  3493. this.$editor = editor;
  3494. this.$data = {editor: editor};
  3495. this.$handlers = [];
  3496. this.setDefaultHandler(editor.commands);
  3497. };
  3498. (function() {
  3499. this.setDefaultHandler = function(kb) {
  3500. this.removeKeyboardHandler(this.$defaultHandler);
  3501. this.$defaultHandler = kb;
  3502. this.addKeyboardHandler(kb, 0);
  3503. };
  3504. this.setKeyboardHandler = function(kb) {
  3505. var h = this.$handlers;
  3506. if (h[h.length - 1] == kb)
  3507. return;
  3508. while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
  3509. this.removeKeyboardHandler(h[h.length - 1]);
  3510. this.addKeyboardHandler(kb, 1);
  3511. };
  3512. this.addKeyboardHandler = function(kb, pos) {
  3513. if (!kb)
  3514. return;
  3515. if (typeof kb == "function" && !kb.handleKeyboard)
  3516. kb.handleKeyboard = kb;
  3517. var i = this.$handlers.indexOf(kb);
  3518. if (i != -1)
  3519. this.$handlers.splice(i, 1);
  3520. if (pos == undefined)
  3521. this.$handlers.push(kb);
  3522. else
  3523. this.$handlers.splice(pos, 0, kb);
  3524. if (i == -1 && kb.attach)
  3525. kb.attach(this.$editor);
  3526. };
  3527. this.removeKeyboardHandler = function(kb) {
  3528. var i = this.$handlers.indexOf(kb);
  3529. if (i == -1)
  3530. return false;
  3531. this.$handlers.splice(i, 1);
  3532. kb.detach && kb.detach(this.$editor);
  3533. return true;
  3534. };
  3535. this.getKeyboardHandler = function() {
  3536. return this.$handlers[this.$handlers.length - 1];
  3537. };
  3538. this.getStatusText = function() {
  3539. var data = this.$data;
  3540. var editor = data.editor;
  3541. return this.$handlers.map(function(h) {
  3542. return h.getStatusText && h.getStatusText(editor, data) || "";
  3543. }).filter(Boolean).join(" ");
  3544. };
  3545. this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
  3546. var toExecute;
  3547. var success = false;
  3548. var commands = this.$editor.commands;
  3549. for (var i = this.$handlers.length; i--;) {
  3550. toExecute = this.$handlers[i].handleKeyboard(
  3551. this.$data, hashId, keyString, keyCode, e
  3552. );
  3553. if (!toExecute || !toExecute.command)
  3554. continue;
  3555. if (toExecute.command == "null") {
  3556. success = true;
  3557. } else {
  3558. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3559. }
  3560. if (success && e && hashId != -1 &&
  3561. toExecute.passEvent != true && toExecute.command.passEvent != true
  3562. ) {
  3563. event.stopEvent(e);
  3564. }
  3565. if (success)
  3566. break;
  3567. }
  3568. if (!success && hashId == -1) {
  3569. toExecute = {command: "insertstring"};
  3570. success = commands.exec("insertstring", this.$editor, keyString);
  3571. }
  3572. if (success)
  3573. this.$editor._signal("keyboardActivity", toExecute);
  3574. return success;
  3575. };
  3576. this.onCommandKey = function(e, hashId, keyCode) {
  3577. var keyString = keyUtil.keyCodeToString(keyCode);
  3578. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3579. };
  3580. this.onTextInput = function(text) {
  3581. this.$callKeyboardHandlers(-1, text);
  3582. };
  3583. }).call(KeyBinding.prototype);
  3584. exports.KeyBinding = KeyBinding;
  3585. });
  3586. ace.define("ace/range",["require","exports","module"], function(require, exports, module) {
  3587. "use strict";
  3588. var comparePoints = function(p1, p2) {
  3589. return p1.row - p2.row || p1.column - p2.column;
  3590. };
  3591. var Range = function(startRow, startColumn, endRow, endColumn) {
  3592. this.start = {
  3593. row: startRow,
  3594. column: startColumn
  3595. };
  3596. this.end = {
  3597. row: endRow,
  3598. column: endColumn
  3599. };
  3600. };
  3601. (function() {
  3602. this.isEqual = function(range) {
  3603. return this.start.row === range.start.row &&
  3604. this.end.row === range.end.row &&
  3605. this.start.column === range.start.column &&
  3606. this.end.column === range.end.column;
  3607. };
  3608. this.toString = function() {
  3609. return ("Range: [" + this.start.row + "/" + this.start.column +
  3610. "] -> [" + this.end.row + "/" + this.end.column + "]");
  3611. };
  3612. this.contains = function(row, column) {
  3613. return this.compare(row, column) == 0;
  3614. };
  3615. this.compareRange = function(range) {
  3616. var cmp,
  3617. end = range.end,
  3618. start = range.start;
  3619. cmp = this.compare(end.row, end.column);
  3620. if (cmp == 1) {
  3621. cmp = this.compare(start.row, start.column);
  3622. if (cmp == 1) {
  3623. return 2;
  3624. } else if (cmp == 0) {
  3625. return 1;
  3626. } else {
  3627. return 0;
  3628. }
  3629. } else if (cmp == -1) {
  3630. return -2;
  3631. } else {
  3632. cmp = this.compare(start.row, start.column);
  3633. if (cmp == -1) {
  3634. return -1;
  3635. } else if (cmp == 1) {
  3636. return 42;
  3637. } else {
  3638. return 0;
  3639. }
  3640. }
  3641. };
  3642. this.comparePoint = function(p) {
  3643. return this.compare(p.row, p.column);
  3644. };
  3645. this.containsRange = function(range) {
  3646. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  3647. };
  3648. this.intersects = function(range) {
  3649. var cmp = this.compareRange(range);
  3650. return (cmp == -1 || cmp == 0 || cmp == 1);
  3651. };
  3652. this.isEnd = function(row, column) {
  3653. return this.end.row == row && this.end.column == column;
  3654. };
  3655. this.isStart = function(row, column) {
  3656. return this.start.row == row && this.start.column == column;
  3657. };
  3658. this.setStart = function(row, column) {
  3659. if (typeof row == "object") {
  3660. this.start.column = row.column;
  3661. this.start.row = row.row;
  3662. } else {
  3663. this.start.row = row;
  3664. this.start.column = column;
  3665. }
  3666. };
  3667. this.setEnd = function(row, column) {
  3668. if (typeof row == "object") {
  3669. this.end.column = row.column;
  3670. this.end.row = row.row;
  3671. } else {
  3672. this.end.row = row;
  3673. this.end.column = column;
  3674. }
  3675. };
  3676. this.inside = function(row, column) {
  3677. if (this.compare(row, column) == 0) {
  3678. if (this.isEnd(row, column) || this.isStart(row, column)) {
  3679. return false;
  3680. } else {
  3681. return true;
  3682. }
  3683. }
  3684. return false;
  3685. };
  3686. this.insideStart = function(row, column) {
  3687. if (this.compare(row, column) == 0) {
  3688. if (this.isEnd(row, column)) {
  3689. return false;
  3690. } else {
  3691. return true;
  3692. }
  3693. }
  3694. return false;
  3695. };
  3696. this.insideEnd = function(row, column) {
  3697. if (this.compare(row, column) == 0) {
  3698. if (this.isStart(row, column)) {
  3699. return false;
  3700. } else {
  3701. return true;
  3702. }
  3703. }
  3704. return false;
  3705. };
  3706. this.compare = function(row, column) {
  3707. if (!this.isMultiLine()) {
  3708. if (row === this.start.row) {
  3709. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  3710. }
  3711. }
  3712. if (row < this.start.row)
  3713. return -1;
  3714. if (row > this.end.row)
  3715. return 1;
  3716. if (this.start.row === row)
  3717. return column >= this.start.column ? 0 : -1;
  3718. if (this.end.row === row)
  3719. return column <= this.end.column ? 0 : 1;
  3720. return 0;
  3721. };
  3722. this.compareStart = function(row, column) {
  3723. if (this.start.row == row && this.start.column == column) {
  3724. return -1;
  3725. } else {
  3726. return this.compare(row, column);
  3727. }
  3728. };
  3729. this.compareEnd = function(row, column) {
  3730. if (this.end.row == row && this.end.column == column) {
  3731. return 1;
  3732. } else {
  3733. return this.compare(row, column);
  3734. }
  3735. };
  3736. this.compareInside = function(row, column) {
  3737. if (this.end.row == row && this.end.column == column) {
  3738. return 1;
  3739. } else if (this.start.row == row && this.start.column == column) {
  3740. return -1;
  3741. } else {
  3742. return this.compare(row, column);
  3743. }
  3744. };
  3745. this.clipRows = function(firstRow, lastRow) {
  3746. if (this.end.row > lastRow)
  3747. var end = {row: lastRow + 1, column: 0};
  3748. else if (this.end.row < firstRow)
  3749. var end = {row: firstRow, column: 0};
  3750. if (this.start.row > lastRow)
  3751. var start = {row: lastRow + 1, column: 0};
  3752. else if (this.start.row < firstRow)
  3753. var start = {row: firstRow, column: 0};
  3754. return Range.fromPoints(start || this.start, end || this.end);
  3755. };
  3756. this.extend = function(row, column) {
  3757. var cmp = this.compare(row, column);
  3758. if (cmp == 0)
  3759. return this;
  3760. else if (cmp == -1)
  3761. var start = {row: row, column: column};
  3762. else
  3763. var end = {row: row, column: column};
  3764. return Range.fromPoints(start || this.start, end || this.end);
  3765. };
  3766. this.isEmpty = function() {
  3767. return (this.start.row === this.end.row && this.start.column === this.end.column);
  3768. };
  3769. this.isMultiLine = function() {
  3770. return (this.start.row !== this.end.row);
  3771. };
  3772. this.clone = function() {
  3773. return Range.fromPoints(this.start, this.end);
  3774. };
  3775. this.collapseRows = function() {
  3776. if (this.end.column == 0)
  3777. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  3778. else
  3779. return new Range(this.start.row, 0, this.end.row, 0)
  3780. };
  3781. this.toScreenRange = function(session) {
  3782. var screenPosStart = session.documentToScreenPosition(this.start);
  3783. var screenPosEnd = session.documentToScreenPosition(this.end);
  3784. return new Range(
  3785. screenPosStart.row, screenPosStart.column,
  3786. screenPosEnd.row, screenPosEnd.column
  3787. );
  3788. };
  3789. this.moveBy = function(row, column) {
  3790. this.start.row += row;
  3791. this.start.column += column;
  3792. this.end.row += row;
  3793. this.end.column += column;
  3794. };
  3795. }).call(Range.prototype);
  3796. Range.fromPoints = function(start, end) {
  3797. return new Range(start.row, start.column, end.row, end.column);
  3798. };
  3799. Range.comparePoints = comparePoints;
  3800. Range.comparePoints = function(p1, p2) {
  3801. return p1.row - p2.row || p1.column - p2.column;
  3802. };
  3803. exports.Range = Range;
  3804. });
  3805. ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
  3806. "use strict";
  3807. var oop = require("./lib/oop");
  3808. var lang = require("./lib/lang");
  3809. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  3810. var Range = require("./range").Range;
  3811. var Selection = function(session) {
  3812. this.session = session;
  3813. this.doc = session.getDocument();
  3814. this.clearSelection();
  3815. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  3816. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  3817. var self = this;
  3818. this.lead.on("change", function(e) {
  3819. self._emit("changeCursor");
  3820. if (!self.$isEmpty)
  3821. self._emit("changeSelection");
  3822. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  3823. self.$desiredColumn = null;
  3824. });
  3825. this.selectionAnchor.on("change", function() {
  3826. if (!self.$isEmpty)
  3827. self._emit("changeSelection");
  3828. });
  3829. };
  3830. (function() {
  3831. oop.implement(this, EventEmitter);
  3832. this.isEmpty = function() {
  3833. return (this.$isEmpty || (
  3834. this.anchor.row == this.lead.row &&
  3835. this.anchor.column == this.lead.column
  3836. ));
  3837. };
  3838. this.isMultiLine = function() {
  3839. if (this.isEmpty()) {
  3840. return false;
  3841. }
  3842. return this.getRange().isMultiLine();
  3843. };
  3844. this.getCursor = function() {
  3845. return this.lead.getPosition();
  3846. };
  3847. this.setSelectionAnchor = function(row, column) {
  3848. this.anchor.setPosition(row, column);
  3849. if (this.$isEmpty) {
  3850. this.$isEmpty = false;
  3851. this._emit("changeSelection");
  3852. }
  3853. };
  3854. this.getSelectionAnchor = function() {
  3855. if (this.$isEmpty)
  3856. return this.getSelectionLead();
  3857. else
  3858. return this.anchor.getPosition();
  3859. };
  3860. this.getSelectionLead = function() {
  3861. return this.lead.getPosition();
  3862. };
  3863. this.shiftSelection = function(columns) {
  3864. if (this.$isEmpty) {
  3865. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  3866. return;
  3867. }
  3868. var anchor = this.getSelectionAnchor();
  3869. var lead = this.getSelectionLead();
  3870. var isBackwards = this.isBackwards();
  3871. if (!isBackwards || anchor.column !== 0)
  3872. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  3873. if (isBackwards || lead.column !== 0) {
  3874. this.$moveSelection(function() {
  3875. this.moveCursorTo(lead.row, lead.column + columns);
  3876. });
  3877. }
  3878. };
  3879. this.isBackwards = function() {
  3880. var anchor = this.anchor;
  3881. var lead = this.lead;
  3882. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  3883. };
  3884. this.getRange = function() {
  3885. var anchor = this.anchor;
  3886. var lead = this.lead;
  3887. if (this.isEmpty())
  3888. return Range.fromPoints(lead, lead);
  3889. if (this.isBackwards()) {
  3890. return Range.fromPoints(lead, anchor);
  3891. }
  3892. else {
  3893. return Range.fromPoints(anchor, lead);
  3894. }
  3895. };
  3896. this.clearSelection = function() {
  3897. if (!this.$isEmpty) {
  3898. this.$isEmpty = true;
  3899. this._emit("changeSelection");
  3900. }
  3901. };
  3902. this.selectAll = function() {
  3903. var lastRow = this.doc.getLength() - 1;
  3904. this.setSelectionAnchor(0, 0);
  3905. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  3906. };
  3907. this.setRange =
  3908. this.setSelectionRange = function(range, reverse) {
  3909. if (reverse) {
  3910. this.setSelectionAnchor(range.end.row, range.end.column);
  3911. this.selectTo(range.start.row, range.start.column);
  3912. } else {
  3913. this.setSelectionAnchor(range.start.row, range.start.column);
  3914. this.selectTo(range.end.row, range.end.column);
  3915. }
  3916. if (this.getRange().isEmpty())
  3917. this.$isEmpty = true;
  3918. this.$desiredColumn = null;
  3919. };
  3920. this.$moveSelection = function(mover) {
  3921. var lead = this.lead;
  3922. if (this.$isEmpty)
  3923. this.setSelectionAnchor(lead.row, lead.column);
  3924. mover.call(this);
  3925. };
  3926. this.selectTo = function(row, column) {
  3927. this.$moveSelection(function() {
  3928. this.moveCursorTo(row, column);
  3929. });
  3930. };
  3931. this.selectToPosition = function(pos) {
  3932. this.$moveSelection(function() {
  3933. this.moveCursorToPosition(pos);
  3934. });
  3935. };
  3936. this.moveTo = function(row, column) {
  3937. this.clearSelection();
  3938. this.moveCursorTo(row, column);
  3939. };
  3940. this.moveToPosition = function(pos) {
  3941. this.clearSelection();
  3942. this.moveCursorToPosition(pos);
  3943. };
  3944. this.selectUp = function() {
  3945. this.$moveSelection(this.moveCursorUp);
  3946. };
  3947. this.selectDown = function() {
  3948. this.$moveSelection(this.moveCursorDown);
  3949. };
  3950. this.selectRight = function() {
  3951. this.$moveSelection(this.moveCursorRight);
  3952. };
  3953. this.selectLeft = function() {
  3954. this.$moveSelection(this.moveCursorLeft);
  3955. };
  3956. this.selectLineStart = function() {
  3957. this.$moveSelection(this.moveCursorLineStart);
  3958. };
  3959. this.selectLineEnd = function() {
  3960. this.$moveSelection(this.moveCursorLineEnd);
  3961. };
  3962. this.selectFileEnd = function() {
  3963. this.$moveSelection(this.moveCursorFileEnd);
  3964. };
  3965. this.selectFileStart = function() {
  3966. this.$moveSelection(this.moveCursorFileStart);
  3967. };
  3968. this.selectWordRight = function() {
  3969. this.$moveSelection(this.moveCursorWordRight);
  3970. };
  3971. this.selectWordLeft = function() {
  3972. this.$moveSelection(this.moveCursorWordLeft);
  3973. };
  3974. this.getWordRange = function(row, column) {
  3975. if (typeof column == "undefined") {
  3976. var cursor = row || this.lead;
  3977. row = cursor.row;
  3978. column = cursor.column;
  3979. }
  3980. return this.session.getWordRange(row, column);
  3981. };
  3982. this.selectWord = function() {
  3983. this.setSelectionRange(this.getWordRange());
  3984. };
  3985. this.selectAWord = function() {
  3986. var cursor = this.getCursor();
  3987. var range = this.session.getAWordRange(cursor.row, cursor.column);
  3988. this.setSelectionRange(range);
  3989. };
  3990. this.getLineRange = function(row, excludeLastChar) {
  3991. var rowStart = typeof row == "number" ? row : this.lead.row;
  3992. var rowEnd;
  3993. var foldLine = this.session.getFoldLine(rowStart);
  3994. if (foldLine) {
  3995. rowStart = foldLine.start.row;
  3996. rowEnd = foldLine.end.row;
  3997. } else {
  3998. rowEnd = rowStart;
  3999. }
  4000. if (excludeLastChar === true)
  4001. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  4002. else
  4003. return new Range(rowStart, 0, rowEnd + 1, 0);
  4004. };
  4005. this.selectLine = function() {
  4006. this.setSelectionRange(this.getLineRange());
  4007. };
  4008. this.moveCursorUp = function() {
  4009. this.moveCursorBy(-1, 0);
  4010. };
  4011. this.moveCursorDown = function() {
  4012. this.moveCursorBy(1, 0);
  4013. };
  4014. this.moveCursorLeft = function() {
  4015. var cursor = this.lead.getPosition(),
  4016. fold;
  4017. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  4018. this.moveCursorTo(fold.start.row, fold.start.column);
  4019. } else if (cursor.column === 0) {
  4020. if (cursor.row > 0) {
  4021. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  4022. }
  4023. }
  4024. else {
  4025. var tabSize = this.session.getTabSize();
  4026. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
  4027. this.moveCursorBy(0, -tabSize);
  4028. else
  4029. this.moveCursorBy(0, -1);
  4030. }
  4031. };
  4032. this.moveCursorRight = function() {
  4033. var cursor = this.lead.getPosition(),
  4034. fold;
  4035. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  4036. this.moveCursorTo(fold.end.row, fold.end.column);
  4037. }
  4038. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  4039. if (this.lead.row < this.doc.getLength() - 1) {
  4040. this.moveCursorTo(this.lead.row + 1, 0);
  4041. }
  4042. }
  4043. else {
  4044. var tabSize = this.session.getTabSize();
  4045. var cursor = this.lead;
  4046. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
  4047. this.moveCursorBy(0, tabSize);
  4048. else
  4049. this.moveCursorBy(0, 1);
  4050. }
  4051. };
  4052. this.moveCursorLineStart = function() {
  4053. var row = this.lead.row;
  4054. var column = this.lead.column;
  4055. var screenRow = this.session.documentToScreenRow(row, column);
  4056. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  4057. var beforeCursor = this.session.getDisplayLine(
  4058. row, null, firstColumnPosition.row,
  4059. firstColumnPosition.column
  4060. );
  4061. var leadingSpace = beforeCursor.match(/^\s*/);
  4062. if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
  4063. firstColumnPosition.column += leadingSpace[0].length;
  4064. this.moveCursorToPosition(firstColumnPosition);
  4065. };
  4066. this.moveCursorLineEnd = function() {
  4067. var lead = this.lead;
  4068. var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  4069. if (this.lead.column == lineEnd.column) {
  4070. var line = this.session.getLine(lineEnd.row);
  4071. if (lineEnd.column == line.length) {
  4072. var textEnd = line.search(/\s+$/);
  4073. if (textEnd > 0)
  4074. lineEnd.column = textEnd;
  4075. }
  4076. }
  4077. this.moveCursorTo(lineEnd.row, lineEnd.column);
  4078. };
  4079. this.moveCursorFileEnd = function() {
  4080. var row = this.doc.getLength() - 1;
  4081. var column = this.doc.getLine(row).length;
  4082. this.moveCursorTo(row, column);
  4083. };
  4084. this.moveCursorFileStart = function() {
  4085. this.moveCursorTo(0, 0);
  4086. };
  4087. this.moveCursorLongWordRight = function() {
  4088. var row = this.lead.row;
  4089. var column = this.lead.column;
  4090. var line = this.doc.getLine(row);
  4091. var rightOfCursor = line.substring(column);
  4092. var match;
  4093. this.session.nonTokenRe.lastIndex = 0;
  4094. this.session.tokenRe.lastIndex = 0;
  4095. var fold = this.session.getFoldAt(row, column, 1);
  4096. if (fold) {
  4097. this.moveCursorTo(fold.end.row, fold.end.column);
  4098. return;
  4099. }
  4100. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  4101. column += this.session.nonTokenRe.lastIndex;
  4102. this.session.nonTokenRe.lastIndex = 0;
  4103. rightOfCursor = line.substring(column);
  4104. }
  4105. if (column >= line.length) {
  4106. this.moveCursorTo(row, line.length);
  4107. this.moveCursorRight();
  4108. if (row < this.doc.getLength() - 1)
  4109. this.moveCursorWordRight();
  4110. return;
  4111. }
  4112. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4113. column += this.session.tokenRe.lastIndex;
  4114. this.session.tokenRe.lastIndex = 0;
  4115. }
  4116. this.moveCursorTo(row, column);
  4117. };
  4118. this.moveCursorLongWordLeft = function() {
  4119. var row = this.lead.row;
  4120. var column = this.lead.column;
  4121. var fold;
  4122. if (fold = this.session.getFoldAt(row, column, -1)) {
  4123. this.moveCursorTo(fold.start.row, fold.start.column);
  4124. return;
  4125. }
  4126. var str = this.session.getFoldStringAt(row, column, -1);
  4127. if (str == null) {
  4128. str = this.doc.getLine(row).substring(0, column);
  4129. }
  4130. var leftOfCursor = lang.stringReverse(str);
  4131. var match;
  4132. this.session.nonTokenRe.lastIndex = 0;
  4133. this.session.tokenRe.lastIndex = 0;
  4134. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  4135. column -= this.session.nonTokenRe.lastIndex;
  4136. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  4137. this.session.nonTokenRe.lastIndex = 0;
  4138. }
  4139. if (column <= 0) {
  4140. this.moveCursorTo(row, 0);
  4141. this.moveCursorLeft();
  4142. if (row > 0)
  4143. this.moveCursorWordLeft();
  4144. return;
  4145. }
  4146. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  4147. column -= this.session.tokenRe.lastIndex;
  4148. this.session.tokenRe.lastIndex = 0;
  4149. }
  4150. this.moveCursorTo(row, column);
  4151. };
  4152. this.$shortWordEndIndex = function(rightOfCursor) {
  4153. var match, index = 0, ch;
  4154. var whitespaceRe = /\s/;
  4155. var tokenRe = this.session.tokenRe;
  4156. tokenRe.lastIndex = 0;
  4157. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4158. index = this.session.tokenRe.lastIndex;
  4159. } else {
  4160. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4161. index ++;
  4162. if (index < 1) {
  4163. tokenRe.lastIndex = 0;
  4164. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  4165. tokenRe.lastIndex = 0;
  4166. index ++;
  4167. if (whitespaceRe.test(ch)) {
  4168. if (index > 2) {
  4169. index--;
  4170. break;
  4171. } else {
  4172. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4173. index ++;
  4174. if (index > 2)
  4175. break;
  4176. }
  4177. }
  4178. }
  4179. }
  4180. }
  4181. tokenRe.lastIndex = 0;
  4182. return index;
  4183. };
  4184. this.moveCursorShortWordRight = function() {
  4185. var row = this.lead.row;
  4186. var column = this.lead.column;
  4187. var line = this.doc.getLine(row);
  4188. var rightOfCursor = line.substring(column);
  4189. var fold = this.session.getFoldAt(row, column, 1);
  4190. if (fold)
  4191. return this.moveCursorTo(fold.end.row, fold.end.column);
  4192. if (column == line.length) {
  4193. var l = this.doc.getLength();
  4194. do {
  4195. row++;
  4196. rightOfCursor = this.doc.getLine(row);
  4197. } while (row < l && /^\s*$/.test(rightOfCursor));
  4198. if (!/^\s+/.test(rightOfCursor))
  4199. rightOfCursor = "";
  4200. column = 0;
  4201. }
  4202. var index = this.$shortWordEndIndex(rightOfCursor);
  4203. this.moveCursorTo(row, column + index);
  4204. };
  4205. this.moveCursorShortWordLeft = function() {
  4206. var row = this.lead.row;
  4207. var column = this.lead.column;
  4208. var fold;
  4209. if (fold = this.session.getFoldAt(row, column, -1))
  4210. return this.moveCursorTo(fold.start.row, fold.start.column);
  4211. var line = this.session.getLine(row).substring(0, column);
  4212. if (column === 0) {
  4213. do {
  4214. row--;
  4215. line = this.doc.getLine(row);
  4216. } while (row > 0 && /^\s*$/.test(line));
  4217. column = line.length;
  4218. if (!/\s+$/.test(line))
  4219. line = "";
  4220. }
  4221. var leftOfCursor = lang.stringReverse(line);
  4222. var index = this.$shortWordEndIndex(leftOfCursor);
  4223. return this.moveCursorTo(row, column - index);
  4224. };
  4225. this.moveCursorWordRight = function() {
  4226. if (this.session.$selectLongWords)
  4227. this.moveCursorLongWordRight();
  4228. else
  4229. this.moveCursorShortWordRight();
  4230. };
  4231. this.moveCursorWordLeft = function() {
  4232. if (this.session.$selectLongWords)
  4233. this.moveCursorLongWordLeft();
  4234. else
  4235. this.moveCursorShortWordLeft();
  4236. };
  4237. this.moveCursorBy = function(rows, chars) {
  4238. var screenPos = this.session.documentToScreenPosition(
  4239. this.lead.row,
  4240. this.lead.column
  4241. );
  4242. if (chars === 0) {
  4243. if (this.$desiredColumn)
  4244. screenPos.column = this.$desiredColumn;
  4245. else
  4246. this.$desiredColumn = screenPos.column;
  4247. }
  4248. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
  4249. if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
  4250. if (this.session.lineWidgets && this.session.lineWidgets[docPos.row]) {
  4251. if (docPos.row > 0 || rows > 0)
  4252. docPos.row++;
  4253. }
  4254. }
  4255. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  4256. };
  4257. this.moveCursorToPosition = function(position) {
  4258. this.moveCursorTo(position.row, position.column);
  4259. };
  4260. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  4261. var fold = this.session.getFoldAt(row, column, 1);
  4262. if (fold) {
  4263. row = fold.start.row;
  4264. column = fold.start.column;
  4265. }
  4266. this.$keepDesiredColumnOnChange = true;
  4267. this.lead.setPosition(row, column);
  4268. this.$keepDesiredColumnOnChange = false;
  4269. if (!keepDesiredColumn)
  4270. this.$desiredColumn = null;
  4271. };
  4272. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  4273. var pos = this.session.screenToDocumentPosition(row, column);
  4274. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  4275. };
  4276. this.detach = function() {
  4277. this.lead.detach();
  4278. this.anchor.detach();
  4279. this.session = this.doc = null;
  4280. };
  4281. this.fromOrientedRange = function(range) {
  4282. this.setSelectionRange(range, range.cursor == range.start);
  4283. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  4284. };
  4285. this.toOrientedRange = function(range) {
  4286. var r = this.getRange();
  4287. if (range) {
  4288. range.start.column = r.start.column;
  4289. range.start.row = r.start.row;
  4290. range.end.column = r.end.column;
  4291. range.end.row = r.end.row;
  4292. } else {
  4293. range = r;
  4294. }
  4295. range.cursor = this.isBackwards() ? range.start : range.end;
  4296. range.desiredColumn = this.$desiredColumn;
  4297. return range;
  4298. };
  4299. this.getRangeOfMovements = function(func) {
  4300. var start = this.getCursor();
  4301. try {
  4302. func(this);
  4303. var end = this.getCursor();
  4304. return Range.fromPoints(start,end);
  4305. } catch(e) {
  4306. return Range.fromPoints(start,start);
  4307. } finally {
  4308. this.moveCursorToPosition(start);
  4309. }
  4310. };
  4311. this.toJSON = function() {
  4312. if (this.rangeCount) {
  4313. var data = this.ranges.map(function(r) {
  4314. var r1 = r.clone();
  4315. r1.isBackwards = r.cursor == r.start;
  4316. return r1;
  4317. });
  4318. } else {
  4319. var data = this.getRange();
  4320. data.isBackwards = this.isBackwards();
  4321. }
  4322. return data;
  4323. };
  4324. this.fromJSON = function(data) {
  4325. if (data.start == undefined) {
  4326. if (this.rangeList) {
  4327. this.toSingleRange(data[0]);
  4328. for (var i = data.length; i--; ) {
  4329. var r = Range.fromPoints(data[i].start, data[i].end);
  4330. if (data[i].isBackwards)
  4331. r.cursor = r.start;
  4332. this.addRange(r, true);
  4333. }
  4334. return;
  4335. } else
  4336. data = data[0];
  4337. }
  4338. if (this.rangeList)
  4339. this.toSingleRange(data);
  4340. this.setSelectionRange(data, data.isBackwards);
  4341. };
  4342. this.isEqual = function(data) {
  4343. if ((data.length || this.rangeCount) && data.length != this.rangeCount)
  4344. return false;
  4345. if (!data.length || !this.ranges)
  4346. return this.getRange().isEqual(data);
  4347. for (var i = this.ranges.length; i--; ) {
  4348. if (!this.ranges[i].isEqual(data[i]))
  4349. return false;
  4350. }
  4351. return true;
  4352. };
  4353. }).call(Selection.prototype);
  4354. exports.Selection = Selection;
  4355. });
  4356. ace.define("ace/tokenizer",["require","exports","module","ace/config"], function(require, exports, module) {
  4357. "use strict";
  4358. var config = require("./config");
  4359. var MAX_TOKEN_COUNT = 2000;
  4360. var Tokenizer = function(rules) {
  4361. this.states = rules;
  4362. this.regExps = {};
  4363. this.matchMappings = {};
  4364. for (var key in this.states) {
  4365. var state = this.states[key];
  4366. var ruleRegExps = [];
  4367. var matchTotal = 0;
  4368. var mapping = this.matchMappings[key] = {defaultToken: "text"};
  4369. var flag = "g";
  4370. var splitterRurles = [];
  4371. for (var i = 0; i < state.length; i++) {
  4372. var rule = state[i];
  4373. if (rule.defaultToken)
  4374. mapping.defaultToken = rule.defaultToken;
  4375. if (rule.caseInsensitive)
  4376. flag = "gi";
  4377. if (rule.regex == null)
  4378. continue;
  4379. if (rule.regex instanceof RegExp)
  4380. rule.regex = rule.regex.toString().slice(1, -1);
  4381. var adjustedregex = rule.regex;
  4382. var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
  4383. if (Array.isArray(rule.token)) {
  4384. if (rule.token.length == 1 || matchcount == 1) {
  4385. rule.token = rule.token[0];
  4386. } else if (matchcount - 1 != rule.token.length) {
  4387. this.reportError("number of classes and regexp groups doesn't match", {
  4388. rule: rule,
  4389. groupCount: matchcount - 1
  4390. });
  4391. rule.token = rule.token[0];
  4392. } else {
  4393. rule.tokenArray = rule.token;
  4394. rule.token = null;
  4395. rule.onMatch = this.$arrayTokens;
  4396. }
  4397. } else if (typeof rule.token == "function" && !rule.onMatch) {
  4398. if (matchcount > 1)
  4399. rule.onMatch = this.$applyToken;
  4400. else
  4401. rule.onMatch = rule.token;
  4402. }
  4403. if (matchcount > 1) {
  4404. if (/\\\d/.test(rule.regex)) {
  4405. adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
  4406. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  4407. });
  4408. } else {
  4409. matchcount = 1;
  4410. adjustedregex = this.removeCapturingGroups(rule.regex);
  4411. }
  4412. if (!rule.splitRegex && typeof rule.token != "string")
  4413. splitterRurles.push(rule); // flag will be known only at the very end
  4414. }
  4415. mapping[matchTotal] = i;
  4416. matchTotal += matchcount;
  4417. ruleRegExps.push(adjustedregex);
  4418. if (!rule.onMatch)
  4419. rule.onMatch = null;
  4420. }
  4421. if (!ruleRegExps.length) {
  4422. mapping[0] = 0;
  4423. ruleRegExps.push("$");
  4424. }
  4425. splitterRurles.forEach(function(rule) {
  4426. rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
  4427. }, this);
  4428. this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
  4429. }
  4430. };
  4431. (function() {
  4432. this.$setMaxTokenCount = function(m) {
  4433. MAX_TOKEN_COUNT = m | 0;
  4434. };
  4435. this.$applyToken = function(str) {
  4436. var values = this.splitRegex.exec(str).slice(1);
  4437. var types = this.token.apply(this, values);
  4438. if (typeof types === "string")
  4439. return [{type: types, value: str}];
  4440. var tokens = [];
  4441. for (var i = 0, l = types.length; i < l; i++) {
  4442. if (values[i])
  4443. tokens[tokens.length] = {
  4444. type: types[i],
  4445. value: values[i]
  4446. };
  4447. }
  4448. return tokens;
  4449. };
  4450. this.$arrayTokens = function(str) {
  4451. if (!str)
  4452. return [];
  4453. var values = this.splitRegex.exec(str);
  4454. if (!values)
  4455. return "text";
  4456. var tokens = [];
  4457. var types = this.tokenArray;
  4458. for (var i = 0, l = types.length; i < l; i++) {
  4459. if (values[i + 1])
  4460. tokens[tokens.length] = {
  4461. type: types[i],
  4462. value: values[i + 1]
  4463. };
  4464. }
  4465. return tokens;
  4466. };
  4467. this.removeCapturingGroups = function(src) {
  4468. var r = src.replace(
  4469. /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
  4470. function(x, y) {return y ? "(?:" : x;}
  4471. );
  4472. return r;
  4473. };
  4474. this.createSplitterRegexp = function(src, flag) {
  4475. if (src.indexOf("(?=") != -1) {
  4476. var stack = 0;
  4477. var inChClass = false;
  4478. var lastCapture = {};
  4479. src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
  4480. m, esc, parenOpen, parenClose, square, index
  4481. ) {
  4482. if (inChClass) {
  4483. inChClass = square != "]";
  4484. } else if (square) {
  4485. inChClass = true;
  4486. } else if (parenClose) {
  4487. if (stack == lastCapture.stack) {
  4488. lastCapture.end = index+1;
  4489. lastCapture.stack = -1;
  4490. }
  4491. stack--;
  4492. } else if (parenOpen) {
  4493. stack++;
  4494. if (parenOpen.length != 1) {
  4495. lastCapture.stack = stack
  4496. lastCapture.start = index;
  4497. }
  4498. }
  4499. return m;
  4500. });
  4501. if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
  4502. src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
  4503. }
  4504. if (src.charAt(0) != "^") src = "^" + src;
  4505. if (src.charAt(src.length - 1) != "$") src += "$";
  4506. return new RegExp(src, (flag||"").replace("g", ""));
  4507. };
  4508. this.getLineTokens = function(line, startState) {
  4509. if (startState && typeof startState != "string") {
  4510. var stack = startState.slice(0);
  4511. startState = stack[0];
  4512. if (startState === "#tmp") {
  4513. stack.shift()
  4514. startState = stack.shift()
  4515. }
  4516. } else
  4517. var stack = [];
  4518. var currentState = startState || "start";
  4519. var state = this.states[currentState];
  4520. if (!state) {
  4521. currentState = "start";
  4522. state = this.states[currentState];
  4523. }
  4524. var mapping = this.matchMappings[currentState];
  4525. var re = this.regExps[currentState];
  4526. re.lastIndex = 0;
  4527. var match, tokens = [];
  4528. var lastIndex = 0;
  4529. var matchAttempts = 0;
  4530. var token = {type: null, value: ""};
  4531. while (match = re.exec(line)) {
  4532. var type = mapping.defaultToken;
  4533. var rule = null;
  4534. var value = match[0];
  4535. var index = re.lastIndex;
  4536. if (index - value.length > lastIndex) {
  4537. var skipped = line.substring(lastIndex, index - value.length);
  4538. if (token.type == type) {
  4539. token.value += skipped;
  4540. } else {
  4541. if (token.type)
  4542. tokens.push(token);
  4543. token = {type: type, value: skipped};
  4544. }
  4545. }
  4546. for (var i = 0; i < match.length-2; i++) {
  4547. if (match[i + 1] === undefined)
  4548. continue;
  4549. rule = state[mapping[i]];
  4550. if (rule.onMatch)
  4551. type = rule.onMatch(value, currentState, stack);
  4552. else
  4553. type = rule.token;
  4554. if (rule.next) {
  4555. if (typeof rule.next == "string") {
  4556. currentState = rule.next;
  4557. } else {
  4558. currentState = rule.next(currentState, stack);
  4559. }
  4560. state = this.states[currentState];
  4561. if (!state) {
  4562. this.reportError("state doesn't exist", currentState);
  4563. currentState = "start";
  4564. state = this.states[currentState];
  4565. }
  4566. mapping = this.matchMappings[currentState];
  4567. lastIndex = index;
  4568. re = this.regExps[currentState];
  4569. re.lastIndex = index;
  4570. }
  4571. break;
  4572. }
  4573. if (value) {
  4574. if (typeof type === "string") {
  4575. if ((!rule || rule.merge !== false) && token.type === type) {
  4576. token.value += value;
  4577. } else {
  4578. if (token.type)
  4579. tokens.push(token);
  4580. token = {type: type, value: value};
  4581. }
  4582. } else if (type) {
  4583. if (token.type)
  4584. tokens.push(token);
  4585. token = {type: null, value: ""};
  4586. for (var i = 0; i < type.length; i++)
  4587. tokens.push(type[i]);
  4588. }
  4589. }
  4590. if (lastIndex == line.length)
  4591. break;
  4592. lastIndex = index;
  4593. if (matchAttempts++ > MAX_TOKEN_COUNT) {
  4594. if (matchAttempts > 2 * line.length) {
  4595. this.reportError("infinite loop with in ace tokenizer", {
  4596. startState: startState,
  4597. line: line
  4598. });
  4599. }
  4600. while (lastIndex < line.length) {
  4601. if (token.type)
  4602. tokens.push(token);
  4603. token = {
  4604. value: line.substring(lastIndex, lastIndex += 2000),
  4605. type: "overflow"
  4606. };
  4607. }
  4608. currentState = "start";
  4609. stack = [];
  4610. break;
  4611. }
  4612. }
  4613. if (token.type)
  4614. tokens.push(token);
  4615. if (stack.length > 1) {
  4616. if (stack[0] !== currentState)
  4617. stack.unshift("#tmp", currentState);
  4618. }
  4619. return {
  4620. tokens : tokens,
  4621. state : stack.length ? stack : currentState
  4622. };
  4623. };
  4624. this.reportError = config.reportError;
  4625. }).call(Tokenizer.prototype);
  4626. exports.Tokenizer = Tokenizer;
  4627. });
  4628. ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
  4629. "use strict";
  4630. var lang = require("../lib/lang");
  4631. var TextHighlightRules = function() {
  4632. this.$rules = {
  4633. "start" : [{
  4634. token : "empty_line",
  4635. regex : '^$'
  4636. }, {
  4637. defaultToken : "text"
  4638. }]
  4639. };
  4640. };
  4641. (function() {
  4642. this.addRules = function(rules, prefix) {
  4643. if (!prefix) {
  4644. for (var key in rules)
  4645. this.$rules[key] = rules[key];
  4646. return;
  4647. }
  4648. for (var key in rules) {
  4649. var state = rules[key];
  4650. for (var i = 0; i < state.length; i++) {
  4651. var rule = state[i];
  4652. if (rule.next || rule.onMatch) {
  4653. if (typeof rule.next == "string") {
  4654. if (rule.next.indexOf(prefix) !== 0)
  4655. rule.next = prefix + rule.next;
  4656. }
  4657. if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
  4658. rule.nextState = prefix + rule.nextState;
  4659. }
  4660. }
  4661. this.$rules[prefix + key] = state;
  4662. }
  4663. };
  4664. this.getRules = function() {
  4665. return this.$rules;
  4666. };
  4667. this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
  4668. var embedRules = typeof HighlightRules == "function"
  4669. ? new HighlightRules().getRules()
  4670. : HighlightRules;
  4671. if (states) {
  4672. for (var i = 0; i < states.length; i++)
  4673. states[i] = prefix + states[i];
  4674. } else {
  4675. states = [];
  4676. for (var key in embedRules)
  4677. states.push(prefix + key);
  4678. }
  4679. this.addRules(embedRules, prefix);
  4680. if (escapeRules) {
  4681. var addRules = Array.prototype[append ? "push" : "unshift"];
  4682. for (var i = 0; i < states.length; i++)
  4683. addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  4684. }
  4685. if (!this.$embeds)
  4686. this.$embeds = [];
  4687. this.$embeds.push(prefix);
  4688. };
  4689. this.getEmbeds = function() {
  4690. return this.$embeds;
  4691. };
  4692. var pushState = function(currentState, stack) {
  4693. if (currentState != "start" || stack.length)
  4694. stack.unshift(this.nextState, currentState);
  4695. return this.nextState;
  4696. };
  4697. var popState = function(currentState, stack) {
  4698. stack.shift();
  4699. return stack.shift() || "start";
  4700. };
  4701. this.normalizeRules = function() {
  4702. var id = 0;
  4703. var rules = this.$rules;
  4704. function processState(key) {
  4705. var state = rules[key];
  4706. state.processed = true;
  4707. for (var i = 0; i < state.length; i++) {
  4708. var rule = state[i];
  4709. if (!rule.regex && rule.start) {
  4710. rule.regex = rule.start;
  4711. if (!rule.next)
  4712. rule.next = [];
  4713. rule.next.push({
  4714. defaultToken: rule.token
  4715. }, {
  4716. token: rule.token + ".end",
  4717. regex: rule.end || rule.start,
  4718. next: "pop"
  4719. });
  4720. rule.token = rule.token + ".start";
  4721. rule.push = true;
  4722. }
  4723. var next = rule.next || rule.push;
  4724. if (next && Array.isArray(next)) {
  4725. var stateName = rule.stateName;
  4726. if (!stateName) {
  4727. stateName = rule.token;
  4728. if (typeof stateName != "string")
  4729. stateName = stateName[0] || "";
  4730. if (rules[stateName])
  4731. stateName += id++;
  4732. }
  4733. rules[stateName] = next;
  4734. rule.next = stateName;
  4735. processState(stateName);
  4736. } else if (next == "pop") {
  4737. rule.next = popState;
  4738. }
  4739. if (rule.push) {
  4740. rule.nextState = rule.next || rule.push;
  4741. rule.next = pushState;
  4742. delete rule.push;
  4743. }
  4744. if (rule.rules) {
  4745. for (var r in rule.rules) {
  4746. if (rules[r]) {
  4747. if (rules[r].push)
  4748. rules[r].push.apply(rules[r], rule.rules[r]);
  4749. } else {
  4750. rules[r] = rule.rules[r];
  4751. }
  4752. }
  4753. }
  4754. if (rule.include || typeof rule == "string") {
  4755. var includeName = rule.include || rule;
  4756. var toInsert = rules[includeName];
  4757. } else if (Array.isArray(rule))
  4758. toInsert = rule;
  4759. if (toInsert) {
  4760. var args = [i, 1].concat(toInsert);
  4761. if (rule.noEscape)
  4762. args = args.filter(function(x) {return !x.next;});
  4763. state.splice.apply(state, args);
  4764. i--;
  4765. toInsert = null;
  4766. }
  4767. if (rule.keywordMap) {
  4768. rule.token = this.createKeywordMapper(
  4769. rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
  4770. );
  4771. delete rule.defaultToken;
  4772. }
  4773. }
  4774. }
  4775. Object.keys(rules).forEach(processState, this);
  4776. };
  4777. this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
  4778. var keywords = Object.create(null);
  4779. Object.keys(map).forEach(function(className) {
  4780. var a = map[className];
  4781. if (ignoreCase)
  4782. a = a.toLowerCase();
  4783. var list = a.split(splitChar || "|");
  4784. for (var i = list.length; i--; )
  4785. keywords[list[i]] = className;
  4786. });
  4787. if (Object.getPrototypeOf(keywords)) {
  4788. keywords.__proto__ = null;
  4789. }
  4790. this.$keywordList = Object.keys(keywords);
  4791. map = null;
  4792. return ignoreCase
  4793. ? function(value) {return keywords[value.toLowerCase()] || defaultToken }
  4794. : function(value) {return keywords[value] || defaultToken };
  4795. };
  4796. this.getKeywords = function() {
  4797. return this.$keywords;
  4798. };
  4799. }).call(TextHighlightRules.prototype);
  4800. exports.TextHighlightRules = TextHighlightRules;
  4801. });
  4802. ace.define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
  4803. "use strict";
  4804. var Behaviour = function() {
  4805. this.$behaviours = {};
  4806. };
  4807. (function () {
  4808. this.add = function (name, action, callback) {
  4809. switch (undefined) {
  4810. case this.$behaviours:
  4811. this.$behaviours = {};
  4812. case this.$behaviours[name]:
  4813. this.$behaviours[name] = {};
  4814. }
  4815. this.$behaviours[name][action] = callback;
  4816. }
  4817. this.addBehaviours = function (behaviours) {
  4818. for (var key in behaviours) {
  4819. for (var action in behaviours[key]) {
  4820. this.add(key, action, behaviours[key][action]);
  4821. }
  4822. }
  4823. }
  4824. this.remove = function (name) {
  4825. if (this.$behaviours && this.$behaviours[name]) {
  4826. delete this.$behaviours[name];
  4827. }
  4828. }
  4829. this.inherit = function (mode, filter) {
  4830. if (typeof mode === "function") {
  4831. var behaviours = new mode().getBehaviours(filter);
  4832. } else {
  4833. var behaviours = mode.getBehaviours(filter);
  4834. }
  4835. this.addBehaviours(behaviours);
  4836. }
  4837. this.getBehaviours = function (filter) {
  4838. if (!filter) {
  4839. return this.$behaviours;
  4840. } else {
  4841. var ret = {}
  4842. for (var i = 0; i < filter.length; i++) {
  4843. if (this.$behaviours[filter[i]]) {
  4844. ret[filter[i]] = this.$behaviours[filter[i]];
  4845. }
  4846. }
  4847. return ret;
  4848. }
  4849. }
  4850. }).call(Behaviour.prototype);
  4851. exports.Behaviour = Behaviour;
  4852. });
  4853. ace.define("ace/unicode",["require","exports","module"], function(require, exports, module) {
  4854. "use strict";
  4855. exports.packages = {};
  4856. addUnicodePackage({
  4857. 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",
  4858. 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",
  4859. 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",
  4860. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  4861. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  4862. 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",
  4863. 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",
  4864. 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",
  4865. 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",
  4866. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  4867. 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",
  4868. 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",
  4869. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  4870. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  4871. 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",
  4872. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  4873. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  4874. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  4875. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  4876. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  4877. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  4878. 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",
  4879. 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",
  4880. 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",
  4881. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  4882. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  4883. 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",
  4884. Z: "002000A01680180E2000-200A20282029202F205F3000",
  4885. Zs: "002000A01680180E2000-200A202F205F3000",
  4886. Zl: "2028",
  4887. Zp: "2029",
  4888. 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",
  4889. Cc: "0000-001F007F-009F",
  4890. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  4891. Co: "E000-F8FF",
  4892. Cs: "D800-DFFF",
  4893. 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"
  4894. });
  4895. function addUnicodePackage (pack) {
  4896. var codePoint = /\w{4}/g;
  4897. for (var name in pack)
  4898. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  4899. }
  4900. });
  4901. ace.define("ace/token_iterator",["require","exports","module"], function(require, exports, module) {
  4902. "use strict";
  4903. var TokenIterator = function(session, initialRow, initialColumn) {
  4904. this.$session = session;
  4905. this.$row = initialRow;
  4906. this.$rowTokens = session.getTokens(initialRow);
  4907. var token = session.getTokenAt(initialRow, initialColumn);
  4908. this.$tokenIndex = token ? token.index : -1;
  4909. };
  4910. (function() {
  4911. this.stepBackward = function() {
  4912. this.$tokenIndex -= 1;
  4913. while (this.$tokenIndex < 0) {
  4914. this.$row -= 1;
  4915. if (this.$row < 0) {
  4916. this.$row = 0;
  4917. return null;
  4918. }
  4919. this.$rowTokens = this.$session.getTokens(this.$row);
  4920. this.$tokenIndex = this.$rowTokens.length - 1;
  4921. }
  4922. return this.$rowTokens[this.$tokenIndex];
  4923. };
  4924. this.stepForward = function() {
  4925. this.$tokenIndex += 1;
  4926. var rowCount;
  4927. while (this.$tokenIndex >= this.$rowTokens.length) {
  4928. this.$row += 1;
  4929. if (!rowCount)
  4930. rowCount = this.$session.getLength();
  4931. if (this.$row >= rowCount) {
  4932. this.$row = rowCount - 1;
  4933. return null;
  4934. }
  4935. this.$rowTokens = this.$session.getTokens(this.$row);
  4936. this.$tokenIndex = 0;
  4937. }
  4938. return this.$rowTokens[this.$tokenIndex];
  4939. };
  4940. this.getCurrentToken = function () {
  4941. return this.$rowTokens[this.$tokenIndex];
  4942. };
  4943. this.getCurrentTokenRow = function () {
  4944. return this.$row;
  4945. };
  4946. this.getCurrentTokenColumn = function() {
  4947. var rowTokens = this.$rowTokens;
  4948. var tokenIndex = this.$tokenIndex;
  4949. var column = rowTokens[tokenIndex].start;
  4950. if (column !== undefined)
  4951. return column;
  4952. column = 0;
  4953. while (tokenIndex > 0) {
  4954. tokenIndex -= 1;
  4955. column += rowTokens[tokenIndex].value.length;
  4956. }
  4957. return column;
  4958. };
  4959. this.getCurrentTokenPosition = function() {
  4960. return {row: this.$row, column: this.getCurrentTokenColumn()};
  4961. };
  4962. }).call(TokenIterator.prototype);
  4963. exports.TokenIterator = TokenIterator;
  4964. });
  4965. 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) {
  4966. "use strict";
  4967. var Tokenizer = require("../tokenizer").Tokenizer;
  4968. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4969. var Behaviour = require("./behaviour").Behaviour;
  4970. var unicode = require("../unicode");
  4971. var lang = require("../lib/lang");
  4972. var TokenIterator = require("../token_iterator").TokenIterator;
  4973. var Range = require("../range").Range;
  4974. var Mode = function() {
  4975. this.HighlightRules = TextHighlightRules;
  4976. this.$behaviour = new Behaviour();
  4977. };
  4978. (function() {
  4979. this.tokenRe = new RegExp("^["
  4980. + unicode.packages.L
  4981. + unicode.packages.Mn + unicode.packages.Mc
  4982. + unicode.packages.Nd
  4983. + unicode.packages.Pc + "\\$_]+", "g"
  4984. );
  4985. this.nonTokenRe = new RegExp("^(?:[^"
  4986. + unicode.packages.L
  4987. + unicode.packages.Mn + unicode.packages.Mc
  4988. + unicode.packages.Nd
  4989. + unicode.packages.Pc + "\\$_]|\\s])+", "g"
  4990. );
  4991. this.getTokenizer = function() {
  4992. if (!this.$tokenizer) {
  4993. this.$highlightRules = this.$highlightRules || new this.HighlightRules();
  4994. this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
  4995. }
  4996. return this.$tokenizer;
  4997. };
  4998. this.lineCommentStart = "";
  4999. this.blockComment = "";
  5000. this.toggleCommentLines = function(state, session, startRow, endRow) {
  5001. var doc = session.doc;
  5002. var ignoreBlankLines = true;
  5003. var shouldRemove = true;
  5004. var minIndent = Infinity;
  5005. var tabSize = session.getTabSize();
  5006. var insertAtTabStop = false;
  5007. if (!this.lineCommentStart) {
  5008. if (!this.blockComment)
  5009. return false;
  5010. var lineCommentStart = this.blockComment.start;
  5011. var lineCommentEnd = this.blockComment.end;
  5012. var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
  5013. var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
  5014. var comment = function(line, i) {
  5015. if (testRemove(line, i))
  5016. return;
  5017. if (!ignoreBlankLines || /\S/.test(line)) {
  5018. doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
  5019. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  5020. }
  5021. };
  5022. var uncomment = function(line, i) {
  5023. var m;
  5024. if (m = line.match(regexpEnd))
  5025. doc.removeInLine(i, line.length - m[0].length, line.length);
  5026. if (m = line.match(regexpStart))
  5027. doc.removeInLine(i, m[1].length, m[0].length);
  5028. };
  5029. var testRemove = function(line, row) {
  5030. if (regexpStart.test(line))
  5031. return true;
  5032. var tokens = session.getTokens(row);
  5033. for (var i = 0; i < tokens.length; i++) {
  5034. if (tokens[i].type === "comment")
  5035. return true;
  5036. }
  5037. };
  5038. } else {
  5039. if (Array.isArray(this.lineCommentStart)) {
  5040. var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
  5041. var lineCommentStart = this.lineCommentStart[0];
  5042. } else {
  5043. var regexpStart = lang.escapeRegExp(this.lineCommentStart);
  5044. var lineCommentStart = this.lineCommentStart;
  5045. }
  5046. regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
  5047. insertAtTabStop = session.getUseSoftTabs();
  5048. var uncomment = function(line, i) {
  5049. var m = line.match(regexpStart);
  5050. if (!m) return;
  5051. var start = m[1].length, end = m[0].length;
  5052. if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
  5053. end--;
  5054. doc.removeInLine(i, start, end);
  5055. };
  5056. var commentWithSpace = lineCommentStart + " ";
  5057. var comment = function(line, i) {
  5058. if (!ignoreBlankLines || /\S/.test(line)) {
  5059. if (shouldInsertSpace(line, minIndent, minIndent))
  5060. doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
  5061. else
  5062. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  5063. }
  5064. };
  5065. var testRemove = function(line, i) {
  5066. return regexpStart.test(line);
  5067. };
  5068. var shouldInsertSpace = function(line, before, after) {
  5069. var spaces = 0;
  5070. while (before-- && line.charAt(before) == " ")
  5071. spaces++;
  5072. if (spaces % tabSize != 0)
  5073. return false;
  5074. var spaces = 0;
  5075. while (line.charAt(after++) == " ")
  5076. spaces++;
  5077. if (tabSize > 2)
  5078. return spaces % tabSize != tabSize - 1;
  5079. else
  5080. return spaces % tabSize == 0;
  5081. return true;
  5082. };
  5083. }
  5084. function iter(fun) {
  5085. for (var i = startRow; i <= endRow; i++)
  5086. fun(doc.getLine(i), i);
  5087. }
  5088. var minEmptyLength = Infinity;
  5089. iter(function(line, i) {
  5090. var indent = line.search(/\S/);
  5091. if (indent !== -1) {
  5092. if (indent < minIndent)
  5093. minIndent = indent;
  5094. if (shouldRemove && !testRemove(line, i))
  5095. shouldRemove = false;
  5096. } else if (minEmptyLength > line.length) {
  5097. minEmptyLength = line.length;
  5098. }
  5099. });
  5100. if (minIndent == Infinity) {
  5101. minIndent = minEmptyLength;
  5102. ignoreBlankLines = false;
  5103. shouldRemove = false;
  5104. }
  5105. if (insertAtTabStop && minIndent % tabSize != 0)
  5106. minIndent = Math.floor(minIndent / tabSize) * tabSize;
  5107. iter(shouldRemove ? uncomment : comment);
  5108. };
  5109. this.toggleBlockComment = function(state, session, range, cursor) {
  5110. var comment = this.blockComment;
  5111. if (!comment)
  5112. return;
  5113. if (!comment.start && comment[0])
  5114. comment = comment[0];
  5115. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5116. var token = iterator.getCurrentToken();
  5117. var sel = session.selection;
  5118. var initialRange = session.selection.toOrientedRange();
  5119. var startRow, colDiff;
  5120. if (token && /comment/.test(token.type)) {
  5121. var startRange, endRange;
  5122. while (token && /comment/.test(token.type)) {
  5123. var i = token.value.indexOf(comment.start);
  5124. if (i != -1) {
  5125. var row = iterator.getCurrentTokenRow();
  5126. var column = iterator.getCurrentTokenColumn() + i;
  5127. startRange = new Range(row, column, row, column + comment.start.length);
  5128. break;
  5129. }
  5130. token = iterator.stepBackward();
  5131. }
  5132. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5133. var token = iterator.getCurrentToken();
  5134. while (token && /comment/.test(token.type)) {
  5135. var i = token.value.indexOf(comment.end);
  5136. if (i != -1) {
  5137. var row = iterator.getCurrentTokenRow();
  5138. var column = iterator.getCurrentTokenColumn() + i;
  5139. endRange = new Range(row, column, row, column + comment.end.length);
  5140. break;
  5141. }
  5142. token = iterator.stepForward();
  5143. }
  5144. if (endRange)
  5145. session.remove(endRange);
  5146. if (startRange) {
  5147. session.remove(startRange);
  5148. startRow = startRange.start.row;
  5149. colDiff = -comment.start.length;
  5150. }
  5151. } else {
  5152. colDiff = comment.start.length;
  5153. startRow = range.start.row;
  5154. session.insert(range.end, comment.end);
  5155. session.insert(range.start, comment.start);
  5156. }
  5157. if (initialRange.start.row == startRow)
  5158. initialRange.start.column += colDiff;
  5159. if (initialRange.end.row == startRow)
  5160. initialRange.end.column += colDiff;
  5161. session.selection.fromOrientedRange(initialRange);
  5162. };
  5163. this.getNextLineIndent = function(state, line, tab) {
  5164. return this.$getIndent(line);
  5165. };
  5166. this.checkOutdent = function(state, line, input) {
  5167. return false;
  5168. };
  5169. this.autoOutdent = function(state, doc, row) {
  5170. };
  5171. this.$getIndent = function(line) {
  5172. return line.match(/^\s*/)[0];
  5173. };
  5174. this.createWorker = function(session) {
  5175. return null;
  5176. };
  5177. this.createModeDelegates = function (mapping) {
  5178. this.$embeds = [];
  5179. this.$modes = {};
  5180. for (var i in mapping) {
  5181. if (mapping[i]) {
  5182. this.$embeds.push(i);
  5183. this.$modes[i] = new mapping[i]();
  5184. }
  5185. }
  5186. var delegations = ["toggleBlockComment", "toggleCommentLines", "getNextLineIndent",
  5187. "checkOutdent", "autoOutdent", "transformAction", "getCompletions"];
  5188. for (var i = 0; i < delegations.length; i++) {
  5189. (function(scope) {
  5190. var functionName = delegations[i];
  5191. var defaultHandler = scope[functionName];
  5192. scope[delegations[i]] = function() {
  5193. return this.$delegator(functionName, arguments, defaultHandler);
  5194. };
  5195. }(this));
  5196. }
  5197. };
  5198. this.$delegator = function(method, args, defaultHandler) {
  5199. var state = args[0];
  5200. if (typeof state != "string")
  5201. state = state[0];
  5202. for (var i = 0; i < this.$embeds.length; i++) {
  5203. if (!this.$modes[this.$embeds[i]]) continue;
  5204. var split = state.split(this.$embeds[i]);
  5205. if (!split[0] && split[1]) {
  5206. args[0] = split[1];
  5207. var mode = this.$modes[this.$embeds[i]];
  5208. return mode[method].apply(mode, args);
  5209. }
  5210. }
  5211. var ret = defaultHandler.apply(this, args);
  5212. return defaultHandler ? ret : undefined;
  5213. };
  5214. this.transformAction = function(state, action, editor, session, param) {
  5215. if (this.$behaviour) {
  5216. var behaviours = this.$behaviour.getBehaviours();
  5217. for (var key in behaviours) {
  5218. if (behaviours[key][action]) {
  5219. var ret = behaviours[key][action].apply(this, arguments);
  5220. if (ret) {
  5221. return ret;
  5222. }
  5223. }
  5224. }
  5225. }
  5226. };
  5227. this.getKeywords = function(append) {
  5228. if (!this.completionKeywords) {
  5229. var rules = this.$tokenizer.rules;
  5230. var completionKeywords = [];
  5231. for (var rule in rules) {
  5232. var ruleItr = rules[rule];
  5233. for (var r = 0, l = ruleItr.length; r < l; r++) {
  5234. if (typeof ruleItr[r].token === "string") {
  5235. if (/keyword|support|storage/.test(ruleItr[r].token))
  5236. completionKeywords.push(ruleItr[r].regex);
  5237. }
  5238. else if (typeof ruleItr[r].token === "object") {
  5239. for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
  5240. if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
  5241. var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
  5242. completionKeywords.push(rule.substr(1, rule.length - 2));
  5243. }
  5244. }
  5245. }
  5246. }
  5247. }
  5248. this.completionKeywords = completionKeywords;
  5249. }
  5250. if (!append)
  5251. return this.$keywordList;
  5252. return completionKeywords.concat(this.$keywordList || []);
  5253. };
  5254. this.$createKeywordList = function() {
  5255. if (!this.$highlightRules)
  5256. this.getTokenizer();
  5257. return this.$keywordList = this.$highlightRules.$keywordList || [];
  5258. };
  5259. this.getCompletions = function(state, session, pos, prefix) {
  5260. var keywords = this.$keywordList || this.$createKeywordList();
  5261. return keywords.map(function(word) {
  5262. return {
  5263. name: word,
  5264. value: word,
  5265. score: 0,
  5266. meta: "keyword"
  5267. };
  5268. });
  5269. };
  5270. this.$id = "ace/mode/text";
  5271. }).call(Mode.prototype);
  5272. exports.Mode = Mode;
  5273. });
  5274. ace.define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
  5275. "use strict";
  5276. function throwDeltaError(delta, errorText){
  5277. console.log("Invalid Delta:", delta);
  5278. throw "Invalid Delta: " + errorText;
  5279. }
  5280. function positionInDocument(docLines, position) {
  5281. return position.row >= 0 && position.row < docLines.length &&
  5282. position.column >= 0 && position.column <= docLines[position.row].length;
  5283. }
  5284. function validateDelta(docLines, delta) {
  5285. if (delta.action != "insert" && delta.action != "remove")
  5286. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  5287. if (!(delta.lines instanceof Array))
  5288. throwDeltaError(delta, "delta.lines must be an Array");
  5289. if (!delta.start || !delta.end)
  5290. throwDeltaError(delta, "delta.start/end must be an present");
  5291. var start = delta.start;
  5292. if (!positionInDocument(docLines, delta.start))
  5293. throwDeltaError(delta, "delta.start must be contained in document");
  5294. var end = delta.end;
  5295. if (delta.action == "remove" && !positionInDocument(docLines, end))
  5296. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  5297. var numRangeRows = end.row - start.row;
  5298. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  5299. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  5300. throwDeltaError(delta, "delta.range must match delta lines");
  5301. }
  5302. exports.applyDelta = function(docLines, delta, doNotValidate) {
  5303. var row = delta.start.row;
  5304. var startColumn = delta.start.column;
  5305. var line = docLines[row] || "";
  5306. switch (delta.action) {
  5307. case "insert":
  5308. var lines = delta.lines;
  5309. if (lines.length === 1) {
  5310. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  5311. } else {
  5312. var args = [row, 1].concat(delta.lines);
  5313. docLines.splice.apply(docLines, args);
  5314. docLines[row] = line.substring(0, startColumn) + docLines[row];
  5315. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  5316. }
  5317. break;
  5318. case "remove":
  5319. var endColumn = delta.end.column;
  5320. var endRow = delta.end.row;
  5321. if (row === endRow) {
  5322. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  5323. } else {
  5324. docLines.splice(
  5325. row, endRow - row + 1,
  5326. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  5327. );
  5328. }
  5329. break;
  5330. }
  5331. }
  5332. });
  5333. ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5334. "use strict";
  5335. var oop = require("./lib/oop");
  5336. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5337. var Anchor = exports.Anchor = function(doc, row, column) {
  5338. this.$onChange = this.onChange.bind(this);
  5339. this.attach(doc);
  5340. if (typeof column == "undefined")
  5341. this.setPosition(row.row, row.column);
  5342. else
  5343. this.setPosition(row, column);
  5344. };
  5345. (function() {
  5346. oop.implement(this, EventEmitter);
  5347. this.getPosition = function() {
  5348. return this.$clipPositionToDocument(this.row, this.column);
  5349. };
  5350. this.getDocument = function() {
  5351. return this.document;
  5352. };
  5353. this.$insertRight = false;
  5354. this.onChange = function(delta) {
  5355. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  5356. return;
  5357. if (delta.start.row > this.row)
  5358. return;
  5359. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  5360. this.setPosition(point.row, point.column, true);
  5361. };
  5362. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  5363. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  5364. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  5365. }
  5366. function $getTransformedPoint(delta, point, moveIfEqual) {
  5367. var deltaIsInsert = delta.action == "insert";
  5368. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  5369. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  5370. var deltaStart = delta.start;
  5371. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  5372. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  5373. return {
  5374. row: point.row,
  5375. column: point.column
  5376. };
  5377. }
  5378. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  5379. return {
  5380. row: point.row + deltaRowShift,
  5381. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  5382. };
  5383. }
  5384. return {
  5385. row: deltaStart.row,
  5386. column: deltaStart.column
  5387. };
  5388. }
  5389. this.setPosition = function(row, column, noClip) {
  5390. var pos;
  5391. if (noClip) {
  5392. pos = {
  5393. row: row,
  5394. column: column
  5395. };
  5396. } else {
  5397. pos = this.$clipPositionToDocument(row, column);
  5398. }
  5399. if (this.row == pos.row && this.column == pos.column)
  5400. return;
  5401. var old = {
  5402. row: this.row,
  5403. column: this.column
  5404. };
  5405. this.row = pos.row;
  5406. this.column = pos.column;
  5407. this._signal("change", {
  5408. old: old,
  5409. value: pos
  5410. });
  5411. };
  5412. this.detach = function() {
  5413. this.document.removeEventListener("change", this.$onChange);
  5414. };
  5415. this.attach = function(doc) {
  5416. this.document = doc || this.document;
  5417. this.document.on("change", this.$onChange);
  5418. };
  5419. this.$clipPositionToDocument = function(row, column) {
  5420. var pos = {};
  5421. if (row >= this.document.getLength()) {
  5422. pos.row = Math.max(0, this.document.getLength() - 1);
  5423. pos.column = this.document.getLine(pos.row).length;
  5424. }
  5425. else if (row < 0) {
  5426. pos.row = 0;
  5427. pos.column = 0;
  5428. }
  5429. else {
  5430. pos.row = row;
  5431. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  5432. }
  5433. if (column < 0)
  5434. pos.column = 0;
  5435. return pos;
  5436. };
  5437. }).call(Anchor.prototype);
  5438. });
  5439. ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
  5440. "use strict";
  5441. var oop = require("./lib/oop");
  5442. var applyDelta = require("./apply_delta").applyDelta;
  5443. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5444. var Range = require("./range").Range;
  5445. var Anchor = require("./anchor").Anchor;
  5446. var Document = function(textOrLines) {
  5447. this.$lines = [""];
  5448. if (textOrLines.length === 0) {
  5449. this.$lines = [""];
  5450. } else if (Array.isArray(textOrLines)) {
  5451. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  5452. } else {
  5453. this.insert({row: 0, column:0}, textOrLines);
  5454. }
  5455. };
  5456. (function() {
  5457. oop.implement(this, EventEmitter);
  5458. this.setValue = function(text) {
  5459. var len = this.getLength() - 1;
  5460. this.remove(new Range(0, 0, len, this.getLine(len).length));
  5461. this.insert({row: 0, column: 0}, text);
  5462. };
  5463. this.getValue = function() {
  5464. return this.getAllLines().join(this.getNewLineCharacter());
  5465. };
  5466. this.createAnchor = function(row, column) {
  5467. return new Anchor(this, row, column);
  5468. };
  5469. if ("aaa".split(/a/).length === 0) {
  5470. this.$split = function(text) {
  5471. return text.replace(/\r\n|\r/g, "\n").split("\n");
  5472. };
  5473. } else {
  5474. this.$split = function(text) {
  5475. return text.split(/\r\n|\r|\n/);
  5476. };
  5477. }
  5478. this.$detectNewLine = function(text) {
  5479. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  5480. this.$autoNewLine = match ? match[1] : "\n";
  5481. this._signal("changeNewLineMode");
  5482. };
  5483. this.getNewLineCharacter = function() {
  5484. switch (this.$newLineMode) {
  5485. case "windows":
  5486. return "\r\n";
  5487. case "unix":
  5488. return "\n";
  5489. default:
  5490. return this.$autoNewLine || "\n";
  5491. }
  5492. };
  5493. this.$autoNewLine = "";
  5494. this.$newLineMode = "auto";
  5495. this.setNewLineMode = function(newLineMode) {
  5496. if (this.$newLineMode === newLineMode)
  5497. return;
  5498. this.$newLineMode = newLineMode;
  5499. this._signal("changeNewLineMode");
  5500. };
  5501. this.getNewLineMode = function() {
  5502. return this.$newLineMode;
  5503. };
  5504. this.isNewLine = function(text) {
  5505. return (text == "\r\n" || text == "\r" || text == "\n");
  5506. };
  5507. this.getLine = function(row) {
  5508. return this.$lines[row] || "";
  5509. };
  5510. this.getLines = function(firstRow, lastRow) {
  5511. return this.$lines.slice(firstRow, lastRow + 1);
  5512. };
  5513. this.getAllLines = function() {
  5514. return this.getLines(0, this.getLength());
  5515. };
  5516. this.getLength = function() {
  5517. return this.$lines.length;
  5518. };
  5519. this.getTextRange = function(range) {
  5520. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  5521. };
  5522. this.getLinesForRange = function(range) {
  5523. var lines;
  5524. if (range.start.row === range.end.row) {
  5525. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  5526. } else {
  5527. lines = this.getLines(range.start.row, range.end.row);
  5528. lines[0] = (lines[0] || "").substring(range.start.column);
  5529. var l = lines.length - 1;
  5530. if (range.end.row - range.start.row == l)
  5531. lines[l] = lines[l].substring(0, range.end.column);
  5532. }
  5533. return lines;
  5534. };
  5535. this.insertLines = function(row, lines) {
  5536. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  5537. return this.insertFullLines(row, lines);
  5538. };
  5539. this.removeLines = function(firstRow, lastRow) {
  5540. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  5541. return this.removeFullLines(firstRow, lastRow);
  5542. };
  5543. this.insertNewLine = function(position) {
  5544. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead.");
  5545. return this.insertMergedLines(position, ["", ""]);
  5546. };
  5547. this.insert = function(position, text) {
  5548. if (this.getLength() <= 1)
  5549. this.$detectNewLine(text);
  5550. return this.insertMergedLines(position, this.$split(text));
  5551. };
  5552. this.insertInLine = function(position, text) {
  5553. var start = this.clippedPos(position.row, position.column);
  5554. var end = this.pos(position.row, position.column + text.length);
  5555. this.applyDelta({
  5556. start: start,
  5557. end: end,
  5558. action: "insert",
  5559. lines: [text]
  5560. }, true);
  5561. return this.clonePos(end);
  5562. };
  5563. this.clippedPos = function(row, column) {
  5564. var length = this.getLength();
  5565. if (row === undefined) {
  5566. row = length;
  5567. } else if (row < 0) {
  5568. row = 0;
  5569. } else if (row >= length) {
  5570. row = length - 1;
  5571. column = undefined;
  5572. }
  5573. var line = this.getLine(row);
  5574. if (column == undefined)
  5575. column = line.length;
  5576. column = Math.min(Math.max(column, 0), line.length);
  5577. return {row: row, column: column};
  5578. };
  5579. this.clonePos = function(pos) {
  5580. return {row: pos.row, column: pos.column};
  5581. };
  5582. this.pos = function(row, column) {
  5583. return {row: row, column: column};
  5584. };
  5585. this.$clipPosition = function(position) {
  5586. var length = this.getLength();
  5587. if (position.row >= length) {
  5588. position.row = Math.max(0, length - 1);
  5589. position.column = this.getLine(length - 1).length;
  5590. } else {
  5591. position.row = Math.max(0, position.row);
  5592. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  5593. }
  5594. return position;
  5595. };
  5596. this.insertFullLines = function(row, lines) {
  5597. row = Math.min(Math.max(row, 0), this.getLength());
  5598. var column = 0;
  5599. if (row < this.getLength()) {
  5600. lines = lines.concat([""]);
  5601. column = 0;
  5602. } else {
  5603. lines = [""].concat(lines);
  5604. row--;
  5605. column = this.$lines[row].length;
  5606. }
  5607. this.insertMergedLines({row: row, column: column}, lines);
  5608. };
  5609. this.insertMergedLines = function(position, lines) {
  5610. var start = this.clippedPos(position.row, position.column);
  5611. var end = {
  5612. row: start.row + lines.length - 1,
  5613. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  5614. };
  5615. this.applyDelta({
  5616. start: start,
  5617. end: end,
  5618. action: "insert",
  5619. lines: lines
  5620. });
  5621. return this.clonePos(end);
  5622. };
  5623. this.remove = function(range) {
  5624. var start = this.clippedPos(range.start.row, range.start.column);
  5625. var end = this.clippedPos(range.end.row, range.end.column);
  5626. this.applyDelta({
  5627. start: start,
  5628. end: end,
  5629. action: "remove",
  5630. lines: this.getLinesForRange({start: start, end: end})
  5631. });
  5632. return this.clonePos(start);
  5633. };
  5634. this.removeInLine = function(row, startColumn, endColumn) {
  5635. var start = this.clippedPos(row, startColumn);
  5636. var end = this.clippedPos(row, endColumn);
  5637. this.applyDelta({
  5638. start: start,
  5639. end: end,
  5640. action: "remove",
  5641. lines: this.getLinesForRange({start: start, end: end})
  5642. }, true);
  5643. return this.clonePos(start);
  5644. };
  5645. this.removeFullLines = function(firstRow, lastRow) {
  5646. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  5647. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  5648. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  5649. var deleteLastNewLine = lastRow < this.getLength() - 1;
  5650. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  5651. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  5652. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  5653. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  5654. var range = new Range(startRow, startCol, endRow, endCol);
  5655. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  5656. this.applyDelta({
  5657. start: range.start,
  5658. end: range.end,
  5659. action: "remove",
  5660. lines: this.getLinesForRange(range)
  5661. });
  5662. return deletedLines;
  5663. };
  5664. this.removeNewLine = function(row) {
  5665. if (row < this.getLength() - 1 && row >= 0) {
  5666. this.applyDelta({
  5667. start: this.pos(row, this.getLine(row).length),
  5668. end: this.pos(row + 1, 0),
  5669. action: "remove",
  5670. lines: ["", ""]
  5671. });
  5672. }
  5673. };
  5674. this.replace = function(range, text) {
  5675. if (!(range instanceof Range))
  5676. range = Range.fromPoints(range.start, range.end);
  5677. if (text.length === 0 && range.isEmpty())
  5678. return range.start;
  5679. if (text == this.getTextRange(range))
  5680. return range.end;
  5681. this.remove(range);
  5682. var end;
  5683. if (text) {
  5684. end = this.insert(range.start, text);
  5685. }
  5686. else {
  5687. end = range.start;
  5688. }
  5689. return end;
  5690. };
  5691. this.applyDeltas = function(deltas) {
  5692. for (var i=0; i<deltas.length; i++) {
  5693. this.applyDelta(deltas[i]);
  5694. }
  5695. };
  5696. this.revertDeltas = function(deltas) {
  5697. for (var i=deltas.length-1; i>=0; i--) {
  5698. this.revertDelta(deltas[i]);
  5699. }
  5700. };
  5701. this.applyDelta = function(delta, doNotValidate) {
  5702. var isInsert = delta.action == "insert";
  5703. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  5704. : !Range.comparePoints(delta.start, delta.end)) {
  5705. return;
  5706. }
  5707. if (isInsert && delta.lines.length > 20000)
  5708. this.$splitAndapplyLargeDelta(delta, 20000);
  5709. applyDelta(this.$lines, delta, doNotValidate);
  5710. this._signal("change", delta);
  5711. };
  5712. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  5713. var lines = delta.lines;
  5714. var l = lines.length;
  5715. var row = delta.start.row;
  5716. var column = delta.start.column;
  5717. var from = 0, to = 0;
  5718. do {
  5719. from = to;
  5720. to += MAX - 1;
  5721. var chunk = lines.slice(from, to);
  5722. if (to > l) {
  5723. delta.lines = chunk;
  5724. delta.start.row = row + from;
  5725. delta.start.column = column;
  5726. break;
  5727. }
  5728. chunk.push("");
  5729. this.applyDelta({
  5730. start: this.pos(row + from, column),
  5731. end: this.pos(row + to, column = 0),
  5732. action: delta.action,
  5733. lines: chunk
  5734. }, true);
  5735. } while(true);
  5736. };
  5737. this.revertDelta = function(delta) {
  5738. this.applyDelta({
  5739. start: this.clonePos(delta.start),
  5740. end: this.clonePos(delta.end),
  5741. action: (delta.action == "insert" ? "remove" : "insert"),
  5742. lines: delta.lines.slice()
  5743. });
  5744. };
  5745. this.indexToPosition = function(index, startRow) {
  5746. var lines = this.$lines || this.getAllLines();
  5747. var newlineLength = this.getNewLineCharacter().length;
  5748. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  5749. index -= lines[i].length + newlineLength;
  5750. if (index < 0)
  5751. return {row: i, column: index + lines[i].length + newlineLength};
  5752. }
  5753. return {row: l-1, column: lines[l-1].length};
  5754. };
  5755. this.positionToIndex = function(pos, startRow) {
  5756. var lines = this.$lines || this.getAllLines();
  5757. var newlineLength = this.getNewLineCharacter().length;
  5758. var index = 0;
  5759. var row = Math.min(pos.row, lines.length);
  5760. for (var i = startRow || 0; i < row; ++i)
  5761. index += lines[i].length + newlineLength;
  5762. return index + pos.column;
  5763. };
  5764. }).call(Document.prototype);
  5765. exports.Document = Document;
  5766. });
  5767. ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5768. "use strict";
  5769. var oop = require("./lib/oop");
  5770. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5771. var BackgroundTokenizer = function(tokenizer, editor) {
  5772. this.running = false;
  5773. this.lines = [];
  5774. this.states = [];
  5775. this.currentLine = 0;
  5776. this.tokenizer = tokenizer;
  5777. var self = this;
  5778. this.$worker = function() {
  5779. if (!self.running) { return; }
  5780. var workerStart = new Date();
  5781. var currentLine = self.currentLine;
  5782. var endLine = -1;
  5783. var doc = self.doc;
  5784. var startLine = currentLine;
  5785. while (self.lines[currentLine])
  5786. currentLine++;
  5787. var len = doc.getLength();
  5788. var processedLines = 0;
  5789. self.running = false;
  5790. while (currentLine < len) {
  5791. self.$tokenizeRow(currentLine);
  5792. endLine = currentLine;
  5793. do {
  5794. currentLine++;
  5795. } while (self.lines[currentLine]);
  5796. processedLines ++;
  5797. if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
  5798. self.running = setTimeout(self.$worker, 20);
  5799. break;
  5800. }
  5801. }
  5802. self.currentLine = currentLine;
  5803. if (startLine <= endLine)
  5804. self.fireUpdateEvent(startLine, endLine);
  5805. };
  5806. };
  5807. (function(){
  5808. oop.implement(this, EventEmitter);
  5809. this.setTokenizer = function(tokenizer) {
  5810. this.tokenizer = tokenizer;
  5811. this.lines = [];
  5812. this.states = [];
  5813. this.start(0);
  5814. };
  5815. this.setDocument = function(doc) {
  5816. this.doc = doc;
  5817. this.lines = [];
  5818. this.states = [];
  5819. this.stop();
  5820. };
  5821. this.fireUpdateEvent = function(firstRow, lastRow) {
  5822. var data = {
  5823. first: firstRow,
  5824. last: lastRow
  5825. };
  5826. this._signal("update", {data: data});
  5827. };
  5828. this.start = function(startRow) {
  5829. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  5830. this.lines.splice(this.currentLine, this.lines.length);
  5831. this.states.splice(this.currentLine, this.states.length);
  5832. this.stop();
  5833. this.running = setTimeout(this.$worker, 700);
  5834. };
  5835. this.scheduleStart = function() {
  5836. if (!this.running)
  5837. this.running = setTimeout(this.$worker, 700);
  5838. }
  5839. this.$updateOnChange = function(delta) {
  5840. var startRow = delta.start.row;
  5841. var len = delta.end.row - startRow;
  5842. if (len === 0) {
  5843. this.lines[startRow] = null;
  5844. } else if (delta.action == "remove") {
  5845. this.lines.splice(startRow, len + 1, null);
  5846. this.states.splice(startRow, len + 1, null);
  5847. } else {
  5848. var args = Array(len + 1);
  5849. args.unshift(startRow, 1);
  5850. this.lines.splice.apply(this.lines, args);
  5851. this.states.splice.apply(this.states, args);
  5852. }
  5853. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  5854. this.stop();
  5855. };
  5856. this.stop = function() {
  5857. if (this.running)
  5858. clearTimeout(this.running);
  5859. this.running = false;
  5860. };
  5861. this.getTokens = function(row) {
  5862. return this.lines[row] || this.$tokenizeRow(row);
  5863. };
  5864. this.getState = function(row) {
  5865. if (this.currentLine == row)
  5866. this.$tokenizeRow(row);
  5867. return this.states[row] || "start";
  5868. };
  5869. this.$tokenizeRow = function(row) {
  5870. var line = this.doc.getLine(row);
  5871. var state = this.states[row - 1];
  5872. var data = this.tokenizer.getLineTokens(line, state, row);
  5873. if (this.states[row] + "" !== data.state + "") {
  5874. this.states[row] = data.state;
  5875. this.lines[row + 1] = null;
  5876. if (this.currentLine > row + 1)
  5877. this.currentLine = row + 1;
  5878. } else if (this.currentLine == row) {
  5879. this.currentLine = row + 1;
  5880. }
  5881. return this.lines[row] = data.tokens;
  5882. };
  5883. }).call(BackgroundTokenizer.prototype);
  5884. exports.BackgroundTokenizer = BackgroundTokenizer;
  5885. });
  5886. ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  5887. "use strict";
  5888. var lang = require("./lib/lang");
  5889. var oop = require("./lib/oop");
  5890. var Range = require("./range").Range;
  5891. var SearchHighlight = function(regExp, clazz, type) {
  5892. this.setRegexp(regExp);
  5893. this.clazz = clazz;
  5894. this.type = type || "text";
  5895. };
  5896. (function() {
  5897. this.MAX_RANGES = 500;
  5898. this.setRegexp = function(regExp) {
  5899. if (this.regExp+"" == regExp+"")
  5900. return;
  5901. this.regExp = regExp;
  5902. this.cache = [];
  5903. };
  5904. this.update = function(html, markerLayer, session, config) {
  5905. if (!this.regExp)
  5906. return;
  5907. var start = config.firstRow, end = config.lastRow;
  5908. for (var i = start; i <= end; i++) {
  5909. var ranges = this.cache[i];
  5910. if (ranges == null) {
  5911. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  5912. if (ranges.length > this.MAX_RANGES)
  5913. ranges = ranges.slice(0, this.MAX_RANGES);
  5914. ranges = ranges.map(function(match) {
  5915. return new Range(i, match.offset, i, match.offset + match.length);
  5916. });
  5917. this.cache[i] = ranges.length ? ranges : "";
  5918. }
  5919. for (var j = ranges.length; j --; ) {
  5920. markerLayer.drawSingleLineMarker(
  5921. html, ranges[j].toScreenRange(session), this.clazz, config);
  5922. }
  5923. }
  5924. };
  5925. }).call(SearchHighlight.prototype);
  5926. exports.SearchHighlight = SearchHighlight;
  5927. });
  5928. ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
  5929. "use strict";
  5930. var Range = require("../range").Range;
  5931. function FoldLine(foldData, folds) {
  5932. this.foldData = foldData;
  5933. if (Array.isArray(folds)) {
  5934. this.folds = folds;
  5935. } else {
  5936. folds = this.folds = [ folds ];
  5937. }
  5938. var last = folds[folds.length - 1];
  5939. this.range = new Range(folds[0].start.row, folds[0].start.column,
  5940. last.end.row, last.end.column);
  5941. this.start = this.range.start;
  5942. this.end = this.range.end;
  5943. this.folds.forEach(function(fold) {
  5944. fold.setFoldLine(this);
  5945. }, this);
  5946. }
  5947. (function() {
  5948. this.shiftRow = function(shift) {
  5949. this.start.row += shift;
  5950. this.end.row += shift;
  5951. this.folds.forEach(function(fold) {
  5952. fold.start.row += shift;
  5953. fold.end.row += shift;
  5954. });
  5955. };
  5956. this.addFold = function(fold) {
  5957. if (fold.sameRow) {
  5958. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  5959. throw new Error("Can't add a fold to this FoldLine as it has no connection");
  5960. }
  5961. this.folds.push(fold);
  5962. this.folds.sort(function(a, b) {
  5963. return -a.range.compareEnd(b.start.row, b.start.column);
  5964. });
  5965. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  5966. this.end.row = fold.end.row;
  5967. this.end.column = fold.end.column;
  5968. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  5969. this.start.row = fold.start.row;
  5970. this.start.column = fold.start.column;
  5971. }
  5972. } else if (fold.start.row == this.end.row) {
  5973. this.folds.push(fold);
  5974. this.end.row = fold.end.row;
  5975. this.end.column = fold.end.column;
  5976. } else if (fold.end.row == this.start.row) {
  5977. this.folds.unshift(fold);
  5978. this.start.row = fold.start.row;
  5979. this.start.column = fold.start.column;
  5980. } else {
  5981. throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
  5982. }
  5983. fold.foldLine = this;
  5984. };
  5985. this.containsRow = function(row) {
  5986. return row >= this.start.row && row <= this.end.row;
  5987. };
  5988. this.walk = function(callback, endRow, endColumn) {
  5989. var lastEnd = 0,
  5990. folds = this.folds,
  5991. fold,
  5992. cmp, stop, isNewRow = true;
  5993. if (endRow == null) {
  5994. endRow = this.end.row;
  5995. endColumn = this.end.column;
  5996. }
  5997. for (var i = 0; i < folds.length; i++) {
  5998. fold = folds[i];
  5999. cmp = fold.range.compareStart(endRow, endColumn);
  6000. if (cmp == -1) {
  6001. callback(null, endRow, endColumn, lastEnd, isNewRow);
  6002. return;
  6003. }
  6004. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  6005. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  6006. if (stop || cmp === 0) {
  6007. return;
  6008. }
  6009. isNewRow = !fold.sameRow;
  6010. lastEnd = fold.end.column;
  6011. }
  6012. callback(null, endRow, endColumn, lastEnd, isNewRow);
  6013. };
  6014. this.getNextFoldTo = function(row, column) {
  6015. var fold, cmp;
  6016. for (var i = 0; i < this.folds.length; i++) {
  6017. fold = this.folds[i];
  6018. cmp = fold.range.compareEnd(row, column);
  6019. if (cmp == -1) {
  6020. return {
  6021. fold: fold,
  6022. kind: "after"
  6023. };
  6024. } else if (cmp === 0) {
  6025. return {
  6026. fold: fold,
  6027. kind: "inside"
  6028. };
  6029. }
  6030. }
  6031. return null;
  6032. };
  6033. this.addRemoveChars = function(row, column, len) {
  6034. var ret = this.getNextFoldTo(row, column),
  6035. fold, folds;
  6036. if (ret) {
  6037. fold = ret.fold;
  6038. if (ret.kind == "inside"
  6039. && fold.start.column != column
  6040. && fold.start.row != row)
  6041. {
  6042. window.console && window.console.log(row, column, fold);
  6043. } else if (fold.start.row == row) {
  6044. folds = this.folds;
  6045. var i = folds.indexOf(fold);
  6046. if (i === 0) {
  6047. this.start.column += len;
  6048. }
  6049. for (i; i < folds.length; i++) {
  6050. fold = folds[i];
  6051. fold.start.column += len;
  6052. if (!fold.sameRow) {
  6053. return;
  6054. }
  6055. fold.end.column += len;
  6056. }
  6057. this.end.column += len;
  6058. }
  6059. }
  6060. };
  6061. this.split = function(row, column) {
  6062. var pos = this.getNextFoldTo(row, column);
  6063. if (!pos || pos.kind == "inside")
  6064. return null;
  6065. var fold = pos.fold;
  6066. var folds = this.folds;
  6067. var foldData = this.foldData;
  6068. var i = folds.indexOf(fold);
  6069. var foldBefore = folds[i - 1];
  6070. this.end.row = foldBefore.end.row;
  6071. this.end.column = foldBefore.end.column;
  6072. folds = folds.splice(i, folds.length - i);
  6073. var newFoldLine = new FoldLine(foldData, folds);
  6074. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  6075. return newFoldLine;
  6076. };
  6077. this.merge = function(foldLineNext) {
  6078. var folds = foldLineNext.folds;
  6079. for (var i = 0; i < folds.length; i++) {
  6080. this.addFold(folds[i]);
  6081. }
  6082. var foldData = this.foldData;
  6083. foldData.splice(foldData.indexOf(foldLineNext), 1);
  6084. };
  6085. this.toString = function() {
  6086. var ret = [this.range.toString() + ": [" ];
  6087. this.folds.forEach(function(fold) {
  6088. ret.push(" " + fold.toString());
  6089. });
  6090. ret.push("]");
  6091. return ret.join("\n");
  6092. };
  6093. this.idxToPosition = function(idx) {
  6094. var lastFoldEndColumn = 0;
  6095. for (var i = 0; i < this.folds.length; i++) {
  6096. var fold = this.folds[i];
  6097. idx -= fold.start.column - lastFoldEndColumn;
  6098. if (idx < 0) {
  6099. return {
  6100. row: fold.start.row,
  6101. column: fold.start.column + idx
  6102. };
  6103. }
  6104. idx -= fold.placeholder.length;
  6105. if (idx < 0) {
  6106. return fold.start;
  6107. }
  6108. lastFoldEndColumn = fold.end.column;
  6109. }
  6110. return {
  6111. row: this.end.row,
  6112. column: this.end.column + idx
  6113. };
  6114. };
  6115. }).call(FoldLine.prototype);
  6116. exports.FoldLine = FoldLine;
  6117. });
  6118. ace.define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
  6119. "use strict";
  6120. var Range = require("./range").Range;
  6121. var comparePoints = Range.comparePoints;
  6122. var RangeList = function() {
  6123. this.ranges = [];
  6124. };
  6125. (function() {
  6126. this.comparePoints = comparePoints;
  6127. this.pointIndex = function(pos, excludeEdges, startIndex) {
  6128. var list = this.ranges;
  6129. for (var i = startIndex || 0; i < list.length; i++) {
  6130. var range = list[i];
  6131. var cmpEnd = comparePoints(pos, range.end);
  6132. if (cmpEnd > 0)
  6133. continue;
  6134. var cmpStart = comparePoints(pos, range.start);
  6135. if (cmpEnd === 0)
  6136. return excludeEdges && cmpStart !== 0 ? -i-2 : i;
  6137. if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
  6138. return i;
  6139. return -i-1;
  6140. }
  6141. return -i - 1;
  6142. };
  6143. this.add = function(range) {
  6144. var excludeEdges = !range.isEmpty();
  6145. var startIndex = this.pointIndex(range.start, excludeEdges);
  6146. if (startIndex < 0)
  6147. startIndex = -startIndex - 1;
  6148. var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
  6149. if (endIndex < 0)
  6150. endIndex = -endIndex - 1;
  6151. else
  6152. endIndex++;
  6153. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  6154. };
  6155. this.addList = function(list) {
  6156. var removed = [];
  6157. for (var i = list.length; i--; ) {
  6158. removed.push.apply(removed, this.add(list[i]));
  6159. }
  6160. return removed;
  6161. };
  6162. this.substractPoint = function(pos) {
  6163. var i = this.pointIndex(pos);
  6164. if (i >= 0)
  6165. return this.ranges.splice(i, 1);
  6166. };
  6167. this.merge = function() {
  6168. var removed = [];
  6169. var list = this.ranges;
  6170. list = list.sort(function(a, b) {
  6171. return comparePoints(a.start, b.start);
  6172. });
  6173. var next = list[0], range;
  6174. for (var i = 1; i < list.length; i++) {
  6175. range = next;
  6176. next = list[i];
  6177. var cmp = comparePoints(range.end, next.start);
  6178. if (cmp < 0)
  6179. continue;
  6180. if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
  6181. continue;
  6182. if (comparePoints(range.end, next.end) < 0) {
  6183. range.end.row = next.end.row;
  6184. range.end.column = next.end.column;
  6185. }
  6186. list.splice(i, 1);
  6187. removed.push(next);
  6188. next = range;
  6189. i--;
  6190. }
  6191. this.ranges = list;
  6192. return removed;
  6193. };
  6194. this.contains = function(row, column) {
  6195. return this.pointIndex({row: row, column: column}) >= 0;
  6196. };
  6197. this.containsPoint = function(pos) {
  6198. return this.pointIndex(pos) >= 0;
  6199. };
  6200. this.rangeAtPoint = function(pos) {
  6201. var i = this.pointIndex(pos);
  6202. if (i >= 0)
  6203. return this.ranges[i];
  6204. };
  6205. this.clipRows = function(startRow, endRow) {
  6206. var list = this.ranges;
  6207. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  6208. return [];
  6209. var startIndex = this.pointIndex({row: startRow, column: 0});
  6210. if (startIndex < 0)
  6211. startIndex = -startIndex - 1;
  6212. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  6213. if (endIndex < 0)
  6214. endIndex = -endIndex - 1;
  6215. var clipped = [];
  6216. for (var i = startIndex; i < endIndex; i++) {
  6217. clipped.push(list[i]);
  6218. }
  6219. return clipped;
  6220. };
  6221. this.removeAll = function() {
  6222. return this.ranges.splice(0, this.ranges.length);
  6223. };
  6224. this.attach = function(session) {
  6225. if (this.session)
  6226. this.detach();
  6227. this.session = session;
  6228. this.onChange = this.$onChange.bind(this);
  6229. this.session.on('change', this.onChange);
  6230. };
  6231. this.detach = function() {
  6232. if (!this.session)
  6233. return;
  6234. this.session.removeListener('change', this.onChange);
  6235. this.session = null;
  6236. };
  6237. this.$onChange = function(delta) {
  6238. if (delta.action == "insert"){
  6239. var start = delta.start;
  6240. var end = delta.end;
  6241. } else {
  6242. var end = delta.start;
  6243. var start = delta.end;
  6244. }
  6245. var startRow = start.row;
  6246. var endRow = end.row;
  6247. var lineDif = endRow - startRow;
  6248. var colDiff = -start.column + end.column;
  6249. var ranges = this.ranges;
  6250. for (var i = 0, n = ranges.length; i < n; i++) {
  6251. var r = ranges[i];
  6252. if (r.end.row < startRow)
  6253. continue;
  6254. if (r.start.row > startRow)
  6255. break;
  6256. if (r.start.row == startRow && r.start.column >= start.column ) {
  6257. if (r.start.column == start.column && this.$insertRight) {
  6258. } else {
  6259. r.start.column += colDiff;
  6260. r.start.row += lineDif;
  6261. }
  6262. }
  6263. if (r.end.row == startRow && r.end.column >= start.column) {
  6264. if (r.end.column == start.column && this.$insertRight) {
  6265. continue;
  6266. }
  6267. if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
  6268. if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
  6269. r.end.column -= colDiff;
  6270. }
  6271. r.end.column += colDiff;
  6272. r.end.row += lineDif;
  6273. }
  6274. }
  6275. if (lineDif != 0 && i < n) {
  6276. for (; i < n; i++) {
  6277. var r = ranges[i];
  6278. r.start.row += lineDif;
  6279. r.end.row += lineDif;
  6280. }
  6281. }
  6282. };
  6283. }).call(RangeList.prototype);
  6284. exports.RangeList = RangeList;
  6285. });
  6286. ace.define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
  6287. "use strict";
  6288. var Range = require("../range").Range;
  6289. var RangeList = require("../range_list").RangeList;
  6290. var oop = require("../lib/oop")
  6291. var Fold = exports.Fold = function(range, placeholder) {
  6292. this.foldLine = null;
  6293. this.placeholder = placeholder;
  6294. this.range = range;
  6295. this.start = range.start;
  6296. this.end = range.end;
  6297. this.sameRow = range.start.row == range.end.row;
  6298. this.subFolds = this.ranges = [];
  6299. };
  6300. oop.inherits(Fold, RangeList);
  6301. (function() {
  6302. this.toString = function() {
  6303. return '"' + this.placeholder + '" ' + this.range.toString();
  6304. };
  6305. this.setFoldLine = function(foldLine) {
  6306. this.foldLine = foldLine;
  6307. this.subFolds.forEach(function(fold) {
  6308. fold.setFoldLine(foldLine);
  6309. });
  6310. };
  6311. this.clone = function() {
  6312. var range = this.range.clone();
  6313. var fold = new Fold(range, this.placeholder);
  6314. this.subFolds.forEach(function(subFold) {
  6315. fold.subFolds.push(subFold.clone());
  6316. });
  6317. fold.collapseChildren = this.collapseChildren;
  6318. return fold;
  6319. };
  6320. this.addSubFold = function(fold) {
  6321. if (this.range.isEqual(fold))
  6322. return;
  6323. if (!this.range.containsRange(fold))
  6324. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6325. consumeRange(fold, this.start);
  6326. var row = fold.start.row, column = fold.start.column;
  6327. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  6328. cmp = this.subFolds[i].range.compare(row, column);
  6329. if (cmp != 1)
  6330. break;
  6331. }
  6332. var afterStart = this.subFolds[i];
  6333. if (cmp == 0)
  6334. return afterStart.addSubFold(fold);
  6335. var row = fold.range.end.row, column = fold.range.end.column;
  6336. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  6337. cmp = this.subFolds[j].range.compare(row, column);
  6338. if (cmp != 1)
  6339. break;
  6340. }
  6341. var afterEnd = this.subFolds[j];
  6342. if (cmp == 0)
  6343. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6344. var consumedFolds = this.subFolds.splice(i, j - i, fold);
  6345. fold.setFoldLine(this.foldLine);
  6346. return fold;
  6347. };
  6348. this.restoreRange = function(range) {
  6349. return restoreRange(range, this.start);
  6350. };
  6351. }).call(Fold.prototype);
  6352. function consumePoint(point, anchor) {
  6353. point.row -= anchor.row;
  6354. if (point.row == 0)
  6355. point.column -= anchor.column;
  6356. }
  6357. function consumeRange(range, anchor) {
  6358. consumePoint(range.start, anchor);
  6359. consumePoint(range.end, anchor);
  6360. }
  6361. function restorePoint(point, anchor) {
  6362. if (point.row == 0)
  6363. point.column += anchor.column;
  6364. point.row += anchor.row;
  6365. }
  6366. function restoreRange(range, anchor) {
  6367. restorePoint(range.start, anchor);
  6368. restorePoint(range.end, anchor);
  6369. }
  6370. });
  6371. 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) {
  6372. "use strict";
  6373. var Range = require("../range").Range;
  6374. var FoldLine = require("./fold_line").FoldLine;
  6375. var Fold = require("./fold").Fold;
  6376. var TokenIterator = require("../token_iterator").TokenIterator;
  6377. function Folding() {
  6378. this.getFoldAt = function(row, column, side) {
  6379. var foldLine = this.getFoldLine(row);
  6380. if (!foldLine)
  6381. return null;
  6382. var folds = foldLine.folds;
  6383. for (var i = 0; i < folds.length; i++) {
  6384. var fold = folds[i];
  6385. if (fold.range.contains(row, column)) {
  6386. if (side == 1 && fold.range.isEnd(row, column)) {
  6387. continue;
  6388. } else if (side == -1 && fold.range.isStart(row, column)) {
  6389. continue;
  6390. }
  6391. return fold;
  6392. }
  6393. }
  6394. };
  6395. this.getFoldsInRange = function(range) {
  6396. var start = range.start;
  6397. var end = range.end;
  6398. var foldLines = this.$foldData;
  6399. var foundFolds = [];
  6400. start.column += 1;
  6401. end.column -= 1;
  6402. for (var i = 0; i < foldLines.length; i++) {
  6403. var cmp = foldLines[i].range.compareRange(range);
  6404. if (cmp == 2) {
  6405. continue;
  6406. }
  6407. else if (cmp == -2) {
  6408. break;
  6409. }
  6410. var folds = foldLines[i].folds;
  6411. for (var j = 0; j < folds.length; j++) {
  6412. var fold = folds[j];
  6413. cmp = fold.range.compareRange(range);
  6414. if (cmp == -2) {
  6415. break;
  6416. } else if (cmp == 2) {
  6417. continue;
  6418. } else
  6419. if (cmp == 42) {
  6420. break;
  6421. }
  6422. foundFolds.push(fold);
  6423. }
  6424. }
  6425. start.column -= 1;
  6426. end.column += 1;
  6427. return foundFolds;
  6428. };
  6429. this.getFoldsInRangeList = function(ranges) {
  6430. if (Array.isArray(ranges)) {
  6431. var folds = [];
  6432. ranges.forEach(function(range) {
  6433. folds = folds.concat(this.getFoldsInRange(range));
  6434. }, this);
  6435. } else {
  6436. var folds = this.getFoldsInRange(ranges);
  6437. }
  6438. return folds;
  6439. };
  6440. this.getAllFolds = function() {
  6441. var folds = [];
  6442. var foldLines = this.$foldData;
  6443. for (var i = 0; i < foldLines.length; i++)
  6444. for (var j = 0; j < foldLines[i].folds.length; j++)
  6445. folds.push(foldLines[i].folds[j]);
  6446. return folds;
  6447. };
  6448. this.getFoldStringAt = function(row, column, trim, foldLine) {
  6449. foldLine = foldLine || this.getFoldLine(row);
  6450. if (!foldLine)
  6451. return null;
  6452. var lastFold = {
  6453. end: { column: 0 }
  6454. };
  6455. var str, fold;
  6456. for (var i = 0; i < foldLine.folds.length; i++) {
  6457. fold = foldLine.folds[i];
  6458. var cmp = fold.range.compareEnd(row, column);
  6459. if (cmp == -1) {
  6460. str = this
  6461. .getLine(fold.start.row)
  6462. .substring(lastFold.end.column, fold.start.column);
  6463. break;
  6464. }
  6465. else if (cmp === 0) {
  6466. return null;
  6467. }
  6468. lastFold = fold;
  6469. }
  6470. if (!str)
  6471. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  6472. if (trim == -1)
  6473. return str.substring(0, column - lastFold.end.column);
  6474. else if (trim == 1)
  6475. return str.substring(column - lastFold.end.column);
  6476. else
  6477. return str;
  6478. };
  6479. this.getFoldLine = function(docRow, startFoldLine) {
  6480. var foldData = this.$foldData;
  6481. var i = 0;
  6482. if (startFoldLine)
  6483. i = foldData.indexOf(startFoldLine);
  6484. if (i == -1)
  6485. i = 0;
  6486. for (i; i < foldData.length; i++) {
  6487. var foldLine = foldData[i];
  6488. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  6489. return foldLine;
  6490. } else if (foldLine.end.row > docRow) {
  6491. return null;
  6492. }
  6493. }
  6494. return null;
  6495. };
  6496. this.getNextFoldLine = function(docRow, startFoldLine) {
  6497. var foldData = this.$foldData;
  6498. var i = 0;
  6499. if (startFoldLine)
  6500. i = foldData.indexOf(startFoldLine);
  6501. if (i == -1)
  6502. i = 0;
  6503. for (i; i < foldData.length; i++) {
  6504. var foldLine = foldData[i];
  6505. if (foldLine.end.row >= docRow) {
  6506. return foldLine;
  6507. }
  6508. }
  6509. return null;
  6510. };
  6511. this.getFoldedRowCount = function(first, last) {
  6512. var foldData = this.$foldData, rowCount = last-first+1;
  6513. for (var i = 0; i < foldData.length; i++) {
  6514. var foldLine = foldData[i],
  6515. end = foldLine.end.row,
  6516. start = foldLine.start.row;
  6517. if (end >= last) {
  6518. if (start < last) {
  6519. if (start >= first)
  6520. rowCount -= last-start;
  6521. else
  6522. rowCount = 0; // in one fold
  6523. }
  6524. break;
  6525. } else if (end >= first){
  6526. if (start >= first) // fold inside range
  6527. rowCount -= end-start;
  6528. else
  6529. rowCount -= end-first+1;
  6530. }
  6531. }
  6532. return rowCount;
  6533. };
  6534. this.$addFoldLine = function(foldLine) {
  6535. this.$foldData.push(foldLine);
  6536. this.$foldData.sort(function(a, b) {
  6537. return a.start.row - b.start.row;
  6538. });
  6539. return foldLine;
  6540. };
  6541. this.addFold = function(placeholder, range) {
  6542. var foldData = this.$foldData;
  6543. var added = false;
  6544. var fold;
  6545. if (placeholder instanceof Fold)
  6546. fold = placeholder;
  6547. else {
  6548. fold = new Fold(range, placeholder);
  6549. fold.collapseChildren = range.collapseChildren;
  6550. }
  6551. this.$clipRangeToDocument(fold.range);
  6552. var startRow = fold.start.row;
  6553. var startColumn = fold.start.column;
  6554. var endRow = fold.end.row;
  6555. var endColumn = fold.end.column;
  6556. if (!(startRow < endRow ||
  6557. startRow == endRow && startColumn <= endColumn - 2))
  6558. throw new Error("The range has to be at least 2 characters width");
  6559. var startFold = this.getFoldAt(startRow, startColumn, 1);
  6560. var endFold = this.getFoldAt(endRow, endColumn, -1);
  6561. if (startFold && endFold == startFold)
  6562. return startFold.addSubFold(fold);
  6563. if (startFold && !startFold.range.isStart(startRow, startColumn))
  6564. this.removeFold(startFold);
  6565. if (endFold && !endFold.range.isEnd(endRow, endColumn))
  6566. this.removeFold(endFold);
  6567. var folds = this.getFoldsInRange(fold.range);
  6568. if (folds.length > 0) {
  6569. this.removeFolds(folds);
  6570. folds.forEach(function(subFold) {
  6571. fold.addSubFold(subFold);
  6572. });
  6573. }
  6574. for (var i = 0; i < foldData.length; i++) {
  6575. var foldLine = foldData[i];
  6576. if (endRow == foldLine.start.row) {
  6577. foldLine.addFold(fold);
  6578. added = true;
  6579. break;
  6580. } else if (startRow == foldLine.end.row) {
  6581. foldLine.addFold(fold);
  6582. added = true;
  6583. if (!fold.sameRow) {
  6584. var foldLineNext = foldData[i + 1];
  6585. if (foldLineNext && foldLineNext.start.row == endRow) {
  6586. foldLine.merge(foldLineNext);
  6587. break;
  6588. }
  6589. }
  6590. break;
  6591. } else if (endRow <= foldLine.start.row) {
  6592. break;
  6593. }
  6594. }
  6595. if (!added)
  6596. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  6597. if (this.$useWrapMode)
  6598. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  6599. else
  6600. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  6601. this.$modified = true;
  6602. this._signal("changeFold", { data: fold, action: "add" });
  6603. return fold;
  6604. };
  6605. this.addFolds = function(folds) {
  6606. folds.forEach(function(fold) {
  6607. this.addFold(fold);
  6608. }, this);
  6609. };
  6610. this.removeFold = function(fold) {
  6611. var foldLine = fold.foldLine;
  6612. var startRow = foldLine.start.row;
  6613. var endRow = foldLine.end.row;
  6614. var foldLines = this.$foldData;
  6615. var folds = foldLine.folds;
  6616. if (folds.length == 1) {
  6617. foldLines.splice(foldLines.indexOf(foldLine), 1);
  6618. } else
  6619. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  6620. folds.pop();
  6621. foldLine.end.row = folds[folds.length - 1].end.row;
  6622. foldLine.end.column = folds[folds.length - 1].end.column;
  6623. } else
  6624. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  6625. folds.shift();
  6626. foldLine.start.row = folds[0].start.row;
  6627. foldLine.start.column = folds[0].start.column;
  6628. } else
  6629. if (fold.sameRow) {
  6630. folds.splice(folds.indexOf(fold), 1);
  6631. } else
  6632. {
  6633. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  6634. folds = newFoldLine.folds;
  6635. folds.shift();
  6636. newFoldLine.start.row = folds[0].start.row;
  6637. newFoldLine.start.column = folds[0].start.column;
  6638. }
  6639. if (!this.$updating) {
  6640. if (this.$useWrapMode)
  6641. this.$updateWrapData(startRow, endRow);
  6642. else
  6643. this.$updateRowLengthCache(startRow, endRow);
  6644. }
  6645. this.$modified = true;
  6646. this._signal("changeFold", { data: fold, action: "remove" });
  6647. };
  6648. this.removeFolds = function(folds) {
  6649. var cloneFolds = [];
  6650. for (var i = 0; i < folds.length; i++) {
  6651. cloneFolds.push(folds[i]);
  6652. }
  6653. cloneFolds.forEach(function(fold) {
  6654. this.removeFold(fold);
  6655. }, this);
  6656. this.$modified = true;
  6657. };
  6658. this.expandFold = function(fold) {
  6659. this.removeFold(fold);
  6660. fold.subFolds.forEach(function(subFold) {
  6661. fold.restoreRange(subFold);
  6662. this.addFold(subFold);
  6663. }, this);
  6664. if (fold.collapseChildren > 0) {
  6665. this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
  6666. }
  6667. fold.subFolds = [];
  6668. };
  6669. this.expandFolds = function(folds) {
  6670. folds.forEach(function(fold) {
  6671. this.expandFold(fold);
  6672. }, this);
  6673. };
  6674. this.unfold = function(location, expandInner) {
  6675. var range, folds;
  6676. if (location == null) {
  6677. range = new Range(0, 0, this.getLength(), 0);
  6678. expandInner = true;
  6679. } else if (typeof location == "number")
  6680. range = new Range(location, 0, location, this.getLine(location).length);
  6681. else if ("row" in location)
  6682. range = Range.fromPoints(location, location);
  6683. else
  6684. range = location;
  6685. folds = this.getFoldsInRangeList(range);
  6686. if (expandInner) {
  6687. this.removeFolds(folds);
  6688. } else {
  6689. var subFolds = folds;
  6690. while (subFolds.length) {
  6691. this.expandFolds(subFolds);
  6692. subFolds = this.getFoldsInRangeList(range);
  6693. }
  6694. }
  6695. if (folds.length)
  6696. return folds;
  6697. };
  6698. this.isRowFolded = function(docRow, startFoldRow) {
  6699. return !!this.getFoldLine(docRow, startFoldRow);
  6700. };
  6701. this.getRowFoldEnd = function(docRow, startFoldRow) {
  6702. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6703. return foldLine ? foldLine.end.row : docRow;
  6704. };
  6705. this.getRowFoldStart = function(docRow, startFoldRow) {
  6706. var foldLine = this.getFoldLine(docRow, startFoldRow);
  6707. return foldLine ? foldLine.start.row : docRow;
  6708. };
  6709. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  6710. if (startRow == null)
  6711. startRow = foldLine.start.row;
  6712. if (startColumn == null)
  6713. startColumn = 0;
  6714. if (endRow == null)
  6715. endRow = foldLine.end.row;
  6716. if (endColumn == null)
  6717. endColumn = this.getLine(endRow).length;
  6718. var doc = this.doc;
  6719. var textLine = "";
  6720. foldLine.walk(function(placeholder, row, column, lastColumn) {
  6721. if (row < startRow)
  6722. return;
  6723. if (row == startRow) {
  6724. if (column < startColumn)
  6725. return;
  6726. lastColumn = Math.max(startColumn, lastColumn);
  6727. }
  6728. if (placeholder != null) {
  6729. textLine += placeholder;
  6730. } else {
  6731. textLine += doc.getLine(row).substring(lastColumn, column);
  6732. }
  6733. }, endRow, endColumn);
  6734. return textLine;
  6735. };
  6736. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  6737. var foldLine = this.getFoldLine(row);
  6738. if (!foldLine) {
  6739. var line;
  6740. line = this.doc.getLine(row);
  6741. return line.substring(startColumn || 0, endColumn || line.length);
  6742. } else {
  6743. return this.getFoldDisplayLine(
  6744. foldLine, row, endColumn, startRow, startColumn);
  6745. }
  6746. };
  6747. this.$cloneFoldData = function() {
  6748. var fd = [];
  6749. fd = this.$foldData.map(function(foldLine) {
  6750. var folds = foldLine.folds.map(function(fold) {
  6751. return fold.clone();
  6752. });
  6753. return new FoldLine(fd, folds);
  6754. });
  6755. return fd;
  6756. };
  6757. this.toggleFold = function(tryToUnfold) {
  6758. var selection = this.selection;
  6759. var range = selection.getRange();
  6760. var fold;
  6761. var bracketPos;
  6762. if (range.isEmpty()) {
  6763. var cursor = range.start;
  6764. fold = this.getFoldAt(cursor.row, cursor.column);
  6765. if (fold) {
  6766. this.expandFold(fold);
  6767. return;
  6768. } else if (bracketPos = this.findMatchingBracket(cursor)) {
  6769. if (range.comparePoint(bracketPos) == 1) {
  6770. range.end = bracketPos;
  6771. } else {
  6772. range.start = bracketPos;
  6773. range.start.column++;
  6774. range.end.column--;
  6775. }
  6776. } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  6777. if (range.comparePoint(bracketPos) == 1)
  6778. range.end = bracketPos;
  6779. else
  6780. range.start = bracketPos;
  6781. range.start.column++;
  6782. } else {
  6783. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  6784. }
  6785. } else {
  6786. var folds = this.getFoldsInRange(range);
  6787. if (tryToUnfold && folds.length) {
  6788. this.expandFolds(folds);
  6789. return;
  6790. } else if (folds.length == 1 ) {
  6791. fold = folds[0];
  6792. }
  6793. }
  6794. if (!fold)
  6795. fold = this.getFoldAt(range.start.row, range.start.column);
  6796. if (fold && fold.range.toString() == range.toString()) {
  6797. this.expandFold(fold);
  6798. return;
  6799. }
  6800. var placeholder = "...";
  6801. if (!range.isMultiLine()) {
  6802. placeholder = this.getTextRange(range);
  6803. if (placeholder.length < 4)
  6804. return;
  6805. placeholder = placeholder.trim().substring(0, 2) + "..";
  6806. }
  6807. this.addFold(placeholder, range);
  6808. };
  6809. this.getCommentFoldRange = function(row, column, dir) {
  6810. var iterator = new TokenIterator(this, row, column);
  6811. var token = iterator.getCurrentToken();
  6812. if (token && /^comment|string/.test(token.type)) {
  6813. var range = new Range();
  6814. var re = new RegExp(token.type.replace(/\..*/, "\\."));
  6815. if (dir != 1) {
  6816. do {
  6817. token = iterator.stepBackward();
  6818. } while (token && re.test(token.type));
  6819. iterator.stepForward();
  6820. }
  6821. range.start.row = iterator.getCurrentTokenRow();
  6822. range.start.column = iterator.getCurrentTokenColumn() + 2;
  6823. iterator = new TokenIterator(this, row, column);
  6824. if (dir != -1) {
  6825. do {
  6826. token = iterator.stepForward();
  6827. } while (token && re.test(token.type));
  6828. token = iterator.stepBackward();
  6829. } else
  6830. token = iterator.getCurrentToken();
  6831. range.end.row = iterator.getCurrentTokenRow();
  6832. range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
  6833. return range;
  6834. }
  6835. };
  6836. this.foldAll = function(startRow, endRow, depth) {
  6837. if (depth == undefined)
  6838. depth = 100000; // JSON.stringify doesn't hanle Infinity
  6839. var foldWidgets = this.foldWidgets;
  6840. if (!foldWidgets)
  6841. return; // mode doesn't support folding
  6842. endRow = endRow || this.getLength();
  6843. startRow = startRow || 0;
  6844. for (var row = startRow; row < endRow; row++) {
  6845. if (foldWidgets[row] == null)
  6846. foldWidgets[row] = this.getFoldWidget(row);
  6847. if (foldWidgets[row] != "start")
  6848. continue;
  6849. var range = this.getFoldWidgetRange(row);
  6850. if (range && range.isMultiLine()
  6851. && range.end.row <= endRow
  6852. && range.start.row >= startRow
  6853. ) {
  6854. row = range.end.row;
  6855. try {
  6856. var fold = this.addFold("...", range);
  6857. if (fold)
  6858. fold.collapseChildren = depth;
  6859. } catch(e) {}
  6860. }
  6861. }
  6862. };
  6863. this.$foldStyles = {
  6864. "manual": 1,
  6865. "markbegin": 1,
  6866. "markbeginend": 1
  6867. };
  6868. this.$foldStyle = "markbegin";
  6869. this.setFoldStyle = function(style) {
  6870. if (!this.$foldStyles[style])
  6871. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  6872. if (this.$foldStyle == style)
  6873. return;
  6874. this.$foldStyle = style;
  6875. if (style == "manual")
  6876. this.unfold();
  6877. var mode = this.$foldMode;
  6878. this.$setFolding(null);
  6879. this.$setFolding(mode);
  6880. };
  6881. this.$setFolding = function(foldMode) {
  6882. if (this.$foldMode == foldMode)
  6883. return;
  6884. this.$foldMode = foldMode;
  6885. this.off('change', this.$updateFoldWidgets);
  6886. this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6887. this._signal("changeAnnotation");
  6888. if (!foldMode || this.$foldStyle == "manual") {
  6889. this.foldWidgets = null;
  6890. return;
  6891. }
  6892. this.foldWidgets = [];
  6893. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  6894. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  6895. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  6896. this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
  6897. this.on('change', this.$updateFoldWidgets);
  6898. this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  6899. };
  6900. this.getParentFoldRangeData = function (row, ignoreCurrent) {
  6901. var fw = this.foldWidgets;
  6902. if (!fw || (ignoreCurrent && fw[row]))
  6903. return {};
  6904. var i = row - 1, firstRange;
  6905. while (i >= 0) {
  6906. var c = fw[i];
  6907. if (c == null)
  6908. c = fw[i] = this.getFoldWidget(i);
  6909. if (c == "start") {
  6910. var range = this.getFoldWidgetRange(i);
  6911. if (!firstRange)
  6912. firstRange = range;
  6913. if (range && range.end.row >= row)
  6914. break;
  6915. }
  6916. i--;
  6917. }
  6918. return {
  6919. range: i !== -1 && range,
  6920. firstRange: firstRange
  6921. };
  6922. };
  6923. this.onFoldWidgetClick = function(row, e) {
  6924. e = e.domEvent;
  6925. var options = {
  6926. children: e.shiftKey,
  6927. all: e.ctrlKey || e.metaKey,
  6928. siblings: e.altKey
  6929. };
  6930. var range = this.$toggleFoldWidget(row, options);
  6931. if (!range) {
  6932. var el = (e.target || e.srcElement);
  6933. if (el && /ace_fold-widget/.test(el.className))
  6934. el.className += " ace_invalid";
  6935. }
  6936. };
  6937. this.$toggleFoldWidget = function(row, options) {
  6938. if (!this.getFoldWidget)
  6939. return;
  6940. var type = this.getFoldWidget(row);
  6941. var line = this.getLine(row);
  6942. var dir = type === "end" ? -1 : 1;
  6943. var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
  6944. if (fold) {
  6945. if (options.children || options.all)
  6946. this.removeFold(fold);
  6947. else
  6948. this.expandFold(fold);
  6949. return;
  6950. }
  6951. var range = this.getFoldWidgetRange(row, true);
  6952. if (range && !range.isMultiLine()) {
  6953. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  6954. if (fold && range.isEqual(fold.range)) {
  6955. this.removeFold(fold);
  6956. return;
  6957. }
  6958. }
  6959. if (options.siblings) {
  6960. var data = this.getParentFoldRangeData(row);
  6961. if (data.range) {
  6962. var startRow = data.range.start.row + 1;
  6963. var endRow = data.range.end.row;
  6964. }
  6965. this.foldAll(startRow, endRow, options.all ? 10000 : 0);
  6966. } else if (options.children) {
  6967. endRow = range ? range.end.row : this.getLength();
  6968. this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
  6969. } else if (range) {
  6970. if (options.all)
  6971. range.collapseChildren = 10000;
  6972. this.addFold("...", range);
  6973. }
  6974. return range;
  6975. };
  6976. this.toggleFoldWidget = function(toggleParent) {
  6977. var row = this.selection.getCursor().row;
  6978. row = this.getRowFoldStart(row);
  6979. var range = this.$toggleFoldWidget(row, {});
  6980. if (range)
  6981. return;
  6982. var data = this.getParentFoldRangeData(row, true);
  6983. range = data.range || data.firstRange;
  6984. if (range) {
  6985. row = range.start.row;
  6986. var fold = this.getFoldAt(row, this.getLine(row).length, 1);
  6987. if (fold) {
  6988. this.removeFold(fold);
  6989. } else {
  6990. this.addFold("...", range);
  6991. }
  6992. }
  6993. };
  6994. this.updateFoldWidgets = function(delta) {
  6995. var firstRow = delta.start.row;
  6996. var len = delta.end.row - firstRow;
  6997. if (len === 0) {
  6998. this.foldWidgets[firstRow] = null;
  6999. } else if (delta.action == 'remove') {
  7000. this.foldWidgets.splice(firstRow, len + 1, null);
  7001. } else {
  7002. var args = Array(len + 1);
  7003. args.unshift(firstRow, 1);
  7004. this.foldWidgets.splice.apply(this.foldWidgets, args);
  7005. }
  7006. };
  7007. this.tokenizerUpdateFoldWidgets = function(e) {
  7008. var rows = e.data;
  7009. if (rows.first != rows.last) {
  7010. if (this.foldWidgets.length > rows.first)
  7011. this.foldWidgets.splice(rows.first, this.foldWidgets.length);
  7012. }
  7013. };
  7014. }
  7015. exports.Folding = Folding;
  7016. });
  7017. ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
  7018. "use strict";
  7019. var TokenIterator = require("../token_iterator").TokenIterator;
  7020. var Range = require("../range").Range;
  7021. function BracketMatch() {
  7022. this.findMatchingBracket = function(position, chr) {
  7023. if (position.column == 0) return null;
  7024. var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
  7025. if (charBeforeCursor == "") return null;
  7026. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  7027. if (!match)
  7028. return null;
  7029. if (match[1])
  7030. return this.$findClosingBracket(match[1], position);
  7031. else
  7032. return this.$findOpeningBracket(match[2], position);
  7033. };
  7034. this.getBracketRange = function(pos) {
  7035. var line = this.getLine(pos.row);
  7036. var before = true, range;
  7037. var chr = line.charAt(pos.column-1);
  7038. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7039. if (!match) {
  7040. chr = line.charAt(pos.column);
  7041. pos = {row: pos.row, column: pos.column + 1};
  7042. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7043. before = false;
  7044. }
  7045. if (!match)
  7046. return null;
  7047. if (match[1]) {
  7048. var bracketPos = this.$findClosingBracket(match[1], pos);
  7049. if (!bracketPos)
  7050. return null;
  7051. range = Range.fromPoints(pos, bracketPos);
  7052. if (!before) {
  7053. range.end.column++;
  7054. range.start.column--;
  7055. }
  7056. range.cursor = range.end;
  7057. } else {
  7058. var bracketPos = this.$findOpeningBracket(match[2], pos);
  7059. if (!bracketPos)
  7060. return null;
  7061. range = Range.fromPoints(bracketPos, pos);
  7062. if (!before) {
  7063. range.start.column++;
  7064. range.end.column--;
  7065. }
  7066. range.cursor = range.start;
  7067. }
  7068. return range;
  7069. };
  7070. this.$brackets = {
  7071. ")": "(",
  7072. "(": ")",
  7073. "]": "[",
  7074. "[": "]",
  7075. "{": "}",
  7076. "}": "{"
  7077. };
  7078. this.$findOpeningBracket = function(bracket, position, typeRe) {
  7079. var openBracket = this.$brackets[bracket];
  7080. var depth = 1;
  7081. var iterator = new TokenIterator(this, position.row, position.column);
  7082. var token = iterator.getCurrentToken();
  7083. if (!token)
  7084. token = iterator.stepForward();
  7085. if (!token)
  7086. return;
  7087. if (!typeRe){
  7088. typeRe = new RegExp(
  7089. "(\\.?" +
  7090. token.type.replace(".", "\\.").replace("rparen", ".paren")
  7091. .replace(/\b(?:end)\b/, "(?:start|begin|end)")
  7092. + ")+"
  7093. );
  7094. }
  7095. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  7096. var value = token.value;
  7097. while (true) {
  7098. while (valueIndex >= 0) {
  7099. var chr = value.charAt(valueIndex);
  7100. if (chr == openBracket) {
  7101. depth -= 1;
  7102. if (depth == 0) {
  7103. return {row: iterator.getCurrentTokenRow(),
  7104. column: valueIndex + iterator.getCurrentTokenColumn()};
  7105. }
  7106. }
  7107. else if (chr == bracket) {
  7108. depth += 1;
  7109. }
  7110. valueIndex -= 1;
  7111. }
  7112. do {
  7113. token = iterator.stepBackward();
  7114. } while (token && !typeRe.test(token.type));
  7115. if (token == null)
  7116. break;
  7117. value = token.value;
  7118. valueIndex = value.length - 1;
  7119. }
  7120. return null;
  7121. };
  7122. this.$findClosingBracket = function(bracket, position, typeRe) {
  7123. var closingBracket = this.$brackets[bracket];
  7124. var depth = 1;
  7125. var iterator = new TokenIterator(this, position.row, position.column);
  7126. var token = iterator.getCurrentToken();
  7127. if (!token)
  7128. token = iterator.stepForward();
  7129. if (!token)
  7130. return;
  7131. if (!typeRe){
  7132. typeRe = new RegExp(
  7133. "(\\.?" +
  7134. token.type.replace(".", "\\.").replace("lparen", ".paren")
  7135. .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
  7136. + ")+"
  7137. );
  7138. }
  7139. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  7140. while (true) {
  7141. var value = token.value;
  7142. var valueLength = value.length;
  7143. while (valueIndex < valueLength) {
  7144. var chr = value.charAt(valueIndex);
  7145. if (chr == closingBracket) {
  7146. depth -= 1;
  7147. if (depth == 0) {
  7148. return {row: iterator.getCurrentTokenRow(),
  7149. column: valueIndex + iterator.getCurrentTokenColumn()};
  7150. }
  7151. }
  7152. else if (chr == bracket) {
  7153. depth += 1;
  7154. }
  7155. valueIndex += 1;
  7156. }
  7157. do {
  7158. token = iterator.stepForward();
  7159. } while (token && !typeRe.test(token.type));
  7160. if (token == null)
  7161. break;
  7162. valueIndex = 0;
  7163. }
  7164. return null;
  7165. };
  7166. }
  7167. exports.BracketMatch = BracketMatch;
  7168. });
  7169. 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) {
  7170. "use strict";
  7171. var oop = require("./lib/oop");
  7172. var lang = require("./lib/lang");
  7173. var config = require("./config");
  7174. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7175. var Selection = require("./selection").Selection;
  7176. var TextMode = require("./mode/text").Mode;
  7177. var Range = require("./range").Range;
  7178. var Document = require("./document").Document;
  7179. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  7180. var SearchHighlight = require("./search_highlight").SearchHighlight;
  7181. var EditSession = function(text, mode) {
  7182. this.$breakpoints = [];
  7183. this.$decorations = [];
  7184. this.$frontMarkers = {};
  7185. this.$backMarkers = {};
  7186. this.$markerId = 1;
  7187. this.$undoSelect = true;
  7188. this.$foldData = [];
  7189. this.$foldData.toString = function() {
  7190. return this.join("\n");
  7191. };
  7192. this.on("changeFold", this.onChangeFold.bind(this));
  7193. this.$onChange = this.onChange.bind(this);
  7194. if (typeof text != "object" || !text.getLine)
  7195. text = new Document(text);
  7196. this.setDocument(text);
  7197. this.selection = new Selection(this);
  7198. config.resetOptions(this);
  7199. this.setMode(mode);
  7200. config._signal("session", this);
  7201. };
  7202. (function() {
  7203. oop.implement(this, EventEmitter);
  7204. this.setDocument = function(doc) {
  7205. if (this.doc)
  7206. this.doc.removeListener("change", this.$onChange);
  7207. this.doc = doc;
  7208. doc.on("change", this.$onChange);
  7209. if (this.bgTokenizer)
  7210. this.bgTokenizer.setDocument(this.getDocument());
  7211. this.resetCaches();
  7212. };
  7213. this.getDocument = function() {
  7214. return this.doc;
  7215. };
  7216. this.$resetRowCache = function(docRow) {
  7217. if (!docRow) {
  7218. this.$docRowCache = [];
  7219. this.$screenRowCache = [];
  7220. return;
  7221. }
  7222. var l = this.$docRowCache.length;
  7223. var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
  7224. if (l > i) {
  7225. this.$docRowCache.splice(i, l);
  7226. this.$screenRowCache.splice(i, l);
  7227. }
  7228. };
  7229. this.$getRowCacheIndex = function(cacheArray, val) {
  7230. var low = 0;
  7231. var hi = cacheArray.length - 1;
  7232. while (low <= hi) {
  7233. var mid = (low + hi) >> 1;
  7234. var c = cacheArray[mid];
  7235. if (val > c)
  7236. low = mid + 1;
  7237. else if (val < c)
  7238. hi = mid - 1;
  7239. else
  7240. return mid;
  7241. }
  7242. return low -1;
  7243. };
  7244. this.resetCaches = function() {
  7245. this.$modified = true;
  7246. this.$wrapData = [];
  7247. this.$rowLengthCache = [];
  7248. this.$resetRowCache(0);
  7249. if (this.bgTokenizer)
  7250. this.bgTokenizer.start(0);
  7251. };
  7252. this.onChangeFold = function(e) {
  7253. var fold = e.data;
  7254. this.$resetRowCache(fold.start.row);
  7255. };
  7256. this.onChange = function(delta) {
  7257. this.$modified = true;
  7258. this.$resetRowCache(delta.start.row);
  7259. var removedFolds = this.$updateInternalDataOnChange(delta);
  7260. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  7261. this.$deltasDoc.push(delta);
  7262. if (removedFolds && removedFolds.length != 0) {
  7263. this.$deltasFold.push({
  7264. action: "removeFolds",
  7265. folds: removedFolds
  7266. });
  7267. }
  7268. this.$informUndoManager.schedule();
  7269. }
  7270. this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
  7271. this._signal("change", delta);
  7272. };
  7273. this.setValue = function(text) {
  7274. this.doc.setValue(text);
  7275. this.selection.moveTo(0, 0);
  7276. this.$resetRowCache(0);
  7277. this.$deltas = [];
  7278. this.$deltasDoc = [];
  7279. this.$deltasFold = [];
  7280. this.setUndoManager(this.$undoManager);
  7281. this.getUndoManager().reset();
  7282. };
  7283. this.getValue =
  7284. this.toString = function() {
  7285. return this.doc.getValue();
  7286. };
  7287. this.getSelection = function() {
  7288. return this.selection;
  7289. };
  7290. this.getState = function(row) {
  7291. return this.bgTokenizer.getState(row);
  7292. };
  7293. this.getTokens = function(row) {
  7294. return this.bgTokenizer.getTokens(row);
  7295. };
  7296. this.getTokenAt = function(row, column) {
  7297. var tokens = this.bgTokenizer.getTokens(row);
  7298. var token, c = 0;
  7299. if (column == null) {
  7300. i = tokens.length - 1;
  7301. c = this.getLine(row).length;
  7302. } else {
  7303. for (var i = 0; i < tokens.length; i++) {
  7304. c += tokens[i].value.length;
  7305. if (c >= column)
  7306. break;
  7307. }
  7308. }
  7309. token = tokens[i];
  7310. if (!token)
  7311. return null;
  7312. token.index = i;
  7313. token.start = c - token.value.length;
  7314. return token;
  7315. };
  7316. this.setUndoManager = function(undoManager) {
  7317. this.$undoManager = undoManager;
  7318. this.$deltas = [];
  7319. this.$deltasDoc = [];
  7320. this.$deltasFold = [];
  7321. if (this.$informUndoManager)
  7322. this.$informUndoManager.cancel();
  7323. if (undoManager) {
  7324. var self = this;
  7325. this.$syncInformUndoManager = function() {
  7326. self.$informUndoManager.cancel();
  7327. if (self.$deltasFold.length) {
  7328. self.$deltas.push({
  7329. group: "fold",
  7330. deltas: self.$deltasFold
  7331. });
  7332. self.$deltasFold = [];
  7333. }
  7334. if (self.$deltasDoc.length) {
  7335. self.$deltas.push({
  7336. group: "doc",
  7337. deltas: self.$deltasDoc
  7338. });
  7339. self.$deltasDoc = [];
  7340. }
  7341. if (self.$deltas.length > 0) {
  7342. undoManager.execute({
  7343. action: "aceupdate",
  7344. args: [self.$deltas, self],
  7345. merge: self.mergeUndoDeltas
  7346. });
  7347. }
  7348. self.mergeUndoDeltas = false;
  7349. self.$deltas = [];
  7350. };
  7351. this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
  7352. }
  7353. };
  7354. this.markUndoGroup = function() {
  7355. if (this.$syncInformUndoManager)
  7356. this.$syncInformUndoManager();
  7357. };
  7358. this.$defaultUndoManager = {
  7359. undo: function() {},
  7360. redo: function() {},
  7361. reset: function() {}
  7362. };
  7363. this.getUndoManager = function() {
  7364. return this.$undoManager || this.$defaultUndoManager;
  7365. };
  7366. this.getTabString = function() {
  7367. if (this.getUseSoftTabs()) {
  7368. return lang.stringRepeat(" ", this.getTabSize());
  7369. } else {
  7370. return "\t";
  7371. }
  7372. };
  7373. this.setUseSoftTabs = function(val) {
  7374. this.setOption("useSoftTabs", val);
  7375. };
  7376. this.getUseSoftTabs = function() {
  7377. return this.$useSoftTabs && !this.$mode.$indentWithTabs;
  7378. };
  7379. this.setTabSize = function(tabSize) {
  7380. this.setOption("tabSize", tabSize);
  7381. };
  7382. this.getTabSize = function() {
  7383. return this.$tabSize;
  7384. };
  7385. this.isTabStop = function(position) {
  7386. return this.$useSoftTabs && (position.column % this.$tabSize === 0);
  7387. };
  7388. this.$overwrite = false;
  7389. this.setOverwrite = function(overwrite) {
  7390. this.setOption("overwrite", overwrite);
  7391. };
  7392. this.getOverwrite = function() {
  7393. return this.$overwrite;
  7394. };
  7395. this.toggleOverwrite = function() {
  7396. this.setOverwrite(!this.$overwrite);
  7397. };
  7398. this.addGutterDecoration = function(row, className) {
  7399. if (!this.$decorations[row])
  7400. this.$decorations[row] = "";
  7401. this.$decorations[row] += " " + className;
  7402. this._signal("changeBreakpoint", {});
  7403. };
  7404. this.removeGutterDecoration = function(row, className) {
  7405. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  7406. this._signal("changeBreakpoint", {});
  7407. };
  7408. this.getBreakpoints = function() {
  7409. return this.$breakpoints;
  7410. };
  7411. this.setBreakpoints = function(rows) {
  7412. this.$breakpoints = [];
  7413. for (var i=0; i<rows.length; i++) {
  7414. this.$breakpoints[rows[i]] = "ace_breakpoint";
  7415. }
  7416. this._signal("changeBreakpoint", {});
  7417. };
  7418. this.clearBreakpoints = function() {
  7419. this.$breakpoints = [];
  7420. this._signal("changeBreakpoint", {});
  7421. };
  7422. this.setBreakpoint = function(row, className) {
  7423. if (className === undefined)
  7424. className = "ace_breakpoint";
  7425. if (className)
  7426. this.$breakpoints[row] = className;
  7427. else
  7428. delete this.$breakpoints[row];
  7429. this._signal("changeBreakpoint", {});
  7430. };
  7431. this.clearBreakpoint = function(row) {
  7432. delete this.$breakpoints[row];
  7433. this._signal("changeBreakpoint", {});
  7434. };
  7435. this.addMarker = function(range, clazz, type, inFront) {
  7436. var id = this.$markerId++;
  7437. var marker = {
  7438. range : range,
  7439. type : type || "line",
  7440. renderer: typeof type == "function" ? type : null,
  7441. clazz : clazz,
  7442. inFront: !!inFront,
  7443. id: id
  7444. };
  7445. if (inFront) {
  7446. this.$frontMarkers[id] = marker;
  7447. this._signal("changeFrontMarker");
  7448. } else {
  7449. this.$backMarkers[id] = marker;
  7450. this._signal("changeBackMarker");
  7451. }
  7452. return id;
  7453. };
  7454. this.addDynamicMarker = function(marker, inFront) {
  7455. if (!marker.update)
  7456. return;
  7457. var id = this.$markerId++;
  7458. marker.id = id;
  7459. marker.inFront = !!inFront;
  7460. if (inFront) {
  7461. this.$frontMarkers[id] = marker;
  7462. this._signal("changeFrontMarker");
  7463. } else {
  7464. this.$backMarkers[id] = marker;
  7465. this._signal("changeBackMarker");
  7466. }
  7467. return marker;
  7468. };
  7469. this.removeMarker = function(markerId) {
  7470. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  7471. if (!marker)
  7472. return;
  7473. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  7474. if (marker) {
  7475. delete (markers[markerId]);
  7476. this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  7477. }
  7478. };
  7479. this.getMarkers = function(inFront) {
  7480. return inFront ? this.$frontMarkers : this.$backMarkers;
  7481. };
  7482. this.highlight = function(re) {
  7483. if (!this.$searchHighlight) {
  7484. var highlight = new SearchHighlight(null, "ace_selected-word", "text");
  7485. this.$searchHighlight = this.addDynamicMarker(highlight);
  7486. }
  7487. this.$searchHighlight.setRegexp(re);
  7488. };
  7489. this.highlightLines = function(startRow, endRow, clazz, inFront) {
  7490. if (typeof endRow != "number") {
  7491. clazz = endRow;
  7492. endRow = startRow;
  7493. }
  7494. if (!clazz)
  7495. clazz = "ace_step";
  7496. var range = new Range(startRow, 0, endRow, Infinity);
  7497. range.id = this.addMarker(range, clazz, "fullLine", inFront);
  7498. return range;
  7499. };
  7500. this.setAnnotations = function(annotations) {
  7501. this.$annotations = annotations;
  7502. this._signal("changeAnnotation", {});
  7503. };
  7504. this.getAnnotations = function() {
  7505. return this.$annotations || [];
  7506. };
  7507. this.clearAnnotations = function() {
  7508. this.setAnnotations([]);
  7509. };
  7510. this.$detectNewLine = function(text) {
  7511. var match = text.match(/^.*?(\r?\n)/m);
  7512. if (match) {
  7513. this.$autoNewLine = match[1];
  7514. } else {
  7515. this.$autoNewLine = "\n";
  7516. }
  7517. };
  7518. this.getWordRange = function(row, column) {
  7519. var line = this.getLine(row);
  7520. var inToken = false;
  7521. if (column > 0)
  7522. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  7523. if (!inToken)
  7524. inToken = !!line.charAt(column).match(this.tokenRe);
  7525. if (inToken)
  7526. var re = this.tokenRe;
  7527. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  7528. var re = /\s/;
  7529. else
  7530. var re = this.nonTokenRe;
  7531. var start = column;
  7532. if (start > 0) {
  7533. do {
  7534. start--;
  7535. }
  7536. while (start >= 0 && line.charAt(start).match(re));
  7537. start++;
  7538. }
  7539. var end = column;
  7540. while (end < line.length && line.charAt(end).match(re)) {
  7541. end++;
  7542. }
  7543. return new Range(row, start, row, end);
  7544. };
  7545. this.getAWordRange = function(row, column) {
  7546. var wordRange = this.getWordRange(row, column);
  7547. var line = this.getLine(wordRange.end.row);
  7548. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  7549. wordRange.end.column += 1;
  7550. }
  7551. return wordRange;
  7552. };
  7553. this.setNewLineMode = function(newLineMode) {
  7554. this.doc.setNewLineMode(newLineMode);
  7555. };
  7556. this.getNewLineMode = function() {
  7557. return this.doc.getNewLineMode();
  7558. };
  7559. this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
  7560. this.getUseWorker = function() { return this.$useWorker; };
  7561. this.onReloadTokenizer = function(e) {
  7562. var rows = e.data;
  7563. this.bgTokenizer.start(rows.first);
  7564. this._signal("tokenizerUpdate", e);
  7565. };
  7566. this.$modes = {};
  7567. this.$mode = null;
  7568. this.$modeId = null;
  7569. this.setMode = function(mode, cb) {
  7570. if (mode && typeof mode === "object") {
  7571. if (mode.getTokenizer)
  7572. return this.$onChangeMode(mode);
  7573. var options = mode;
  7574. var path = options.path;
  7575. } else {
  7576. path = mode || "ace/mode/text";
  7577. }
  7578. if (!this.$modes["ace/mode/text"])
  7579. this.$modes["ace/mode/text"] = new TextMode();
  7580. if (this.$modes[path] && !options) {
  7581. this.$onChangeMode(this.$modes[path]);
  7582. cb && cb();
  7583. return;
  7584. }
  7585. this.$modeId = path;
  7586. config.loadModule(["mode", path], function(m) {
  7587. if (this.$modeId !== path)
  7588. return cb && cb();
  7589. if (this.$modes[path] && !options) {
  7590. this.$onChangeMode(this.$modes[path]);
  7591. } else if (m && m.Mode) {
  7592. m = new m.Mode(options);
  7593. if (!options) {
  7594. this.$modes[path] = m;
  7595. m.$id = path;
  7596. }
  7597. this.$onChangeMode(m);
  7598. }
  7599. cb && cb();
  7600. }.bind(this));
  7601. if (!this.$mode)
  7602. this.$onChangeMode(this.$modes["ace/mode/text"], true);
  7603. };
  7604. this.$onChangeMode = function(mode, $isPlaceholder) {
  7605. if (!$isPlaceholder)
  7606. this.$modeId = mode.$id;
  7607. if (this.$mode === mode)
  7608. return;
  7609. this.$mode = mode;
  7610. this.$stopWorker();
  7611. if (this.$useWorker)
  7612. this.$startWorker();
  7613. var tokenizer = mode.getTokenizer();
  7614. if(tokenizer.addEventListener !== undefined) {
  7615. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  7616. tokenizer.addEventListener("update", onReloadTokenizer);
  7617. }
  7618. if (!this.bgTokenizer) {
  7619. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  7620. var _self = this;
  7621. this.bgTokenizer.addEventListener("update", function(e) {
  7622. _self._signal("tokenizerUpdate", e);
  7623. });
  7624. } else {
  7625. this.bgTokenizer.setTokenizer(tokenizer);
  7626. }
  7627. this.bgTokenizer.setDocument(this.getDocument());
  7628. this.tokenRe = mode.tokenRe;
  7629. this.nonTokenRe = mode.nonTokenRe;
  7630. if (!$isPlaceholder) {
  7631. if (mode.attachToSession)
  7632. mode.attachToSession(this);
  7633. this.$options.wrapMethod.set.call(this, this.$wrapMethod);
  7634. this.$setFolding(mode.foldingRules);
  7635. this.bgTokenizer.start(0);
  7636. this._emit("changeMode");
  7637. }
  7638. };
  7639. this.$stopWorker = function() {
  7640. if (this.$worker) {
  7641. this.$worker.terminate();
  7642. this.$worker = null;
  7643. }
  7644. };
  7645. this.$startWorker = function() {
  7646. try {
  7647. this.$worker = this.$mode.createWorker(this);
  7648. } catch (e) {
  7649. config.warn("Could not load worker", e);
  7650. this.$worker = null;
  7651. }
  7652. };
  7653. this.getMode = function() {
  7654. return this.$mode;
  7655. };
  7656. this.$scrollTop = 0;
  7657. this.setScrollTop = function(scrollTop) {
  7658. if (this.$scrollTop === scrollTop || isNaN(scrollTop))
  7659. return;
  7660. this.$scrollTop = scrollTop;
  7661. this._signal("changeScrollTop", scrollTop);
  7662. };
  7663. this.getScrollTop = function() {
  7664. return this.$scrollTop;
  7665. };
  7666. this.$scrollLeft = 0;
  7667. this.setScrollLeft = function(scrollLeft) {
  7668. if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
  7669. return;
  7670. this.$scrollLeft = scrollLeft;
  7671. this._signal("changeScrollLeft", scrollLeft);
  7672. };
  7673. this.getScrollLeft = function() {
  7674. return this.$scrollLeft;
  7675. };
  7676. this.getScreenWidth = function() {
  7677. this.$computeWidth();
  7678. if (this.lineWidgets)
  7679. return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
  7680. return this.screenWidth;
  7681. };
  7682. this.getLineWidgetMaxWidth = function() {
  7683. if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
  7684. var width = 0;
  7685. this.lineWidgets.forEach(function(w) {
  7686. if (w && w.screenWidth > width)
  7687. width = w.screenWidth;
  7688. });
  7689. return this.lineWidgetWidth = width;
  7690. };
  7691. this.$computeWidth = function(force) {
  7692. if (this.$modified || force) {
  7693. this.$modified = false;
  7694. if (this.$useWrapMode)
  7695. return this.screenWidth = this.$wrapLimit;
  7696. var lines = this.doc.getAllLines();
  7697. var cache = this.$rowLengthCache;
  7698. var longestScreenLine = 0;
  7699. var foldIndex = 0;
  7700. var foldLine = this.$foldData[foldIndex];
  7701. var foldStart = foldLine ? foldLine.start.row : Infinity;
  7702. var len = lines.length;
  7703. for (var i = 0; i < len; i++) {
  7704. if (i > foldStart) {
  7705. i = foldLine.end.row + 1;
  7706. if (i >= len)
  7707. break;
  7708. foldLine = this.$foldData[foldIndex++];
  7709. foldStart = foldLine ? foldLine.start.row : Infinity;
  7710. }
  7711. if (cache[i] == null)
  7712. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  7713. if (cache[i] > longestScreenLine)
  7714. longestScreenLine = cache[i];
  7715. }
  7716. this.screenWidth = longestScreenLine;
  7717. }
  7718. };
  7719. this.getLine = function(row) {
  7720. return this.doc.getLine(row);
  7721. };
  7722. this.getLines = function(firstRow, lastRow) {
  7723. return this.doc.getLines(firstRow, lastRow);
  7724. };
  7725. this.getLength = function() {
  7726. return this.doc.getLength();
  7727. };
  7728. this.getTextRange = function(range) {
  7729. return this.doc.getTextRange(range || this.selection.getRange());
  7730. };
  7731. this.insert = function(position, text) {
  7732. return this.doc.insert(position, text);
  7733. };
  7734. this.remove = function(range) {
  7735. return this.doc.remove(range);
  7736. };
  7737. this.removeFullLines = function(firstRow, lastRow){
  7738. return this.doc.removeFullLines(firstRow, lastRow);
  7739. };
  7740. this.undoChanges = function(deltas, dontSelect) {
  7741. if (!deltas.length)
  7742. return;
  7743. this.$fromUndo = true;
  7744. var lastUndoRange = null;
  7745. for (var i = deltas.length - 1; i != -1; i--) {
  7746. var delta = deltas[i];
  7747. if (delta.group == "doc") {
  7748. this.doc.revertDeltas(delta.deltas);
  7749. lastUndoRange =
  7750. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  7751. } else {
  7752. delta.deltas.forEach(function(foldDelta) {
  7753. this.addFolds(foldDelta.folds);
  7754. }, this);
  7755. }
  7756. }
  7757. this.$fromUndo = false;
  7758. lastUndoRange &&
  7759. this.$undoSelect &&
  7760. !dontSelect &&
  7761. this.selection.setSelectionRange(lastUndoRange);
  7762. return lastUndoRange;
  7763. };
  7764. this.redoChanges = function(deltas, dontSelect) {
  7765. if (!deltas.length)
  7766. return;
  7767. this.$fromUndo = true;
  7768. var lastUndoRange = null;
  7769. for (var i = 0; i < deltas.length; i++) {
  7770. var delta = deltas[i];
  7771. if (delta.group == "doc") {
  7772. this.doc.applyDeltas(delta.deltas);
  7773. lastUndoRange =
  7774. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  7775. }
  7776. }
  7777. this.$fromUndo = false;
  7778. lastUndoRange &&
  7779. this.$undoSelect &&
  7780. !dontSelect &&
  7781. this.selection.setSelectionRange(lastUndoRange);
  7782. return lastUndoRange;
  7783. };
  7784. this.setUndoSelect = function(enable) {
  7785. this.$undoSelect = enable;
  7786. };
  7787. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  7788. function isInsert(delta) {
  7789. return isUndo ? delta.action !== "insert" : delta.action === "insert";
  7790. }
  7791. var delta = deltas[0];
  7792. var range, point;
  7793. var lastDeltaIsInsert = false;
  7794. if (isInsert(delta)) {
  7795. range = Range.fromPoints(delta.start, delta.end);
  7796. lastDeltaIsInsert = true;
  7797. } else {
  7798. range = Range.fromPoints(delta.start, delta.start);
  7799. lastDeltaIsInsert = false;
  7800. }
  7801. for (var i = 1; i < deltas.length; i++) {
  7802. delta = deltas[i];
  7803. if (isInsert(delta)) {
  7804. point = delta.start;
  7805. if (range.compare(point.row, point.column) == -1) {
  7806. range.setStart(point);
  7807. }
  7808. point = delta.end;
  7809. if (range.compare(point.row, point.column) == 1) {
  7810. range.setEnd(point);
  7811. }
  7812. lastDeltaIsInsert = true;
  7813. } else {
  7814. point = delta.start;
  7815. if (range.compare(point.row, point.column) == -1) {
  7816. range = Range.fromPoints(delta.start, delta.start);
  7817. }
  7818. lastDeltaIsInsert = false;
  7819. }
  7820. }
  7821. if (lastUndoRange != null) {
  7822. if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
  7823. lastUndoRange.start.column += range.end.column - range.start.column;
  7824. lastUndoRange.end.column += range.end.column - range.start.column;
  7825. }
  7826. var cmp = lastUndoRange.compareRange(range);
  7827. if (cmp == 1) {
  7828. range.setStart(lastUndoRange.start);
  7829. } else if (cmp == -1) {
  7830. range.setEnd(lastUndoRange.end);
  7831. }
  7832. }
  7833. return range;
  7834. };
  7835. this.replace = function(range, text) {
  7836. return this.doc.replace(range, text);
  7837. };
  7838. this.moveText = function(fromRange, toPosition, copy) {
  7839. var text = this.getTextRange(fromRange);
  7840. var folds = this.getFoldsInRange(fromRange);
  7841. var toRange = Range.fromPoints(toPosition, toPosition);
  7842. if (!copy) {
  7843. this.remove(fromRange);
  7844. var rowDiff = fromRange.start.row - fromRange.end.row;
  7845. var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
  7846. if (collDiff) {
  7847. if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
  7848. toRange.start.column += collDiff;
  7849. if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
  7850. toRange.end.column += collDiff;
  7851. }
  7852. if (rowDiff && toRange.start.row >= fromRange.end.row) {
  7853. toRange.start.row += rowDiff;
  7854. toRange.end.row += rowDiff;
  7855. }
  7856. }
  7857. toRange.end = this.insert(toRange.start, text);
  7858. if (folds.length) {
  7859. var oldStart = fromRange.start;
  7860. var newStart = toRange.start;
  7861. var rowDiff = newStart.row - oldStart.row;
  7862. var collDiff = newStart.column - oldStart.column;
  7863. this.addFolds(folds.map(function(x) {
  7864. x = x.clone();
  7865. if (x.start.row == oldStart.row)
  7866. x.start.column += collDiff;
  7867. if (x.end.row == oldStart.row)
  7868. x.end.column += collDiff;
  7869. x.start.row += rowDiff;
  7870. x.end.row += rowDiff;
  7871. return x;
  7872. }));
  7873. }
  7874. return toRange;
  7875. };
  7876. this.indentRows = function(startRow, endRow, indentString) {
  7877. indentString = indentString.replace(/\t/g, this.getTabString());
  7878. for (var row=startRow; row<=endRow; row++)
  7879. this.doc.insertInLine({row: row, column: 0}, indentString);
  7880. };
  7881. this.outdentRows = function (range) {
  7882. var rowRange = range.collapseRows();
  7883. var deleteRange = new Range(0, 0, 0, 0);
  7884. var size = this.getTabSize();
  7885. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  7886. var line = this.getLine(i);
  7887. deleteRange.start.row = i;
  7888. deleteRange.end.row = i;
  7889. for (var j = 0; j < size; ++j)
  7890. if (line.charAt(j) != ' ')
  7891. break;
  7892. if (j < size && line.charAt(j) == '\t') {
  7893. deleteRange.start.column = j;
  7894. deleteRange.end.column = j + 1;
  7895. } else {
  7896. deleteRange.start.column = 0;
  7897. deleteRange.end.column = j;
  7898. }
  7899. this.remove(deleteRange);
  7900. }
  7901. };
  7902. this.$moveLines = function(firstRow, lastRow, dir) {
  7903. firstRow = this.getRowFoldStart(firstRow);
  7904. lastRow = this.getRowFoldEnd(lastRow);
  7905. if (dir < 0) {
  7906. var row = this.getRowFoldStart(firstRow + dir);
  7907. if (row < 0) return 0;
  7908. var diff = row-firstRow;
  7909. } else if (dir > 0) {
  7910. var row = this.getRowFoldEnd(lastRow + dir);
  7911. if (row > this.doc.getLength()-1) return 0;
  7912. var diff = row-lastRow;
  7913. } else {
  7914. firstRow = this.$clipRowToDocument(firstRow);
  7915. lastRow = this.$clipRowToDocument(lastRow);
  7916. var diff = lastRow - firstRow + 1;
  7917. }
  7918. var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
  7919. var folds = this.getFoldsInRange(range).map(function(x){
  7920. x = x.clone();
  7921. x.start.row += diff;
  7922. x.end.row += diff;
  7923. return x;
  7924. });
  7925. var lines = dir == 0
  7926. ? this.doc.getLines(firstRow, lastRow)
  7927. : this.doc.removeFullLines(firstRow, lastRow);
  7928. this.doc.insertFullLines(firstRow+diff, lines);
  7929. folds.length && this.addFolds(folds);
  7930. return diff;
  7931. };
  7932. this.moveLinesUp = function(firstRow, lastRow) {
  7933. return this.$moveLines(firstRow, lastRow, -1);
  7934. };
  7935. this.moveLinesDown = function(firstRow, lastRow) {
  7936. return this.$moveLines(firstRow, lastRow, 1);
  7937. };
  7938. this.duplicateLines = function(firstRow, lastRow) {
  7939. return this.$moveLines(firstRow, lastRow, 0);
  7940. };
  7941. this.$clipRowToDocument = function(row) {
  7942. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  7943. };
  7944. this.$clipColumnToRow = function(row, column) {
  7945. if (column < 0)
  7946. return 0;
  7947. return Math.min(this.doc.getLine(row).length, column);
  7948. };
  7949. this.$clipPositionToDocument = function(row, column) {
  7950. column = Math.max(0, column);
  7951. if (row < 0) {
  7952. row = 0;
  7953. column = 0;
  7954. } else {
  7955. var len = this.doc.getLength();
  7956. if (row >= len) {
  7957. row = len - 1;
  7958. column = this.doc.getLine(len-1).length;
  7959. } else {
  7960. column = Math.min(this.doc.getLine(row).length, column);
  7961. }
  7962. }
  7963. return {
  7964. row: row,
  7965. column: column
  7966. };
  7967. };
  7968. this.$clipRangeToDocument = function(range) {
  7969. if (range.start.row < 0) {
  7970. range.start.row = 0;
  7971. range.start.column = 0;
  7972. } else {
  7973. range.start.column = this.$clipColumnToRow(
  7974. range.start.row,
  7975. range.start.column
  7976. );
  7977. }
  7978. var len = this.doc.getLength() - 1;
  7979. if (range.end.row > len) {
  7980. range.end.row = len;
  7981. range.end.column = this.doc.getLine(len).length;
  7982. } else {
  7983. range.end.column = this.$clipColumnToRow(
  7984. range.end.row,
  7985. range.end.column
  7986. );
  7987. }
  7988. return range;
  7989. };
  7990. this.$wrapLimit = 80;
  7991. this.$useWrapMode = false;
  7992. this.$wrapLimitRange = {
  7993. min : null,
  7994. max : null
  7995. };
  7996. this.setUseWrapMode = function(useWrapMode) {
  7997. if (useWrapMode != this.$useWrapMode) {
  7998. this.$useWrapMode = useWrapMode;
  7999. this.$modified = true;
  8000. this.$resetRowCache(0);
  8001. if (useWrapMode) {
  8002. var len = this.getLength();
  8003. this.$wrapData = Array(len);
  8004. this.$updateWrapData(0, len - 1);
  8005. }
  8006. this._signal("changeWrapMode");
  8007. }
  8008. };
  8009. this.getUseWrapMode = function() {
  8010. return this.$useWrapMode;
  8011. };
  8012. this.setWrapLimitRange = function(min, max) {
  8013. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  8014. this.$wrapLimitRange = { min: min, max: max };
  8015. this.$modified = true;
  8016. if (this.$useWrapMode)
  8017. this._signal("changeWrapMode");
  8018. }
  8019. };
  8020. this.adjustWrapLimit = function(desiredLimit, $printMargin) {
  8021. var limits = this.$wrapLimitRange;
  8022. if (limits.max < 0)
  8023. limits = {min: $printMargin, max: $printMargin};
  8024. var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
  8025. if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
  8026. this.$wrapLimit = wrapLimit;
  8027. this.$modified = true;
  8028. if (this.$useWrapMode) {
  8029. this.$updateWrapData(0, this.getLength() - 1);
  8030. this.$resetRowCache(0);
  8031. this._signal("changeWrapLimit");
  8032. }
  8033. return true;
  8034. }
  8035. return false;
  8036. };
  8037. this.$constrainWrapLimit = function(wrapLimit, min, max) {
  8038. if (min)
  8039. wrapLimit = Math.max(min, wrapLimit);
  8040. if (max)
  8041. wrapLimit = Math.min(max, wrapLimit);
  8042. return wrapLimit;
  8043. };
  8044. this.getWrapLimit = function() {
  8045. return this.$wrapLimit;
  8046. };
  8047. this.setWrapLimit = function (limit) {
  8048. this.setWrapLimitRange(limit, limit);
  8049. };
  8050. this.getWrapLimitRange = function() {
  8051. return {
  8052. min : this.$wrapLimitRange.min,
  8053. max : this.$wrapLimitRange.max
  8054. };
  8055. };
  8056. this.$updateInternalDataOnChange = function(delta) {
  8057. var useWrapMode = this.$useWrapMode;
  8058. var action = delta.action;
  8059. var start = delta.start;
  8060. var end = delta.end;
  8061. var firstRow = start.row;
  8062. var lastRow = end.row;
  8063. var len = lastRow - firstRow;
  8064. var removedFolds = null;
  8065. this.$updating = true;
  8066. if (len != 0) {
  8067. if (action === "remove") {
  8068. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  8069. var foldLines = this.$foldData;
  8070. removedFolds = this.getFoldsInRange(delta);
  8071. this.removeFolds(removedFolds);
  8072. var foldLine = this.getFoldLine(end.row);
  8073. var idx = 0;
  8074. if (foldLine) {
  8075. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  8076. foldLine.shiftRow(-len);
  8077. var foldLineBefore = this.getFoldLine(firstRow);
  8078. if (foldLineBefore && foldLineBefore !== foldLine) {
  8079. foldLineBefore.merge(foldLine);
  8080. foldLine = foldLineBefore;
  8081. }
  8082. idx = foldLines.indexOf(foldLine) + 1;
  8083. }
  8084. for (idx; idx < foldLines.length; idx++) {
  8085. var foldLine = foldLines[idx];
  8086. if (foldLine.start.row >= end.row) {
  8087. foldLine.shiftRow(-len);
  8088. }
  8089. }
  8090. lastRow = firstRow;
  8091. } else {
  8092. var args = Array(len);
  8093. args.unshift(firstRow, 0);
  8094. var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
  8095. arr.splice.apply(arr, args);
  8096. var foldLines = this.$foldData;
  8097. var foldLine = this.getFoldLine(firstRow);
  8098. var idx = 0;
  8099. if (foldLine) {
  8100. var cmp = foldLine.range.compareInside(start.row, start.column);
  8101. if (cmp == 0) {
  8102. foldLine = foldLine.split(start.row, start.column);
  8103. if (foldLine) {
  8104. foldLine.shiftRow(len);
  8105. foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
  8106. }
  8107. } else
  8108. if (cmp == -1) {
  8109. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  8110. foldLine.shiftRow(len);
  8111. }
  8112. idx = foldLines.indexOf(foldLine) + 1;
  8113. }
  8114. for (idx; idx < foldLines.length; idx++) {
  8115. var foldLine = foldLines[idx];
  8116. if (foldLine.start.row >= firstRow) {
  8117. foldLine.shiftRow(len);
  8118. }
  8119. }
  8120. }
  8121. } else {
  8122. len = Math.abs(delta.start.column - delta.end.column);
  8123. if (action === "remove") {
  8124. removedFolds = this.getFoldsInRange(delta);
  8125. this.removeFolds(removedFolds);
  8126. len = -len;
  8127. }
  8128. var foldLine = this.getFoldLine(firstRow);
  8129. if (foldLine) {
  8130. foldLine.addRemoveChars(firstRow, start.column, len);
  8131. }
  8132. }
  8133. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  8134. console.error("doc.getLength() and $wrapData.length have to be the same!");
  8135. }
  8136. this.$updating = false;
  8137. if (useWrapMode)
  8138. this.$updateWrapData(firstRow, lastRow);
  8139. else
  8140. this.$updateRowLengthCache(firstRow, lastRow);
  8141. return removedFolds;
  8142. };
  8143. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  8144. this.$rowLengthCache[firstRow] = null;
  8145. this.$rowLengthCache[lastRow] = null;
  8146. };
  8147. this.$updateWrapData = function(firstRow, lastRow) {
  8148. var lines = this.doc.getAllLines();
  8149. var tabSize = this.getTabSize();
  8150. var wrapData = this.$wrapData;
  8151. var wrapLimit = this.$wrapLimit;
  8152. var tokens;
  8153. var foldLine;
  8154. var row = firstRow;
  8155. lastRow = Math.min(lastRow, lines.length - 1);
  8156. while (row <= lastRow) {
  8157. foldLine = this.getFoldLine(row, foldLine);
  8158. if (!foldLine) {
  8159. tokens = this.$getDisplayTokens(lines[row]);
  8160. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8161. row ++;
  8162. } else {
  8163. tokens = [];
  8164. foldLine.walk(function(placeholder, row, column, lastColumn) {
  8165. var walkTokens;
  8166. if (placeholder != null) {
  8167. walkTokens = this.$getDisplayTokens(
  8168. placeholder, tokens.length);
  8169. walkTokens[0] = PLACEHOLDER_START;
  8170. for (var i = 1; i < walkTokens.length; i++) {
  8171. walkTokens[i] = PLACEHOLDER_BODY;
  8172. }
  8173. } else {
  8174. walkTokens = this.$getDisplayTokens(
  8175. lines[row].substring(lastColumn, column),
  8176. tokens.length);
  8177. }
  8178. tokens = tokens.concat(walkTokens);
  8179. }.bind(this),
  8180. foldLine.end.row,
  8181. lines[foldLine.end.row].length + 1
  8182. );
  8183. wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8184. row = foldLine.end.row + 1;
  8185. }
  8186. }
  8187. };
  8188. var CHAR = 1,
  8189. CHAR_EXT = 2,
  8190. PLACEHOLDER_START = 3,
  8191. PLACEHOLDER_BODY = 4,
  8192. PUNCTUATION = 9,
  8193. SPACE = 10,
  8194. TAB = 11,
  8195. TAB_SPACE = 12;
  8196. this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
  8197. if (tokens.length == 0) {
  8198. return [];
  8199. }
  8200. var splits = [];
  8201. var displayLength = tokens.length;
  8202. var lastSplit = 0, lastDocSplit = 0;
  8203. var isCode = this.$wrapAsCode;
  8204. var indentedSoftWrap = this.$indentedSoftWrap;
  8205. var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
  8206. || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
  8207. function getWrapIndent() {
  8208. var indentation = 0;
  8209. if (maxIndent === 0)
  8210. return indentation;
  8211. if (indentedSoftWrap) {
  8212. for (var i = 0; i < tokens.length; i++) {
  8213. var token = tokens[i];
  8214. if (token == SPACE)
  8215. indentation += 1;
  8216. else if (token == TAB)
  8217. indentation += tabSize;
  8218. else if (token == TAB_SPACE)
  8219. continue;
  8220. else
  8221. break;
  8222. }
  8223. }
  8224. if (isCode && indentedSoftWrap !== false)
  8225. indentation += tabSize;
  8226. return Math.min(indentation, maxIndent);
  8227. }
  8228. function addSplit(screenPos) {
  8229. var displayed = tokens.slice(lastSplit, screenPos);
  8230. var len = displayed.length;
  8231. displayed.join("")
  8232. .replace(/12/g, function() {
  8233. len -= 1;
  8234. })
  8235. .replace(/2/g, function() {
  8236. len -= 1;
  8237. });
  8238. if (!splits.length) {
  8239. indent = getWrapIndent();
  8240. splits.indent = indent;
  8241. }
  8242. lastDocSplit += len;
  8243. splits.push(lastDocSplit);
  8244. lastSplit = screenPos;
  8245. }
  8246. var indent = 0;
  8247. while (displayLength - lastSplit > wrapLimit - indent) {
  8248. var split = lastSplit + wrapLimit - indent;
  8249. if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
  8250. addSplit(split);
  8251. continue;
  8252. }
  8253. if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
  8254. for (split; split != lastSplit - 1; split--) {
  8255. if (tokens[split] == PLACEHOLDER_START) {
  8256. break;
  8257. }
  8258. }
  8259. if (split > lastSplit) {
  8260. addSplit(split);
  8261. continue;
  8262. }
  8263. split = lastSplit + wrapLimit;
  8264. for (split; split < tokens.length; split++) {
  8265. if (tokens[split] != PLACEHOLDER_BODY) {
  8266. break;
  8267. }
  8268. }
  8269. if (split == tokens.length) {
  8270. break; // Breaks the while-loop.
  8271. }
  8272. addSplit(split);
  8273. continue;
  8274. }
  8275. var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
  8276. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8277. split --;
  8278. }
  8279. if (isCode) {
  8280. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8281. split --;
  8282. }
  8283. while (split > minSplit && tokens[split] == PUNCTUATION) {
  8284. split --;
  8285. }
  8286. } else {
  8287. while (split > minSplit && tokens[split] < SPACE) {
  8288. split --;
  8289. }
  8290. }
  8291. if (split > minSplit) {
  8292. addSplit(++split);
  8293. continue;
  8294. }
  8295. split = lastSplit + wrapLimit;
  8296. if (tokens[split] == CHAR_EXT)
  8297. split--;
  8298. addSplit(split - indent);
  8299. }
  8300. return splits;
  8301. };
  8302. this.$getDisplayTokens = function(str, offset) {
  8303. var arr = [];
  8304. var tabSize;
  8305. offset = offset || 0;
  8306. for (var i = 0; i < str.length; i++) {
  8307. var c = str.charCodeAt(i);
  8308. if (c == 9) {
  8309. tabSize = this.getScreenTabSize(arr.length + offset);
  8310. arr.push(TAB);
  8311. for (var n = 1; n < tabSize; n++) {
  8312. arr.push(TAB_SPACE);
  8313. }
  8314. }
  8315. else if (c == 32) {
  8316. arr.push(SPACE);
  8317. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  8318. arr.push(PUNCTUATION);
  8319. }
  8320. else if (c >= 0x1100 && isFullWidth(c)) {
  8321. arr.push(CHAR, CHAR_EXT);
  8322. } else {
  8323. arr.push(CHAR);
  8324. }
  8325. }
  8326. return arr;
  8327. };
  8328. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8329. if (maxScreenColumn == 0)
  8330. return [0, 0];
  8331. if (maxScreenColumn == null)
  8332. maxScreenColumn = Infinity;
  8333. screenColumn = screenColumn || 0;
  8334. var c, column;
  8335. for (column = 0; column < str.length; column++) {
  8336. c = str.charCodeAt(column);
  8337. if (c == 9) {
  8338. screenColumn += this.getScreenTabSize(screenColumn);
  8339. }
  8340. else if (c >= 0x1100 && isFullWidth(c)) {
  8341. screenColumn += 2;
  8342. } else {
  8343. screenColumn += 1;
  8344. }
  8345. if (screenColumn > maxScreenColumn) {
  8346. break;
  8347. }
  8348. }
  8349. return [screenColumn, column];
  8350. };
  8351. this.lineWidgets = null;
  8352. this.getRowLength = function(row) {
  8353. if (this.lineWidgets)
  8354. var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  8355. else
  8356. h = 0
  8357. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8358. return 1 + h;
  8359. } else {
  8360. return this.$wrapData[row].length + 1 + h;
  8361. }
  8362. };
  8363. this.getRowLineCount = function(row) {
  8364. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8365. return 1;
  8366. } else {
  8367. return this.$wrapData[row].length + 1;
  8368. }
  8369. };
  8370. this.getRowWrapIndent = function(screenRow) {
  8371. if (this.$useWrapMode) {
  8372. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8373. var splits = this.$wrapData[pos.row];
  8374. return splits.length && splits[0] < pos.column ? splits.indent : 0;
  8375. } else {
  8376. return 0;
  8377. }
  8378. }
  8379. this.getScreenLastRowColumn = function(screenRow) {
  8380. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8381. return this.documentToScreenColumn(pos.row, pos.column);
  8382. };
  8383. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  8384. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8385. return this.getScreenLastRowColumn(screenRow);
  8386. };
  8387. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  8388. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8389. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  8390. };
  8391. this.getRowSplitData = function(row) {
  8392. if (!this.$useWrapMode) {
  8393. return undefined;
  8394. } else {
  8395. return this.$wrapData[row];
  8396. }
  8397. };
  8398. this.getScreenTabSize = function(screenColumn) {
  8399. return this.$tabSize - screenColumn % this.$tabSize;
  8400. };
  8401. this.screenToDocumentRow = function(screenRow, screenColumn) {
  8402. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  8403. };
  8404. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  8405. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  8406. };
  8407. this.screenToDocumentPosition = function(screenRow, screenColumn) {
  8408. if (screenRow < 0)
  8409. return {row: 0, column: 0};
  8410. var line;
  8411. var docRow = 0;
  8412. var docColumn = 0;
  8413. var column;
  8414. var row = 0;
  8415. var rowLength = 0;
  8416. var rowCache = this.$screenRowCache;
  8417. var i = this.$getRowCacheIndex(rowCache, screenRow);
  8418. var l = rowCache.length;
  8419. if (l && i >= 0) {
  8420. var row = rowCache[i];
  8421. var docRow = this.$docRowCache[i];
  8422. var doCache = screenRow > rowCache[l - 1];
  8423. } else {
  8424. var doCache = !l;
  8425. }
  8426. var maxRow = this.getLength() - 1;
  8427. var foldLine = this.getNextFoldLine(docRow);
  8428. var foldStart = foldLine ? foldLine.start.row : Infinity;
  8429. while (row <= screenRow) {
  8430. rowLength = this.getRowLength(docRow);
  8431. if (row + rowLength > screenRow || docRow >= maxRow) {
  8432. break;
  8433. } else {
  8434. row += rowLength;
  8435. docRow++;
  8436. if (docRow > foldStart) {
  8437. docRow = foldLine.end.row+1;
  8438. foldLine = this.getNextFoldLine(docRow, foldLine);
  8439. foldStart = foldLine ? foldLine.start.row : Infinity;
  8440. }
  8441. }
  8442. if (doCache) {
  8443. this.$docRowCache.push(docRow);
  8444. this.$screenRowCache.push(row);
  8445. }
  8446. }
  8447. if (foldLine && foldLine.start.row <= docRow) {
  8448. line = this.getFoldDisplayLine(foldLine);
  8449. docRow = foldLine.start.row;
  8450. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  8451. return {
  8452. row: maxRow,
  8453. column: this.getLine(maxRow).length
  8454. };
  8455. } else {
  8456. line = this.getLine(docRow);
  8457. foldLine = null;
  8458. }
  8459. var wrapIndent = 0;
  8460. if (this.$useWrapMode) {
  8461. var splits = this.$wrapData[docRow];
  8462. if (splits) {
  8463. var splitIndex = Math.floor(screenRow - row);
  8464. column = splits[splitIndex];
  8465. if(splitIndex > 0 && splits.length) {
  8466. wrapIndent = splits.indent;
  8467. docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
  8468. line = line.substring(docColumn);
  8469. }
  8470. }
  8471. }
  8472. docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
  8473. if (this.$useWrapMode && docColumn >= column)
  8474. docColumn = column - 1;
  8475. if (foldLine)
  8476. return foldLine.idxToPosition(docColumn);
  8477. return {row: docRow, column: docColumn};
  8478. };
  8479. this.documentToScreenPosition = function(docRow, docColumn) {
  8480. if (typeof docColumn === "undefined")
  8481. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  8482. else
  8483. pos = this.$clipPositionToDocument(docRow, docColumn);
  8484. docRow = pos.row;
  8485. docColumn = pos.column;
  8486. var screenRow = 0;
  8487. var foldStartRow = null;
  8488. var fold = null;
  8489. fold = this.getFoldAt(docRow, docColumn, 1);
  8490. if (fold) {
  8491. docRow = fold.start.row;
  8492. docColumn = fold.start.column;
  8493. }
  8494. var rowEnd, row = 0;
  8495. var rowCache = this.$docRowCache;
  8496. var i = this.$getRowCacheIndex(rowCache, docRow);
  8497. var l = rowCache.length;
  8498. if (l && i >= 0) {
  8499. var row = rowCache[i];
  8500. var screenRow = this.$screenRowCache[i];
  8501. var doCache = docRow > rowCache[l - 1];
  8502. } else {
  8503. var doCache = !l;
  8504. }
  8505. var foldLine = this.getNextFoldLine(row);
  8506. var foldStart = foldLine ?foldLine.start.row :Infinity;
  8507. while (row < docRow) {
  8508. if (row >= foldStart) {
  8509. rowEnd = foldLine.end.row + 1;
  8510. if (rowEnd > docRow)
  8511. break;
  8512. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  8513. foldStart = foldLine ?foldLine.start.row :Infinity;
  8514. }
  8515. else {
  8516. rowEnd = row + 1;
  8517. }
  8518. screenRow += this.getRowLength(row);
  8519. row = rowEnd;
  8520. if (doCache) {
  8521. this.$docRowCache.push(row);
  8522. this.$screenRowCache.push(screenRow);
  8523. }
  8524. }
  8525. var textLine = "";
  8526. if (foldLine && row >= foldStart) {
  8527. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  8528. foldStartRow = foldLine.start.row;
  8529. } else {
  8530. textLine = this.getLine(docRow).substring(0, docColumn);
  8531. foldStartRow = docRow;
  8532. }
  8533. var wrapIndent = 0;
  8534. if (this.$useWrapMode) {
  8535. var wrapRow = this.$wrapData[foldStartRow];
  8536. if (wrapRow) {
  8537. var screenRowOffset = 0;
  8538. while (textLine.length >= wrapRow[screenRowOffset]) {
  8539. screenRow ++;
  8540. screenRowOffset++;
  8541. }
  8542. textLine = textLine.substring(
  8543. wrapRow[screenRowOffset - 1] || 0, textLine.length
  8544. );
  8545. wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
  8546. }
  8547. }
  8548. return {
  8549. row: screenRow,
  8550. column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
  8551. };
  8552. };
  8553. this.documentToScreenColumn = function(row, docColumn) {
  8554. return this.documentToScreenPosition(row, docColumn).column;
  8555. };
  8556. this.documentToScreenRow = function(docRow, docColumn) {
  8557. return this.documentToScreenPosition(docRow, docColumn).row;
  8558. };
  8559. this.getScreenLength = function() {
  8560. var screenRows = 0;
  8561. var fold = null;
  8562. if (!this.$useWrapMode) {
  8563. screenRows = this.getLength();
  8564. var foldData = this.$foldData;
  8565. for (var i = 0; i < foldData.length; i++) {
  8566. fold = foldData[i];
  8567. screenRows -= fold.end.row - fold.start.row;
  8568. }
  8569. } else {
  8570. var lastRow = this.$wrapData.length;
  8571. var row = 0, i = 0;
  8572. var fold = this.$foldData[i++];
  8573. var foldStart = fold ? fold.start.row :Infinity;
  8574. while (row < lastRow) {
  8575. var splits = this.$wrapData[row];
  8576. screenRows += splits ? splits.length + 1 : 1;
  8577. row ++;
  8578. if (row > foldStart) {
  8579. row = fold.end.row+1;
  8580. fold = this.$foldData[i++];
  8581. foldStart = fold ?fold.start.row :Infinity;
  8582. }
  8583. }
  8584. }
  8585. if (this.lineWidgets)
  8586. screenRows += this.$getWidgetScreenLength();
  8587. return screenRows;
  8588. };
  8589. this.$setFontMetrics = function(fm) {
  8590. if (!this.$enableVarChar) return;
  8591. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8592. if (maxScreenColumn === 0)
  8593. return [0, 0];
  8594. if (!maxScreenColumn)
  8595. maxScreenColumn = Infinity;
  8596. screenColumn = screenColumn || 0;
  8597. var c, column;
  8598. for (column = 0; column < str.length; column++) {
  8599. c = str.charAt(column);
  8600. if (c === "\t") {
  8601. screenColumn += this.getScreenTabSize(screenColumn);
  8602. } else {
  8603. screenColumn += fm.getCharacterWidth(c);
  8604. }
  8605. if (screenColumn > maxScreenColumn) {
  8606. break;
  8607. }
  8608. }
  8609. return [screenColumn, column];
  8610. };
  8611. };
  8612. this.destroy = function() {
  8613. if (this.bgTokenizer) {
  8614. this.bgTokenizer.setDocument(null);
  8615. this.bgTokenizer = null;
  8616. }
  8617. this.$stopWorker();
  8618. };
  8619. function isFullWidth(c) {
  8620. if (c < 0x1100)
  8621. return false;
  8622. return c >= 0x1100 && c <= 0x115F ||
  8623. c >= 0x11A3 && c <= 0x11A7 ||
  8624. c >= 0x11FA && c <= 0x11FF ||
  8625. c >= 0x2329 && c <= 0x232A ||
  8626. c >= 0x2E80 && c <= 0x2E99 ||
  8627. c >= 0x2E9B && c <= 0x2EF3 ||
  8628. c >= 0x2F00 && c <= 0x2FD5 ||
  8629. c >= 0x2FF0 && c <= 0x2FFB ||
  8630. c >= 0x3000 && c <= 0x303E ||
  8631. c >= 0x3041 && c <= 0x3096 ||
  8632. c >= 0x3099 && c <= 0x30FF ||
  8633. c >= 0x3105 && c <= 0x312D ||
  8634. c >= 0x3131 && c <= 0x318E ||
  8635. c >= 0x3190 && c <= 0x31BA ||
  8636. c >= 0x31C0 && c <= 0x31E3 ||
  8637. c >= 0x31F0 && c <= 0x321E ||
  8638. c >= 0x3220 && c <= 0x3247 ||
  8639. c >= 0x3250 && c <= 0x32FE ||
  8640. c >= 0x3300 && c <= 0x4DBF ||
  8641. c >= 0x4E00 && c <= 0xA48C ||
  8642. c >= 0xA490 && c <= 0xA4C6 ||
  8643. c >= 0xA960 && c <= 0xA97C ||
  8644. c >= 0xAC00 && c <= 0xD7A3 ||
  8645. c >= 0xD7B0 && c <= 0xD7C6 ||
  8646. c >= 0xD7CB && c <= 0xD7FB ||
  8647. c >= 0xF900 && c <= 0xFAFF ||
  8648. c >= 0xFE10 && c <= 0xFE19 ||
  8649. c >= 0xFE30 && c <= 0xFE52 ||
  8650. c >= 0xFE54 && c <= 0xFE66 ||
  8651. c >= 0xFE68 && c <= 0xFE6B ||
  8652. c >= 0xFF01 && c <= 0xFF60 ||
  8653. c >= 0xFFE0 && c <= 0xFFE6;
  8654. }
  8655. }).call(EditSession.prototype);
  8656. require("./edit_session/folding").Folding.call(EditSession.prototype);
  8657. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  8658. config.defineOptions(EditSession.prototype, "session", {
  8659. wrap: {
  8660. set: function(value) {
  8661. if (!value || value == "off")
  8662. value = false;
  8663. else if (value == "free")
  8664. value = true;
  8665. else if (value == "printMargin")
  8666. value = -1;
  8667. else if (typeof value == "string")
  8668. value = parseInt(value, 10) || false;
  8669. if (this.$wrap == value)
  8670. return;
  8671. this.$wrap = value;
  8672. if (!value) {
  8673. this.setUseWrapMode(false);
  8674. } else {
  8675. var col = typeof value == "number" ? value : null;
  8676. this.setWrapLimitRange(col, col);
  8677. this.setUseWrapMode(true);
  8678. }
  8679. },
  8680. get: function() {
  8681. if (this.getUseWrapMode()) {
  8682. if (this.$wrap == -1)
  8683. return "printMargin";
  8684. if (!this.getWrapLimitRange().min)
  8685. return "free";
  8686. return this.$wrap;
  8687. }
  8688. return "off";
  8689. },
  8690. handlesSet: true
  8691. },
  8692. wrapMethod: {
  8693. set: function(val) {
  8694. val = val == "auto"
  8695. ? this.$mode.type != "text"
  8696. : val != "text";
  8697. if (val != this.$wrapAsCode) {
  8698. this.$wrapAsCode = val;
  8699. if (this.$useWrapMode) {
  8700. this.$modified = true;
  8701. this.$resetRowCache(0);
  8702. this.$updateWrapData(0, this.getLength() - 1);
  8703. }
  8704. }
  8705. },
  8706. initialValue: "auto"
  8707. },
  8708. indentedSoftWrap: { initialValue: true },
  8709. firstLineNumber: {
  8710. set: function() {this._signal("changeBreakpoint");},
  8711. initialValue: 1
  8712. },
  8713. useWorker: {
  8714. set: function(useWorker) {
  8715. this.$useWorker = useWorker;
  8716. this.$stopWorker();
  8717. if (useWorker)
  8718. this.$startWorker();
  8719. },
  8720. initialValue: true
  8721. },
  8722. useSoftTabs: {initialValue: true},
  8723. tabSize: {
  8724. set: function(tabSize) {
  8725. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  8726. this.$modified = true;
  8727. this.$rowLengthCache = [];
  8728. this.$tabSize = tabSize;
  8729. this._signal("changeTabSize");
  8730. },
  8731. initialValue: 4,
  8732. handlesSet: true
  8733. },
  8734. overwrite: {
  8735. set: function(val) {this._signal("changeOverwrite");},
  8736. initialValue: false
  8737. },
  8738. newLineMode: {
  8739. set: function(val) {this.doc.setNewLineMode(val)},
  8740. get: function() {return this.doc.getNewLineMode()},
  8741. handlesSet: true
  8742. },
  8743. mode: {
  8744. set: function(val) { this.setMode(val) },
  8745. get: function() { return this.$modeId }
  8746. }
  8747. });
  8748. exports.EditSession = EditSession;
  8749. });
  8750. ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  8751. "use strict";
  8752. var lang = require("./lib/lang");
  8753. var oop = require("./lib/oop");
  8754. var Range = require("./range").Range;
  8755. var Search = function() {
  8756. this.$options = {};
  8757. };
  8758. (function() {
  8759. this.set = function(options) {
  8760. oop.mixin(this.$options, options);
  8761. return this;
  8762. };
  8763. this.getOptions = function() {
  8764. return lang.copyObject(this.$options);
  8765. };
  8766. this.setOptions = function(options) {
  8767. this.$options = options;
  8768. };
  8769. this.find = function(session) {
  8770. var options = this.$options;
  8771. var iterator = this.$matchIterator(session, options);
  8772. if (!iterator)
  8773. return false;
  8774. var firstRange = null;
  8775. iterator.forEach(function(range, row, offset) {
  8776. if (!range.start) {
  8777. var column = range.offset + (offset || 0);
  8778. firstRange = new Range(row, column, row, column + range.length);
  8779. if (!range.length && options.start && options.start.start
  8780. && options.skipCurrent != false && firstRange.isEqual(options.start)
  8781. ) {
  8782. firstRange = null;
  8783. return false;
  8784. }
  8785. } else
  8786. firstRange = range;
  8787. return true;
  8788. });
  8789. return firstRange;
  8790. };
  8791. this.findAll = function(session) {
  8792. var options = this.$options;
  8793. if (!options.needle)
  8794. return [];
  8795. this.$assembleRegExp(options);
  8796. var range = options.range;
  8797. var lines = range
  8798. ? session.getLines(range.start.row, range.end.row)
  8799. : session.doc.getAllLines();
  8800. var ranges = [];
  8801. var re = options.re;
  8802. if (options.$isMultiLine) {
  8803. var len = re.length;
  8804. var maxRow = lines.length - len;
  8805. var prevRange;
  8806. outer: for (var row = re.offset || 0; row <= maxRow; row++) {
  8807. for (var j = 0; j < len; j++)
  8808. if (lines[row + j].search(re[j]) == -1)
  8809. continue outer;
  8810. var startLine = lines[row];
  8811. var line = lines[row + len - 1];
  8812. var startIndex = startLine.length - startLine.match(re[0])[0].length;
  8813. var endIndex = line.match(re[len - 1])[0].length;
  8814. if (prevRange && prevRange.end.row === row &&
  8815. prevRange.end.column > startIndex
  8816. ) {
  8817. continue;
  8818. }
  8819. ranges.push(prevRange = new Range(
  8820. row, startIndex, row + len - 1, endIndex
  8821. ));
  8822. if (len > 2)
  8823. row = row + len - 2;
  8824. }
  8825. } else {
  8826. for (var i = 0; i < lines.length; i++) {
  8827. var matches = lang.getMatchOffsets(lines[i], re);
  8828. for (var j = 0; j < matches.length; j++) {
  8829. var match = matches[j];
  8830. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  8831. }
  8832. }
  8833. }
  8834. if (range) {
  8835. var startColumn = range.start.column;
  8836. var endColumn = range.start.column;
  8837. var i = 0, j = ranges.length - 1;
  8838. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  8839. i++;
  8840. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  8841. j--;
  8842. ranges = ranges.slice(i, j + 1);
  8843. for (i = 0, j = ranges.length; i < j; i++) {
  8844. ranges[i].start.row += range.start.row;
  8845. ranges[i].end.row += range.start.row;
  8846. }
  8847. }
  8848. return ranges;
  8849. };
  8850. this.replace = function(input, replacement) {
  8851. var options = this.$options;
  8852. var re = this.$assembleRegExp(options);
  8853. if (options.$isMultiLine)
  8854. return replacement;
  8855. if (!re)
  8856. return;
  8857. var match = re.exec(input);
  8858. if (!match || match[0].length != input.length)
  8859. return null;
  8860. replacement = input.replace(re, replacement);
  8861. if (options.preserveCase) {
  8862. replacement = replacement.split("");
  8863. for (var i = Math.min(input.length, input.length); i--; ) {
  8864. var ch = input[i];
  8865. if (ch && ch.toLowerCase() != ch)
  8866. replacement[i] = replacement[i].toUpperCase();
  8867. else
  8868. replacement[i] = replacement[i].toLowerCase();
  8869. }
  8870. replacement = replacement.join("");
  8871. }
  8872. return replacement;
  8873. };
  8874. this.$matchIterator = function(session, options) {
  8875. var re = this.$assembleRegExp(options);
  8876. if (!re)
  8877. return false;
  8878. var callback;
  8879. if (options.$isMultiLine) {
  8880. var len = re.length;
  8881. var matchIterator = function(line, row, offset) {
  8882. var startIndex = line.search(re[0]);
  8883. if (startIndex == -1)
  8884. return;
  8885. for (var i = 1; i < len; i++) {
  8886. line = session.getLine(row + i);
  8887. if (line.search(re[i]) == -1)
  8888. return;
  8889. }
  8890. var endIndex = line.match(re[len - 1])[0].length;
  8891. var range = new Range(row, startIndex, row + len - 1, endIndex);
  8892. if (re.offset == 1) {
  8893. range.start.row--;
  8894. range.start.column = Number.MAX_VALUE;
  8895. } else if (offset)
  8896. range.start.column += offset;
  8897. if (callback(range))
  8898. return true;
  8899. };
  8900. } else if (options.backwards) {
  8901. var matchIterator = function(line, row, startIndex) {
  8902. var matches = lang.getMatchOffsets(line, re);
  8903. for (var i = matches.length-1; i >= 0; i--)
  8904. if (callback(matches[i], row, startIndex))
  8905. return true;
  8906. };
  8907. } else {
  8908. var matchIterator = function(line, row, startIndex) {
  8909. var matches = lang.getMatchOffsets(line, re);
  8910. for (var i = 0; i < matches.length; i++)
  8911. if (callback(matches[i], row, startIndex))
  8912. return true;
  8913. };
  8914. }
  8915. var lineIterator = this.$lineIterator(session, options);
  8916. return {
  8917. forEach: function(_callback) {
  8918. callback = _callback;
  8919. lineIterator.forEach(matchIterator);
  8920. }
  8921. };
  8922. };
  8923. this.$assembleRegExp = function(options, $disableFakeMultiline) {
  8924. if (options.needle instanceof RegExp)
  8925. return options.re = options.needle;
  8926. var needle = options.needle;
  8927. if (!options.needle)
  8928. return options.re = false;
  8929. if (!options.regExp)
  8930. needle = lang.escapeRegExp(needle);
  8931. if (options.wholeWord)
  8932. needle = "\\b" + needle + "\\b";
  8933. var modifier = options.caseSensitive ? "gm" : "gmi";
  8934. options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
  8935. if (options.$isMultiLine)
  8936. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  8937. try {
  8938. var re = new RegExp(needle, modifier);
  8939. } catch(e) {
  8940. re = false;
  8941. }
  8942. return options.re = re;
  8943. };
  8944. this.$assembleMultilineRegExp = function(needle, modifier) {
  8945. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  8946. var re = [];
  8947. for (var i = 0; i < parts.length; i++) try {
  8948. re.push(new RegExp(parts[i], modifier));
  8949. } catch(e) {
  8950. return false;
  8951. }
  8952. if (parts[0] == "") {
  8953. re.shift();
  8954. re.offset = 1;
  8955. } else {
  8956. re.offset = 0;
  8957. }
  8958. return re;
  8959. };
  8960. this.$lineIterator = function(session, options) {
  8961. var backwards = options.backwards == true;
  8962. var skipCurrent = options.skipCurrent != false;
  8963. var range = options.range;
  8964. var start = options.start;
  8965. if (!start)
  8966. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  8967. if (start.start)
  8968. start = start[skipCurrent != backwards ? "end" : "start"];
  8969. var firstRow = range ? range.start.row : 0;
  8970. var lastRow = range ? range.end.row : session.getLength() - 1;
  8971. var forEach = backwards ? function(callback) {
  8972. var row = start.row;
  8973. var line = session.getLine(row).substring(0, start.column);
  8974. if (callback(line, row))
  8975. return;
  8976. for (row--; row >= firstRow; row--)
  8977. if (callback(session.getLine(row), row))
  8978. return;
  8979. if (options.wrap == false)
  8980. return;
  8981. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  8982. if (callback(session.getLine(row), row))
  8983. return;
  8984. } : function(callback) {
  8985. var row = start.row;
  8986. var line = session.getLine(row).substr(start.column);
  8987. if (callback(line, row, start.column))
  8988. return;
  8989. for (row = row+1; row <= lastRow; row++)
  8990. if (callback(session.getLine(row), row))
  8991. return;
  8992. if (options.wrap == false)
  8993. return;
  8994. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  8995. if (callback(session.getLine(row), row))
  8996. return;
  8997. };
  8998. return {forEach: forEach};
  8999. };
  9000. }).call(Search.prototype);
  9001. exports.Search = Search;
  9002. });
  9003. ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  9004. "use strict";
  9005. var keyUtil = require("../lib/keys");
  9006. var useragent = require("../lib/useragent");
  9007. var KEY_MODS = keyUtil.KEY_MODS;
  9008. function HashHandler(config, platform) {
  9009. this.platform = platform || (useragent.isMac ? "mac" : "win");
  9010. this.commands = {};
  9011. this.commandKeyBinding = {};
  9012. this.addCommands(config);
  9013. this.$singleCommand = true;
  9014. }
  9015. function MultiHashHandler(config, platform) {
  9016. HashHandler.call(this, config, platform);
  9017. this.$singleCommand = false;
  9018. }
  9019. MultiHashHandler.prototype = HashHandler.prototype;
  9020. (function() {
  9021. this.addCommand = function(command) {
  9022. if (this.commands[command.name])
  9023. this.removeCommand(command);
  9024. this.commands[command.name] = command;
  9025. if (command.bindKey)
  9026. this._buildKeyHash(command);
  9027. };
  9028. this.removeCommand = function(command, keepCommand) {
  9029. var name = command && (typeof command === 'string' ? command : command.name);
  9030. command = this.commands[name];
  9031. if (!keepCommand)
  9032. delete this.commands[name];
  9033. var ckb = this.commandKeyBinding;
  9034. for (var keyId in ckb) {
  9035. var cmdGroup = ckb[keyId];
  9036. if (cmdGroup == command) {
  9037. delete ckb[keyId];
  9038. } else if (Array.isArray(cmdGroup)) {
  9039. var i = cmdGroup.indexOf(command);
  9040. if (i != -1) {
  9041. cmdGroup.splice(i, 1);
  9042. if (cmdGroup.length == 1)
  9043. ckb[keyId] = cmdGroup[0];
  9044. }
  9045. }
  9046. }
  9047. };
  9048. this.bindKey = function(key, command, position) {
  9049. if (typeof key == "object" && key) {
  9050. if (position == undefined)
  9051. position = key.position;
  9052. key = key[this.platform];
  9053. }
  9054. if (!key)
  9055. return;
  9056. if (typeof command == "function")
  9057. return this.addCommand({exec: command, bindKey: key, name: command.name || key});
  9058. key.split("|").forEach(function(keyPart) {
  9059. var chain = "";
  9060. if (keyPart.indexOf(" ") != -1) {
  9061. var parts = keyPart.split(/\s+/);
  9062. keyPart = parts.pop();
  9063. parts.forEach(function(keyPart) {
  9064. var binding = this.parseKeys(keyPart);
  9065. var id = KEY_MODS[binding.hashId] + binding.key;
  9066. chain += (chain ? " " : "") + id;
  9067. this._addCommandToBinding(chain, "chainKeys");
  9068. }, this);
  9069. chain += " ";
  9070. }
  9071. var binding = this.parseKeys(keyPart);
  9072. var id = KEY_MODS[binding.hashId] + binding.key;
  9073. this._addCommandToBinding(chain + id, command, position);
  9074. }, this);
  9075. };
  9076. function getPosition(command) {
  9077. return typeof command == "object" && command.bindKey
  9078. && command.bindKey.position || 0;
  9079. }
  9080. this._addCommandToBinding = function(keyId, command, position) {
  9081. var ckb = this.commandKeyBinding, i;
  9082. if (!command) {
  9083. delete ckb[keyId];
  9084. } else if (!ckb[keyId] || this.$singleCommand) {
  9085. ckb[keyId] = command;
  9086. } else {
  9087. if (!Array.isArray(ckb[keyId])) {
  9088. ckb[keyId] = [ckb[keyId]];
  9089. } else if ((i = ckb[keyId].indexOf(command)) != -1) {
  9090. ckb[keyId].splice(i, 1);
  9091. }
  9092. if (typeof position != "number") {
  9093. if (position || command.isDefault)
  9094. position = -100;
  9095. else
  9096. position = getPosition(command);
  9097. }
  9098. var commands = ckb[keyId];
  9099. for (i = 0; i < commands.length; i++) {
  9100. var other = commands[i];
  9101. var otherPos = getPosition(other);
  9102. if (otherPos > position)
  9103. break;
  9104. }
  9105. commands.splice(i, 0, command);
  9106. }
  9107. };
  9108. this.addCommands = function(commands) {
  9109. commands && Object.keys(commands).forEach(function(name) {
  9110. var command = commands[name];
  9111. if (!command)
  9112. return;
  9113. if (typeof command === "string")
  9114. return this.bindKey(command, name);
  9115. if (typeof command === "function")
  9116. command = { exec: command };
  9117. if (typeof command !== "object")
  9118. return;
  9119. if (!command.name)
  9120. command.name = name;
  9121. this.addCommand(command);
  9122. }, this);
  9123. };
  9124. this.removeCommands = function(commands) {
  9125. Object.keys(commands).forEach(function(name) {
  9126. this.removeCommand(commands[name]);
  9127. }, this);
  9128. };
  9129. this.bindKeys = function(keyList) {
  9130. Object.keys(keyList).forEach(function(key) {
  9131. this.bindKey(key, keyList[key]);
  9132. }, this);
  9133. };
  9134. this._buildKeyHash = function(command) {
  9135. this.bindKey(command.bindKey, command);
  9136. };
  9137. this.parseKeys = function(keys) {
  9138. var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
  9139. var key = parts.pop();
  9140. var keyCode = keyUtil[key];
  9141. if (keyUtil.FUNCTION_KEYS[keyCode])
  9142. key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
  9143. else if (!parts.length)
  9144. return {key: key, hashId: -1};
  9145. else if (parts.length == 1 && parts[0] == "shift")
  9146. return {key: key.toUpperCase(), hashId: -1};
  9147. var hashId = 0;
  9148. for (var i = parts.length; i--;) {
  9149. var modifier = keyUtil.KEY_MODS[parts[i]];
  9150. if (modifier == null) {
  9151. if (typeof console != "undefined")
  9152. console.error("invalid modifier " + parts[i] + " in " + keys);
  9153. return false;
  9154. }
  9155. hashId |= modifier;
  9156. }
  9157. return {key: key, hashId: hashId};
  9158. };
  9159. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  9160. var key = KEY_MODS[hashId] + keyString;
  9161. return this.commandKeyBinding[key];
  9162. };
  9163. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  9164. if (keyCode < 0) return;
  9165. var key = KEY_MODS[hashId] + keyString;
  9166. var command = this.commandKeyBinding[key];
  9167. if (data.$keyChain) {
  9168. data.$keyChain += " " + key;
  9169. command = this.commandKeyBinding[data.$keyChain] || command;
  9170. }
  9171. if (command) {
  9172. if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
  9173. data.$keyChain = data.$keyChain || key;
  9174. return {command: "null"};
  9175. }
  9176. }
  9177. if (data.$keyChain) {
  9178. if ((!hashId || hashId == 4) && keyString.length == 1)
  9179. data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
  9180. else if (hashId == -1 || keyCode > 0)
  9181. data.$keyChain = ""; // reset keyChain
  9182. }
  9183. return {command: command};
  9184. };
  9185. this.getStatusText = function(editor, data) {
  9186. return data.$keyChain || "";
  9187. };
  9188. }).call(HashHandler.prototype);
  9189. exports.HashHandler = HashHandler;
  9190. exports.MultiHashHandler = MultiHashHandler;
  9191. });
  9192. ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
  9193. "use strict";
  9194. var oop = require("../lib/oop");
  9195. var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
  9196. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  9197. var CommandManager = function(platform, commands) {
  9198. MultiHashHandler.call(this, commands, platform);
  9199. this.byName = this.commands;
  9200. this.setDefaultHandler("exec", function(e) {
  9201. return e.command.exec(e.editor, e.args || {});
  9202. });
  9203. };
  9204. oop.inherits(CommandManager, MultiHashHandler);
  9205. (function() {
  9206. oop.implement(this, EventEmitter);
  9207. this.exec = function(command, editor, args) {
  9208. if (Array.isArray(command)) {
  9209. for (var i = command.length; i--; ) {
  9210. if (this.exec(command[i], editor, args)) return true;
  9211. }
  9212. return false;
  9213. }
  9214. if (typeof command === "string")
  9215. command = this.commands[command];
  9216. if (!command)
  9217. return false;
  9218. if (editor && editor.$readOnly && !command.readOnly)
  9219. return false;
  9220. var e = {editor: editor, command: command, args: args};
  9221. e.returnValue = this._emit("exec", e);
  9222. this._signal("afterExec", e);
  9223. return e.returnValue === false ? false : true;
  9224. };
  9225. this.toggleRecording = function(editor) {
  9226. if (this.$inReplay)
  9227. return;
  9228. editor && editor._emit("changeStatus");
  9229. if (this.recording) {
  9230. this.macro.pop();
  9231. this.removeEventListener("exec", this.$addCommandToMacro);
  9232. if (!this.macro.length)
  9233. this.macro = this.oldMacro;
  9234. return this.recording = false;
  9235. }
  9236. if (!this.$addCommandToMacro) {
  9237. this.$addCommandToMacro = function(e) {
  9238. this.macro.push([e.command, e.args]);
  9239. }.bind(this);
  9240. }
  9241. this.oldMacro = this.macro;
  9242. this.macro = [];
  9243. this.on("exec", this.$addCommandToMacro);
  9244. return this.recording = true;
  9245. };
  9246. this.replay = function(editor) {
  9247. if (this.$inReplay || !this.macro)
  9248. return;
  9249. if (this.recording)
  9250. return this.toggleRecording(editor);
  9251. try {
  9252. this.$inReplay = true;
  9253. this.macro.forEach(function(x) {
  9254. if (typeof x == "string")
  9255. this.exec(x, editor);
  9256. else
  9257. this.exec(x[0], editor, x[1]);
  9258. }, this);
  9259. } finally {
  9260. this.$inReplay = false;
  9261. }
  9262. };
  9263. this.trimMacro = function(m) {
  9264. return m.map(function(x){
  9265. if (typeof x[0] != "string")
  9266. x[0] = x[0].name;
  9267. if (!x[1])
  9268. x = x[0];
  9269. return x;
  9270. });
  9271. };
  9272. }).call(CommandManager.prototype);
  9273. exports.CommandManager = CommandManager;
  9274. });
  9275. ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
  9276. "use strict";
  9277. var lang = require("../lib/lang");
  9278. var config = require("../config");
  9279. var Range = require("../range").Range;
  9280. function bindKey(win, mac) {
  9281. return {win: win, mac: mac};
  9282. }
  9283. exports.commands = [{
  9284. name: "showSettingsMenu",
  9285. bindKey: bindKey("Ctrl-,", "Command-,"),
  9286. exec: function(editor) {
  9287. config.loadModule("ace/ext/settings_menu", function(module) {
  9288. module.init(editor);
  9289. editor.showSettingsMenu();
  9290. });
  9291. },
  9292. readOnly: true
  9293. }, {
  9294. name: "goToNextError",
  9295. bindKey: bindKey("Alt-E", "Ctrl-E"),
  9296. exec: function(editor) {
  9297. config.loadModule("ace/ext/error_marker", function(module) {
  9298. module.showErrorMarker(editor, 1);
  9299. });
  9300. },
  9301. scrollIntoView: "animate",
  9302. readOnly: true
  9303. }, {
  9304. name: "goToPreviousError",
  9305. bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
  9306. exec: function(editor) {
  9307. config.loadModule("ace/ext/error_marker", function(module) {
  9308. module.showErrorMarker(editor, -1);
  9309. });
  9310. },
  9311. scrollIntoView: "animate",
  9312. readOnly: true
  9313. }, {
  9314. name: "selectall",
  9315. bindKey: bindKey("Ctrl-A", "Command-A"),
  9316. exec: function(editor) { editor.selectAll(); },
  9317. readOnly: true
  9318. }, {
  9319. name: "centerselection",
  9320. bindKey: bindKey(null, "Ctrl-L"),
  9321. exec: function(editor) { editor.centerSelection(); },
  9322. readOnly: true
  9323. }, {
  9324. name: "gotoline",
  9325. bindKey: bindKey("Ctrl-L", "Command-L"),
  9326. exec: function(editor) {
  9327. var line = parseInt(prompt("Enter line number:"), 10);
  9328. if (!isNaN(line)) {
  9329. editor.gotoLine(line);
  9330. }
  9331. },
  9332. readOnly: true
  9333. }, {
  9334. name: "fold",
  9335. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  9336. exec: function(editor) { editor.session.toggleFold(false); },
  9337. multiSelectAction: "forEach",
  9338. scrollIntoView: "center",
  9339. readOnly: true
  9340. }, {
  9341. name: "unfold",
  9342. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  9343. exec: function(editor) { editor.session.toggleFold(true); },
  9344. multiSelectAction: "forEach",
  9345. scrollIntoView: "center",
  9346. readOnly: true
  9347. }, {
  9348. name: "toggleFoldWidget",
  9349. bindKey: bindKey("F2", "F2"),
  9350. exec: function(editor) { editor.session.toggleFoldWidget(); },
  9351. multiSelectAction: "forEach",
  9352. scrollIntoView: "center",
  9353. readOnly: true
  9354. }, {
  9355. name: "toggleParentFoldWidget",
  9356. bindKey: bindKey("Alt-F2", "Alt-F2"),
  9357. exec: function(editor) { editor.session.toggleFoldWidget(true); },
  9358. multiSelectAction: "forEach",
  9359. scrollIntoView: "center",
  9360. readOnly: true
  9361. }, {
  9362. name: "foldall",
  9363. bindKey: bindKey(null, "Ctrl-Command-Option-0"),
  9364. exec: function(editor) { editor.session.foldAll(); },
  9365. scrollIntoView: "center",
  9366. readOnly: true
  9367. }, {
  9368. name: "foldOther",
  9369. bindKey: bindKey("Alt-0", "Command-Option-0"),
  9370. exec: function(editor) {
  9371. editor.session.foldAll();
  9372. editor.session.unfold(editor.selection.getAllRanges());
  9373. },
  9374. scrollIntoView: "center",
  9375. readOnly: true
  9376. }, {
  9377. name: "unfoldall",
  9378. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  9379. exec: function(editor) { editor.session.unfold(); },
  9380. scrollIntoView: "center",
  9381. readOnly: true
  9382. }, {
  9383. name: "findnext",
  9384. bindKey: bindKey("Ctrl-K", "Command-G"),
  9385. exec: function(editor) { editor.findNext(); },
  9386. multiSelectAction: "forEach",
  9387. scrollIntoView: "center",
  9388. readOnly: true
  9389. }, {
  9390. name: "findprevious",
  9391. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  9392. exec: function(editor) { editor.findPrevious(); },
  9393. multiSelectAction: "forEach",
  9394. scrollIntoView: "center",
  9395. readOnly: true
  9396. }, {
  9397. name: "selectOrFindNext",
  9398. bindKey: bindKey("Alt-K", "Ctrl-G"),
  9399. exec: function(editor) {
  9400. if (editor.selection.isEmpty())
  9401. editor.selection.selectWord();
  9402. else
  9403. editor.findNext();
  9404. },
  9405. readOnly: true
  9406. }, {
  9407. name: "selectOrFindPrevious",
  9408. bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
  9409. exec: function(editor) {
  9410. if (editor.selection.isEmpty())
  9411. editor.selection.selectWord();
  9412. else
  9413. editor.findPrevious();
  9414. },
  9415. readOnly: true
  9416. }, {
  9417. name: "find",
  9418. bindKey: bindKey("Ctrl-F", "Command-F"),
  9419. exec: function(editor) {
  9420. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
  9421. },
  9422. readOnly: true
  9423. }, {
  9424. name: "overwrite",
  9425. bindKey: "Insert",
  9426. exec: function(editor) { editor.toggleOverwrite(); },
  9427. readOnly: true
  9428. }, {
  9429. name: "selecttostart",
  9430. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
  9431. exec: function(editor) { editor.getSelection().selectFileStart(); },
  9432. multiSelectAction: "forEach",
  9433. readOnly: true,
  9434. scrollIntoView: "animate",
  9435. aceCommandGroup: "fileJump"
  9436. }, {
  9437. name: "gotostart",
  9438. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  9439. exec: function(editor) { editor.navigateFileStart(); },
  9440. multiSelectAction: "forEach",
  9441. readOnly: true,
  9442. scrollIntoView: "animate",
  9443. aceCommandGroup: "fileJump"
  9444. }, {
  9445. name: "selectup",
  9446. bindKey: bindKey("Shift-Up", "Shift-Up"),
  9447. exec: function(editor) { editor.getSelection().selectUp(); },
  9448. multiSelectAction: "forEach",
  9449. scrollIntoView: "cursor",
  9450. readOnly: true
  9451. }, {
  9452. name: "golineup",
  9453. bindKey: bindKey("Up", "Up|Ctrl-P"),
  9454. exec: function(editor, args) { editor.navigateUp(args.times); },
  9455. multiSelectAction: "forEach",
  9456. scrollIntoView: "cursor",
  9457. readOnly: true
  9458. }, {
  9459. name: "selecttoend",
  9460. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
  9461. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  9462. multiSelectAction: "forEach",
  9463. readOnly: true,
  9464. scrollIntoView: "animate",
  9465. aceCommandGroup: "fileJump"
  9466. }, {
  9467. name: "gotoend",
  9468. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  9469. exec: function(editor) { editor.navigateFileEnd(); },
  9470. multiSelectAction: "forEach",
  9471. readOnly: true,
  9472. scrollIntoView: "animate",
  9473. aceCommandGroup: "fileJump"
  9474. }, {
  9475. name: "selectdown",
  9476. bindKey: bindKey("Shift-Down", "Shift-Down"),
  9477. exec: function(editor) { editor.getSelection().selectDown(); },
  9478. multiSelectAction: "forEach",
  9479. scrollIntoView: "cursor",
  9480. readOnly: true
  9481. }, {
  9482. name: "golinedown",
  9483. bindKey: bindKey("Down", "Down|Ctrl-N"),
  9484. exec: function(editor, args) { editor.navigateDown(args.times); },
  9485. multiSelectAction: "forEach",
  9486. scrollIntoView: "cursor",
  9487. readOnly: true
  9488. }, {
  9489. name: "selectwordleft",
  9490. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  9491. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  9492. multiSelectAction: "forEach",
  9493. scrollIntoView: "cursor",
  9494. readOnly: true
  9495. }, {
  9496. name: "gotowordleft",
  9497. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  9498. exec: function(editor) { editor.navigateWordLeft(); },
  9499. multiSelectAction: "forEach",
  9500. scrollIntoView: "cursor",
  9501. readOnly: true
  9502. }, {
  9503. name: "selecttolinestart",
  9504. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
  9505. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9506. multiSelectAction: "forEach",
  9507. scrollIntoView: "cursor",
  9508. readOnly: true
  9509. }, {
  9510. name: "gotolinestart",
  9511. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  9512. exec: function(editor) { editor.navigateLineStart(); },
  9513. multiSelectAction: "forEach",
  9514. scrollIntoView: "cursor",
  9515. readOnly: true
  9516. }, {
  9517. name: "selectleft",
  9518. bindKey: bindKey("Shift-Left", "Shift-Left"),
  9519. exec: function(editor) { editor.getSelection().selectLeft(); },
  9520. multiSelectAction: "forEach",
  9521. scrollIntoView: "cursor",
  9522. readOnly: true
  9523. }, {
  9524. name: "gotoleft",
  9525. bindKey: bindKey("Left", "Left|Ctrl-B"),
  9526. exec: function(editor, args) { editor.navigateLeft(args.times); },
  9527. multiSelectAction: "forEach",
  9528. scrollIntoView: "cursor",
  9529. readOnly: true
  9530. }, {
  9531. name: "selectwordright",
  9532. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  9533. exec: function(editor) { editor.getSelection().selectWordRight(); },
  9534. multiSelectAction: "forEach",
  9535. scrollIntoView: "cursor",
  9536. readOnly: true
  9537. }, {
  9538. name: "gotowordright",
  9539. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  9540. exec: function(editor) { editor.navigateWordRight(); },
  9541. multiSelectAction: "forEach",
  9542. scrollIntoView: "cursor",
  9543. readOnly: true
  9544. }, {
  9545. name: "selecttolineend",
  9546. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
  9547. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9548. multiSelectAction: "forEach",
  9549. scrollIntoView: "cursor",
  9550. readOnly: true
  9551. }, {
  9552. name: "gotolineend",
  9553. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  9554. exec: function(editor) { editor.navigateLineEnd(); },
  9555. multiSelectAction: "forEach",
  9556. scrollIntoView: "cursor",
  9557. readOnly: true
  9558. }, {
  9559. name: "selectright",
  9560. bindKey: bindKey("Shift-Right", "Shift-Right"),
  9561. exec: function(editor) { editor.getSelection().selectRight(); },
  9562. multiSelectAction: "forEach",
  9563. scrollIntoView: "cursor",
  9564. readOnly: true
  9565. }, {
  9566. name: "gotoright",
  9567. bindKey: bindKey("Right", "Right|Ctrl-F"),
  9568. exec: function(editor, args) { editor.navigateRight(args.times); },
  9569. multiSelectAction: "forEach",
  9570. scrollIntoView: "cursor",
  9571. readOnly: true
  9572. }, {
  9573. name: "selectpagedown",
  9574. bindKey: "Shift-PageDown",
  9575. exec: function(editor) { editor.selectPageDown(); },
  9576. readOnly: true
  9577. }, {
  9578. name: "pagedown",
  9579. bindKey: bindKey(null, "Option-PageDown"),
  9580. exec: function(editor) { editor.scrollPageDown(); },
  9581. readOnly: true
  9582. }, {
  9583. name: "gotopagedown",
  9584. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  9585. exec: function(editor) { editor.gotoPageDown(); },
  9586. readOnly: true
  9587. }, {
  9588. name: "selectpageup",
  9589. bindKey: "Shift-PageUp",
  9590. exec: function(editor) { editor.selectPageUp(); },
  9591. readOnly: true
  9592. }, {
  9593. name: "pageup",
  9594. bindKey: bindKey(null, "Option-PageUp"),
  9595. exec: function(editor) { editor.scrollPageUp(); },
  9596. readOnly: true
  9597. }, {
  9598. name: "gotopageup",
  9599. bindKey: "PageUp",
  9600. exec: function(editor) { editor.gotoPageUp(); },
  9601. readOnly: true
  9602. }, {
  9603. name: "scrollup",
  9604. bindKey: bindKey("Ctrl-Up", null),
  9605. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  9606. readOnly: true
  9607. }, {
  9608. name: "scrolldown",
  9609. bindKey: bindKey("Ctrl-Down", null),
  9610. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  9611. readOnly: true
  9612. }, {
  9613. name: "selectlinestart",
  9614. bindKey: "Shift-Home",
  9615. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9616. multiSelectAction: "forEach",
  9617. scrollIntoView: "cursor",
  9618. readOnly: true
  9619. }, {
  9620. name: "selectlineend",
  9621. bindKey: "Shift-End",
  9622. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9623. multiSelectAction: "forEach",
  9624. scrollIntoView: "cursor",
  9625. readOnly: true
  9626. }, {
  9627. name: "togglerecording",
  9628. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  9629. exec: function(editor) { editor.commands.toggleRecording(editor); },
  9630. readOnly: true
  9631. }, {
  9632. name: "replaymacro",
  9633. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  9634. exec: function(editor) { editor.commands.replay(editor); },
  9635. readOnly: true
  9636. }, {
  9637. name: "jumptomatching",
  9638. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  9639. exec: function(editor) { editor.jumpToMatching(); },
  9640. multiSelectAction: "forEach",
  9641. scrollIntoView: "animate",
  9642. readOnly: true
  9643. }, {
  9644. name: "selecttomatching",
  9645. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  9646. exec: function(editor) { editor.jumpToMatching(true); },
  9647. multiSelectAction: "forEach",
  9648. scrollIntoView: "animate",
  9649. readOnly: true
  9650. }, {
  9651. name: "expandToMatching",
  9652. bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
  9653. exec: function(editor) { editor.jumpToMatching(true, true); },
  9654. multiSelectAction: "forEach",
  9655. scrollIntoView: "animate",
  9656. readOnly: true
  9657. }, {
  9658. name: "passKeysToBrowser",
  9659. bindKey: bindKey(null, null),
  9660. exec: function() {},
  9661. passEvent: true,
  9662. readOnly: true
  9663. }, {
  9664. name: "copy",
  9665. exec: function(editor) {
  9666. },
  9667. readOnly: true
  9668. },
  9669. {
  9670. name: "cut",
  9671. exec: function(editor) {
  9672. var range = editor.getSelectionRange();
  9673. editor._emit("cut", range);
  9674. if (!editor.selection.isEmpty()) {
  9675. editor.session.remove(range);
  9676. editor.clearSelection();
  9677. }
  9678. },
  9679. scrollIntoView: "cursor",
  9680. multiSelectAction: "forEach"
  9681. }, {
  9682. name: "paste",
  9683. exec: function(editor, args) {
  9684. editor.$handlePaste(args);
  9685. },
  9686. scrollIntoView: "cursor"
  9687. }, {
  9688. name: "removeline",
  9689. bindKey: bindKey("Ctrl-D", "Command-D"),
  9690. exec: function(editor) { editor.removeLines(); },
  9691. scrollIntoView: "cursor",
  9692. multiSelectAction: "forEachLine"
  9693. }, {
  9694. name: "duplicateSelection",
  9695. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  9696. exec: function(editor) { editor.duplicateSelection(); },
  9697. scrollIntoView: "cursor",
  9698. multiSelectAction: "forEach"
  9699. }, {
  9700. name: "sortlines",
  9701. bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
  9702. exec: function(editor) { editor.sortLines(); },
  9703. scrollIntoView: "selection",
  9704. multiSelectAction: "forEachLine"
  9705. }, {
  9706. name: "togglecomment",
  9707. bindKey: bindKey("Ctrl-/", "Command-/"),
  9708. exec: function(editor) { editor.toggleCommentLines(); },
  9709. multiSelectAction: "forEachLine",
  9710. scrollIntoView: "selectionPart"
  9711. }, {
  9712. name: "toggleBlockComment",
  9713. bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
  9714. exec: function(editor) { editor.toggleBlockComment(); },
  9715. multiSelectAction: "forEach",
  9716. scrollIntoView: "selectionPart"
  9717. }, {
  9718. name: "modifyNumberUp",
  9719. bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
  9720. exec: function(editor) { editor.modifyNumber(1); },
  9721. scrollIntoView: "cursor",
  9722. multiSelectAction: "forEach"
  9723. }, {
  9724. name: "modifyNumberDown",
  9725. bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
  9726. exec: function(editor) { editor.modifyNumber(-1); },
  9727. scrollIntoView: "cursor",
  9728. multiSelectAction: "forEach"
  9729. }, {
  9730. name: "replace",
  9731. bindKey: bindKey("Ctrl-H", "Command-Option-F"),
  9732. exec: function(editor) {
  9733. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
  9734. }
  9735. }, {
  9736. name: "undo",
  9737. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  9738. exec: function(editor) { editor.undo(); }
  9739. }, {
  9740. name: "redo",
  9741. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  9742. exec: function(editor) { editor.redo(); }
  9743. }, {
  9744. name: "copylinesup",
  9745. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  9746. exec: function(editor) { editor.copyLinesUp(); },
  9747. scrollIntoView: "cursor"
  9748. }, {
  9749. name: "movelinesup",
  9750. bindKey: bindKey("Alt-Up", "Option-Up"),
  9751. exec: function(editor) { editor.moveLinesUp(); },
  9752. scrollIntoView: "cursor"
  9753. }, {
  9754. name: "copylinesdown",
  9755. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  9756. exec: function(editor) { editor.copyLinesDown(); },
  9757. scrollIntoView: "cursor"
  9758. }, {
  9759. name: "movelinesdown",
  9760. bindKey: bindKey("Alt-Down", "Option-Down"),
  9761. exec: function(editor) { editor.moveLinesDown(); },
  9762. scrollIntoView: "cursor"
  9763. }, {
  9764. name: "del",
  9765. bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
  9766. exec: function(editor) { editor.remove("right"); },
  9767. multiSelectAction: "forEach",
  9768. scrollIntoView: "cursor"
  9769. }, {
  9770. name: "backspace",
  9771. bindKey: bindKey(
  9772. "Shift-Backspace|Backspace",
  9773. "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  9774. ),
  9775. exec: function(editor) { editor.remove("left"); },
  9776. multiSelectAction: "forEach",
  9777. scrollIntoView: "cursor"
  9778. }, {
  9779. name: "cut_or_delete",
  9780. bindKey: bindKey("Shift-Delete", null),
  9781. exec: function(editor) {
  9782. if (editor.selection.isEmpty()) {
  9783. editor.remove("left");
  9784. } else {
  9785. return false;
  9786. }
  9787. },
  9788. multiSelectAction: "forEach",
  9789. scrollIntoView: "cursor"
  9790. }, {
  9791. name: "removetolinestart",
  9792. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  9793. exec: function(editor) { editor.removeToLineStart(); },
  9794. multiSelectAction: "forEach",
  9795. scrollIntoView: "cursor"
  9796. }, {
  9797. name: "removetolineend",
  9798. bindKey: bindKey("Alt-Delete", "Ctrl-K"),
  9799. exec: function(editor) { editor.removeToLineEnd(); },
  9800. multiSelectAction: "forEach",
  9801. scrollIntoView: "cursor"
  9802. }, {
  9803. name: "removewordleft",
  9804. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  9805. exec: function(editor) { editor.removeWordLeft(); },
  9806. multiSelectAction: "forEach",
  9807. scrollIntoView: "cursor"
  9808. }, {
  9809. name: "removewordright",
  9810. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  9811. exec: function(editor) { editor.removeWordRight(); },
  9812. multiSelectAction: "forEach",
  9813. scrollIntoView: "cursor"
  9814. }, {
  9815. name: "outdent",
  9816. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  9817. exec: function(editor) { editor.blockOutdent(); },
  9818. multiSelectAction: "forEach",
  9819. scrollIntoView: "selectionPart"
  9820. }, {
  9821. name: "indent",
  9822. bindKey: bindKey("Tab", "Tab"),
  9823. exec: function(editor) { editor.indent(); },
  9824. multiSelectAction: "forEach",
  9825. scrollIntoView: "selectionPart"
  9826. }, {
  9827. name: "blockoutdent",
  9828. bindKey: bindKey("Ctrl-[", "Ctrl-["),
  9829. exec: function(editor) { editor.blockOutdent(); },
  9830. multiSelectAction: "forEachLine",
  9831. scrollIntoView: "selectionPart"
  9832. }, {
  9833. name: "blockindent",
  9834. bindKey: bindKey("Ctrl-]", "Ctrl-]"),
  9835. exec: function(editor) { editor.blockIndent(); },
  9836. multiSelectAction: "forEachLine",
  9837. scrollIntoView: "selectionPart"
  9838. }, {
  9839. name: "insertstring",
  9840. exec: function(editor, str) { editor.insert(str); },
  9841. multiSelectAction: "forEach",
  9842. scrollIntoView: "cursor"
  9843. }, {
  9844. name: "inserttext",
  9845. exec: function(editor, args) {
  9846. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  9847. },
  9848. multiSelectAction: "forEach",
  9849. scrollIntoView: "cursor"
  9850. }, {
  9851. name: "splitline",
  9852. bindKey: bindKey(null, "Ctrl-O"),
  9853. exec: function(editor) { editor.splitLine(); },
  9854. multiSelectAction: "forEach",
  9855. scrollIntoView: "cursor"
  9856. }, {
  9857. name: "transposeletters",
  9858. bindKey: bindKey("Ctrl-T", "Ctrl-T"),
  9859. exec: function(editor) { editor.transposeLetters(); },
  9860. multiSelectAction: function(editor) {editor.transposeSelections(1); },
  9861. scrollIntoView: "cursor"
  9862. }, {
  9863. name: "touppercase",
  9864. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  9865. exec: function(editor) { editor.toUpperCase(); },
  9866. multiSelectAction: "forEach",
  9867. scrollIntoView: "cursor"
  9868. }, {
  9869. name: "tolowercase",
  9870. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  9871. exec: function(editor) { editor.toLowerCase(); },
  9872. multiSelectAction: "forEach",
  9873. scrollIntoView: "cursor"
  9874. }, {
  9875. name: "expandtoline",
  9876. bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
  9877. exec: function(editor) {
  9878. var range = editor.selection.getRange();
  9879. range.start.column = range.end.column = 0;
  9880. range.end.row++;
  9881. editor.selection.setRange(range, false);
  9882. },
  9883. multiSelectAction: "forEach",
  9884. scrollIntoView: "cursor",
  9885. readOnly: true
  9886. }, {
  9887. name: "joinlines",
  9888. bindKey: bindKey(null, null),
  9889. exec: function(editor) {
  9890. var isBackwards = editor.selection.isBackwards();
  9891. var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
  9892. var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
  9893. var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
  9894. var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
  9895. var selectedCount = selectedText.replace(/\n\s*/, " ").length;
  9896. var insertLine = editor.session.doc.getLine(selectionStart.row);
  9897. for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
  9898. var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
  9899. if (curLine.length !== 0) {
  9900. curLine = " " + curLine;
  9901. }
  9902. insertLine += curLine;
  9903. }
  9904. if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
  9905. insertLine += editor.session.doc.getNewLineCharacter();
  9906. }
  9907. editor.clearSelection();
  9908. editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
  9909. if (selectedCount > 0) {
  9910. editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
  9911. editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
  9912. } else {
  9913. firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
  9914. editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
  9915. }
  9916. },
  9917. multiSelectAction: "forEach",
  9918. readOnly: true
  9919. }, {
  9920. name: "invertSelection",
  9921. bindKey: bindKey(null, null),
  9922. exec: function(editor) {
  9923. var endRow = editor.session.doc.getLength() - 1;
  9924. var endCol = editor.session.doc.getLine(endRow).length;
  9925. var ranges = editor.selection.rangeList.ranges;
  9926. var newRanges = [];
  9927. if (ranges.length < 1) {
  9928. ranges = [editor.selection.getRange()];
  9929. }
  9930. for (var i = 0; i < ranges.length; i++) {
  9931. if (i == (ranges.length - 1)) {
  9932. if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
  9933. newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
  9934. }
  9935. }
  9936. if (i === 0) {
  9937. if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
  9938. newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
  9939. }
  9940. } else {
  9941. newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
  9942. }
  9943. }
  9944. editor.exitMultiSelectMode();
  9945. editor.clearSelection();
  9946. for(var i = 0; i < newRanges.length; i++) {
  9947. editor.selection.addRange(newRanges[i], false);
  9948. }
  9949. },
  9950. readOnly: true,
  9951. scrollIntoView: "none"
  9952. }];
  9953. });
  9954. 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) {
  9955. "use strict";
  9956. require("./lib/fixoldbrowsers");
  9957. var oop = require("./lib/oop");
  9958. var dom = require("./lib/dom");
  9959. var lang = require("./lib/lang");
  9960. var useragent = require("./lib/useragent");
  9961. var TextInput = require("./keyboard/textinput").TextInput;
  9962. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  9963. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  9964. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  9965. var EditSession = require("./edit_session").EditSession;
  9966. var Search = require("./search").Search;
  9967. var Range = require("./range").Range;
  9968. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  9969. var CommandManager = require("./commands/command_manager").CommandManager;
  9970. var defaultCommands = require("./commands/default_commands").commands;
  9971. var config = require("./config");
  9972. var TokenIterator = require("./token_iterator").TokenIterator;
  9973. var Editor = function(renderer, session) {
  9974. var container = renderer.getContainerElement();
  9975. this.container = container;
  9976. this.renderer = renderer;
  9977. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  9978. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  9979. this.renderer.textarea = this.textInput.getElement();
  9980. this.keyBinding = new KeyBinding(this);
  9981. this.$mouseHandler = new MouseHandler(this);
  9982. new FoldHandler(this);
  9983. this.$blockScrolling = 0;
  9984. this.$search = new Search().set({
  9985. wrap: true
  9986. });
  9987. this.$historyTracker = this.$historyTracker.bind(this);
  9988. this.commands.on("exec", this.$historyTracker);
  9989. this.$initOperationListeners();
  9990. this._$emitInputEvent = lang.delayedCall(function() {
  9991. this._signal("input", {});
  9992. if (this.session && this.session.bgTokenizer)
  9993. this.session.bgTokenizer.scheduleStart();
  9994. }.bind(this));
  9995. this.on("change", function(_, _self) {
  9996. _self._$emitInputEvent.schedule(31);
  9997. });
  9998. this.setSession(session || new EditSession(""));
  9999. config.resetOptions(this);
  10000. config._signal("editor", this);
  10001. };
  10002. (function(){
  10003. oop.implement(this, EventEmitter);
  10004. this.$initOperationListeners = function() {
  10005. function last(a) {return a[a.length - 1]}
  10006. this.selections = [];
  10007. this.commands.on("exec", this.startOperation.bind(this), true);
  10008. this.commands.on("afterExec", this.endOperation.bind(this), true);
  10009. this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
  10010. this.on("change", function() {
  10011. this.curOp || this.startOperation();
  10012. this.curOp.docChanged = true;
  10013. }.bind(this), true);
  10014. this.on("changeSelection", function() {
  10015. this.curOp || this.startOperation();
  10016. this.curOp.selectionChanged = true;
  10017. }.bind(this), true);
  10018. };
  10019. this.curOp = null;
  10020. this.prevOp = {};
  10021. this.startOperation = function(commadEvent) {
  10022. if (this.curOp) {
  10023. if (!commadEvent || this.curOp.command)
  10024. return;
  10025. this.prevOp = this.curOp;
  10026. }
  10027. if (!commadEvent) {
  10028. this.previousCommand = null;
  10029. commadEvent = {};
  10030. }
  10031. this.$opResetTimer.schedule();
  10032. this.curOp = {
  10033. command: commadEvent.command || {},
  10034. args: commadEvent.args,
  10035. scrollTop: this.renderer.scrollTop
  10036. };
  10037. if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
  10038. this.$blockScrolling++;
  10039. };
  10040. this.endOperation = function(e) {
  10041. if (this.curOp) {
  10042. if (e && e.returnValue === false)
  10043. return this.curOp = null;
  10044. this._signal("beforeEndOperation");
  10045. var command = this.curOp.command;
  10046. if (command.name && this.$blockScrolling > 0)
  10047. this.$blockScrolling--;
  10048. var scrollIntoView = command && command.scrollIntoView;
  10049. if (scrollIntoView) {
  10050. switch (scrollIntoView) {
  10051. case "center-animate":
  10052. scrollIntoView = "animate";
  10053. case "center":
  10054. this.renderer.scrollCursorIntoView(null, 0.5);
  10055. break;
  10056. case "animate":
  10057. case "cursor":
  10058. this.renderer.scrollCursorIntoView();
  10059. break;
  10060. case "selectionPart":
  10061. var range = this.selection.getRange();
  10062. var config = this.renderer.layerConfig;
  10063. if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
  10064. this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
  10065. }
  10066. break;
  10067. default:
  10068. break;
  10069. }
  10070. if (scrollIntoView == "animate")
  10071. this.renderer.animateScrolling(this.curOp.scrollTop);
  10072. }
  10073. this.prevOp = this.curOp;
  10074. this.curOp = null;
  10075. }
  10076. };
  10077. this.$mergeableCommands = ["backspace", "del", "insertstring"];
  10078. this.$historyTracker = function(e) {
  10079. if (!this.$mergeUndoDeltas)
  10080. return;
  10081. var prev = this.prevOp;
  10082. var mergeableCommands = this.$mergeableCommands;
  10083. var shouldMerge = prev.command && (e.command.name == prev.command.name);
  10084. if (e.command.name == "insertstring") {
  10085. var text = e.args;
  10086. if (this.mergeNextCommand === undefined)
  10087. this.mergeNextCommand = true;
  10088. shouldMerge = shouldMerge
  10089. && this.mergeNextCommand // previous command allows to coalesce with
  10090. && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
  10091. this.mergeNextCommand = true;
  10092. } else {
  10093. shouldMerge = shouldMerge
  10094. && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
  10095. }
  10096. if (
  10097. this.$mergeUndoDeltas != "always"
  10098. && Date.now() - this.sequenceStartTime > 2000
  10099. ) {
  10100. shouldMerge = false; // the sequence is too long
  10101. }
  10102. if (shouldMerge)
  10103. this.session.mergeUndoDeltas = true;
  10104. else if (mergeableCommands.indexOf(e.command.name) !== -1)
  10105. this.sequenceStartTime = Date.now();
  10106. };
  10107. this.setKeyboardHandler = function(keyboardHandler, cb) {
  10108. if (keyboardHandler && typeof keyboardHandler === "string") {
  10109. this.$keybindingId = keyboardHandler;
  10110. var _self = this;
  10111. config.loadModule(["keybinding", keyboardHandler], function(module) {
  10112. if (_self.$keybindingId == keyboardHandler)
  10113. _self.keyBinding.setKeyboardHandler(module && module.handler);
  10114. cb && cb();
  10115. });
  10116. } else {
  10117. this.$keybindingId = null;
  10118. this.keyBinding.setKeyboardHandler(keyboardHandler);
  10119. cb && cb();
  10120. }
  10121. };
  10122. this.getKeyboardHandler = function() {
  10123. return this.keyBinding.getKeyboardHandler();
  10124. };
  10125. this.setSession = function(session) {
  10126. if (this.session == session)
  10127. return;
  10128. if (this.curOp) this.endOperation();
  10129. this.curOp = {};
  10130. var oldSession = this.session;
  10131. if (oldSession) {
  10132. this.session.off("change", this.$onDocumentChange);
  10133. this.session.off("changeMode", this.$onChangeMode);
  10134. this.session.off("tokenizerUpdate", this.$onTokenizerUpdate);
  10135. this.session.off("changeTabSize", this.$onChangeTabSize);
  10136. this.session.off("changeWrapLimit", this.$onChangeWrapLimit);
  10137. this.session.off("changeWrapMode", this.$onChangeWrapMode);
  10138. this.session.off("changeFold", this.$onChangeFold);
  10139. this.session.off("changeFrontMarker", this.$onChangeFrontMarker);
  10140. this.session.off("changeBackMarker", this.$onChangeBackMarker);
  10141. this.session.off("changeBreakpoint", this.$onChangeBreakpoint);
  10142. this.session.off("changeAnnotation", this.$onChangeAnnotation);
  10143. this.session.off("changeOverwrite", this.$onCursorChange);
  10144. this.session.off("changeScrollTop", this.$onScrollTopChange);
  10145. this.session.off("changeScrollLeft", this.$onScrollLeftChange);
  10146. var selection = this.session.getSelection();
  10147. selection.off("changeCursor", this.$onCursorChange);
  10148. selection.off("changeSelection", this.$onSelectionChange);
  10149. }
  10150. this.session = session;
  10151. if (session) {
  10152. this.$onDocumentChange = this.onDocumentChange.bind(this);
  10153. session.on("change", this.$onDocumentChange);
  10154. this.renderer.setSession(session);
  10155. this.$onChangeMode = this.onChangeMode.bind(this);
  10156. session.on("changeMode", this.$onChangeMode);
  10157. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  10158. session.on("tokenizerUpdate", this.$onTokenizerUpdate);
  10159. this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
  10160. session.on("changeTabSize", this.$onChangeTabSize);
  10161. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  10162. session.on("changeWrapLimit", this.$onChangeWrapLimit);
  10163. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  10164. session.on("changeWrapMode", this.$onChangeWrapMode);
  10165. this.$onChangeFold = this.onChangeFold.bind(this);
  10166. session.on("changeFold", this.$onChangeFold);
  10167. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  10168. this.session.on("changeFrontMarker", this.$onChangeFrontMarker);
  10169. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  10170. this.session.on("changeBackMarker", this.$onChangeBackMarker);
  10171. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  10172. this.session.on("changeBreakpoint", this.$onChangeBreakpoint);
  10173. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  10174. this.session.on("changeAnnotation", this.$onChangeAnnotation);
  10175. this.$onCursorChange = this.onCursorChange.bind(this);
  10176. this.session.on("changeOverwrite", this.$onCursorChange);
  10177. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  10178. this.session.on("changeScrollTop", this.$onScrollTopChange);
  10179. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  10180. this.session.on("changeScrollLeft", this.$onScrollLeftChange);
  10181. this.selection = session.getSelection();
  10182. this.selection.on("changeCursor", this.$onCursorChange);
  10183. this.$onSelectionChange = this.onSelectionChange.bind(this);
  10184. this.selection.on("changeSelection", this.$onSelectionChange);
  10185. this.onChangeMode();
  10186. this.$blockScrolling += 1;
  10187. this.onCursorChange();
  10188. this.$blockScrolling -= 1;
  10189. this.onScrollTopChange();
  10190. this.onScrollLeftChange();
  10191. this.onSelectionChange();
  10192. this.onChangeFrontMarker();
  10193. this.onChangeBackMarker();
  10194. this.onChangeBreakpoint();
  10195. this.onChangeAnnotation();
  10196. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  10197. this.renderer.updateFull();
  10198. } else {
  10199. this.selection = null;
  10200. this.renderer.setSession(session);
  10201. }
  10202. this._signal("changeSession", {
  10203. session: session,
  10204. oldSession: oldSession
  10205. });
  10206. this.curOp = null;
  10207. oldSession && oldSession._signal("changeEditor", {oldEditor: this});
  10208. session && session._signal("changeEditor", {editor: this});
  10209. };
  10210. this.getSession = function() {
  10211. return this.session;
  10212. };
  10213. this.setValue = function(val, cursorPos) {
  10214. this.session.doc.setValue(val);
  10215. if (!cursorPos)
  10216. this.selectAll();
  10217. else if (cursorPos == 1)
  10218. this.navigateFileEnd();
  10219. else if (cursorPos == -1)
  10220. this.navigateFileStart();
  10221. return val;
  10222. };
  10223. this.getValue = function() {
  10224. return this.session.getValue();
  10225. };
  10226. this.getSelection = function() {
  10227. return this.selection;
  10228. };
  10229. this.resize = function(force) {
  10230. this.renderer.onResize(force);
  10231. };
  10232. this.setTheme = function(theme, cb) {
  10233. this.renderer.setTheme(theme, cb);
  10234. };
  10235. this.getTheme = function() {
  10236. return this.renderer.getTheme();
  10237. };
  10238. this.setStyle = function(style) {
  10239. this.renderer.setStyle(style);
  10240. };
  10241. this.unsetStyle = function(style) {
  10242. this.renderer.unsetStyle(style);
  10243. };
  10244. this.getFontSize = function () {
  10245. return this.getOption("fontSize") ||
  10246. dom.computedStyle(this.container, "fontSize");
  10247. };
  10248. this.setFontSize = function(size) {
  10249. this.setOption("fontSize", size);
  10250. };
  10251. this.$highlightBrackets = function() {
  10252. if (this.session.$bracketHighlight) {
  10253. this.session.removeMarker(this.session.$bracketHighlight);
  10254. this.session.$bracketHighlight = null;
  10255. }
  10256. if (this.$highlightPending) {
  10257. return;
  10258. }
  10259. var self = this;
  10260. this.$highlightPending = true;
  10261. setTimeout(function() {
  10262. self.$highlightPending = false;
  10263. var session = self.session;
  10264. if (!session || !session.bgTokenizer) return;
  10265. var pos = session.findMatchingBracket(self.getCursorPosition());
  10266. if (pos) {
  10267. var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
  10268. } else if (session.$mode.getMatching) {
  10269. var range = session.$mode.getMatching(self.session);
  10270. }
  10271. if (range)
  10272. session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
  10273. }, 50);
  10274. };
  10275. this.$highlightTags = function() {
  10276. if (this.$highlightTagPending)
  10277. return;
  10278. var self = this;
  10279. this.$highlightTagPending = true;
  10280. setTimeout(function() {
  10281. self.$highlightTagPending = false;
  10282. var session = self.session;
  10283. if (!session || !session.bgTokenizer) return;
  10284. var pos = self.getCursorPosition();
  10285. var iterator = new TokenIterator(self.session, pos.row, pos.column);
  10286. var token = iterator.getCurrentToken();
  10287. if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
  10288. session.removeMarker(session.$tagHighlight);
  10289. session.$tagHighlight = null;
  10290. return;
  10291. }
  10292. if (token.type.indexOf("tag-open") != -1) {
  10293. token = iterator.stepForward();
  10294. if (!token)
  10295. return;
  10296. }
  10297. var tag = token.value;
  10298. var depth = 0;
  10299. var prevToken = iterator.stepBackward();
  10300. if (prevToken.value == '<'){
  10301. do {
  10302. prevToken = token;
  10303. token = iterator.stepForward();
  10304. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10305. if (prevToken.value === '<'){
  10306. depth++;
  10307. } else if (prevToken.value === '</'){
  10308. depth--;
  10309. }
  10310. }
  10311. } while (token && depth >= 0);
  10312. } else {
  10313. do {
  10314. token = prevToken;
  10315. prevToken = iterator.stepBackward();
  10316. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10317. if (prevToken.value === '<') {
  10318. depth++;
  10319. } else if (prevToken.value === '</') {
  10320. depth--;
  10321. }
  10322. }
  10323. } while (prevToken && depth <= 0);
  10324. iterator.stepForward();
  10325. }
  10326. if (!token) {
  10327. session.removeMarker(session.$tagHighlight);
  10328. session.$tagHighlight = null;
  10329. return;
  10330. }
  10331. var row = iterator.getCurrentTokenRow();
  10332. var column = iterator.getCurrentTokenColumn();
  10333. var range = new Range(row, column, row, column+token.value.length);
  10334. if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
  10335. session.removeMarker(session.$tagHighlight);
  10336. session.$tagHighlight = null;
  10337. }
  10338. if (range && !session.$tagHighlight)
  10339. session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
  10340. }, 50);
  10341. };
  10342. this.focus = function() {
  10343. var _self = this;
  10344. setTimeout(function() {
  10345. _self.textInput.focus();
  10346. });
  10347. this.textInput.focus();
  10348. };
  10349. this.isFocused = function() {
  10350. return this.textInput.isFocused();
  10351. };
  10352. this.blur = function() {
  10353. this.textInput.blur();
  10354. };
  10355. this.onFocus = function(e) {
  10356. if (this.$isFocused)
  10357. return;
  10358. this.$isFocused = true;
  10359. this.renderer.showCursor();
  10360. this.renderer.visualizeFocus();
  10361. this._emit("focus", e);
  10362. };
  10363. this.onBlur = function(e) {
  10364. if (!this.$isFocused)
  10365. return;
  10366. this.$isFocused = false;
  10367. this.renderer.hideCursor();
  10368. this.renderer.visualizeBlur();
  10369. this._emit("blur", e);
  10370. };
  10371. this.$cursorChange = function() {
  10372. this.renderer.updateCursor();
  10373. };
  10374. this.onDocumentChange = function(delta) {
  10375. var wrap = this.session.$useWrapMode;
  10376. var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
  10377. this.renderer.updateLines(delta.start.row, lastRow, wrap);
  10378. this._signal("change", delta);
  10379. this.$cursorChange();
  10380. this.$updateHighlightActiveLine();
  10381. };
  10382. this.onTokenizerUpdate = function(e) {
  10383. var rows = e.data;
  10384. this.renderer.updateLines(rows.first, rows.last);
  10385. };
  10386. this.onScrollTopChange = function() {
  10387. this.renderer.scrollToY(this.session.getScrollTop());
  10388. };
  10389. this.onScrollLeftChange = function() {
  10390. this.renderer.scrollToX(this.session.getScrollLeft());
  10391. };
  10392. this.onCursorChange = function() {
  10393. this.$cursorChange();
  10394. if (!this.$blockScrolling) {
  10395. config.warn("Automatically scrolling cursor into view after selection change",
  10396. "this will be disabled in the next version",
  10397. "set editor.$blockScrolling = Infinity to disable this message"
  10398. );
  10399. this.renderer.scrollCursorIntoView();
  10400. }
  10401. this.$highlightBrackets();
  10402. this.$highlightTags();
  10403. this.$updateHighlightActiveLine();
  10404. this._signal("changeSelection");
  10405. };
  10406. this.$updateHighlightActiveLine = function() {
  10407. var session = this.getSession();
  10408. var highlight;
  10409. if (this.$highlightActiveLine) {
  10410. if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
  10411. highlight = this.getCursorPosition();
  10412. if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
  10413. highlight = false;
  10414. }
  10415. if (session.$highlightLineMarker && !highlight) {
  10416. session.removeMarker(session.$highlightLineMarker.id);
  10417. session.$highlightLineMarker = null;
  10418. } else if (!session.$highlightLineMarker && highlight) {
  10419. var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
  10420. range.id = session.addMarker(range, "ace_active-line", "screenLine");
  10421. session.$highlightLineMarker = range;
  10422. } else if (highlight) {
  10423. session.$highlightLineMarker.start.row = highlight.row;
  10424. session.$highlightLineMarker.end.row = highlight.row;
  10425. session.$highlightLineMarker.start.column = highlight.column;
  10426. session._signal("changeBackMarker");
  10427. }
  10428. };
  10429. this.onSelectionChange = function(e) {
  10430. var session = this.session;
  10431. if (session.$selectionMarker) {
  10432. session.removeMarker(session.$selectionMarker);
  10433. }
  10434. session.$selectionMarker = null;
  10435. if (!this.selection.isEmpty()) {
  10436. var range = this.selection.getRange();
  10437. var style = this.getSelectionStyle();
  10438. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  10439. } else {
  10440. this.$updateHighlightActiveLine();
  10441. }
  10442. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
  10443. this.session.highlight(re);
  10444. this._signal("changeSelection");
  10445. };
  10446. this.$getSelectionHighLightRegexp = function() {
  10447. var session = this.session;
  10448. var selection = this.getSelectionRange();
  10449. if (selection.isEmpty() || selection.isMultiLine())
  10450. return;
  10451. var startOuter = selection.start.column - 1;
  10452. var endOuter = selection.end.column + 1;
  10453. var line = session.getLine(selection.start.row);
  10454. var lineCols = line.length;
  10455. var needle = line.substring(Math.max(startOuter, 0),
  10456. Math.min(endOuter, lineCols));
  10457. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  10458. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  10459. return;
  10460. needle = line.substring(selection.start.column, selection.end.column);
  10461. if (!/^[\w\d]+$/.test(needle))
  10462. return;
  10463. var re = this.$search.$assembleRegExp({
  10464. wholeWord: true,
  10465. caseSensitive: true,
  10466. needle: needle
  10467. });
  10468. return re;
  10469. };
  10470. this.onChangeFrontMarker = function() {
  10471. this.renderer.updateFrontMarkers();
  10472. };
  10473. this.onChangeBackMarker = function() {
  10474. this.renderer.updateBackMarkers();
  10475. };
  10476. this.onChangeBreakpoint = function() {
  10477. this.renderer.updateBreakpoints();
  10478. };
  10479. this.onChangeAnnotation = function() {
  10480. this.renderer.setAnnotations(this.session.getAnnotations());
  10481. };
  10482. this.onChangeMode = function(e) {
  10483. this.renderer.updateText();
  10484. this._emit("changeMode", e);
  10485. };
  10486. this.onChangeWrapLimit = function() {
  10487. this.renderer.updateFull();
  10488. };
  10489. this.onChangeWrapMode = function() {
  10490. this.renderer.onResize(true);
  10491. };
  10492. this.onChangeFold = function() {
  10493. this.$updateHighlightActiveLine();
  10494. this.renderer.updateFull();
  10495. };
  10496. this.getSelectedText = function() {
  10497. return this.session.getTextRange(this.getSelectionRange());
  10498. };
  10499. this.getCopyText = function() {
  10500. var text = this.getSelectedText();
  10501. this._signal("copy", text);
  10502. return text;
  10503. };
  10504. this.onCopy = function() {
  10505. this.commands.exec("copy", this);
  10506. };
  10507. this.onCut = function() {
  10508. this.commands.exec("cut", this);
  10509. };
  10510. this.onPaste = function(text, event) {
  10511. var e = {text: text, event: event};
  10512. this.commands.exec("paste", this, e);
  10513. };
  10514. this.$handlePaste = function(e) {
  10515. if (typeof e == "string")
  10516. e = {text: e};
  10517. this._signal("paste", e);
  10518. var text = e.text;
  10519. if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
  10520. this.insert(text);
  10521. } else {
  10522. var lines = text.split(/\r\n|\r|\n/);
  10523. var ranges = this.selection.rangeList.ranges;
  10524. if (lines.length > ranges.length || lines.length < 2 || !lines[1])
  10525. return this.commands.exec("insertstring", this, text);
  10526. for (var i = ranges.length; i--;) {
  10527. var range = ranges[i];
  10528. if (!range.isEmpty())
  10529. this.session.remove(range);
  10530. this.session.insert(range.start, lines[i]);
  10531. }
  10532. }
  10533. };
  10534. this.execCommand = function(command, args) {
  10535. return this.commands.exec(command, this, args);
  10536. };
  10537. this.insert = function(text, pasted) {
  10538. var session = this.session;
  10539. var mode = session.getMode();
  10540. var cursor = this.getCursorPosition();
  10541. if (this.getBehavioursEnabled() && !pasted) {
  10542. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  10543. if (transform) {
  10544. if (text !== transform.text) {
  10545. this.session.mergeUndoDeltas = false;
  10546. this.$mergeNextCommand = false;
  10547. }
  10548. text = transform.text;
  10549. }
  10550. }
  10551. if (text == "\t")
  10552. text = this.session.getTabString();
  10553. if (!this.selection.isEmpty()) {
  10554. var range = this.getSelectionRange();
  10555. cursor = this.session.remove(range);
  10556. this.clearSelection();
  10557. }
  10558. else if (this.session.getOverwrite()) {
  10559. var range = new Range.fromPoints(cursor, cursor);
  10560. range.end.column += text.length;
  10561. this.session.remove(range);
  10562. }
  10563. if (text == "\n" || text == "\r\n") {
  10564. var line = session.getLine(cursor.row);
  10565. if (cursor.column > line.search(/\S|$/)) {
  10566. var d = line.substr(cursor.column).search(/\S|$/);
  10567. session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
  10568. }
  10569. }
  10570. this.clearSelection();
  10571. var start = cursor.column;
  10572. var lineState = session.getState(cursor.row);
  10573. var line = session.getLine(cursor.row);
  10574. var shouldOutdent = mode.checkOutdent(lineState, line, text);
  10575. var end = session.insert(cursor, text);
  10576. if (transform && transform.selection) {
  10577. if (transform.selection.length == 2) { // Transform relative to the current column
  10578. this.selection.setSelectionRange(
  10579. new Range(cursor.row, start + transform.selection[0],
  10580. cursor.row, start + transform.selection[1]));
  10581. } else { // Transform relative to the current row.
  10582. this.selection.setSelectionRange(
  10583. new Range(cursor.row + transform.selection[0],
  10584. transform.selection[1],
  10585. cursor.row + transform.selection[2],
  10586. transform.selection[3]));
  10587. }
  10588. }
  10589. if (session.getDocument().isNewLine(text)) {
  10590. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  10591. session.insert({row: cursor.row+1, column: 0}, lineIndent);
  10592. }
  10593. if (shouldOutdent)
  10594. mode.autoOutdent(lineState, session, cursor.row);
  10595. };
  10596. this.onTextInput = function(text) {
  10597. this.keyBinding.onTextInput(text);
  10598. };
  10599. this.onCommandKey = function(e, hashId, keyCode) {
  10600. this.keyBinding.onCommandKey(e, hashId, keyCode);
  10601. };
  10602. this.setOverwrite = function(overwrite) {
  10603. this.session.setOverwrite(overwrite);
  10604. };
  10605. this.getOverwrite = function() {
  10606. return this.session.getOverwrite();
  10607. };
  10608. this.toggleOverwrite = function() {
  10609. this.session.toggleOverwrite();
  10610. };
  10611. this.setScrollSpeed = function(speed) {
  10612. this.setOption("scrollSpeed", speed);
  10613. };
  10614. this.getScrollSpeed = function() {
  10615. return this.getOption("scrollSpeed");
  10616. };
  10617. this.setDragDelay = function(dragDelay) {
  10618. this.setOption("dragDelay", dragDelay);
  10619. };
  10620. this.getDragDelay = function() {
  10621. return this.getOption("dragDelay");
  10622. };
  10623. this.setSelectionStyle = function(val) {
  10624. this.setOption("selectionStyle", val);
  10625. };
  10626. this.getSelectionStyle = function() {
  10627. return this.getOption("selectionStyle");
  10628. };
  10629. this.setHighlightActiveLine = function(shouldHighlight) {
  10630. this.setOption("highlightActiveLine", shouldHighlight);
  10631. };
  10632. this.getHighlightActiveLine = function() {
  10633. return this.getOption("highlightActiveLine");
  10634. };
  10635. this.setHighlightGutterLine = function(shouldHighlight) {
  10636. this.setOption("highlightGutterLine", shouldHighlight);
  10637. };
  10638. this.getHighlightGutterLine = function() {
  10639. return this.getOption("highlightGutterLine");
  10640. };
  10641. this.setHighlightSelectedWord = function(shouldHighlight) {
  10642. this.setOption("highlightSelectedWord", shouldHighlight);
  10643. };
  10644. this.getHighlightSelectedWord = function() {
  10645. return this.$highlightSelectedWord;
  10646. };
  10647. this.setAnimatedScroll = function(shouldAnimate){
  10648. this.renderer.setAnimatedScroll(shouldAnimate);
  10649. };
  10650. this.getAnimatedScroll = function(){
  10651. return this.renderer.getAnimatedScroll();
  10652. };
  10653. this.setShowInvisibles = function(showInvisibles) {
  10654. this.renderer.setShowInvisibles(showInvisibles);
  10655. };
  10656. this.getShowInvisibles = function() {
  10657. return this.renderer.getShowInvisibles();
  10658. };
  10659. this.setDisplayIndentGuides = function(display) {
  10660. this.renderer.setDisplayIndentGuides(display);
  10661. };
  10662. this.getDisplayIndentGuides = function() {
  10663. return this.renderer.getDisplayIndentGuides();
  10664. };
  10665. this.setShowPrintMargin = function(showPrintMargin) {
  10666. this.renderer.setShowPrintMargin(showPrintMargin);
  10667. };
  10668. this.getShowPrintMargin = function() {
  10669. return this.renderer.getShowPrintMargin();
  10670. };
  10671. this.setPrintMarginColumn = function(showPrintMargin) {
  10672. this.renderer.setPrintMarginColumn(showPrintMargin);
  10673. };
  10674. this.getPrintMarginColumn = function() {
  10675. return this.renderer.getPrintMarginColumn();
  10676. };
  10677. this.setReadOnly = function(readOnly) {
  10678. this.setOption("readOnly", readOnly);
  10679. };
  10680. this.getReadOnly = function() {
  10681. return this.getOption("readOnly");
  10682. };
  10683. this.setBehavioursEnabled = function (enabled) {
  10684. this.setOption("behavioursEnabled", enabled);
  10685. };
  10686. this.getBehavioursEnabled = function () {
  10687. return this.getOption("behavioursEnabled");
  10688. };
  10689. this.setWrapBehavioursEnabled = function (enabled) {
  10690. this.setOption("wrapBehavioursEnabled", enabled);
  10691. };
  10692. this.getWrapBehavioursEnabled = function () {
  10693. return this.getOption("wrapBehavioursEnabled");
  10694. };
  10695. this.setShowFoldWidgets = function(show) {
  10696. this.setOption("showFoldWidgets", show);
  10697. };
  10698. this.getShowFoldWidgets = function() {
  10699. return this.getOption("showFoldWidgets");
  10700. };
  10701. this.setFadeFoldWidgets = function(fade) {
  10702. this.setOption("fadeFoldWidgets", fade);
  10703. };
  10704. this.getFadeFoldWidgets = function() {
  10705. return this.getOption("fadeFoldWidgets");
  10706. };
  10707. this.remove = function(dir) {
  10708. if (this.selection.isEmpty()){
  10709. if (dir == "left")
  10710. this.selection.selectLeft();
  10711. else
  10712. this.selection.selectRight();
  10713. }
  10714. var range = this.getSelectionRange();
  10715. if (this.getBehavioursEnabled()) {
  10716. var session = this.session;
  10717. var state = session.getState(range.start.row);
  10718. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  10719. if (range.end.column === 0) {
  10720. var text = session.getTextRange(range);
  10721. if (text[text.length - 1] == "\n") {
  10722. var line = session.getLine(range.end.row);
  10723. if (/^\s+$/.test(line)) {
  10724. range.end.column = line.length;
  10725. }
  10726. }
  10727. }
  10728. if (new_range)
  10729. range = new_range;
  10730. }
  10731. this.session.remove(range);
  10732. this.clearSelection();
  10733. };
  10734. this.removeWordRight = function() {
  10735. if (this.selection.isEmpty())
  10736. this.selection.selectWordRight();
  10737. this.session.remove(this.getSelectionRange());
  10738. this.clearSelection();
  10739. };
  10740. this.removeWordLeft = function() {
  10741. if (this.selection.isEmpty())
  10742. this.selection.selectWordLeft();
  10743. this.session.remove(this.getSelectionRange());
  10744. this.clearSelection();
  10745. };
  10746. this.removeToLineStart = function() {
  10747. if (this.selection.isEmpty())
  10748. this.selection.selectLineStart();
  10749. this.session.remove(this.getSelectionRange());
  10750. this.clearSelection();
  10751. };
  10752. this.removeToLineEnd = function() {
  10753. if (this.selection.isEmpty())
  10754. this.selection.selectLineEnd();
  10755. var range = this.getSelectionRange();
  10756. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  10757. range.end.column = 0;
  10758. range.end.row++;
  10759. }
  10760. this.session.remove(range);
  10761. this.clearSelection();
  10762. };
  10763. this.splitLine = function() {
  10764. if (!this.selection.isEmpty()) {
  10765. this.session.remove(this.getSelectionRange());
  10766. this.clearSelection();
  10767. }
  10768. var cursor = this.getCursorPosition();
  10769. this.insert("\n");
  10770. this.moveCursorToPosition(cursor);
  10771. };
  10772. this.transposeLetters = function() {
  10773. if (!this.selection.isEmpty()) {
  10774. return;
  10775. }
  10776. var cursor = this.getCursorPosition();
  10777. var column = cursor.column;
  10778. if (column === 0)
  10779. return;
  10780. var line = this.session.getLine(cursor.row);
  10781. var swap, range;
  10782. if (column < line.length) {
  10783. swap = line.charAt(column) + line.charAt(column-1);
  10784. range = new Range(cursor.row, column-1, cursor.row, column+1);
  10785. }
  10786. else {
  10787. swap = line.charAt(column-1) + line.charAt(column-2);
  10788. range = new Range(cursor.row, column-2, cursor.row, column);
  10789. }
  10790. this.session.replace(range, swap);
  10791. };
  10792. this.toLowerCase = function() {
  10793. var originalRange = this.getSelectionRange();
  10794. if (this.selection.isEmpty()) {
  10795. this.selection.selectWord();
  10796. }
  10797. var range = this.getSelectionRange();
  10798. var text = this.session.getTextRange(range);
  10799. this.session.replace(range, text.toLowerCase());
  10800. this.selection.setSelectionRange(originalRange);
  10801. };
  10802. this.toUpperCase = function() {
  10803. var originalRange = this.getSelectionRange();
  10804. if (this.selection.isEmpty()) {
  10805. this.selection.selectWord();
  10806. }
  10807. var range = this.getSelectionRange();
  10808. var text = this.session.getTextRange(range);
  10809. this.session.replace(range, text.toUpperCase());
  10810. this.selection.setSelectionRange(originalRange);
  10811. };
  10812. this.indent = function() {
  10813. var session = this.session;
  10814. var range = this.getSelectionRange();
  10815. if (range.start.row < range.end.row) {
  10816. var rows = this.$getSelectedRows();
  10817. session.indentRows(rows.first, rows.last, "\t");
  10818. return;
  10819. } else if (range.start.column < range.end.column) {
  10820. var text = session.getTextRange(range);
  10821. if (!/^\s+$/.test(text)) {
  10822. var rows = this.$getSelectedRows();
  10823. session.indentRows(rows.first, rows.last, "\t");
  10824. return;
  10825. }
  10826. }
  10827. var line = session.getLine(range.start.row);
  10828. var position = range.start;
  10829. var size = session.getTabSize();
  10830. var column = session.documentToScreenColumn(position.row, position.column);
  10831. if (this.session.getUseSoftTabs()) {
  10832. var count = (size - column % size);
  10833. var indentString = lang.stringRepeat(" ", count);
  10834. } else {
  10835. var count = column % size;
  10836. while (line[range.start.column] == " " && count) {
  10837. range.start.column--;
  10838. count--;
  10839. }
  10840. this.selection.setSelectionRange(range);
  10841. indentString = "\t";
  10842. }
  10843. return this.insert(indentString);
  10844. };
  10845. this.blockIndent = function() {
  10846. var rows = this.$getSelectedRows();
  10847. this.session.indentRows(rows.first, rows.last, "\t");
  10848. };
  10849. this.blockOutdent = function() {
  10850. var selection = this.session.getSelection();
  10851. this.session.outdentRows(selection.getRange());
  10852. };
  10853. this.sortLines = function() {
  10854. var rows = this.$getSelectedRows();
  10855. var session = this.session;
  10856. var lines = [];
  10857. for (i = rows.first; i <= rows.last; i++)
  10858. lines.push(session.getLine(i));
  10859. lines.sort(function(a, b) {
  10860. if (a.toLowerCase() < b.toLowerCase()) return -1;
  10861. if (a.toLowerCase() > b.toLowerCase()) return 1;
  10862. return 0;
  10863. });
  10864. var deleteRange = new Range(0, 0, 0, 0);
  10865. for (var i = rows.first; i <= rows.last; i++) {
  10866. var line = session.getLine(i);
  10867. deleteRange.start.row = i;
  10868. deleteRange.end.row = i;
  10869. deleteRange.end.column = line.length;
  10870. session.replace(deleteRange, lines[i-rows.first]);
  10871. }
  10872. };
  10873. this.toggleCommentLines = function() {
  10874. var state = this.session.getState(this.getCursorPosition().row);
  10875. var rows = this.$getSelectedRows();
  10876. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  10877. };
  10878. this.toggleBlockComment = function() {
  10879. var cursor = this.getCursorPosition();
  10880. var state = this.session.getState(cursor.row);
  10881. var range = this.getSelectionRange();
  10882. this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
  10883. };
  10884. this.getNumberAt = function(row, column) {
  10885. var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
  10886. _numberRx.lastIndex = 0;
  10887. var s = this.session.getLine(row);
  10888. while (_numberRx.lastIndex < column) {
  10889. var m = _numberRx.exec(s);
  10890. if(m.index <= column && m.index+m[0].length >= column){
  10891. var number = {
  10892. value: m[0],
  10893. start: m.index,
  10894. end: m.index+m[0].length
  10895. };
  10896. return number;
  10897. }
  10898. }
  10899. return null;
  10900. };
  10901. this.modifyNumber = function(amount) {
  10902. var row = this.selection.getCursor().row;
  10903. var column = this.selection.getCursor().column;
  10904. var charRange = new Range(row, column-1, row, column);
  10905. var c = this.session.getTextRange(charRange);
  10906. if (!isNaN(parseFloat(c)) && isFinite(c)) {
  10907. var nr = this.getNumberAt(row, column);
  10908. if (nr) {
  10909. var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
  10910. var decimals = nr.start + nr.value.length - fp;
  10911. var t = parseFloat(nr.value);
  10912. t *= Math.pow(10, decimals);
  10913. if(fp !== nr.end && column < fp){
  10914. amount *= Math.pow(10, nr.end - column - 1);
  10915. } else {
  10916. amount *= Math.pow(10, nr.end - column);
  10917. }
  10918. t += amount;
  10919. t /= Math.pow(10, decimals);
  10920. var nnr = t.toFixed(decimals);
  10921. var replaceRange = new Range(row, nr.start, row, nr.end);
  10922. this.session.replace(replaceRange, nnr);
  10923. this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
  10924. }
  10925. }
  10926. };
  10927. this.removeLines = function() {
  10928. var rows = this.$getSelectedRows();
  10929. this.session.removeFullLines(rows.first, rows.last);
  10930. this.clearSelection();
  10931. };
  10932. this.duplicateSelection = function() {
  10933. var sel = this.selection;
  10934. var doc = this.session;
  10935. var range = sel.getRange();
  10936. var reverse = sel.isBackwards();
  10937. if (range.isEmpty()) {
  10938. var row = range.start.row;
  10939. doc.duplicateLines(row, row);
  10940. } else {
  10941. var point = reverse ? range.start : range.end;
  10942. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  10943. range.start = point;
  10944. range.end = endPoint;
  10945. sel.setSelectionRange(range, reverse);
  10946. }
  10947. };
  10948. this.moveLinesDown = function() {
  10949. this.$moveLines(1, false);
  10950. };
  10951. this.moveLinesUp = function() {
  10952. this.$moveLines(-1, false);
  10953. };
  10954. this.moveText = function(range, toPosition, copy) {
  10955. return this.session.moveText(range, toPosition, copy);
  10956. };
  10957. this.copyLinesUp = function() {
  10958. this.$moveLines(-1, true);
  10959. };
  10960. this.copyLinesDown = function() {
  10961. this.$moveLines(1, true);
  10962. };
  10963. this.$moveLines = function(dir, copy) {
  10964. var rows, moved;
  10965. var selection = this.selection;
  10966. if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
  10967. var range = selection.toOrientedRange();
  10968. rows = this.$getSelectedRows(range);
  10969. moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
  10970. if (copy && dir == -1) moved = 0;
  10971. range.moveBy(moved, 0);
  10972. selection.fromOrientedRange(range);
  10973. } else {
  10974. var ranges = selection.rangeList.ranges;
  10975. selection.rangeList.detach(this.session);
  10976. this.inVirtualSelectionMode = true;
  10977. var diff = 0;
  10978. var totalDiff = 0;
  10979. var l = ranges.length;
  10980. for (var i = 0; i < l; i++) {
  10981. var rangeIndex = i;
  10982. ranges[i].moveBy(diff, 0);
  10983. rows = this.$getSelectedRows(ranges[i]);
  10984. var first = rows.first;
  10985. var last = rows.last;
  10986. while (++i < l) {
  10987. if (totalDiff) ranges[i].moveBy(totalDiff, 0);
  10988. var subRows = this.$getSelectedRows(ranges[i]);
  10989. if (copy && subRows.first != last)
  10990. break;
  10991. else if (!copy && subRows.first > last + 1)
  10992. break;
  10993. last = subRows.last;
  10994. }
  10995. i--;
  10996. diff = this.session.$moveLines(first, last, copy ? 0 : dir);
  10997. if (copy && dir == -1) rangeIndex = i + 1;
  10998. while (rangeIndex <= i) {
  10999. ranges[rangeIndex].moveBy(diff, 0);
  11000. rangeIndex++;
  11001. }
  11002. if (!copy) diff = 0;
  11003. totalDiff += diff;
  11004. }
  11005. selection.fromOrientedRange(selection.ranges[0]);
  11006. selection.rangeList.attach(this.session);
  11007. this.inVirtualSelectionMode = false;
  11008. }
  11009. };
  11010. this.$getSelectedRows = function(range) {
  11011. range = (range || this.getSelectionRange()).collapseRows();
  11012. return {
  11013. first: this.session.getRowFoldStart(range.start.row),
  11014. last: this.session.getRowFoldEnd(range.end.row)
  11015. };
  11016. };
  11017. this.onCompositionStart = function(text) {
  11018. this.renderer.showComposition(this.getCursorPosition());
  11019. };
  11020. this.onCompositionUpdate = function(text) {
  11021. this.renderer.setCompositionText(text);
  11022. };
  11023. this.onCompositionEnd = function() {
  11024. this.renderer.hideComposition();
  11025. };
  11026. this.getFirstVisibleRow = function() {
  11027. return this.renderer.getFirstVisibleRow();
  11028. };
  11029. this.getLastVisibleRow = function() {
  11030. return this.renderer.getLastVisibleRow();
  11031. };
  11032. this.isRowVisible = function(row) {
  11033. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  11034. };
  11035. this.isRowFullyVisible = function(row) {
  11036. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  11037. };
  11038. this.$getVisibleRowCount = function() {
  11039. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  11040. };
  11041. this.$moveByPage = function(dir, select) {
  11042. var renderer = this.renderer;
  11043. var config = this.renderer.layerConfig;
  11044. var rows = dir * Math.floor(config.height / config.lineHeight);
  11045. this.$blockScrolling++;
  11046. if (select === true) {
  11047. this.selection.$moveSelection(function(){
  11048. this.moveCursorBy(rows, 0);
  11049. });
  11050. } else if (select === false) {
  11051. this.selection.moveCursorBy(rows, 0);
  11052. this.selection.clearSelection();
  11053. }
  11054. this.$blockScrolling--;
  11055. var scrollTop = renderer.scrollTop;
  11056. renderer.scrollBy(0, rows * config.lineHeight);
  11057. if (select != null)
  11058. renderer.scrollCursorIntoView(null, 0.5);
  11059. renderer.animateScrolling(scrollTop);
  11060. };
  11061. this.selectPageDown = function() {
  11062. this.$moveByPage(1, true);
  11063. };
  11064. this.selectPageUp = function() {
  11065. this.$moveByPage(-1, true);
  11066. };
  11067. this.gotoPageDown = function() {
  11068. this.$moveByPage(1, false);
  11069. };
  11070. this.gotoPageUp = function() {
  11071. this.$moveByPage(-1, false);
  11072. };
  11073. this.scrollPageDown = function() {
  11074. this.$moveByPage(1);
  11075. };
  11076. this.scrollPageUp = function() {
  11077. this.$moveByPage(-1);
  11078. };
  11079. this.scrollToRow = function(row) {
  11080. this.renderer.scrollToRow(row);
  11081. };
  11082. this.scrollToLine = function(line, center, animate, callback) {
  11083. this.renderer.scrollToLine(line, center, animate, callback);
  11084. };
  11085. this.centerSelection = function() {
  11086. var range = this.getSelectionRange();
  11087. var pos = {
  11088. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  11089. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  11090. };
  11091. this.renderer.alignCursor(pos, 0.5);
  11092. };
  11093. this.getCursorPosition = function() {
  11094. return this.selection.getCursor();
  11095. };
  11096. this.getCursorPositionScreen = function() {
  11097. return this.session.documentToScreenPosition(this.getCursorPosition());
  11098. };
  11099. this.getSelectionRange = function() {
  11100. return this.selection.getRange();
  11101. };
  11102. this.selectAll = function() {
  11103. this.$blockScrolling += 1;
  11104. this.selection.selectAll();
  11105. this.$blockScrolling -= 1;
  11106. };
  11107. this.clearSelection = function() {
  11108. this.selection.clearSelection();
  11109. };
  11110. this.moveCursorTo = function(row, column) {
  11111. this.selection.moveCursorTo(row, column);
  11112. };
  11113. this.moveCursorToPosition = function(pos) {
  11114. this.selection.moveCursorToPosition(pos);
  11115. };
  11116. this.jumpToMatching = function(select, expand) {
  11117. var cursor = this.getCursorPosition();
  11118. var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
  11119. var prevToken = iterator.getCurrentToken();
  11120. var token = prevToken || iterator.stepForward();
  11121. if (!token) return;
  11122. var matchType;
  11123. var found = false;
  11124. var depth = {};
  11125. var i = cursor.column - token.start;
  11126. var bracketType;
  11127. var brackets = {
  11128. ")": "(",
  11129. "(": "(",
  11130. "]": "[",
  11131. "[": "[",
  11132. "{": "{",
  11133. "}": "{"
  11134. };
  11135. do {
  11136. if (token.value.match(/[{}()\[\]]/g)) {
  11137. for (; i < token.value.length && !found; i++) {
  11138. if (!brackets[token.value[i]]) {
  11139. continue;
  11140. }
  11141. bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
  11142. if (isNaN(depth[bracketType])) {
  11143. depth[bracketType] = 0;
  11144. }
  11145. switch (token.value[i]) {
  11146. case '(':
  11147. case '[':
  11148. case '{':
  11149. depth[bracketType]++;
  11150. break;
  11151. case ')':
  11152. case ']':
  11153. case '}':
  11154. depth[bracketType]--;
  11155. if (depth[bracketType] === -1) {
  11156. matchType = 'bracket';
  11157. found = true;
  11158. }
  11159. break;
  11160. }
  11161. }
  11162. }
  11163. else if (token && token.type.indexOf('tag-name') !== -1) {
  11164. if (isNaN(depth[token.value])) {
  11165. depth[token.value] = 0;
  11166. }
  11167. if (prevToken.value === '<') {
  11168. depth[token.value]++;
  11169. }
  11170. else if (prevToken.value === '</') {
  11171. depth[token.value]--;
  11172. }
  11173. if (depth[token.value] === -1) {
  11174. matchType = 'tag';
  11175. found = true;
  11176. }
  11177. }
  11178. if (!found) {
  11179. prevToken = token;
  11180. token = iterator.stepForward();
  11181. i = 0;
  11182. }
  11183. } while (token && !found);
  11184. if (!matchType)
  11185. return;
  11186. var range, pos;
  11187. if (matchType === 'bracket') {
  11188. range = this.session.getBracketRange(cursor);
  11189. if (!range) {
  11190. range = new Range(
  11191. iterator.getCurrentTokenRow(),
  11192. iterator.getCurrentTokenColumn() + i - 1,
  11193. iterator.getCurrentTokenRow(),
  11194. iterator.getCurrentTokenColumn() + i - 1
  11195. );
  11196. pos = range.start;
  11197. if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11198. range = this.session.getBracketRange(pos);
  11199. }
  11200. }
  11201. else if (matchType === 'tag') {
  11202. if (token && token.type.indexOf('tag-name') !== -1)
  11203. var tag = token.value;
  11204. else
  11205. return;
  11206. range = new Range(
  11207. iterator.getCurrentTokenRow(),
  11208. iterator.getCurrentTokenColumn() - 2,
  11209. iterator.getCurrentTokenRow(),
  11210. iterator.getCurrentTokenColumn() - 2
  11211. );
  11212. if (range.compare(cursor.row, cursor.column) === 0) {
  11213. found = false;
  11214. do {
  11215. token = prevToken;
  11216. prevToken = iterator.stepBackward();
  11217. if (prevToken) {
  11218. if (prevToken.type.indexOf('tag-close') !== -1) {
  11219. range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
  11220. }
  11221. if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11222. if (prevToken.value === '<') {
  11223. depth[tag]++;
  11224. }
  11225. else if (prevToken.value === '</') {
  11226. depth[tag]--;
  11227. }
  11228. if (depth[tag] === 0)
  11229. found = true;
  11230. }
  11231. }
  11232. } while (prevToken && !found);
  11233. }
  11234. if (token && token.type.indexOf('tag-name')) {
  11235. pos = range.start;
  11236. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11237. pos = range.end;
  11238. }
  11239. }
  11240. pos = range && range.cursor || pos;
  11241. if (pos) {
  11242. if (select) {
  11243. if (range && expand) {
  11244. this.selection.setRange(range);
  11245. } else if (range && range.isEqual(this.getSelectionRange())) {
  11246. this.clearSelection();
  11247. } else {
  11248. this.selection.selectTo(pos.row, pos.column);
  11249. }
  11250. } else {
  11251. this.selection.moveTo(pos.row, pos.column);
  11252. }
  11253. }
  11254. };
  11255. this.gotoLine = function(lineNumber, column, animate) {
  11256. this.selection.clearSelection();
  11257. this.session.unfold({row: lineNumber - 1, column: column || 0});
  11258. this.$blockScrolling += 1;
  11259. this.exitMultiSelectMode && this.exitMultiSelectMode();
  11260. this.moveCursorTo(lineNumber - 1, column || 0);
  11261. this.$blockScrolling -= 1;
  11262. if (!this.isRowFullyVisible(lineNumber - 1))
  11263. this.scrollToLine(lineNumber - 1, true, animate);
  11264. };
  11265. this.navigateTo = function(row, column) {
  11266. this.selection.moveTo(row, column);
  11267. };
  11268. this.navigateUp = function(times) {
  11269. if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
  11270. var selectionStart = this.selection.anchor.getPosition();
  11271. return this.moveCursorToPosition(selectionStart);
  11272. }
  11273. this.selection.clearSelection();
  11274. this.selection.moveCursorBy(-times || -1, 0);
  11275. };
  11276. this.navigateDown = function(times) {
  11277. if (this.selection.isMultiLine() && this.selection.isBackwards()) {
  11278. var selectionEnd = this.selection.anchor.getPosition();
  11279. return this.moveCursorToPosition(selectionEnd);
  11280. }
  11281. this.selection.clearSelection();
  11282. this.selection.moveCursorBy(times || 1, 0);
  11283. };
  11284. this.navigateLeft = function(times) {
  11285. if (!this.selection.isEmpty()) {
  11286. var selectionStart = this.getSelectionRange().start;
  11287. this.moveCursorToPosition(selectionStart);
  11288. }
  11289. else {
  11290. times = times || 1;
  11291. while (times--) {
  11292. this.selection.moveCursorLeft();
  11293. }
  11294. }
  11295. this.clearSelection();
  11296. };
  11297. this.navigateRight = function(times) {
  11298. if (!this.selection.isEmpty()) {
  11299. var selectionEnd = this.getSelectionRange().end;
  11300. this.moveCursorToPosition(selectionEnd);
  11301. }
  11302. else {
  11303. times = times || 1;
  11304. while (times--) {
  11305. this.selection.moveCursorRight();
  11306. }
  11307. }
  11308. this.clearSelection();
  11309. };
  11310. this.navigateLineStart = function() {
  11311. this.selection.moveCursorLineStart();
  11312. this.clearSelection();
  11313. };
  11314. this.navigateLineEnd = function() {
  11315. this.selection.moveCursorLineEnd();
  11316. this.clearSelection();
  11317. };
  11318. this.navigateFileEnd = function() {
  11319. this.selection.moveCursorFileEnd();
  11320. this.clearSelection();
  11321. };
  11322. this.navigateFileStart = function() {
  11323. this.selection.moveCursorFileStart();
  11324. this.clearSelection();
  11325. };
  11326. this.navigateWordRight = function() {
  11327. this.selection.moveCursorWordRight();
  11328. this.clearSelection();
  11329. };
  11330. this.navigateWordLeft = function() {
  11331. this.selection.moveCursorWordLeft();
  11332. this.clearSelection();
  11333. };
  11334. this.replace = function(replacement, options) {
  11335. if (options)
  11336. this.$search.set(options);
  11337. var range = this.$search.find(this.session);
  11338. var replaced = 0;
  11339. if (!range)
  11340. return replaced;
  11341. if (this.$tryReplace(range, replacement)) {
  11342. replaced = 1;
  11343. }
  11344. if (range !== null) {
  11345. this.selection.setSelectionRange(range);
  11346. this.renderer.scrollSelectionIntoView(range.start, range.end);
  11347. }
  11348. return replaced;
  11349. };
  11350. this.replaceAll = function(replacement, options) {
  11351. if (options) {
  11352. this.$search.set(options);
  11353. }
  11354. var ranges = this.$search.findAll(this.session);
  11355. var replaced = 0;
  11356. if (!ranges.length)
  11357. return replaced;
  11358. this.$blockScrolling += 1;
  11359. var selection = this.getSelectionRange();
  11360. this.selection.moveTo(0, 0);
  11361. for (var i = ranges.length - 1; i >= 0; --i) {
  11362. if(this.$tryReplace(ranges[i], replacement)) {
  11363. replaced++;
  11364. }
  11365. }
  11366. this.selection.setSelectionRange(selection);
  11367. this.$blockScrolling -= 1;
  11368. return replaced;
  11369. };
  11370. this.$tryReplace = function(range, replacement) {
  11371. var input = this.session.getTextRange(range);
  11372. replacement = this.$search.replace(input, replacement);
  11373. if (replacement !== null) {
  11374. range.end = this.session.replace(range, replacement);
  11375. return range;
  11376. } else {
  11377. return null;
  11378. }
  11379. };
  11380. this.getLastSearchOptions = function() {
  11381. return this.$search.getOptions();
  11382. };
  11383. this.find = function(needle, options, animate) {
  11384. if (!options)
  11385. options = {};
  11386. if (typeof needle == "string" || needle instanceof RegExp)
  11387. options.needle = needle;
  11388. else if (typeof needle == "object")
  11389. oop.mixin(options, needle);
  11390. var range = this.selection.getRange();
  11391. if (options.needle == null) {
  11392. needle = this.session.getTextRange(range)
  11393. || this.$search.$options.needle;
  11394. if (!needle) {
  11395. range = this.session.getWordRange(range.start.row, range.start.column);
  11396. needle = this.session.getTextRange(range);
  11397. }
  11398. this.$search.set({needle: needle});
  11399. }
  11400. this.$search.set(options);
  11401. if (!options.start)
  11402. this.$search.set({start: range});
  11403. var newRange = this.$search.find(this.session);
  11404. if (options.preventScroll)
  11405. return newRange;
  11406. if (newRange) {
  11407. this.revealRange(newRange, animate);
  11408. return newRange;
  11409. }
  11410. if (options.backwards)
  11411. range.start = range.end;
  11412. else
  11413. range.end = range.start;
  11414. this.selection.setRange(range);
  11415. };
  11416. this.findNext = function(options, animate) {
  11417. this.find({skipCurrent: true, backwards: false}, options, animate);
  11418. };
  11419. this.findPrevious = function(options, animate) {
  11420. this.find(options, {skipCurrent: true, backwards: true}, animate);
  11421. };
  11422. this.revealRange = function(range, animate) {
  11423. this.$blockScrolling += 1;
  11424. this.session.unfold(range);
  11425. this.selection.setSelectionRange(range);
  11426. this.$blockScrolling -= 1;
  11427. var scrollTop = this.renderer.scrollTop;
  11428. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  11429. if (animate !== false)
  11430. this.renderer.animateScrolling(scrollTop);
  11431. };
  11432. this.undo = function() {
  11433. this.$blockScrolling++;
  11434. this.session.getUndoManager().undo();
  11435. this.$blockScrolling--;
  11436. this.renderer.scrollCursorIntoView(null, 0.5);
  11437. };
  11438. this.redo = function() {
  11439. this.$blockScrolling++;
  11440. this.session.getUndoManager().redo();
  11441. this.$blockScrolling--;
  11442. this.renderer.scrollCursorIntoView(null, 0.5);
  11443. };
  11444. this.destroy = function() {
  11445. this.renderer.destroy();
  11446. this._signal("destroy", this);
  11447. if (this.session) {
  11448. this.session.destroy();
  11449. }
  11450. };
  11451. this.setAutoScrollEditorIntoView = function(enable) {
  11452. if (!enable)
  11453. return;
  11454. var rect;
  11455. var self = this;
  11456. var shouldScroll = false;
  11457. if (!this.$scrollAnchor)
  11458. this.$scrollAnchor = document.createElement("div");
  11459. var scrollAnchor = this.$scrollAnchor;
  11460. scrollAnchor.style.cssText = "position:absolute";
  11461. this.container.insertBefore(scrollAnchor, this.container.firstChild);
  11462. var onChangeSelection = this.on("changeSelection", function() {
  11463. shouldScroll = true;
  11464. });
  11465. var onBeforeRender = this.renderer.on("beforeRender", function() {
  11466. if (shouldScroll)
  11467. rect = self.renderer.container.getBoundingClientRect();
  11468. });
  11469. var onAfterRender = this.renderer.on("afterRender", function() {
  11470. if (shouldScroll && rect && (self.isFocused()
  11471. || self.searchBox && self.searchBox.isFocused())
  11472. ) {
  11473. var renderer = self.renderer;
  11474. var pos = renderer.$cursorLayer.$pixelPos;
  11475. var config = renderer.layerConfig;
  11476. var top = pos.top - config.offset;
  11477. if (pos.top >= 0 && top + rect.top < 0) {
  11478. shouldScroll = true;
  11479. } else if (pos.top < config.height &&
  11480. pos.top + rect.top + config.lineHeight > window.innerHeight) {
  11481. shouldScroll = false;
  11482. } else {
  11483. shouldScroll = null;
  11484. }
  11485. if (shouldScroll != null) {
  11486. scrollAnchor.style.top = top + "px";
  11487. scrollAnchor.style.left = pos.left + "px";
  11488. scrollAnchor.style.height = config.lineHeight + "px";
  11489. scrollAnchor.scrollIntoView(shouldScroll);
  11490. }
  11491. shouldScroll = rect = null;
  11492. }
  11493. });
  11494. this.setAutoScrollEditorIntoView = function(enable) {
  11495. if (enable)
  11496. return;
  11497. delete this.setAutoScrollEditorIntoView;
  11498. this.off("changeSelection", onChangeSelection);
  11499. this.renderer.off("afterRender", onAfterRender);
  11500. this.renderer.off("beforeRender", onBeforeRender);
  11501. };
  11502. };
  11503. this.$resetCursorStyle = function() {
  11504. var style = this.$cursorStyle || "ace";
  11505. var cursorLayer = this.renderer.$cursorLayer;
  11506. if (!cursorLayer)
  11507. return;
  11508. cursorLayer.setSmoothBlinking(/smooth/.test(style));
  11509. cursorLayer.isBlinking = !this.$readOnly && style != "wide";
  11510. dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
  11511. };
  11512. }).call(Editor.prototype);
  11513. config.defineOptions(Editor.prototype, "editor", {
  11514. selectionStyle: {
  11515. set: function(style) {
  11516. this.onSelectionChange();
  11517. this._signal("changeSelectionStyle", {data: style});
  11518. },
  11519. initialValue: "line"
  11520. },
  11521. highlightActiveLine: {
  11522. set: function() {this.$updateHighlightActiveLine();},
  11523. initialValue: true
  11524. },
  11525. highlightSelectedWord: {
  11526. set: function(shouldHighlight) {this.$onSelectionChange();},
  11527. initialValue: true
  11528. },
  11529. readOnly: {
  11530. set: function(readOnly) {
  11531. this.$resetCursorStyle();
  11532. },
  11533. initialValue: false
  11534. },
  11535. cursorStyle: {
  11536. set: function(val) { this.$resetCursorStyle(); },
  11537. values: ["ace", "slim", "smooth", "wide"],
  11538. initialValue: "ace"
  11539. },
  11540. mergeUndoDeltas: {
  11541. values: [false, true, "always"],
  11542. initialValue: true
  11543. },
  11544. behavioursEnabled: {initialValue: true},
  11545. wrapBehavioursEnabled: {initialValue: true},
  11546. autoScrollEditorIntoView: {
  11547. set: function(val) {this.setAutoScrollEditorIntoView(val)}
  11548. },
  11549. keyboardHandler: {
  11550. set: function(val) { this.setKeyboardHandler(val); },
  11551. get: function() { return this.keybindingId; },
  11552. handlesSet: true
  11553. },
  11554. hScrollBarAlwaysVisible: "renderer",
  11555. vScrollBarAlwaysVisible: "renderer",
  11556. highlightGutterLine: "renderer",
  11557. animatedScroll: "renderer",
  11558. showInvisibles: "renderer",
  11559. showPrintMargin: "renderer",
  11560. printMarginColumn: "renderer",
  11561. printMargin: "renderer",
  11562. fadeFoldWidgets: "renderer",
  11563. showFoldWidgets: "renderer",
  11564. showLineNumbers: "renderer",
  11565. showGutter: "renderer",
  11566. displayIndentGuides: "renderer",
  11567. fontSize: "renderer",
  11568. fontFamily: "renderer",
  11569. maxLines: "renderer",
  11570. minLines: "renderer",
  11571. scrollPastEnd: "renderer",
  11572. fixedWidthGutter: "renderer",
  11573. theme: "renderer",
  11574. scrollSpeed: "$mouseHandler",
  11575. dragDelay: "$mouseHandler",
  11576. dragEnabled: "$mouseHandler",
  11577. focusTimout: "$mouseHandler",
  11578. tooltipFollowsMouse: "$mouseHandler",
  11579. firstLineNumber: "session",
  11580. overwrite: "session",
  11581. newLineMode: "session",
  11582. useWorker: "session",
  11583. useSoftTabs: "session",
  11584. tabSize: "session",
  11585. wrap: "session",
  11586. indentedSoftWrap: "session",
  11587. foldStyle: "session",
  11588. mode: "session"
  11589. });
  11590. exports.Editor = Editor;
  11591. });
  11592. ace.define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
  11593. "use strict";
  11594. var UndoManager = function() {
  11595. this.reset();
  11596. };
  11597. (function() {
  11598. this.execute = function(options) {
  11599. var deltaSets = options.args[0];
  11600. this.$doc = options.args[1];
  11601. if (options.merge && this.hasUndo()){
  11602. this.dirtyCounter--;
  11603. deltaSets = this.$undoStack.pop().concat(deltaSets);
  11604. }
  11605. this.$undoStack.push(deltaSets);
  11606. this.$redoStack = [];
  11607. if (this.dirtyCounter < 0) {
  11608. this.dirtyCounter = NaN;
  11609. }
  11610. this.dirtyCounter++;
  11611. };
  11612. this.undo = function(dontSelect) {
  11613. var deltaSets = this.$undoStack.pop();
  11614. var undoSelectionRange = null;
  11615. if (deltaSets) {
  11616. undoSelectionRange = this.$doc.undoChanges(deltaSets, dontSelect);
  11617. this.$redoStack.push(deltaSets);
  11618. this.dirtyCounter--;
  11619. }
  11620. return undoSelectionRange;
  11621. };
  11622. this.redo = function(dontSelect) {
  11623. var deltaSets = this.$redoStack.pop();
  11624. var redoSelectionRange = null;
  11625. if (deltaSets) {
  11626. redoSelectionRange =
  11627. this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
  11628. this.$undoStack.push(deltaSets);
  11629. this.dirtyCounter++;
  11630. }
  11631. return redoSelectionRange;
  11632. };
  11633. this.reset = function() {
  11634. this.$undoStack = [];
  11635. this.$redoStack = [];
  11636. this.dirtyCounter = 0;
  11637. };
  11638. this.hasUndo = function() {
  11639. return this.$undoStack.length > 0;
  11640. };
  11641. this.hasRedo = function() {
  11642. return this.$redoStack.length > 0;
  11643. };
  11644. this.markClean = function() {
  11645. this.dirtyCounter = 0;
  11646. };
  11647. this.isClean = function() {
  11648. return this.dirtyCounter === 0;
  11649. };
  11650. this.$serializeDeltas = function(deltaSets) {
  11651. return cloneDeltaSetsObj(deltaSets, $serializeDelta);
  11652. };
  11653. this.$deserializeDeltas = function(deltaSets) {
  11654. return cloneDeltaSetsObj(deltaSets, $deserializeDelta);
  11655. };
  11656. function $serializeDelta(delta){
  11657. return {
  11658. action: delta.action,
  11659. start: delta.start,
  11660. end: delta.end,
  11661. lines: delta.lines.length == 1 ? null : delta.lines,
  11662. text: delta.lines.length == 1 ? delta.lines[0] : null
  11663. };
  11664. }
  11665. function $deserializeDelta(delta) {
  11666. return {
  11667. action: delta.action,
  11668. start: delta.start,
  11669. end: delta.end,
  11670. lines: delta.lines || [delta.text]
  11671. };
  11672. }
  11673. function cloneDeltaSetsObj(deltaSets_old, fnGetModifiedDelta) {
  11674. var deltaSets_new = new Array(deltaSets_old.length);
  11675. for (var i = 0; i < deltaSets_old.length; i++) {
  11676. var deltaSet_old = deltaSets_old[i];
  11677. var deltaSet_new = { group: deltaSet_old.group, deltas: new Array(deltaSet_old.length)};
  11678. for (var j = 0; j < deltaSet_old.deltas.length; j++) {
  11679. var delta_old = deltaSet_old.deltas[j];
  11680. deltaSet_new.deltas[j] = fnGetModifiedDelta(delta_old);
  11681. }
  11682. deltaSets_new[i] = deltaSet_new;
  11683. }
  11684. return deltaSets_new;
  11685. }
  11686. }).call(UndoManager.prototype);
  11687. exports.UndoManager = UndoManager;
  11688. });
  11689. 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) {
  11690. "use strict";
  11691. var dom = require("../lib/dom");
  11692. var oop = require("../lib/oop");
  11693. var lang = require("../lib/lang");
  11694. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  11695. var Gutter = function(parentEl) {
  11696. this.element = dom.createElement("div");
  11697. this.element.className = "ace_layer ace_gutter-layer";
  11698. parentEl.appendChild(this.element);
  11699. this.setShowFoldWidgets(this.$showFoldWidgets);
  11700. this.gutterWidth = 0;
  11701. this.$annotations = [];
  11702. this.$updateAnnotations = this.$updateAnnotations.bind(this);
  11703. this.$cells = [];
  11704. };
  11705. (function() {
  11706. oop.implement(this, EventEmitter);
  11707. this.setSession = function(session) {
  11708. if (this.session)
  11709. this.session.removeEventListener("change", this.$updateAnnotations);
  11710. this.session = session;
  11711. if (session)
  11712. session.on("change", this.$updateAnnotations);
  11713. };
  11714. this.addGutterDecoration = function(row, className){
  11715. if (window.console)
  11716. console.warn && console.warn("deprecated use session.addGutterDecoration");
  11717. this.session.addGutterDecoration(row, className);
  11718. };
  11719. this.removeGutterDecoration = function(row, className){
  11720. if (window.console)
  11721. console.warn && console.warn("deprecated use session.removeGutterDecoration");
  11722. this.session.removeGutterDecoration(row, className);
  11723. };
  11724. this.setAnnotations = function(annotations) {
  11725. this.$annotations = [];
  11726. for (var i = 0; i < annotations.length; i++) {
  11727. var annotation = annotations[i];
  11728. var row = annotation.row;
  11729. var rowInfo = this.$annotations[row];
  11730. if (!rowInfo)
  11731. rowInfo = this.$annotations[row] = {text: []};
  11732. var annoText = annotation.text;
  11733. annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
  11734. if (rowInfo.text.indexOf(annoText) === -1)
  11735. rowInfo.text.push(annoText);
  11736. var type = annotation.type;
  11737. if (type == "error")
  11738. rowInfo.className = " ace_error";
  11739. else if (type == "warning" && rowInfo.className != " ace_error")
  11740. rowInfo.className = " ace_warning";
  11741. else if (type == "info" && (!rowInfo.className))
  11742. rowInfo.className = " ace_info";
  11743. }
  11744. };
  11745. this.$updateAnnotations = function (delta) {
  11746. if (!this.$annotations.length)
  11747. return;
  11748. var firstRow = delta.start.row;
  11749. var len = delta.end.row - firstRow;
  11750. if (len === 0) {
  11751. } else if (delta.action == 'remove') {
  11752. this.$annotations.splice(firstRow, len + 1, null);
  11753. } else {
  11754. var args = new Array(len + 1);
  11755. args.unshift(firstRow, 1);
  11756. this.$annotations.splice.apply(this.$annotations, args);
  11757. }
  11758. };
  11759. this.update = function(config) {
  11760. var session = this.session;
  11761. var firstRow = config.firstRow;
  11762. var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
  11763. session.getLength() - 1);
  11764. var fold = session.getNextFoldLine(firstRow);
  11765. var foldStart = fold ? fold.start.row : Infinity;
  11766. var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
  11767. var breakpoints = session.$breakpoints;
  11768. var decorations = session.$decorations;
  11769. var firstLineNumber = session.$firstLineNumber;
  11770. var lastLineNumber = 0;
  11771. var gutterRenderer = session.gutterRenderer || this.$renderer;
  11772. var cell = null;
  11773. var index = -1;
  11774. var row = firstRow;
  11775. while (true) {
  11776. if (row > foldStart) {
  11777. row = fold.end.row + 1;
  11778. fold = session.getNextFoldLine(row, fold);
  11779. foldStart = fold ? fold.start.row : Infinity;
  11780. }
  11781. if (row > lastRow) {
  11782. while (this.$cells.length > index + 1) {
  11783. cell = this.$cells.pop();
  11784. this.element.removeChild(cell.element);
  11785. }
  11786. break;
  11787. }
  11788. cell = this.$cells[++index];
  11789. if (!cell) {
  11790. cell = {element: null, textNode: null, foldWidget: null};
  11791. cell.element = dom.createElement("div");
  11792. cell.textNode = document.createTextNode('');
  11793. cell.element.appendChild(cell.textNode);
  11794. this.element.appendChild(cell.element);
  11795. this.$cells[index] = cell;
  11796. }
  11797. var className = "ace_gutter-cell ";
  11798. if (breakpoints[row])
  11799. className += breakpoints[row];
  11800. if (decorations[row])
  11801. className += decorations[row];
  11802. if (this.$annotations[row])
  11803. className += this.$annotations[row].className;
  11804. if (cell.element.className != className)
  11805. cell.element.className = className;
  11806. var height = session.getRowLength(row) * config.lineHeight + "px";
  11807. if (height != cell.element.style.height)
  11808. cell.element.style.height = height;
  11809. if (foldWidgets) {
  11810. var c = foldWidgets[row];
  11811. if (c == null)
  11812. c = foldWidgets[row] = session.getFoldWidget(row);
  11813. }
  11814. if (c) {
  11815. if (!cell.foldWidget) {
  11816. cell.foldWidget = dom.createElement("span");
  11817. cell.element.appendChild(cell.foldWidget);
  11818. }
  11819. var className = "ace_fold-widget ace_" + c;
  11820. if (c == "start" && row == foldStart && row < fold.end.row)
  11821. className += " ace_closed";
  11822. else
  11823. className += " ace_open";
  11824. if (cell.foldWidget.className != className)
  11825. cell.foldWidget.className = className;
  11826. var height = config.lineHeight + "px";
  11827. if (cell.foldWidget.style.height != height)
  11828. cell.foldWidget.style.height = height;
  11829. } else {
  11830. if (cell.foldWidget) {
  11831. cell.element.removeChild(cell.foldWidget);
  11832. cell.foldWidget = null;
  11833. }
  11834. }
  11835. var text = lastLineNumber = gutterRenderer
  11836. ? gutterRenderer.getText(session, row)
  11837. : row + firstLineNumber;
  11838. if (text != cell.textNode.data)
  11839. cell.textNode.data = text;
  11840. row++;
  11841. }
  11842. this.element.style.height = config.minHeight + "px";
  11843. if (this.$fixedWidth || session.$useWrapMode)
  11844. lastLineNumber = session.getLength() + firstLineNumber;
  11845. var gutterWidth = gutterRenderer
  11846. ? gutterRenderer.getWidth(session, lastLineNumber, config)
  11847. : lastLineNumber.toString().length * config.characterWidth;
  11848. var padding = this.$padding || this.$computePadding();
  11849. gutterWidth += padding.left + padding.right;
  11850. if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
  11851. this.gutterWidth = gutterWidth;
  11852. this.element.style.width = Math.ceil(this.gutterWidth) + "px";
  11853. this._emit("changeGutterWidth", gutterWidth);
  11854. }
  11855. };
  11856. this.$fixedWidth = false;
  11857. this.$showLineNumbers = true;
  11858. this.$renderer = "";
  11859. this.setShowLineNumbers = function(show) {
  11860. this.$renderer = !show && {
  11861. getWidth: function() {return ""},
  11862. getText: function() {return ""}
  11863. };
  11864. };
  11865. this.getShowLineNumbers = function() {
  11866. return this.$showLineNumbers;
  11867. };
  11868. this.$showFoldWidgets = true;
  11869. this.setShowFoldWidgets = function(show) {
  11870. if (show)
  11871. dom.addCssClass(this.element, "ace_folding-enabled");
  11872. else
  11873. dom.removeCssClass(this.element, "ace_folding-enabled");
  11874. this.$showFoldWidgets = show;
  11875. this.$padding = null;
  11876. };
  11877. this.getShowFoldWidgets = function() {
  11878. return this.$showFoldWidgets;
  11879. };
  11880. this.$computePadding = function() {
  11881. if (!this.element.firstChild)
  11882. return {left: 0, right: 0};
  11883. var style = dom.computedStyle(this.element.firstChild);
  11884. this.$padding = {};
  11885. this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
  11886. this.$padding.right = parseInt(style.paddingRight) || 0;
  11887. return this.$padding;
  11888. };
  11889. this.getRegion = function(point) {
  11890. var padding = this.$padding || this.$computePadding();
  11891. var rect = this.element.getBoundingClientRect();
  11892. if (point.x < padding.left + rect.left)
  11893. return "markers";
  11894. if (this.$showFoldWidgets && point.x > rect.right - padding.right)
  11895. return "foldWidgets";
  11896. };
  11897. }).call(Gutter.prototype);
  11898. exports.Gutter = Gutter;
  11899. });
  11900. ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
  11901. "use strict";
  11902. var Range = require("../range").Range;
  11903. var dom = require("../lib/dom");
  11904. var Marker = function(parentEl) {
  11905. this.element = dom.createElement("div");
  11906. this.element.className = "ace_layer ace_marker-layer";
  11907. parentEl.appendChild(this.element);
  11908. };
  11909. (function() {
  11910. this.$padding = 0;
  11911. this.setPadding = function(padding) {
  11912. this.$padding = padding;
  11913. };
  11914. this.setSession = function(session) {
  11915. this.session = session;
  11916. };
  11917. this.setMarkers = function(markers) {
  11918. this.markers = markers;
  11919. };
  11920. this.update = function(config) {
  11921. var config = config || this.config;
  11922. if (!config)
  11923. return;
  11924. this.config = config;
  11925. var html = [];
  11926. for (var key in this.markers) {
  11927. var marker = this.markers[key];
  11928. if (!marker.range) {
  11929. marker.update(html, this, this.session, config);
  11930. continue;
  11931. }
  11932. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  11933. if (range.isEmpty()) continue;
  11934. range = range.toScreenRange(this.session);
  11935. if (marker.renderer) {
  11936. var top = this.$getTop(range.start.row, config);
  11937. var left = this.$padding + range.start.column * config.characterWidth;
  11938. marker.renderer(html, range, left, top, config);
  11939. } else if (marker.type == "fullLine") {
  11940. this.drawFullLineMarker(html, range, marker.clazz, config);
  11941. } else if (marker.type == "screenLine") {
  11942. this.drawScreenLineMarker(html, range, marker.clazz, config);
  11943. } else if (range.isMultiLine()) {
  11944. if (marker.type == "text")
  11945. this.drawTextMarker(html, range, marker.clazz, config);
  11946. else
  11947. this.drawMultiLineMarker(html, range, marker.clazz, config);
  11948. } else {
  11949. this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
  11950. }
  11951. }
  11952. this.element.innerHTML = html.join("");
  11953. };
  11954. this.$getTop = function(row, layerConfig) {
  11955. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  11956. };
  11957. function getBorderClass(tl, tr, br, bl) {
  11958. return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
  11959. }
  11960. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
  11961. var session = this.session;
  11962. var start = range.start.row;
  11963. var end = range.end.row;
  11964. var row = start;
  11965. var prev = 0;
  11966. var curr = 0;
  11967. var next = session.getScreenLastRowColumn(row);
  11968. var lineRange = new Range(row, range.start.column, row, curr);
  11969. for (; row <= end; row++) {
  11970. lineRange.start.row = lineRange.end.row = row;
  11971. lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
  11972. lineRange.end.column = next;
  11973. prev = curr;
  11974. curr = next;
  11975. next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
  11976. this.drawSingleLineMarker(stringBuilder, lineRange,
  11977. clazz + (row == start ? " ace_start" : "") + " ace_br"
  11978. + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end),
  11979. layerConfig, row == end ? 0 : 1, extraStyle);
  11980. }
  11981. };
  11982. this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  11983. var padding = this.$padding;
  11984. var height = config.lineHeight;
  11985. var top = this.$getTop(range.start.row, config);
  11986. var left = padding + range.start.column * config.characterWidth;
  11987. extraStyle = extraStyle || "";
  11988. stringBuilder.push(
  11989. "<div class='", clazz, " ace_br1 ace_start' style='",
  11990. "height:", height, "px;",
  11991. "right:0;",
  11992. "top:", top, "px;",
  11993. "left:", left, "px;", extraStyle, "'></div>"
  11994. );
  11995. top = this.$getTop(range.end.row, config);
  11996. var width = range.end.column * config.characterWidth;
  11997. stringBuilder.push(
  11998. "<div class='", clazz, " ace_br12' style='",
  11999. "height:", height, "px;",
  12000. "width:", width, "px;",
  12001. "top:", top, "px;",
  12002. "left:", padding, "px;", extraStyle, "'></div>"
  12003. );
  12004. height = (range.end.row - range.start.row - 1) * config.lineHeight;
  12005. if (height <= 0)
  12006. return;
  12007. top = this.$getTop(range.start.row + 1, config);
  12008. var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
  12009. stringBuilder.push(
  12010. "<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
  12011. "height:", height, "px;",
  12012. "right:0;",
  12013. "top:", top, "px;",
  12014. "left:", padding, "px;", extraStyle, "'></div>"
  12015. );
  12016. };
  12017. this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  12018. var height = config.lineHeight;
  12019. var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
  12020. var top = this.$getTop(range.start.row, config);
  12021. var left = this.$padding + range.start.column * config.characterWidth;
  12022. stringBuilder.push(
  12023. "<div class='", clazz, "' style='",
  12024. "height:", height, "px;",
  12025. "width:", width, "px;",
  12026. "top:", top, "px;",
  12027. "left:", left, "px;", extraStyle || "", "'></div>"
  12028. );
  12029. };
  12030. this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  12031. var top = this.$getTop(range.start.row, config);
  12032. var height = config.lineHeight;
  12033. if (range.start.row != range.end.row)
  12034. height += this.$getTop(range.end.row, config) - top;
  12035. stringBuilder.push(
  12036. "<div class='", clazz, "' style='",
  12037. "height:", height, "px;",
  12038. "top:", top, "px;",
  12039. "left:0;right:0;", extraStyle || "", "'></div>"
  12040. );
  12041. };
  12042. this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  12043. var top = this.$getTop(range.start.row, config);
  12044. var height = config.lineHeight;
  12045. stringBuilder.push(
  12046. "<div class='", clazz, "' style='",
  12047. "height:", height, "px;",
  12048. "top:", top, "px;",
  12049. "left:0;right:0;", extraStyle || "", "'></div>"
  12050. );
  12051. };
  12052. }).call(Marker.prototype);
  12053. exports.Marker = Marker;
  12054. });
  12055. 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) {
  12056. "use strict";
  12057. var oop = require("../lib/oop");
  12058. var dom = require("../lib/dom");
  12059. var lang = require("../lib/lang");
  12060. var useragent = require("../lib/useragent");
  12061. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12062. var Text = function(parentEl) {
  12063. this.element = dom.createElement("div");
  12064. this.element.className = "ace_layer ace_text-layer";
  12065. parentEl.appendChild(this.element);
  12066. this.$updateEolChar = this.$updateEolChar.bind(this);
  12067. };
  12068. (function() {
  12069. oop.implement(this, EventEmitter);
  12070. this.EOF_CHAR = "\xB6";
  12071. this.EOL_CHAR_LF = "\xAC";
  12072. this.EOL_CHAR_CRLF = "\xa4";
  12073. this.EOL_CHAR = this.EOL_CHAR_LF;
  12074. this.TAB_CHAR = "\u2014"; //"\u21E5";
  12075. this.SPACE_CHAR = "\xB7";
  12076. this.$padding = 0;
  12077. this.$updateEolChar = function() {
  12078. var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
  12079. ? this.EOL_CHAR_LF
  12080. : this.EOL_CHAR_CRLF;
  12081. if (this.EOL_CHAR != EOL_CHAR) {
  12082. this.EOL_CHAR = EOL_CHAR;
  12083. return true;
  12084. }
  12085. }
  12086. this.setPadding = function(padding) {
  12087. this.$padding = padding;
  12088. this.element.style.padding = "0 " + padding + "px";
  12089. };
  12090. this.getLineHeight = function() {
  12091. return this.$fontMetrics.$characterSize.height || 0;
  12092. };
  12093. this.getCharacterWidth = function() {
  12094. return this.$fontMetrics.$characterSize.width || 0;
  12095. };
  12096. this.$setFontMetrics = function(measure) {
  12097. this.$fontMetrics = measure;
  12098. this.$fontMetrics.on("changeCharacterSize", function(e) {
  12099. this._signal("changeCharacterSize", e);
  12100. }.bind(this));
  12101. this.$pollSizeChanges();
  12102. }
  12103. this.checkForSizeChanges = function() {
  12104. this.$fontMetrics.checkForSizeChanges();
  12105. };
  12106. this.$pollSizeChanges = function() {
  12107. return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
  12108. };
  12109. this.setSession = function(session) {
  12110. this.session = session;
  12111. if (session)
  12112. this.$computeTabString();
  12113. };
  12114. this.showInvisibles = false;
  12115. this.setShowInvisibles = function(showInvisibles) {
  12116. if (this.showInvisibles == showInvisibles)
  12117. return false;
  12118. this.showInvisibles = showInvisibles;
  12119. this.$computeTabString();
  12120. return true;
  12121. };
  12122. this.displayIndentGuides = true;
  12123. this.setDisplayIndentGuides = function(display) {
  12124. if (this.displayIndentGuides == display)
  12125. return false;
  12126. this.displayIndentGuides = display;
  12127. this.$computeTabString();
  12128. return true;
  12129. };
  12130. this.$tabStrings = [];
  12131. this.onChangeTabSize =
  12132. this.$computeTabString = function() {
  12133. var tabSize = this.session.getTabSize();
  12134. this.tabSize = tabSize;
  12135. var tabStr = this.$tabStrings = [0];
  12136. for (var i = 1; i < tabSize + 1; i++) {
  12137. if (this.showInvisibles) {
  12138. tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
  12139. + lang.stringRepeat(this.TAB_CHAR, i)
  12140. + "</span>");
  12141. } else {
  12142. tabStr.push(lang.stringRepeat(" ", i));
  12143. }
  12144. }
  12145. if (this.displayIndentGuides) {
  12146. this.$indentGuideRe = /\s\S| \t|\t |\s$/;
  12147. var className = "ace_indent-guide";
  12148. var spaceClass = "";
  12149. var tabClass = "";
  12150. if (this.showInvisibles) {
  12151. className += " ace_invisible";
  12152. spaceClass = " ace_invisible_space";
  12153. tabClass = " ace_invisible_tab";
  12154. var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
  12155. var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
  12156. } else{
  12157. var spaceContent = lang.stringRepeat(" ", this.tabSize);
  12158. var tabContent = spaceContent;
  12159. }
  12160. this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
  12161. this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
  12162. }
  12163. };
  12164. this.updateLines = function(config, firstRow, lastRow) {
  12165. if (this.config.lastRow != config.lastRow ||
  12166. this.config.firstRow != config.firstRow) {
  12167. this.scrollLines(config);
  12168. }
  12169. this.config = config;
  12170. var first = Math.max(firstRow, config.firstRow);
  12171. var last = Math.min(lastRow, config.lastRow);
  12172. var lineElements = this.element.childNodes;
  12173. var lineElementsIdx = 0;
  12174. for (var row = config.firstRow; row < first; row++) {
  12175. var foldLine = this.session.getFoldLine(row);
  12176. if (foldLine) {
  12177. if (foldLine.containsRow(first)) {
  12178. first = foldLine.start.row;
  12179. break;
  12180. } else {
  12181. row = foldLine.end.row;
  12182. }
  12183. }
  12184. lineElementsIdx ++;
  12185. }
  12186. var row = first;
  12187. var foldLine = this.session.getNextFoldLine(row);
  12188. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12189. while (true) {
  12190. if (row > foldStart) {
  12191. row = foldLine.end.row+1;
  12192. foldLine = this.session.getNextFoldLine(row, foldLine);
  12193. foldStart = foldLine ? foldLine.start.row :Infinity;
  12194. }
  12195. if (row > last)
  12196. break;
  12197. var lineElement = lineElements[lineElementsIdx++];
  12198. if (lineElement) {
  12199. var html = [];
  12200. this.$renderLine(
  12201. html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
  12202. );
  12203. lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12204. lineElement.innerHTML = html.join("");
  12205. }
  12206. row++;
  12207. }
  12208. };
  12209. this.scrollLines = function(config) {
  12210. var oldConfig = this.config;
  12211. this.config = config;
  12212. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  12213. return this.update(config);
  12214. if (config.lastRow < oldConfig.firstRow)
  12215. return this.update(config);
  12216. var el = this.element;
  12217. if (oldConfig.firstRow < config.firstRow)
  12218. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  12219. el.removeChild(el.firstChild);
  12220. if (oldConfig.lastRow > config.lastRow)
  12221. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  12222. el.removeChild(el.lastChild);
  12223. if (config.firstRow < oldConfig.firstRow) {
  12224. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  12225. if (el.firstChild)
  12226. el.insertBefore(fragment, el.firstChild);
  12227. else
  12228. el.appendChild(fragment);
  12229. }
  12230. if (config.lastRow > oldConfig.lastRow) {
  12231. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  12232. el.appendChild(fragment);
  12233. }
  12234. };
  12235. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  12236. var fragment = this.element.ownerDocument.createDocumentFragment();
  12237. var row = firstRow;
  12238. var foldLine = this.session.getNextFoldLine(row);
  12239. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12240. while (true) {
  12241. if (row > foldStart) {
  12242. row = foldLine.end.row+1;
  12243. foldLine = this.session.getNextFoldLine(row, foldLine);
  12244. foldStart = foldLine ? foldLine.start.row : Infinity;
  12245. }
  12246. if (row > lastRow)
  12247. break;
  12248. var container = dom.createElement("div");
  12249. var html = [];
  12250. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12251. container.innerHTML = html.join("");
  12252. if (this.$useLineGroups()) {
  12253. container.className = 'ace_line_group';
  12254. fragment.appendChild(container);
  12255. container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12256. } else {
  12257. while(container.firstChild)
  12258. fragment.appendChild(container.firstChild);
  12259. }
  12260. row++;
  12261. }
  12262. return fragment;
  12263. };
  12264. this.update = function(config) {
  12265. this.config = config;
  12266. var html = [];
  12267. var firstRow = config.firstRow, lastRow = config.lastRow;
  12268. var row = firstRow;
  12269. var foldLine = this.session.getNextFoldLine(row);
  12270. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12271. while (true) {
  12272. if (row > foldStart) {
  12273. row = foldLine.end.row+1;
  12274. foldLine = this.session.getNextFoldLine(row, foldLine);
  12275. foldStart = foldLine ? foldLine.start.row :Infinity;
  12276. }
  12277. if (row > lastRow)
  12278. break;
  12279. if (this.$useLineGroups())
  12280. html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>")
  12281. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12282. if (this.$useLineGroups())
  12283. html.push("</div>"); // end the line group
  12284. row++;
  12285. }
  12286. this.element.innerHTML = html.join("");
  12287. };
  12288. this.$textToken = {
  12289. "text": true,
  12290. "rparen": true,
  12291. "lparen": true
  12292. };
  12293. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  12294. var self = this;
  12295. var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\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;
  12296. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  12297. if (a) {
  12298. return self.showInvisibles
  12299. ? "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>"
  12300. : c;
  12301. } else if (c == "&") {
  12302. return "&#38;";
  12303. } else if (c == "<") {
  12304. return "&#60;";
  12305. } else if (c == ">") {
  12306. return "&#62;";
  12307. } else if (c == "\t") {
  12308. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  12309. screenColumn += tabSize - 1;
  12310. return self.$tabStrings[tabSize];
  12311. } else if (c == "\u3000") {
  12312. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
  12313. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  12314. screenColumn += 1;
  12315. return "<span class='" + classToUse + "' style='width:" +
  12316. (self.config.characterWidth * 2) +
  12317. "px'>" + space + "</span>";
  12318. } else if (b) {
  12319. return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
  12320. } else {
  12321. screenColumn += 1;
  12322. return "<span class='ace_cjk' style='width:" +
  12323. (self.config.characterWidth * 2) +
  12324. "px'>" + c + "</span>";
  12325. }
  12326. };
  12327. var output = value.replace(replaceReg, replaceFunc);
  12328. if (!this.$textToken[token.type]) {
  12329. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  12330. var style = "";
  12331. if (token.type == "fold")
  12332. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  12333. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  12334. }
  12335. else {
  12336. stringBuilder.push(output);
  12337. }
  12338. return screenColumn + value.length;
  12339. };
  12340. this.renderIndentGuide = function(stringBuilder, value, max) {
  12341. var cols = value.search(this.$indentGuideRe);
  12342. if (cols <= 0 || cols >= max)
  12343. return value;
  12344. if (value[0] == " ") {
  12345. cols -= cols % this.tabSize;
  12346. stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
  12347. return value.substr(cols);
  12348. } else if (value[0] == "\t") {
  12349. stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
  12350. return value.substr(cols);
  12351. }
  12352. return value;
  12353. };
  12354. this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
  12355. var chars = 0;
  12356. var split = 0;
  12357. var splitChars = splits[0];
  12358. var screenColumn = 0;
  12359. for (var i = 0; i < tokens.length; i++) {
  12360. var token = tokens[i];
  12361. var value = token.value;
  12362. if (i == 0 && this.displayIndentGuides) {
  12363. chars = value.length;
  12364. value = this.renderIndentGuide(stringBuilder, value, splitChars);
  12365. if (!value)
  12366. continue;
  12367. chars -= value.length;
  12368. }
  12369. if (chars + value.length < splitChars) {
  12370. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12371. chars += value.length;
  12372. } else {
  12373. while (chars + value.length >= splitChars) {
  12374. screenColumn = this.$renderToken(
  12375. stringBuilder, screenColumn,
  12376. token, value.substring(0, splitChars - chars)
  12377. );
  12378. value = value.substring(splitChars - chars);
  12379. chars = splitChars;
  12380. if (!onlyContents) {
  12381. stringBuilder.push("</div>",
  12382. "<div class='ace_line' style='height:",
  12383. this.config.lineHeight, "px'>"
  12384. );
  12385. }
  12386. stringBuilder.push(lang.stringRepeat("\xa0", splits.indent));
  12387. split ++;
  12388. screenColumn = 0;
  12389. splitChars = splits[split] || Number.MAX_VALUE;
  12390. }
  12391. if (value.length != 0) {
  12392. chars += value.length;
  12393. screenColumn = this.$renderToken(
  12394. stringBuilder, screenColumn, token, value
  12395. );
  12396. }
  12397. }
  12398. }
  12399. };
  12400. this.$renderSimpleLine = function(stringBuilder, tokens) {
  12401. var screenColumn = 0;
  12402. var token = tokens[0];
  12403. var value = token.value;
  12404. if (this.displayIndentGuides)
  12405. value = this.renderIndentGuide(stringBuilder, value);
  12406. if (value)
  12407. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12408. for (var i = 1; i < tokens.length; i++) {
  12409. token = tokens[i];
  12410. value = token.value;
  12411. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12412. }
  12413. };
  12414. this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
  12415. if (!foldLine && foldLine != false)
  12416. foldLine = this.session.getFoldLine(row);
  12417. if (foldLine)
  12418. var tokens = this.$getFoldLineTokens(row, foldLine);
  12419. else
  12420. var tokens = this.session.getTokens(row);
  12421. if (!onlyContents) {
  12422. stringBuilder.push(
  12423. "<div class='ace_line' style='height:",
  12424. this.config.lineHeight * (
  12425. this.$useLineGroups() ? 1 :this.session.getRowLength(row)
  12426. ), "px'>"
  12427. );
  12428. }
  12429. if (tokens.length) {
  12430. var splits = this.session.getRowSplitData(row);
  12431. if (splits && splits.length)
  12432. this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
  12433. else
  12434. this.$renderSimpleLine(stringBuilder, tokens);
  12435. }
  12436. if (this.showInvisibles) {
  12437. if (foldLine)
  12438. row = foldLine.end.row
  12439. stringBuilder.push(
  12440. "<span class='ace_invisible ace_invisible_eol'>",
  12441. row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
  12442. "</span>"
  12443. );
  12444. }
  12445. if (!onlyContents)
  12446. stringBuilder.push("</div>");
  12447. };
  12448. this.$getFoldLineTokens = function(row, foldLine) {
  12449. var session = this.session;
  12450. var renderTokens = [];
  12451. function addTokens(tokens, from, to) {
  12452. var idx = 0, col = 0;
  12453. while ((col + tokens[idx].value.length) < from) {
  12454. col += tokens[idx].value.length;
  12455. idx++;
  12456. if (idx == tokens.length)
  12457. return;
  12458. }
  12459. if (col != from) {
  12460. var value = tokens[idx].value.substring(from - col);
  12461. if (value.length > (to - from))
  12462. value = value.substring(0, to - from);
  12463. renderTokens.push({
  12464. type: tokens[idx].type,
  12465. value: value
  12466. });
  12467. col = from + value.length;
  12468. idx += 1;
  12469. }
  12470. while (col < to && idx < tokens.length) {
  12471. var value = tokens[idx].value;
  12472. if (value.length + col > to) {
  12473. renderTokens.push({
  12474. type: tokens[idx].type,
  12475. value: value.substring(0, to - col)
  12476. });
  12477. } else
  12478. renderTokens.push(tokens[idx]);
  12479. col += value.length;
  12480. idx += 1;
  12481. }
  12482. }
  12483. var tokens = session.getTokens(row);
  12484. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  12485. if (placeholder != null) {
  12486. renderTokens.push({
  12487. type: "fold",
  12488. value: placeholder
  12489. });
  12490. } else {
  12491. if (isNewRow)
  12492. tokens = session.getTokens(row);
  12493. if (tokens.length)
  12494. addTokens(tokens, lastColumn, column);
  12495. }
  12496. }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  12497. return renderTokens;
  12498. };
  12499. this.$useLineGroups = function() {
  12500. return this.session.getUseWrapMode();
  12501. };
  12502. this.destroy = function() {
  12503. clearInterval(this.$pollSizeChangesTimer);
  12504. if (this.$measureNode)
  12505. this.$measureNode.parentNode.removeChild(this.$measureNode);
  12506. delete this.$measureNode;
  12507. };
  12508. }).call(Text.prototype);
  12509. exports.Text = Text;
  12510. });
  12511. ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  12512. "use strict";
  12513. var dom = require("../lib/dom");
  12514. var isIE8;
  12515. var Cursor = function(parentEl) {
  12516. this.element = dom.createElement("div");
  12517. this.element.className = "ace_layer ace_cursor-layer";
  12518. parentEl.appendChild(this.element);
  12519. if (isIE8 === undefined)
  12520. isIE8 = !("opacity" in this.element.style);
  12521. this.isVisible = false;
  12522. this.isBlinking = true;
  12523. this.blinkInterval = 1000;
  12524. this.smoothBlinking = false;
  12525. this.cursors = [];
  12526. this.cursor = this.addCursor();
  12527. dom.addCssClass(this.element, "ace_hidden-cursors");
  12528. this.$updateCursors = (isIE8
  12529. ? this.$updateVisibility
  12530. : this.$updateOpacity).bind(this);
  12531. };
  12532. (function() {
  12533. this.$updateVisibility = function(val) {
  12534. var cursors = this.cursors;
  12535. for (var i = cursors.length; i--; )
  12536. cursors[i].style.visibility = val ? "" : "hidden";
  12537. };
  12538. this.$updateOpacity = function(val) {
  12539. var cursors = this.cursors;
  12540. for (var i = cursors.length; i--; )
  12541. cursors[i].style.opacity = val ? "" : "0";
  12542. };
  12543. this.$padding = 0;
  12544. this.setPadding = function(padding) {
  12545. this.$padding = padding;
  12546. };
  12547. this.setSession = function(session) {
  12548. this.session = session;
  12549. };
  12550. this.setBlinking = function(blinking) {
  12551. if (blinking != this.isBlinking){
  12552. this.isBlinking = blinking;
  12553. this.restartTimer();
  12554. }
  12555. };
  12556. this.setBlinkInterval = function(blinkInterval) {
  12557. if (blinkInterval != this.blinkInterval){
  12558. this.blinkInterval = blinkInterval;
  12559. this.restartTimer();
  12560. }
  12561. };
  12562. this.setSmoothBlinking = function(smoothBlinking) {
  12563. if (smoothBlinking != this.smoothBlinking && !isIE8) {
  12564. this.smoothBlinking = smoothBlinking;
  12565. dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
  12566. this.$updateCursors(true);
  12567. this.$updateCursors = (this.$updateOpacity).bind(this);
  12568. this.restartTimer();
  12569. }
  12570. };
  12571. this.addCursor = function() {
  12572. var el = dom.createElement("div");
  12573. el.className = "ace_cursor";
  12574. this.element.appendChild(el);
  12575. this.cursors.push(el);
  12576. return el;
  12577. };
  12578. this.removeCursor = function() {
  12579. if (this.cursors.length > 1) {
  12580. var el = this.cursors.pop();
  12581. el.parentNode.removeChild(el);
  12582. return el;
  12583. }
  12584. };
  12585. this.hideCursor = function() {
  12586. this.isVisible = false;
  12587. dom.addCssClass(this.element, "ace_hidden-cursors");
  12588. this.restartTimer();
  12589. };
  12590. this.showCursor = function() {
  12591. this.isVisible = true;
  12592. dom.removeCssClass(this.element, "ace_hidden-cursors");
  12593. this.restartTimer();
  12594. };
  12595. this.restartTimer = function() {
  12596. var update = this.$updateCursors;
  12597. clearInterval(this.intervalId);
  12598. clearTimeout(this.timeoutId);
  12599. if (this.smoothBlinking) {
  12600. dom.removeCssClass(this.element, "ace_smooth-blinking");
  12601. }
  12602. update(true);
  12603. if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
  12604. return;
  12605. if (this.smoothBlinking) {
  12606. setTimeout(function(){
  12607. dom.addCssClass(this.element, "ace_smooth-blinking");
  12608. }.bind(this));
  12609. }
  12610. var blink = function(){
  12611. this.timeoutId = setTimeout(function() {
  12612. update(false);
  12613. }, 0.6 * this.blinkInterval);
  12614. }.bind(this);
  12615. this.intervalId = setInterval(function() {
  12616. update(true);
  12617. blink();
  12618. }, this.blinkInterval);
  12619. blink();
  12620. };
  12621. this.getPixelPosition = function(position, onScreen) {
  12622. if (!this.config || !this.session)
  12623. return {left : 0, top : 0};
  12624. if (!position)
  12625. position = this.session.selection.getCursor();
  12626. var pos = this.session.documentToScreenPosition(position);
  12627. var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
  12628. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  12629. this.config.lineHeight;
  12630. return {left : cursorLeft, top : cursorTop};
  12631. };
  12632. this.update = function(config) {
  12633. this.config = config;
  12634. var selections = this.session.$selectionMarkers;
  12635. var i = 0, cursorIndex = 0;
  12636. if (selections === undefined || selections.length === 0){
  12637. selections = [{cursor: null}];
  12638. }
  12639. for (var i = 0, n = selections.length; i < n; i++) {
  12640. var pixelPos = this.getPixelPosition(selections[i].cursor, true);
  12641. if ((pixelPos.top > config.height + config.offset ||
  12642. pixelPos.top < 0) && i > 1) {
  12643. continue;
  12644. }
  12645. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  12646. if (!this.drawCursor) {
  12647. style.left = pixelPos.left + "px";
  12648. style.top = pixelPos.top + "px";
  12649. style.width = config.characterWidth + "px";
  12650. style.height = config.lineHeight + "px";
  12651. } else {
  12652. this.drawCursor(style, pixelPos, config, selections[i], this.session);
  12653. }
  12654. }
  12655. while (this.cursors.length > cursorIndex)
  12656. this.removeCursor();
  12657. var overwrite = this.session.getOverwrite();
  12658. this.$setOverwrite(overwrite);
  12659. this.$pixelPos = pixelPos;
  12660. this.restartTimer();
  12661. };
  12662. this.drawCursor = null;
  12663. this.$setOverwrite = function(overwrite) {
  12664. if (overwrite != this.overwrite) {
  12665. this.overwrite = overwrite;
  12666. if (overwrite)
  12667. dom.addCssClass(this.element, "ace_overwrite-cursors");
  12668. else
  12669. dom.removeCssClass(this.element, "ace_overwrite-cursors");
  12670. }
  12671. };
  12672. this.destroy = function() {
  12673. clearInterval(this.intervalId);
  12674. clearTimeout(this.timeoutId);
  12675. };
  12676. }).call(Cursor.prototype);
  12677. exports.Cursor = Cursor;
  12678. });
  12679. ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
  12680. "use strict";
  12681. var oop = require("./lib/oop");
  12682. var dom = require("./lib/dom");
  12683. var event = require("./lib/event");
  12684. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12685. var ScrollBar = function(parent) {
  12686. this.element = dom.createElement("div");
  12687. this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
  12688. this.inner = dom.createElement("div");
  12689. this.inner.className = "ace_scrollbar-inner";
  12690. this.element.appendChild(this.inner);
  12691. parent.appendChild(this.element);
  12692. this.setVisible(false);
  12693. this.skipEvent = false;
  12694. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  12695. event.addListener(this.element, "mousedown", event.preventDefault);
  12696. };
  12697. (function() {
  12698. oop.implement(this, EventEmitter);
  12699. this.setVisible = function(isVisible) {
  12700. this.element.style.display = isVisible ? "" : "none";
  12701. this.isVisible = isVisible;
  12702. };
  12703. }).call(ScrollBar.prototype);
  12704. var VScrollBar = function(parent, renderer) {
  12705. ScrollBar.call(this, parent);
  12706. this.scrollTop = 0;
  12707. renderer.$scrollbarWidth =
  12708. this.width = dom.scrollbarWidth(parent.ownerDocument);
  12709. this.inner.style.width =
  12710. this.element.style.width = (this.width || 15) + 5 + "px";
  12711. };
  12712. oop.inherits(VScrollBar, ScrollBar);
  12713. (function() {
  12714. this.classSuffix = '-v';
  12715. this.onScroll = function() {
  12716. if (!this.skipEvent) {
  12717. this.scrollTop = this.element.scrollTop;
  12718. this._emit("scroll", {data: this.scrollTop});
  12719. }
  12720. this.skipEvent = false;
  12721. };
  12722. this.getWidth = function() {
  12723. return this.isVisible ? this.width : 0;
  12724. };
  12725. this.setHeight = function(height) {
  12726. this.element.style.height = height + "px";
  12727. };
  12728. this.setInnerHeight = function(height) {
  12729. this.inner.style.height = height + "px";
  12730. };
  12731. this.setScrollHeight = function(height) {
  12732. this.inner.style.height = height + "px";
  12733. };
  12734. this.setScrollTop = function(scrollTop) {
  12735. if (this.scrollTop != scrollTop) {
  12736. this.skipEvent = true;
  12737. this.scrollTop = this.element.scrollTop = scrollTop;
  12738. }
  12739. };
  12740. }).call(VScrollBar.prototype);
  12741. var HScrollBar = function(parent, renderer) {
  12742. ScrollBar.call(this, parent);
  12743. this.scrollLeft = 0;
  12744. this.height = renderer.$scrollbarWidth;
  12745. this.inner.style.height =
  12746. this.element.style.height = (this.height || 15) + 5 + "px";
  12747. };
  12748. oop.inherits(HScrollBar, ScrollBar);
  12749. (function() {
  12750. this.classSuffix = '-h';
  12751. this.onScroll = function() {
  12752. if (!this.skipEvent) {
  12753. this.scrollLeft = this.element.scrollLeft;
  12754. this._emit("scroll", {data: this.scrollLeft});
  12755. }
  12756. this.skipEvent = false;
  12757. };
  12758. this.getHeight = function() {
  12759. return this.isVisible ? this.height : 0;
  12760. };
  12761. this.setWidth = function(width) {
  12762. this.element.style.width = width + "px";
  12763. };
  12764. this.setInnerWidth = function(width) {
  12765. this.inner.style.width = width + "px";
  12766. };
  12767. this.setScrollWidth = function(width) {
  12768. this.inner.style.width = width + "px";
  12769. };
  12770. this.setScrollLeft = function(scrollLeft) {
  12771. if (this.scrollLeft != scrollLeft) {
  12772. this.skipEvent = true;
  12773. this.scrollLeft = this.element.scrollLeft = scrollLeft;
  12774. }
  12775. };
  12776. }).call(HScrollBar.prototype);
  12777. exports.ScrollBar = VScrollBar; // backward compatibility
  12778. exports.ScrollBarV = VScrollBar; // backward compatibility
  12779. exports.ScrollBarH = HScrollBar; // backward compatibility
  12780. exports.VScrollBar = VScrollBar;
  12781. exports.HScrollBar = HScrollBar;
  12782. });
  12783. ace.define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
  12784. "use strict";
  12785. var event = require("./lib/event");
  12786. var RenderLoop = function(onRender, win) {
  12787. this.onRender = onRender;
  12788. this.pending = false;
  12789. this.changes = 0;
  12790. this.window = win || window;
  12791. };
  12792. (function() {
  12793. this.schedule = function(change) {
  12794. this.changes = this.changes | change;
  12795. if (!this.pending && this.changes) {
  12796. this.pending = true;
  12797. var _self = this;
  12798. event.nextFrame(function() {
  12799. _self.pending = false;
  12800. var changes;
  12801. while (changes = _self.changes) {
  12802. _self.changes = 0;
  12803. _self.onRender(changes);
  12804. }
  12805. }, this.window);
  12806. }
  12807. };
  12808. }).call(RenderLoop.prototype);
  12809. exports.RenderLoop = RenderLoop;
  12810. });
  12811. 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) {
  12812. var oop = require("../lib/oop");
  12813. var dom = require("../lib/dom");
  12814. var lang = require("../lib/lang");
  12815. var useragent = require("../lib/useragent");
  12816. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12817. var CHAR_COUNT = 0;
  12818. var FontMetrics = exports.FontMetrics = function(parentEl) {
  12819. this.el = dom.createElement("div");
  12820. this.$setMeasureNodeStyles(this.el.style, true);
  12821. this.$main = dom.createElement("div");
  12822. this.$setMeasureNodeStyles(this.$main.style);
  12823. this.$measureNode = dom.createElement("div");
  12824. this.$setMeasureNodeStyles(this.$measureNode.style);
  12825. this.el.appendChild(this.$main);
  12826. this.el.appendChild(this.$measureNode);
  12827. parentEl.appendChild(this.el);
  12828. if (!CHAR_COUNT)
  12829. this.$testFractionalRect();
  12830. this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
  12831. this.$characterSize = {width: 0, height: 0};
  12832. this.checkForSizeChanges();
  12833. };
  12834. (function() {
  12835. oop.implement(this, EventEmitter);
  12836. this.$characterSize = {width: 0, height: 0};
  12837. this.$testFractionalRect = function() {
  12838. var el = dom.createElement("div");
  12839. this.$setMeasureNodeStyles(el.style);
  12840. el.style.width = "0.2px";
  12841. document.documentElement.appendChild(el);
  12842. var w = el.getBoundingClientRect().width;
  12843. if (w > 0 && w < 1)
  12844. CHAR_COUNT = 50;
  12845. else
  12846. CHAR_COUNT = 100;
  12847. el.parentNode.removeChild(el);
  12848. };
  12849. this.$setMeasureNodeStyles = function(style, isRoot) {
  12850. style.width = style.height = "auto";
  12851. style.left = style.top = "0px";
  12852. style.visibility = "hidden";
  12853. style.position = "absolute";
  12854. style.whiteSpace = "pre";
  12855. if (useragent.isIE < 8) {
  12856. style["font-family"] = "inherit";
  12857. } else {
  12858. style.font = "inherit";
  12859. }
  12860. style.overflow = isRoot ? "hidden" : "visible";
  12861. };
  12862. this.checkForSizeChanges = function() {
  12863. var size = this.$measureSizes();
  12864. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  12865. this.$measureNode.style.fontWeight = "bold";
  12866. var boldSize = this.$measureSizes();
  12867. this.$measureNode.style.fontWeight = "";
  12868. this.$characterSize = size;
  12869. this.charSizes = Object.create(null);
  12870. this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
  12871. this._emit("changeCharacterSize", {data: size});
  12872. }
  12873. };
  12874. this.$pollSizeChanges = function() {
  12875. if (this.$pollSizeChangesTimer)
  12876. return this.$pollSizeChangesTimer;
  12877. var self = this;
  12878. return this.$pollSizeChangesTimer = setInterval(function() {
  12879. self.checkForSizeChanges();
  12880. }, 500);
  12881. };
  12882. this.setPolling = function(val) {
  12883. if (val) {
  12884. this.$pollSizeChanges();
  12885. } else if (this.$pollSizeChangesTimer) {
  12886. clearInterval(this.$pollSizeChangesTimer);
  12887. this.$pollSizeChangesTimer = 0;
  12888. }
  12889. };
  12890. this.$measureSizes = function() {
  12891. if (CHAR_COUNT === 50) {
  12892. var rect = null;
  12893. try {
  12894. rect = this.$measureNode.getBoundingClientRect();
  12895. } catch(e) {
  12896. rect = {width: 0, height:0 };
  12897. }
  12898. var size = {
  12899. height: rect.height,
  12900. width: rect.width / CHAR_COUNT
  12901. };
  12902. } else {
  12903. var size = {
  12904. height: this.$measureNode.clientHeight,
  12905. width: this.$measureNode.clientWidth / CHAR_COUNT
  12906. };
  12907. }
  12908. if (size.width === 0 || size.height === 0)
  12909. return null;
  12910. return size;
  12911. };
  12912. this.$measureCharWidth = function(ch) {
  12913. this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
  12914. var rect = this.$main.getBoundingClientRect();
  12915. return rect.width / CHAR_COUNT;
  12916. };
  12917. this.getCharacterWidth = function(ch) {
  12918. var w = this.charSizes[ch];
  12919. if (w === undefined) {
  12920. w = this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
  12921. }
  12922. return w;
  12923. };
  12924. this.destroy = function() {
  12925. clearInterval(this.$pollSizeChangesTimer);
  12926. if (this.el && this.el.parentNode)
  12927. this.el.parentNode.removeChild(this.el);
  12928. };
  12929. }).call(FontMetrics.prototype);
  12930. });
  12931. 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) {
  12932. "use strict";
  12933. var oop = require("./lib/oop");
  12934. var dom = require("./lib/dom");
  12935. var config = require("./config");
  12936. var useragent = require("./lib/useragent");
  12937. var GutterLayer = require("./layer/gutter").Gutter;
  12938. var MarkerLayer = require("./layer/marker").Marker;
  12939. var TextLayer = require("./layer/text").Text;
  12940. var CursorLayer = require("./layer/cursor").Cursor;
  12941. var HScrollBar = require("./scrollbar").HScrollBar;
  12942. var VScrollBar = require("./scrollbar").VScrollBar;
  12943. var RenderLoop = require("./renderloop").RenderLoop;
  12944. var FontMetrics = require("./layer/font_metrics").FontMetrics;
  12945. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  12946. var editorCss = ".ace_editor {\
  12947. position: relative;\
  12948. overflow: hidden;\
  12949. font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
  12950. direction: ltr;\
  12951. }\
  12952. .ace_scroller {\
  12953. position: absolute;\
  12954. overflow: hidden;\
  12955. top: 0;\
  12956. bottom: 0;\
  12957. background-color: inherit;\
  12958. -ms-user-select: none;\
  12959. -moz-user-select: none;\
  12960. -webkit-user-select: none;\
  12961. user-select: none;\
  12962. cursor: text;\
  12963. }\
  12964. .ace_content {\
  12965. position: absolute;\
  12966. -moz-box-sizing: border-box;\
  12967. -webkit-box-sizing: border-box;\
  12968. box-sizing: border-box;\
  12969. min-width: 100%;\
  12970. }\
  12971. .ace_dragging .ace_scroller:before{\
  12972. position: absolute;\
  12973. top: 0;\
  12974. left: 0;\
  12975. right: 0;\
  12976. bottom: 0;\
  12977. content: '';\
  12978. background: rgba(250, 250, 250, 0.01);\
  12979. z-index: 1000;\
  12980. }\
  12981. .ace_dragging.ace_dark .ace_scroller:before{\
  12982. background: rgba(0, 0, 0, 0.01);\
  12983. }\
  12984. .ace_selecting, .ace_selecting * {\
  12985. cursor: text !important;\
  12986. }\
  12987. .ace_gutter {\
  12988. position: absolute;\
  12989. overflow : hidden;\
  12990. width: auto;\
  12991. top: 0;\
  12992. bottom: 0;\
  12993. left: 0;\
  12994. cursor: default;\
  12995. z-index: 4;\
  12996. -ms-user-select: none;\
  12997. -moz-user-select: none;\
  12998. -webkit-user-select: none;\
  12999. user-select: none;\
  13000. }\
  13001. .ace_gutter-active-line {\
  13002. position: absolute;\
  13003. left: 0;\
  13004. right: 0;\
  13005. }\
  13006. .ace_scroller.ace_scroll-left {\
  13007. box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
  13008. }\
  13009. .ace_gutter-cell {\
  13010. padding-left: 19px;\
  13011. padding-right: 6px;\
  13012. background-repeat: no-repeat;\
  13013. }\
  13014. .ace_gutter-cell.ace_error {\
  13015. 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==\");\
  13016. background-repeat: no-repeat;\
  13017. background-position: 2px center;\
  13018. }\
  13019. .ace_gutter-cell.ace_warning {\
  13020. 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==\");\
  13021. background-position: 2px center;\
  13022. }\
  13023. .ace_gutter-cell.ace_info {\
  13024. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
  13025. background-position: 2px center;\
  13026. }\
  13027. .ace_dark .ace_gutter-cell.ace_info {\
  13028. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
  13029. }\
  13030. .ace_scrollbar {\
  13031. position: absolute;\
  13032. right: 0;\
  13033. bottom: 0;\
  13034. z-index: 6;\
  13035. }\
  13036. .ace_scrollbar-inner {\
  13037. position: absolute;\
  13038. cursor: text;\
  13039. left: 0;\
  13040. top: 0;\
  13041. }\
  13042. .ace_scrollbar-v{\
  13043. overflow-x: hidden;\
  13044. overflow-y: scroll;\
  13045. top: 0;\
  13046. }\
  13047. .ace_scrollbar-h {\
  13048. overflow-x: scroll;\
  13049. overflow-y: hidden;\
  13050. left: 0;\
  13051. }\
  13052. .ace_print-margin {\
  13053. position: absolute;\
  13054. height: 100%;\
  13055. }\
  13056. .ace_text-input {\
  13057. position: absolute;\
  13058. z-index: 0;\
  13059. width: 0.5em;\
  13060. height: 1em;\
  13061. opacity: 0;\
  13062. background: transparent;\
  13063. -moz-appearance: none;\
  13064. appearance: none;\
  13065. border: none;\
  13066. resize: none;\
  13067. outline: none;\
  13068. overflow: hidden;\
  13069. font: inherit;\
  13070. padding: 0 1px;\
  13071. margin: 0 -1px;\
  13072. text-indent: -1em;\
  13073. -ms-user-select: text;\
  13074. -moz-user-select: text;\
  13075. -webkit-user-select: text;\
  13076. user-select: text;\
  13077. white-space: pre!important;\
  13078. }\
  13079. .ace_text-input.ace_composition {\
  13080. background: inherit;\
  13081. color: inherit;\
  13082. z-index: 1000;\
  13083. opacity: 1;\
  13084. text-indent: 0;\
  13085. }\
  13086. .ace_layer {\
  13087. z-index: 1;\
  13088. position: absolute;\
  13089. overflow: hidden;\
  13090. word-wrap: normal;\
  13091. white-space: pre;\
  13092. height: 100%;\
  13093. width: 100%;\
  13094. -moz-box-sizing: border-box;\
  13095. -webkit-box-sizing: border-box;\
  13096. box-sizing: border-box;\
  13097. pointer-events: none;\
  13098. }\
  13099. .ace_gutter-layer {\
  13100. position: relative;\
  13101. width: auto;\
  13102. text-align: right;\
  13103. pointer-events: auto;\
  13104. }\
  13105. .ace_text-layer {\
  13106. font: inherit !important;\
  13107. }\
  13108. .ace_cjk {\
  13109. display: inline-block;\
  13110. text-align: center;\
  13111. }\
  13112. .ace_cursor-layer {\
  13113. z-index: 4;\
  13114. }\
  13115. .ace_cursor {\
  13116. z-index: 4;\
  13117. position: absolute;\
  13118. -moz-box-sizing: border-box;\
  13119. -webkit-box-sizing: border-box;\
  13120. box-sizing: border-box;\
  13121. border-left: 2px solid;\
  13122. transform: translatez(0);\
  13123. }\
  13124. .ace_slim-cursors .ace_cursor {\
  13125. border-left-width: 1px;\
  13126. }\
  13127. .ace_overwrite-cursors .ace_cursor {\
  13128. border-left-width: 0;\
  13129. border-bottom: 1px solid;\
  13130. }\
  13131. .ace_hidden-cursors .ace_cursor {\
  13132. opacity: 0.2;\
  13133. }\
  13134. .ace_smooth-blinking .ace_cursor {\
  13135. -webkit-transition: opacity 0.18s;\
  13136. transition: opacity 0.18s;\
  13137. }\
  13138. .ace_editor.ace_multiselect .ace_cursor {\
  13139. border-left-width: 1px;\
  13140. }\
  13141. .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
  13142. position: absolute;\
  13143. z-index: 3;\
  13144. }\
  13145. .ace_marker-layer .ace_selection {\
  13146. position: absolute;\
  13147. z-index: 5;\
  13148. }\
  13149. .ace_marker-layer .ace_bracket {\
  13150. position: absolute;\
  13151. z-index: 6;\
  13152. }\
  13153. .ace_marker-layer .ace_active-line {\
  13154. position: absolute;\
  13155. z-index: 2;\
  13156. }\
  13157. .ace_marker-layer .ace_selected-word {\
  13158. position: absolute;\
  13159. z-index: 4;\
  13160. -moz-box-sizing: border-box;\
  13161. -webkit-box-sizing: border-box;\
  13162. box-sizing: border-box;\
  13163. }\
  13164. .ace_line .ace_fold {\
  13165. -moz-box-sizing: border-box;\
  13166. -webkit-box-sizing: border-box;\
  13167. box-sizing: border-box;\
  13168. display: inline-block;\
  13169. height: 11px;\
  13170. margin-top: -2px;\
  13171. vertical-align: middle;\
  13172. background-image:\
  13173. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13174. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
  13175. background-repeat: no-repeat, repeat-x;\
  13176. background-position: center center, top left;\
  13177. color: transparent;\
  13178. border: 1px solid black;\
  13179. border-radius: 2px;\
  13180. cursor: pointer;\
  13181. pointer-events: auto;\
  13182. }\
  13183. .ace_dark .ace_fold {\
  13184. }\
  13185. .ace_fold:hover{\
  13186. background-image:\
  13187. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13188. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
  13189. }\
  13190. .ace_tooltip {\
  13191. background-color: #FFF;\
  13192. background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
  13193. background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
  13194. border: 1px solid gray;\
  13195. border-radius: 1px;\
  13196. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
  13197. color: black;\
  13198. max-width: 100%;\
  13199. padding: 3px 4px;\
  13200. position: fixed;\
  13201. z-index: 999999;\
  13202. -moz-box-sizing: border-box;\
  13203. -webkit-box-sizing: border-box;\
  13204. box-sizing: border-box;\
  13205. cursor: default;\
  13206. white-space: pre;\
  13207. word-wrap: break-word;\
  13208. line-height: normal;\
  13209. font-style: normal;\
  13210. font-weight: normal;\
  13211. letter-spacing: normal;\
  13212. pointer-events: none;\
  13213. }\
  13214. .ace_folding-enabled > .ace_gutter-cell {\
  13215. padding-right: 13px;\
  13216. }\
  13217. .ace_fold-widget {\
  13218. -moz-box-sizing: border-box;\
  13219. -webkit-box-sizing: border-box;\
  13220. box-sizing: border-box;\
  13221. margin: 0 -12px 0 1px;\
  13222. display: none;\
  13223. width: 11px;\
  13224. vertical-align: top;\
  13225. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
  13226. background-repeat: no-repeat;\
  13227. background-position: center;\
  13228. border-radius: 3px;\
  13229. border: 1px solid transparent;\
  13230. cursor: pointer;\
  13231. }\
  13232. .ace_folding-enabled .ace_fold-widget {\
  13233. display: inline-block; \
  13234. }\
  13235. .ace_fold-widget.ace_end {\
  13236. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
  13237. }\
  13238. .ace_fold-widget.ace_closed {\
  13239. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
  13240. }\
  13241. .ace_fold-widget:hover {\
  13242. border: 1px solid rgba(0, 0, 0, 0.3);\
  13243. background-color: rgba(255, 255, 255, 0.2);\
  13244. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
  13245. }\
  13246. .ace_fold-widget:active {\
  13247. border: 1px solid rgba(0, 0, 0, 0.4);\
  13248. background-color: rgba(0, 0, 0, 0.05);\
  13249. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
  13250. }\
  13251. .ace_dark .ace_fold-widget {\
  13252. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
  13253. }\
  13254. .ace_dark .ace_fold-widget.ace_end {\
  13255. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
  13256. }\
  13257. .ace_dark .ace_fold-widget.ace_closed {\
  13258. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
  13259. }\
  13260. .ace_dark .ace_fold-widget:hover {\
  13261. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13262. background-color: rgba(255, 255, 255, 0.1);\
  13263. }\
  13264. .ace_dark .ace_fold-widget:active {\
  13265. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13266. }\
  13267. .ace_fold-widget.ace_invalid {\
  13268. background-color: #FFB4B4;\
  13269. border-color: #DE5555;\
  13270. }\
  13271. .ace_fade-fold-widgets .ace_fold-widget {\
  13272. -webkit-transition: opacity 0.4s ease 0.05s;\
  13273. transition: opacity 0.4s ease 0.05s;\
  13274. opacity: 0;\
  13275. }\
  13276. .ace_fade-fold-widgets:hover .ace_fold-widget {\
  13277. -webkit-transition: opacity 0.05s ease 0.05s;\
  13278. transition: opacity 0.05s ease 0.05s;\
  13279. opacity:1;\
  13280. }\
  13281. .ace_underline {\
  13282. text-decoration: underline;\
  13283. }\
  13284. .ace_bold {\
  13285. font-weight: bold;\
  13286. }\
  13287. .ace_nobold .ace_bold {\
  13288. font-weight: normal;\
  13289. }\
  13290. .ace_italic {\
  13291. font-style: italic;\
  13292. }\
  13293. .ace_error-marker {\
  13294. background-color: rgba(255, 0, 0,0.2);\
  13295. position: absolute;\
  13296. z-index: 9;\
  13297. }\
  13298. .ace_highlight-marker {\
  13299. background-color: rgba(255, 255, 0,0.2);\
  13300. position: absolute;\
  13301. z-index: 8;\
  13302. }\
  13303. .ace_br1 {border-top-left-radius : 3px;}\
  13304. .ace_br2 {border-top-right-radius : 3px;}\
  13305. .ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\
  13306. .ace_br4 {border-bottom-right-radius: 3px;}\
  13307. .ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\
  13308. .ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\
  13309. .ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\
  13310. .ace_br8 {border-bottom-left-radius : 3px;}\
  13311. .ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\
  13312. .ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\
  13313. .ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13314. .ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13315. .ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13316. .ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13317. .ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13318. ";
  13319. dom.importCssString(editorCss, "ace_editor.css");
  13320. var VirtualRenderer = function(container, theme) {
  13321. var _self = this;
  13322. this.container = container || dom.createElement("div");
  13323. this.$keepTextAreaAtCursor = !useragent.isOldIE;
  13324. dom.addCssClass(this.container, "ace_editor");
  13325. this.setTheme(theme);
  13326. this.$gutter = dom.createElement("div");
  13327. this.$gutter.className = "ace_gutter";
  13328. this.container.appendChild(this.$gutter);
  13329. this.scroller = dom.createElement("div");
  13330. this.scroller.className = "ace_scroller";
  13331. this.container.appendChild(this.scroller);
  13332. this.content = dom.createElement("div");
  13333. this.content.className = "ace_content";
  13334. this.scroller.appendChild(this.content);
  13335. this.$gutterLayer = new GutterLayer(this.$gutter);
  13336. this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
  13337. this.$markerBack = new MarkerLayer(this.content);
  13338. var textLayer = this.$textLayer = new TextLayer(this.content);
  13339. this.canvas = textLayer.element;
  13340. this.$markerFront = new MarkerLayer(this.content);
  13341. this.$cursorLayer = new CursorLayer(this.content);
  13342. this.$horizScroll = false;
  13343. this.$vScroll = false;
  13344. this.scrollBar =
  13345. this.scrollBarV = new VScrollBar(this.container, this);
  13346. this.scrollBarH = new HScrollBar(this.container, this);
  13347. this.scrollBarV.addEventListener("scroll", function(e) {
  13348. if (!_self.$scrollAnimation)
  13349. _self.session.setScrollTop(e.data - _self.scrollMargin.top);
  13350. });
  13351. this.scrollBarH.addEventListener("scroll", function(e) {
  13352. if (!_self.$scrollAnimation)
  13353. _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
  13354. });
  13355. this.scrollTop = 0;
  13356. this.scrollLeft = 0;
  13357. this.cursorPos = {
  13358. row : 0,
  13359. column : 0
  13360. };
  13361. this.$fontMetrics = new FontMetrics(this.container);
  13362. this.$textLayer.$setFontMetrics(this.$fontMetrics);
  13363. this.$textLayer.addEventListener("changeCharacterSize", function(e) {
  13364. _self.updateCharacterSize();
  13365. _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
  13366. _self._signal("changeCharacterSize", e);
  13367. });
  13368. this.$size = {
  13369. width: 0,
  13370. height: 0,
  13371. scrollerHeight: 0,
  13372. scrollerWidth: 0,
  13373. $dirty: true
  13374. };
  13375. this.layerConfig = {
  13376. width : 1,
  13377. padding : 0,
  13378. firstRow : 0,
  13379. firstRowScreen: 0,
  13380. lastRow : 0,
  13381. lineHeight : 0,
  13382. characterWidth : 0,
  13383. minHeight : 1,
  13384. maxHeight : 1,
  13385. offset : 0,
  13386. height : 1,
  13387. gutterOffset: 1
  13388. };
  13389. this.scrollMargin = {
  13390. left: 0,
  13391. right: 0,
  13392. top: 0,
  13393. bottom: 0,
  13394. v: 0,
  13395. h: 0
  13396. };
  13397. this.$loop = new RenderLoop(
  13398. this.$renderChanges.bind(this),
  13399. this.container.ownerDocument.defaultView
  13400. );
  13401. this.$loop.schedule(this.CHANGE_FULL);
  13402. this.updateCharacterSize();
  13403. this.setPadding(4);
  13404. config.resetOptions(this);
  13405. config._emit("renderer", this);
  13406. };
  13407. (function() {
  13408. this.CHANGE_CURSOR = 1;
  13409. this.CHANGE_MARKER = 2;
  13410. this.CHANGE_GUTTER = 4;
  13411. this.CHANGE_SCROLL = 8;
  13412. this.CHANGE_LINES = 16;
  13413. this.CHANGE_TEXT = 32;
  13414. this.CHANGE_SIZE = 64;
  13415. this.CHANGE_MARKER_BACK = 128;
  13416. this.CHANGE_MARKER_FRONT = 256;
  13417. this.CHANGE_FULL = 512;
  13418. this.CHANGE_H_SCROLL = 1024;
  13419. oop.implement(this, EventEmitter);
  13420. this.updateCharacterSize = function() {
  13421. if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
  13422. this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
  13423. this.setStyle("ace_nobold", !this.$allowBoldFonts);
  13424. }
  13425. this.layerConfig.characterWidth =
  13426. this.characterWidth = this.$textLayer.getCharacterWidth();
  13427. this.layerConfig.lineHeight =
  13428. this.lineHeight = this.$textLayer.getLineHeight();
  13429. this.$updatePrintMargin();
  13430. };
  13431. this.setSession = function(session) {
  13432. if (this.session)
  13433. this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
  13434. this.session = session;
  13435. if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
  13436. session.setScrollTop(-this.scrollMargin.top);
  13437. this.$cursorLayer.setSession(session);
  13438. this.$markerBack.setSession(session);
  13439. this.$markerFront.setSession(session);
  13440. this.$gutterLayer.setSession(session);
  13441. this.$textLayer.setSession(session);
  13442. if (!session)
  13443. return;
  13444. this.$loop.schedule(this.CHANGE_FULL);
  13445. this.session.$setFontMetrics(this.$fontMetrics);
  13446. this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
  13447. this.onChangeNewLineMode()
  13448. this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
  13449. };
  13450. this.updateLines = function(firstRow, lastRow, force) {
  13451. if (lastRow === undefined)
  13452. lastRow = Infinity;
  13453. if (!this.$changedLines) {
  13454. this.$changedLines = {
  13455. firstRow: firstRow,
  13456. lastRow: lastRow
  13457. };
  13458. }
  13459. else {
  13460. if (this.$changedLines.firstRow > firstRow)
  13461. this.$changedLines.firstRow = firstRow;
  13462. if (this.$changedLines.lastRow < lastRow)
  13463. this.$changedLines.lastRow = lastRow;
  13464. }
  13465. if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
  13466. if (force)
  13467. this.$changedLines.lastRow = this.layerConfig.lastRow;
  13468. else
  13469. return;
  13470. }
  13471. if (this.$changedLines.firstRow > this.layerConfig.lastRow)
  13472. return;
  13473. this.$loop.schedule(this.CHANGE_LINES);
  13474. };
  13475. this.onChangeNewLineMode = function() {
  13476. this.$loop.schedule(this.CHANGE_TEXT);
  13477. this.$textLayer.$updateEolChar();
  13478. };
  13479. this.onChangeTabSize = function() {
  13480. this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
  13481. this.$textLayer.onChangeTabSize();
  13482. };
  13483. this.updateText = function() {
  13484. this.$loop.schedule(this.CHANGE_TEXT);
  13485. };
  13486. this.updateFull = function(force) {
  13487. if (force)
  13488. this.$renderChanges(this.CHANGE_FULL, true);
  13489. else
  13490. this.$loop.schedule(this.CHANGE_FULL);
  13491. };
  13492. this.updateFontSize = function() {
  13493. this.$textLayer.checkForSizeChanges();
  13494. };
  13495. this.$changes = 0;
  13496. this.$updateSizeAsync = function() {
  13497. if (this.$loop.pending)
  13498. this.$size.$dirty = true;
  13499. else
  13500. this.onResize();
  13501. };
  13502. this.onResize = function(force, gutterWidth, width, height) {
  13503. if (this.resizing > 2)
  13504. return;
  13505. else if (this.resizing > 0)
  13506. this.resizing++;
  13507. else
  13508. this.resizing = force ? 1 : 0;
  13509. var el = this.container;
  13510. if (!height)
  13511. height = el.clientHeight || el.scrollHeight;
  13512. if (!width)
  13513. width = el.clientWidth || el.scrollWidth;
  13514. var changes = this.$updateCachedSize(force, gutterWidth, width, height);
  13515. if (!this.$size.scrollerHeight || (!width && !height))
  13516. return this.resizing = 0;
  13517. if (force)
  13518. this.$gutterLayer.$padding = null;
  13519. if (force)
  13520. this.$renderChanges(changes | this.$changes, true);
  13521. else
  13522. this.$loop.schedule(changes | this.$changes);
  13523. if (this.resizing)
  13524. this.resizing = 0;
  13525. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  13526. };
  13527. this.$updateCachedSize = function(force, gutterWidth, width, height) {
  13528. height -= (this.$extraHeight || 0);
  13529. var changes = 0;
  13530. var size = this.$size;
  13531. var oldSize = {
  13532. width: size.width,
  13533. height: size.height,
  13534. scrollerHeight: size.scrollerHeight,
  13535. scrollerWidth: size.scrollerWidth
  13536. };
  13537. if (height && (force || size.height != height)) {
  13538. size.height = height;
  13539. changes |= this.CHANGE_SIZE;
  13540. size.scrollerHeight = size.height;
  13541. if (this.$horizScroll)
  13542. size.scrollerHeight -= this.scrollBarH.getHeight();
  13543. this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
  13544. changes = changes | this.CHANGE_SCROLL;
  13545. }
  13546. if (width && (force || size.width != width)) {
  13547. changes |= this.CHANGE_SIZE;
  13548. size.width = width;
  13549. if (gutterWidth == null)
  13550. gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13551. this.gutterWidth = gutterWidth;
  13552. this.scrollBarH.element.style.left =
  13553. this.scroller.style.left = gutterWidth + "px";
  13554. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
  13555. this.scrollBarH.element.style.right =
  13556. this.scroller.style.right = this.scrollBarV.getWidth() + "px";
  13557. this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
  13558. if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  13559. changes |= this.CHANGE_FULL;
  13560. }
  13561. size.$dirty = !width || !height;
  13562. if (changes)
  13563. this._signal("resize", oldSize);
  13564. return changes;
  13565. };
  13566. this.onGutterResize = function() {
  13567. var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13568. if (gutterWidth != this.gutterWidth)
  13569. this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
  13570. if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
  13571. this.$loop.schedule(this.CHANGE_FULL);
  13572. } else if (this.$size.$dirty) {
  13573. this.$loop.schedule(this.CHANGE_FULL);
  13574. } else {
  13575. this.$computeLayerConfig();
  13576. this.$loop.schedule(this.CHANGE_MARKER);
  13577. }
  13578. };
  13579. this.adjustWrapLimit = function() {
  13580. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  13581. var limit = Math.floor(availableWidth / this.characterWidth);
  13582. return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
  13583. };
  13584. this.setAnimatedScroll = function(shouldAnimate){
  13585. this.setOption("animatedScroll", shouldAnimate);
  13586. };
  13587. this.getAnimatedScroll = function() {
  13588. return this.$animatedScroll;
  13589. };
  13590. this.setShowInvisibles = function(showInvisibles) {
  13591. this.setOption("showInvisibles", showInvisibles);
  13592. };
  13593. this.getShowInvisibles = function() {
  13594. return this.getOption("showInvisibles");
  13595. };
  13596. this.getDisplayIndentGuides = function() {
  13597. return this.getOption("displayIndentGuides");
  13598. };
  13599. this.setDisplayIndentGuides = function(display) {
  13600. this.setOption("displayIndentGuides", display);
  13601. };
  13602. this.setShowPrintMargin = function(showPrintMargin) {
  13603. this.setOption("showPrintMargin", showPrintMargin);
  13604. };
  13605. this.getShowPrintMargin = function() {
  13606. return this.getOption("showPrintMargin");
  13607. };
  13608. this.setPrintMarginColumn = function(showPrintMargin) {
  13609. this.setOption("printMarginColumn", showPrintMargin);
  13610. };
  13611. this.getPrintMarginColumn = function() {
  13612. return this.getOption("printMarginColumn");
  13613. };
  13614. this.getShowGutter = function(){
  13615. return this.getOption("showGutter");
  13616. };
  13617. this.setShowGutter = function(show){
  13618. return this.setOption("showGutter", show);
  13619. };
  13620. this.getFadeFoldWidgets = function(){
  13621. return this.getOption("fadeFoldWidgets")
  13622. };
  13623. this.setFadeFoldWidgets = function(show) {
  13624. this.setOption("fadeFoldWidgets", show);
  13625. };
  13626. this.setHighlightGutterLine = function(shouldHighlight) {
  13627. this.setOption("highlightGutterLine", shouldHighlight);
  13628. };
  13629. this.getHighlightGutterLine = function() {
  13630. return this.getOption("highlightGutterLine");
  13631. };
  13632. this.$updateGutterLineHighlight = function() {
  13633. var pos = this.$cursorLayer.$pixelPos;
  13634. var height = this.layerConfig.lineHeight;
  13635. if (this.session.getUseWrapMode()) {
  13636. var cursor = this.session.selection.getCursor();
  13637. cursor.column = 0;
  13638. pos = this.$cursorLayer.getPixelPosition(cursor, true);
  13639. height *= this.session.getRowLength(cursor.row);
  13640. }
  13641. this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
  13642. this.$gutterLineHighlight.style.height = height + "px";
  13643. };
  13644. this.$updatePrintMargin = function() {
  13645. if (!this.$showPrintMargin && !this.$printMarginEl)
  13646. return;
  13647. if (!this.$printMarginEl) {
  13648. var containerEl = dom.createElement("div");
  13649. containerEl.className = "ace_layer ace_print-margin-layer";
  13650. this.$printMarginEl = dom.createElement("div");
  13651. this.$printMarginEl.className = "ace_print-margin";
  13652. containerEl.appendChild(this.$printMarginEl);
  13653. this.content.insertBefore(containerEl, this.content.firstChild);
  13654. }
  13655. var style = this.$printMarginEl.style;
  13656. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  13657. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  13658. if (this.session && this.session.$wrap == -1)
  13659. this.adjustWrapLimit();
  13660. };
  13661. this.getContainerElement = function() {
  13662. return this.container;
  13663. };
  13664. this.getMouseEventTarget = function() {
  13665. return this.scroller;
  13666. };
  13667. this.getTextAreaContainer = function() {
  13668. return this.container;
  13669. };
  13670. this.$moveTextAreaToCursor = function() {
  13671. if (!this.$keepTextAreaAtCursor)
  13672. return;
  13673. var config = this.layerConfig;
  13674. var posTop = this.$cursorLayer.$pixelPos.top;
  13675. var posLeft = this.$cursorLayer.$pixelPos.left;
  13676. posTop -= config.offset;
  13677. var style = this.textarea.style;
  13678. var h = this.lineHeight;
  13679. if (posTop < 0 || posTop > config.height - h) {
  13680. style.top = style.left = "0";
  13681. return;
  13682. }
  13683. var w = this.characterWidth;
  13684. if (this.$composition) {
  13685. var val = this.textarea.value.replace(/^\x01+/, "");
  13686. w *= (this.session.$getStringScreenWidth(val)[0]+2);
  13687. h += 2;
  13688. }
  13689. posLeft -= this.scrollLeft;
  13690. if (posLeft > this.$size.scrollerWidth - w)
  13691. posLeft = this.$size.scrollerWidth - w;
  13692. posLeft += this.gutterWidth;
  13693. style.height = h + "px";
  13694. style.width = w + "px";
  13695. style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
  13696. style.top = Math.min(posTop, this.$size.height - h) + "px";
  13697. };
  13698. this.getFirstVisibleRow = function() {
  13699. return this.layerConfig.firstRow;
  13700. };
  13701. this.getFirstFullyVisibleRow = function() {
  13702. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  13703. };
  13704. this.getLastFullyVisibleRow = function() {
  13705. var config = this.layerConfig;
  13706. var lastRow = config.lastRow
  13707. var top = this.session.documentToScreenRow(lastRow, 0) * config.lineHeight;
  13708. if (top - this.session.getScrollTop() > config.height - config.lineHeight)
  13709. return lastRow - 1;
  13710. return lastRow;
  13711. };
  13712. this.getLastVisibleRow = function() {
  13713. return this.layerConfig.lastRow;
  13714. };
  13715. this.$padding = null;
  13716. this.setPadding = function(padding) {
  13717. this.$padding = padding;
  13718. this.$textLayer.setPadding(padding);
  13719. this.$cursorLayer.setPadding(padding);
  13720. this.$markerFront.setPadding(padding);
  13721. this.$markerBack.setPadding(padding);
  13722. this.$loop.schedule(this.CHANGE_FULL);
  13723. this.$updatePrintMargin();
  13724. };
  13725. this.setScrollMargin = function(top, bottom, left, right) {
  13726. var sm = this.scrollMargin;
  13727. sm.top = top|0;
  13728. sm.bottom = bottom|0;
  13729. sm.right = right|0;
  13730. sm.left = left|0;
  13731. sm.v = sm.top + sm.bottom;
  13732. sm.h = sm.left + sm.right;
  13733. if (sm.top && this.scrollTop <= 0 && this.session)
  13734. this.session.setScrollTop(-sm.top);
  13735. this.updateFull();
  13736. };
  13737. this.getHScrollBarAlwaysVisible = function() {
  13738. return this.$hScrollBarAlwaysVisible;
  13739. };
  13740. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  13741. this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
  13742. };
  13743. this.getVScrollBarAlwaysVisible = function() {
  13744. return this.$vScrollBarAlwaysVisible;
  13745. };
  13746. this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
  13747. this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
  13748. };
  13749. this.$updateScrollBarV = function() {
  13750. var scrollHeight = this.layerConfig.maxHeight;
  13751. var scrollerHeight = this.$size.scrollerHeight;
  13752. if (!this.$maxLines && this.$scrollPastEnd) {
  13753. scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
  13754. if (this.scrollTop > scrollHeight - scrollerHeight) {
  13755. scrollHeight = this.scrollTop + scrollerHeight;
  13756. this.scrollBarV.scrollTop = null;
  13757. }
  13758. }
  13759. this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
  13760. this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
  13761. };
  13762. this.$updateScrollBarH = function() {
  13763. this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
  13764. this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
  13765. };
  13766. this.$frozen = false;
  13767. this.freeze = function() {
  13768. this.$frozen = true;
  13769. };
  13770. this.unfreeze = function() {
  13771. this.$frozen = false;
  13772. };
  13773. this.$renderChanges = function(changes, force) {
  13774. if (this.$changes) {
  13775. changes |= this.$changes;
  13776. this.$changes = 0;
  13777. }
  13778. if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
  13779. this.$changes |= changes;
  13780. return;
  13781. }
  13782. if (this.$size.$dirty) {
  13783. this.$changes |= changes;
  13784. return this.onResize(true);
  13785. }
  13786. if (!this.lineHeight) {
  13787. this.$textLayer.checkForSizeChanges();
  13788. }
  13789. this._signal("beforeRender");
  13790. var config = this.layerConfig;
  13791. if (changes & this.CHANGE_FULL ||
  13792. changes & this.CHANGE_SIZE ||
  13793. changes & this.CHANGE_TEXT ||
  13794. changes & this.CHANGE_LINES ||
  13795. changes & this.CHANGE_SCROLL ||
  13796. changes & this.CHANGE_H_SCROLL
  13797. ) {
  13798. changes |= this.$computeLayerConfig();
  13799. if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
  13800. var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
  13801. if (st > 0) {
  13802. this.scrollTop = st;
  13803. changes = changes | this.CHANGE_SCROLL;
  13804. changes |= this.$computeLayerConfig();
  13805. }
  13806. }
  13807. config = this.layerConfig;
  13808. this.$updateScrollBarV();
  13809. if (changes & this.CHANGE_H_SCROLL)
  13810. this.$updateScrollBarH();
  13811. this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
  13812. this.content.style.marginTop = (-config.offset) + "px";
  13813. this.content.style.width = config.width + 2 * this.$padding + "px";
  13814. this.content.style.height = config.minHeight + "px";
  13815. }
  13816. if (changes & this.CHANGE_H_SCROLL) {
  13817. this.content.style.marginLeft = -this.scrollLeft + "px";
  13818. this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
  13819. }
  13820. if (changes & this.CHANGE_FULL) {
  13821. this.$textLayer.update(config);
  13822. if (this.$showGutter)
  13823. this.$gutterLayer.update(config);
  13824. this.$markerBack.update(config);
  13825. this.$markerFront.update(config);
  13826. this.$cursorLayer.update(config);
  13827. this.$moveTextAreaToCursor();
  13828. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13829. this._signal("afterRender");
  13830. return;
  13831. }
  13832. if (changes & this.CHANGE_SCROLL) {
  13833. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  13834. this.$textLayer.update(config);
  13835. else
  13836. this.$textLayer.scrollLines(config);
  13837. if (this.$showGutter)
  13838. this.$gutterLayer.update(config);
  13839. this.$markerBack.update(config);
  13840. this.$markerFront.update(config);
  13841. this.$cursorLayer.update(config);
  13842. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13843. this.$moveTextAreaToCursor();
  13844. this._signal("afterRender");
  13845. return;
  13846. }
  13847. if (changes & this.CHANGE_TEXT) {
  13848. this.$textLayer.update(config);
  13849. if (this.$showGutter)
  13850. this.$gutterLayer.update(config);
  13851. }
  13852. else if (changes & this.CHANGE_LINES) {
  13853. if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
  13854. this.$gutterLayer.update(config);
  13855. }
  13856. else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
  13857. if (this.$showGutter)
  13858. this.$gutterLayer.update(config);
  13859. }
  13860. if (changes & this.CHANGE_CURSOR) {
  13861. this.$cursorLayer.update(config);
  13862. this.$moveTextAreaToCursor();
  13863. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  13864. }
  13865. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  13866. this.$markerFront.update(config);
  13867. }
  13868. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  13869. this.$markerBack.update(config);
  13870. }
  13871. this._signal("afterRender");
  13872. };
  13873. this.$autosize = function() {
  13874. var height = this.session.getScreenLength() * this.lineHeight;
  13875. var maxHeight = this.$maxLines * this.lineHeight;
  13876. var desiredHeight = Math.max(
  13877. (this.$minLines||1) * this.lineHeight,
  13878. Math.min(maxHeight, height)
  13879. ) + this.scrollMargin.v + (this.$extraHeight || 0);
  13880. if (this.$horizScroll)
  13881. desiredHeight += this.scrollBarH.getHeight();
  13882. var vScroll = height > maxHeight;
  13883. if (desiredHeight != this.desiredHeight ||
  13884. this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
  13885. if (vScroll != this.$vScroll) {
  13886. this.$vScroll = vScroll;
  13887. this.scrollBarV.setVisible(vScroll);
  13888. }
  13889. var w = this.container.clientWidth;
  13890. this.container.style.height = desiredHeight + "px";
  13891. this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
  13892. this.desiredHeight = desiredHeight;
  13893. this._signal("autosize");
  13894. }
  13895. };
  13896. this.$computeLayerConfig = function() {
  13897. var session = this.session;
  13898. var size = this.$size;
  13899. var hideScrollbars = size.height <= 2 * this.lineHeight;
  13900. var screenLines = this.session.getScreenLength();
  13901. var maxHeight = screenLines * this.lineHeight;
  13902. var longestLine = this.$getLongestLine();
  13903. var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
  13904. size.scrollerWidth - longestLine - 2 * this.$padding < 0);
  13905. var hScrollChanged = this.$horizScroll !== horizScroll;
  13906. if (hScrollChanged) {
  13907. this.$horizScroll = horizScroll;
  13908. this.scrollBarH.setVisible(horizScroll);
  13909. }
  13910. var vScrollBefore = this.$vScroll; // autosize can change vscroll value in which case we need to update longestLine
  13911. if (this.$maxLines && this.lineHeight > 1)
  13912. this.$autosize();
  13913. var offset = this.scrollTop % this.lineHeight;
  13914. var minHeight = size.scrollerHeight + this.lineHeight;
  13915. var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
  13916. ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
  13917. : 0;
  13918. maxHeight += scrollPastEnd;
  13919. var sm = this.scrollMargin;
  13920. this.session.setScrollTop(Math.max(-sm.top,
  13921. Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
  13922. this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
  13923. longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
  13924. var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
  13925. size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
  13926. var vScrollChanged = vScrollBefore !== vScroll;
  13927. if (vScrollChanged) {
  13928. this.$vScroll = vScroll;
  13929. this.scrollBarV.setVisible(vScroll);
  13930. }
  13931. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  13932. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  13933. var lastRow = firstRow + lineCount;
  13934. var firstRowScreen, firstRowHeight;
  13935. var lineHeight = this.lineHeight;
  13936. firstRow = session.screenToDocumentRow(firstRow, 0);
  13937. var foldLine = session.getFoldLine(firstRow);
  13938. if (foldLine) {
  13939. firstRow = foldLine.start.row;
  13940. }
  13941. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  13942. firstRowHeight = session.getRowLength(firstRow) * lineHeight;
  13943. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  13944. minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
  13945. firstRowHeight;
  13946. offset = this.scrollTop - firstRowScreen * lineHeight;
  13947. var changes = 0;
  13948. if (this.layerConfig.width != longestLine)
  13949. changes = this.CHANGE_H_SCROLL;
  13950. if (hScrollChanged || vScrollChanged) {
  13951. changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
  13952. this._signal("scrollbarVisibilityChanged");
  13953. if (vScrollChanged)
  13954. longestLine = this.$getLongestLine();
  13955. }
  13956. this.layerConfig = {
  13957. width : longestLine,
  13958. padding : this.$padding,
  13959. firstRow : firstRow,
  13960. firstRowScreen: firstRowScreen,
  13961. lastRow : lastRow,
  13962. lineHeight : lineHeight,
  13963. characterWidth : this.characterWidth,
  13964. minHeight : minHeight,
  13965. maxHeight : maxHeight,
  13966. offset : offset,
  13967. gutterOffset : Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)),
  13968. height : this.$size.scrollerHeight
  13969. };
  13970. return changes;
  13971. };
  13972. this.$updateLines = function() {
  13973. var firstRow = this.$changedLines.firstRow;
  13974. var lastRow = this.$changedLines.lastRow;
  13975. this.$changedLines = null;
  13976. var layerConfig = this.layerConfig;
  13977. if (firstRow > layerConfig.lastRow + 1) { return; }
  13978. if (lastRow < layerConfig.firstRow) { return; }
  13979. if (lastRow === Infinity) {
  13980. if (this.$showGutter)
  13981. this.$gutterLayer.update(layerConfig);
  13982. this.$textLayer.update(layerConfig);
  13983. return;
  13984. }
  13985. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  13986. return true;
  13987. };
  13988. this.$getLongestLine = function() {
  13989. var charCount = this.session.getScreenWidth();
  13990. if (this.showInvisibles && !this.session.$useWrapMode)
  13991. charCount += 1;
  13992. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  13993. };
  13994. this.updateFrontMarkers = function() {
  13995. this.$markerFront.setMarkers(this.session.getMarkers(true));
  13996. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  13997. };
  13998. this.updateBackMarkers = function() {
  13999. this.$markerBack.setMarkers(this.session.getMarkers());
  14000. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  14001. };
  14002. this.addGutterDecoration = function(row, className){
  14003. this.$gutterLayer.addGutterDecoration(row, className);
  14004. };
  14005. this.removeGutterDecoration = function(row, className){
  14006. this.$gutterLayer.removeGutterDecoration(row, className);
  14007. };
  14008. this.updateBreakpoints = function(rows) {
  14009. this.$loop.schedule(this.CHANGE_GUTTER);
  14010. };
  14011. this.setAnnotations = function(annotations) {
  14012. this.$gutterLayer.setAnnotations(annotations);
  14013. this.$loop.schedule(this.CHANGE_GUTTER);
  14014. };
  14015. this.updateCursor = function() {
  14016. this.$loop.schedule(this.CHANGE_CURSOR);
  14017. };
  14018. this.hideCursor = function() {
  14019. this.$cursorLayer.hideCursor();
  14020. };
  14021. this.showCursor = function() {
  14022. this.$cursorLayer.showCursor();
  14023. };
  14024. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  14025. this.scrollCursorIntoView(anchor, offset);
  14026. this.scrollCursorIntoView(lead, offset);
  14027. };
  14028. this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
  14029. if (this.$size.scrollerHeight === 0)
  14030. return;
  14031. var pos = this.$cursorLayer.getPixelPosition(cursor);
  14032. var left = pos.left;
  14033. var top = pos.top;
  14034. var topMargin = $viewMargin && $viewMargin.top || 0;
  14035. var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
  14036. var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
  14037. if (scrollTop + topMargin > top) {
  14038. if (offset && scrollTop + topMargin > top + this.lineHeight)
  14039. top -= offset * this.$size.scrollerHeight;
  14040. if (top === 0)
  14041. top = -this.scrollMargin.top;
  14042. this.session.setScrollTop(top);
  14043. } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
  14044. if (offset && scrollTop + this.$size.scrollerHeight - bottomMargin < top - this.lineHeight)
  14045. top += offset * this.$size.scrollerHeight;
  14046. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  14047. }
  14048. var scrollLeft = this.scrollLeft;
  14049. if (scrollLeft > left) {
  14050. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  14051. left = -this.scrollMargin.left;
  14052. this.session.setScrollLeft(left);
  14053. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  14054. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  14055. } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
  14056. this.session.setScrollLeft(0);
  14057. }
  14058. };
  14059. this.getScrollTop = function() {
  14060. return this.session.getScrollTop();
  14061. };
  14062. this.getScrollLeft = function() {
  14063. return this.session.getScrollLeft();
  14064. };
  14065. this.getScrollTopRow = function() {
  14066. return this.scrollTop / this.lineHeight;
  14067. };
  14068. this.getScrollBottomRow = function() {
  14069. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  14070. };
  14071. this.scrollToRow = function(row) {
  14072. this.session.setScrollTop(row * this.lineHeight);
  14073. };
  14074. this.alignCursor = function(cursor, alignment) {
  14075. if (typeof cursor == "number")
  14076. cursor = {row: cursor, column: 0};
  14077. var pos = this.$cursorLayer.getPixelPosition(cursor);
  14078. var h = this.$size.scrollerHeight - this.lineHeight;
  14079. var offset = pos.top - h * (alignment || 0);
  14080. this.session.setScrollTop(offset);
  14081. return offset;
  14082. };
  14083. this.STEPS = 8;
  14084. this.$calcSteps = function(fromValue, toValue){
  14085. var i = 0;
  14086. var l = this.STEPS;
  14087. var steps = [];
  14088. var func = function(t, x_min, dx) {
  14089. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  14090. };
  14091. for (i = 0; i < l; ++i)
  14092. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  14093. return steps;
  14094. };
  14095. this.scrollToLine = function(line, center, animate, callback) {
  14096. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  14097. var offset = pos.top;
  14098. if (center)
  14099. offset -= this.$size.scrollerHeight / 2;
  14100. var initialScroll = this.scrollTop;
  14101. this.session.setScrollTop(offset);
  14102. if (animate !== false)
  14103. this.animateScrolling(initialScroll, callback);
  14104. };
  14105. this.animateScrolling = function(fromValue, callback) {
  14106. var toValue = this.scrollTop;
  14107. if (!this.$animatedScroll)
  14108. return;
  14109. var _self = this;
  14110. if (fromValue == toValue)
  14111. return;
  14112. if (this.$scrollAnimation) {
  14113. var oldSteps = this.$scrollAnimation.steps;
  14114. if (oldSteps.length) {
  14115. fromValue = oldSteps[0];
  14116. if (fromValue == toValue)
  14117. return;
  14118. }
  14119. }
  14120. var steps = _self.$calcSteps(fromValue, toValue);
  14121. this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
  14122. clearInterval(this.$timer);
  14123. _self.session.setScrollTop(steps.shift());
  14124. _self.session.$scrollTop = toValue;
  14125. this.$timer = setInterval(function() {
  14126. if (steps.length) {
  14127. _self.session.setScrollTop(steps.shift());
  14128. _self.session.$scrollTop = toValue;
  14129. } else if (toValue != null) {
  14130. _self.session.$scrollTop = -1;
  14131. _self.session.setScrollTop(toValue);
  14132. toValue = null;
  14133. } else {
  14134. _self.$timer = clearInterval(_self.$timer);
  14135. _self.$scrollAnimation = null;
  14136. callback && callback();
  14137. }
  14138. }, 10);
  14139. };
  14140. this.scrollToY = function(scrollTop) {
  14141. if (this.scrollTop !== scrollTop) {
  14142. this.$loop.schedule(this.CHANGE_SCROLL);
  14143. this.scrollTop = scrollTop;
  14144. }
  14145. };
  14146. this.scrollToX = function(scrollLeft) {
  14147. if (this.scrollLeft !== scrollLeft)
  14148. this.scrollLeft = scrollLeft;
  14149. this.$loop.schedule(this.CHANGE_H_SCROLL);
  14150. };
  14151. this.scrollTo = function(x, y) {
  14152. this.session.setScrollTop(y);
  14153. this.session.setScrollLeft(y);
  14154. };
  14155. this.scrollBy = function(deltaX, deltaY) {
  14156. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  14157. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  14158. };
  14159. this.isScrollableBy = function(deltaX, deltaY) {
  14160. if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
  14161. return true;
  14162. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
  14163. - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
  14164. return true;
  14165. if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
  14166. return true;
  14167. if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
  14168. - this.layerConfig.width < -1 + this.scrollMargin.right)
  14169. return true;
  14170. };
  14171. this.pixelToScreenCoordinates = function(x, y) {
  14172. var canvasPos = this.scroller.getBoundingClientRect();
  14173. var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
  14174. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  14175. var col = Math.round(offset);
  14176. return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
  14177. };
  14178. this.screenToTextCoordinates = function(x, y) {
  14179. var canvasPos = this.scroller.getBoundingClientRect();
  14180. var col = Math.round(
  14181. (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
  14182. );
  14183. var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
  14184. return this.session.screenToDocumentPosition(row, Math.max(col, 0));
  14185. };
  14186. this.textToScreenCoordinates = function(row, column) {
  14187. var canvasPos = this.scroller.getBoundingClientRect();
  14188. var pos = this.session.documentToScreenPosition(row, column);
  14189. var x = this.$padding + Math.round(pos.column * this.characterWidth);
  14190. var y = pos.row * this.lineHeight;
  14191. return {
  14192. pageX: canvasPos.left + x - this.scrollLeft,
  14193. pageY: canvasPos.top + y - this.scrollTop
  14194. };
  14195. };
  14196. this.visualizeFocus = function() {
  14197. dom.addCssClass(this.container, "ace_focus");
  14198. };
  14199. this.visualizeBlur = function() {
  14200. dom.removeCssClass(this.container, "ace_focus");
  14201. };
  14202. this.showComposition = function(position) {
  14203. if (!this.$composition)
  14204. this.$composition = {
  14205. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  14206. cssText: this.textarea.style.cssText
  14207. };
  14208. this.$keepTextAreaAtCursor = true;
  14209. dom.addCssClass(this.textarea, "ace_composition");
  14210. this.textarea.style.cssText = "";
  14211. this.$moveTextAreaToCursor();
  14212. };
  14213. this.setCompositionText = function(text) {
  14214. this.$moveTextAreaToCursor();
  14215. };
  14216. this.hideComposition = function() {
  14217. if (!this.$composition)
  14218. return;
  14219. dom.removeCssClass(this.textarea, "ace_composition");
  14220. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  14221. this.textarea.style.cssText = this.$composition.cssText;
  14222. this.$composition = null;
  14223. };
  14224. this.setTheme = function(theme, cb) {
  14225. var _self = this;
  14226. this.$themeId = theme;
  14227. _self._dispatchEvent('themeChange',{theme:theme});
  14228. if (!theme || typeof theme == "string") {
  14229. var moduleName = theme || this.$options.theme.initialValue;
  14230. config.loadModule(["theme", moduleName], afterLoad);
  14231. } else {
  14232. afterLoad(theme);
  14233. }
  14234. function afterLoad(module) {
  14235. if (_self.$themeId != theme)
  14236. return cb && cb();
  14237. if (!module.cssClass)
  14238. return;
  14239. dom.importCssString(
  14240. module.cssText,
  14241. module.cssClass,
  14242. _self.container.ownerDocument
  14243. );
  14244. if (_self.theme)
  14245. dom.removeCssClass(_self.container, _self.theme.cssClass);
  14246. var padding = "padding" in module ? module.padding
  14247. : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
  14248. if (_self.$padding && padding != _self.$padding)
  14249. _self.setPadding(padding);
  14250. _self.$theme = module.cssClass;
  14251. _self.theme = module;
  14252. dom.addCssClass(_self.container, module.cssClass);
  14253. dom.setCssClass(_self.container, "ace_dark", module.isDark);
  14254. if (_self.$size) {
  14255. _self.$size.width = 0;
  14256. _self.$updateSizeAsync();
  14257. }
  14258. _self._dispatchEvent('themeLoaded', {theme:module});
  14259. cb && cb();
  14260. }
  14261. };
  14262. this.getTheme = function() {
  14263. return this.$themeId;
  14264. };
  14265. this.setStyle = function(style, include) {
  14266. dom.setCssClass(this.container, style, include !== false);
  14267. };
  14268. this.unsetStyle = function(style) {
  14269. dom.removeCssClass(this.container, style);
  14270. };
  14271. this.setCursorStyle = function(style) {
  14272. if (this.scroller.style.cursor != style)
  14273. this.scroller.style.cursor = style;
  14274. };
  14275. this.setMouseCursor = function(cursorStyle) {
  14276. this.scroller.style.cursor = cursorStyle;
  14277. };
  14278. this.destroy = function() {
  14279. this.$textLayer.destroy();
  14280. this.$cursorLayer.destroy();
  14281. };
  14282. }).call(VirtualRenderer.prototype);
  14283. config.defineOptions(VirtualRenderer.prototype, "renderer", {
  14284. animatedScroll: {initialValue: false},
  14285. showInvisibles: {
  14286. set: function(value) {
  14287. if (this.$textLayer.setShowInvisibles(value))
  14288. this.$loop.schedule(this.CHANGE_TEXT);
  14289. },
  14290. initialValue: false
  14291. },
  14292. showPrintMargin: {
  14293. set: function() { this.$updatePrintMargin(); },
  14294. initialValue: true
  14295. },
  14296. printMarginColumn: {
  14297. set: function() { this.$updatePrintMargin(); },
  14298. initialValue: 80
  14299. },
  14300. printMargin: {
  14301. set: function(val) {
  14302. if (typeof val == "number")
  14303. this.$printMarginColumn = val;
  14304. this.$showPrintMargin = !!val;
  14305. this.$updatePrintMargin();
  14306. },
  14307. get: function() {
  14308. return this.$showPrintMargin && this.$printMarginColumn;
  14309. }
  14310. },
  14311. showGutter: {
  14312. set: function(show){
  14313. this.$gutter.style.display = show ? "block" : "none";
  14314. this.$loop.schedule(this.CHANGE_FULL);
  14315. this.onGutterResize();
  14316. },
  14317. initialValue: true
  14318. },
  14319. fadeFoldWidgets: {
  14320. set: function(show) {
  14321. dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
  14322. },
  14323. initialValue: false
  14324. },
  14325. showFoldWidgets: {
  14326. set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
  14327. initialValue: true
  14328. },
  14329. showLineNumbers: {
  14330. set: function(show) {
  14331. this.$gutterLayer.setShowLineNumbers(show);
  14332. this.$loop.schedule(this.CHANGE_GUTTER);
  14333. },
  14334. initialValue: true
  14335. },
  14336. displayIndentGuides: {
  14337. set: function(show) {
  14338. if (this.$textLayer.setDisplayIndentGuides(show))
  14339. this.$loop.schedule(this.CHANGE_TEXT);
  14340. },
  14341. initialValue: true
  14342. },
  14343. highlightGutterLine: {
  14344. set: function(shouldHighlight) {
  14345. if (!this.$gutterLineHighlight) {
  14346. this.$gutterLineHighlight = dom.createElement("div");
  14347. this.$gutterLineHighlight.className = "ace_gutter-active-line";
  14348. this.$gutter.appendChild(this.$gutterLineHighlight);
  14349. return;
  14350. }
  14351. this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
  14352. if (this.$cursorLayer.$pixelPos)
  14353. this.$updateGutterLineHighlight();
  14354. },
  14355. initialValue: false,
  14356. value: true
  14357. },
  14358. hScrollBarAlwaysVisible: {
  14359. set: function(val) {
  14360. if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
  14361. this.$loop.schedule(this.CHANGE_SCROLL);
  14362. },
  14363. initialValue: false
  14364. },
  14365. vScrollBarAlwaysVisible: {
  14366. set: function(val) {
  14367. if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
  14368. this.$loop.schedule(this.CHANGE_SCROLL);
  14369. },
  14370. initialValue: false
  14371. },
  14372. fontSize: {
  14373. set: function(size) {
  14374. if (typeof size == "number")
  14375. size = size + "px";
  14376. this.container.style.fontSize = size;
  14377. this.updateFontSize();
  14378. },
  14379. initialValue: 12
  14380. },
  14381. fontFamily: {
  14382. set: function(name) {
  14383. this.container.style.fontFamily = name;
  14384. this.updateFontSize();
  14385. }
  14386. },
  14387. maxLines: {
  14388. set: function(val) {
  14389. this.updateFull();
  14390. }
  14391. },
  14392. minLines: {
  14393. set: function(val) {
  14394. this.updateFull();
  14395. }
  14396. },
  14397. scrollPastEnd: {
  14398. set: function(val) {
  14399. val = +val || 0;
  14400. if (this.$scrollPastEnd == val)
  14401. return;
  14402. this.$scrollPastEnd = val;
  14403. this.$loop.schedule(this.CHANGE_SCROLL);
  14404. },
  14405. initialValue: 0,
  14406. handlesSet: true
  14407. },
  14408. fixedWidthGutter: {
  14409. set: function(val) {
  14410. this.$gutterLayer.$fixedWidth = !!val;
  14411. this.$loop.schedule(this.CHANGE_GUTTER);
  14412. }
  14413. },
  14414. theme: {
  14415. set: function(val) { this.setTheme(val) },
  14416. get: function() { return this.$themeId || this.theme; },
  14417. initialValue: "./theme/textmate",
  14418. handlesSet: true
  14419. }
  14420. });
  14421. exports.VirtualRenderer = VirtualRenderer;
  14422. });
  14423. 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) {
  14424. "use strict";
  14425. var oop = require("../lib/oop");
  14426. var net = require("../lib/net");
  14427. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  14428. var config = require("../config");
  14429. var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
  14430. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14431. this.changeListener = this.changeListener.bind(this);
  14432. this.onMessage = this.onMessage.bind(this);
  14433. if (require.nameToUrl && !require.toUrl)
  14434. require.toUrl = require.nameToUrl;
  14435. if (config.get("packaged") || !require.toUrl) {
  14436. workerUrl = workerUrl || config.moduleUrl(mod, "worker");
  14437. } else {
  14438. var normalizePath = this.$normalizePath;
  14439. workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
  14440. var tlns = {};
  14441. topLevelNamespaces.forEach(function(ns) {
  14442. tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
  14443. });
  14444. }
  14445. try {
  14446. this.$worker = new Worker(workerUrl);
  14447. } catch(e) {
  14448. if (e instanceof window.DOMException) {
  14449. var blob = this.$workerBlob(workerUrl);
  14450. var URL = window.URL || window.webkitURL;
  14451. var blobURL = URL.createObjectURL(blob);
  14452. this.$worker = new Worker(blobURL);
  14453. URL.revokeObjectURL(blobURL);
  14454. } else {
  14455. throw e;
  14456. }
  14457. }
  14458. this.$worker.postMessage({
  14459. init : true,
  14460. tlns : tlns,
  14461. module : mod,
  14462. classname : classname
  14463. });
  14464. this.callbackId = 1;
  14465. this.callbacks = {};
  14466. this.$worker.onmessage = this.onMessage;
  14467. };
  14468. (function(){
  14469. oop.implement(this, EventEmitter);
  14470. this.onMessage = function(e) {
  14471. var msg = e.data;
  14472. switch(msg.type) {
  14473. case "event":
  14474. this._signal(msg.name, {data: msg.data});
  14475. break;
  14476. case "call":
  14477. var callback = this.callbacks[msg.id];
  14478. if (callback) {
  14479. callback(msg.data);
  14480. delete this.callbacks[msg.id];
  14481. }
  14482. break;
  14483. case "error":
  14484. this.reportError(msg.data);
  14485. break;
  14486. case "log":
  14487. window.console && console.log && console.log.apply(console, msg.data);
  14488. break;
  14489. }
  14490. };
  14491. this.reportError = function(err) {
  14492. window.console && console.error && console.error(err);
  14493. };
  14494. this.$normalizePath = function(path) {
  14495. return net.qualifyURL(path);
  14496. };
  14497. this.terminate = function() {
  14498. this._signal("terminate", {});
  14499. this.deltaQueue = null;
  14500. this.$worker.terminate();
  14501. this.$worker = null;
  14502. if (this.$doc)
  14503. this.$doc.off("change", this.changeListener);
  14504. this.$doc = null;
  14505. };
  14506. this.send = function(cmd, args) {
  14507. this.$worker.postMessage({command: cmd, args: args});
  14508. };
  14509. this.call = function(cmd, args, callback) {
  14510. if (callback) {
  14511. var id = this.callbackId++;
  14512. this.callbacks[id] = callback;
  14513. args.push(id);
  14514. }
  14515. this.send(cmd, args);
  14516. };
  14517. this.emit = function(event, data) {
  14518. try {
  14519. this.$worker.postMessage({event: event, data: {data: data.data}});
  14520. }
  14521. catch(ex) {
  14522. console.error(ex.stack);
  14523. }
  14524. };
  14525. this.attachToDocument = function(doc) {
  14526. if(this.$doc)
  14527. this.terminate();
  14528. this.$doc = doc;
  14529. this.call("setValue", [doc.getValue()]);
  14530. doc.on("change", this.changeListener);
  14531. };
  14532. this.changeListener = function(delta) {
  14533. if (!this.deltaQueue) {
  14534. this.deltaQueue = [];
  14535. setTimeout(this.$sendDeltaQueue, 0);
  14536. }
  14537. if (delta.action == "insert")
  14538. this.deltaQueue.push(delta.start, delta.lines);
  14539. else
  14540. this.deltaQueue.push(delta.start, delta.end);
  14541. };
  14542. this.$sendDeltaQueue = function() {
  14543. var q = this.deltaQueue;
  14544. if (!q) return;
  14545. this.deltaQueue = null;
  14546. if (q.length > 50 && q.length > this.$doc.getLength() >> 1) {
  14547. this.call("setValue", [this.$doc.getValue()]);
  14548. } else
  14549. this.emit("change", {data: q});
  14550. };
  14551. this.$workerBlob = function(workerUrl) {
  14552. var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
  14553. try {
  14554. return new Blob([script], {"type": "application/javascript"});
  14555. } catch (e) { // Backwards-compatibility
  14556. var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
  14557. var blobBuilder = new BlobBuilder();
  14558. blobBuilder.append(script);
  14559. return blobBuilder.getBlob("application/javascript");
  14560. }
  14561. };
  14562. }).call(WorkerClient.prototype);
  14563. var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
  14564. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14565. this.changeListener = this.changeListener.bind(this);
  14566. this.callbackId = 1;
  14567. this.callbacks = {};
  14568. this.messageBuffer = [];
  14569. var main = null;
  14570. var emitSync = false;
  14571. var sender = Object.create(EventEmitter);
  14572. var _self = this;
  14573. this.$worker = {};
  14574. this.$worker.terminate = function() {};
  14575. this.$worker.postMessage = function(e) {
  14576. _self.messageBuffer.push(e);
  14577. if (main) {
  14578. if (emitSync)
  14579. setTimeout(processNext);
  14580. else
  14581. processNext();
  14582. }
  14583. };
  14584. this.setEmitSync = function(val) { emitSync = val };
  14585. var processNext = function() {
  14586. var msg = _self.messageBuffer.shift();
  14587. if (msg.command)
  14588. main[msg.command].apply(main, msg.args);
  14589. else if (msg.event)
  14590. sender._signal(msg.event, msg.data);
  14591. };
  14592. sender.postMessage = function(msg) {
  14593. _self.onMessage({data: msg});
  14594. };
  14595. sender.callback = function(data, callbackId) {
  14596. this.postMessage({type: "call", id: callbackId, data: data});
  14597. };
  14598. sender.emit = function(name, data) {
  14599. this.postMessage({type: "event", name: name, data: data});
  14600. };
  14601. config.loadModule(["worker", mod], function(Main) {
  14602. main = new Main[classname](sender);
  14603. while (_self.messageBuffer.length)
  14604. processNext();
  14605. });
  14606. };
  14607. UIWorkerClient.prototype = WorkerClient.prototype;
  14608. exports.UIWorkerClient = UIWorkerClient;
  14609. exports.WorkerClient = WorkerClient;
  14610. });
  14611. ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
  14612. "use strict";
  14613. var Range = require("./range").Range;
  14614. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14615. var oop = require("./lib/oop");
  14616. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  14617. var _self = this;
  14618. this.length = length;
  14619. this.session = session;
  14620. this.doc = session.getDocument();
  14621. this.mainClass = mainClass;
  14622. this.othersClass = othersClass;
  14623. this.$onUpdate = this.onUpdate.bind(this);
  14624. this.doc.on("change", this.$onUpdate);
  14625. this.$others = others;
  14626. this.$onCursorChange = function() {
  14627. setTimeout(function() {
  14628. _self.onCursorChange();
  14629. });
  14630. };
  14631. this.$pos = pos;
  14632. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  14633. this.$undoStackDepth = undoStack.length;
  14634. this.setup();
  14635. session.selection.on("changeCursor", this.$onCursorChange);
  14636. };
  14637. (function() {
  14638. oop.implement(this, EventEmitter);
  14639. this.setup = function() {
  14640. var _self = this;
  14641. var doc = this.doc;
  14642. var session = this.session;
  14643. this.selectionBefore = session.selection.toJSON();
  14644. if (session.selection.inMultiSelectMode)
  14645. session.selection.toSingleRange();
  14646. this.pos = doc.createAnchor(this.$pos.row, this.$pos.column);
  14647. var pos = this.pos;
  14648. pos.$insertRight = true;
  14649. pos.detach();
  14650. pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  14651. this.others = [];
  14652. this.$others.forEach(function(other) {
  14653. var anchor = doc.createAnchor(other.row, other.column);
  14654. anchor.$insertRight = true;
  14655. anchor.detach();
  14656. _self.others.push(anchor);
  14657. });
  14658. session.setUndoSelect(false);
  14659. };
  14660. this.showOtherMarkers = function() {
  14661. if (this.othersActive) return;
  14662. var session = this.session;
  14663. var _self = this;
  14664. this.othersActive = true;
  14665. this.others.forEach(function(anchor) {
  14666. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  14667. });
  14668. };
  14669. this.hideOtherMarkers = function() {
  14670. if (!this.othersActive) return;
  14671. this.othersActive = false;
  14672. for (var i = 0; i < this.others.length; i++) {
  14673. this.session.removeMarker(this.others[i].markerId);
  14674. }
  14675. };
  14676. this.onUpdate = function(delta) {
  14677. if (this.$updating)
  14678. return this.updateAnchors(delta);
  14679. var range = delta;
  14680. if (range.start.row !== range.end.row) return;
  14681. if (range.start.row !== this.pos.row) return;
  14682. this.$updating = true;
  14683. var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
  14684. var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1;
  14685. var distanceFromStart = range.start.column - this.pos.column;
  14686. this.updateAnchors(delta);
  14687. if (inMainRange)
  14688. this.length += lengthDiff;
  14689. if (inMainRange && !this.session.$fromUndo) {
  14690. if (delta.action === 'insert') {
  14691. for (var i = this.others.length - 1; i >= 0; i--) {
  14692. var otherPos = this.others[i];
  14693. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14694. this.doc.insertMergedLines(newPos, delta.lines);
  14695. }
  14696. } else if (delta.action === 'remove') {
  14697. for (var i = this.others.length - 1; i >= 0; i--) {
  14698. var otherPos = this.others[i];
  14699. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  14700. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  14701. }
  14702. }
  14703. }
  14704. this.$updating = false;
  14705. this.updateMarkers();
  14706. };
  14707. this.updateAnchors = function(delta) {
  14708. this.pos.onChange(delta);
  14709. for (var i = this.others.length; i--;)
  14710. this.others[i].onChange(delta);
  14711. this.updateMarkers();
  14712. };
  14713. this.updateMarkers = function() {
  14714. if (this.$updating)
  14715. return;
  14716. var _self = this;
  14717. var session = this.session;
  14718. var updateMarker = function(pos, className) {
  14719. session.removeMarker(pos.markerId);
  14720. pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column+_self.length), className, null, false);
  14721. };
  14722. updateMarker(this.pos, this.mainClass);
  14723. for (var i = this.others.length; i--;)
  14724. updateMarker(this.others[i], this.othersClass);
  14725. };
  14726. this.onCursorChange = function(event) {
  14727. if (this.$updating || !this.session) return;
  14728. var pos = this.session.selection.getCursor();
  14729. if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  14730. this.showOtherMarkers();
  14731. this._emit("cursorEnter", event);
  14732. } else {
  14733. this.hideOtherMarkers();
  14734. this._emit("cursorLeave", event);
  14735. }
  14736. };
  14737. this.detach = function() {
  14738. this.session.removeMarker(this.pos && this.pos.markerId);
  14739. this.hideOtherMarkers();
  14740. this.doc.removeEventListener("change", this.$onUpdate);
  14741. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  14742. this.session.setUndoSelect(true);
  14743. this.session = null;
  14744. };
  14745. this.cancel = function() {
  14746. if (this.$undoStackDepth === -1)
  14747. return;
  14748. var undoManager = this.session.getUndoManager();
  14749. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  14750. for (var i = 0; i < undosRequired; i++) {
  14751. undoManager.undo(true);
  14752. }
  14753. if (this.selectionBefore)
  14754. this.session.selection.fromJSON(this.selectionBefore);
  14755. };
  14756. }).call(PlaceHolder.prototype);
  14757. exports.PlaceHolder = PlaceHolder;
  14758. });
  14759. ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  14760. var event = require("../lib/event");
  14761. var useragent = require("../lib/useragent");
  14762. function isSamePoint(p1, p2) {
  14763. return p1.row == p2.row && p1.column == p2.column;
  14764. }
  14765. function onMouseDown(e) {
  14766. var ev = e.domEvent;
  14767. var alt = ev.altKey;
  14768. var shift = ev.shiftKey;
  14769. var ctrl = ev.ctrlKey;
  14770. var accel = e.getAccelKey();
  14771. var button = e.getButton();
  14772. if (ctrl && useragent.isMac)
  14773. button = ev.button;
  14774. if (e.editor.inMultiSelectMode && button == 2) {
  14775. e.editor.textInput.onContextMenu(e.domEvent);
  14776. return;
  14777. }
  14778. if (!ctrl && !alt && !accel) {
  14779. if (button === 0 && e.editor.inMultiSelectMode)
  14780. e.editor.exitMultiSelectMode();
  14781. return;
  14782. }
  14783. if (button !== 0)
  14784. return;
  14785. var editor = e.editor;
  14786. var selection = editor.selection;
  14787. var isMultiSelect = editor.inMultiSelectMode;
  14788. var pos = e.getDocumentPosition();
  14789. var cursor = selection.getCursor();
  14790. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  14791. var mouseX = e.x, mouseY = e.y;
  14792. var onMouseSelection = function(e) {
  14793. mouseX = e.clientX;
  14794. mouseY = e.clientY;
  14795. };
  14796. var session = editor.session;
  14797. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14798. var screenCursor = screenAnchor;
  14799. var selectionMode;
  14800. if (editor.$mouseHandler.$enableJumpToDef) {
  14801. if (ctrl && alt || accel && alt)
  14802. selectionMode = shift ? "block" : "add";
  14803. else if (alt && editor.$blockSelectEnabled)
  14804. selectionMode = "block";
  14805. } else {
  14806. if (accel && !alt) {
  14807. selectionMode = "add";
  14808. if (!isMultiSelect && shift)
  14809. return;
  14810. } else if (alt && editor.$blockSelectEnabled) {
  14811. selectionMode = "block";
  14812. }
  14813. }
  14814. if (selectionMode && useragent.isMac && ev.ctrlKey) {
  14815. editor.$mouseHandler.cancelContextMenu();
  14816. }
  14817. if (selectionMode == "add") {
  14818. if (!isMultiSelect && inSelection)
  14819. return; // dragging
  14820. if (!isMultiSelect) {
  14821. var range = selection.toOrientedRange();
  14822. editor.addSelectionMarker(range);
  14823. }
  14824. var oldRange = selection.rangeList.rangeAtPoint(pos);
  14825. editor.$blockScrolling++;
  14826. editor.inVirtualSelectionMode = true;
  14827. if (shift) {
  14828. oldRange = null;
  14829. range = selection.ranges[0] || range;
  14830. editor.removeSelectionMarker(range);
  14831. }
  14832. editor.once("mouseup", function() {
  14833. var tmpSel = selection.toOrientedRange();
  14834. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  14835. selection.substractPoint(tmpSel.cursor);
  14836. else {
  14837. if (shift) {
  14838. selection.substractPoint(range.cursor);
  14839. } else if (range) {
  14840. editor.removeSelectionMarker(range);
  14841. selection.addRange(range);
  14842. }
  14843. selection.addRange(tmpSel);
  14844. }
  14845. editor.$blockScrolling--;
  14846. editor.inVirtualSelectionMode = false;
  14847. });
  14848. } else if (selectionMode == "block") {
  14849. e.stop();
  14850. editor.inVirtualSelectionMode = true;
  14851. var initialRange;
  14852. var rectSel = [];
  14853. var blockSelect = function() {
  14854. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  14855. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
  14856. if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
  14857. return;
  14858. screenCursor = newCursor;
  14859. editor.$blockScrolling++;
  14860. editor.selection.moveToPosition(cursor);
  14861. editor.renderer.scrollCursorIntoView();
  14862. editor.removeSelectionMarkers(rectSel);
  14863. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  14864. if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
  14865. rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
  14866. rectSel.forEach(editor.addSelectionMarker, editor);
  14867. editor.updateSelectionMarkers();
  14868. editor.$blockScrolling--;
  14869. };
  14870. editor.$blockScrolling++;
  14871. if (isMultiSelect && !accel) {
  14872. selection.toSingleRange();
  14873. } else if (!isMultiSelect && accel) {
  14874. initialRange = selection.toOrientedRange();
  14875. editor.addSelectionMarker(initialRange);
  14876. }
  14877. if (shift)
  14878. screenAnchor = session.documentToScreenPosition(selection.lead);
  14879. else
  14880. selection.moveToPosition(pos);
  14881. editor.$blockScrolling--;
  14882. screenCursor = {row: -1, column: -1};
  14883. var onMouseSelectionEnd = function(e) {
  14884. clearInterval(timerId);
  14885. editor.removeSelectionMarkers(rectSel);
  14886. if (!rectSel.length)
  14887. rectSel = [selection.toOrientedRange()];
  14888. editor.$blockScrolling++;
  14889. if (initialRange) {
  14890. editor.removeSelectionMarker(initialRange);
  14891. selection.toSingleRange(initialRange);
  14892. }
  14893. for (var i = 0; i < rectSel.length; i++)
  14894. selection.addRange(rectSel[i]);
  14895. editor.inVirtualSelectionMode = false;
  14896. editor.$mouseHandler.$clickSelection = null;
  14897. editor.$blockScrolling--;
  14898. };
  14899. var onSelectionInterval = blockSelect;
  14900. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  14901. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  14902. return e.preventDefault();
  14903. }
  14904. }
  14905. exports.onMouseDown = onMouseDown;
  14906. });
  14907. ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
  14908. exports.defaultCommands = [{
  14909. name: "addCursorAbove",
  14910. exec: function(editor) { editor.selectMoreLines(-1); },
  14911. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  14912. scrollIntoView: "cursor",
  14913. readOnly: true
  14914. }, {
  14915. name: "addCursorBelow",
  14916. exec: function(editor) { editor.selectMoreLines(1); },
  14917. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  14918. scrollIntoView: "cursor",
  14919. readOnly: true
  14920. }, {
  14921. name: "addCursorAboveSkipCurrent",
  14922. exec: function(editor) { editor.selectMoreLines(-1, true); },
  14923. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  14924. scrollIntoView: "cursor",
  14925. readOnly: true
  14926. }, {
  14927. name: "addCursorBelowSkipCurrent",
  14928. exec: function(editor) { editor.selectMoreLines(1, true); },
  14929. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  14930. scrollIntoView: "cursor",
  14931. readOnly: true
  14932. }, {
  14933. name: "selectMoreBefore",
  14934. exec: function(editor) { editor.selectMore(-1); },
  14935. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  14936. scrollIntoView: "cursor",
  14937. readOnly: true
  14938. }, {
  14939. name: "selectMoreAfter",
  14940. exec: function(editor) { editor.selectMore(1); },
  14941. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  14942. scrollIntoView: "cursor",
  14943. readOnly: true
  14944. }, {
  14945. name: "selectNextBefore",
  14946. exec: function(editor) { editor.selectMore(-1, true); },
  14947. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  14948. scrollIntoView: "cursor",
  14949. readOnly: true
  14950. }, {
  14951. name: "selectNextAfter",
  14952. exec: function(editor) { editor.selectMore(1, true); },
  14953. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  14954. scrollIntoView: "cursor",
  14955. readOnly: true
  14956. }, {
  14957. name: "splitIntoLines",
  14958. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  14959. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  14960. readOnly: true
  14961. }, {
  14962. name: "alignCursors",
  14963. exec: function(editor) { editor.alignCursors(); },
  14964. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  14965. scrollIntoView: "cursor"
  14966. }, {
  14967. name: "findAll",
  14968. exec: function(editor) { editor.findAll(); },
  14969. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  14970. scrollIntoView: "cursor",
  14971. readOnly: true
  14972. }];
  14973. exports.multiSelectCommands = [{
  14974. name: "singleSelection",
  14975. bindKey: "esc",
  14976. exec: function(editor) { editor.exitMultiSelectMode(); },
  14977. scrollIntoView: "cursor",
  14978. readOnly: true,
  14979. isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
  14980. }];
  14981. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  14982. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  14983. });
  14984. 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) {
  14985. var RangeList = require("./range_list").RangeList;
  14986. var Range = require("./range").Range;
  14987. var Selection = require("./selection").Selection;
  14988. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  14989. var event = require("./lib/event");
  14990. var lang = require("./lib/lang");
  14991. var commands = require("./commands/multi_select_commands");
  14992. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  14993. var Search = require("./search").Search;
  14994. var search = new Search();
  14995. function find(session, needle, dir) {
  14996. search.$options.wrap = true;
  14997. search.$options.needle = needle;
  14998. search.$options.backwards = dir == -1;
  14999. return search.find(session);
  15000. }
  15001. var EditSession = require("./edit_session").EditSession;
  15002. (function() {
  15003. this.getSelectionMarkers = function() {
  15004. return this.$selectionMarkers;
  15005. };
  15006. }).call(EditSession.prototype);
  15007. (function() {
  15008. this.ranges = null;
  15009. this.rangeList = null;
  15010. this.addRange = function(range, $blockChangeEvents) {
  15011. if (!range)
  15012. return;
  15013. if (!this.inMultiSelectMode && this.rangeCount === 0) {
  15014. var oldRange = this.toOrientedRange();
  15015. this.rangeList.add(oldRange);
  15016. this.rangeList.add(range);
  15017. if (this.rangeList.ranges.length != 2) {
  15018. this.rangeList.removeAll();
  15019. return $blockChangeEvents || this.fromOrientedRange(range);
  15020. }
  15021. this.rangeList.removeAll();
  15022. this.rangeList.add(oldRange);
  15023. this.$onAddRange(oldRange);
  15024. }
  15025. if (!range.cursor)
  15026. range.cursor = range.end;
  15027. var removed = this.rangeList.add(range);
  15028. this.$onAddRange(range);
  15029. if (removed.length)
  15030. this.$onRemoveRange(removed);
  15031. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  15032. this._signal("multiSelect");
  15033. this.inMultiSelectMode = true;
  15034. this.session.$undoSelect = false;
  15035. this.rangeList.attach(this.session);
  15036. }
  15037. return $blockChangeEvents || this.fromOrientedRange(range);
  15038. };
  15039. this.toSingleRange = function(range) {
  15040. range = range || this.ranges[0];
  15041. var removed = this.rangeList.removeAll();
  15042. if (removed.length)
  15043. this.$onRemoveRange(removed);
  15044. range && this.fromOrientedRange(range);
  15045. };
  15046. this.substractPoint = function(pos) {
  15047. var removed = this.rangeList.substractPoint(pos);
  15048. if (removed) {
  15049. this.$onRemoveRange(removed);
  15050. return removed[0];
  15051. }
  15052. };
  15053. this.mergeOverlappingRanges = function() {
  15054. var removed = this.rangeList.merge();
  15055. if (removed.length)
  15056. this.$onRemoveRange(removed);
  15057. else if(this.ranges[0])
  15058. this.fromOrientedRange(this.ranges[0]);
  15059. };
  15060. this.$onAddRange = function(range) {
  15061. this.rangeCount = this.rangeList.ranges.length;
  15062. this.ranges.unshift(range);
  15063. this._signal("addRange", {range: range});
  15064. };
  15065. this.$onRemoveRange = function(removed) {
  15066. this.rangeCount = this.rangeList.ranges.length;
  15067. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  15068. var lastRange = this.rangeList.ranges.pop();
  15069. removed.push(lastRange);
  15070. this.rangeCount = 0;
  15071. }
  15072. for (var i = removed.length; i--; ) {
  15073. var index = this.ranges.indexOf(removed[i]);
  15074. this.ranges.splice(index, 1);
  15075. }
  15076. this._signal("removeRange", {ranges: removed});
  15077. if (this.rangeCount === 0 && this.inMultiSelectMode) {
  15078. this.inMultiSelectMode = false;
  15079. this._signal("singleSelect");
  15080. this.session.$undoSelect = true;
  15081. this.rangeList.detach(this.session);
  15082. }
  15083. lastRange = lastRange || this.ranges[0];
  15084. if (lastRange && !lastRange.isEqual(this.getRange()))
  15085. this.fromOrientedRange(lastRange);
  15086. };
  15087. this.$initRangeList = function() {
  15088. if (this.rangeList)
  15089. return;
  15090. this.rangeList = new RangeList();
  15091. this.ranges = [];
  15092. this.rangeCount = 0;
  15093. };
  15094. this.getAllRanges = function() {
  15095. return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
  15096. };
  15097. this.splitIntoLines = function () {
  15098. if (this.rangeCount > 1) {
  15099. var ranges = this.rangeList.ranges;
  15100. var lastRange = ranges[ranges.length - 1];
  15101. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15102. this.toSingleRange();
  15103. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15104. } else {
  15105. var range = this.getRange();
  15106. var isBackwards = this.isBackwards();
  15107. var startRow = range.start.row;
  15108. var endRow = range.end.row;
  15109. if (startRow == endRow) {
  15110. if (isBackwards)
  15111. var start = range.end, end = range.start;
  15112. else
  15113. var start = range.start, end = range.end;
  15114. this.addRange(Range.fromPoints(end, end));
  15115. this.addRange(Range.fromPoints(start, start));
  15116. return;
  15117. }
  15118. var rectSel = [];
  15119. var r = this.getLineRange(startRow, true);
  15120. r.start.column = range.start.column;
  15121. rectSel.push(r);
  15122. for (var i = startRow + 1; i < endRow; i++)
  15123. rectSel.push(this.getLineRange(i, true));
  15124. r = this.getLineRange(endRow, true);
  15125. r.end.column = range.end.column;
  15126. rectSel.push(r);
  15127. rectSel.forEach(this.addRange, this);
  15128. }
  15129. };
  15130. this.toggleBlockSelection = function () {
  15131. if (this.rangeCount > 1) {
  15132. var ranges = this.rangeList.ranges;
  15133. var lastRange = ranges[ranges.length - 1];
  15134. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15135. this.toSingleRange();
  15136. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15137. } else {
  15138. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  15139. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  15140. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  15141. rectSel.forEach(this.addRange, this);
  15142. }
  15143. };
  15144. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  15145. var rectSel = [];
  15146. var xBackwards = screenCursor.column < screenAnchor.column;
  15147. if (xBackwards) {
  15148. var startColumn = screenCursor.column;
  15149. var endColumn = screenAnchor.column;
  15150. } else {
  15151. var startColumn = screenAnchor.column;
  15152. var endColumn = screenCursor.column;
  15153. }
  15154. var yBackwards = screenCursor.row < screenAnchor.row;
  15155. if (yBackwards) {
  15156. var startRow = screenCursor.row;
  15157. var endRow = screenAnchor.row;
  15158. } else {
  15159. var startRow = screenAnchor.row;
  15160. var endRow = screenCursor.row;
  15161. }
  15162. if (startColumn < 0)
  15163. startColumn = 0;
  15164. if (startRow < 0)
  15165. startRow = 0;
  15166. if (startRow == endRow)
  15167. includeEmptyLines = true;
  15168. for (var row = startRow; row <= endRow; row++) {
  15169. var range = Range.fromPoints(
  15170. this.session.screenToDocumentPosition(row, startColumn),
  15171. this.session.screenToDocumentPosition(row, endColumn)
  15172. );
  15173. if (range.isEmpty()) {
  15174. if (docEnd && isSamePoint(range.end, docEnd))
  15175. break;
  15176. var docEnd = range.end;
  15177. }
  15178. range.cursor = xBackwards ? range.start : range.end;
  15179. rectSel.push(range);
  15180. }
  15181. if (yBackwards)
  15182. rectSel.reverse();
  15183. if (!includeEmptyLines) {
  15184. var end = rectSel.length - 1;
  15185. while (rectSel[end].isEmpty() && end > 0)
  15186. end--;
  15187. if (end > 0) {
  15188. var start = 0;
  15189. while (rectSel[start].isEmpty())
  15190. start++;
  15191. }
  15192. for (var i = end; i >= start; i--) {
  15193. if (rectSel[i].isEmpty())
  15194. rectSel.splice(i, 1);
  15195. }
  15196. }
  15197. return rectSel;
  15198. };
  15199. }).call(Selection.prototype);
  15200. var Editor = require("./editor").Editor;
  15201. (function() {
  15202. this.updateSelectionMarkers = function() {
  15203. this.renderer.updateCursor();
  15204. this.renderer.updateBackMarkers();
  15205. };
  15206. this.addSelectionMarker = function(orientedRange) {
  15207. if (!orientedRange.cursor)
  15208. orientedRange.cursor = orientedRange.end;
  15209. var style = this.getSelectionStyle();
  15210. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  15211. this.session.$selectionMarkers.push(orientedRange);
  15212. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15213. return orientedRange;
  15214. };
  15215. this.removeSelectionMarker = function(range) {
  15216. if (!range.marker)
  15217. return;
  15218. this.session.removeMarker(range.marker);
  15219. var index = this.session.$selectionMarkers.indexOf(range);
  15220. if (index != -1)
  15221. this.session.$selectionMarkers.splice(index, 1);
  15222. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15223. };
  15224. this.removeSelectionMarkers = function(ranges) {
  15225. var markerList = this.session.$selectionMarkers;
  15226. for (var i = ranges.length; i--; ) {
  15227. var range = ranges[i];
  15228. if (!range.marker)
  15229. continue;
  15230. this.session.removeMarker(range.marker);
  15231. var index = markerList.indexOf(range);
  15232. if (index != -1)
  15233. markerList.splice(index, 1);
  15234. }
  15235. this.session.selectionMarkerCount = markerList.length;
  15236. };
  15237. this.$onAddRange = function(e) {
  15238. this.addSelectionMarker(e.range);
  15239. this.renderer.updateCursor();
  15240. this.renderer.updateBackMarkers();
  15241. };
  15242. this.$onRemoveRange = function(e) {
  15243. this.removeSelectionMarkers(e.ranges);
  15244. this.renderer.updateCursor();
  15245. this.renderer.updateBackMarkers();
  15246. };
  15247. this.$onMultiSelect = function(e) {
  15248. if (this.inMultiSelectMode)
  15249. return;
  15250. this.inMultiSelectMode = true;
  15251. this.setStyle("ace_multiselect");
  15252. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  15253. this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
  15254. this.renderer.updateCursor();
  15255. this.renderer.updateBackMarkers();
  15256. };
  15257. this.$onSingleSelect = function(e) {
  15258. if (this.session.multiSelect.inVirtualMode)
  15259. return;
  15260. this.inMultiSelectMode = false;
  15261. this.unsetStyle("ace_multiselect");
  15262. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  15263. this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
  15264. this.renderer.updateCursor();
  15265. this.renderer.updateBackMarkers();
  15266. this._emit("changeSelection");
  15267. };
  15268. this.$onMultiSelectExec = function(e) {
  15269. var command = e.command;
  15270. var editor = e.editor;
  15271. if (!editor.multiSelect)
  15272. return;
  15273. if (!command.multiSelectAction) {
  15274. var result = command.exec(editor, e.args || {});
  15275. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  15276. editor.multiSelect.mergeOverlappingRanges();
  15277. } else if (command.multiSelectAction == "forEach") {
  15278. result = editor.forEachSelection(command, e.args);
  15279. } else if (command.multiSelectAction == "forEachLine") {
  15280. result = editor.forEachSelection(command, e.args, true);
  15281. } else if (command.multiSelectAction == "single") {
  15282. editor.exitMultiSelectMode();
  15283. result = command.exec(editor, e.args || {});
  15284. } else {
  15285. result = command.multiSelectAction(editor, e.args || {});
  15286. }
  15287. return result;
  15288. };
  15289. this.forEachSelection = function(cmd, args, options) {
  15290. if (this.inVirtualSelectionMode)
  15291. return;
  15292. var keepOrder = options && options.keepOrder;
  15293. var $byLines = options == true || options && options.$byLines
  15294. var session = this.session;
  15295. var selection = this.selection;
  15296. var rangeList = selection.rangeList;
  15297. var ranges = (keepOrder ? selection : rangeList).ranges;
  15298. var result;
  15299. if (!ranges.length)
  15300. return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15301. var reg = selection._eventRegistry;
  15302. selection._eventRegistry = {};
  15303. var tmpSel = new Selection(session);
  15304. this.inVirtualSelectionMode = true;
  15305. for (var i = ranges.length; i--;) {
  15306. if ($byLines) {
  15307. while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
  15308. i--;
  15309. }
  15310. tmpSel.fromOrientedRange(ranges[i]);
  15311. tmpSel.index = i;
  15312. this.selection = session.selection = tmpSel;
  15313. var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15314. if (!result && cmdResult !== undefined)
  15315. result = cmdResult;
  15316. tmpSel.toOrientedRange(ranges[i]);
  15317. }
  15318. tmpSel.detach();
  15319. this.selection = session.selection = selection;
  15320. this.inVirtualSelectionMode = false;
  15321. selection._eventRegistry = reg;
  15322. selection.mergeOverlappingRanges();
  15323. var anim = this.renderer.$scrollAnimation;
  15324. this.onCursorChange();
  15325. this.onSelectionChange();
  15326. if (anim && anim.from == anim.to)
  15327. this.renderer.animateScrolling(anim.from);
  15328. return result;
  15329. };
  15330. this.exitMultiSelectMode = function() {
  15331. if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
  15332. return;
  15333. this.multiSelect.toSingleRange();
  15334. };
  15335. this.getSelectedText = function() {
  15336. var text = "";
  15337. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15338. var ranges = this.multiSelect.rangeList.ranges;
  15339. var buf = [];
  15340. for (var i = 0; i < ranges.length; i++) {
  15341. buf.push(this.session.getTextRange(ranges[i]));
  15342. }
  15343. var nl = this.session.getDocument().getNewLineCharacter();
  15344. text = buf.join(nl);
  15345. if (text.length == (buf.length - 1) * nl.length)
  15346. text = "";
  15347. } else if (!this.selection.isEmpty()) {
  15348. text = this.session.getTextRange(this.getSelectionRange());
  15349. }
  15350. return text;
  15351. };
  15352. this.$checkMultiselectChange = function(e, anchor) {
  15353. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15354. var range = this.multiSelect.ranges[0];
  15355. if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
  15356. return;
  15357. var pos = anchor == this.multiSelect.anchor
  15358. ? range.cursor == range.start ? range.end : range.start
  15359. : range.cursor;
  15360. if (pos.row != anchor.row
  15361. || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
  15362. this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
  15363. }
  15364. };
  15365. this.findAll = function(needle, options, additive) {
  15366. options = options || {};
  15367. options.needle = needle || options.needle;
  15368. if (options.needle == undefined) {
  15369. var range = this.selection.isEmpty()
  15370. ? this.selection.getWordRange()
  15371. : this.selection.getRange();
  15372. options.needle = this.session.getTextRange(range);
  15373. }
  15374. this.$search.set(options);
  15375. var ranges = this.$search.findAll(this.session);
  15376. if (!ranges.length)
  15377. return 0;
  15378. this.$blockScrolling += 1;
  15379. var selection = this.multiSelect;
  15380. if (!additive)
  15381. selection.toSingleRange(ranges[0]);
  15382. for (var i = ranges.length; i--; )
  15383. selection.addRange(ranges[i], true);
  15384. if (range && selection.rangeList.rangeAtPoint(range.start))
  15385. selection.addRange(range, true);
  15386. this.$blockScrolling -= 1;
  15387. return ranges.length;
  15388. };
  15389. this.selectMoreLines = function(dir, skip) {
  15390. var range = this.selection.toOrientedRange();
  15391. var isBackwards = range.cursor == range.end;
  15392. var screenLead = this.session.documentToScreenPosition(range.cursor);
  15393. if (this.selection.$desiredColumn)
  15394. screenLead.column = this.selection.$desiredColumn;
  15395. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  15396. if (!range.isEmpty()) {
  15397. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  15398. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  15399. } else {
  15400. var anchor = lead;
  15401. }
  15402. if (isBackwards) {
  15403. var newRange = Range.fromPoints(lead, anchor);
  15404. newRange.cursor = newRange.start;
  15405. } else {
  15406. var newRange = Range.fromPoints(anchor, lead);
  15407. newRange.cursor = newRange.end;
  15408. }
  15409. newRange.desiredColumn = screenLead.column;
  15410. if (!this.selection.inMultiSelectMode) {
  15411. this.selection.addRange(range);
  15412. } else {
  15413. if (skip)
  15414. var toRemove = range.cursor;
  15415. }
  15416. this.selection.addRange(newRange);
  15417. if (toRemove)
  15418. this.selection.substractPoint(toRemove);
  15419. };
  15420. this.transposeSelections = function(dir) {
  15421. var session = this.session;
  15422. var sel = session.multiSelect;
  15423. var all = sel.ranges;
  15424. for (var i = all.length; i--; ) {
  15425. var range = all[i];
  15426. if (range.isEmpty()) {
  15427. var tmp = session.getWordRange(range.start.row, range.start.column);
  15428. range.start.row = tmp.start.row;
  15429. range.start.column = tmp.start.column;
  15430. range.end.row = tmp.end.row;
  15431. range.end.column = tmp.end.column;
  15432. }
  15433. }
  15434. sel.mergeOverlappingRanges();
  15435. var words = [];
  15436. for (var i = all.length; i--; ) {
  15437. var range = all[i];
  15438. words.unshift(session.getTextRange(range));
  15439. }
  15440. if (dir < 0)
  15441. words.unshift(words.pop());
  15442. else
  15443. words.push(words.shift());
  15444. for (var i = all.length; i--; ) {
  15445. var range = all[i];
  15446. var tmp = range.clone();
  15447. session.replace(range, words[i]);
  15448. range.start.row = tmp.start.row;
  15449. range.start.column = tmp.start.column;
  15450. }
  15451. };
  15452. this.selectMore = function(dir, skip, stopAtFirst) {
  15453. var session = this.session;
  15454. var sel = session.multiSelect;
  15455. var range = sel.toOrientedRange();
  15456. if (range.isEmpty()) {
  15457. range = session.getWordRange(range.start.row, range.start.column);
  15458. range.cursor = dir == -1 ? range.start : range.end;
  15459. this.multiSelect.addRange(range);
  15460. if (stopAtFirst)
  15461. return;
  15462. }
  15463. var needle = session.getTextRange(range);
  15464. var newRange = find(session, needle, dir);
  15465. if (newRange) {
  15466. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  15467. this.$blockScrolling += 1;
  15468. this.session.unfold(newRange);
  15469. this.multiSelect.addRange(newRange);
  15470. this.$blockScrolling -= 1;
  15471. this.renderer.scrollCursorIntoView(null, 0.5);
  15472. }
  15473. if (skip)
  15474. this.multiSelect.substractPoint(range.cursor);
  15475. };
  15476. this.alignCursors = function() {
  15477. var session = this.session;
  15478. var sel = session.multiSelect;
  15479. var ranges = sel.ranges;
  15480. var row = -1;
  15481. var sameRowRanges = ranges.filter(function(r) {
  15482. if (r.cursor.row == row)
  15483. return true;
  15484. row = r.cursor.row;
  15485. });
  15486. if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
  15487. var range = this.selection.getRange();
  15488. var fr = range.start.row, lr = range.end.row;
  15489. var guessRange = fr == lr;
  15490. if (guessRange) {
  15491. var max = this.session.getLength();
  15492. var line;
  15493. do {
  15494. line = this.session.getLine(lr);
  15495. } while (/[=:]/.test(line) && ++lr < max);
  15496. do {
  15497. line = this.session.getLine(fr);
  15498. } while (/[=:]/.test(line) && --fr > 0);
  15499. if (fr < 0) fr = 0;
  15500. if (lr >= max) lr = max - 1;
  15501. }
  15502. var lines = this.session.removeFullLines(fr, lr);
  15503. lines = this.$reAlignText(lines, guessRange);
  15504. this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
  15505. if (!guessRange) {
  15506. range.start.column = 0;
  15507. range.end.column = lines[lines.length - 1].length;
  15508. }
  15509. this.selection.setRange(range);
  15510. } else {
  15511. sameRowRanges.forEach(function(r) {
  15512. sel.substractPoint(r.cursor);
  15513. });
  15514. var maxCol = 0;
  15515. var minSpace = Infinity;
  15516. var spaceOffsets = ranges.map(function(r) {
  15517. var p = r.cursor;
  15518. var line = session.getLine(p.row);
  15519. var spaceOffset = line.substr(p.column).search(/\S/g);
  15520. if (spaceOffset == -1)
  15521. spaceOffset = 0;
  15522. if (p.column > maxCol)
  15523. maxCol = p.column;
  15524. if (spaceOffset < minSpace)
  15525. minSpace = spaceOffset;
  15526. return spaceOffset;
  15527. });
  15528. ranges.forEach(function(r, i) {
  15529. var p = r.cursor;
  15530. var l = maxCol - p.column;
  15531. var d = spaceOffsets[i] - minSpace;
  15532. if (l > d)
  15533. session.insert(p, lang.stringRepeat(" ", l - d));
  15534. else
  15535. session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
  15536. r.start.column = r.end.column = maxCol;
  15537. r.start.row = r.end.row = p.row;
  15538. r.cursor = r.end;
  15539. });
  15540. sel.fromOrientedRange(ranges[0]);
  15541. this.renderer.updateCursor();
  15542. this.renderer.updateBackMarkers();
  15543. }
  15544. };
  15545. this.$reAlignText = function(lines, forceLeft) {
  15546. var isLeftAligned = true, isRightAligned = true;
  15547. var startW, textW, endW;
  15548. return lines.map(function(line) {
  15549. var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
  15550. if (!m)
  15551. return [line];
  15552. if (startW == null) {
  15553. startW = m[1].length;
  15554. textW = m[2].length;
  15555. endW = m[3].length;
  15556. return m;
  15557. }
  15558. if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
  15559. isRightAligned = false;
  15560. if (startW != m[1].length)
  15561. isLeftAligned = false;
  15562. if (startW > m[1].length)
  15563. startW = m[1].length;
  15564. if (textW < m[2].length)
  15565. textW = m[2].length;
  15566. if (endW > m[3].length)
  15567. endW = m[3].length;
  15568. return m;
  15569. }).map(forceLeft ? alignLeft :
  15570. isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
  15571. function spaces(n) {
  15572. return lang.stringRepeat(" ", n);
  15573. }
  15574. function alignLeft(m) {
  15575. return !m[2] ? m[0] : spaces(startW) + m[2]
  15576. + spaces(textW - m[2].length + endW)
  15577. + m[4].replace(/^([=:])\s+/, "$1 ");
  15578. }
  15579. function alignRight(m) {
  15580. return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
  15581. + spaces(endW, " ")
  15582. + m[4].replace(/^([=:])\s+/, "$1 ");
  15583. }
  15584. function unAlign(m) {
  15585. return !m[2] ? m[0] : spaces(startW) + m[2]
  15586. + spaces(endW)
  15587. + m[4].replace(/^([=:])\s+/, "$1 ");
  15588. }
  15589. };
  15590. }).call(Editor.prototype);
  15591. function isSamePoint(p1, p2) {
  15592. return p1.row == p2.row && p1.column == p2.column;
  15593. }
  15594. exports.onSessionChange = function(e) {
  15595. var session = e.session;
  15596. if (session && !session.multiSelect) {
  15597. session.$selectionMarkers = [];
  15598. session.selection.$initRangeList();
  15599. session.multiSelect = session.selection;
  15600. }
  15601. this.multiSelect = session && session.multiSelect;
  15602. var oldSession = e.oldSession;
  15603. if (oldSession) {
  15604. oldSession.multiSelect.off("addRange", this.$onAddRange);
  15605. oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
  15606. oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
  15607. oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
  15608. oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
  15609. oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
  15610. }
  15611. if (session) {
  15612. session.multiSelect.on("addRange", this.$onAddRange);
  15613. session.multiSelect.on("removeRange", this.$onRemoveRange);
  15614. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  15615. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  15616. session.multiSelect.lead.on("change", this.$checkMultiselectChange);
  15617. session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
  15618. }
  15619. if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  15620. if (session.selection.inMultiSelectMode)
  15621. this.$onMultiSelect();
  15622. else
  15623. this.$onSingleSelect();
  15624. }
  15625. };
  15626. function MultiSelect(editor) {
  15627. if (editor.$multiselectOnSessionChange)
  15628. return;
  15629. editor.$onAddRange = editor.$onAddRange.bind(editor);
  15630. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  15631. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  15632. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  15633. editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
  15634. editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
  15635. editor.$multiselectOnSessionChange(editor);
  15636. editor.on("changeSession", editor.$multiselectOnSessionChange);
  15637. editor.on("mousedown", onMouseDown);
  15638. editor.commands.addCommands(commands.defaultCommands);
  15639. addAltCursorListeners(editor);
  15640. }
  15641. function addAltCursorListeners(editor){
  15642. var el = editor.textInput.getElement();
  15643. var altCursor = false;
  15644. event.addListener(el, "keydown", function(e) {
  15645. var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey);
  15646. if (editor.$blockSelectEnabled && altDown) {
  15647. if (!altCursor) {
  15648. editor.renderer.setMouseCursor("crosshair");
  15649. altCursor = true;
  15650. }
  15651. } else if (altCursor) {
  15652. reset();
  15653. }
  15654. });
  15655. event.addListener(el, "keyup", reset);
  15656. event.addListener(el, "blur", reset);
  15657. function reset(e) {
  15658. if (altCursor) {
  15659. editor.renderer.setMouseCursor("");
  15660. altCursor = false;
  15661. }
  15662. }
  15663. }
  15664. exports.MultiSelect = MultiSelect;
  15665. require("./config").defineOptions(Editor.prototype, "editor", {
  15666. enableMultiselect: {
  15667. set: function(val) {
  15668. MultiSelect(this);
  15669. if (val) {
  15670. this.on("changeSession", this.$multiselectOnSessionChange);
  15671. this.on("mousedown", onMouseDown);
  15672. } else {
  15673. this.off("changeSession", this.$multiselectOnSessionChange);
  15674. this.off("mousedown", onMouseDown);
  15675. }
  15676. },
  15677. value: true
  15678. },
  15679. enableBlockSelect: {
  15680. set: function(val) {
  15681. this.$blockSelectEnabled = val;
  15682. },
  15683. value: true
  15684. }
  15685. });
  15686. });
  15687. ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
  15688. "use strict";
  15689. var Range = require("../../range").Range;
  15690. var FoldMode = exports.FoldMode = function() {};
  15691. (function() {
  15692. this.foldingStartMarker = null;
  15693. this.foldingStopMarker = null;
  15694. this.getFoldWidget = function(session, foldStyle, row) {
  15695. var line = session.getLine(row);
  15696. if (this.foldingStartMarker.test(line))
  15697. return "start";
  15698. if (foldStyle == "markbeginend"
  15699. && this.foldingStopMarker
  15700. && this.foldingStopMarker.test(line))
  15701. return "end";
  15702. return "";
  15703. };
  15704. this.getFoldWidgetRange = function(session, foldStyle, row) {
  15705. return null;
  15706. };
  15707. this.indentationBlock = function(session, row, column) {
  15708. var re = /\S/;
  15709. var line = session.getLine(row);
  15710. var startLevel = line.search(re);
  15711. if (startLevel == -1)
  15712. return;
  15713. var startColumn = column || line.length;
  15714. var maxRow = session.getLength();
  15715. var startRow = row;
  15716. var endRow = row;
  15717. while (++row < maxRow) {
  15718. var level = session.getLine(row).search(re);
  15719. if (level == -1)
  15720. continue;
  15721. if (level <= startLevel)
  15722. break;
  15723. endRow = row;
  15724. }
  15725. if (endRow > startRow) {
  15726. var endColumn = session.getLine(endRow).length;
  15727. return new Range(startRow, startColumn, endRow, endColumn);
  15728. }
  15729. };
  15730. this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
  15731. var start = {row: row, column: column + 1};
  15732. var end = session.$findClosingBracket(bracket, start, typeRe);
  15733. if (!end)
  15734. return;
  15735. var fw = session.foldWidgets[end.row];
  15736. if (fw == null)
  15737. fw = session.getFoldWidget(end.row);
  15738. if (fw == "start" && end.row > start.row) {
  15739. end.row --;
  15740. end.column = session.getLine(end.row).length;
  15741. }
  15742. return Range.fromPoints(start, end);
  15743. };
  15744. this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
  15745. var end = {row: row, column: column};
  15746. var start = session.$findOpeningBracket(bracket, end);
  15747. if (!start)
  15748. return;
  15749. start.column++;
  15750. end.column--;
  15751. return Range.fromPoints(start, end);
  15752. };
  15753. }).call(FoldMode.prototype);
  15754. });
  15755. ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  15756. "use strict";
  15757. exports.isDark = false;
  15758. exports.cssClass = "ace-tm";
  15759. exports.cssText = ".ace-tm .ace_gutter {\
  15760. background: #f0f0f0;\
  15761. color: #333;\
  15762. }\
  15763. .ace-tm .ace_print-margin {\
  15764. width: 1px;\
  15765. background: #e8e8e8;\
  15766. }\
  15767. .ace-tm .ace_fold {\
  15768. background-color: #6B72E6;\
  15769. }\
  15770. .ace-tm {\
  15771. background-color: #FFFFFF;\
  15772. color: black;\
  15773. }\
  15774. .ace-tm .ace_cursor {\
  15775. color: black;\
  15776. }\
  15777. .ace-tm .ace_invisible {\
  15778. color: rgb(191, 191, 191);\
  15779. }\
  15780. .ace-tm .ace_storage,\
  15781. .ace-tm .ace_keyword {\
  15782. color: blue;\
  15783. }\
  15784. .ace-tm .ace_constant {\
  15785. color: rgb(197, 6, 11);\
  15786. }\
  15787. .ace-tm .ace_constant.ace_buildin {\
  15788. color: rgb(88, 72, 246);\
  15789. }\
  15790. .ace-tm .ace_constant.ace_language {\
  15791. color: rgb(88, 92, 246);\
  15792. }\
  15793. .ace-tm .ace_constant.ace_library {\
  15794. color: rgb(6, 150, 14);\
  15795. }\
  15796. .ace-tm .ace_invalid {\
  15797. background-color: rgba(255, 0, 0, 0.1);\
  15798. color: red;\
  15799. }\
  15800. .ace-tm .ace_support.ace_function {\
  15801. color: rgb(60, 76, 114);\
  15802. }\
  15803. .ace-tm .ace_support.ace_constant {\
  15804. color: rgb(6, 150, 14);\
  15805. }\
  15806. .ace-tm .ace_support.ace_type,\
  15807. .ace-tm .ace_support.ace_class {\
  15808. color: rgb(109, 121, 222);\
  15809. }\
  15810. .ace-tm .ace_keyword.ace_operator {\
  15811. color: rgb(104, 118, 135);\
  15812. }\
  15813. .ace-tm .ace_string {\
  15814. color: rgb(3, 106, 7);\
  15815. }\
  15816. .ace-tm .ace_comment {\
  15817. color: rgb(76, 136, 107);\
  15818. }\
  15819. .ace-tm .ace_comment.ace_doc {\
  15820. color: rgb(0, 102, 255);\
  15821. }\
  15822. .ace-tm .ace_comment.ace_doc.ace_tag {\
  15823. color: rgb(128, 159, 191);\
  15824. }\
  15825. .ace-tm .ace_constant.ace_numeric {\
  15826. color: rgb(0, 0, 205);\
  15827. }\
  15828. .ace-tm .ace_variable {\
  15829. color: rgb(49, 132, 149);\
  15830. }\
  15831. .ace-tm .ace_xml-pe {\
  15832. color: rgb(104, 104, 91);\
  15833. }\
  15834. .ace-tm .ace_entity.ace_name.ace_function {\
  15835. color: #0000A2;\
  15836. }\
  15837. .ace-tm .ace_heading {\
  15838. color: rgb(12, 7, 255);\
  15839. }\
  15840. .ace-tm .ace_list {\
  15841. color:rgb(185, 6, 144);\
  15842. }\
  15843. .ace-tm .ace_meta.ace_tag {\
  15844. color:rgb(0, 22, 142);\
  15845. }\
  15846. .ace-tm .ace_string.ace_regex {\
  15847. color: rgb(255, 0, 0)\
  15848. }\
  15849. .ace-tm .ace_marker-layer .ace_selection {\
  15850. background: rgb(181, 213, 255);\
  15851. }\
  15852. .ace-tm.ace_multiselect .ace_selection.ace_start {\
  15853. box-shadow: 0 0 3px 0px white;\
  15854. }\
  15855. .ace-tm .ace_marker-layer .ace_step {\
  15856. background: rgb(252, 255, 0);\
  15857. }\
  15858. .ace-tm .ace_marker-layer .ace_stack {\
  15859. background: rgb(164, 229, 101);\
  15860. }\
  15861. .ace-tm .ace_marker-layer .ace_bracket {\
  15862. margin: -1px 0 0 -1px;\
  15863. border: 1px solid rgb(192, 192, 192);\
  15864. }\
  15865. .ace-tm .ace_marker-layer .ace_active-line {\
  15866. background: rgba(0, 0, 0, 0.07);\
  15867. }\
  15868. .ace-tm .ace_gutter-active-line {\
  15869. background-color : #dcdcdc;\
  15870. }\
  15871. .ace-tm .ace_marker-layer .ace_selected-word {\
  15872. background: rgb(250, 250, 255);\
  15873. border: 1px solid rgb(200, 200, 250);\
  15874. }\
  15875. .ace-tm .ace_indent-guide {\
  15876. background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
  15877. }\
  15878. ";
  15879. var dom = require("../lib/dom");
  15880. dom.importCssString(exports.cssText, exports.cssClass);
  15881. });
  15882. ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
  15883. "use strict";
  15884. var oop = require("./lib/oop");
  15885. var dom = require("./lib/dom");
  15886. var Range = require("./range").Range;
  15887. function LineWidgets(session) {
  15888. this.session = session;
  15889. this.session.widgetManager = this;
  15890. this.session.getRowLength = this.getRowLength;
  15891. this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
  15892. this.updateOnChange = this.updateOnChange.bind(this);
  15893. this.renderWidgets = this.renderWidgets.bind(this);
  15894. this.measureWidgets = this.measureWidgets.bind(this);
  15895. this.session._changedWidgets = [];
  15896. this.$onChangeEditor = this.$onChangeEditor.bind(this);
  15897. this.session.on("change", this.updateOnChange);
  15898. this.session.on("changeFold", this.updateOnFold);
  15899. this.session.on("changeEditor", this.$onChangeEditor);
  15900. }
  15901. (function() {
  15902. this.getRowLength = function(row) {
  15903. var h;
  15904. if (this.lineWidgets)
  15905. h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  15906. else
  15907. h = 0;
  15908. if (!this.$useWrapMode || !this.$wrapData[row]) {
  15909. return 1 + h;
  15910. } else {
  15911. return this.$wrapData[row].length + 1 + h;
  15912. }
  15913. };
  15914. this.$getWidgetScreenLength = function() {
  15915. var screenRows = 0;
  15916. this.lineWidgets.forEach(function(w){
  15917. if (w && w.rowCount && !w.hidden)
  15918. screenRows += w.rowCount;
  15919. });
  15920. return screenRows;
  15921. };
  15922. this.$onChangeEditor = function(e) {
  15923. this.attach(e.editor);
  15924. };
  15925. this.attach = function(editor) {
  15926. if (editor && editor.widgetManager && editor.widgetManager != this)
  15927. editor.widgetManager.detach();
  15928. if (this.editor == editor)
  15929. return;
  15930. this.detach();
  15931. this.editor = editor;
  15932. if (editor) {
  15933. editor.widgetManager = this;
  15934. editor.renderer.on("beforeRender", this.measureWidgets);
  15935. editor.renderer.on("afterRender", this.renderWidgets);
  15936. }
  15937. };
  15938. this.detach = function(e) {
  15939. var editor = this.editor;
  15940. if (!editor)
  15941. return;
  15942. this.editor = null;
  15943. editor.widgetManager = null;
  15944. editor.renderer.off("beforeRender", this.measureWidgets);
  15945. editor.renderer.off("afterRender", this.renderWidgets);
  15946. var lineWidgets = this.session.lineWidgets;
  15947. lineWidgets && lineWidgets.forEach(function(w) {
  15948. if (w && w.el && w.el.parentNode) {
  15949. w._inDocument = false;
  15950. w.el.parentNode.removeChild(w.el);
  15951. }
  15952. });
  15953. };
  15954. this.updateOnFold = function(e, session) {
  15955. var lineWidgets = session.lineWidgets;
  15956. if (!lineWidgets || !e.action)
  15957. return;
  15958. var fold = e.data;
  15959. var start = fold.start.row;
  15960. var end = fold.end.row;
  15961. var hide = e.action == "add";
  15962. for (var i = start + 1; i < end; i++) {
  15963. if (lineWidgets[i])
  15964. lineWidgets[i].hidden = hide;
  15965. }
  15966. if (lineWidgets[end]) {
  15967. if (hide) {
  15968. if (!lineWidgets[start])
  15969. lineWidgets[start] = lineWidgets[end];
  15970. else
  15971. lineWidgets[end].hidden = hide;
  15972. } else {
  15973. if (lineWidgets[start] == lineWidgets[end])
  15974. lineWidgets[start] = undefined;
  15975. lineWidgets[end].hidden = hide;
  15976. }
  15977. }
  15978. };
  15979. this.updateOnChange = function(delta) {
  15980. var lineWidgets = this.session.lineWidgets;
  15981. if (!lineWidgets) return;
  15982. var startRow = delta.start.row;
  15983. var len = delta.end.row - startRow;
  15984. if (len === 0) {
  15985. } else if (delta.action == 'remove') {
  15986. var removed = lineWidgets.splice(startRow + 1, len);
  15987. removed.forEach(function(w) {
  15988. w && this.removeLineWidget(w);
  15989. }, this);
  15990. this.$updateRows();
  15991. } else {
  15992. var args = new Array(len);
  15993. args.unshift(startRow, 0);
  15994. lineWidgets.splice.apply(lineWidgets, args);
  15995. this.$updateRows();
  15996. }
  15997. };
  15998. this.$updateRows = function() {
  15999. var lineWidgets = this.session.lineWidgets;
  16000. if (!lineWidgets) return;
  16001. var noWidgets = true;
  16002. lineWidgets.forEach(function(w, i) {
  16003. if (w) {
  16004. noWidgets = false;
  16005. w.row = i;
  16006. while (w.$oldWidget) {
  16007. w.$oldWidget.row = i;
  16008. w = w.$oldWidget;
  16009. }
  16010. }
  16011. });
  16012. if (noWidgets)
  16013. this.session.lineWidgets = null;
  16014. };
  16015. this.addLineWidget = function(w) {
  16016. if (!this.session.lineWidgets)
  16017. this.session.lineWidgets = new Array(this.session.getLength());
  16018. var old = this.session.lineWidgets[w.row];
  16019. if (old) {
  16020. w.$oldWidget = old;
  16021. if (old.el && old.el.parentNode) {
  16022. old.el.parentNode.removeChild(old.el);
  16023. old._inDocument = false;
  16024. }
  16025. }
  16026. this.session.lineWidgets[w.row] = w;
  16027. w.session = this.session;
  16028. var renderer = this.editor.renderer;
  16029. if (w.html && !w.el) {
  16030. w.el = dom.createElement("div");
  16031. w.el.innerHTML = w.html;
  16032. }
  16033. if (w.el) {
  16034. dom.addCssClass(w.el, "ace_lineWidgetContainer");
  16035. w.el.style.position = "absolute";
  16036. w.el.style.zIndex = 5;
  16037. renderer.container.appendChild(w.el);
  16038. w._inDocument = true;
  16039. }
  16040. if (!w.coverGutter) {
  16041. w.el.style.zIndex = 3;
  16042. }
  16043. if (!w.pixelHeight) {
  16044. w.pixelHeight = w.el.offsetHeight;
  16045. }
  16046. if (w.rowCount == null) {
  16047. w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
  16048. }
  16049. var fold = this.session.getFoldAt(w.row, 0);
  16050. w.$fold = fold;
  16051. if (fold) {
  16052. var lineWidgets = this.session.lineWidgets;
  16053. if (w.row == fold.end.row && !lineWidgets[fold.start.row])
  16054. lineWidgets[fold.start.row] = w;
  16055. else
  16056. w.hidden = true;
  16057. }
  16058. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  16059. this.$updateRows();
  16060. this.renderWidgets(null, renderer);
  16061. this.onWidgetChanged(w);
  16062. return w;
  16063. };
  16064. this.removeLineWidget = function(w) {
  16065. w._inDocument = false;
  16066. w.session = null;
  16067. if (w.el && w.el.parentNode)
  16068. w.el.parentNode.removeChild(w.el);
  16069. if (w.editor && w.editor.destroy) try {
  16070. w.editor.destroy();
  16071. } catch(e){}
  16072. if (this.session.lineWidgets) {
  16073. var w1 = this.session.lineWidgets[w.row]
  16074. if (w1 == w) {
  16075. this.session.lineWidgets[w.row] = w.$oldWidget;
  16076. if (w.$oldWidget)
  16077. this.onWidgetChanged(w.$oldWidget);
  16078. } else {
  16079. while (w1) {
  16080. if (w1.$oldWidget == w) {
  16081. w1.$oldWidget = w.$oldWidget;
  16082. break;
  16083. }
  16084. w1 = w1.$oldWidget;
  16085. }
  16086. }
  16087. }
  16088. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  16089. this.$updateRows();
  16090. };
  16091. this.getWidgetsAtRow = function(row) {
  16092. var lineWidgets = this.session.lineWidgets;
  16093. var w = lineWidgets && lineWidgets[row];
  16094. var list = [];
  16095. while (w) {
  16096. list.push(w);
  16097. w = w.$oldWidget;
  16098. }
  16099. return list;
  16100. };
  16101. this.onWidgetChanged = function(w) {
  16102. this.session._changedWidgets.push(w);
  16103. this.editor && this.editor.renderer.updateFull();
  16104. };
  16105. this.measureWidgets = function(e, renderer) {
  16106. var changedWidgets = this.session._changedWidgets;
  16107. var config = renderer.layerConfig;
  16108. if (!changedWidgets || !changedWidgets.length) return;
  16109. var min = Infinity;
  16110. for (var i = 0; i < changedWidgets.length; i++) {
  16111. var w = changedWidgets[i];
  16112. if (!w || !w.el) continue;
  16113. if (w.session != this.session) continue;
  16114. if (!w._inDocument) {
  16115. if (this.session.lineWidgets[w.row] != w)
  16116. continue;
  16117. w._inDocument = true;
  16118. renderer.container.appendChild(w.el);
  16119. }
  16120. w.h = w.el.offsetHeight;
  16121. if (!w.fixedWidth) {
  16122. w.w = w.el.offsetWidth;
  16123. w.screenWidth = Math.ceil(w.w / config.characterWidth);
  16124. }
  16125. var rowCount = w.h / config.lineHeight;
  16126. if (w.coverLine) {
  16127. rowCount -= this.session.getRowLineCount(w.row);
  16128. if (rowCount < 0)
  16129. rowCount = 0;
  16130. }
  16131. if (w.rowCount != rowCount) {
  16132. w.rowCount = rowCount;
  16133. if (w.row < min)
  16134. min = w.row;
  16135. }
  16136. }
  16137. if (min != Infinity) {
  16138. this.session._emit("changeFold", {data:{start:{row: min}}});
  16139. this.session.lineWidgetWidth = null;
  16140. }
  16141. this.session._changedWidgets = [];
  16142. };
  16143. this.renderWidgets = function(e, renderer) {
  16144. var config = renderer.layerConfig;
  16145. var lineWidgets = this.session.lineWidgets;
  16146. if (!lineWidgets)
  16147. return;
  16148. var first = Math.min(this.firstRow, config.firstRow);
  16149. var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
  16150. while (first > 0 && !lineWidgets[first])
  16151. first--;
  16152. this.firstRow = config.firstRow;
  16153. this.lastRow = config.lastRow;
  16154. renderer.$cursorLayer.config = config;
  16155. for (var i = first; i <= last; i++) {
  16156. var w = lineWidgets[i];
  16157. if (!w || !w.el) continue;
  16158. if (w.hidden) {
  16159. w.el.style.top = -100 - (w.pixelHeight || 0) + "px";
  16160. continue;
  16161. }
  16162. if (!w._inDocument) {
  16163. w._inDocument = true;
  16164. renderer.container.appendChild(w.el);
  16165. }
  16166. var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
  16167. if (!w.coverLine)
  16168. top += config.lineHeight * this.session.getRowLineCount(w.row);
  16169. w.el.style.top = top - config.offset + "px";
  16170. var left = w.coverGutter ? 0 : renderer.gutterWidth;
  16171. if (!w.fixedWidth)
  16172. left -= renderer.scrollLeft;
  16173. w.el.style.left = left + "px";
  16174. if (w.fullWidth && w.screenWidth) {
  16175. w.el.style.minWidth = config.width + 2 * config.padding + "px";
  16176. }
  16177. if (w.fixedWidth) {
  16178. w.el.style.right = renderer.scrollBar.getWidth() + "px";
  16179. } else {
  16180. w.el.style.right = "";
  16181. }
  16182. }
  16183. };
  16184. }).call(LineWidgets.prototype);
  16185. exports.LineWidgets = LineWidgets;
  16186. });
  16187. ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
  16188. "use strict";
  16189. var LineWidgets = require("../line_widgets").LineWidgets;
  16190. var dom = require("../lib/dom");
  16191. var Range = require("../range").Range;
  16192. function binarySearch(array, needle, comparator) {
  16193. var first = 0;
  16194. var last = array.length - 1;
  16195. while (first <= last) {
  16196. var mid = (first + last) >> 1;
  16197. var c = comparator(needle, array[mid]);
  16198. if (c > 0)
  16199. first = mid + 1;
  16200. else if (c < 0)
  16201. last = mid - 1;
  16202. else
  16203. return mid;
  16204. }
  16205. return -(first + 1);
  16206. }
  16207. function findAnnotations(session, row, dir) {
  16208. var annotations = session.getAnnotations().sort(Range.comparePoints);
  16209. if (!annotations.length)
  16210. return;
  16211. var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
  16212. if (i < 0)
  16213. i = -i - 1;
  16214. if (i >= annotations.length)
  16215. i = dir > 0 ? 0 : annotations.length - 1;
  16216. else if (i === 0 && dir < 0)
  16217. i = annotations.length - 1;
  16218. var annotation = annotations[i];
  16219. if (!annotation || !dir)
  16220. return;
  16221. if (annotation.row === row) {
  16222. do {
  16223. annotation = annotations[i += dir];
  16224. } while (annotation && annotation.row === row);
  16225. if (!annotation)
  16226. return annotations.slice();
  16227. }
  16228. var matched = [];
  16229. row = annotation.row;
  16230. do {
  16231. matched[dir < 0 ? "unshift" : "push"](annotation);
  16232. annotation = annotations[i += dir];
  16233. } while (annotation && annotation.row == row);
  16234. return matched.length && matched;
  16235. }
  16236. exports.showErrorMarker = function(editor, dir) {
  16237. var session = editor.session;
  16238. if (!session.widgetManager) {
  16239. session.widgetManager = new LineWidgets(session);
  16240. session.widgetManager.attach(editor);
  16241. }
  16242. var pos = editor.getCursorPosition();
  16243. var row = pos.row;
  16244. var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function(w) {
  16245. return w.type == "errorMarker";
  16246. })[0];
  16247. if (oldWidget) {
  16248. oldWidget.destroy();
  16249. } else {
  16250. row -= dir;
  16251. }
  16252. var annotations = findAnnotations(session, row, dir);
  16253. var gutterAnno;
  16254. if (annotations) {
  16255. var annotation = annotations[0];
  16256. pos.column = (annotation.pos && typeof annotation.column != "number"
  16257. ? annotation.pos.sc
  16258. : annotation.column) || 0;
  16259. pos.row = annotation.row;
  16260. gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
  16261. } else if (oldWidget) {
  16262. return;
  16263. } else {
  16264. gutterAnno = {
  16265. text: ["Looks good!"],
  16266. className: "ace_ok"
  16267. };
  16268. }
  16269. editor.session.unfold(pos.row);
  16270. editor.selection.moveToPosition(pos);
  16271. var w = {
  16272. row: pos.row,
  16273. fixedWidth: true,
  16274. coverGutter: true,
  16275. el: dom.createElement("div"),
  16276. type: "errorMarker"
  16277. };
  16278. var el = w.el.appendChild(dom.createElement("div"));
  16279. var arrow = w.el.appendChild(dom.createElement("div"));
  16280. arrow.className = "error_widget_arrow " + gutterAnno.className;
  16281. var left = editor.renderer.$cursorLayer
  16282. .getPixelPosition(pos).left;
  16283. arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
  16284. w.el.className = "error_widget_wrapper";
  16285. el.className = "error_widget " + gutterAnno.className;
  16286. el.innerHTML = gutterAnno.text.join("<br>");
  16287. el.appendChild(dom.createElement("div"));
  16288. var kb = function(_, hashId, keyString) {
  16289. if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
  16290. w.destroy();
  16291. return {command: "null"};
  16292. }
  16293. };
  16294. w.destroy = function() {
  16295. if (editor.$mouseHandler.isMousePressed)
  16296. return;
  16297. editor.keyBinding.removeKeyboardHandler(kb);
  16298. session.widgetManager.removeLineWidget(w);
  16299. editor.off("changeSelection", w.destroy);
  16300. editor.off("changeSession", w.destroy);
  16301. editor.off("mouseup", w.destroy);
  16302. editor.off("change", w.destroy);
  16303. };
  16304. editor.keyBinding.addKeyboardHandler(kb);
  16305. editor.on("changeSelection", w.destroy);
  16306. editor.on("changeSession", w.destroy);
  16307. editor.on("mouseup", w.destroy);
  16308. editor.on("change", w.destroy);
  16309. editor.session.widgetManager.addLineWidget(w);
  16310. w.el.onmousedown = editor.focus.bind(editor);
  16311. editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
  16312. };
  16313. dom.importCssString("\
  16314. .error_widget_wrapper {\
  16315. background: inherit;\
  16316. color: inherit;\
  16317. border:none\
  16318. }\
  16319. .error_widget {\
  16320. border-top: solid 2px;\
  16321. border-bottom: solid 2px;\
  16322. margin: 5px 0;\
  16323. padding: 10px 40px;\
  16324. white-space: pre-wrap;\
  16325. }\
  16326. .error_widget.ace_error, .error_widget_arrow.ace_error{\
  16327. border-color: #ff5a5a\
  16328. }\
  16329. .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
  16330. border-color: #F1D817\
  16331. }\
  16332. .error_widget.ace_info, .error_widget_arrow.ace_info{\
  16333. border-color: #5a5a5a\
  16334. }\
  16335. .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
  16336. border-color: #5aaa5a\
  16337. }\
  16338. .error_widget_arrow {\
  16339. position: absolute;\
  16340. border: solid 5px;\
  16341. border-top-color: transparent!important;\
  16342. border-right-color: transparent!important;\
  16343. border-left-color: transparent!important;\
  16344. top: -5px;\
  16345. }\
  16346. ", "");
  16347. });
  16348. 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) {
  16349. "use strict";
  16350. require("./lib/fixoldbrowsers");
  16351. var dom = require("./lib/dom");
  16352. var event = require("./lib/event");
  16353. var Editor = require("./editor").Editor;
  16354. var EditSession = require("./edit_session").EditSession;
  16355. var UndoManager = require("./undomanager").UndoManager;
  16356. var Renderer = require("./virtual_renderer").VirtualRenderer;
  16357. require("./worker/worker_client");
  16358. require("./keyboard/hash_handler");
  16359. require("./placeholder");
  16360. require("./multi_select");
  16361. require("./mode/folding/fold_mode");
  16362. require("./theme/textmate");
  16363. require("./ext/error_marker");
  16364. exports.config = require("./config");
  16365. exports.require = require;
  16366. exports.edit = function(el) {
  16367. if (typeof el == "string") {
  16368. var _id = el;
  16369. el = document.getElementById(_id);
  16370. if (!el)
  16371. throw new Error("ace.edit can't find div #" + _id);
  16372. }
  16373. if (el && el.env && el.env.editor instanceof Editor)
  16374. return el.env.editor;
  16375. var value = "";
  16376. if (el && /input|textarea/i.test(el.tagName)) {
  16377. var oldNode = el;
  16378. value = oldNode.value;
  16379. el = dom.createElement("pre");
  16380. oldNode.parentNode.replaceChild(el, oldNode);
  16381. } else if (el) {
  16382. value = dom.getInnerText(el);
  16383. el.innerHTML = "";
  16384. }
  16385. var doc = exports.createEditSession(value);
  16386. var editor = new Editor(new Renderer(el));
  16387. editor.setSession(doc);
  16388. var env = {
  16389. document: doc,
  16390. editor: editor,
  16391. onResize: editor.resize.bind(editor, null)
  16392. };
  16393. if (oldNode) env.textarea = oldNode;
  16394. event.addListener(window, "resize", env.onResize);
  16395. editor.on("destroy", function() {
  16396. event.removeListener(window, "resize", env.onResize);
  16397. env.editor.container.env = null; // prevent memory leak on old ie
  16398. });
  16399. editor.container.env = editor.env = env;
  16400. return editor;
  16401. };
  16402. exports.createEditSession = function(text, mode) {
  16403. var doc = new EditSession(text, mode);
  16404. doc.setUndoManager(new UndoManager());
  16405. return doc;
  16406. }
  16407. exports.EditSession = EditSession;
  16408. exports.UndoManager = UndoManager;
  16409. exports.version = "1.2.3";
  16410. });
  16411. (function() {
  16412. ace.require(["ace/ace"], function(a) {
  16413. a && a.config.init(true);
  16414. if (!window.ace)
  16415. window.ace = a;
  16416. for (var key in a) if (a.hasOwnProperty(key))
  16417. window.ace[key] = a[key];
  16418. });
  16419. })();