ace.js 646 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069
  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 (e.getModifierState && (e.getModifierState("OS") || e.getModifierState("Win")))
  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. pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1;
  1488. var result = normalizeCommandKeys(callback, e, e.keyCode);
  1489. lastDefaultPrevented = e.defaultPrevented;
  1490. return result;
  1491. });
  1492. addListener(el, "keypress", function(e) {
  1493. if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  1494. exports.stopEvent(e);
  1495. lastDefaultPrevented = null;
  1496. }
  1497. });
  1498. addListener(el, "keyup", function(e) {
  1499. pressedKeys[e.keyCode] = null;
  1500. });
  1501. if (!pressedKeys) {
  1502. resetPressedKeys();
  1503. addListener(window, "focus", resetPressedKeys);
  1504. }
  1505. }
  1506. };
  1507. function resetPressedKeys() {
  1508. pressedKeys = Object.create(null);
  1509. }
  1510. if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
  1511. var postMessageId = 1;
  1512. exports.nextTick = function(callback, win) {
  1513. win = win || window;
  1514. var messageName = "zero-timeout-message-" + postMessageId;
  1515. exports.addListener(win, "message", function listener(e) {
  1516. if (e.data == messageName) {
  1517. exports.stopPropagation(e);
  1518. exports.removeListener(win, "message", listener);
  1519. callback();
  1520. }
  1521. });
  1522. win.postMessage(messageName, "*");
  1523. };
  1524. }
  1525. exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
  1526. || window.mozRequestAnimationFrame
  1527. || window.webkitRequestAnimationFrame
  1528. || window.msRequestAnimationFrame
  1529. || window.oRequestAnimationFrame);
  1530. if (exports.nextFrame)
  1531. exports.nextFrame = exports.nextFrame.bind(window);
  1532. else
  1533. exports.nextFrame = function(callback) {
  1534. setTimeout(callback, 17);
  1535. };
  1536. });
  1537. ace.define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
  1538. "use strict";
  1539. exports.last = function(a) {
  1540. return a[a.length - 1];
  1541. };
  1542. exports.stringReverse = function(string) {
  1543. return string.split("").reverse().join("");
  1544. };
  1545. exports.stringRepeat = function (string, count) {
  1546. var result = '';
  1547. while (count > 0) {
  1548. if (count & 1)
  1549. result += string;
  1550. if (count >>= 1)
  1551. string += string;
  1552. }
  1553. return result;
  1554. };
  1555. var trimBeginRegexp = /^\s\s*/;
  1556. var trimEndRegexp = /\s\s*$/;
  1557. exports.stringTrimLeft = function (string) {
  1558. return string.replace(trimBeginRegexp, '');
  1559. };
  1560. exports.stringTrimRight = function (string) {
  1561. return string.replace(trimEndRegexp, '');
  1562. };
  1563. exports.copyObject = function(obj) {
  1564. var copy = {};
  1565. for (var key in obj) {
  1566. copy[key] = obj[key];
  1567. }
  1568. return copy;
  1569. };
  1570. exports.copyArray = function(array){
  1571. var copy = [];
  1572. for (var i=0, l=array.length; i<l; i++) {
  1573. if (array[i] && typeof array[i] == "object")
  1574. copy[i] = this.copyObject(array[i]);
  1575. else
  1576. copy[i] = array[i];
  1577. }
  1578. return copy;
  1579. };
  1580. exports.deepCopy = function deepCopy(obj) {
  1581. if (typeof obj !== "object" || !obj)
  1582. return obj;
  1583. var copy;
  1584. if (Array.isArray(obj)) {
  1585. copy = [];
  1586. for (var key = 0; key < obj.length; key++) {
  1587. copy[key] = deepCopy(obj[key]);
  1588. }
  1589. return copy;
  1590. }
  1591. if (Object.prototype.toString.call(obj) !== "[object Object]")
  1592. return obj;
  1593. copy = {};
  1594. for (var key in obj)
  1595. copy[key] = deepCopy(obj[key]);
  1596. return copy;
  1597. };
  1598. exports.arrayToMap = function(arr) {
  1599. var map = {};
  1600. for (var i=0; i<arr.length; i++) {
  1601. map[arr[i]] = 1;
  1602. }
  1603. return map;
  1604. };
  1605. exports.createMap = function(props) {
  1606. var map = Object.create(null);
  1607. for (var i in props) {
  1608. map[i] = props[i];
  1609. }
  1610. return map;
  1611. };
  1612. exports.arrayRemove = function(array, value) {
  1613. for (var i = 0; i <= array.length; i++) {
  1614. if (value === array[i]) {
  1615. array.splice(i, 1);
  1616. }
  1617. }
  1618. };
  1619. exports.escapeRegExp = function(str) {
  1620. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1621. };
  1622. exports.escapeHTML = function(str) {
  1623. return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1624. };
  1625. exports.getMatchOffsets = function(string, regExp) {
  1626. var matches = [];
  1627. string.replace(regExp, function(str) {
  1628. matches.push({
  1629. offset: arguments[arguments.length-2],
  1630. length: str.length
  1631. });
  1632. });
  1633. return matches;
  1634. };
  1635. exports.deferredCall = function(fcn) {
  1636. var timer = null;
  1637. var callback = function() {
  1638. timer = null;
  1639. fcn();
  1640. };
  1641. var deferred = function(timeout) {
  1642. deferred.cancel();
  1643. timer = setTimeout(callback, timeout || 0);
  1644. return deferred;
  1645. };
  1646. deferred.schedule = deferred;
  1647. deferred.call = function() {
  1648. this.cancel();
  1649. fcn();
  1650. return deferred;
  1651. };
  1652. deferred.cancel = function() {
  1653. clearTimeout(timer);
  1654. timer = null;
  1655. return deferred;
  1656. };
  1657. deferred.isPending = function() {
  1658. return timer;
  1659. };
  1660. return deferred;
  1661. };
  1662. exports.delayedCall = function(fcn, defaultTimeout) {
  1663. var timer = null;
  1664. var callback = function() {
  1665. timer = null;
  1666. fcn();
  1667. };
  1668. var _self = function(timeout) {
  1669. if (timer == null)
  1670. timer = setTimeout(callback, timeout || defaultTimeout);
  1671. };
  1672. _self.delay = function(timeout) {
  1673. timer && clearTimeout(timer);
  1674. timer = setTimeout(callback, timeout || defaultTimeout);
  1675. };
  1676. _self.schedule = _self;
  1677. _self.call = function() {
  1678. this.cancel();
  1679. fcn();
  1680. };
  1681. _self.cancel = function() {
  1682. timer && clearTimeout(timer);
  1683. timer = null;
  1684. };
  1685. _self.isPending = function() {
  1686. return timer;
  1687. };
  1688. return _self;
  1689. };
  1690. });
  1691. ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"], function(require, exports, module) {
  1692. "use strict";
  1693. var event = require("../lib/event");
  1694. var useragent = require("../lib/useragent");
  1695. var dom = require("../lib/dom");
  1696. var lang = require("../lib/lang");
  1697. var BROKEN_SETDATA = useragent.isChrome < 18;
  1698. var USE_IE_MIME_TYPE = useragent.isIE;
  1699. var TextInput = function(parentNode, host) {
  1700. var text = dom.createElement("textarea");
  1701. text.className = "ace_text-input";
  1702. if (useragent.isTouchPad)
  1703. text.setAttribute("x-palm-disable-auto-cap", true);
  1704. text.setAttribute("wrap", "off");
  1705. text.setAttribute("autocorrect", "off");
  1706. text.setAttribute("autocapitalize", "off");
  1707. text.setAttribute("spellcheck", false);
  1708. text.style.opacity = "0";
  1709. if (useragent.isOldIE) text.style.top = "-1000px";
  1710. parentNode.insertBefore(text, parentNode.firstChild);
  1711. var PLACEHOLDER = "\x01\x01";
  1712. var copied = false;
  1713. var pasted = false;
  1714. var inComposition = false;
  1715. var tempStyle = '';
  1716. var isSelectionEmpty = true;
  1717. try { var isFocused = document.activeElement === text; } catch(e) {}
  1718. event.addListener(text, "blur", function(e) {
  1719. host.onBlur(e);
  1720. isFocused = false;
  1721. });
  1722. event.addListener(text, "focus", function(e) {
  1723. isFocused = true;
  1724. host.onFocus(e);
  1725. resetSelection();
  1726. });
  1727. this.focus = function() {
  1728. if (tempStyle) return text.focus();
  1729. var top = text.style.top;
  1730. text.style.position = "fixed";
  1731. text.style.top = "0px";
  1732. text.focus();
  1733. setTimeout(function() {
  1734. text.style.position = "";
  1735. if (text.style.top == "0px")
  1736. text.style.top = top;
  1737. }, 0);
  1738. };
  1739. this.blur = function() {
  1740. text.blur();
  1741. };
  1742. this.isFocused = function() {
  1743. return isFocused;
  1744. };
  1745. var syncSelection = lang.delayedCall(function() {
  1746. isFocused && resetSelection(isSelectionEmpty);
  1747. });
  1748. var syncValue = lang.delayedCall(function() {
  1749. if (!inComposition) {
  1750. text.value = PLACEHOLDER;
  1751. isFocused && resetSelection();
  1752. }
  1753. });
  1754. function resetSelection(isEmpty) {
  1755. if (inComposition)
  1756. return;
  1757. inComposition = true;
  1758. if (inputHandler) {
  1759. selectionStart = 0;
  1760. selectionEnd = isEmpty ? 0 : text.value.length - 1;
  1761. } else {
  1762. var selectionStart = isEmpty ? 2 : 1;
  1763. var selectionEnd = 2;
  1764. }
  1765. try {
  1766. text.setSelectionRange(selectionStart, selectionEnd);
  1767. } catch(e){}
  1768. inComposition = false;
  1769. }
  1770. function resetValue() {
  1771. if (inComposition)
  1772. return;
  1773. text.value = PLACEHOLDER;
  1774. if (useragent.isWebKit)
  1775. syncValue.schedule();
  1776. }
  1777. useragent.isWebKit || host.addEventListener('changeSelection', function() {
  1778. if (host.selection.isEmpty() != isSelectionEmpty) {
  1779. isSelectionEmpty = !isSelectionEmpty;
  1780. syncSelection.schedule();
  1781. }
  1782. });
  1783. resetValue();
  1784. if (isFocused)
  1785. host.onFocus();
  1786. var isAllSelected = function(text) {
  1787. return text.selectionStart === 0 && text.selectionEnd === text.value.length;
  1788. };
  1789. if (!text.setSelectionRange && text.createTextRange) {
  1790. text.setSelectionRange = function(selectionStart, selectionEnd) {
  1791. var range = this.createTextRange();
  1792. range.collapse(true);
  1793. range.moveStart('character', selectionStart);
  1794. range.moveEnd('character', selectionEnd);
  1795. range.select();
  1796. };
  1797. isAllSelected = function(text) {
  1798. try {
  1799. var range = text.ownerDocument.selection.createRange();
  1800. }catch(e) {}
  1801. if (!range || range.parentElement() != text) return false;
  1802. return range.text == text.value;
  1803. }
  1804. }
  1805. if (useragent.isOldIE) {
  1806. var inPropertyChange = false;
  1807. var onPropertyChange = function(e){
  1808. if (inPropertyChange)
  1809. return;
  1810. var data = text.value;
  1811. if (inComposition || !data || data == PLACEHOLDER)
  1812. return;
  1813. if (e && data == PLACEHOLDER[0])
  1814. return syncProperty.schedule();
  1815. sendText(data);
  1816. inPropertyChange = true;
  1817. resetValue();
  1818. inPropertyChange = false;
  1819. };
  1820. var syncProperty = lang.delayedCall(onPropertyChange);
  1821. event.addListener(text, "propertychange", onPropertyChange);
  1822. var keytable = { 13:1, 27:1 };
  1823. event.addListener(text, "keyup", function (e) {
  1824. if (inComposition && (!text.value || keytable[e.keyCode]))
  1825. setTimeout(onCompositionEnd, 0);
  1826. if ((text.value.charCodeAt(0)||0) < 129) {
  1827. return syncProperty.call();
  1828. }
  1829. inComposition ? onCompositionUpdate() : onCompositionStart();
  1830. });
  1831. event.addListener(text, "keydown", function (e) {
  1832. syncProperty.schedule(50);
  1833. });
  1834. }
  1835. var onSelect = function(e) {
  1836. if (copied) {
  1837. copied = false;
  1838. } else if (isAllSelected(text)) {
  1839. host.selectAll();
  1840. resetSelection();
  1841. } else if (inputHandler) {
  1842. resetSelection(host.selection.isEmpty());
  1843. }
  1844. };
  1845. var inputHandler = null;
  1846. this.setInputHandler = function(cb) {inputHandler = cb};
  1847. this.getInputHandler = function() {return inputHandler};
  1848. var afterContextMenu = false;
  1849. var sendText = function(data) {
  1850. if (inputHandler) {
  1851. data = inputHandler(data);
  1852. inputHandler = null;
  1853. }
  1854. if (pasted) {
  1855. resetSelection();
  1856. if (data)
  1857. host.onPaste(data);
  1858. pasted = false;
  1859. } else if (data == PLACEHOLDER.charAt(0)) {
  1860. if (afterContextMenu)
  1861. host.execCommand("del", {source: "ace"});
  1862. else // some versions of android do not fire keydown when pressing backspace
  1863. host.execCommand("backspace", {source: "ace"});
  1864. } else {
  1865. if (data.substring(0, 2) == PLACEHOLDER)
  1866. data = data.substr(2);
  1867. else if (data.charAt(0) == PLACEHOLDER.charAt(0))
  1868. data = data.substr(1);
  1869. else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1870. data = data.slice(0, -1);
  1871. if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
  1872. data = data.slice(0, -1);
  1873. if (data)
  1874. host.onTextInput(data);
  1875. }
  1876. if (afterContextMenu)
  1877. afterContextMenu = false;
  1878. };
  1879. var onInput = function(e) {
  1880. if (inComposition)
  1881. return;
  1882. var data = text.value;
  1883. sendText(data);
  1884. resetValue();
  1885. };
  1886. var handleClipboardData = function(e, data, forceIEMime) {
  1887. var clipboardData = e.clipboardData || window.clipboardData;
  1888. if (!clipboardData || BROKEN_SETDATA)
  1889. return;
  1890. var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain";
  1891. try {
  1892. if (data) {
  1893. return clipboardData.setData(mime, data) !== false;
  1894. } else {
  1895. return clipboardData.getData(mime);
  1896. }
  1897. } catch(e) {
  1898. if (!forceIEMime)
  1899. return handleClipboardData(e, data, true);
  1900. }
  1901. };
  1902. var doCopy = function(e, isCut) {
  1903. var data = host.getCopyText();
  1904. if (!data)
  1905. return event.preventDefault(e);
  1906. if (handleClipboardData(e, data)) {
  1907. isCut ? host.onCut() : host.onCopy();
  1908. event.preventDefault(e);
  1909. } else {
  1910. copied = true;
  1911. text.value = data;
  1912. text.select();
  1913. setTimeout(function(){
  1914. copied = false;
  1915. resetValue();
  1916. resetSelection();
  1917. isCut ? host.onCut() : host.onCopy();
  1918. });
  1919. }
  1920. };
  1921. var onCut = function(e) {
  1922. doCopy(e, true);
  1923. };
  1924. var onCopy = function(e) {
  1925. doCopy(e, false);
  1926. };
  1927. var onPaste = function(e) {
  1928. var data = handleClipboardData(e);
  1929. if (typeof data == "string") {
  1930. if (data)
  1931. host.onPaste(data, e);
  1932. if (useragent.isIE)
  1933. setTimeout(resetSelection);
  1934. event.preventDefault(e);
  1935. }
  1936. else {
  1937. text.value = "";
  1938. pasted = true;
  1939. }
  1940. };
  1941. event.addCommandKeyListener(text, host.onCommandKey.bind(host));
  1942. event.addListener(text, "select", onSelect);
  1943. event.addListener(text, "input", onInput);
  1944. event.addListener(text, "cut", onCut);
  1945. event.addListener(text, "copy", onCopy);
  1946. event.addListener(text, "paste", onPaste);
  1947. if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
  1948. event.addListener(parentNode, "keydown", function(e) {
  1949. if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
  1950. return;
  1951. switch (e.keyCode) {
  1952. case 67:
  1953. onCopy(e);
  1954. break;
  1955. case 86:
  1956. onPaste(e);
  1957. break;
  1958. case 88:
  1959. onCut(e);
  1960. break;
  1961. }
  1962. });
  1963. }
  1964. var onCompositionStart = function(e) {
  1965. if (inComposition || !host.onCompositionStart || host.$readOnly)
  1966. return;
  1967. inComposition = {};
  1968. inComposition.canUndo = host.session.$undoManager;
  1969. host.onCompositionStart();
  1970. setTimeout(onCompositionUpdate, 0);
  1971. host.on("mousedown", onCompositionEnd);
  1972. if (inComposition.canUndo && !host.selection.isEmpty()) {
  1973. host.insert("");
  1974. host.session.markUndoGroup();
  1975. host.selection.clearSelection();
  1976. }
  1977. host.session.markUndoGroup();
  1978. };
  1979. var onCompositionUpdate = function() {
  1980. if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
  1981. return;
  1982. var val = text.value.replace(/\x01/g, "");
  1983. if (inComposition.lastValue === val) return;
  1984. host.onCompositionUpdate(val);
  1985. if (inComposition.lastValue)
  1986. host.undo();
  1987. if (inComposition.canUndo)
  1988. inComposition.lastValue = val;
  1989. if (inComposition.lastValue) {
  1990. var r = host.selection.getRange();
  1991. host.insert(inComposition.lastValue);
  1992. host.session.markUndoGroup();
  1993. inComposition.range = host.selection.getRange();
  1994. host.selection.setRange(r);
  1995. host.selection.clearSelection();
  1996. }
  1997. };
  1998. var onCompositionEnd = function(e) {
  1999. if (!host.onCompositionEnd || host.$readOnly) return;
  2000. var c = inComposition;
  2001. inComposition = false;
  2002. var timer = setTimeout(function() {
  2003. timer = null;
  2004. var str = text.value.replace(/\x01/g, "");
  2005. if (inComposition)
  2006. return;
  2007. else if (str == c.lastValue)
  2008. resetValue();
  2009. else if (!c.lastValue && str) {
  2010. resetValue();
  2011. sendText(str);
  2012. }
  2013. });
  2014. inputHandler = function compositionInputHandler(str) {
  2015. if (timer)
  2016. clearTimeout(timer);
  2017. str = str.replace(/\x01/g, "");
  2018. if (str == c.lastValue)
  2019. return "";
  2020. if (c.lastValue && timer)
  2021. host.undo();
  2022. return str;
  2023. };
  2024. host.onCompositionEnd();
  2025. host.removeListener("mousedown", onCompositionEnd);
  2026. if (e.type == "compositionend" && c.range) {
  2027. host.selection.setRange(c.range);
  2028. }
  2029. if (useragent.isChrome && useragent.isChrome >= 53) {
  2030. onInput();
  2031. }
  2032. };
  2033. var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
  2034. event.addListener(text, "compositionstart", onCompositionStart);
  2035. if (useragent.isGecko) {
  2036. event.addListener(text, "text", function(){syncComposition.schedule()});
  2037. } else {
  2038. event.addListener(text, "keyup", function(){syncComposition.schedule()});
  2039. event.addListener(text, "keydown", function(){syncComposition.schedule()});
  2040. }
  2041. event.addListener(text, "compositionend", onCompositionEnd);
  2042. this.getElement = function() {
  2043. return text;
  2044. };
  2045. this.setReadOnly = function(readOnly) {
  2046. text.readOnly = readOnly;
  2047. };
  2048. this.onContextMenu = function(e) {
  2049. afterContextMenu = true;
  2050. resetSelection(host.selection.isEmpty());
  2051. host._emit("nativecontextmenu", {target: host, domEvent: e});
  2052. this.moveToMouse(e, true);
  2053. };
  2054. this.moveToMouse = function(e, bringToFront) {
  2055. if (!bringToFront && useragent.isOldIE)
  2056. return;
  2057. if (!tempStyle)
  2058. tempStyle = text.style.cssText;
  2059. text.style.cssText = (bringToFront ? "z-index:100000;" : "")
  2060. + "height:" + text.style.height + ";"
  2061. + (useragent.isIE ? "opacity:0.1;" : "");
  2062. var rect = host.container.getBoundingClientRect();
  2063. var style = dom.computedStyle(host.container);
  2064. var top = rect.top + (parseInt(style.borderTopWidth) || 0);
  2065. var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
  2066. var maxTop = rect.bottom - top - text.clientHeight -2;
  2067. var move = function(e) {
  2068. text.style.left = e.clientX - left - 2 + "px";
  2069. text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
  2070. };
  2071. move(e);
  2072. if (e.type != "mousedown")
  2073. return;
  2074. if (host.renderer.$keepTextAreaAtCursor)
  2075. host.renderer.$keepTextAreaAtCursor = null;
  2076. clearTimeout(closeTimeout);
  2077. if (useragent.isWin && !useragent.isOldIE)
  2078. event.capture(host.container, move, onContextMenuClose);
  2079. };
  2080. this.onContextMenuClose = onContextMenuClose;
  2081. var closeTimeout;
  2082. function onContextMenuClose() {
  2083. clearTimeout(closeTimeout);
  2084. closeTimeout = setTimeout(function () {
  2085. if (tempStyle) {
  2086. text.style.cssText = tempStyle;
  2087. tempStyle = '';
  2088. }
  2089. if (host.renderer.$keepTextAreaAtCursor == null) {
  2090. host.renderer.$keepTextAreaAtCursor = true;
  2091. host.renderer.$moveTextAreaToCursor();
  2092. }
  2093. }, useragent.isOldIE ? 200 : 0);
  2094. }
  2095. var onContextMenu = function(e) {
  2096. host.textInput.onContextMenu(e);
  2097. onContextMenuClose();
  2098. };
  2099. event.addListener(text, "mouseup", onContextMenu);
  2100. event.addListener(text, "mousedown", function(e) {
  2101. e.preventDefault();
  2102. onContextMenuClose();
  2103. });
  2104. event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
  2105. event.addListener(text, "contextmenu", onContextMenu);
  2106. };
  2107. exports.TextInput = TextInput;
  2108. });
  2109. ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2110. "use strict";
  2111. var dom = require("../lib/dom");
  2112. var event = require("../lib/event");
  2113. var useragent = require("../lib/useragent");
  2114. var DRAG_OFFSET = 0; // pixels
  2115. function DefaultHandlers(mouseHandler) {
  2116. mouseHandler.$clickSelection = null;
  2117. var editor = mouseHandler.editor;
  2118. editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
  2119. editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
  2120. editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
  2121. editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
  2122. editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
  2123. editor.setDefaultHandler("touchmove", this.onTouchMove.bind(mouseHandler));
  2124. var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
  2125. "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
  2126. exports.forEach(function(x) {
  2127. mouseHandler[x] = this[x];
  2128. }, this);
  2129. mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
  2130. mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
  2131. }
  2132. (function() {
  2133. this.onMouseDown = function(ev) {
  2134. var inSelection = ev.inSelection();
  2135. var pos = ev.getDocumentPosition();
  2136. this.mousedownEvent = ev;
  2137. var editor = this.editor;
  2138. var button = ev.getButton();
  2139. if (button !== 0) {
  2140. var selectionRange = editor.getSelectionRange();
  2141. var selectionEmpty = selectionRange.isEmpty();
  2142. editor.$blockScrolling++;
  2143. if (selectionEmpty || button == 1)
  2144. editor.selection.moveToPosition(pos);
  2145. editor.$blockScrolling--;
  2146. if (button == 2)
  2147. editor.textInput.onContextMenu(ev.domEvent);
  2148. return; // stopping event here breaks contextmenu on ff mac
  2149. }
  2150. this.mousedownEvent.time = Date.now();
  2151. if (inSelection && !editor.isFocused()) {
  2152. editor.focus();
  2153. if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
  2154. this.setState("focusWait");
  2155. this.captureMouse(ev);
  2156. return;
  2157. }
  2158. }
  2159. this.captureMouse(ev);
  2160. this.startSelect(pos, ev.domEvent._clicks > 1);
  2161. return ev.preventDefault();
  2162. };
  2163. this.startSelect = function(pos, waitForClickSelection) {
  2164. pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
  2165. var editor = this.editor;
  2166. editor.$blockScrolling++;
  2167. if (this.mousedownEvent.getShiftKey())
  2168. editor.selection.selectToPosition(pos);
  2169. else if (!waitForClickSelection)
  2170. editor.selection.moveToPosition(pos);
  2171. if (!waitForClickSelection)
  2172. this.select();
  2173. if (editor.renderer.scroller.setCapture) {
  2174. editor.renderer.scroller.setCapture();
  2175. }
  2176. editor.setStyle("ace_selecting");
  2177. this.setState("select");
  2178. editor.$blockScrolling--;
  2179. };
  2180. this.select = function() {
  2181. var anchor, editor = this.editor;
  2182. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2183. editor.$blockScrolling++;
  2184. if (this.$clickSelection) {
  2185. var cmp = this.$clickSelection.comparePoint(cursor);
  2186. if (cmp == -1) {
  2187. anchor = this.$clickSelection.end;
  2188. } else if (cmp == 1) {
  2189. anchor = this.$clickSelection.start;
  2190. } else {
  2191. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2192. cursor = orientedRange.cursor;
  2193. anchor = orientedRange.anchor;
  2194. }
  2195. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2196. }
  2197. editor.selection.selectToPosition(cursor);
  2198. editor.$blockScrolling--;
  2199. editor.renderer.scrollCursorIntoView();
  2200. };
  2201. this.extendSelectionBy = function(unitName) {
  2202. var anchor, editor = this.editor;
  2203. var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
  2204. var range = editor.selection[unitName](cursor.row, cursor.column);
  2205. editor.$blockScrolling++;
  2206. if (this.$clickSelection) {
  2207. var cmpStart = this.$clickSelection.comparePoint(range.start);
  2208. var cmpEnd = this.$clickSelection.comparePoint(range.end);
  2209. if (cmpStart == -1 && cmpEnd <= 0) {
  2210. anchor = this.$clickSelection.end;
  2211. if (range.end.row != cursor.row || range.end.column != cursor.column)
  2212. cursor = range.start;
  2213. } else if (cmpEnd == 1 && cmpStart >= 0) {
  2214. anchor = this.$clickSelection.start;
  2215. if (range.start.row != cursor.row || range.start.column != cursor.column)
  2216. cursor = range.end;
  2217. } else if (cmpStart == -1 && cmpEnd == 1) {
  2218. cursor = range.end;
  2219. anchor = range.start;
  2220. } else {
  2221. var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
  2222. cursor = orientedRange.cursor;
  2223. anchor = orientedRange.anchor;
  2224. }
  2225. editor.selection.setSelectionAnchor(anchor.row, anchor.column);
  2226. }
  2227. editor.selection.selectToPosition(cursor);
  2228. editor.$blockScrolling--;
  2229. editor.renderer.scrollCursorIntoView();
  2230. };
  2231. this.selectEnd =
  2232. this.selectAllEnd =
  2233. this.selectByWordsEnd =
  2234. this.selectByLinesEnd = function() {
  2235. this.$clickSelection = null;
  2236. this.editor.unsetStyle("ace_selecting");
  2237. if (this.editor.renderer.scroller.releaseCapture) {
  2238. this.editor.renderer.scroller.releaseCapture();
  2239. }
  2240. };
  2241. this.focusWait = function() {
  2242. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2243. var time = Date.now();
  2244. if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
  2245. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2246. };
  2247. this.onDoubleClick = function(ev) {
  2248. var pos = ev.getDocumentPosition();
  2249. var editor = this.editor;
  2250. var session = editor.session;
  2251. var range = session.getBracketRange(pos);
  2252. if (range) {
  2253. if (range.isEmpty()) {
  2254. range.start.column--;
  2255. range.end.column++;
  2256. }
  2257. this.setState("select");
  2258. } else {
  2259. range = editor.selection.getWordRange(pos.row, pos.column);
  2260. this.setState("selectByWords");
  2261. }
  2262. this.$clickSelection = range;
  2263. this.select();
  2264. };
  2265. this.onTripleClick = function(ev) {
  2266. var pos = ev.getDocumentPosition();
  2267. var editor = this.editor;
  2268. this.setState("selectByLines");
  2269. var range = editor.getSelectionRange();
  2270. if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
  2271. this.$clickSelection = editor.selection.getLineRange(range.start.row);
  2272. this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
  2273. } else {
  2274. this.$clickSelection = editor.selection.getLineRange(pos.row);
  2275. }
  2276. this.select();
  2277. };
  2278. this.onQuadClick = function(ev) {
  2279. var editor = this.editor;
  2280. editor.selectAll();
  2281. this.$clickSelection = editor.getSelectionRange();
  2282. this.setState("selectAll");
  2283. };
  2284. this.onMouseWheel = function(ev) {
  2285. if (ev.getAccelKey())
  2286. return;
  2287. if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
  2288. ev.wheelX = ev.wheelY;
  2289. ev.wheelY = 0;
  2290. }
  2291. var t = ev.domEvent.timeStamp;
  2292. var dt = t - (this.$lastScrollTime||0);
  2293. var editor = this.editor;
  2294. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2295. if (isScrolable || dt < 200) {
  2296. this.$lastScrollTime = t;
  2297. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2298. return ev.stop();
  2299. }
  2300. };
  2301. this.onTouchMove = function (ev) {
  2302. var t = ev.domEvent.timeStamp;
  2303. var dt = t - (this.$lastScrollTime || 0);
  2304. var editor = this.editor;
  2305. var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2306. if (isScrolable || dt < 200) {
  2307. this.$lastScrollTime = t;
  2308. editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
  2309. return ev.stop();
  2310. }
  2311. };
  2312. }).call(DefaultHandlers.prototype);
  2313. exports.DefaultHandlers = DefaultHandlers;
  2314. function calcDistance(ax, ay, bx, by) {
  2315. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2316. }
  2317. function calcRangeOrientation(range, cursor) {
  2318. if (range.start.row == range.end.row)
  2319. var cmp = 2 * cursor.column - range.start.column - range.end.column;
  2320. else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
  2321. var cmp = cursor.column - 4;
  2322. else
  2323. var cmp = 2 * cursor.row - range.start.row - range.end.row;
  2324. if (cmp < 0)
  2325. return {cursor: range.start, anchor: range.end};
  2326. else
  2327. return {cursor: range.end, anchor: range.start};
  2328. }
  2329. });
  2330. ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
  2331. "use strict";
  2332. var oop = require("./lib/oop");
  2333. var dom = require("./lib/dom");
  2334. function Tooltip (parentNode) {
  2335. this.isOpen = false;
  2336. this.$element = null;
  2337. this.$parentNode = parentNode;
  2338. }
  2339. (function() {
  2340. this.$init = function() {
  2341. this.$element = dom.createElement("div");
  2342. this.$element.className = "ace_tooltip";
  2343. this.$element.style.display = "none";
  2344. this.$parentNode.appendChild(this.$element);
  2345. return this.$element;
  2346. };
  2347. this.getElement = function() {
  2348. return this.$element || this.$init();
  2349. };
  2350. this.setText = function(text) {
  2351. dom.setInnerText(this.getElement(), text);
  2352. };
  2353. this.setHtml = function(html) {
  2354. this.getElement().innerHTML = html;
  2355. };
  2356. this.setPosition = function(x, y) {
  2357. this.getElement().style.left = x + "px";
  2358. this.getElement().style.top = y + "px";
  2359. };
  2360. this.setClassName = function(className) {
  2361. dom.addCssClass(this.getElement(), className);
  2362. };
  2363. this.show = function(text, x, y) {
  2364. if (text != null)
  2365. this.setText(text);
  2366. if (x != null && y != null)
  2367. this.setPosition(x, y);
  2368. if (!this.isOpen) {
  2369. this.getElement().style.display = "block";
  2370. this.isOpen = true;
  2371. }
  2372. };
  2373. this.hide = function() {
  2374. if (this.isOpen) {
  2375. this.getElement().style.display = "none";
  2376. this.isOpen = false;
  2377. }
  2378. };
  2379. this.getHeight = function() {
  2380. return this.getElement().offsetHeight;
  2381. };
  2382. this.getWidth = function() {
  2383. return this.getElement().offsetWidth;
  2384. };
  2385. }).call(Tooltip.prototype);
  2386. exports.Tooltip = Tooltip;
  2387. });
  2388. 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) {
  2389. "use strict";
  2390. var dom = require("../lib/dom");
  2391. var oop = require("../lib/oop");
  2392. var event = require("../lib/event");
  2393. var Tooltip = require("../tooltip").Tooltip;
  2394. function GutterHandler(mouseHandler) {
  2395. var editor = mouseHandler.editor;
  2396. var gutter = editor.renderer.$gutterLayer;
  2397. var tooltip = new GutterTooltip(editor.container);
  2398. mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
  2399. if (!editor.isFocused() || e.getButton() != 0)
  2400. return;
  2401. var gutterRegion = gutter.getRegion(e);
  2402. if (gutterRegion == "foldWidgets")
  2403. return;
  2404. var row = e.getDocumentPosition().row;
  2405. var selection = editor.session.selection;
  2406. if (e.getShiftKey())
  2407. selection.selectTo(row, 0);
  2408. else {
  2409. if (e.domEvent.detail == 2) {
  2410. editor.selectAll();
  2411. return e.preventDefault();
  2412. }
  2413. mouseHandler.$clickSelection = editor.selection.getLineRange(row);
  2414. }
  2415. mouseHandler.setState("selectByLines");
  2416. mouseHandler.captureMouse(e);
  2417. return e.preventDefault();
  2418. });
  2419. var tooltipTimeout, mouseEvent, tooltipAnnotation;
  2420. function showTooltip() {
  2421. var row = mouseEvent.getDocumentPosition().row;
  2422. var annotation = gutter.$annotations[row];
  2423. if (!annotation)
  2424. return hideTooltip();
  2425. var maxRow = editor.session.getLength();
  2426. if (row == maxRow) {
  2427. var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
  2428. var pos = mouseEvent.$pos;
  2429. if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
  2430. return hideTooltip();
  2431. }
  2432. if (tooltipAnnotation == annotation)
  2433. return;
  2434. tooltipAnnotation = annotation.text.join("<br/>");
  2435. tooltip.setHtml(tooltipAnnotation);
  2436. tooltip.show();
  2437. editor._signal("showGutterTooltip", tooltip);
  2438. editor.on("mousewheel", hideTooltip);
  2439. if (mouseHandler.$tooltipFollowsMouse) {
  2440. moveTooltip(mouseEvent);
  2441. } else {
  2442. var gutterElement = mouseEvent.domEvent.target;
  2443. var rect = gutterElement.getBoundingClientRect();
  2444. var style = tooltip.getElement().style;
  2445. style.left = rect.right + "px";
  2446. style.top = rect.bottom + "px";
  2447. }
  2448. }
  2449. function hideTooltip() {
  2450. if (tooltipTimeout)
  2451. tooltipTimeout = clearTimeout(tooltipTimeout);
  2452. if (tooltipAnnotation) {
  2453. tooltip.hide();
  2454. tooltipAnnotation = null;
  2455. editor._signal("hideGutterTooltip", tooltip);
  2456. editor.removeEventListener("mousewheel", hideTooltip);
  2457. }
  2458. }
  2459. function moveTooltip(e) {
  2460. tooltip.setPosition(e.x, e.y);
  2461. }
  2462. mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
  2463. var target = e.domEvent.target || e.domEvent.srcElement;
  2464. if (dom.hasCssClass(target, "ace_fold-widget"))
  2465. return hideTooltip();
  2466. if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
  2467. moveTooltip(e);
  2468. mouseEvent = e;
  2469. if (tooltipTimeout)
  2470. return;
  2471. tooltipTimeout = setTimeout(function() {
  2472. tooltipTimeout = null;
  2473. if (mouseEvent && !mouseHandler.isMousePressed)
  2474. showTooltip();
  2475. else
  2476. hideTooltip();
  2477. }, 50);
  2478. });
  2479. event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
  2480. mouseEvent = null;
  2481. if (!tooltipAnnotation || tooltipTimeout)
  2482. return;
  2483. tooltipTimeout = setTimeout(function() {
  2484. tooltipTimeout = null;
  2485. hideTooltip();
  2486. }, 50);
  2487. });
  2488. editor.on("changeSession", hideTooltip);
  2489. }
  2490. function GutterTooltip(parentNode) {
  2491. Tooltip.call(this, parentNode);
  2492. }
  2493. oop.inherits(GutterTooltip, Tooltip);
  2494. (function(){
  2495. this.setPosition = function(x, y) {
  2496. var windowWidth = window.innerWidth || document.documentElement.clientWidth;
  2497. var windowHeight = window.innerHeight || document.documentElement.clientHeight;
  2498. var width = this.getWidth();
  2499. var height = this.getHeight();
  2500. x += 15;
  2501. y += 15;
  2502. if (x + width > windowWidth) {
  2503. x -= (x + width) - windowWidth;
  2504. }
  2505. if (y + height > windowHeight) {
  2506. y -= 20 + height;
  2507. }
  2508. Tooltip.prototype.setPosition.call(this, x, y);
  2509. };
  2510. }).call(GutterTooltip.prototype);
  2511. exports.GutterHandler = GutterHandler;
  2512. });
  2513. ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2514. "use strict";
  2515. var event = require("../lib/event");
  2516. var useragent = require("../lib/useragent");
  2517. var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
  2518. this.domEvent = domEvent;
  2519. this.editor = editor;
  2520. this.x = this.clientX = domEvent.clientX;
  2521. this.y = this.clientY = domEvent.clientY;
  2522. this.$pos = null;
  2523. this.$inSelection = null;
  2524. this.propagationStopped = false;
  2525. this.defaultPrevented = false;
  2526. };
  2527. (function() {
  2528. this.stopPropagation = function() {
  2529. event.stopPropagation(this.domEvent);
  2530. this.propagationStopped = true;
  2531. };
  2532. this.preventDefault = function() {
  2533. event.preventDefault(this.domEvent);
  2534. this.defaultPrevented = true;
  2535. };
  2536. this.stop = function() {
  2537. this.stopPropagation();
  2538. this.preventDefault();
  2539. };
  2540. this.getDocumentPosition = function() {
  2541. if (this.$pos)
  2542. return this.$pos;
  2543. this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
  2544. return this.$pos;
  2545. };
  2546. this.inSelection = function() {
  2547. if (this.$inSelection !== null)
  2548. return this.$inSelection;
  2549. var editor = this.editor;
  2550. var selectionRange = editor.getSelectionRange();
  2551. if (selectionRange.isEmpty())
  2552. this.$inSelection = false;
  2553. else {
  2554. var pos = this.getDocumentPosition();
  2555. this.$inSelection = selectionRange.contains(pos.row, pos.column);
  2556. }
  2557. return this.$inSelection;
  2558. };
  2559. this.getButton = function() {
  2560. return event.getButton(this.domEvent);
  2561. };
  2562. this.getShiftKey = function() {
  2563. return this.domEvent.shiftKey;
  2564. };
  2565. this.getAccelKey = useragent.isMac
  2566. ? function() { return this.domEvent.metaKey; }
  2567. : function() { return this.domEvent.ctrlKey; };
  2568. }).call(MouseEvent.prototype);
  2569. });
  2570. ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  2571. "use strict";
  2572. var dom = require("../lib/dom");
  2573. var event = require("../lib/event");
  2574. var useragent = require("../lib/useragent");
  2575. var AUTOSCROLL_DELAY = 200;
  2576. var SCROLL_CURSOR_DELAY = 200;
  2577. var SCROLL_CURSOR_HYSTERESIS = 5;
  2578. function DragdropHandler(mouseHandler) {
  2579. var editor = mouseHandler.editor;
  2580. var blankImage = dom.createElement("img");
  2581. blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  2582. if (useragent.isOpera)
  2583. blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
  2584. var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
  2585. exports.forEach(function(x) {
  2586. mouseHandler[x] = this[x];
  2587. }, this);
  2588. editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
  2589. var mouseTarget = editor.container;
  2590. var dragSelectionMarker, x, y;
  2591. var timerId, range;
  2592. var dragCursor, counter = 0;
  2593. var dragOperation;
  2594. var isInternal;
  2595. var autoScrollStartTime;
  2596. var cursorMovedTime;
  2597. var cursorPointOnCaretMoved;
  2598. this.onDragStart = function(e) {
  2599. if (this.cancelDrag || !mouseTarget.draggable) {
  2600. var self = this;
  2601. setTimeout(function(){
  2602. self.startSelect();
  2603. self.captureMouse(e);
  2604. }, 0);
  2605. return e.preventDefault();
  2606. }
  2607. range = editor.getSelectionRange();
  2608. var dataTransfer = e.dataTransfer;
  2609. dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
  2610. if (useragent.isOpera) {
  2611. editor.container.appendChild(blankImage);
  2612. blankImage.scrollTop = 0;
  2613. }
  2614. dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
  2615. if (useragent.isOpera) {
  2616. editor.container.removeChild(blankImage);
  2617. }
  2618. dataTransfer.clearData();
  2619. dataTransfer.setData("Text", editor.session.getTextRange());
  2620. isInternal = true;
  2621. this.setState("drag");
  2622. };
  2623. this.onDragEnd = function(e) {
  2624. mouseTarget.draggable = false;
  2625. isInternal = false;
  2626. this.setState(null);
  2627. if (!editor.getReadOnly()) {
  2628. var dropEffect = e.dataTransfer.dropEffect;
  2629. if (!dragOperation && dropEffect == "move")
  2630. editor.session.remove(editor.getSelectionRange());
  2631. editor.renderer.$cursorLayer.setBlinking(true);
  2632. }
  2633. this.editor.unsetStyle("ace_dragging");
  2634. this.editor.renderer.setCursorStyle("");
  2635. };
  2636. this.onDragEnter = function(e) {
  2637. if (editor.getReadOnly() || !canAccept(e.dataTransfer))
  2638. return;
  2639. x = e.clientX;
  2640. y = e.clientY;
  2641. if (!dragSelectionMarker)
  2642. addDragMarker();
  2643. counter++;
  2644. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2645. return event.preventDefault(e);
  2646. };
  2647. this.onDragOver = 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. }
  2656. if (onMouseMoveTimer !== null)
  2657. onMouseMoveTimer = null;
  2658. e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
  2659. return event.preventDefault(e);
  2660. };
  2661. this.onDragLeave = function(e) {
  2662. counter--;
  2663. if (counter <= 0 && dragSelectionMarker) {
  2664. clearDragMarker();
  2665. dragOperation = null;
  2666. return event.preventDefault(e);
  2667. }
  2668. };
  2669. this.onDrop = function(e) {
  2670. if (!dragCursor)
  2671. return;
  2672. var dataTransfer = e.dataTransfer;
  2673. if (isInternal) {
  2674. switch (dragOperation) {
  2675. case "move":
  2676. if (range.contains(dragCursor.row, dragCursor.column)) {
  2677. range = {
  2678. start: dragCursor,
  2679. end: dragCursor
  2680. };
  2681. } else {
  2682. range = editor.moveText(range, dragCursor);
  2683. }
  2684. break;
  2685. case "copy":
  2686. range = editor.moveText(range, dragCursor, true);
  2687. break;
  2688. }
  2689. } else {
  2690. var dropData = dataTransfer.getData('Text');
  2691. range = {
  2692. start: dragCursor,
  2693. end: editor.session.insert(dragCursor, dropData)
  2694. };
  2695. editor.focus();
  2696. dragOperation = null;
  2697. }
  2698. clearDragMarker();
  2699. return event.preventDefault(e);
  2700. };
  2701. event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
  2702. event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
  2703. event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
  2704. event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
  2705. event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
  2706. event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
  2707. function scrollCursorIntoView(cursor, prevCursor) {
  2708. var now = Date.now();
  2709. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2710. var hMovement = !prevCursor || cursor.column != prevCursor.column;
  2711. if (!cursorMovedTime || vMovement || hMovement) {
  2712. editor.$blockScrolling += 1;
  2713. editor.moveCursorToPosition(cursor);
  2714. editor.$blockScrolling -= 1;
  2715. cursorMovedTime = now;
  2716. cursorPointOnCaretMoved = {x: x, y: y};
  2717. } else {
  2718. var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
  2719. if (distance > SCROLL_CURSOR_HYSTERESIS) {
  2720. cursorMovedTime = null;
  2721. } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
  2722. editor.renderer.scrollCursorIntoView();
  2723. cursorMovedTime = null;
  2724. }
  2725. }
  2726. }
  2727. function autoScroll(cursor, prevCursor) {
  2728. var now = Date.now();
  2729. var lineHeight = editor.renderer.layerConfig.lineHeight;
  2730. var characterWidth = editor.renderer.layerConfig.characterWidth;
  2731. var editorRect = editor.renderer.scroller.getBoundingClientRect();
  2732. var offsets = {
  2733. x: {
  2734. left: x - editorRect.left,
  2735. right: editorRect.right - x
  2736. },
  2737. y: {
  2738. top: y - editorRect.top,
  2739. bottom: editorRect.bottom - y
  2740. }
  2741. };
  2742. var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
  2743. var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
  2744. var scrollCursor = {row: cursor.row, column: cursor.column};
  2745. if (nearestXOffset / characterWidth <= 2) {
  2746. scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
  2747. }
  2748. if (nearestYOffset / lineHeight <= 1) {
  2749. scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
  2750. }
  2751. var vScroll = cursor.row != scrollCursor.row;
  2752. var hScroll = cursor.column != scrollCursor.column;
  2753. var vMovement = !prevCursor || cursor.row != prevCursor.row;
  2754. if (vScroll || (hScroll && !vMovement)) {
  2755. if (!autoScrollStartTime)
  2756. autoScrollStartTime = now;
  2757. else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
  2758. editor.renderer.scrollCursorIntoView(scrollCursor);
  2759. } else {
  2760. autoScrollStartTime = null;
  2761. }
  2762. }
  2763. function onDragInterval() {
  2764. var prevCursor = dragCursor;
  2765. dragCursor = editor.renderer.screenToTextCoordinates(x, y);
  2766. scrollCursorIntoView(dragCursor, prevCursor);
  2767. autoScroll(dragCursor, prevCursor);
  2768. }
  2769. function addDragMarker() {
  2770. range = editor.selection.toOrientedRange();
  2771. dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
  2772. editor.clearSelection();
  2773. if (editor.isFocused())
  2774. editor.renderer.$cursorLayer.setBlinking(false);
  2775. clearInterval(timerId);
  2776. onDragInterval();
  2777. timerId = setInterval(onDragInterval, 20);
  2778. counter = 0;
  2779. event.addListener(document, "mousemove", onMouseMove);
  2780. }
  2781. function clearDragMarker() {
  2782. clearInterval(timerId);
  2783. editor.session.removeMarker(dragSelectionMarker);
  2784. dragSelectionMarker = null;
  2785. editor.$blockScrolling += 1;
  2786. editor.selection.fromOrientedRange(range);
  2787. editor.$blockScrolling -= 1;
  2788. if (editor.isFocused() && !isInternal)
  2789. editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
  2790. range = null;
  2791. dragCursor = null;
  2792. counter = 0;
  2793. autoScrollStartTime = null;
  2794. cursorMovedTime = null;
  2795. event.removeListener(document, "mousemove", onMouseMove);
  2796. }
  2797. var onMouseMoveTimer = null;
  2798. function onMouseMove() {
  2799. if (onMouseMoveTimer == null) {
  2800. onMouseMoveTimer = setTimeout(function() {
  2801. if (onMouseMoveTimer != null && dragSelectionMarker)
  2802. clearDragMarker();
  2803. }, 20);
  2804. }
  2805. }
  2806. function canAccept(dataTransfer) {
  2807. var types = dataTransfer.types;
  2808. return !types || Array.prototype.some.call(types, function(type) {
  2809. return type == 'text/plain' || type == 'Text';
  2810. });
  2811. }
  2812. function getDropEffect(e) {
  2813. var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
  2814. var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
  2815. var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
  2816. var effectAllowed = "uninitialized";
  2817. try {
  2818. effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
  2819. } catch (e) {}
  2820. var dropEffect = "none";
  2821. if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
  2822. dropEffect = "copy";
  2823. else if (moveAllowed.indexOf(effectAllowed) >= 0)
  2824. dropEffect = "move";
  2825. else if (copyAllowed.indexOf(effectAllowed) >= 0)
  2826. dropEffect = "copy";
  2827. return dropEffect;
  2828. }
  2829. }
  2830. (function() {
  2831. this.dragWait = function() {
  2832. var interval = Date.now() - this.mousedownEvent.time;
  2833. if (interval > this.editor.getDragDelay())
  2834. this.startDrag();
  2835. };
  2836. this.dragWaitEnd = function() {
  2837. var target = this.editor.container;
  2838. target.draggable = false;
  2839. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2840. this.selectEnd();
  2841. };
  2842. this.dragReadyEnd = function(e) {
  2843. this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
  2844. this.editor.unsetStyle("ace_dragging");
  2845. this.editor.renderer.setCursorStyle("");
  2846. this.dragWaitEnd();
  2847. };
  2848. this.startDrag = function(){
  2849. this.cancelDrag = false;
  2850. var editor = this.editor;
  2851. var target = editor.container;
  2852. target.draggable = true;
  2853. editor.renderer.$cursorLayer.setBlinking(false);
  2854. editor.setStyle("ace_dragging");
  2855. var cursorStyle = useragent.isWin ? "default" : "move";
  2856. editor.renderer.setCursorStyle(cursorStyle);
  2857. this.setState("dragReady");
  2858. };
  2859. this.onMouseDrag = function(e) {
  2860. var target = this.editor.container;
  2861. if (useragent.isIE && this.state == "dragReady") {
  2862. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2863. if (distance > 3)
  2864. target.dragDrop();
  2865. }
  2866. if (this.state === "dragWait") {
  2867. var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
  2868. if (distance > 0) {
  2869. target.draggable = false;
  2870. this.startSelect(this.mousedownEvent.getDocumentPosition());
  2871. }
  2872. }
  2873. };
  2874. this.onMouseDown = function(e) {
  2875. if (!this.$dragEnabled)
  2876. return;
  2877. this.mousedownEvent = e;
  2878. var editor = this.editor;
  2879. var inSelection = e.inSelection();
  2880. var button = e.getButton();
  2881. var clickCount = e.domEvent.detail || 1;
  2882. if (clickCount === 1 && button === 0 && inSelection) {
  2883. if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
  2884. return;
  2885. this.mousedownEvent.time = Date.now();
  2886. var eventTarget = e.domEvent.target || e.domEvent.srcElement;
  2887. if ("unselectable" in eventTarget)
  2888. eventTarget.unselectable = "on";
  2889. if (editor.getDragDelay()) {
  2890. if (useragent.isWebKit) {
  2891. this.cancelDrag = true;
  2892. var mouseTarget = editor.container;
  2893. mouseTarget.draggable = true;
  2894. }
  2895. this.setState("dragWait");
  2896. } else {
  2897. this.startDrag();
  2898. }
  2899. this.captureMouse(e, this.onMouseDrag.bind(this));
  2900. e.defaultPrevented = true;
  2901. }
  2902. };
  2903. }).call(DragdropHandler.prototype);
  2904. function calcDistance(ax, ay, bx, by) {
  2905. return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
  2906. }
  2907. exports.DragdropHandler = DragdropHandler;
  2908. });
  2909. ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  2910. "use strict";
  2911. var dom = require("./dom");
  2912. exports.get = function (url, callback) {
  2913. var xhr = new XMLHttpRequest();
  2914. xhr.open('GET', url, true);
  2915. xhr.onreadystatechange = function () {
  2916. if (xhr.readyState === 4) {
  2917. callback(xhr.responseText);
  2918. }
  2919. };
  2920. xhr.send(null);
  2921. };
  2922. exports.loadScript = function(path, callback) {
  2923. var head = dom.getDocumentHead();
  2924. var s = document.createElement('script');
  2925. s.src = path;
  2926. head.appendChild(s);
  2927. s.onload = s.onreadystatechange = function(_, isAbort) {
  2928. if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
  2929. s = s.onload = s.onreadystatechange = null;
  2930. if (!isAbort)
  2931. callback();
  2932. }
  2933. };
  2934. };
  2935. exports.qualifyURL = function(url) {
  2936. var a = document.createElement('a');
  2937. a.href = url;
  2938. return a.href;
  2939. }
  2940. });
  2941. ace.define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
  2942. "use strict";
  2943. var EventEmitter = {};
  2944. var stopPropagation = function() { this.propagationStopped = true; };
  2945. var preventDefault = function() { this.defaultPrevented = true; };
  2946. EventEmitter._emit =
  2947. EventEmitter._dispatchEvent = function(eventName, e) {
  2948. this._eventRegistry || (this._eventRegistry = {});
  2949. this._defaultHandlers || (this._defaultHandlers = {});
  2950. var listeners = this._eventRegistry[eventName] || [];
  2951. var defaultHandler = this._defaultHandlers[eventName];
  2952. if (!listeners.length && !defaultHandler)
  2953. return;
  2954. if (typeof e != "object" || !e)
  2955. e = {};
  2956. if (!e.type)
  2957. e.type = eventName;
  2958. if (!e.stopPropagation)
  2959. e.stopPropagation = stopPropagation;
  2960. if (!e.preventDefault)
  2961. e.preventDefault = preventDefault;
  2962. listeners = listeners.slice();
  2963. for (var i=0; i<listeners.length; i++) {
  2964. listeners[i](e, this);
  2965. if (e.propagationStopped)
  2966. break;
  2967. }
  2968. if (defaultHandler && !e.defaultPrevented)
  2969. return defaultHandler(e, this);
  2970. };
  2971. EventEmitter._signal = function(eventName, e) {
  2972. var listeners = (this._eventRegistry || {})[eventName];
  2973. if (!listeners)
  2974. return;
  2975. listeners = listeners.slice();
  2976. for (var i=0; i<listeners.length; i++)
  2977. listeners[i](e, this);
  2978. };
  2979. EventEmitter.once = function(eventName, callback) {
  2980. var _self = this;
  2981. callback && this.addEventListener(eventName, function newCallback() {
  2982. _self.removeEventListener(eventName, newCallback);
  2983. callback.apply(null, arguments);
  2984. });
  2985. };
  2986. EventEmitter.setDefaultHandler = function(eventName, callback) {
  2987. var handlers = this._defaultHandlers
  2988. if (!handlers)
  2989. handlers = this._defaultHandlers = {_disabled_: {}};
  2990. if (handlers[eventName]) {
  2991. var old = handlers[eventName];
  2992. var disabled = handlers._disabled_[eventName];
  2993. if (!disabled)
  2994. handlers._disabled_[eventName] = disabled = [];
  2995. disabled.push(old);
  2996. var i = disabled.indexOf(callback);
  2997. if (i != -1)
  2998. disabled.splice(i, 1);
  2999. }
  3000. handlers[eventName] = callback;
  3001. };
  3002. EventEmitter.removeDefaultHandler = function(eventName, callback) {
  3003. var handlers = this._defaultHandlers
  3004. if (!handlers)
  3005. return;
  3006. var disabled = handlers._disabled_[eventName];
  3007. if (handlers[eventName] == callback) {
  3008. var old = handlers[eventName];
  3009. if (disabled)
  3010. this.setDefaultHandler(eventName, disabled.pop());
  3011. } else if (disabled) {
  3012. var i = disabled.indexOf(callback);
  3013. if (i != -1)
  3014. disabled.splice(i, 1);
  3015. }
  3016. };
  3017. EventEmitter.on =
  3018. EventEmitter.addEventListener = function(eventName, callback, capturing) {
  3019. this._eventRegistry = this._eventRegistry || {};
  3020. var listeners = this._eventRegistry[eventName];
  3021. if (!listeners)
  3022. listeners = this._eventRegistry[eventName] = [];
  3023. if (listeners.indexOf(callback) == -1)
  3024. listeners[capturing ? "unshift" : "push"](callback);
  3025. return callback;
  3026. };
  3027. EventEmitter.off =
  3028. EventEmitter.removeListener =
  3029. EventEmitter.removeEventListener = function(eventName, callback) {
  3030. this._eventRegistry = this._eventRegistry || {};
  3031. var listeners = this._eventRegistry[eventName];
  3032. if (!listeners)
  3033. return;
  3034. var index = listeners.indexOf(callback);
  3035. if (index !== -1)
  3036. listeners.splice(index, 1);
  3037. };
  3038. EventEmitter.removeAllListeners = function(eventName) {
  3039. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  3040. };
  3041. exports.EventEmitter = EventEmitter;
  3042. });
  3043. ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  3044. "no use strict";
  3045. var oop = require("./oop");
  3046. var EventEmitter = require("./event_emitter").EventEmitter;
  3047. var optionsProvider = {
  3048. setOptions: function(optList) {
  3049. Object.keys(optList).forEach(function(key) {
  3050. this.setOption(key, optList[key]);
  3051. }, this);
  3052. },
  3053. getOptions: function(optionNames) {
  3054. var result = {};
  3055. if (!optionNames) {
  3056. optionNames = Object.keys(this.$options);
  3057. } else if (!Array.isArray(optionNames)) {
  3058. result = optionNames;
  3059. optionNames = Object.keys(result);
  3060. }
  3061. optionNames.forEach(function(key) {
  3062. result[key] = this.getOption(key);
  3063. }, this);
  3064. return result;
  3065. },
  3066. setOption: function(name, value) {
  3067. if (this["$" + name] === value)
  3068. return;
  3069. var opt = this.$options[name];
  3070. if (!opt) {
  3071. return warn('misspelled option "' + name + '"');
  3072. }
  3073. if (opt.forwardTo)
  3074. return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
  3075. if (!opt.handlesSet)
  3076. this["$" + name] = value;
  3077. if (opt && opt.set)
  3078. opt.set.call(this, value);
  3079. },
  3080. getOption: function(name) {
  3081. var opt = this.$options[name];
  3082. if (!opt) {
  3083. return warn('misspelled option "' + name + '"');
  3084. }
  3085. if (opt.forwardTo)
  3086. return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
  3087. return opt && opt.get ? opt.get.call(this) : this["$" + name];
  3088. }
  3089. };
  3090. function warn(message) {
  3091. if (typeof console != "undefined" && console.warn)
  3092. console.warn.apply(console, arguments);
  3093. }
  3094. function reportError(msg, data) {
  3095. var e = new Error(msg);
  3096. e.data = data;
  3097. if (typeof console == "object" && console.error)
  3098. console.error(e);
  3099. setTimeout(function() { throw e; });
  3100. }
  3101. var AppConfig = function() {
  3102. this.$defaultOptions = {};
  3103. };
  3104. (function() {
  3105. oop.implement(this, EventEmitter);
  3106. this.defineOptions = function(obj, path, options) {
  3107. if (!obj.$options)
  3108. this.$defaultOptions[path] = obj.$options = {};
  3109. Object.keys(options).forEach(function(key) {
  3110. var opt = options[key];
  3111. if (typeof opt == "string")
  3112. opt = {forwardTo: opt};
  3113. opt.name || (opt.name = key);
  3114. obj.$options[opt.name] = opt;
  3115. if ("initialValue" in opt)
  3116. obj["$" + opt.name] = opt.initialValue;
  3117. });
  3118. oop.implement(obj, optionsProvider);
  3119. return this;
  3120. };
  3121. this.resetOptions = function(obj) {
  3122. Object.keys(obj.$options).forEach(function(key) {
  3123. var opt = obj.$options[key];
  3124. if ("value" in opt)
  3125. obj.setOption(key, opt.value);
  3126. });
  3127. };
  3128. this.setDefaultValue = function(path, name, value) {
  3129. var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
  3130. if (opts[name]) {
  3131. if (opts.forwardTo)
  3132. this.setDefaultValue(opts.forwardTo, name, value);
  3133. else
  3134. opts[name].value = value;
  3135. }
  3136. };
  3137. this.setDefaultValues = function(path, optionHash) {
  3138. Object.keys(optionHash).forEach(function(key) {
  3139. this.setDefaultValue(path, key, optionHash[key]);
  3140. }, this);
  3141. };
  3142. this.warn = warn;
  3143. this.reportError = reportError;
  3144. }).call(AppConfig.prototype);
  3145. exports.AppConfig = AppConfig;
  3146. });
  3147. ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(require, exports, module) {
  3148. "no use strict";
  3149. var lang = require("./lib/lang");
  3150. var oop = require("./lib/oop");
  3151. var net = require("./lib/net");
  3152. var AppConfig = require("./lib/app_config").AppConfig;
  3153. module.exports = exports = new AppConfig();
  3154. var global = (function() {
  3155. return this || typeof window != "undefined" && window;
  3156. })();
  3157. var options = {
  3158. packaged: false,
  3159. workerPath: null,
  3160. modePath: null,
  3161. themePath: null,
  3162. basePath: "",
  3163. suffix: ".js",
  3164. $moduleUrls: {}
  3165. };
  3166. exports.get = function(key) {
  3167. if (!options.hasOwnProperty(key))
  3168. throw new Error("Unknown config key: " + key);
  3169. return options[key];
  3170. };
  3171. exports.set = function(key, value) {
  3172. if (!options.hasOwnProperty(key))
  3173. throw new Error("Unknown config key: " + key);
  3174. options[key] = value;
  3175. };
  3176. exports.all = function() {
  3177. return lang.copyObject(options);
  3178. };
  3179. exports.moduleUrl = function(name, component) {
  3180. if (options.$moduleUrls[name])
  3181. return options.$moduleUrls[name];
  3182. var parts = name.split("/");
  3183. component = component || parts[parts.length - 2] || "";
  3184. var sep = component == "snippets" ? "/" : "-";
  3185. var base = parts[parts.length - 1];
  3186. if (component == "worker" && sep == "-") {
  3187. var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
  3188. base = base.replace(re, "");
  3189. }
  3190. if ((!base || base == component) && parts.length > 1)
  3191. base = parts[parts.length - 2];
  3192. var path = options[component + "Path"];
  3193. if (path == null) {
  3194. path = options.basePath;
  3195. } else if (sep == "/") {
  3196. component = sep = "";
  3197. }
  3198. if (path && path.slice(-1) != "/")
  3199. path += "/";
  3200. return path + component + sep + base + this.get("suffix");
  3201. };
  3202. exports.setModuleUrl = function(name, subst) {
  3203. return options.$moduleUrls[name] = subst;
  3204. };
  3205. exports.$loading = {};
  3206. exports.loadModule = function(moduleName, onLoad) {
  3207. var module, moduleType;
  3208. if (Array.isArray(moduleName)) {
  3209. moduleType = moduleName[0];
  3210. moduleName = moduleName[1];
  3211. }
  3212. try {
  3213. module = require(moduleName);
  3214. } catch (e) {}
  3215. if (module && !exports.$loading[moduleName])
  3216. return onLoad && onLoad(module);
  3217. if (!exports.$loading[moduleName])
  3218. exports.$loading[moduleName] = [];
  3219. exports.$loading[moduleName].push(onLoad);
  3220. if (exports.$loading[moduleName].length > 1)
  3221. return;
  3222. var afterLoad = function() {
  3223. require([moduleName], function(module) {
  3224. exports._emit("load.module", {name: moduleName, module: module});
  3225. var listeners = exports.$loading[moduleName];
  3226. exports.$loading[moduleName] = null;
  3227. listeners.forEach(function(onLoad) {
  3228. onLoad && onLoad(module);
  3229. });
  3230. });
  3231. };
  3232. if (!exports.get("packaged"))
  3233. return afterLoad();
  3234. net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
  3235. };
  3236. init(true);function init(packaged) {
  3237. if (!global || !global.document)
  3238. return;
  3239. options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
  3240. var scriptOptions = {};
  3241. var scriptUrl = "";
  3242. var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
  3243. var currentDocument = currentScript && currentScript.ownerDocument || document;
  3244. var scripts = currentDocument.getElementsByTagName("script");
  3245. for (var i=0; i<scripts.length; i++) {
  3246. var script = scripts[i];
  3247. var src = script.src || script.getAttribute("src");
  3248. if (!src)
  3249. continue;
  3250. var attributes = script.attributes;
  3251. for (var j=0, l=attributes.length; j < l; j++) {
  3252. var attr = attributes[j];
  3253. if (attr.name.indexOf("data-ace-") === 0) {
  3254. scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
  3255. }
  3256. }
  3257. var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
  3258. if (m)
  3259. scriptUrl = m[1];
  3260. }
  3261. if (scriptUrl) {
  3262. scriptOptions.base = scriptOptions.base || scriptUrl;
  3263. scriptOptions.packaged = true;
  3264. }
  3265. scriptOptions.basePath = scriptOptions.base;
  3266. scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
  3267. scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
  3268. scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
  3269. delete scriptOptions.base;
  3270. for (var key in scriptOptions)
  3271. if (typeof scriptOptions[key] !== "undefined")
  3272. exports.set(key, scriptOptions[key]);
  3273. }
  3274. exports.init = init;
  3275. function deHyphenate(str) {
  3276. return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
  3277. }
  3278. });
  3279. 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) {
  3280. "use strict";
  3281. var event = require("../lib/event");
  3282. var useragent = require("../lib/useragent");
  3283. var DefaultHandlers = require("./default_handlers").DefaultHandlers;
  3284. var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
  3285. var MouseEvent = require("./mouse_event").MouseEvent;
  3286. var DragdropHandler = require("./dragdrop_handler").DragdropHandler;
  3287. var config = require("../config");
  3288. var MouseHandler = function(editor) {
  3289. var _self = this;
  3290. this.editor = editor;
  3291. new DefaultHandlers(this);
  3292. new DefaultGutterHandler(this);
  3293. new DragdropHandler(this);
  3294. var focusEditor = function(e) {
  3295. var windowBlurred = !document.hasFocus || !document.hasFocus()
  3296. || !editor.isFocused() && document.activeElement == (editor.textInput && editor.textInput.getElement())
  3297. if (windowBlurred)
  3298. window.focus();
  3299. editor.focus();
  3300. };
  3301. var mouseTarget = editor.renderer.getMouseEventTarget();
  3302. event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
  3303. event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
  3304. event.addMultiMouseDownListener([
  3305. mouseTarget,
  3306. editor.renderer.scrollBarV && editor.renderer.scrollBarV.inner,
  3307. editor.renderer.scrollBarH && editor.renderer.scrollBarH.inner,
  3308. editor.textInput && editor.textInput.getElement()
  3309. ].filter(Boolean), [400, 300, 250], this, "onMouseEvent");
  3310. event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
  3311. event.addTouchMoveListener(editor.container, this.onTouchMove.bind(this, "touchmove"));
  3312. var gutterEl = editor.renderer.$gutter;
  3313. event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
  3314. event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
  3315. event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
  3316. event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
  3317. event.addListener(mouseTarget, "mousedown", focusEditor);
  3318. event.addListener(gutterEl, "mousedown", focusEditor);
  3319. if (useragent.isIE && editor.renderer.scrollBarV) {
  3320. event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
  3321. event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
  3322. }
  3323. editor.on("mousemove", function(e){
  3324. if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
  3325. return;
  3326. var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
  3327. var range = editor.session.selection.getRange();
  3328. var renderer = editor.renderer;
  3329. if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
  3330. renderer.setCursorStyle("default");
  3331. } else {
  3332. renderer.setCursorStyle("");
  3333. }
  3334. });
  3335. };
  3336. (function() {
  3337. this.onMouseEvent = function(name, e) {
  3338. this.editor._emit(name, new MouseEvent(e, this.editor));
  3339. };
  3340. this.onMouseMove = function(name, e) {
  3341. var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
  3342. if (!listeners || !listeners.length)
  3343. return;
  3344. this.editor._emit(name, new MouseEvent(e, this.editor));
  3345. };
  3346. this.onMouseWheel = function(name, e) {
  3347. var mouseEvent = new MouseEvent(e, this.editor);
  3348. mouseEvent.speed = this.$scrollSpeed * 2;
  3349. mouseEvent.wheelX = e.wheelX;
  3350. mouseEvent.wheelY = e.wheelY;
  3351. this.editor._emit(name, mouseEvent);
  3352. };
  3353. this.onTouchMove = function (name, e) {
  3354. var mouseEvent = new MouseEvent(e, this.editor);
  3355. mouseEvent.speed = 1;//this.$scrollSpeed * 2;
  3356. mouseEvent.wheelX = e.wheelX;
  3357. mouseEvent.wheelY = e.wheelY;
  3358. this.editor._emit(name, mouseEvent);
  3359. };
  3360. this.setState = function(state) {
  3361. this.state = state;
  3362. };
  3363. this.captureMouse = function(ev, mouseMoveHandler) {
  3364. this.x = ev.x;
  3365. this.y = ev.y;
  3366. this.isMousePressed = true;
  3367. var renderer = this.editor.renderer;
  3368. if (renderer.$keepTextAreaAtCursor)
  3369. renderer.$keepTextAreaAtCursor = null;
  3370. var self = this;
  3371. var onMouseMove = function(e) {
  3372. if (!e) return;
  3373. if (useragent.isWebKit && !e.which && self.releaseMouse)
  3374. return self.releaseMouse();
  3375. self.x = e.clientX;
  3376. self.y = e.clientY;
  3377. mouseMoveHandler && mouseMoveHandler(e);
  3378. self.mouseEvent = new MouseEvent(e, self.editor);
  3379. self.$mouseMoved = true;
  3380. };
  3381. var onCaptureEnd = function(e) {
  3382. clearInterval(timerId);
  3383. onCaptureInterval();
  3384. self[self.state + "End"] && self[self.state + "End"](e);
  3385. self.state = "";
  3386. if (renderer.$keepTextAreaAtCursor == null) {
  3387. renderer.$keepTextAreaAtCursor = true;
  3388. renderer.$moveTextAreaToCursor();
  3389. }
  3390. self.isMousePressed = false;
  3391. self.$onCaptureMouseMove = self.releaseMouse = null;
  3392. e && self.onMouseEvent("mouseup", e);
  3393. };
  3394. var onCaptureInterval = function() {
  3395. self[self.state] && self[self.state]();
  3396. self.$mouseMoved = false;
  3397. };
  3398. if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
  3399. return setTimeout(function() {onCaptureEnd(ev);});
  3400. }
  3401. self.$onCaptureMouseMove = onMouseMove;
  3402. self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
  3403. var timerId = setInterval(onCaptureInterval, 20);
  3404. };
  3405. this.releaseMouse = null;
  3406. this.cancelContextMenu = function() {
  3407. var stop = function(e) {
  3408. if (e && e.domEvent && e.domEvent.type != "contextmenu")
  3409. return;
  3410. this.editor.off("nativecontextmenu", stop);
  3411. if (e && e.domEvent)
  3412. event.stopEvent(e.domEvent);
  3413. }.bind(this);
  3414. setTimeout(stop, 10);
  3415. this.editor.on("nativecontextmenu", stop);
  3416. };
  3417. }).call(MouseHandler.prototype);
  3418. config.defineOptions(MouseHandler.prototype, "mouseHandler", {
  3419. scrollSpeed: {initialValue: 2},
  3420. dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
  3421. dragEnabled: {initialValue: true},
  3422. focusTimout: {initialValue: 0},
  3423. tooltipFollowsMouse: {initialValue: true}
  3424. });
  3425. exports.MouseHandler = MouseHandler;
  3426. });
  3427. ace.define("ace/mouse/fold_handler",["require","exports","module"], function(require, exports, module) {
  3428. "use strict";
  3429. function FoldHandler(editor) {
  3430. editor.on("click", function(e) {
  3431. var position = e.getDocumentPosition();
  3432. var session = editor.session;
  3433. var fold = session.getFoldAt(position.row, position.column, 1);
  3434. if (fold) {
  3435. if (e.getAccelKey())
  3436. session.removeFold(fold);
  3437. else
  3438. session.expandFold(fold);
  3439. e.stop();
  3440. }
  3441. });
  3442. editor.on("gutterclick", function(e) {
  3443. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3444. if (gutterRegion == "foldWidgets") {
  3445. var row = e.getDocumentPosition().row;
  3446. var session = editor.session;
  3447. if (session.foldWidgets && session.foldWidgets[row])
  3448. editor.session.onFoldWidgetClick(row, e);
  3449. if (!editor.isFocused())
  3450. editor.focus();
  3451. e.stop();
  3452. }
  3453. });
  3454. editor.on("gutterdblclick", function(e) {
  3455. var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
  3456. if (gutterRegion == "foldWidgets") {
  3457. var row = e.getDocumentPosition().row;
  3458. var session = editor.session;
  3459. var data = session.getParentFoldRangeData(row, true);
  3460. var range = data.range || data.firstRange;
  3461. if (range) {
  3462. row = range.start.row;
  3463. var fold = session.getFoldAt(row, session.getLine(row).length, 1);
  3464. if (fold) {
  3465. session.removeFold(fold);
  3466. } else {
  3467. session.addFold("...", range);
  3468. editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
  3469. }
  3470. }
  3471. e.stop();
  3472. }
  3473. });
  3474. }
  3475. exports.FoldHandler = FoldHandler;
  3476. });
  3477. ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module) {
  3478. "use strict";
  3479. var keyUtil = require("../lib/keys");
  3480. var event = require("../lib/event");
  3481. var KeyBinding = function(editor) {
  3482. this.$editor = editor;
  3483. this.$data = {editor: editor};
  3484. this.$handlers = [];
  3485. this.setDefaultHandler(editor.commands);
  3486. };
  3487. (function() {
  3488. this.setDefaultHandler = function(kb) {
  3489. this.removeKeyboardHandler(this.$defaultHandler);
  3490. this.$defaultHandler = kb;
  3491. this.addKeyboardHandler(kb, 0);
  3492. };
  3493. this.setKeyboardHandler = function(kb) {
  3494. var h = this.$handlers;
  3495. if (h[h.length - 1] == kb)
  3496. return;
  3497. while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
  3498. this.removeKeyboardHandler(h[h.length - 1]);
  3499. this.addKeyboardHandler(kb, 1);
  3500. };
  3501. this.addKeyboardHandler = function(kb, pos) {
  3502. if (!kb)
  3503. return;
  3504. if (typeof kb == "function" && !kb.handleKeyboard)
  3505. kb.handleKeyboard = kb;
  3506. var i = this.$handlers.indexOf(kb);
  3507. if (i != -1)
  3508. this.$handlers.splice(i, 1);
  3509. if (pos == undefined)
  3510. this.$handlers.push(kb);
  3511. else
  3512. this.$handlers.splice(pos, 0, kb);
  3513. if (i == -1 && kb.attach)
  3514. kb.attach(this.$editor);
  3515. };
  3516. this.removeKeyboardHandler = function(kb) {
  3517. var i = this.$handlers.indexOf(kb);
  3518. if (i == -1)
  3519. return false;
  3520. this.$handlers.splice(i, 1);
  3521. kb.detach && kb.detach(this.$editor);
  3522. return true;
  3523. };
  3524. this.getKeyboardHandler = function() {
  3525. return this.$handlers[this.$handlers.length - 1];
  3526. };
  3527. this.getStatusText = function() {
  3528. var data = this.$data;
  3529. var editor = data.editor;
  3530. return this.$handlers.map(function(h) {
  3531. return h.getStatusText && h.getStatusText(editor, data) || "";
  3532. }).filter(Boolean).join(" ");
  3533. };
  3534. this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
  3535. var toExecute;
  3536. var success = false;
  3537. var commands = this.$editor.commands;
  3538. for (var i = this.$handlers.length; i--;) {
  3539. toExecute = this.$handlers[i].handleKeyboard(
  3540. this.$data, hashId, keyString, keyCode, e
  3541. );
  3542. if (!toExecute || !toExecute.command)
  3543. continue;
  3544. if (toExecute.command == "null") {
  3545. success = true;
  3546. } else {
  3547. success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
  3548. }
  3549. if (success && e && hashId != -1 &&
  3550. toExecute.passEvent != true && toExecute.command.passEvent != true
  3551. ) {
  3552. event.stopEvent(e);
  3553. }
  3554. if (success)
  3555. break;
  3556. }
  3557. if (!success && hashId == -1) {
  3558. toExecute = {command: "insertstring"};
  3559. success = commands.exec("insertstring", this.$editor, keyString);
  3560. }
  3561. if (success && this.$editor._signal)
  3562. this.$editor._signal("keyboardActivity", toExecute);
  3563. return success;
  3564. };
  3565. this.onCommandKey = function(e, hashId, keyCode) {
  3566. var keyString = keyUtil.keyCodeToString(keyCode);
  3567. this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
  3568. };
  3569. this.onTextInput = function(text) {
  3570. this.$callKeyboardHandlers(-1, text);
  3571. };
  3572. }).call(KeyBinding.prototype);
  3573. exports.KeyBinding = KeyBinding;
  3574. });
  3575. ace.define("ace/range",["require","exports","module"], function(require, exports, module) {
  3576. "use strict";
  3577. var comparePoints = function(p1, p2) {
  3578. return p1.row - p2.row || p1.column - p2.column;
  3579. };
  3580. var Range = function(startRow, startColumn, endRow, endColumn) {
  3581. this.start = {
  3582. row: startRow,
  3583. column: startColumn
  3584. };
  3585. this.end = {
  3586. row: endRow,
  3587. column: endColumn
  3588. };
  3589. };
  3590. (function() {
  3591. this.isEqual = function(range) {
  3592. return this.start.row === range.start.row &&
  3593. this.end.row === range.end.row &&
  3594. this.start.column === range.start.column &&
  3595. this.end.column === range.end.column;
  3596. };
  3597. this.toString = function() {
  3598. return ("Range: [" + this.start.row + "/" + this.start.column +
  3599. "] -> [" + this.end.row + "/" + this.end.column + "]");
  3600. };
  3601. this.contains = function(row, column) {
  3602. return this.compare(row, column) == 0;
  3603. };
  3604. this.compareRange = function(range) {
  3605. var cmp,
  3606. end = range.end,
  3607. start = range.start;
  3608. cmp = this.compare(end.row, end.column);
  3609. if (cmp == 1) {
  3610. cmp = this.compare(start.row, start.column);
  3611. if (cmp == 1) {
  3612. return 2;
  3613. } else if (cmp == 0) {
  3614. return 1;
  3615. } else {
  3616. return 0;
  3617. }
  3618. } else if (cmp == -1) {
  3619. return -2;
  3620. } else {
  3621. cmp = this.compare(start.row, start.column);
  3622. if (cmp == -1) {
  3623. return -1;
  3624. } else if (cmp == 1) {
  3625. return 42;
  3626. } else {
  3627. return 0;
  3628. }
  3629. }
  3630. };
  3631. this.comparePoint = function(p) {
  3632. return this.compare(p.row, p.column);
  3633. };
  3634. this.containsRange = function(range) {
  3635. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  3636. };
  3637. this.intersects = function(range) {
  3638. var cmp = this.compareRange(range);
  3639. return (cmp == -1 || cmp == 0 || cmp == 1);
  3640. };
  3641. this.isEnd = function(row, column) {
  3642. return this.end.row == row && this.end.column == column;
  3643. };
  3644. this.isStart = function(row, column) {
  3645. return this.start.row == row && this.start.column == column;
  3646. };
  3647. this.setStart = function(row, column) {
  3648. if (typeof row == "object") {
  3649. this.start.column = row.column;
  3650. this.start.row = row.row;
  3651. } else {
  3652. this.start.row = row;
  3653. this.start.column = column;
  3654. }
  3655. };
  3656. this.setEnd = function(row, column) {
  3657. if (typeof row == "object") {
  3658. this.end.column = row.column;
  3659. this.end.row = row.row;
  3660. } else {
  3661. this.end.row = row;
  3662. this.end.column = column;
  3663. }
  3664. };
  3665. this.inside = function(row, column) {
  3666. if (this.compare(row, column) == 0) {
  3667. if (this.isEnd(row, column) || this.isStart(row, column)) {
  3668. return false;
  3669. } else {
  3670. return true;
  3671. }
  3672. }
  3673. return false;
  3674. };
  3675. this.insideStart = function(row, column) {
  3676. if (this.compare(row, column) == 0) {
  3677. if (this.isEnd(row, column)) {
  3678. return false;
  3679. } else {
  3680. return true;
  3681. }
  3682. }
  3683. return false;
  3684. };
  3685. this.insideEnd = function(row, column) {
  3686. if (this.compare(row, column) == 0) {
  3687. if (this.isStart(row, column)) {
  3688. return false;
  3689. } else {
  3690. return true;
  3691. }
  3692. }
  3693. return false;
  3694. };
  3695. this.compare = function(row, column) {
  3696. if (!this.isMultiLine()) {
  3697. if (row === this.start.row) {
  3698. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  3699. }
  3700. }
  3701. if (row < this.start.row)
  3702. return -1;
  3703. if (row > this.end.row)
  3704. return 1;
  3705. if (this.start.row === row)
  3706. return column >= this.start.column ? 0 : -1;
  3707. if (this.end.row === row)
  3708. return column <= this.end.column ? 0 : 1;
  3709. return 0;
  3710. };
  3711. this.compareStart = function(row, column) {
  3712. if (this.start.row == row && this.start.column == column) {
  3713. return -1;
  3714. } else {
  3715. return this.compare(row, column);
  3716. }
  3717. };
  3718. this.compareEnd = function(row, column) {
  3719. if (this.end.row == row && this.end.column == column) {
  3720. return 1;
  3721. } else {
  3722. return this.compare(row, column);
  3723. }
  3724. };
  3725. this.compareInside = function(row, column) {
  3726. if (this.end.row == row && this.end.column == column) {
  3727. return 1;
  3728. } else if (this.start.row == row && this.start.column == column) {
  3729. return -1;
  3730. } else {
  3731. return this.compare(row, column);
  3732. }
  3733. };
  3734. this.clipRows = function(firstRow, lastRow) {
  3735. if (this.end.row > lastRow)
  3736. var end = {row: lastRow + 1, column: 0};
  3737. else if (this.end.row < firstRow)
  3738. var end = {row: firstRow, column: 0};
  3739. if (this.start.row > lastRow)
  3740. var start = {row: lastRow + 1, column: 0};
  3741. else if (this.start.row < firstRow)
  3742. var start = {row: firstRow, column: 0};
  3743. return Range.fromPoints(start || this.start, end || this.end);
  3744. };
  3745. this.extend = function(row, column) {
  3746. var cmp = this.compare(row, column);
  3747. if (cmp == 0)
  3748. return this;
  3749. else if (cmp == -1)
  3750. var start = {row: row, column: column};
  3751. else
  3752. var end = {row: row, column: column};
  3753. return Range.fromPoints(start || this.start, end || this.end);
  3754. };
  3755. this.isEmpty = function() {
  3756. return (this.start.row === this.end.row && this.start.column === this.end.column);
  3757. };
  3758. this.isMultiLine = function() {
  3759. return (this.start.row !== this.end.row);
  3760. };
  3761. this.clone = function() {
  3762. return Range.fromPoints(this.start, this.end);
  3763. };
  3764. this.collapseRows = function() {
  3765. if (this.end.column == 0)
  3766. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
  3767. else
  3768. return new Range(this.start.row, 0, this.end.row, 0)
  3769. };
  3770. this.toScreenRange = function(session) {
  3771. var screenPosStart = session.documentToScreenPosition(this.start);
  3772. var screenPosEnd = session.documentToScreenPosition(this.end);
  3773. return new Range(
  3774. screenPosStart.row, screenPosStart.column,
  3775. screenPosEnd.row, screenPosEnd.column
  3776. );
  3777. };
  3778. this.moveBy = function(row, column) {
  3779. this.start.row += row;
  3780. this.start.column += column;
  3781. this.end.row += row;
  3782. this.end.column += column;
  3783. };
  3784. }).call(Range.prototype);
  3785. Range.fromPoints = function(start, end) {
  3786. return new Range(start.row, start.column, end.row, end.column);
  3787. };
  3788. Range.comparePoints = comparePoints;
  3789. Range.comparePoints = function(p1, p2) {
  3790. return p1.row - p2.row || p1.column - p2.column;
  3791. };
  3792. exports.Range = Range;
  3793. });
  3794. ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
  3795. "use strict";
  3796. var oop = require("./lib/oop");
  3797. var lang = require("./lib/lang");
  3798. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  3799. var Range = require("./range").Range;
  3800. var Selection = function(session) {
  3801. this.session = session;
  3802. this.doc = session.getDocument();
  3803. this.clearSelection();
  3804. this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
  3805. this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
  3806. var self = this;
  3807. this.lead.on("change", function(e) {
  3808. self._emit("changeCursor");
  3809. if (!self.$isEmpty)
  3810. self._emit("changeSelection");
  3811. if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
  3812. self.$desiredColumn = null;
  3813. });
  3814. this.selectionAnchor.on("change", function() {
  3815. if (!self.$isEmpty)
  3816. self._emit("changeSelection");
  3817. });
  3818. };
  3819. (function() {
  3820. oop.implement(this, EventEmitter);
  3821. this.isEmpty = function() {
  3822. return (this.$isEmpty || (
  3823. this.anchor.row == this.lead.row &&
  3824. this.anchor.column == this.lead.column
  3825. ));
  3826. };
  3827. this.isMultiLine = function() {
  3828. if (this.isEmpty()) {
  3829. return false;
  3830. }
  3831. return this.getRange().isMultiLine();
  3832. };
  3833. this.getCursor = function() {
  3834. return this.lead.getPosition();
  3835. };
  3836. this.setSelectionAnchor = function(row, column) {
  3837. this.anchor.setPosition(row, column);
  3838. if (this.$isEmpty) {
  3839. this.$isEmpty = false;
  3840. this._emit("changeSelection");
  3841. }
  3842. };
  3843. this.getSelectionAnchor = function() {
  3844. if (this.$isEmpty)
  3845. return this.getSelectionLead();
  3846. else
  3847. return this.anchor.getPosition();
  3848. };
  3849. this.getSelectionLead = function() {
  3850. return this.lead.getPosition();
  3851. };
  3852. this.shiftSelection = function(columns) {
  3853. if (this.$isEmpty) {
  3854. this.moveCursorTo(this.lead.row, this.lead.column + columns);
  3855. return;
  3856. }
  3857. var anchor = this.getSelectionAnchor();
  3858. var lead = this.getSelectionLead();
  3859. var isBackwards = this.isBackwards();
  3860. if (!isBackwards || anchor.column !== 0)
  3861. this.setSelectionAnchor(anchor.row, anchor.column + columns);
  3862. if (isBackwards || lead.column !== 0) {
  3863. this.$moveSelection(function() {
  3864. this.moveCursorTo(lead.row, lead.column + columns);
  3865. });
  3866. }
  3867. };
  3868. this.isBackwards = function() {
  3869. var anchor = this.anchor;
  3870. var lead = this.lead;
  3871. return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
  3872. };
  3873. this.getRange = function() {
  3874. var anchor = this.anchor;
  3875. var lead = this.lead;
  3876. if (this.isEmpty())
  3877. return Range.fromPoints(lead, lead);
  3878. if (this.isBackwards()) {
  3879. return Range.fromPoints(lead, anchor);
  3880. }
  3881. else {
  3882. return Range.fromPoints(anchor, lead);
  3883. }
  3884. };
  3885. this.clearSelection = function() {
  3886. if (!this.$isEmpty) {
  3887. this.$isEmpty = true;
  3888. this._emit("changeSelection");
  3889. }
  3890. };
  3891. this.selectAll = function() {
  3892. var lastRow = this.doc.getLength() - 1;
  3893. this.setSelectionAnchor(0, 0);
  3894. this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
  3895. };
  3896. this.setRange =
  3897. this.setSelectionRange = function(range, reverse) {
  3898. if (reverse) {
  3899. this.setSelectionAnchor(range.end.row, range.end.column);
  3900. this.selectTo(range.start.row, range.start.column);
  3901. } else {
  3902. this.setSelectionAnchor(range.start.row, range.start.column);
  3903. this.selectTo(range.end.row, range.end.column);
  3904. }
  3905. if (this.getRange().isEmpty())
  3906. this.$isEmpty = true;
  3907. this.$desiredColumn = null;
  3908. };
  3909. this.$moveSelection = function(mover) {
  3910. var lead = this.lead;
  3911. if (this.$isEmpty)
  3912. this.setSelectionAnchor(lead.row, lead.column);
  3913. mover.call(this);
  3914. };
  3915. this.selectTo = function(row, column) {
  3916. this.$moveSelection(function() {
  3917. this.moveCursorTo(row, column);
  3918. });
  3919. };
  3920. this.selectToPosition = function(pos) {
  3921. this.$moveSelection(function() {
  3922. this.moveCursorToPosition(pos);
  3923. });
  3924. };
  3925. this.moveTo = function(row, column) {
  3926. this.clearSelection();
  3927. this.moveCursorTo(row, column);
  3928. };
  3929. this.moveToPosition = function(pos) {
  3930. this.clearSelection();
  3931. this.moveCursorToPosition(pos);
  3932. };
  3933. this.selectUp = function() {
  3934. this.$moveSelection(this.moveCursorUp);
  3935. };
  3936. this.selectDown = function() {
  3937. this.$moveSelection(this.moveCursorDown);
  3938. };
  3939. this.selectRight = function() {
  3940. this.$moveSelection(this.moveCursorRight);
  3941. };
  3942. this.selectLeft = function() {
  3943. this.$moveSelection(this.moveCursorLeft);
  3944. };
  3945. this.selectLineStart = function() {
  3946. this.$moveSelection(this.moveCursorLineStart);
  3947. };
  3948. this.selectLineEnd = function() {
  3949. this.$moveSelection(this.moveCursorLineEnd);
  3950. };
  3951. this.selectFileEnd = function() {
  3952. this.$moveSelection(this.moveCursorFileEnd);
  3953. };
  3954. this.selectFileStart = function() {
  3955. this.$moveSelection(this.moveCursorFileStart);
  3956. };
  3957. this.selectWordRight = function() {
  3958. this.$moveSelection(this.moveCursorWordRight);
  3959. };
  3960. this.selectWordLeft = function() {
  3961. this.$moveSelection(this.moveCursorWordLeft);
  3962. };
  3963. this.getWordRange = function(row, column) {
  3964. if (typeof column == "undefined") {
  3965. var cursor = row || this.lead;
  3966. row = cursor.row;
  3967. column = cursor.column;
  3968. }
  3969. return this.session.getWordRange(row, column);
  3970. };
  3971. this.selectWord = function() {
  3972. this.setSelectionRange(this.getWordRange());
  3973. };
  3974. this.selectAWord = function() {
  3975. var cursor = this.getCursor();
  3976. var range = this.session.getAWordRange(cursor.row, cursor.column);
  3977. this.setSelectionRange(range);
  3978. };
  3979. this.getLineRange = function(row, excludeLastChar) {
  3980. var rowStart = typeof row == "number" ? row : this.lead.row;
  3981. var rowEnd;
  3982. var foldLine = this.session.getFoldLine(rowStart);
  3983. if (foldLine) {
  3984. rowStart = foldLine.start.row;
  3985. rowEnd = foldLine.end.row;
  3986. } else {
  3987. rowEnd = rowStart;
  3988. }
  3989. if (excludeLastChar === true)
  3990. return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
  3991. else
  3992. return new Range(rowStart, 0, rowEnd + 1, 0);
  3993. };
  3994. this.selectLine = function() {
  3995. this.setSelectionRange(this.getLineRange());
  3996. };
  3997. this.moveCursorUp = function() {
  3998. this.moveCursorBy(-1, 0);
  3999. };
  4000. this.moveCursorDown = function() {
  4001. this.moveCursorBy(1, 0);
  4002. };
  4003. this.moveCursorLeft = function() {
  4004. var cursor = this.lead.getPosition(),
  4005. fold;
  4006. if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
  4007. this.moveCursorTo(fold.start.row, fold.start.column);
  4008. } else if (cursor.column === 0) {
  4009. if (cursor.row > 0) {
  4010. this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
  4011. }
  4012. }
  4013. else {
  4014. var tabSize = this.session.getTabSize();
  4015. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
  4016. this.moveCursorBy(0, -tabSize);
  4017. else
  4018. this.moveCursorBy(0, -1);
  4019. }
  4020. };
  4021. this.moveCursorRight = function() {
  4022. var cursor = this.lead.getPosition(),
  4023. fold;
  4024. if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
  4025. this.moveCursorTo(fold.end.row, fold.end.column);
  4026. }
  4027. else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
  4028. if (this.lead.row < this.doc.getLength() - 1) {
  4029. this.moveCursorTo(this.lead.row + 1, 0);
  4030. }
  4031. }
  4032. else {
  4033. var tabSize = this.session.getTabSize();
  4034. var cursor = this.lead;
  4035. if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
  4036. this.moveCursorBy(0, tabSize);
  4037. else
  4038. this.moveCursorBy(0, 1);
  4039. }
  4040. };
  4041. this.moveCursorLineStart = function() {
  4042. var row = this.lead.row;
  4043. var column = this.lead.column;
  4044. var screenRow = this.session.documentToScreenRow(row, column);
  4045. var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
  4046. var beforeCursor = this.session.getDisplayLine(
  4047. row, null, firstColumnPosition.row,
  4048. firstColumnPosition.column
  4049. );
  4050. var leadingSpace = beforeCursor.match(/^\s*/);
  4051. if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
  4052. firstColumnPosition.column += leadingSpace[0].length;
  4053. this.moveCursorToPosition(firstColumnPosition);
  4054. };
  4055. this.moveCursorLineEnd = function() {
  4056. var lead = this.lead;
  4057. var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
  4058. if (this.lead.column == lineEnd.column) {
  4059. var line = this.session.getLine(lineEnd.row);
  4060. if (lineEnd.column == line.length) {
  4061. var textEnd = line.search(/\s+$/);
  4062. if (textEnd > 0)
  4063. lineEnd.column = textEnd;
  4064. }
  4065. }
  4066. this.moveCursorTo(lineEnd.row, lineEnd.column);
  4067. };
  4068. this.moveCursorFileEnd = function() {
  4069. var row = this.doc.getLength() - 1;
  4070. var column = this.doc.getLine(row).length;
  4071. this.moveCursorTo(row, column);
  4072. };
  4073. this.moveCursorFileStart = function() {
  4074. this.moveCursorTo(0, 0);
  4075. };
  4076. this.moveCursorLongWordRight = function() {
  4077. var row = this.lead.row;
  4078. var column = this.lead.column;
  4079. var line = this.doc.getLine(row);
  4080. var rightOfCursor = line.substring(column);
  4081. var match;
  4082. this.session.nonTokenRe.lastIndex = 0;
  4083. this.session.tokenRe.lastIndex = 0;
  4084. var fold = this.session.getFoldAt(row, column, 1);
  4085. if (fold) {
  4086. this.moveCursorTo(fold.end.row, fold.end.column);
  4087. return;
  4088. }
  4089. if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
  4090. column += this.session.nonTokenRe.lastIndex;
  4091. this.session.nonTokenRe.lastIndex = 0;
  4092. rightOfCursor = line.substring(column);
  4093. }
  4094. if (column >= line.length) {
  4095. this.moveCursorTo(row, line.length);
  4096. this.moveCursorRight();
  4097. if (row < this.doc.getLength() - 1)
  4098. this.moveCursorWordRight();
  4099. return;
  4100. }
  4101. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4102. column += this.session.tokenRe.lastIndex;
  4103. this.session.tokenRe.lastIndex = 0;
  4104. }
  4105. this.moveCursorTo(row, column);
  4106. };
  4107. this.moveCursorLongWordLeft = function() {
  4108. var row = this.lead.row;
  4109. var column = this.lead.column;
  4110. var fold;
  4111. if (fold = this.session.getFoldAt(row, column, -1)) {
  4112. this.moveCursorTo(fold.start.row, fold.start.column);
  4113. return;
  4114. }
  4115. var str = this.session.getFoldStringAt(row, column, -1);
  4116. if (str == null) {
  4117. str = this.doc.getLine(row).substring(0, column);
  4118. }
  4119. var leftOfCursor = lang.stringReverse(str);
  4120. var match;
  4121. this.session.nonTokenRe.lastIndex = 0;
  4122. this.session.tokenRe.lastIndex = 0;
  4123. if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
  4124. column -= this.session.nonTokenRe.lastIndex;
  4125. leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
  4126. this.session.nonTokenRe.lastIndex = 0;
  4127. }
  4128. if (column <= 0) {
  4129. this.moveCursorTo(row, 0);
  4130. this.moveCursorLeft();
  4131. if (row > 0)
  4132. this.moveCursorWordLeft();
  4133. return;
  4134. }
  4135. if (match = this.session.tokenRe.exec(leftOfCursor)) {
  4136. column -= this.session.tokenRe.lastIndex;
  4137. this.session.tokenRe.lastIndex = 0;
  4138. }
  4139. this.moveCursorTo(row, column);
  4140. };
  4141. this.$shortWordEndIndex = function(rightOfCursor) {
  4142. var match, index = 0, ch;
  4143. var whitespaceRe = /\s/;
  4144. var tokenRe = this.session.tokenRe;
  4145. tokenRe.lastIndex = 0;
  4146. if (match = this.session.tokenRe.exec(rightOfCursor)) {
  4147. index = this.session.tokenRe.lastIndex;
  4148. } else {
  4149. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4150. index ++;
  4151. if (index < 1) {
  4152. tokenRe.lastIndex = 0;
  4153. while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
  4154. tokenRe.lastIndex = 0;
  4155. index ++;
  4156. if (whitespaceRe.test(ch)) {
  4157. if (index > 2) {
  4158. index--;
  4159. break;
  4160. } else {
  4161. while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
  4162. index ++;
  4163. if (index > 2)
  4164. break;
  4165. }
  4166. }
  4167. }
  4168. }
  4169. }
  4170. tokenRe.lastIndex = 0;
  4171. return index;
  4172. };
  4173. this.moveCursorShortWordRight = function() {
  4174. var row = this.lead.row;
  4175. var column = this.lead.column;
  4176. var line = this.doc.getLine(row);
  4177. var rightOfCursor = line.substring(column);
  4178. var fold = this.session.getFoldAt(row, column, 1);
  4179. if (fold)
  4180. return this.moveCursorTo(fold.end.row, fold.end.column);
  4181. if (column == line.length) {
  4182. var l = this.doc.getLength();
  4183. do {
  4184. row++;
  4185. rightOfCursor = this.doc.getLine(row);
  4186. } while (row < l && /^\s*$/.test(rightOfCursor));
  4187. if (!/^\s+/.test(rightOfCursor))
  4188. rightOfCursor = "";
  4189. column = 0;
  4190. }
  4191. var index = this.$shortWordEndIndex(rightOfCursor);
  4192. this.moveCursorTo(row, column + index);
  4193. };
  4194. this.moveCursorShortWordLeft = function() {
  4195. var row = this.lead.row;
  4196. var column = this.lead.column;
  4197. var fold;
  4198. if (fold = this.session.getFoldAt(row, column, -1))
  4199. return this.moveCursorTo(fold.start.row, fold.start.column);
  4200. var line = this.session.getLine(row).substring(0, column);
  4201. if (column === 0) {
  4202. do {
  4203. row--;
  4204. line = this.doc.getLine(row);
  4205. } while (row > 0 && /^\s*$/.test(line));
  4206. column = line.length;
  4207. if (!/\s+$/.test(line))
  4208. line = "";
  4209. }
  4210. var leftOfCursor = lang.stringReverse(line);
  4211. var index = this.$shortWordEndIndex(leftOfCursor);
  4212. return this.moveCursorTo(row, column - index);
  4213. };
  4214. this.moveCursorWordRight = function() {
  4215. if (this.session.$selectLongWords)
  4216. this.moveCursorLongWordRight();
  4217. else
  4218. this.moveCursorShortWordRight();
  4219. };
  4220. this.moveCursorWordLeft = function() {
  4221. if (this.session.$selectLongWords)
  4222. this.moveCursorLongWordLeft();
  4223. else
  4224. this.moveCursorShortWordLeft();
  4225. };
  4226. this.moveCursorBy = function(rows, chars) {
  4227. var screenPos = this.session.documentToScreenPosition(
  4228. this.lead.row,
  4229. this.lead.column
  4230. );
  4231. if (chars === 0) {
  4232. if (this.$desiredColumn)
  4233. screenPos.column = this.$desiredColumn;
  4234. else
  4235. this.$desiredColumn = screenPos.column;
  4236. }
  4237. var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
  4238. if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
  4239. if (this.session.lineWidgets && this.session.lineWidgets[docPos.row]) {
  4240. if (docPos.row > 0 || rows > 0)
  4241. docPos.row++;
  4242. }
  4243. }
  4244. this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
  4245. };
  4246. this.moveCursorToPosition = function(position) {
  4247. this.moveCursorTo(position.row, position.column);
  4248. };
  4249. this.moveCursorTo = function(row, column, keepDesiredColumn) {
  4250. var fold = this.session.getFoldAt(row, column, 1);
  4251. if (fold) {
  4252. row = fold.start.row;
  4253. column = fold.start.column;
  4254. }
  4255. this.$keepDesiredColumnOnChange = true;
  4256. this.lead.setPosition(row, column);
  4257. this.$keepDesiredColumnOnChange = false;
  4258. if (!keepDesiredColumn)
  4259. this.$desiredColumn = null;
  4260. };
  4261. this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
  4262. var pos = this.session.screenToDocumentPosition(row, column);
  4263. this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
  4264. };
  4265. this.detach = function() {
  4266. this.lead.detach();
  4267. this.anchor.detach();
  4268. this.session = this.doc = null;
  4269. };
  4270. this.fromOrientedRange = function(range) {
  4271. this.setSelectionRange(range, range.cursor == range.start);
  4272. this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
  4273. };
  4274. this.toOrientedRange = function(range) {
  4275. var r = this.getRange();
  4276. if (range) {
  4277. range.start.column = r.start.column;
  4278. range.start.row = r.start.row;
  4279. range.end.column = r.end.column;
  4280. range.end.row = r.end.row;
  4281. } else {
  4282. range = r;
  4283. }
  4284. range.cursor = this.isBackwards() ? range.start : range.end;
  4285. range.desiredColumn = this.$desiredColumn;
  4286. return range;
  4287. };
  4288. this.getRangeOfMovements = function(func) {
  4289. var start = this.getCursor();
  4290. try {
  4291. func(this);
  4292. var end = this.getCursor();
  4293. return Range.fromPoints(start,end);
  4294. } catch(e) {
  4295. return Range.fromPoints(start,start);
  4296. } finally {
  4297. this.moveCursorToPosition(start);
  4298. }
  4299. };
  4300. this.toJSON = function() {
  4301. if (this.rangeCount) {
  4302. var data = this.ranges.map(function(r) {
  4303. var r1 = r.clone();
  4304. r1.isBackwards = r.cursor == r.start;
  4305. return r1;
  4306. });
  4307. } else {
  4308. var data = this.getRange();
  4309. data.isBackwards = this.isBackwards();
  4310. }
  4311. return data;
  4312. };
  4313. this.fromJSON = function(data) {
  4314. if (data.start == undefined) {
  4315. if (this.rangeList) {
  4316. this.toSingleRange(data[0]);
  4317. for (var i = data.length; i--; ) {
  4318. var r = Range.fromPoints(data[i].start, data[i].end);
  4319. if (data[i].isBackwards)
  4320. r.cursor = r.start;
  4321. this.addRange(r, true);
  4322. }
  4323. return;
  4324. } else
  4325. data = data[0];
  4326. }
  4327. if (this.rangeList)
  4328. this.toSingleRange(data);
  4329. this.setSelectionRange(data, data.isBackwards);
  4330. };
  4331. this.isEqual = function(data) {
  4332. if ((data.length || this.rangeCount) && data.length != this.rangeCount)
  4333. return false;
  4334. if (!data.length || !this.ranges)
  4335. return this.getRange().isEqual(data);
  4336. for (var i = this.ranges.length; i--; ) {
  4337. if (!this.ranges[i].isEqual(data[i]))
  4338. return false;
  4339. }
  4340. return true;
  4341. };
  4342. }).call(Selection.prototype);
  4343. exports.Selection = Selection;
  4344. });
  4345. ace.define("ace/tokenizer",["require","exports","module","ace/config"], function(require, exports, module) {
  4346. "use strict";
  4347. var config = require("./config");
  4348. var MAX_TOKEN_COUNT = 2000;
  4349. var Tokenizer = function(rules) {
  4350. this.states = rules;
  4351. this.regExps = {};
  4352. this.matchMappings = {};
  4353. for (var key in this.states) {
  4354. var state = this.states[key];
  4355. var ruleRegExps = [];
  4356. var matchTotal = 0;
  4357. var mapping = this.matchMappings[key] = {defaultToken: "text"};
  4358. var flag = "g";
  4359. var splitterRurles = [];
  4360. for (var i = 0; i < state.length; i++) {
  4361. var rule = state[i];
  4362. if (rule.defaultToken)
  4363. mapping.defaultToken = rule.defaultToken;
  4364. if (rule.caseInsensitive)
  4365. flag = "gi";
  4366. if (rule.regex == null)
  4367. continue;
  4368. if (rule.regex instanceof RegExp)
  4369. rule.regex = rule.regex.toString().slice(1, -1);
  4370. var adjustedregex = rule.regex;
  4371. var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
  4372. if (Array.isArray(rule.token)) {
  4373. if (rule.token.length == 1 || matchcount == 1) {
  4374. rule.token = rule.token[0];
  4375. } else if (matchcount - 1 != rule.token.length) {
  4376. this.reportError("number of classes and regexp groups doesn't match", {
  4377. rule: rule,
  4378. groupCount: matchcount - 1
  4379. });
  4380. rule.token = rule.token[0];
  4381. } else {
  4382. rule.tokenArray = rule.token;
  4383. rule.token = null;
  4384. rule.onMatch = this.$arrayTokens;
  4385. }
  4386. } else if (typeof rule.token == "function" && !rule.onMatch) {
  4387. if (matchcount > 1)
  4388. rule.onMatch = this.$applyToken;
  4389. else
  4390. rule.onMatch = rule.token;
  4391. }
  4392. if (matchcount > 1) {
  4393. if (/\\\d/.test(rule.regex)) {
  4394. adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
  4395. return "\\" + (parseInt(digit, 10) + matchTotal + 1);
  4396. });
  4397. } else {
  4398. matchcount = 1;
  4399. adjustedregex = this.removeCapturingGroups(rule.regex);
  4400. }
  4401. if (!rule.splitRegex && typeof rule.token != "string")
  4402. splitterRurles.push(rule); // flag will be known only at the very end
  4403. }
  4404. mapping[matchTotal] = i;
  4405. matchTotal += matchcount;
  4406. ruleRegExps.push(adjustedregex);
  4407. if (!rule.onMatch)
  4408. rule.onMatch = null;
  4409. }
  4410. if (!ruleRegExps.length) {
  4411. mapping[0] = 0;
  4412. ruleRegExps.push("$");
  4413. }
  4414. splitterRurles.forEach(function(rule) {
  4415. rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
  4416. }, this);
  4417. this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
  4418. }
  4419. };
  4420. (function() {
  4421. this.$setMaxTokenCount = function(m) {
  4422. MAX_TOKEN_COUNT = m | 0;
  4423. };
  4424. this.$applyToken = function(str) {
  4425. var values = this.splitRegex.exec(str).slice(1);
  4426. var types = this.token.apply(this, values);
  4427. if (typeof types === "string")
  4428. return [{type: types, value: str}];
  4429. var tokens = [];
  4430. for (var i = 0, l = types.length; i < l; i++) {
  4431. if (values[i])
  4432. tokens[tokens.length] = {
  4433. type: types[i],
  4434. value: values[i]
  4435. };
  4436. }
  4437. return tokens;
  4438. };
  4439. this.$arrayTokens = function(str) {
  4440. if (!str)
  4441. return [];
  4442. var values = this.splitRegex.exec(str);
  4443. if (!values)
  4444. return "text";
  4445. var tokens = [];
  4446. var types = this.tokenArray;
  4447. for (var i = 0, l = types.length; i < l; i++) {
  4448. if (values[i + 1])
  4449. tokens[tokens.length] = {
  4450. type: types[i],
  4451. value: values[i + 1]
  4452. };
  4453. }
  4454. return tokens;
  4455. };
  4456. this.removeCapturingGroups = function(src) {
  4457. var r = src.replace(
  4458. /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
  4459. function(x, y) {return y ? "(?:" : x;}
  4460. );
  4461. return r;
  4462. };
  4463. this.createSplitterRegexp = function(src, flag) {
  4464. if (src.indexOf("(?=") != -1) {
  4465. var stack = 0;
  4466. var inChClass = false;
  4467. var lastCapture = {};
  4468. src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
  4469. m, esc, parenOpen, parenClose, square, index
  4470. ) {
  4471. if (inChClass) {
  4472. inChClass = square != "]";
  4473. } else if (square) {
  4474. inChClass = true;
  4475. } else if (parenClose) {
  4476. if (stack == lastCapture.stack) {
  4477. lastCapture.end = index+1;
  4478. lastCapture.stack = -1;
  4479. }
  4480. stack--;
  4481. } else if (parenOpen) {
  4482. stack++;
  4483. if (parenOpen.length != 1) {
  4484. lastCapture.stack = stack
  4485. lastCapture.start = index;
  4486. }
  4487. }
  4488. return m;
  4489. });
  4490. if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
  4491. src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
  4492. }
  4493. if (src.charAt(0) != "^") src = "^" + src;
  4494. if (src.charAt(src.length - 1) != "$") src += "$";
  4495. return new RegExp(src, (flag||"").replace("g", ""));
  4496. };
  4497. this.getLineTokens = function(line, startState) {
  4498. if (startState && typeof startState != "string") {
  4499. var stack = startState.slice(0);
  4500. startState = stack[0];
  4501. if (startState === "#tmp") {
  4502. stack.shift()
  4503. startState = stack.shift()
  4504. }
  4505. } else
  4506. var stack = [];
  4507. var currentState = startState || "start";
  4508. var state = this.states[currentState];
  4509. if (!state) {
  4510. currentState = "start";
  4511. state = this.states[currentState];
  4512. }
  4513. var mapping = this.matchMappings[currentState];
  4514. var re = this.regExps[currentState];
  4515. re.lastIndex = 0;
  4516. var match, tokens = [];
  4517. var lastIndex = 0;
  4518. var matchAttempts = 0;
  4519. var token = {type: null, value: ""};
  4520. while (match = re.exec(line)) {
  4521. var type = mapping.defaultToken;
  4522. var rule = null;
  4523. var value = match[0];
  4524. var index = re.lastIndex;
  4525. if (index - value.length > lastIndex) {
  4526. var skipped = line.substring(lastIndex, index - value.length);
  4527. if (token.type == type) {
  4528. token.value += skipped;
  4529. } else {
  4530. if (token.type)
  4531. tokens.push(token);
  4532. token = {type: type, value: skipped};
  4533. }
  4534. }
  4535. for (var i = 0; i < match.length-2; i++) {
  4536. if (match[i + 1] === undefined)
  4537. continue;
  4538. rule = state[mapping[i]];
  4539. if (rule.onMatch)
  4540. type = rule.onMatch(value, currentState, stack);
  4541. else
  4542. type = rule.token;
  4543. if (rule.next) {
  4544. if (typeof rule.next == "string") {
  4545. currentState = rule.next;
  4546. } else {
  4547. currentState = rule.next(currentState, stack);
  4548. }
  4549. state = this.states[currentState];
  4550. if (!state) {
  4551. this.reportError("state doesn't exist", currentState);
  4552. currentState = "start";
  4553. state = this.states[currentState];
  4554. }
  4555. mapping = this.matchMappings[currentState];
  4556. lastIndex = index;
  4557. re = this.regExps[currentState];
  4558. re.lastIndex = index;
  4559. }
  4560. break;
  4561. }
  4562. if (value) {
  4563. if (typeof type === "string") {
  4564. if ((!rule || rule.merge !== false) && token.type === type) {
  4565. token.value += value;
  4566. } else {
  4567. if (token.type)
  4568. tokens.push(token);
  4569. token = {type: type, value: value};
  4570. }
  4571. } else if (type) {
  4572. if (token.type)
  4573. tokens.push(token);
  4574. token = {type: null, value: ""};
  4575. for (var i = 0; i < type.length; i++)
  4576. tokens.push(type[i]);
  4577. }
  4578. }
  4579. if (lastIndex == line.length)
  4580. break;
  4581. lastIndex = index;
  4582. if (matchAttempts++ > MAX_TOKEN_COUNT) {
  4583. if (matchAttempts > 2 * line.length) {
  4584. this.reportError("infinite loop with in ace tokenizer", {
  4585. startState: startState,
  4586. line: line
  4587. });
  4588. }
  4589. while (lastIndex < line.length) {
  4590. if (token.type)
  4591. tokens.push(token);
  4592. token = {
  4593. value: line.substring(lastIndex, lastIndex += 2000),
  4594. type: "overflow"
  4595. };
  4596. }
  4597. currentState = "start";
  4598. stack = [];
  4599. break;
  4600. }
  4601. }
  4602. if (token.type)
  4603. tokens.push(token);
  4604. if (stack.length > 1) {
  4605. if (stack[0] !== currentState)
  4606. stack.unshift("#tmp", currentState);
  4607. }
  4608. return {
  4609. tokens : tokens,
  4610. state : stack.length ? stack : currentState
  4611. };
  4612. };
  4613. this.reportError = config.reportError;
  4614. }).call(Tokenizer.prototype);
  4615. exports.Tokenizer = Tokenizer;
  4616. });
  4617. ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
  4618. "use strict";
  4619. var lang = require("../lib/lang");
  4620. var TextHighlightRules = function() {
  4621. this.$rules = {
  4622. "start" : [{
  4623. token : "empty_line",
  4624. regex : '^$'
  4625. }, {
  4626. defaultToken : "text"
  4627. }]
  4628. };
  4629. };
  4630. (function() {
  4631. this.addRules = function(rules, prefix) {
  4632. if (!prefix) {
  4633. for (var key in rules)
  4634. this.$rules[key] = rules[key];
  4635. return;
  4636. }
  4637. for (var key in rules) {
  4638. var state = rules[key];
  4639. for (var i = 0; i < state.length; i++) {
  4640. var rule = state[i];
  4641. if (rule.next || rule.onMatch) {
  4642. if (typeof rule.next == "string") {
  4643. if (rule.next.indexOf(prefix) !== 0)
  4644. rule.next = prefix + rule.next;
  4645. }
  4646. if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
  4647. rule.nextState = prefix + rule.nextState;
  4648. }
  4649. }
  4650. this.$rules[prefix + key] = state;
  4651. }
  4652. };
  4653. this.getRules = function() {
  4654. return this.$rules;
  4655. };
  4656. this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
  4657. var embedRules = typeof HighlightRules == "function"
  4658. ? new HighlightRules().getRules()
  4659. : HighlightRules;
  4660. if (states) {
  4661. for (var i = 0; i < states.length; i++)
  4662. states[i] = prefix + states[i];
  4663. } else {
  4664. states = [];
  4665. for (var key in embedRules)
  4666. states.push(prefix + key);
  4667. }
  4668. this.addRules(embedRules, prefix);
  4669. if (escapeRules) {
  4670. var addRules = Array.prototype[append ? "push" : "unshift"];
  4671. for (var i = 0; i < states.length; i++)
  4672. addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
  4673. }
  4674. if (!this.$embeds)
  4675. this.$embeds = [];
  4676. this.$embeds.push(prefix);
  4677. };
  4678. this.getEmbeds = function() {
  4679. return this.$embeds;
  4680. };
  4681. var pushState = function(currentState, stack) {
  4682. if (currentState != "start" || stack.length)
  4683. stack.unshift(this.nextState, currentState);
  4684. return this.nextState;
  4685. };
  4686. var popState = function(currentState, stack) {
  4687. stack.shift();
  4688. return stack.shift() || "start";
  4689. };
  4690. this.normalizeRules = function() {
  4691. var id = 0;
  4692. var rules = this.$rules;
  4693. function processState(key) {
  4694. var state = rules[key];
  4695. state.processed = true;
  4696. for (var i = 0; i < state.length; i++) {
  4697. var rule = state[i];
  4698. var toInsert = null;
  4699. if (Array.isArray(rule)) {
  4700. toInsert = rule;
  4701. rule = {};
  4702. }
  4703. if (!rule.regex && rule.start) {
  4704. rule.regex = rule.start;
  4705. if (!rule.next)
  4706. rule.next = [];
  4707. rule.next.push({
  4708. defaultToken: rule.token
  4709. }, {
  4710. token: rule.token + ".end",
  4711. regex: rule.end || rule.start,
  4712. next: "pop"
  4713. });
  4714. rule.token = rule.token + ".start";
  4715. rule.push = true;
  4716. }
  4717. var next = rule.next || rule.push;
  4718. if (next && Array.isArray(next)) {
  4719. var stateName = rule.stateName;
  4720. if (!stateName) {
  4721. stateName = rule.token;
  4722. if (typeof stateName != "string")
  4723. stateName = stateName[0] || "";
  4724. if (rules[stateName])
  4725. stateName += id++;
  4726. }
  4727. rules[stateName] = next;
  4728. rule.next = stateName;
  4729. processState(stateName);
  4730. } else if (next == "pop") {
  4731. rule.next = popState;
  4732. }
  4733. if (rule.push) {
  4734. rule.nextState = rule.next || rule.push;
  4735. rule.next = pushState;
  4736. delete rule.push;
  4737. }
  4738. if (rule.rules) {
  4739. for (var r in rule.rules) {
  4740. if (rules[r]) {
  4741. if (rules[r].push)
  4742. rules[r].push.apply(rules[r], rule.rules[r]);
  4743. } else {
  4744. rules[r] = rule.rules[r];
  4745. }
  4746. }
  4747. }
  4748. var includeName = typeof rule == "string"
  4749. ? rule
  4750. : typeof rule.include == "string"
  4751. ? rule.include
  4752. : "";
  4753. if (includeName) {
  4754. toInsert = rules[includeName];
  4755. }
  4756. if (toInsert) {
  4757. var args = [i, 1].concat(toInsert);
  4758. if (rule.noEscape)
  4759. args = args.filter(function(x) {return !x.next;});
  4760. state.splice.apply(state, args);
  4761. i--;
  4762. }
  4763. if (rule.keywordMap) {
  4764. rule.token = this.createKeywordMapper(
  4765. rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
  4766. );
  4767. delete rule.defaultToken;
  4768. }
  4769. }
  4770. }
  4771. Object.keys(rules).forEach(processState, this);
  4772. };
  4773. this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
  4774. var keywords = Object.create(null);
  4775. Object.keys(map).forEach(function(className) {
  4776. var a = map[className];
  4777. if (ignoreCase)
  4778. a = a.toLowerCase();
  4779. var list = a.split(splitChar || "|");
  4780. for (var i = list.length; i--; )
  4781. keywords[list[i]] = className;
  4782. });
  4783. if (Object.getPrototypeOf(keywords)) {
  4784. keywords.__proto__ = null;
  4785. }
  4786. this.$keywordList = Object.keys(keywords);
  4787. map = null;
  4788. return ignoreCase
  4789. ? function(value) {return keywords[value.toLowerCase()] || defaultToken }
  4790. : function(value) {return keywords[value] || defaultToken };
  4791. };
  4792. this.getKeywords = function() {
  4793. return this.$keywords;
  4794. };
  4795. }).call(TextHighlightRules.prototype);
  4796. exports.TextHighlightRules = TextHighlightRules;
  4797. });
  4798. ace.define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
  4799. "use strict";
  4800. var Behaviour = function() {
  4801. this.$behaviours = {};
  4802. };
  4803. (function () {
  4804. this.add = function (name, action, callback) {
  4805. switch (undefined) {
  4806. case this.$behaviours:
  4807. this.$behaviours = {};
  4808. case this.$behaviours[name]:
  4809. this.$behaviours[name] = {};
  4810. }
  4811. this.$behaviours[name][action] = callback;
  4812. }
  4813. this.addBehaviours = function (behaviours) {
  4814. for (var key in behaviours) {
  4815. for (var action in behaviours[key]) {
  4816. this.add(key, action, behaviours[key][action]);
  4817. }
  4818. }
  4819. }
  4820. this.remove = function (name) {
  4821. if (this.$behaviours && this.$behaviours[name]) {
  4822. delete this.$behaviours[name];
  4823. }
  4824. }
  4825. this.inherit = function (mode, filter) {
  4826. if (typeof mode === "function") {
  4827. var behaviours = new mode().getBehaviours(filter);
  4828. } else {
  4829. var behaviours = mode.getBehaviours(filter);
  4830. }
  4831. this.addBehaviours(behaviours);
  4832. }
  4833. this.getBehaviours = function (filter) {
  4834. if (!filter) {
  4835. return this.$behaviours;
  4836. } else {
  4837. var ret = {}
  4838. for (var i = 0; i < filter.length; i++) {
  4839. if (this.$behaviours[filter[i]]) {
  4840. ret[filter[i]] = this.$behaviours[filter[i]];
  4841. }
  4842. }
  4843. return ret;
  4844. }
  4845. }
  4846. }).call(Behaviour.prototype);
  4847. exports.Behaviour = Behaviour;
  4848. });
  4849. ace.define("ace/token_iterator",["require","exports","module"], function(require, exports, module) {
  4850. "use strict";
  4851. var TokenIterator = function(session, initialRow, initialColumn) {
  4852. this.$session = session;
  4853. this.$row = initialRow;
  4854. this.$rowTokens = session.getTokens(initialRow);
  4855. var token = session.getTokenAt(initialRow, initialColumn);
  4856. this.$tokenIndex = token ? token.index : -1;
  4857. };
  4858. (function() {
  4859. this.stepBackward = function() {
  4860. this.$tokenIndex -= 1;
  4861. while (this.$tokenIndex < 0) {
  4862. this.$row -= 1;
  4863. if (this.$row < 0) {
  4864. this.$row = 0;
  4865. return null;
  4866. }
  4867. this.$rowTokens = this.$session.getTokens(this.$row);
  4868. this.$tokenIndex = this.$rowTokens.length - 1;
  4869. }
  4870. return this.$rowTokens[this.$tokenIndex];
  4871. };
  4872. this.stepForward = function() {
  4873. this.$tokenIndex += 1;
  4874. var rowCount;
  4875. while (this.$tokenIndex >= this.$rowTokens.length) {
  4876. this.$row += 1;
  4877. if (!rowCount)
  4878. rowCount = this.$session.getLength();
  4879. if (this.$row >= rowCount) {
  4880. this.$row = rowCount - 1;
  4881. return null;
  4882. }
  4883. this.$rowTokens = this.$session.getTokens(this.$row);
  4884. this.$tokenIndex = 0;
  4885. }
  4886. return this.$rowTokens[this.$tokenIndex];
  4887. };
  4888. this.getCurrentToken = function () {
  4889. return this.$rowTokens[this.$tokenIndex];
  4890. };
  4891. this.getCurrentTokenRow = function () {
  4892. return this.$row;
  4893. };
  4894. this.getCurrentTokenColumn = function() {
  4895. var rowTokens = this.$rowTokens;
  4896. var tokenIndex = this.$tokenIndex;
  4897. var column = rowTokens[tokenIndex].start;
  4898. if (column !== undefined)
  4899. return column;
  4900. column = 0;
  4901. while (tokenIndex > 0) {
  4902. tokenIndex -= 1;
  4903. column += rowTokens[tokenIndex].value.length;
  4904. }
  4905. return column;
  4906. };
  4907. this.getCurrentTokenPosition = function() {
  4908. return {row: this.$row, column: this.getCurrentTokenColumn()};
  4909. };
  4910. }).call(TokenIterator.prototype);
  4911. exports.TokenIterator = TokenIterator;
  4912. });
  4913. ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
  4914. "use strict";
  4915. var oop = require("../../lib/oop");
  4916. var Behaviour = require("../behaviour").Behaviour;
  4917. var TokenIterator = require("../../token_iterator").TokenIterator;
  4918. var lang = require("../../lib/lang");
  4919. var SAFE_INSERT_IN_TOKENS =
  4920. ["text", "paren.rparen", "punctuation.operator"];
  4921. var SAFE_INSERT_BEFORE_TOKENS =
  4922. ["text", "paren.rparen", "punctuation.operator", "comment"];
  4923. var context;
  4924. var contextCache = {};
  4925. var initContext = function(editor) {
  4926. var id = -1;
  4927. if (editor.multiSelect) {
  4928. id = editor.selection.index;
  4929. if (contextCache.rangeCount != editor.multiSelect.rangeCount)
  4930. contextCache = {rangeCount: editor.multiSelect.rangeCount};
  4931. }
  4932. if (contextCache[id])
  4933. return context = contextCache[id];
  4934. context = contextCache[id] = {
  4935. autoInsertedBrackets: 0,
  4936. autoInsertedRow: -1,
  4937. autoInsertedLineEnd: "",
  4938. maybeInsertedBrackets: 0,
  4939. maybeInsertedRow: -1,
  4940. maybeInsertedLineStart: "",
  4941. maybeInsertedLineEnd: ""
  4942. };
  4943. };
  4944. var getWrapped = function(selection, selected, opening, closing) {
  4945. var rowDiff = selection.end.row - selection.start.row;
  4946. return {
  4947. text: opening + selected + closing,
  4948. selection: [
  4949. 0,
  4950. selection.start.column + 1,
  4951. rowDiff,
  4952. selection.end.column + (rowDiff ? 0 : 1)
  4953. ]
  4954. };
  4955. };
  4956. var CstyleBehaviour = function() {
  4957. this.add("braces", "insertion", function(state, action, editor, session, text) {
  4958. var cursor = editor.getCursorPosition();
  4959. var line = session.doc.getLine(cursor.row);
  4960. if (text == '{') {
  4961. initContext(editor);
  4962. var selection = editor.getSelectionRange();
  4963. var selected = session.doc.getTextRange(selection);
  4964. if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
  4965. return getWrapped(selection, selected, '{', '}');
  4966. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  4967. if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
  4968. CstyleBehaviour.recordAutoInsert(editor, session, "}");
  4969. return {
  4970. text: '{}',
  4971. selection: [1, 1]
  4972. };
  4973. } else {
  4974. CstyleBehaviour.recordMaybeInsert(editor, session, "{");
  4975. return {
  4976. text: '{',
  4977. selection: [1, 1]
  4978. };
  4979. }
  4980. }
  4981. } else if (text == '}') {
  4982. initContext(editor);
  4983. var rightChar = line.substring(cursor.column, cursor.column + 1);
  4984. if (rightChar == '}') {
  4985. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  4986. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  4987. CstyleBehaviour.popAutoInsertedClosing();
  4988. return {
  4989. text: '',
  4990. selection: [1, 1]
  4991. };
  4992. }
  4993. }
  4994. } else if (text == "\n" || text == "\r\n") {
  4995. initContext(editor);
  4996. var closing = "";
  4997. if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
  4998. closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
  4999. CstyleBehaviour.clearMaybeInsertedClosing();
  5000. }
  5001. var rightChar = line.substring(cursor.column, cursor.column + 1);
  5002. if (rightChar === '}') {
  5003. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
  5004. if (!openBracePos)
  5005. return null;
  5006. var next_indent = this.$getIndent(session.getLine(openBracePos.row));
  5007. } else if (closing) {
  5008. var next_indent = this.$getIndent(line);
  5009. } else {
  5010. CstyleBehaviour.clearMaybeInsertedClosing();
  5011. return;
  5012. }
  5013. var indent = next_indent + session.getTabString();
  5014. return {
  5015. text: '\n' + indent + '\n' + next_indent + closing,
  5016. selection: [1, indent.length, 1, indent.length]
  5017. };
  5018. } else {
  5019. CstyleBehaviour.clearMaybeInsertedClosing();
  5020. }
  5021. });
  5022. this.add("braces", "deletion", function(state, action, editor, session, range) {
  5023. var selected = session.doc.getTextRange(range);
  5024. if (!range.isMultiLine() && selected == '{') {
  5025. initContext(editor);
  5026. var line = session.doc.getLine(range.start.row);
  5027. var rightChar = line.substring(range.end.column, range.end.column + 1);
  5028. if (rightChar == '}') {
  5029. range.end.column++;
  5030. return range;
  5031. } else {
  5032. context.maybeInsertedBrackets--;
  5033. }
  5034. }
  5035. });
  5036. this.add("parens", "insertion", function(state, action, editor, session, text) {
  5037. if (text == '(') {
  5038. initContext(editor);
  5039. var selection = editor.getSelectionRange();
  5040. var selected = session.doc.getTextRange(selection);
  5041. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  5042. return getWrapped(selection, selected, '(', ')');
  5043. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  5044. CstyleBehaviour.recordAutoInsert(editor, session, ")");
  5045. return {
  5046. text: '()',
  5047. selection: [1, 1]
  5048. };
  5049. }
  5050. } else if (text == ')') {
  5051. initContext(editor);
  5052. var cursor = editor.getCursorPosition();
  5053. var line = session.doc.getLine(cursor.row);
  5054. var rightChar = line.substring(cursor.column, cursor.column + 1);
  5055. if (rightChar == ')') {
  5056. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  5057. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  5058. CstyleBehaviour.popAutoInsertedClosing();
  5059. return {
  5060. text: '',
  5061. selection: [1, 1]
  5062. };
  5063. }
  5064. }
  5065. }
  5066. });
  5067. this.add("parens", "deletion", function(state, action, editor, session, range) {
  5068. var selected = session.doc.getTextRange(range);
  5069. if (!range.isMultiLine() && selected == '(') {
  5070. initContext(editor);
  5071. var line = session.doc.getLine(range.start.row);
  5072. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  5073. if (rightChar == ')') {
  5074. range.end.column++;
  5075. return range;
  5076. }
  5077. }
  5078. });
  5079. this.add("brackets", "insertion", function(state, action, editor, session, text) {
  5080. if (text == '[') {
  5081. initContext(editor);
  5082. var selection = editor.getSelectionRange();
  5083. var selected = session.doc.getTextRange(selection);
  5084. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  5085. return getWrapped(selection, selected, '[', ']');
  5086. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  5087. CstyleBehaviour.recordAutoInsert(editor, session, "]");
  5088. return {
  5089. text: '[]',
  5090. selection: [1, 1]
  5091. };
  5092. }
  5093. } else if (text == ']') {
  5094. initContext(editor);
  5095. var cursor = editor.getCursorPosition();
  5096. var line = session.doc.getLine(cursor.row);
  5097. var rightChar = line.substring(cursor.column, cursor.column + 1);
  5098. if (rightChar == ']') {
  5099. var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
  5100. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  5101. CstyleBehaviour.popAutoInsertedClosing();
  5102. return {
  5103. text: '',
  5104. selection: [1, 1]
  5105. };
  5106. }
  5107. }
  5108. }
  5109. });
  5110. this.add("brackets", "deletion", function(state, action, editor, session, range) {
  5111. var selected = session.doc.getTextRange(range);
  5112. if (!range.isMultiLine() && selected == '[') {
  5113. initContext(editor);
  5114. var line = session.doc.getLine(range.start.row);
  5115. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  5116. if (rightChar == ']') {
  5117. range.end.column++;
  5118. return range;
  5119. }
  5120. }
  5121. });
  5122. this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
  5123. if (text == '"' || text == "'") {
  5124. if (this.lineCommentStart && this.lineCommentStart.indexOf(text) != -1)
  5125. return;
  5126. initContext(editor);
  5127. var quote = text;
  5128. var selection = editor.getSelectionRange();
  5129. var selected = session.doc.getTextRange(selection);
  5130. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  5131. return getWrapped(selection, selected, quote, quote);
  5132. } else if (!selected) {
  5133. var cursor = editor.getCursorPosition();
  5134. var line = session.doc.getLine(cursor.row);
  5135. var leftChar = line.substring(cursor.column-1, cursor.column);
  5136. var rightChar = line.substring(cursor.column, cursor.column + 1);
  5137. var token = session.getTokenAt(cursor.row, cursor.column);
  5138. var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
  5139. if (leftChar == "\\" && token && /escape/.test(token.type))
  5140. return null;
  5141. var stringBefore = token && /string|escape/.test(token.type);
  5142. var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
  5143. var pair;
  5144. if (rightChar == quote) {
  5145. pair = stringBefore !== stringAfter;
  5146. if (pair && /string\.end/.test(rightToken.type))
  5147. pair = false;
  5148. } else {
  5149. if (stringBefore && !stringAfter)
  5150. return null; // wrap string with different quote
  5151. if (stringBefore && stringAfter)
  5152. return null; // do not pair quotes inside strings
  5153. var wordRe = session.$mode.tokenRe;
  5154. wordRe.lastIndex = 0;
  5155. var isWordBefore = wordRe.test(leftChar);
  5156. wordRe.lastIndex = 0;
  5157. var isWordAfter = wordRe.test(leftChar);
  5158. if (isWordBefore || isWordAfter)
  5159. return null; // before or after alphanumeric
  5160. if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
  5161. return null; // there is rightChar and it isn't closing
  5162. pair = true;
  5163. }
  5164. return {
  5165. text: pair ? quote + quote : "",
  5166. selection: [1,1]
  5167. };
  5168. }
  5169. }
  5170. });
  5171. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  5172. var selected = session.doc.getTextRange(range);
  5173. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  5174. initContext(editor);
  5175. var line = session.doc.getLine(range.start.row);
  5176. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  5177. if (rightChar == selected) {
  5178. range.end.column++;
  5179. return range;
  5180. }
  5181. }
  5182. });
  5183. };
  5184. CstyleBehaviour.isSaneInsertion = function(editor, session) {
  5185. var cursor = editor.getCursorPosition();
  5186. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5187. if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
  5188. var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
  5189. if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
  5190. return false;
  5191. }
  5192. iterator.stepForward();
  5193. return iterator.getCurrentTokenRow() !== cursor.row ||
  5194. this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
  5195. };
  5196. CstyleBehaviour.$matchTokenType = function(token, types) {
  5197. return types.indexOf(token.type || token) > -1;
  5198. };
  5199. CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
  5200. var cursor = editor.getCursorPosition();
  5201. var line = session.doc.getLine(cursor.row);
  5202. if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
  5203. context.autoInsertedBrackets = 0;
  5204. context.autoInsertedRow = cursor.row;
  5205. context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
  5206. context.autoInsertedBrackets++;
  5207. };
  5208. CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
  5209. var cursor = editor.getCursorPosition();
  5210. var line = session.doc.getLine(cursor.row);
  5211. if (!this.isMaybeInsertedClosing(cursor, line))
  5212. context.maybeInsertedBrackets = 0;
  5213. context.maybeInsertedRow = cursor.row;
  5214. context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
  5215. context.maybeInsertedLineEnd = line.substr(cursor.column);
  5216. context.maybeInsertedBrackets++;
  5217. };
  5218. CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
  5219. return context.autoInsertedBrackets > 0 &&
  5220. cursor.row === context.autoInsertedRow &&
  5221. bracket === context.autoInsertedLineEnd[0] &&
  5222. line.substr(cursor.column) === context.autoInsertedLineEnd;
  5223. };
  5224. CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
  5225. return context.maybeInsertedBrackets > 0 &&
  5226. cursor.row === context.maybeInsertedRow &&
  5227. line.substr(cursor.column) === context.maybeInsertedLineEnd &&
  5228. line.substr(0, cursor.column) == context.maybeInsertedLineStart;
  5229. };
  5230. CstyleBehaviour.popAutoInsertedClosing = function() {
  5231. context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
  5232. context.autoInsertedBrackets--;
  5233. };
  5234. CstyleBehaviour.clearMaybeInsertedClosing = function() {
  5235. if (context) {
  5236. context.maybeInsertedBrackets = 0;
  5237. context.maybeInsertedRow = -1;
  5238. }
  5239. };
  5240. oop.inherits(CstyleBehaviour, Behaviour);
  5241. exports.CstyleBehaviour = CstyleBehaviour;
  5242. });
  5243. ace.define("ace/unicode",["require","exports","module"], function(require, exports, module) {
  5244. "use strict";
  5245. exports.packages = {};
  5246. addUnicodePackage({
  5247. 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",
  5248. 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",
  5249. 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",
  5250. Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
  5251. Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
  5252. 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",
  5253. 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",
  5254. 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",
  5255. 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",
  5256. Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
  5257. 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",
  5258. 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",
  5259. Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
  5260. No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
  5261. 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",
  5262. Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
  5263. Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
  5264. Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
  5265. Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
  5266. Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
  5267. Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
  5268. 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",
  5269. 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",
  5270. 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",
  5271. Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
  5272. Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
  5273. 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",
  5274. Z: "002000A01680180E2000-200A20282029202F205F3000",
  5275. Zs: "002000A01680180E2000-200A202F205F3000",
  5276. Zl: "2028",
  5277. Zp: "2029",
  5278. 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",
  5279. Cc: "0000-001F007F-009F",
  5280. Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
  5281. Co: "E000-F8FF",
  5282. Cs: "D800-DFFF",
  5283. 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"
  5284. });
  5285. function addUnicodePackage (pack) {
  5286. var codePoint = /\w{4}/g;
  5287. for (var name in pack)
  5288. exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
  5289. }
  5290. });
  5291. ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(require, exports, module) {
  5292. "use strict";
  5293. var Tokenizer = require("../tokenizer").Tokenizer;
  5294. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5295. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  5296. var unicode = require("../unicode");
  5297. var lang = require("../lib/lang");
  5298. var TokenIterator = require("../token_iterator").TokenIterator;
  5299. var Range = require("../range").Range;
  5300. var Mode = function() {
  5301. this.HighlightRules = TextHighlightRules;
  5302. };
  5303. (function() {
  5304. this.$defaultBehaviour = new CstyleBehaviour();
  5305. this.tokenRe = new RegExp("^["
  5306. + unicode.packages.L
  5307. + unicode.packages.Mn + unicode.packages.Mc
  5308. + unicode.packages.Nd
  5309. + unicode.packages.Pc + "\\$_]+", "g"
  5310. );
  5311. this.nonTokenRe = new RegExp("^(?:[^"
  5312. + unicode.packages.L
  5313. + unicode.packages.Mn + unicode.packages.Mc
  5314. + unicode.packages.Nd
  5315. + unicode.packages.Pc + "\\$_]|\\s])+", "g"
  5316. );
  5317. this.getTokenizer = function() {
  5318. if (!this.$tokenizer) {
  5319. this.$highlightRules = this.$highlightRules || new this.HighlightRules(this.$highlightRuleConfig);
  5320. this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
  5321. }
  5322. return this.$tokenizer;
  5323. };
  5324. this.lineCommentStart = "";
  5325. this.blockComment = "";
  5326. this.toggleCommentLines = function(state, session, startRow, endRow) {
  5327. var doc = session.doc;
  5328. var ignoreBlankLines = true;
  5329. var shouldRemove = true;
  5330. var minIndent = Infinity;
  5331. var tabSize = session.getTabSize();
  5332. var insertAtTabStop = false;
  5333. if (!this.lineCommentStart) {
  5334. if (!this.blockComment)
  5335. return false;
  5336. var lineCommentStart = this.blockComment.start;
  5337. var lineCommentEnd = this.blockComment.end;
  5338. var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
  5339. var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
  5340. var comment = function(line, i) {
  5341. if (testRemove(line, i))
  5342. return;
  5343. if (!ignoreBlankLines || /\S/.test(line)) {
  5344. doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
  5345. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  5346. }
  5347. };
  5348. var uncomment = function(line, i) {
  5349. var m;
  5350. if (m = line.match(regexpEnd))
  5351. doc.removeInLine(i, line.length - m[0].length, line.length);
  5352. if (m = line.match(regexpStart))
  5353. doc.removeInLine(i, m[1].length, m[0].length);
  5354. };
  5355. var testRemove = function(line, row) {
  5356. if (regexpStart.test(line))
  5357. return true;
  5358. var tokens = session.getTokens(row);
  5359. for (var i = 0; i < tokens.length; i++) {
  5360. if (tokens[i].type === "comment")
  5361. return true;
  5362. }
  5363. };
  5364. } else {
  5365. if (Array.isArray(this.lineCommentStart)) {
  5366. var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
  5367. var lineCommentStart = this.lineCommentStart[0];
  5368. } else {
  5369. var regexpStart = lang.escapeRegExp(this.lineCommentStart);
  5370. var lineCommentStart = this.lineCommentStart;
  5371. }
  5372. regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
  5373. insertAtTabStop = session.getUseSoftTabs();
  5374. var uncomment = function(line, i) {
  5375. var m = line.match(regexpStart);
  5376. if (!m) return;
  5377. var start = m[1].length, end = m[0].length;
  5378. if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
  5379. end--;
  5380. doc.removeInLine(i, start, end);
  5381. };
  5382. var commentWithSpace = lineCommentStart + " ";
  5383. var comment = function(line, i) {
  5384. if (!ignoreBlankLines || /\S/.test(line)) {
  5385. if (shouldInsertSpace(line, minIndent, minIndent))
  5386. doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
  5387. else
  5388. doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
  5389. }
  5390. };
  5391. var testRemove = function(line, i) {
  5392. return regexpStart.test(line);
  5393. };
  5394. var shouldInsertSpace = function(line, before, after) {
  5395. var spaces = 0;
  5396. while (before-- && line.charAt(before) == " ")
  5397. spaces++;
  5398. if (spaces % tabSize != 0)
  5399. return false;
  5400. var spaces = 0;
  5401. while (line.charAt(after++) == " ")
  5402. spaces++;
  5403. if (tabSize > 2)
  5404. return spaces % tabSize != tabSize - 1;
  5405. else
  5406. return spaces % tabSize == 0;
  5407. return true;
  5408. };
  5409. }
  5410. function iter(fun) {
  5411. for (var i = startRow; i <= endRow; i++)
  5412. fun(doc.getLine(i), i);
  5413. }
  5414. var minEmptyLength = Infinity;
  5415. iter(function(line, i) {
  5416. var indent = line.search(/\S/);
  5417. if (indent !== -1) {
  5418. if (indent < minIndent)
  5419. minIndent = indent;
  5420. if (shouldRemove && !testRemove(line, i))
  5421. shouldRemove = false;
  5422. } else if (minEmptyLength > line.length) {
  5423. minEmptyLength = line.length;
  5424. }
  5425. });
  5426. if (minIndent == Infinity) {
  5427. minIndent = minEmptyLength;
  5428. ignoreBlankLines = false;
  5429. shouldRemove = false;
  5430. }
  5431. if (insertAtTabStop && minIndent % tabSize != 0)
  5432. minIndent = Math.floor(minIndent / tabSize) * tabSize;
  5433. iter(shouldRemove ? uncomment : comment);
  5434. };
  5435. this.toggleBlockComment = function(state, session, range, cursor) {
  5436. var comment = this.blockComment;
  5437. if (!comment)
  5438. return;
  5439. if (!comment.start && comment[0])
  5440. comment = comment[0];
  5441. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5442. var token = iterator.getCurrentToken();
  5443. var sel = session.selection;
  5444. var initialRange = session.selection.toOrientedRange();
  5445. var startRow, colDiff;
  5446. if (token && /comment/.test(token.type)) {
  5447. var startRange, endRange;
  5448. while (token && /comment/.test(token.type)) {
  5449. var i = token.value.indexOf(comment.start);
  5450. if (i != -1) {
  5451. var row = iterator.getCurrentTokenRow();
  5452. var column = iterator.getCurrentTokenColumn() + i;
  5453. startRange = new Range(row, column, row, column + comment.start.length);
  5454. break;
  5455. }
  5456. token = iterator.stepBackward();
  5457. }
  5458. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  5459. var token = iterator.getCurrentToken();
  5460. while (token && /comment/.test(token.type)) {
  5461. var i = token.value.indexOf(comment.end);
  5462. if (i != -1) {
  5463. var row = iterator.getCurrentTokenRow();
  5464. var column = iterator.getCurrentTokenColumn() + i;
  5465. endRange = new Range(row, column, row, column + comment.end.length);
  5466. break;
  5467. }
  5468. token = iterator.stepForward();
  5469. }
  5470. if (endRange)
  5471. session.remove(endRange);
  5472. if (startRange) {
  5473. session.remove(startRange);
  5474. startRow = startRange.start.row;
  5475. colDiff = -comment.start.length;
  5476. }
  5477. } else {
  5478. colDiff = comment.start.length;
  5479. startRow = range.start.row;
  5480. session.insert(range.end, comment.end);
  5481. session.insert(range.start, comment.start);
  5482. }
  5483. if (initialRange.start.row == startRow)
  5484. initialRange.start.column += colDiff;
  5485. if (initialRange.end.row == startRow)
  5486. initialRange.end.column += colDiff;
  5487. session.selection.fromOrientedRange(initialRange);
  5488. };
  5489. this.getNextLineIndent = function(state, line, tab) {
  5490. return this.$getIndent(line);
  5491. };
  5492. this.checkOutdent = function(state, line, input) {
  5493. return false;
  5494. };
  5495. this.autoOutdent = function(state, doc, row) {
  5496. };
  5497. this.$getIndent = function(line) {
  5498. return line.match(/^\s*/)[0];
  5499. };
  5500. this.createWorker = function(session) {
  5501. return null;
  5502. };
  5503. this.createModeDelegates = function (mapping) {
  5504. this.$embeds = [];
  5505. this.$modes = {};
  5506. for (var i in mapping) {
  5507. if (mapping[i]) {
  5508. this.$embeds.push(i);
  5509. this.$modes[i] = new mapping[i]();
  5510. }
  5511. }
  5512. var delegations = ["toggleBlockComment", "toggleCommentLines", "getNextLineIndent",
  5513. "checkOutdent", "autoOutdent", "transformAction", "getCompletions"];
  5514. for (var i = 0; i < delegations.length; i++) {
  5515. (function(scope) {
  5516. var functionName = delegations[i];
  5517. var defaultHandler = scope[functionName];
  5518. scope[delegations[i]] = function() {
  5519. return this.$delegator(functionName, arguments, defaultHandler);
  5520. };
  5521. }(this));
  5522. }
  5523. };
  5524. this.$delegator = function(method, args, defaultHandler) {
  5525. var state = args[0];
  5526. if (typeof state != "string")
  5527. state = state[0];
  5528. for (var i = 0; i < this.$embeds.length; i++) {
  5529. if (!this.$modes[this.$embeds[i]]) continue;
  5530. var split = state.split(this.$embeds[i]);
  5531. if (!split[0] && split[1]) {
  5532. args[0] = split[1];
  5533. var mode = this.$modes[this.$embeds[i]];
  5534. return mode[method].apply(mode, args);
  5535. }
  5536. }
  5537. var ret = defaultHandler.apply(this, args);
  5538. return defaultHandler ? ret : undefined;
  5539. };
  5540. this.transformAction = function(state, action, editor, session, param) {
  5541. if (this.$behaviour) {
  5542. var behaviours = this.$behaviour.getBehaviours();
  5543. for (var key in behaviours) {
  5544. if (behaviours[key][action]) {
  5545. var ret = behaviours[key][action].apply(this, arguments);
  5546. if (ret) {
  5547. return ret;
  5548. }
  5549. }
  5550. }
  5551. }
  5552. };
  5553. this.getKeywords = function(append) {
  5554. if (!this.completionKeywords) {
  5555. var rules = this.$tokenizer.rules;
  5556. var completionKeywords = [];
  5557. for (var rule in rules) {
  5558. var ruleItr = rules[rule];
  5559. for (var r = 0, l = ruleItr.length; r < l; r++) {
  5560. if (typeof ruleItr[r].token === "string") {
  5561. if (/keyword|support|storage/.test(ruleItr[r].token))
  5562. completionKeywords.push(ruleItr[r].regex);
  5563. }
  5564. else if (typeof ruleItr[r].token === "object") {
  5565. for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
  5566. if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
  5567. var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
  5568. completionKeywords.push(rule.substr(1, rule.length - 2));
  5569. }
  5570. }
  5571. }
  5572. }
  5573. }
  5574. this.completionKeywords = completionKeywords;
  5575. }
  5576. if (!append)
  5577. return this.$keywordList;
  5578. return completionKeywords.concat(this.$keywordList || []);
  5579. };
  5580. this.$createKeywordList = function() {
  5581. if (!this.$highlightRules)
  5582. this.getTokenizer();
  5583. return this.$keywordList = this.$highlightRules.$keywordList || [];
  5584. };
  5585. this.getCompletions = function(state, session, pos, prefix) {
  5586. var keywords = this.$keywordList || this.$createKeywordList();
  5587. return keywords.map(function(word) {
  5588. return {
  5589. name: word,
  5590. value: word,
  5591. score: 0,
  5592. meta: "keyword"
  5593. };
  5594. });
  5595. };
  5596. this.$id = "ace/mode/text";
  5597. }).call(Mode.prototype);
  5598. exports.Mode = Mode;
  5599. });
  5600. ace.define("ace/apply_delta",["require","exports","module"], function(require, exports, module) {
  5601. "use strict";
  5602. function throwDeltaError(delta, errorText){
  5603. console.log("Invalid Delta:", delta);
  5604. throw "Invalid Delta: " + errorText;
  5605. }
  5606. function positionInDocument(docLines, position) {
  5607. return position.row >= 0 && position.row < docLines.length &&
  5608. position.column >= 0 && position.column <= docLines[position.row].length;
  5609. }
  5610. function validateDelta(docLines, delta) {
  5611. if (delta.action != "insert" && delta.action != "remove")
  5612. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  5613. if (!(delta.lines instanceof Array))
  5614. throwDeltaError(delta, "delta.lines must be an Array");
  5615. if (!delta.start || !delta.end)
  5616. throwDeltaError(delta, "delta.start/end must be an present");
  5617. var start = delta.start;
  5618. if (!positionInDocument(docLines, delta.start))
  5619. throwDeltaError(delta, "delta.start must be contained in document");
  5620. var end = delta.end;
  5621. if (delta.action == "remove" && !positionInDocument(docLines, end))
  5622. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  5623. var numRangeRows = end.row - start.row;
  5624. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  5625. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  5626. throwDeltaError(delta, "delta.range must match delta lines");
  5627. }
  5628. exports.applyDelta = function(docLines, delta, doNotValidate) {
  5629. var row = delta.start.row;
  5630. var startColumn = delta.start.column;
  5631. var line = docLines[row] || "";
  5632. switch (delta.action) {
  5633. case "insert":
  5634. var lines = delta.lines;
  5635. if (lines.length === 1) {
  5636. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  5637. } else {
  5638. var args = [row, 1].concat(delta.lines);
  5639. docLines.splice.apply(docLines, args);
  5640. docLines[row] = line.substring(0, startColumn) + docLines[row];
  5641. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  5642. }
  5643. break;
  5644. case "remove":
  5645. var endColumn = delta.end.column;
  5646. var endRow = delta.end.row;
  5647. if (row === endRow) {
  5648. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  5649. } else {
  5650. docLines.splice(
  5651. row, endRow - row + 1,
  5652. line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
  5653. );
  5654. }
  5655. break;
  5656. }
  5657. }
  5658. });
  5659. ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  5660. "use strict";
  5661. var oop = require("./lib/oop");
  5662. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5663. var Anchor = exports.Anchor = function(doc, row, column) {
  5664. this.$onChange = this.onChange.bind(this);
  5665. this.attach(doc);
  5666. if (typeof column == "undefined")
  5667. this.setPosition(row.row, row.column);
  5668. else
  5669. this.setPosition(row, column);
  5670. };
  5671. (function() {
  5672. oop.implement(this, EventEmitter);
  5673. this.getPosition = function() {
  5674. return this.$clipPositionToDocument(this.row, this.column);
  5675. };
  5676. this.getDocument = function() {
  5677. return this.document;
  5678. };
  5679. this.$insertRight = false;
  5680. this.onChange = function(delta) {
  5681. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  5682. return;
  5683. if (delta.start.row > this.row)
  5684. return;
  5685. var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
  5686. this.setPosition(point.row, point.column, true);
  5687. };
  5688. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  5689. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  5690. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  5691. }
  5692. function $getTransformedPoint(delta, point, moveIfEqual) {
  5693. var deltaIsInsert = delta.action == "insert";
  5694. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  5695. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  5696. var deltaStart = delta.start;
  5697. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  5698. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  5699. return {
  5700. row: point.row,
  5701. column: point.column
  5702. };
  5703. }
  5704. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  5705. return {
  5706. row: point.row + deltaRowShift,
  5707. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  5708. };
  5709. }
  5710. return {
  5711. row: deltaStart.row,
  5712. column: deltaStart.column
  5713. };
  5714. }
  5715. this.setPosition = function(row, column, noClip) {
  5716. var pos;
  5717. if (noClip) {
  5718. pos = {
  5719. row: row,
  5720. column: column
  5721. };
  5722. } else {
  5723. pos = this.$clipPositionToDocument(row, column);
  5724. }
  5725. if (this.row == pos.row && this.column == pos.column)
  5726. return;
  5727. var old = {
  5728. row: this.row,
  5729. column: this.column
  5730. };
  5731. this.row = pos.row;
  5732. this.column = pos.column;
  5733. this._signal("change", {
  5734. old: old,
  5735. value: pos
  5736. });
  5737. };
  5738. this.detach = function() {
  5739. this.document.removeEventListener("change", this.$onChange);
  5740. };
  5741. this.attach = function(doc) {
  5742. this.document = doc || this.document;
  5743. this.document.on("change", this.$onChange);
  5744. };
  5745. this.$clipPositionToDocument = function(row, column) {
  5746. var pos = {};
  5747. if (row >= this.document.getLength()) {
  5748. pos.row = Math.max(0, this.document.getLength() - 1);
  5749. pos.column = this.document.getLine(pos.row).length;
  5750. }
  5751. else if (row < 0) {
  5752. pos.row = 0;
  5753. pos.column = 0;
  5754. }
  5755. else {
  5756. pos.row = row;
  5757. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  5758. }
  5759. if (column < 0)
  5760. pos.column = 0;
  5761. return pos;
  5762. };
  5763. }).call(Anchor.prototype);
  5764. });
  5765. 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) {
  5766. "use strict";
  5767. var oop = require("./lib/oop");
  5768. var applyDelta = require("./apply_delta").applyDelta;
  5769. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  5770. var Range = require("./range").Range;
  5771. var Anchor = require("./anchor").Anchor;
  5772. var Document = function(textOrLines) {
  5773. this.$lines = [""];
  5774. if (textOrLines.length === 0) {
  5775. this.$lines = [""];
  5776. } else if (Array.isArray(textOrLines)) {
  5777. this.insertMergedLines({row: 0, column: 0}, textOrLines);
  5778. } else {
  5779. this.insert({row: 0, column:0}, textOrLines);
  5780. }
  5781. };
  5782. (function() {
  5783. oop.implement(this, EventEmitter);
  5784. this.setValue = function(text) {
  5785. var len = this.getLength() - 1;
  5786. this.remove(new Range(0, 0, len, this.getLine(len).length));
  5787. this.insert({row: 0, column: 0}, text);
  5788. };
  5789. this.getValue = function() {
  5790. return this.getAllLines().join(this.getNewLineCharacter());
  5791. };
  5792. this.createAnchor = function(row, column) {
  5793. return new Anchor(this, row, column);
  5794. };
  5795. if ("aaa".split(/a/).length === 0) {
  5796. this.$split = function(text) {
  5797. return text.replace(/\r\n|\r/g, "\n").split("\n");
  5798. };
  5799. } else {
  5800. this.$split = function(text) {
  5801. return text.split(/\r\n|\r|\n/);
  5802. };
  5803. }
  5804. this.$detectNewLine = function(text) {
  5805. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  5806. this.$autoNewLine = match ? match[1] : "\n";
  5807. this._signal("changeNewLineMode");
  5808. };
  5809. this.getNewLineCharacter = function() {
  5810. switch (this.$newLineMode) {
  5811. case "windows":
  5812. return "\r\n";
  5813. case "unix":
  5814. return "\n";
  5815. default:
  5816. return this.$autoNewLine || "\n";
  5817. }
  5818. };
  5819. this.$autoNewLine = "";
  5820. this.$newLineMode = "auto";
  5821. this.setNewLineMode = function(newLineMode) {
  5822. if (this.$newLineMode === newLineMode)
  5823. return;
  5824. this.$newLineMode = newLineMode;
  5825. this._signal("changeNewLineMode");
  5826. };
  5827. this.getNewLineMode = function() {
  5828. return this.$newLineMode;
  5829. };
  5830. this.isNewLine = function(text) {
  5831. return (text == "\r\n" || text == "\r" || text == "\n");
  5832. };
  5833. this.getLine = function(row) {
  5834. return this.$lines[row] || "";
  5835. };
  5836. this.getLines = function(firstRow, lastRow) {
  5837. return this.$lines.slice(firstRow, lastRow + 1);
  5838. };
  5839. this.getAllLines = function() {
  5840. return this.getLines(0, this.getLength());
  5841. };
  5842. this.getLength = function() {
  5843. return this.$lines.length;
  5844. };
  5845. this.getTextRange = function(range) {
  5846. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  5847. };
  5848. this.getLinesForRange = function(range) {
  5849. var lines;
  5850. if (range.start.row === range.end.row) {
  5851. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  5852. } else {
  5853. lines = this.getLines(range.start.row, range.end.row);
  5854. lines[0] = (lines[0] || "").substring(range.start.column);
  5855. var l = lines.length - 1;
  5856. if (range.end.row - range.start.row == l)
  5857. lines[l] = lines[l].substring(0, range.end.column);
  5858. }
  5859. return lines;
  5860. };
  5861. this.insertLines = function(row, lines) {
  5862. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  5863. return this.insertFullLines(row, lines);
  5864. };
  5865. this.removeLines = function(firstRow, lastRow) {
  5866. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  5867. return this.removeFullLines(firstRow, lastRow);
  5868. };
  5869. this.insertNewLine = function(position) {
  5870. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  5871. return this.insertMergedLines(position, ["", ""]);
  5872. };
  5873. this.insert = function(position, text) {
  5874. if (this.getLength() <= 1)
  5875. this.$detectNewLine(text);
  5876. return this.insertMergedLines(position, this.$split(text));
  5877. };
  5878. this.insertInLine = function(position, text) {
  5879. var start = this.clippedPos(position.row, position.column);
  5880. var end = this.pos(position.row, position.column + text.length);
  5881. this.applyDelta({
  5882. start: start,
  5883. end: end,
  5884. action: "insert",
  5885. lines: [text]
  5886. }, true);
  5887. return this.clonePos(end);
  5888. };
  5889. this.clippedPos = function(row, column) {
  5890. var length = this.getLength();
  5891. if (row === undefined) {
  5892. row = length;
  5893. } else if (row < 0) {
  5894. row = 0;
  5895. } else if (row >= length) {
  5896. row = length - 1;
  5897. column = undefined;
  5898. }
  5899. var line = this.getLine(row);
  5900. if (column == undefined)
  5901. column = line.length;
  5902. column = Math.min(Math.max(column, 0), line.length);
  5903. return {row: row, column: column};
  5904. };
  5905. this.clonePos = function(pos) {
  5906. return {row: pos.row, column: pos.column};
  5907. };
  5908. this.pos = function(row, column) {
  5909. return {row: row, column: column};
  5910. };
  5911. this.$clipPosition = function(position) {
  5912. var length = this.getLength();
  5913. if (position.row >= length) {
  5914. position.row = Math.max(0, length - 1);
  5915. position.column = this.getLine(length - 1).length;
  5916. } else {
  5917. position.row = Math.max(0, position.row);
  5918. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  5919. }
  5920. return position;
  5921. };
  5922. this.insertFullLines = function(row, lines) {
  5923. row = Math.min(Math.max(row, 0), this.getLength());
  5924. var column = 0;
  5925. if (row < this.getLength()) {
  5926. lines = lines.concat([""]);
  5927. column = 0;
  5928. } else {
  5929. lines = [""].concat(lines);
  5930. row--;
  5931. column = this.$lines[row].length;
  5932. }
  5933. this.insertMergedLines({row: row, column: column}, lines);
  5934. };
  5935. this.insertMergedLines = function(position, lines) {
  5936. var start = this.clippedPos(position.row, position.column);
  5937. var end = {
  5938. row: start.row + lines.length - 1,
  5939. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  5940. };
  5941. this.applyDelta({
  5942. start: start,
  5943. end: end,
  5944. action: "insert",
  5945. lines: lines
  5946. });
  5947. return this.clonePos(end);
  5948. };
  5949. this.remove = function(range) {
  5950. var start = this.clippedPos(range.start.row, range.start.column);
  5951. var end = this.clippedPos(range.end.row, range.end.column);
  5952. this.applyDelta({
  5953. start: start,
  5954. end: end,
  5955. action: "remove",
  5956. lines: this.getLinesForRange({start: start, end: end})
  5957. });
  5958. return this.clonePos(start);
  5959. };
  5960. this.removeInLine = function(row, startColumn, endColumn) {
  5961. var start = this.clippedPos(row, startColumn);
  5962. var end = this.clippedPos(row, endColumn);
  5963. this.applyDelta({
  5964. start: start,
  5965. end: end,
  5966. action: "remove",
  5967. lines: this.getLinesForRange({start: start, end: end})
  5968. }, true);
  5969. return this.clonePos(start);
  5970. };
  5971. this.removeFullLines = function(firstRow, lastRow) {
  5972. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  5973. lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
  5974. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  5975. var deleteLastNewLine = lastRow < this.getLength() - 1;
  5976. var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
  5977. var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
  5978. var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
  5979. var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
  5980. var range = new Range(startRow, startCol, endRow, endCol);
  5981. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  5982. this.applyDelta({
  5983. start: range.start,
  5984. end: range.end,
  5985. action: "remove",
  5986. lines: this.getLinesForRange(range)
  5987. });
  5988. return deletedLines;
  5989. };
  5990. this.removeNewLine = function(row) {
  5991. if (row < this.getLength() - 1 && row >= 0) {
  5992. this.applyDelta({
  5993. start: this.pos(row, this.getLine(row).length),
  5994. end: this.pos(row + 1, 0),
  5995. action: "remove",
  5996. lines: ["", ""]
  5997. });
  5998. }
  5999. };
  6000. this.replace = function(range, text) {
  6001. if (!(range instanceof Range))
  6002. range = Range.fromPoints(range.start, range.end);
  6003. if (text.length === 0 && range.isEmpty())
  6004. return range.start;
  6005. if (text == this.getTextRange(range))
  6006. return range.end;
  6007. this.remove(range);
  6008. var end;
  6009. if (text) {
  6010. end = this.insert(range.start, text);
  6011. }
  6012. else {
  6013. end = range.start;
  6014. }
  6015. return end;
  6016. };
  6017. this.applyDeltas = function(deltas) {
  6018. for (var i=0; i<deltas.length; i++) {
  6019. this.applyDelta(deltas[i]);
  6020. }
  6021. };
  6022. this.revertDeltas = function(deltas) {
  6023. for (var i=deltas.length-1; i>=0; i--) {
  6024. this.revertDelta(deltas[i]);
  6025. }
  6026. };
  6027. this.applyDelta = function(delta, doNotValidate) {
  6028. var isInsert = delta.action == "insert";
  6029. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  6030. : !Range.comparePoints(delta.start, delta.end)) {
  6031. return;
  6032. }
  6033. if (isInsert && delta.lines.length > 20000)
  6034. this.$splitAndapplyLargeDelta(delta, 20000);
  6035. applyDelta(this.$lines, delta, doNotValidate);
  6036. this._signal("change", delta);
  6037. };
  6038. this.$splitAndapplyLargeDelta = function(delta, MAX) {
  6039. var lines = delta.lines;
  6040. var l = lines.length;
  6041. var row = delta.start.row;
  6042. var column = delta.start.column;
  6043. var from = 0, to = 0;
  6044. do {
  6045. from = to;
  6046. to += MAX - 1;
  6047. var chunk = lines.slice(from, to);
  6048. if (to > l) {
  6049. delta.lines = chunk;
  6050. delta.start.row = row + from;
  6051. delta.start.column = column;
  6052. break;
  6053. }
  6054. chunk.push("");
  6055. this.applyDelta({
  6056. start: this.pos(row + from, column),
  6057. end: this.pos(row + to, column = 0),
  6058. action: delta.action,
  6059. lines: chunk
  6060. }, true);
  6061. } while(true);
  6062. };
  6063. this.revertDelta = function(delta) {
  6064. this.applyDelta({
  6065. start: this.clonePos(delta.start),
  6066. end: this.clonePos(delta.end),
  6067. action: (delta.action == "insert" ? "remove" : "insert"),
  6068. lines: delta.lines.slice()
  6069. });
  6070. };
  6071. this.indexToPosition = function(index, startRow) {
  6072. var lines = this.$lines || this.getAllLines();
  6073. var newlineLength = this.getNewLineCharacter().length;
  6074. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  6075. index -= lines[i].length + newlineLength;
  6076. if (index < 0)
  6077. return {row: i, column: index + lines[i].length + newlineLength};
  6078. }
  6079. return {row: l-1, column: lines[l-1].length};
  6080. };
  6081. this.positionToIndex = function(pos, startRow) {
  6082. var lines = this.$lines || this.getAllLines();
  6083. var newlineLength = this.getNewLineCharacter().length;
  6084. var index = 0;
  6085. var row = Math.min(pos.row, lines.length);
  6086. for (var i = startRow || 0; i < row; ++i)
  6087. index += lines[i].length + newlineLength;
  6088. return index + pos.column;
  6089. };
  6090. }).call(Document.prototype);
  6091. exports.Document = Document;
  6092. });
  6093. ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
  6094. "use strict";
  6095. var oop = require("./lib/oop");
  6096. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  6097. var BackgroundTokenizer = function(tokenizer, editor) {
  6098. this.running = false;
  6099. this.lines = [];
  6100. this.states = [];
  6101. this.currentLine = 0;
  6102. this.tokenizer = tokenizer;
  6103. var self = this;
  6104. this.$worker = function() {
  6105. if (!self.running) { return; }
  6106. var workerStart = new Date();
  6107. var currentLine = self.currentLine;
  6108. var endLine = -1;
  6109. var doc = self.doc;
  6110. var startLine = currentLine;
  6111. while (self.lines[currentLine])
  6112. currentLine++;
  6113. var len = doc.getLength();
  6114. var processedLines = 0;
  6115. self.running = false;
  6116. while (currentLine < len) {
  6117. self.$tokenizeRow(currentLine);
  6118. endLine = currentLine;
  6119. do {
  6120. currentLine++;
  6121. } while (self.lines[currentLine]);
  6122. processedLines ++;
  6123. if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
  6124. self.running = setTimeout(self.$worker, 20);
  6125. break;
  6126. }
  6127. }
  6128. self.currentLine = currentLine;
  6129. if (startLine <= endLine)
  6130. self.fireUpdateEvent(startLine, endLine);
  6131. };
  6132. };
  6133. (function(){
  6134. oop.implement(this, EventEmitter);
  6135. this.setTokenizer = function(tokenizer) {
  6136. this.tokenizer = tokenizer;
  6137. this.lines = [];
  6138. this.states = [];
  6139. this.start(0);
  6140. };
  6141. this.setDocument = function(doc) {
  6142. this.doc = doc;
  6143. this.lines = [];
  6144. this.states = [];
  6145. this.stop();
  6146. };
  6147. this.fireUpdateEvent = function(firstRow, lastRow) {
  6148. var data = {
  6149. first: firstRow,
  6150. last: lastRow
  6151. };
  6152. this._signal("update", {data: data});
  6153. };
  6154. this.start = function(startRow) {
  6155. this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
  6156. this.lines.splice(this.currentLine, this.lines.length);
  6157. this.states.splice(this.currentLine, this.states.length);
  6158. this.stop();
  6159. this.running = setTimeout(this.$worker, 700);
  6160. };
  6161. this.scheduleStart = function() {
  6162. if (!this.running)
  6163. this.running = setTimeout(this.$worker, 700);
  6164. }
  6165. this.$updateOnChange = function(delta) {
  6166. var startRow = delta.start.row;
  6167. var len = delta.end.row - startRow;
  6168. if (len === 0) {
  6169. this.lines[startRow] = null;
  6170. } else if (delta.action == "remove") {
  6171. this.lines.splice(startRow, len + 1, null);
  6172. this.states.splice(startRow, len + 1, null);
  6173. } else {
  6174. var args = Array(len + 1);
  6175. args.unshift(startRow, 1);
  6176. this.lines.splice.apply(this.lines, args);
  6177. this.states.splice.apply(this.states, args);
  6178. }
  6179. this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
  6180. this.stop();
  6181. };
  6182. this.stop = function() {
  6183. if (this.running)
  6184. clearTimeout(this.running);
  6185. this.running = false;
  6186. };
  6187. this.getTokens = function(row) {
  6188. return this.lines[row] || this.$tokenizeRow(row);
  6189. };
  6190. this.getState = function(row) {
  6191. if (this.currentLine == row)
  6192. this.$tokenizeRow(row);
  6193. return this.states[row] || "start";
  6194. };
  6195. this.$tokenizeRow = function(row) {
  6196. var line = this.doc.getLine(row);
  6197. var state = this.states[row - 1];
  6198. var data = this.tokenizer.getLineTokens(line, state, row);
  6199. if (this.states[row] + "" !== data.state + "") {
  6200. this.states[row] = data.state;
  6201. this.lines[row + 1] = null;
  6202. if (this.currentLine > row + 1)
  6203. this.currentLine = row + 1;
  6204. } else if (this.currentLine == row) {
  6205. this.currentLine = row + 1;
  6206. }
  6207. return this.lines[row] = data.tokens;
  6208. };
  6209. }).call(BackgroundTokenizer.prototype);
  6210. exports.BackgroundTokenizer = BackgroundTokenizer;
  6211. });
  6212. ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  6213. "use strict";
  6214. var lang = require("./lib/lang");
  6215. var oop = require("./lib/oop");
  6216. var Range = require("./range").Range;
  6217. var SearchHighlight = function(regExp, clazz, type) {
  6218. this.setRegexp(regExp);
  6219. this.clazz = clazz;
  6220. this.type = type || "text";
  6221. };
  6222. (function() {
  6223. this.MAX_RANGES = 500;
  6224. this.setRegexp = function(regExp) {
  6225. if (this.regExp+"" == regExp+"")
  6226. return;
  6227. this.regExp = regExp;
  6228. this.cache = [];
  6229. };
  6230. this.update = function(html, markerLayer, session, config) {
  6231. if (!this.regExp)
  6232. return;
  6233. var start = config.firstRow, end = config.lastRow;
  6234. for (var i = start; i <= end; i++) {
  6235. var ranges = this.cache[i];
  6236. if (ranges == null) {
  6237. ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
  6238. if (ranges.length > this.MAX_RANGES)
  6239. ranges = ranges.slice(0, this.MAX_RANGES);
  6240. ranges = ranges.map(function(match) {
  6241. return new Range(i, match.offset, i, match.offset + match.length);
  6242. });
  6243. this.cache[i] = ranges.length ? ranges : "";
  6244. }
  6245. for (var j = ranges.length; j --; ) {
  6246. markerLayer.drawSingleLineMarker(
  6247. html, ranges[j].toScreenRange(session), this.clazz, config);
  6248. }
  6249. }
  6250. };
  6251. }).call(SearchHighlight.prototype);
  6252. exports.SearchHighlight = SearchHighlight;
  6253. });
  6254. ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
  6255. "use strict";
  6256. var Range = require("../range").Range;
  6257. function FoldLine(foldData, folds) {
  6258. this.foldData = foldData;
  6259. if (Array.isArray(folds)) {
  6260. this.folds = folds;
  6261. } else {
  6262. folds = this.folds = [ folds ];
  6263. }
  6264. var last = folds[folds.length - 1];
  6265. this.range = new Range(folds[0].start.row, folds[0].start.column,
  6266. last.end.row, last.end.column);
  6267. this.start = this.range.start;
  6268. this.end = this.range.end;
  6269. this.folds.forEach(function(fold) {
  6270. fold.setFoldLine(this);
  6271. }, this);
  6272. }
  6273. (function() {
  6274. this.shiftRow = function(shift) {
  6275. this.start.row += shift;
  6276. this.end.row += shift;
  6277. this.folds.forEach(function(fold) {
  6278. fold.start.row += shift;
  6279. fold.end.row += shift;
  6280. });
  6281. };
  6282. this.addFold = function(fold) {
  6283. if (fold.sameRow) {
  6284. if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
  6285. throw new Error("Can't add a fold to this FoldLine as it has no connection");
  6286. }
  6287. this.folds.push(fold);
  6288. this.folds.sort(function(a, b) {
  6289. return -a.range.compareEnd(b.start.row, b.start.column);
  6290. });
  6291. if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
  6292. this.end.row = fold.end.row;
  6293. this.end.column = fold.end.column;
  6294. } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
  6295. this.start.row = fold.start.row;
  6296. this.start.column = fold.start.column;
  6297. }
  6298. } else if (fold.start.row == this.end.row) {
  6299. this.folds.push(fold);
  6300. this.end.row = fold.end.row;
  6301. this.end.column = fold.end.column;
  6302. } else if (fold.end.row == this.start.row) {
  6303. this.folds.unshift(fold);
  6304. this.start.row = fold.start.row;
  6305. this.start.column = fold.start.column;
  6306. } else {
  6307. throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
  6308. }
  6309. fold.foldLine = this;
  6310. };
  6311. this.containsRow = function(row) {
  6312. return row >= this.start.row && row <= this.end.row;
  6313. };
  6314. this.walk = function(callback, endRow, endColumn) {
  6315. var lastEnd = 0,
  6316. folds = this.folds,
  6317. fold,
  6318. cmp, stop, isNewRow = true;
  6319. if (endRow == null) {
  6320. endRow = this.end.row;
  6321. endColumn = this.end.column;
  6322. }
  6323. for (var i = 0; i < folds.length; i++) {
  6324. fold = folds[i];
  6325. cmp = fold.range.compareStart(endRow, endColumn);
  6326. if (cmp == -1) {
  6327. callback(null, endRow, endColumn, lastEnd, isNewRow);
  6328. return;
  6329. }
  6330. stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
  6331. stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
  6332. if (stop || cmp === 0) {
  6333. return;
  6334. }
  6335. isNewRow = !fold.sameRow;
  6336. lastEnd = fold.end.column;
  6337. }
  6338. callback(null, endRow, endColumn, lastEnd, isNewRow);
  6339. };
  6340. this.getNextFoldTo = function(row, column) {
  6341. var fold, cmp;
  6342. for (var i = 0; i < this.folds.length; i++) {
  6343. fold = this.folds[i];
  6344. cmp = fold.range.compareEnd(row, column);
  6345. if (cmp == -1) {
  6346. return {
  6347. fold: fold,
  6348. kind: "after"
  6349. };
  6350. } else if (cmp === 0) {
  6351. return {
  6352. fold: fold,
  6353. kind: "inside"
  6354. };
  6355. }
  6356. }
  6357. return null;
  6358. };
  6359. this.addRemoveChars = function(row, column, len) {
  6360. var ret = this.getNextFoldTo(row, column),
  6361. fold, folds;
  6362. if (ret) {
  6363. fold = ret.fold;
  6364. if (ret.kind == "inside"
  6365. && fold.start.column != column
  6366. && fold.start.row != row)
  6367. {
  6368. window.console && window.console.log(row, column, fold);
  6369. } else if (fold.start.row == row) {
  6370. folds = this.folds;
  6371. var i = folds.indexOf(fold);
  6372. if (i === 0) {
  6373. this.start.column += len;
  6374. }
  6375. for (i; i < folds.length; i++) {
  6376. fold = folds[i];
  6377. fold.start.column += len;
  6378. if (!fold.sameRow) {
  6379. return;
  6380. }
  6381. fold.end.column += len;
  6382. }
  6383. this.end.column += len;
  6384. }
  6385. }
  6386. };
  6387. this.split = function(row, column) {
  6388. var pos = this.getNextFoldTo(row, column);
  6389. if (!pos || pos.kind == "inside")
  6390. return null;
  6391. var fold = pos.fold;
  6392. var folds = this.folds;
  6393. var foldData = this.foldData;
  6394. var i = folds.indexOf(fold);
  6395. var foldBefore = folds[i - 1];
  6396. this.end.row = foldBefore.end.row;
  6397. this.end.column = foldBefore.end.column;
  6398. folds = folds.splice(i, folds.length - i);
  6399. var newFoldLine = new FoldLine(foldData, folds);
  6400. foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
  6401. return newFoldLine;
  6402. };
  6403. this.merge = function(foldLineNext) {
  6404. var folds = foldLineNext.folds;
  6405. for (var i = 0; i < folds.length; i++) {
  6406. this.addFold(folds[i]);
  6407. }
  6408. var foldData = this.foldData;
  6409. foldData.splice(foldData.indexOf(foldLineNext), 1);
  6410. };
  6411. this.toString = function() {
  6412. var ret = [this.range.toString() + ": [" ];
  6413. this.folds.forEach(function(fold) {
  6414. ret.push(" " + fold.toString());
  6415. });
  6416. ret.push("]");
  6417. return ret.join("\n");
  6418. };
  6419. this.idxToPosition = function(idx) {
  6420. var lastFoldEndColumn = 0;
  6421. for (var i = 0; i < this.folds.length; i++) {
  6422. var fold = this.folds[i];
  6423. idx -= fold.start.column - lastFoldEndColumn;
  6424. if (idx < 0) {
  6425. return {
  6426. row: fold.start.row,
  6427. column: fold.start.column + idx
  6428. };
  6429. }
  6430. idx -= fold.placeholder.length;
  6431. if (idx < 0) {
  6432. return fold.start;
  6433. }
  6434. lastFoldEndColumn = fold.end.column;
  6435. }
  6436. return {
  6437. row: this.end.row,
  6438. column: this.end.column + idx
  6439. };
  6440. };
  6441. }).call(FoldLine.prototype);
  6442. exports.FoldLine = FoldLine;
  6443. });
  6444. ace.define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
  6445. "use strict";
  6446. var Range = require("./range").Range;
  6447. var comparePoints = Range.comparePoints;
  6448. var RangeList = function() {
  6449. this.ranges = [];
  6450. };
  6451. (function() {
  6452. this.comparePoints = comparePoints;
  6453. this.pointIndex = function(pos, excludeEdges, startIndex) {
  6454. var list = this.ranges;
  6455. for (var i = startIndex || 0; i < list.length; i++) {
  6456. var range = list[i];
  6457. var cmpEnd = comparePoints(pos, range.end);
  6458. if (cmpEnd > 0)
  6459. continue;
  6460. var cmpStart = comparePoints(pos, range.start);
  6461. if (cmpEnd === 0)
  6462. return excludeEdges && cmpStart !== 0 ? -i-2 : i;
  6463. if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
  6464. return i;
  6465. return -i-1;
  6466. }
  6467. return -i - 1;
  6468. };
  6469. this.add = function(range) {
  6470. var excludeEdges = !range.isEmpty();
  6471. var startIndex = this.pointIndex(range.start, excludeEdges);
  6472. if (startIndex < 0)
  6473. startIndex = -startIndex - 1;
  6474. var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
  6475. if (endIndex < 0)
  6476. endIndex = -endIndex - 1;
  6477. else
  6478. endIndex++;
  6479. return this.ranges.splice(startIndex, endIndex - startIndex, range);
  6480. };
  6481. this.addList = function(list) {
  6482. var removed = [];
  6483. for (var i = list.length; i--; ) {
  6484. removed.push.apply(removed, this.add(list[i]));
  6485. }
  6486. return removed;
  6487. };
  6488. this.substractPoint = function(pos) {
  6489. var i = this.pointIndex(pos);
  6490. if (i >= 0)
  6491. return this.ranges.splice(i, 1);
  6492. };
  6493. this.merge = function() {
  6494. var removed = [];
  6495. var list = this.ranges;
  6496. list = list.sort(function(a, b) {
  6497. return comparePoints(a.start, b.start);
  6498. });
  6499. var next = list[0], range;
  6500. for (var i = 1; i < list.length; i++) {
  6501. range = next;
  6502. next = list[i];
  6503. var cmp = comparePoints(range.end, next.start);
  6504. if (cmp < 0)
  6505. continue;
  6506. if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
  6507. continue;
  6508. if (comparePoints(range.end, next.end) < 0) {
  6509. range.end.row = next.end.row;
  6510. range.end.column = next.end.column;
  6511. }
  6512. list.splice(i, 1);
  6513. removed.push(next);
  6514. next = range;
  6515. i--;
  6516. }
  6517. this.ranges = list;
  6518. return removed;
  6519. };
  6520. this.contains = function(row, column) {
  6521. return this.pointIndex({row: row, column: column}) >= 0;
  6522. };
  6523. this.containsPoint = function(pos) {
  6524. return this.pointIndex(pos) >= 0;
  6525. };
  6526. this.rangeAtPoint = function(pos) {
  6527. var i = this.pointIndex(pos);
  6528. if (i >= 0)
  6529. return this.ranges[i];
  6530. };
  6531. this.clipRows = function(startRow, endRow) {
  6532. var list = this.ranges;
  6533. if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
  6534. return [];
  6535. var startIndex = this.pointIndex({row: startRow, column: 0});
  6536. if (startIndex < 0)
  6537. startIndex = -startIndex - 1;
  6538. var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
  6539. if (endIndex < 0)
  6540. endIndex = -endIndex - 1;
  6541. var clipped = [];
  6542. for (var i = startIndex; i < endIndex; i++) {
  6543. clipped.push(list[i]);
  6544. }
  6545. return clipped;
  6546. };
  6547. this.removeAll = function() {
  6548. return this.ranges.splice(0, this.ranges.length);
  6549. };
  6550. this.attach = function(session) {
  6551. if (this.session)
  6552. this.detach();
  6553. this.session = session;
  6554. this.onChange = this.$onChange.bind(this);
  6555. this.session.on('change', this.onChange);
  6556. };
  6557. this.detach = function() {
  6558. if (!this.session)
  6559. return;
  6560. this.session.removeListener('change', this.onChange);
  6561. this.session = null;
  6562. };
  6563. this.$onChange = function(delta) {
  6564. if (delta.action == "insert"){
  6565. var start = delta.start;
  6566. var end = delta.end;
  6567. } else {
  6568. var end = delta.start;
  6569. var start = delta.end;
  6570. }
  6571. var startRow = start.row;
  6572. var endRow = end.row;
  6573. var lineDif = endRow - startRow;
  6574. var colDiff = -start.column + end.column;
  6575. var ranges = this.ranges;
  6576. for (var i = 0, n = ranges.length; i < n; i++) {
  6577. var r = ranges[i];
  6578. if (r.end.row < startRow)
  6579. continue;
  6580. if (r.start.row > startRow)
  6581. break;
  6582. if (r.start.row == startRow && r.start.column >= start.column ) {
  6583. if (r.start.column == start.column && this.$insertRight) {
  6584. } else {
  6585. r.start.column += colDiff;
  6586. r.start.row += lineDif;
  6587. }
  6588. }
  6589. if (r.end.row == startRow && r.end.column >= start.column) {
  6590. if (r.end.column == start.column && this.$insertRight) {
  6591. continue;
  6592. }
  6593. if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
  6594. if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
  6595. r.end.column -= colDiff;
  6596. }
  6597. r.end.column += colDiff;
  6598. r.end.row += lineDif;
  6599. }
  6600. }
  6601. if (lineDif != 0 && i < n) {
  6602. for (; i < n; i++) {
  6603. var r = ranges[i];
  6604. r.start.row += lineDif;
  6605. r.end.row += lineDif;
  6606. }
  6607. }
  6608. };
  6609. }).call(RangeList.prototype);
  6610. exports.RangeList = RangeList;
  6611. });
  6612. ace.define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
  6613. "use strict";
  6614. var Range = require("../range").Range;
  6615. var RangeList = require("../range_list").RangeList;
  6616. var oop = require("../lib/oop")
  6617. var Fold = exports.Fold = function(range, placeholder) {
  6618. this.foldLine = null;
  6619. this.placeholder = placeholder;
  6620. this.range = range;
  6621. this.start = range.start;
  6622. this.end = range.end;
  6623. this.sameRow = range.start.row == range.end.row;
  6624. this.subFolds = this.ranges = [];
  6625. };
  6626. oop.inherits(Fold, RangeList);
  6627. (function() {
  6628. this.toString = function() {
  6629. return '"' + this.placeholder + '" ' + this.range.toString();
  6630. };
  6631. this.setFoldLine = function(foldLine) {
  6632. this.foldLine = foldLine;
  6633. this.subFolds.forEach(function(fold) {
  6634. fold.setFoldLine(foldLine);
  6635. });
  6636. };
  6637. this.clone = function() {
  6638. var range = this.range.clone();
  6639. var fold = new Fold(range, this.placeholder);
  6640. this.subFolds.forEach(function(subFold) {
  6641. fold.subFolds.push(subFold.clone());
  6642. });
  6643. fold.collapseChildren = this.collapseChildren;
  6644. return fold;
  6645. };
  6646. this.addSubFold = function(fold) {
  6647. if (this.range.isEqual(fold))
  6648. return;
  6649. if (!this.range.containsRange(fold))
  6650. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6651. consumeRange(fold, this.start);
  6652. var row = fold.start.row, column = fold.start.column;
  6653. for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
  6654. cmp = this.subFolds[i].range.compare(row, column);
  6655. if (cmp != 1)
  6656. break;
  6657. }
  6658. var afterStart = this.subFolds[i];
  6659. if (cmp == 0)
  6660. return afterStart.addSubFold(fold);
  6661. var row = fold.range.end.row, column = fold.range.end.column;
  6662. for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
  6663. cmp = this.subFolds[j].range.compare(row, column);
  6664. if (cmp != 1)
  6665. break;
  6666. }
  6667. var afterEnd = this.subFolds[j];
  6668. if (cmp == 0)
  6669. throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
  6670. var consumedFolds = this.subFolds.splice(i, j - i, fold);
  6671. fold.setFoldLine(this.foldLine);
  6672. return fold;
  6673. };
  6674. this.restoreRange = function(range) {
  6675. return restoreRange(range, this.start);
  6676. };
  6677. }).call(Fold.prototype);
  6678. function consumePoint(point, anchor) {
  6679. point.row -= anchor.row;
  6680. if (point.row == 0)
  6681. point.column -= anchor.column;
  6682. }
  6683. function consumeRange(range, anchor) {
  6684. consumePoint(range.start, anchor);
  6685. consumePoint(range.end, anchor);
  6686. }
  6687. function restorePoint(point, anchor) {
  6688. if (point.row == 0)
  6689. point.column += anchor.column;
  6690. point.row += anchor.row;
  6691. }
  6692. function restoreRange(range, anchor) {
  6693. restorePoint(range.start, anchor);
  6694. restorePoint(range.end, anchor);
  6695. }
  6696. });
  6697. 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) {
  6698. "use strict";
  6699. var Range = require("../range").Range;
  6700. var FoldLine = require("./fold_line").FoldLine;
  6701. var Fold = require("./fold").Fold;
  6702. var TokenIterator = require("../token_iterator").TokenIterator;
  6703. function Folding() {
  6704. this.getFoldAt = function(row, column, side) {
  6705. var foldLine = this.getFoldLine(row);
  6706. if (!foldLine)
  6707. return null;
  6708. var folds = foldLine.folds;
  6709. for (var i = 0; i < folds.length; i++) {
  6710. var fold = folds[i];
  6711. if (fold.range.contains(row, column)) {
  6712. if (side == 1 && fold.range.isEnd(row, column)) {
  6713. continue;
  6714. } else if (side == -1 && fold.range.isStart(row, column)) {
  6715. continue;
  6716. }
  6717. return fold;
  6718. }
  6719. }
  6720. };
  6721. this.getFoldsInRange = function(range) {
  6722. var start = range.start;
  6723. var end = range.end;
  6724. var foldLines = this.$foldData;
  6725. var foundFolds = [];
  6726. start.column += 1;
  6727. end.column -= 1;
  6728. for (var i = 0; i < foldLines.length; i++) {
  6729. var cmp = foldLines[i].range.compareRange(range);
  6730. if (cmp == 2) {
  6731. continue;
  6732. }
  6733. else if (cmp == -2) {
  6734. break;
  6735. }
  6736. var folds = foldLines[i].folds;
  6737. for (var j = 0; j < folds.length; j++) {
  6738. var fold = folds[j];
  6739. cmp = fold.range.compareRange(range);
  6740. if (cmp == -2) {
  6741. break;
  6742. } else if (cmp == 2) {
  6743. continue;
  6744. } else
  6745. if (cmp == 42) {
  6746. break;
  6747. }
  6748. foundFolds.push(fold);
  6749. }
  6750. }
  6751. start.column -= 1;
  6752. end.column += 1;
  6753. return foundFolds;
  6754. };
  6755. this.getFoldsInRangeList = function(ranges) {
  6756. if (Array.isArray(ranges)) {
  6757. var folds = [];
  6758. ranges.forEach(function(range) {
  6759. folds = folds.concat(this.getFoldsInRange(range));
  6760. }, this);
  6761. } else {
  6762. var folds = this.getFoldsInRange(ranges);
  6763. }
  6764. return folds;
  6765. };
  6766. this.getAllFolds = function() {
  6767. var folds = [];
  6768. var foldLines = this.$foldData;
  6769. for (var i = 0; i < foldLines.length; i++)
  6770. for (var j = 0; j < foldLines[i].folds.length; j++)
  6771. folds.push(foldLines[i].folds[j]);
  6772. return folds;
  6773. };
  6774. this.getFoldStringAt = function(row, column, trim, foldLine) {
  6775. foldLine = foldLine || this.getFoldLine(row);
  6776. if (!foldLine)
  6777. return null;
  6778. var lastFold = {
  6779. end: { column: 0 }
  6780. };
  6781. var str, fold;
  6782. for (var i = 0; i < foldLine.folds.length; i++) {
  6783. fold = foldLine.folds[i];
  6784. var cmp = fold.range.compareEnd(row, column);
  6785. if (cmp == -1) {
  6786. str = this
  6787. .getLine(fold.start.row)
  6788. .substring(lastFold.end.column, fold.start.column);
  6789. break;
  6790. }
  6791. else if (cmp === 0) {
  6792. return null;
  6793. }
  6794. lastFold = fold;
  6795. }
  6796. if (!str)
  6797. str = this.getLine(fold.start.row).substring(lastFold.end.column);
  6798. if (trim == -1)
  6799. return str.substring(0, column - lastFold.end.column);
  6800. else if (trim == 1)
  6801. return str.substring(column - lastFold.end.column);
  6802. else
  6803. return str;
  6804. };
  6805. this.getFoldLine = function(docRow, startFoldLine) {
  6806. var foldData = this.$foldData;
  6807. var i = 0;
  6808. if (startFoldLine)
  6809. i = foldData.indexOf(startFoldLine);
  6810. if (i == -1)
  6811. i = 0;
  6812. for (i; i < foldData.length; i++) {
  6813. var foldLine = foldData[i];
  6814. if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
  6815. return foldLine;
  6816. } else if (foldLine.end.row > docRow) {
  6817. return null;
  6818. }
  6819. }
  6820. return null;
  6821. };
  6822. this.getNextFoldLine = function(docRow, startFoldLine) {
  6823. var foldData = this.$foldData;
  6824. var i = 0;
  6825. if (startFoldLine)
  6826. i = foldData.indexOf(startFoldLine);
  6827. if (i == -1)
  6828. i = 0;
  6829. for (i; i < foldData.length; i++) {
  6830. var foldLine = foldData[i];
  6831. if (foldLine.end.row >= docRow) {
  6832. return foldLine;
  6833. }
  6834. }
  6835. return null;
  6836. };
  6837. this.getFoldedRowCount = function(first, last) {
  6838. var foldData = this.$foldData, rowCount = last-first+1;
  6839. for (var i = 0; i < foldData.length; i++) {
  6840. var foldLine = foldData[i],
  6841. end = foldLine.end.row,
  6842. start = foldLine.start.row;
  6843. if (end >= last) {
  6844. if (start < last) {
  6845. if (start >= first)
  6846. rowCount -= last-start;
  6847. else
  6848. rowCount = 0; // in one fold
  6849. }
  6850. break;
  6851. } else if (end >= first){
  6852. if (start >= first) // fold inside range
  6853. rowCount -= end-start;
  6854. else
  6855. rowCount -= end-first+1;
  6856. }
  6857. }
  6858. return rowCount;
  6859. };
  6860. this.$addFoldLine = function(foldLine) {
  6861. this.$foldData.push(foldLine);
  6862. this.$foldData.sort(function(a, b) {
  6863. return a.start.row - b.start.row;
  6864. });
  6865. return foldLine;
  6866. };
  6867. this.addFold = function(placeholder, range) {
  6868. var foldData = this.$foldData;
  6869. var added = false;
  6870. var fold;
  6871. if (placeholder instanceof Fold)
  6872. fold = placeholder;
  6873. else {
  6874. fold = new Fold(range, placeholder);
  6875. fold.collapseChildren = range.collapseChildren;
  6876. }
  6877. this.$clipRangeToDocument(fold.range);
  6878. var startRow = fold.start.row;
  6879. var startColumn = fold.start.column;
  6880. var endRow = fold.end.row;
  6881. var endColumn = fold.end.column;
  6882. if (!(startRow < endRow ||
  6883. startRow == endRow && startColumn <= endColumn - 2))
  6884. throw new Error("The range has to be at least 2 characters width");
  6885. var startFold = this.getFoldAt(startRow, startColumn, 1);
  6886. var endFold = this.getFoldAt(endRow, endColumn, -1);
  6887. if (startFold && endFold == startFold)
  6888. return startFold.addSubFold(fold);
  6889. if (startFold && !startFold.range.isStart(startRow, startColumn))
  6890. this.removeFold(startFold);
  6891. if (endFold && !endFold.range.isEnd(endRow, endColumn))
  6892. this.removeFold(endFold);
  6893. var folds = this.getFoldsInRange(fold.range);
  6894. if (folds.length > 0) {
  6895. this.removeFolds(folds);
  6896. folds.forEach(function(subFold) {
  6897. fold.addSubFold(subFold);
  6898. });
  6899. }
  6900. for (var i = 0; i < foldData.length; i++) {
  6901. var foldLine = foldData[i];
  6902. if (endRow == foldLine.start.row) {
  6903. foldLine.addFold(fold);
  6904. added = true;
  6905. break;
  6906. } else if (startRow == foldLine.end.row) {
  6907. foldLine.addFold(fold);
  6908. added = true;
  6909. if (!fold.sameRow) {
  6910. var foldLineNext = foldData[i + 1];
  6911. if (foldLineNext && foldLineNext.start.row == endRow) {
  6912. foldLine.merge(foldLineNext);
  6913. break;
  6914. }
  6915. }
  6916. break;
  6917. } else if (endRow <= foldLine.start.row) {
  6918. break;
  6919. }
  6920. }
  6921. if (!added)
  6922. foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
  6923. if (this.$useWrapMode)
  6924. this.$updateWrapData(foldLine.start.row, foldLine.start.row);
  6925. else
  6926. this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
  6927. this.$modified = true;
  6928. this._signal("changeFold", { data: fold, action: "add" });
  6929. return fold;
  6930. };
  6931. this.addFolds = function(folds) {
  6932. folds.forEach(function(fold) {
  6933. this.addFold(fold);
  6934. }, this);
  6935. };
  6936. this.removeFold = function(fold) {
  6937. var foldLine = fold.foldLine;
  6938. var startRow = foldLine.start.row;
  6939. var endRow = foldLine.end.row;
  6940. var foldLines = this.$foldData;
  6941. var folds = foldLine.folds;
  6942. if (folds.length == 1) {
  6943. foldLines.splice(foldLines.indexOf(foldLine), 1);
  6944. } else
  6945. if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
  6946. folds.pop();
  6947. foldLine.end.row = folds[folds.length - 1].end.row;
  6948. foldLine.end.column = folds[folds.length - 1].end.column;
  6949. } else
  6950. if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
  6951. folds.shift();
  6952. foldLine.start.row = folds[0].start.row;
  6953. foldLine.start.column = folds[0].start.column;
  6954. } else
  6955. if (fold.sameRow) {
  6956. folds.splice(folds.indexOf(fold), 1);
  6957. } else
  6958. {
  6959. var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
  6960. folds = newFoldLine.folds;
  6961. folds.shift();
  6962. newFoldLine.start.row = folds[0].start.row;
  6963. newFoldLine.start.column = folds[0].start.column;
  6964. }
  6965. if (!this.$updating) {
  6966. if (this.$useWrapMode)
  6967. this.$updateWrapData(startRow, endRow);
  6968. else
  6969. this.$updateRowLengthCache(startRow, endRow);
  6970. }
  6971. this.$modified = true;
  6972. this._signal("changeFold", { data: fold, action: "remove" });
  6973. };
  6974. this.removeFolds = function(folds) {
  6975. var cloneFolds = [];
  6976. for (var i = 0; i < folds.length; i++) {
  6977. cloneFolds.push(folds[i]);
  6978. }
  6979. cloneFolds.forEach(function(fold) {
  6980. this.removeFold(fold);
  6981. }, this);
  6982. this.$modified = true;
  6983. };
  6984. this.expandFold = function(fold) {
  6985. this.removeFold(fold);
  6986. fold.subFolds.forEach(function(subFold) {
  6987. fold.restoreRange(subFold);
  6988. this.addFold(subFold);
  6989. }, this);
  6990. if (fold.collapseChildren > 0) {
  6991. this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
  6992. }
  6993. fold.subFolds = [];
  6994. };
  6995. this.expandFolds = function(folds) {
  6996. folds.forEach(function(fold) {
  6997. this.expandFold(fold);
  6998. }, this);
  6999. };
  7000. this.unfold = function(location, expandInner) {
  7001. var range, folds;
  7002. if (location == null) {
  7003. range = new Range(0, 0, this.getLength(), 0);
  7004. expandInner = true;
  7005. } else if (typeof location == "number")
  7006. range = new Range(location, 0, location, this.getLine(location).length);
  7007. else if ("row" in location)
  7008. range = Range.fromPoints(location, location);
  7009. else
  7010. range = location;
  7011. folds = this.getFoldsInRangeList(range);
  7012. if (expandInner) {
  7013. this.removeFolds(folds);
  7014. } else {
  7015. var subFolds = folds;
  7016. while (subFolds.length) {
  7017. this.expandFolds(subFolds);
  7018. subFolds = this.getFoldsInRangeList(range);
  7019. }
  7020. }
  7021. if (folds.length)
  7022. return folds;
  7023. };
  7024. this.isRowFolded = function(docRow, startFoldRow) {
  7025. return !!this.getFoldLine(docRow, startFoldRow);
  7026. };
  7027. this.getRowFoldEnd = function(docRow, startFoldRow) {
  7028. var foldLine = this.getFoldLine(docRow, startFoldRow);
  7029. return foldLine ? foldLine.end.row : docRow;
  7030. };
  7031. this.getRowFoldStart = function(docRow, startFoldRow) {
  7032. var foldLine = this.getFoldLine(docRow, startFoldRow);
  7033. return foldLine ? foldLine.start.row : docRow;
  7034. };
  7035. this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
  7036. if (startRow == null)
  7037. startRow = foldLine.start.row;
  7038. if (startColumn == null)
  7039. startColumn = 0;
  7040. if (endRow == null)
  7041. endRow = foldLine.end.row;
  7042. if (endColumn == null)
  7043. endColumn = this.getLine(endRow).length;
  7044. var doc = this.doc;
  7045. var textLine = "";
  7046. foldLine.walk(function(placeholder, row, column, lastColumn) {
  7047. if (row < startRow)
  7048. return;
  7049. if (row == startRow) {
  7050. if (column < startColumn)
  7051. return;
  7052. lastColumn = Math.max(startColumn, lastColumn);
  7053. }
  7054. if (placeholder != null) {
  7055. textLine += placeholder;
  7056. } else {
  7057. textLine += doc.getLine(row).substring(lastColumn, column);
  7058. }
  7059. }, endRow, endColumn);
  7060. return textLine;
  7061. };
  7062. this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
  7063. var foldLine = this.getFoldLine(row);
  7064. if (!foldLine) {
  7065. var line;
  7066. line = this.doc.getLine(row);
  7067. return line.substring(startColumn || 0, endColumn || line.length);
  7068. } else {
  7069. return this.getFoldDisplayLine(
  7070. foldLine, row, endColumn, startRow, startColumn);
  7071. }
  7072. };
  7073. this.$cloneFoldData = function() {
  7074. var fd = [];
  7075. fd = this.$foldData.map(function(foldLine) {
  7076. var folds = foldLine.folds.map(function(fold) {
  7077. return fold.clone();
  7078. });
  7079. return new FoldLine(fd, folds);
  7080. });
  7081. return fd;
  7082. };
  7083. this.toggleFold = function(tryToUnfold) {
  7084. var selection = this.selection;
  7085. var range = selection.getRange();
  7086. var fold;
  7087. var bracketPos;
  7088. if (range.isEmpty()) {
  7089. var cursor = range.start;
  7090. fold = this.getFoldAt(cursor.row, cursor.column);
  7091. if (fold) {
  7092. this.expandFold(fold);
  7093. return;
  7094. } else if (bracketPos = this.findMatchingBracket(cursor)) {
  7095. if (range.comparePoint(bracketPos) == 1) {
  7096. range.end = bracketPos;
  7097. } else {
  7098. range.start = bracketPos;
  7099. range.start.column++;
  7100. range.end.column--;
  7101. }
  7102. } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
  7103. if (range.comparePoint(bracketPos) == 1)
  7104. range.end = bracketPos;
  7105. else
  7106. range.start = bracketPos;
  7107. range.start.column++;
  7108. } else {
  7109. range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
  7110. }
  7111. } else {
  7112. var folds = this.getFoldsInRange(range);
  7113. if (tryToUnfold && folds.length) {
  7114. this.expandFolds(folds);
  7115. return;
  7116. } else if (folds.length == 1 ) {
  7117. fold = folds[0];
  7118. }
  7119. }
  7120. if (!fold)
  7121. fold = this.getFoldAt(range.start.row, range.start.column);
  7122. if (fold && fold.range.toString() == range.toString()) {
  7123. this.expandFold(fold);
  7124. return;
  7125. }
  7126. var placeholder = "...";
  7127. if (!range.isMultiLine()) {
  7128. placeholder = this.getTextRange(range);
  7129. if (placeholder.length < 4)
  7130. return;
  7131. placeholder = placeholder.trim().substring(0, 2) + "..";
  7132. }
  7133. this.addFold(placeholder, range);
  7134. };
  7135. this.getCommentFoldRange = function(row, column, dir) {
  7136. var iterator = new TokenIterator(this, row, column);
  7137. var token = iterator.getCurrentToken();
  7138. if (token && /^comment|string/.test(token.type)) {
  7139. var range = new Range();
  7140. var re = new RegExp(token.type.replace(/\..*/, "\\."));
  7141. if (dir != 1) {
  7142. do {
  7143. token = iterator.stepBackward();
  7144. } while (token && re.test(token.type));
  7145. iterator.stepForward();
  7146. }
  7147. range.start.row = iterator.getCurrentTokenRow();
  7148. range.start.column = iterator.getCurrentTokenColumn() + 2;
  7149. iterator = new TokenIterator(this, row, column);
  7150. if (dir != -1) {
  7151. do {
  7152. token = iterator.stepForward();
  7153. } while (token && re.test(token.type));
  7154. token = iterator.stepBackward();
  7155. } else
  7156. token = iterator.getCurrentToken();
  7157. range.end.row = iterator.getCurrentTokenRow();
  7158. range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
  7159. return range;
  7160. }
  7161. };
  7162. this.foldAll = function(startRow, endRow, depth) {
  7163. if (depth == undefined)
  7164. depth = 100000; // JSON.stringify doesn't hanle Infinity
  7165. var foldWidgets = this.foldWidgets;
  7166. if (!foldWidgets)
  7167. return; // mode doesn't support folding
  7168. endRow = endRow || this.getLength();
  7169. startRow = startRow || 0;
  7170. for (var row = startRow; row < endRow; row++) {
  7171. if (foldWidgets[row] == null)
  7172. foldWidgets[row] = this.getFoldWidget(row);
  7173. if (foldWidgets[row] != "start")
  7174. continue;
  7175. var range = this.getFoldWidgetRange(row);
  7176. if (range && range.isMultiLine()
  7177. && range.end.row <= endRow
  7178. && range.start.row >= startRow
  7179. ) {
  7180. row = range.end.row;
  7181. try {
  7182. var fold = this.addFold("...", range);
  7183. if (fold)
  7184. fold.collapseChildren = depth;
  7185. } catch(e) {}
  7186. }
  7187. }
  7188. };
  7189. this.$foldStyles = {
  7190. "manual": 1,
  7191. "markbegin": 1,
  7192. "markbeginend": 1
  7193. };
  7194. this.$foldStyle = "markbegin";
  7195. this.setFoldStyle = function(style) {
  7196. if (!this.$foldStyles[style])
  7197. throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
  7198. if (this.$foldStyle == style)
  7199. return;
  7200. this.$foldStyle = style;
  7201. if (style == "manual")
  7202. this.unfold();
  7203. var mode = this.$foldMode;
  7204. this.$setFolding(null);
  7205. this.$setFolding(mode);
  7206. };
  7207. this.$setFolding = function(foldMode) {
  7208. if (this.$foldMode == foldMode)
  7209. return;
  7210. this.$foldMode = foldMode;
  7211. this.off('change', this.$updateFoldWidgets);
  7212. this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  7213. this._signal("changeAnnotation");
  7214. if (!foldMode || this.$foldStyle == "manual") {
  7215. this.foldWidgets = null;
  7216. return;
  7217. }
  7218. this.foldWidgets = [];
  7219. this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
  7220. this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
  7221. this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
  7222. this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
  7223. this.on('change', this.$updateFoldWidgets);
  7224. this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
  7225. };
  7226. this.getParentFoldRangeData = function (row, ignoreCurrent) {
  7227. var fw = this.foldWidgets;
  7228. if (!fw || (ignoreCurrent && fw[row]))
  7229. return {};
  7230. var i = row - 1, firstRange;
  7231. while (i >= 0) {
  7232. var c = fw[i];
  7233. if (c == null)
  7234. c = fw[i] = this.getFoldWidget(i);
  7235. if (c == "start") {
  7236. var range = this.getFoldWidgetRange(i);
  7237. if (!firstRange)
  7238. firstRange = range;
  7239. if (range && range.end.row >= row)
  7240. break;
  7241. }
  7242. i--;
  7243. }
  7244. return {
  7245. range: i !== -1 && range,
  7246. firstRange: firstRange
  7247. };
  7248. };
  7249. this.onFoldWidgetClick = function(row, e) {
  7250. e = e.domEvent;
  7251. var options = {
  7252. children: e.shiftKey,
  7253. all: e.ctrlKey || e.metaKey,
  7254. siblings: e.altKey
  7255. };
  7256. var range = this.$toggleFoldWidget(row, options);
  7257. if (!range) {
  7258. var el = (e.target || e.srcElement);
  7259. if (el && /ace_fold-widget/.test(el.className))
  7260. el.className += " ace_invalid";
  7261. }
  7262. };
  7263. this.$toggleFoldWidget = function(row, options) {
  7264. if (!this.getFoldWidget)
  7265. return;
  7266. var type = this.getFoldWidget(row);
  7267. var line = this.getLine(row);
  7268. var dir = type === "end" ? -1 : 1;
  7269. var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
  7270. if (fold) {
  7271. if (options.children || options.all)
  7272. this.removeFold(fold);
  7273. else
  7274. this.expandFold(fold);
  7275. return fold;
  7276. }
  7277. var range = this.getFoldWidgetRange(row, true);
  7278. if (range && !range.isMultiLine()) {
  7279. fold = this.getFoldAt(range.start.row, range.start.column, 1);
  7280. if (fold && range.isEqual(fold.range)) {
  7281. this.removeFold(fold);
  7282. return fold;
  7283. }
  7284. }
  7285. if (options.siblings) {
  7286. var data = this.getParentFoldRangeData(row);
  7287. if (data.range) {
  7288. var startRow = data.range.start.row + 1;
  7289. var endRow = data.range.end.row;
  7290. }
  7291. this.foldAll(startRow, endRow, options.all ? 10000 : 0);
  7292. } else if (options.children) {
  7293. endRow = range ? range.end.row : this.getLength();
  7294. this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
  7295. } else if (range) {
  7296. if (options.all)
  7297. range.collapseChildren = 10000;
  7298. this.addFold("...", range);
  7299. }
  7300. return range;
  7301. };
  7302. this.toggleFoldWidget = function(toggleParent) {
  7303. var row = this.selection.getCursor().row;
  7304. row = this.getRowFoldStart(row);
  7305. var range = this.$toggleFoldWidget(row, {});
  7306. if (range)
  7307. return;
  7308. var data = this.getParentFoldRangeData(row, true);
  7309. range = data.range || data.firstRange;
  7310. if (range) {
  7311. row = range.start.row;
  7312. var fold = this.getFoldAt(row, this.getLine(row).length, 1);
  7313. if (fold) {
  7314. this.removeFold(fold);
  7315. } else {
  7316. this.addFold("...", range);
  7317. }
  7318. }
  7319. };
  7320. this.updateFoldWidgets = function(delta) {
  7321. var firstRow = delta.start.row;
  7322. var len = delta.end.row - firstRow;
  7323. if (len === 0) {
  7324. this.foldWidgets[firstRow] = null;
  7325. } else if (delta.action == 'remove') {
  7326. this.foldWidgets.splice(firstRow, len + 1, null);
  7327. } else {
  7328. var args = Array(len + 1);
  7329. args.unshift(firstRow, 1);
  7330. this.foldWidgets.splice.apply(this.foldWidgets, args);
  7331. }
  7332. };
  7333. this.tokenizerUpdateFoldWidgets = function(e) {
  7334. var rows = e.data;
  7335. if (rows.first != rows.last) {
  7336. if (this.foldWidgets.length > rows.first)
  7337. this.foldWidgets.splice(rows.first, this.foldWidgets.length);
  7338. }
  7339. };
  7340. }
  7341. exports.Folding = Folding;
  7342. });
  7343. ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
  7344. "use strict";
  7345. var TokenIterator = require("../token_iterator").TokenIterator;
  7346. var Range = require("../range").Range;
  7347. function BracketMatch() {
  7348. this.findMatchingBracket = function(position, chr) {
  7349. if (position.column == 0) return null;
  7350. var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
  7351. if (charBeforeCursor == "") return null;
  7352. var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
  7353. if (!match)
  7354. return null;
  7355. if (match[1])
  7356. return this.$findClosingBracket(match[1], position);
  7357. else
  7358. return this.$findOpeningBracket(match[2], position);
  7359. };
  7360. this.getBracketRange = function(pos) {
  7361. var line = this.getLine(pos.row);
  7362. var before = true, range;
  7363. var chr = line.charAt(pos.column-1);
  7364. var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7365. if (!match) {
  7366. chr = line.charAt(pos.column);
  7367. pos = {row: pos.row, column: pos.column + 1};
  7368. match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
  7369. before = false;
  7370. }
  7371. if (!match)
  7372. return null;
  7373. if (match[1]) {
  7374. var bracketPos = this.$findClosingBracket(match[1], pos);
  7375. if (!bracketPos)
  7376. return null;
  7377. range = Range.fromPoints(pos, bracketPos);
  7378. if (!before) {
  7379. range.end.column++;
  7380. range.start.column--;
  7381. }
  7382. range.cursor = range.end;
  7383. } else {
  7384. var bracketPos = this.$findOpeningBracket(match[2], pos);
  7385. if (!bracketPos)
  7386. return null;
  7387. range = Range.fromPoints(bracketPos, pos);
  7388. if (!before) {
  7389. range.start.column++;
  7390. range.end.column--;
  7391. }
  7392. range.cursor = range.start;
  7393. }
  7394. return range;
  7395. };
  7396. this.$brackets = {
  7397. ")": "(",
  7398. "(": ")",
  7399. "]": "[",
  7400. "[": "]",
  7401. "{": "}",
  7402. "}": "{"
  7403. };
  7404. this.$findOpeningBracket = function(bracket, position, typeRe) {
  7405. var openBracket = this.$brackets[bracket];
  7406. var depth = 1;
  7407. var iterator = new TokenIterator(this, position.row, position.column);
  7408. var token = iterator.getCurrentToken();
  7409. if (!token)
  7410. token = iterator.stepForward();
  7411. if (!token)
  7412. return;
  7413. if (!typeRe){
  7414. typeRe = new RegExp(
  7415. "(\\.?" +
  7416. token.type.replace(".", "\\.").replace("rparen", ".paren")
  7417. .replace(/\b(?:end)\b/, "(?:start|begin|end)")
  7418. + ")+"
  7419. );
  7420. }
  7421. var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
  7422. var value = token.value;
  7423. while (true) {
  7424. while (valueIndex >= 0) {
  7425. var chr = value.charAt(valueIndex);
  7426. if (chr == openBracket) {
  7427. depth -= 1;
  7428. if (depth == 0) {
  7429. return {row: iterator.getCurrentTokenRow(),
  7430. column: valueIndex + iterator.getCurrentTokenColumn()};
  7431. }
  7432. }
  7433. else if (chr == bracket) {
  7434. depth += 1;
  7435. }
  7436. valueIndex -= 1;
  7437. }
  7438. do {
  7439. token = iterator.stepBackward();
  7440. } while (token && !typeRe.test(token.type));
  7441. if (token == null)
  7442. break;
  7443. value = token.value;
  7444. valueIndex = value.length - 1;
  7445. }
  7446. return null;
  7447. };
  7448. this.$findClosingBracket = function(bracket, position, typeRe) {
  7449. var closingBracket = this.$brackets[bracket];
  7450. var depth = 1;
  7451. var iterator = new TokenIterator(this, position.row, position.column);
  7452. var token = iterator.getCurrentToken();
  7453. if (!token)
  7454. token = iterator.stepForward();
  7455. if (!token)
  7456. return;
  7457. if (!typeRe){
  7458. typeRe = new RegExp(
  7459. "(\\.?" +
  7460. token.type.replace(".", "\\.").replace("lparen", ".paren")
  7461. .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
  7462. + ")+"
  7463. );
  7464. }
  7465. var valueIndex = position.column - iterator.getCurrentTokenColumn();
  7466. while (true) {
  7467. var value = token.value;
  7468. var valueLength = value.length;
  7469. while (valueIndex < valueLength) {
  7470. var chr = value.charAt(valueIndex);
  7471. if (chr == closingBracket) {
  7472. depth -= 1;
  7473. if (depth == 0) {
  7474. return {row: iterator.getCurrentTokenRow(),
  7475. column: valueIndex + iterator.getCurrentTokenColumn()};
  7476. }
  7477. }
  7478. else if (chr == bracket) {
  7479. depth += 1;
  7480. }
  7481. valueIndex += 1;
  7482. }
  7483. do {
  7484. token = iterator.stepForward();
  7485. } while (token && !typeRe.test(token.type));
  7486. if (token == null)
  7487. break;
  7488. valueIndex = 0;
  7489. }
  7490. return null;
  7491. };
  7492. }
  7493. exports.BracketMatch = BracketMatch;
  7494. });
  7495. 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) {
  7496. "use strict";
  7497. var oop = require("./lib/oop");
  7498. var lang = require("./lib/lang");
  7499. var config = require("./config");
  7500. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  7501. var Selection = require("./selection").Selection;
  7502. var TextMode = require("./mode/text").Mode;
  7503. var Range = require("./range").Range;
  7504. var Document = require("./document").Document;
  7505. var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
  7506. var SearchHighlight = require("./search_highlight").SearchHighlight;
  7507. var EditSession = function(text, mode) {
  7508. this.$breakpoints = [];
  7509. this.$decorations = [];
  7510. this.$frontMarkers = {};
  7511. this.$backMarkers = {};
  7512. this.$markerId = 1;
  7513. this.$undoSelect = true;
  7514. this.$foldData = [];
  7515. this.id = "session" + (++EditSession.$uid);
  7516. this.$foldData.toString = function() {
  7517. return this.join("\n");
  7518. };
  7519. this.on("changeFold", this.onChangeFold.bind(this));
  7520. this.$onChange = this.onChange.bind(this);
  7521. if (typeof text != "object" || !text.getLine)
  7522. text = new Document(text);
  7523. this.setDocument(text);
  7524. this.selection = new Selection(this);
  7525. config.resetOptions(this);
  7526. this.setMode(mode);
  7527. config._signal("session", this);
  7528. };
  7529. (function() {
  7530. oop.implement(this, EventEmitter);
  7531. this.setDocument = function(doc) {
  7532. if (this.doc)
  7533. this.doc.removeListener("change", this.$onChange);
  7534. this.doc = doc;
  7535. doc.on("change", this.$onChange);
  7536. if (this.bgTokenizer)
  7537. this.bgTokenizer.setDocument(this.getDocument());
  7538. this.resetCaches();
  7539. };
  7540. this.getDocument = function() {
  7541. return this.doc;
  7542. };
  7543. this.$resetRowCache = function(docRow) {
  7544. if (!docRow) {
  7545. this.$docRowCache = [];
  7546. this.$screenRowCache = [];
  7547. return;
  7548. }
  7549. var l = this.$docRowCache.length;
  7550. var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
  7551. if (l > i) {
  7552. this.$docRowCache.splice(i, l);
  7553. this.$screenRowCache.splice(i, l);
  7554. }
  7555. };
  7556. this.$getRowCacheIndex = function(cacheArray, val) {
  7557. var low = 0;
  7558. var hi = cacheArray.length - 1;
  7559. while (low <= hi) {
  7560. var mid = (low + hi) >> 1;
  7561. var c = cacheArray[mid];
  7562. if (val > c)
  7563. low = mid + 1;
  7564. else if (val < c)
  7565. hi = mid - 1;
  7566. else
  7567. return mid;
  7568. }
  7569. return low -1;
  7570. };
  7571. this.resetCaches = function() {
  7572. this.$modified = true;
  7573. this.$wrapData = [];
  7574. this.$rowLengthCache = [];
  7575. this.$resetRowCache(0);
  7576. if (this.bgTokenizer)
  7577. this.bgTokenizer.start(0);
  7578. };
  7579. this.onChangeFold = function(e) {
  7580. var fold = e.data;
  7581. this.$resetRowCache(fold.start.row);
  7582. };
  7583. this.onChange = function(delta) {
  7584. this.$modified = true;
  7585. this.$resetRowCache(delta.start.row);
  7586. var removedFolds = this.$updateInternalDataOnChange(delta);
  7587. if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
  7588. this.$deltasDoc.push(delta);
  7589. if (removedFolds && removedFolds.length != 0) {
  7590. this.$deltasFold.push({
  7591. action: "removeFolds",
  7592. folds: removedFolds
  7593. });
  7594. }
  7595. this.$informUndoManager.schedule();
  7596. }
  7597. this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
  7598. this._signal("change", delta);
  7599. };
  7600. this.setValue = function(text) {
  7601. this.doc.setValue(text);
  7602. this.selection.moveTo(0, 0);
  7603. this.$resetRowCache(0);
  7604. this.$deltas = [];
  7605. this.$deltasDoc = [];
  7606. this.$deltasFold = [];
  7607. this.setUndoManager(this.$undoManager);
  7608. this.getUndoManager().reset();
  7609. };
  7610. this.getValue =
  7611. this.toString = function() {
  7612. return this.doc.getValue();
  7613. };
  7614. this.getSelection = function() {
  7615. return this.selection;
  7616. };
  7617. this.getState = function(row) {
  7618. return this.bgTokenizer.getState(row);
  7619. };
  7620. this.getTokens = function(row) {
  7621. return this.bgTokenizer.getTokens(row);
  7622. };
  7623. this.getTokenAt = function(row, column) {
  7624. var tokens = this.bgTokenizer.getTokens(row);
  7625. var token, c = 0;
  7626. if (column == null) {
  7627. i = tokens.length - 1;
  7628. c = this.getLine(row).length;
  7629. } else {
  7630. for (var i = 0; i < tokens.length; i++) {
  7631. c += tokens[i].value.length;
  7632. if (c >= column)
  7633. break;
  7634. }
  7635. }
  7636. token = tokens[i];
  7637. if (!token)
  7638. return null;
  7639. token.index = i;
  7640. token.start = c - token.value.length;
  7641. return token;
  7642. };
  7643. this.setUndoManager = function(undoManager) {
  7644. this.$undoManager = undoManager;
  7645. this.$deltas = [];
  7646. this.$deltasDoc = [];
  7647. this.$deltasFold = [];
  7648. if (this.$informUndoManager)
  7649. this.$informUndoManager.cancel();
  7650. if (undoManager) {
  7651. var self = this;
  7652. this.$syncInformUndoManager = function() {
  7653. self.$informUndoManager.cancel();
  7654. if (self.$deltasFold.length) {
  7655. self.$deltas.push({
  7656. group: "fold",
  7657. deltas: self.$deltasFold
  7658. });
  7659. self.$deltasFold = [];
  7660. }
  7661. if (self.$deltasDoc.length) {
  7662. self.$deltas.push({
  7663. group: "doc",
  7664. deltas: self.$deltasDoc
  7665. });
  7666. self.$deltasDoc = [];
  7667. }
  7668. if (self.$deltas.length > 0) {
  7669. undoManager.execute({
  7670. action: "aceupdate",
  7671. args: [self.$deltas, self],
  7672. merge: self.mergeUndoDeltas
  7673. });
  7674. }
  7675. self.mergeUndoDeltas = false;
  7676. self.$deltas = [];
  7677. };
  7678. this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
  7679. }
  7680. };
  7681. this.markUndoGroup = function() {
  7682. if (this.$syncInformUndoManager)
  7683. this.$syncInformUndoManager();
  7684. };
  7685. this.$defaultUndoManager = {
  7686. undo: function() {},
  7687. redo: function() {},
  7688. reset: function() {}
  7689. };
  7690. this.getUndoManager = function() {
  7691. return this.$undoManager || this.$defaultUndoManager;
  7692. };
  7693. this.getTabString = function() {
  7694. if (this.getUseSoftTabs()) {
  7695. return lang.stringRepeat(" ", this.getTabSize());
  7696. } else {
  7697. return "\t";
  7698. }
  7699. };
  7700. this.setUseSoftTabs = function(val) {
  7701. this.setOption("useSoftTabs", val);
  7702. };
  7703. this.getUseSoftTabs = function() {
  7704. return this.$useSoftTabs && !this.$mode.$indentWithTabs;
  7705. };
  7706. this.setTabSize = function(tabSize) {
  7707. this.setOption("tabSize", tabSize);
  7708. };
  7709. this.getTabSize = function() {
  7710. return this.$tabSize;
  7711. };
  7712. this.isTabStop = function(position) {
  7713. return this.$useSoftTabs && (position.column % this.$tabSize === 0);
  7714. };
  7715. this.$overwrite = false;
  7716. this.setOverwrite = function(overwrite) {
  7717. this.setOption("overwrite", overwrite);
  7718. };
  7719. this.getOverwrite = function() {
  7720. return this.$overwrite;
  7721. };
  7722. this.toggleOverwrite = function() {
  7723. this.setOverwrite(!this.$overwrite);
  7724. };
  7725. this.addGutterDecoration = function(row, className) {
  7726. if (!this.$decorations[row])
  7727. this.$decorations[row] = "";
  7728. this.$decorations[row] += " " + className;
  7729. this._signal("changeBreakpoint", {});
  7730. };
  7731. this.removeGutterDecoration = function(row, className) {
  7732. this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
  7733. this._signal("changeBreakpoint", {});
  7734. };
  7735. this.getBreakpoints = function() {
  7736. return this.$breakpoints;
  7737. };
  7738. this.setBreakpoints = function(rows) {
  7739. this.$breakpoints = [];
  7740. for (var i=0; i<rows.length; i++) {
  7741. this.$breakpoints[rows[i]] = "ace_breakpoint";
  7742. }
  7743. this._signal("changeBreakpoint", {});
  7744. };
  7745. this.clearBreakpoints = function() {
  7746. this.$breakpoints = [];
  7747. this._signal("changeBreakpoint", {});
  7748. };
  7749. this.setBreakpoint = function(row, className) {
  7750. if (className === undefined)
  7751. className = "ace_breakpoint";
  7752. if (className)
  7753. this.$breakpoints[row] = className;
  7754. else
  7755. delete this.$breakpoints[row];
  7756. this._signal("changeBreakpoint", {});
  7757. };
  7758. this.clearBreakpoint = function(row) {
  7759. delete this.$breakpoints[row];
  7760. this._signal("changeBreakpoint", {});
  7761. };
  7762. this.addMarker = function(range, clazz, type, inFront) {
  7763. var id = this.$markerId++;
  7764. var marker = {
  7765. range : range,
  7766. type : type || "line",
  7767. renderer: typeof type == "function" ? type : null,
  7768. clazz : clazz,
  7769. inFront: !!inFront,
  7770. id: id
  7771. };
  7772. if (inFront) {
  7773. this.$frontMarkers[id] = marker;
  7774. this._signal("changeFrontMarker");
  7775. } else {
  7776. this.$backMarkers[id] = marker;
  7777. this._signal("changeBackMarker");
  7778. }
  7779. return id;
  7780. };
  7781. this.addDynamicMarker = function(marker, inFront) {
  7782. if (!marker.update)
  7783. return;
  7784. var id = this.$markerId++;
  7785. marker.id = id;
  7786. marker.inFront = !!inFront;
  7787. if (inFront) {
  7788. this.$frontMarkers[id] = marker;
  7789. this._signal("changeFrontMarker");
  7790. } else {
  7791. this.$backMarkers[id] = marker;
  7792. this._signal("changeBackMarker");
  7793. }
  7794. return marker;
  7795. };
  7796. this.removeMarker = function(markerId) {
  7797. var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
  7798. if (!marker)
  7799. return;
  7800. var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
  7801. if (marker) {
  7802. delete (markers[markerId]);
  7803. this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
  7804. }
  7805. };
  7806. this.getMarkers = function(inFront) {
  7807. return inFront ? this.$frontMarkers : this.$backMarkers;
  7808. };
  7809. this.highlight = function(re) {
  7810. if (!this.$searchHighlight) {
  7811. var highlight = new SearchHighlight(null, "ace_selected-word", "text");
  7812. this.$searchHighlight = this.addDynamicMarker(highlight);
  7813. }
  7814. this.$searchHighlight.setRegexp(re);
  7815. };
  7816. this.highlightLines = function(startRow, endRow, clazz, inFront) {
  7817. if (typeof endRow != "number") {
  7818. clazz = endRow;
  7819. endRow = startRow;
  7820. }
  7821. if (!clazz)
  7822. clazz = "ace_step";
  7823. var range = new Range(startRow, 0, endRow, Infinity);
  7824. range.id = this.addMarker(range, clazz, "fullLine", inFront);
  7825. return range;
  7826. };
  7827. this.setAnnotations = function(annotations) {
  7828. this.$annotations = annotations;
  7829. this._signal("changeAnnotation", {});
  7830. };
  7831. this.getAnnotations = function() {
  7832. return this.$annotations || [];
  7833. };
  7834. this.clearAnnotations = function() {
  7835. this.setAnnotations([]);
  7836. };
  7837. this.$detectNewLine = function(text) {
  7838. var match = text.match(/^.*?(\r?\n)/m);
  7839. if (match) {
  7840. this.$autoNewLine = match[1];
  7841. } else {
  7842. this.$autoNewLine = "\n";
  7843. }
  7844. };
  7845. this.getWordRange = function(row, column) {
  7846. var line = this.getLine(row);
  7847. var inToken = false;
  7848. if (column > 0)
  7849. inToken = !!line.charAt(column - 1).match(this.tokenRe);
  7850. if (!inToken)
  7851. inToken = !!line.charAt(column).match(this.tokenRe);
  7852. if (inToken)
  7853. var re = this.tokenRe;
  7854. else if (/^\s+$/.test(line.slice(column-1, column+1)))
  7855. var re = /\s/;
  7856. else
  7857. var re = this.nonTokenRe;
  7858. var start = column;
  7859. if (start > 0) {
  7860. do {
  7861. start--;
  7862. }
  7863. while (start >= 0 && line.charAt(start).match(re));
  7864. start++;
  7865. }
  7866. var end = column;
  7867. while (end < line.length && line.charAt(end).match(re)) {
  7868. end++;
  7869. }
  7870. return new Range(row, start, row, end);
  7871. };
  7872. this.getAWordRange = function(row, column) {
  7873. var wordRange = this.getWordRange(row, column);
  7874. var line = this.getLine(wordRange.end.row);
  7875. while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
  7876. wordRange.end.column += 1;
  7877. }
  7878. return wordRange;
  7879. };
  7880. this.setNewLineMode = function(newLineMode) {
  7881. this.doc.setNewLineMode(newLineMode);
  7882. };
  7883. this.getNewLineMode = function() {
  7884. return this.doc.getNewLineMode();
  7885. };
  7886. this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
  7887. this.getUseWorker = function() { return this.$useWorker; };
  7888. this.onReloadTokenizer = function(e) {
  7889. var rows = e.data;
  7890. this.bgTokenizer.start(rows.first);
  7891. this._signal("tokenizerUpdate", e);
  7892. };
  7893. this.$modes = {};
  7894. this.$mode = null;
  7895. this.$modeId = null;
  7896. this.setMode = function(mode, cb) {
  7897. if (mode && typeof mode === "object") {
  7898. if (mode.getTokenizer)
  7899. return this.$onChangeMode(mode);
  7900. var options = mode;
  7901. var path = options.path;
  7902. } else {
  7903. path = mode || "ace/mode/text";
  7904. }
  7905. if (!this.$modes["ace/mode/text"])
  7906. this.$modes["ace/mode/text"] = new TextMode();
  7907. if (this.$modes[path] && !options) {
  7908. this.$onChangeMode(this.$modes[path]);
  7909. cb && cb();
  7910. return;
  7911. }
  7912. this.$modeId = path;
  7913. config.loadModule(["mode", path], function(m) {
  7914. if (this.$modeId !== path)
  7915. return cb && cb();
  7916. if (this.$modes[path] && !options) {
  7917. this.$onChangeMode(this.$modes[path]);
  7918. } else if (m && m.Mode) {
  7919. m = new m.Mode(options);
  7920. if (!options) {
  7921. this.$modes[path] = m;
  7922. m.$id = path;
  7923. }
  7924. this.$onChangeMode(m);
  7925. }
  7926. cb && cb();
  7927. }.bind(this));
  7928. if (!this.$mode)
  7929. this.$onChangeMode(this.$modes["ace/mode/text"], true);
  7930. };
  7931. this.$onChangeMode = function(mode, $isPlaceholder) {
  7932. if (!$isPlaceholder)
  7933. this.$modeId = mode.$id;
  7934. if (this.$mode === mode)
  7935. return;
  7936. this.$mode = mode;
  7937. this.$stopWorker();
  7938. if (this.$useWorker)
  7939. this.$startWorker();
  7940. var tokenizer = mode.getTokenizer();
  7941. if(tokenizer.addEventListener !== undefined) {
  7942. var onReloadTokenizer = this.onReloadTokenizer.bind(this);
  7943. tokenizer.addEventListener("update", onReloadTokenizer);
  7944. }
  7945. if (!this.bgTokenizer) {
  7946. this.bgTokenizer = new BackgroundTokenizer(tokenizer);
  7947. var _self = this;
  7948. this.bgTokenizer.addEventListener("update", function(e) {
  7949. _self._signal("tokenizerUpdate", e);
  7950. });
  7951. } else {
  7952. this.bgTokenizer.setTokenizer(tokenizer);
  7953. }
  7954. this.bgTokenizer.setDocument(this.getDocument());
  7955. this.tokenRe = mode.tokenRe;
  7956. this.nonTokenRe = mode.nonTokenRe;
  7957. if (!$isPlaceholder) {
  7958. if (mode.attachToSession)
  7959. mode.attachToSession(this);
  7960. this.$options.wrapMethod.set.call(this, this.$wrapMethod);
  7961. this.$setFolding(mode.foldingRules);
  7962. this.bgTokenizer.start(0);
  7963. this._emit("changeMode");
  7964. }
  7965. };
  7966. this.$stopWorker = function() {
  7967. if (this.$worker) {
  7968. this.$worker.terminate();
  7969. this.$worker = null;
  7970. }
  7971. };
  7972. this.$startWorker = function() {
  7973. try {
  7974. this.$worker = this.$mode.createWorker(this);
  7975. } catch (e) {
  7976. config.warn("Could not load worker", e);
  7977. this.$worker = null;
  7978. }
  7979. };
  7980. this.getMode = function() {
  7981. return this.$mode;
  7982. };
  7983. this.$scrollTop = 0;
  7984. this.setScrollTop = function(scrollTop) {
  7985. if (this.$scrollTop === scrollTop || isNaN(scrollTop))
  7986. return;
  7987. this.$scrollTop = scrollTop;
  7988. this._signal("changeScrollTop", scrollTop);
  7989. };
  7990. this.getScrollTop = function() {
  7991. return this.$scrollTop;
  7992. };
  7993. this.$scrollLeft = 0;
  7994. this.setScrollLeft = function(scrollLeft) {
  7995. if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
  7996. return;
  7997. this.$scrollLeft = scrollLeft;
  7998. this._signal("changeScrollLeft", scrollLeft);
  7999. };
  8000. this.getScrollLeft = function() {
  8001. return this.$scrollLeft;
  8002. };
  8003. this.getScreenWidth = function() {
  8004. this.$computeWidth();
  8005. if (this.lineWidgets)
  8006. return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
  8007. return this.screenWidth;
  8008. };
  8009. this.getLineWidgetMaxWidth = function() {
  8010. if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
  8011. var width = 0;
  8012. this.lineWidgets.forEach(function(w) {
  8013. if (w && w.screenWidth > width)
  8014. width = w.screenWidth;
  8015. });
  8016. return this.lineWidgetWidth = width;
  8017. };
  8018. this.$computeWidth = function(force) {
  8019. if (this.$modified || force) {
  8020. this.$modified = false;
  8021. if (this.$useWrapMode)
  8022. return this.screenWidth = this.$wrapLimit;
  8023. var lines = this.doc.getAllLines();
  8024. var cache = this.$rowLengthCache;
  8025. var longestScreenLine = 0;
  8026. var foldIndex = 0;
  8027. var foldLine = this.$foldData[foldIndex];
  8028. var foldStart = foldLine ? foldLine.start.row : Infinity;
  8029. var len = lines.length;
  8030. for (var i = 0; i < len; i++) {
  8031. if (i > foldStart) {
  8032. i = foldLine.end.row + 1;
  8033. if (i >= len)
  8034. break;
  8035. foldLine = this.$foldData[foldIndex++];
  8036. foldStart = foldLine ? foldLine.start.row : Infinity;
  8037. }
  8038. if (cache[i] == null)
  8039. cache[i] = this.$getStringScreenWidth(lines[i])[0];
  8040. if (cache[i] > longestScreenLine)
  8041. longestScreenLine = cache[i];
  8042. }
  8043. this.screenWidth = longestScreenLine;
  8044. }
  8045. };
  8046. this.getLine = function(row) {
  8047. return this.doc.getLine(row);
  8048. };
  8049. this.getLines = function(firstRow, lastRow) {
  8050. return this.doc.getLines(firstRow, lastRow);
  8051. };
  8052. this.getLength = function() {
  8053. return this.doc.getLength();
  8054. };
  8055. this.getTextRange = function(range) {
  8056. return this.doc.getTextRange(range || this.selection.getRange());
  8057. };
  8058. this.insert = function(position, text) {
  8059. return this.doc.insert(position, text);
  8060. };
  8061. this.remove = function(range) {
  8062. return this.doc.remove(range);
  8063. };
  8064. this.removeFullLines = function(firstRow, lastRow){
  8065. return this.doc.removeFullLines(firstRow, lastRow);
  8066. };
  8067. this.undoChanges = function(deltas, dontSelect) {
  8068. if (!deltas.length)
  8069. return;
  8070. this.$fromUndo = true;
  8071. var lastUndoRange = null;
  8072. for (var i = deltas.length - 1; i != -1; i--) {
  8073. var delta = deltas[i];
  8074. if (delta.group == "doc") {
  8075. this.doc.revertDeltas(delta.deltas);
  8076. lastUndoRange =
  8077. this.$getUndoSelection(delta.deltas, true, lastUndoRange);
  8078. } else {
  8079. delta.deltas.forEach(function(foldDelta) {
  8080. this.addFolds(foldDelta.folds);
  8081. }, this);
  8082. }
  8083. }
  8084. this.$fromUndo = false;
  8085. lastUndoRange &&
  8086. this.$undoSelect &&
  8087. !dontSelect &&
  8088. this.selection.setSelectionRange(lastUndoRange);
  8089. return lastUndoRange;
  8090. };
  8091. this.redoChanges = function(deltas, dontSelect) {
  8092. if (!deltas.length)
  8093. return;
  8094. this.$fromUndo = true;
  8095. var lastUndoRange = null;
  8096. for (var i = 0; i < deltas.length; i++) {
  8097. var delta = deltas[i];
  8098. if (delta.group == "doc") {
  8099. this.doc.applyDeltas(delta.deltas);
  8100. lastUndoRange =
  8101. this.$getUndoSelection(delta.deltas, false, lastUndoRange);
  8102. }
  8103. }
  8104. this.$fromUndo = false;
  8105. lastUndoRange &&
  8106. this.$undoSelect &&
  8107. !dontSelect &&
  8108. this.selection.setSelectionRange(lastUndoRange);
  8109. return lastUndoRange;
  8110. };
  8111. this.setUndoSelect = function(enable) {
  8112. this.$undoSelect = enable;
  8113. };
  8114. this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
  8115. function isInsert(delta) {
  8116. return isUndo ? delta.action !== "insert" : delta.action === "insert";
  8117. }
  8118. var delta = deltas[0];
  8119. var range, point;
  8120. var lastDeltaIsInsert = false;
  8121. if (isInsert(delta)) {
  8122. range = Range.fromPoints(delta.start, delta.end);
  8123. lastDeltaIsInsert = true;
  8124. } else {
  8125. range = Range.fromPoints(delta.start, delta.start);
  8126. lastDeltaIsInsert = false;
  8127. }
  8128. for (var i = 1; i < deltas.length; i++) {
  8129. delta = deltas[i];
  8130. if (isInsert(delta)) {
  8131. point = delta.start;
  8132. if (range.compare(point.row, point.column) == -1) {
  8133. range.setStart(point);
  8134. }
  8135. point = delta.end;
  8136. if (range.compare(point.row, point.column) == 1) {
  8137. range.setEnd(point);
  8138. }
  8139. lastDeltaIsInsert = true;
  8140. } else {
  8141. point = delta.start;
  8142. if (range.compare(point.row, point.column) == -1) {
  8143. range = Range.fromPoints(delta.start, delta.start);
  8144. }
  8145. lastDeltaIsInsert = false;
  8146. }
  8147. }
  8148. if (lastUndoRange != null) {
  8149. if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
  8150. lastUndoRange.start.column += range.end.column - range.start.column;
  8151. lastUndoRange.end.column += range.end.column - range.start.column;
  8152. }
  8153. var cmp = lastUndoRange.compareRange(range);
  8154. if (cmp == 1) {
  8155. range.setStart(lastUndoRange.start);
  8156. } else if (cmp == -1) {
  8157. range.setEnd(lastUndoRange.end);
  8158. }
  8159. }
  8160. return range;
  8161. };
  8162. this.replace = function(range, text) {
  8163. return this.doc.replace(range, text);
  8164. };
  8165. this.moveText = function(fromRange, toPosition, copy) {
  8166. var text = this.getTextRange(fromRange);
  8167. var folds = this.getFoldsInRange(fromRange);
  8168. var toRange = Range.fromPoints(toPosition, toPosition);
  8169. if (!copy) {
  8170. this.remove(fromRange);
  8171. var rowDiff = fromRange.start.row - fromRange.end.row;
  8172. var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
  8173. if (collDiff) {
  8174. if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
  8175. toRange.start.column += collDiff;
  8176. if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
  8177. toRange.end.column += collDiff;
  8178. }
  8179. if (rowDiff && toRange.start.row >= fromRange.end.row) {
  8180. toRange.start.row += rowDiff;
  8181. toRange.end.row += rowDiff;
  8182. }
  8183. }
  8184. toRange.end = this.insert(toRange.start, text);
  8185. if (folds.length) {
  8186. var oldStart = fromRange.start;
  8187. var newStart = toRange.start;
  8188. var rowDiff = newStart.row - oldStart.row;
  8189. var collDiff = newStart.column - oldStart.column;
  8190. this.addFolds(folds.map(function(x) {
  8191. x = x.clone();
  8192. if (x.start.row == oldStart.row)
  8193. x.start.column += collDiff;
  8194. if (x.end.row == oldStart.row)
  8195. x.end.column += collDiff;
  8196. x.start.row += rowDiff;
  8197. x.end.row += rowDiff;
  8198. return x;
  8199. }));
  8200. }
  8201. return toRange;
  8202. };
  8203. this.indentRows = function(startRow, endRow, indentString) {
  8204. indentString = indentString.replace(/\t/g, this.getTabString());
  8205. for (var row=startRow; row<=endRow; row++)
  8206. this.doc.insertInLine({row: row, column: 0}, indentString);
  8207. };
  8208. this.outdentRows = function (range) {
  8209. var rowRange = range.collapseRows();
  8210. var deleteRange = new Range(0, 0, 0, 0);
  8211. var size = this.getTabSize();
  8212. for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
  8213. var line = this.getLine(i);
  8214. deleteRange.start.row = i;
  8215. deleteRange.end.row = i;
  8216. for (var j = 0; j < size; ++j)
  8217. if (line.charAt(j) != ' ')
  8218. break;
  8219. if (j < size && line.charAt(j) == '\t') {
  8220. deleteRange.start.column = j;
  8221. deleteRange.end.column = j + 1;
  8222. } else {
  8223. deleteRange.start.column = 0;
  8224. deleteRange.end.column = j;
  8225. }
  8226. this.remove(deleteRange);
  8227. }
  8228. };
  8229. this.$moveLines = function(firstRow, lastRow, dir) {
  8230. firstRow = this.getRowFoldStart(firstRow);
  8231. lastRow = this.getRowFoldEnd(lastRow);
  8232. if (dir < 0) {
  8233. var row = this.getRowFoldStart(firstRow + dir);
  8234. if (row < 0) return 0;
  8235. var diff = row-firstRow;
  8236. } else if (dir > 0) {
  8237. var row = this.getRowFoldEnd(lastRow + dir);
  8238. if (row > this.doc.getLength()-1) return 0;
  8239. var diff = row-lastRow;
  8240. } else {
  8241. firstRow = this.$clipRowToDocument(firstRow);
  8242. lastRow = this.$clipRowToDocument(lastRow);
  8243. var diff = lastRow - firstRow + 1;
  8244. }
  8245. var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
  8246. var folds = this.getFoldsInRange(range).map(function(x){
  8247. x = x.clone();
  8248. x.start.row += diff;
  8249. x.end.row += diff;
  8250. return x;
  8251. });
  8252. var lines = dir == 0
  8253. ? this.doc.getLines(firstRow, lastRow)
  8254. : this.doc.removeFullLines(firstRow, lastRow);
  8255. this.doc.insertFullLines(firstRow+diff, lines);
  8256. folds.length && this.addFolds(folds);
  8257. return diff;
  8258. };
  8259. this.moveLinesUp = function(firstRow, lastRow) {
  8260. return this.$moveLines(firstRow, lastRow, -1);
  8261. };
  8262. this.moveLinesDown = function(firstRow, lastRow) {
  8263. return this.$moveLines(firstRow, lastRow, 1);
  8264. };
  8265. this.duplicateLines = function(firstRow, lastRow) {
  8266. return this.$moveLines(firstRow, lastRow, 0);
  8267. };
  8268. this.$clipRowToDocument = function(row) {
  8269. return Math.max(0, Math.min(row, this.doc.getLength()-1));
  8270. };
  8271. this.$clipColumnToRow = function(row, column) {
  8272. if (column < 0)
  8273. return 0;
  8274. return Math.min(this.doc.getLine(row).length, column);
  8275. };
  8276. this.$clipPositionToDocument = function(row, column) {
  8277. column = Math.max(0, column);
  8278. if (row < 0) {
  8279. row = 0;
  8280. column = 0;
  8281. } else {
  8282. var len = this.doc.getLength();
  8283. if (row >= len) {
  8284. row = len - 1;
  8285. column = this.doc.getLine(len-1).length;
  8286. } else {
  8287. column = Math.min(this.doc.getLine(row).length, column);
  8288. }
  8289. }
  8290. return {
  8291. row: row,
  8292. column: column
  8293. };
  8294. };
  8295. this.$clipRangeToDocument = function(range) {
  8296. if (range.start.row < 0) {
  8297. range.start.row = 0;
  8298. range.start.column = 0;
  8299. } else {
  8300. range.start.column = this.$clipColumnToRow(
  8301. range.start.row,
  8302. range.start.column
  8303. );
  8304. }
  8305. var len = this.doc.getLength() - 1;
  8306. if (range.end.row > len) {
  8307. range.end.row = len;
  8308. range.end.column = this.doc.getLine(len).length;
  8309. } else {
  8310. range.end.column = this.$clipColumnToRow(
  8311. range.end.row,
  8312. range.end.column
  8313. );
  8314. }
  8315. return range;
  8316. };
  8317. this.$wrapLimit = 80;
  8318. this.$useWrapMode = false;
  8319. this.$wrapLimitRange = {
  8320. min : null,
  8321. max : null
  8322. };
  8323. this.setUseWrapMode = function(useWrapMode) {
  8324. if (useWrapMode != this.$useWrapMode) {
  8325. this.$useWrapMode = useWrapMode;
  8326. this.$modified = true;
  8327. this.$resetRowCache(0);
  8328. if (useWrapMode) {
  8329. var len = this.getLength();
  8330. this.$wrapData = Array(len);
  8331. this.$updateWrapData(0, len - 1);
  8332. }
  8333. this._signal("changeWrapMode");
  8334. }
  8335. };
  8336. this.getUseWrapMode = function() {
  8337. return this.$useWrapMode;
  8338. };
  8339. this.setWrapLimitRange = function(min, max) {
  8340. if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
  8341. this.$wrapLimitRange = { min: min, max: max };
  8342. this.$modified = true;
  8343. if (this.$useWrapMode)
  8344. this._signal("changeWrapMode");
  8345. }
  8346. };
  8347. this.adjustWrapLimit = function(desiredLimit, $printMargin) {
  8348. var limits = this.$wrapLimitRange;
  8349. if (limits.max < 0)
  8350. limits = {min: $printMargin, max: $printMargin};
  8351. var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
  8352. if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
  8353. this.$wrapLimit = wrapLimit;
  8354. this.$modified = true;
  8355. if (this.$useWrapMode) {
  8356. this.$updateWrapData(0, this.getLength() - 1);
  8357. this.$resetRowCache(0);
  8358. this._signal("changeWrapLimit");
  8359. }
  8360. return true;
  8361. }
  8362. return false;
  8363. };
  8364. this.$constrainWrapLimit = function(wrapLimit, min, max) {
  8365. if (min)
  8366. wrapLimit = Math.max(min, wrapLimit);
  8367. if (max)
  8368. wrapLimit = Math.min(max, wrapLimit);
  8369. return wrapLimit;
  8370. };
  8371. this.getWrapLimit = function() {
  8372. return this.$wrapLimit;
  8373. };
  8374. this.setWrapLimit = function (limit) {
  8375. this.setWrapLimitRange(limit, limit);
  8376. };
  8377. this.getWrapLimitRange = function() {
  8378. return {
  8379. min : this.$wrapLimitRange.min,
  8380. max : this.$wrapLimitRange.max
  8381. };
  8382. };
  8383. this.$updateInternalDataOnChange = function(delta) {
  8384. var useWrapMode = this.$useWrapMode;
  8385. var action = delta.action;
  8386. var start = delta.start;
  8387. var end = delta.end;
  8388. var firstRow = start.row;
  8389. var lastRow = end.row;
  8390. var len = lastRow - firstRow;
  8391. var removedFolds = null;
  8392. this.$updating = true;
  8393. if (len != 0) {
  8394. if (action === "remove") {
  8395. this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
  8396. var foldLines = this.$foldData;
  8397. removedFolds = this.getFoldsInRange(delta);
  8398. this.removeFolds(removedFolds);
  8399. var foldLine = this.getFoldLine(end.row);
  8400. var idx = 0;
  8401. if (foldLine) {
  8402. foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
  8403. foldLine.shiftRow(-len);
  8404. var foldLineBefore = this.getFoldLine(firstRow);
  8405. if (foldLineBefore && foldLineBefore !== foldLine) {
  8406. foldLineBefore.merge(foldLine);
  8407. foldLine = foldLineBefore;
  8408. }
  8409. idx = foldLines.indexOf(foldLine) + 1;
  8410. }
  8411. for (idx; idx < foldLines.length; idx++) {
  8412. var foldLine = foldLines[idx];
  8413. if (foldLine.start.row >= end.row) {
  8414. foldLine.shiftRow(-len);
  8415. }
  8416. }
  8417. lastRow = firstRow;
  8418. } else {
  8419. var args = Array(len);
  8420. args.unshift(firstRow, 0);
  8421. var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
  8422. arr.splice.apply(arr, args);
  8423. var foldLines = this.$foldData;
  8424. var foldLine = this.getFoldLine(firstRow);
  8425. var idx = 0;
  8426. if (foldLine) {
  8427. var cmp = foldLine.range.compareInside(start.row, start.column);
  8428. if (cmp == 0) {
  8429. foldLine = foldLine.split(start.row, start.column);
  8430. if (foldLine) {
  8431. foldLine.shiftRow(len);
  8432. foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
  8433. }
  8434. } else
  8435. if (cmp == -1) {
  8436. foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
  8437. foldLine.shiftRow(len);
  8438. }
  8439. idx = foldLines.indexOf(foldLine) + 1;
  8440. }
  8441. for (idx; idx < foldLines.length; idx++) {
  8442. var foldLine = foldLines[idx];
  8443. if (foldLine.start.row >= firstRow) {
  8444. foldLine.shiftRow(len);
  8445. }
  8446. }
  8447. }
  8448. } else {
  8449. len = Math.abs(delta.start.column - delta.end.column);
  8450. if (action === "remove") {
  8451. removedFolds = this.getFoldsInRange(delta);
  8452. this.removeFolds(removedFolds);
  8453. len = -len;
  8454. }
  8455. var foldLine = this.getFoldLine(firstRow);
  8456. if (foldLine) {
  8457. foldLine.addRemoveChars(firstRow, start.column, len);
  8458. }
  8459. }
  8460. if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
  8461. console.error("doc.getLength() and $wrapData.length have to be the same!");
  8462. }
  8463. this.$updating = false;
  8464. if (useWrapMode)
  8465. this.$updateWrapData(firstRow, lastRow);
  8466. else
  8467. this.$updateRowLengthCache(firstRow, lastRow);
  8468. return removedFolds;
  8469. };
  8470. this.$updateRowLengthCache = function(firstRow, lastRow, b) {
  8471. this.$rowLengthCache[firstRow] = null;
  8472. this.$rowLengthCache[lastRow] = null;
  8473. };
  8474. this.$updateWrapData = function(firstRow, lastRow) {
  8475. var lines = this.doc.getAllLines();
  8476. var tabSize = this.getTabSize();
  8477. var wrapData = this.$wrapData;
  8478. var wrapLimit = this.$wrapLimit;
  8479. var tokens;
  8480. var foldLine;
  8481. var row = firstRow;
  8482. lastRow = Math.min(lastRow, lines.length - 1);
  8483. while (row <= lastRow) {
  8484. foldLine = this.getFoldLine(row, foldLine);
  8485. if (!foldLine) {
  8486. tokens = this.$getDisplayTokens(lines[row]);
  8487. wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8488. row ++;
  8489. } else {
  8490. tokens = [];
  8491. foldLine.walk(function(placeholder, row, column, lastColumn) {
  8492. var walkTokens;
  8493. if (placeholder != null) {
  8494. walkTokens = this.$getDisplayTokens(
  8495. placeholder, tokens.length);
  8496. walkTokens[0] = PLACEHOLDER_START;
  8497. for (var i = 1; i < walkTokens.length; i++) {
  8498. walkTokens[i] = PLACEHOLDER_BODY;
  8499. }
  8500. } else {
  8501. walkTokens = this.$getDisplayTokens(
  8502. lines[row].substring(lastColumn, column),
  8503. tokens.length);
  8504. }
  8505. tokens = tokens.concat(walkTokens);
  8506. }.bind(this),
  8507. foldLine.end.row,
  8508. lines[foldLine.end.row].length + 1
  8509. );
  8510. wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
  8511. row = foldLine.end.row + 1;
  8512. }
  8513. }
  8514. };
  8515. var CHAR = 1,
  8516. CHAR_EXT = 2,
  8517. PLACEHOLDER_START = 3,
  8518. PLACEHOLDER_BODY = 4,
  8519. PUNCTUATION = 9,
  8520. SPACE = 10,
  8521. TAB = 11,
  8522. TAB_SPACE = 12;
  8523. this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
  8524. if (tokens.length == 0) {
  8525. return [];
  8526. }
  8527. var splits = [];
  8528. var displayLength = tokens.length;
  8529. var lastSplit = 0, lastDocSplit = 0;
  8530. var isCode = this.$wrapAsCode;
  8531. var indentedSoftWrap = this.$indentedSoftWrap;
  8532. var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
  8533. || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
  8534. function getWrapIndent() {
  8535. var indentation = 0;
  8536. if (maxIndent === 0)
  8537. return indentation;
  8538. if (indentedSoftWrap) {
  8539. for (var i = 0; i < tokens.length; i++) {
  8540. var token = tokens[i];
  8541. if (token == SPACE)
  8542. indentation += 1;
  8543. else if (token == TAB)
  8544. indentation += tabSize;
  8545. else if (token == TAB_SPACE)
  8546. continue;
  8547. else
  8548. break;
  8549. }
  8550. }
  8551. if (isCode && indentedSoftWrap !== false)
  8552. indentation += tabSize;
  8553. return Math.min(indentation, maxIndent);
  8554. }
  8555. function addSplit(screenPos) {
  8556. var displayed = tokens.slice(lastSplit, screenPos);
  8557. var len = displayed.length;
  8558. displayed.join("")
  8559. .replace(/12/g, function() {
  8560. len -= 1;
  8561. })
  8562. .replace(/2/g, function() {
  8563. len -= 1;
  8564. });
  8565. if (!splits.length) {
  8566. indent = getWrapIndent();
  8567. splits.indent = indent;
  8568. }
  8569. lastDocSplit += len;
  8570. splits.push(lastDocSplit);
  8571. lastSplit = screenPos;
  8572. }
  8573. var indent = 0;
  8574. while (displayLength - lastSplit > wrapLimit - indent) {
  8575. var split = lastSplit + wrapLimit - indent;
  8576. if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
  8577. addSplit(split);
  8578. continue;
  8579. }
  8580. if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
  8581. for (split; split != lastSplit - 1; split--) {
  8582. if (tokens[split] == PLACEHOLDER_START) {
  8583. break;
  8584. }
  8585. }
  8586. if (split > lastSplit) {
  8587. addSplit(split);
  8588. continue;
  8589. }
  8590. split = lastSplit + wrapLimit;
  8591. for (split; split < tokens.length; split++) {
  8592. if (tokens[split] != PLACEHOLDER_BODY) {
  8593. break;
  8594. }
  8595. }
  8596. if (split == tokens.length) {
  8597. break; // Breaks the while-loop.
  8598. }
  8599. addSplit(split);
  8600. continue;
  8601. }
  8602. var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
  8603. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8604. split --;
  8605. }
  8606. if (isCode) {
  8607. while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
  8608. split --;
  8609. }
  8610. while (split > minSplit && tokens[split] == PUNCTUATION) {
  8611. split --;
  8612. }
  8613. } else {
  8614. while (split > minSplit && tokens[split] < SPACE) {
  8615. split --;
  8616. }
  8617. }
  8618. if (split > minSplit) {
  8619. addSplit(++split);
  8620. continue;
  8621. }
  8622. split = lastSplit + wrapLimit;
  8623. if (tokens[split] == CHAR_EXT)
  8624. split--;
  8625. addSplit(split - indent);
  8626. }
  8627. return splits;
  8628. };
  8629. this.$getDisplayTokens = function(str, offset) {
  8630. var arr = [];
  8631. var tabSize;
  8632. offset = offset || 0;
  8633. for (var i = 0; i < str.length; i++) {
  8634. var c = str.charCodeAt(i);
  8635. if (c == 9) {
  8636. tabSize = this.getScreenTabSize(arr.length + offset);
  8637. arr.push(TAB);
  8638. for (var n = 1; n < tabSize; n++) {
  8639. arr.push(TAB_SPACE);
  8640. }
  8641. }
  8642. else if (c == 32) {
  8643. arr.push(SPACE);
  8644. } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
  8645. arr.push(PUNCTUATION);
  8646. }
  8647. else if (c >= 0x1100 && isFullWidth(c)) {
  8648. arr.push(CHAR, CHAR_EXT);
  8649. } else {
  8650. arr.push(CHAR);
  8651. }
  8652. }
  8653. return arr;
  8654. };
  8655. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8656. if (maxScreenColumn == 0)
  8657. return [0, 0];
  8658. if (maxScreenColumn == null)
  8659. maxScreenColumn = Infinity;
  8660. screenColumn = screenColumn || 0;
  8661. var c, column;
  8662. for (column = 0; column < str.length; column++) {
  8663. c = str.charCodeAt(column);
  8664. if (c == 9) {
  8665. screenColumn += this.getScreenTabSize(screenColumn);
  8666. }
  8667. else if (c >= 0x1100 && isFullWidth(c)) {
  8668. screenColumn += 2;
  8669. } else {
  8670. screenColumn += 1;
  8671. }
  8672. if (screenColumn > maxScreenColumn) {
  8673. break;
  8674. }
  8675. }
  8676. return [screenColumn, column];
  8677. };
  8678. this.lineWidgets = null;
  8679. this.getRowLength = function(row) {
  8680. if (this.lineWidgets)
  8681. var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  8682. else
  8683. h = 0
  8684. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8685. return 1 + h;
  8686. } else {
  8687. return this.$wrapData[row].length + 1 + h;
  8688. }
  8689. };
  8690. this.getRowLineCount = function(row) {
  8691. if (!this.$useWrapMode || !this.$wrapData[row]) {
  8692. return 1;
  8693. } else {
  8694. return this.$wrapData[row].length + 1;
  8695. }
  8696. };
  8697. this.getRowWrapIndent = function(screenRow) {
  8698. if (this.$useWrapMode) {
  8699. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8700. var splits = this.$wrapData[pos.row];
  8701. return splits.length && splits[0] < pos.column ? splits.indent : 0;
  8702. } else {
  8703. return 0;
  8704. }
  8705. }
  8706. this.getScreenLastRowColumn = function(screenRow) {
  8707. var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
  8708. return this.documentToScreenColumn(pos.row, pos.column);
  8709. };
  8710. this.getDocumentLastRowColumn = function(docRow, docColumn) {
  8711. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8712. return this.getScreenLastRowColumn(screenRow);
  8713. };
  8714. this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
  8715. var screenRow = this.documentToScreenRow(docRow, docColumn);
  8716. return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
  8717. };
  8718. this.getRowSplitData = function(row) {
  8719. if (!this.$useWrapMode) {
  8720. return undefined;
  8721. } else {
  8722. return this.$wrapData[row];
  8723. }
  8724. };
  8725. this.getScreenTabSize = function(screenColumn) {
  8726. return this.$tabSize - screenColumn % this.$tabSize;
  8727. };
  8728. this.screenToDocumentRow = function(screenRow, screenColumn) {
  8729. return this.screenToDocumentPosition(screenRow, screenColumn).row;
  8730. };
  8731. this.screenToDocumentColumn = function(screenRow, screenColumn) {
  8732. return this.screenToDocumentPosition(screenRow, screenColumn).column;
  8733. };
  8734. this.screenToDocumentPosition = function(screenRow, screenColumn) {
  8735. if (screenRow < 0)
  8736. return {row: 0, column: 0};
  8737. var line;
  8738. var docRow = 0;
  8739. var docColumn = 0;
  8740. var column;
  8741. var row = 0;
  8742. var rowLength = 0;
  8743. var rowCache = this.$screenRowCache;
  8744. var i = this.$getRowCacheIndex(rowCache, screenRow);
  8745. var l = rowCache.length;
  8746. if (l && i >= 0) {
  8747. var row = rowCache[i];
  8748. var docRow = this.$docRowCache[i];
  8749. var doCache = screenRow > rowCache[l - 1];
  8750. } else {
  8751. var doCache = !l;
  8752. }
  8753. var maxRow = this.getLength() - 1;
  8754. var foldLine = this.getNextFoldLine(docRow);
  8755. var foldStart = foldLine ? foldLine.start.row : Infinity;
  8756. while (row <= screenRow) {
  8757. rowLength = this.getRowLength(docRow);
  8758. if (row + rowLength > screenRow || docRow >= maxRow) {
  8759. break;
  8760. } else {
  8761. row += rowLength;
  8762. docRow++;
  8763. if (docRow > foldStart) {
  8764. docRow = foldLine.end.row+1;
  8765. foldLine = this.getNextFoldLine(docRow, foldLine);
  8766. foldStart = foldLine ? foldLine.start.row : Infinity;
  8767. }
  8768. }
  8769. if (doCache) {
  8770. this.$docRowCache.push(docRow);
  8771. this.$screenRowCache.push(row);
  8772. }
  8773. }
  8774. if (foldLine && foldLine.start.row <= docRow) {
  8775. line = this.getFoldDisplayLine(foldLine);
  8776. docRow = foldLine.start.row;
  8777. } else if (row + rowLength <= screenRow || docRow > maxRow) {
  8778. return {
  8779. row: maxRow,
  8780. column: this.getLine(maxRow).length
  8781. };
  8782. } else {
  8783. line = this.getLine(docRow);
  8784. foldLine = null;
  8785. }
  8786. var wrapIndent = 0;
  8787. if (this.$useWrapMode) {
  8788. var splits = this.$wrapData[docRow];
  8789. if (splits) {
  8790. var splitIndex = Math.floor(screenRow - row);
  8791. column = splits[splitIndex];
  8792. if(splitIndex > 0 && splits.length) {
  8793. wrapIndent = splits.indent;
  8794. docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
  8795. line = line.substring(docColumn);
  8796. }
  8797. }
  8798. }
  8799. docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
  8800. if (this.$useWrapMode && docColumn >= column)
  8801. docColumn = column - 1;
  8802. if (foldLine)
  8803. return foldLine.idxToPosition(docColumn);
  8804. return {row: docRow, column: docColumn};
  8805. };
  8806. this.documentToScreenPosition = function(docRow, docColumn) {
  8807. if (typeof docColumn === "undefined")
  8808. var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
  8809. else
  8810. pos = this.$clipPositionToDocument(docRow, docColumn);
  8811. docRow = pos.row;
  8812. docColumn = pos.column;
  8813. var screenRow = 0;
  8814. var foldStartRow = null;
  8815. var fold = null;
  8816. fold = this.getFoldAt(docRow, docColumn, 1);
  8817. if (fold) {
  8818. docRow = fold.start.row;
  8819. docColumn = fold.start.column;
  8820. }
  8821. var rowEnd, row = 0;
  8822. var rowCache = this.$docRowCache;
  8823. var i = this.$getRowCacheIndex(rowCache, docRow);
  8824. var l = rowCache.length;
  8825. if (l && i >= 0) {
  8826. var row = rowCache[i];
  8827. var screenRow = this.$screenRowCache[i];
  8828. var doCache = docRow > rowCache[l - 1];
  8829. } else {
  8830. var doCache = !l;
  8831. }
  8832. var foldLine = this.getNextFoldLine(row);
  8833. var foldStart = foldLine ?foldLine.start.row :Infinity;
  8834. while (row < docRow) {
  8835. if (row >= foldStart) {
  8836. rowEnd = foldLine.end.row + 1;
  8837. if (rowEnd > docRow)
  8838. break;
  8839. foldLine = this.getNextFoldLine(rowEnd, foldLine);
  8840. foldStart = foldLine ?foldLine.start.row :Infinity;
  8841. }
  8842. else {
  8843. rowEnd = row + 1;
  8844. }
  8845. screenRow += this.getRowLength(row);
  8846. row = rowEnd;
  8847. if (doCache) {
  8848. this.$docRowCache.push(row);
  8849. this.$screenRowCache.push(screenRow);
  8850. }
  8851. }
  8852. var textLine = "";
  8853. if (foldLine && row >= foldStart) {
  8854. textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
  8855. foldStartRow = foldLine.start.row;
  8856. } else {
  8857. textLine = this.getLine(docRow).substring(0, docColumn);
  8858. foldStartRow = docRow;
  8859. }
  8860. var wrapIndent = 0;
  8861. if (this.$useWrapMode) {
  8862. var wrapRow = this.$wrapData[foldStartRow];
  8863. if (wrapRow) {
  8864. var screenRowOffset = 0;
  8865. while (textLine.length >= wrapRow[screenRowOffset]) {
  8866. screenRow ++;
  8867. screenRowOffset++;
  8868. }
  8869. textLine = textLine.substring(
  8870. wrapRow[screenRowOffset - 1] || 0, textLine.length
  8871. );
  8872. wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
  8873. }
  8874. }
  8875. return {
  8876. row: screenRow,
  8877. column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
  8878. };
  8879. };
  8880. this.documentToScreenColumn = function(row, docColumn) {
  8881. return this.documentToScreenPosition(row, docColumn).column;
  8882. };
  8883. this.documentToScreenRow = function(docRow, docColumn) {
  8884. return this.documentToScreenPosition(docRow, docColumn).row;
  8885. };
  8886. this.getScreenLength = function() {
  8887. var screenRows = 0;
  8888. var fold = null;
  8889. if (!this.$useWrapMode) {
  8890. screenRows = this.getLength();
  8891. var foldData = this.$foldData;
  8892. for (var i = 0; i < foldData.length; i++) {
  8893. fold = foldData[i];
  8894. screenRows -= fold.end.row - fold.start.row;
  8895. }
  8896. } else {
  8897. var lastRow = this.$wrapData.length;
  8898. var row = 0, i = 0;
  8899. var fold = this.$foldData[i++];
  8900. var foldStart = fold ? fold.start.row :Infinity;
  8901. while (row < lastRow) {
  8902. var splits = this.$wrapData[row];
  8903. screenRows += splits ? splits.length + 1 : 1;
  8904. row ++;
  8905. if (row > foldStart) {
  8906. row = fold.end.row+1;
  8907. fold = this.$foldData[i++];
  8908. foldStart = fold ?fold.start.row :Infinity;
  8909. }
  8910. }
  8911. }
  8912. if (this.lineWidgets)
  8913. screenRows += this.$getWidgetScreenLength();
  8914. return screenRows;
  8915. };
  8916. this.$setFontMetrics = function(fm) {
  8917. if (!this.$enableVarChar) return;
  8918. this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
  8919. if (maxScreenColumn === 0)
  8920. return [0, 0];
  8921. if (!maxScreenColumn)
  8922. maxScreenColumn = Infinity;
  8923. screenColumn = screenColumn || 0;
  8924. var c, column;
  8925. for (column = 0; column < str.length; column++) {
  8926. c = str.charAt(column);
  8927. if (c === "\t") {
  8928. screenColumn += this.getScreenTabSize(screenColumn);
  8929. } else {
  8930. screenColumn += fm.getCharacterWidth(c);
  8931. }
  8932. if (screenColumn > maxScreenColumn) {
  8933. break;
  8934. }
  8935. }
  8936. return [screenColumn, column];
  8937. };
  8938. };
  8939. this.destroy = function() {
  8940. if (this.bgTokenizer) {
  8941. this.bgTokenizer.setDocument(null);
  8942. this.bgTokenizer = null;
  8943. }
  8944. this.$stopWorker();
  8945. };
  8946. function isFullWidth(c) {
  8947. if (c < 0x1100)
  8948. return false;
  8949. return c >= 0x1100 && c <= 0x115F ||
  8950. c >= 0x11A3 && c <= 0x11A7 ||
  8951. c >= 0x11FA && c <= 0x11FF ||
  8952. c >= 0x2329 && c <= 0x232A ||
  8953. c >= 0x2E80 && c <= 0x2E99 ||
  8954. c >= 0x2E9B && c <= 0x2EF3 ||
  8955. c >= 0x2F00 && c <= 0x2FD5 ||
  8956. c >= 0x2FF0 && c <= 0x2FFB ||
  8957. c >= 0x3000 && c <= 0x303E ||
  8958. c >= 0x3041 && c <= 0x3096 ||
  8959. c >= 0x3099 && c <= 0x30FF ||
  8960. c >= 0x3105 && c <= 0x312D ||
  8961. c >= 0x3131 && c <= 0x318E ||
  8962. c >= 0x3190 && c <= 0x31BA ||
  8963. c >= 0x31C0 && c <= 0x31E3 ||
  8964. c >= 0x31F0 && c <= 0x321E ||
  8965. c >= 0x3220 && c <= 0x3247 ||
  8966. c >= 0x3250 && c <= 0x32FE ||
  8967. c >= 0x3300 && c <= 0x4DBF ||
  8968. c >= 0x4E00 && c <= 0xA48C ||
  8969. c >= 0xA490 && c <= 0xA4C6 ||
  8970. c >= 0xA960 && c <= 0xA97C ||
  8971. c >= 0xAC00 && c <= 0xD7A3 ||
  8972. c >= 0xD7B0 && c <= 0xD7C6 ||
  8973. c >= 0xD7CB && c <= 0xD7FB ||
  8974. c >= 0xF900 && c <= 0xFAFF ||
  8975. c >= 0xFE10 && c <= 0xFE19 ||
  8976. c >= 0xFE30 && c <= 0xFE52 ||
  8977. c >= 0xFE54 && c <= 0xFE66 ||
  8978. c >= 0xFE68 && c <= 0xFE6B ||
  8979. c >= 0xFF01 && c <= 0xFF60 ||
  8980. c >= 0xFFE0 && c <= 0xFFE6;
  8981. }
  8982. }).call(EditSession.prototype);
  8983. require("./edit_session/folding").Folding.call(EditSession.prototype);
  8984. require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
  8985. config.defineOptions(EditSession.prototype, "session", {
  8986. wrap: {
  8987. set: function(value) {
  8988. if (!value || value == "off")
  8989. value = false;
  8990. else if (value == "free")
  8991. value = true;
  8992. else if (value == "printMargin")
  8993. value = -1;
  8994. else if (typeof value == "string")
  8995. value = parseInt(value, 10) || false;
  8996. if (this.$wrap == value)
  8997. return;
  8998. this.$wrap = value;
  8999. if (!value) {
  9000. this.setUseWrapMode(false);
  9001. } else {
  9002. var col = typeof value == "number" ? value : null;
  9003. this.setWrapLimitRange(col, col);
  9004. this.setUseWrapMode(true);
  9005. }
  9006. },
  9007. get: function() {
  9008. if (this.getUseWrapMode()) {
  9009. if (this.$wrap == -1)
  9010. return "printMargin";
  9011. if (!this.getWrapLimitRange().min)
  9012. return "free";
  9013. return this.$wrap;
  9014. }
  9015. return "off";
  9016. },
  9017. handlesSet: true
  9018. },
  9019. wrapMethod: {
  9020. set: function(val) {
  9021. val = val == "auto"
  9022. ? this.$mode.type != "text"
  9023. : val != "text";
  9024. if (val != this.$wrapAsCode) {
  9025. this.$wrapAsCode = val;
  9026. if (this.$useWrapMode) {
  9027. this.$modified = true;
  9028. this.$resetRowCache(0);
  9029. this.$updateWrapData(0, this.getLength() - 1);
  9030. }
  9031. }
  9032. },
  9033. initialValue: "auto"
  9034. },
  9035. indentedSoftWrap: { initialValue: true },
  9036. firstLineNumber: {
  9037. set: function() {this._signal("changeBreakpoint");},
  9038. initialValue: 1
  9039. },
  9040. useWorker: {
  9041. set: function(useWorker) {
  9042. this.$useWorker = useWorker;
  9043. this.$stopWorker();
  9044. if (useWorker)
  9045. this.$startWorker();
  9046. },
  9047. initialValue: true
  9048. },
  9049. useSoftTabs: {initialValue: true},
  9050. tabSize: {
  9051. set: function(tabSize) {
  9052. if (isNaN(tabSize) || this.$tabSize === tabSize) return;
  9053. this.$modified = true;
  9054. this.$rowLengthCache = [];
  9055. this.$tabSize = tabSize;
  9056. this._signal("changeTabSize");
  9057. },
  9058. initialValue: 4,
  9059. handlesSet: true
  9060. },
  9061. overwrite: {
  9062. set: function(val) {this._signal("changeOverwrite");},
  9063. initialValue: false
  9064. },
  9065. newLineMode: {
  9066. set: function(val) {this.doc.setNewLineMode(val)},
  9067. get: function() {return this.doc.getNewLineMode()},
  9068. handlesSet: true
  9069. },
  9070. mode: {
  9071. set: function(val) { this.setMode(val) },
  9072. get: function() { return this.$modeId }
  9073. }
  9074. });
  9075. exports.EditSession = EditSession;
  9076. });
  9077. ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
  9078. "use strict";
  9079. var lang = require("./lib/lang");
  9080. var oop = require("./lib/oop");
  9081. var Range = require("./range").Range;
  9082. var Search = function() {
  9083. this.$options = {};
  9084. };
  9085. (function() {
  9086. this.set = function(options) {
  9087. oop.mixin(this.$options, options);
  9088. return this;
  9089. };
  9090. this.getOptions = function() {
  9091. return lang.copyObject(this.$options);
  9092. };
  9093. this.setOptions = function(options) {
  9094. this.$options = options;
  9095. };
  9096. this.find = function(session) {
  9097. var options = this.$options;
  9098. var iterator = this.$matchIterator(session, options);
  9099. if (!iterator)
  9100. return false;
  9101. var firstRange = null;
  9102. iterator.forEach(function(range, row, offset) {
  9103. if (!range.start) {
  9104. var column = range.offset + (offset || 0);
  9105. firstRange = new Range(row, column, row, column + range.length);
  9106. if (!range.length && options.start && options.start.start
  9107. && options.skipCurrent != false && firstRange.isEqual(options.start)
  9108. ) {
  9109. firstRange = null;
  9110. return false;
  9111. }
  9112. } else
  9113. firstRange = range;
  9114. return true;
  9115. });
  9116. return firstRange;
  9117. };
  9118. this.findAll = function(session) {
  9119. var options = this.$options;
  9120. if (!options.needle)
  9121. return [];
  9122. this.$assembleRegExp(options);
  9123. var range = options.range;
  9124. var lines = range
  9125. ? session.getLines(range.start.row, range.end.row)
  9126. : session.doc.getAllLines();
  9127. var ranges = [];
  9128. var re = options.re;
  9129. if (options.$isMultiLine) {
  9130. var len = re.length;
  9131. var maxRow = lines.length - len;
  9132. var prevRange;
  9133. outer: for (var row = re.offset || 0; row <= maxRow; row++) {
  9134. for (var j = 0; j < len; j++)
  9135. if (lines[row + j].search(re[j]) == -1)
  9136. continue outer;
  9137. var startLine = lines[row];
  9138. var line = lines[row + len - 1];
  9139. var startIndex = startLine.length - startLine.match(re[0])[0].length;
  9140. var endIndex = line.match(re[len - 1])[0].length;
  9141. if (prevRange && prevRange.end.row === row &&
  9142. prevRange.end.column > startIndex
  9143. ) {
  9144. continue;
  9145. }
  9146. ranges.push(prevRange = new Range(
  9147. row, startIndex, row + len - 1, endIndex
  9148. ));
  9149. if (len > 2)
  9150. row = row + len - 2;
  9151. }
  9152. } else {
  9153. for (var i = 0; i < lines.length; i++) {
  9154. var matches = lang.getMatchOffsets(lines[i], re);
  9155. for (var j = 0; j < matches.length; j++) {
  9156. var match = matches[j];
  9157. ranges.push(new Range(i, match.offset, i, match.offset + match.length));
  9158. }
  9159. }
  9160. }
  9161. if (range) {
  9162. var startColumn = range.start.column;
  9163. var endColumn = range.start.column;
  9164. var i = 0, j = ranges.length - 1;
  9165. while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
  9166. i++;
  9167. while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
  9168. j--;
  9169. ranges = ranges.slice(i, j + 1);
  9170. for (i = 0, j = ranges.length; i < j; i++) {
  9171. ranges[i].start.row += range.start.row;
  9172. ranges[i].end.row += range.start.row;
  9173. }
  9174. }
  9175. return ranges;
  9176. };
  9177. this.replace = function(input, replacement) {
  9178. var options = this.$options;
  9179. var re = this.$assembleRegExp(options);
  9180. if (options.$isMultiLine)
  9181. return replacement;
  9182. if (!re)
  9183. return;
  9184. var match = re.exec(input);
  9185. if (!match || match[0].length != input.length)
  9186. return null;
  9187. replacement = input.replace(re, replacement);
  9188. if (options.preserveCase) {
  9189. replacement = replacement.split("");
  9190. for (var i = Math.min(input.length, input.length); i--; ) {
  9191. var ch = input[i];
  9192. if (ch && ch.toLowerCase() != ch)
  9193. replacement[i] = replacement[i].toUpperCase();
  9194. else
  9195. replacement[i] = replacement[i].toLowerCase();
  9196. }
  9197. replacement = replacement.join("");
  9198. }
  9199. return replacement;
  9200. };
  9201. this.$matchIterator = function(session, options) {
  9202. var re = this.$assembleRegExp(options);
  9203. if (!re)
  9204. return false;
  9205. var callback;
  9206. if (options.$isMultiLine) {
  9207. var len = re.length;
  9208. var matchIterator = function(line, row, offset) {
  9209. var startIndex = line.search(re[0]);
  9210. if (startIndex == -1)
  9211. return;
  9212. for (var i = 1; i < len; i++) {
  9213. line = session.getLine(row + i);
  9214. if (line.search(re[i]) == -1)
  9215. return;
  9216. }
  9217. var endIndex = line.match(re[len - 1])[0].length;
  9218. var range = new Range(row, startIndex, row + len - 1, endIndex);
  9219. if (re.offset == 1) {
  9220. range.start.row--;
  9221. range.start.column = Number.MAX_VALUE;
  9222. } else if (offset)
  9223. range.start.column += offset;
  9224. if (callback(range))
  9225. return true;
  9226. };
  9227. } else if (options.backwards) {
  9228. var matchIterator = function(line, row, startIndex) {
  9229. var matches = lang.getMatchOffsets(line, re);
  9230. for (var i = matches.length-1; i >= 0; i--)
  9231. if (callback(matches[i], row, startIndex))
  9232. return true;
  9233. };
  9234. } else {
  9235. var matchIterator = function(line, row, startIndex) {
  9236. var matches = lang.getMatchOffsets(line, re);
  9237. for (var i = 0; i < matches.length; i++)
  9238. if (callback(matches[i], row, startIndex))
  9239. return true;
  9240. };
  9241. }
  9242. var lineIterator = this.$lineIterator(session, options);
  9243. return {
  9244. forEach: function(_callback) {
  9245. callback = _callback;
  9246. lineIterator.forEach(matchIterator);
  9247. }
  9248. };
  9249. };
  9250. this.$assembleRegExp = function(options, $disableFakeMultiline) {
  9251. if (options.needle instanceof RegExp)
  9252. return options.re = options.needle;
  9253. var needle = options.needle;
  9254. if (!options.needle)
  9255. return options.re = false;
  9256. if (!options.regExp)
  9257. needle = lang.escapeRegExp(needle);
  9258. if (options.wholeWord)
  9259. needle = addWordBoundary(needle, options);
  9260. var modifier = options.caseSensitive ? "gm" : "gmi";
  9261. options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
  9262. if (options.$isMultiLine)
  9263. return options.re = this.$assembleMultilineRegExp(needle, modifier);
  9264. try {
  9265. var re = new RegExp(needle, modifier);
  9266. } catch(e) {
  9267. re = false;
  9268. }
  9269. return options.re = re;
  9270. };
  9271. this.$assembleMultilineRegExp = function(needle, modifier) {
  9272. var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
  9273. var re = [];
  9274. for (var i = 0; i < parts.length; i++) try {
  9275. re.push(new RegExp(parts[i], modifier));
  9276. } catch(e) {
  9277. return false;
  9278. }
  9279. if (parts[0] == "") {
  9280. re.shift();
  9281. re.offset = 1;
  9282. } else {
  9283. re.offset = 0;
  9284. }
  9285. return re;
  9286. };
  9287. this.$lineIterator = function(session, options) {
  9288. var backwards = options.backwards == true;
  9289. var skipCurrent = options.skipCurrent != false;
  9290. var range = options.range;
  9291. var start = options.start;
  9292. if (!start)
  9293. start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
  9294. if (start.start)
  9295. start = start[skipCurrent != backwards ? "end" : "start"];
  9296. var firstRow = range ? range.start.row : 0;
  9297. var lastRow = range ? range.end.row : session.getLength() - 1;
  9298. var forEach = backwards ? function(callback) {
  9299. var row = start.row;
  9300. var line = session.getLine(row).substring(0, start.column);
  9301. if (callback(line, row))
  9302. return;
  9303. for (row--; row >= firstRow; row--)
  9304. if (callback(session.getLine(row), row))
  9305. return;
  9306. if (options.wrap == false)
  9307. return;
  9308. for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
  9309. if (callback(session.getLine(row), row))
  9310. return;
  9311. } : function(callback) {
  9312. var row = start.row;
  9313. var line = session.getLine(row).substr(start.column);
  9314. if (callback(line, row, start.column))
  9315. return;
  9316. for (row = row+1; row <= lastRow; row++)
  9317. if (callback(session.getLine(row), row))
  9318. return;
  9319. if (options.wrap == false)
  9320. return;
  9321. for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
  9322. if (callback(session.getLine(row), row))
  9323. return;
  9324. };
  9325. return {forEach: forEach};
  9326. };
  9327. }).call(Search.prototype);
  9328. function addWordBoundary(needle, options) {
  9329. function wordBoundary(c) {
  9330. if (/\w/.test(c) || options.regExp) return "\\b";
  9331. return "";
  9332. }
  9333. return wordBoundary(needle[0]) + needle
  9334. + wordBoundary(needle[needle.length - 1]);
  9335. }
  9336. exports.Search = Search;
  9337. });
  9338. ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
  9339. "use strict";
  9340. var keyUtil = require("../lib/keys");
  9341. var useragent = require("../lib/useragent");
  9342. var KEY_MODS = keyUtil.KEY_MODS;
  9343. function HashHandler(config, platform) {
  9344. this.platform = platform || (useragent.isMac ? "mac" : "win");
  9345. this.commands = {};
  9346. this.commandKeyBinding = {};
  9347. this.addCommands(config);
  9348. this.$singleCommand = true;
  9349. }
  9350. function MultiHashHandler(config, platform) {
  9351. HashHandler.call(this, config, platform);
  9352. this.$singleCommand = false;
  9353. }
  9354. MultiHashHandler.prototype = HashHandler.prototype;
  9355. (function() {
  9356. this.addCommand = function(command) {
  9357. if (this.commands[command.name])
  9358. this.removeCommand(command);
  9359. this.commands[command.name] = command;
  9360. if (command.bindKey)
  9361. this._buildKeyHash(command);
  9362. };
  9363. this.removeCommand = function(command, keepCommand) {
  9364. var name = command && (typeof command === 'string' ? command : command.name);
  9365. command = this.commands[name];
  9366. if (!keepCommand)
  9367. delete this.commands[name];
  9368. var ckb = this.commandKeyBinding;
  9369. for (var keyId in ckb) {
  9370. var cmdGroup = ckb[keyId];
  9371. if (cmdGroup == command) {
  9372. delete ckb[keyId];
  9373. } else if (Array.isArray(cmdGroup)) {
  9374. var i = cmdGroup.indexOf(command);
  9375. if (i != -1) {
  9376. cmdGroup.splice(i, 1);
  9377. if (cmdGroup.length == 1)
  9378. ckb[keyId] = cmdGroup[0];
  9379. }
  9380. }
  9381. }
  9382. };
  9383. this.bindKey = function(key, command, position) {
  9384. if (typeof key == "object" && key) {
  9385. if (position == undefined)
  9386. position = key.position;
  9387. key = key[this.platform];
  9388. }
  9389. if (!key)
  9390. return;
  9391. if (typeof command == "function")
  9392. return this.addCommand({exec: command, bindKey: key, name: command.name || key});
  9393. key.split("|").forEach(function(keyPart) {
  9394. var chain = "";
  9395. if (keyPart.indexOf(" ") != -1) {
  9396. var parts = keyPart.split(/\s+/);
  9397. keyPart = parts.pop();
  9398. parts.forEach(function(keyPart) {
  9399. var binding = this.parseKeys(keyPart);
  9400. var id = KEY_MODS[binding.hashId] + binding.key;
  9401. chain += (chain ? " " : "") + id;
  9402. this._addCommandToBinding(chain, "chainKeys");
  9403. }, this);
  9404. chain += " ";
  9405. }
  9406. var binding = this.parseKeys(keyPart);
  9407. var id = KEY_MODS[binding.hashId] + binding.key;
  9408. this._addCommandToBinding(chain + id, command, position);
  9409. }, this);
  9410. };
  9411. function getPosition(command) {
  9412. return typeof command == "object" && command.bindKey
  9413. && command.bindKey.position || 0;
  9414. }
  9415. this._addCommandToBinding = function(keyId, command, position) {
  9416. var ckb = this.commandKeyBinding, i;
  9417. if (!command) {
  9418. delete ckb[keyId];
  9419. } else if (!ckb[keyId] || this.$singleCommand) {
  9420. ckb[keyId] = command;
  9421. } else {
  9422. if (!Array.isArray(ckb[keyId])) {
  9423. ckb[keyId] = [ckb[keyId]];
  9424. } else if ((i = ckb[keyId].indexOf(command)) != -1) {
  9425. ckb[keyId].splice(i, 1);
  9426. }
  9427. if (typeof position != "number") {
  9428. if (position || command.isDefault)
  9429. position = -100;
  9430. else
  9431. position = getPosition(command);
  9432. }
  9433. var commands = ckb[keyId];
  9434. for (i = 0; i < commands.length; i++) {
  9435. var other = commands[i];
  9436. var otherPos = getPosition(other);
  9437. if (otherPos > position)
  9438. break;
  9439. }
  9440. commands.splice(i, 0, command);
  9441. }
  9442. };
  9443. this.addCommands = function(commands) {
  9444. commands && Object.keys(commands).forEach(function(name) {
  9445. var command = commands[name];
  9446. if (!command)
  9447. return;
  9448. if (typeof command === "string")
  9449. return this.bindKey(command, name);
  9450. if (typeof command === "function")
  9451. command = { exec: command };
  9452. if (typeof command !== "object")
  9453. return;
  9454. if (!command.name)
  9455. command.name = name;
  9456. this.addCommand(command);
  9457. }, this);
  9458. };
  9459. this.removeCommands = function(commands) {
  9460. Object.keys(commands).forEach(function(name) {
  9461. this.removeCommand(commands[name]);
  9462. }, this);
  9463. };
  9464. this.bindKeys = function(keyList) {
  9465. Object.keys(keyList).forEach(function(key) {
  9466. this.bindKey(key, keyList[key]);
  9467. }, this);
  9468. };
  9469. this._buildKeyHash = function(command) {
  9470. this.bindKey(command.bindKey, command);
  9471. };
  9472. this.parseKeys = function(keys) {
  9473. var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
  9474. var key = parts.pop();
  9475. var keyCode = keyUtil[key];
  9476. if (keyUtil.FUNCTION_KEYS[keyCode])
  9477. key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
  9478. else if (!parts.length)
  9479. return {key: key, hashId: -1};
  9480. else if (parts.length == 1 && parts[0] == "shift")
  9481. return {key: key.toUpperCase(), hashId: -1};
  9482. var hashId = 0;
  9483. for (var i = parts.length; i--;) {
  9484. var modifier = keyUtil.KEY_MODS[parts[i]];
  9485. if (modifier == null) {
  9486. if (typeof console != "undefined")
  9487. console.error("invalid modifier " + parts[i] + " in " + keys);
  9488. return false;
  9489. }
  9490. hashId |= modifier;
  9491. }
  9492. return {key: key, hashId: hashId};
  9493. };
  9494. this.findKeyCommand = function findKeyCommand(hashId, keyString) {
  9495. var key = KEY_MODS[hashId] + keyString;
  9496. return this.commandKeyBinding[key];
  9497. };
  9498. this.handleKeyboard = function(data, hashId, keyString, keyCode) {
  9499. if (keyCode < 0) return;
  9500. var key = KEY_MODS[hashId] + keyString;
  9501. var command = this.commandKeyBinding[key];
  9502. if (data.$keyChain) {
  9503. data.$keyChain += " " + key;
  9504. command = this.commandKeyBinding[data.$keyChain] || command;
  9505. }
  9506. if (command) {
  9507. if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
  9508. data.$keyChain = data.$keyChain || key;
  9509. return {command: "null"};
  9510. }
  9511. }
  9512. if (data.$keyChain) {
  9513. if ((!hashId || hashId == 4) && keyString.length == 1)
  9514. data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
  9515. else if (hashId == -1 || keyCode > 0)
  9516. data.$keyChain = ""; // reset keyChain
  9517. }
  9518. return {command: command};
  9519. };
  9520. this.getStatusText = function(editor, data) {
  9521. return data.$keyChain || "";
  9522. };
  9523. }).call(HashHandler.prototype);
  9524. exports.HashHandler = HashHandler;
  9525. exports.MultiHashHandler = MultiHashHandler;
  9526. });
  9527. ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
  9528. "use strict";
  9529. var oop = require("../lib/oop");
  9530. var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
  9531. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  9532. var CommandManager = function(platform, commands) {
  9533. MultiHashHandler.call(this, commands, platform);
  9534. this.byName = this.commands;
  9535. this.setDefaultHandler("exec", function(e) {
  9536. return e.command.exec(e.editor, e.args || {});
  9537. });
  9538. };
  9539. oop.inherits(CommandManager, MultiHashHandler);
  9540. (function() {
  9541. oop.implement(this, EventEmitter);
  9542. this.exec = function(command, editor, args) {
  9543. if (Array.isArray(command)) {
  9544. for (var i = command.length; i--; ) {
  9545. if (this.exec(command[i], editor, args)) return true;
  9546. }
  9547. return false;
  9548. }
  9549. if (typeof command === "string")
  9550. command = this.commands[command];
  9551. if (!command)
  9552. return false;
  9553. if (editor && editor.$readOnly && !command.readOnly)
  9554. return false;
  9555. var e = {editor: editor, command: command, args: args};
  9556. e.returnValue = this._emit("exec", e);
  9557. this._signal("afterExec", e);
  9558. return e.returnValue === false ? false : true;
  9559. };
  9560. this.toggleRecording = function(editor) {
  9561. if (this.$inReplay)
  9562. return;
  9563. editor && editor._emit("changeStatus");
  9564. if (this.recording) {
  9565. this.macro.pop();
  9566. this.removeEventListener("exec", this.$addCommandToMacro);
  9567. if (!this.macro.length)
  9568. this.macro = this.oldMacro;
  9569. return this.recording = false;
  9570. }
  9571. if (!this.$addCommandToMacro) {
  9572. this.$addCommandToMacro = function(e) {
  9573. this.macro.push([e.command, e.args]);
  9574. }.bind(this);
  9575. }
  9576. this.oldMacro = this.macro;
  9577. this.macro = [];
  9578. this.on("exec", this.$addCommandToMacro);
  9579. return this.recording = true;
  9580. };
  9581. this.replay = function(editor) {
  9582. if (this.$inReplay || !this.macro)
  9583. return;
  9584. if (this.recording)
  9585. return this.toggleRecording(editor);
  9586. try {
  9587. this.$inReplay = true;
  9588. this.macro.forEach(function(x) {
  9589. if (typeof x == "string")
  9590. this.exec(x, editor);
  9591. else
  9592. this.exec(x[0], editor, x[1]);
  9593. }, this);
  9594. } finally {
  9595. this.$inReplay = false;
  9596. }
  9597. };
  9598. this.trimMacro = function(m) {
  9599. return m.map(function(x){
  9600. if (typeof x[0] != "string")
  9601. x[0] = x[0].name;
  9602. if (!x[1])
  9603. x = x[0];
  9604. return x;
  9605. });
  9606. };
  9607. }).call(CommandManager.prototype);
  9608. exports.CommandManager = CommandManager;
  9609. });
  9610. ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
  9611. "use strict";
  9612. var lang = require("../lib/lang");
  9613. var config = require("../config");
  9614. var Range = require("../range").Range;
  9615. function bindKey(win, mac) {
  9616. return {win: win, mac: mac};
  9617. }
  9618. exports.commands = [{
  9619. name: "showSettingsMenu",
  9620. bindKey: bindKey("Ctrl-,", "Command-,"),
  9621. exec: function(editor) {
  9622. config.loadModule("ace/ext/settings_menu", function(module) {
  9623. module.init(editor);
  9624. editor.showSettingsMenu();
  9625. });
  9626. },
  9627. readOnly: true
  9628. }, {
  9629. name: "goToNextError",
  9630. bindKey: bindKey("Alt-E", "F4"),
  9631. exec: function(editor) {
  9632. config.loadModule("ace/ext/error_marker", function(module) {
  9633. module.showErrorMarker(editor, 1);
  9634. });
  9635. },
  9636. scrollIntoView: "animate",
  9637. readOnly: true
  9638. }, {
  9639. name: "goToPreviousError",
  9640. bindKey: bindKey("Alt-Shift-E", "Shift-F4"),
  9641. exec: function(editor) {
  9642. config.loadModule("ace/ext/error_marker", function(module) {
  9643. module.showErrorMarker(editor, -1);
  9644. });
  9645. },
  9646. scrollIntoView: "animate",
  9647. readOnly: true
  9648. }, {
  9649. name: "selectall",
  9650. bindKey: bindKey("Ctrl-A", "Command-A"),
  9651. exec: function(editor) { editor.selectAll(); },
  9652. readOnly: true
  9653. }, {
  9654. name: "centerselection",
  9655. bindKey: bindKey(null, "Ctrl-L"),
  9656. exec: function(editor) { editor.centerSelection(); },
  9657. readOnly: true
  9658. }, {
  9659. name: "gotoline",
  9660. bindKey: bindKey("Ctrl-L", "Command-L"),
  9661. exec: function(editor) {
  9662. var line = parseInt(prompt("Enter line number:"), 10);
  9663. if (!isNaN(line)) {
  9664. editor.gotoLine(line);
  9665. }
  9666. },
  9667. readOnly: true
  9668. }, {
  9669. name: "fold",
  9670. bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
  9671. exec: function(editor) { editor.session.toggleFold(false); },
  9672. multiSelectAction: "forEach",
  9673. scrollIntoView: "center",
  9674. readOnly: true
  9675. }, {
  9676. name: "unfold",
  9677. bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
  9678. exec: function(editor) { editor.session.toggleFold(true); },
  9679. multiSelectAction: "forEach",
  9680. scrollIntoView: "center",
  9681. readOnly: true
  9682. }, {
  9683. name: "toggleFoldWidget",
  9684. bindKey: bindKey("F2", "F2"),
  9685. exec: function(editor) { editor.session.toggleFoldWidget(); },
  9686. multiSelectAction: "forEach",
  9687. scrollIntoView: "center",
  9688. readOnly: true
  9689. }, {
  9690. name: "toggleParentFoldWidget",
  9691. bindKey: bindKey("Alt-F2", "Alt-F2"),
  9692. exec: function(editor) { editor.session.toggleFoldWidget(true); },
  9693. multiSelectAction: "forEach",
  9694. scrollIntoView: "center",
  9695. readOnly: true
  9696. }, {
  9697. name: "foldall",
  9698. bindKey: bindKey(null, "Ctrl-Command-Option-0"),
  9699. exec: function(editor) { editor.session.foldAll(); },
  9700. scrollIntoView: "center",
  9701. readOnly: true
  9702. }, {
  9703. name: "foldOther",
  9704. bindKey: bindKey("Alt-0", "Command-Option-0"),
  9705. exec: function(editor) {
  9706. editor.session.foldAll();
  9707. editor.session.unfold(editor.selection.getAllRanges());
  9708. },
  9709. scrollIntoView: "center",
  9710. readOnly: true
  9711. }, {
  9712. name: "unfoldall",
  9713. bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
  9714. exec: function(editor) { editor.session.unfold(); },
  9715. scrollIntoView: "center",
  9716. readOnly: true
  9717. }, {
  9718. name: "findnext",
  9719. bindKey: bindKey("Ctrl-K", "Command-G"),
  9720. exec: function(editor) { editor.findNext(); },
  9721. multiSelectAction: "forEach",
  9722. scrollIntoView: "center",
  9723. readOnly: true
  9724. }, {
  9725. name: "findprevious",
  9726. bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
  9727. exec: function(editor) { editor.findPrevious(); },
  9728. multiSelectAction: "forEach",
  9729. scrollIntoView: "center",
  9730. readOnly: true
  9731. }, {
  9732. name: "selectOrFindNext",
  9733. bindKey: bindKey("Alt-K", "Ctrl-G"),
  9734. exec: function(editor) {
  9735. if (editor.selection.isEmpty())
  9736. editor.selection.selectWord();
  9737. else
  9738. editor.findNext();
  9739. },
  9740. readOnly: true
  9741. }, {
  9742. name: "selectOrFindPrevious",
  9743. bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
  9744. exec: function(editor) {
  9745. if (editor.selection.isEmpty())
  9746. editor.selection.selectWord();
  9747. else
  9748. editor.findPrevious();
  9749. },
  9750. readOnly: true
  9751. }, {
  9752. name: "find",
  9753. bindKey: bindKey("Ctrl-F", "Command-F"),
  9754. exec: function(editor) {
  9755. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
  9756. },
  9757. readOnly: true
  9758. }, {
  9759. name: "overwrite",
  9760. bindKey: "Insert",
  9761. exec: function(editor) { editor.toggleOverwrite(); },
  9762. readOnly: true
  9763. }, {
  9764. name: "selecttostart",
  9765. bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Home|Command-Shift-Up"),
  9766. exec: function(editor) { editor.getSelection().selectFileStart(); },
  9767. multiSelectAction: "forEach",
  9768. readOnly: true,
  9769. scrollIntoView: "animate",
  9770. aceCommandGroup: "fileJump"
  9771. }, {
  9772. name: "gotostart",
  9773. bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
  9774. exec: function(editor) { editor.navigateFileStart(); },
  9775. multiSelectAction: "forEach",
  9776. readOnly: true,
  9777. scrollIntoView: "animate",
  9778. aceCommandGroup: "fileJump"
  9779. }, {
  9780. name: "selectup",
  9781. bindKey: bindKey("Shift-Up", "Shift-Up|Ctrl-Shift-P"),
  9782. exec: function(editor) { editor.getSelection().selectUp(); },
  9783. multiSelectAction: "forEach",
  9784. scrollIntoView: "cursor",
  9785. readOnly: true
  9786. }, {
  9787. name: "golineup",
  9788. bindKey: bindKey("Up", "Up|Ctrl-P"),
  9789. exec: function(editor, args) { editor.navigateUp(args.times); },
  9790. multiSelectAction: "forEach",
  9791. scrollIntoView: "cursor",
  9792. readOnly: true
  9793. }, {
  9794. name: "selecttoend",
  9795. bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-End|Command-Shift-Down"),
  9796. exec: function(editor) { editor.getSelection().selectFileEnd(); },
  9797. multiSelectAction: "forEach",
  9798. readOnly: true,
  9799. scrollIntoView: "animate",
  9800. aceCommandGroup: "fileJump"
  9801. }, {
  9802. name: "gotoend",
  9803. bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
  9804. exec: function(editor) { editor.navigateFileEnd(); },
  9805. multiSelectAction: "forEach",
  9806. readOnly: true,
  9807. scrollIntoView: "animate",
  9808. aceCommandGroup: "fileJump"
  9809. }, {
  9810. name: "selectdown",
  9811. bindKey: bindKey("Shift-Down", "Shift-Down|Ctrl-Shift-N"),
  9812. exec: function(editor) { editor.getSelection().selectDown(); },
  9813. multiSelectAction: "forEach",
  9814. scrollIntoView: "cursor",
  9815. readOnly: true
  9816. }, {
  9817. name: "golinedown",
  9818. bindKey: bindKey("Down", "Down|Ctrl-N"),
  9819. exec: function(editor, args) { editor.navigateDown(args.times); },
  9820. multiSelectAction: "forEach",
  9821. scrollIntoView: "cursor",
  9822. readOnly: true
  9823. }, {
  9824. name: "selectwordleft",
  9825. bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
  9826. exec: function(editor) { editor.getSelection().selectWordLeft(); },
  9827. multiSelectAction: "forEach",
  9828. scrollIntoView: "cursor",
  9829. readOnly: true
  9830. }, {
  9831. name: "gotowordleft",
  9832. bindKey: bindKey("Ctrl-Left", "Option-Left"),
  9833. exec: function(editor) { editor.navigateWordLeft(); },
  9834. multiSelectAction: "forEach",
  9835. scrollIntoView: "cursor",
  9836. readOnly: true
  9837. }, {
  9838. name: "selecttolinestart",
  9839. bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left|Ctrl-Shift-A"),
  9840. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9841. multiSelectAction: "forEach",
  9842. scrollIntoView: "cursor",
  9843. readOnly: true
  9844. }, {
  9845. name: "gotolinestart",
  9846. bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
  9847. exec: function(editor) { editor.navigateLineStart(); },
  9848. multiSelectAction: "forEach",
  9849. scrollIntoView: "cursor",
  9850. readOnly: true
  9851. }, {
  9852. name: "selectleft",
  9853. bindKey: bindKey("Shift-Left", "Shift-Left|Ctrl-Shift-B"),
  9854. exec: function(editor) { editor.getSelection().selectLeft(); },
  9855. multiSelectAction: "forEach",
  9856. scrollIntoView: "cursor",
  9857. readOnly: true
  9858. }, {
  9859. name: "gotoleft",
  9860. bindKey: bindKey("Left", "Left|Ctrl-B"),
  9861. exec: function(editor, args) { editor.navigateLeft(args.times); },
  9862. multiSelectAction: "forEach",
  9863. scrollIntoView: "cursor",
  9864. readOnly: true
  9865. }, {
  9866. name: "selectwordright",
  9867. bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
  9868. exec: function(editor) { editor.getSelection().selectWordRight(); },
  9869. multiSelectAction: "forEach",
  9870. scrollIntoView: "cursor",
  9871. readOnly: true
  9872. }, {
  9873. name: "gotowordright",
  9874. bindKey: bindKey("Ctrl-Right", "Option-Right"),
  9875. exec: function(editor) { editor.navigateWordRight(); },
  9876. multiSelectAction: "forEach",
  9877. scrollIntoView: "cursor",
  9878. readOnly: true
  9879. }, {
  9880. name: "selecttolineend",
  9881. bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right|Shift-End|Ctrl-Shift-E"),
  9882. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9883. multiSelectAction: "forEach",
  9884. scrollIntoView: "cursor",
  9885. readOnly: true
  9886. }, {
  9887. name: "gotolineend",
  9888. bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
  9889. exec: function(editor) { editor.navigateLineEnd(); },
  9890. multiSelectAction: "forEach",
  9891. scrollIntoView: "cursor",
  9892. readOnly: true
  9893. }, {
  9894. name: "selectright",
  9895. bindKey: bindKey("Shift-Right", "Shift-Right"),
  9896. exec: function(editor) { editor.getSelection().selectRight(); },
  9897. multiSelectAction: "forEach",
  9898. scrollIntoView: "cursor",
  9899. readOnly: true
  9900. }, {
  9901. name: "gotoright",
  9902. bindKey: bindKey("Right", "Right|Ctrl-F"),
  9903. exec: function(editor, args) { editor.navigateRight(args.times); },
  9904. multiSelectAction: "forEach",
  9905. scrollIntoView: "cursor",
  9906. readOnly: true
  9907. }, {
  9908. name: "selectpagedown",
  9909. bindKey: "Shift-PageDown",
  9910. exec: function(editor) { editor.selectPageDown(); },
  9911. readOnly: true
  9912. }, {
  9913. name: "pagedown",
  9914. bindKey: bindKey(null, "Option-PageDown"),
  9915. exec: function(editor) { editor.scrollPageDown(); },
  9916. readOnly: true
  9917. }, {
  9918. name: "gotopagedown",
  9919. bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
  9920. exec: function(editor) { editor.gotoPageDown(); },
  9921. readOnly: true
  9922. }, {
  9923. name: "selectpageup",
  9924. bindKey: "Shift-PageUp",
  9925. exec: function(editor) { editor.selectPageUp(); },
  9926. readOnly: true
  9927. }, {
  9928. name: "pageup",
  9929. bindKey: bindKey(null, "Option-PageUp"),
  9930. exec: function(editor) { editor.scrollPageUp(); },
  9931. readOnly: true
  9932. }, {
  9933. name: "gotopageup",
  9934. bindKey: "PageUp",
  9935. exec: function(editor) { editor.gotoPageUp(); },
  9936. readOnly: true
  9937. }, {
  9938. name: "scrollup",
  9939. bindKey: bindKey("Ctrl-Up", null),
  9940. exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
  9941. readOnly: true
  9942. }, {
  9943. name: "scrolldown",
  9944. bindKey: bindKey("Ctrl-Down", null),
  9945. exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
  9946. readOnly: true
  9947. }, {
  9948. name: "selectlinestart",
  9949. bindKey: "Shift-Home",
  9950. exec: function(editor) { editor.getSelection().selectLineStart(); },
  9951. multiSelectAction: "forEach",
  9952. scrollIntoView: "cursor",
  9953. readOnly: true
  9954. }, {
  9955. name: "selectlineend",
  9956. bindKey: "Shift-End",
  9957. exec: function(editor) { editor.getSelection().selectLineEnd(); },
  9958. multiSelectAction: "forEach",
  9959. scrollIntoView: "cursor",
  9960. readOnly: true
  9961. }, {
  9962. name: "togglerecording",
  9963. bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
  9964. exec: function(editor) { editor.commands.toggleRecording(editor); },
  9965. readOnly: true
  9966. }, {
  9967. name: "replaymacro",
  9968. bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
  9969. exec: function(editor) { editor.commands.replay(editor); },
  9970. readOnly: true
  9971. }, {
  9972. name: "jumptomatching",
  9973. bindKey: bindKey("Ctrl-P", "Ctrl-P"),
  9974. exec: function(editor) { editor.jumpToMatching(); },
  9975. multiSelectAction: "forEach",
  9976. scrollIntoView: "animate",
  9977. readOnly: true
  9978. }, {
  9979. name: "selecttomatching",
  9980. bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
  9981. exec: function(editor) { editor.jumpToMatching(true); },
  9982. multiSelectAction: "forEach",
  9983. scrollIntoView: "animate",
  9984. readOnly: true
  9985. }, {
  9986. name: "expandToMatching",
  9987. bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
  9988. exec: function(editor) { editor.jumpToMatching(true, true); },
  9989. multiSelectAction: "forEach",
  9990. scrollIntoView: "animate",
  9991. readOnly: true
  9992. }, {
  9993. name: "passKeysToBrowser",
  9994. bindKey: bindKey(null, null),
  9995. exec: function() {},
  9996. passEvent: true,
  9997. readOnly: true
  9998. }, {
  9999. name: "copy",
  10000. exec: function(editor) {
  10001. },
  10002. readOnly: true
  10003. },
  10004. {
  10005. name: "cut",
  10006. exec: function(editor) {
  10007. var range = editor.getSelectionRange();
  10008. editor._emit("cut", range);
  10009. if (!editor.selection.isEmpty()) {
  10010. editor.session.remove(range);
  10011. editor.clearSelection();
  10012. }
  10013. },
  10014. scrollIntoView: "cursor",
  10015. multiSelectAction: "forEach"
  10016. }, {
  10017. name: "paste",
  10018. exec: function(editor, args) {
  10019. editor.$handlePaste(args);
  10020. },
  10021. scrollIntoView: "cursor"
  10022. }, {
  10023. name: "removeline",
  10024. bindKey: bindKey("Ctrl-D", "Command-D"),
  10025. exec: function(editor) { editor.removeLines(); },
  10026. scrollIntoView: "cursor",
  10027. multiSelectAction: "forEachLine"
  10028. }, {
  10029. name: "duplicateSelection",
  10030. bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
  10031. exec: function(editor) { editor.duplicateSelection(); },
  10032. scrollIntoView: "cursor",
  10033. multiSelectAction: "forEach"
  10034. }, {
  10035. name: "sortlines",
  10036. bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
  10037. exec: function(editor) { editor.sortLines(); },
  10038. scrollIntoView: "selection",
  10039. multiSelectAction: "forEachLine"
  10040. }, {
  10041. name: "togglecomment",
  10042. bindKey: bindKey("Ctrl-/", "Command-/"),
  10043. exec: function(editor) { editor.toggleCommentLines(); },
  10044. multiSelectAction: "forEachLine",
  10045. scrollIntoView: "selectionPart"
  10046. }, {
  10047. name: "toggleBlockComment",
  10048. bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
  10049. exec: function(editor) { editor.toggleBlockComment(); },
  10050. multiSelectAction: "forEach",
  10051. scrollIntoView: "selectionPart"
  10052. }, {
  10053. name: "modifyNumberUp",
  10054. bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
  10055. exec: function(editor) { editor.modifyNumber(1); },
  10056. scrollIntoView: "cursor",
  10057. multiSelectAction: "forEach"
  10058. }, {
  10059. name: "modifyNumberDown",
  10060. bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
  10061. exec: function(editor) { editor.modifyNumber(-1); },
  10062. scrollIntoView: "cursor",
  10063. multiSelectAction: "forEach"
  10064. }, {
  10065. name: "replace",
  10066. bindKey: bindKey("Ctrl-H", "Command-Option-F"),
  10067. exec: function(editor) {
  10068. config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
  10069. }
  10070. }, {
  10071. name: "undo",
  10072. bindKey: bindKey("Ctrl-Z", "Command-Z"),
  10073. exec: function(editor) { editor.undo(); }
  10074. }, {
  10075. name: "redo",
  10076. bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
  10077. exec: function(editor) { editor.redo(); }
  10078. }, {
  10079. name: "copylinesup",
  10080. bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
  10081. exec: function(editor) { editor.copyLinesUp(); },
  10082. scrollIntoView: "cursor"
  10083. }, {
  10084. name: "movelinesup",
  10085. bindKey: bindKey("Alt-Up", "Option-Up"),
  10086. exec: function(editor) { editor.moveLinesUp(); },
  10087. scrollIntoView: "cursor"
  10088. }, {
  10089. name: "copylinesdown",
  10090. bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
  10091. exec: function(editor) { editor.copyLinesDown(); },
  10092. scrollIntoView: "cursor"
  10093. }, {
  10094. name: "movelinesdown",
  10095. bindKey: bindKey("Alt-Down", "Option-Down"),
  10096. exec: function(editor) { editor.moveLinesDown(); },
  10097. scrollIntoView: "cursor"
  10098. }, {
  10099. name: "del",
  10100. bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
  10101. exec: function(editor) { editor.remove("right"); },
  10102. multiSelectAction: "forEach",
  10103. scrollIntoView: "cursor"
  10104. }, {
  10105. name: "backspace",
  10106. bindKey: bindKey(
  10107. "Shift-Backspace|Backspace",
  10108. "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
  10109. ),
  10110. exec: function(editor) { editor.remove("left"); },
  10111. multiSelectAction: "forEach",
  10112. scrollIntoView: "cursor"
  10113. }, {
  10114. name: "cut_or_delete",
  10115. bindKey: bindKey("Shift-Delete", null),
  10116. exec: function(editor) {
  10117. if (editor.selection.isEmpty()) {
  10118. editor.remove("left");
  10119. } else {
  10120. return false;
  10121. }
  10122. },
  10123. multiSelectAction: "forEach",
  10124. scrollIntoView: "cursor"
  10125. }, {
  10126. name: "removetolinestart",
  10127. bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
  10128. exec: function(editor) { editor.removeToLineStart(); },
  10129. multiSelectAction: "forEach",
  10130. scrollIntoView: "cursor"
  10131. }, {
  10132. name: "removetolineend",
  10133. bindKey: bindKey("Alt-Delete", "Ctrl-K"),
  10134. exec: function(editor) { editor.removeToLineEnd(); },
  10135. multiSelectAction: "forEach",
  10136. scrollIntoView: "cursor"
  10137. }, {
  10138. name: "removewordleft",
  10139. bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
  10140. exec: function(editor) { editor.removeWordLeft(); },
  10141. multiSelectAction: "forEach",
  10142. scrollIntoView: "cursor"
  10143. }, {
  10144. name: "removewordright",
  10145. bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
  10146. exec: function(editor) { editor.removeWordRight(); },
  10147. multiSelectAction: "forEach",
  10148. scrollIntoView: "cursor"
  10149. }, {
  10150. name: "outdent",
  10151. bindKey: bindKey("Shift-Tab", "Shift-Tab"),
  10152. exec: function(editor) { editor.blockOutdent(); },
  10153. multiSelectAction: "forEach",
  10154. scrollIntoView: "selectionPart"
  10155. }, {
  10156. name: "indent",
  10157. bindKey: bindKey("Tab", "Tab"),
  10158. exec: function(editor) { editor.indent(); },
  10159. multiSelectAction: "forEach",
  10160. scrollIntoView: "selectionPart"
  10161. }, {
  10162. name: "blockoutdent",
  10163. bindKey: bindKey("Ctrl-[", "Ctrl-["),
  10164. exec: function(editor) { editor.blockOutdent(); },
  10165. multiSelectAction: "forEachLine",
  10166. scrollIntoView: "selectionPart"
  10167. }, {
  10168. name: "blockindent",
  10169. bindKey: bindKey("Ctrl-]", "Ctrl-]"),
  10170. exec: function(editor) { editor.blockIndent(); },
  10171. multiSelectAction: "forEachLine",
  10172. scrollIntoView: "selectionPart"
  10173. }, {
  10174. name: "insertstring",
  10175. exec: function(editor, str) { editor.insert(str); },
  10176. multiSelectAction: "forEach",
  10177. scrollIntoView: "cursor"
  10178. }, {
  10179. name: "inserttext",
  10180. exec: function(editor, args) {
  10181. editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
  10182. },
  10183. multiSelectAction: "forEach",
  10184. scrollIntoView: "cursor"
  10185. }, {
  10186. name: "splitline",
  10187. bindKey: bindKey(null, "Ctrl-O"),
  10188. exec: function(editor) { editor.splitLine(); },
  10189. multiSelectAction: "forEach",
  10190. scrollIntoView: "cursor"
  10191. }, {
  10192. name: "transposeletters",
  10193. bindKey: bindKey("Ctrl-T", "Ctrl-T"),
  10194. exec: function(editor) { editor.transposeLetters(); },
  10195. multiSelectAction: function(editor) {editor.transposeSelections(1); },
  10196. scrollIntoView: "cursor"
  10197. }, {
  10198. name: "touppercase",
  10199. bindKey: bindKey("Ctrl-U", "Ctrl-U"),
  10200. exec: function(editor) { editor.toUpperCase(); },
  10201. multiSelectAction: "forEach",
  10202. scrollIntoView: "cursor"
  10203. }, {
  10204. name: "tolowercase",
  10205. bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
  10206. exec: function(editor) { editor.toLowerCase(); },
  10207. multiSelectAction: "forEach",
  10208. scrollIntoView: "cursor"
  10209. }, {
  10210. name: "expandtoline",
  10211. bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
  10212. exec: function(editor) {
  10213. var range = editor.selection.getRange();
  10214. range.start.column = range.end.column = 0;
  10215. range.end.row++;
  10216. editor.selection.setRange(range, false);
  10217. },
  10218. multiSelectAction: "forEach",
  10219. scrollIntoView: "cursor",
  10220. readOnly: true
  10221. }, {
  10222. name: "joinlines",
  10223. bindKey: bindKey(null, null),
  10224. exec: function(editor) {
  10225. var isBackwards = editor.selection.isBackwards();
  10226. var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
  10227. var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
  10228. var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
  10229. var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
  10230. var selectedCount = selectedText.replace(/\n\s*/, " ").length;
  10231. var insertLine = editor.session.doc.getLine(selectionStart.row);
  10232. for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
  10233. var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
  10234. if (curLine.length !== 0) {
  10235. curLine = " " + curLine;
  10236. }
  10237. insertLine += curLine;
  10238. }
  10239. if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
  10240. insertLine += editor.session.doc.getNewLineCharacter();
  10241. }
  10242. editor.clearSelection();
  10243. editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
  10244. if (selectedCount > 0) {
  10245. editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
  10246. editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
  10247. } else {
  10248. firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
  10249. editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
  10250. }
  10251. },
  10252. multiSelectAction: "forEach",
  10253. readOnly: true
  10254. }, {
  10255. name: "invertSelection",
  10256. bindKey: bindKey(null, null),
  10257. exec: function(editor) {
  10258. var endRow = editor.session.doc.getLength() - 1;
  10259. var endCol = editor.session.doc.getLine(endRow).length;
  10260. var ranges = editor.selection.rangeList.ranges;
  10261. var newRanges = [];
  10262. if (ranges.length < 1) {
  10263. ranges = [editor.selection.getRange()];
  10264. }
  10265. for (var i = 0; i < ranges.length; i++) {
  10266. if (i == (ranges.length - 1)) {
  10267. if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
  10268. newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
  10269. }
  10270. }
  10271. if (i === 0) {
  10272. if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
  10273. newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
  10274. }
  10275. } else {
  10276. newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
  10277. }
  10278. }
  10279. editor.exitMultiSelectMode();
  10280. editor.clearSelection();
  10281. for(var i = 0; i < newRanges.length; i++) {
  10282. editor.selection.addRange(newRanges[i], false);
  10283. }
  10284. },
  10285. readOnly: true,
  10286. scrollIntoView: "none"
  10287. }];
  10288. });
  10289. 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) {
  10290. "use strict";
  10291. require("./lib/fixoldbrowsers");
  10292. var oop = require("./lib/oop");
  10293. var dom = require("./lib/dom");
  10294. var lang = require("./lib/lang");
  10295. var useragent = require("./lib/useragent");
  10296. var TextInput = require("./keyboard/textinput").TextInput;
  10297. var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
  10298. var FoldHandler = require("./mouse/fold_handler").FoldHandler;
  10299. var KeyBinding = require("./keyboard/keybinding").KeyBinding;
  10300. var EditSession = require("./edit_session").EditSession;
  10301. var Search = require("./search").Search;
  10302. var Range = require("./range").Range;
  10303. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  10304. var CommandManager = require("./commands/command_manager").CommandManager;
  10305. var defaultCommands = require("./commands/default_commands").commands;
  10306. var config = require("./config");
  10307. var TokenIterator = require("./token_iterator").TokenIterator;
  10308. var Editor = function(renderer, session) {
  10309. var container = renderer.getContainerElement();
  10310. this.container = container;
  10311. this.renderer = renderer;
  10312. this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
  10313. this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
  10314. this.renderer.textarea = this.textInput.getElement();
  10315. this.keyBinding = new KeyBinding(this);
  10316. this.$mouseHandler = new MouseHandler(this);
  10317. new FoldHandler(this);
  10318. this.$blockScrolling = 0;
  10319. this.$search = new Search().set({
  10320. wrap: true
  10321. });
  10322. this.$historyTracker = this.$historyTracker.bind(this);
  10323. this.commands.on("exec", this.$historyTracker);
  10324. this.$initOperationListeners();
  10325. this._$emitInputEvent = lang.delayedCall(function() {
  10326. this._signal("input", {});
  10327. if (this.session && this.session.bgTokenizer)
  10328. this.session.bgTokenizer.scheduleStart();
  10329. }.bind(this));
  10330. this.on("change", function(_, _self) {
  10331. _self._$emitInputEvent.schedule(31);
  10332. });
  10333. this.setSession(session || new EditSession(""));
  10334. config.resetOptions(this);
  10335. config._signal("editor", this);
  10336. };
  10337. (function(){
  10338. oop.implement(this, EventEmitter);
  10339. this.$initOperationListeners = function() {
  10340. function last(a) {return a[a.length - 1]}
  10341. this.selections = [];
  10342. this.commands.on("exec", this.startOperation.bind(this), true);
  10343. this.commands.on("afterExec", this.endOperation.bind(this), true);
  10344. this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
  10345. this.on("change", function() {
  10346. this.curOp || this.startOperation();
  10347. this.curOp.docChanged = true;
  10348. }.bind(this), true);
  10349. this.on("changeSelection", function() {
  10350. this.curOp || this.startOperation();
  10351. this.curOp.selectionChanged = true;
  10352. }.bind(this), true);
  10353. };
  10354. this.curOp = null;
  10355. this.prevOp = {};
  10356. this.startOperation = function(commadEvent) {
  10357. if (this.curOp) {
  10358. if (!commadEvent || this.curOp.command)
  10359. return;
  10360. this.prevOp = this.curOp;
  10361. }
  10362. if (!commadEvent) {
  10363. this.previousCommand = null;
  10364. commadEvent = {};
  10365. }
  10366. this.$opResetTimer.schedule();
  10367. this.curOp = {
  10368. command: commadEvent.command || {},
  10369. args: commadEvent.args,
  10370. scrollTop: this.renderer.scrollTop
  10371. };
  10372. if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
  10373. this.$blockScrolling++;
  10374. };
  10375. this.endOperation = function(e) {
  10376. if (this.curOp) {
  10377. if (e && e.returnValue === false)
  10378. return this.curOp = null;
  10379. this._signal("beforeEndOperation");
  10380. var command = this.curOp.command;
  10381. if (command.name && this.$blockScrolling > 0)
  10382. this.$blockScrolling--;
  10383. var scrollIntoView = command && command.scrollIntoView;
  10384. if (scrollIntoView) {
  10385. switch (scrollIntoView) {
  10386. case "center-animate":
  10387. scrollIntoView = "animate";
  10388. case "center":
  10389. this.renderer.scrollCursorIntoView(null, 0.5);
  10390. break;
  10391. case "animate":
  10392. case "cursor":
  10393. this.renderer.scrollCursorIntoView();
  10394. break;
  10395. case "selectionPart":
  10396. var range = this.selection.getRange();
  10397. var config = this.renderer.layerConfig;
  10398. if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
  10399. this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
  10400. }
  10401. break;
  10402. default:
  10403. break;
  10404. }
  10405. if (scrollIntoView == "animate")
  10406. this.renderer.animateScrolling(this.curOp.scrollTop);
  10407. }
  10408. this.prevOp = this.curOp;
  10409. this.curOp = null;
  10410. }
  10411. };
  10412. this.$mergeableCommands = ["backspace", "del", "insertstring"];
  10413. this.$historyTracker = function(e) {
  10414. if (!this.$mergeUndoDeltas)
  10415. return;
  10416. var prev = this.prevOp;
  10417. var mergeableCommands = this.$mergeableCommands;
  10418. var shouldMerge = prev.command && (e.command.name == prev.command.name);
  10419. if (e.command.name == "insertstring") {
  10420. var text = e.args;
  10421. if (this.mergeNextCommand === undefined)
  10422. this.mergeNextCommand = true;
  10423. shouldMerge = shouldMerge
  10424. && this.mergeNextCommand // previous command allows to coalesce with
  10425. && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
  10426. this.mergeNextCommand = true;
  10427. } else {
  10428. shouldMerge = shouldMerge
  10429. && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
  10430. }
  10431. if (
  10432. this.$mergeUndoDeltas != "always"
  10433. && Date.now() - this.sequenceStartTime > 2000
  10434. ) {
  10435. shouldMerge = false; // the sequence is too long
  10436. }
  10437. if (shouldMerge)
  10438. this.session.mergeUndoDeltas = true;
  10439. else if (mergeableCommands.indexOf(e.command.name) !== -1)
  10440. this.sequenceStartTime = Date.now();
  10441. };
  10442. this.setKeyboardHandler = function(keyboardHandler, cb) {
  10443. if (keyboardHandler && typeof keyboardHandler === "string") {
  10444. this.$keybindingId = keyboardHandler;
  10445. var _self = this;
  10446. config.loadModule(["keybinding", keyboardHandler], function(module) {
  10447. if (_self.$keybindingId == keyboardHandler)
  10448. _self.keyBinding.setKeyboardHandler(module && module.handler);
  10449. cb && cb();
  10450. });
  10451. } else {
  10452. this.$keybindingId = null;
  10453. this.keyBinding.setKeyboardHandler(keyboardHandler);
  10454. cb && cb();
  10455. }
  10456. };
  10457. this.getKeyboardHandler = function() {
  10458. return this.keyBinding.getKeyboardHandler();
  10459. };
  10460. this.setSession = function(session) {
  10461. if (this.session == session)
  10462. return;
  10463. if (this.curOp) this.endOperation();
  10464. this.curOp = {};
  10465. var oldSession = this.session;
  10466. if (oldSession) {
  10467. this.session.off("change", this.$onDocumentChange);
  10468. this.session.off("changeMode", this.$onChangeMode);
  10469. this.session.off("tokenizerUpdate", this.$onTokenizerUpdate);
  10470. this.session.off("changeTabSize", this.$onChangeTabSize);
  10471. this.session.off("changeWrapLimit", this.$onChangeWrapLimit);
  10472. this.session.off("changeWrapMode", this.$onChangeWrapMode);
  10473. this.session.off("changeFold", this.$onChangeFold);
  10474. this.session.off("changeFrontMarker", this.$onChangeFrontMarker);
  10475. this.session.off("changeBackMarker", this.$onChangeBackMarker);
  10476. this.session.off("changeBreakpoint", this.$onChangeBreakpoint);
  10477. this.session.off("changeAnnotation", this.$onChangeAnnotation);
  10478. this.session.off("changeOverwrite", this.$onCursorChange);
  10479. this.session.off("changeScrollTop", this.$onScrollTopChange);
  10480. this.session.off("changeScrollLeft", this.$onScrollLeftChange);
  10481. var selection = this.session.getSelection();
  10482. selection.off("changeCursor", this.$onCursorChange);
  10483. selection.off("changeSelection", this.$onSelectionChange);
  10484. }
  10485. this.session = session;
  10486. if (session) {
  10487. this.$onDocumentChange = this.onDocumentChange.bind(this);
  10488. session.on("change", this.$onDocumentChange);
  10489. this.renderer.setSession(session);
  10490. this.$onChangeMode = this.onChangeMode.bind(this);
  10491. session.on("changeMode", this.$onChangeMode);
  10492. this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
  10493. session.on("tokenizerUpdate", this.$onTokenizerUpdate);
  10494. this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
  10495. session.on("changeTabSize", this.$onChangeTabSize);
  10496. this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
  10497. session.on("changeWrapLimit", this.$onChangeWrapLimit);
  10498. this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
  10499. session.on("changeWrapMode", this.$onChangeWrapMode);
  10500. this.$onChangeFold = this.onChangeFold.bind(this);
  10501. session.on("changeFold", this.$onChangeFold);
  10502. this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
  10503. this.session.on("changeFrontMarker", this.$onChangeFrontMarker);
  10504. this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
  10505. this.session.on("changeBackMarker", this.$onChangeBackMarker);
  10506. this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
  10507. this.session.on("changeBreakpoint", this.$onChangeBreakpoint);
  10508. this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
  10509. this.session.on("changeAnnotation", this.$onChangeAnnotation);
  10510. this.$onCursorChange = this.onCursorChange.bind(this);
  10511. this.session.on("changeOverwrite", this.$onCursorChange);
  10512. this.$onScrollTopChange = this.onScrollTopChange.bind(this);
  10513. this.session.on("changeScrollTop", this.$onScrollTopChange);
  10514. this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
  10515. this.session.on("changeScrollLeft", this.$onScrollLeftChange);
  10516. this.selection = session.getSelection();
  10517. this.selection.on("changeCursor", this.$onCursorChange);
  10518. this.$onSelectionChange = this.onSelectionChange.bind(this);
  10519. this.selection.on("changeSelection", this.$onSelectionChange);
  10520. this.onChangeMode();
  10521. this.$blockScrolling += 1;
  10522. this.onCursorChange();
  10523. this.$blockScrolling -= 1;
  10524. this.onScrollTopChange();
  10525. this.onScrollLeftChange();
  10526. this.onSelectionChange();
  10527. this.onChangeFrontMarker();
  10528. this.onChangeBackMarker();
  10529. this.onChangeBreakpoint();
  10530. this.onChangeAnnotation();
  10531. this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
  10532. this.renderer.updateFull();
  10533. } else {
  10534. this.selection = null;
  10535. this.renderer.setSession(session);
  10536. }
  10537. this._signal("changeSession", {
  10538. session: session,
  10539. oldSession: oldSession
  10540. });
  10541. this.curOp = null;
  10542. oldSession && oldSession._signal("changeEditor", {oldEditor: this});
  10543. session && session._signal("changeEditor", {editor: this});
  10544. };
  10545. this.getSession = function() {
  10546. return this.session;
  10547. };
  10548. this.setValue = function(val, cursorPos) {
  10549. this.session.doc.setValue(val);
  10550. if (!cursorPos)
  10551. this.selectAll();
  10552. else if (cursorPos == 1)
  10553. this.navigateFileEnd();
  10554. else if (cursorPos == -1)
  10555. this.navigateFileStart();
  10556. return val;
  10557. };
  10558. this.getValue = function() {
  10559. return this.session.getValue();
  10560. };
  10561. this.getSelection = function() {
  10562. return this.selection;
  10563. };
  10564. this.resize = function(force) {
  10565. this.renderer.onResize(force);
  10566. };
  10567. this.setTheme = function(theme, cb) {
  10568. this.renderer.setTheme(theme, cb);
  10569. };
  10570. this.getTheme = function() {
  10571. return this.renderer.getTheme();
  10572. };
  10573. this.setStyle = function(style) {
  10574. this.renderer.setStyle(style);
  10575. };
  10576. this.unsetStyle = function(style) {
  10577. this.renderer.unsetStyle(style);
  10578. };
  10579. this.getFontSize = function () {
  10580. return this.getOption("fontSize") ||
  10581. dom.computedStyle(this.container, "fontSize");
  10582. };
  10583. this.setFontSize = function(size) {
  10584. this.setOption("fontSize", size);
  10585. };
  10586. this.$highlightBrackets = function() {
  10587. if (this.session.$bracketHighlight) {
  10588. this.session.removeMarker(this.session.$bracketHighlight);
  10589. this.session.$bracketHighlight = null;
  10590. }
  10591. if (this.$highlightPending) {
  10592. return;
  10593. }
  10594. var self = this;
  10595. this.$highlightPending = true;
  10596. setTimeout(function() {
  10597. self.$highlightPending = false;
  10598. var session = self.session;
  10599. if (!session || !session.bgTokenizer) return;
  10600. var pos = session.findMatchingBracket(self.getCursorPosition());
  10601. if (pos) {
  10602. var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
  10603. } else if (session.$mode.getMatching) {
  10604. var range = session.$mode.getMatching(self.session);
  10605. }
  10606. if (range)
  10607. session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
  10608. }, 50);
  10609. };
  10610. this.$highlightTags = function() {
  10611. if (this.$highlightTagPending)
  10612. return;
  10613. var self = this;
  10614. this.$highlightTagPending = true;
  10615. setTimeout(function() {
  10616. self.$highlightTagPending = false;
  10617. var session = self.session;
  10618. if (!session || !session.bgTokenizer) return;
  10619. var pos = self.getCursorPosition();
  10620. var iterator = new TokenIterator(self.session, pos.row, pos.column);
  10621. var token = iterator.getCurrentToken();
  10622. if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
  10623. session.removeMarker(session.$tagHighlight);
  10624. session.$tagHighlight = null;
  10625. return;
  10626. }
  10627. if (token.type.indexOf("tag-open") != -1) {
  10628. token = iterator.stepForward();
  10629. if (!token)
  10630. return;
  10631. }
  10632. var tag = token.value;
  10633. var depth = 0;
  10634. var prevToken = iterator.stepBackward();
  10635. if (prevToken.value == '<'){
  10636. do {
  10637. prevToken = token;
  10638. token = iterator.stepForward();
  10639. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10640. if (prevToken.value === '<'){
  10641. depth++;
  10642. } else if (prevToken.value === '</'){
  10643. depth--;
  10644. }
  10645. }
  10646. } while (token && depth >= 0);
  10647. } else {
  10648. do {
  10649. token = prevToken;
  10650. prevToken = iterator.stepBackward();
  10651. if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
  10652. if (prevToken.value === '<') {
  10653. depth++;
  10654. } else if (prevToken.value === '</') {
  10655. depth--;
  10656. }
  10657. }
  10658. } while (prevToken && depth <= 0);
  10659. iterator.stepForward();
  10660. }
  10661. if (!token) {
  10662. session.removeMarker(session.$tagHighlight);
  10663. session.$tagHighlight = null;
  10664. return;
  10665. }
  10666. var row = iterator.getCurrentTokenRow();
  10667. var column = iterator.getCurrentTokenColumn();
  10668. var range = new Range(row, column, row, column+token.value.length);
  10669. var sbm = session.$backMarkers[session.$tagHighlight];
  10670. if (session.$tagHighlight && sbm != undefined && range.compareRange(sbm.range) !== 0) {
  10671. session.removeMarker(session.$tagHighlight);
  10672. session.$tagHighlight = null;
  10673. }
  10674. if (range && !session.$tagHighlight)
  10675. session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
  10676. }, 50);
  10677. };
  10678. this.focus = function() {
  10679. var _self = this;
  10680. setTimeout(function() {
  10681. _self.textInput.focus();
  10682. });
  10683. this.textInput.focus();
  10684. };
  10685. this.isFocused = function() {
  10686. return this.textInput.isFocused();
  10687. };
  10688. this.blur = function() {
  10689. this.textInput.blur();
  10690. };
  10691. this.onFocus = function(e) {
  10692. if (this.$isFocused)
  10693. return;
  10694. this.$isFocused = true;
  10695. this.renderer.showCursor();
  10696. this.renderer.visualizeFocus();
  10697. this._emit("focus", e);
  10698. };
  10699. this.onBlur = function(e) {
  10700. if (!this.$isFocused)
  10701. return;
  10702. this.$isFocused = false;
  10703. this.renderer.hideCursor();
  10704. this.renderer.visualizeBlur();
  10705. this._emit("blur", e);
  10706. };
  10707. this.$cursorChange = function() {
  10708. this.renderer.updateCursor();
  10709. };
  10710. this.onDocumentChange = function(delta) {
  10711. var wrap = this.session.$useWrapMode;
  10712. var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
  10713. this.renderer.updateLines(delta.start.row, lastRow, wrap);
  10714. this._signal("change", delta);
  10715. this.$cursorChange();
  10716. this.$updateHighlightActiveLine();
  10717. };
  10718. this.onTokenizerUpdate = function(e) {
  10719. var rows = e.data;
  10720. this.renderer.updateLines(rows.first, rows.last);
  10721. };
  10722. this.onScrollTopChange = function() {
  10723. this.renderer.scrollToY(this.session.getScrollTop());
  10724. };
  10725. this.onScrollLeftChange = function() {
  10726. this.renderer.scrollToX(this.session.getScrollLeft());
  10727. };
  10728. this.onCursorChange = function() {
  10729. this.$cursorChange();
  10730. if (!this.$blockScrolling) {
  10731. config.warn("Automatically scrolling cursor into view after selection change",
  10732. "this will be disabled in the next version",
  10733. "set editor.$blockScrolling = Infinity to disable this message"
  10734. );
  10735. this.renderer.scrollCursorIntoView();
  10736. }
  10737. this.$highlightBrackets();
  10738. this.$highlightTags();
  10739. this.$updateHighlightActiveLine();
  10740. this._signal("changeSelection");
  10741. };
  10742. this.$updateHighlightActiveLine = function() {
  10743. var session = this.getSession();
  10744. var highlight;
  10745. if (this.$highlightActiveLine) {
  10746. if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
  10747. highlight = this.getCursorPosition();
  10748. if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
  10749. highlight = false;
  10750. }
  10751. if (session.$highlightLineMarker && !highlight) {
  10752. session.removeMarker(session.$highlightLineMarker.id);
  10753. session.$highlightLineMarker = null;
  10754. } else if (!session.$highlightLineMarker && highlight) {
  10755. var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
  10756. range.id = session.addMarker(range, "ace_active-line", "screenLine");
  10757. session.$highlightLineMarker = range;
  10758. } else if (highlight) {
  10759. session.$highlightLineMarker.start.row = highlight.row;
  10760. session.$highlightLineMarker.end.row = highlight.row;
  10761. session.$highlightLineMarker.start.column = highlight.column;
  10762. session._signal("changeBackMarker");
  10763. }
  10764. };
  10765. this.onSelectionChange = function(e) {
  10766. var session = this.session;
  10767. if (session.$selectionMarker) {
  10768. session.removeMarker(session.$selectionMarker);
  10769. }
  10770. session.$selectionMarker = null;
  10771. if (!this.selection.isEmpty()) {
  10772. var range = this.selection.getRange();
  10773. var style = this.getSelectionStyle();
  10774. session.$selectionMarker = session.addMarker(range, "ace_selection", style);
  10775. } else {
  10776. this.$updateHighlightActiveLine();
  10777. }
  10778. var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
  10779. this.session.highlight(re);
  10780. this._signal("changeSelection");
  10781. };
  10782. this.$getSelectionHighLightRegexp = function() {
  10783. var session = this.session;
  10784. var selection = this.getSelectionRange();
  10785. if (selection.isEmpty() || selection.isMultiLine())
  10786. return;
  10787. var startOuter = selection.start.column - 1;
  10788. var endOuter = selection.end.column + 1;
  10789. var line = session.getLine(selection.start.row);
  10790. var lineCols = line.length;
  10791. var needle = line.substring(Math.max(startOuter, 0),
  10792. Math.min(endOuter, lineCols));
  10793. if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
  10794. (endOuter <= lineCols && /[\w\d]$/.test(needle)))
  10795. return;
  10796. needle = line.substring(selection.start.column, selection.end.column);
  10797. if (!/^[\w\d]+$/.test(needle))
  10798. return;
  10799. var re = this.$search.$assembleRegExp({
  10800. wholeWord: true,
  10801. caseSensitive: true,
  10802. needle: needle
  10803. });
  10804. return re;
  10805. };
  10806. this.onChangeFrontMarker = function() {
  10807. this.renderer.updateFrontMarkers();
  10808. };
  10809. this.onChangeBackMarker = function() {
  10810. this.renderer.updateBackMarkers();
  10811. };
  10812. this.onChangeBreakpoint = function() {
  10813. this.renderer.updateBreakpoints();
  10814. };
  10815. this.onChangeAnnotation = function() {
  10816. this.renderer.setAnnotations(this.session.getAnnotations());
  10817. };
  10818. this.onChangeMode = function(e) {
  10819. this.renderer.updateText();
  10820. this._emit("changeMode", e);
  10821. };
  10822. this.onChangeWrapLimit = function() {
  10823. this.renderer.updateFull();
  10824. };
  10825. this.onChangeWrapMode = function() {
  10826. this.renderer.onResize(true);
  10827. };
  10828. this.onChangeFold = function() {
  10829. this.$updateHighlightActiveLine();
  10830. this.renderer.updateFull();
  10831. };
  10832. this.getSelectedText = function() {
  10833. return this.session.getTextRange(this.getSelectionRange());
  10834. };
  10835. this.getCopyText = function() {
  10836. var text = this.getSelectedText();
  10837. this._signal("copy", text);
  10838. return text;
  10839. };
  10840. this.onCopy = function() {
  10841. this.commands.exec("copy", this);
  10842. };
  10843. this.onCut = function() {
  10844. this.commands.exec("cut", this);
  10845. };
  10846. this.onPaste = function(text, event) {
  10847. var e = {text: text, event: event};
  10848. this.commands.exec("paste", this, e);
  10849. };
  10850. this.$handlePaste = function(e) {
  10851. if (typeof e == "string")
  10852. e = {text: e};
  10853. this._signal("paste", e);
  10854. var text = e.text;
  10855. if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
  10856. this.insert(text);
  10857. } else {
  10858. var lines = text.split(/\r\n|\r|\n/);
  10859. var ranges = this.selection.rangeList.ranges;
  10860. if (lines.length > ranges.length || lines.length < 2 || !lines[1])
  10861. return this.commands.exec("insertstring", this, text);
  10862. for (var i = ranges.length; i--;) {
  10863. var range = ranges[i];
  10864. if (!range.isEmpty())
  10865. this.session.remove(range);
  10866. this.session.insert(range.start, lines[i]);
  10867. }
  10868. }
  10869. };
  10870. this.execCommand = function(command, args) {
  10871. return this.commands.exec(command, this, args);
  10872. };
  10873. this.insert = function(text, pasted) {
  10874. var session = this.session;
  10875. var mode = session.getMode();
  10876. var cursor = this.getCursorPosition();
  10877. if (this.getBehavioursEnabled() && !pasted) {
  10878. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
  10879. if (transform) {
  10880. if (text !== transform.text) {
  10881. this.session.mergeUndoDeltas = false;
  10882. this.$mergeNextCommand = false;
  10883. }
  10884. text = transform.text;
  10885. }
  10886. }
  10887. if (text == "\t")
  10888. text = this.session.getTabString();
  10889. if (!this.selection.isEmpty()) {
  10890. var range = this.getSelectionRange();
  10891. cursor = this.session.remove(range);
  10892. this.clearSelection();
  10893. }
  10894. else if (this.session.getOverwrite()) {
  10895. var range = new Range.fromPoints(cursor, cursor);
  10896. range.end.column += text.length;
  10897. this.session.remove(range);
  10898. }
  10899. if (text == "\n" || text == "\r\n") {
  10900. var line = session.getLine(cursor.row);
  10901. if (cursor.column > line.search(/\S|$/)) {
  10902. var d = line.substr(cursor.column).search(/\S|$/);
  10903. session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
  10904. }
  10905. }
  10906. this.clearSelection();
  10907. var start = cursor.column;
  10908. var lineState = session.getState(cursor.row);
  10909. var line = session.getLine(cursor.row);
  10910. var shouldOutdent = mode.checkOutdent(lineState, line, text);
  10911. var end = session.insert(cursor, text);
  10912. if (transform && transform.selection) {
  10913. if (transform.selection.length == 2) { // Transform relative to the current column
  10914. this.selection.setSelectionRange(
  10915. new Range(cursor.row, start + transform.selection[0],
  10916. cursor.row, start + transform.selection[1]));
  10917. } else { // Transform relative to the current row.
  10918. this.selection.setSelectionRange(
  10919. new Range(cursor.row + transform.selection[0],
  10920. transform.selection[1],
  10921. cursor.row + transform.selection[2],
  10922. transform.selection[3]));
  10923. }
  10924. }
  10925. if (session.getDocument().isNewLine(text)) {
  10926. var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
  10927. session.insert({row: cursor.row+1, column: 0}, lineIndent);
  10928. }
  10929. if (shouldOutdent)
  10930. mode.autoOutdent(lineState, session, cursor.row);
  10931. };
  10932. this.onTextInput = function(text) {
  10933. this.keyBinding.onTextInput(text);
  10934. };
  10935. this.onCommandKey = function(e, hashId, keyCode) {
  10936. this.keyBinding.onCommandKey(e, hashId, keyCode);
  10937. };
  10938. this.setOverwrite = function(overwrite) {
  10939. this.session.setOverwrite(overwrite);
  10940. };
  10941. this.getOverwrite = function() {
  10942. return this.session.getOverwrite();
  10943. };
  10944. this.toggleOverwrite = function() {
  10945. this.session.toggleOverwrite();
  10946. };
  10947. this.setScrollSpeed = function(speed) {
  10948. this.setOption("scrollSpeed", speed);
  10949. };
  10950. this.getScrollSpeed = function() {
  10951. return this.getOption("scrollSpeed");
  10952. };
  10953. this.setDragDelay = function(dragDelay) {
  10954. this.setOption("dragDelay", dragDelay);
  10955. };
  10956. this.getDragDelay = function() {
  10957. return this.getOption("dragDelay");
  10958. };
  10959. this.setSelectionStyle = function(val) {
  10960. this.setOption("selectionStyle", val);
  10961. };
  10962. this.getSelectionStyle = function() {
  10963. return this.getOption("selectionStyle");
  10964. };
  10965. this.setHighlightActiveLine = function(shouldHighlight) {
  10966. this.setOption("highlightActiveLine", shouldHighlight);
  10967. };
  10968. this.getHighlightActiveLine = function() {
  10969. return this.getOption("highlightActiveLine");
  10970. };
  10971. this.setHighlightGutterLine = function(shouldHighlight) {
  10972. this.setOption("highlightGutterLine", shouldHighlight);
  10973. };
  10974. this.getHighlightGutterLine = function() {
  10975. return this.getOption("highlightGutterLine");
  10976. };
  10977. this.setHighlightSelectedWord = function(shouldHighlight) {
  10978. this.setOption("highlightSelectedWord", shouldHighlight);
  10979. };
  10980. this.getHighlightSelectedWord = function() {
  10981. return this.$highlightSelectedWord;
  10982. };
  10983. this.setAnimatedScroll = function(shouldAnimate){
  10984. this.renderer.setAnimatedScroll(shouldAnimate);
  10985. };
  10986. this.getAnimatedScroll = function(){
  10987. return this.renderer.getAnimatedScroll();
  10988. };
  10989. this.setShowInvisibles = function(showInvisibles) {
  10990. this.renderer.setShowInvisibles(showInvisibles);
  10991. };
  10992. this.getShowInvisibles = function() {
  10993. return this.renderer.getShowInvisibles();
  10994. };
  10995. this.setDisplayIndentGuides = function(display) {
  10996. this.renderer.setDisplayIndentGuides(display);
  10997. };
  10998. this.getDisplayIndentGuides = function() {
  10999. return this.renderer.getDisplayIndentGuides();
  11000. };
  11001. this.setShowPrintMargin = function(showPrintMargin) {
  11002. this.renderer.setShowPrintMargin(showPrintMargin);
  11003. };
  11004. this.getShowPrintMargin = function() {
  11005. return this.renderer.getShowPrintMargin();
  11006. };
  11007. this.setPrintMarginColumn = function(showPrintMargin) {
  11008. this.renderer.setPrintMarginColumn(showPrintMargin);
  11009. };
  11010. this.getPrintMarginColumn = function() {
  11011. return this.renderer.getPrintMarginColumn();
  11012. };
  11013. this.setReadOnly = function(readOnly) {
  11014. this.setOption("readOnly", readOnly);
  11015. };
  11016. this.getReadOnly = function() {
  11017. return this.getOption("readOnly");
  11018. };
  11019. this.setBehavioursEnabled = function (enabled) {
  11020. this.setOption("behavioursEnabled", enabled);
  11021. };
  11022. this.getBehavioursEnabled = function () {
  11023. return this.getOption("behavioursEnabled");
  11024. };
  11025. this.setWrapBehavioursEnabled = function (enabled) {
  11026. this.setOption("wrapBehavioursEnabled", enabled);
  11027. };
  11028. this.getWrapBehavioursEnabled = function () {
  11029. return this.getOption("wrapBehavioursEnabled");
  11030. };
  11031. this.setShowFoldWidgets = function(show) {
  11032. this.setOption("showFoldWidgets", show);
  11033. };
  11034. this.getShowFoldWidgets = function() {
  11035. return this.getOption("showFoldWidgets");
  11036. };
  11037. this.setFadeFoldWidgets = function(fade) {
  11038. this.setOption("fadeFoldWidgets", fade);
  11039. };
  11040. this.getFadeFoldWidgets = function() {
  11041. return this.getOption("fadeFoldWidgets");
  11042. };
  11043. this.remove = function(dir) {
  11044. if (this.selection.isEmpty()){
  11045. if (dir == "left")
  11046. this.selection.selectLeft();
  11047. else
  11048. this.selection.selectRight();
  11049. }
  11050. var range = this.getSelectionRange();
  11051. if (this.getBehavioursEnabled()) {
  11052. var session = this.session;
  11053. var state = session.getState(range.start.row);
  11054. var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
  11055. if (range.end.column === 0) {
  11056. var text = session.getTextRange(range);
  11057. if (text[text.length - 1] == "\n") {
  11058. var line = session.getLine(range.end.row);
  11059. if (/^\s+$/.test(line)) {
  11060. range.end.column = line.length;
  11061. }
  11062. }
  11063. }
  11064. if (new_range)
  11065. range = new_range;
  11066. }
  11067. this.session.remove(range);
  11068. this.clearSelection();
  11069. };
  11070. this.removeWordRight = function() {
  11071. if (this.selection.isEmpty())
  11072. this.selection.selectWordRight();
  11073. this.session.remove(this.getSelectionRange());
  11074. this.clearSelection();
  11075. };
  11076. this.removeWordLeft = function() {
  11077. if (this.selection.isEmpty())
  11078. this.selection.selectWordLeft();
  11079. this.session.remove(this.getSelectionRange());
  11080. this.clearSelection();
  11081. };
  11082. this.removeToLineStart = function() {
  11083. if (this.selection.isEmpty())
  11084. this.selection.selectLineStart();
  11085. this.session.remove(this.getSelectionRange());
  11086. this.clearSelection();
  11087. };
  11088. this.removeToLineEnd = function() {
  11089. if (this.selection.isEmpty())
  11090. this.selection.selectLineEnd();
  11091. var range = this.getSelectionRange();
  11092. if (range.start.column == range.end.column && range.start.row == range.end.row) {
  11093. range.end.column = 0;
  11094. range.end.row++;
  11095. }
  11096. this.session.remove(range);
  11097. this.clearSelection();
  11098. };
  11099. this.splitLine = function() {
  11100. if (!this.selection.isEmpty()) {
  11101. this.session.remove(this.getSelectionRange());
  11102. this.clearSelection();
  11103. }
  11104. var cursor = this.getCursorPosition();
  11105. this.insert("\n");
  11106. this.moveCursorToPosition(cursor);
  11107. };
  11108. this.transposeLetters = function() {
  11109. if (!this.selection.isEmpty()) {
  11110. return;
  11111. }
  11112. var cursor = this.getCursorPosition();
  11113. var column = cursor.column;
  11114. if (column === 0)
  11115. return;
  11116. var line = this.session.getLine(cursor.row);
  11117. var swap, range;
  11118. if (column < line.length) {
  11119. swap = line.charAt(column) + line.charAt(column-1);
  11120. range = new Range(cursor.row, column-1, cursor.row, column+1);
  11121. }
  11122. else {
  11123. swap = line.charAt(column-1) + line.charAt(column-2);
  11124. range = new Range(cursor.row, column-2, cursor.row, column);
  11125. }
  11126. this.session.replace(range, swap);
  11127. };
  11128. this.toLowerCase = function() {
  11129. var originalRange = this.getSelectionRange();
  11130. if (this.selection.isEmpty()) {
  11131. this.selection.selectWord();
  11132. }
  11133. var range = this.getSelectionRange();
  11134. var text = this.session.getTextRange(range);
  11135. this.session.replace(range, text.toLowerCase());
  11136. this.selection.setSelectionRange(originalRange);
  11137. };
  11138. this.toUpperCase = function() {
  11139. var originalRange = this.getSelectionRange();
  11140. if (this.selection.isEmpty()) {
  11141. this.selection.selectWord();
  11142. }
  11143. var range = this.getSelectionRange();
  11144. var text = this.session.getTextRange(range);
  11145. this.session.replace(range, text.toUpperCase());
  11146. this.selection.setSelectionRange(originalRange);
  11147. };
  11148. this.indent = function() {
  11149. var session = this.session;
  11150. var range = this.getSelectionRange();
  11151. if (range.start.row < range.end.row) {
  11152. var rows = this.$getSelectedRows();
  11153. session.indentRows(rows.first, rows.last, "\t");
  11154. return;
  11155. } else if (range.start.column < range.end.column) {
  11156. var text = session.getTextRange(range);
  11157. if (!/^\s+$/.test(text)) {
  11158. var rows = this.$getSelectedRows();
  11159. session.indentRows(rows.first, rows.last, "\t");
  11160. return;
  11161. }
  11162. }
  11163. var line = session.getLine(range.start.row);
  11164. var position = range.start;
  11165. var size = session.getTabSize();
  11166. var column = session.documentToScreenColumn(position.row, position.column);
  11167. if (this.session.getUseSoftTabs()) {
  11168. var count = (size - column % size);
  11169. var indentString = lang.stringRepeat(" ", count);
  11170. } else {
  11171. var count = column % size;
  11172. while (line[range.start.column - 1] == " " && count) {
  11173. range.start.column--;
  11174. count--;
  11175. }
  11176. this.selection.setSelectionRange(range);
  11177. indentString = "\t";
  11178. }
  11179. return this.insert(indentString);
  11180. };
  11181. this.blockIndent = function() {
  11182. var rows = this.$getSelectedRows();
  11183. this.session.indentRows(rows.first, rows.last, "\t");
  11184. };
  11185. this.blockOutdent = function() {
  11186. var selection = this.session.getSelection();
  11187. this.session.outdentRows(selection.getRange());
  11188. };
  11189. this.sortLines = function() {
  11190. var rows = this.$getSelectedRows();
  11191. var session = this.session;
  11192. var lines = [];
  11193. for (i = rows.first; i <= rows.last; i++)
  11194. lines.push(session.getLine(i));
  11195. lines.sort(function(a, b) {
  11196. if (a.toLowerCase() < b.toLowerCase()) return -1;
  11197. if (a.toLowerCase() > b.toLowerCase()) return 1;
  11198. return 0;
  11199. });
  11200. var deleteRange = new Range(0, 0, 0, 0);
  11201. for (var i = rows.first; i <= rows.last; i++) {
  11202. var line = session.getLine(i);
  11203. deleteRange.start.row = i;
  11204. deleteRange.end.row = i;
  11205. deleteRange.end.column = line.length;
  11206. session.replace(deleteRange, lines[i-rows.first]);
  11207. }
  11208. };
  11209. this.toggleCommentLines = function() {
  11210. var state = this.session.getState(this.getCursorPosition().row);
  11211. var rows = this.$getSelectedRows();
  11212. this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
  11213. };
  11214. this.toggleBlockComment = function() {
  11215. var cursor = this.getCursorPosition();
  11216. var state = this.session.getState(cursor.row);
  11217. var range = this.getSelectionRange();
  11218. this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
  11219. };
  11220. this.getNumberAt = function(row, column) {
  11221. var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
  11222. _numberRx.lastIndex = 0;
  11223. var s = this.session.getLine(row);
  11224. while (_numberRx.lastIndex < column) {
  11225. var m = _numberRx.exec(s);
  11226. if(m.index <= column && m.index+m[0].length >= column){
  11227. var number = {
  11228. value: m[0],
  11229. start: m.index,
  11230. end: m.index+m[0].length
  11231. };
  11232. return number;
  11233. }
  11234. }
  11235. return null;
  11236. };
  11237. this.modifyNumber = function(amount) {
  11238. var row = this.selection.getCursor().row;
  11239. var column = this.selection.getCursor().column;
  11240. var charRange = new Range(row, column-1, row, column);
  11241. var c = this.session.getTextRange(charRange);
  11242. if (!isNaN(parseFloat(c)) && isFinite(c)) {
  11243. var nr = this.getNumberAt(row, column);
  11244. if (nr) {
  11245. var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
  11246. var decimals = nr.start + nr.value.length - fp;
  11247. var t = parseFloat(nr.value);
  11248. t *= Math.pow(10, decimals);
  11249. if(fp !== nr.end && column < fp){
  11250. amount *= Math.pow(10, nr.end - column - 1);
  11251. } else {
  11252. amount *= Math.pow(10, nr.end - column);
  11253. }
  11254. t += amount;
  11255. t /= Math.pow(10, decimals);
  11256. var nnr = t.toFixed(decimals);
  11257. var replaceRange = new Range(row, nr.start, row, nr.end);
  11258. this.session.replace(replaceRange, nnr);
  11259. this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
  11260. }
  11261. }
  11262. };
  11263. this.removeLines = function() {
  11264. var rows = this.$getSelectedRows();
  11265. this.session.removeFullLines(rows.first, rows.last);
  11266. this.clearSelection();
  11267. };
  11268. this.duplicateSelection = function() {
  11269. var sel = this.selection;
  11270. var doc = this.session;
  11271. var range = sel.getRange();
  11272. var reverse = sel.isBackwards();
  11273. if (range.isEmpty()) {
  11274. var row = range.start.row;
  11275. doc.duplicateLines(row, row);
  11276. } else {
  11277. var point = reverse ? range.start : range.end;
  11278. var endPoint = doc.insert(point, doc.getTextRange(range), false);
  11279. range.start = point;
  11280. range.end = endPoint;
  11281. sel.setSelectionRange(range, reverse);
  11282. }
  11283. };
  11284. this.moveLinesDown = function() {
  11285. this.$moveLines(1, false);
  11286. };
  11287. this.moveLinesUp = function() {
  11288. this.$moveLines(-1, false);
  11289. };
  11290. this.moveText = function(range, toPosition, copy) {
  11291. return this.session.moveText(range, toPosition, copy);
  11292. };
  11293. this.copyLinesUp = function() {
  11294. this.$moveLines(-1, true);
  11295. };
  11296. this.copyLinesDown = function() {
  11297. this.$moveLines(1, true);
  11298. };
  11299. this.$moveLines = function(dir, copy) {
  11300. var rows, moved;
  11301. var selection = this.selection;
  11302. if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
  11303. var range = selection.toOrientedRange();
  11304. rows = this.$getSelectedRows(range);
  11305. moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
  11306. if (copy && dir == -1) moved = 0;
  11307. range.moveBy(moved, 0);
  11308. selection.fromOrientedRange(range);
  11309. } else {
  11310. var ranges = selection.rangeList.ranges;
  11311. selection.rangeList.detach(this.session);
  11312. this.inVirtualSelectionMode = true;
  11313. var diff = 0;
  11314. var totalDiff = 0;
  11315. var l = ranges.length;
  11316. for (var i = 0; i < l; i++) {
  11317. var rangeIndex = i;
  11318. ranges[i].moveBy(diff, 0);
  11319. rows = this.$getSelectedRows(ranges[i]);
  11320. var first = rows.first;
  11321. var last = rows.last;
  11322. while (++i < l) {
  11323. if (totalDiff) ranges[i].moveBy(totalDiff, 0);
  11324. var subRows = this.$getSelectedRows(ranges[i]);
  11325. if (copy && subRows.first != last)
  11326. break;
  11327. else if (!copy && subRows.first > last + 1)
  11328. break;
  11329. last = subRows.last;
  11330. }
  11331. i--;
  11332. diff = this.session.$moveLines(first, last, copy ? 0 : dir);
  11333. if (copy && dir == -1) rangeIndex = i + 1;
  11334. while (rangeIndex <= i) {
  11335. ranges[rangeIndex].moveBy(diff, 0);
  11336. rangeIndex++;
  11337. }
  11338. if (!copy) diff = 0;
  11339. totalDiff += diff;
  11340. }
  11341. selection.fromOrientedRange(selection.ranges[0]);
  11342. selection.rangeList.attach(this.session);
  11343. this.inVirtualSelectionMode = false;
  11344. }
  11345. };
  11346. this.$getSelectedRows = function(range) {
  11347. range = (range || this.getSelectionRange()).collapseRows();
  11348. return {
  11349. first: this.session.getRowFoldStart(range.start.row),
  11350. last: this.session.getRowFoldEnd(range.end.row)
  11351. };
  11352. };
  11353. this.onCompositionStart = function(text) {
  11354. this.renderer.showComposition(this.getCursorPosition());
  11355. };
  11356. this.onCompositionUpdate = function(text) {
  11357. this.renderer.setCompositionText(text);
  11358. };
  11359. this.onCompositionEnd = function() {
  11360. this.renderer.hideComposition();
  11361. };
  11362. this.getFirstVisibleRow = function() {
  11363. return this.renderer.getFirstVisibleRow();
  11364. };
  11365. this.getLastVisibleRow = function() {
  11366. return this.renderer.getLastVisibleRow();
  11367. };
  11368. this.isRowVisible = function(row) {
  11369. return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
  11370. };
  11371. this.isRowFullyVisible = function(row) {
  11372. return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
  11373. };
  11374. this.$getVisibleRowCount = function() {
  11375. return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
  11376. };
  11377. this.$moveByPage = function(dir, select) {
  11378. var renderer = this.renderer;
  11379. var config = this.renderer.layerConfig;
  11380. var rows = dir * Math.floor(config.height / config.lineHeight);
  11381. this.$blockScrolling++;
  11382. if (select === true) {
  11383. this.selection.$moveSelection(function(){
  11384. this.moveCursorBy(rows, 0);
  11385. });
  11386. } else if (select === false) {
  11387. this.selection.moveCursorBy(rows, 0);
  11388. this.selection.clearSelection();
  11389. }
  11390. this.$blockScrolling--;
  11391. var scrollTop = renderer.scrollTop;
  11392. renderer.scrollBy(0, rows * config.lineHeight);
  11393. if (select != null)
  11394. renderer.scrollCursorIntoView(null, 0.5);
  11395. renderer.animateScrolling(scrollTop);
  11396. };
  11397. this.selectPageDown = function() {
  11398. this.$moveByPage(1, true);
  11399. };
  11400. this.selectPageUp = function() {
  11401. this.$moveByPage(-1, true);
  11402. };
  11403. this.gotoPageDown = function() {
  11404. this.$moveByPage(1, false);
  11405. };
  11406. this.gotoPageUp = function() {
  11407. this.$moveByPage(-1, false);
  11408. };
  11409. this.scrollPageDown = function() {
  11410. this.$moveByPage(1);
  11411. };
  11412. this.scrollPageUp = function() {
  11413. this.$moveByPage(-1);
  11414. };
  11415. this.scrollToRow = function(row) {
  11416. this.renderer.scrollToRow(row);
  11417. };
  11418. this.scrollToLine = function(line, center, animate, callback) {
  11419. this.renderer.scrollToLine(line, center, animate, callback);
  11420. };
  11421. this.centerSelection = function() {
  11422. var range = this.getSelectionRange();
  11423. var pos = {
  11424. row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
  11425. column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
  11426. };
  11427. this.renderer.alignCursor(pos, 0.5);
  11428. };
  11429. this.getCursorPosition = function() {
  11430. return this.selection.getCursor();
  11431. };
  11432. this.getCursorPositionScreen = function() {
  11433. return this.session.documentToScreenPosition(this.getCursorPosition());
  11434. };
  11435. this.getSelectionRange = function() {
  11436. return this.selection.getRange();
  11437. };
  11438. this.selectAll = function() {
  11439. this.$blockScrolling += 1;
  11440. this.selection.selectAll();
  11441. this.$blockScrolling -= 1;
  11442. };
  11443. this.clearSelection = function() {
  11444. this.selection.clearSelection();
  11445. };
  11446. this.moveCursorTo = function(row, column) {
  11447. this.selection.moveCursorTo(row, column);
  11448. };
  11449. this.moveCursorToPosition = function(pos) {
  11450. this.selection.moveCursorToPosition(pos);
  11451. };
  11452. this.jumpToMatching = function(select, expand) {
  11453. var cursor = this.getCursorPosition();
  11454. var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
  11455. var prevToken = iterator.getCurrentToken();
  11456. var token = prevToken || iterator.stepForward();
  11457. if (!token) return;
  11458. var matchType;
  11459. var found = false;
  11460. var depth = {};
  11461. var i = cursor.column - token.start;
  11462. var bracketType;
  11463. var brackets = {
  11464. ")": "(",
  11465. "(": "(",
  11466. "]": "[",
  11467. "[": "[",
  11468. "{": "{",
  11469. "}": "{"
  11470. };
  11471. do {
  11472. if (token.value.match(/[{}()\[\]]/g)) {
  11473. for (; i < token.value.length && !found; i++) {
  11474. if (!brackets[token.value[i]]) {
  11475. continue;
  11476. }
  11477. bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
  11478. if (isNaN(depth[bracketType])) {
  11479. depth[bracketType] = 0;
  11480. }
  11481. switch (token.value[i]) {
  11482. case '(':
  11483. case '[':
  11484. case '{':
  11485. depth[bracketType]++;
  11486. break;
  11487. case ')':
  11488. case ']':
  11489. case '}':
  11490. depth[bracketType]--;
  11491. if (depth[bracketType] === -1) {
  11492. matchType = 'bracket';
  11493. found = true;
  11494. }
  11495. break;
  11496. }
  11497. }
  11498. }
  11499. else if (token && token.type.indexOf('tag-name') !== -1) {
  11500. if (isNaN(depth[token.value])) {
  11501. depth[token.value] = 0;
  11502. }
  11503. if (prevToken.value === '<') {
  11504. depth[token.value]++;
  11505. }
  11506. else if (prevToken.value === '</') {
  11507. depth[token.value]--;
  11508. }
  11509. if (depth[token.value] === -1) {
  11510. matchType = 'tag';
  11511. found = true;
  11512. }
  11513. }
  11514. if (!found) {
  11515. prevToken = token;
  11516. token = iterator.stepForward();
  11517. i = 0;
  11518. }
  11519. } while (token && !found);
  11520. if (!matchType)
  11521. return;
  11522. var range, pos;
  11523. if (matchType === 'bracket') {
  11524. range = this.session.getBracketRange(cursor);
  11525. if (!range) {
  11526. range = new Range(
  11527. iterator.getCurrentTokenRow(),
  11528. iterator.getCurrentTokenColumn() + i - 1,
  11529. iterator.getCurrentTokenRow(),
  11530. iterator.getCurrentTokenColumn() + i - 1
  11531. );
  11532. pos = range.start;
  11533. if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11534. range = this.session.getBracketRange(pos);
  11535. }
  11536. }
  11537. else if (matchType === 'tag') {
  11538. if (token && token.type.indexOf('tag-name') !== -1)
  11539. var tag = token.value;
  11540. else
  11541. return;
  11542. range = new Range(
  11543. iterator.getCurrentTokenRow(),
  11544. iterator.getCurrentTokenColumn() - 2,
  11545. iterator.getCurrentTokenRow(),
  11546. iterator.getCurrentTokenColumn() - 2
  11547. );
  11548. if (range.compare(cursor.row, cursor.column) === 0) {
  11549. found = false;
  11550. do {
  11551. token = prevToken;
  11552. prevToken = iterator.stepBackward();
  11553. if (prevToken) {
  11554. if (prevToken.type.indexOf('tag-close') !== -1) {
  11555. range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
  11556. }
  11557. if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
  11558. if (prevToken.value === '<') {
  11559. depth[tag]++;
  11560. }
  11561. else if (prevToken.value === '</') {
  11562. depth[tag]--;
  11563. }
  11564. if (depth[tag] === 0)
  11565. found = true;
  11566. }
  11567. }
  11568. } while (prevToken && !found);
  11569. }
  11570. if (token && token.type.indexOf('tag-name')) {
  11571. pos = range.start;
  11572. if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
  11573. pos = range.end;
  11574. }
  11575. }
  11576. pos = range && range.cursor || pos;
  11577. if (pos) {
  11578. if (select) {
  11579. if (range && expand) {
  11580. this.selection.setRange(range);
  11581. } else if (range && range.isEqual(this.getSelectionRange())) {
  11582. this.clearSelection();
  11583. } else {
  11584. this.selection.selectTo(pos.row, pos.column);
  11585. }
  11586. } else {
  11587. this.selection.moveTo(pos.row, pos.column);
  11588. }
  11589. }
  11590. };
  11591. this.gotoLine = function(lineNumber, column, animate) {
  11592. this.selection.clearSelection();
  11593. this.session.unfold({row: lineNumber - 1, column: column || 0});
  11594. this.$blockScrolling += 1;
  11595. this.exitMultiSelectMode && this.exitMultiSelectMode();
  11596. this.moveCursorTo(lineNumber - 1, column || 0);
  11597. this.$blockScrolling -= 1;
  11598. if (!this.isRowFullyVisible(lineNumber - 1))
  11599. this.scrollToLine(lineNumber - 1, true, animate);
  11600. };
  11601. this.navigateTo = function(row, column) {
  11602. this.selection.moveTo(row, column);
  11603. };
  11604. this.navigateUp = function(times) {
  11605. if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
  11606. var selectionStart = this.selection.anchor.getPosition();
  11607. return this.moveCursorToPosition(selectionStart);
  11608. }
  11609. this.selection.clearSelection();
  11610. this.selection.moveCursorBy(-times || -1, 0);
  11611. };
  11612. this.navigateDown = function(times) {
  11613. if (this.selection.isMultiLine() && this.selection.isBackwards()) {
  11614. var selectionEnd = this.selection.anchor.getPosition();
  11615. return this.moveCursorToPosition(selectionEnd);
  11616. }
  11617. this.selection.clearSelection();
  11618. this.selection.moveCursorBy(times || 1, 0);
  11619. };
  11620. this.navigateLeft = function(times) {
  11621. if (!this.selection.isEmpty()) {
  11622. var selectionStart = this.getSelectionRange().start;
  11623. this.moveCursorToPosition(selectionStart);
  11624. }
  11625. else {
  11626. times = times || 1;
  11627. while (times--) {
  11628. this.selection.moveCursorLeft();
  11629. }
  11630. }
  11631. this.clearSelection();
  11632. };
  11633. this.navigateRight = function(times) {
  11634. if (!this.selection.isEmpty()) {
  11635. var selectionEnd = this.getSelectionRange().end;
  11636. this.moveCursorToPosition(selectionEnd);
  11637. }
  11638. else {
  11639. times = times || 1;
  11640. while (times--) {
  11641. this.selection.moveCursorRight();
  11642. }
  11643. }
  11644. this.clearSelection();
  11645. };
  11646. this.navigateLineStart = function() {
  11647. this.selection.moveCursorLineStart();
  11648. this.clearSelection();
  11649. };
  11650. this.navigateLineEnd = function() {
  11651. this.selection.moveCursorLineEnd();
  11652. this.clearSelection();
  11653. };
  11654. this.navigateFileEnd = function() {
  11655. this.selection.moveCursorFileEnd();
  11656. this.clearSelection();
  11657. };
  11658. this.navigateFileStart = function() {
  11659. this.selection.moveCursorFileStart();
  11660. this.clearSelection();
  11661. };
  11662. this.navigateWordRight = function() {
  11663. this.selection.moveCursorWordRight();
  11664. this.clearSelection();
  11665. };
  11666. this.navigateWordLeft = function() {
  11667. this.selection.moveCursorWordLeft();
  11668. this.clearSelection();
  11669. };
  11670. this.replace = function(replacement, options) {
  11671. if (options)
  11672. this.$search.set(options);
  11673. var range = this.$search.find(this.session);
  11674. var replaced = 0;
  11675. if (!range)
  11676. return replaced;
  11677. if (this.$tryReplace(range, replacement)) {
  11678. replaced = 1;
  11679. }
  11680. if (range !== null) {
  11681. this.selection.setSelectionRange(range);
  11682. this.renderer.scrollSelectionIntoView(range.start, range.end);
  11683. }
  11684. return replaced;
  11685. };
  11686. this.replaceAll = function(replacement, options) {
  11687. if (options) {
  11688. this.$search.set(options);
  11689. }
  11690. var ranges = this.$search.findAll(this.session);
  11691. var replaced = 0;
  11692. if (!ranges.length)
  11693. return replaced;
  11694. this.$blockScrolling += 1;
  11695. var selection = this.getSelectionRange();
  11696. this.selection.moveTo(0, 0);
  11697. for (var i = ranges.length - 1; i >= 0; --i) {
  11698. if(this.$tryReplace(ranges[i], replacement)) {
  11699. replaced++;
  11700. }
  11701. }
  11702. this.selection.setSelectionRange(selection);
  11703. this.$blockScrolling -= 1;
  11704. return replaced;
  11705. };
  11706. this.$tryReplace = function(range, replacement) {
  11707. var input = this.session.getTextRange(range);
  11708. replacement = this.$search.replace(input, replacement);
  11709. if (replacement !== null) {
  11710. range.end = this.session.replace(range, replacement);
  11711. return range;
  11712. } else {
  11713. return null;
  11714. }
  11715. };
  11716. this.getLastSearchOptions = function() {
  11717. return this.$search.getOptions();
  11718. };
  11719. this.find = function(needle, options, animate) {
  11720. if (!options)
  11721. options = {};
  11722. if (typeof needle == "string" || needle instanceof RegExp)
  11723. options.needle = needle;
  11724. else if (typeof needle == "object")
  11725. oop.mixin(options, needle);
  11726. var range = this.selection.getRange();
  11727. if (options.needle == null) {
  11728. needle = this.session.getTextRange(range)
  11729. || this.$search.$options.needle;
  11730. if (!needle) {
  11731. range = this.session.getWordRange(range.start.row, range.start.column);
  11732. needle = this.session.getTextRange(range);
  11733. }
  11734. this.$search.set({needle: needle});
  11735. }
  11736. this.$search.set(options);
  11737. if (!options.start)
  11738. this.$search.set({start: range});
  11739. var newRange = this.$search.find(this.session);
  11740. if (options.preventScroll)
  11741. return newRange;
  11742. if (newRange) {
  11743. this.revealRange(newRange, animate);
  11744. return newRange;
  11745. }
  11746. if (options.backwards)
  11747. range.start = range.end;
  11748. else
  11749. range.end = range.start;
  11750. this.selection.setRange(range);
  11751. };
  11752. this.findNext = function(options, animate) {
  11753. this.find({skipCurrent: true, backwards: false}, options, animate);
  11754. };
  11755. this.findPrevious = function(options, animate) {
  11756. this.find(options, {skipCurrent: true, backwards: true}, animate);
  11757. };
  11758. this.revealRange = function(range, animate) {
  11759. this.$blockScrolling += 1;
  11760. this.session.unfold(range);
  11761. this.selection.setSelectionRange(range);
  11762. this.$blockScrolling -= 1;
  11763. var scrollTop = this.renderer.scrollTop;
  11764. this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
  11765. if (animate !== false)
  11766. this.renderer.animateScrolling(scrollTop);
  11767. };
  11768. this.undo = function() {
  11769. this.$blockScrolling++;
  11770. this.session.getUndoManager().undo();
  11771. this.$blockScrolling--;
  11772. this.renderer.scrollCursorIntoView(null, 0.5);
  11773. };
  11774. this.redo = function() {
  11775. this.$blockScrolling++;
  11776. this.session.getUndoManager().redo();
  11777. this.$blockScrolling--;
  11778. this.renderer.scrollCursorIntoView(null, 0.5);
  11779. };
  11780. this.destroy = function() {
  11781. this.renderer.destroy();
  11782. this._signal("destroy", this);
  11783. if (this.session) {
  11784. this.session.destroy();
  11785. }
  11786. };
  11787. this.setAutoScrollEditorIntoView = function(enable) {
  11788. if (!enable)
  11789. return;
  11790. var rect;
  11791. var self = this;
  11792. var shouldScroll = false;
  11793. if (!this.$scrollAnchor)
  11794. this.$scrollAnchor = document.createElement("div");
  11795. var scrollAnchor = this.$scrollAnchor;
  11796. scrollAnchor.style.cssText = "position:absolute";
  11797. this.container.insertBefore(scrollAnchor, this.container.firstChild);
  11798. var onChangeSelection = this.on("changeSelection", function() {
  11799. shouldScroll = true;
  11800. });
  11801. var onBeforeRender = this.renderer.on("beforeRender", function() {
  11802. if (shouldScroll)
  11803. rect = self.renderer.container.getBoundingClientRect();
  11804. });
  11805. var onAfterRender = this.renderer.on("afterRender", function() {
  11806. if (shouldScroll && rect && (self.isFocused()
  11807. || self.searchBox && self.searchBox.isFocused())
  11808. ) {
  11809. var renderer = self.renderer;
  11810. var pos = renderer.$cursorLayer.$pixelPos;
  11811. var config = renderer.layerConfig;
  11812. var top = pos.top - config.offset;
  11813. if (pos.top >= 0 && top + rect.top < 0) {
  11814. shouldScroll = true;
  11815. } else if (pos.top < config.height &&
  11816. pos.top + rect.top + config.lineHeight > window.innerHeight) {
  11817. shouldScroll = false;
  11818. } else {
  11819. shouldScroll = null;
  11820. }
  11821. if (shouldScroll != null) {
  11822. scrollAnchor.style.top = top + "px";
  11823. scrollAnchor.style.left = pos.left + "px";
  11824. scrollAnchor.style.height = config.lineHeight + "px";
  11825. scrollAnchor.scrollIntoView(shouldScroll);
  11826. }
  11827. shouldScroll = rect = null;
  11828. }
  11829. });
  11830. this.setAutoScrollEditorIntoView = function(enable) {
  11831. if (enable)
  11832. return;
  11833. delete this.setAutoScrollEditorIntoView;
  11834. this.off("changeSelection", onChangeSelection);
  11835. this.renderer.off("afterRender", onAfterRender);
  11836. this.renderer.off("beforeRender", onBeforeRender);
  11837. };
  11838. };
  11839. this.$resetCursorStyle = function() {
  11840. var style = this.$cursorStyle || "ace";
  11841. var cursorLayer = this.renderer.$cursorLayer;
  11842. if (!cursorLayer)
  11843. return;
  11844. cursorLayer.setSmoothBlinking(/smooth/.test(style));
  11845. cursorLayer.isBlinking = !this.$readOnly && style != "wide";
  11846. dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
  11847. };
  11848. }).call(Editor.prototype);
  11849. config.defineOptions(Editor.prototype, "editor", {
  11850. selectionStyle: {
  11851. set: function(style) {
  11852. this.onSelectionChange();
  11853. this._signal("changeSelectionStyle", {data: style});
  11854. },
  11855. initialValue: "line"
  11856. },
  11857. highlightActiveLine: {
  11858. set: function() {this.$updateHighlightActiveLine();},
  11859. initialValue: true
  11860. },
  11861. highlightSelectedWord: {
  11862. set: function(shouldHighlight) {this.$onSelectionChange();},
  11863. initialValue: true
  11864. },
  11865. readOnly: {
  11866. set: function(readOnly) {
  11867. this.$resetCursorStyle();
  11868. },
  11869. initialValue: false
  11870. },
  11871. cursorStyle: {
  11872. set: function(val) { this.$resetCursorStyle(); },
  11873. values: ["ace", "slim", "smooth", "wide"],
  11874. initialValue: "ace"
  11875. },
  11876. mergeUndoDeltas: {
  11877. values: [false, true, "always"],
  11878. initialValue: true
  11879. },
  11880. behavioursEnabled: {initialValue: true},
  11881. wrapBehavioursEnabled: {initialValue: true},
  11882. autoScrollEditorIntoView: {
  11883. set: function(val) {this.setAutoScrollEditorIntoView(val)}
  11884. },
  11885. keyboardHandler: {
  11886. set: function(val) { this.setKeyboardHandler(val); },
  11887. get: function() { return this.keybindingId; },
  11888. handlesSet: true
  11889. },
  11890. hScrollBarAlwaysVisible: "renderer",
  11891. vScrollBarAlwaysVisible: "renderer",
  11892. highlightGutterLine: "renderer",
  11893. animatedScroll: "renderer",
  11894. showInvisibles: "renderer",
  11895. showPrintMargin: "renderer",
  11896. printMarginColumn: "renderer",
  11897. printMargin: "renderer",
  11898. fadeFoldWidgets: "renderer",
  11899. showFoldWidgets: "renderer",
  11900. showLineNumbers: "renderer",
  11901. showGutter: "renderer",
  11902. displayIndentGuides: "renderer",
  11903. fontSize: "renderer",
  11904. fontFamily: "renderer",
  11905. maxLines: "renderer",
  11906. minLines: "renderer",
  11907. scrollPastEnd: "renderer",
  11908. fixedWidthGutter: "renderer",
  11909. theme: "renderer",
  11910. scrollSpeed: "$mouseHandler",
  11911. dragDelay: "$mouseHandler",
  11912. dragEnabled: "$mouseHandler",
  11913. focusTimout: "$mouseHandler",
  11914. tooltipFollowsMouse: "$mouseHandler",
  11915. firstLineNumber: "session",
  11916. overwrite: "session",
  11917. newLineMode: "session",
  11918. useWorker: "session",
  11919. useSoftTabs: "session",
  11920. tabSize: "session",
  11921. wrap: "session",
  11922. indentedSoftWrap: "session",
  11923. foldStyle: "session",
  11924. mode: "session"
  11925. });
  11926. exports.Editor = Editor;
  11927. });
  11928. ace.define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
  11929. "use strict";
  11930. var UndoManager = function() {
  11931. this.reset();
  11932. };
  11933. (function() {
  11934. this.execute = function(options) {
  11935. var deltaSets = options.args[0];
  11936. this.$doc = options.args[1];
  11937. if (options.merge && this.hasUndo()){
  11938. this.dirtyCounter--;
  11939. deltaSets = this.$undoStack.pop().concat(deltaSets);
  11940. }
  11941. this.$undoStack.push(deltaSets);
  11942. this.$redoStack = [];
  11943. if (this.dirtyCounter < 0) {
  11944. this.dirtyCounter = NaN;
  11945. }
  11946. this.dirtyCounter++;
  11947. };
  11948. this.undo = function(dontSelect) {
  11949. var deltaSets = this.$undoStack.pop();
  11950. var undoSelectionRange = null;
  11951. if (deltaSets) {
  11952. undoSelectionRange = this.$doc.undoChanges(deltaSets, dontSelect);
  11953. this.$redoStack.push(deltaSets);
  11954. this.dirtyCounter--;
  11955. }
  11956. return undoSelectionRange;
  11957. };
  11958. this.redo = function(dontSelect) {
  11959. var deltaSets = this.$redoStack.pop();
  11960. var redoSelectionRange = null;
  11961. if (deltaSets) {
  11962. redoSelectionRange =
  11963. this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
  11964. this.$undoStack.push(deltaSets);
  11965. this.dirtyCounter++;
  11966. }
  11967. return redoSelectionRange;
  11968. };
  11969. this.reset = function() {
  11970. this.$undoStack = [];
  11971. this.$redoStack = [];
  11972. this.dirtyCounter = 0;
  11973. };
  11974. this.hasUndo = function() {
  11975. return this.$undoStack.length > 0;
  11976. };
  11977. this.hasRedo = function() {
  11978. return this.$redoStack.length > 0;
  11979. };
  11980. this.markClean = function() {
  11981. this.dirtyCounter = 0;
  11982. };
  11983. this.isClean = function() {
  11984. return this.dirtyCounter === 0;
  11985. };
  11986. this.$serializeDeltas = function(deltaSets) {
  11987. return cloneDeltaSetsObj(deltaSets, $serializeDelta);
  11988. };
  11989. this.$deserializeDeltas = function(deltaSets) {
  11990. return cloneDeltaSetsObj(deltaSets, $deserializeDelta);
  11991. };
  11992. function $serializeDelta(delta){
  11993. return {
  11994. action: delta.action,
  11995. start: delta.start,
  11996. end: delta.end,
  11997. lines: delta.lines.length == 1 ? null : delta.lines,
  11998. text: delta.lines.length == 1 ? delta.lines[0] : null
  11999. };
  12000. }
  12001. function $deserializeDelta(delta) {
  12002. return {
  12003. action: delta.action,
  12004. start: delta.start,
  12005. end: delta.end,
  12006. lines: delta.lines || [delta.text]
  12007. };
  12008. }
  12009. function cloneDeltaSetsObj(deltaSets_old, fnGetModifiedDelta) {
  12010. var deltaSets_new = new Array(deltaSets_old.length);
  12011. for (var i = 0; i < deltaSets_old.length; i++) {
  12012. var deltaSet_old = deltaSets_old[i];
  12013. var deltaSet_new = { group: deltaSet_old.group, deltas: new Array(deltaSet_old.length)};
  12014. for (var j = 0; j < deltaSet_old.deltas.length; j++) {
  12015. var delta_old = deltaSet_old.deltas[j];
  12016. deltaSet_new.deltas[j] = fnGetModifiedDelta(delta_old);
  12017. }
  12018. deltaSets_new[i] = deltaSet_new;
  12019. }
  12020. return deltaSets_new;
  12021. }
  12022. }).call(UndoManager.prototype);
  12023. exports.UndoManager = UndoManager;
  12024. });
  12025. 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) {
  12026. "use strict";
  12027. var dom = require("../lib/dom");
  12028. var oop = require("../lib/oop");
  12029. var lang = require("../lib/lang");
  12030. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12031. var Gutter = function(parentEl) {
  12032. this.element = dom.createElement("div");
  12033. this.element.className = "ace_layer ace_gutter-layer";
  12034. parentEl.appendChild(this.element);
  12035. this.setShowFoldWidgets(this.$showFoldWidgets);
  12036. this.gutterWidth = 0;
  12037. this.$annotations = [];
  12038. this.$updateAnnotations = this.$updateAnnotations.bind(this);
  12039. this.$cells = [];
  12040. };
  12041. (function() {
  12042. oop.implement(this, EventEmitter);
  12043. this.setSession = function(session) {
  12044. if (this.session)
  12045. this.session.removeEventListener("change", this.$updateAnnotations);
  12046. this.session = session;
  12047. if (session)
  12048. session.on("change", this.$updateAnnotations);
  12049. };
  12050. this.addGutterDecoration = function(row, className){
  12051. if (window.console)
  12052. console.warn && console.warn("deprecated use session.addGutterDecoration");
  12053. this.session.addGutterDecoration(row, className);
  12054. };
  12055. this.removeGutterDecoration = function(row, className){
  12056. if (window.console)
  12057. console.warn && console.warn("deprecated use session.removeGutterDecoration");
  12058. this.session.removeGutterDecoration(row, className);
  12059. };
  12060. this.setAnnotations = function(annotations) {
  12061. this.$annotations = [];
  12062. for (var i = 0; i < annotations.length; i++) {
  12063. var annotation = annotations[i];
  12064. var row = annotation.row;
  12065. var rowInfo = this.$annotations[row];
  12066. if (!rowInfo)
  12067. rowInfo = this.$annotations[row] = {text: []};
  12068. var annoText = annotation.text;
  12069. annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
  12070. if (rowInfo.text.indexOf(annoText) === -1)
  12071. rowInfo.text.push(annoText);
  12072. var type = annotation.type;
  12073. if (type == "error")
  12074. rowInfo.className = " ace_error";
  12075. else if (type == "warning" && rowInfo.className != " ace_error")
  12076. rowInfo.className = " ace_warning";
  12077. else if (type == "info" && (!rowInfo.className))
  12078. rowInfo.className = " ace_info";
  12079. }
  12080. };
  12081. this.$updateAnnotations = function (delta) {
  12082. if (!this.$annotations.length)
  12083. return;
  12084. var firstRow = delta.start.row;
  12085. var len = delta.end.row - firstRow;
  12086. if (len === 0) {
  12087. } else if (delta.action == 'remove') {
  12088. this.$annotations.splice(firstRow, len + 1, null);
  12089. } else {
  12090. var args = new Array(len + 1);
  12091. args.unshift(firstRow, 1);
  12092. this.$annotations.splice.apply(this.$annotations, args);
  12093. }
  12094. };
  12095. this.update = function(config) {
  12096. var session = this.session;
  12097. var firstRow = config.firstRow;
  12098. var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
  12099. session.getLength() - 1);
  12100. var fold = session.getNextFoldLine(firstRow);
  12101. var foldStart = fold ? fold.start.row : Infinity;
  12102. var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
  12103. var breakpoints = session.$breakpoints;
  12104. var decorations = session.$decorations;
  12105. var firstLineNumber = session.$firstLineNumber;
  12106. var lastLineNumber = 0;
  12107. var gutterRenderer = session.gutterRenderer || this.$renderer;
  12108. var cell = null;
  12109. var index = -1;
  12110. var row = firstRow;
  12111. while (true) {
  12112. if (row > foldStart) {
  12113. row = fold.end.row + 1;
  12114. fold = session.getNextFoldLine(row, fold);
  12115. foldStart = fold ? fold.start.row : Infinity;
  12116. }
  12117. if (row > lastRow) {
  12118. while (this.$cells.length > index + 1) {
  12119. cell = this.$cells.pop();
  12120. this.element.removeChild(cell.element);
  12121. }
  12122. break;
  12123. }
  12124. cell = this.$cells[++index];
  12125. if (!cell) {
  12126. cell = {element: null, textNode: null, foldWidget: null};
  12127. cell.element = dom.createElement("div");
  12128. cell.textNode = document.createTextNode('');
  12129. cell.element.appendChild(cell.textNode);
  12130. this.element.appendChild(cell.element);
  12131. this.$cells[index] = cell;
  12132. }
  12133. var className = "ace_gutter-cell ";
  12134. if (breakpoints[row])
  12135. className += breakpoints[row];
  12136. if (decorations[row])
  12137. className += decorations[row];
  12138. if (this.$annotations[row])
  12139. className += this.$annotations[row].className;
  12140. if (cell.element.className != className)
  12141. cell.element.className = className;
  12142. var height = session.getRowLength(row) * config.lineHeight + "px";
  12143. if (height != cell.element.style.height)
  12144. cell.element.style.height = height;
  12145. if (foldWidgets) {
  12146. var c = foldWidgets[row];
  12147. if (c == null)
  12148. c = foldWidgets[row] = session.getFoldWidget(row);
  12149. }
  12150. if (c) {
  12151. if (!cell.foldWidget) {
  12152. cell.foldWidget = dom.createElement("span");
  12153. cell.element.appendChild(cell.foldWidget);
  12154. }
  12155. var className = "ace_fold-widget ace_" + c;
  12156. if (c == "start" && row == foldStart && row < fold.end.row)
  12157. className += " ace_closed";
  12158. else
  12159. className += " ace_open";
  12160. if (cell.foldWidget.className != className)
  12161. cell.foldWidget.className = className;
  12162. var height = config.lineHeight + "px";
  12163. if (cell.foldWidget.style.height != height)
  12164. cell.foldWidget.style.height = height;
  12165. } else {
  12166. if (cell.foldWidget) {
  12167. cell.element.removeChild(cell.foldWidget);
  12168. cell.foldWidget = null;
  12169. }
  12170. }
  12171. var text = lastLineNumber = gutterRenderer
  12172. ? gutterRenderer.getText(session, row)
  12173. : row + firstLineNumber;
  12174. if (text != cell.textNode.data)
  12175. cell.textNode.data = text;
  12176. row++;
  12177. }
  12178. this.element.style.height = config.minHeight + "px";
  12179. if (this.$fixedWidth || session.$useWrapMode)
  12180. lastLineNumber = session.getLength() + firstLineNumber;
  12181. var gutterWidth = gutterRenderer
  12182. ? gutterRenderer.getWidth(session, lastLineNumber, config)
  12183. : lastLineNumber.toString().length * config.characterWidth;
  12184. var padding = this.$padding || this.$computePadding();
  12185. gutterWidth += padding.left + padding.right;
  12186. if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
  12187. this.gutterWidth = gutterWidth;
  12188. this.element.style.width = Math.ceil(this.gutterWidth) + "px";
  12189. this._emit("changeGutterWidth", gutterWidth);
  12190. }
  12191. };
  12192. this.$fixedWidth = false;
  12193. this.$showLineNumbers = true;
  12194. this.$renderer = "";
  12195. this.setShowLineNumbers = function(show) {
  12196. this.$renderer = !show && {
  12197. getWidth: function() {return ""},
  12198. getText: function() {return ""}
  12199. };
  12200. };
  12201. this.getShowLineNumbers = function() {
  12202. return this.$showLineNumbers;
  12203. };
  12204. this.$showFoldWidgets = true;
  12205. this.setShowFoldWidgets = function(show) {
  12206. if (show)
  12207. dom.addCssClass(this.element, "ace_folding-enabled");
  12208. else
  12209. dom.removeCssClass(this.element, "ace_folding-enabled");
  12210. this.$showFoldWidgets = show;
  12211. this.$padding = null;
  12212. };
  12213. this.getShowFoldWidgets = function() {
  12214. return this.$showFoldWidgets;
  12215. };
  12216. this.$computePadding = function() {
  12217. if (!this.element.firstChild)
  12218. return {left: 0, right: 0};
  12219. var style = dom.computedStyle(this.element.firstChild);
  12220. this.$padding = {};
  12221. this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
  12222. this.$padding.right = parseInt(style.paddingRight) || 0;
  12223. return this.$padding;
  12224. };
  12225. this.getRegion = function(point) {
  12226. var padding = this.$padding || this.$computePadding();
  12227. var rect = this.element.getBoundingClientRect();
  12228. if (point.x < padding.left + rect.left)
  12229. return "markers";
  12230. if (this.$showFoldWidgets && point.x > rect.right - padding.right)
  12231. return "foldWidgets";
  12232. };
  12233. }).call(Gutter.prototype);
  12234. exports.Gutter = Gutter;
  12235. });
  12236. ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
  12237. "use strict";
  12238. var Range = require("../range").Range;
  12239. var dom = require("../lib/dom");
  12240. var Marker = function(parentEl) {
  12241. this.element = dom.createElement("div");
  12242. this.element.className = "ace_layer ace_marker-layer";
  12243. parentEl.appendChild(this.element);
  12244. };
  12245. (function() {
  12246. this.$padding = 0;
  12247. this.setPadding = function(padding) {
  12248. this.$padding = padding;
  12249. };
  12250. this.setSession = function(session) {
  12251. this.session = session;
  12252. };
  12253. this.setMarkers = function(markers) {
  12254. this.markers = markers;
  12255. };
  12256. this.update = function(config) {
  12257. var config = config || this.config;
  12258. if (!config)
  12259. return;
  12260. this.config = config;
  12261. var html = [];
  12262. for (var key in this.markers) {
  12263. var marker = this.markers[key];
  12264. if (!marker.range) {
  12265. marker.update(html, this, this.session, config);
  12266. continue;
  12267. }
  12268. var range = marker.range.clipRows(config.firstRow, config.lastRow);
  12269. if (range.isEmpty()) continue;
  12270. range = range.toScreenRange(this.session);
  12271. if (marker.renderer) {
  12272. var top = this.$getTop(range.start.row, config);
  12273. var left = this.$padding + range.start.column * config.characterWidth;
  12274. marker.renderer(html, range, left, top, config);
  12275. } else if (marker.type == "fullLine") {
  12276. this.drawFullLineMarker(html, range, marker.clazz, config);
  12277. } else if (marker.type == "screenLine") {
  12278. this.drawScreenLineMarker(html, range, marker.clazz, config);
  12279. } else if (range.isMultiLine()) {
  12280. if (marker.type == "text")
  12281. this.drawTextMarker(html, range, marker.clazz, config);
  12282. else
  12283. this.drawMultiLineMarker(html, range, marker.clazz, config);
  12284. } else {
  12285. this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
  12286. }
  12287. }
  12288. this.element.innerHTML = html.join("");
  12289. };
  12290. this.$getTop = function(row, layerConfig) {
  12291. return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
  12292. };
  12293. function getBorderClass(tl, tr, br, bl) {
  12294. return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
  12295. }
  12296. this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
  12297. var session = this.session;
  12298. var start = range.start.row;
  12299. var end = range.end.row;
  12300. var row = start;
  12301. var prev = 0;
  12302. var curr = 0;
  12303. var next = session.getScreenLastRowColumn(row);
  12304. var lineRange = new Range(row, range.start.column, row, curr);
  12305. for (; row <= end; row++) {
  12306. lineRange.start.row = lineRange.end.row = row;
  12307. lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
  12308. lineRange.end.column = next;
  12309. prev = curr;
  12310. curr = next;
  12311. next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
  12312. this.drawSingleLineMarker(stringBuilder, lineRange,
  12313. clazz + (row == start ? " ace_start" : "") + " ace_br"
  12314. + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end),
  12315. layerConfig, row == end ? 0 : 1, extraStyle);
  12316. }
  12317. };
  12318. this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  12319. var padding = this.$padding;
  12320. var height = config.lineHeight;
  12321. var top = this.$getTop(range.start.row, config);
  12322. var left = padding + range.start.column * config.characterWidth;
  12323. extraStyle = extraStyle || "";
  12324. stringBuilder.push(
  12325. "<div class='", clazz, " ace_br1 ace_start' style='",
  12326. "height:", height, "px;",
  12327. "right:0;",
  12328. "top:", top, "px;",
  12329. "left:", left, "px;", extraStyle, "'></div>"
  12330. );
  12331. top = this.$getTop(range.end.row, config);
  12332. var width = range.end.column * config.characterWidth;
  12333. stringBuilder.push(
  12334. "<div class='", clazz, " ace_br12' style='",
  12335. "height:", height, "px;",
  12336. "width:", width, "px;",
  12337. "top:", top, "px;",
  12338. "left:", padding, "px;", extraStyle, "'></div>"
  12339. );
  12340. height = (range.end.row - range.start.row - 1) * config.lineHeight;
  12341. if (height <= 0)
  12342. return;
  12343. top = this.$getTop(range.start.row + 1, config);
  12344. var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
  12345. stringBuilder.push(
  12346. "<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
  12347. "height:", height, "px;",
  12348. "right:0;",
  12349. "top:", top, "px;",
  12350. "left:", padding, "px;", extraStyle, "'></div>"
  12351. );
  12352. };
  12353. this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
  12354. var height = config.lineHeight;
  12355. var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
  12356. var top = this.$getTop(range.start.row, config);
  12357. var left = this.$padding + range.start.column * config.characterWidth;
  12358. stringBuilder.push(
  12359. "<div class='", clazz, "' style='",
  12360. "height:", height, "px;",
  12361. "width:", width, "px;",
  12362. "top:", top, "px;",
  12363. "left:", left, "px;", extraStyle || "", "'></div>"
  12364. );
  12365. };
  12366. this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  12367. var top = this.$getTop(range.start.row, config);
  12368. var height = config.lineHeight;
  12369. if (range.start.row != range.end.row)
  12370. height += this.$getTop(range.end.row, config) - top;
  12371. stringBuilder.push(
  12372. "<div class='", clazz, "' style='",
  12373. "height:", height, "px;",
  12374. "top:", top, "px;",
  12375. "left:0;right:0;", extraStyle || "", "'></div>"
  12376. );
  12377. };
  12378. this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
  12379. var top = this.$getTop(range.start.row, config);
  12380. var height = config.lineHeight;
  12381. stringBuilder.push(
  12382. "<div class='", clazz, "' style='",
  12383. "height:", height, "px;",
  12384. "top:", top, "px;",
  12385. "left:0;right:0;", extraStyle || "", "'></div>"
  12386. );
  12387. };
  12388. }).call(Marker.prototype);
  12389. exports.Marker = Marker;
  12390. });
  12391. 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) {
  12392. "use strict";
  12393. var oop = require("../lib/oop");
  12394. var dom = require("../lib/dom");
  12395. var lang = require("../lib/lang");
  12396. var useragent = require("../lib/useragent");
  12397. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  12398. var Text = function(parentEl) {
  12399. this.element = dom.createElement("div");
  12400. this.element.className = "ace_layer ace_text-layer";
  12401. parentEl.appendChild(this.element);
  12402. this.$updateEolChar = this.$updateEolChar.bind(this);
  12403. };
  12404. (function() {
  12405. oop.implement(this, EventEmitter);
  12406. this.EOF_CHAR = "\xB6";
  12407. this.EOL_CHAR_LF = "\xAC";
  12408. this.EOL_CHAR_CRLF = "\xa4";
  12409. this.EOL_CHAR = this.EOL_CHAR_LF;
  12410. this.TAB_CHAR = "\u2014"; //"\u21E5";
  12411. this.SPACE_CHAR = "\xB7";
  12412. this.$padding = 0;
  12413. this.$updateEolChar = function() {
  12414. var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
  12415. ? this.EOL_CHAR_LF
  12416. : this.EOL_CHAR_CRLF;
  12417. if (this.EOL_CHAR != EOL_CHAR) {
  12418. this.EOL_CHAR = EOL_CHAR;
  12419. return true;
  12420. }
  12421. }
  12422. this.setPadding = function(padding) {
  12423. this.$padding = padding;
  12424. this.element.style.padding = "0 " + padding + "px";
  12425. };
  12426. this.getLineHeight = function() {
  12427. return this.$fontMetrics.$characterSize.height || 0;
  12428. };
  12429. this.getCharacterWidth = function() {
  12430. return this.$fontMetrics.$characterSize.width || 0;
  12431. };
  12432. this.$setFontMetrics = function(measure) {
  12433. this.$fontMetrics = measure;
  12434. this.$fontMetrics.on("changeCharacterSize", function(e) {
  12435. this._signal("changeCharacterSize", e);
  12436. }.bind(this));
  12437. this.$pollSizeChanges();
  12438. }
  12439. this.checkForSizeChanges = function() {
  12440. this.$fontMetrics.checkForSizeChanges();
  12441. };
  12442. this.$pollSizeChanges = function() {
  12443. return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
  12444. };
  12445. this.setSession = function(session) {
  12446. this.session = session;
  12447. if (session)
  12448. this.$computeTabString();
  12449. };
  12450. this.showInvisibles = false;
  12451. this.setShowInvisibles = function(showInvisibles) {
  12452. if (this.showInvisibles == showInvisibles)
  12453. return false;
  12454. this.showInvisibles = showInvisibles;
  12455. this.$computeTabString();
  12456. return true;
  12457. };
  12458. this.displayIndentGuides = true;
  12459. this.setDisplayIndentGuides = function(display) {
  12460. if (this.displayIndentGuides == display)
  12461. return false;
  12462. this.displayIndentGuides = display;
  12463. this.$computeTabString();
  12464. return true;
  12465. };
  12466. this.$tabStrings = [];
  12467. this.onChangeTabSize =
  12468. this.$computeTabString = function() {
  12469. var tabSize = this.session.getTabSize();
  12470. this.tabSize = tabSize;
  12471. var tabStr = this.$tabStrings = [0];
  12472. for (var i = 1; i < tabSize + 1; i++) {
  12473. if (this.showInvisibles) {
  12474. tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
  12475. + lang.stringRepeat(this.TAB_CHAR, i)
  12476. + "</span>");
  12477. } else {
  12478. tabStr.push(lang.stringRepeat(" ", i));
  12479. }
  12480. }
  12481. if (this.displayIndentGuides) {
  12482. this.$indentGuideRe = /\s\S| \t|\t |\s$/;
  12483. var className = "ace_indent-guide";
  12484. var spaceClass = "";
  12485. var tabClass = "";
  12486. if (this.showInvisibles) {
  12487. className += " ace_invisible";
  12488. spaceClass = " ace_invisible_space";
  12489. tabClass = " ace_invisible_tab";
  12490. var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
  12491. var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
  12492. } else{
  12493. var spaceContent = lang.stringRepeat(" ", this.tabSize);
  12494. var tabContent = spaceContent;
  12495. }
  12496. this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
  12497. this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
  12498. }
  12499. };
  12500. this.updateLines = function(config, firstRow, lastRow) {
  12501. if (this.config.lastRow != config.lastRow ||
  12502. this.config.firstRow != config.firstRow) {
  12503. this.scrollLines(config);
  12504. }
  12505. this.config = config;
  12506. var first = Math.max(firstRow, config.firstRow);
  12507. var last = Math.min(lastRow, config.lastRow);
  12508. var lineElements = this.element.childNodes;
  12509. var lineElementsIdx = 0;
  12510. for (var row = config.firstRow; row < first; row++) {
  12511. var foldLine = this.session.getFoldLine(row);
  12512. if (foldLine) {
  12513. if (foldLine.containsRow(first)) {
  12514. first = foldLine.start.row;
  12515. break;
  12516. } else {
  12517. row = foldLine.end.row;
  12518. }
  12519. }
  12520. lineElementsIdx ++;
  12521. }
  12522. var row = first;
  12523. var foldLine = this.session.getNextFoldLine(row);
  12524. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12525. while (true) {
  12526. if (row > foldStart) {
  12527. row = foldLine.end.row+1;
  12528. foldLine = this.session.getNextFoldLine(row, foldLine);
  12529. foldStart = foldLine ? foldLine.start.row :Infinity;
  12530. }
  12531. if (row > last)
  12532. break;
  12533. var lineElement = lineElements[lineElementsIdx++];
  12534. if (lineElement) {
  12535. var html = [];
  12536. this.$renderLine(
  12537. html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
  12538. );
  12539. lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12540. lineElement.innerHTML = html.join("");
  12541. }
  12542. row++;
  12543. }
  12544. };
  12545. this.scrollLines = function(config) {
  12546. var oldConfig = this.config;
  12547. this.config = config;
  12548. if (!oldConfig || oldConfig.lastRow < config.firstRow)
  12549. return this.update(config);
  12550. if (config.lastRow < oldConfig.firstRow)
  12551. return this.update(config);
  12552. var el = this.element;
  12553. if (oldConfig.firstRow < config.firstRow)
  12554. for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
  12555. el.removeChild(el.firstChild);
  12556. if (oldConfig.lastRow > config.lastRow)
  12557. for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
  12558. el.removeChild(el.lastChild);
  12559. if (config.firstRow < oldConfig.firstRow) {
  12560. var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
  12561. if (el.firstChild)
  12562. el.insertBefore(fragment, el.firstChild);
  12563. else
  12564. el.appendChild(fragment);
  12565. }
  12566. if (config.lastRow > oldConfig.lastRow) {
  12567. var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
  12568. el.appendChild(fragment);
  12569. }
  12570. };
  12571. this.$renderLinesFragment = function(config, firstRow, lastRow) {
  12572. var fragment = this.element.ownerDocument.createDocumentFragment();
  12573. var row = firstRow;
  12574. var foldLine = this.session.getNextFoldLine(row);
  12575. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12576. while (true) {
  12577. if (row > foldStart) {
  12578. row = foldLine.end.row+1;
  12579. foldLine = this.session.getNextFoldLine(row, foldLine);
  12580. foldStart = foldLine ? foldLine.start.row : Infinity;
  12581. }
  12582. if (row > lastRow)
  12583. break;
  12584. var container = dom.createElement("div");
  12585. var html = [];
  12586. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12587. container.innerHTML = html.join("");
  12588. if (this.$useLineGroups()) {
  12589. container.className = 'ace_line_group';
  12590. fragment.appendChild(container);
  12591. container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
  12592. } else {
  12593. while(container.firstChild)
  12594. fragment.appendChild(container.firstChild);
  12595. }
  12596. row++;
  12597. }
  12598. return fragment;
  12599. };
  12600. this.update = function(config) {
  12601. this.config = config;
  12602. var html = [];
  12603. var firstRow = config.firstRow, lastRow = config.lastRow;
  12604. var row = firstRow;
  12605. var foldLine = this.session.getNextFoldLine(row);
  12606. var foldStart = foldLine ? foldLine.start.row : Infinity;
  12607. while (true) {
  12608. if (row > foldStart) {
  12609. row = foldLine.end.row+1;
  12610. foldLine = this.session.getNextFoldLine(row, foldLine);
  12611. foldStart = foldLine ? foldLine.start.row :Infinity;
  12612. }
  12613. if (row > lastRow)
  12614. break;
  12615. if (this.$useLineGroups())
  12616. html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>")
  12617. this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
  12618. if (this.$useLineGroups())
  12619. html.push("</div>"); // end the line group
  12620. row++;
  12621. }
  12622. this.element.innerHTML = html.join("");
  12623. };
  12624. this.$textToken = {
  12625. "text": true,
  12626. "rparen": true,
  12627. "lparen": true
  12628. };
  12629. this.$renderToken = function(stringBuilder, screenColumn, token, value) {
  12630. var self = this;
  12631. 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;
  12632. var replaceFunc = function(c, a, b, tabIdx, idx4) {
  12633. if (a) {
  12634. return self.showInvisibles
  12635. ? "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>"
  12636. : c;
  12637. } else if (c == "&") {
  12638. return "&#38;";
  12639. } else if (c == "<") {
  12640. return "&#60;";
  12641. } else if (c == ">") {
  12642. return "&#62;";
  12643. } else if (c == "\t") {
  12644. var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
  12645. screenColumn += tabSize - 1;
  12646. return self.$tabStrings[tabSize];
  12647. } else if (c == "\u3000") {
  12648. var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
  12649. var space = self.showInvisibles ? self.SPACE_CHAR : "";
  12650. screenColumn += 1;
  12651. return "<span class='" + classToUse + "' style='width:" +
  12652. (self.config.characterWidth * 2) +
  12653. "px'>" + space + "</span>";
  12654. } else if (b) {
  12655. return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
  12656. } else {
  12657. screenColumn += 1;
  12658. return "<span class='ace_cjk' style='width:" +
  12659. (self.config.characterWidth * 2) +
  12660. "px'>" + c + "</span>";
  12661. }
  12662. };
  12663. var output = value.replace(replaceReg, replaceFunc);
  12664. if (!this.$textToken[token.type]) {
  12665. var classes = "ace_" + token.type.replace(/\./g, " ace_");
  12666. var style = "";
  12667. if (token.type == "fold")
  12668. style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
  12669. stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
  12670. }
  12671. else {
  12672. stringBuilder.push(output);
  12673. }
  12674. return screenColumn + value.length;
  12675. };
  12676. this.renderIndentGuide = function(stringBuilder, value, max) {
  12677. var cols = value.search(this.$indentGuideRe);
  12678. if (cols <= 0 || cols >= max)
  12679. return value;
  12680. if (value[0] == " ") {
  12681. cols -= cols % this.tabSize;
  12682. stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
  12683. return value.substr(cols);
  12684. } else if (value[0] == "\t") {
  12685. stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
  12686. return value.substr(cols);
  12687. }
  12688. return value;
  12689. };
  12690. this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
  12691. var chars = 0;
  12692. var split = 0;
  12693. var splitChars = splits[0];
  12694. var screenColumn = 0;
  12695. for (var i = 0; i < tokens.length; i++) {
  12696. var token = tokens[i];
  12697. var value = token.value;
  12698. if (i == 0 && this.displayIndentGuides) {
  12699. chars = value.length;
  12700. value = this.renderIndentGuide(stringBuilder, value, splitChars);
  12701. if (!value)
  12702. continue;
  12703. chars -= value.length;
  12704. }
  12705. if (chars + value.length < splitChars) {
  12706. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12707. chars += value.length;
  12708. } else {
  12709. while (chars + value.length >= splitChars) {
  12710. screenColumn = this.$renderToken(
  12711. stringBuilder, screenColumn,
  12712. token, value.substring(0, splitChars - chars)
  12713. );
  12714. value = value.substring(splitChars - chars);
  12715. chars = splitChars;
  12716. if (!onlyContents) {
  12717. stringBuilder.push("</div>",
  12718. "<div class='ace_line' style='height:",
  12719. this.config.lineHeight, "px'>"
  12720. );
  12721. }
  12722. stringBuilder.push(lang.stringRepeat("\xa0", splits.indent));
  12723. split ++;
  12724. screenColumn = 0;
  12725. splitChars = splits[split] || Number.MAX_VALUE;
  12726. }
  12727. if (value.length != 0) {
  12728. chars += value.length;
  12729. screenColumn = this.$renderToken(
  12730. stringBuilder, screenColumn, token, value
  12731. );
  12732. }
  12733. }
  12734. }
  12735. };
  12736. this.$renderSimpleLine = function(stringBuilder, tokens) {
  12737. var screenColumn = 0;
  12738. var token = tokens[0];
  12739. var value = token.value;
  12740. if (this.displayIndentGuides)
  12741. value = this.renderIndentGuide(stringBuilder, value);
  12742. if (value)
  12743. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12744. for (var i = 1; i < tokens.length; i++) {
  12745. token = tokens[i];
  12746. value = token.value;
  12747. screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
  12748. }
  12749. };
  12750. this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
  12751. if (!foldLine && foldLine != false)
  12752. foldLine = this.session.getFoldLine(row);
  12753. if (foldLine)
  12754. var tokens = this.$getFoldLineTokens(row, foldLine);
  12755. else
  12756. var tokens = this.session.getTokens(row);
  12757. if (!onlyContents) {
  12758. stringBuilder.push(
  12759. "<div class='ace_line' style='height:",
  12760. this.config.lineHeight * (
  12761. this.$useLineGroups() ? 1 :this.session.getRowLength(row)
  12762. ), "px'>"
  12763. );
  12764. }
  12765. if (tokens.length) {
  12766. var splits = this.session.getRowSplitData(row);
  12767. if (splits && splits.length)
  12768. this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
  12769. else
  12770. this.$renderSimpleLine(stringBuilder, tokens);
  12771. }
  12772. if (this.showInvisibles) {
  12773. if (foldLine)
  12774. row = foldLine.end.row
  12775. stringBuilder.push(
  12776. "<span class='ace_invisible ace_invisible_eol'>",
  12777. row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
  12778. "</span>"
  12779. );
  12780. }
  12781. if (!onlyContents)
  12782. stringBuilder.push("</div>");
  12783. };
  12784. this.$getFoldLineTokens = function(row, foldLine) {
  12785. var session = this.session;
  12786. var renderTokens = [];
  12787. function addTokens(tokens, from, to) {
  12788. var idx = 0, col = 0;
  12789. while ((col + tokens[idx].value.length) < from) {
  12790. col += tokens[idx].value.length;
  12791. idx++;
  12792. if (idx == tokens.length)
  12793. return;
  12794. }
  12795. if (col != from) {
  12796. var value = tokens[idx].value.substring(from - col);
  12797. if (value.length > (to - from))
  12798. value = value.substring(0, to - from);
  12799. renderTokens.push({
  12800. type: tokens[idx].type,
  12801. value: value
  12802. });
  12803. col = from + value.length;
  12804. idx += 1;
  12805. }
  12806. while (col < to && idx < tokens.length) {
  12807. var value = tokens[idx].value;
  12808. if (value.length + col > to) {
  12809. renderTokens.push({
  12810. type: tokens[idx].type,
  12811. value: value.substring(0, to - col)
  12812. });
  12813. } else
  12814. renderTokens.push(tokens[idx]);
  12815. col += value.length;
  12816. idx += 1;
  12817. }
  12818. }
  12819. var tokens = session.getTokens(row);
  12820. foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
  12821. if (placeholder != null) {
  12822. renderTokens.push({
  12823. type: "fold",
  12824. value: placeholder
  12825. });
  12826. } else {
  12827. if (isNewRow)
  12828. tokens = session.getTokens(row);
  12829. if (tokens.length)
  12830. addTokens(tokens, lastColumn, column);
  12831. }
  12832. }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
  12833. return renderTokens;
  12834. };
  12835. this.$useLineGroups = function() {
  12836. return this.session.getUseWrapMode();
  12837. };
  12838. this.destroy = function() {
  12839. clearInterval(this.$pollSizeChangesTimer);
  12840. if (this.$measureNode)
  12841. this.$measureNode.parentNode.removeChild(this.$measureNode);
  12842. delete this.$measureNode;
  12843. };
  12844. }).call(Text.prototype);
  12845. exports.Text = Text;
  12846. });
  12847. ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  12848. "use strict";
  12849. var dom = require("../lib/dom");
  12850. var isIE8;
  12851. var Cursor = function(parentEl) {
  12852. this.element = dom.createElement("div");
  12853. this.element.className = "ace_layer ace_cursor-layer";
  12854. parentEl.appendChild(this.element);
  12855. if (isIE8 === undefined)
  12856. isIE8 = !("opacity" in this.element.style);
  12857. this.isVisible = false;
  12858. this.isBlinking = true;
  12859. this.blinkInterval = 1000;
  12860. this.smoothBlinking = false;
  12861. this.cursors = [];
  12862. this.cursor = this.addCursor();
  12863. dom.addCssClass(this.element, "ace_hidden-cursors");
  12864. this.$updateCursors = (isIE8
  12865. ? this.$updateVisibility
  12866. : this.$updateOpacity).bind(this);
  12867. };
  12868. (function() {
  12869. this.$updateVisibility = function(val) {
  12870. var cursors = this.cursors;
  12871. for (var i = cursors.length; i--; )
  12872. cursors[i].style.visibility = val ? "" : "hidden";
  12873. };
  12874. this.$updateOpacity = function(val) {
  12875. var cursors = this.cursors;
  12876. for (var i = cursors.length; i--; )
  12877. cursors[i].style.opacity = val ? "" : "0";
  12878. };
  12879. this.$padding = 0;
  12880. this.setPadding = function(padding) {
  12881. this.$padding = padding;
  12882. };
  12883. this.setSession = function(session) {
  12884. this.session = session;
  12885. };
  12886. this.setBlinking = function(blinking) {
  12887. if (blinking != this.isBlinking){
  12888. this.isBlinking = blinking;
  12889. this.restartTimer();
  12890. }
  12891. };
  12892. this.setBlinkInterval = function(blinkInterval) {
  12893. if (blinkInterval != this.blinkInterval){
  12894. this.blinkInterval = blinkInterval;
  12895. this.restartTimer();
  12896. }
  12897. };
  12898. this.setSmoothBlinking = function(smoothBlinking) {
  12899. if (smoothBlinking != this.smoothBlinking && !isIE8) {
  12900. this.smoothBlinking = smoothBlinking;
  12901. dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
  12902. this.$updateCursors(true);
  12903. this.$updateCursors = (this.$updateOpacity).bind(this);
  12904. this.restartTimer();
  12905. }
  12906. };
  12907. this.addCursor = function() {
  12908. var el = dom.createElement("div");
  12909. el.className = "ace_cursor";
  12910. this.element.appendChild(el);
  12911. this.cursors.push(el);
  12912. return el;
  12913. };
  12914. this.removeCursor = function() {
  12915. if (this.cursors.length > 1) {
  12916. var el = this.cursors.pop();
  12917. el.parentNode.removeChild(el);
  12918. return el;
  12919. }
  12920. };
  12921. this.hideCursor = function() {
  12922. this.isVisible = false;
  12923. dom.addCssClass(this.element, "ace_hidden-cursors");
  12924. this.restartTimer();
  12925. };
  12926. this.showCursor = function() {
  12927. this.isVisible = true;
  12928. dom.removeCssClass(this.element, "ace_hidden-cursors");
  12929. this.restartTimer();
  12930. };
  12931. this.restartTimer = function() {
  12932. var update = this.$updateCursors;
  12933. clearInterval(this.intervalId);
  12934. clearTimeout(this.timeoutId);
  12935. if (this.smoothBlinking) {
  12936. dom.removeCssClass(this.element, "ace_smooth-blinking");
  12937. }
  12938. update(true);
  12939. if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
  12940. return;
  12941. if (this.smoothBlinking) {
  12942. setTimeout(function(){
  12943. dom.addCssClass(this.element, "ace_smooth-blinking");
  12944. }.bind(this));
  12945. }
  12946. var blink = function(){
  12947. this.timeoutId = setTimeout(function() {
  12948. update(false);
  12949. }, 0.6 * this.blinkInterval);
  12950. }.bind(this);
  12951. this.intervalId = setInterval(function() {
  12952. update(true);
  12953. blink();
  12954. }, this.blinkInterval);
  12955. blink();
  12956. };
  12957. this.getPixelPosition = function(position, onScreen) {
  12958. if (!this.config || !this.session)
  12959. return {left : 0, top : 0};
  12960. if (!position)
  12961. position = this.session.selection.getCursor();
  12962. var pos = this.session.documentToScreenPosition(position);
  12963. var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
  12964. var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
  12965. this.config.lineHeight;
  12966. return {left : cursorLeft, top : cursorTop};
  12967. };
  12968. this.update = function(config) {
  12969. this.config = config;
  12970. var selections = this.session.$selectionMarkers;
  12971. var i = 0, cursorIndex = 0;
  12972. if (selections === undefined || selections.length === 0){
  12973. selections = [{cursor: null}];
  12974. }
  12975. for (var i = 0, n = selections.length; i < n; i++) {
  12976. var pixelPos = this.getPixelPosition(selections[i].cursor, true);
  12977. if ((pixelPos.top > config.height + config.offset ||
  12978. pixelPos.top < 0) && i > 1) {
  12979. continue;
  12980. }
  12981. var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
  12982. if (!this.drawCursor) {
  12983. style.left = pixelPos.left + "px";
  12984. style.top = pixelPos.top + "px";
  12985. style.width = config.characterWidth + "px";
  12986. style.height = config.lineHeight + "px";
  12987. } else {
  12988. this.drawCursor(style, pixelPos, config, selections[i], this.session);
  12989. }
  12990. }
  12991. while (this.cursors.length > cursorIndex)
  12992. this.removeCursor();
  12993. var overwrite = this.session.getOverwrite();
  12994. this.$setOverwrite(overwrite);
  12995. this.$pixelPos = pixelPos;
  12996. this.restartTimer();
  12997. };
  12998. this.drawCursor = null;
  12999. this.$setOverwrite = function(overwrite) {
  13000. if (overwrite != this.overwrite) {
  13001. this.overwrite = overwrite;
  13002. if (overwrite)
  13003. dom.addCssClass(this.element, "ace_overwrite-cursors");
  13004. else
  13005. dom.removeCssClass(this.element, "ace_overwrite-cursors");
  13006. }
  13007. };
  13008. this.destroy = function() {
  13009. clearInterval(this.intervalId);
  13010. clearTimeout(this.timeoutId);
  13011. };
  13012. }).call(Cursor.prototype);
  13013. exports.Cursor = Cursor;
  13014. });
  13015. ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
  13016. "use strict";
  13017. var oop = require("./lib/oop");
  13018. var dom = require("./lib/dom");
  13019. var event = require("./lib/event");
  13020. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  13021. var MAX_SCROLL_H = 0x8000;
  13022. var ScrollBar = function(parent) {
  13023. this.element = dom.createElement("div");
  13024. this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
  13025. this.inner = dom.createElement("div");
  13026. this.inner.className = "ace_scrollbar-inner";
  13027. this.element.appendChild(this.inner);
  13028. parent.appendChild(this.element);
  13029. this.setVisible(false);
  13030. this.skipEvent = false;
  13031. event.addListener(this.element, "scroll", this.onScroll.bind(this));
  13032. event.addListener(this.element, "mousedown", event.preventDefault);
  13033. };
  13034. (function() {
  13035. oop.implement(this, EventEmitter);
  13036. this.setVisible = function(isVisible) {
  13037. this.element.style.display = isVisible ? "" : "none";
  13038. this.isVisible = isVisible;
  13039. this.coeff = 1;
  13040. };
  13041. }).call(ScrollBar.prototype);
  13042. var VScrollBar = function(parent, renderer) {
  13043. ScrollBar.call(this, parent);
  13044. this.scrollTop = 0;
  13045. this.scrollHeight = 0;
  13046. renderer.$scrollbarWidth =
  13047. this.width = dom.scrollbarWidth(parent.ownerDocument);
  13048. this.inner.style.width =
  13049. this.element.style.width = (this.width || 15) + 5 + "px";
  13050. };
  13051. oop.inherits(VScrollBar, ScrollBar);
  13052. (function() {
  13053. this.classSuffix = '-v';
  13054. this.onScroll = function() {
  13055. if (!this.skipEvent) {
  13056. this.scrollTop = this.element.scrollTop;
  13057. if (this.coeff != 1) {
  13058. var h = this.element.clientHeight / this.scrollHeight;
  13059. this.scrollTop = this.scrollTop * (1 - h) / (this.coeff - h);
  13060. }
  13061. this._emit("scroll", {data: this.scrollTop});
  13062. }
  13063. this.skipEvent = false;
  13064. };
  13065. this.getWidth = function() {
  13066. return this.isVisible ? this.width : 0;
  13067. };
  13068. this.setHeight = function(height) {
  13069. this.element.style.height = height + "px";
  13070. };
  13071. this.setInnerHeight =
  13072. this.setScrollHeight = function(height) {
  13073. this.scrollHeight = height;
  13074. if (height > MAX_SCROLL_H) {
  13075. this.coeff = MAX_SCROLL_H / height;
  13076. height = MAX_SCROLL_H;
  13077. } else if (this.coeff != 1) {
  13078. this.coeff = 1
  13079. }
  13080. this.inner.style.height = height + "px";
  13081. };
  13082. this.setScrollTop = function(scrollTop) {
  13083. if (this.scrollTop != scrollTop) {
  13084. this.skipEvent = true;
  13085. this.scrollTop = scrollTop;
  13086. this.element.scrollTop = scrollTop * this.coeff;
  13087. }
  13088. };
  13089. }).call(VScrollBar.prototype);
  13090. var HScrollBar = function(parent, renderer) {
  13091. ScrollBar.call(this, parent);
  13092. this.scrollLeft = 0;
  13093. this.height = renderer.$scrollbarWidth;
  13094. this.inner.style.height =
  13095. this.element.style.height = (this.height || 15) + 5 + "px";
  13096. };
  13097. oop.inherits(HScrollBar, ScrollBar);
  13098. (function() {
  13099. this.classSuffix = '-h';
  13100. this.onScroll = function() {
  13101. if (!this.skipEvent) {
  13102. this.scrollLeft = this.element.scrollLeft;
  13103. this._emit("scroll", {data: this.scrollLeft});
  13104. }
  13105. this.skipEvent = false;
  13106. };
  13107. this.getHeight = function() {
  13108. return this.isVisible ? this.height : 0;
  13109. };
  13110. this.setWidth = function(width) {
  13111. this.element.style.width = width + "px";
  13112. };
  13113. this.setInnerWidth = function(width) {
  13114. this.inner.style.width = width + "px";
  13115. };
  13116. this.setScrollWidth = function(width) {
  13117. this.inner.style.width = width + "px";
  13118. };
  13119. this.setScrollLeft = function(scrollLeft) {
  13120. if (this.scrollLeft != scrollLeft) {
  13121. this.skipEvent = true;
  13122. this.scrollLeft = this.element.scrollLeft = scrollLeft;
  13123. }
  13124. };
  13125. }).call(HScrollBar.prototype);
  13126. exports.ScrollBar = VScrollBar; // backward compatibility
  13127. exports.ScrollBarV = VScrollBar; // backward compatibility
  13128. exports.ScrollBarH = HScrollBar; // backward compatibility
  13129. exports.VScrollBar = VScrollBar;
  13130. exports.HScrollBar = HScrollBar;
  13131. });
  13132. ace.define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
  13133. "use strict";
  13134. var event = require("./lib/event");
  13135. var RenderLoop = function(onRender, win) {
  13136. this.onRender = onRender;
  13137. this.pending = false;
  13138. this.changes = 0;
  13139. this.window = win || window;
  13140. };
  13141. (function() {
  13142. this.schedule = function(change) {
  13143. this.changes = this.changes | change;
  13144. if (!this.pending && this.changes) {
  13145. this.pending = true;
  13146. var _self = this;
  13147. event.nextFrame(function() {
  13148. _self.pending = false;
  13149. var changes;
  13150. while (changes = _self.changes) {
  13151. _self.changes = 0;
  13152. _self.onRender(changes);
  13153. }
  13154. }, this.window);
  13155. }
  13156. };
  13157. }).call(RenderLoop.prototype);
  13158. exports.RenderLoop = RenderLoop;
  13159. });
  13160. 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) {
  13161. var oop = require("../lib/oop");
  13162. var dom = require("../lib/dom");
  13163. var lang = require("../lib/lang");
  13164. var useragent = require("../lib/useragent");
  13165. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  13166. var CHAR_COUNT = 0;
  13167. var FontMetrics = exports.FontMetrics = function(parentEl) {
  13168. this.el = dom.createElement("div");
  13169. this.$setMeasureNodeStyles(this.el.style, true);
  13170. this.$main = dom.createElement("div");
  13171. this.$setMeasureNodeStyles(this.$main.style);
  13172. this.$measureNode = dom.createElement("div");
  13173. this.$setMeasureNodeStyles(this.$measureNode.style);
  13174. this.el.appendChild(this.$main);
  13175. this.el.appendChild(this.$measureNode);
  13176. parentEl.appendChild(this.el);
  13177. if (!CHAR_COUNT)
  13178. this.$testFractionalRect();
  13179. this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
  13180. this.$characterSize = {width: 0, height: 0};
  13181. this.checkForSizeChanges();
  13182. };
  13183. (function() {
  13184. oop.implement(this, EventEmitter);
  13185. this.$characterSize = {width: 0, height: 0};
  13186. this.$testFractionalRect = function() {
  13187. var el = dom.createElement("div");
  13188. this.$setMeasureNodeStyles(el.style);
  13189. el.style.width = "0.2px";
  13190. document.documentElement.appendChild(el);
  13191. var w = el.getBoundingClientRect().width;
  13192. if (w > 0 && w < 1)
  13193. CHAR_COUNT = 50;
  13194. else
  13195. CHAR_COUNT = 100;
  13196. el.parentNode.removeChild(el);
  13197. };
  13198. this.$setMeasureNodeStyles = function(style, isRoot) {
  13199. style.width = style.height = "auto";
  13200. style.left = style.top = "0px";
  13201. style.visibility = "hidden";
  13202. style.position = "absolute";
  13203. style.whiteSpace = "pre";
  13204. if (useragent.isIE < 8) {
  13205. style["font-family"] = "inherit";
  13206. } else {
  13207. style.font = "inherit";
  13208. }
  13209. style.overflow = isRoot ? "hidden" : "visible";
  13210. };
  13211. this.checkForSizeChanges = function() {
  13212. var size = this.$measureSizes();
  13213. if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
  13214. this.$measureNode.style.fontWeight = "bold";
  13215. var boldSize = this.$measureSizes();
  13216. this.$measureNode.style.fontWeight = "";
  13217. this.$characterSize = size;
  13218. this.charSizes = Object.create(null);
  13219. this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
  13220. this._emit("changeCharacterSize", {data: size});
  13221. }
  13222. };
  13223. this.$pollSizeChanges = function() {
  13224. if (this.$pollSizeChangesTimer)
  13225. return this.$pollSizeChangesTimer;
  13226. var self = this;
  13227. return this.$pollSizeChangesTimer = setInterval(function() {
  13228. self.checkForSizeChanges();
  13229. }, 500);
  13230. };
  13231. this.setPolling = function(val) {
  13232. if (val) {
  13233. this.$pollSizeChanges();
  13234. } else if (this.$pollSizeChangesTimer) {
  13235. clearInterval(this.$pollSizeChangesTimer);
  13236. this.$pollSizeChangesTimer = 0;
  13237. }
  13238. };
  13239. this.$measureSizes = function() {
  13240. if (CHAR_COUNT === 50) {
  13241. var rect = null;
  13242. try {
  13243. rect = this.$measureNode.getBoundingClientRect();
  13244. } catch(e) {
  13245. rect = {width: 0, height:0 };
  13246. }
  13247. var size = {
  13248. height: rect.height,
  13249. width: rect.width / CHAR_COUNT
  13250. };
  13251. } else {
  13252. var size = {
  13253. height: this.$measureNode.clientHeight,
  13254. width: this.$measureNode.clientWidth / CHAR_COUNT
  13255. };
  13256. }
  13257. if (size.width === 0 || size.height === 0)
  13258. return null;
  13259. return size;
  13260. };
  13261. this.$measureCharWidth = function(ch) {
  13262. this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
  13263. var rect = this.$main.getBoundingClientRect();
  13264. return rect.width / CHAR_COUNT;
  13265. };
  13266. this.getCharacterWidth = function(ch) {
  13267. var w = this.charSizes[ch];
  13268. if (w === undefined) {
  13269. w = this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
  13270. }
  13271. return w;
  13272. };
  13273. this.destroy = function() {
  13274. clearInterval(this.$pollSizeChangesTimer);
  13275. if (this.el && this.el.parentNode)
  13276. this.el.parentNode.removeChild(this.el);
  13277. };
  13278. }).call(FontMetrics.prototype);
  13279. });
  13280. 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) {
  13281. "use strict";
  13282. var oop = require("./lib/oop");
  13283. var dom = require("./lib/dom");
  13284. var config = require("./config");
  13285. var useragent = require("./lib/useragent");
  13286. var GutterLayer = require("./layer/gutter").Gutter;
  13287. var MarkerLayer = require("./layer/marker").Marker;
  13288. var TextLayer = require("./layer/text").Text;
  13289. var CursorLayer = require("./layer/cursor").Cursor;
  13290. var HScrollBar = require("./scrollbar").HScrollBar;
  13291. var VScrollBar = require("./scrollbar").VScrollBar;
  13292. var RenderLoop = require("./renderloop").RenderLoop;
  13293. var FontMetrics = require("./layer/font_metrics").FontMetrics;
  13294. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  13295. var editorCss = ".ace_editor {\
  13296. position: relative;\
  13297. overflow: hidden;\
  13298. font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
  13299. direction: ltr;\
  13300. text-align: left;\
  13301. }\
  13302. .ace_scroller {\
  13303. position: absolute;\
  13304. overflow: hidden;\
  13305. top: 0;\
  13306. bottom: 0;\
  13307. background-color: inherit;\
  13308. -ms-user-select: none;\
  13309. -moz-user-select: none;\
  13310. -webkit-user-select: none;\
  13311. user-select: none;\
  13312. cursor: text;\
  13313. }\
  13314. .ace_content {\
  13315. position: absolute;\
  13316. -moz-box-sizing: border-box;\
  13317. -webkit-box-sizing: border-box;\
  13318. box-sizing: border-box;\
  13319. min-width: 100%;\
  13320. }\
  13321. .ace_dragging .ace_scroller:before{\
  13322. position: absolute;\
  13323. top: 0;\
  13324. left: 0;\
  13325. right: 0;\
  13326. bottom: 0;\
  13327. content: '';\
  13328. background: rgba(250, 250, 250, 0.01);\
  13329. z-index: 1000;\
  13330. }\
  13331. .ace_dragging.ace_dark .ace_scroller:before{\
  13332. background: rgba(0, 0, 0, 0.01);\
  13333. }\
  13334. .ace_selecting, .ace_selecting * {\
  13335. cursor: text !important;\
  13336. }\
  13337. .ace_gutter {\
  13338. position: absolute;\
  13339. overflow : hidden;\
  13340. width: auto;\
  13341. top: 0;\
  13342. bottom: 0;\
  13343. left: 0;\
  13344. cursor: default;\
  13345. z-index: 4;\
  13346. -ms-user-select: none;\
  13347. -moz-user-select: none;\
  13348. -webkit-user-select: none;\
  13349. user-select: none;\
  13350. }\
  13351. .ace_gutter-active-line {\
  13352. position: absolute;\
  13353. left: 0;\
  13354. right: 0;\
  13355. }\
  13356. .ace_scroller.ace_scroll-left {\
  13357. box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
  13358. }\
  13359. .ace_gutter-cell {\
  13360. padding-left: 19px;\
  13361. padding-right: 6px;\
  13362. background-repeat: no-repeat;\
  13363. }\
  13364. .ace_gutter-cell.ace_error {\
  13365. 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==\");\
  13366. background-repeat: no-repeat;\
  13367. background-position: 2px center;\
  13368. }\
  13369. .ace_gutter-cell.ace_warning {\
  13370. 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==\");\
  13371. background-position: 2px center;\
  13372. }\
  13373. .ace_gutter-cell.ace_info {\
  13374. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
  13375. background-position: 2px center;\
  13376. }\
  13377. .ace_dark .ace_gutter-cell.ace_info {\
  13378. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
  13379. }\
  13380. .ace_scrollbar {\
  13381. position: absolute;\
  13382. right: 0;\
  13383. bottom: 0;\
  13384. z-index: 6;\
  13385. }\
  13386. .ace_scrollbar-inner {\
  13387. position: absolute;\
  13388. cursor: text;\
  13389. left: 0;\
  13390. top: 0;\
  13391. }\
  13392. .ace_scrollbar-v{\
  13393. overflow-x: hidden;\
  13394. overflow-y: scroll;\
  13395. top: 0;\
  13396. }\
  13397. .ace_scrollbar-h {\
  13398. overflow-x: scroll;\
  13399. overflow-y: hidden;\
  13400. left: 0;\
  13401. }\
  13402. .ace_print-margin {\
  13403. position: absolute;\
  13404. height: 100%;\
  13405. }\
  13406. .ace_text-input {\
  13407. position: absolute;\
  13408. z-index: 0;\
  13409. width: 0.5em;\
  13410. height: 1em;\
  13411. opacity: 0;\
  13412. background: transparent;\
  13413. -moz-appearance: none;\
  13414. appearance: none;\
  13415. border: none;\
  13416. resize: none;\
  13417. outline: none;\
  13418. overflow: hidden;\
  13419. font: inherit;\
  13420. padding: 0 1px;\
  13421. margin: 0 -1px;\
  13422. text-indent: -1em;\
  13423. -ms-user-select: text;\
  13424. -moz-user-select: text;\
  13425. -webkit-user-select: text;\
  13426. user-select: text;\
  13427. white-space: pre!important;\
  13428. }\
  13429. .ace_text-input.ace_composition {\
  13430. background: inherit;\
  13431. color: inherit;\
  13432. z-index: 1000;\
  13433. opacity: 1;\
  13434. text-indent: 0;\
  13435. }\
  13436. .ace_layer {\
  13437. z-index: 1;\
  13438. position: absolute;\
  13439. overflow: hidden;\
  13440. word-wrap: normal;\
  13441. white-space: pre;\
  13442. height: 100%;\
  13443. width: 100%;\
  13444. -moz-box-sizing: border-box;\
  13445. -webkit-box-sizing: border-box;\
  13446. box-sizing: border-box;\
  13447. pointer-events: none;\
  13448. }\
  13449. .ace_gutter-layer {\
  13450. position: relative;\
  13451. width: auto;\
  13452. text-align: right;\
  13453. pointer-events: auto;\
  13454. }\
  13455. .ace_text-layer {\
  13456. font: inherit !important;\
  13457. }\
  13458. .ace_cjk {\
  13459. display: inline-block;\
  13460. text-align: center;\
  13461. }\
  13462. .ace_cursor-layer {\
  13463. z-index: 4;\
  13464. }\
  13465. .ace_cursor {\
  13466. z-index: 4;\
  13467. position: absolute;\
  13468. -moz-box-sizing: border-box;\
  13469. -webkit-box-sizing: border-box;\
  13470. box-sizing: border-box;\
  13471. border-left: 2px solid;\
  13472. transform: translatez(0);\
  13473. }\
  13474. .ace_slim-cursors .ace_cursor {\
  13475. border-left-width: 1px;\
  13476. }\
  13477. .ace_overwrite-cursors .ace_cursor {\
  13478. border-left-width: 0;\
  13479. border-bottom: 1px solid;\
  13480. }\
  13481. .ace_hidden-cursors .ace_cursor {\
  13482. opacity: 0.2;\
  13483. }\
  13484. .ace_smooth-blinking .ace_cursor {\
  13485. -webkit-transition: opacity 0.18s;\
  13486. transition: opacity 0.18s;\
  13487. }\
  13488. .ace_editor.ace_multiselect .ace_cursor {\
  13489. border-left-width: 1px;\
  13490. }\
  13491. .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
  13492. position: absolute;\
  13493. z-index: 3;\
  13494. }\
  13495. .ace_marker-layer .ace_selection {\
  13496. position: absolute;\
  13497. z-index: 5;\
  13498. }\
  13499. .ace_marker-layer .ace_bracket {\
  13500. position: absolute;\
  13501. z-index: 6;\
  13502. }\
  13503. .ace_marker-layer .ace_active-line {\
  13504. position: absolute;\
  13505. z-index: 2;\
  13506. }\
  13507. .ace_marker-layer .ace_selected-word {\
  13508. position: absolute;\
  13509. z-index: 4;\
  13510. -moz-box-sizing: border-box;\
  13511. -webkit-box-sizing: border-box;\
  13512. box-sizing: border-box;\
  13513. }\
  13514. .ace_line .ace_fold {\
  13515. -moz-box-sizing: border-box;\
  13516. -webkit-box-sizing: border-box;\
  13517. box-sizing: border-box;\
  13518. display: inline-block;\
  13519. height: 11px;\
  13520. margin-top: -2px;\
  13521. vertical-align: middle;\
  13522. background-image:\
  13523. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13524. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
  13525. background-repeat: no-repeat, repeat-x;\
  13526. background-position: center center, top left;\
  13527. color: transparent;\
  13528. border: 1px solid black;\
  13529. border-radius: 2px;\
  13530. cursor: pointer;\
  13531. pointer-events: auto;\
  13532. }\
  13533. .ace_dark .ace_fold {\
  13534. }\
  13535. .ace_fold:hover{\
  13536. background-image:\
  13537. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
  13538. url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
  13539. }\
  13540. .ace_tooltip {\
  13541. background-color: #FFF;\
  13542. background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
  13543. background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
  13544. border: 1px solid gray;\
  13545. border-radius: 1px;\
  13546. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
  13547. color: black;\
  13548. max-width: 100%;\
  13549. padding: 3px 4px;\
  13550. position: fixed;\
  13551. z-index: 999999;\
  13552. -moz-box-sizing: border-box;\
  13553. -webkit-box-sizing: border-box;\
  13554. box-sizing: border-box;\
  13555. cursor: default;\
  13556. white-space: pre;\
  13557. word-wrap: break-word;\
  13558. line-height: normal;\
  13559. font-style: normal;\
  13560. font-weight: normal;\
  13561. letter-spacing: normal;\
  13562. pointer-events: none;\
  13563. }\
  13564. .ace_folding-enabled > .ace_gutter-cell {\
  13565. padding-right: 13px;\
  13566. }\
  13567. .ace_fold-widget {\
  13568. -moz-box-sizing: border-box;\
  13569. -webkit-box-sizing: border-box;\
  13570. box-sizing: border-box;\
  13571. margin: 0 -12px 0 1px;\
  13572. display: none;\
  13573. width: 11px;\
  13574. vertical-align: top;\
  13575. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
  13576. background-repeat: no-repeat;\
  13577. background-position: center;\
  13578. border-radius: 3px;\
  13579. border: 1px solid transparent;\
  13580. cursor: pointer;\
  13581. }\
  13582. .ace_folding-enabled .ace_fold-widget {\
  13583. display: inline-block; \
  13584. }\
  13585. .ace_fold-widget.ace_end {\
  13586. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
  13587. }\
  13588. .ace_fold-widget.ace_closed {\
  13589. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
  13590. }\
  13591. .ace_fold-widget:hover {\
  13592. border: 1px solid rgba(0, 0, 0, 0.3);\
  13593. background-color: rgba(255, 255, 255, 0.2);\
  13594. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
  13595. }\
  13596. .ace_fold-widget:active {\
  13597. border: 1px solid rgba(0, 0, 0, 0.4);\
  13598. background-color: rgba(0, 0, 0, 0.05);\
  13599. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
  13600. }\
  13601. .ace_dark .ace_fold-widget {\
  13602. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
  13603. }\
  13604. .ace_dark .ace_fold-widget.ace_end {\
  13605. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
  13606. }\
  13607. .ace_dark .ace_fold-widget.ace_closed {\
  13608. background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
  13609. }\
  13610. .ace_dark .ace_fold-widget:hover {\
  13611. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13612. background-color: rgba(255, 255, 255, 0.1);\
  13613. }\
  13614. .ace_dark .ace_fold-widget:active {\
  13615. box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
  13616. }\
  13617. .ace_fold-widget.ace_invalid {\
  13618. background-color: #FFB4B4;\
  13619. border-color: #DE5555;\
  13620. }\
  13621. .ace_fade-fold-widgets .ace_fold-widget {\
  13622. -webkit-transition: opacity 0.4s ease 0.05s;\
  13623. transition: opacity 0.4s ease 0.05s;\
  13624. opacity: 0;\
  13625. }\
  13626. .ace_fade-fold-widgets:hover .ace_fold-widget {\
  13627. -webkit-transition: opacity 0.05s ease 0.05s;\
  13628. transition: opacity 0.05s ease 0.05s;\
  13629. opacity:1;\
  13630. }\
  13631. .ace_underline {\
  13632. text-decoration: underline;\
  13633. }\
  13634. .ace_bold {\
  13635. font-weight: bold;\
  13636. }\
  13637. .ace_nobold .ace_bold {\
  13638. font-weight: normal;\
  13639. }\
  13640. .ace_italic {\
  13641. font-style: italic;\
  13642. }\
  13643. .ace_error-marker {\
  13644. background-color: rgba(255, 0, 0,0.2);\
  13645. position: absolute;\
  13646. z-index: 9;\
  13647. }\
  13648. .ace_highlight-marker {\
  13649. background-color: rgba(255, 255, 0,0.2);\
  13650. position: absolute;\
  13651. z-index: 8;\
  13652. }\
  13653. .ace_br1 {border-top-left-radius : 3px;}\
  13654. .ace_br2 {border-top-right-radius : 3px;}\
  13655. .ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\
  13656. .ace_br4 {border-bottom-right-radius: 3px;}\
  13657. .ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\
  13658. .ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\
  13659. .ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\
  13660. .ace_br8 {border-bottom-left-radius : 3px;}\
  13661. .ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\
  13662. .ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\
  13663. .ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13664. .ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13665. .ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13666. .ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13667. .ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
  13668. ";
  13669. dom.importCssString(editorCss, "ace_editor.css");
  13670. var VirtualRenderer = function(container, theme) {
  13671. var _self = this;
  13672. this.container = container || dom.createElement("div");
  13673. this.$keepTextAreaAtCursor = !useragent.isOldIE;
  13674. dom.addCssClass(this.container, "ace_editor");
  13675. this.setTheme(theme);
  13676. this.$gutter = dom.createElement("div");
  13677. this.$gutter.className = "ace_gutter";
  13678. this.container.appendChild(this.$gutter);
  13679. this.scroller = dom.createElement("div");
  13680. this.scroller.className = "ace_scroller";
  13681. this.container.appendChild(this.scroller);
  13682. this.content = dom.createElement("div");
  13683. this.content.className = "ace_content";
  13684. this.scroller.appendChild(this.content);
  13685. this.$gutterLayer = new GutterLayer(this.$gutter);
  13686. this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
  13687. this.$markerBack = new MarkerLayer(this.content);
  13688. var textLayer = this.$textLayer = new TextLayer(this.content);
  13689. this.canvas = textLayer.element;
  13690. this.$markerFront = new MarkerLayer(this.content);
  13691. this.$cursorLayer = new CursorLayer(this.content);
  13692. this.$horizScroll = false;
  13693. this.$vScroll = false;
  13694. this.scrollBar =
  13695. this.scrollBarV = new VScrollBar(this.container, this);
  13696. this.scrollBarH = new HScrollBar(this.container, this);
  13697. this.scrollBarV.addEventListener("scroll", function(e) {
  13698. if (!_self.$scrollAnimation)
  13699. _self.session.setScrollTop(e.data - _self.scrollMargin.top);
  13700. });
  13701. this.scrollBarH.addEventListener("scroll", function(e) {
  13702. if (!_self.$scrollAnimation)
  13703. _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
  13704. });
  13705. this.scrollTop = 0;
  13706. this.scrollLeft = 0;
  13707. this.cursorPos = {
  13708. row : 0,
  13709. column : 0
  13710. };
  13711. this.$fontMetrics = new FontMetrics(this.container);
  13712. this.$textLayer.$setFontMetrics(this.$fontMetrics);
  13713. this.$textLayer.addEventListener("changeCharacterSize", function(e) {
  13714. _self.updateCharacterSize();
  13715. _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
  13716. _self._signal("changeCharacterSize", e);
  13717. });
  13718. this.$size = {
  13719. width: 0,
  13720. height: 0,
  13721. scrollerHeight: 0,
  13722. scrollerWidth: 0,
  13723. $dirty: true
  13724. };
  13725. this.layerConfig = {
  13726. width : 1,
  13727. padding : 0,
  13728. firstRow : 0,
  13729. firstRowScreen: 0,
  13730. lastRow : 0,
  13731. lineHeight : 0,
  13732. characterWidth : 0,
  13733. minHeight : 1,
  13734. maxHeight : 1,
  13735. offset : 0,
  13736. height : 1,
  13737. gutterOffset: 1
  13738. };
  13739. this.scrollMargin = {
  13740. left: 0,
  13741. right: 0,
  13742. top: 0,
  13743. bottom: 0,
  13744. v: 0,
  13745. h: 0
  13746. };
  13747. this.$loop = new RenderLoop(
  13748. this.$renderChanges.bind(this),
  13749. this.container.ownerDocument.defaultView
  13750. );
  13751. this.$loop.schedule(this.CHANGE_FULL);
  13752. this.updateCharacterSize();
  13753. this.setPadding(4);
  13754. config.resetOptions(this);
  13755. config._emit("renderer", this);
  13756. };
  13757. (function() {
  13758. this.CHANGE_CURSOR = 1;
  13759. this.CHANGE_MARKER = 2;
  13760. this.CHANGE_GUTTER = 4;
  13761. this.CHANGE_SCROLL = 8;
  13762. this.CHANGE_LINES = 16;
  13763. this.CHANGE_TEXT = 32;
  13764. this.CHANGE_SIZE = 64;
  13765. this.CHANGE_MARKER_BACK = 128;
  13766. this.CHANGE_MARKER_FRONT = 256;
  13767. this.CHANGE_FULL = 512;
  13768. this.CHANGE_H_SCROLL = 1024;
  13769. oop.implement(this, EventEmitter);
  13770. this.updateCharacterSize = function() {
  13771. if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
  13772. this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
  13773. this.setStyle("ace_nobold", !this.$allowBoldFonts);
  13774. }
  13775. this.layerConfig.characterWidth =
  13776. this.characterWidth = this.$textLayer.getCharacterWidth();
  13777. this.layerConfig.lineHeight =
  13778. this.lineHeight = this.$textLayer.getLineHeight();
  13779. this.$updatePrintMargin();
  13780. };
  13781. this.setSession = function(session) {
  13782. if (this.session)
  13783. this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
  13784. this.session = session;
  13785. if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
  13786. session.setScrollTop(-this.scrollMargin.top);
  13787. this.$cursorLayer.setSession(session);
  13788. this.$markerBack.setSession(session);
  13789. this.$markerFront.setSession(session);
  13790. this.$gutterLayer.setSession(session);
  13791. this.$textLayer.setSession(session);
  13792. if (!session)
  13793. return;
  13794. this.$loop.schedule(this.CHANGE_FULL);
  13795. this.session.$setFontMetrics(this.$fontMetrics);
  13796. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  13797. this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
  13798. this.onChangeNewLineMode()
  13799. this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
  13800. };
  13801. this.updateLines = function(firstRow, lastRow, force) {
  13802. if (lastRow === undefined)
  13803. lastRow = Infinity;
  13804. if (!this.$changedLines) {
  13805. this.$changedLines = {
  13806. firstRow: firstRow,
  13807. lastRow: lastRow
  13808. };
  13809. }
  13810. else {
  13811. if (this.$changedLines.firstRow > firstRow)
  13812. this.$changedLines.firstRow = firstRow;
  13813. if (this.$changedLines.lastRow < lastRow)
  13814. this.$changedLines.lastRow = lastRow;
  13815. }
  13816. if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
  13817. if (force)
  13818. this.$changedLines.lastRow = this.layerConfig.lastRow;
  13819. else
  13820. return;
  13821. }
  13822. if (this.$changedLines.firstRow > this.layerConfig.lastRow)
  13823. return;
  13824. this.$loop.schedule(this.CHANGE_LINES);
  13825. };
  13826. this.onChangeNewLineMode = function() {
  13827. this.$loop.schedule(this.CHANGE_TEXT);
  13828. this.$textLayer.$updateEolChar();
  13829. };
  13830. this.onChangeTabSize = function() {
  13831. this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
  13832. this.$textLayer.onChangeTabSize();
  13833. };
  13834. this.updateText = function() {
  13835. this.$loop.schedule(this.CHANGE_TEXT);
  13836. };
  13837. this.updateFull = function(force) {
  13838. if (force)
  13839. this.$renderChanges(this.CHANGE_FULL, true);
  13840. else
  13841. this.$loop.schedule(this.CHANGE_FULL);
  13842. };
  13843. this.updateFontSize = function() {
  13844. this.$textLayer.checkForSizeChanges();
  13845. };
  13846. this.$changes = 0;
  13847. this.$updateSizeAsync = function() {
  13848. if (this.$loop.pending)
  13849. this.$size.$dirty = true;
  13850. else
  13851. this.onResize();
  13852. };
  13853. this.onResize = function(force, gutterWidth, width, height) {
  13854. if (this.resizing > 2)
  13855. return;
  13856. else if (this.resizing > 0)
  13857. this.resizing++;
  13858. else
  13859. this.resizing = force ? 1 : 0;
  13860. var el = this.container;
  13861. if (!height)
  13862. height = el.clientHeight || el.scrollHeight;
  13863. if (!width)
  13864. width = el.clientWidth || el.scrollWidth;
  13865. var changes = this.$updateCachedSize(force, gutterWidth, width, height);
  13866. if (!this.$size.scrollerHeight || (!width && !height))
  13867. return this.resizing = 0;
  13868. if (force)
  13869. this.$gutterLayer.$padding = null;
  13870. if (force)
  13871. this.$renderChanges(changes | this.$changes, true);
  13872. else
  13873. this.$loop.schedule(changes | this.$changes);
  13874. if (this.resizing)
  13875. this.resizing = 0;
  13876. this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
  13877. };
  13878. this.$updateCachedSize = function(force, gutterWidth, width, height) {
  13879. height -= (this.$extraHeight || 0);
  13880. var changes = 0;
  13881. var size = this.$size;
  13882. var oldSize = {
  13883. width: size.width,
  13884. height: size.height,
  13885. scrollerHeight: size.scrollerHeight,
  13886. scrollerWidth: size.scrollerWidth
  13887. };
  13888. if (height && (force || size.height != height)) {
  13889. size.height = height;
  13890. changes |= this.CHANGE_SIZE;
  13891. size.scrollerHeight = size.height;
  13892. if (this.$horizScroll)
  13893. size.scrollerHeight -= this.scrollBarH.getHeight();
  13894. this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
  13895. changes = changes | this.CHANGE_SCROLL;
  13896. }
  13897. if (width && (force || size.width != width)) {
  13898. changes |= this.CHANGE_SIZE;
  13899. size.width = width;
  13900. if (gutterWidth == null)
  13901. gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13902. this.gutterWidth = gutterWidth;
  13903. this.scrollBarH.element.style.left =
  13904. this.scroller.style.left = gutterWidth + "px";
  13905. size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
  13906. this.scrollBarH.element.style.right =
  13907. this.scroller.style.right = this.scrollBarV.getWidth() + "px";
  13908. this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
  13909. if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
  13910. changes |= this.CHANGE_FULL;
  13911. }
  13912. size.$dirty = !width || !height;
  13913. if (changes)
  13914. this._signal("resize", oldSize);
  13915. return changes;
  13916. };
  13917. this.onGutterResize = function() {
  13918. var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
  13919. if (gutterWidth != this.gutterWidth)
  13920. this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
  13921. if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
  13922. this.$loop.schedule(this.CHANGE_FULL);
  13923. } else if (this.$size.$dirty) {
  13924. this.$loop.schedule(this.CHANGE_FULL);
  13925. } else {
  13926. this.$computeLayerConfig();
  13927. this.$loop.schedule(this.CHANGE_MARKER);
  13928. }
  13929. };
  13930. this.adjustWrapLimit = function() {
  13931. var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
  13932. var limit = Math.floor(availableWidth / this.characterWidth);
  13933. return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
  13934. };
  13935. this.setAnimatedScroll = function(shouldAnimate){
  13936. this.setOption("animatedScroll", shouldAnimate);
  13937. };
  13938. this.getAnimatedScroll = function() {
  13939. return this.$animatedScroll;
  13940. };
  13941. this.setShowInvisibles = function(showInvisibles) {
  13942. this.setOption("showInvisibles", showInvisibles);
  13943. };
  13944. this.getShowInvisibles = function() {
  13945. return this.getOption("showInvisibles");
  13946. };
  13947. this.getDisplayIndentGuides = function() {
  13948. return this.getOption("displayIndentGuides");
  13949. };
  13950. this.setDisplayIndentGuides = function(display) {
  13951. this.setOption("displayIndentGuides", display);
  13952. };
  13953. this.setShowPrintMargin = function(showPrintMargin) {
  13954. this.setOption("showPrintMargin", showPrintMargin);
  13955. };
  13956. this.getShowPrintMargin = function() {
  13957. return this.getOption("showPrintMargin");
  13958. };
  13959. this.setPrintMarginColumn = function(showPrintMargin) {
  13960. this.setOption("printMarginColumn", showPrintMargin);
  13961. };
  13962. this.getPrintMarginColumn = function() {
  13963. return this.getOption("printMarginColumn");
  13964. };
  13965. this.getShowGutter = function(){
  13966. return this.getOption("showGutter");
  13967. };
  13968. this.setShowGutter = function(show){
  13969. return this.setOption("showGutter", show);
  13970. };
  13971. this.getFadeFoldWidgets = function(){
  13972. return this.getOption("fadeFoldWidgets")
  13973. };
  13974. this.setFadeFoldWidgets = function(show) {
  13975. this.setOption("fadeFoldWidgets", show);
  13976. };
  13977. this.setHighlightGutterLine = function(shouldHighlight) {
  13978. this.setOption("highlightGutterLine", shouldHighlight);
  13979. };
  13980. this.getHighlightGutterLine = function() {
  13981. return this.getOption("highlightGutterLine");
  13982. };
  13983. this.$updateGutterLineHighlight = function() {
  13984. var pos = this.$cursorLayer.$pixelPos;
  13985. var height = this.layerConfig.lineHeight;
  13986. if (this.session.getUseWrapMode()) {
  13987. var cursor = this.session.selection.getCursor();
  13988. cursor.column = 0;
  13989. pos = this.$cursorLayer.getPixelPosition(cursor, true);
  13990. height *= this.session.getRowLength(cursor.row);
  13991. }
  13992. this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
  13993. this.$gutterLineHighlight.style.height = height + "px";
  13994. };
  13995. this.$updatePrintMargin = function() {
  13996. if (!this.$showPrintMargin && !this.$printMarginEl)
  13997. return;
  13998. if (!this.$printMarginEl) {
  13999. var containerEl = dom.createElement("div");
  14000. containerEl.className = "ace_layer ace_print-margin-layer";
  14001. this.$printMarginEl = dom.createElement("div");
  14002. this.$printMarginEl.className = "ace_print-margin";
  14003. containerEl.appendChild(this.$printMarginEl);
  14004. this.content.insertBefore(containerEl, this.content.firstChild);
  14005. }
  14006. var style = this.$printMarginEl.style;
  14007. style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
  14008. style.visibility = this.$showPrintMargin ? "visible" : "hidden";
  14009. if (this.session && this.session.$wrap == -1)
  14010. this.adjustWrapLimit();
  14011. };
  14012. this.getContainerElement = function() {
  14013. return this.container;
  14014. };
  14015. this.getMouseEventTarget = function() {
  14016. return this.scroller;
  14017. };
  14018. this.getTextAreaContainer = function() {
  14019. return this.container;
  14020. };
  14021. this.$moveTextAreaToCursor = function() {
  14022. if (!this.$keepTextAreaAtCursor)
  14023. return;
  14024. var config = this.layerConfig;
  14025. var posTop = this.$cursorLayer.$pixelPos.top;
  14026. var posLeft = this.$cursorLayer.$pixelPos.left;
  14027. posTop -= config.offset;
  14028. var style = this.textarea.style;
  14029. var h = this.lineHeight;
  14030. if (posTop < 0 || posTop > config.height - h) {
  14031. style.top = style.left = "0";
  14032. return;
  14033. }
  14034. var w = this.characterWidth;
  14035. if (this.$composition) {
  14036. var val = this.textarea.value.replace(/^\x01+/, "");
  14037. w *= (this.session.$getStringScreenWidth(val)[0]+2);
  14038. h += 2;
  14039. }
  14040. posLeft -= this.scrollLeft;
  14041. if (posLeft > this.$size.scrollerWidth - w)
  14042. posLeft = this.$size.scrollerWidth - w;
  14043. posLeft += this.gutterWidth;
  14044. style.height = h + "px";
  14045. style.width = w + "px";
  14046. style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
  14047. style.top = Math.min(posTop, this.$size.height - h) + "px";
  14048. };
  14049. this.getFirstVisibleRow = function() {
  14050. return this.layerConfig.firstRow;
  14051. };
  14052. this.getFirstFullyVisibleRow = function() {
  14053. return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
  14054. };
  14055. this.getLastFullyVisibleRow = function() {
  14056. var config = this.layerConfig;
  14057. var lastRow = config.lastRow
  14058. var top = this.session.documentToScreenRow(lastRow, 0) * config.lineHeight;
  14059. if (top - this.session.getScrollTop() > config.height - config.lineHeight)
  14060. return lastRow - 1;
  14061. return lastRow;
  14062. };
  14063. this.getLastVisibleRow = function() {
  14064. return this.layerConfig.lastRow;
  14065. };
  14066. this.$padding = null;
  14067. this.setPadding = function(padding) {
  14068. this.$padding = padding;
  14069. this.$textLayer.setPadding(padding);
  14070. this.$cursorLayer.setPadding(padding);
  14071. this.$markerFront.setPadding(padding);
  14072. this.$markerBack.setPadding(padding);
  14073. this.$loop.schedule(this.CHANGE_FULL);
  14074. this.$updatePrintMargin();
  14075. };
  14076. this.setScrollMargin = function(top, bottom, left, right) {
  14077. var sm = this.scrollMargin;
  14078. sm.top = top|0;
  14079. sm.bottom = bottom|0;
  14080. sm.right = right|0;
  14081. sm.left = left|0;
  14082. sm.v = sm.top + sm.bottom;
  14083. sm.h = sm.left + sm.right;
  14084. if (sm.top && this.scrollTop <= 0 && this.session)
  14085. this.session.setScrollTop(-sm.top);
  14086. this.updateFull();
  14087. };
  14088. this.getHScrollBarAlwaysVisible = function() {
  14089. return this.$hScrollBarAlwaysVisible;
  14090. };
  14091. this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
  14092. this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
  14093. };
  14094. this.getVScrollBarAlwaysVisible = function() {
  14095. return this.$vScrollBarAlwaysVisible;
  14096. };
  14097. this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
  14098. this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
  14099. };
  14100. this.$updateScrollBarV = function() {
  14101. var scrollHeight = this.layerConfig.maxHeight;
  14102. var scrollerHeight = this.$size.scrollerHeight;
  14103. if (!this.$maxLines && this.$scrollPastEnd) {
  14104. scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
  14105. if (this.scrollTop > scrollHeight - scrollerHeight) {
  14106. scrollHeight = this.scrollTop + scrollerHeight;
  14107. this.scrollBarV.scrollTop = null;
  14108. }
  14109. }
  14110. this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
  14111. this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
  14112. };
  14113. this.$updateScrollBarH = function() {
  14114. this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
  14115. this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
  14116. };
  14117. this.$frozen = false;
  14118. this.freeze = function() {
  14119. this.$frozen = true;
  14120. };
  14121. this.unfreeze = function() {
  14122. this.$frozen = false;
  14123. };
  14124. this.$renderChanges = function(changes, force) {
  14125. if (this.$changes) {
  14126. changes |= this.$changes;
  14127. this.$changes = 0;
  14128. }
  14129. if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
  14130. this.$changes |= changes;
  14131. return;
  14132. }
  14133. if (this.$size.$dirty) {
  14134. this.$changes |= changes;
  14135. return this.onResize(true);
  14136. }
  14137. if (!this.lineHeight) {
  14138. this.$textLayer.checkForSizeChanges();
  14139. }
  14140. this._signal("beforeRender");
  14141. var config = this.layerConfig;
  14142. if (changes & this.CHANGE_FULL ||
  14143. changes & this.CHANGE_SIZE ||
  14144. changes & this.CHANGE_TEXT ||
  14145. changes & this.CHANGE_LINES ||
  14146. changes & this.CHANGE_SCROLL ||
  14147. changes & this.CHANGE_H_SCROLL
  14148. ) {
  14149. changes |= this.$computeLayerConfig();
  14150. if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
  14151. var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
  14152. if (st > 0) {
  14153. this.scrollTop = st;
  14154. changes = changes | this.CHANGE_SCROLL;
  14155. changes |= this.$computeLayerConfig();
  14156. }
  14157. }
  14158. config = this.layerConfig;
  14159. this.$updateScrollBarV();
  14160. if (changes & this.CHANGE_H_SCROLL)
  14161. this.$updateScrollBarH();
  14162. this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
  14163. this.content.style.marginTop = (-config.offset) + "px";
  14164. this.content.style.width = config.width + 2 * this.$padding + "px";
  14165. this.content.style.height = config.minHeight + "px";
  14166. }
  14167. if (changes & this.CHANGE_H_SCROLL) {
  14168. this.content.style.marginLeft = -this.scrollLeft + "px";
  14169. this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
  14170. }
  14171. if (changes & this.CHANGE_FULL) {
  14172. this.$textLayer.update(config);
  14173. if (this.$showGutter)
  14174. this.$gutterLayer.update(config);
  14175. this.$markerBack.update(config);
  14176. this.$markerFront.update(config);
  14177. this.$cursorLayer.update(config);
  14178. this.$moveTextAreaToCursor();
  14179. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  14180. this._signal("afterRender");
  14181. return;
  14182. }
  14183. if (changes & this.CHANGE_SCROLL) {
  14184. if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
  14185. this.$textLayer.update(config);
  14186. else
  14187. this.$textLayer.scrollLines(config);
  14188. if (this.$showGutter)
  14189. this.$gutterLayer.update(config);
  14190. this.$markerBack.update(config);
  14191. this.$markerFront.update(config);
  14192. this.$cursorLayer.update(config);
  14193. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  14194. this.$moveTextAreaToCursor();
  14195. this._signal("afterRender");
  14196. return;
  14197. }
  14198. if (changes & this.CHANGE_TEXT) {
  14199. this.$textLayer.update(config);
  14200. if (this.$showGutter)
  14201. this.$gutterLayer.update(config);
  14202. }
  14203. else if (changes & this.CHANGE_LINES) {
  14204. if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
  14205. this.$gutterLayer.update(config);
  14206. }
  14207. else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
  14208. if (this.$showGutter)
  14209. this.$gutterLayer.update(config);
  14210. }
  14211. if (changes & this.CHANGE_CURSOR) {
  14212. this.$cursorLayer.update(config);
  14213. this.$moveTextAreaToCursor();
  14214. this.$highlightGutterLine && this.$updateGutterLineHighlight();
  14215. }
  14216. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
  14217. this.$markerFront.update(config);
  14218. }
  14219. if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
  14220. this.$markerBack.update(config);
  14221. }
  14222. this._signal("afterRender");
  14223. };
  14224. this.$autosize = function() {
  14225. var height = this.session.getScreenLength() * this.lineHeight;
  14226. var maxHeight = this.$maxLines * this.lineHeight;
  14227. var desiredHeight = Math.min(maxHeight,
  14228. Math.max((this.$minLines || 1) * this.lineHeight, height)
  14229. ) + this.scrollMargin.v + (this.$extraHeight || 0);
  14230. if (this.$horizScroll)
  14231. desiredHeight += this.scrollBarH.getHeight();
  14232. if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight)
  14233. desiredHeight = this.$maxPixelHeight;
  14234. var vScroll = height > maxHeight;
  14235. if (desiredHeight != this.desiredHeight ||
  14236. this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
  14237. if (vScroll != this.$vScroll) {
  14238. this.$vScroll = vScroll;
  14239. this.scrollBarV.setVisible(vScroll);
  14240. }
  14241. var w = this.container.clientWidth;
  14242. this.container.style.height = desiredHeight + "px";
  14243. this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
  14244. this.desiredHeight = desiredHeight;
  14245. this._signal("autosize");
  14246. }
  14247. };
  14248. this.$computeLayerConfig = function() {
  14249. var session = this.session;
  14250. var size = this.$size;
  14251. var hideScrollbars = size.height <= 2 * this.lineHeight;
  14252. var screenLines = this.session.getScreenLength();
  14253. var maxHeight = screenLines * this.lineHeight;
  14254. var longestLine = this.$getLongestLine();
  14255. var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
  14256. size.scrollerWidth - longestLine - 2 * this.$padding < 0);
  14257. var hScrollChanged = this.$horizScroll !== horizScroll;
  14258. if (hScrollChanged) {
  14259. this.$horizScroll = horizScroll;
  14260. this.scrollBarH.setVisible(horizScroll);
  14261. }
  14262. var vScrollBefore = this.$vScroll; // autosize can change vscroll value in which case we need to update longestLine
  14263. if (this.$maxLines && this.lineHeight > 1)
  14264. this.$autosize();
  14265. var offset = this.scrollTop % this.lineHeight;
  14266. var minHeight = size.scrollerHeight + this.lineHeight;
  14267. var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
  14268. ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
  14269. : 0;
  14270. maxHeight += scrollPastEnd;
  14271. var sm = this.scrollMargin;
  14272. this.session.setScrollTop(Math.max(-sm.top,
  14273. Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
  14274. this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
  14275. longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
  14276. var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
  14277. size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
  14278. var vScrollChanged = vScrollBefore !== vScroll;
  14279. if (vScrollChanged) {
  14280. this.$vScroll = vScroll;
  14281. this.scrollBarV.setVisible(vScroll);
  14282. }
  14283. var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
  14284. var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
  14285. var lastRow = firstRow + lineCount;
  14286. var firstRowScreen, firstRowHeight;
  14287. var lineHeight = this.lineHeight;
  14288. firstRow = session.screenToDocumentRow(firstRow, 0);
  14289. var foldLine = session.getFoldLine(firstRow);
  14290. if (foldLine) {
  14291. firstRow = foldLine.start.row;
  14292. }
  14293. firstRowScreen = session.documentToScreenRow(firstRow, 0);
  14294. firstRowHeight = session.getRowLength(firstRow) * lineHeight;
  14295. lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
  14296. minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
  14297. firstRowHeight;
  14298. offset = this.scrollTop - firstRowScreen * lineHeight;
  14299. var changes = 0;
  14300. if (this.layerConfig.width != longestLine)
  14301. changes = this.CHANGE_H_SCROLL;
  14302. if (hScrollChanged || vScrollChanged) {
  14303. changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
  14304. this._signal("scrollbarVisibilityChanged");
  14305. if (vScrollChanged)
  14306. longestLine = this.$getLongestLine();
  14307. }
  14308. this.layerConfig = {
  14309. width : longestLine,
  14310. padding : this.$padding,
  14311. firstRow : firstRow,
  14312. firstRowScreen: firstRowScreen,
  14313. lastRow : lastRow,
  14314. lineHeight : lineHeight,
  14315. characterWidth : this.characterWidth,
  14316. minHeight : minHeight,
  14317. maxHeight : maxHeight,
  14318. offset : offset,
  14319. gutterOffset : lineHeight ? Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)) : 0,
  14320. height : this.$size.scrollerHeight
  14321. };
  14322. return changes;
  14323. };
  14324. this.$updateLines = function() {
  14325. var firstRow = this.$changedLines.firstRow;
  14326. var lastRow = this.$changedLines.lastRow;
  14327. this.$changedLines = null;
  14328. var layerConfig = this.layerConfig;
  14329. if (firstRow > layerConfig.lastRow + 1) { return; }
  14330. if (lastRow < layerConfig.firstRow) { return; }
  14331. if (lastRow === Infinity) {
  14332. if (this.$showGutter)
  14333. this.$gutterLayer.update(layerConfig);
  14334. this.$textLayer.update(layerConfig);
  14335. return;
  14336. }
  14337. this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
  14338. return true;
  14339. };
  14340. this.$getLongestLine = function() {
  14341. var charCount = this.session.getScreenWidth();
  14342. if (this.showInvisibles && !this.session.$useWrapMode)
  14343. charCount += 1;
  14344. return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
  14345. };
  14346. this.updateFrontMarkers = function() {
  14347. this.$markerFront.setMarkers(this.session.getMarkers(true));
  14348. this.$loop.schedule(this.CHANGE_MARKER_FRONT);
  14349. };
  14350. this.updateBackMarkers = function() {
  14351. this.$markerBack.setMarkers(this.session.getMarkers());
  14352. this.$loop.schedule(this.CHANGE_MARKER_BACK);
  14353. };
  14354. this.addGutterDecoration = function(row, className){
  14355. this.$gutterLayer.addGutterDecoration(row, className);
  14356. };
  14357. this.removeGutterDecoration = function(row, className){
  14358. this.$gutterLayer.removeGutterDecoration(row, className);
  14359. };
  14360. this.updateBreakpoints = function(rows) {
  14361. this.$loop.schedule(this.CHANGE_GUTTER);
  14362. };
  14363. this.setAnnotations = function(annotations) {
  14364. this.$gutterLayer.setAnnotations(annotations);
  14365. this.$loop.schedule(this.CHANGE_GUTTER);
  14366. };
  14367. this.updateCursor = function() {
  14368. this.$loop.schedule(this.CHANGE_CURSOR);
  14369. };
  14370. this.hideCursor = function() {
  14371. this.$cursorLayer.hideCursor();
  14372. };
  14373. this.showCursor = function() {
  14374. this.$cursorLayer.showCursor();
  14375. };
  14376. this.scrollSelectionIntoView = function(anchor, lead, offset) {
  14377. this.scrollCursorIntoView(anchor, offset);
  14378. this.scrollCursorIntoView(lead, offset);
  14379. };
  14380. this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
  14381. if (this.$size.scrollerHeight === 0)
  14382. return;
  14383. var pos = this.$cursorLayer.getPixelPosition(cursor);
  14384. var left = pos.left;
  14385. var top = pos.top;
  14386. var topMargin = $viewMargin && $viewMargin.top || 0;
  14387. var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
  14388. var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
  14389. if (scrollTop + topMargin > top) {
  14390. if (offset && scrollTop + topMargin > top + this.lineHeight)
  14391. top -= offset * this.$size.scrollerHeight;
  14392. if (top === 0)
  14393. top = -this.scrollMargin.top;
  14394. this.session.setScrollTop(top);
  14395. } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
  14396. if (offset && scrollTop + this.$size.scrollerHeight - bottomMargin < top - this.lineHeight)
  14397. top += offset * this.$size.scrollerHeight;
  14398. this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
  14399. }
  14400. var scrollLeft = this.scrollLeft;
  14401. if (scrollLeft > left) {
  14402. if (left < this.$padding + 2 * this.layerConfig.characterWidth)
  14403. left = -this.scrollMargin.left;
  14404. this.session.setScrollLeft(left);
  14405. } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
  14406. this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
  14407. } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
  14408. this.session.setScrollLeft(0);
  14409. }
  14410. };
  14411. this.getScrollTop = function() {
  14412. return this.session.getScrollTop();
  14413. };
  14414. this.getScrollLeft = function() {
  14415. return this.session.getScrollLeft();
  14416. };
  14417. this.getScrollTopRow = function() {
  14418. return this.scrollTop / this.lineHeight;
  14419. };
  14420. this.getScrollBottomRow = function() {
  14421. return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
  14422. };
  14423. this.scrollToRow = function(row) {
  14424. this.session.setScrollTop(row * this.lineHeight);
  14425. };
  14426. this.alignCursor = function(cursor, alignment) {
  14427. if (typeof cursor == "number")
  14428. cursor = {row: cursor, column: 0};
  14429. var pos = this.$cursorLayer.getPixelPosition(cursor);
  14430. var h = this.$size.scrollerHeight - this.lineHeight;
  14431. var offset = pos.top - h * (alignment || 0);
  14432. this.session.setScrollTop(offset);
  14433. return offset;
  14434. };
  14435. this.STEPS = 8;
  14436. this.$calcSteps = function(fromValue, toValue){
  14437. var i = 0;
  14438. var l = this.STEPS;
  14439. var steps = [];
  14440. var func = function(t, x_min, dx) {
  14441. return dx * (Math.pow(t - 1, 3) + 1) + x_min;
  14442. };
  14443. for (i = 0; i < l; ++i)
  14444. steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
  14445. return steps;
  14446. };
  14447. this.scrollToLine = function(line, center, animate, callback) {
  14448. var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
  14449. var offset = pos.top;
  14450. if (center)
  14451. offset -= this.$size.scrollerHeight / 2;
  14452. var initialScroll = this.scrollTop;
  14453. this.session.setScrollTop(offset);
  14454. if (animate !== false)
  14455. this.animateScrolling(initialScroll, callback);
  14456. };
  14457. this.animateScrolling = function(fromValue, callback) {
  14458. var toValue = this.scrollTop;
  14459. if (!this.$animatedScroll)
  14460. return;
  14461. var _self = this;
  14462. if (fromValue == toValue)
  14463. return;
  14464. if (this.$scrollAnimation) {
  14465. var oldSteps = this.$scrollAnimation.steps;
  14466. if (oldSteps.length) {
  14467. fromValue = oldSteps[0];
  14468. if (fromValue == toValue)
  14469. return;
  14470. }
  14471. }
  14472. var steps = _self.$calcSteps(fromValue, toValue);
  14473. this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
  14474. clearInterval(this.$timer);
  14475. _self.session.setScrollTop(steps.shift());
  14476. _self.session.$scrollTop = toValue;
  14477. this.$timer = setInterval(function() {
  14478. if (steps.length) {
  14479. _self.session.setScrollTop(steps.shift());
  14480. _self.session.$scrollTop = toValue;
  14481. } else if (toValue != null) {
  14482. _self.session.$scrollTop = -1;
  14483. _self.session.setScrollTop(toValue);
  14484. toValue = null;
  14485. } else {
  14486. _self.$timer = clearInterval(_self.$timer);
  14487. _self.$scrollAnimation = null;
  14488. callback && callback();
  14489. }
  14490. }, 10);
  14491. };
  14492. this.scrollToY = function(scrollTop) {
  14493. if (this.scrollTop !== scrollTop) {
  14494. this.$loop.schedule(this.CHANGE_SCROLL);
  14495. this.scrollTop = scrollTop;
  14496. }
  14497. };
  14498. this.scrollToX = function(scrollLeft) {
  14499. if (this.scrollLeft !== scrollLeft)
  14500. this.scrollLeft = scrollLeft;
  14501. this.$loop.schedule(this.CHANGE_H_SCROLL);
  14502. };
  14503. this.scrollTo = function(x, y) {
  14504. this.session.setScrollTop(y);
  14505. this.session.setScrollLeft(y);
  14506. };
  14507. this.scrollBy = function(deltaX, deltaY) {
  14508. deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
  14509. deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
  14510. };
  14511. this.isScrollableBy = function(deltaX, deltaY) {
  14512. if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
  14513. return true;
  14514. if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
  14515. - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
  14516. return true;
  14517. if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
  14518. return true;
  14519. if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
  14520. - this.layerConfig.width < -1 + this.scrollMargin.right)
  14521. return true;
  14522. };
  14523. this.pixelToScreenCoordinates = function(x, y) {
  14524. var canvasPos = this.scroller.getBoundingClientRect();
  14525. var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
  14526. var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
  14527. var col = Math.round(offset);
  14528. return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
  14529. };
  14530. this.screenToTextCoordinates = function(x, y) {
  14531. var canvasPos = this.scroller.getBoundingClientRect();
  14532. var col = Math.round(
  14533. (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
  14534. );
  14535. var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
  14536. return this.session.screenToDocumentPosition(row, Math.max(col, 0));
  14537. };
  14538. this.textToScreenCoordinates = function(row, column) {
  14539. var canvasPos = this.scroller.getBoundingClientRect();
  14540. var pos = this.session.documentToScreenPosition(row, column);
  14541. var x = this.$padding + Math.round(pos.column * this.characterWidth);
  14542. var y = pos.row * this.lineHeight;
  14543. return {
  14544. pageX: canvasPos.left + x - this.scrollLeft,
  14545. pageY: canvasPos.top + y - this.scrollTop
  14546. };
  14547. };
  14548. this.visualizeFocus = function() {
  14549. dom.addCssClass(this.container, "ace_focus");
  14550. };
  14551. this.visualizeBlur = function() {
  14552. dom.removeCssClass(this.container, "ace_focus");
  14553. };
  14554. this.showComposition = function(position) {
  14555. if (!this.$composition)
  14556. this.$composition = {
  14557. keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
  14558. cssText: this.textarea.style.cssText
  14559. };
  14560. this.$keepTextAreaAtCursor = true;
  14561. dom.addCssClass(this.textarea, "ace_composition");
  14562. this.textarea.style.cssText = "";
  14563. this.$moveTextAreaToCursor();
  14564. };
  14565. this.setCompositionText = function(text) {
  14566. this.$moveTextAreaToCursor();
  14567. };
  14568. this.hideComposition = function() {
  14569. if (!this.$composition)
  14570. return;
  14571. dom.removeCssClass(this.textarea, "ace_composition");
  14572. this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
  14573. this.textarea.style.cssText = this.$composition.cssText;
  14574. this.$composition = null;
  14575. };
  14576. this.setTheme = function(theme, cb) {
  14577. var _self = this;
  14578. this.$themeId = theme;
  14579. _self._dispatchEvent('themeChange',{theme:theme});
  14580. if (!theme || typeof theme == "string") {
  14581. var moduleName = theme || this.$options.theme.initialValue;
  14582. config.loadModule(["theme", moduleName], afterLoad);
  14583. } else {
  14584. afterLoad(theme);
  14585. }
  14586. function afterLoad(module) {
  14587. if (_self.$themeId != theme)
  14588. return cb && cb();
  14589. if (!module || !module.cssClass)
  14590. throw new Error("couldn't load module " + theme + " or it didn't call define");
  14591. dom.importCssString(
  14592. module.cssText,
  14593. module.cssClass,
  14594. _self.container.ownerDocument
  14595. );
  14596. if (_self.theme)
  14597. dom.removeCssClass(_self.container, _self.theme.cssClass);
  14598. var padding = "padding" in module ? module.padding
  14599. : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
  14600. if (_self.$padding && padding != _self.$padding)
  14601. _self.setPadding(padding);
  14602. _self.$theme = module.cssClass;
  14603. _self.theme = module;
  14604. dom.addCssClass(_self.container, module.cssClass);
  14605. dom.setCssClass(_self.container, "ace_dark", module.isDark);
  14606. if (_self.$size) {
  14607. _self.$size.width = 0;
  14608. _self.$updateSizeAsync();
  14609. }
  14610. _self._dispatchEvent('themeLoaded', {theme:module});
  14611. cb && cb();
  14612. }
  14613. };
  14614. this.getTheme = function() {
  14615. return this.$themeId;
  14616. };
  14617. this.setStyle = function(style, include) {
  14618. dom.setCssClass(this.container, style, include !== false);
  14619. };
  14620. this.unsetStyle = function(style) {
  14621. dom.removeCssClass(this.container, style);
  14622. };
  14623. this.setCursorStyle = function(style) {
  14624. if (this.scroller.style.cursor != style)
  14625. this.scroller.style.cursor = style;
  14626. };
  14627. this.setMouseCursor = function(cursorStyle) {
  14628. this.scroller.style.cursor = cursorStyle;
  14629. };
  14630. this.destroy = function() {
  14631. this.$textLayer.destroy();
  14632. this.$cursorLayer.destroy();
  14633. };
  14634. }).call(VirtualRenderer.prototype);
  14635. config.defineOptions(VirtualRenderer.prototype, "renderer", {
  14636. animatedScroll: {initialValue: false},
  14637. showInvisibles: {
  14638. set: function(value) {
  14639. if (this.$textLayer.setShowInvisibles(value))
  14640. this.$loop.schedule(this.CHANGE_TEXT);
  14641. },
  14642. initialValue: false
  14643. },
  14644. showPrintMargin: {
  14645. set: function() { this.$updatePrintMargin(); },
  14646. initialValue: true
  14647. },
  14648. printMarginColumn: {
  14649. set: function() { this.$updatePrintMargin(); },
  14650. initialValue: 80
  14651. },
  14652. printMargin: {
  14653. set: function(val) {
  14654. if (typeof val == "number")
  14655. this.$printMarginColumn = val;
  14656. this.$showPrintMargin = !!val;
  14657. this.$updatePrintMargin();
  14658. },
  14659. get: function() {
  14660. return this.$showPrintMargin && this.$printMarginColumn;
  14661. }
  14662. },
  14663. showGutter: {
  14664. set: function(show){
  14665. this.$gutter.style.display = show ? "block" : "none";
  14666. this.$loop.schedule(this.CHANGE_FULL);
  14667. this.onGutterResize();
  14668. },
  14669. initialValue: true
  14670. },
  14671. fadeFoldWidgets: {
  14672. set: function(show) {
  14673. dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
  14674. },
  14675. initialValue: false
  14676. },
  14677. showFoldWidgets: {
  14678. set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
  14679. initialValue: true
  14680. },
  14681. showLineNumbers: {
  14682. set: function(show) {
  14683. this.$gutterLayer.setShowLineNumbers(show);
  14684. this.$loop.schedule(this.CHANGE_GUTTER);
  14685. },
  14686. initialValue: true
  14687. },
  14688. displayIndentGuides: {
  14689. set: function(show) {
  14690. if (this.$textLayer.setDisplayIndentGuides(show))
  14691. this.$loop.schedule(this.CHANGE_TEXT);
  14692. },
  14693. initialValue: true
  14694. },
  14695. highlightGutterLine: {
  14696. set: function(shouldHighlight) {
  14697. if (!this.$gutterLineHighlight) {
  14698. this.$gutterLineHighlight = dom.createElement("div");
  14699. this.$gutterLineHighlight.className = "ace_gutter-active-line";
  14700. this.$gutter.appendChild(this.$gutterLineHighlight);
  14701. return;
  14702. }
  14703. this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
  14704. if (this.$cursorLayer.$pixelPos)
  14705. this.$updateGutterLineHighlight();
  14706. },
  14707. initialValue: false,
  14708. value: true
  14709. },
  14710. hScrollBarAlwaysVisible: {
  14711. set: function(val) {
  14712. if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
  14713. this.$loop.schedule(this.CHANGE_SCROLL);
  14714. },
  14715. initialValue: false
  14716. },
  14717. vScrollBarAlwaysVisible: {
  14718. set: function(val) {
  14719. if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
  14720. this.$loop.schedule(this.CHANGE_SCROLL);
  14721. },
  14722. initialValue: false
  14723. },
  14724. fontSize: {
  14725. set: function(size) {
  14726. if (typeof size == "number")
  14727. size = size + "px";
  14728. this.container.style.fontSize = size;
  14729. this.updateFontSize();
  14730. },
  14731. initialValue: 12
  14732. },
  14733. fontFamily: {
  14734. set: function(name) {
  14735. this.container.style.fontFamily = name;
  14736. this.updateFontSize();
  14737. }
  14738. },
  14739. maxLines: {
  14740. set: function(val) {
  14741. this.updateFull();
  14742. }
  14743. },
  14744. minLines: {
  14745. set: function(val) {
  14746. this.updateFull();
  14747. }
  14748. },
  14749. maxPixelHeight: {
  14750. set: function(val) {
  14751. this.updateFull();
  14752. },
  14753. initialValue: 0
  14754. },
  14755. scrollPastEnd: {
  14756. set: function(val) {
  14757. val = +val || 0;
  14758. if (this.$scrollPastEnd == val)
  14759. return;
  14760. this.$scrollPastEnd = val;
  14761. this.$loop.schedule(this.CHANGE_SCROLL);
  14762. },
  14763. initialValue: 0,
  14764. handlesSet: true
  14765. },
  14766. fixedWidthGutter: {
  14767. set: function(val) {
  14768. this.$gutterLayer.$fixedWidth = !!val;
  14769. this.$loop.schedule(this.CHANGE_GUTTER);
  14770. }
  14771. },
  14772. theme: {
  14773. set: function(val) { this.setTheme(val) },
  14774. get: function() { return this.$themeId || this.theme; },
  14775. initialValue: "./theme/textmate",
  14776. handlesSet: true
  14777. }
  14778. });
  14779. exports.VirtualRenderer = VirtualRenderer;
  14780. });
  14781. 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) {
  14782. "use strict";
  14783. var oop = require("../lib/oop");
  14784. var net = require("../lib/net");
  14785. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  14786. var config = require("../config");
  14787. var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
  14788. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14789. this.changeListener = this.changeListener.bind(this);
  14790. this.onMessage = this.onMessage.bind(this);
  14791. if (require.nameToUrl && !require.toUrl)
  14792. require.toUrl = require.nameToUrl;
  14793. if (config.get("packaged") || !require.toUrl) {
  14794. workerUrl = workerUrl || config.moduleUrl(mod, "worker");
  14795. } else {
  14796. var normalizePath = this.$normalizePath;
  14797. workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
  14798. var tlns = {};
  14799. topLevelNamespaces.forEach(function(ns) {
  14800. tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
  14801. });
  14802. }
  14803. try {
  14804. this.$worker = new Worker(workerUrl);
  14805. } catch(e) {
  14806. if (e instanceof window.DOMException) {
  14807. var blob = this.$workerBlob(workerUrl);
  14808. var URL = window.URL || window.webkitURL;
  14809. var blobURL = URL.createObjectURL(blob);
  14810. this.$worker = new Worker(blobURL);
  14811. URL.revokeObjectURL(blobURL);
  14812. } else {
  14813. throw e;
  14814. }
  14815. }
  14816. this.$worker.postMessage({
  14817. init : true,
  14818. tlns : tlns,
  14819. module : mod,
  14820. classname : classname
  14821. });
  14822. this.callbackId = 1;
  14823. this.callbacks = {};
  14824. this.$worker.onmessage = this.onMessage;
  14825. };
  14826. (function(){
  14827. oop.implement(this, EventEmitter);
  14828. this.onMessage = function(e) {
  14829. var msg = e.data;
  14830. switch(msg.type) {
  14831. case "event":
  14832. this._signal(msg.name, {data: msg.data});
  14833. break;
  14834. case "call":
  14835. var callback = this.callbacks[msg.id];
  14836. if (callback) {
  14837. callback(msg.data);
  14838. delete this.callbacks[msg.id];
  14839. }
  14840. break;
  14841. case "error":
  14842. this.reportError(msg.data);
  14843. break;
  14844. case "log":
  14845. window.console && console.log && console.log.apply(console, msg.data);
  14846. break;
  14847. }
  14848. };
  14849. this.reportError = function(err) {
  14850. window.console && console.error && console.error(err);
  14851. };
  14852. this.$normalizePath = function(path) {
  14853. return net.qualifyURL(path);
  14854. };
  14855. this.terminate = function() {
  14856. this._signal("terminate", {});
  14857. this.deltaQueue = null;
  14858. this.$worker.terminate();
  14859. this.$worker = null;
  14860. if (this.$doc)
  14861. this.$doc.off("change", this.changeListener);
  14862. this.$doc = null;
  14863. };
  14864. this.send = function(cmd, args) {
  14865. this.$worker.postMessage({command: cmd, args: args});
  14866. };
  14867. this.call = function(cmd, args, callback) {
  14868. if (callback) {
  14869. var id = this.callbackId++;
  14870. this.callbacks[id] = callback;
  14871. args.push(id);
  14872. }
  14873. this.send(cmd, args);
  14874. };
  14875. this.emit = function(event, data) {
  14876. try {
  14877. this.$worker.postMessage({event: event, data: {data: data.data}});
  14878. }
  14879. catch(ex) {
  14880. console.error(ex.stack);
  14881. }
  14882. };
  14883. this.attachToDocument = function(doc) {
  14884. if(this.$doc)
  14885. this.terminate();
  14886. this.$doc = doc;
  14887. this.call("setValue", [doc.getValue()]);
  14888. doc.on("change", this.changeListener);
  14889. };
  14890. this.changeListener = function(delta) {
  14891. if (!this.deltaQueue) {
  14892. this.deltaQueue = [];
  14893. setTimeout(this.$sendDeltaQueue, 0);
  14894. }
  14895. if (delta.action == "insert")
  14896. this.deltaQueue.push(delta.start, delta.lines);
  14897. else
  14898. this.deltaQueue.push(delta.start, delta.end);
  14899. };
  14900. this.$sendDeltaQueue = function() {
  14901. var q = this.deltaQueue;
  14902. if (!q) return;
  14903. this.deltaQueue = null;
  14904. if (q.length > 50 && q.length > this.$doc.getLength() >> 1) {
  14905. this.call("setValue", [this.$doc.getValue()]);
  14906. } else
  14907. this.emit("change", {data: q});
  14908. };
  14909. this.$workerBlob = function(workerUrl) {
  14910. var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
  14911. try {
  14912. return new Blob([script], {"type": "application/javascript"});
  14913. } catch (e) { // Backwards-compatibility
  14914. var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
  14915. var blobBuilder = new BlobBuilder();
  14916. blobBuilder.append(script);
  14917. return blobBuilder.getBlob("application/javascript");
  14918. }
  14919. };
  14920. }).call(WorkerClient.prototype);
  14921. var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
  14922. this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
  14923. this.changeListener = this.changeListener.bind(this);
  14924. this.callbackId = 1;
  14925. this.callbacks = {};
  14926. this.messageBuffer = [];
  14927. var main = null;
  14928. var emitSync = false;
  14929. var sender = Object.create(EventEmitter);
  14930. var _self = this;
  14931. this.$worker = {};
  14932. this.$worker.terminate = function() {};
  14933. this.$worker.postMessage = function(e) {
  14934. _self.messageBuffer.push(e);
  14935. if (main) {
  14936. if (emitSync)
  14937. setTimeout(processNext);
  14938. else
  14939. processNext();
  14940. }
  14941. };
  14942. this.setEmitSync = function(val) { emitSync = val };
  14943. var processNext = function() {
  14944. var msg = _self.messageBuffer.shift();
  14945. if (msg.command)
  14946. main[msg.command].apply(main, msg.args);
  14947. else if (msg.event)
  14948. sender._signal(msg.event, msg.data);
  14949. };
  14950. sender.postMessage = function(msg) {
  14951. _self.onMessage({data: msg});
  14952. };
  14953. sender.callback = function(data, callbackId) {
  14954. this.postMessage({type: "call", id: callbackId, data: data});
  14955. };
  14956. sender.emit = function(name, data) {
  14957. this.postMessage({type: "event", name: name, data: data});
  14958. };
  14959. config.loadModule(["worker", mod], function(Main) {
  14960. main = new Main[classname](sender);
  14961. while (_self.messageBuffer.length)
  14962. processNext();
  14963. });
  14964. };
  14965. UIWorkerClient.prototype = WorkerClient.prototype;
  14966. exports.UIWorkerClient = UIWorkerClient;
  14967. exports.WorkerClient = WorkerClient;
  14968. });
  14969. ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
  14970. "use strict";
  14971. var Range = require("./range").Range;
  14972. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  14973. var oop = require("./lib/oop");
  14974. var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
  14975. var _self = this;
  14976. this.length = length;
  14977. this.session = session;
  14978. this.doc = session.getDocument();
  14979. this.mainClass = mainClass;
  14980. this.othersClass = othersClass;
  14981. this.$onUpdate = this.onUpdate.bind(this);
  14982. this.doc.on("change", this.$onUpdate);
  14983. this.$others = others;
  14984. this.$onCursorChange = function() {
  14985. setTimeout(function() {
  14986. _self.onCursorChange();
  14987. });
  14988. };
  14989. this.$pos = pos;
  14990. var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
  14991. this.$undoStackDepth = undoStack.length;
  14992. this.setup();
  14993. session.selection.on("changeCursor", this.$onCursorChange);
  14994. };
  14995. (function() {
  14996. oop.implement(this, EventEmitter);
  14997. this.setup = function() {
  14998. var _self = this;
  14999. var doc = this.doc;
  15000. var session = this.session;
  15001. this.selectionBefore = session.selection.toJSON();
  15002. if (session.selection.inMultiSelectMode)
  15003. session.selection.toSingleRange();
  15004. this.pos = doc.createAnchor(this.$pos.row, this.$pos.column);
  15005. var pos = this.pos;
  15006. pos.$insertRight = true;
  15007. pos.detach();
  15008. pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
  15009. this.others = [];
  15010. this.$others.forEach(function(other) {
  15011. var anchor = doc.createAnchor(other.row, other.column);
  15012. anchor.$insertRight = true;
  15013. anchor.detach();
  15014. _self.others.push(anchor);
  15015. });
  15016. session.setUndoSelect(false);
  15017. };
  15018. this.showOtherMarkers = function() {
  15019. if (this.othersActive) return;
  15020. var session = this.session;
  15021. var _self = this;
  15022. this.othersActive = true;
  15023. this.others.forEach(function(anchor) {
  15024. anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
  15025. });
  15026. };
  15027. this.hideOtherMarkers = function() {
  15028. if (!this.othersActive) return;
  15029. this.othersActive = false;
  15030. for (var i = 0; i < this.others.length; i++) {
  15031. this.session.removeMarker(this.others[i].markerId);
  15032. }
  15033. };
  15034. this.onUpdate = function(delta) {
  15035. if (this.$updating)
  15036. return this.updateAnchors(delta);
  15037. var range = delta;
  15038. if (range.start.row !== range.end.row) return;
  15039. if (range.start.row !== this.pos.row) return;
  15040. this.$updating = true;
  15041. var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
  15042. var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1;
  15043. var distanceFromStart = range.start.column - this.pos.column;
  15044. this.updateAnchors(delta);
  15045. if (inMainRange)
  15046. this.length += lengthDiff;
  15047. if (inMainRange && !this.session.$fromUndo) {
  15048. if (delta.action === 'insert') {
  15049. for (var i = this.others.length - 1; i >= 0; i--) {
  15050. var otherPos = this.others[i];
  15051. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  15052. this.doc.insertMergedLines(newPos, delta.lines);
  15053. }
  15054. } else if (delta.action === 'remove') {
  15055. for (var i = this.others.length - 1; i >= 0; i--) {
  15056. var otherPos = this.others[i];
  15057. var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
  15058. this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
  15059. }
  15060. }
  15061. }
  15062. this.$updating = false;
  15063. this.updateMarkers();
  15064. };
  15065. this.updateAnchors = function(delta) {
  15066. this.pos.onChange(delta);
  15067. for (var i = this.others.length; i--;)
  15068. this.others[i].onChange(delta);
  15069. this.updateMarkers();
  15070. };
  15071. this.updateMarkers = function() {
  15072. if (this.$updating)
  15073. return;
  15074. var _self = this;
  15075. var session = this.session;
  15076. var updateMarker = function(pos, className) {
  15077. session.removeMarker(pos.markerId);
  15078. pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column+_self.length), className, null, false);
  15079. };
  15080. updateMarker(this.pos, this.mainClass);
  15081. for (var i = this.others.length; i--;)
  15082. updateMarker(this.others[i], this.othersClass);
  15083. };
  15084. this.onCursorChange = function(event) {
  15085. if (this.$updating || !this.session) return;
  15086. var pos = this.session.selection.getCursor();
  15087. if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
  15088. this.showOtherMarkers();
  15089. this._emit("cursorEnter", event);
  15090. } else {
  15091. this.hideOtherMarkers();
  15092. this._emit("cursorLeave", event);
  15093. }
  15094. };
  15095. this.detach = function() {
  15096. this.session.removeMarker(this.pos && this.pos.markerId);
  15097. this.hideOtherMarkers();
  15098. this.doc.removeEventListener("change", this.$onUpdate);
  15099. this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
  15100. this.session.setUndoSelect(true);
  15101. this.session = null;
  15102. };
  15103. this.cancel = function() {
  15104. if (this.$undoStackDepth === -1)
  15105. return;
  15106. var undoManager = this.session.getUndoManager();
  15107. var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
  15108. for (var i = 0; i < undosRequired; i++) {
  15109. undoManager.undo(true);
  15110. }
  15111. if (this.selectionBefore)
  15112. this.session.selection.fromJSON(this.selectionBefore);
  15113. };
  15114. }).call(PlaceHolder.prototype);
  15115. exports.PlaceHolder = PlaceHolder;
  15116. });
  15117. ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
  15118. var event = require("../lib/event");
  15119. var useragent = require("../lib/useragent");
  15120. function isSamePoint(p1, p2) {
  15121. return p1.row == p2.row && p1.column == p2.column;
  15122. }
  15123. function onMouseDown(e) {
  15124. var ev = e.domEvent;
  15125. var alt = ev.altKey;
  15126. var shift = ev.shiftKey;
  15127. var ctrl = ev.ctrlKey;
  15128. var accel = e.getAccelKey();
  15129. var button = e.getButton();
  15130. if (ctrl && useragent.isMac)
  15131. button = ev.button;
  15132. if (e.editor.inMultiSelectMode && button == 2) {
  15133. e.editor.textInput.onContextMenu(e.domEvent);
  15134. return;
  15135. }
  15136. if (!ctrl && !alt && !accel) {
  15137. if (button === 0 && e.editor.inMultiSelectMode)
  15138. e.editor.exitMultiSelectMode();
  15139. return;
  15140. }
  15141. if (button !== 0)
  15142. return;
  15143. var editor = e.editor;
  15144. var selection = editor.selection;
  15145. var isMultiSelect = editor.inMultiSelectMode;
  15146. var pos = e.getDocumentPosition();
  15147. var cursor = selection.getCursor();
  15148. var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
  15149. var mouseX = e.x, mouseY = e.y;
  15150. var onMouseSelection = function(e) {
  15151. mouseX = e.clientX;
  15152. mouseY = e.clientY;
  15153. };
  15154. var session = editor.session;
  15155. var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  15156. var screenCursor = screenAnchor;
  15157. var selectionMode;
  15158. if (editor.$mouseHandler.$enableJumpToDef) {
  15159. if (ctrl && alt || accel && alt)
  15160. selectionMode = shift ? "block" : "add";
  15161. else if (alt && editor.$blockSelectEnabled)
  15162. selectionMode = "block";
  15163. } else {
  15164. if (accel && !alt) {
  15165. selectionMode = "add";
  15166. if (!isMultiSelect && shift)
  15167. return;
  15168. } else if (alt && editor.$blockSelectEnabled) {
  15169. selectionMode = "block";
  15170. }
  15171. }
  15172. if (selectionMode && useragent.isMac && ev.ctrlKey) {
  15173. editor.$mouseHandler.cancelContextMenu();
  15174. }
  15175. if (selectionMode == "add") {
  15176. if (!isMultiSelect && inSelection)
  15177. return; // dragging
  15178. if (!isMultiSelect) {
  15179. var range = selection.toOrientedRange();
  15180. editor.addSelectionMarker(range);
  15181. }
  15182. var oldRange = selection.rangeList.rangeAtPoint(pos);
  15183. editor.$blockScrolling++;
  15184. editor.inVirtualSelectionMode = true;
  15185. if (shift) {
  15186. oldRange = null;
  15187. range = selection.ranges[0] || range;
  15188. editor.removeSelectionMarker(range);
  15189. }
  15190. editor.once("mouseup", function() {
  15191. var tmpSel = selection.toOrientedRange();
  15192. if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
  15193. selection.substractPoint(tmpSel.cursor);
  15194. else {
  15195. if (shift) {
  15196. selection.substractPoint(range.cursor);
  15197. } else if (range) {
  15198. editor.removeSelectionMarker(range);
  15199. selection.addRange(range);
  15200. }
  15201. selection.addRange(tmpSel);
  15202. }
  15203. editor.$blockScrolling--;
  15204. editor.inVirtualSelectionMode = false;
  15205. });
  15206. } else if (selectionMode == "block") {
  15207. e.stop();
  15208. editor.inVirtualSelectionMode = true;
  15209. var initialRange;
  15210. var rectSel = [];
  15211. var blockSelect = function() {
  15212. var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
  15213. var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
  15214. if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
  15215. return;
  15216. screenCursor = newCursor;
  15217. editor.$blockScrolling++;
  15218. editor.selection.moveToPosition(cursor);
  15219. editor.renderer.scrollCursorIntoView();
  15220. editor.removeSelectionMarkers(rectSel);
  15221. rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
  15222. if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
  15223. rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
  15224. rectSel.forEach(editor.addSelectionMarker, editor);
  15225. editor.updateSelectionMarkers();
  15226. editor.$blockScrolling--;
  15227. };
  15228. editor.$blockScrolling++;
  15229. if (isMultiSelect && !accel) {
  15230. selection.toSingleRange();
  15231. } else if (!isMultiSelect && accel) {
  15232. initialRange = selection.toOrientedRange();
  15233. editor.addSelectionMarker(initialRange);
  15234. }
  15235. if (shift)
  15236. screenAnchor = session.documentToScreenPosition(selection.lead);
  15237. else
  15238. selection.moveToPosition(pos);
  15239. editor.$blockScrolling--;
  15240. screenCursor = {row: -1, column: -1};
  15241. var onMouseSelectionEnd = function(e) {
  15242. clearInterval(timerId);
  15243. editor.removeSelectionMarkers(rectSel);
  15244. if (!rectSel.length)
  15245. rectSel = [selection.toOrientedRange()];
  15246. editor.$blockScrolling++;
  15247. if (initialRange) {
  15248. editor.removeSelectionMarker(initialRange);
  15249. selection.toSingleRange(initialRange);
  15250. }
  15251. for (var i = 0; i < rectSel.length; i++)
  15252. selection.addRange(rectSel[i]);
  15253. editor.inVirtualSelectionMode = false;
  15254. editor.$mouseHandler.$clickSelection = null;
  15255. editor.$blockScrolling--;
  15256. };
  15257. var onSelectionInterval = blockSelect;
  15258. event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
  15259. var timerId = setInterval(function() {onSelectionInterval();}, 20);
  15260. return e.preventDefault();
  15261. }
  15262. }
  15263. exports.onMouseDown = onMouseDown;
  15264. });
  15265. ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
  15266. exports.defaultCommands = [{
  15267. name: "addCursorAbove",
  15268. exec: function(editor) { editor.selectMoreLines(-1); },
  15269. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  15270. scrollIntoView: "cursor",
  15271. readOnly: true
  15272. }, {
  15273. name: "addCursorBelow",
  15274. exec: function(editor) { editor.selectMoreLines(1); },
  15275. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  15276. scrollIntoView: "cursor",
  15277. readOnly: true
  15278. }, {
  15279. name: "addCursorAboveSkipCurrent",
  15280. exec: function(editor) { editor.selectMoreLines(-1, true); },
  15281. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  15282. scrollIntoView: "cursor",
  15283. readOnly: true
  15284. }, {
  15285. name: "addCursorBelowSkipCurrent",
  15286. exec: function(editor) { editor.selectMoreLines(1, true); },
  15287. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  15288. scrollIntoView: "cursor",
  15289. readOnly: true
  15290. }, {
  15291. name: "selectMoreBefore",
  15292. exec: function(editor) { editor.selectMore(-1); },
  15293. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  15294. scrollIntoView: "cursor",
  15295. readOnly: true
  15296. }, {
  15297. name: "selectMoreAfter",
  15298. exec: function(editor) { editor.selectMore(1); },
  15299. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  15300. scrollIntoView: "cursor",
  15301. readOnly: true
  15302. }, {
  15303. name: "selectNextBefore",
  15304. exec: function(editor) { editor.selectMore(-1, true); },
  15305. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  15306. scrollIntoView: "cursor",
  15307. readOnly: true
  15308. }, {
  15309. name: "selectNextAfter",
  15310. exec: function(editor) { editor.selectMore(1, true); },
  15311. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  15312. scrollIntoView: "cursor",
  15313. readOnly: true
  15314. }, {
  15315. name: "splitIntoLines",
  15316. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  15317. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  15318. readOnly: true
  15319. }, {
  15320. name: "alignCursors",
  15321. exec: function(editor) { editor.alignCursors(); },
  15322. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  15323. scrollIntoView: "cursor"
  15324. }, {
  15325. name: "findAll",
  15326. exec: function(editor) { editor.findAll(); },
  15327. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  15328. scrollIntoView: "cursor",
  15329. readOnly: true
  15330. }];
  15331. exports.multiSelectCommands = [{
  15332. name: "singleSelection",
  15333. bindKey: "esc",
  15334. exec: function(editor) { editor.exitMultiSelectMode(); },
  15335. scrollIntoView: "cursor",
  15336. readOnly: true,
  15337. isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
  15338. }];
  15339. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  15340. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  15341. });
  15342. 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) {
  15343. var RangeList = require("./range_list").RangeList;
  15344. var Range = require("./range").Range;
  15345. var Selection = require("./selection").Selection;
  15346. var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
  15347. var event = require("./lib/event");
  15348. var lang = require("./lib/lang");
  15349. var commands = require("./commands/multi_select_commands");
  15350. exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
  15351. var Search = require("./search").Search;
  15352. var search = new Search();
  15353. function find(session, needle, dir) {
  15354. search.$options.wrap = true;
  15355. search.$options.needle = needle;
  15356. search.$options.backwards = dir == -1;
  15357. return search.find(session);
  15358. }
  15359. var EditSession = require("./edit_session").EditSession;
  15360. (function() {
  15361. this.getSelectionMarkers = function() {
  15362. return this.$selectionMarkers;
  15363. };
  15364. }).call(EditSession.prototype);
  15365. (function() {
  15366. this.ranges = null;
  15367. this.rangeList = null;
  15368. this.addRange = function(range, $blockChangeEvents) {
  15369. if (!range)
  15370. return;
  15371. if (!this.inMultiSelectMode && this.rangeCount === 0) {
  15372. var oldRange = this.toOrientedRange();
  15373. this.rangeList.add(oldRange);
  15374. this.rangeList.add(range);
  15375. if (this.rangeList.ranges.length != 2) {
  15376. this.rangeList.removeAll();
  15377. return $blockChangeEvents || this.fromOrientedRange(range);
  15378. }
  15379. this.rangeList.removeAll();
  15380. this.rangeList.add(oldRange);
  15381. this.$onAddRange(oldRange);
  15382. }
  15383. if (!range.cursor)
  15384. range.cursor = range.end;
  15385. var removed = this.rangeList.add(range);
  15386. this.$onAddRange(range);
  15387. if (removed.length)
  15388. this.$onRemoveRange(removed);
  15389. if (this.rangeCount > 1 && !this.inMultiSelectMode) {
  15390. this._signal("multiSelect");
  15391. this.inMultiSelectMode = true;
  15392. this.session.$undoSelect = false;
  15393. this.rangeList.attach(this.session);
  15394. }
  15395. return $blockChangeEvents || this.fromOrientedRange(range);
  15396. };
  15397. this.toSingleRange = function(range) {
  15398. range = range || this.ranges[0];
  15399. var removed = this.rangeList.removeAll();
  15400. if (removed.length)
  15401. this.$onRemoveRange(removed);
  15402. range && this.fromOrientedRange(range);
  15403. };
  15404. this.substractPoint = function(pos) {
  15405. var removed = this.rangeList.substractPoint(pos);
  15406. if (removed) {
  15407. this.$onRemoveRange(removed);
  15408. return removed[0];
  15409. }
  15410. };
  15411. this.mergeOverlappingRanges = function() {
  15412. var removed = this.rangeList.merge();
  15413. if (removed.length)
  15414. this.$onRemoveRange(removed);
  15415. else if(this.ranges[0])
  15416. this.fromOrientedRange(this.ranges[0]);
  15417. };
  15418. this.$onAddRange = function(range) {
  15419. this.rangeCount = this.rangeList.ranges.length;
  15420. this.ranges.unshift(range);
  15421. this._signal("addRange", {range: range});
  15422. };
  15423. this.$onRemoveRange = function(removed) {
  15424. this.rangeCount = this.rangeList.ranges.length;
  15425. if (this.rangeCount == 1 && this.inMultiSelectMode) {
  15426. var lastRange = this.rangeList.ranges.pop();
  15427. removed.push(lastRange);
  15428. this.rangeCount = 0;
  15429. }
  15430. for (var i = removed.length; i--; ) {
  15431. var index = this.ranges.indexOf(removed[i]);
  15432. this.ranges.splice(index, 1);
  15433. }
  15434. this._signal("removeRange", {ranges: removed});
  15435. if (this.rangeCount === 0 && this.inMultiSelectMode) {
  15436. this.inMultiSelectMode = false;
  15437. this._signal("singleSelect");
  15438. this.session.$undoSelect = true;
  15439. this.rangeList.detach(this.session);
  15440. }
  15441. lastRange = lastRange || this.ranges[0];
  15442. if (lastRange && !lastRange.isEqual(this.getRange()))
  15443. this.fromOrientedRange(lastRange);
  15444. };
  15445. this.$initRangeList = function() {
  15446. if (this.rangeList)
  15447. return;
  15448. this.rangeList = new RangeList();
  15449. this.ranges = [];
  15450. this.rangeCount = 0;
  15451. };
  15452. this.getAllRanges = function() {
  15453. return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
  15454. };
  15455. this.splitIntoLines = function () {
  15456. if (this.rangeCount > 1) {
  15457. var ranges = this.rangeList.ranges;
  15458. var lastRange = ranges[ranges.length - 1];
  15459. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15460. this.toSingleRange();
  15461. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15462. } else {
  15463. var range = this.getRange();
  15464. var isBackwards = this.isBackwards();
  15465. var startRow = range.start.row;
  15466. var endRow = range.end.row;
  15467. if (startRow == endRow) {
  15468. if (isBackwards)
  15469. var start = range.end, end = range.start;
  15470. else
  15471. var start = range.start, end = range.end;
  15472. this.addRange(Range.fromPoints(end, end));
  15473. this.addRange(Range.fromPoints(start, start));
  15474. return;
  15475. }
  15476. var rectSel = [];
  15477. var r = this.getLineRange(startRow, true);
  15478. r.start.column = range.start.column;
  15479. rectSel.push(r);
  15480. for (var i = startRow + 1; i < endRow; i++)
  15481. rectSel.push(this.getLineRange(i, true));
  15482. r = this.getLineRange(endRow, true);
  15483. r.end.column = range.end.column;
  15484. rectSel.push(r);
  15485. rectSel.forEach(this.addRange, this);
  15486. }
  15487. };
  15488. this.toggleBlockSelection = function () {
  15489. if (this.rangeCount > 1) {
  15490. var ranges = this.rangeList.ranges;
  15491. var lastRange = ranges[ranges.length - 1];
  15492. var range = Range.fromPoints(ranges[0].start, lastRange.end);
  15493. this.toSingleRange();
  15494. this.setSelectionRange(range, lastRange.cursor == lastRange.start);
  15495. } else {
  15496. var cursor = this.session.documentToScreenPosition(this.selectionLead);
  15497. var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
  15498. var rectSel = this.rectangularRangeBlock(cursor, anchor);
  15499. rectSel.forEach(this.addRange, this);
  15500. }
  15501. };
  15502. this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
  15503. var rectSel = [];
  15504. var xBackwards = screenCursor.column < screenAnchor.column;
  15505. if (xBackwards) {
  15506. var startColumn = screenCursor.column;
  15507. var endColumn = screenAnchor.column;
  15508. } else {
  15509. var startColumn = screenAnchor.column;
  15510. var endColumn = screenCursor.column;
  15511. }
  15512. var yBackwards = screenCursor.row < screenAnchor.row;
  15513. if (yBackwards) {
  15514. var startRow = screenCursor.row;
  15515. var endRow = screenAnchor.row;
  15516. } else {
  15517. var startRow = screenAnchor.row;
  15518. var endRow = screenCursor.row;
  15519. }
  15520. if (startColumn < 0)
  15521. startColumn = 0;
  15522. if (startRow < 0)
  15523. startRow = 0;
  15524. if (startRow == endRow)
  15525. includeEmptyLines = true;
  15526. for (var row = startRow; row <= endRow; row++) {
  15527. var range = Range.fromPoints(
  15528. this.session.screenToDocumentPosition(row, startColumn),
  15529. this.session.screenToDocumentPosition(row, endColumn)
  15530. );
  15531. if (range.isEmpty()) {
  15532. if (docEnd && isSamePoint(range.end, docEnd))
  15533. break;
  15534. var docEnd = range.end;
  15535. }
  15536. range.cursor = xBackwards ? range.start : range.end;
  15537. rectSel.push(range);
  15538. }
  15539. if (yBackwards)
  15540. rectSel.reverse();
  15541. if (!includeEmptyLines) {
  15542. var end = rectSel.length - 1;
  15543. while (rectSel[end].isEmpty() && end > 0)
  15544. end--;
  15545. if (end > 0) {
  15546. var start = 0;
  15547. while (rectSel[start].isEmpty())
  15548. start++;
  15549. }
  15550. for (var i = end; i >= start; i--) {
  15551. if (rectSel[i].isEmpty())
  15552. rectSel.splice(i, 1);
  15553. }
  15554. }
  15555. return rectSel;
  15556. };
  15557. }).call(Selection.prototype);
  15558. var Editor = require("./editor").Editor;
  15559. (function() {
  15560. this.updateSelectionMarkers = function() {
  15561. this.renderer.updateCursor();
  15562. this.renderer.updateBackMarkers();
  15563. };
  15564. this.addSelectionMarker = function(orientedRange) {
  15565. if (!orientedRange.cursor)
  15566. orientedRange.cursor = orientedRange.end;
  15567. var style = this.getSelectionStyle();
  15568. orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
  15569. this.session.$selectionMarkers.push(orientedRange);
  15570. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15571. return orientedRange;
  15572. };
  15573. this.removeSelectionMarker = function(range) {
  15574. if (!range.marker)
  15575. return;
  15576. this.session.removeMarker(range.marker);
  15577. var index = this.session.$selectionMarkers.indexOf(range);
  15578. if (index != -1)
  15579. this.session.$selectionMarkers.splice(index, 1);
  15580. this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
  15581. };
  15582. this.removeSelectionMarkers = function(ranges) {
  15583. var markerList = this.session.$selectionMarkers;
  15584. for (var i = ranges.length; i--; ) {
  15585. var range = ranges[i];
  15586. if (!range.marker)
  15587. continue;
  15588. this.session.removeMarker(range.marker);
  15589. var index = markerList.indexOf(range);
  15590. if (index != -1)
  15591. markerList.splice(index, 1);
  15592. }
  15593. this.session.selectionMarkerCount = markerList.length;
  15594. };
  15595. this.$onAddRange = function(e) {
  15596. this.addSelectionMarker(e.range);
  15597. this.renderer.updateCursor();
  15598. this.renderer.updateBackMarkers();
  15599. };
  15600. this.$onRemoveRange = function(e) {
  15601. this.removeSelectionMarkers(e.ranges);
  15602. this.renderer.updateCursor();
  15603. this.renderer.updateBackMarkers();
  15604. };
  15605. this.$onMultiSelect = function(e) {
  15606. if (this.inMultiSelectMode)
  15607. return;
  15608. this.inMultiSelectMode = true;
  15609. this.setStyle("ace_multiselect");
  15610. this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
  15611. this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
  15612. this.renderer.updateCursor();
  15613. this.renderer.updateBackMarkers();
  15614. };
  15615. this.$onSingleSelect = function(e) {
  15616. if (this.session.multiSelect.inVirtualMode)
  15617. return;
  15618. this.inMultiSelectMode = false;
  15619. this.unsetStyle("ace_multiselect");
  15620. this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
  15621. this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
  15622. this.renderer.updateCursor();
  15623. this.renderer.updateBackMarkers();
  15624. this._emit("changeSelection");
  15625. };
  15626. this.$onMultiSelectExec = function(e) {
  15627. var command = e.command;
  15628. var editor = e.editor;
  15629. if (!editor.multiSelect)
  15630. return;
  15631. if (!command.multiSelectAction) {
  15632. var result = command.exec(editor, e.args || {});
  15633. editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
  15634. editor.multiSelect.mergeOverlappingRanges();
  15635. } else if (command.multiSelectAction == "forEach") {
  15636. result = editor.forEachSelection(command, e.args);
  15637. } else if (command.multiSelectAction == "forEachLine") {
  15638. result = editor.forEachSelection(command, e.args, true);
  15639. } else if (command.multiSelectAction == "single") {
  15640. editor.exitMultiSelectMode();
  15641. result = command.exec(editor, e.args || {});
  15642. } else {
  15643. result = command.multiSelectAction(editor, e.args || {});
  15644. }
  15645. return result;
  15646. };
  15647. this.forEachSelection = function(cmd, args, options) {
  15648. if (this.inVirtualSelectionMode)
  15649. return;
  15650. var keepOrder = options && options.keepOrder;
  15651. var $byLines = options == true || options && options.$byLines
  15652. var session = this.session;
  15653. var selection = this.selection;
  15654. var rangeList = selection.rangeList;
  15655. var ranges = (keepOrder ? selection : rangeList).ranges;
  15656. var result;
  15657. if (!ranges.length)
  15658. return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15659. var reg = selection._eventRegistry;
  15660. selection._eventRegistry = {};
  15661. var tmpSel = new Selection(session);
  15662. this.inVirtualSelectionMode = true;
  15663. for (var i = ranges.length; i--;) {
  15664. if ($byLines) {
  15665. while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
  15666. i--;
  15667. }
  15668. tmpSel.fromOrientedRange(ranges[i]);
  15669. tmpSel.index = i;
  15670. this.selection = session.selection = tmpSel;
  15671. var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
  15672. if (!result && cmdResult !== undefined)
  15673. result = cmdResult;
  15674. tmpSel.toOrientedRange(ranges[i]);
  15675. }
  15676. tmpSel.detach();
  15677. this.selection = session.selection = selection;
  15678. this.inVirtualSelectionMode = false;
  15679. selection._eventRegistry = reg;
  15680. selection.mergeOverlappingRanges();
  15681. var anim = this.renderer.$scrollAnimation;
  15682. this.onCursorChange();
  15683. this.onSelectionChange();
  15684. if (anim && anim.from == anim.to)
  15685. this.renderer.animateScrolling(anim.from);
  15686. return result;
  15687. };
  15688. this.exitMultiSelectMode = function() {
  15689. if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
  15690. return;
  15691. this.multiSelect.toSingleRange();
  15692. };
  15693. this.getSelectedText = function() {
  15694. var text = "";
  15695. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15696. var ranges = this.multiSelect.rangeList.ranges;
  15697. var buf = [];
  15698. for (var i = 0; i < ranges.length; i++) {
  15699. buf.push(this.session.getTextRange(ranges[i]));
  15700. }
  15701. var nl = this.session.getDocument().getNewLineCharacter();
  15702. text = buf.join(nl);
  15703. if (text.length == (buf.length - 1) * nl.length)
  15704. text = "";
  15705. } else if (!this.selection.isEmpty()) {
  15706. text = this.session.getTextRange(this.getSelectionRange());
  15707. }
  15708. return text;
  15709. };
  15710. this.$checkMultiselectChange = function(e, anchor) {
  15711. if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
  15712. var range = this.multiSelect.ranges[0];
  15713. if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
  15714. return;
  15715. var pos = anchor == this.multiSelect.anchor
  15716. ? range.cursor == range.start ? range.end : range.start
  15717. : range.cursor;
  15718. if (pos.row != anchor.row
  15719. || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
  15720. this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
  15721. }
  15722. };
  15723. this.findAll = function(needle, options, additive) {
  15724. options = options || {};
  15725. options.needle = needle || options.needle;
  15726. if (options.needle == undefined) {
  15727. var range = this.selection.isEmpty()
  15728. ? this.selection.getWordRange()
  15729. : this.selection.getRange();
  15730. options.needle = this.session.getTextRange(range);
  15731. }
  15732. this.$search.set(options);
  15733. var ranges = this.$search.findAll(this.session);
  15734. if (!ranges.length)
  15735. return 0;
  15736. this.$blockScrolling += 1;
  15737. var selection = this.multiSelect;
  15738. if (!additive)
  15739. selection.toSingleRange(ranges[0]);
  15740. for (var i = ranges.length; i--; )
  15741. selection.addRange(ranges[i], true);
  15742. if (range && selection.rangeList.rangeAtPoint(range.start))
  15743. selection.addRange(range, true);
  15744. this.$blockScrolling -= 1;
  15745. return ranges.length;
  15746. };
  15747. this.selectMoreLines = function(dir, skip) {
  15748. var range = this.selection.toOrientedRange();
  15749. var isBackwards = range.cursor == range.end;
  15750. var screenLead = this.session.documentToScreenPosition(range.cursor);
  15751. if (this.selection.$desiredColumn)
  15752. screenLead.column = this.selection.$desiredColumn;
  15753. var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
  15754. if (!range.isEmpty()) {
  15755. var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
  15756. var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
  15757. } else {
  15758. var anchor = lead;
  15759. }
  15760. if (isBackwards) {
  15761. var newRange = Range.fromPoints(lead, anchor);
  15762. newRange.cursor = newRange.start;
  15763. } else {
  15764. var newRange = Range.fromPoints(anchor, lead);
  15765. newRange.cursor = newRange.end;
  15766. }
  15767. newRange.desiredColumn = screenLead.column;
  15768. if (!this.selection.inMultiSelectMode) {
  15769. this.selection.addRange(range);
  15770. } else {
  15771. if (skip)
  15772. var toRemove = range.cursor;
  15773. }
  15774. this.selection.addRange(newRange);
  15775. if (toRemove)
  15776. this.selection.substractPoint(toRemove);
  15777. };
  15778. this.transposeSelections = function(dir) {
  15779. var session = this.session;
  15780. var sel = session.multiSelect;
  15781. var all = sel.ranges;
  15782. for (var i = all.length; i--; ) {
  15783. var range = all[i];
  15784. if (range.isEmpty()) {
  15785. var tmp = session.getWordRange(range.start.row, range.start.column);
  15786. range.start.row = tmp.start.row;
  15787. range.start.column = tmp.start.column;
  15788. range.end.row = tmp.end.row;
  15789. range.end.column = tmp.end.column;
  15790. }
  15791. }
  15792. sel.mergeOverlappingRanges();
  15793. var words = [];
  15794. for (var i = all.length; i--; ) {
  15795. var range = all[i];
  15796. words.unshift(session.getTextRange(range));
  15797. }
  15798. if (dir < 0)
  15799. words.unshift(words.pop());
  15800. else
  15801. words.push(words.shift());
  15802. for (var i = all.length; i--; ) {
  15803. var range = all[i];
  15804. var tmp = range.clone();
  15805. session.replace(range, words[i]);
  15806. range.start.row = tmp.start.row;
  15807. range.start.column = tmp.start.column;
  15808. }
  15809. };
  15810. this.selectMore = function(dir, skip, stopAtFirst) {
  15811. var session = this.session;
  15812. var sel = session.multiSelect;
  15813. var range = sel.toOrientedRange();
  15814. if (range.isEmpty()) {
  15815. range = session.getWordRange(range.start.row, range.start.column);
  15816. range.cursor = dir == -1 ? range.start : range.end;
  15817. this.multiSelect.addRange(range);
  15818. if (stopAtFirst)
  15819. return;
  15820. }
  15821. var needle = session.getTextRange(range);
  15822. var newRange = find(session, needle, dir);
  15823. if (newRange) {
  15824. newRange.cursor = dir == -1 ? newRange.start : newRange.end;
  15825. this.$blockScrolling += 1;
  15826. this.session.unfold(newRange);
  15827. this.multiSelect.addRange(newRange);
  15828. this.$blockScrolling -= 1;
  15829. this.renderer.scrollCursorIntoView(null, 0.5);
  15830. }
  15831. if (skip)
  15832. this.multiSelect.substractPoint(range.cursor);
  15833. };
  15834. this.alignCursors = function() {
  15835. var session = this.session;
  15836. var sel = session.multiSelect;
  15837. var ranges = sel.ranges;
  15838. var row = -1;
  15839. var sameRowRanges = ranges.filter(function(r) {
  15840. if (r.cursor.row == row)
  15841. return true;
  15842. row = r.cursor.row;
  15843. });
  15844. if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
  15845. var range = this.selection.getRange();
  15846. var fr = range.start.row, lr = range.end.row;
  15847. var guessRange = fr == lr;
  15848. if (guessRange) {
  15849. var max = this.session.getLength();
  15850. var line;
  15851. do {
  15852. line = this.session.getLine(lr);
  15853. } while (/[=:]/.test(line) && ++lr < max);
  15854. do {
  15855. line = this.session.getLine(fr);
  15856. } while (/[=:]/.test(line) && --fr > 0);
  15857. if (fr < 0) fr = 0;
  15858. if (lr >= max) lr = max - 1;
  15859. }
  15860. var lines = this.session.removeFullLines(fr, lr);
  15861. lines = this.$reAlignText(lines, guessRange);
  15862. this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
  15863. if (!guessRange) {
  15864. range.start.column = 0;
  15865. range.end.column = lines[lines.length - 1].length;
  15866. }
  15867. this.selection.setRange(range);
  15868. } else {
  15869. sameRowRanges.forEach(function(r) {
  15870. sel.substractPoint(r.cursor);
  15871. });
  15872. var maxCol = 0;
  15873. var minSpace = Infinity;
  15874. var spaceOffsets = ranges.map(function(r) {
  15875. var p = r.cursor;
  15876. var line = session.getLine(p.row);
  15877. var spaceOffset = line.substr(p.column).search(/\S/g);
  15878. if (spaceOffset == -1)
  15879. spaceOffset = 0;
  15880. if (p.column > maxCol)
  15881. maxCol = p.column;
  15882. if (spaceOffset < minSpace)
  15883. minSpace = spaceOffset;
  15884. return spaceOffset;
  15885. });
  15886. ranges.forEach(function(r, i) {
  15887. var p = r.cursor;
  15888. var l = maxCol - p.column;
  15889. var d = spaceOffsets[i] - minSpace;
  15890. if (l > d)
  15891. session.insert(p, lang.stringRepeat(" ", l - d));
  15892. else
  15893. session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
  15894. r.start.column = r.end.column = maxCol;
  15895. r.start.row = r.end.row = p.row;
  15896. r.cursor = r.end;
  15897. });
  15898. sel.fromOrientedRange(ranges[0]);
  15899. this.renderer.updateCursor();
  15900. this.renderer.updateBackMarkers();
  15901. }
  15902. };
  15903. this.$reAlignText = function(lines, forceLeft) {
  15904. var isLeftAligned = true, isRightAligned = true;
  15905. var startW, textW, endW;
  15906. return lines.map(function(line) {
  15907. var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
  15908. if (!m)
  15909. return [line];
  15910. if (startW == null) {
  15911. startW = m[1].length;
  15912. textW = m[2].length;
  15913. endW = m[3].length;
  15914. return m;
  15915. }
  15916. if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
  15917. isRightAligned = false;
  15918. if (startW != m[1].length)
  15919. isLeftAligned = false;
  15920. if (startW > m[1].length)
  15921. startW = m[1].length;
  15922. if (textW < m[2].length)
  15923. textW = m[2].length;
  15924. if (endW > m[3].length)
  15925. endW = m[3].length;
  15926. return m;
  15927. }).map(forceLeft ? alignLeft :
  15928. isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
  15929. function spaces(n) {
  15930. return lang.stringRepeat(" ", n);
  15931. }
  15932. function alignLeft(m) {
  15933. return !m[2] ? m[0] : spaces(startW) + m[2]
  15934. + spaces(textW - m[2].length + endW)
  15935. + m[4].replace(/^([=:])\s+/, "$1 ");
  15936. }
  15937. function alignRight(m) {
  15938. return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
  15939. + spaces(endW, " ")
  15940. + m[4].replace(/^([=:])\s+/, "$1 ");
  15941. }
  15942. function unAlign(m) {
  15943. return !m[2] ? m[0] : spaces(startW) + m[2]
  15944. + spaces(endW)
  15945. + m[4].replace(/^([=:])\s+/, "$1 ");
  15946. }
  15947. };
  15948. }).call(Editor.prototype);
  15949. function isSamePoint(p1, p2) {
  15950. return p1.row == p2.row && p1.column == p2.column;
  15951. }
  15952. exports.onSessionChange = function(e) {
  15953. var session = e.session;
  15954. if (session && !session.multiSelect) {
  15955. session.$selectionMarkers = [];
  15956. session.selection.$initRangeList();
  15957. session.multiSelect = session.selection;
  15958. }
  15959. this.multiSelect = session && session.multiSelect;
  15960. var oldSession = e.oldSession;
  15961. if (oldSession) {
  15962. oldSession.multiSelect.off("addRange", this.$onAddRange);
  15963. oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
  15964. oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
  15965. oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
  15966. oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
  15967. oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
  15968. }
  15969. if (session) {
  15970. session.multiSelect.on("addRange", this.$onAddRange);
  15971. session.multiSelect.on("removeRange", this.$onRemoveRange);
  15972. session.multiSelect.on("multiSelect", this.$onMultiSelect);
  15973. session.multiSelect.on("singleSelect", this.$onSingleSelect);
  15974. session.multiSelect.lead.on("change", this.$checkMultiselectChange);
  15975. session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
  15976. }
  15977. if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
  15978. if (session.selection.inMultiSelectMode)
  15979. this.$onMultiSelect();
  15980. else
  15981. this.$onSingleSelect();
  15982. }
  15983. };
  15984. function MultiSelect(editor) {
  15985. if (editor.$multiselectOnSessionChange)
  15986. return;
  15987. editor.$onAddRange = editor.$onAddRange.bind(editor);
  15988. editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
  15989. editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
  15990. editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
  15991. editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
  15992. editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
  15993. editor.$multiselectOnSessionChange(editor);
  15994. editor.on("changeSession", editor.$multiselectOnSessionChange);
  15995. editor.on("mousedown", onMouseDown);
  15996. editor.commands.addCommands(commands.defaultCommands);
  15997. addAltCursorListeners(editor);
  15998. }
  15999. function addAltCursorListeners(editor){
  16000. var el = editor.textInput.getElement();
  16001. var altCursor = false;
  16002. event.addListener(el, "keydown", function(e) {
  16003. var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey);
  16004. if (editor.$blockSelectEnabled && altDown) {
  16005. if (!altCursor) {
  16006. editor.renderer.setMouseCursor("crosshair");
  16007. altCursor = true;
  16008. }
  16009. } else if (altCursor) {
  16010. reset();
  16011. }
  16012. });
  16013. event.addListener(el, "keyup", reset);
  16014. event.addListener(el, "blur", reset);
  16015. function reset(e) {
  16016. if (altCursor) {
  16017. editor.renderer.setMouseCursor("");
  16018. altCursor = false;
  16019. }
  16020. }
  16021. }
  16022. exports.MultiSelect = MultiSelect;
  16023. require("./config").defineOptions(Editor.prototype, "editor", {
  16024. enableMultiselect: {
  16025. set: function(val) {
  16026. MultiSelect(this);
  16027. if (val) {
  16028. this.on("changeSession", this.$multiselectOnSessionChange);
  16029. this.on("mousedown", onMouseDown);
  16030. } else {
  16031. this.off("changeSession", this.$multiselectOnSessionChange);
  16032. this.off("mousedown", onMouseDown);
  16033. }
  16034. },
  16035. value: true
  16036. },
  16037. enableBlockSelect: {
  16038. set: function(val) {
  16039. this.$blockSelectEnabled = val;
  16040. },
  16041. value: true
  16042. }
  16043. });
  16044. });
  16045. ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
  16046. "use strict";
  16047. var Range = require("../../range").Range;
  16048. var FoldMode = exports.FoldMode = function() {};
  16049. (function() {
  16050. this.foldingStartMarker = null;
  16051. this.foldingStopMarker = null;
  16052. this.getFoldWidget = function(session, foldStyle, row) {
  16053. var line = session.getLine(row);
  16054. if (this.foldingStartMarker.test(line))
  16055. return "start";
  16056. if (foldStyle == "markbeginend"
  16057. && this.foldingStopMarker
  16058. && this.foldingStopMarker.test(line))
  16059. return "end";
  16060. return "";
  16061. };
  16062. this.getFoldWidgetRange = function(session, foldStyle, row) {
  16063. return null;
  16064. };
  16065. this.indentationBlock = function(session, row, column) {
  16066. var re = /\S/;
  16067. var line = session.getLine(row);
  16068. var startLevel = line.search(re);
  16069. if (startLevel == -1)
  16070. return;
  16071. var startColumn = column || line.length;
  16072. var maxRow = session.getLength();
  16073. var startRow = row;
  16074. var endRow = row;
  16075. while (++row < maxRow) {
  16076. var level = session.getLine(row).search(re);
  16077. if (level == -1)
  16078. continue;
  16079. if (level <= startLevel)
  16080. break;
  16081. endRow = row;
  16082. }
  16083. if (endRow > startRow) {
  16084. var endColumn = session.getLine(endRow).length;
  16085. return new Range(startRow, startColumn, endRow, endColumn);
  16086. }
  16087. };
  16088. this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
  16089. var start = {row: row, column: column + 1};
  16090. var end = session.$findClosingBracket(bracket, start, typeRe);
  16091. if (!end)
  16092. return;
  16093. var fw = session.foldWidgets[end.row];
  16094. if (fw == null)
  16095. fw = session.getFoldWidget(end.row);
  16096. if (fw == "start" && end.row > start.row) {
  16097. end.row --;
  16098. end.column = session.getLine(end.row).length;
  16099. }
  16100. return Range.fromPoints(start, end);
  16101. };
  16102. this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
  16103. var end = {row: row, column: column};
  16104. var start = session.$findOpeningBracket(bracket, end);
  16105. if (!start)
  16106. return;
  16107. start.column++;
  16108. end.column--;
  16109. return Range.fromPoints(start, end);
  16110. };
  16111. }).call(FoldMode.prototype);
  16112. });
  16113. ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
  16114. "use strict";
  16115. exports.isDark = false;
  16116. exports.cssClass = "ace-tm";
  16117. exports.cssText = ".ace-tm .ace_gutter {\
  16118. background: #f0f0f0;\
  16119. color: #333;\
  16120. }\
  16121. .ace-tm .ace_print-margin {\
  16122. width: 1px;\
  16123. background: #e8e8e8;\
  16124. }\
  16125. .ace-tm .ace_fold {\
  16126. background-color: #6B72E6;\
  16127. }\
  16128. .ace-tm {\
  16129. background-color: #FFFFFF;\
  16130. color: black;\
  16131. }\
  16132. .ace-tm .ace_cursor {\
  16133. color: black;\
  16134. }\
  16135. .ace-tm .ace_invisible {\
  16136. color: rgb(191, 191, 191);\
  16137. }\
  16138. .ace-tm .ace_storage,\
  16139. .ace-tm .ace_keyword {\
  16140. color: blue;\
  16141. }\
  16142. .ace-tm .ace_constant {\
  16143. color: rgb(197, 6, 11);\
  16144. }\
  16145. .ace-tm .ace_constant.ace_buildin {\
  16146. color: rgb(88, 72, 246);\
  16147. }\
  16148. .ace-tm .ace_constant.ace_language {\
  16149. color: rgb(88, 92, 246);\
  16150. }\
  16151. .ace-tm .ace_constant.ace_library {\
  16152. color: rgb(6, 150, 14);\
  16153. }\
  16154. .ace-tm .ace_invalid {\
  16155. background-color: rgba(255, 0, 0, 0.1);\
  16156. color: red;\
  16157. }\
  16158. .ace-tm .ace_support.ace_function {\
  16159. color: rgb(60, 76, 114);\
  16160. }\
  16161. .ace-tm .ace_support.ace_constant {\
  16162. color: rgb(6, 150, 14);\
  16163. }\
  16164. .ace-tm .ace_support.ace_type,\
  16165. .ace-tm .ace_support.ace_class {\
  16166. color: rgb(109, 121, 222);\
  16167. }\
  16168. .ace-tm .ace_keyword.ace_operator {\
  16169. color: rgb(104, 118, 135);\
  16170. }\
  16171. .ace-tm .ace_string {\
  16172. color: rgb(3, 106, 7);\
  16173. }\
  16174. .ace-tm .ace_comment {\
  16175. color: rgb(76, 136, 107);\
  16176. }\
  16177. .ace-tm .ace_comment.ace_doc {\
  16178. color: rgb(0, 102, 255);\
  16179. }\
  16180. .ace-tm .ace_comment.ace_doc.ace_tag {\
  16181. color: rgb(128, 159, 191);\
  16182. }\
  16183. .ace-tm .ace_constant.ace_numeric {\
  16184. color: rgb(0, 0, 205);\
  16185. }\
  16186. .ace-tm .ace_variable {\
  16187. color: rgb(49, 132, 149);\
  16188. }\
  16189. .ace-tm .ace_xml-pe {\
  16190. color: rgb(104, 104, 91);\
  16191. }\
  16192. .ace-tm .ace_entity.ace_name.ace_function {\
  16193. color: #0000A2;\
  16194. }\
  16195. .ace-tm .ace_heading {\
  16196. color: rgb(12, 7, 255);\
  16197. }\
  16198. .ace-tm .ace_list {\
  16199. color:rgb(185, 6, 144);\
  16200. }\
  16201. .ace-tm .ace_meta.ace_tag {\
  16202. color:rgb(0, 22, 142);\
  16203. }\
  16204. .ace-tm .ace_string.ace_regex {\
  16205. color: rgb(255, 0, 0)\
  16206. }\
  16207. .ace-tm .ace_marker-layer .ace_selection {\
  16208. background: rgb(181, 213, 255);\
  16209. }\
  16210. .ace-tm.ace_multiselect .ace_selection.ace_start {\
  16211. box-shadow: 0 0 3px 0px white;\
  16212. }\
  16213. .ace-tm .ace_marker-layer .ace_step {\
  16214. background: rgb(252, 255, 0);\
  16215. }\
  16216. .ace-tm .ace_marker-layer .ace_stack {\
  16217. background: rgb(164, 229, 101);\
  16218. }\
  16219. .ace-tm .ace_marker-layer .ace_bracket {\
  16220. margin: -1px 0 0 -1px;\
  16221. border: 1px solid rgb(192, 192, 192);\
  16222. }\
  16223. .ace-tm .ace_marker-layer .ace_active-line {\
  16224. background: rgba(0, 0, 0, 0.07);\
  16225. }\
  16226. .ace-tm .ace_gutter-active-line {\
  16227. background-color : #dcdcdc;\
  16228. }\
  16229. .ace-tm .ace_marker-layer .ace_selected-word {\
  16230. background: rgb(250, 250, 255);\
  16231. border: 1px solid rgb(200, 200, 250);\
  16232. }\
  16233. .ace-tm .ace_indent-guide {\
  16234. background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
  16235. }\
  16236. ";
  16237. var dom = require("../lib/dom");
  16238. dom.importCssString(exports.cssText, exports.cssClass);
  16239. });
  16240. ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
  16241. "use strict";
  16242. var oop = require("./lib/oop");
  16243. var dom = require("./lib/dom");
  16244. var Range = require("./range").Range;
  16245. function LineWidgets(session) {
  16246. this.session = session;
  16247. this.session.widgetManager = this;
  16248. this.session.getRowLength = this.getRowLength;
  16249. this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
  16250. this.updateOnChange = this.updateOnChange.bind(this);
  16251. this.renderWidgets = this.renderWidgets.bind(this);
  16252. this.measureWidgets = this.measureWidgets.bind(this);
  16253. this.session._changedWidgets = [];
  16254. this.$onChangeEditor = this.$onChangeEditor.bind(this);
  16255. this.session.on("change", this.updateOnChange);
  16256. this.session.on("changeFold", this.updateOnFold);
  16257. this.session.on("changeEditor", this.$onChangeEditor);
  16258. }
  16259. (function() {
  16260. this.getRowLength = function(row) {
  16261. var h;
  16262. if (this.lineWidgets)
  16263. h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
  16264. else
  16265. h = 0;
  16266. if (!this.$useWrapMode || !this.$wrapData[row]) {
  16267. return 1 + h;
  16268. } else {
  16269. return this.$wrapData[row].length + 1 + h;
  16270. }
  16271. };
  16272. this.$getWidgetScreenLength = function() {
  16273. var screenRows = 0;
  16274. this.lineWidgets.forEach(function(w){
  16275. if (w && w.rowCount && !w.hidden)
  16276. screenRows += w.rowCount;
  16277. });
  16278. return screenRows;
  16279. };
  16280. this.$onChangeEditor = function(e) {
  16281. this.attach(e.editor);
  16282. };
  16283. this.attach = function(editor) {
  16284. if (editor && editor.widgetManager && editor.widgetManager != this)
  16285. editor.widgetManager.detach();
  16286. if (this.editor == editor)
  16287. return;
  16288. this.detach();
  16289. this.editor = editor;
  16290. if (editor) {
  16291. editor.widgetManager = this;
  16292. editor.renderer.on("beforeRender", this.measureWidgets);
  16293. editor.renderer.on("afterRender", this.renderWidgets);
  16294. }
  16295. };
  16296. this.detach = function(e) {
  16297. var editor = this.editor;
  16298. if (!editor)
  16299. return;
  16300. this.editor = null;
  16301. editor.widgetManager = null;
  16302. editor.renderer.off("beforeRender", this.measureWidgets);
  16303. editor.renderer.off("afterRender", this.renderWidgets);
  16304. var lineWidgets = this.session.lineWidgets;
  16305. lineWidgets && lineWidgets.forEach(function(w) {
  16306. if (w && w.el && w.el.parentNode) {
  16307. w._inDocument = false;
  16308. w.el.parentNode.removeChild(w.el);
  16309. }
  16310. });
  16311. };
  16312. this.updateOnFold = function(e, session) {
  16313. var lineWidgets = session.lineWidgets;
  16314. if (!lineWidgets || !e.action)
  16315. return;
  16316. var fold = e.data;
  16317. var start = fold.start.row;
  16318. var end = fold.end.row;
  16319. var hide = e.action == "add";
  16320. for (var i = start + 1; i < end; i++) {
  16321. if (lineWidgets[i])
  16322. lineWidgets[i].hidden = hide;
  16323. }
  16324. if (lineWidgets[end]) {
  16325. if (hide) {
  16326. if (!lineWidgets[start])
  16327. lineWidgets[start] = lineWidgets[end];
  16328. else
  16329. lineWidgets[end].hidden = hide;
  16330. } else {
  16331. if (lineWidgets[start] == lineWidgets[end])
  16332. lineWidgets[start] = undefined;
  16333. lineWidgets[end].hidden = hide;
  16334. }
  16335. }
  16336. };
  16337. this.updateOnChange = function(delta) {
  16338. var lineWidgets = this.session.lineWidgets;
  16339. if (!lineWidgets) return;
  16340. var startRow = delta.start.row;
  16341. var len = delta.end.row - startRow;
  16342. if (len === 0) {
  16343. } else if (delta.action == 'remove') {
  16344. var removed = lineWidgets.splice(startRow + 1, len);
  16345. removed.forEach(function(w) {
  16346. w && this.removeLineWidget(w);
  16347. }, this);
  16348. this.$updateRows();
  16349. } else {
  16350. var args = new Array(len);
  16351. args.unshift(startRow, 0);
  16352. lineWidgets.splice.apply(lineWidgets, args);
  16353. this.$updateRows();
  16354. }
  16355. };
  16356. this.$updateRows = function() {
  16357. var lineWidgets = this.session.lineWidgets;
  16358. if (!lineWidgets) return;
  16359. var noWidgets = true;
  16360. lineWidgets.forEach(function(w, i) {
  16361. if (w) {
  16362. noWidgets = false;
  16363. w.row = i;
  16364. while (w.$oldWidget) {
  16365. w.$oldWidget.row = i;
  16366. w = w.$oldWidget;
  16367. }
  16368. }
  16369. });
  16370. if (noWidgets)
  16371. this.session.lineWidgets = null;
  16372. };
  16373. this.addLineWidget = function(w) {
  16374. if (!this.session.lineWidgets)
  16375. this.session.lineWidgets = new Array(this.session.getLength());
  16376. var old = this.session.lineWidgets[w.row];
  16377. if (old) {
  16378. w.$oldWidget = old;
  16379. if (old.el && old.el.parentNode) {
  16380. old.el.parentNode.removeChild(old.el);
  16381. old._inDocument = false;
  16382. }
  16383. }
  16384. this.session.lineWidgets[w.row] = w;
  16385. w.session = this.session;
  16386. var renderer = this.editor.renderer;
  16387. if (w.html && !w.el) {
  16388. w.el = dom.createElement("div");
  16389. w.el.innerHTML = w.html;
  16390. }
  16391. if (w.el) {
  16392. dom.addCssClass(w.el, "ace_lineWidgetContainer");
  16393. w.el.style.position = "absolute";
  16394. w.el.style.zIndex = 5;
  16395. renderer.container.appendChild(w.el);
  16396. w._inDocument = true;
  16397. }
  16398. if (!w.coverGutter) {
  16399. w.el.style.zIndex = 3;
  16400. }
  16401. if (w.pixelHeight == null) {
  16402. w.pixelHeight = w.el.offsetHeight;
  16403. }
  16404. if (w.rowCount == null) {
  16405. w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
  16406. }
  16407. var fold = this.session.getFoldAt(w.row, 0);
  16408. w.$fold = fold;
  16409. if (fold) {
  16410. var lineWidgets = this.session.lineWidgets;
  16411. if (w.row == fold.end.row && !lineWidgets[fold.start.row])
  16412. lineWidgets[fold.start.row] = w;
  16413. else
  16414. w.hidden = true;
  16415. }
  16416. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  16417. this.$updateRows();
  16418. this.renderWidgets(null, renderer);
  16419. this.onWidgetChanged(w);
  16420. return w;
  16421. };
  16422. this.removeLineWidget = function(w) {
  16423. w._inDocument = false;
  16424. w.session = null;
  16425. if (w.el && w.el.parentNode)
  16426. w.el.parentNode.removeChild(w.el);
  16427. if (w.editor && w.editor.destroy) try {
  16428. w.editor.destroy();
  16429. } catch(e){}
  16430. if (this.session.lineWidgets) {
  16431. var w1 = this.session.lineWidgets[w.row]
  16432. if (w1 == w) {
  16433. this.session.lineWidgets[w.row] = w.$oldWidget;
  16434. if (w.$oldWidget)
  16435. this.onWidgetChanged(w.$oldWidget);
  16436. } else {
  16437. while (w1) {
  16438. if (w1.$oldWidget == w) {
  16439. w1.$oldWidget = w.$oldWidget;
  16440. break;
  16441. }
  16442. w1 = w1.$oldWidget;
  16443. }
  16444. }
  16445. }
  16446. this.session._emit("changeFold", {data:{start:{row: w.row}}});
  16447. this.$updateRows();
  16448. };
  16449. this.getWidgetsAtRow = function(row) {
  16450. var lineWidgets = this.session.lineWidgets;
  16451. var w = lineWidgets && lineWidgets[row];
  16452. var list = [];
  16453. while (w) {
  16454. list.push(w);
  16455. w = w.$oldWidget;
  16456. }
  16457. return list;
  16458. };
  16459. this.onWidgetChanged = function(w) {
  16460. this.session._changedWidgets.push(w);
  16461. this.editor && this.editor.renderer.updateFull();
  16462. };
  16463. this.measureWidgets = function(e, renderer) {
  16464. var changedWidgets = this.session._changedWidgets;
  16465. var config = renderer.layerConfig;
  16466. if (!changedWidgets || !changedWidgets.length) return;
  16467. var min = Infinity;
  16468. for (var i = 0; i < changedWidgets.length; i++) {
  16469. var w = changedWidgets[i];
  16470. if (!w || !w.el) continue;
  16471. if (w.session != this.session) continue;
  16472. if (!w._inDocument) {
  16473. if (this.session.lineWidgets[w.row] != w)
  16474. continue;
  16475. w._inDocument = true;
  16476. renderer.container.appendChild(w.el);
  16477. }
  16478. w.h = w.el.offsetHeight;
  16479. if (!w.fixedWidth) {
  16480. w.w = w.el.offsetWidth;
  16481. w.screenWidth = Math.ceil(w.w / config.characterWidth);
  16482. }
  16483. var rowCount = w.h / config.lineHeight;
  16484. if (w.coverLine) {
  16485. rowCount -= this.session.getRowLineCount(w.row);
  16486. if (rowCount < 0)
  16487. rowCount = 0;
  16488. }
  16489. if (w.rowCount != rowCount) {
  16490. w.rowCount = rowCount;
  16491. if (w.row < min)
  16492. min = w.row;
  16493. }
  16494. }
  16495. if (min != Infinity) {
  16496. this.session._emit("changeFold", {data:{start:{row: min}}});
  16497. this.session.lineWidgetWidth = null;
  16498. }
  16499. this.session._changedWidgets = [];
  16500. };
  16501. this.renderWidgets = function(e, renderer) {
  16502. var config = renderer.layerConfig;
  16503. var lineWidgets = this.session.lineWidgets;
  16504. if (!lineWidgets)
  16505. return;
  16506. var first = Math.min(this.firstRow, config.firstRow);
  16507. var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
  16508. while (first > 0 && !lineWidgets[first])
  16509. first--;
  16510. this.firstRow = config.firstRow;
  16511. this.lastRow = config.lastRow;
  16512. renderer.$cursorLayer.config = config;
  16513. for (var i = first; i <= last; i++) {
  16514. var w = lineWidgets[i];
  16515. if (!w || !w.el) continue;
  16516. if (w.hidden) {
  16517. w.el.style.top = -100 - (w.pixelHeight || 0) + "px";
  16518. continue;
  16519. }
  16520. if (!w._inDocument) {
  16521. w._inDocument = true;
  16522. renderer.container.appendChild(w.el);
  16523. }
  16524. var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
  16525. if (!w.coverLine)
  16526. top += config.lineHeight * this.session.getRowLineCount(w.row);
  16527. w.el.style.top = top - config.offset + "px";
  16528. var left = w.coverGutter ? 0 : renderer.gutterWidth;
  16529. if (!w.fixedWidth)
  16530. left -= renderer.scrollLeft;
  16531. w.el.style.left = left + "px";
  16532. if (w.fullWidth && w.screenWidth) {
  16533. w.el.style.minWidth = config.width + 2 * config.padding + "px";
  16534. }
  16535. if (w.fixedWidth) {
  16536. w.el.style.right = renderer.scrollBar.getWidth() + "px";
  16537. } else {
  16538. w.el.style.right = "";
  16539. }
  16540. }
  16541. };
  16542. }).call(LineWidgets.prototype);
  16543. exports.LineWidgets = LineWidgets;
  16544. });
  16545. ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
  16546. "use strict";
  16547. var LineWidgets = require("../line_widgets").LineWidgets;
  16548. var dom = require("../lib/dom");
  16549. var Range = require("../range").Range;
  16550. function binarySearch(array, needle, comparator) {
  16551. var first = 0;
  16552. var last = array.length - 1;
  16553. while (first <= last) {
  16554. var mid = (first + last) >> 1;
  16555. var c = comparator(needle, array[mid]);
  16556. if (c > 0)
  16557. first = mid + 1;
  16558. else if (c < 0)
  16559. last = mid - 1;
  16560. else
  16561. return mid;
  16562. }
  16563. return -(first + 1);
  16564. }
  16565. function findAnnotations(session, row, dir) {
  16566. var annotations = session.getAnnotations().sort(Range.comparePoints);
  16567. if (!annotations.length)
  16568. return;
  16569. var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
  16570. if (i < 0)
  16571. i = -i - 1;
  16572. if (i >= annotations.length)
  16573. i = dir > 0 ? 0 : annotations.length - 1;
  16574. else if (i === 0 && dir < 0)
  16575. i = annotations.length - 1;
  16576. var annotation = annotations[i];
  16577. if (!annotation || !dir)
  16578. return;
  16579. if (annotation.row === row) {
  16580. do {
  16581. annotation = annotations[i += dir];
  16582. } while (annotation && annotation.row === row);
  16583. if (!annotation)
  16584. return annotations.slice();
  16585. }
  16586. var matched = [];
  16587. row = annotation.row;
  16588. do {
  16589. matched[dir < 0 ? "unshift" : "push"](annotation);
  16590. annotation = annotations[i += dir];
  16591. } while (annotation && annotation.row == row);
  16592. return matched.length && matched;
  16593. }
  16594. exports.showErrorMarker = function(editor, dir) {
  16595. var session = editor.session;
  16596. if (!session.widgetManager) {
  16597. session.widgetManager = new LineWidgets(session);
  16598. session.widgetManager.attach(editor);
  16599. }
  16600. var pos = editor.getCursorPosition();
  16601. var row = pos.row;
  16602. var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function(w) {
  16603. return w.type == "errorMarker";
  16604. })[0];
  16605. if (oldWidget) {
  16606. oldWidget.destroy();
  16607. } else {
  16608. row -= dir;
  16609. }
  16610. var annotations = findAnnotations(session, row, dir);
  16611. var gutterAnno;
  16612. if (annotations) {
  16613. var annotation = annotations[0];
  16614. pos.column = (annotation.pos && typeof annotation.column != "number"
  16615. ? annotation.pos.sc
  16616. : annotation.column) || 0;
  16617. pos.row = annotation.row;
  16618. gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
  16619. } else if (oldWidget) {
  16620. return;
  16621. } else {
  16622. gutterAnno = {
  16623. text: ["Looks good!"],
  16624. className: "ace_ok"
  16625. };
  16626. }
  16627. editor.session.unfold(pos.row);
  16628. editor.selection.moveToPosition(pos);
  16629. var w = {
  16630. row: pos.row,
  16631. fixedWidth: true,
  16632. coverGutter: true,
  16633. el: dom.createElement("div"),
  16634. type: "errorMarker"
  16635. };
  16636. var el = w.el.appendChild(dom.createElement("div"));
  16637. var arrow = w.el.appendChild(dom.createElement("div"));
  16638. arrow.className = "error_widget_arrow " + gutterAnno.className;
  16639. var left = editor.renderer.$cursorLayer
  16640. .getPixelPosition(pos).left;
  16641. arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
  16642. w.el.className = "error_widget_wrapper";
  16643. el.className = "error_widget " + gutterAnno.className;
  16644. el.innerHTML = gutterAnno.text.join("<br>");
  16645. el.appendChild(dom.createElement("div"));
  16646. var kb = function(_, hashId, keyString) {
  16647. if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
  16648. w.destroy();
  16649. return {command: "null"};
  16650. }
  16651. };
  16652. w.destroy = function() {
  16653. if (editor.$mouseHandler.isMousePressed)
  16654. return;
  16655. editor.keyBinding.removeKeyboardHandler(kb);
  16656. session.widgetManager.removeLineWidget(w);
  16657. editor.off("changeSelection", w.destroy);
  16658. editor.off("changeSession", w.destroy);
  16659. editor.off("mouseup", w.destroy);
  16660. editor.off("change", w.destroy);
  16661. };
  16662. editor.keyBinding.addKeyboardHandler(kb);
  16663. editor.on("changeSelection", w.destroy);
  16664. editor.on("changeSession", w.destroy);
  16665. editor.on("mouseup", w.destroy);
  16666. editor.on("change", w.destroy);
  16667. editor.session.widgetManager.addLineWidget(w);
  16668. w.el.onmousedown = editor.focus.bind(editor);
  16669. editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
  16670. };
  16671. dom.importCssString("\
  16672. .error_widget_wrapper {\
  16673. background: inherit;\
  16674. color: inherit;\
  16675. border:none\
  16676. }\
  16677. .error_widget {\
  16678. border-top: solid 2px;\
  16679. border-bottom: solid 2px;\
  16680. margin: 5px 0;\
  16681. padding: 10px 40px;\
  16682. white-space: pre-wrap;\
  16683. }\
  16684. .error_widget.ace_error, .error_widget_arrow.ace_error{\
  16685. border-color: #ff5a5a\
  16686. }\
  16687. .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
  16688. border-color: #F1D817\
  16689. }\
  16690. .error_widget.ace_info, .error_widget_arrow.ace_info{\
  16691. border-color: #5a5a5a\
  16692. }\
  16693. .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
  16694. border-color: #5aaa5a\
  16695. }\
  16696. .error_widget_arrow {\
  16697. position: absolute;\
  16698. border: solid 5px;\
  16699. border-top-color: transparent!important;\
  16700. border-right-color: transparent!important;\
  16701. border-left-color: transparent!important;\
  16702. top: -5px;\
  16703. }\
  16704. ", "");
  16705. });
  16706. 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) {
  16707. "use strict";
  16708. require("./lib/fixoldbrowsers");
  16709. var dom = require("./lib/dom");
  16710. var event = require("./lib/event");
  16711. var Editor = require("./editor").Editor;
  16712. var EditSession = require("./edit_session").EditSession;
  16713. var UndoManager = require("./undomanager").UndoManager;
  16714. var Renderer = require("./virtual_renderer").VirtualRenderer;
  16715. require("./worker/worker_client");
  16716. require("./keyboard/hash_handler");
  16717. require("./placeholder");
  16718. require("./multi_select");
  16719. require("./mode/folding/fold_mode");
  16720. require("./theme/textmate");
  16721. require("./ext/error_marker");
  16722. exports.config = require("./config");
  16723. exports.require = require;
  16724. if (typeof define === "function")
  16725. exports.define = define;
  16726. exports.edit = function(el) {
  16727. if (typeof el == "string") {
  16728. var _id = el;
  16729. el = document.getElementById(_id);
  16730. if (!el)
  16731. throw new Error("ace.edit can't find div #" + _id);
  16732. }
  16733. if (el && el.env && el.env.editor instanceof Editor)
  16734. return el.env.editor;
  16735. var value = "";
  16736. if (el && /input|textarea/i.test(el.tagName)) {
  16737. var oldNode = el;
  16738. value = oldNode.value;
  16739. el = dom.createElement("pre");
  16740. oldNode.parentNode.replaceChild(el, oldNode);
  16741. } else if (el) {
  16742. value = dom.getInnerText(el);
  16743. el.innerHTML = "";
  16744. }
  16745. var doc = exports.createEditSession(value);
  16746. var editor = new Editor(new Renderer(el));
  16747. editor.setSession(doc);
  16748. var env = {
  16749. document: doc,
  16750. editor: editor,
  16751. onResize: editor.resize.bind(editor, null)
  16752. };
  16753. if (oldNode) env.textarea = oldNode;
  16754. event.addListener(window, "resize", env.onResize);
  16755. editor.on("destroy", function() {
  16756. event.removeListener(window, "resize", env.onResize);
  16757. env.editor.container.env = null; // prevent memory leak on old ie
  16758. });
  16759. editor.container.env = editor.env = env;
  16760. return editor;
  16761. };
  16762. exports.createEditSession = function(text, mode) {
  16763. var doc = new EditSession(text, mode);
  16764. doc.setUndoManager(new UndoManager());
  16765. return doc;
  16766. }
  16767. exports.EditSession = EditSession;
  16768. exports.UndoManager = UndoManager;
  16769. exports.version = "1.2.6";
  16770. });
  16771. (function() {
  16772. ace.require(["ace/ace"], function(a) {
  16773. if (a) {
  16774. a.config.init(true);
  16775. a.define = ace.define;
  16776. }
  16777. if (!window.ace)
  16778. window.ace = a;
  16779. for (var key in a) if (a.hasOwnProperty(key))
  16780. window.ace[key] = a[key];
  16781. });
  16782. })();